17 #if defined(OPENNURBS_INC_IN_PROGRESS) 23 #error Please read the comment above this line. 26 #if defined(ON_COMPILING_OPENNURBS) 27 #if !defined(OPENNURBS_SUBD_UNSTABLE_CORE_AVAIALABLE) 28 #define OPENNURBS_SUBD_UNSTABLE_CORE_AVAIALABLE 33 #if !defined(OPENNURBS_SUBD_UNSTABLE_CORE_AVAIALABLE) 43 #error Please read the comment above this line. 46 #if !defined(OPENNURBS_SUBD_DATA_INC_) 47 #define OPENNURBS_SUBD_DATA_INC_ 49 #if defined(OPENNURBS_SUBD_WIP) 56 class ON_CLASS ON_SubDFaceNeighborhood
59 ON_SubDFaceNeighborhood() =
default;
60 ~ON_SubDFaceNeighborhood();
63 const ON_SubDFace* m_face0 =
nullptr;
66 ON_SubD::SubDType m_subd_type = ON_SubD::SubDType::Unset;
77 const ON_SubDVertex* m_center_vertex1 =
nullptr;
86 unsigned int m_face1_count = 0;
87 const class ON_SubDFace** m_face1 =
nullptr;
103 ON_SubD::SubDType subd_type,
104 const ON_SubDFace* face
108 bool TriSubdivideHelper(
109 const ON_SubDFace* face
112 bool QuadSubdivideHelper(
113 const ON_SubDFace* face
116 bool ReserveCapacity(
117 ON_SubD::SubDType subd_type,
118 const ON_SubDFace* face
121 ON_SubD_FixedSizeHeap m_fsh;
129 class ON_CLASS ON_SubDQuadNeighborhood
132 ON_SubDQuadNeighborhood() =
default;
133 ~ON_SubDQuadNeighborhood();
135 void Internal_Destroy(
bool bReinitialize);
138 ON_SubDQuadNeighborhood(
const ON_SubDQuadNeighborhood&) =
delete;
139 ON_SubDQuadNeighborhood& operator=(
const ON_SubDQuadNeighborhood&) =
delete;
144 bool m_bIsCubicPatch =
false;
145 unsigned char m_initial_subdivision_level = 0;
146 unsigned char m_current_subdivision_level = 0;
151 unsigned char m_extraordinary_corner_vertex_count = 0;
154 bool m_bExtraordinaryCornerVertex[4];
158 unsigned char m_exact_quadrant_patch_count = 0;
159 bool m_bExactQuadrantPatch[4];
163 unsigned char m_boundary_crease_count = 0;
164 bool m_bBoundaryCrease[4];
167 unsigned short m_reserved2 = 0;
170 const ON_SubDVertex* m_vertex_grid[4][4];
172 const ON_SubDEdge* m_edge_grid[4][2];
183 const ON_SubDFace* m_face_grid[3][3];
190 const ON_SubDEdge* m_center_edges[4];
193 class ON_SubD_FixedSizeHeap* m_fsh =
nullptr;
196 double m_srf_cv1[5][5][3];
202 const ON_SubDFace* CenterQuad()
const;
204 const ON_SubDVertex* CenterVertex(
220 const ON_SubDFace* SideFace(
236 const ON_SubDFace* CornerFace(
241 const ON_SubDFace* center_quad_face
255 ON_SubDQuadNeighborhood* subd_quad_nbd,
256 bool bRetainFixedSizeHeap
259 bool IsValid()
const;
263 return (
nullptr != m_face_grid[1][1]);
270 bool GetLimitSurfaceCV(
273 unsigned int srf_cv_grid_size
282 bool GetLimitSubSurfaceSinglePatchCV(
284 double srf_cv[4][4][3]
315 unsigned int GetLimitSubSurfaceMultiPatchCV(
317 bool bEnableApproximatePatch,
318 double srf_cv[5][5][3],
319 ON_SubDLimitPatchFragment::PatchType patch_type[4]
323 unsigned int SetLimitSubSurfaceExactCVs(
324 unsigned int quadrant_index
340 bool GetApproximateCV(
344 double approximate_cv[3]
351 const unsigned int fvi0
355 bool VertexGridIsExactCubicPatch(
356 const ON_2dex min_face_grid_dex,
357 const ON_2dex max_face_grid_dex,
358 unsigned int boundary_corner_index
369 const unsigned int q0fvi,
370 ON_SubD_FixedSizeHeap& fsh,
371 class ON_SubDQuadNeighborhood* q1ft
374 static ON_2dex GridDex(
375 unsigned int grid_size,
376 unsigned int corner_index,
381 static ON_2dex DeltaDex(
382 unsigned int corner_index,
387 static bool GetSubdivisionPoint(
388 const ON_SubDVertex* vertex,
392 static bool GetLimitPoint(
393 const ON_SubDVertex* vertex,
398 static bool GetSubdivisionPoint(
399 const ON_SubDEdge* edge,
403 static bool GetSubdivisionPoint(
404 const ON_SubDFace* face,
409 #if defined(ON_COMPILING_OPENNURBS) 429 void ON_SubDIncrementErrorCount();
430 #define ON_SUBD_RETURN_ERROR(rc) (ON_SubDIncrementErrorCount(),rc) 431 #define ON_SUBD_ERROR(msg) (ON_SubDIncrementErrorCount(),ON_ERROR(msg)) 444 #define ON_SUBD_ELEMENT_MARK_MASK (0x1U) 445 #define ON_SUBD_ELEMENT_TYPE_MASK (0x6U) 446 #define ON_SUBD_ELEMENT_FLAGS_MASK (0x7U) 447 #if (8 == ON_SIZEOF_POINTER) 448 #define ON_SUBD_ELEMENT_POINTER_MASK (0xFFFFFFFFFFFFFFF8ULL) 450 #define ON_SUBD_ELEMENT_POINTER_MASK (0xFFFFFFF8U) 453 #define ON_SUBD_ELEMENT_TYPE_VERTEX (0x2U) 454 #define ON_SUBD_ELEMENT_TYPE_EDGE (0x4U) 455 #define ON_SUBD_ELEMENT_TYPE_FACE (0x6U) 457 #define ON_SUBD_ELEMENT_POINTER(p) ((void*)((p) & ON_SUBD_ELEMENT_POINTER_MASK)) 458 #define ON_SUBD_ELEMENT_MARK(p) ((p) & ON_SUBD_ELEMENT_MARK_MASK) 459 #define ON_SUBD_ELEMENT_TYPE(p) ((p) & ON_SUBD_ELEMENT_TYPE_MASK) 460 #define ON_SUBD_ELEMENT_FLAGS(p) ((p) & ON_SUBD_ELEMENT_FLAGS_MASK) 462 #define ON_SUBD_VERTEX_POINTER(p) ((class ON_SubDVertex*)ON_SUBD_ELEMENT_POINTER(p)) 463 #define ON_SUBD_VERTEX_MARK(p) ON_SUBD_ELEMENT_MARK(p) 465 #define ON_SUBD_EDGE_POINTER(p) ((class ON_SubDEdge*)ON_SUBD_ELEMENT_POINTER(p)) 466 #define ON_SUBD_FACE_POINTER(p) ((class ON_SubDFace*)ON_SUBD_ELEMENT_POINTER(p)) 468 #define ON_SUBD_EDGE_DIRECTION(p) ON_SUBD_ELEMENT_MARK(p) 469 #define ON_SUBD_FACE_DIRECTION(p) ON_SUBD_ELEMENT_MARK(p) 476 #define ON_SUBD_CACHE_TYPE_MASK (0x1FU) 478 #define ON_SUBD_CACHE_POINT_FLAG_MASK (0x20U) 479 #define ON_SUBD_CACHE_DISPLACEMENT_FLAG_MASK (0x40U) 480 #define ON_SUBD_CACHE_LIMIT_FLAG_MASK (0x80U) 481 #define ON_SUBD_CACHE_FLAGS_MASK (ON_SUBD_CACHE_POINT_FLAG_MASK|ON_SUBD_CACHE_DISPLACEMENT_FLAG_MASK|ON_SUBD_CACHE_LIMIT_FLAG_MASK) 483 #define ON_SUBD_CACHE_TYPE(cache_subd_flags) (ON_SUBD_CACHE_TYPE_MASK&(cache_subd_flags)) 484 #define ON_SUBD_CACHE_FLAGS(cache_subd_flags) (ON_SUBD_CACHE_FLAGS_MASK&(cache_subd_flags)) 485 #define ON_SUBD_CACHE_POINT_FLAG(cache_subd_flags) (ON_SUBD_CACHE_POINT_FLAG_MASK&(cache_subd_flags)) 486 #define ON_SUBD_CACHE_DISPLACEMENT_FLAG(cache_subd_flags) (ON_SUBD_CACHE_DISPLACEMENT_FLAG_MASK&(cache_subd_flags)) 487 #define ON_SUBD_CACHE_LIMIT_FLAG(cache_subd_flags) (ON_SUBD_CACHE_LIMIT_FLAG_MASK&(cache_subd_flags)) 489 #define ON_SUBD_CACHE_CLEAR_POINT_FLAG(cache_subd_flags) (cache_subd_flags &= (ON_SUBD_CACHE_TYPE_MASK|ON_SUBD_CACHE_DISPLACEMENT_FLAG_MASK|ON_SUBD_CACHE_LIMIT_FLAG_MASK)) 490 #define ON_SUBD_CACHE_CLEAR_DISPLACEMENT_FLAG(cache_subd_flags) (cache_subd_flags &= (ON_SUBD_CACHE_TYPE_MASK|ON_SUBD_CACHE_POINT_FLAG_MASK|ON_SUBD_CACHE_LIMIT_FLAG_MASK)) 491 #define ON_SUBD_CACHE_CLEAR_LIMIT_FLAG(cache_subd_flags) (cache_subd_flags &= (ON_SUBD_CACHE_TYPE_MASK|ON_SUBD_CACHE_POINT_FLAG_MASK|ON_SUBD_CACHE_DISPLACEMENT_FLAG_MASK)) 498 class ON_SubDAggregates
501 void UpdateBoundingBox(
502 const ON_SubDLevel* level
505 void UpdateEdgeFlags(
506 const ON_SubDLevel* level
509 void UpdateAggregateComponentStatus(
510 const ON_SubDLevel* level
513 void MarkAllAsNotCurrent()
515 m_bDirtyEdgeFlags =
true;
516 m_bDirtyBoundingBox =
true;
517 m_aggregate_status.MarkAsNotCurrent();
520 bool m_bDirtyEdgeFlags =
false;
521 bool m_bDirtyBoundingBox =
false;
523 unsigned int m_edge_flags;
535 static const ON_SubDLevel Empty;
537 bool IsEmpty()
const;
541 m_vertex[0] = m_vertex[1] =
nullptr;
542 m_edge[0] = m_edge[1] =
nullptr;
543 m_face[0] = m_face[1] =
nullptr;
547 ON_SubDLevel(
const ON_SubDLevel&) =
delete;
548 ON_SubDLevel& operator=(
const ON_SubDLevel&) =
delete;
551 unsigned int m_level_index = ON_UNSET_UINT_INDEX;
553 ON_SubD::SubDType m_subdivision_type = ON_SubD::SubDType::Unset;
555 unsigned char m_ordinary_vertex_valence = 0;
556 unsigned char m_ordinary_face_edge_count = 0;
559 unsigned char m_reserved1 = 0;
563 const ON_SubDLevel& src,
564 class ON_SubDArchiveIdMap& eptrlist,
565 class ON_SubDimple& subdimple,
566 bool bCopyComponentStatus
574 unsigned int UpdateEdgeTags(
575 bool bUnsetEdgeTagsOnly
578 unsigned int UpdateVertexTags(
579 bool bVertexEdgeTagsOnly
582 unsigned int UpdateAllTagsAndSectorCoefficients(
583 bool bUnsetValuesOnly
587 void DestroyOnError()
589 ON_SubDIncrementErrorCount();
593 m_vertex_array_count = 0;
594 m_edge_array_count = 0;
595 m_face_array_count = 0; m_vertex[0] = m_vertex[1] =
nullptr;
596 m_edge[0] = m_edge[1] =
nullptr;
597 m_face[0] = m_face[1] =
nullptr;
606 class ON_SubDVertex* m_vertex[2];
609 class ON_SubDEdge* m_edge[2];
612 class ON_SubDFace* m_face[2];
614 unsigned int m_vertex_count = 0;
615 unsigned int m_edge_count = 0;
616 unsigned int m_face_count = 0;
617 unsigned int m_vertex_array_count = 0;
618 unsigned int m_edge_array_count = 0;
619 unsigned int m_face_array_count = 0;
621 std::shared_ptr<const ON_SubDVertex*> VertexArray()
const;
622 std::shared_ptr<const ON_SubDEdge*> EdgeArray()
const;
623 std::shared_ptr<const ON_SubDFace*> FaceArray()
const;
625 mutable ON_SubDLimitMesh m_limit_mesh;
642 unsigned int SetArchiveId(
643 unsigned int archive_id_partition[4]
646 void ClearArchiveId()
const;
650 class ON_SubDArchiveIdMap& element_list,
672 bool bGlobalTransformationIsIsometricOrDilation,
677 ON_SubD::SubDType subdivision_type
680 void ResetVertexArray()
682 if (m_vertex_array_count)
684 m_vertex_array_count = 0;
685 m_vertex_array.reset();
689 void ResetEdgeArray()
691 if (m_edge_array_count)
693 m_edge_array_count = 0;
694 m_edge_array.reset();
698 void ResetFaceArray()
700 if (m_face_array_count)
702 m_face_array_count = 0;
703 m_face_array.reset();
707 std::shared_ptr<const ON_SubDVertex*> m_vertex_array;
708 std::shared_ptr<const ON_SubDEdge*> m_edge_array;
709 std::shared_ptr<const ON_SubDFace*> m_face_array;
711 bool RemoveVertex(
class ON_SubDVertex* vertex)
713 m_aggregates.m_bDirtyBoundingBox =
true;
714 if (
nullptr == vertex || vertex->m_level != this->m_level_index )
715 return ON_SUBD_RETURN_ERROR(
false);
716 if ( 0 == m_vertex_count)
717 return ON_SUBD_RETURN_ERROR(
false);
718 ON_SubDVertex* prev_vertex =
const_cast<ON_SubDVertex*
>(vertex->m_prev_vertex);
719 ON_SubDVertex* next_vertex =
const_cast<ON_SubDVertex*
>(vertex->m_next_vertex);
720 vertex->m_prev_vertex =
nullptr;
721 vertex->m_next_vertex =
nullptr;
722 if (1 == m_vertex_count)
724 if (m_vertex[0] == vertex && m_vertex[1] == vertex &&
nullptr == prev_vertex &&
nullptr == next_vertex)
726 m_vertex[0] =
nullptr;
727 m_vertex[1] =
nullptr;
738 if (m_vertex[0] == vertex)
740 if (m_vertex_count >= 2 &&
nullptr == prev_vertex &&
nullptr != next_vertex )
742 m_vertex[0] = next_vertex;
743 next_vertex->m_prev_vertex =
nullptr;
751 else if (m_vertex[1] == vertex)
753 if (m_vertex_count >= 2 &&
nullptr == next_vertex &&
nullptr != prev_vertex)
755 m_vertex[1] = prev_vertex;
756 prev_vertex->m_next_vertex =
nullptr;
766 if (m_vertex_count > 2 &&
nullptr != prev_vertex &&
nullptr != next_vertex)
768 prev_vertex->m_next_vertex = next_vertex;
769 next_vertex->m_prev_vertex = prev_vertex;
784 bool RemoveEdge(
class ON_SubDEdge* edge)
786 m_aggregates.m_bDirtyEdgeFlags =
true;
787 if (
nullptr == edge || edge->m_level != this->m_level_index )
788 return ON_SUBD_RETURN_ERROR(
false);
789 if ( 0 == m_edge_count)
790 return ON_SUBD_RETURN_ERROR(
false);
791 ON_SubDEdge* prev_edge =
const_cast<ON_SubDEdge*
>(edge->m_prev_edge);
792 ON_SubDEdge* next_edge =
const_cast<ON_SubDEdge*
>(edge->m_next_edge);
793 edge->m_prev_edge =
nullptr;
794 edge->m_next_edge =
nullptr;
795 if (1 == m_edge_count)
797 if (m_edge[0] == edge && m_edge[1] == edge &&
nullptr == prev_edge &&
nullptr == next_edge)
811 if (m_edge[0] == edge)
813 if (m_edge_count >= 2 &&
nullptr == prev_edge &&
nullptr != next_edge )
815 m_edge[0] = next_edge;
816 next_edge->m_prev_edge =
nullptr;
824 else if (m_edge[1] == edge)
826 if (m_edge_count >= 2 &&
nullptr == next_edge &&
nullptr != prev_edge)
828 m_edge[1] = prev_edge;
829 prev_edge->m_next_edge =
nullptr;
839 if (m_edge_count > 2 &&
nullptr != prev_edge &&
nullptr != next_edge)
841 prev_edge->m_next_edge = next_edge;
842 next_edge->m_prev_edge = prev_edge;
857 bool RemoveFace(
class ON_SubDFace* face)
859 if (
nullptr == face || face->m_level != this->m_level_index )
860 return ON_SUBD_RETURN_ERROR(
false);
861 if ( 0 == m_face_count)
862 return ON_SUBD_RETURN_ERROR(
false);
863 ON_SubDFace* prev_face =
const_cast<ON_SubDFace*
>(face->m_prev_face);
864 ON_SubDFace* next_face =
const_cast<ON_SubDFace*
>(face->m_next_face);
865 face->m_prev_face =
nullptr;
866 face->m_next_face =
nullptr;
867 if (1 == m_face_count)
869 if (m_face[0] == face && m_face[1] == face &&
nullptr == prev_face &&
nullptr == next_face)
883 if (m_face[0] == face)
885 if (m_face_count >= 2 &&
nullptr == prev_face &&
nullptr != next_face )
887 m_face[0] = next_face;
888 next_face->m_prev_face =
nullptr;
896 else if (m_face[1] == face)
898 if (m_face_count >= 2 &&
nullptr == next_face &&
nullptr != prev_face)
900 m_face[1] = prev_face;
901 prev_face->m_next_face =
nullptr;
911 if (m_face_count > 2 &&
nullptr != prev_face &&
nullptr != next_face)
913 prev_face->m_next_face = next_face;
914 next_face->m_prev_face = prev_face;
928 const ON_SubDVertex* AddVertex(
class ON_SubDVertex* vertex)
930 m_aggregates.m_bDirtyBoundingBox =
true;
931 if (
nullptr == vertex)
933 if (
nullptr == m_vertex[1])
935 m_vertex[0] = vertex;
936 vertex->m_prev_vertex =
nullptr;
940 m_vertex[1]->m_next_vertex = vertex;
941 vertex->m_prev_vertex = m_vertex[1];
943 m_vertex[1] = vertex;
944 vertex->m_next_vertex =
nullptr;
950 const ON_SubDEdge* AddEdge(
class ON_SubDEdge* edge)
952 m_aggregates.m_bDirtyEdgeFlags =
true;
955 if (
nullptr == m_edge[1])
958 edge->m_prev_edge =
nullptr;
962 m_edge[1]->m_next_edge = edge;
963 edge->m_prev_edge = m_edge[1];
966 edge->m_next_edge =
nullptr;
972 const ON_SubDFace* AddFace(
class ON_SubDFace* face)
976 if (
nullptr == m_face[1])
979 face->m_prev_face =
nullptr;
983 m_face[1]->m_next_face = face;
984 face->m_prev_face = m_face[1];
987 face->m_next_face =
nullptr;
994 unsigned int m_reserved4 = 0;
997 unsigned int UpdateEdgeSectorCoefficients(
998 bool bUnsetEdgeSectorCoefficientsOnly
1002 void ClearSubdivisonAndLimitPoints()
const;
1011 unsigned int ClearStates(
1015 unsigned int GetComponentsWithSetStates(
1017 bool bAllEqualStates,
1021 unsigned int SetStates(
1022 ON_SubDComponentPtr component_ptr,
1026 unsigned int ClearStates(
1027 ON_SubDComponentPtr component_ptr,
1031 unsigned int SetStatus(
1032 ON_SubDComponentPtr component_ptr,
1038 void MarkAggregateComponentStatusAsNotCurrent()
const 1040 m_aggregates.m_aggregate_status.MarkAsNotCurrent();
1043 void ClearBoundingBox()
const 1045 m_aggregates.m_bDirtyBoundingBox =
true;
1050 void ClearEdgeFlags()
const 1052 m_aggregates.m_bDirtyEdgeFlags =
true;
1055 unsigned int EdgeFlags()
const;
1057 ON_SubDLimitMesh UpdateLimitSurfaceMesh(
1058 const ON_SubD& subd,
1059 const class ON_SubDDisplayParameters& display_parameters
1062 unsigned int LimitSurfaceMeshFragmentCount()
const;
1065 mutable ON_SubDAggregates m_aggregates;
1072 class ON_SubDLevelIterator
1075 class ON_SubDLevel* First()
1077 for (m_level_index = 0; m_level_index < m_level_count; m_level_index++)
1079 if (
nullptr != m_levels[m_level_index])
1080 return m_levels[m_level_index];
1085 class ON_SubDLevel* Next()
1087 for (m_level_index++; m_level_index < m_level_count; m_level_index++)
1089 if (
nullptr != m_levels[m_level_index])
1090 return m_levels[m_level_index];
1095 unsigned int LevelIndex()
1097 return m_level_index;
1100 unsigned int LevelCount()
1102 return m_level_count;
1106 friend class ON_SubDimple;
1107 ON_SubDLevelIterator() =
default;
1108 ~ON_SubDLevelIterator() =
default;
1109 ON_SubDLevelIterator(
const ON_SubDLevelIterator&) =
default;
1110 ON_SubDLevelIterator& operator=(
const ON_SubDLevelIterator&) =
default;
1112 class ON_SubDLevel** m_levels =
nullptr;
1113 unsigned int m_level_count = 0;
1114 unsigned int m_level_index = 0;
1128 class ON_SubDVertex* AllocateVertexAndSetId(
unsigned int& max_vertex_id);
1130 void ReturnVertex(
class ON_SubDVertex* v);
1132 class ON_SubDEdge* AllocateEdgeAndSetId(
unsigned int& max_edge_id);
1134 void ReturnEdge(
class ON_SubDEdge* e);
1136 class ON_SubDFace* AllocateFaceAndSetId(
unsigned int& max_face_id);
1138 void ReturnFace(
class ON_SubDFace* f);
1144 void ClearArchiveId();
1146 const class ON_SubDVertex* VertexFromId(
1147 unsigned int vertex_id
1150 const class ON_SubDEdge* EdgeFromId(
1151 unsigned int edge_id
1154 const class ON_SubDFace* FaceFromId(
1155 unsigned int face_id
1165 ON__UINT_PTR* AllocateArray(
1172 static ON__UINT_PTR ArrayCapacity(
1176 ON__UINT_PTR* ResizeArray(
1177 size_t current_count,
1178 size_t current_capacity,
1179 ON__UINT_PTR* current_a,
1180 size_t* new_capacity
1184 bool GrowVertexEdgeArray(
1188 bool GrowVertexFaceArray(
1192 bool GrowEdgeFaceArray(
1196 bool GrowFaceEdgeArray(
1201 bool GrowVertexEdgeArrayByOne(
1204 bool GrowVertexFaceArrayByOne(
1207 bool GrowEdgeFaceArrayByOne(
1210 bool GrowFaceEdgeArrayByOne(
1214 bool ReturnVertexEdgeAndFaceArrays(
1218 bool ReturnEdgeExtraArray(
1222 bool ReturnFaceExtraArray(
1241 size_t SizeOf()
const 1243 size_t sz =
sizeof(*this);
1244 sz += m_fsp5.SizeofElement()*m_fsp5.TotalElementCount();
1245 sz += m_fsp9.SizeofElement()*m_fsp9.TotalElementCount();
1246 sz += m_fsp17.SizeofElement()*m_fsp17.TotalElementCount();
1255 class tagWSItem* m_prev;
1256 class tagWSItem* m_next;
1259 class tagWSItem* m_ws =
nullptr;
1268 ON_SubDVertex* m_unused_vertex =
nullptr;
1269 ON_SubDEdge* m_unused_edge =
nullptr;
1270 ON_SubDFace* m_unused_face =
nullptr;
1272 ON__UINT_PTR* AllocateOversizedElementQWERTY(
1275 void ReturnOversizedElement(
1279 static size_t OversizedElementCapacityQWERTY(
1283 static size_t m_offset_vertex_id;
1284 static size_t m_offset_edge_id;
1285 static size_t m_offset_face_id;
1296 #if defined(ON_SUBD_CENSUS) 1297 ON_SubDImpleCensusCounter m_census_counter;
1300 ON_SubDimple() =
default;
1302 ON_SubDimple(
const ON_SubDimple&);
1305 const ON_SubD& subd,
1338 const class ON_SubDVertex* VertexFromId(
1339 unsigned int vertex_id
1342 return m_heap.VertexFromId(vertex_id);
1345 const class ON_SubDEdge* EdgeFromId(
1346 unsigned int edge_id
1349 return m_heap.EdgeFromId(edge_id);
1352 const class ON_SubDFace* FaceFromId(
1353 unsigned int face_id
1356 return m_heap.FaceFromId(face_id);
1359 ON_SubDLevelIterator LevelIterator()
const 1361 ON_SubDLevelIterator lit;
1362 lit.m_levels = (ON_SubDLevel**)m_levels.Array();
1363 lit.m_level_count = m_levels.UnsignedCount();
1367 unsigned int LevelCount()
const 1369 return m_levels.UnsignedCount();
1373 class ON_SubDEdge* AddEdge(
1374 ON_SubD::EdgeTag edge_tag,
1376 double v0_sector_weight,
1378 double v1_sector_weight
1394 const ON_SubDEdge* SplitEdge(
1399 class ON_SubDFace* AddFace(
1400 unsigned int edge_count,
1401 const ON_SubDEdgePtr* edge
1422 const ON_SubDEdge* SplitFace(
1429 ON_SubD::SubDType subdivision_type
1432 class ON_SubDVertex* AllocateVertex(
1433 ON_SubD::VertexTag vertex_tag,
1438 class ON_SubDVertex* v = m_heap.AllocateVertexAndSetId(m_max_vertex_id);
1439 v->m_level = (
unsigned short)level;
1440 v->m_vertex_tag = vertex_tag;
1450 class ON_SubDVertex* AllocateVertex(
1451 ON_SubD::VertexTag vertex_tag,
1454 unsigned int edge_capacity,
1455 unsigned int face_capacity
1458 class ON_SubDVertex* v = AllocateVertex(vertex_tag,level,P);
1460 if (edge_capacity > 0 && edge_capacity < ON_SubDVertex::MaximumEdgeCount )
1461 m_heap.GrowVertexEdgeArray(v,edge_capacity);
1462 if (face_capacity > 0 && face_capacity < ON_SubDVertex::MaximumFaceCount )
1463 m_heap.GrowVertexFaceArray(v,face_capacity);
1467 const class ON_SubDVertex* AddVertexToLevel(
class ON_SubDVertex* v)
1469 class ON_SubDLevel* subd_level = SubDLevel(v->m_level,
true);
1470 return (subd_level) ? subd_level->AddVertex(v) :
nullptr;
1473 void ReturnVertex(
class ON_SubDVertex* v)
1475 if (
nullptr != v && v->m_level < m_levels.UnsignedCount())
1477 ON_SubDLevel* level = m_levels[v->m_level];
1479 level->RemoveVertex(v);
1481 v->ClearSavedLimitPoints();
1482 m_heap.ReturnVertex(v);
1485 class ON_SubDEdge* AllocateEdge(
1486 ON_SubD::EdgeTag edge_tag
1489 class ON_SubDEdge* e = m_heap.AllocateEdgeAndSetId(m_max_edge_id);
1490 e->m_edge_tag = edge_tag;
1494 class ON_SubDEdge* AllocateEdge(
1495 ON_SubD::EdgeTag edge_tag,
1497 unsigned int face_capacity
1500 class ON_SubDEdge* e = AllocateEdge(edge_tag);
1501 e->m_level = (
unsigned short)level;
1502 if (face_capacity > 0 && face_capacity <= ON_SubDEdge::MaximumFaceCount )
1503 m_heap.GrowEdgeFaceArray(e,face_capacity);
1507 const class ON_SubDEdge* AddEdgeToLevel(
class ON_SubDEdge* e)
1509 class ON_SubDLevel* subd_level = SubDLevel(e->m_level,
true);
1510 return (subd_level) ? subd_level->AddEdge(e) :
nullptr;
1513 void ReturnEdge(
class ON_SubDEdge* e)
1515 if (
nullptr != e && e->m_level < m_levels.UnsignedCount())
1517 ON_SubDLevel* level = m_levels[e->m_level];
1519 level->RemoveEdge(e);
1521 m_heap.ReturnEdge(e);
1524 class ON_SubDFace* AllocateFace()
1526 class ON_SubDFace* f = m_heap.AllocateFaceAndSetId(m_max_face_id);
1530 class ON_SubDFace* AllocateFace(
1532 unsigned int edge_capacity
1535 class ON_SubDFace* f = AllocateFace();
1538 f->m_level = (
unsigned short)level;
1539 if (edge_capacity >
sizeof(f->m_edge4)/
sizeof(f->m_edge4[0]) && edge_capacity <= ON_SubDFace::MaximumEdgeCount)
1540 m_heap.GrowFaceEdgeArray(f,edge_capacity);
1545 const class ON_SubDFace* AddFaceToLevel(
class ON_SubDFace* f)
1547 class ON_SubDLevel* subd_level = SubDLevel(f->m_level,
true);
1548 return (subd_level) ? subd_level->AddFace(f) :
nullptr;
1551 void ReturnFace(
class ON_SubDFace* f)
1553 if (
nullptr != f && f->m_level < m_levels.UnsignedCount())
1555 ON_SubDLevel* level = m_levels[f->m_level];
1557 level->RemoveFace(f);
1559 m_heap.ReturnFace(f);
1562 unsigned int DeleteComponents(
1563 unsigned int level_index
1574 void ClearSubdivisionLevels(
1575 unsigned int max_level_index
1578 size_t SizeOf()
const 1580 size_t sz =
sizeof(*this) + m_heap.SizeOf() -
sizeof(m_heap);
1585 ON_SubD::SubDType subd_type,
1586 unsigned int level_index,
1594 unsigned int GlobalSubdivide(
1595 ON_SubD::SubDType subdivision_type,
1596 bool bUseSavedSubdivisionPoints
1599 unsigned int MergeColinearEdges(
1600 double distance_tolerance,
1601 double maximum_aspect,
1602 double sin_angle_tolerance
1605 ON_SubDEdgePtr MergeEdges(
1606 ON_SubDEdgePtr eptr0,
1607 ON_SubDEdgePtr eptr1
1611 bool GrowVertexEdgeArray(
1615 bool GrowVertexFaceArray(
1619 bool GrowEdgeFaceArray(
1623 bool GrowFaceEdgeArray(
1631 unsigned int m_max_vertex_id = 0;
1632 unsigned int m_max_edge_id = 0;
1633 unsigned int m_max_face_id = 0;
1636 ON_SubDLevel* m_active_level =
nullptr;
1643 const ON_SubDLevel& ActiveLevel()
const 1645 return (
nullptr != m_active_level) ? *m_active_level : ON_SubDLevel::Empty;
1648 ON_SubDLevel* ActiveLevelPointer()
1650 return m_active_level;
1653 bool SetActiveLevel(
1654 unsigned int level_index
1659 m_active_level = m_levels[level_index];
1665 class ON_SubDLevel const * SubDLevel(
1666 unsigned int level_index
1670 ON_SubDLevel* ActiveLevel(
1671 bool bCreateIfNeeded
1674 class ON_SubDLevel* SubDLevel(
1675 unsigned int level_index,
1676 bool bCreateIfNeeded
1686 const ON_SubD& subd,
1687 unsigned int level_index,
1697 unsigned int GlobalQuadSubdivideFace(
1698 bool bUseSavedSubdivisionPoint,
1699 const ON_SubDFace* face
1720 unsigned int GlobalTriSubdivideFace(
1721 const ON_SubDFace* face,
1722 bool bUseSavedSubdivisionPoint,
1723 bool* bUnsetEdgeWeight
1727 ON_SubDimple& operator=(
const ON_SubDimple&) =
delete;
1732 class ON_SubDQuadFaceSubdivisionCounter
1735 const ON_SubDFace* m_level0_face =
nullptr;
1736 unsigned int m_level0_face_id = 0;
1738 unsigned short m_subdivision_count = 0;
1739 unsigned short m_corner_index[9];
1742 const ON_SubDFace* face
1745 m_level0_face = face;
1746 m_level0_face_id = (
nullptr == face) ? 0 : face->m_id;
1747 m_subdivision_count = 0;
1750 bool BreakpointTest();
1753 unsigned int face_corner_index
1756 if ( face_corner_index >= 0xFFFFU )
1757 face_corner_index = 0xFFFFU;
1758 if ( m_subdivision_count <
sizeof(m_corner_index)/
sizeof(m_corner_index[0]) )
1759 m_corner_index[m_subdivision_count] = (
unsigned short)face_corner_index;
1760 m_subdivision_count++;
1766 if ( m_subdivision_count > 0 )
1767 m_subdivision_count--;
1777 class ON_SubDQuadFacePatcher
1780 ON_SubDLimitPatchFragment m_patch_fragment = ON_SubDLimitPatchFragment::Empty;
1781 unsigned int m_display_density = 0;
1782 unsigned int m_patch_count = 0;
1783 ON__UINT_PTR m_fragment_callback_context = 0;
1784 bool (*m_fragment_callback_function)(ON__UINT_PTR,
const class ON_SubDLimitPatchFragment*) =
nullptr;
1785 bool m_bCallbackResult =
false;
1787 bool SendSinglePatch(
1788 unsigned int display_density,
1789 const class ON_SubDQuadFaceSubdivisionCounter& quad_face_subdivision_counter,
1790 ON_SubDLimitPatchFragment::PatchType patch_type
1793 bool SendMultiPatch(
1794 unsigned int display_density,
1795 const class ON_SubDQuadFaceSubdivisionCounter& quad_face_subdivision_counter,
1796 const ON_SubDLimitPatchFragment::PatchType patch_type[4]
1800 class ON_SubDQuadFaceMesher
1803 ON_SubDQuadFaceMesher() =
default;
1805 ~ON_SubDQuadFaceMesher()
1807 if (
nullptr != m__buffer)
1810 m__buffer =
nullptr;
1811 m__buffer_capacity = 0;
1815 enum class Output : unsigned int
1822 ON_SubDQuadFaceMesher::Output m_output = ON_SubDQuadFaceMesher::Output::unset;
1825 unsigned int m_display_density = 0;
1828 unsigned int m_reserved = 0;
1837 unsigned int m_count = 0;
1838 unsigned int m_capacity = 0;
1842 size_t m_point_stride0 = 0;
1843 size_t m_point_stride1 = 0;
1844 double* m_points =
nullptr;
1847 size_t m_normal_stride0 = 0;
1848 size_t m_normal_stride1 = 0;
1849 double* m_normals =
nullptr;
1855 class ON_SubDQuadFacePatcher* m_patcher =
nullptr;
1862 bool SetDestinationToLocalMeshBuffer(
1863 unsigned int mesh_density
1870 bool UnsetMeshPoints();
1877 bool SetDestinationToMeshFragment(
1878 unsigned int mesh_density,
1879 class ON_SubDLimitMeshFragment& mesh_fragment
1882 bool SetDestinationToPatchFragment(
1883 class ON_SubDQuadFacePatcher& patcher
1887 class ON_SubDQuadFaceSubdivisionCounter& quad_face_subdivision_counter,
1888 const ON_SubDFace* face
1891 bool GetLimitPatches(
1892 class ON_SubDQuadFaceSubdivisionCounter& quad_face_subdivision_counter,
1893 const ON_SubDFace* face
1897 double* Internal_Buffer(
size_t buffer_capacity);
1899 size_t m__buffer_capacity = 0;
1900 double* m__buffer =
nullptr;
1919 static void Get6xCubicBasis(
1941 static void GetCubicBasisDerivative(
1956 bool EvaluateSurface(
1958 unsigned int point_i0,
1959 unsigned int point_j0
1962 bool GetLimitSubMeshOrPatch(
1963 class ON_SubDQuadFaceSubdivisionCounter& quad_face_subdivision_counter,
1964 class ON_SubDQuadNeighborhood* qft,
1965 unsigned int display_density,
1966 unsigned int point_i0,
1967 unsigned int point_j0
1971 bool Internal_EvaluateSurfaceNormalBackup1(
1979 bool Internal_EvaluateSurfaceNormalBackup2(
1987 double m_srf_cv[4][4][3];
1988 ON_SubD_FixedSizeHeap m_fshx[5];
1990 ON_SubD_FixedSizeHeap* CheckOutLocalFixedSizeHeap()
1992 const size_t count =
sizeof(m_fshx) /
sizeof(m_fshx[0]);
1993 for (
size_t i = 0; i < count; i++)
1995 if (
false == m_fshx[i].InUse() )
1998 return ON_SUBD_RETURN_ERROR(
nullptr);
2001 bool ReturnLocalFixedSizeHeap(ON_SubD_FixedSizeHeap* fsh)
2003 if (
nullptr == fsh)
2004 return ON_SUBD_RETURN_ERROR(
false);
2006 const size_t count =
sizeof(m_fshx) /
sizeof(m_fshx[0]);
2007 for (
size_t i = 0; i < count; i++)
2009 if (fsh == &m_fshx[i])
2019 void ReturnAllFixedSizeHeaps()
2021 const size_t count =
sizeof(m_fshx) /
sizeof(m_fshx[0]);
2022 for (
size_t i = 0; i < count; i++)
2029 void SetDestinationInitialize(
2030 ON_SubDQuadFaceMesher::Output output
2036 ON_SubDQuadFaceMesher(
const ON_SubDQuadFaceMesher&) =
delete;
2037 ON_SubDQuadFaceMesher& operator=(
const ON_SubDQuadFaceMesher&) =
delete;
2041 class ON_SubDArchiveIdMap
2046 static unsigned int ArchiveIdFromComponentPtr(
2050 bool ConvertArchiveIdToRuntimeVertexPtr(
2051 unsigned int vertex_count,
2052 size_t vertex_capacity,
2053 ON_SubDVertex** vertex
2056 bool ConvertArchiveIdToRuntimeEdgePtr(
2057 unsigned int edge_count,
2058 size_t edgeN_capacity,
2059 ON_SubDEdgePtr* edgeN,
2060 unsigned int edgeX_capacity,
2061 ON_SubDEdgePtr* edgeX
2064 bool ConvertArchiveIdToRuntimeFacePtr(
2065 unsigned int face_count,
2066 size_t faceN_capacity,
2067 ON_SubDFacePtr* faceN,
2068 unsigned int faceX_capacity,
2069 ON_SubDFacePtr* faceX
2072 static void ValidateArrayCounts(
2073 unsigned short& array_count,
2074 size_t arrayN_capacity,
2076 unsigned short arrayX_capacity,
2080 static ON_SubDComponentPtr FromVertex(
2081 ON_SubDVertexPtr vertex_ptr
2084 static ON_SubDComponentPtr FromEdge(
2085 ON_SubDEdgePtr edge_ptr
2088 static ON_SubDComponentPtr FromFace(
2089 ON_SubDFacePtr face_ptr
2092 static ON_SubDComponentPtr FromVertex(
2093 const ON_SubDVertex* vertex
2096 static ON_SubDComponentPtr FromEdge(
2097 const ON_SubDEdge* edge
2100 static ON_SubDComponentPtr FromFace(
2101 const ON_SubDFace* face
2104 static ON_SubDVertex* CopyVertex(
2105 const ON_SubDVertex* src,
2106 class ON_SubDimple& subdimple
2109 static ON_SubDEdge* CopyEdge(
2110 const ON_SubDEdge* src,
2111 class ON_SubDimple& subdimple
2114 static ON_SubDFace* CopyFace(
2115 const ON_SubDFace* src,
2116 class ON_SubDimple& subdimple
2119 ON_SubDArchiveIdMap();
2123 unsigned int Count();
2125 const ON_SubDComponentPtr* First();
2126 const ON_SubDComponentPtr* Next();
2128 bool Add(
const ON_SubDVertex* vertex);
2129 bool Add(
const ON_SubDEdge* edge);
2130 bool Add(
const ON_SubDFace* face);
2132 class ON_SubDVertex* AddCopy(
const class ON_SubDVertex* source_vertex,
class ON_SubDimple& subdimple);
2133 class ON_SubDEdge* AddCopy(
const class ON_SubDEdge* source_edgeclass,
class ON_SubDimple& subdimple);
2134 class ON_SubDFace* AddCopy(
const class ON_SubDFace* source_faceclass,
class ON_SubDimple& subdimple);
2136 const ON_SubDComponentPtr* ComponentPtrFromArchiveId(
2137 unsigned int archive_id
2140 unsigned int m_archive_id_partition[4];
2142 unsigned int ConvertArchiveIdsToRuntimePointers();
2145 bool AddComponentPtr(ON_SubDComponentPtr eptr,
unsigned int archive_id);
2147 unsigned int m_element_index = ON_UNSET_UINT_INDEX;
2148 unsigned int m_element_count = 0;
2158 class ON_SubDLimitMeshImpl
2160 #if defined(ON_SUBD_CENSUS) 2161 ON_SubDLimitMeshImplCensusCounter m_census_counter;
2165 ON_SubDLimitMeshImpl();
2166 ~ON_SubDLimitMeshImpl() =
default;
2167 ON_SubDLimitMeshImpl(
const ON_SubDLimitMeshImpl& src);
2171 ON_SubDLimitMeshImpl& operator=(
const ON_SubDLimitMeshImpl&) =
delete;
2174 ON_SubD::FacetType m_facet_type = ON_SubD::FacetType::Unset;
2176 unsigned char m_reserved1 = 0;
2177 unsigned short m_reserved2 = 0;
2178 unsigned int m_reserved3 = 0;
2180 unsigned int m_limit_mesh_content_serial_number;
2182 static unsigned int Internal_NextContentSerialNumber();
2184 unsigned int m_display_density = 0;
2185 unsigned int m_fragment_count = 0;
2186 unsigned int m_fragment_point_count = 0;
2187 ON_SubDLimitMeshFragment* m_first_fragment =
nullptr;
2188 ON_SubDLimitMeshFragment* m_last_fragment =
nullptr;
2190 bool ReserveCapacity(
2191 unsigned int subd_fragment_count,
2192 ON_SubD::FacetType facet_type,
2193 unsigned int display_density
2202 ON_SubDLimitMeshFragment* CopyCallbackFragment(
2203 const ON_SubDLimitMeshFragment* callback_fragment
2212 bool AddFinishedFragment(
2213 ON_SubDLimitMeshFragment* fragment
2216 const ON_RTree& FragmentTree()
const;
2225 bool GetTightBoundingBox(
2240 std::weak_ptr<class ON_SubDimple> m_subdimple_wp;
2242 void ClearFragmentFacePointers();
2245 ON_RTree* m_fragment_tree =
nullptr;
2251 #endif // ON_COMPILING_OPENNURBS) 2253 #endif // OPENNURBS_SUBD_WIP 2255 #endif // OPENNURBS_SUBD_DATA_INC_ static const ON_BoundingBox EmptyBoundingBox
Definition: opennurbs_bounding_box.h:28
Definition: opennurbs_rtree.h:398
Definition: opennurbs_array.h:36
static const ON_AggregateComponentStatus Empty
Definition: opennurbs_compstat.h:399
Definition: opennurbs_fsp.h:19
Definition: opennurbs_compstat.h:396
Definition: opennurbs_bounding_box.h:25
unsigned int UnsignedCount() const
Definition: opennurbs_array_defs.h:167
Definition: opennurbs_compstat.h:88
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
Definition: opennurbs_point.h:460
Definition: opennurbs_fsp.h:239