#include "Iguana/Inventor/interface/IgBSPNode.h"
#include <cassert>
Go to the source code of this file.
Functions | |
void | addPlane (IgBSPNode *&treeNode, const SbPlane &plane) |
void | addTriangleInBack (IgBSPNode *&node, IgBSPTriangle *triangle, bool addTriangle, IgBSPTriangle::List *trianglesAddedInFront, IgBSPTriangle::List *trianglesAddedInBack) |
void | addTriangleInFront (IgBSPNode *&node, IgBSPTriangle *triangle, bool addTriangle, IgBSPTriangle::List *trianglesAddedInFront, IgBSPTriangle::List *trianglesAddedInBack) |
static bool | doPlaneIntersect (const SbPlane &plane1, const SbPlane &plane2) |
SbVec3f | getFaceNormal (IgBSPTriangle &triangle) |
static SbVec3f | pointOnPlane (const SbPlane &plane) |
Definition at line 297 of file IgBSPNode.cc.
References IgBSPNode::add(), and IgBSPNode::IgBSPNode().
Referenced by IgBSPNode::add().
00298 { 00299 if (treeNode) 00300 { 00301 // If it is not a leaf, continue the navigation process. 00302 treeNode->add (plane); 00303 } 00304 else 00305 { 00306 treeNode = new IgBSPNode (plane); 00307 } 00308 }
void addTriangleInBack | ( | IgBSPNode *& | node, | |
IgBSPTriangle * | triangle, | |||
bool | addTriangle, | |||
IgBSPTriangle::List * | trianglesAddedInFront, | |||
IgBSPTriangle::List * | trianglesAddedInBack | |||
) |
Definition at line 120 of file IgBSPNode.cc.
References IgBSPNode::add(), IgBSPNode::IgBSPNode(), and IgBSPTriangle::ref().
Referenced by IgBSPNode::add().
00125 { 00126 // If the back branch exists make the triangle go down it, 00127 // otherwise, create a new back branch, using the triangle as 00128 // initialization. 00129 // 00130 // The node is actually added only if addTriangle is true 00131 // 00132 // If the list of triangles added in back is there, the 00133 // triangle is also added there. 00134 00135 assert (triangle); 00136 00137 if (node) 00138 { 00139 // if node is there, we navigate further. 00140 node->add (triangle, 00141 addTriangle, 00142 trianglesAddedInFront, 00143 trianglesAddedInBack); 00144 } 00145 else 00146 { 00147 if (addTriangle) 00148 { 00149 node = new IgBSPNode (triangle); 00150 } 00151 if (trianglesAddedInBack != 0) 00152 { 00153 triangle->ref (); 00154 trianglesAddedInBack->push_back (triangle); 00155 } 00156 } 00157 }
void addTriangleInFront | ( | IgBSPNode *& | node, | |
IgBSPTriangle * | triangle, | |||
bool | addTriangle, | |||
IgBSPTriangle::List * | trianglesAddedInFront, | |||
IgBSPTriangle::List * | trianglesAddedInBack | |||
) |
Definition at line 85 of file IgBSPNode.cc.
References IgBSPNode::add(), IgBSPNode::IgBSPNode(), and IgBSPTriangle::ref().
Referenced by IgBSPNode::add().
00090 { 00091 // If the triangle is in front either pass it down the front 00092 // branch (if it exists) or create a new front branch. 00093 // 00094 // The node is actually added only if addTriangle is true. 00095 // 00096 // If the list of triangles added in front is there, the 00097 // triangle is also added there. 00098 00099 if (node) 00100 { 00101 // if node is there, we navigate further. 00102 node->add (triangle, 00103 addTriangle, 00104 trianglesAddedInFront, 00105 trianglesAddedInBack); 00106 } 00107 else 00108 { 00109 if (addTriangle) 00110 node = new IgBSPNode (triangle); 00111 if (trianglesAddedInFront != 0) 00112 { 00113 triangle->ref (); 00114 trianglesAddedInFront->push_back (triangle); 00115 } 00116 } 00117 }
static bool doPlaneIntersect | ( | const SbPlane & | plane1, | |
const SbPlane & | plane2 | |||
) | [static] |
Definition at line 22 of file IgBSPNode.cc.
Referenced by IgBSPNode::add().
00023 { 00024 if (plane1 == plane2) 00025 return true; 00026 00027 SbVec3f n1 = plane1.getNormal (); 00028 SbVec3f n2 = plane2.getNormal (); 00029 00030 if (n1 == n2 00031 || n1 == -n2) 00032 { 00033 // If the normals are the same, or opposite, they are parallel 00034 // and therefore don't intersect 00035 return false; 00036 } 00037 00038 return true; 00039 }
SbVec3f getFaceNormal | ( | IgBSPTriangle & | triangle | ) |
Definition at line 74 of file IgBSPNode.cc.
References IgBSPTriangle::v().
Referenced by IgBSPNode::add().
00075 { 00076 SbVec3f side1 = triangle.v (1) - triangle.v (0); 00077 SbVec3f side2 = triangle.v (2) - triangle.v (0); 00078 side1.normalize (); 00079 side2.normalize (); 00080 return side1.cross (side2); 00081 }
static SbVec3f pointOnPlane | ( | const SbPlane & | plane | ) | [static] |
Definition at line 15 of file IgBSPNode.cc.
Referenced by IgBSPNode::add().
00016 { 00017 SbVec3f planeNormal = plane.getNormal (); 00018 return plane.getDistanceFromOrigin () * planeNormal; 00019 }