19 #include <boost/container/flat_set.hpp> 31 #include <xmsgrid/ugrid/XmEdge.h> 89 VecInt& a_commonCellIdxs)
const;
127 void GetCellEdges(
int a_cellIdx, std::vector<XmEdge>& a_edges)
const;
143 int& a_neighborFace)
const;
148 bool IsSideFace(
int a_cellIdx,
int a_faceIdx)
const;
161 const Pt3d& a_newPosition)
const;
175 VecInt& a_uniqueGetCellPoints,
176 VecInt& a_pointLastUsedIdx);
182 boost::container::flat_set<XmEdge>& a_cellEdges,
192 const Pt3d& a_newPosition,
193 const std::vector<XmEdge>& a_edges)
const;
205 int& a_columnEnd)
const;
236 const char* CELLSTREAM_OFFSETS =
"CELLSTREAM_OFFSETS";
237 const char* POINTS_TO_CELLS =
"POINTS_TO_CELLS";
238 const char* POINTS_TO_CELLS_OFFSETS =
"POINTS_TO_CELLS_OFFSETS";
240 typedef std::vector<XmEdge>
VecEdge;
247 const VecEdge& iGetEdgeOffsetTable(
int a_cellType)
250 static const VecEdge fg_line = {{0, 1}};
251 static const VecEdge fg_triangle = {{0, 1}, {1, 2}, {2, 0}};
252 static const VecEdge fg_pixel = {{0, 1}, {1, 3}, {3, 2}, {2, 0}};
253 static const VecEdge fg_quad = {{0, 1}, {1, 2}, {2, 3}, {3, 0}};
254 static const VecEdge fg_tetra = {{0, 1}, {1, 2}, {2, 0}, {0, 3}, {1, 3}, {2, 3}};
255 static const VecEdge fg_wedge = {{0, 1}, {1, 2}, {2, 0}, {3, 4}, {4, 5},
256 {5, 3}, {0, 3}, {1, 4}, {2, 5}};
257 static const VecEdge fg_voxel = {{0, 1}, {1, 3}, {2, 3}, {0, 2}, {4, 5}, {5, 7},
258 {6, 7}, {4, 6}, {0, 4}, {1, 5}, {2, 6}, {3, 7}};
259 static const VecEdge fg_hexahedron = {{0, 1}, {1, 2}, {3, 2}, {0, 3}, {4, 5}, {5, 6},
260 {7, 6}, {4, 7}, {0, 4}, {1, 5}, {3, 7}, {2, 6}};
261 static const VecEdge fg_pyramid = {{0, 1}, {1, 2}, {2, 3}, {3, 0},
262 {0, 4}, {1, 4}, {2, 4}, {3, 4}};
263 static const VecEdge fg_pentagonalPrism = {{0, 1}, {1, 2}, {2, 3}, {3, 4}, {4, 0},
264 {5, 6}, {6, 7}, {7, 8}, {8, 9}, {9, 5},
265 {0, 5}, {1, 6}, {2, 7}, {3, 8}, {4, 9}};
266 static const VecEdge fg_hexagonalPrism = {{0, 1}, {1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 0},
267 {6, 7}, {7, 8}, {8, 9}, {9, 10}, {10, 11}, {11, 6},
268 {0, 6}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {5, 11}};
273 case XMU_INVALID_CELL_TYPE:
279 case XMU_POLY_VERTEX:
280 case XMU_CONVEX_POINT_SET:
302 case XMU_QUADRATIC_EDGE:
303 case XMU_PARAMETRIC_CURVE:
304 case XMU_HIGHER_ORDER_EDGE:
306 case XMU_TRIANGLE_STRIP:
307 case XMU_QUADRATIC_TRIANGLE:
308 case XMU_BIQUADRATIC_TRIANGLE:
309 case XMU_HIGHER_ORDER_TRIANGLE:
310 case XMU_HIGHER_ORDER_POLYGON:
311 case XMU_QUADRATIC_POLYGON:
312 case XMU_PARAMETRIC_SURFACE:
313 case XMU_PARAMETRIC_TRI_SURFACE:
314 case XMU_PARAMETRIC_QUAD_SURFACE:
326 return fg_hexahedron;
329 case XMU_PENTAGONAL_PRISM:
330 return fg_pentagonalPrism;
331 case XMU_HEXAGONAL_PRISM:
332 return fg_hexagonalPrism;
339 case XMU_QUADRATIC_TETRA:
340 case XMU_HIGHER_ORDER_TETRAHEDRON:
341 case XMU_QUADRATIC_WEDGE:
342 case XMU_QUADRATIC_LINEAR_WEDGE:
343 case XMU_BIQUADRATIC_QUADRATIC_WEDGE:
344 case XMU_HIGHER_ORDER_WEDGE:
345 case XMU_QUADRATIC_HEXAHEDRON:
346 case XMU_TRIQUADRATIC_HEXAHEDRON:
347 case XMU_BIQUADRATIC_QUADRATIC_HEXAHEDRON:
348 case XMU_HIGHER_ORDER_HEXAHEDRON:
349 case XMU_QUADRATIC_PYRAMID:
350 case XMU_HIGHER_ORDER_PYRAMID:
351 case XMU_PARAMETRIC_TETRA_REGION:
352 case XMU_PARAMETRIC_HEX_REGION:
368 const VecInt2d& iGetFaceOffsetTable(
int a_cellType)
371 static const VecInt2d fg_tetra = {{0, 1, 3}, {1, 2, 3}, {2, 0, 3}, {0, 2, 1}};
372 static const VecInt2d fg_wedge = {{0, 1, 2}, {3, 5, 4}, {0, 3, 4, 1}, {1, 4, 5, 2}, {2, 5, 3, 0}};
373 static const VecInt2d fg_voxel = {{0, 4, 6, 2}, {1, 3, 7, 5}, {0, 1, 5, 4},
374 {2, 6, 7, 3}, {0, 2, 3, 1}, {4, 5, 7, 6}};
375 static const VecInt2d fg_hexahedron = {{0, 4, 7, 3}, {1, 2, 6, 5}, {0, 1, 5, 4},
376 {3, 7, 6, 2}, {0, 3, 2, 1}, {4, 5, 6, 7}};
377 static const VecInt2d fg_pyramid = {{0, 3, 2, 1}, {0, 1, 4}, {1, 2, 4}, {2, 3, 4}, {3, 0, 4}};
378 static const VecInt2d fg_pentagonalPrism = {{0, 4, 3, 2, 1}, {5, 6, 7, 8, 9}, {0, 1, 6, 5},
379 {1, 2, 7, 6}, {2, 3, 8, 7}, {3, 4, 9, 8},
381 static const VecInt2d fg_hexagonalPrism = {
382 {0, 5, 4, 3, 2, 1}, {6, 7, 8, 9, 10, 11}, {0, 1, 7, 6}, {1, 2, 8, 7},
383 {2, 3, 9, 8}, {3, 4, 10, 9}, {4, 5, 11, 10}, {5, 0, 6, 11}};
390 case XMU_INVALID_CELL_TYPE:
393 case XMU_POLY_VERTEX:
394 case XMU_CONVEX_POINT_SET:
402 case XMU_QUADRATIC_EDGE:
403 case XMU_PARAMETRIC_CURVE:
404 case XMU_HIGHER_ORDER_EDGE:
406 case XMU_TRIANGLE_STRIP:
407 case XMU_QUADRATIC_TRIANGLE:
408 case XMU_BIQUADRATIC_TRIANGLE:
409 case XMU_HIGHER_ORDER_TRIANGLE:
410 case XMU_HIGHER_ORDER_POLYGON:
411 case XMU_QUADRATIC_POLYGON:
412 case XMU_PARAMETRIC_SURFACE:
413 case XMU_PARAMETRIC_TRI_SURFACE:
414 case XMU_PARAMETRIC_QUAD_SURFACE:
425 return fg_hexahedron;
428 case XMU_PENTAGONAL_PRISM:
429 return fg_pentagonalPrism;
430 case XMU_HEXAGONAL_PRISM:
431 return fg_hexagonalPrism;
438 case XMU_QUADRATIC_TETRA:
439 case XMU_HIGHER_ORDER_TETRAHEDRON:
440 case XMU_QUADRATIC_WEDGE:
441 case XMU_QUADRATIC_LINEAR_WEDGE:
442 case XMU_BIQUADRATIC_QUADRATIC_WEDGE:
443 case XMU_HIGHER_ORDER_WEDGE:
444 case XMU_QUADRATIC_HEXAHEDRON:
445 case XMU_TRIQUADRATIC_HEXAHEDRON:
446 case XMU_BIQUADRATIC_QUADRATIC_HEXAHEDRON:
447 case XMU_HIGHER_ORDER_HEXAHEDRON:
448 case XMU_QUADRATIC_PYRAMID:
449 case XMU_HIGHER_ORDER_PYRAMID:
450 case XMU_PARAMETRIC_TETRA_REGION:
451 case XMU_PARAMETRIC_HEX_REGION:
469 bool iPointInSegmentBounds(
const Pt3d& a_location,
const Pt3d& a_first,
const Pt3d& a_second)
471 bool inBounds = a_location.
x >= std::min(a_first.
x, a_second.
x) &&
472 a_location.
y >= std::min(a_first.
y, a_second.
y) &&
473 a_location.
x <= std::max(a_first.
x, a_second.
x) &&
474 a_location.
y <= std::max(a_first.
y, a_second.
y);
482 template <
typename T>
483 std::vector<T> iGetUniquePoints(
const std::vector<T>& a_segments)
485 std::vector<T> points = a_segments;
486 std::sort(points.begin(), points.end());
487 auto pIt = std::unique(points.begin(), points.end());
488 points.resize(pIt - points.begin());
496 template <
typename T>
497 void iBuildPolygon(std::vector<std::pair<T, T>>& a_segs, std::vector<T>& a_polygon)
499 xms::VecChar placed(a_segs.size(),
false);
500 a_polygon.push_back(a_segs[0].first);
501 a_polygon.push_back(a_segs[0].second);
503 for (
size_t i = 1; i != a_segs.size(); ++i)
505 T& toMatch = a_polygon.back();
506 for (
size_t j = 1; j != a_segs.size(); ++j)
510 if (a_segs[j].first == toMatch)
512 a_polygon.push_back(a_segs[j].second);
515 else if (a_segs[j].second == toMatch)
517 a_polygon.push_back(a_segs[j].first);
530 template <
typename T>
531 std::vector<std::pair<T, T>> iGetUniqueSegments(
const std::vector<T>& a_segments)
533 std::vector<std::pair<T, T>> segs;
534 for (
size_t i = 0; i < a_segments.size(); i += 2)
537 T b = a_segments[i + 1];
539 segs.push_back(std::pair<T, T>(a, b));
541 segs.push_back(std::pair<T, T>(b, a));
543 std::sort(segs.begin(), segs.end());
544 auto segIt = std::unique(segs.begin(), segs.end());
545 segs.resize(segIt - segs.begin());
554 void iMergeSegmentsToPoly(
const VecPt3d& a_segments,
VecPt3d& a_polygon)
556 if (a_segments.empty())
559 VecPt3d points = iGetUniquePoints(a_segments);
560 std::vector<std::pair<Pt3d, Pt3d>> segs = iGetUniqueSegments(a_segments);
563 for (
auto& point : points)
565 size_t segsSize = segs.size();
566 for (
size_t i = 0; i < segsSize; ++i)
568 Pt3d pt1 = segs[i].first;
569 Pt3d pt2 = segs[i].second;
570 if (point != pt1 && point != pt2 && iPointInSegmentBounds(point, pt1, pt2))
572 Pt3d diff = pt1 - pt2;
573 double distance = std::max(fabs(diff.
x), fabs(diff.
y));
574 double tolerance = distance / 1.0e6;
577 segs.emplace_back(point, pt2);
578 segs[i].second = point;
583 std::sort(segs.begin(), segs.end());
584 auto segIt = std::unique(segs.begin(), segs.end());
585 segs.resize(segIt - segs.begin());
587 iBuildPolygon(segs, a_polygon);
589 if (a_polygon.size() > 3 && a_polygon.front() == a_polygon.back())
591 a_polygon.pop_back();
592 double area =
gmPolygonArea(&a_polygon[0], (
int)a_polygon.size());
594 std::reverse(a_polygon.begin(), a_polygon.end());
639 m_useCache = a_useCache;
648 return (
int)m_locations.size();
664 m_locations = a_locations;
674 if (a_pointIdx >= 0 && a_pointIdx < m_locations.size())
675 return m_locations[a_pointIdx];
686 if (a_pointIdx >= 0 && a_pointIdx < m_locations.size())
688 m_locations[a_pointIdx] = a_location;
715 for (
auto point : a_points)
729 GetExtentsFromPoints(m_locations, a_min, a_max);
739 if (a_pointIdx < 0 || a_pointIdx >= m_locations.size())
741 int numCells = m_pointsToCells[m_pointIdxToPointsToCells[a_pointIdx]];
764 a_adjacentCells.clear();
766 for (
int cellIdx = 0; cellIdx < numCells; cellIdx++)
768 a_adjacentCells.push_back(m_pointsToCells[m_pointIdxToPointsToCells[a_pointIdx] + cellIdx + 1]);
779 if (!a_points.empty())
791 VecInt& a_commonCellIdxs)
const 793 a_commonCellIdxs.clear();
794 if (a_numPointIdxs == 0)
797 for (
int i = 1; i < a_numPointIdxs; ++i)
801 for (
int j = 0; j < a_commonCellIdxs.size(); ++j)
804 for (
int tempAssociatedCell : tempAssociatedCells)
806 if (a_commonCellIdxs[j] == tempAssociatedCell)
815 for (
int j = (
int)
remove.size() - 1; j >= 0; --j)
817 a_commonCellIdxs.erase(a_commonCellIdxs.begin() +
remove[j]);
819 if (a_commonCellIdxs.empty())
829 VecInt& a_adjacentCellIdxs)
const 831 if (!a_pointIdxs.empty())
842 VecInt& a_adjacentCellIdxs)
const 844 int points[] = {a_pointIdx1, a_pointIdx2};
854 if (m_cellIdxToStreamIdx.empty())
857 return (
int)m_cellIdxToStreamIdx.size() - 1;
869 boost::container::flat_set<int> uniqueIdxs;
870 const int* cellstream =
nullptr;
876 int numFaces = cellstream[currIdx++];
877 for (
int faceIdx = 0; faceIdx < numFaces; faceIdx++)
879 int numPoints = cellstream[currIdx++];
880 for (
int pointIdx = 0; pointIdx < numPoints; ++pointIdx)
882 int point = cellstream[currIdx++];
883 uniqueIdxs.insert(point);
887 pointCount = (int)uniqueIdxs.size();
891 pointCount = GetNumberOfItemsForCell(a_cellIdx);
915 a_cellPoints.clear();
920 int cellType = cellstream[0];
921 if (cellType == XMU_POLYHEDRON)
923 GetUniquePointsFromPolyhedronSingleCellstream(cellstream, a_cellPoints);
926 else if (cellType == XMU_PIXEL)
928 a_cellPoints.push_back(cellstream[2]);
929 a_cellPoints.push_back(cellstream[3]);
930 a_cellPoints.push_back(cellstream[5]);
931 a_cellPoints.push_back(cellstream[4]);
936 a_cellPoints.assign(cellstream.begin() + 2, cellstream.end());
961 if (a_cellIdx < 0 || m_cellIdxToStreamIdx.size() < 2 ||
962 a_cellIdx > m_cellIdxToStreamIdx.size() - 2)
964 return XMU_INVALID_CELL_TYPE;
968 int cellStart = m_cellIdxToStreamIdx[a_cellIdx];
970 if ((m_cellstream[cellStart] > XMU_PYRAMID) && (m_cellstream[cellStart] != XMU_POLYHEDRON) ||
971 (m_cellstream[cellStart] == XMU_TRIANGLE_STRIP))
973 assert(
"UNSUPPORTED TYPE!");
985 if (!m_cellDimensionCounts.empty())
987 return m_cellDimensionCounts;
991 m_cellDimensionCounts.clear();
992 m_cellDimensionCounts.resize(4, 0);
995 for (
int i = 0; i < cellCount; i++)
1000 m_cellDimensionCounts[itemp]++;
1003 return m_cellDimensionCounts;
1014 return DimensionFromCellType(
GetCellType(a_cellIdx));
1027 GetExtentsFromPoints(pts, a_min, a_max);
1036 return m_cellstream;
1055 m_cellstream = a_cellstream;
1075 a_cellstream.clear();
1076 if (a_cellIdx < 0 || m_cellIdxToStreamIdx.size() < 2 ||
1077 a_cellIdx > m_cellIdxToStreamIdx.size() - 2)
1081 int startIndex(m_cellIdxToStreamIdx[a_cellIdx]), endIndex(m_cellIdxToStreamIdx[a_cellIdx + 1]);
1082 a_cellstream.assign(m_cellstream.begin() + startIndex, m_cellstream.begin() + endIndex);
1104 a_cellNeighbors.clear();
1107 for (
int pointIdx : pointsOfCell)
1110 for (
int associatedCell : associatedCells)
1112 if (associatedCell != a_cellIdx)
1115 for (
int a_cellNeighbor : a_cellNeighbors)
1117 if (a_cellNeighbor == associatedCell)
1124 a_cellNeighbors.push_back(associatedCell);
1140 if (!IsValidCellIdx(a_cellIdx))
1144 return GetPlanViewPolygon3d(a_cellIdx, a_polygon);
1145 else if (dimension == 2)
1146 return GetPlanViewPolygon2d(a_cellIdx, a_polygon);
1161 Pt3d centroid =
Pt3d(0.0, 0.0, 0.0);
1166 else if (!IsValidCellIdx(a_cellIdx))
1174 for (
Pt3d& pt : cellPoints)
1178 centroid /= (double)cellPoints.size();
1180 a_centroid = centroid;
1192 const Pt3d& a_newPosition)
const 1197 return !DoEdgesCrossWithPointChange(a_changedPtIdx, a_newPosition, edges);
1204 for (
int faceIdx = 0; faceIdx < faces.size(); faceIdx++)
1206 bool faceIsAffected =
false;
1207 for (
int ptIdx = 0; ptIdx < faces[faceIdx].size(); ptIdx++)
1209 if (faces[faceIdx][ptIdx] == a_changedPtIdx)
1211 faceIsAffected =
true;
1216 std::vector<XmEdge> edges;
1217 GetEdgesOfFace(faces[faceIdx], edges);
1218 if (DoEdgesCrossWithPointChange(a_changedPtIdx, a_newPosition, edges))
1242 bool validChange =
false;
1243 if (a_changedPtIdx >= 0 && a_changedPtIdx < m_locations.size())
1247 for (
int affectedCell : affectedCells)
1249 if (!IsCellValidWithPointChange(affectedCell, a_changedPtIdx, a_newPosition))
1251 validChange =
false;
1265 a_edges.reserve(a_face.size());
1266 for (
int i = 1; i < a_face.size(); ++i)
1268 a_edges.emplace_back(a_face[i - 1], a_face[i]);
1270 if (a_edges.size() > 1)
1271 a_edges.emplace_back(a_face[a_face.size() - 1], a_face[0]);
1282 const Pt3d& a_newPosition,
1283 const std::vector<XmEdge>& a_edges)
const 1285 std::vector<std::pair<Pt3d, Pt3d>> changedEdges;
1286 std::vector<std::pair<Pt3d, Pt3d>> unChangedEdges;
1287 for (
const auto& edge : a_edges)
1289 if (edge.GetFirst() == a_changedPtIdx)
1291 changedEdges.emplace_back(a_newPosition,
GetPointLocation(edge.GetSecond()));
1293 else if (edge.GetSecond() == a_changedPtIdx)
1295 changedEdges.emplace_back(
GetPointLocation(edge.GetFirst()), a_newPosition);
1303 for (
const auto& changedEdge : changedEdges)
1305 for (
const auto& unChangedEdge : unChangedEdges)
1307 if (
gmLinesCross(changedEdge.first, changedEdge.second, unChangedEdge.first,
1308 unChangedEdge.second))
1326 case XMU_INVALID_CELL_TYPE:
1331 return GetNumberOfItemsForCell(a_cellIdx) - 1;
1335 return GetNumberOfItemsForCell(a_cellIdx);
1338 case XMU_POLYHEDRON:
1339 return GetNumberOfPolyhedronEdges(a_cellIdx);
1344 const VecEdge& edgeTable = iGetEdgeOffsetTable(cellType);
1345 if (!edgeTable.empty())
1346 return (
int)edgeTable.size();
1366 const int* cellstream =
nullptr;
1371 if (streamLength < 4)
1374 int cellType = cellstream[0];
1380 int numPoints = cellstream[1];
1381 const int* cellPoints = cellstream + 2;
1382 int idx1 = cellPoints[a_edgeIdx];
1383 int idx2 = cellPoints[(a_edgeIdx + 1) % numPoints];
1384 edge =
XmEdge(idx1, idx2);
1388 case XMU_POLYHEDRON:
1390 boost::container::flat_set<XmEdge> cellEdges;
1392 GetUniqueEdgesFromPolyhedronCellstream(cellstream, streamLength, cellEdges, currIdx);
1394 if (a_edgeIdx < (
int)cellEdges.size())
1395 edge = *(cellEdges.begin() + a_edgeIdx);
1401 const VecEdge& edgeTable = iGetEdgeOffsetTable(cellType);
1402 if (a_edgeIdx < (
int)edgeTable.size())
1404 const XmEdge& edgeOffset = edgeTable[a_edgeIdx];
1405 const int* cellPoints = cellstream + 2;
1406 int idx1 = cellPoints[edgeOffset.
GetFirst()];
1407 int idx2 = cellPoints[edgeOffset.
GetSecond()];
1408 edge =
XmEdge(idx1, idx2);
1427 return adjacentCells;
1438 VecInt& a_adjacentCellIdxs)
const 1440 a_adjacentCellIdxs.clear();
1443 if (cellNeighbors.empty())
1452 XmEdge currEdge, neighborEdge;
1454 for (
int cellNeighbor : cellNeighbors)
1461 a_adjacentCellIdxs.push_back(cellNeighbor);
1481 for (
int cellIdx = 0; cellIdx < adjCellCount; cellIdx++)
1483 int adjacentCell = m_pointsToCells[m_pointIdxToPointsToCells[pointIdx] + cellIdx + 1];
1484 if (adjacentCell == a_cellIdx)
1488 for (
int adjacentEdgeIdx = 0; adjacentEdgeIdx < edgeCount; ++adjacentEdgeIdx)
1492 return adjacentCell;
1505 a_adjacentCellIdxs.clear();
1517 return adjacentCellIdxs;
1526 std::vector<XmEdge> edges;
1539 for (
int i = 0; i < numEdges; ++i)
1552 a_edgePoints.clear();
1554 if (associatedCells.empty())
1558 for (
int associatedCell : associatedCells)
1565 a_edgePoints.push_back(temp.
GetSecond());
1567 else if (temp.
GetSecond() == a_pointIdx)
1569 a_edgePoints.push_back(temp.
GetFirst());
1573 std::sort(a_edgePoints.begin(), a_edgePoints.end());
1574 auto it = std::unique(a_edgePoints.begin(), a_edgePoints.end());
1575 a_edgePoints.erase(it, a_edgePoints.end());
1600 CalculateCacheValues();
1601 int faceCount = IsValidCellIdx(a_cellIdx) ? m_numberOfFaces[a_cellIdx] : -1;
1606 return GetCell3dFaceCountNoCache(a_cellIdx);
1618 if (!IsValidCellIdx(a_cellIdx))
1624 if (cellType == XMU_POLYHEDRON)
1626 const int* cellstream;
1629 if (cellstream !=
nullptr)
1631 auto currItem = cellstream;
1633 int numFaces = *currItem++;
1634 for (
int faceIdx = 0; faceIdx < numFaces; ++faceIdx)
1636 int numFacePoints = *currItem++;
1637 if (a_faceIdx == faceIdx)
1639 return numFacePoints;
1641 currItem += numFacePoints;
1647 const VecInt2d& faceTable = iGetFaceOffsetTable(cellType);
1648 if (a_faceIdx >= 0 && a_faceIdx < (
int)faceTable.size())
1650 return (
int)faceTable[a_faceIdx].size();
1677 a_facePtIdxs.clear();
1683 const int* cellstream =
nullptr;
1689 int cellType = *cellstream++;
1690 if (cellType == XMU_POLYHEDRON)
1692 int numFaces = *cellstream++;
1693 for (
int faceIdx = 0; faceIdx < numFaces; ++faceIdx)
1695 int numFacePoints = *cellstream++;
1696 if (faceIdx == a_faceIdx)
1698 a_facePtIdxs.assign(cellstream, cellstream + numFacePoints);
1701 cellstream += numFacePoints;
1706 const VecInt2d& faceTable = iGetFaceOffsetTable(cellType);
1707 if (a_faceIdx < (
int)faceTable.size())
1711 const int* cellPoints = ++cellstream;
1712 const VecInt& faceOffsets = faceTable[a_faceIdx];
1713 for (
auto offset : faceOffsets)
1715 int idx = cellPoints[offset];
1716 a_facePtIdxs.push_back(idx);
1732 for (
int i(0); i < numFaces; i++)
1748 CalculateCacheValues();
1749 int faceNeighbor = -1;
1751 if (a_faceIdx >= 0 && a_faceIdx < numFaces)
1753 int faceOffset = m_cellFaceOffset[a_cellIdx];
1754 if (faceOffset >= 0)
1756 faceOffset += a_faceIdx;
1757 faceNeighbor = m_faceNeighbor[faceOffset];
1758 if (faceNeighbor == NEEDS_CALCULATION)
1760 faceNeighbor = GetCell3dFaceAdjacentCellNoCache(a_cellIdx, a_faceIdx);
1761 m_faceNeighbor[faceOffset] = faceNeighbor;
1765 faceNeighbor = m_faceNeighbor[faceOffset];
1769 return faceNeighbor;
1773 return GetCell3dFaceAdjacentCellNoCache(a_cellIdx, a_faceIdx);
1787 int& a_neighborCell,
1788 int& a_neighborFace)
const 1791 if (a_neighborCell < 0)
1793 a_neighborCell = a_neighborFace = -1;
1800 if (cellFacePts.size() == curCellFacePts.size())
1802 int cellFacePtsIdx(0);
1803 for (; cellFacePtsIdx < (int)cellFacePts.size(); ++cellFacePtsIdx)
1806 for (
int curCellFacePt : curCellFacePts)
1808 if (cellFacePts[cellFacePtsIdx] == curCellFacePt)
1817 if (cellFacePtsIdx == (
int)cellFacePts.size())
1819 a_neighborFace = faceIdx;
1820 a_neighborFace = faceIdx;
1825 a_neighborCell = a_neighborFace = -1;
1838 CalculateCacheValues();
1839 int faceOrientation = XMU_ORIENTATION_UNKNOWN;
1841 if (a_faceIdx >= 0 && a_faceIdx < numFaces)
1843 int faceOffset = m_cellFaceOffset[a_cellIdx];
1844 if (faceOffset >= 0)
1846 faceOffset += a_faceIdx;
1847 faceOrientation = m_faceOrientation[faceOffset];
1848 if (faceOrientation == NEEDS_CALCULATION)
1850 faceOrientation = (int)GetCell3dFaceOrientationNoCache(a_cellIdx, a_faceIdx);
1851 m_faceOrientation[faceOffset] = faceOrientation;
1855 faceOrientation = m_faceOrientation[faceOffset];
1863 return GetCell3dFaceOrientationNoCache(a_cellIdx, a_faceIdx);
1875 if (orientation == XMU_ORIENTATION_UNKNOWN)
1880 orientation = VerticalOrientationFromOpposing(a_cellIdx, a_faceIdx);
1883 XM_ASSERT(orientation != XMU_ORIENTATION_UNKNOWN);
1900 m_cellIdxToStreamIdx.clear();
1903 if (m_cellstream.empty())
1905 m_cellIdxToStreamIdx.push_back(currIdx);
1909 int numItems = (int)m_cellstream.size();
1910 while (currIdx < numItems)
1912 m_cellIdxToStreamIdx.push_back(currIdx);
1915 int cellType = m_cellstream[currIdx++];
1916 if (currIdx >= numItems)
1920 int numPoints = m_cellstream[currIdx++];
1921 if (currIdx >= numItems)
1924 if (cellType == XMU_POLYHEDRON)
1926 int numFaces = numPoints;
1927 for (
int faceIdx = 0; faceIdx < numFaces; ++faceIdx)
1929 int numFacePoints = m_cellstream[currIdx++];
1930 currIdx += numFacePoints;
1935 currIdx += numPoints;
1939 m_cellIdxToStreamIdx.push_back(currIdx);
1946 m_pointIdxToPointsToCells.clear();
1947 m_pointIdxToPointsToCells.resize(m_locations.size(), 0);
1948 m_pointsToCells.clear();
1951 int numStreamItems = (int)m_cellstream.size();
1954 VecInt pointLastUsedIdx(m_locations.size(), -1);
1956 while (currIdx < numStreamItems)
1959 int cellType = m_cellstream[currIdx++];
1960 if (currIdx >= numStreamItems)
1964 int numCellItems = m_cellstream[currIdx++];
1965 if (currIdx >= numStreamItems)
1968 if (cellType == XMU_POLYHEDRON)
1970 GetUniquePointsFromPolyhedronCellstream(m_cellstream, numCellItems, currIdx, cellPoints,
1980 for (
auto cellPoint : cellPoints)
1982 m_pointIdxToPointsToCells[cellPoint] += 1;
1988 int numPoints = numCellItems;
1989 for (
int ptIdx = 0; ptIdx < numPoints; ++ptIdx)
1991 int pt = m_cellstream[currIdx++];
1992 m_pointIdxToPointsToCells[pt] += 1;
1998 m_pointIdxToPointsToCells.push_back(0);
2002 for (
auto& item : m_pointIdxToPointsToCells)
2004 int count = item + 1;
2011 m_pointsToCells.resize(currCount, 0);
2012 std::fill(pointLastUsedIdx.begin(), pointLastUsedIdx.end(), -1);
2013 while (currIdx < numStreamItems)
2016 int cellType = m_cellstream[currIdx++];
2017 if (currIdx >= numStreamItems)
2021 int numCellItems = m_cellstream[currIdx++];
2022 if (currIdx >= numStreamItems)
2025 if (cellType == XMU_POLYHEDRON)
2027 GetUniquePointsFromPolyhedronCellstream(m_cellstream, numCellItems, currIdx, cellPoints,
2035 for (
auto cellPoint : cellPoints)
2037 int countIdx = m_pointIdxToPointsToCells[cellPoint];
2038 int& count = m_pointsToCells[countIdx];
2040 int updateIdx = countIdx + count;
2041 m_pointsToCells[updateIdx] = cellIdx;
2047 int numPoints = numCellItems;
2048 for (
int ptIdx = 0; ptIdx < numPoints; ++ptIdx)
2050 int pt = m_cellstream[currIdx++];
2051 int countIdx = m_pointIdxToPointsToCells[pt];
2052 int& count = m_pointsToCells[countIdx];
2054 int updateIdx = countIdx + count;
2055 m_pointsToCells[updateIdx] = cellIdx;
2072 case XMU_INVALID_CELL_TYPE:
2077 case XMU_EMPTY_CELL:
2079 case XMU_POLY_VERTEX:
2080 case XMU_CONVEX_POINT_SET:
2089 case XMU_QUADRATIC_EDGE:
2090 case XMU_PARAMETRIC_CURVE:
2091 case XMU_HIGHER_ORDER_EDGE:
2092 case XMU_CUBIC_LINE:
2097 case XMU_TRIANGLE_STRIP:
2102 case XMU_QUADRATIC_TRIANGLE:
2103 case XMU_QUADRATIC_QUAD:
2104 case XMU_BIQUADRATIC_QUAD:
2105 case XMU_QUADRATIC_LINEAR_QUAD:
2106 case XMU_BIQUADRATIC_TRIANGLE:
2107 case XMU_QUADRATIC_POLYGON:
2109 case XMU_PARAMETRIC_SURFACE:
2110 case XMU_PARAMETRIC_TRI_SURFACE:
2111 case XMU_PARAMETRIC_QUAD_SURFACE:
2113 case XMU_HIGHER_ORDER_TRIANGLE:
2114 case XMU_HIGHER_ORDER_QUAD:
2115 case XMU_HIGHER_ORDER_POLYGON:
2124 #if 0 // Remaining definitions 2127 XMU_HEXAHEDRON = 12,
2130 XMU_PENTAGONAL_PRISM = 15,
2131 XMU_HEXAGONAL_PRISM = 16,
2134 XMU_QUADRATIC_TETRA = 24,
2135 XMU_QUADRATIC_HEXAHEDRON = 25,
2136 XMU_QUADRATIC_WEDGE = 26,
2137 XMU_QUADRATIC_PYRAMID = 27,
2138 XMU_TRIQUADRATIC_HEXAHEDRON = 29,
2139 XMU_QUADRATIC_LINEAR_WEDGE = 31,
2140 XMU_BIQUADRATIC_QUADRATIC_WEDGE = 32,
2141 XMU_BIQUADRATIC_QUADRATIC_HEXAHEDRON = 33,
2144 XMU_POLYHEDRON = 42,
2147 XMU_PARAMETRIC_TETRA_REGION = 55,
2148 XMU_PARAMETRIC_HEX_REGION = 56,
2151 XMU_HIGHER_ORDER_TETRAHEDRON = 64,
2152 XMU_HIGHER_ORDER_WEDGE = 65,
2153 XMU_HIGHER_ORDER_PYRAMID = 66,
2154 XMU_HIGHER_ORDER_HEXAHEDRON = 67,
2170 if (cellType == XMU_INVALID_CELL_TYPE)
2174 else if (cellType != XMU_POLYHEDRON)
2177 int startIndex = m_cellIdxToStreamIdx[a_cellIdx];
2178 return m_cellstream[startIndex + 1];
2182 int startIndex = m_cellIdxToStreamIdx[a_cellIdx];
2183 return m_cellstream[startIndex + 1];
2196 if (cellType == XMU_INVALID_CELL_TYPE)
2203 int startIndex = m_cellIdxToStreamIdx[a_cellIdx];
2204 int nextCellIndex = m_cellIdxToStreamIdx[a_cellIdx + 1];
2205 *a_start = &m_cellstream[startIndex];
2206 a_length = nextCellIndex - startIndex;
2216 const int* cellstream;
2219 if (cellstream && streamLength > 0 && cellstream[0] == XMU_POLYHEDRON)
2221 boost::container::flat_set<XmEdge> edges;
2223 while (currItem < streamLength)
2225 GetUniqueEdgesFromPolyhedronCellstream(cellstream, streamLength, edges, currItem);
2227 return (
int)edges.size();
2247 VecInt& a_uniqueGetCellPoints,
2248 VecInt& a_pointLastUsedIdx)
2250 int stable = a_currIdx;
2251 a_uniqueGetCellPoints.clear();
2252 int numFaces = a_numCellItems;
2253 for (
int faceIdx = 0; faceIdx < numFaces; ++faceIdx)
2255 int numFacePoints = a_cellstream[a_currIdx++];
2256 for (
int ptIdx = 0; ptIdx < numFacePoints; ++ptIdx)
2258 int pt = a_cellstream[a_currIdx++];
2259 if (a_pointLastUsedIdx[pt] < stable)
2261 a_pointLastUsedIdx[pt] = stable;
2262 a_uniqueGetCellPoints.push_back(pt);
2276 a_cellPoints.clear();
2277 if (a_cellstream.size() < 2)
2282 auto currItem = a_cellstream.begin();
2283 int cellType = *currItem++;
2284 if (cellType != XMU_POLYHEDRON)
2289 int numFaces = *currItem++;
2290 for (
int faceIdx = 0; faceIdx < numFaces; ++faceIdx)
2292 int numFacePoints = *currItem++;
2293 for (
int ptIdx = 0; ptIdx < numFacePoints; ++ptIdx)
2295 int pt = *currItem++;
2296 if (std::find(a_cellPoints.begin(), a_cellPoints.end(), pt) == a_cellPoints.end())
2298 a_cellPoints.push_back(pt);
2319 boost::container::flat_set<XmEdge>& a_cellEdges,
2322 int numFaces = a_start[1];
2323 for (
int i(0); i < numFaces; i++)
2325 int numPoints = a_start[a_currIdx++];
2326 for (
int pointIdx = 0; pointIdx < numPoints; ++pointIdx)
2328 int pt1Idx = pointIdx;
2329 int pt2Idx = (pointIdx + 1) % numPoints;
2332 int pt1 = a_start[a_currIdx + pt1Idx];
2333 int pt2 = a_start[a_currIdx + pt2Idx];
2336 a_cellEdges.insert(
XmEdge(pt1, pt2));
2338 a_cellEdges.insert(
XmEdge(pt2, pt1));
2340 a_currIdx += numPoints;
2352 if (!a_polygon.empty())
2367 if (GetCellXySegments(a_cellIdx, segments))
2370 iMergeSegmentsToPoly(segments, a_polygon);
2377 VecPt3d cellPoints(uniquePoints.size());
2378 for (
int i(0); i < uniquePoints.size(); i++)
2381 cellPoints[i].z = 0.0;
2398 if (a_facePts.size() > 2)
2401 for (
size_t facePtIdx = 1; facePtIdx < a_facePts.size(); ++facePtIdx)
2404 if ((ptLast.
x == ptCurr.
x) && (ptLast.
y == ptCurr.
y))
2420 bool foundSideFace =
false;
2424 if (IsFaceSide(ptIdxs))
2426 foundSideFace =
true;
2427 if (!GetFaceXySegments(a_cellIdx, faceIdx, a_segments))
2433 return foundSideFace;
2445 a_min.
x = a_min.
y = a_min.
z = xms::XM_DBL_HIGHEST;
2446 a_max.
x = a_max.
y = a_max.
z = xms::XM_DBL_LOWEST;
2447 for (
const Pt3d& pt : a_locations)
2464 if (facePts.empty())
2467 int column1Begin, column1End;
2468 if (!GetNextFaceColumn(facePts, 0, column1Begin, column1End))
2471 int column2Begin, column2End;
2472 if (!GetNextFaceColumn(facePts, column1End, column2Begin, column2End))
2475 GetFacePointSegments(facePts, column1End, column2Begin, a_segments);
2476 GetFacePointSegments(facePts, column2End, column1Begin, a_segments);
2487 m_numberOfFaces.assign(cellCount, 0);
2488 m_cellFaceOffset.assign(cellCount + 1, 0);
2490 for (
int cellIdx = 0; cellIdx < cellCount; ++cellIdx)
2492 int numberOfFaces = GetCell3dFaceCountNoCache(cellIdx);
2493 m_numberOfFaces[cellIdx] = numberOfFaces;
2494 faceCount += numberOfFaces;
2495 m_cellFaceOffset[cellIdx + 1] = faceCount;
2498 m_faceOrientation.assign(faceCount, NEEDS_CALCULATION);
2499 m_faceNeighbor.assign(faceCount, NEEDS_CALCULATION);
2507 m_numberOfFaces.clear();
2508 m_cellFaceOffset.clear();
2509 m_faceOrientation.clear();
2510 m_faceNeighbor.clear();
2511 m_cellDimensionCounts.clear();
2520 if (!IsValidCellIdx(a_cellIdx))
2526 case XMU_POLYHEDRON:
2527 return GetNumberOfItemsForCell(a_cellIdx);
2532 const VecInt2d& faceTable = iGetFaceOffsetTable(cellType);
2533 return (
int)faceTable.size();
2549 if (cellFace.empty())
2552 if (neighborCellFace.size() <= 1)
2554 if (neighborCellFace.size() > 2)
2556 assert(
"Cell definitions are invalid; more than 2 cells found sharing the same face.");
2558 for (
int i : neighborCellFace)
2574 int a_faceIdx)
const 2577 return faceOrientation;
2591 int& a_columnEnd)
const 2593 int facePointsSize = (int)a_facePoints.size();
2597 int lasti = a_starti;
2598 int i = (a_starti + 1) % facePointsSize;
2601 while (!found && i != a_starti)
2606 a_columnBegin = lasti;
2611 i = (i + 1) % facePointsSize;
2622 while (!found && i != a_columnBegin)
2627 a_columnEnd = lasti;
2634 i = (i + 1) % facePointsSize;
2659 int i = a_columnBegin;
2660 while (i != a_columnEnd)
2663 a_segments.push_back(p);
2664 if (i != a_columnBegin)
2665 a_segments.push_back(p);
2666 i = (i + 1) % a_facePts.size();
2682 if (IsSideFace(a_cellIdx, a_faceIdx))
2683 return XMU_ORIENTATION_SIDE;
2688 if (orientation != XMU_ORIENTATION_UNKNOWN)
2692 orientation = GetOrientationFromArea(a_cellIdx, a_faceIdx);
2693 if (orientation != XMU_ORIENTATION_UNKNOWN)
2696 return XMU_ORIENTATION_UNKNOWN;
2705 int a_faceIdx)
const 2711 bool firstUnknown =
false;
2712 bool foundTop =
false;
2713 bool foundBot =
false;
2716 int orientation = FaceOrientationWithFail(a_cellIdx, face);
2717 if (orientation == XMU_ORIENTATION_UNKNOWN)
2719 if (a_faceIdx == face)
2720 firstUnknown =
true;
2722 else if (orientation == XMU_ORIENTATION_TOP)
2724 else if (orientation == XMU_ORIENTATION_BOTTOM)
2729 orientation = XMU_ORIENTATION_BOTTOM;
2731 orientation = XMU_ORIENTATION_TOP;
2732 else if (firstUnknown)
2733 orientation = XMU_ORIENTATION_TOP;
2735 orientation = XMU_ORIENTATION_BOTTOM;
2751 if (!facePts.empty())
2754 for (
size_t facePtIdx = 1; facePtIdx < facePts.size(); ++facePtIdx)
2757 if (ptLast == ptCurr)
2776 if (adjacentCellIdx !=
XM_NONE && adjacentCellIdx < a_cellIdx)
2777 return XMU_ORIENTATION_TOP;
2778 else if (adjacentCellIdx !=
XM_NONE && adjacentCellIdx > a_cellIdx)
2779 return XMU_ORIENTATION_BOTTOM;
2780 return XMU_ORIENTATION_UNKNOWN;
2795 for (
int facePtIdx : facePtIdxs)
2799 return XMU_ORIENTATION_TOP;
2800 else if (area < 0.0)
2801 return XMU_ORIENTATION_BOTTOM;
2802 return XMU_ORIENTATION_UNKNOWN;
2876 std::shared_ptr<XmUGrid> ugrid(
new XmUGrid());
2888 ugrid->SetLocations(a_locations);
2889 ugrid->SetCellstream(a_cellstream);
2949 if (a_cellstream.empty())
2952 int numItems = (int)a_cellstream.size();
2954 while (currIdx < numItems)
2957 int cellType = a_cellstream[currIdx++];
2958 if (currIdx >= numItems)
2962 int numPoints = a_cellstream[currIdx++];
2963 if (currIdx >= numItems)
2968 case XMU_EMPTY_CELL:
2975 currIdx += numPoints;
2980 currIdx += numPoints;
2985 currIdx += numPoints;
2992 currIdx += numPoints;
2997 currIdx += numPoints;
3000 case XMU_PENTAGONAL_PRISM:
3003 currIdx += numPoints;
3005 case XMU_HEXAGONAL_PRISM:
3008 currIdx += numPoints;
3011 case XMU_HEXAHEDRON:
3014 currIdx += numPoints;
3016 case XMU_POLY_VERTEX:
3019 currIdx += numPoints;
3024 currIdx += numPoints;
3026 case XMU_TRIANGLE_STRIP:
3030 currIdx += numPoints;
3032 case XMU_POLYHEDRON:
3034 int numFaces = numPoints;
3037 for (
int faceIdx = 0; faceIdx < numFaces; ++faceIdx)
3039 if (currIdx >= numItems)
3041 int numPoints = a_cellstream[currIdx++];
3044 currIdx += numPoints;
3049 currIdx += numPoints;
3053 if (currIdx > numItems)
3066 return m_impl->GetModified();
3083 m_impl->SetUseCache(a_useCache);
3094 return m_impl->GetPointCount();
3103 return m_impl->GetLocations();
3112 m_impl->SetLocations(a_locations);
3122 return m_impl->GetPointLocation(a_pointIdx);
3133 return m_impl->SetPointLocation(a_pointIdx, a_location);
3143 return m_impl->GetPointXy0(a_pointIdx);
3153 return m_impl->GetPointsLocations(a_points);
3163 m_impl->GetExtents(a_min, a_max);
3173 return m_impl->GetPointAdjacentCellCount(a_pointIdx);
3183 return m_impl->GetPointAdjacentCells(a_pointIdx);
3194 m_impl->GetPointAdjacentCells(a_pointIdx, a_adjacentCells);
3204 return m_impl->GetPointsAdjacentCells(a_points);
3212 const VecInt& a_pointIdxs,
3214 VecInt& a_adjacentCellIdxs)
const 3216 m_impl->GetPointsAdjacentCells(a_pointIdxs, a_adjacentCellIdxs);
3228 VecInt& a_adjacentCellIdxs)
const 3230 m_impl->GetPointsAdjacentCells(a_pointIdx1, a_pointIdx2, a_adjacentCellIdxs);
3241 return m_impl->IsValidPointChange(a_changedPtIdx, a_newPosition);
3250 return m_impl->GetCellCount();
3260 return m_impl->GetCellPointCount(a_cellIdx);
3270 return m_impl->GetCellPoints(a_cellIdx);
3281 return m_impl->GetCellPoints(a_cellIdx, a_cellPoints);
3291 m_impl->GetCellLocations(a_cellIdx, a_cellLocations);
3301 return m_impl->GetCellType(a_cellIdx);
3310 return m_impl->GetDimensionCounts();
3321 return m_impl->GetCellDimension(a_cellIdx);
3332 m_impl->GetCellExtents(a_cellIdx, a_min, a_max);
3348 return m_impl->GetCellstream();
3359 return m_impl->SetCellstream(a_cellstream);
3371 return m_impl->GetCellCellstream(a_cellIdx, a_cellstream);
3381 return m_impl->GetCellAdjacentCells(a_cellIdx);
3391 m_impl->GetCellAdjacentCells(a_cellIdx, a_cellNeighbors);
3403 return m_impl->GetCellPlanViewPolygon(a_cellIdx, a_polygon);
3414 return m_impl->GetCellCentroid(a_cellIdx, a_centroid);
3424 return m_impl->GetCellEdgeCount(a_cellIdx);
3435 return m_impl->GetCellEdge(a_cellIdx, a_edgeIdx);
3446 return m_impl->GetCellEdgeAdjacentCells(a_cellIdx, a_edgeIdx);
3458 VecInt& a_adjacentCellIdxs)
const 3460 m_impl->GetCellEdgeAdjacentCells(a_cellIdx, a_edgeIdx, a_adjacentCellIdxs);
3471 return m_impl->GetCell2dEdgeAdjacentCell(a_cellIdx, a_edgeIdx);
3481 m_impl->GetEdgeAdjacentCells(a_edge, a_adjacentCellIdxs);
3491 return m_impl->GetEdgeAdjacentCells(a_edge);
3501 return m_impl->GetCellEdges(a_cellIdx);
3511 m_impl->GetCellEdges(a_cellIdx, a_edges);
3521 m_impl->GetPointAdjacentPoints(a_pointIdx, a_edgePoints);
3531 m_impl->GetPointAdjacentLocations(a_pointIdx, a_edgePoints);
3543 return m_impl->GetCell3dFaceCount(a_cellIdx);
3553 return m_impl->GetCell3dFacePointCount(a_cellIdx, a_faceIdx);
3564 return m_impl->GetCell3dFacePoints(a_cellIdx, a_faceIdx);
3576 m_impl->GetCell3dFacePoints(a_cellIdx, a_faceIdx, a_facePtIdxs);
3586 return m_impl->GetCell3dFacesPoints(a_cellIdx);
3597 return m_impl->GetCell3dFaceAdjacentCell(a_cellIdx, a_faceIdx);
3611 int& a_neighborCell,
3612 int& a_neighborFace)
const 3614 return m_impl->GetCell3dFaceAdjacentCell(a_cellIdx, a_faceIdx, a_neighborCell, a_neighborFace);
3625 return m_impl->GetCell3dFaceOrientation(a_cellIdx, a_faceIdx);
3641 VecPt3d points = {{0, 0, 0}, {20, 0, 0}, {0, 20, 0}};
3644 std::vector<int> cells = {5, 3, 0, 1, 2};
3646 std::shared_ptr<XmUGrid> ugrid =
XmUGrid::New(points, cells);
3664 VecPt3d points = {{0, 10, 0}, {10, 10, 0}, {20, 10, 0}, {0, 0, 0}, {10, 0, 0},
3665 {20, 0, 0}, {0, -10, 0}, {10, -10, 0}, {20, -10, 0}};
3668 VecInt cellstream = {XMU_QUAD, 4, 0, 3, 4, 1, XMU_QUAD, 4, 1, 4, 5, 2,
3669 XMU_QUAD, 4, 3, 6, 7, 4, XMU_QUAD, 4, 4, 7, 8, 5};
3671 std::shared_ptr<XmUGrid> ugrid =
XmUGrid::New(points, cellstream);
3683 VecPt3d points = { { 0, 0, 0 }, { 10, 0, 0 }, { 20, 0, 0 }, { 30, 0, 0 }, { 40, 0, 0 },
3684 {0, 10, 0}, {10, 10, 0}, {20, 10, 0}, {40, 10, 0}, {0, 20, 0},
3685 {10, 20, 0}, {20, 20, 0}, {30, 20, 0}, {40, 20, 0}};
3688 std::vector<int> cells = {(int)XMU_QUAD, 4, 0, 1, 6, 5,
3689 (
int)XMU_PIXEL, 4, 1, 2, 6, 7,
3690 (int)XMU_TRIANGLE, 3, 2, 3, 7,
3691 (
int)XMU_POLYGON, 6, 3, 4, 8, 13, 12, 7,
3692 (int)XMU_POLY_LINE, 3, 7, 11, 10,
3693 (
int)XMU_LINE, 2, 5, 9};
3697 std::shared_ptr<XmUGrid> ugrid =
XmUGrid::New(points, cells);
3709 VecPt3d points = {{0, 0, 0}, {10, 0, 0}, {20, 0, 0}, {30, 0, 0}, {40, 0, 0},
3710 {0, 10, 0}, {10, 10, 0}, {20, 10, 0}, {30, 10, 0}, {40, 10, 0},
3711 {0, 20, 0}, {10, 20, 0}, {20, 20, 0}, {30, 20, 0}, {40, 20, 0},
3712 {0, 0, 10}, {10, 0, 10}, {20, 0, 10}, {30, 0, 10}, {40, 0, 10},
3713 {0, 10, 10}, {10, 10, 10}, {20, 10, 10}, {30, 10, 10}, {40, 10, 10},
3714 {0, 20, 10}, {10, 20, 10}, {20, 20, 10}, {30, 20, 10}, {40, 20, 10}};
3717 std::vector<int> cells = {(int)XMU_TETRA, 4, 0, 1, 5, 15,
3718 (
int)XMU_VOXEL, 8, 1, 2, 6, 7, 16, 17, 21, 22,
3719 (int)XMU_HEXAHEDRON, 8, 2, 3, 8, 7, 17, 18, 23, 22,
3720 (
int)XMU_POLYHEDRON, 6,
3727 (int)XMU_WEDGE, 6, 3, 4, 18, 8, 9, 23,
3728 (
int)XMU_PYRAMID, 5, 5, 6, 11, 10, 20};
3732 std::shared_ptr<XmUGrid> ugrid =
XmUGrid::New(points, cells);
3743 {0, 0, 10}, {10, 0, 10}, {10, 10, 10}, {0, 10, 10},
3744 {0, 0, 0}, {10, 0, 0}, {10, 10, 0}, {0, 10, 0},
3750 std::vector<int> cells = {(int)XMU_POLYHEDRON, 6,
3759 std::shared_ptr<XmUGrid> ugrid =
XmUGrid::New(points, cells);
3771 Pt3d origin(0.0, 0.0, 0.0);
3784 points.reserve(a_rows * a_cols);
3785 for (
int i = 0; i < a_rows; ++i)
3787 for (
int j = 0; j < a_cols; ++j)
3789 points.push_back(
Pt3d(j + a_origin.x, a_rows - i + a_origin.y));
3794 cells.reserve((a_rows - 1) * (a_cols - 1) * 6);
3795 for (
int i = 0; i < a_rows - 1; ++i)
3797 for (
int j = 0; j < a_cols - 1; ++j)
3799 cells.push_back(XMU_QUAD);
3801 cells.push_back(j + a_cols * i);
3802 cells.push_back(j + a_cols * (i + 1));
3803 cells.push_back(j + 1 + a_cols * (i + 1));
3804 cells.push_back(j + 1 + a_cols * i);
3819 Pt3d origin(0.0, 0.0, 0.0);
3833 const xms::Pt3d& a_origin)
3836 points.reserve(a_rows * a_cols);
3837 for (
int k = 0; k < a_lays; ++k)
3839 for (
int i = 0; i < a_rows; ++i)
3841 for (
int j = 0; j < a_cols; ++j)
3844 Pt3d(j + a_origin.x, a_rows - i - 1 + a_origin.y, a_lays - k - 1 + a_origin.z));
3850 cells.reserve((a_rows - 1) * (a_cols - 1) * (a_lays - 1) * 10);
3851 int numInLayer = a_rows * a_cols;
3852 for (
int k = 0; k < a_lays - 1; ++k)
3854 int layOffset = numInLayer * k;
3855 for (
int i = 0; i < a_rows - 1; ++i)
3857 for (
int j = 0; j < a_cols - 1; ++j)
3859 cells.push_back(XMU_HEXAHEDRON);
3862 cells.push_back(j + a_cols * i + layOffset);
3863 cells.push_back(j + 1 + a_cols * i + layOffset);
3864 cells.push_back(j + 1 + a_cols * (i + 1) + layOffset);
3865 cells.push_back(j + a_cols * (i + 1) + layOffset);
3867 cells.push_back(j + a_cols * i + layOffset + numInLayer);
3868 cells.push_back(j + 1 + a_cols * i + layOffset + numInLayer);
3869 cells.push_back(j + 1 + a_cols * (i + 1) + layOffset + numInLayer);
3870 cells.push_back(j + a_cols * (i + 1) + layOffset + numInLayer);
3885 Pt3d origin(0.0, 0.0, 0.0);
3899 const xms::Pt3d& a_origin)
3902 points.reserve(a_rows * a_cols);
3903 for (
int k = 0; k < a_lays; ++k)
3905 for (
int i = 0; i < a_rows; ++i)
3907 for (
int j = 0; j < a_cols; ++j)
3909 points.push_back(
Pt3d(j + a_origin.x, a_rows - i + a_origin.y, a_lays - k + a_origin.z));
3915 cells.reserve((a_rows - 1) * (a_cols - 1) * (a_lays - 1) * 10);
3916 int numInLayer = a_rows * a_cols;
3917 for (
int k = 0; k < a_lays - 1; ++k)
3919 int layOffset = numInLayer * k;
3920 for (
int i = 0; i < a_rows - 1; ++i)
3922 for (
int j = 0; j < a_cols - 1; ++j)
3924 int pt0 = j + a_cols * i + layOffset;
3925 int pt1 = j + 1 + a_cols * i + layOffset;
3926 int pt2 = j + a_cols * (i + 1) + layOffset;
3927 int pt3 = j + 1 + a_cols * (i + 1) + layOffset;
3928 int pt4 = pt0 + numInLayer;
3929 int pt5 = pt1 + numInLayer;
3930 int pt6 = pt2 + numInLayer;
3931 int pt7 = pt3 + numInLayer;
3933 cells.push_back(XMU_POLYHEDRON);
3937 cells.push_back(pt2);
3938 cells.push_back(pt6);
3939 cells.push_back(pt7);
3940 cells.push_back(pt3);
3943 cells.push_back(pt1);
3944 cells.push_back(pt5);
3945 cells.push_back(pt7);
3946 cells.push_back(pt3);
3949 cells.push_back(pt0);
3950 cells.push_back(pt1);
3951 cells.push_back(pt5);
3952 cells.push_back(pt4);
3955 cells.push_back(pt0);
3956 cells.push_back(pt4);
3957 cells.push_back(pt6);
3958 cells.push_back(pt2);
3961 cells.push_back(pt0);
3962 cells.push_back(pt2);
3963 cells.push_back(pt3);
3964 cells.push_back(pt1);
3967 cells.push_back(pt4);
3968 cells.push_back(pt5);
3969 cells.push_back(pt7);
3970 cells.push_back(pt6);
3982 VecPt3d ugridPoints = {{0.0, 0.0, 0.0}, {20.0, 10.0, 0.0}, {40.0, 0.0, 0.0},
3983 {20.0, 50.0, 0.0}, {0.0, 0.0, 10.0}, {20.0, 10.0, 10.0},
3984 {40.0, 0.0, 10.0}, {20.0, 50.0, 10.0}};
3986 VecInt ugridCell = { (int)XMU_POLYHEDRON, 6,
4008 using namespace xms;
4024 TS_ASSERT_EQUALS(xmUGrid->GetLocations(), grid1.
GetLocations());
4027 XmUGrid grid2(std::move(grid1));
4029 TS_ASSERT_EQUALS(xmUGrid->GetLocations(), grid2.GetLocations());
4033 TS_ASSERT_EQUALS(xmUGrid->GetLocations(), grid1.GetLocations());
4034 TS_ASSERT_EQUALS(xmUGrid->GetLocations(), grid2.GetLocations());
4045 VecPt3d points = emptyUGrid->GetLocations();
4046 TS_ASSERT_EQUALS(0, points.size());
4048 VecInt cellstream = emptyUGrid->GetCellstream();
4050 TS_ASSERT_EQUALS(0, cellstream.size());
4062 points = {{0, 10, 0}, {10, 10, 0}, {20, 10, 0}, {0, 0, 0}, {10, 0, 0},
4063 {20, 0, 0}, {0, -10, 0}, {10, -10, 0}, {20, -10, 0}};
4066 cellstream = {9, 4, 0, 3, 4, 1, 9, 4, 1, 4, 5, 2, 9, 4, 3, 6, 7, 4, 9, 4, 4, 7, 8, 5};
4068 TS_ASSERT(!ugrid->GetModified());
4069 ugrid->SetLocations(points);
4070 VecPt3d pointsOut = ugrid->GetLocations();
4071 TS_ASSERT_EQUALS(points, pointsOut);
4072 TS_ASSERT(ugrid->GetModified());
4074 ugrid->SetUnmodified();
4075 TS_ASSERT(!ugrid->GetModified());
4076 TS_ASSERT(ugrid->SetCellstream(cellstream));
4077 VecInt cellstreamOut = ugrid->GetCellstream();
4078 TS_ASSERT_EQUALS(cellstream, cellstreamOut);
4079 TS_ASSERT(ugrid->GetModified());
4084 cellstream = {9, 4, 0, 3, 4};
4086 cellstream = {9, 3, 0, 3, 4, 1};
4090 std::shared_ptr<XmUGrid> ugridBadOrder =
XmUGrid::New();
4091 TS_ASSERT(!ugridBadOrder->SetCellstream(cellstream));
4108 VecPt3d points = {{0, 10, 0}, {10, 10, 10}, {20, 10, 0}, {0, 0, 0}, {10, 0, 0},
4109 {20, 0, 0}, {0, -10, 0}, {10, -10, 0}, {20, -10, 0}};
4112 VecInt cellstream = {9, 4, 0, 3, 4, 1, 9, 4, 1, 4, 5, 2, 9, 4, 3, 6, 7, 4, 9, 4, 4, 7, 8, 5};
4114 std::shared_ptr<XmUGrid> ugrid =
XmUGrid::New(points, cellstream);
4117 TS_ASSERT_EQUALS(
Pt3d(), ugrid->GetPointLocation(-1));
4118 for (
int i = 0; i < (int)points.size(); i++)
4120 TS_ASSERT_EQUALS(points[i], ugrid->GetPointLocation(i));
4122 TS_ASSERT_EQUALS(
Pt3d(10, 10, 0), ugrid->GetPointXy0(1));
4123 TS_ASSERT_EQUALS(
Pt3d(), ugrid->GetPointLocation((
int)points.size()));
4124 TS_ASSERT(ugrid->GetModified());
4126 ugrid->SetUnmodified();
4127 TS_ASSERT(!ugrid->GetModified());
4128 TS_ASSERT(!ugrid->SetPointLocation(-1,
Pt3d()));
4129 TS_ASSERT(!ugrid->SetPointLocation((
int)points.size(),
Pt3d()));
4130 TS_ASSERT(!ugrid->GetModified());
4132 TS_ASSERT(ugrid->SetPointLocation(0,
Pt3d(-10, 10, 0)));
4133 TS_ASSERT_EQUALS(
Pt3d(-10, 10, 0), ugrid->GetPointLocation(0));
4134 TS_ASSERT(ugrid->GetModified());
4147 VecPt3d points = {{0, 10, 0}, {10, 10, 0}, {20, 10, 0}, {0, 0, 0}, {10, 0, 0},
4148 {20, 0, 0}, {0, -10, 0}, {10, -10, 0}, {20, -10, 0}};
4150 VecInt cell0 = {9, 4, 0, 3, 4, 1}, cell1 = {9, 4, 1, 4, 5, 2}, cell2 = {9, 4, 3, 6, 7, 4},
4151 cell3 = {9, 4, 4, 7, 8, 5};
4154 cellstream.insert(cellstream.end(), cell0.begin(), cell0.end());
4155 cellstream.insert(cellstream.end(), cell1.begin(), cell1.end());
4156 cellstream.insert(cellstream.end(), cell2.begin(), cell2.end());
4157 cellstream.insert(cellstream.end(), cell3.begin(), cell3.end());
4159 std::shared_ptr<XmUGrid> ugrid =
XmUGrid::New(points, cellstream);
4162 TS_ASSERT_EQUALS(
false, ugrid->GetCellCellstream(-1, cellResult));
4164 TS_ASSERT_EQUALS(
true, ugrid->GetCellCellstream(0, cellResult));
4165 TS_ASSERT_EQUALS(cell0, cellResult);
4166 TS_ASSERT_EQUALS(
true, ugrid->GetCellCellstream(1, cellResult));
4167 TS_ASSERT_EQUALS(cell1, cellResult);
4168 TS_ASSERT_EQUALS(
true, ugrid->GetCellCellstream(2, cellResult));
4169 TS_ASSERT_EQUALS(cell2, cellResult);
4170 TS_ASSERT_EQUALS(
true, ugrid->GetCellCellstream(3, cellResult));
4171 TS_ASSERT_EQUALS(cell3, cellResult);
4173 TS_ASSERT_EQUALS(
false, ugrid->GetCellCellstream((
int)points.size(), cellResult));
4183 TS_ASSERT_EQUALS(14, ugrid2d->GetPointCount());
4184 TS_ASSERT_EQUALS(6, ugrid2d->GetCellCount());
4185 TS_ASSERT_EQUALS(XMU_INVALID_CELL_TYPE, ugrid2d->GetCellType(-1));
4186 TS_ASSERT_EQUALS(XMU_INVALID_CELL_TYPE, ugrid2d->GetCellType(6));
4187 TS_ASSERT_EQUALS(XMU_QUAD, ugrid2d->GetCellType(0));
4188 TS_ASSERT_EQUALS(XMU_PIXEL, ugrid2d->GetCellType(1));
4189 TS_ASSERT_EQUALS(XMU_TRIANGLE, ugrid2d->GetCellType(2));
4190 TS_ASSERT_EQUALS(XMU_POLYGON, ugrid2d->GetCellType(3));
4191 TS_ASSERT_EQUALS(XMU_POLY_LINE, ugrid2d->GetCellType(4));
4192 TS_ASSERT_EQUALS(XMU_LINE, ugrid2d->GetCellType(5));
4197 TS_ASSERT_EQUALS(30, ugrid3d->GetPointCount());
4198 TS_ASSERT_EQUALS(6, ugrid3d->GetCellCount());
4199 TS_ASSERT_EQUALS(XMU_INVALID_CELL_TYPE, ugrid3d->GetCellType(-1));
4200 TS_ASSERT_EQUALS(XMU_INVALID_CELL_TYPE, ugrid3d->GetCellType(6));
4201 TS_ASSERT_EQUALS(XMU_TETRA, ugrid3d->GetCellType(0));
4202 TS_ASSERT_EQUALS(XMU_VOXEL, ugrid3d->GetCellType(1));
4203 TS_ASSERT_EQUALS(XMU_HEXAHEDRON, ugrid3d->GetCellType(2));
4204 TS_ASSERT_EQUALS(XMU_POLYHEDRON, ugrid3d->GetCellType(3));
4205 TS_ASSERT_EQUALS(XMU_WEDGE, ugrid3d->GetCellType(4));
4206 TS_ASSERT_EQUALS(XMU_PYRAMID, ugrid3d->GetCellType(5));
4216 TS_ASSERT_EQUALS(XMU_INVALID_CELL_TYPE, ugrid2d->GetCellDimension(-1));
4217 TS_ASSERT_EQUALS(XMU_INVALID_CELL_TYPE, ugrid2d->GetCellDimension(6));
4218 TS_ASSERT_EQUALS(2, ugrid2d->GetCellDimension(0));
4219 TS_ASSERT_EQUALS(2, ugrid2d->GetCellDimension(1));
4220 TS_ASSERT_EQUALS(2, ugrid2d->GetCellDimension(2));
4221 TS_ASSERT_EQUALS(2, ugrid2d->GetCellDimension(3));
4222 TS_ASSERT_EQUALS(1, ugrid2d->GetCellDimension(4));
4223 TS_ASSERT_EQUALS(1, ugrid2d->GetCellDimension(5));
4228 TS_ASSERT_EQUALS(XMU_INVALID_CELL_TYPE, ugrid3d->GetCellDimension(-1));
4229 TS_ASSERT_EQUALS(XMU_INVALID_CELL_TYPE, ugrid3d->GetCellDimension(6));
4230 TS_ASSERT_EQUALS(3, ugrid3d->GetCellDimension(0));
4231 TS_ASSERT_EQUALS(3, ugrid3d->GetCellDimension(1));
4232 TS_ASSERT_EQUALS(3, ugrid3d->GetCellDimension(2));
4233 TS_ASSERT_EQUALS(3, ugrid3d->GetCellDimension(3));
4234 TS_ASSERT_EQUALS(3, ugrid3d->GetCellDimension(4));
4235 TS_ASSERT_EQUALS(3, ugrid3d->GetCellDimension(5));
4238 std::vector<int> twoDResults(4, 0), threeDResults(4, 0);
4241 threeDResults[3] = 6;
4242 TS_ASSERT_EQUALS(twoDResults, ugrid2d->GetDimensionCounts());
4243 TS_ASSERT_EQUALS(threeDResults, ugrid3d->GetDimensionCounts());
4247 std::vector<int> emptyResults = emptyUgrid->GetDimensionCounts();
4248 TS_ASSERT_EQUALS(
VecInt(4, 0), emptyResults);
4259 Pt3d expectedMin = {0.0, 0.0, 0.0}, expectMax = {40.0, 20.0, 0.0};
4260 ugrid2d->GetExtents(min, max);
4261 TS_ASSERT_EQUALS(expectedMin, min);
4262 TS_ASSERT_EQUALS(expectMax, max);
4267 expectedMin = {0.0, 0.0, 0.0};
4268 expectMax = {40.0, 20.0, 10.0};
4269 ugrid3d->GetExtents(min, max);
4270 TS_ASSERT_EQUALS(expectedMin, min);
4271 TS_ASSERT_EQUALS(expectMax, max);
4273 Pt3d origin(-25.0, -25.0, -15.0);
4277 expectedMin = {-25.0, -25.0, -15.0};
4278 expectMax = {25.0, 25.0, 15.0};
4279 ugridBuild->GetExtents(min, max);
4280 TS_ASSERT_EQUALS(expectedMin, min);
4281 TS_ASSERT_EQUALS(expectMax, max);
4291 TS_ASSERT_EQUALS(-1, ugrid2d->GetCellEdgeCount(-1));
4292 TS_ASSERT_EQUALS(-1, ugrid2d->GetCellEdgeCount(6));
4293 TS_ASSERT_EQUALS(4, ugrid2d->GetCellEdgeCount(0));
4294 TS_ASSERT_EQUALS(4, ugrid2d->GetCellEdgeCount(1));
4295 TS_ASSERT_EQUALS(3, ugrid2d->GetCellEdgeCount(2));
4296 TS_ASSERT_EQUALS(6, ugrid2d->GetCellEdgeCount(3));
4297 TS_ASSERT_EQUALS(2, ugrid2d->GetCellEdgeCount(4));
4298 TS_ASSERT_EQUALS(1, ugrid2d->GetCellEdgeCount(5));
4303 TS_ASSERT_EQUALS(-1, ugrid3d->GetCellEdgeCount(-1));
4304 TS_ASSERT_EQUALS(-1, ugrid3d->GetCellEdgeCount(6));
4305 TS_ASSERT_EQUALS(6, ugrid3d->GetCellEdgeCount(0));
4306 TS_ASSERT_EQUALS(12, ugrid3d->GetCellEdgeCount(1));
4307 TS_ASSERT_EQUALS(12, ugrid3d->GetCellEdgeCount(2));
4308 TS_ASSERT_EQUALS(12, ugrid3d->GetCellEdgeCount(3));
4309 TS_ASSERT_EQUALS(9, ugrid3d->GetCellEdgeCount(4));
4310 TS_ASSERT_EQUALS(8, ugrid3d->GetCellEdgeCount(5));
4324 TS_ASSERT_EQUALS(-1, ugrid2d->GetCell3dFaceCount(-1));
4325 for (
int cellIdx = 0; cellIdx < ugrid2d->GetCellCount(); ++cellIdx)
4327 TS_ASSERT_EQUALS(0, ugrid2d->GetCell3dFaceCount(cellIdx));
4329 TS_ASSERT_EQUALS(-1, ugrid2d->GetCell3dFaceCount(ugrid2d->GetCellCount()));
4335 TS_ASSERT_EQUALS(-1, ugrid3d->GetCell3dFaceCount(-1));
4336 TS_ASSERT_EQUALS(-1, ugrid3d->GetCell3dFaceCount(6));
4337 TS_ASSERT_EQUALS(4, ugrid3d->GetCell3dFaceCount(0));
4338 TS_ASSERT_EQUALS(6, ugrid3d->GetCell3dFaceCount(1));
4339 TS_ASSERT_EQUALS(6, ugrid3d->GetCell3dFaceCount(2));
4340 TS_ASSERT_EQUALS(6, ugrid3d->GetCell3dFaceCount(3));
4341 TS_ASSERT_EQUALS(5, ugrid3d->GetCell3dFaceCount(4));
4342 TS_ASSERT_EQUALS(5, ugrid3d->GetCell3dFaceCount(5));
4355 TS_ASSERT_EQUALS(-1, ugrid2d->GetCell3dFacePointCount(-1, 0));
4356 TS_ASSERT_EQUALS(0, ugrid2d->GetCell3dFacePointCount(1, 0));
4357 TS_ASSERT_EQUALS(-1, ugrid2d->GetCell3dFacePointCount(ugrid2d->GetCellCount(), 0));
4363 TS_ASSERT_EQUALS(-1, ugrid3d->GetCell3dFacePointCount(-1, 0));
4364 TS_ASSERT_EQUALS(-1, ugrid3d->GetCell3dFacePointCount(6, 0));
4365 TS_ASSERT_EQUALS(4, ugrid3d->GetCell3dFacePointCount(1, 3));
4366 TS_ASSERT_EQUALS(4, ugrid3d->GetCell3dFacePointCount(3, 2));
4377 VecPt3d points = {{0, 10, 0}, {10, 10, 0}, {20, 10, 0}, {0, 0, 0}, {10, 0, 0}, {20, 0, 0}};
4379 VecInt cellstream = {XMU_QUAD, 4, 0, 3, 4, 1, XMU_QUAD, 4, 1, 4, 5, 2};
4381 std::shared_ptr<XmUGrid> ugrid =
XmUGrid::New(points, cellstream);
4385 VecInt cellZeroAndOne = {0, 1};
4388 TS_ASSERT_EQUALS(cellEmpty, ugrid->GetPointAdjacentCells(-1));
4389 TS_ASSERT_EQUALS(cellZero, ugrid->GetPointAdjacentCells(0));
4390 TS_ASSERT_EQUALS(cellZeroAndOne, ugrid->GetPointAdjacentCells(1));
4391 TS_ASSERT_EQUALS(cellOne, ugrid->GetPointAdjacentCells(2));
4392 TS_ASSERT_EQUALS(cellZero, ugrid->GetPointAdjacentCells(3));
4393 TS_ASSERT_EQUALS(cellZeroAndOne, ugrid->GetPointAdjacentCells(4));
4394 TS_ASSERT_EQUALS(cellOne, ugrid->GetPointAdjacentCells(5));
4395 TS_ASSERT_EQUALS(cellEmpty, ugrid->GetPointAdjacentCells(6));
4397 TS_ASSERT_EQUALS(0, ugrid->GetPointAdjacentCellCount(-1));
4398 TS_ASSERT_EQUALS(1, ugrid->GetPointAdjacentCellCount(0));
4399 TS_ASSERT_EQUALS(2, ugrid->GetPointAdjacentCellCount(1));
4400 TS_ASSERT_EQUALS(1, ugrid->GetPointAdjacentCellCount(2));
4401 TS_ASSERT_EQUALS(1, ugrid->GetPointAdjacentCellCount(3));
4402 TS_ASSERT_EQUALS(2, ugrid->GetPointAdjacentCellCount(4));
4403 TS_ASSERT_EQUALS(1, ugrid->GetPointAdjacentCellCount(5));
4404 TS_ASSERT_EQUALS(0, ugrid->GetPointAdjacentCellCount(6));
4432 for (
int i(0); i < cellsFor2DPoints.size(); i++)
4434 TS_ASSERT_EQUALS(cellsFor2DPoints[i], ugrid2d->GetPointAdjacentCells(i));
4473 for (
int i(0); i < cellsFor3DPoints.size(); i++)
4475 if (cellsFor3DPoints[i] != ugrid3d->GetPointAdjacentCells(i))
4479 TS_ASSERT_EQUALS(cellsFor3DPoints[i], ugrid3d->GetPointAdjacentCells(i));
4491 VecInt2d expectedGetCellPoints = {{0, 3, 4, 1}, {1, 4, 5, 2}, {3, 6, 7, 4}, {4, 7, 8, 5}};
4494 TS_ASSERT(!ugrid->GetCellPoints(-1, cellPoint1D));
4495 TS_ASSERT(!ugrid->GetCellPoints(5, cellPoint1D));
4497 for (
int i(0); i < ugrid->GetCellCount(); i++)
4499 TS_ASSERT(ugrid->GetCellPoints(i, cellPoint1D));
4500 cellPoints.push_back(cellPoint1D);
4501 TS_ASSERT_EQUALS(expectedGetCellPoints[i], cellPoints[i]);
4504 expectedGetCellPoints = {{0, 1, 6, 5}, {1, 2, 7, 6}, {2, 3, 7},
4505 {3, 4, 8, 13, 12, 7}, {7, 11, 10}, {5, 9}};
4510 for (
int i(0); i < ugrid2d->GetCellCount(); i++)
4512 TS_ASSERT(ugrid2d->GetCellPoints(i, cellPoint1D));
4513 cellPoints.push_back(cellPoint1D);
4514 TS_ASSERT_EQUALS(expectedGetCellPoints[i], cellPoints[i]);
4517 expectedGetCellPoints = {{0, 1, 5, 15},
4518 {1, 2, 6, 7, 16, 17, 21, 22},
4519 {2, 3, 8, 7, 17, 18, 23, 22},
4520 {9, 8, 13, 14, 24, 23, 29, 28},
4521 {3, 4, 18, 8, 9, 23},
4522 {5, 6, 11, 10, 20}};
4523 VecInt expectedPointCounts = {4, 8, 8, 8, 6, 5};
4528 for (
int i(0); i < ugrid3d->GetCellCount(); i++)
4530 TS_ASSERT(ugrid3d->GetCellPoints(i, cellPoint1D));
4531 cellPoints.push_back(cellPoint1D);
4532 TS_ASSERT_EQUALS(expectedGetCellPoints[i], cellPoints[i]);
4533 TS_ASSERT_EQUALS(expectedPointCounts[i], ugrid3d->GetCellPointCount(i));
4554 XmEdge edge0(0, 3), edge1(3, 4), edge2(4, 1), edge3(1, 0);
4555 XmEdge edge4(1, 4), edge5(4, 5), edge6(5, 2), edge7(2, 1);
4556 XmEdge edge8(3, 6), edge9(6, 7), edge10(7, 4), edge11(4, 3);
4557 XmEdge edge12(4, 7), edge13(7, 8), edge14(8, 5), edge15(5, 4);
4559 std::vector<std::vector<XmEdge>> expectedCellsCellEdges;
4560 std::vector<XmEdge> emptyVec = {emptyEdge};
4561 std::vector<XmEdge> cellEdges;
4563 cellEdges.push_back(ugrid->GetCellEdge(0, -1));
4564 TS_ASSERT_EQUALS(emptyVec, cellEdges);
4567 cellEdges.push_back(ugrid->GetCellEdge(0, ugrid->GetCellEdgeCount(0)));
4568 TS_ASSERT_EQUALS(emptyVec, cellEdges);
4571 expectedCellsCellEdges = {{edge0, edge1, edge2, edge3},
4572 {edge4, edge5, edge6, edge7},
4573 {edge8, edge9, edge10, edge11},
4574 {edge12, edge13, edge14, edge15}};
4575 for (
int i(0); i < ugrid->GetCellCount(); i++)
4577 for (
int j(0); j < ugrid->GetCellEdgeCount(i); j++)
4579 cellEdges.push_back(ugrid->GetCellEdge(i, j));
4581 TS_ASSERT_EQUALS(expectedCellsCellEdges[i], cellEdges);
4587 XmEdge edge0(0, 1), edge1(1, 6), edge2(6, 5), edge3(5, 0);
4588 XmEdge edge4(1, 2), edge5(2, 7), edge6(7, 6), edge7(6, 1);
4589 XmEdge edge8(2, 3), edge9(3, 7), edge10(7, 2);
4590 XmEdge edge11(3, 4), edge12(4, 8), edge13(8, 13), edge14(13, 12), edge15(12, 7),
4592 XmEdge edge17(7, 11), edge18(11, 10);
4599 std::vector<std::vector<XmEdge>> expectedCellsCellEdges;
4600 expectedCellsCellEdges = {{edge0, edge1, edge2, edge3},
4601 {edge4, edge5, edge6, edge7},
4602 {edge8, edge9, edge10},
4603 {edge11, edge12, edge13, edge14, edge15, edge16},
4606 std::vector<XmEdge> cellEdges;
4607 for (
int i(0); i < ugrid2d->GetCellCount(); i++)
4609 for (
int j(0); j < ugrid2d->GetCellEdgeCount(i); j++)
4611 cellEdges.push_back(ugrid2d->GetCellEdge(i, j));
4613 TS_ASSERT_EQUALS(expectedCellsCellEdges[i], cellEdges);
4626 std::vector<std::vector<XmEdge>> expectedCellsCellEdges =
4628 {{0, 1}, {1, 5}, {5, 0}, {0, 15}, {1, 15}, {5, 15}},
4629 {{1, 2}, {2, 7}, {6, 7}, {1, 6}, {16, 17}, {17, 22}, {21, 22}, {16, 21}, {1, 16}, {2, 17}, {6, 21}, {7, 22}},
4630 {{2, 3}, {3, 8}, {7, 8}, {2, 7}, {17, 18}, {18, 23}, {22, 23}, {17, 22}, {2, 17}, {3, 18}, {7, 22}, {8, 23}},
4631 {{8, 9}, {8, 13}, {8, 23}, {9, 14}, {9, 24}, {13, 14}, {13, 28}, {14, 29}, {23, 24}, {23, 28}, {24, 29}, {28, 29}},
4632 {{3, 4}, {4, 18}, {18, 3}, {8, 9}, {9, 23}, {23, 8}, {3, 8}, {4, 9}, {18, 23}},
4633 {{5, 6}, {6, 11}, {11, 10}, {10, 5}, {5, 20}, {6, 20}, {11, 20}, {10, 20}}
4636 std::vector<XmEdge> cellEdges;
4637 for (
int i(0); i < ugrid3d->GetCellCount(); i++)
4639 for (
int j(0); j < ugrid3d->GetCellEdgeCount(i); j++)
4641 cellEdges.push_back(ugrid3d->GetCellEdge(i, j));
4643 TS_ASSERT_EQUALS(expectedCellsCellEdges[i], cellEdges);
4667 retrievedCells = ugrid->GetPointsAdjacentCells(points);
4668 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4671 retrievedCells = ugrid->GetPointsAdjacentCells(points);
4672 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4675 retrievedCells = ugrid->GetPointsAdjacentCells(points);
4676 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4677 expectedCells.clear();
4679 retrievedCells.clear();
4681 expectedCells = {0, 2};
4683 retrievedCells = ugrid->GetPointsAdjacentCells(points);
4684 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4685 expectedCells.clear();
4687 retrievedCells.clear();
4689 expectedCells = {0};
4691 retrievedCells = ugrid->GetPointsAdjacentCells(points);
4692 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4693 expectedCells.clear();
4695 retrievedCells.clear();
4698 retrievedCells = ugrid->GetPointsAdjacentCells(points);
4699 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4700 expectedCells.clear();
4702 retrievedCells.clear();
4704 points = {ugrid->GetPointCount(), 0};
4705 retrievedCells = ugrid->GetPointsAdjacentCells(points);
4706 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4708 points = {0, ugrid->GetPointCount()};
4709 retrievedCells = ugrid->GetPointsAdjacentCells(points);
4710 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4732 retrievedCells = ugrid->GetCellAdjacentCells(-1);
4733 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4734 retrievedCells = ugrid->GetCellAdjacentCells(0);
4735 expectedCells = {2, 1, 3};
4736 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4737 expectedCells.clear();
4738 retrievedCells = ugrid->GetCellAdjacentCells(4);
4739 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4740 expectedCells.clear();
4741 retrievedCells = ugrid->GetCellAdjacentCells(5);
4742 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4743 expectedCells.clear();
4744 retrievedCells.clear();
4750 expectedCells = {1, 5};
4751 retrievedCells = ugrid2d->GetCellAdjacentCells(0);
4752 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4753 expectedCells = {0, 2, 3, 4};
4754 retrievedCells = ugrid2d->GetCellAdjacentCells(1);
4755 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4756 expectedCells = {1, 3, 4};
4757 retrievedCells = ugrid2d->GetCellAdjacentCells(2);
4758 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4759 expectedCells = {2, 1, 4};
4760 retrievedCells = ugrid2d->GetCellAdjacentCells(3);
4761 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4762 expectedCells = {1, 2, 3};
4763 retrievedCells = ugrid2d->GetCellAdjacentCells(4);
4764 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4765 expectedCells = {0};
4766 retrievedCells = ugrid2d->GetCellAdjacentCells(5);
4767 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4773 expectedCells = {1, 5};
4774 retrievedCells = ugrid3d->GetCellAdjacentCells(0);
4775 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4776 expectedCells = {0, 2, 5};
4777 retrievedCells = ugrid3d->GetCellAdjacentCells(1);
4778 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4779 expectedCells = {1, 4, 3};
4780 retrievedCells = ugrid3d->GetCellAdjacentCells(2);
4781 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4782 expectedCells = {4, 2};
4783 retrievedCells = ugrid3d->GetCellAdjacentCells(3);
4784 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4785 expectedCells = {2, 3};
4786 retrievedCells = ugrid3d->GetCellAdjacentCells(4);
4787 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4788 expectedCells = {0, 1};
4789 retrievedCells = ugrid3d->GetCellAdjacentCells(5);
4790 TS_ASSERT_EQUALS(expectedCells, retrievedCells);
4810 VecInt2d expectedCells = {{}, {2}, {1}, {}};
4811 VecInt expected2dCells = {-1, 2, 1, -1};
4814 VecInt adjacentCells = ugrid->GetCellEdgeAdjacentCells(0, -1);
4815 TS_ASSERT_EQUALS(expectedFail, adjacentCells);
4816 adjacentCell = ugrid->GetCell2dEdgeAdjacentCell(0, -1);
4817 TS_ASSERT_EQUALS(-1, adjacentCell);
4819 for (
int i(0); i < ugrid->GetCellEdgeCount(0); i++)
4821 adjacentCells = ugrid->GetCellEdgeAdjacentCells(0, i);
4822 TS_ASSERT_EQUALS(expectedCells[i], adjacentCells);
4824 adjacentCell = ugrid->GetCell2dEdgeAdjacentCell(0, i);
4825 TS_ASSERT_EQUALS(expected2dCells[i], adjacentCell);
4827 adjacentCells = ugrid->GetCellEdgeAdjacentCells(0, ugrid->GetCellEdgeCount(0));
4828 TS_ASSERT_EQUALS(expectedFail, adjacentCells);
4829 adjacentCell = ugrid->GetCell2dEdgeAdjacentCell(0, ugrid->GetCellEdgeCount(0));
4830 TS_ASSERT_EQUALS(-1, adjacentCell);
4836 expectedCells = {{2, 6, 18}, {6, 7, 23}, {6, 10, 26}, {5, 6, 21},
4837 {18, 34, 38}, {23, 38, 39}, {26, 38, 42}, {21, 37, 38},
4838 {17, 18, 21}, {18, 19, 23}, {21, 26, 25}, {23, 26, 27}};
4840 for (
int i(0); i < hexUgrid->GetCellEdgeCount(22); i++)
4842 adjacentCells = hexUgrid->GetCellEdgeAdjacentCells(22, i);
4843 TS_ASSERT_EQUALS(expectedCells[i], adjacentCells);
4861 VecInt2d expectedCells = {{0, 1}, {0, 2}, {0}};
4862 std::vector<XmEdge> edges = {{1, 4}, {3, 4}, {0, 3}};
4864 VecInt adjacentCells = ugrid->GetEdgeAdjacentCells(
XmEdge(-1, -1));
4865 TS_ASSERT_EQUALS(expectedFail, adjacentCells);
4866 for (
int i(0); i < edges.size(); i++)
4868 adjacentCells = ugrid->GetEdgeAdjacentCells(edges[i]);
4869 TS_ASSERT_EQUALS(expectedCells[i], adjacentCells);
4872 XmEdge badEdge(0, ugrid->GetPointCount());
4873 adjacentCells = ugrid->GetEdgeAdjacentCells(badEdge);
4874 TS_ASSERT_EQUALS(expectedFail, adjacentCells);
4884 VecInt emptyCellFaces = {};
4903 cellFaces = ugrid2d->GetCell3dFacePoints(-1, 0);
4904 TS_ASSERT_EQUALS(emptyCellFaces, cellFaces);
4905 cellFaces = ugrid2d->GetCell3dFacePoints(0, -1);
4906 TS_ASSERT_EQUALS(emptyCellFaces, cellFaces);
4908 for (
int i(0); i < ugrid2d->GetCellCount(); i++)
4910 cellFaces = ugrid2d->GetCell3dFacePoints(i, 0);
4911 TS_ASSERT_EQUALS(expectedCellFaces[i], cellFaces);
4914 cellFaces = ugrid2d->GetCell3dFacePoints(ugrid2d->GetCellCount(), 0);
4915 TS_ASSERT_EQUALS(emptyCellFaces, cellFaces);
4916 cellFaces = ugrid2d->GetCell3dFacePoints(0, 1);
4917 TS_ASSERT_EQUALS(emptyCellFaces, cellFaces);
4923 expectedCellFaces = {
4962 for (
int i(0); i < ugrid3d->GetCellCount(); i++)
4964 for (
int j(0); j < ugrid3d->GetCell3dFaceCount(i); j++, currId++)
4966 cellFaces = ugrid3d->GetCell3dFacePoints(i, j);
4967 TS_ASSERT_EQUALS(expectedCellFaces[currId], cellFaces);
4987 VecInt expectedNeighbor = {-1, -1, -1, 1, -1, -1, -1, -1, 0, -1, -1, -1};
4988 VecInt expectedFace = {-1, -1, -1, 2, -1, -1, -1, -1, 3, -1, -1, -1};
4991 int expectedIdx = 0;
4992 int neighborCellIdx;
4994 neighborCellIdx = grid->GetCell3dFaceAdjacentCell(-1, 0);
4995 TS_ASSERT_EQUALS(-1, neighborCellIdx);
4996 neighborCellIdx = grid->GetCell3dFaceAdjacentCell(0, -1);
4997 TS_ASSERT_EQUALS(-1, neighborCellIdx);
4999 for (
int cellIdx = 0; cellIdx < grid->GetCellCount(); cellIdx++)
5001 for (
int faceIdx = 0; faceIdx < grid->GetCell3dFaceCount(cellIdx); faceIdx++, expectedIdx++)
5004 neighborCellIdx = grid->GetCell3dFaceAdjacentCell(cellIdx, faceIdx);
5005 TS_ASSERT_EQUALS(expectedNeighbor[expectedIdx], neighborCellIdx);
5008 int neighborFaceIdx = -1;
5009 grid->GetCell3dFaceAdjacentCell(cellIdx, faceIdx, neighborCellIdx, neighborFaceIdx);
5010 TS_ASSERT_EQUALS(expectedNeighbor[expectedIdx], neighborCellIdx);
5011 TS_ASSERT_EQUALS(expectedFace[expectedIdx], neighborFaceIdx);
5014 VecInt expectedFacePt = grid->GetCell3dFacePoints(cellIdx, faceIdx);
5015 std::sort(expectedFacePt.begin(), expectedFacePt.end());
5016 VecInt neighborFacePt = grid->GetCell3dFacePoints(neighborCellIdx, neighborFaceIdx);
5017 std::sort(neighborFacePt.begin(), neighborFacePt.end());
5018 if (!expectedFacePt.empty() && !neighborFacePt.empty())
5020 TS_ASSERT_EQUALS(expectedFacePt, neighborFacePt);
5024 neighborCellIdx = grid->GetCell3dFaceAdjacentCell(grid->GetCellCount(), 0);
5025 TS_ASSERT_EQUALS(-1, neighborCellIdx);
5026 neighborCellIdx = grid->GetCell3dFaceAdjacentCell(0, grid->GetCellCount());
5027 TS_ASSERT_EQUALS(-1, neighborCellIdx);
5035 expectedNeighbor.clear();
5037 expectedNeighbor = {-1, 1, -1, 2, -1, 4, 0, -1, -1, 3, -1, 5, -1, 3, 0, -1, -1, 6, 2, -1, 1, -1, -1, 7, -1, 5, -1, 6, 0, -1, 4, -1, -1, 7, 1, -1, -1, 7, 4, -1, 2, -1, 6, -1, 5, -1, 3, -1};
5038 expectedFace = {-1, 0, -1, 2, -1, 4, 1, -1, -1, 2, -1, 4, -1, 0, 3, -1, -1, 4, 1, -1, 3, -1, -1, 4, -1, 0, -1, 2, 5, -1, 1, -1, -1, 2, 5, -1, -1, 0, 3, -1, 5, -1, 1, -1, 3, -1, 5, -1};
5042 for (
int cellIdx = 0; cellIdx < grid->GetCellCount(); ++cellIdx)
5044 for (
int faceIdx = 0; faceIdx < grid->GetCell3dFaceCount(cellIdx); faceIdx++, expectedIdx++)
5047 neighborCellIdx = grid->GetCell3dFaceAdjacentCell(cellIdx, faceIdx);
5048 TS_ASSERT_EQUALS(expectedNeighbor[expectedIdx], neighborCellIdx);
5051 int neighborFaceIdx = -1;
5052 grid->GetCell3dFaceAdjacentCell(cellIdx, faceIdx, neighborCellIdx, neighborFaceIdx);
5053 TS_ASSERT_EQUALS(expectedNeighbor[expectedIdx], neighborCellIdx);
5054 TS_ASSERT_EQUALS(expectedFace[expectedIdx], neighborFaceIdx);
5057 VecInt expectedFacePt = grid->GetCell3dFacePoints(cellIdx, faceIdx);
5058 std::sort(expectedFacePt.begin(), expectedFacePt.end());
5059 VecInt neighborFacePt = grid->GetCell3dFacePoints(neighborCellIdx, neighborFaceIdx);
5060 std::sort(neighborFacePt.begin(), neighborFacePt.end());
5061 if (!expectedFacePt.empty() && !neighborFacePt.empty())
5063 TS_ASSERT_EQUALS(expectedFacePt, neighborFacePt);
5086 grid->GetPointAdjacentPoints(0, attachedIdxs);
5087 VecInt expectedIdxs = {1, 3};
5088 TS_ASSERT_EQUALS(expectedIdxs, attachedIdxs);
5089 grid->GetPointAdjacentPoints(3, attachedIdxs);
5090 expectedIdxs = {0, 4, 6};
5091 TS_ASSERT_EQUALS(expectedIdxs, attachedIdxs);
5092 grid->GetPointAdjacentPoints(4, attachedIdxs);
5093 expectedIdxs = {1, 3, 5, 7};
5094 TS_ASSERT_EQUALS(expectedIdxs, attachedIdxs);
5096 grid->GetPointAdjacentLocations(0, attachedPts);
5097 VecPt3d expectedPts = {{10, 10, 0}, {0, 0, 0}};
5098 TS_ASSERT_EQUALS(expectedPts, attachedPts);
5099 grid->GetPointAdjacentLocations(3, attachedPts);
5100 expectedPts = {{0, 10, 0}, {10, 0, 0}, {0, -10, 0}};
5101 TS_ASSERT_EQUALS(expectedPts, attachedPts);
5102 grid->GetPointAdjacentLocations(4, attachedPts);
5103 expectedPts = {{10, 10, 0}, {0, 0, 0}, {20, 0, 0}, {10, -10, 0}};
5104 TS_ASSERT_EQUALS(expectedPts, attachedPts);
5119 {{0, 0, 0}, {10, 0, 0}, {10, 10, 0}, {0, 10, 0}},
5120 {{10, 0, 0}, {20, 0, 0}, {20, 10, 0}, {10, 10, 0}},
5121 {{20, 0, 0}, {30, 0, 0}, {20, 10, 0}},
5122 {{30, 0, 0}, {40, 0, 0}, {40, 10, 0}, {40, 20, 0}, {30, 20, 0}, {20, 10, 0}},
5128 TS_ASSERT(!grid2d->GetCellPlanViewPolygon(-1, viewPolygon));
5129 TS_ASSERT_EQUALS(empty, viewPolygon);
5130 TS_ASSERT(!grid2d->GetCellPlanViewPolygon(grid2d->GetCellCount(), viewPolygon));
5131 TS_ASSERT_EQUALS(empty, viewPolygon);
5133 for (
int i = 0; i < grid2d->GetCellCount(); ++i)
5136 TS_ASSERT(grid2d->GetCellPlanViewPolygon(i, viewPolygon) != i >= 4);
5137 TS_ASSERT_EQUALS(expectedPolygons[i], viewPolygon);
5144 expectedPolygons = {{{0, 0, 0}, {10, 0, 0}, {0, 10, 0}},
5145 {{20, 0, 0}, {20, 10, 0}, {10, 10, 0}, {10, 0, 0}},
5146 {{30, 0, 0}, {30, 10, 0}, {20, 10, 0}, {20, 0, 0}},
5147 {{40, 10, 0}, {40, 20, 0}, {30, 20, 0}, {30, 10, 0}},
5148 {{30, 0, 0}, {40, 0, 0}, {40, 10, 0}, {30, 10, 0}},
5149 {{0, 10, 0}, {10, 10, 0}, {10, 20, 0}, {0, 20, 0}}};
5151 for (
int i = 0; i < ugrid3d->GetCellCount(); ++i)
5153 TS_ASSERT(ugrid3d->GetCellPlanViewPolygon(i, viewPolygon));
5154 TS_ASSERT_EQUALS(expectedPolygons[i], viewPolygon);
5160 expectedPolygons = {{{0.0, 0.0, 0.0}, {20.0, 10.0, 0.0}, {40.0, 0.0, 0.0}, {20.0, 50.0, 0.0}}};
5161 TS_ASSERT(chevronUgrid->GetCellPlanViewPolygon(0, viewPolygon));
5162 TS_ASSERT_EQUALS(expectedPolygons[0], viewPolygon);
5175 {0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {0, 0, 1}, {1, 0, 1},
5176 {2, 0, 1}, {0, 0, 2}, {2, 0, 2},
5177 {0, 1, 2}, {1, 1, 2}, {2, 1, 2},
5178 {0, 2, 0}, {2, 2, 0}, {0, 2, 2}, {1, 2, 2}, {2, 2, 2},
5179 {4, 2, 0}, {3, 1, 2}
5190 6, 0, 3, 6, 8, 13, 11,
5191 6, 2, 12, 15, 10, 7, 5,
5193 5, 11, 13, 14, 15, 12,
5194 XMU_TETRA, 4, 2, 16, 12, 17
5197 std::shared_ptr<XmUGrid> ugrid3d =
XmUGrid::New(points, cells);
5202 ugrid3d->GetCellPlanViewPolygon(0, cellPoints);
5203 VecPt3d expectedGetCellPoints = {{1, 0, 0}, {2, 0, 0}, {2, 1, 0}, {2, 2, 0},
5204 {1, 2, 0}, {0, 2, 0}, {0, 1, 0}, {0, 0, 0}};
5205 TS_ASSERT_EQUALS(expectedGetCellPoints, cellPoints);
5208 ugrid3d->GetCellPlanViewPolygon(1, cellPoints);
5209 expectedGetCellPoints = {{2, 0, 0}, {4, 2, 0}, {2, 2, 0}};
5210 TS_ASSERT_EQUALS(expectedGetCellPoints, cellPoints);
5229 Pt3d validPt = {5.0, 5.0, 0.0};
5230 Pt3d invalid = {500.0, 500.0, 0.0};
5232 TS_ASSERT(ugrid->IsValidPointChange(4, validPt));
5233 TS_ASSERT(!ugrid->IsValidPointChange(4, invalid));
5237 validPt = ugrid3d->GetPointLocation(21);
5241 TS_ASSERT(ugrid3d->IsValidPointChange(21, validPt));
5242 TS_ASSERT(!ugrid3d->IsValidPointChange(21, invalid));
5244 TS_ASSERT(ugrid->SetPointLocation(4, validPt));
5245 TS_ASSERT(ugrid->SetPointLocation(4, invalid));
5246 TS_ASSERT(ugrid3d->SetPointLocation(21, validPt));
5247 TS_ASSERT(ugrid3d->SetPointLocation(21, invalid));
5260 TS_ASSERT_EQUALS(ugrid->GetPointCount(), 9);
5261 VecPt3d points = {{0, 10, 0}, {10, 10, 0}, {20, 10, 0}, {0, 0, 0}, {10, 0, 0},
5262 {20, 0, 0}, {0, -10, 0}, {10, -10, 0}, {20, -10, 0}};
5265 TS_ASSERT_EQUALS(ugrid->GetLocations(), points);
5266 for (
int i = 0; i < points.size(); ++i)
5268 TS_ASSERT_EQUALS(points[i], ugrid->GetPointLocation(i));
5272 Pt3d invalid = {100, 100, 100};
5273 Pt3d valid = {5, 5, 5};
5274 TS_ASSERT(!ugrid->IsValidPointChange(4, invalid));
5275 TS_ASSERT(ugrid->SetPointLocation(4, valid));
5276 TS_ASSERT_EQUALS(valid, ugrid->GetPointLocation(4));
5278 VecInt pointIndices = {0, 3, 6};
5279 VecPt3d expectedPoints = {{0, 10, 0}, {0, 0, 0}, {0, -10, 0}};
5283 pointsPt3d = ugrid->GetPointsLocations(pointIndices);
5284 TS_ASSERT_EQUALS(expectedPoints, pointsPt3d);
5287 Pt3d min, max, expectedMin = {0, -10, 0}, expectedMax = {20, 10, 5};
5288 ugrid->GetExtents(min, max);
5289 TS_ASSERT_EQUALS(expectedMin, min);
5290 TS_ASSERT_EQUALS(expectedMax, max);
5293 VecInt expectedCells = {0, 2};
5294 VecInt cellsAssociated = ugrid->GetPointAdjacentCells(3);
5295 TS_ASSERT_EQUALS(expectedCells, cellsAssociated);
5298 VecInt expectedCommonCells = {0, 1};
5300 VecInt commonCells = ugrid->GetPointsAdjacentCells(pointIndex);
5301 TS_ASSERT_EQUALS(expectedCells, cellsAssociated);
5316 VecInt pointsOfCell = ugrid->GetCellPoints(0);
5317 VecInt expectedPoints = {0, 3, 4, 1};
5318 TS_ASSERT_EQUALS(expectedPoints, pointsOfCell);
5320 ugrid->GetCellPoints(0, pointsOfCell);
5321 TS_ASSERT_EQUALS(expectedPoints, pointsOfCell);
5323 ugrid->GetCellLocations(0, locations);
5324 VecPt3d expectedLocations = {{0, 10, 0}, {0, 0, 0}, {10, 0, 0}, {10, 10, 0}};
5325 TS_ASSERT_EQUALS(expectedLocations, locations);
5329 ugrid->GetCellExtents(0, min, max);
5330 TS_ASSERT_EQUALS(
Pt3d(0, 0, 0), min);
5331 TS_ASSERT_EQUALS(
Pt3d(10, 10, 0), max);
5334 TS_ASSERT_EQUALS(XMU_QUAD, ugrid->GetCellType(0));
5337 VecInt expectedDimensions = {0, 0, 4, 0};
5338 TS_ASSERT_EQUALS(expectedDimensions, ugrid->GetDimensionCounts());
5341 TS_ASSERT_EQUALS(2, ugrid->GetCellDimension(0));
5345 TS_ASSERT(ugrid->GetCellCentroid(0, centroid));
5346 TS_ASSERT_EQUALS(
Pt3d(5, 5, 0), centroid);
5359 VecInt cellstream = ugrid->GetCellstream();
5360 VecInt expectedCellstream = {XMU_QUAD, 4, 0, 3, 4, 1, XMU_QUAD, 4, 1, 4, 5, 2,
5361 XMU_QUAD, 4, 3, 6, 7, 4, XMU_QUAD, 4, 4, 7, 8, 5};
5362 TS_ASSERT_EQUALS(expectedCellstream, cellstream);
5365 ugrid->GetCellCellstream(0, cellstream);
5366 expectedCellstream = {XMU_QUAD, 4, 0, 3, 4, 1};
5367 TS_ASSERT_EQUALS(expectedCellstream, cellstream);
5386 VecInt2d expectedCells = {{}, {2}, {1}, {}};
5387 VecInt expected2dCells = {-1, 2, 1, -1};
5390 for (
int i(0); i < ugrid->GetCellEdgeCount(0); i++)
5392 adjacentCells = ugrid->GetCellEdgeAdjacentCells(0, i);
5393 TS_ASSERT_EQUALS(expectedCells[i], adjacentCells);
5395 adjacentCell = ugrid->GetCell2dEdgeAdjacentCell(0, i);
5396 TS_ASSERT_EQUALS(expected2dCells[i], adjacentCell);
5400 VecInt2d expectedCellsFromEdge = {{0, 1}, {0, 2}, {0}};
5401 std::vector<XmEdge> edges = {{1, 4}, {3, 4}, {0, 3}};
5402 adjacentCells = ugrid->GetEdgeAdjacentCells(
XmEdge(-1, -1));
5403 for (
int i(0); i < edges.size(); i++)
5405 adjacentCells = ugrid->GetEdgeAdjacentCells(edges[i]);
5406 TS_ASSERT_EQUALS(expectedCellsFromEdge[i], adjacentCells);
5420 std::vector<XmEdge> edges = ugrid->GetCellEdges(0);
5421 std::vector<XmEdge> expectededges = {{0, 3}, {3, 4}, {4, 1}, {1, 0}};
5422 TS_ASSERT_EQUALS(expectededges, edges);
5475 int expectedIdx = 0;
5476 for (
int i(0); i < ugrid3d->GetCellCount(); i++)
5478 for (
int j(0); j < ugrid3d->GetCell3dFaceCount(i); j++, expectedIdx++)
5480 cellFace = ugrid3d->GetCell3dFacePoints(i, j);
5481 TS_ASSERT_EQUALS(expectedCellFaces[expectedIdx], cellFace);
5487 for (
int i(0); i < ugrid3d->GetCellCount(); i++)
5489 cellFaces = ugrid3d->GetCell3dFacesPoints(i);
5490 TS_ASSERT_EQUALS(cellFaces.size(), ugrid3d->GetCell3dFaceCount(i));
5491 for (
int j(0); j < ugrid3d->GetCell3dFaceCount(i); j++, expectedIdx++)
5493 TS_ASSERT_EQUALS(expectedCellFaces[expectedIdx], cellFaces[j]);
5498 for (
int cellIdx = 0; cellIdx < ugrid3d->GetCellCount(); ++cellIdx)
5500 for (
int faceIdx = 0; faceIdx < ugrid3d->GetCell3dFaceCount(cellIdx); ++faceIdx)
5502 faceOrientations.push_back(ugrid3d->GetCell3dFaceOrientation(cellIdx, faceIdx));
5506 VecInt expectedFaceOrientations = {
5508 XMU_ORIENTATION_BOTTOM, XMU_ORIENTATION_TOP, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_BOTTOM,
5510 XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5511 XMU_ORIENTATION_BOTTOM, XMU_ORIENTATION_TOP,
5513 XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5514 XMU_ORIENTATION_BOTTOM, XMU_ORIENTATION_TOP,
5516 XMU_ORIENTATION_BOTTOM, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5517 XMU_ORIENTATION_SIDE, XMU_ORIENTATION_TOP,
5519 XMU_ORIENTATION_BOTTOM, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_BOTTOM, XMU_ORIENTATION_TOP,
5520 XMU_ORIENTATION_SIDE,
5522 XMU_ORIENTATION_BOTTOM, XMU_ORIENTATION_BOTTOM, XMU_ORIENTATION_TOP, XMU_ORIENTATION_TOP,
5523 XMU_ORIENTATION_SIDE};
5525 TS_ASSERT_EQUALS(expectedFaceOrientations, faceOrientations);
5534 TS_ASSERT_EQUALS(XMU_ORIENTATION_SIDE, xmUGrid->GetCell3dFaceOrientation(0, 0));
5535 TS_ASSERT_EQUALS(XMU_ORIENTATION_SIDE, xmUGrid->GetCell3dFaceOrientation(0, 1));
5536 TS_ASSERT_EQUALS(XMU_ORIENTATION_SIDE, xmUGrid->GetCell3dFaceOrientation(0, 2));
5537 TS_ASSERT_EQUALS(XMU_ORIENTATION_SIDE, xmUGrid->GetCell3dFaceOrientation(0, 3));
5538 TS_ASSERT_EQUALS(XMU_ORIENTATION_TOP, xmUGrid->GetCell3dFaceOrientation(0, 4));
5539 TS_ASSERT_EQUALS(XMU_ORIENTATION_BOTTOM, xmUGrid->GetCell3dFaceOrientation(0, 5));
5541 TS_ASSERT_EQUALS(XMU_ORIENTATION_SIDE, xmUGrid->GetCell3dFaceOrientation(0, 0));
5542 TS_ASSERT_EQUALS(XMU_ORIENTATION_SIDE, xmUGrid->GetCell3dFaceOrientation(0, 1));
5543 TS_ASSERT_EQUALS(XMU_ORIENTATION_SIDE, xmUGrid->GetCell3dFaceOrientation(0, 2));
5544 TS_ASSERT_EQUALS(XMU_ORIENTATION_SIDE, xmUGrid->GetCell3dFaceOrientation(0, 3));
5545 TS_ASSERT_EQUALS(XMU_ORIENTATION_TOP, xmUGrid->GetCell3dFaceOrientation(0, 4));
5546 TS_ASSERT_EQUALS(XMU_ORIENTATION_BOTTOM, xmUGrid->GetCell3dFaceOrientation(0, 5));
5558 Pt3d(1620022.8468, 6134363.759, 0),
Pt3d(1620009.9411, 6134414.9476, 0),
5559 Pt3d(1619994.9996, 6134289.4991, 0),
Pt3d(1619866.1047, 6134542.8755, 0),
5560 Pt3d(1619745.5374, 6134167.0467, 0),
Pt3d(1619829.9996, 6134192.9991, 0),
5561 Pt3d(1619773.3077, 6134545.2322, 0),
Pt3d(1619710.0815, 6134182.8542, 0),
5562 Pt3d(1619693.1618, 6134208.2547, 0),
Pt3d(1619645.5529, 6134438.0278, 0),
5563 Pt3d(1619774.9993, 6134371.9982, 0),
Pt3d(1620022.8468, 6134363.759, -10),
5564 Pt3d(1620009.9411, 6134414.9476, -10),
Pt3d(1619994.9996, 6134289.4991, -10),
5565 Pt3d(1619866.1047, 6134542.8755, -10),
Pt3d(1619745.5374, 6134167.0467, -10),
5566 Pt3d(1619829.9996, 6134192.9991, -10),
Pt3d(1619773.3077, 6134545.2322, -10),
5567 Pt3d(1619710.0815, 6134182.8542, -10),
Pt3d(1619693.1618, 6134208.2547, -10),
5568 Pt3d(1619645.5529, 6134438.0278, -10),
Pt3d(1619774.9993, 6134371.9982, -10) };
5572 11, 5, 10, 2, 0, 1, 3, 6, 9, 8, 7, 4,
5573 11, 16, 15, 18, 19, 20, 17, 14, 12, 11, 13, 21,
5588 std::shared_ptr<XmUGrid> xmUGrid =
XmUGrid::New(nodes, elements);
5590 for (
int faceIdx = 0; faceIdx < xmUGrid->GetCell3dFaceCount(0); ++faceIdx)
5592 actual.push_back(xmUGrid->GetCell3dFaceOrientation(0, faceIdx));
5594 VecInt expected = {XMU_ORIENTATION_TOP, XMU_ORIENTATION_BOTTOM, XMU_ORIENTATION_SIDE,
5595 XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5596 XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5597 XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5598 XMU_ORIENTATION_SIDE};
5599 TS_ASSERT_EQUALS(expected, actual);
5608 VecInt2d expectedNeighbors = {{-1, 1, -1, -1, -1, -1}, {0, -1, -1, -1, -1, -1}};
5610 {XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5611 XMU_ORIENTATION_TOP, XMU_ORIENTATION_BOTTOM},
5612 {XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5613 XMU_ORIENTATION_TOP, XMU_ORIENTATION_BOTTOM}};
5617 bool useCacheValues[] = {
true,
true,
false,
true};
5618 for (
bool useCacheValue : useCacheValues)
5620 xmUGrid->SetUseCache(useCacheValue);
5621 for (
int cellIdx = 0; cellIdx < xmUGrid->GetCellCount(); ++cellIdx)
5623 TS_ASSERT_EQUALS(6, xmUGrid->GetCell3dFaceCount(cellIdx));
5624 for (
int faceIdx = 0; faceIdx < xmUGrid->GetCell3dFaceCount(cellIdx); ++faceIdx)
5626 int neighbor = xmUGrid->GetCell3dFaceAdjacentCell(cellIdx, faceIdx);
5627 TS_ASSERT_EQUALS(expectedNeighbors[cellIdx][faceIdx], neighbor);
5628 int orientation = (int)xmUGrid->GetCell3dFaceOrientation(cellIdx, faceIdx);
5629 TS_ASSERT_EQUALS(expectedOrientations[cellIdx][faceIdx], orientation);
5635 expectedNeighbors = {{-1, 1, -1, -1, -1, -1}, {0, 2, -1, -1, -1, -1}, {1, -1, -1, -1, -1, -1}};
5636 expectedOrientations = {{XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5637 XMU_ORIENTATION_SIDE, XMU_ORIENTATION_TOP, XMU_ORIENTATION_BOTTOM},
5638 {XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5639 XMU_ORIENTATION_SIDE, XMU_ORIENTATION_TOP, XMU_ORIENTATION_BOTTOM},
5640 {XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE, XMU_ORIENTATION_SIDE,
5641 XMU_ORIENTATION_SIDE, XMU_ORIENTATION_TOP, XMU_ORIENTATION_BOTTOM}};
5643 xmUGrid->SetLocations(newXmUGrid->GetLocations());
5644 xmUGrid->SetCellstream(newXmUGrid->GetCellstream());
5645 for (
bool useCacheValue : useCacheValues)
5647 xmUGrid->SetUseCache(useCacheValue);
5648 for (
int cellIdx = 0; cellIdx < xmUGrid->GetCellCount(); ++cellIdx)
5650 TS_ASSERT_EQUALS(6, xmUGrid->GetCell3dFaceCount(cellIdx));
5651 for (
int faceIdx = 0; faceIdx < xmUGrid->GetCell3dFaceCount(cellIdx); ++faceIdx)
5653 int neighbor = xmUGrid->GetCell3dFaceAdjacentCell(cellIdx, faceIdx);
5654 TS_ASSERT_EQUALS(expectedNeighbors[cellIdx][faceIdx], neighbor);
5655 int orientation = (int)xmUGrid->GetCell3dFaceOrientation(cellIdx, faceIdx);
5656 TS_ASSERT_EQUALS(expectedOrientations[cellIdx][faceIdx], orientation);
5666 #include <boost/timer/timer.hpp> 5680 boost::timer::cpu_timer timer;
5681 std::shared_ptr<XmUGrid> ugrid =
XmUGrid::New(grid->GetLocations(), grid->GetCellstream());
5682 std::cerr << timer.format() <<
'\n';
Cached value needs to be calculated.
void testUGridStreams()
[snip_test_UGrid_Streams]
std::shared_ptr< XmUGrid > TEST_XmUGrid1Left90Tri()
Builds a 1 cell (left 90 degree triangle) 2D XmUGrid for testing.
VecInt GetCellEdgeAdjacentCells(int a_cellIdx, int a_edgeIdx) const
Get the index of the adjacent cells (that shares the same cell edge)
bool gmOnLineWithTol(const Pt3d &p1, const Pt3d &p2, const double x, const double y, const double tol)
Determines if a point (x,y) is on the line defined by p1 and p2. Assumes p1 and p2 aren't the same...
std::shared_ptr< XmUGrid > TEST_XmUGrid3dLinear()
Builds an XmUGrid with supported 3D linear cells for testing.
void SetLocations(const VecPt3d &a_locations)
Set UGrid points.
int GetPointAdjacentCellCount(int a_pointIdx) const
Get the number of cells that use a point.
VecInt GetCellAdjacentCells(int a_cellIdx) const
Get the cells neighboring a cell (cells associated with any of it's points)
bool SetCellstream(const VecInt &a_cellstream)
Set the ugrid cells for the entire UGrid using a cell stream.
bool GetCellCentroid(int a_cellIdx, Pt3d &a_centroid) const
Get the centroid location of a cell.
Pt3d GetPointXy0(int a_pointIdx) const
Get the X, Y location of a point.
XmEdge GetCellEdge(int a_cellIdx, int a_edgeIdx) const
Get the points of a cell.
Contains the XmUGrid Class and supporting data types.
std::shared_ptr< xms::XmUGrid > TEST_XmUBuildHexahedronUgrid(int a_rows, int a_cols, int a_lays)
Builds a UGrid of Quads at 1 spacing for rows & cols specified.
void testCellEdges()
Test various cell functions.
void testGetPointAdjacentCellsSimple()
Test getting the cells attached to points.
Implementation for XmUGrid.
std::vector< int > VecInt
int GetCellDimension(int a_cellIdx) const
Get the dimension of the specified cell.
void testGetCellPlanViewPolygonMultiSideFace()
[snip_test_GetCellPlanViewPolygon]
int GetCell3dFacePointCount(int a_cellIdx, int a_faceIdx) const
Get the number of face points for a given cell and face.
VecInt m_faceOrientation
For vertically prismatic cell is face top, side, bottom.
bool DoEdgesCrossWithPointChange(int a_changedPtIdx, const Pt3d &a_newPosition, const std::vector< XmEdge > &a_edges) const
Gets whether or not edges cross with a point change.
XmUGrid & operator=(XmUGrid a_xmUGrid)
Assignment operator.
int GetCellEdgeCount(int a_cellIdx) const
Get the number of edges for a cell.
void testGetPointAdjacentPoints()
[snip_test_GetCell3dFaceAdjacentCell]
int GetCell2dEdgeAdjacentCell(int a_cellIdx, int a_edgeIdx) const
Get the index of the adjacent cells (that shares the same cell edge)
Pt3d GetPointXy0(int a_pointIdx) const
Get the X, Y location of a point.
VecInt2d GetCell3dFacesPoints(int a_cellIdx) const
Get the faces of a cell.
void testGetCell3dFaceOrientationHexahedrons()
[snip_test_Cell3dFaceFunctions]
static void GetUniquePointsFromPolyhedronCellstream(const VecInt &a_cellstream, int a_numCellItems, int &a_currIdx, VecInt &a_uniqueGetCellPoints, VecInt &a_pointLastUsedIdx)
Get the unique points in a flat set.
bool SetCellstream(const VecInt &a_cellstream)
Set the ugrid cells for the entire UGrid using a cell stream.
Pt3d GetPointLocation(int a_pointIdx) const
Get the point.
std::shared_ptr< xms::XmUGrid > TEST_XmUBuildPolyhedronUgrid(int a_rows, int a_cols, int a_lays)
Builds a UGrid of Quads at 1 spacing for rows & cols specified.
XmUGridCellType
Matches cell types from VTK (see vtkCellType.h)
Impl & operator=(const Impl &a_xmUGrid)=default
Default ssignment operator.
void testGetPointAdjacentCells()
Test getting cells adjacent to a point.
std::shared_ptr< XmUGrid > TEST_XmUGridSimpleQuad()
Builds a 2 cell (Quad) 2D XmUGrid for testing.
VecInt GetPointsAdjacentCells(const VecInt &a_points) const
Gets the common cells from a vector of points.
void testGetCellType()
Test getting number of points, cells, and cell type.
XmUGridCellType GetCellType(int a_cellIdx) const
Get the cell type of a specified cell.
void testGetCellPoints()
Test getting a vector of point indices for a cell.
void GetExtents(Pt3d &a_min, Pt3d &a_max) const
Get extents of all points in UGrid.
bool IsValidPointChange(int a_changedPtIdx, const Pt3d &a_newPosition) const
Determine whether adjacent cells are valid after a point is moved.
Pt3d GetPointLocation(int a_pointIdx) const
Get the point.
int GetCell3dFaceAdjacentCell(int a_cellIdx, int a_faceIdx) const
Get the cell face neighbors for given cell and face index.
const VecPt3d & GetLocations() const
Get vector of UGrid points.
int GetCell3dFaceCount(int a_cellIdx) const
Get the number of cell faces for given cell.
const VecInt & GetCellstream() const
Get cell stream vector for the entire UGrid.
bool IsValidCellIdx(int a_cellIdx) const
Determine if a cell index is valid.
bool GetCellXySegments(int cellIdx, VecPt3d &a_segments) const
Get the XY segments of a cell.
bool IsValidPointChange(int a_changedPtIdx, const Pt3d &a_newPosition) const
Determine whether adjacent cells are valid after a point is moved.
int GetCellDimension(int a_cellIdx) const
Get the dimension of the specified cell.
std::shared_ptr< XmUGrid > TEST_XmUGrid2dLinear()
Builds an XmUGrid with supported 1D and 2D linear cells for testing.
void gmGetConvexHull(const VecPt3d &a_pts, VecPt3d &a_hull, bool a_includeOn)
Calculate convex hull using Monotone chain aka Andrew's algorithm.
int GetSecond() const
Get the second index.
bool SetPointLocation(int a_pointIdx, const Pt3d &a_location)
Set the point.
bool m_useCache
Are we using caching for some calls?
#define XM_ENSURE_TRUE_NO_ASSERT(...)
static bool GetUniquePointsFromPolyhedronSingleCellstream(const VecInt &a_cellstream, VecInt &a_cellPoints)
Get the unique points for cell stream of a single polyhedron cell.
std::unique_ptr< Impl > m_impl
implementation
VecInt GetCellAdjacentCells(int a_cellIdx) const
Get the cells neighboring a cell (cells associated with any of it's points)
void GetExtentsFromPoints(const VecPt3d &a_locations, Pt3d &a_min, Pt3d &a_max) const
Function to get the extents from a list of points. Will be removed after geometry library is built...
bool IsSideFace(int a_cellIdx, int a_faceIdx) const
Determines if a cell face is a vertical side face.
int GetCellEdgeCount(int a_cellIdx) const
Get the number of edges for a cell.
Code to calculate the convex hull of a set of points in two dimensions.
void SetUseCache(bool a_useCache)
Turn on or off use of caching to speed up some operations.
void testGetCellAdjacentCells()
[snip_test_GetCellAdjacentCells]
void GetCellExtents(int a_cellIdx, Pt3d &a_min, Pt3d &a_max) const
Get the extents of the given cell.
void Swap(XmUGrid &a_xmUGrid)
Swap data between two XmUGrids.
void testGetSetPoint()
[snip_test_UGrid_Streams]
int GetCellCount() const
Get the number of cells.
void testCellstreamFunctions()
Test various cell functions.
bool IsEquivalent(const XmEdge &a_edge) const
Test if edge is the same ignoring direction.
VecInt m_faceNeighbor
Cache for Face neighbor.
void UpdateLinks()
Update internal links to navigate between associated points and cells.
void testGetCell3dFacePoints()
Test retrieving Cell Face.
VecInt GetPointAdjacentCells(int a_pointIdx) const
Get the cells that are associated with the specified point.
double gmPolygonArea(const Pt3d *pts, size_t npoints)
Compute 2d planview projection of area of polygon.
int GetCell3dFaceCount(int a_cellIdx) const
Get the number of cell faces for given cell.
int GetPointCount() const
Get the number of points.
VecInt m_cellDimensionCounts
Cache for cell dimension counts.
std::vector< VecInt > VecInt2d
void SetUnmodified()
Resets the modified flag to false.
VecInt GetCellEdgeAdjacentCells(int a_cellIdx, int a_edgeIdx) const
Get the index of the adjacent cells (that shares the same cell edge)
bool IsFaceSide(const VecInt &a_facePts) const
Get whether the cell face is of a side orientation. Only works for plan view prismatic cells...
bool m_modified
Has UGrid been modified since last SetUnmodified call?
void testGetCellEdge()
Test iterating through the edges of cells.
VecInt m_cellIdxToStreamIdx
Indexes for each cell in the cell stream.
VecPt3d m_locations
UGrid point locations.
Functions dealing with geometry.
std::vector< XmEdge > GetCellEdges(int a_cellIdx) const
Get the Edges of a cell.
bool GetCellCellstream(int a_cellIdx, VecInt &a_cellstream) const
Get cell stream vector for a single cell.
void testCellFunctions()
[snip_test_PointFunctions]
bool IsCellValidWithPointChange(int a_cellIdx, int a_changedPtIdx, const Pt3d &a_newPosition) const
Determine whether a cell is valid after a point is moved.
std::vector< int > GetDimensionCounts() const
Count all number of the cells with each dimenion (0, 1, 2, 3)
VecInt GetPointsAdjacentCells(const VecInt &a_points) const
Gets the common cells from a vector of points.
void testCell3dFaceFunctions()
Test various get face functions.
bool GetCellCentroid(int a_cellIdx, Pt3d &a_centroid) const
Get the centroid location of a cell.
std::shared_ptr< XmUGrid > TEST_XmUGridHexagonalPolyhedron()
Builds a 1 cell hexagon with cell type polyhedron.
void testGetExtents()
Test getting the extents of a UGrid.
void GetCellExtents(int a_cellIdx, Pt3d &a_min, Pt3d &a_max) const
Get the extents of the given cell.
bool GetModified() const
Returns the modified flag. Gets set when points or cells get changed.
void GetPointAdjacentLocations(int a_pointIdx, VecPt3d &a_edgePoints) const
Given a point gets point locations attached to the point by an edge.
VecInt m_cellFaceOffset
Cache for offset to m_faceOrientation and m_faceNeighbor.
int GetCellPointCount(int a_cellIdx) const
Get the number of cell points (including polyhedron).
void GetEdgesOfFace(const VecInt &a_face, std::vector< XmEdge > &a_edges) const
Get the edges of a cell given a face.
void testOperators()
Test constructors and assignment operator.
Impl()=default
Default constructor.
VecInt GetCell3dFacePoints(int a_cellIdx, int a_faceIdx) const
Get the cell face for given cell and face index.
XmUGridFaceOrientation FaceOrientation(int a_cellIdx, int a_faceIdx) const
Find the orientation of a given 3D cell face.
VecInt GetPointAdjacentCells(int a_pointIdx) const
Get the cells that are associated with the specified point.
bool GetCellPlanViewPolygon(int a_cellIdx, VecPt3d &a_polygon) const
Get a plan view polygon of a specified cell.
bool GetModified() const
Returns the modified flag. Gets set when points or cells get changed.
void UpdateCellLinks()
Update internal link from cells to cell stream index.
VecInt m_numberOfFaces
Cache for number of cell faces.
void testGetCellCellstream()
Test Getting a cell stream.
VecInt GetCellPoints(int a_cellIdx) const
Get the points of a cell (including polyhedron)
void GetCellLocations(int a_cellIdx, VecPt3d &a_cellLocations) const
Get locations of cell points.
static int DimensionFromCellType(XmUGridCellType a_cellType)
Get the dimension given the cell type (0d, 1d, 2d, or 3d).
XmEdge GetCellEdge(int a_cellIdx, int a_edgeIdx) const
Get the points of a cell.
void GetPointAdjacentPoints(int a_pointIdx, VecInt &a_edgePoints) const
Given a point gets point indices attached to the point by an edge.
VecInt m_cellstream
UGrid cell stream.
void testGetCell3dFaceAdjacentCell()
[snip_test_GetCell3dFaceAdjacentCell]
int GetNumberOfPolyhedronEdges(int a_cellIdx) const
Get the number of edges for a polyhedron cell.
std::shared_ptr< xms::XmUGrid > TEST_XmUBuildQuadUGrid(int a_rows, int a_cols)
Builds a UGrid of Quads at 1 spacing for rows & cols specified.
Two integer values representing an edge of an XmUGrid. By default has a direction. Can be sorted to have minimum index first.
Geometry for an unstructured grid. An XmUGrid is defined as a vector of 3d points and a stream of cel...
void UpdatePointLinks()
Update internal links from points to associated cells.
XmUGridCacheHolder
Constant for when a cached integer item needs to be calculated.
XmUGridFaceOrientation
The orientation of a 3D face must be one of these.
void GetCellLocations(int a_cellIdx, VecPt3d &a_cellLocations) const
Get locations of cell points.
std::shared_ptr< xms::XmUGrid > TEST_XmUBuild3DChevronUgrid()
Builds a UGrid with one 3D Chevron polyhedron.
XmUGridFaceOrientation GetCell3dFaceOrientationNoCache(int a_cellIdx, int a_faceIdx) const
Get the orientation of the face of a vertically prismatic cell.
void SetUseCache(bool a_useCache)
Turn on or off use of caching.
void testCell3dFunctionCaching()
Test caching to speed up a few 3D cell getters.
void GetExtents(Pt3d &a_min, Pt3d &a_max) const
Get extents of all points in UGrid.
void SetLocations(const VecPt3d &a_locations)
Set UGrid points.
bool GetCellPlanViewPolygon(int a_cellIdx, VecPt3d &a_polygon) const
Get a plan view polygon of a specified cell.
static bool IsValidCellstream(const VecInt &a_cellstream)
Check a cell stream to make sure it's valid. Compares cell type against expected number of points...
std::vector< int > GetDimensionCounts() const
Count all number of the cells with each dimension (0, 1, 2, 3)
int GetPointAdjacentCellCount(int a_pointIdx) const
Get the number of cells that use a point.
XmUGridFaceOrientation GetCell3dFaceOrientation(int a_cellIdx, int a_faceIdx) const
Get the orientation of the face of a vertically prismatic cell.
XmUGridFaceOrientation VerticalOrientationFromOpposing(int a_cellIdx, int a_faceIdx) const
Find vertical orientation of a given 3D cell face from opposing face.
const VecInt & GetCellstream() const
Get cell stream vector for the entire UGrid. A cellstream is defined as follows: Polyhedrons: Cell ty...
void GetFacePointSegments(const VecInt &a_facePts, int a_columnBegin, int a_columnEnd, VecPt3d &a_segments) const
Get plan view segments of face points.
std::vector< VecPt3d > VecPt3d2d
VecInt GetCellPoints(int a_cellIdx) const
Get the points of a cell (including polyhedron)
static void GetUniqueEdgesFromPolyhedronCellstream(const int *a_start, int &a_length, boost::container::flat_set< XmEdge > &a_cellEdges, int &a_currIdx)
Get the unique edges in a flat set for a given polyhedron.
int GetCell3dFaceCountNoCache(int a_cellIdx) const
Get the number of cell faces for given cell.
bool gmLinesCross(const Pt3d &a_segment1Point1, const Pt3d &a_segment1Point2, const Pt3d &a_segment2Point1, const Pt3d &a_segment2Point2)
Determine whether 2 line segments cross. The segments may touch at the end points.
int GetNumberOfItemsForCell(int a_cellIdx) const
Get number of items given cell. For polyhedron number of items is number of faces. For other cell types it is number of points.
bool GetFaceXySegments(int a_cellIdx, int a_faceIdx, VecPt3d &a_segments) const
Get the Xy locations of Face Points.
bool GetPlanViewPolygon3d(int a_cellIdx, VecPt3d &a_polygon) const
Get a plan view polygon of a specified 3D cell.
VecInt GetCell3dFacePoints(int a_cellIdx, int a_faceIdx) const
Get the cell face for given cell and face index.
void ClearCacheValues()
Clear cached so they will be recalculated.
void gmAddToExtents(const Pt3d &a_pt, Pt3d &a_min, Pt3d &a_max)
Compares a_pt to a_min and a_max. If a_pt is less than a_min or greater than a_max, a_min and a_max are updated.
void testGetCell3dFaceCount()
[snip_test_GetNumberOfCellFaces]
int GetCell2dEdgeAdjacentCell(int a_cellIdx, int a_edgeIdx) const
Get the index of the adjacent cells (that shares the same cell edge)
void testEdgeAdjacentCells()
Test retrieving Adjacent Cell.
void testGetCellEdgeAdjacentCells()
[snip_test_GetCellAdjacentCells]
bool GetPlanViewPolygon2d(int a_cellIdx, VecPt3d &a_polygon) const
Get a plan view polygon of a specified 2D cell.
void GetEdgeAdjacentCells(const XmEdge &a_edge, VecInt &a_adjacentCellIdxs) const
Get the indices of the adjacent cells (that shares the same cell edge)
VecInt m_pointIdxToPointsToCells
XmUGridFaceOrientation ConnectedTopOrBottom(int a_cellIdx, int a_faceIdx) const
Determine face orientation by using cell index of connected face. Top face is connected to lower inde...
XmUGridFaceOrientation GetCell3dFaceOrientation(int a_cellIdx, int a_faceIdx) const
Get the orientation of the face of a vertically prismatic cell.
int GetCellPointCount(int a_cellIdx) const
Get the number of cell points (including polyhedron).
void testGetCellDimension()
Test getting dimension of single cells and all cells.
void GetPointAdjacentLocations(int a_pointIdx, VecPt3d &a_edgePoints) const
Given a point gets point locations attached to the point by an edge.
void testGetCell3dFaceOrientationConcaveCell()
Test face orientation for concave cell where a triangle from the first two points in the top face to ...
void testPointFunctions()
[snip_test_PointFunctions]
void testLargeUGridLinkSpeed()
Tests creating a large UGrid and checks the time spent.
void testCellEdgeAdjacentCellFunctions()
Test all get adjacent cell functions.
std::vector< edgerecord > VecEdge
Vector of edgerecord.
void SetUnmodified()
Resets the modified flag to false.
XmUGridFaceOrientation FaceOrientationWithFail(int a_cellIdx, int a_faceIdx) const
Find the orientation of a given 3D cell face. Check first for side face, then top or bottom based on ...
VecInt2d GetCell3dFacesPoints(int a_cellIdx) const
Get the faces of a cell.
XmUGridFaceOrientation GetOrientationFromArea(int a_cellIdx, int a_faceIdx) const
Determine top or bottom face orientation using area. Since faces are ordered CCW looking in...
int GetCell3dFaceAdjacentCell(int a_cellIdx, int a_faceIdx) const
Get the cell face neighbors for given cell and face index.
void testGetPointsAdjacentCells()
Test retrieving common cells from points.
int GetCell3dFaceAdjacentCellNoCache(int a_cellIdx, int a_faceIdx) const
Get the cell face neighbors for given cell and face index.
XmUGridCellType GetCellType(int a_cellIdx) const
Get the number of cells.
int GetPointCount() const
Get the number of points.
void testGetCell3dFacePointCount()
[snip_test_GetNumberOfCellFaces]
static std::shared_ptr< XmUGrid > New()
Create a new XmUGrid.
VecPt3d GetPointsLocations(const VecInt &a_points) const
Convert a vector of point indices into a vector of point 3d.
const VecPt3d & GetLocations() const
Get vector of UGrid points.
bool GetNextFaceColumn(const VecInt &a_facePoints, int a_starti, int &a_columnBegin, int &a_columnEnd) const
Get next vertical column of points with equal x/y values for side face.
void GetPointAdjacentPoints(int a_pointIdx, VecInt &a_edgePoints) const
Given a point gets point indices attached to the point by an edge.
bool SetPointLocation(int a_pointIdx, const Pt3d &a_location)
Set the point.
std::vector< XmEdge > GetCellEdges(int a_cellIdx) const
Get the Edges of a cell.
Pt3d gmComputePolygonCentroid(const VecPt3d &pts)
Computes the plan view centroid of a non-self-intersecting polygon.
void SetModified()
Sets the modified flag to true.
void CalculateCacheValues() const
Calculate cached values for faster lookup.
void GetEdgeAdjacentCells(const XmEdge &a_edge, VecInt &a_adjacentCellIdxs) const
Get the indices of the adjacent cells (that shares the same cell edge)
VecPt3d GetPointsLocations(const VecInt &a_points) const
Convert a vector of point indices into a vector of point 3d.
int GetCellCount() const
Get the number of cells.
int GetFirst() const
Get the first index.
void testGetCellEdgeCount()
Test getting edges of single cells.
int GetCell3dFacePointCount(int a_cellIdx, int a_faceIdx) const
Get the number of face points for a given cell and face.
bool GetCellCellstream(int a_cellIdx, VecInt &a_cellstream) const
Get cell stream vector for a single cell.
void testGetCellPlanViewPolygon()
[snip_test_GetPointAdjacentPoints]
std::vector< Pt3d > VecPt3d
void testIsCellValidWithPointChange()
Test validating a cell for a changed point.