25bool COctreeAgentNode::isOverlappingCell(
const pair<int, XYZ>& item,
const Vector3f& lowerCorner,
const Vector3f& upperCorner)
const
39 const Vector3f* lowMidPoints[] = { &lower, &middle };
40 const Vector3f* midHighPoints[] = { &middle, &upper };
42 for (dword i = 8; i-- > 0; )
44 Vector3f lowerCorner( lowMidPoints[ i & 1]->getX(),
45 lowMidPoints[(i >> 1) & 1]->getY(),
46 lowMidPoints[(i >> 2) & 1]->getZ() );
47 Vector3f upperCorner( midHighPoints[ i & 1]->getX(),
48 midHighPoints[(i >> 1) & 1]->getY(),
49 midHighPoints[(i >> 2) & 1]->getZ() );
64 pRootCell->visit(octreeData, *
this);
74 for (dword i = 0; i < 8; ++i)
76 const OctreeCell* pSubCell = subCells[i];
79 const OctreeData subCellData(octreeData, i);
80 pSubCell->visit(subCellData, *
this);
88 int iNumItems = items.getLength();
89 for (i=0; i<iNumItems; ++i)
92 for (j=0; j<iNumItems; ++j)
99 if (items[i]->first < items[j]->first)
105 else if (items[i]->first > items[j]->first)
120 vector<int>::const_iterator itNodeIndex;
124 cout << *itNodeIndex << endl;
133 return (
Max.x >= lowerCorner.getX() &&
Max.y >= lowerCorner.getY() &&
Max.z >= lowerCorner.getZ() &&
134 Min.
x <= upperCorner.getX() &&
Min.
y <= upperCorner.getY() &&
Min.
z <= upperCorner.getZ());
139 vector<int>::const_iterator itNodeIndex;
143 cout << *itNodeIndex << endl;
155 const Vector3f* lowMidPoints[] = { &lower, &middle };
156 const Vector3f* midHighPoints[] = { &middle, &upper };
158 for (dword i = 8; i-- > 0; )
160 Vector3f lowerCorner( lowMidPoints[ i & 1]->getX(),
161 lowMidPoints[(i >> 1) & 1]->getY(),
162 lowMidPoints[(i >> 2) & 1]->getZ() );
163 Vector3f upperCorner( midHighPoints[ i & 1]->getX(),
164 midHighPoints[(i >> 1) & 1]->getY(),
165 midHighPoints[(i >> 2) & 1]->getZ() );
166 if (
Max.x >= lowerCorner.getX() &&
Max.y >= lowerCorner.getY() &&
Max.z >= lowerCorner.getZ() &&
167 Min.
x <= upperCorner.getX() &&
Min.
y <= upperCorner.getY() &&
Min.
z <= upperCorner.getZ())
182 pRootCell->visit(octreeData, *
this);
188 const Vector3f &LowerCorner = octreeData.getBound().getLowerCorner();
189 const Vector3f &UpperCorner = octreeData.getBound().getUpperCorner();
190 const Vector3f &Center = octreeData.getBound().getCenter();
192 Bounds[0] =
XYZ(LowerCorner.getX(), LowerCorner.getY(), LowerCorner.getZ());
193 Bounds[1] =
XYZ(Center.getX(), Center.getY(), Center.getZ());
194 Bounds[2] =
XYZ(UpperCorner.getX(), UpperCorner.getY(), UpperCorner.getZ());
195 vector<bool> IntersectingCells;
196 IntersectingCells.resize(8,
false);
215 if (abs(dDenom) > 1e-6)
219 u = (Bounds[j][x] -
m_P1[x]) / dDenom;
225 if (Bounds[0][y] <= P[y] && P[y] <= Bounds[1][y])
227 if (Bounds[0][z] <= P[z] && P[z] <= Bounds[1][z])
231 IntersectingCells[(0<<x) | (0<<y) | (0<<z)] =
true;
235 IntersectingCells[(1<<x) | (0<<y) | (0<<z)] =
true;
238 else if (Bounds[1][z] <= P[z] && P[z] <= Bounds[2][z])
242 IntersectingCells[(0<<x) | (0<<y) | (1<<z)] =
true;
246 IntersectingCells[(1<<x) | (0<<y) | (1<<z)] =
true;
250 else if (Bounds[1][y] <= P[y] && P[y] <= Bounds[2][y])
252 if (Bounds[0][z] <= P[z] && P[z] <= Bounds[1][z])
256 IntersectingCells[(0<<x) | (1<<y) | (0<<z)] =
true;
260 IntersectingCells[(1<<x) | (1<<y) | (0<<z)] =
true;
263 else if (Bounds[1][z] <= P[z] && P[z] <= Bounds[2][z])
267 IntersectingCells[(0<<x) | (1<<y) | (1<<z)] =
true;
271 IntersectingCells[(1<<x) | (1<<y) | (1<<z)] =
true;
295 IntersectingCells[dwCell] =
true;
300 for (dword i = 0; i < 8; ++i)
302 const OctreeCell* pSubCell = subCells[i];
303 if(IntersectingCells[i] ==
true && pSubCell != 0)
305 const OctreeData subCellData(octreeData, i);
306 pSubCell->visit(subCellData, *
this);
314 int iNumItems = items.getLength();
315 for (i=0; i<iNumItems; ++i)
void ChangeNodeIndices(int iChangeTo, int iChangeFrom)
Change all the indices from one number to another.
void GetNodeElementReferences(vector< vector< int * > > &References)
Get a list of elements which reference each node.
const XYZ & GetNode(int iIndex) const
Get the node with given ID.
int DeleteNodes(const set< int > &Nodes)
Delete nodes and adjust node indices.
dword getSubcellOverlaps(const MESH_ELEMENT &item, const Vector3f &lower, const Vector3f &middle, const Vector3f &upper) const
bool isOverlappingCell(const MESH_ELEMENT &item, const Vector3f &lowerCorner, const Vector3f &upperCorner) const
bool isOverlappingCell(const pair< int, XYZ > &item, const Vector3f &lowerCorner, const Vector3f &upperCorner) const
dword getSubcellOverlaps(const pair< int, XYZ > &item, const Vector3f &lower, const Vector3f &middle, const Vector3f &upper) const
pair< bool, bool > m_TrimLine
void visitBranch(const OctreeCell *subCells[8], const OctreeData &octreeData)
list< vector< int > > & m_Elements
void visitRoot(const OctreeCell *pRootCell, const OctreeData &octreeData)
void visitLeaf(const Array< const MESH_ELEMENT * > &items, const OctreeData &octreeData)
void visitBranch(const OctreeCell *subCells[8], const OctreeData &octreeData)
double m_dToleranceSquared
void visitRoot(const OctreeCell *pRootCell, const OctreeData &octreeData)
void visitLeaf(const Array< const pair< int, XYZ > * > &items, const OctreeData &octreeData)
vector< vector< int * > > m_NodeElementReferences
set< int > m_DeletedNodes
Namespace containing a series of customised math operations not found in the standard c++ library.
double GetLengthSquared(const XYZ &Point1, const XYZ &Point2)
Get the length squared between two points.
double Max(XYZ &Vector)
Get maximum element of vector and return it.
XYZ Min(const XYZ &P1, const XYZ &P2)
Given two points, return a new point who's coordinates are the smaller of the two.
Elements of a given, is used in conjunction with COctreeAgentElement.
vector< int > NodeIndices
Struct for representing points in 3D space.