NDEVR
API Documentation
Geometry.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: Geometry
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/DesignObject.h>
34#include <NDEVR/Triangle.h>
35#include <NDEVR/Polygon.h>
36#include <functional>
37namespace NDEVR
38{
39 struct FilterDescription;
40 template<uint01 t_dims, class t_type>
41 class Plane;
42 class SelectionInfo;
43 class InfoPipe;
44 class Scene;
45 class Log;
46 class RGBColor;
47 class Geometry;
79
82 template<> struct PropertySpec<NDPG::geometry_type> { using type = StringView; };
83 template<> struct PropertySpec<NDPG::thickness> { using type = fltp04; };
84 template<> struct PropertySpec<NDPG::thickness_mode> { using type = uint01; };
85 template<> struct PropertySpec<NDPG::is_surface> { using type = bool; };
86 template<> struct PropertySpec<NDPG::has_closed_primitive> { using type = bool; };
87 template<> struct PropertySpec<NDPG::plane_normal> { using type = Ray<3, fltp08>; };
88 template<> struct PropertySpec<NDPG::plane_offset> { using type = fltp08; };
89 template<> struct PropertySpec<NDPG::poly_holes> { using type = bool; };
90 template<> struct PropertySpec<NDPG::is_smooth> { using type = bool; };
91 template<> struct PropertySpec<NDPG::smooth_algorithm> { using type = StringView; };
92 template<> struct PropertySpec<NDPG::smooth_level> { using type = uint04; };
93 template<> struct PropertySpec<NDPG::normal_smoothing_angle> { using type = fltp04; };
94 template<> struct PropertySpec<NDPG::is_closed_solid> { using type = bool; };
95 template<> struct PropertySpec<NDPG::shape_type> { using type = StringView; };
96 template<> struct PropertySpec<NDPG::is_clipping_geo> { using type = bool; };
97 template<> struct PropertySpec<NDPG::preserve_primitive_order> { using type = bool; };
98 template<> struct PropertySpec<NDPG::preserve_vertex_order> { using type = bool; };
99 template<> struct PropertySpec<NDPG::no_auto_tree_creation> { using type = bool; };
101
105 template<>
107 {
108 public:
113 static constexpr TableColumn* column(const DesignInfo* object, NDPG property)
114 {
115 return object->m_base->geometry_properties[eint01(property)];
116 }
117
120 static constexpr uint04 index(const DesignInfo* object, NDPG)
121 {
122 return object->m_design_index;
123 }
124 };
125
142 class NDEVR_DESIGN_API Geometry : public DesignObject
143 {
144 friend class Model;
145 public:
179
190
203 public:
204 Geometry() = default;
205
209
214
217 explicit Geometry(const DesignObject& obj);
218
221 void setGeometryType(GeometryType geometry_type);
222
226
229
233 void split(Geometry& other_geo, const Buffer<bool>& vertex_mask);
234
238 void combine(Geometry& geo, const Matrix<fltp08>& conversion = Matrix<fltp08>(1.0));
239
244 void copyFrom(const Geometry& geo, bool copy_tree = true, bool copy_vertices = true);
245
248 void copyTraitsFrom(const Geometry& geo);
249
252 inline uint04 parentCount() const;
253
258
263
267
271 inline Model getParent(uint04 index) const;
272
275
280 uint01 parity(const Matrix<fltp04>& parent_matrix, PrimitiveMode mode) const;
281
286 uint01 parity(const Matrix<fltp08>& parent_matrix, PrimitiveMode mode) const;
287
292 void fillHolesByNeighbor(PrimitiveProperty property, const void* lock = nullptr, LogPtr log = LogPtr());
293
297 void removeHoleFill(const void* lock = nullptr, LogPtr log = LogPtr());
298
302
305
308
311
314 void setBounds(const Bounds<3, fltp08>& bounds);
315
319 bool canBeClosedSolid(const void* lock = nullptr) const;
320
324 bool hasParent(const Model& model) const;
325
329
333
336 bool canExplode() const;
337
341
343 void outline();
344
350 void setNormalMode(NormalMode mode, Angle<fltp08> max_sep_angle, const void* lock = nullptr, LogPtr log = LogPtr());
351
357 void calculateNormals(NormalMode mode, Angle<fltp08> max_difference, const void* lock = nullptr, LogPtr log = LogPtr());
358
364 void setRealThickness(fltp08 real_thickness, const Matrix<fltp08>& transform, const void* lock, LogPtr log = LogPtr());
365
369
373
377
380
385 void removeDuplicateVertices(fltp08 epsilon, const void* lock, LogPtr log = LogPtr());
386
389
394 void convertPolarToCartesian(const StringView& roll_column, const StringView& pitch_column, const StringView& distance_column);
395
396
409
413
417
420 void clearSmoothing(const SmoothingParameters& properties);
421
425 void calculateTangentSpace(bool calc_tan, bool calc_bitan);
426
429 bool validate() const;
430
434 bool hasHoles(PrimitiveProperty property) const;
435
438
443 void setVertexFlag(uint04 vertex, VertexFlags flag, bool value);
444
449 void setVerticesFlag(const Buffer<uint04>& vertices, VertexFlags flag, bool value);
450
455 void setVerticesFlag(const Buffer<bool>& selection_mask, VertexFlags flag, bool value);
456
461 void setVerticesFlags(const Buffer<bool>& selection_mask, BitFlag on_flags, BitFlag off_flags);
462
470 void setVerticesFlags(const Buffer<bool>& selection_mask, BitFlag selected_on_flags, BitFlag selected_off_flags, BitFlag unselected_on_flags, BitFlag unselected_off_flags, uint04 bitmask_offset = 0);
471
475 void setVerticesFlagAll(VertexFlags flag, bool value);
476
480 void setVerticesFlagAll(uint01 on_flags, uint01 off_flags);
481
487 void setPrimitiveIndexFlag(PrimitiveProperty property, uint04 primitive_index, PrimitiveBitFlags flag, bool value);
488
494 bool primitiveIndexFlag(PrimitiveProperty property, uint04 primitive_index, PrimitiveBitFlags flag) const;
495
500 bool vertexFlag(uint04 vertex_index, VertexFlags flag) const;
501
505 BitFlag vertexFlag(uint04 vertex_index) const;
506
510
515
518 void setGeometryTransform(const Matrix<fltp08>& transform);
519
523 void updateGeometryTransform(const Matrix<fltp08>& transform, const void* lock_ptr = nullptr);
524
531 bool operator==(const Geometry& geo) const
532 {
533 if (!isValid() || !geo.isValid())
534 return isValid() == geo.isValid();
535 return (m_base == geo.m_base && m_index == geo.m_index);
536 }
537
541 bool operator!=(const Geometry& geo) const
542 {
543 if (!isValid() || !geo.isValid())
544 return isValid() != geo.isValid();
545 return (m_base != geo.m_base || m_index != geo.m_index);
546 }
547
552 Time getAscModifiedTime(bool include_self, bool include_layer = false) const;
553
556 void normalExpansion(const Vector<3, fltp04>& expansion_vector);
557 private:
560 Bounds<3, fltp08> _calculateBounds() const;
561
562
563 //void getVertexDesignParameters(DesignParameters& params, const Matrix<fltp08>& transform, bool deviation_pass) const;
564
565
566 public:
569
572 ColumnT<uint04>& primitiveColumn()
573 {
574 return m_base->primitive_index_column;
575 }
576
579 const ColumnT<uint04>& primitiveColumn() const
580 {
581 return m_base->primitive_index_column;
582 }
583
586 ColumnT<uint04>& primitiveFanColumn()
587 {
588 return m_base->primitive_fan_column;
589 }
590
593 const ColumnT<uint04>& primitiveFanColumn() const
594 {
595 return m_base->primitive_fan_column;
596 }
597
600 ColumnT<uint01>& primitiveFlagColumn()
601 {
602 return m_base->primitive_flag_column;
603 }
604
607 const ColumnT<uint01>& primitiveFlagColumn() const
608 {
609 return m_base->primitive_flag_column;
610 }
611
615 {
616 return *m_base->face_to_edge_column;
617 }
618
622 {
623 return *m_base->face_to_edge_column;
624 }
625
629 {
630 return *m_base->edge_to_face_column;
631 }
632
636 {
637 return *m_base->edge_to_face_column;
638 }
639
644 {
645 return m_base->primitive_property_mode_column[cast<uint01>(property)]->get<PrimitiveMode>(m_design_index);
646 }
647
651 bool hasProperty(PrimitiveProperty property) const
652 {
653 return mode(property) != PrimitiveMode::e_no_index;
654 }
655
658 bool hasIndexColumn() const
659 {
660 return m_base->primitive_index_column.size() > 0;
661 }
662
665 bool hasIndexFanColumn() const
666 {
667 return m_base->primitive_fan_column.size() > 0;
668 }
669
673
678 void setPrimitiveRange(PrimitiveProperty mode, uint04 start, uint04 primitive_count);
679
684
688 void updatePrimitiveColumn(PrimitiveProperty property, bool remove_tree = true);
689
692 void updatePrimitiveColumns(bool remove_tree = true);
693
697
701
711 template<class t_type>
712 void setPrimitive(PrimitiveProperty property, uint04 index, t_type index_value)
713 {
714 lib_assert(index < indicesPerPrimitive(mode(property)) * primitiveCount(property), "Bad index set");
715 const uint04 index_offset = indexOffset() + indexOffset(property) + index;
716 if (IsValid(index_value))
717 {
718 lib_assert(cast<uint04>(index_value) < vertexCount(), "index for geometry out of range");
719 primitiveColumn()[index_offset] = index_value + t_type(vertexOffset());
720 }
721 else
722 primitiveColumn()[index_offset] = Constant<uint04>::Invalid;
723 }
724
728 template<class t_type>
730 {
731 lib_assert(index < primitiveCount(property), "Bad index set");
732 const uint04 index_offset = indexOffset() + indexOffset(property);
734 if (IsValid(index_value))
735 {
736 lib_assert(index_value[A] < vertexCount(), "index for geometry out of range A");
737 lib_assert(index_value[B] < vertexCount(), "index for geometry out of range B");
738 index_value += cast<t_type>(vertexOffset());
739 }
740 else
741 {
742 index_value = Constant<Vector<2, t_type>>::Invalid;
743 }
744 switch (mode(property))
745 {
747 column.set(index_offset + index + A, index_value[A]);
748 column.set(index_offset + index + B, index_value[B]);
749 break;
751 column.set(index_offset + 2 * index + A, index_value[A]);
752 column.set(index_offset + 2 * index + B, index_value[B]);
753 break;
754 default:
755 lib_assert(false, "Unknown Primitive Mode for vertex<2>");
756 }
757 }
758
761 struct OptimizedPrimitiveDef
762 {
763 OptimizedPrimitiveDef()
764 {}
768 OptimizedPrimitiveDef(ColumnT<uint04>& column, ColumnT<uint04>& fan_column)
769 : column(&column)
771 {}
772 ColumnT<uint04>* column = nullptr;
773 ColumnT<uint04>* fan_column = nullptr;
776#ifdef _DEBUG
777 uint04 index_max_offset;
778 uint04 min_vertex_index;
779 uint04 max_vertex_index;
780#endif
782 };
783
787 {
789 ref.index_offset = indexOffset() + indexOffset(property);
791#ifdef _DEBUG
792 ref.min_vertex_index = vertexOffset();
793 ref.max_vertex_index = ref.min_vertex_index + vertexCount();
794 ref.index_max_offset = primitiveCount(property);
795#endif
796 ref.mode = mode(property);
797 return ref;
798 }
799
803 template<class t_vec_type>
804 static void OptimizedSetPrimitive(const OptimizedPrimitiveDef& ref, uint04 index, t_vec_type index_value)
805 {
806#ifdef _DEBUG
807 lib_assert(index < ref.index_max_offset, "Index out of bounds");
808 for (uint01 i = 0; i < 3; i++)
809 {
810 lib_assert(IsInvalid(index_value) || index_value >= ref.min_vertex_index, "Index out of bounds");
811 lib_assert(IsInvalid(index_value) || index_value < ref.max_vertex_index, "Index out of bounds");
812 }
813#endif
814 (*ref.column)[ref.index_offset + index] = index_value;
815 }
816
820 template<class t_vec_type>
821 static void OptimizedSetPrimitiveVec(const OptimizedPrimitiveDef& ref, uint04 index, t_vec_type index_value)
822 {
823#ifdef _DEBUG
824 lib_assert(index < ref.index_max_offset, "Index out of bounds");
825 for (uint01 i = 0; i < 3; i++)
826 {
827 lib_assert(IsInvalid(index_value[i]) || index_value[i] >= ref.min_vertex_index, "Index out of bounds");
828 lib_assert(IsInvalid(index_value[i]) || index_value[i] < ref.max_vertex_index, "Index out of bounds");
829 }
830#endif
831 switch (ref.mode)
832 {
834 (*ref.column)[ref.index_offset + 3 * index + A] = index_value[A];
835 (*ref.column)[ref.index_offset + 3 * index + B] = index_value[B];
836 (*ref.column)[ref.index_offset + 3 * index + C] = index_value[C];
837 break;
839 (*ref.column)[ref.index_offset + index + A] = index_value[A];
840 (*ref.column)[ref.index_offset + index + B] = index_value[B];
841 (*ref.column)[ref.index_offset + index + C] = index_value[C];
842 break;
844 {
845 uint04 index_fan_location = (*ref.fan_column)[index + ref.fan_offset];
846 if (IsValid(index_fan_location))
847 {
848 (*ref.column)[index_fan_location] = index_value[A];
849 (*ref.column)[index + ref.index_offset - 1] = index_value[B];
850 (*ref.column)[index + ref.index_offset] = index_value[C];
851 }
852 } break;
853 default:
854 lib_assert(false, "Unknown Primitive Mode for vertex<3>");
855 }
856 }
857
861 template<class t_vec_type>
863 {
864 lib_assert(index < ref.index_max_offset, "Index out of bounds");
865 t_vec_type index_value;
866 switch (ref.mode)
867 {
869 index_value[A] = (*ref.column)[ref.index_offset + 2 * index + A];
870 index_value[B] = (*ref.column)[ref.index_offset + 2 * index + B];
871 break;
873 index_value[A] = (*ref.column)[ref.index_offset + index + A];
874 index_value[B] = (*ref.column)[ref.index_offset + index + B];
875 break;
877 index_value[A] = (*ref.column)[ref.index_offset + 3 * index + A];
878 index_value[B] = (*ref.column)[ref.index_offset + 3 * index + B];
879 index_value[C] = (*ref.column)[ref.index_offset + 3 * index + C];
880 break;
882 index_value[A] = (*ref.column)[ref.index_offset + index + A];
883 index_value[B] = (*ref.column)[ref.index_offset + index + B];
884 index_value[C] = (*ref.column)[ref.index_offset + index + C];
885 break;
887 {
888 uint04 index_fan_location = (*ref.fan_column)[index + ref.fan_offset];
889 if (IsInvalid(index_fan_location))
890 {
891 index_value = Constant<t_vec_type>::Invalid;
892 }
893 else
894 {
895
896 lib_assert(index_fan_location >= ref.index_offset && index_fan_location - ref.index_offset < ref.index_max_offset, "bad fan location");
897 index_value[A] = (*ref.column)[index_fan_location];
898 index_value[B] = (*ref.column)[index + ref.index_offset - 1];
899 index_value[C] = (*ref.column)[index + ref.index_offset];
900 }
901 } break;
902 default:
903 lib_assert(false, "Unknown Primitive Mode for vertex<3>");
904 }
905 return index_value;
906 }
907
911 template<class t_type>
913 {
914 setPrimitiveVec<t_type>(property, index, index_value);
915 }
916
921 template<class t_type>
923 {
924 setPrimitiveVec<t_type>(property, index, index_value);
925 }
926
930 static constexpr uint04 indicesPerPrimitive(PrimitiveMode property)
931 {
932 switch (property)
933 {
935 return 0;
937 return 3;
939 return 2;
940 default:
941 return 1;
942 }
943 }
944
948 template<class t_type>
950 {
951 lib_assert(index < indicesPerPrimitive(mode(property)) * primitiveCount(property), "Out of bounds index request");
952 const uint04 index_offset = indexOffset() + indexOffset(property);
953 t_type index_value(primitiveColumn()[index_offset + index]);
954 if (IsInvalid(index_value))
955 return Constant<t_type>::Invalid;
956 return index_value - t_type(vertexOffset());
957 }
958
962 template<class t_type>
963 t_type primitive(PrimitiveProperty property, typename std::enable_if<ObjectInfo<t_type>::Dimensions == 2, uint04>::type index) const
964 {
965 uint04 primitive_count = primitiveCount(property);
966 if (primitive_count == 0)
967 {
968 lib_assert(index + 1 < vertexCount(), "Out of bounds index request");
969 t_type index_value = { index, index + 1 };
970 return index_value;
971 }
972 else
973 {
974 t_type index_value;
975 const uint04 index_offset = indexOffset() + indexOffset(property);
977 switch (mode(property))
978 {
980 lib_assert(index < primitive_count, "Out of bounds index request");
981 index_value = { column.get<uint04>(index_offset + 2 * index), column.get<uint04>(index_offset + 2 * index + 1) };
982 break;
984 lib_assert(index + 1 < primitive_count, "Out of bounds index request");
985 index_value = { column.get<uint04>(index_offset + index), column.get<uint04>(index_offset + index + 1) };
986 break;
987 default:
988 lib_assert(false, "Bad property fetch mode");
989 }
990
991 if (IsInvalid(index_value))
992 return Constant<t_type>::Invalid;
993 return index_value - t_type(vertexOffset());
994 }
995 }
996
1000 template<class t_type>
1001 t_type primitive(PrimitiveProperty property, typename std::enable_if<ObjectInfo<t_type>::Dimensions == 3, uint04>::type index) const
1002 {
1003 lib_assert(index < primitiveCount(property), "Out of bounds index request");
1004 t_type index_value;
1005 const uint04 index_offset = indexOffset() + indexOffset(property);
1006 const ColumnT<uint04>& column = primitiveColumn();
1007 auto v_mode = mode(property);
1008 switch (v_mode)
1009 {
1011 index_value = {
1012 column[index_offset + 3 * index + 0]
1013 , column[index_offset + 3 * index + 1]
1014 , column[index_offset + 3 * index + 2] };
1015 break;
1017 index += index_offset;
1018 index_value = {
1019 column[index + 0]
1020 , column[index + 1]
1021 , column[index + 2] };
1022 break;
1024 {
1025 uint04 index_fan_location = primitiveFanColumn()[index + indexFanOffset()];
1026 if (IsInvalid(index_fan_location))
1027 index_value = Constant<t_type>::Invalid;
1028 else
1029 index_value = {
1030 column[index_fan_location]
1031 , column[index + index_offset - 1]
1032 , column[index + index_offset] };
1033 } break;
1034 default:
1035 lib_assert(false, "Bad property fetch mode");
1036 }
1037 if (IsInvalid(index_value))
1038 return Constant<t_type>::Invalid;
1039 return index_value - t_type(vertexOffset());
1040 }
1041
1046
1052 Buffer<uint04> indices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const;
1053
1058 {
1059 return lineIndices(primitive_property, 0, primitiveCount(primitive_property));
1060 }
1061
1067 Buffer<Vector<2, uint04>> lineIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const;
1068
1073 {
1074 return triIndices(primitive_property, 0, primitiveCount(primitive_property));
1075 }
1076
1082 Buffer<Vector<3, uint04>> triIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const;
1083
1084
1088 {
1089 return m_base->index_mode_offset_column[m_design_index];
1090 }
1091
1096 {
1097 return (*m_base->primitive_property_offset_column[eint01(property)])[m_design_index];
1098 }
1099
1103 {
1104 return m_base->index_fan_offset_column[m_design_index];
1105 }
1106
1110 {
1111 return m_base->index_fan_size_column[m_design_index];
1112 }
1113
1118 template<class t_type>
1119 uint04 addPrimitive(PrimitiveProperty index_property, const t_type& primitive)
1120 {
1121 const uint04 primitive_count = primitiveCount(index_property);
1122 setPrimitiveRange(index_property, indexOffset(index_property), primitive_count + 1);
1123 setPrimitive(index_property, primitive_count, primitive);
1124 return primitive_count;
1125 }
1126
1131 uint04 addPrimitives(PrimitiveProperty index_property, uint04 insersion_size)
1132 {
1133 const uint04 primitive_count = primitiveCount(index_property);
1134 setPrimitiveRange(index_property, indexOffset(index_property), primitive_count + insersion_size);
1135 return primitive_count;
1136 }
1137
1141
1147 void autoCalculateIndices(PrimitiveProperty property, const void* lock = nullptr, const Matrix<fltp08>& transform = Matrix<fltp08>(1.0), LogPtr log = LogPtr());
1148 public:
1151 static void SetTriangulationMethod(std::function<void(Geometry& geo, const Matrix<fltp08>& matrix, const void* lock, LogPtr log)> function);
1152
1156 {
1157 return m_base->index_mode_size_column[m_design_index];
1158 }
1159
1164 {
1165 return (*m_base->primitive_property_size_column[cast<uint01>(property)])[m_design_index];
1166 }
1167
1172 {
1173 return indicesPerPrimitive(mode(property)) * primitiveCount(property);
1174 }
1175
1178
1182 {
1183 const uint04 count = vertexCount();
1184 setVertexCount(count + 1);
1185 return count;
1186 }
1187
1191
1196 {
1197 const uint04 count = vertexCount();
1198 setVertexCount(count + size);
1199 return count;
1200 }
1201
1205 void addVertices(uint04 location, uint04 size);
1206
1210 void setVertexCount(uint04 size, bool deallocate_if_possible = true);
1211
1214 void removeVertex(uint04 location);
1215
1219 void removeVertices(uint04 location, uint04 size);
1220
1224
1227 void removeVertices(const Buffer<bool>& selection_mask);
1228
1232 void removeVertices(uint04 mask_offset, const Buffer<bool>& selection_mask);
1233
1237 void removePrimitive(PrimitiveProperty property, uint04 location);
1238
1243 void removePrimitive(PrimitiveProperty property, uint04 location, uint04 size);
1244
1249
1253 void removePrimitive(PrimitiveProperty property, const Buffer<bool>& selection_mask);
1254
1258
1262 Matrix<fltp08> getCompleteTransform(const Model& parent) const;
1267 {
1268 return m_base->vertex_reserved_count_column[m_design_index];
1269 }
1270
1274 {
1275 return m_base->vertex_offset_column[m_design_index];
1276 }
1277
1281 {
1282 return m_base->vertex_count_column[m_design_index];
1283 }
1284
1288 {
1289 return m_base->solid_vertex_offset_column[m_design_index];
1290 }
1291
1295 {
1296 return m_base->solid_vertex_reserved_count_column[m_design_index];
1297 }
1298
1302 {
1303 return m_base->solid_vertex_count_column[m_design_index];
1304 }
1305
1308
1312 const String& vertexPropertyName(uint04 property_index) const
1313 {
1314 return m_base->vertex_table.get(property_index).label();
1315 }
1316
1320
1324 uint04 vertexPropertyIndex(const StringView& property_name) const;
1325
1329 bool hasVertexProperty(const StringView& property_name) const;
1330
1334 bool hasVertexProperty(const VertexProperty& property) const;
1335
1339 TypeInfo vertexPropertyType(uint04 property_index) const
1340 {
1341 return propertyColumn(property_index).type();
1342 }
1343
1347 template<class t_type>
1349 {
1350 return createVertexProperty(property_name, GetTypeInfo<t_type>());
1351 }
1352
1357 uint04 createVertexProperty(const StringView& property_name, const TypeInfo& type);
1358
1363 template<class t_type>
1364 t_type vertexProperty(uint04 property_index, uint04 vertex_index) const
1365 {
1366 return propertyColumn(property_index).get<t_type>(vertexOffset() + vertex_index);
1367 }
1368
1373 template<class t_type>
1374 t_type vertexProperty(const StringView& property, uint04 vertex_index) const
1375 {
1376 return propertyColumn(property).get<t_type>(vertexOffset() + vertex_index);
1377 }
1378
1384 template<class t_type>
1385 t_type vertexProperty(uint04 property_index, uint04 vertex_index, uint04 sub_index) const
1386 {
1387 return propertyColumn(property_index).get<t_type>(vertexOffset() + vertex_index, sub_index);
1388 }
1389
1395 template<class t_type>
1396 t_type vertexProperty(const StringView& property, uint04 vertex_index, uint04 sub_index) const
1397 {
1398 return propertyColumn(property).get<t_type>(vertexOffset() + vertex_index, sub_index);
1399 }
1400
1401
1406 template<class t_type>
1407 void setVertexProperty(uint04 property, uint04 index, const t_type& vector)
1408 {
1409 lib_assert(index <= vertexCount(), "Out of bounds vertex set");
1410 propertyColumn(property).set(vertexOffset() + index, vector);
1411 }
1412
1416 template<class t_type>
1417 void setVertexProperty(const StringView& property, uint04 index, const t_type& property_value)
1418 {
1419 lib_assert(index <= vertexCount(), "Out of bounds vertex set");
1420 propertyColumn(property).set(vertexOffset() + index, property_value);
1421 }
1422
1428 template<class t_type>
1429 void setVertexProperty(uint04 property, uint04 index, uint04 sub_index, const t_type& vector)
1430 {
1431 lib_assert(index <= vertexCount(), "Out of bounds vertex set");
1432 propertyColumn(property).set(vertexOffset() + index, sub_index, vector);
1433 }
1434
1440 template<class t_type>
1441 void setVertexProperty(const StringView& property, uint04 index, uint04 sub_index, const t_type& vector)
1442 {
1443 lib_assert(index <= vertexCount(), "Out of bounds vertex set");
1444 propertyColumn(property).set(vertexOffset() + index, sub_index, vector);
1445 }
1446
1451 template<class t_type>
1452 void setVertexProperties(const StringView& property, const Buffer<t_type>& vertices, uint04 offset = 0)
1453 {
1454 lib_assert(offset + vertices.size() <= vertexCount(), "Out of bounds vertex set");
1455 uint04 vertex_offset = vertexOffset() + offset;
1456 auto& col = propertyColumn(property);
1457 for (uint04 i = 0; i < vertices.size(); i++)
1458 {
1459 col.set(vertex_offset + i, vertices[i]);
1460 }
1461 }
1462
1463
1470 {
1471 return m_base->vertex_table[property];
1472 }
1473
1477 const TableColumn& propertyColumn(uint04 property) const
1478 {
1479 return m_base->vertex_table[property];
1480 }
1481
1485 bool hasProperty(VertexProperty property) const
1486 {
1487 return mode(property) != VertexMode::e_no_vertex;
1488 }
1489
1494 {
1495 return m_base->vertex_mode_column[eint01(property)]->get<VertexMode>(m_design_index);
1496 }
1497
1507 void setupVertexTable(uint04 vertex_size
1508 , VertexMode position
1515
1519
1526 void updateVertexColumn(VertexProperty property, uint04 index, uint04 size, bool invalidate_bounds = true, bool erase_kd_tree = true);
1527
1530 void updateVertexColumn(const StringView& property);
1531
1534 void updateVertexColumn(const uint04& property);
1535
1540 void updateVertexColumn(const StringView& property, uint04 index, uint04 size);
1541
1546 void updateVertexColumn(const uint04& property, uint04 index, uint04 size);
1547
1551 void updateVertexColumns(bool invalidate_bounds = true, bool erase_kd_tree = true);
1552
1556 void updateSolidVertexColumns(bool invalidate_bounds = true, bool erase_kd_tree = true);
1557
1563 void updateVertexColumns(uint04 index, uint04 size, bool invalidate_bounds = true, bool erase_kd_tree = true);
1564
1568 fltp08 calculateVolume(const Matrix<fltp08>& parent_transform) const;
1569
1573 fltp08 calculateSurfaceArea(const Matrix<fltp08>& parent_transform) const;
1574
1579 Vector<2, fltp08> calculateVolumeAndSurfaceArea(const Matrix<fltp08>& transform, const void* lock) const;
1580
1584 fltp08 calculateLength(const Matrix<fltp08>& transform) const;
1585
1590
1595
1600 bool hasTree(PrimitiveProperty primitive_property, VertexProperty vertex_property = VertexProperty::Position) const;
1601
1607
1612 void setTree(DynamicPointer<RTree<3, fltp04>> tree, PrimitiveProperty primitive_property, VertexProperty vertex_property = VertexProperty::Position) const;
1613
1617
1622
1626 const Buffer<uint04>& getTreeIndices(PrimitiveProperty primitive_property) const;
1631 template<class t_type>
1633 {
1634 const Buffer<uint04>& indices = getTreeIndices(primitive_property);
1635 Buffer<t_type> original_vals = vertices<t_type>(vertex_property);
1636 Buffer<t_type> sorted_vertices(indices.size());
1637 sorted_vertices.setSize(indices.size(), Constant<t_type>::Invalid);
1638 for(uint04 i = 0; i < indices.size(); ++i)
1639 {
1640 if (indices[i] < original_vals.size())
1641 sorted_vertices[i] = original_vals[indices[i]];
1642 }
1643 return sorted_vertices;
1644 }
1645
1647 Ray<3, fltp08> surfaceNormal() const;
1648
1653 template<class t_type>
1654 void setVertex(VertexProperty property, uint04 index, const t_type& vector)
1655 {
1656 lib_assert(index < vertexCount(), "Out of bounds vertex set");
1657 column(property).set(vertexOffset() + index, vector);
1658 }
1659
1665 template<class t_type>
1666 void setVertex(VertexProperty property, uint04 index, uint04 sub_index, const t_type& vector)
1667 {
1668 lib_assert(index < vertexCount(), "Out of bounds vertex set");
1669 column(property).set(vertexOffset() + index, sub_index, vector);
1670 }
1671
1676 template<class t_type>
1677 void setVertices(VertexProperty property, const Buffer<t_type>& vertices, uint04 offset = 0)
1678 {
1679 lib_assert(offset + vertices.size() <= vertexCount(), "Out of bounds vertex set");
1680 uint04 vertex_offset = vertexOffset() + offset;
1681 auto& col = column(property);
1682 for (uint04 i = 0; i < vertices.size(); i++)
1683 {
1684 col.set(vertex_offset + i, vertices[i]);
1685 }
1686 }
1687
1693 template<class t_type, class t_matrix_type>
1694 void setVertices(VertexProperty property, const Buffer<t_type>& vertices, const Matrix<t_matrix_type>& matrix, uint04 offset = 0)
1695 {
1696 lib_assert(offset + vertices.size() <= vertexCount(), "Out of bounds vertex set");
1697 uint04 vertex_offset = vertexOffset() + offset;
1698 auto& col = column(property);
1699 for (uint04 i = 0; i < vertices.size(); i++)
1700 {
1701 col.set(vertex_offset + i, matrix * vertices[i].template as<t_type::NumberOfDimensions(), t_matrix_type>());
1702 }
1703 }
1704
1709 template<class t_type>
1710 void setVertices(VertexProperty property, const t_type* vertices, uint04 size, uint04 offset = 0)
1711 {
1712 lib_assert(offset + size <= vertexCount(), "Out of bounds vertex set");
1713 uint04 vertex_offset = vertexOffset() + offset;
1714 auto& col = column(property);
1715 for (uint04 i = 0; i < size; i++)
1716 {
1717 col.set(vertex_offset + i, vertices[i]);
1718 }
1719 }
1720
1724 template<class t_type>
1725 decltype(auto) vertex(VertexProperty property, uint04 index) const
1726 {
1727 lib_assert(index < vertexCount(), "Out of bounds vertex get");
1728 return column(property).get<t_type>(vertexOffset() + index);
1729 }
1730
1735 template<uint01 t_dims, class t_type>
1736 LineSegment<t_dims, t_type> lineSegment(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 line_index) const
1737 {
1738 const Vector<2, uint04> line = primitive<Vector<2, uint04>>(primitive_property, line_index);
1739 if (IsInvalid(line))
1740 return Constant<LineSegment<t_dims, t_type>>::Invalid;
1742 vertex<Vector<t_dims, t_type>>(vertex_property, line[A])
1743 , vertex<Vector<t_dims, t_type>>(vertex_property, line[B]));
1744 }
1745
1750 template<uint01 t_dims, class t_type>
1751 Triangle<t_dims, t_type> triangle(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 tri_index) const
1752 {
1753 const Vector<3, uint04> tri = primitive<Vector<3, uint04>>(primitive_property, tri_index);
1754 if (IsInvalid(tri))
1755 return Constant<Triangle<t_dims, t_type>>::Invalid;
1757 vertex<Vector<t_dims, t_type>>(vertex_property, tri[A])
1758 , vertex<Vector<t_dims, t_type>>(vertex_property, tri[B])
1759 , vertex<Vector<t_dims, t_type>>(vertex_property, tri[C]));
1760 }
1761
1764 bool hasColumn(VertexProperty property) const
1765 {
1766 return m_base->vertex_property_column[cast<uint01>(property)] != nullptr;
1767 }
1768
1771 template<class t_type>
1773 {
1774 return propertyVertices<t_type>(property, 0, vertexCount());
1775 }
1776
1781 template<class t_type>
1783 {
1784 lib_assert(start + size <= vertexCount(), "Out of bounds vertex selection");
1785 const uint04 vertex_offset = vertexOffset();
1786 return m_base->vertex_table[property].getAll<t_type>(vertex_offset + start, size);
1787 }
1788
1791 template<class t_type>
1793 {
1794 return vertices<t_type>(property, 0, vertexCount());
1795 }
1796
1802 template<class t_type>
1804 {
1805 lib_assert(start + size <= vertexCount(), "Out of bounds vertex selection");
1806 const uint04 vertex_offset = vertexOffset();
1807 return column(property).getAll<t_type>(vertex_offset + start, size);
1808 }
1809
1813 template<class t_type>
1814 Buffer<t_type> vertices(const StringView& property) const
1815 {
1816 return vertices<t_type>(property, 0, vertexCount());
1817 }
1818
1823 template<class t_type>
1824 Buffer<t_type> vertices(const StringView& property, uint04 start, uint04 size) const
1825 {
1826 lib_assert(start + size <= vertexCount(), "Out of bounds vertex selection");
1827 const uint04 vertex_offset = vertexOffset();
1828 return propertyColumn(property).getAll<t_type>(vertex_offset + start, size);
1829 }
1830
1835 template<uint01 t_dims, class t_type>
1837 {
1838 uint04 size = primitiveCount(primitive_property);
1839 switch (mode(primitive_property))
1840 {
1842 break;
1844 --size;//polylines have 1 less line segment than number of indices
1845 break;
1846 default:
1847 lib_assert(false, "Bad property fetch mode");
1848 }
1850 for (uint04 i = 0; i < size; ++i)
1851 lines.add(lineSegment<t_dims, t_type>(primitive_property, vertex_property, i));
1852 return lines;
1853 }
1854
1858 template<uint01 t_dims, class t_type>
1860 {
1861 return triangles<t_dims, t_type>(primitive_property, vertex_property, 0, primitiveCount(primitive_property));
1862 }
1863
1870 template<uint01 t_dims, class t_type>
1871 Buffer<Triangle<t_dims, t_type>> triangles(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
1872 {
1873 lib_assert(start + size <= primitiveCount(primitive_property), "Out of bounds triangle selection");
1874 const uint04 index_offset = indexOffset() + indexOffset(primitive_property);
1875 const PrimitiveMode index_mode = mode(primitive_property);
1876 const TableColumn& index_column = primitiveColumn();
1877 const TableColumn& fan_column = primitiveFanColumn();
1878 const TableColumn& vertex_column = column(vertex_property);
1880
1881 for (uint04 i = start; i < size + start; i++)
1882 {
1883 Vector<3, uint04> index_value;
1884 switch (index_mode)
1885 {
1887 index_value = {
1888 index_column.get<uint04>(index_offset + 3 * i + 0)
1889 , index_column.get<uint04>(index_offset + 3 * i + 1)
1890 , index_column.get<uint04>(index_offset + 3 * i + 2) };
1891 break;
1893 index_value = {
1894 index_column.get<uint04>(i + index_offset + 0)
1895 , index_column.get<uint04>(i + index_offset + 1)
1896 , index_column.get<uint04>(i + index_offset + 2) };
1897 break;
1899 {
1900 const uint04 fan_offset = indexFanOffset();
1901 uint04 index_fan_location = fan_column.get<uint04>(i + fan_offset);
1902 if (IsInvalid(index_fan_location))
1903 {
1904 index_value = Constant<Vector<3, uint04>>::Invalid;
1905 }
1906 else
1907 {
1908 lib_assert(index_fan_location >= index_offset && index_fan_location - index_offset < primitiveCount(primitive_property), "bad fan location");
1909 index_value = {
1910 index_column.get<uint04>(index_fan_location)
1911 , index_column.get<uint04>(i + index_offset - 1)
1912 , index_column.get<uint04>(i + index_offset) };
1913 }
1914 } break;
1915 default:
1916 lib_assert(false, "Bad property fetch mode");
1917 }
1918 if (IsInvalid(index_value))
1919 {
1921 }
1922 else
1923 {
1925 vertex_column.get<Vector<t_dims, t_type>>(index_value[A])
1926 , vertex_column.get<Vector<t_dims, t_type>>(index_value[B])
1927 , vertex_column.get<Vector<t_dims, t_type>>(index_value[C])));
1928 }
1929 }
1930 return triangles;
1931 }
1932
1936
1942 Buffer<Buffer<uint04>> polyIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const;
1947 template<uint01 t_dims, class t_type>
1949 {
1950 return polygons<t_dims, t_type>(primitive_property, vertex_property, 0, primitiveCount(primitive_property));
1951 }
1952
1959 template<uint01 t_dims, class t_type>
1961 {
1962 lib_assert(start + size <= primitiveCount(primitive_property), "Out of bounds polygon selection");
1963 const uint04 index_offset = indexOffset() + indexOffset(primitive_property);
1964 //const uint04 vertex_offset = vertexOffset();
1965 const PrimitiveMode index_mode = mode(primitive_property);
1966 const TableColumn& index_column = primitiveColumn();
1967 const TableColumn& vertex_column = column(vertex_property);
1969 switch (index_mode)
1970 {
1974 {
1975 const TableColumn& fan_column = primitiveFanColumn();
1976 const uint04 fan_offset = indexFanOffset();
1977 for (uint04 i = start; i < size + start; i++)
1978 {
1979 Vector<3, uint04> index_value;
1980 switch (index_mode)
1981 {
1983 index_value = {
1984 index_column.get<uint04>(index_offset + 3 * i + 0)
1985 , index_column.get<uint04>(index_offset + 3 * i + 1)
1986 , index_column.get<uint04>(index_offset + 3 * i + 2) };
1987 break;
1989 index_value = {
1990 index_column.get<uint04>(i + index_offset + 0)
1991 , index_column.get<uint04>(i + index_offset + 1)
1992 , index_column.get<uint04>(i + index_offset + 2) };
1993 break;
1995 {
1996 uint04 index_fan_location = fan_column.get<uint04>(i + fan_offset);
1997 if (IsInvalid(index_fan_location))
1998 index_value = Constant<Vector<3, uint04>>::Invalid;
1999 else
2000 index_value = {
2001 index_column.get<uint04>(index_fan_location)
2002 , index_column.get<uint04>(i + index_offset - 1)
2003 , index_column.get<uint04>(i + index_offset) };
2004 } break;
2005 default:
2006 lib_assert(false, "Bad property fetch mode");
2007 }
2008 if (IsValid(index_value))
2009 {
2010 polygons.add(Polygon<t_type, Vertex<t_dims, t_type>>(3));
2011 polygons.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[A]));
2012 polygons.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[B]));
2013 polygons.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[C]));
2014
2015 }
2016 }
2017 } break;
2019 {
2021 for (uint04 i = start; i < size + start; i++)
2022 {
2023 uint04 index = index_column.get<uint04>(index_offset + i);
2024 if (IsValid(index))
2025 {
2026 poly.add(vertex_column.get<Vector<t_dims, t_type>>(index));
2027 }
2028 else
2029 {
2030 if (poly.vertexCount() > 0)
2031 {
2032 polygons.add(poly);
2033 poly.clear();
2034 }
2035 }
2036 }
2037 if (poly.vertexCount() > 0)
2038 {
2039 polygons.add(poly);
2040 }
2041 } break;
2042 default:
2043 break;
2044 }
2045 return polygons;
2046 }
2047
2052 template<uint01 t_dims, class t_type>
2054 {
2055 uint04 primitive_count = primitiveCount(primitive_property);
2056 if(primitive_count == 0)
2057 return polylines<t_dims, t_type>(primitive_property, vertex_property, 0, vertexCount());
2058 else
2059 return polylines<t_dims, t_type>(primitive_property, vertex_property, 0, primitiveCount(primitive_property));
2060 }
2061
2067 template<uint01 t_dims, class t_type>
2068 Buffer<Polyline<t_dims, t_type>> polylines(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
2069 {
2070 const uint04 primitive_count = primitiveCount(primitive_property);
2071 lib_assert(primitive_count == 0 || start + size <= primitive_count, "Out of bounds polyline selection");
2072 const uint04 index_offset = primitive_count == 0 ? vertexOffset() : indexOffset() + indexOffset(primitive_property);
2073 const PrimitiveMode index_mode = mode(primitive_property);
2074 const TableColumn& index_column = primitiveColumn();
2075 const TableColumn& vertex_column = column(vertex_property);
2077 switch (index_mode)
2078 {
2082 {
2083 if (primitive_count == 0)
2084 return polylines;//not yet finished
2085 const TableColumn& fan_column = primitiveFanColumn();
2086 const uint04 fan_offset = indexFanOffset();
2087 for (uint04 i = start; i < size + start; i++)
2088 {
2089 Vector<3, uint04> index_value;
2090 switch (index_mode)
2091 {
2093 index_value = {
2094 index_column.get<uint04>(index_offset + 3 * i + 0)
2095 , index_column.get<uint04>(index_offset + 3 * i + 1)
2096 , index_column.get<uint04>(index_offset + 3 * i + 2) };
2097 break;
2099 index_value = {
2100 index_column.get<uint04>(i + index_offset + 0)
2101 , index_column.get<uint04>(i + index_offset + 1)
2102 , index_column.get<uint04>(i + index_offset + 2) };
2103 break;
2105 {
2106 uint04 index_fan_location = fan_column.get<uint04>(i + fan_offset);
2107 if (IsInvalid(index_fan_location))
2108 index_value = Constant<Vector<3, uint04>>::Invalid;
2109 else
2110 index_value = {
2111 index_column.get<uint04>(index_fan_location)
2112 , index_column.get<uint04>(i + index_offset - 1)
2113 , index_column.get<uint04>(i + index_offset) };
2114 } break;
2115 default:
2116 lib_assert(false, "Bad property fetch mode");
2117 }
2118 if (IsValid(index_value))
2119 {
2121 polylines.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[A]));
2122 polylines.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[B]));
2123 polylines.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[C]));
2124 polylines.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[A]));
2125
2126 }
2127 }
2128 } break;
2130 {
2132 for (uint04 i = start; i < size + start; i++)
2133 {
2134 uint04 index = primitive_count > 0 ? index_column.get<uint04>(index_offset + i) : i + index_offset;
2136 if (IsValid(index))
2137 vert = vertex_column.get<Vector<t_dims, t_type>>(index);
2138
2139 if (IsValid(vert))
2140 {
2141 poly.add(vert);
2142 }
2143 else
2144 {
2145 if (poly.vertexCount() > 0)
2146 {
2147 polylines.add(poly);
2148 poly.clear();
2149 }
2150 }
2151 }
2152 if (poly.vertexCount() > 0)
2153 {
2154 polylines.add(poly);
2155 }
2156 } break;
2158 {
2160 if (primitive_count == 0)
2161 start++;//prevent overflow
2162 for (uint04 i = start; i < size + start; i++)
2163 {
2165 if (primitive_count == 0)
2166 {
2167 index = Vector<2, uint04>(i - 1, i) + index_offset;
2168 i++;//increment i by one since
2169 }
2170 else
2171 {
2173 index_column.get<uint04>(index_offset + 2 * i + 0)
2174 , index_column.get<uint04>(index_offset + 2 * i + 1));
2175 }
2176 if (IsValid(index))
2177 {
2178 Vertex<3, fltp08> vert_a = vertex_column.get<Vector<t_dims, t_type>>(index[A]);
2179 if (IsInvalid(vert_a))
2180 continue;
2181 Vertex<3, fltp08> vert_b = vertex_column.get<Vector<t_dims, t_type>>(index[B]);
2182 if (IsInvalid(vert_b))
2183 continue;
2184 poly.add(vert_a);
2185 poly.add(vert_b);
2186 polylines.add(poly);
2187 poly.clear();
2188 }
2189 }
2190 } break;
2191 default:
2192 break;
2193 }
2194 return polylines;
2195 }
2196
2201
2206 {
2207 return *m_base->vertex_property_column[cast<uint01>(property)];
2208 }
2209
2213 const TableColumn& column(VertexProperty property) const
2214 {
2215 return *m_base->vertex_property_column[cast<uint01>(property)];
2216 }
2217
2221 {
2222 TableColumn* column = m_base->vertex_property_column[eint01(VertexProperty::BitFlag)];
2223 if (column == nullptr)
2224 return nullptr;
2225 return dynamic_cast<TableVectorType<1, uint01>*>(column);
2226 };
2227
2231 {
2232 TableColumn* column = m_base->vertex_property_column[eint01(VertexProperty::BitFlag)];
2233 if (column == nullptr)
2234 return nullptr;
2235 return dynamic_cast<TableVectorType<1, uint01>*>(column);
2236 };
2237 public:
2242 {
2243 return m_base->vertex_table.get(property);
2244 }
2245
2249 const TableColumn& propertyColumn(const StringView& property) const
2250 {
2251 return m_base->vertex_table.get(property);
2252 }
2253
2254
2258 {
2259 m_base->solid_vertex_count_column[m_design_index] = count;
2260 }
2261
2265 {
2266 m_base->solid_vertex_reserved_count_column[m_design_index] = count;
2267 }
2268
2272 {
2273 m_base->solid_vertex_offset_column[m_design_index] = count;
2274 }
2275
2278
2282
2285 void addFromParent(Model& parent);
2286
2289 void removeParent(Model& parent);
2290 protected:
2295 template<class t_index_type, class t_vec_type>
2296 void setPrimitiveVec(PrimitiveProperty property, uint04 index, t_vec_type& index_value)
2297 {
2298 lib_assert(index < primitiveCount(property), "Bad index set");
2299 if (IsValid(index_value))
2300 {
2301#ifdef _DEBUG
2302 uint04 vertex_count = vertexCount();
2303 lib_assert(index_value[A] < vertex_count, "Bad vertex A");
2304 lib_assert(index_value[B] < vertex_count, "Bad vertex B");
2305 lib_assert(index_value[C] < vertex_count, "Bad vertex C");
2306#endif
2307 index_value += t_vec_type(vertexOffset());
2308 }
2309 else
2310 {
2311 index_value = Constant<t_vec_type>::Invalid;
2312 }
2315 {
2316 primitiveFanColumn()[index + indexFanOffset()] = index_value[A];
2317 (*def.column)[def.index_offset + index - 1] = index_value[B];
2318 (*def.column)[def.index_offset + index - 0] = index_value[C];
2319 }
2320 else
2321 {
2322 OptimizedSetPrimitiveVec(def, index, index_value);
2323 }
2324 }
2325
2328
2332 {
2333 m_base->index_mode_size_column[m_design_index] = count;
2334 }
2335
2339 {
2340 m_base->index_fan_size_column[m_design_index] = count;
2341 }
2342
2347 {
2348 (*m_base->primitive_property_size_column[cast<uint01>(property)])[m_design_index] = count;
2349 }
2350
2354 {
2355 m_base->index_fan_offset_column[m_design_index] = offset;
2356 }
2357
2361 {
2362 m_base->index_mode_offset_column[m_design_index] = offset;
2363 }
2364
2369 {
2370 (*m_base->primitive_property_offset_column[cast<uint01>(property)])[m_design_index] = offset;
2371 }
2372
2377 {
2378 m_base->primitive_property_mode_column[cast<uint01>(property)]->set(m_design_index, mode);
2379 }
2380
2381
2384
2388 {
2389 m_base->vertex_count_column[m_design_index] = count;
2390 }
2391
2395 {
2396 m_base->vertex_reserved_count_column[m_design_index] = count;
2397 }
2398
2402 {
2403 m_base->vertex_offset_column[m_design_index] = count;
2404 }
2405
2406
2407
2408
2412 void setModeValue(VertexProperty property, VertexMode vert_mode)
2413 {
2414 lib_assert(vert_mode != e_index, "Not yet supported");
2415 m_base->vertex_mode_column[cast<uint01>(property)]->set(m_design_index, vert_mode);
2416 }
2417
2418
2419 private:
2423 void reserveVertexSpace(uint04 count, uint04 current_reserve_count);
2424 protected:
2425 static std::function<void(Geometry& geo, const Matrix<fltp08>& matrix, const void* lock, LogPtr log)> s_geometry_triangulation;
2426 };
2427
2431 template<>
2432 struct ObjectInfo<Geometry, false, false>
2433 {
2434 static const uint01 Dimensions = 0;
2435 static const bool Vector = false;
2436 static const bool Buffer = false;
2437 static const bool Primitive = true;
2438 static const bool Pointer = false;
2439 static const bool Unsigned = false;
2440 static const bool Float = false;
2441 static const bool Integer = false;
2442 static const bool Number = false;
2443 static const bool Enum = false;
2444 static const bool String = false;
2445 static const bool Color = false;
2446 static const bool Boolean = false;
2447 static constexpr ObjectInfo<Geometry, false, false> VectorSub() { return ObjectInfo<Geometry, false, false>(); }
2448 };
2449
2455 {
2456 public:
2459 : m_column(nullptr)
2460 , m_flag_column(nullptr)
2462 , m_vertex_offset(0)
2463 , m_vertex_count(0)
2464 {
2465 }
2466
2471 : m_geo(geo)
2472 , m_column(&geo.column(vertex_property))
2473 , m_flag_column(geo.hasVertexProperty(VertexProperty::BitFlag) ? &geo.column(VertexProperty::BitFlag) : nullptr)
2474 , m_vertex_property(vertex_property)
2475 , m_vertex_offset(geo.vertexOffset())
2476 , m_vertex_count(geo.vertexCount())
2477
2478 {}
2479
2483 VertexLookup(const StringView& vertex_property, Geometry geo)
2484 : m_geo(geo)
2485 , m_column(&geo.propertyColumn(vertex_property))
2486 , m_flag_column(geo.hasVertexProperty(VertexProperty::BitFlag) ? &geo.column(VertexProperty::BitFlag) : nullptr)
2488 , m_vertex_offset(geo.vertexOffset())
2489 , m_vertex_count(geo.vertexCount())
2490
2491 {}
2492
2496 template<class t_type>
2497 t_type get(uint04 index) const
2498 {
2499 //const BitFlag flag = m_flag_column.get<uint01>(m_vertex_offset + index);
2500 //if (flag[cast<uint01>(VertexBitFlags::e_is_hidden)])
2501 //return Constant<Vertex<t_dims, t_type>>::Invalid;
2502 return m_column->get<t_type>(m_vertex_offset + index);
2503 }
2504
2507 BitFlag flag(uint04 index) const
2508 {
2509 BitFlag flag(0);
2510 if (m_flag_column == nullptr)
2511 return flag;
2512 flag = m_flag_column->get<uint01>(m_vertex_offset + index);
2513 return flag;
2514 }
2515
2518 void swap(uint04 a, uint04 b)
2519 {
2521 }
2522
2526 template<class t_type>
2527 void setVertex(uint04 index, const t_type& value)
2528 {
2529 return m_column->set(m_vertex_offset + index, value);
2530 }
2531
2535 void setFlag(uint04 index, const BitFlag& value)
2536 {
2537 if (m_flag_column == nullptr)
2538 {
2539 if (value == BitFlag(0))
2540 return;
2541 m_geo.ensureFlagColumnExists();
2543 }
2544 return m_flag_column->set(m_vertex_offset + index, value);
2545 }
2546
2549 uint04 size() const
2550 {
2551 return m_vertex_count;
2552 }
2559 };
2560
2564 template<class t_type>
2565 class VertexIterator : public VertexLookup
2566 {
2567 public:
2568 VertexIterator()
2569 {}
2570
2575 : VertexLookup(vertex_property, geo)
2576 {}
2577
2581 VertexIterator(const StringView& vertex_property, Geometry geo)
2582 : VertexLookup(vertex_property, geo)
2583 {}
2584
2588 t_type operator[](uint04 index) const
2589 {
2590 return get<t_type>(index);
2591 }
2592 };
2593
2597 template<uint01 t_dims, class t_type>
2599 {
2600 public:
2603 : m_primitive_def(Geometry::OptimizedPrimitiveDef())
2604 , m_vertex_column(nullptr)
2605 , m_flag_column(nullptr)
2607 , m_vertex_offset(0)
2608 {}
2609
2614 LineIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry geo)
2615 : m_vertex_column(&geo.column(vertex_property))
2616 , m_flag_column(geo.hasVertexProperty(VertexProperty::BitFlag) ? &geo.column(VertexProperty::BitFlag) : nullptr)
2617 , m_primitive_count(geo.primitiveCount(primitive_property))
2618 , m_vertex_offset(geo.vertexOffset())
2619 {
2620 if (m_primitive_count == 0)
2621 {
2622 m_primitive_def.mode = geo.mode(primitive_property);
2623 switch (m_primitive_def.mode)
2624 {
2627 if (m_primitive_count > 0)
2629 break;
2631 m_primitive_count = geo.vertexCount() / 2;
2632 break;
2633 default:
2634 lib_assert(false, "Unknown point type");
2635 break;
2636 }
2637 }
2638 else
2639 {
2640 m_primitive_def = geo.optimizedPrimitiveDef(primitive_property);
2642 m_primitive_count--;//since sending vertex count, segment count is one less
2643 }
2644 }
2645
2656 LineIterator& operator=(const LineIterator& other) = default;
2657
2662 {
2663 Vector<2, uint04> index_vert = rawIndex(index);
2664 for (uint01 i = 0; i < 2; i++)
2665 {
2666 if (IsInvalid(index_vert[i]))
2667 index_vert[i] = Constant<uint04>::Invalid;
2668 else
2669 index_vert[i] -= m_vertex_offset;
2670 }
2671 return index_vert;
2672 }
2673
2676 template<class t_line_type>
2678 {
2679 Vector<2, uint04> index_vert = rawIndex(index);
2680 if (IsInvalid(index_vert[0]) || IsInvalid(index_vert[1]) || isHidden(index_vert[0]))
2681 {
2683 }
2685 m_vertex_column->get(index_vert[0], seg[0]);
2686 m_vertex_column->get(index_vert[1], seg[1]);
2687 return seg;
2688 }
2689
2693 {
2694 return get<t_type>(index);
2695 }
2696
2699 uint04 size() const
2700 {
2701 return m_primitive_count;
2702 }
2703 protected:
2708 {
2709 if (m_primitive_def.column == nullptr)
2710 return Vector<2, uint04>(m_vertex_offset + index, m_vertex_offset + index + 1);
2711 else
2713 }
2714
2717 bool isHidden(uint04 index) const
2718 {
2719 if (m_flag_column == nullptr)
2720 return false;
2721 BitFlag bit_flags = m_flag_column->get<uint01>(index);
2722 return bit_flags[cast<uint01>(VertexFlags::e_is_hidden)];
2723 }
2730 };
2731
2735 template<uint01 t_dims, class t_type>
2737 {
2738 public:
2741 : m_vertex_column(nullptr)
2742 , m_vertex_offset(0)
2743 {}
2744
2749 TriangleIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry mesh)
2750 : m_primitive_def(mesh.optimizedPrimitiveDef(primitive_property))
2751 , m_vertex_column(&mesh.column(vertex_property))
2752 , m_flag_column(mesh.hasVertexProperty(VertexProperty::BitFlag) ? &mesh.column(VertexProperty::BitFlag) : nullptr)
2753 , m_primitive_count(mesh.primitiveCount(primitive_property))
2754 , m_vertex_offset(mesh.vertexOffset())
2755 {
2757 m_primitive_count -= 2;//primitive count is vertices so minus 2 triangles
2758 }
2759
2763 TriangleIterator(PrimitiveProperty primitive_property, const StringView& vertex_property, Geometry mesh)
2764 : m_primitive_def(mesh.optimizedPrimitiveDef(primitive_property))
2765 , m_vertex_column(&mesh.propertyColumn(vertex_property))
2766 , m_flag_column(mesh.hasVertexProperty(VertexProperty::BitFlag) ? &mesh.column(VertexProperty::BitFlag) : nullptr)
2767 , m_primitive_count(mesh.primitiveCount(primitive_property))
2768 , m_vertex_offset(mesh.vertexOffset())
2769 {
2771 m_primitive_count -= 2;//primitive count is vertices so minus 2 triangles
2772 }
2773
2776 template<class t_tri_type>
2778 {
2779 Vector<3, uint04> index_vert = rawIndex(index);
2781 for (uint01 i = 0; i < 3; i++)
2782 {
2783 if (IsInvalid(index_vert[i]))
2784 tri[i] = Constant<t_tri_type>::Invalid;
2785 else
2786 m_vertex_column->get(index_vert[i], tri[i]);
2787
2788 }
2789 return tri;
2790 }
2791
2795 {
2796 return get<t_type>(index);
2797 }
2798
2803 {
2804 Vector<3, uint04> index_vert = rawIndex(index);
2805 for (uint01 i = 0; i < 3; i++)
2806 {
2807 if (IsValid(index_vert[i]))
2808 index_vert[i] -= m_vertex_offset;
2809 }
2810 return index_vert;
2811 }
2812
2816 {
2818 if (m_flag_column == nullptr)
2819 return flag;
2820 Vector<3, uint04> index_vert = rawIndex(index);
2821 for (uint01 i = 0; i < 3; i++)
2822 flag[i] = m_flag_column->get<uint01>(index_vert[i]);
2823 return flag;
2824 }
2825
2827 uint04 size() const
2828 {
2829 return m_primitive_count;
2830 }
2831 protected:
2844 };
2845
2851 {
2852 public:
2856
2860 {
2861 store(geo);
2862 }
2863
2866 void store(const Geometry& geo);
2867
2871 void restoreNormals(const void* lock, LogPtr ptr = LogPtr());
2872
2876 void restoreClosed(const void* lock, LogPtr ptr = LogPtr());
2877
2881 void restoreAll(const void* lock, LogPtr ptr = LogPtr());
2882
2886 void restoreSmooth(const void* lock, LogPtr ptr = LogPtr());
2887
2888 bool restore_closed = true;
2889 bool restore_normals = true;
2890 bool restore_smooth = true;
2891 protected:
2896 void restoreNormals(Geometry& geo, const void* lock, LogPtr ptr = LogPtr());
2897
2902 void restoreClosed(Geometry& geo, const void* lock, LogPtr ptr = LogPtr());
2903
2904 bool m_has_tangent = false;
2905 bool m_has_bitangent = false;
2906 bool m_is_closed = false;
2908 fltp04 smoothing_angle = Constant<fltp04>::Invalid;
2912 };
2913
2914
2915 template class NDEVR_DESIGN_API StringStream<NDPG>;
2916}
2917
2921namespace std
2922{
2923 template <>
2924 struct hash<Geometry>
2925 {
2929 std::size_t operator()(const Geometry& d) const noexcept
2930 {
2931 UUID s = d.get<NDPO::guid>();
2932 std::size_t value = 0;
2933 for (uint01 i = 0; i < 8; i++)
2934 value = value * 256 + (s[i + 0U] ^ s[i + 8U]);
2935 return value;
2936 }
2937 };
2938};
2939#include <NDEVR/Model.h>
2940namespace NDEVR
2941{
2944 {
2945 return Model(m_base->geometry_parent[m_design_index][index], m_base);
2946 }
2947
2949 {
2950 return m_base->geometry_parent[m_design_index].size();
2951 }
2952}
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Definition Angle.h:83
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
void add(t_type &&object)
Adds object to the end of the buffer.
Definition Buffer.hpp:190
Base information class for all design objects in the NDEVR property database.
uint04 m_index
Row index of this object within the property database.
uint04 m_design_index
Index of the parent design that owns this object.
DesignObjectBase * m_base
Pointer to the owning DesignObjectBase property database.
Provides the underlying data storage for the NDEVR Scene Model hierarchy.
DesignObject()=default
Creates an "invalid" design object.
constexpr decltype(auto) get(t_property_type property) const
Retrieves a property value from the database, cast to the requested type.
uint04 index() const
Returns the primary row index of this object within the DesignObjectBase property table.
bool isValid() const
Checks whether this design object has a valid index into the database.
DesignObjectBase & base() const
Returns a reference to the underlying DesignObjectBase database.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
GeometryPositionModRestore()
Default constructor.
Definition Geometry.h:2854
void restoreNormals(const void *lock, LogPtr ptr=LogPtr())
Restores previously stored normal data.
bool restore_smooth
Whether to restore smoothing data.
Definition Geometry.h:2890
String m_smoothing_algo
The stored smoothing algorithm name.
Definition Geometry.h:2909
void restoreAll(const void *lock, LogPtr ptr=LogPtr())
Restores all previously stored calculated data (normals, closed, smooth).
void restoreClosed(const void *lock, LogPtr ptr=LogPtr())
Restores previously stored closed-solid state.
NormalMode normal_mode
The stored normal mode.
Definition Geometry.h:2907
bool restore_normals
Whether to restore normal data.
Definition Geometry.h:2889
bool m_has_tangent
Whether the geometry had tangent data.
Definition Geometry.h:2904
bool m_has_bitangent
Whether the geometry had bitangent data.
Definition Geometry.h:2905
GeometryPositionModRestore(const Geometry &geo)
Constructs and immediately stores the geometry state for later restoration.
Definition Geometry.h:2859
uint04 m_smoothing_times
The stored number of smoothing iterations.
Definition Geometry.h:2910
void restoreClosed(Geometry &geo, const void *lock, LogPtr ptr=LogPtr())
Internal: restores closed-solid state for a specific geometry.
bool restore_closed
Whether to restore the closed-solid state.
Definition Geometry.h:2888
void store(const Geometry &geo)
Captures the current calculated state of the geometry.
Geometry m_geo
The geometry being restored.
Definition Geometry.h:2911
bool m_is_closed
Whether the geometry was a closed solid.
Definition Geometry.h:2906
void restoreNormals(Geometry &geo, const void *lock, LogPtr ptr=LogPtr())
Internal: restores normals for a specific geometry.
fltp04 smoothing_angle
The stored normal smoothing angle.
Definition Geometry.h:2908
void restoreSmooth(const void *lock, LogPtr ptr=LogPtr())
Restores previously stored smoothing data.
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
StringView getGeometryIcon() const
Retrieves the icon identifier string for this geometry type.
void updateVertexColumn(VertexProperty property)
Notifies the system that a standard vertex column has been modified.
Buffer< Polyline< t_dims, t_type > > polylines(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Retrieves all polylines from the geometry.
Definition Geometry.h:2053
void updateGeometryTransform(const Matrix< fltp08 > &transform, const void *lock_ptr=nullptr)
Updates geometry after a transform change, recalculating derived data.
ThicknessMode thicknessMode() const
Retrieves the current thickness mode.
Buffer< Polygon< t_type, Vertex< t_dims, t_type > > > polygons(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
Retrieves a range of polygons from the geometry.
Definition Geometry.h:1960
Buffer< Polyline< t_dims, t_type > > polylines(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
Retrieves a range of polylines from the geometry.
Definition Geometry.h:2068
Ray< 3, fltp08 > surfaceNormal() const
Calculates and returns the surface normal ray for this geometry.
bool validate() const
Validates the internal consistency of the geometry data.
void updateVertexColumns(bool invalidate_bounds=true, bool erase_kd_tree=true)
Notifies the system that all vertex columns have been modified.
static constexpr uint04 indicesPerPrimitive(PrimitiveMode property)
Returns the number of vertex indices per primitive for a given mode.
Definition Geometry.h:930
void setVertexFlag(uint04 vertex, VertexFlags flag, bool value)
Sets a flag on a single vertex.
void removeTree(PrimitiveProperty property, VertexProperty vertex_property=VertexProperty::Position)
Removes the spatial tree for a specific primitive property.
uint04 indexOffset(PrimitiveProperty property) const
Returns the index offset for a specific primitive property.
Definition Geometry.h:1095
ColumnT< uint01 > & primitiveFlagColumn()
Returns a mutable reference to the primitive flag column.
Definition Geometry.h:600
void laplacianSmoothing(const SmoothingParameters &properties)
Applies Laplacian smoothing to the mesh.
void setSolidVertexCountValue(uint04 count)
Sets the solid vertex count value in the database.
Definition Geometry.h:2257
void setVertex(VertexProperty property, uint04 index, uint04 sub_index, const t_type &vector)
Sets a sub-component of a standard vertex property at the given index.
Definition Geometry.h:1666
Model getParent(uint04 index) const
Retrieves a specific parent Model by index.
Definition Geometry.h:2943
VertexMode
Describes the storage format and coordinate system of vertex data.
Definition Geometry.h:150
@ e_bitflag
Bitflag vertex data.
Definition Geometry.h:173
@ e_cartesian_3D
3D Cartesian coordinates, double-precision float.
Definition Geometry.h:158
@ e_color_hsb
HSB color data.
Definition Geometry.h:168
@ e_cartesian_3F
3D Cartesian coordinates, single-precision float.
Definition Geometry.h:156
@ e_cartesian_3S
3D Cartesian coordinates, short integer.
Definition Geometry.h:177
@ e_normal_ray_3F
3D normal ray, single-precision float.
Definition Geometry.h:159
@ e_index
Vertices stored as indices into another buffer.
Definition Geometry.h:152
@ e_color_xyz
CIE XYZ color data.
Definition Geometry.h:172
@ e_normal_ray_3D
3D normal ray, double-precision float.
Definition Geometry.h:160
@ e_cartesian_1D
1D Cartesian coordinates, double-precision float.
Definition Geometry.h:154
@ e_color_rgb
RGB color data.
Definition Geometry.h:171
@ e_cartesian_grid_1D
1D Cartesian grid, double-precision float.
Definition Geometry.h:163
@ e_cartesian_3I
3D Cartesian coordinates, integer.
Definition Geometry.h:175
@ e_cartesian_grid_3D
3D Cartesian grid, double-precision float.
Definition Geometry.h:164
@ e_color_aci
AutoCAD Color Index color data.
Definition Geometry.h:167
@ e_cartesian_grid_image
Cartesian grid for image data.
Definition Geometry.h:165
@ e_cartesian_grid_3F
3D Cartesian grid, single-precision float.
Definition Geometry.h:162
@ e_cartesian_2S
2D Cartesian coordinates, short integer.
Definition Geometry.h:176
@ e_cartesian_grid_1F
1D Cartesian grid, single-precision float.
Definition Geometry.h:161
@ e_color_lab
CIELAB color data.
Definition Geometry.h:170
@ e_color_hsl
HSL color data.
Definition Geometry.h:169
@ e_no_vertex
No vertex data present.
Definition Geometry.h:151
@ e_polar_grid_1F
1D polar grid, single-precision float.
Definition Geometry.h:166
@ e_cartesian_1F
1D Cartesian coordinates, single-precision float.
Definition Geometry.h:153
@ e_cartesian_2F
2D Cartesian coordinates, single-precision float.
Definition Geometry.h:155
@ e_cartesian_2D
2D Cartesian coordinates, double-precision float.
Definition Geometry.h:157
@ e_cartesian_2I
2D Cartesian coordinates, integer.
Definition Geometry.h:174
Buffer< Polygon< t_type, Vertex< t_dims, t_type > > > polygons(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Retrieves all polygons from the geometry.
Definition Geometry.h:1948
void setVertices(VertexProperty property, const Buffer< t_type > &vertices, const Matrix< t_matrix_type > &matrix, uint04 offset=0)
Sets vertices with a transformation matrix applied to each value.
Definition Geometry.h:1694
bool hasTree(PrimitiveProperty primitive_property, VertexProperty vertex_property=VertexProperty::Position) const
Checks whether a spatial tree exists for the given primitive and vertex property.
void copyFrom(const Geometry &geo, bool copy_tree=true, bool copy_vertices=true)
Copies all data from another geometry into this one.
bool hasIndexFanColumn() const
Checks whether the primitive fan index column has any entries.
Definition Geometry.h:665
TypeInfo vertexPropertyType(uint04 property_index) const
Returns the type information for a vertex property column.
Definition Geometry.h:1339
const Buffer< uint04 > & getTreeIndices(PrimitiveProperty primitive_property) const
Retrieves the index mapping used by the spatial tree.
void removeVertices(Buffer< uint04 > vertices)
Removes vertices at the specified indices.
void updateVertexColumn(VertexProperty property, uint04 index, uint04 size, bool invalidate_bounds=true, bool erase_kd_tree=true)
Notifies the system that a range within a standard vertex column was modified.
void setSolidVertexReservedValue(uint04 count)
Sets the solid vertex reserved count value in the database.
Definition Geometry.h:2264
void invalidateBounds()
Invalidates cached bounding box, forcing recalculation on next access.
void updateSolidVertexColumns(bool invalidate_bounds=true, bool erase_kd_tree=true)
Notifies the system that all solid vertex columns have been modified.
uint04 parentCount() const
Returns the number of parent Models referencing this geometry.
Definition Geometry.h:2948
t_type primitive(PrimitiveProperty property, typename std::enable_if< ObjectInfo< t_type >::Dimensions<=1, uint04 >::type index) const
Retrieves a scalar (1D) primitive index value, adjusted for vertex offset.
Definition Geometry.h:949
bool canBeClosedSolid(const void *lock=nullptr) const
Checks whether this geometry can form a closed solid (watertight mesh).
Buffer< t_type > vertices(const StringView &property) const
Retrieves all vertex values for a named custom property.
Definition Geometry.h:1814
GeometryBuffer explode() const
Explodes this geometry into individual primitive geometries.
ModelBuffer getParents() const
Retrieves all parent Models of this geometry.
void setNormalMode(NormalMode mode, Angle< fltp08 > max_sep_angle, const void *lock=nullptr, LogPtr log=LogPtr())
Sets the normal calculation mode and recalculates normals.
uint01 provokingPrimitiveOffset() const
Returns the provoking primitive offset for flat shading.
bool hasVertexProperty(const StringView &property_name) const
Checks whether a named vertex property exists.
uint04 createVertexProperty(const StringView &property_name, const TypeInfo &type)
Creates a new custom vertex property column with a runtime type.
void setVertexReservedValue(uint04 count)
Sets the vertex reserved count in the database.
Definition Geometry.h:2394
uint04 solidVertexReservedCount() const
Returns the reserved capacity for solid vertices.
Definition Geometry.h:1294
TableColumn & faceToEdgeColumn()
Returns a mutable reference to the face-to-edge mapping column.
Definition Geometry.h:614
void removeVertices(uint04 location, uint04 size)
Removes a contiguous range of vertices.
void setVerticesFlag(const Buffer< bool > &selection_mask, VertexFlags flag, bool value)
Sets a flag on vertices indicated by a boolean mask.
void setPrimitive(PrimitiveProperty property, uint04 index, Vector< 3, t_type > index_value)
Sets a triangle primitive (3-vertex index vector).
Definition Geometry.h:912
bool hasColumn(VertexProperty property) const
Checks whether the underlying column exists for a standard vertex property.
Definition Geometry.h:1764
Buffer< t_type > getTreeSortedVertices(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Retrieves vertices sorted according to the spatial tree index order.
Definition Geometry.h:1632
Plane< 3, fltp08 > calculatePlaneAtVertex(uint04 vertex_index) const
Calculates the best-fit plane at a given vertex position.
Buffer< Buffer< uint04 > > polyIndices(PrimitiveProperty primitive_property) const
Retrieves all polygon index buffers for a primitive property.
const TableColumn & column(VertexProperty property) const
Returns a const reference to the column for a standard vertex property.
Definition Geometry.h:2213
Geometry(DesignObjectBase *base)
Constructs a new Geometry and allocates it in the given design database.
Buffer< Triangle< t_dims, t_type > > triangles(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
Retrieves a range of triangles from the geometry.
Definition Geometry.h:1871
uint04 solidVertexCount() const
Returns the number of solid vertices.
Definition Geometry.h:1301
bool operator!=(const Geometry &geo) const
Checks inequality with another Geometry.
Definition Geometry.h:541
void splitDuplicateVertices()
Splits shared vertices so each primitive has its own unique vertex data.
void closePolyline(PrimitiveProperty property)
Closes an open polyline by connecting the last vertex to the first.
void setModeValue(PrimitiveProperty property, PrimitiveMode mode)
Sets the primitive mode for a property in the database.
Definition Geometry.h:2376
fltp08 calculateSurfaceArea(const Matrix< fltp08 > &parent_transform) const
Calculates the surface area of the geometry in the given coordinate space.
uint04 indexFanCount() const
Returns the number of fan indices for this geometry.
Definition Geometry.h:1109
Bounds< 3, fltp08 > getBounds() const
Retrieves the 3D bounding box of this geometry.
void setVerticesFlags(const Buffer< bool > &selection_mask, BitFlag on_flags, BitFlag off_flags)
Sets multiple flags on vertices using a boolean mask with on/off flag pairs.
void setGeometryTransform(const Matrix< fltp08 > &transform)
Applies a transformation matrix to all geometry vertices.
void createDrapedMaterialCoordinates(const Matrix< fltp08 > &mat=Matrix< fltp08 >())
Creates material (texture) coordinates by draping them onto the geometry surface.
uint04 vertexOffset() const
Returns the offset of this geometry's vertices within the shared vertex table.
Definition Geometry.h:1273
void updateModifiedTime(Time time=Time::SystemTime())
Updates the modified timestamp for this geometry.
void updatePrimitiveColumns(bool remove_tree=true)
Notifies the system that all primitive columns have been modified.
uint04 vertexReservedCount() const
Returns the total reserved (allocated) vertex capacity.
Definition Geometry.h:1266
bool canExplode() const
Checks whether this geometry can be exploded into individual primitives.
void setupVertexTable(uint04 vertex_size, VertexMode position, VertexMode normal=VertexMode::e_no_vertex, VertexMode color=VertexMode::e_no_vertex, VertexMode texture=VertexMode::e_no_vertex, VertexMode tangent=VertexMode::e_no_vertex, VertexMode bitangent=VertexMode::e_no_vertex, VertexMode bones=VertexMode::e_no_vertex)
Configures the vertex table with the specified modes for standard properties.
ColumnT< uint04 > & primitiveFanColumn()
Returns a mutable reference to the primitive fan column.
Definition Geometry.h:586
void cotangentLaplacianSmoothing(const SmoothingParameters &properties)
Applies cotangent-weighted Laplacian smoothing to the mesh.
Buffer< uint04 > primitiveIndices(PrimitiveProperty primitive_property) const
Retrieves all raw primitive indices for a given property.
Geometry(const DesignObject &obj)
Constructs a Geometry from a generic DesignObject.
void fillHolesByNeighbor(PrimitiveProperty property, const void *lock=nullptr, LogPtr log=LogPtr())
Fills holes in the mesh by interpolating from neighboring primitives.
const String & vertexPropertyName(uint04 property_index) const
Returns the name of a vertex property by its column index.
Definition Geometry.h:1312
void removeTrees(VertexProperty vertex_property=VertexProperty::Position)
Removes all spatial trees for the given vertex property.
uint04 addVertex()
Adds a single vertex to the geometry.
Definition Geometry.h:1181
void setVerticesFlagAll(uint01 on_flags, uint01 off_flags)
Sets on/off flag masks for all vertices.
TableColumn & edgeToFaceColumn()
Returns a mutable reference to the edge-to-face mapping column.
Definition Geometry.h:628
void updateGeometryTime(Time time=Time::SystemTime())
Updates the geometry-specific timestamp.
static void SetTriangulationMethod(std::function< void(Geometry &geo, const Matrix< fltp08 > &matrix, const void *lock, LogPtr log)> function)
Sets the global triangulation method used by autoCalculateIndices.
Buffer< t_type > vertices(const StringView &property, uint04 start, uint04 size) const
Retrieves a range of vertex values for a named custom property.
Definition Geometry.h:1824
Buffer< Vector< 3, uint04 > > triIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const
Retrieves a range of triangle index triples.
Buffer< Vector< 3, uint04 > > triIndices(PrimitiveProperty primitive_property) const
Retrieves all triangle index triples for a primitive property.
Definition Geometry.h:1072
const ColumnT< uint04 > & primitiveColumn() const
Returns a const reference to the primitive index column.
Definition Geometry.h:579
void setVertexCountValue(uint04 count)
Sets the vertex count in the database.
Definition Geometry.h:2387
Buffer< Buffer< uint04 > > polyIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const
Retrieves a range of polygon index buffers.
void removePrimitive(PrimitiveProperty property, uint04 location)
Removes a single primitive at the given location.
Vector< 3, fltp08 > calculateAverageDirection(const Matrix< fltp08 > &mat) const
Calculates the average direction vector of linework geometry.
void combine(Geometry &geo, const Matrix< fltp08 > &conversion=Matrix< fltp08 >(1.0))
Combines another geometry into this one.
const ColumnT< uint01 > & primitiveFlagColumn() const
Returns a const reference to the primitive flag column.
Definition Geometry.h:607
uint04 solidVertexOffset() const
Returns the offset of solid (thickness-expanded) vertices in the vertex table.
Definition Geometry.h:1287
ThicknessMode
Describes how line/edge thickness is applied to geometry rendering.
Definition Geometry.h:195
@ e_none
No thickness applied.
Definition Geometry.h:196
@ e_pixel
Thickness in screen pixels.
Definition Geometry.h:197
@ e_flat_single
Flat thickness, single value for all vertices.
Definition Geometry.h:198
@ e_circle_per_vertex
Circular cross-section thickness, per-vertex value.
Definition Geometry.h:201
@ e_flat_per_vertex
Flat thickness, per-vertex value.
Definition Geometry.h:199
@ e_circle
Circular cross-section thickness, single value.
Definition Geometry.h:200
VertexMode mode(VertexProperty property) const
Retrieves the vertex storage mode for a standard vertex property.
Definition Geometry.h:1493
TableColumn & column(VertexProperty property)
Returns a mutable reference to the column for a standard vertex property.
Definition Geometry.h:2205
void autoCalculateIndices(PrimitiveProperty property, const void *lock=nullptr, const Matrix< fltp08 > &transform=Matrix< fltp08 >(1.0), LogPtr log=LogPtr())
Automatically calculates primitive indices (e.g.
void setVertexOffsetValue(uint04 count)
Sets the vertex offset in the database.
Definition Geometry.h:2401
void updateVertexColumn(const StringView &property, uint04 index, uint04 size)
Notifies the system that a range within a named custom vertex column was modified.
void setPrimitiveMode(PrimitiveProperty property, PrimitiveMode mode)
Sets the primitive mode for a given property.
void setIndexCountValue(uint04 count)
Sets the total index count in the database.
Definition Geometry.h:2331
TreeMode
Describes the type of spatial index tree used for acceleration.
Definition Geometry.h:184
@ e_quad_tree
Quad-tree spatial index.
Definition Geometry.h:188
@ e_r_tree
R-tree spatial index.
Definition Geometry.h:186
@ e_no_tree
No spatial tree.
Definition Geometry.h:185
@ e_kd_tree
KD-tree spatial index.
Definition Geometry.h:187
void removeVertex(uint04 location)
Removes a single vertex at the given location.
static t_vec_type OptimizedGetPrimitiveVec(const OptimizedPrimitiveDef &ref, uint04 index)
Retrieves a vector primitive using pre-computed offsets for maximum performance.
Definition Geometry.h:862
Buffer< LineSegment< 3, fltp08 > > faceEdges(uint04 index) const
Retrieves all edges of a face at the given index.
void setVerticesFlagAll(VertexFlags flag, bool value)
Sets a flag value for all vertices in this geometry.
void calculateNormals(NormalMode mode, Angle< fltp08 > max_difference, const void *lock=nullptr, LogPtr log=LogPtr())
Calculates vertex normals using the specified mode.
Buffer< t_type > vertices(VertexProperty property) const
Retrieves all vertex values for a standard property.
Definition Geometry.h:1792
void split(Geometry &other_geo, const Buffer< bool > &vertex_mask)
Splits this geometry into two based on a vertex mask.
t_type primitive(PrimitiveProperty property, typename std::enable_if< ObjectInfo< t_type >::Dimensions==2, uint04 >::type index) const
Retrieves a line (2D) primitive index pair, adjusted for vertex offset.
Definition Geometry.h:963
void updateVertexColumn(const uint04 &property)
Notifies the system that a custom vertex column was modified by index.
void optimizeVertexLocations()
Reorders vertices to optimize spatial locality for rendering.
void ensureFlagColumnExists()
Ensures a bitflag column exists in the vertex table, creating one if necessary.
void setPrimitive(PrimitiveProperty property, uint04 index, t_type index_value)
Sets a single primitive index value.
Definition Geometry.h:712
void centerAlign()
Translates all vertices so that the geometry center aligns with the origin.
void setTree(DynamicPointer< RTree< 3, fltp04 > > tree, PrimitiveProperty primitive_property, VertexProperty vertex_property=VertexProperty::Position) const
Sets (replaces) the spatial R-tree for the given properties.
bool primitiveIndexFlag(PrimitiveProperty property, uint04 primitive_index, PrimitiveBitFlags flag) const
Retrieves a flag value from a specific primitive index.
static std::function< void(Geometry &geo, const Matrix< fltp08 > &matrix, const void *lock, LogPtr log)> s_geometry_triangulation
The global triangulation callback.
Definition Geometry.h:2425
Vector< 2, fltp08 > calculateVolumeAndSurfaceArea(const Matrix< fltp08 > &transform, const void *lock) const
Calculates both volume and surface area simultaneously.
void copyTraitsFrom(const Geometry &geo)
Copies traits (properties) from another geometry without copying vertices or primitives.
uint04 primitiveCount(PrimitiveProperty property) const
Returns the number of primitives for a specific property.
Definition Geometry.h:1163
t_type vertexProperty(const StringView &property, uint04 vertex_index, uint04 sub_index) const
Retrieves a sub-component of a custom vertex property by name.
Definition Geometry.h:1396
void removeVertices(uint04 mask_offset, const Buffer< bool > &selection_mask)
Removes vertices indicated by a boolean mask with an offset.
void setWindingMode(WindingMode mode)
Sets the winding mode for face orientation.
void removeParent(Model &parent)
Removes a parent Model from this geometry.
const TableVectorType< 1, uint01 > * vertexFlagColumn() const
Returns a const pointer to the vertex flag column, or nullptr if none exists.
Definition Geometry.h:2220
void setPrimitive(PrimitiveProperty property, uint04 index, Triangle< 1, t_type > index_value)
Sets a triangle primitive from a Triangle index type.
Definition Geometry.h:922
void setVerticesFlag(const Buffer< uint04 > &vertices, VertexFlags flag, bool value)
Sets a flag on a list of vertices by index.
bool hasIndexColumn() const
Checks whether the primitive index column has any entries.
Definition Geometry.h:658
void calculateIndexNeighborList(PrimitiveProperty primitive_property)
Builds a neighbor list for primitive indices to accelerate adjacency queries.
uint04 addVertices(uint04 size)
Adds multiple vertices to the geometry.
Definition Geometry.h:1195
Buffer< uint04 > getSelectedVertices() const
Retrieves indices of all currently selected vertices.
void setIndexFanOffsetValue(uint04 offset)
Sets the fan index offset in the database.
Definition Geometry.h:2353
void clearVerticesAndPrimitives()
Removes all vertex and primitive data from this geometry.
decltype(auto) vertex(VertexProperty property, uint04 index) const
Retrieves a single vertex value for a standard property.
Definition Geometry.h:1725
void setVertices(VertexProperty property, const Buffer< t_type > &vertices, uint04 offset=0)
Sets a standard vertex property for multiple vertices from a buffer.
Definition Geometry.h:1677
fltp08 calculateVolume(const Matrix< fltp08 > &parent_transform) const
Calculates the volume of the geometry in the given coordinate space.
void setIndexOffsetValue(uint04 offset)
Sets the base index offset in the database.
Definition Geometry.h:2360
void removePrimitive(PrimitiveProperty property, const Buffer< bool > &selection_mask)
Removes primitives indicated by a boolean mask.
uint04 createVertexProperty(const StringView &property_name)
Creates a new custom vertex property column with a compile-time type.
Definition Geometry.h:1348
const TableColumn & edgeToFaceColumn() const
Returns a const reference to the edge-to-face mapping column.
Definition Geometry.h:635
ColumnT< uint04 > & primitiveColumn()
Returns a mutable reference to the primitive index column.
Definition Geometry.h:572
Buffer< Vector< 2, uint04 > > lineIndices(PrimitiveProperty primitive_property) const
Retrieves all line index pairs for a primitive property.
Definition Geometry.h:1057
Buffer< t_type > propertyVertices(uint04 property, uint04 start, uint04 size) const
Retrieves a range of custom vertex property values.
Definition Geometry.h:1782
bool hasParent(const Model &model) const
Checks whether a given Model is a parent of this geometry.
void convertPolarToCartesian(const StringView &roll_column, const StringView &pitch_column, const StringView &distance_column)
Converts polar coordinate vertex properties to Cartesian coordinates.
void setVertexProperty(uint04 property, uint04 index, uint04 sub_index, const t_type &vector)
Sets a sub-component of a custom vertex property by column index.
Definition Geometry.h:1429
void sortVertices(Buffer< uint04 > new_order)
Reorders vertices according to the given index mapping.
void setSolidVertexOffsetValue(uint04 count)
Sets the solid vertex offset value in the database.
Definition Geometry.h:2271
void setThicknessMode(ThicknessMode mode)
Sets how thickness is interpreted during rendering.
uint04 vertexPropertyCount() const
Returns the number of vertex property columns.
Buffer< t_type > vertices(VertexProperty property, uint04 start, uint04 size) const
Retrieves a range of vertex values for a standard property.
Definition Geometry.h:1803
void addVertices(uint04 location, uint04 size)
Inserts vertices at a specific location.
uint01 parity(const Matrix< fltp08 > &parent_matrix, PrimitiveMode mode) const
Calculates the parity (orientation) of the geometry relative to a transformation.
Buffer< Triangle< t_dims, t_type > > triangles(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Retrieves all triangles from the geometry.
Definition Geometry.h:1859
void setVerticesFlags(const Buffer< bool > &selection_mask, BitFlag selected_on_flags, BitFlag selected_off_flags, BitFlag unselected_on_flags, BitFlag unselected_off_flags, uint04 bitmask_offset=0)
Sets different flag combinations for selected and unselected vertices.
void updateVertexColumn(const uint04 &property, uint04 index, uint04 size)
Notifies the system that a range within a custom vertex column was modified by index.
void setupIndexFanColumn()
Ensures the index fan column is initialized and allocated.
PrimitiveMode mode(PrimitiveProperty property) const
Retrieves the primitive mode for a given primitive property.
Definition Geometry.h:643
void setPrimitive(PrimitiveProperty property, uint04 index, Vector< 2, t_type > index_value)
Sets a line primitive (2-vertex index pair).
Definition Geometry.h:729
void updateVertexColumns(uint04 index, uint04 size, bool invalidate_bounds=true, bool erase_kd_tree=true)
Notifies the system that a range across all vertex columns was modified.
void removeVertices(const Buffer< bool > &selection_mask)
Removes vertices indicated by a boolean mask.
void reservePrimitiveIndexSpace(uint04 index_size)
Pre-allocates space in the primitive index column.
bool hasProperty(PrimitiveProperty property) const
Checks whether a given primitive property has index data.
Definition Geometry.h:651
uint04 indexOffset() const
Returns the base index offset for this geometry within the shared index column.
Definition Geometry.h:1087
bool operator==(const Geometry &geo) const
Checks equality with another Geometry by comparing base and index.
Definition Geometry.h:531
Buffer< LineSegment< t_dims, t_type > > lineSegments(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Retrieves all line segments from the geometry.
Definition Geometry.h:1836
t_type primitive(PrimitiveProperty property, typename std::enable_if< ObjectInfo< t_type >::Dimensions==3, uint04 >::type index) const
Retrieves a triangle (3D) primitive index triple, adjusted for vertex offset.
Definition Geometry.h:1001
uint04 vertexCount() const
Returns the number of vertices in this geometry.
Definition Geometry.h:1280
void setModeValue(VertexProperty property, VertexMode vert_mode)
Sets the vertex mode for a standard property in the database.
Definition Geometry.h:2412
DynamicPointer< RTree< 3, fltp04 > > tree(PrimitiveProperty primitive_property, VertexProperty vertex_property=VertexProperty::Position) const
Retrieves the spatial R-tree for the given properties.
void setVertexProperties(const StringView &property, const Buffer< t_type > &vertices, uint04 offset=0)
Sets a named vertex property for multiple vertices from a buffer.
Definition Geometry.h:1452
void setBounds(const Bounds< 3, fltp08 > &bounds)
Manually sets the bounding box for this geometry.
void setCountValue(PrimitiveProperty property, uint04 count)
Sets the primitive count for a specific property in the database.
Definition Geometry.h:2346
void addFromParent(Model &parent)
Registers a parent Model for this geometry.
void updateVertexColumn(const StringView &property)
Notifies the system that a named custom vertex column was modified.
void setVertexProperty(const StringView &property, uint04 index, const t_type &property_value)
Sets a custom vertex property value by name.
Definition Geometry.h:1417
void setVertexProperty(const StringView &property, uint04 index, uint04 sub_index, const t_type &vector)
Sets a sub-component of a custom vertex property by name.
Definition Geometry.h:1441
bool vertexSelected(uint04 vertex) const
Checks whether a vertex is selected.
uint04 indexFanOffset() const
Returns the offset into the fan index column for this geometry.
Definition Geometry.h:1102
void normalExpansion(const Vector< 3, fltp04 > &expansion_vector)
Expands vertex positions along their normals by a given vector.
void setVertices(VertexProperty property, const t_type *vertices, uint04 size, uint04 offset=0)
Sets vertices from a raw pointer array.
Definition Geometry.h:1710
uint04 primitiveIndexCount() const
Returns the total number of primitive indices across all properties.
Definition Geometry.h:1155
uint04 addVertexWithExtraReservedSpace()
Adds a single vertex with extra reserved space for future growth.
void removePrimitive(PrimitiveProperty property, Buffer< uint04 > vertices)
Removes primitives at the specified indices.
TableVectorType< 1, uint01 > * vertexFlagColumn()
Returns a mutable pointer to the vertex flag column, or nullptr if none exists.
Definition Geometry.h:2230
BitFlag vertexFlag(uint04 vertex_index) const
Retrieves all flags for a vertex as a BitFlag.
void setIndexFanCountValue(uint04 count)
Sets the fan index count in the database.
Definition Geometry.h:2338
bool hasVertexProperty(const VertexProperty &property) const
Checks whether a standard vertex property exists.
LineSegment< t_dims, t_type > lineSegment(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 line_index) const
Retrieves a line segment from the geometry using primitive and vertex properties.
Definition Geometry.h:1736
void setVertexMode(VertexProperty property, VertexMode mode)
Sets the vertex storage mode for a standard property.
Matrix< fltp08 > getCompleteTransform(const Model &parent) const
Computes the complete transformation matrix from geometry space to world space via a parent Model.
const ColumnT< uint04 > & primitiveFanColumn() const
Returns a const reference to the primitive fan column.
Definition Geometry.h:593
void removeDuplicateVertices(fltp08 epsilon, const void *lock, LogPtr log=LogPtr())
Removes vertices that are within epsilon distance of each other.
bool hasHoles(PrimitiveProperty property) const
Checks whether the mesh has holes for the given primitive property.
Vertex< 3, fltp08 > faceCenter(uint04 index) const
Calculates the center point of a face at the given index.
void outline()
Converts the geometry to its outline representation.
void setGeometryType(GeometryType geometry_type)
Sets the geometry type identifier.
t_type vertexProperty(const StringView &property, uint04 vertex_index) const
Retrieves a custom vertex property value by name.
Definition Geometry.h:1374
uint01 parity(const Matrix< fltp04 > &parent_matrix, PrimitiveMode mode) const
Calculates the parity (orientation) of the geometry relative to a transformation.
void removeHoleFill(const void *lock=nullptr, LogPtr log=LogPtr())
Removes any previously applied hole fill data.
uint04 primitiveIndexCount(PrimitiveProperty property) const
Returns the total number of index entries for a specific property.
Definition Geometry.h:1171
void setVertex(VertexProperty property, uint04 index, const t_type &vector)
Sets a standard vertex property value at the given index.
Definition Geometry.h:1654
TableColumn & propertyColumn(uint04 property)
Returns a mutable reference to a custom vertex property column by index.
Definition Geometry.h:1469
void setPrimitiveRange(PrimitiveProperty mode, uint04 start, uint04 primitive_count)
Sets the start offset and count for a primitive property range.
void clearSmoothing(const SmoothingParameters &properties)
Removes smoothing and restores original vertex positions.
uint04 addPrimitive(PrimitiveProperty index_property, const t_type &primitive)
Adds a single primitive and sets its index data.
Definition Geometry.h:1119
const TableColumn & propertyColumn(const StringView &property) const
Returns a const reference to a named custom property column.
Definition Geometry.h:2249
void calculateTangentSpace(bool calc_tan, bool calc_bitan)
Calculates tangent and/or bitangent vectors for texture mapping.
t_type vertexProperty(uint04 property_index, uint04 vertex_index) const
Retrieves a custom vertex property value by column index.
Definition Geometry.h:1364
void removePrimitive(PrimitiveProperty property, uint04 location, uint04 size)
Removes a contiguous range of primitives.
void setPrimitiveVec(PrimitiveProperty property, uint04 index, t_vec_type &index_value)
Internal method to set a vector primitive with offset adjustment and fan handling.
Definition Geometry.h:2296
uint04 addPrimitives(PrimitiveProperty index_property, uint04 insersion_size)
Adds multiple uninitialized primitives to the geometry.
Definition Geometry.h:1131
void deleteGeometry()
Deletes this geometry and removes it from the design database.
static void OptimizedSetPrimitiveVec(const OptimizedPrimitiveDef &ref, uint04 index, t_vec_type index_value)
Sets a vector primitive (triangle/line) using pre-computed offsets for maximum performance.
Definition Geometry.h:821
Vector< 2, fltp08 > calculateHVLength(const Matrix< fltp08 > &mat) const
Calculates the horizontal and vertical length components of linework.
uint04 vertexPropertyIndex(const StringView &property_name) const
Finds the column index of a named vertex property.
void setVertexCount(uint04 size, bool deallocate_if_possible=true)
Sets the total vertex count, resizing vertex data columns.
Time getAscModifiedTime(bool include_self, bool include_layer=false) const
Gets the most recent ascending modified time across hierarchy.
t_type vertexProperty(uint04 property_index, uint04 vertex_index, uint04 sub_index) const
Retrieves a sub-component of a custom vertex property by column index.
Definition Geometry.h:1385
void setRealThickness(fltp08 real_thickness, const Matrix< fltp08 > &transform, const void *lock, LogPtr log=LogPtr())
Sets a real-world thickness value and generates thickness geometry.
fltp08 calculateLength(const Matrix< fltp08 > &transform) const
Calculates the total length of linework geometry.
const TableColumn & propertyColumn(uint04 property) const
Returns a const reference to a custom vertex property column by index.
Definition Geometry.h:1477
static void OptimizedSetPrimitive(const OptimizedPrimitiveDef &ref, uint04 index, t_vec_type index_value)
Sets a single primitive index using pre-computed offsets for maximum performance.
Definition Geometry.h:804
void setOffsetValue(PrimitiveProperty property, uint04 offset)
Sets the primitive property offset in the database.
Definition Geometry.h:2368
bool hasProperty(VertexProperty property) const
Checks whether a standard vertex property has data.
Definition Geometry.h:1485
void setVertexProperty(uint04 property, uint04 index, const t_type &vector)
Sets a custom vertex property value by column index.
Definition Geometry.h:1407
GeometryType getGeometryType() const
Retrieves the geometry type identifier.
Buffer< t_type > propertyVertices(uint04 property) const
Retrieves all values of a custom vertex property as a buffer.
Definition Geometry.h:1772
Buffer< Vector< 2, uint04 > > lineIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const
Retrieves a range of line index pairs.
void updatePrimitiveColumn(PrimitiveProperty property, bool remove_tree=true)
Notifies the system that a primitive column has been modified.
void flipNormals()
Reverses the direction of all vertex normals.
Buffer< uint04 > indices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const
Retrieves a range of raw primitive indices.
OptimizedPrimitiveDef optimizedPrimitiveDef(PrimitiveProperty property)
Creates a pre-computed primitive definition for fast repeated access.
Definition Geometry.h:786
bool vertexFlag(uint04 vertex_index, VertexFlags flag) const
Retrieves whether a specific flag is set on a vertex.
Geometry(uint04 index, DesignObjectBase *base)
Constructs a Geometry referencing an existing entry in the design database.
Triangle< t_dims, t_type > triangle(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 tri_index) const
Retrieves a triangle from the geometry using primitive and vertex properties.
Definition Geometry.h:1751
const TableColumn & faceToEdgeColumn() const
Returns a const reference to the face-to-edge mapping column.
Definition Geometry.h:621
void setPrimitiveIndexFlag(PrimitiveProperty property, uint04 primitive_index, PrimitiveBitFlags flag, bool value)
Sets a flag on a specific primitive index.
TableColumn & propertyColumn(const StringView &property)
Returns a mutable reference to a named custom property column.
Definition Geometry.h:2241
A light-weight base class for Log that allows processes to update, without the need for additional in...
A class to easily iterate each line segment over a Geometry of lines.
Definition Geometry.h:2599
Geometry::OptimizedPrimitiveDef m_primitive_def
Pre-computed primitive definition for fast access.
Definition Geometry.h:2725
Vector< 2, uint04 > vertexIndex(uint04 index) const
Returns the local vertex indices (offset-adjusted) for a line primitive.
Definition Geometry.h:2661
uint04 m_vertex_offset
The vertex offset in the shared table.
Definition Geometry.h:2729
LineSegment< t_dims, t_type > operator[](uint04 index) const
Array-style access to a line segment.
Definition Geometry.h:2692
LineIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry geo)
Constructs a line iterator from a geometry's primitive and vertex properties.
Definition Geometry.h:2614
LineIterator()
Default constructor creating an empty iterator.
Definition Geometry.h:2602
TableColumn * m_vertex_column
Pointer to the vertex data column.
Definition Geometry.h:2726
LineIterator(const LineIterator< t_dims, t_type > &iter)
Copy constructor.
Definition Geometry.h:2647
uint04 size() const
Returns the number of line primitives available.
Definition Geometry.h:2699
bool isHidden(uint04 index) const
Checks whether a vertex is hidden via its flag.
Definition Geometry.h:2717
LineSegment< t_dims, t_line_type > get(uint04 index) const
Retrieves the line segment at the given index.
Definition Geometry.h:2677
TableColumn * m_flag_column
Pointer to the vertex flag column (may be nullptr).
Definition Geometry.h:2727
VertexProperty m_vertex_property
The vertex property being accessed.
Definition Geometry.h:2724
Vector< 2, uint04 > rawIndex(uint04 index) const
Returns raw (non-offset-adjusted) vertex indices for a line primitive.
Definition Geometry.h:2707
uint04 m_primitive_count
The number of line primitives.
Definition Geometry.h:2728
Class: LineSegment.
Definition Line.hpp:52
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Serves as the primary program interface for processes to report issues and allows any number of LogSt...
Definition Log.h:50
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
Logic for a given plane or N-dimensions.
Definition Plane.hpp:53
An N-sided polygon.
Definition Polygon.hpp:55
uint04 vertexCount() const
Definition Polygon.hpp:206
void add(const t_vertex &vertex)
Definition Polygon.hpp:295
A sequence of connected line segments defined by ordered vertices along a path.
Definition PolyLine.hpp:55
uint04 vertexCount() const
Definition PolyLine.hpp:194
void clear()
Definition PolyLine.hpp:399
void add(const t_vertex &vertex)
Definition PolyLine.hpp:244
static constexpr TableColumn * column(const DesignInfo *object, NDPG property)
Retrieves the TableColumn storing the given NDPG property.
Definition Geometry.h:113
static constexpr uint04 index(const DesignInfo *object, NDPG)
Retrieves the design index for geometry property access.
Definition Geometry.h:120
Provides access to the TableColumn and row index for a given property enum value.
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
The root Model that is responsible for storing the underlying data for all Scene Models.
Definition Scene.h:52
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
Definition Selector.h:52
Logic for reading or writing to a string or a user friendly, TranslatedString.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Definition TableColumn.h:86
void get(uint04 index, Vector< 1, t_class > &vector) const
Retrieves a 1D vector value at the given row index by delegating to the scalar get.
A TableColumnBuffer that also has some number of defined rows stored in a Vector object Allows for vi...
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
static Time SystemTime()
Retrieves the current system time which is a combination of std::chrono::steady_clock to ensure smoot...
TableColumn * m_vertex_column
Pointer to the vertex data column.
Definition Geometry.h:2840
TriangleIterator(PrimitiveProperty primitive_property, const StringView &vertex_property, Geometry mesh)
Constructs a triangle iterator using a named custom vertex property.
Definition Geometry.h:2763
uint04 m_vertex_offset
The vertex offset in the shared table.
Definition Geometry.h:2843
TriangleIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry mesh)
Constructs a triangle iterator from a geometry's primitive and vertex properties.
Definition Geometry.h:2749
Geometry::OptimizedPrimitiveDef m_primitive_def
Pre-computed primitive definition for fast access.
Definition Geometry.h:2839
Triangle< t_dims, t_tri_type > get(uint04 index) const
Retrieves the triangle at the given index.
Definition Geometry.h:2777
uint04 size() const
Returns the number of triangle primitives available.
Definition Geometry.h:2827
Vector< 3, BitFlag > flag(uint04 index) const
Retrieves the vertex flags for all three vertices of a triangle.
Definition Geometry.h:2815
uint04 m_primitive_count
The number of triangle primitives.
Definition Geometry.h:2842
Triangle< t_dims, t_type > operator[](uint04 index) const
Array-style access to a triangle.
Definition Geometry.h:2794
Vector< 3, uint04 > vertexIndex(uint04 index) const
Returns the local vertex indices (offset-adjusted) for a triangle.
Definition Geometry.h:2802
Vector< 3, uint04 > rawIndex(uint04 index) const
Returns raw (non-offset-adjusted) vertex indices for a triangle primitive.
Definition Geometry.h:2835
TableColumn * m_flag_column
Pointer to the vertex flag column (may be nullptr).
Definition Geometry.h:2841
TriangleIterator()
Default constructor creating an empty iterator.
Definition Geometry.h:2740
A three-vertex polygon representing a triangle in N-dimensional space.
Definition Triangle.hpp:142
Stores information about a type, relevant for certain templated functions.
Definition TypeInfo.h:43
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
VertexIterator(VertexProperty vertex_property, Geometry geo)
Constructs a typed iterator for a standard vertex property.
Definition Geometry.h:2574
VertexIterator(const StringView &vertex_property, Geometry geo)
Constructs a typed iterator for a named custom vertex property.
Definition Geometry.h:2581
t_type operator[](uint04 index) const
Array-style access to a vertex value.
Definition Geometry.h:2588
uint04 m_vertex_offset
The offset of this geometry's vertices in the shared table.
Definition Geometry.h:2557
VertexLookup(VertexProperty vertex_property, Geometry geo)
Constructs a lookup for a standard vertex property.
Definition Geometry.h:2470
uint04 m_vertex_count
The number of vertices in this geometry.
Definition Geometry.h:2558
TableColumn * m_column
Pointer to the vertex data column.
Definition Geometry.h:2554
BitFlag flag(uint04 index) const
Retrieves the vertex flags at the given index.
Definition Geometry.h:2507
t_type get(uint04 index) const
Retrieves a vertex value at the given index.
Definition Geometry.h:2497
VertexLookup(const StringView &vertex_property, Geometry geo)
Constructs a lookup for a named custom vertex property.
Definition Geometry.h:2483
Geometry m_geo
The geometry being iterated.
Definition Geometry.h:2553
void swap(uint04 a, uint04 b)
Swaps two vertex entries in the column.
Definition Geometry.h:2518
void setFlag(uint04 index, const BitFlag &value)
Sets the flag value for a vertex, creating the flag column if necessary.
Definition Geometry.h:2535
VertexProperty m_vertex_property
The vertex property being accessed.
Definition Geometry.h:2556
void setVertex(uint04 index, const t_type &value)
Sets a vertex value at the given index.
Definition Geometry.h:2527
VertexLookup()
Default constructor creating an empty lookup.
Definition Geometry.h:2458
uint04 size() const
Returns the number of vertices available for iteration.
Definition Geometry.h:2549
TableColumn * m_flag_column
Pointer to the vertex flag column (may be nullptr).
Definition Geometry.h:2555
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
NormalMode
Describes how surface normals are computed or stored for a Geometry object.
@ e_no_normals
No normals are provided.
@ type
The type identifier string for this model node.
Definition Model.h:58
VertexProperty
Per-vertex data channels that can be stored in the vertex table to be used by Geometry.
@ Position
XYZ position of the vertex.
@ BitFlag
Per-vertex bit flags (selected, hidden, etc.).
PrimitiveMode
Used with Geometry to describe how vertices and indices are used to form shapes.
@ e_no_index
No index buffer is used; vertices are not indexed.
@ e_triangle_strip
Indices define a triangle strip.
@ e_lines
Each pair of indices defines a line segment.
@ e_polyline
Indices define a connected polyline.
@ e_triangle
Each triplet of indices defines a triangle.
@ e_triangle_fan
Indices define a triangle fan around a central vertex.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
static constexpr bool IsValid(const Angle< t_type > &value)
Checks whether the given Angle holds a valid value.
Definition Angle.h:398
constexpr std::enable_if<!ObjectInfo< t_type >::Buffer, TypeInfo >::type GetTypeInfo()
Constructs a TypeInfo for a non-buffer type at compile time using ObjectInfo traits.
Definition TypeInfo.h:125
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
GeometryType
Describes the high-level geometric topology of a Geometry object.
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
Definition Angle.h:388
@ guid
A 128-bit globally unique identifier for the object.
PrimitiveProperty
Describes which rendering property a primitive index buffer corresponds to.
PrimitiveAlignedBuffer< Model, 16 > ModelBuffer
Aligned buffer of Model objects with 16-byte alignment.
WindingMode
Describes the vertex winding order used to determine front-facing direction of polygons.
PrimitiveAlignedBuffer< Geometry, 16 > GeometryBuffer
Aligned buffer of Geometry objects with 16-byte alignment.
VertexFlags
Bit flags that can be set on individual vertices to control selection, visibility,...
@ e_is_hidden
Vertex is hidden from display.
PrimitiveBitFlags
Bit flags that can be set on individual primitives (triangles, lines, etc.) to control their selectio...
NDPG
Forward declaration for Geometry design object.
Definition Geometry.h:56
@ normal_mode
Normal calculation mode (smooth, no normal, or hard).
Definition Geometry.h:70
@ is_clipping_geo
Whether this geometry should be treated as a clipping region. Default: false.
Definition Geometry.h:74
@ has_closed_primitive
Whether primitives are closed, enabling volume calculations.
Definition Geometry.h:63
@ is_smooth
Whether vertices should be ignored and surfaces treated as smooth (circles, spheres,...
Definition Geometry.h:67
@ preserve_vertex_order
Whether vertex order must be preserved. If false, order may be automatically optimized....
Definition Geometry.h:76
@ is_surface
Whether the geometry represents a surface relative to some plane.
Definition Geometry.h:62
@ normal_smoothing_angle
The maximum angle threshold for normal smoothing between adjacent faces.
Definition Geometry.h:71
@ thickness
The thickness value applied to geometry rendering.
Definition Geometry.h:58
@ smooth_level
How smoothed the surface is, based on the argument passed to the smoothing algorithm.
Definition Geometry.h:69
@ thickness_mode
How thickness is interpreted (pixel, flat, circle, etc.).
Definition Geometry.h:59
@ plane_offset
The offset distance of the surface plane from the origin.
Definition Geometry.h:65
@ poly_holes
Whether surfacing should check for holes in polygons.
Definition Geometry.h:66
@ plane_normal
The normal ray of the surface plane.
Definition Geometry.h:64
@ is_closed_solid
Whether the geometry forms a closed solid (watertight mesh).
Definition Geometry.h:72
@ preserve_primitive_order
Whether primitive order must be preserved. If false, order may be automatically optimized....
Definition Geometry.h:75
@ no_auto_tree_creation
Whether automatic spatial tree creation is disabled.
Definition Geometry.h:77
@ geometry_type
The type identifier string for this geometry.
Definition Geometry.h:57
@ shape_type
A string identifier describing the shape type.
Definition Geometry.h:73
@ smooth_algorithm
The algorithm used for smoothing (e.g. Cotangent, Laplacian).
Definition Geometry.h:68
@ property_fields
Bitmask of which property fields are active.
Definition Geometry.h:61
@ winding
The winding order used for face orientation.
Definition Geometry.h:60
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Definition Angle.h:408
STL namespace.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Describes special options/parameters for a GeometryFilter engine.
Pre-computed offsets and references for fast primitive index access without repeated lookups.
Definition Geometry.h:762
PrimitiveMode mode
The primitive mode for this definition.
Definition Geometry.h:781
ColumnT< uint04 > * fan_column
Pointer to the primitive fan column.
Definition Geometry.h:773
uint04 index_offset
The computed offset into the index column.
Definition Geometry.h:774
ColumnT< uint04 > * column
Pointer to the primitive index column.
Definition Geometry.h:772
OptimizedPrimitiveDef(ColumnT< uint04 > &column, ColumnT< uint04 > &fan_column)
Constructs with references to the index and fan columns.
Definition Geometry.h:768
uint04 fan_offset
The computed offset into the fan column.
Definition Geometry.h:775
Parameters controlling mesh smoothing operations.
Definition Geometry.h:401
fltp08 grow_rate
The grow factor per smoothing pass (negative to counteract shrinkage).
Definition Geometry.h:407
const void * lock
Optional thread lock pointer.
Definition Geometry.h:405
uint04 iterations
The number of smoothing iterations to perform.
Definition Geometry.h:403
LogPtr log
Optional log for progress reporting.
Definition Geometry.h:404
fltp08 shrink_rate
The shrink factor per smoothing pass.
Definition Geometry.h:406
PrimitiveProperty property
The primitive property to smooth over.
Definition Geometry.h:402
static const bool Color
Not a color type.
Definition Geometry.h:2445
static const bool Pointer
Not a pointer type.
Definition Geometry.h:2438
static const uint01 Dimensions
Geometry is not a dimensional type.
Definition Geometry.h:2434
static const bool String
Not a string type.
Definition Geometry.h:2444
static const bool Boolean
Not a boolean type.
Definition Geometry.h:2446
static const bool Enum
Not an enum type.
Definition Geometry.h:2443
static const bool Buffer
Not a buffer type.
Definition Geometry.h:2436
static const bool Primitive
Is a primitive design type.
Definition Geometry.h:2437
static const bool Integer
Not an integer type.
Definition Geometry.h:2441
static const bool Vector
Not a vector type.
Definition Geometry.h:2435
static const bool Unsigned
Not an unsigned numeric type.
Definition Geometry.h:2439
static const bool Float
Not a floating-point type.
Definition Geometry.h:2440
static const bool Number
Not a numeric type.
Definition Geometry.h:2442
Information about the object.
Definition ObjectInfo.h:55
Maps a compile-time property enum value to its corresponding C++ storage type.