#include <SMESH_Octree.hxx>

Data Structures | |
| struct | Limit |
Public Member Functions | |
| SMESH_Octree (Limit *limit=0) | |
| Constructor. | |
| virtual | ~SMESH_Octree () |
| SMESH_Octree Destructor. | |
| void | compute () |
| Compute the Octree. | |
| bool | isLeaf () const |
| Tell if Octree is a leaf or not An inheriting class can influence it via myIsLeaf protected field. | |
| int | level () const |
| const Bnd_B3d & | getBox () const |
| double | maxSize () const |
| Compute the bigger dimension of my box. | |
| int | getChildIndex (double x, double y, double z, const gp_XYZ &boxMiddle) const |
| Return index of a child the given point is in. | |
Protected Member Functions | |
| virtual Bnd_B3d * | buildRootBox ()=0 |
| virtual SMESH_Octree * | allocateOctreeChild () const =0 |
| virtual void | buildChildrenData ()=0 |
Protected Attributes | |
| SMESH_Octree ** | myChildren |
| SMESH_Octree * | myFather |
| bool | myIsLeaf |
| const Limit * | myLimit |
Private Member Functions | |
| void | buildChildren () |
| Build the 8 children boxes and call buildChildrenData() | |
Private Attributes | |
| int | myLevel |
| Bnd_B3d * | myBox |
Definition at line 34 of file SMESH_Octree.hxx.
| SMESH_Octree::SMESH_Octree | ( | SMESH_Octree::Limit * | limit = 0 | ) |
Constructor.
limit must be provided at tree root construction. limit will be deleted by SMESH_Octree.
Definition at line 38 of file SMESH_Octree.cxx.
| SMESH_Octree::~SMESH_Octree | ( | ) | [virtual] |
SMESH_Octree Destructor.
Definition at line 72 of file SMESH_Octree.cxx.
References isLeaf(), level(), myBox, myChildren, and myLimit.
{
if(myChildren != NULL)
{
if(!isLeaf())
{
for(int i = 0; i<8; i++)
delete myChildren[i];
delete[] myChildren;
myChildren = 0;
}
}
if ( myBox )
delete myBox;
myBox = 0;
if ( level() == 0 )
delete myLimit;
myLimit = 0;
}
| virtual SMESH_Octree* SMESH_Octree.allocateOctreeChild | ( | ) | const [protected, pure virtual] |
Implemented in SMESH_OctreeNode.
Referenced by buildChildren().
| void SMESH_Octree::buildChildren | ( | ) | [private] |
Build the 8 children boxes and call buildChildrenData()
Definition at line 98 of file SMESH_Octree.cxx.
References allocateOctreeChild(), buildChildrenData(), isLeaf(), maxSize(), myBox, myChildren, myFather, myIsLeaf, myLevel, myLimit, and SMESH_Octree.Limit.myMinBoxSize.
Referenced by compute().
{
if ( isLeaf() ) return;
myChildren = new SMESH_Octree*[8];
gp_XYZ min = myBox->CornerMin();
gp_XYZ max = myBox->CornerMax();
gp_XYZ HSize = (max - min)/2.;
gp_XYZ mid = min + HSize;
gp_XYZ childHsize = HSize/2.;
// get the whole model size
double rootSize = 0;
{
SMESH_Octree* root = this;
while ( root->myLevel > 0 )
root = root->myFather;
rootSize = root->maxSize();
}
Standard_Real XminChild, YminChild, ZminChild;
gp_XYZ minChild;
for (int i = 0; i < 8; i++)
{
// We build the eight boxes, we need 2 points to do that:
// Min and Mid
// In binary, we can write i from 0 to 7
// For instance :
// 5 is 101, it corresponds here in coordinates to ZYX
// If coordinate is 0 in Y-> box from Ymin to Ymid
// If coordinate is 1 in Y-> box from Ymid to Ymax
// Same scheme for X and Z
// I need the minChild to build the Bnd_B3d box.
XminChild = (i%2==0)?min.X():mid.X();
YminChild = ((i%4)/2==0)?min.Y():mid.Y();
ZminChild = (i<4)?min.Z():mid.Z();
minChild.SetCoord(XminChild, YminChild, ZminChild);
// The child is of the same type than its father (For instance, a SMESH_OctreeNode)
// We allocate the memory we need for the child
myChildren[i] = allocateOctreeChild();
// and we assign to him its box.
myChildren[i]->myFather = this;
myChildren[i]->myLimit = myLimit;
myChildren[i]->myLevel = myLevel + 1;
myChildren[i]->myBox = new Bnd_B3d(minChild+childHsize,childHsize);
myChildren[i]->myBox->Enlarge( rootSize * 1e-10 );
if ( myLimit->myMinBoxSize > 0. && myChildren[i]->maxSize() <= myLimit->myMinBoxSize )
myChildren[i]->myIsLeaf = true;
}
// After building the 8 boxes, we put the data into the children.
buildChildrenData();
//After we pass to the next level of the Octree
for (int i = 0; i<8; i++)
myChildren[i]->buildChildren();
}
| virtual void SMESH_Octree.buildChildrenData | ( | ) | [protected, pure virtual] |
Implemented in SMESH_OctreeNode.
Referenced by buildChildren().
| virtual Bnd_B3d* SMESH_Octree.buildRootBox | ( | ) | [protected, pure virtual] |
Implemented in SMESH_OctreeNode.
Referenced by compute().
| void SMESH_Octree::compute | ( | ) |
Compute the Octree.
Definition at line 54 of file SMESH_Octree.cxx.
References buildChildren(), buildRootBox(), maxSize(), myBox, myIsLeaf, myLevel, myLimit, and SMESH_Octree.Limit.myMinBoxSize.
Referenced by SMESH_OctreeNode.SMESH_OctreeNode().
{
if ( myLevel==0 )
{
myBox = buildRootBox();
if ( myLimit->myMinBoxSize > 0. && maxSize() <= myLimit->myMinBoxSize )
myIsLeaf = true;
else
buildChildren();
}
}
| const Bnd_B3d& SMESH_Octree.getBox | ( | ) | const |
Definition at line 70 of file SMESH_Octree.hxx.
References myBox.
Referenced by SMESH_OctreeNode.buildChildrenData(), SMESH_NodeSearcherImpl.FindClosestTo(), SMESH_OctreeNode.isInside(), SMESH_OctreeNode.NodesAround(), and SMESH_OctreeNode.UpdateByMoveNode().
{ return *myBox; }
| int SMESH_Octree::getChildIndex | ( | double | x, |
| double | y, | ||
| double | z, | ||
| const gp_XYZ & | boxMiddle | ||
| ) | const |
Return index of a child the given point is in.
Definition at line 118 of file SMESH_Octree.hxx.
Referenced by SMESH_OctreeNode.buildChildrenData(), SMESH_OctreeNode.NodesAround(), and SMESH_OctreeNode.UpdateByMoveNode().
| bool SMESH_Octree::isLeaf | ( | ) | const |
Tell if Octree is a leaf or not An inheriting class can influence it via myIsLeaf protected field.
Definition at line 165 of file SMESH_Octree.cxx.
References level(), myIsLeaf, myLimit, and SMESH_Octree.Limit.myMaxLevel.
Referenced by buildChildren(), SMESH_NodeSearcherImpl.FindClosestTo(), SMESH_OctreeNode.FindCoincidentNodes(), SMESH_OctreeNode.GetChildrenIterator(), SMESH_OctreeNode.NodesAround(), SMESH_NodeSearcherImpl.SMESH_NodeSearcherImpl(), SMESH_OctreeNode.UpdateByMoveNode(), and ~SMESH_Octree().
{
return myIsLeaf || ((myLimit->myMaxLevel > 0) ? (level() >= myLimit->myMaxLevel) : false );
}
| int SMESH_Octree.level | ( | ) | const |
Definition at line 67 of file SMESH_Octree.hxx.
References myLevel.
Referenced by isLeaf(), and ~SMESH_Octree().
{ return myLevel; }
| double SMESH_Octree::maxSize | ( | ) | const |
Compute the bigger dimension of my box.
Definition at line 176 of file SMESH_Octree.cxx.
References myBox.
Referenced by buildChildren(), compute(), SMESH_ElementSearcherImpl.getTolerance(), SMESH_OctreeNode.NodesAround(), and SMESH_NodeSearcherImpl.SMESH_NodeSearcherImpl().
Bnd_B3d* SMESH_Octree.myBox [private] |
Definition at line 109 of file SMESH_Octree.hxx.
Referenced by buildChildren(), compute(), getBox(), maxSize(), and ~SMESH_Octree().
SMESH_Octree** SMESH_Octree.myChildren [protected] |
Definition at line 91 of file SMESH_Octree.hxx.
Referenced by buildChildren(), SMESH_OctreeNode.buildChildrenData(), SMESH_OctreeNode.FindCoincidentNodes(), SMESH_OctreeNode.GetChildrenIterator(), SMESH_OctreeNode.NodesAround(), SMESH_OctreeNode.UpdateByMoveNode(), and ~SMESH_Octree().
SMESH_Octree* SMESH_Octree.myFather [protected] |
Definition at line 94 of file SMESH_Octree.hxx.
Referenced by buildChildren().
bool SMESH_Octree.myIsLeaf [protected] |
Definition at line 97 of file SMESH_Octree.hxx.
Referenced by buildChildren(), SMESH_OctreeNode.buildChildrenData(), SMESH_OctreeNode.buildRootBox(), compute(), and isLeaf().
int SMESH_Octree.myLevel [private] |
Definition at line 107 of file SMESH_Octree.hxx.
Referenced by buildChildren(), compute(), and level().
const Limit* SMESH_Octree.myLimit [protected] |
Definition at line 100 of file SMESH_Octree.hxx.
Referenced by buildChildren(), compute(), isLeaf(), and ~SMESH_Octree().