API Documentation
Loading...
Searching...
No Matches
Geometry.h
Go to the documentation of this file.
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 ProgressInfo;
44 class Model;
45 class Scene;
46 class Log;
47 class RGBColor;
48 class Geometry;
49 /**--------------------------------------------------------------------------------------------------
50 \brief A core class within the model heirarchy containing vertex-based data (Usually 3D data) within
51 a set container. Geometries can be shared by multiple Model parents.
52 The primary information for Geometry comes from its vertices, which can be resized. In addition, primitive
53 columns are used to group these vertices in various different ways.
54 Geometries can take on different shapes depending on their Type. See PrimitiveMode.
55 In addition to vertices some data is stored in the form of GeometryProperty values which can be accessed
56 via getGeometryProperty(GeometryProperty).
57 For iterating over each vertex in the Geometry, use VertexIterator
58 For iterating over each line in linework Geometry, use LineIterator
59 For iterating over Geoemetry colors, use VertexColorIterator.
60 \warning Access to these members and data should be made in a thread-safe manner using DesignObjectLookup
61 read and write locks.
62 **/
64 {
65 friend class Model;
66 public:
68 {
69 e_no_vertex
70 , e_index
71 , e_cartesian_1F
72 , e_cartesian_1D
73 , e_cartesian_2F
74 , e_cartesian_3F
75 , e_cartesian_2D
76 , e_cartesian_3D
77 , e_normal_ray_3F
78 , e_normal_ray_3D
79 , e_cartesian_grid_1F
80 , e_cartesian_grid_3F
81 , e_cartesian_grid_1D
82 , e_cartesian_grid_3D
83 , e_cartesian_grid_image
84 , e_polar_grid_1F
85 , e_color_aci
86 , e_color_hsb
87 , e_color_hsl
88 , e_color_lab
89 , e_color_rgb
90 , e_color_xyz
91 , e_bitflag
92 , e_cartesian_2I
93 , e_cartesian_3I
94 , e_cartesian_2S
95 , e_cartesian_3S
96 };
97
99 {
100 e_geometry_type
101 , e_thickness
102 , e_thickness_mode //
103 , e_winding
104 , e_property_fields
105 , e_is_surface//is a surface relative to some plane
106 , e_has_closed_primitive//if closed, than we can calculate volumes
107 , e_plane_normal
108 , e_plane_offset
109 , e_poly_holes//surfacing must check for holes in polygon
110 , e_is_smooth//vertices should be ignored, and all surface should be considered smooth (circles, spheres, bezier curves, etc)
111 , e_smooth_algorithm //The algorithm used for smoothing (Cotangent, Laplacian, etc)
112 , e_smooth_level //How smoothed the surface is (Based around argument passed to smoothing algorithm
113 , e_normal_mode //Smooth, no normal, or hard
114 , e_normal_smoothing_angle
115 , e_is_closed_solid
116 , e_shape_type
117 , e_is_clipping_geo //Default: false, If this is true, geometry should be treated as a clipped area.
118 , e_preserve_primitive_order // Default: false, If this is true, geometry primitive order will be preserved, if false, order may be automatically optimized
119 , e_preserve_vertex_order // Default: false, If this is true, geometry vertex order will be preserved, if false, order may be automatically optimized
120 , e_no_auto_tree_creation
121 };
123 {
124 e_no_tree
125 , e_r_tree
126 , e_kd_tree
127 , e_quad_tree
128 };
130 {
131 e_none
132 , e_pixel
133 , e_flat_single
134 , e_flat_per_vertex
135 , e_circle
136 , e_circle_per_vertex
137 };
138 public:
139 Geometry() = default;
142 explicit Geometry(const DesignObject& obj);
143 void setGeometryType(GeometryType geometry_type);
146 template<class t_type>
147 void setGeometryProperty(GeometryProperty property, const t_type& value)
148 {
149 m_base->geometry_table.get()[m_base->geometry_property_index[cast<uint04>(property)]].set(m_design_index, value);
150#ifdef _DEBUG
151 switch (property)
152 {
153 case e_geometry_type:
154 {
155 uint01 val = getGeometryProperty<uint01>(Geometry::e_geometry_type);
156 lib_assert(IsInvalid(val) || val < cast<uint01>(GeometryType::e_geometry_type_size), "Bad geo type set");
157 } break;
158 default:
159 break;
160 }
161#endif
162 }
163 template<class t_type>
164 void updateGeometryProperty(GeometryProperty property, const t_type& type, const void* lock_ptr = nullptr)
165 {
166 if (getGeometryProperty<t_type>(property) != type)
167 {
168 WLock wLock(lock_ptr);
169 setGeometryProperty(property, type);
170 updateModifiedTime();
171 }
172 }
173 template<class t_type>
175 {
176 return m_base->geometry_table.get()[m_base->geometry_property_index[cast<uint04>(property)]].get<t_type>(m_design_index);
177 }
178 void split(Geometry& other_geo, const Buffer<bool>& vertex_mask);
179 void combine(const Geometry& geo, const Matrix<fltp08>& conversion = Matrix<fltp08>(1.0));
180 void combine(const Geometry& geo, const Matrix<fltp08>& conversion, Buffer<bool> vertex_mask);
181 void copyFrom(const Geometry& geo, bool copy_tree = true);
182 void copyTraitsFrom(const Geometry& geo);//Does not copy vertices or primitives
183
188 Model getParent(uint04 index) const;
190 uint01 parity(const Matrix<fltp04>& parent_matrix, PrimitiveMode mode) const;
191 uint01 parity(const Matrix<fltp08>& parent_matrix, PrimitiveMode mode) const;
192 void fillHolesByNeighbor(PrimitiveProperty property, const void* lock = nullptr, ProgressInfo* log = nullptr);
193 void removeHoleFill(const void* lock = nullptr, ProgressInfo* log = nullptr);
194 void setWindingMode(WindingMode mode, const void* lock = nullptr);
198 bool canBeClosedSolid(const void* lock = nullptr) const;
199 bool hasParent(const Model& model) const;
202 bool canExplode() const;
204 void outline();
205 void setNormalMode(NormalMode mode, Angle<fltp08> max_sep_angle, const void* lock = nullptr, ProgressInfo* log = nullptr);
206 void calculateNormals(NormalMode mode, Angle<fltp08> max_difference, const void* lock = nullptr, ProgressInfo* log = nullptr);
207 void setRealThickness(fltp08 real_thickness, const Matrix<fltp08>& transform, const void* lock, ProgressInfo* log = nullptr);
211 void removeDuplicateVertices(fltp08 epsilon, const void* lock, ProgressInfo* log = nullptr);
213 void convertPolarToCartesian(const String& roll_column, const String& pitch_column, const String& distance_column);
214
215
217 {
220 ProgressInfo* log = nullptr;
221 const void* lock = nullptr;
222 fltp08 shrink_rate = 0.5;
223 fltp08 grow_rate = -0.53;
224 };
227 void clearSmoothing(const SmoothingParameters& properties);
228
229 void calculateTangentSpace(bool calc_tan, bool calc_bitan);
230 bool validate() const;
231 bool hasHoles(PrimitiveProperty property) const;
232 void setVertexFlag(uint04 vertex, VertexFlags flag, bool value);
233 void setVerticesFlag(const Buffer<uint04>& vertices, VertexFlags flag, bool value);
234 void setVerticesFlag(const Buffer<bool>& selection_mask, VertexFlags flag, bool value);
235 void setVerticesFlags(const Buffer<bool>& selection_mask, BitFlag on_flags, BitFlag off_flags);
236 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);
237 void setVerticesFlagAll(VertexFlags flag, bool value);
238 void setVerticesFlagAll(uint01 on_flags, uint01 off_flags);
239
240 void setPrimitiveIndexFlag(PrimitiveProperty property, uint04 primitive_index, PrimitiveBitFlags flag, bool value);
241 bool primitiveIndexFlag(PrimitiveProperty property, uint04 primitive_index, PrimitiveBitFlags flag) const;
242 bool vertexFlag(uint04 vertex_index, VertexFlags flag) const;
244 bool vertexSelected(uint04 vertex) const;
245 void setTransform(const Matrix<fltp08>& transform);
246 void updateTransform(const Matrix<fltp08>& transform, const void* lock_ptr = nullptr);
248 bool operator==(const Geometry& model) const
249 {
250 if (!isValid() || !model.isValid())
251 return isValid() == model.isValid();
252 return (model.uuid() == uuid());
253 }
254 bool operator!=(const Geometry& model) const
255 {
256 if (!isValid() || !model.isValid())
257 return isValid() != model.isValid();
258 return (model.uuid() != uuid());
259 }
260 Time getAscModifiedTime(bool include_self, bool include_layer = false) const;
261 void normalExpansion(const Vector<3, fltp04>& expansion_vector);
262 private:
263 Bounds<3, fltp08> _calculateBounds() const;
264
265
266 //void getVertexDesignParameters(DesignParameters& params, const Matrix<fltp08>& transform, bool deviation_pass) const;
267
268
269 public:
270 //////////////////////////////[Index]////////////////////////////////////
273 {
274 return m_base->primitive_index_table.get()[m_base->primitive_index_column];
275 }
277 {
278 return m_base->primitive_index_table.get()[m_base->primitive_fan_column];
279 }
281 {
282 return m_base->primitive_index_table.get()[m_base->primitive_fan_column];
283 }
285 {
286 return m_base->primitive_index_table.get()[m_base->primitive_flag_column];
287 }
289 {
290 return m_base->primitive_index_table.get()[m_base->primitive_flag_column];
291 }
293 {
294 return m_base->vertex_table.get()[m_base->face_to_edge_column];
295 }
297 {
298 return m_base->vertex_table.get()[m_base->face_to_edge_column];
299 }
300
302 {
303 return m_base->vertex_table.get()[m_base->edge_to_face_column];
304 }
306 {
307 return m_base->vertex_table.get()[m_base->edge_to_face_column];
308 }
310 {
311 return m_base->geometry_table.get()[m_base->primitive_property_mode_column[cast<uint04>(property)]].get<PrimitiveMode>(m_design_index);
312 }
313 bool hasProperty(PrimitiveProperty property) const
314 {
315 return mode(property) != PrimitiveMode::e_no_index;
316 }
317 bool hasIndexColumn() const
318 {
319 return m_base->vertex_table->hasColumn(m_base->primitive_index_column);
320 }
321 bool hasIndexFanColumn() const
322 {
323 return m_base->vertex_table->hasColumn(m_base->primitive_fan_column);
324 }
326
327 void setPrimitiveRange(PrimitiveProperty mode, uint04 start, uint04 primitive_count);
328
330 void updatePrimitiveColumn(PrimitiveProperty property, bool remove_tree = true);
331 void updatePrimitiveColumns(bool remove_tree = true);
332 void updateModifiedTime(Time time = Time::SystemTime());
334 template<class t_type>
335 void setPrimitive(PrimitiveProperty property, uint04 index, t_type index_value)
336 {
337 lib_assert(index < indicesPerPrimitive(mode(property)) * primitiveCount(property), "Bad index set");
338 const uint04 index_offset = indexOffset() + indexOffset(property) + index;
339 if (!IsInvalid(index_value))
340 {
341 lib_assert(cast<uint04>(index_value) < vertexCount(), "index for geometry out of range");
342 primitiveColumn().set(index_offset, index_value + t_type(vertexOffset()));
343 }
344 else
345 primitiveColumn().set(index_offset, Constant<uint04>::Invalid);
346 }
347 template<class t_type>
348 void setPrimitive(PrimitiveProperty property, uint04 index, Vector<2, t_type> index_value)
349 {
350 lib_assert(index < primitiveCount(property), "Bad index set");
351 const uint04 index_offset = indexOffset() + indexOffset(property);
352 TableColumn& column = primitiveColumn();
353 if (!IsInvalid(index_value))
354 {
355 lib_assert(index_value[A] < vertexCount(), "index for geometry out of range A");
356 lib_assert(index_value[B] < vertexCount(), "index for geometry out of range B");
357 index_value += cast<t_type>(vertexOffset());
358 }
359 else
360 {
361 index_value = Constant<Vector<2, t_type>>::Invalid;
362 }
363 switch (mode(property))
364 {
365 case PrimitiveMode::e_polyline:
366 column.set(index_offset + index + A, index_value[A]);
367 column.set(index_offset + index + B, index_value[B]);
368 break;
369 case PrimitiveMode::e_lines:
370 column.set(index_offset + 2 * index + A, index_value[A]);
371 column.set(index_offset + 2 * index + B, index_value[B]);
372 break;
373 default:
374 lib_assert(false, "Unknown Primitive Mode for vertex<2>");
375 }
376 }
378 {
380 : column(column)
381 , fan_column(fan_column)
382 {}
387#ifdef _DEBUG
388 uint04 index_max_offset;
389 uint04 min_vertex_index;
390 uint04 max_vertex_index;
391#endif
393 };
395 {
396 OptimizedPrimitiveDef ref(primitiveColumn(), primitiveFanColumn());
397 ref.index_offset = indexOffset() + indexOffset(property);
398 ref.fan_offset = indexFanOffset();
399#ifdef _DEBUG
400 ref.min_vertex_index = vertexOffset();
401 ref.max_vertex_index = ref.min_vertex_index + vertexCount();
402 ref.index_max_offset = primitiveCount(property);
403#endif
404 ref.mode = mode(property);
405 return ref;
406 }
407 template<class t_vec_type>
408 static void OptimizedSetPrimitive(const OptimizedPrimitiveDef& ref, uint04 index, t_vec_type index_value)
409 {
410#ifdef _DEBUG
411 lib_assert(index < ref.index_max_offset, "Index out of bounds");
412 for (uint01 i = 0; i < 3; i++)
413 {
414 lib_assert(IsInvalid(index_value) || index_value >= ref.min_vertex_index, "Index out of bounds");
415 lib_assert(IsInvalid(index_value) || index_value < ref.max_vertex_index, "Index out of bounds");
416 }
417#endif
418 ref.column.set(ref.index_offset + index, index_value);
419 }
420 template<class t_vec_type>
421 static void OptimizedSetPrimitiveVec(const OptimizedPrimitiveDef& ref, uint04 index, t_vec_type index_value)
422 {
423#ifdef _DEBUG
424 lib_assert(index < ref.index_max_offset, "Index out of bounds");
425 for (uint01 i = 0; i < 3; i++)
426 {
427 lib_assert(IsInvalid(index_value[i]) || index_value[i] >= ref.min_vertex_index, "Index out of bounds");
428 lib_assert(IsInvalid(index_value[i]) || index_value[i] < ref.max_vertex_index, "Index out of bounds");
429 }
430#endif
431 switch (ref.mode)
432 {
433 case PrimitiveMode::e_triangle:
434 ref.column.set(ref.index_offset + 3 * index + A, index_value[A]);
435 ref.column.set(ref.index_offset + 3 * index + B, index_value[B]);
436 ref.column.set(ref.index_offset + 3 * index + C, index_value[C]);
437 break;
438 case PrimitiveMode::e_triangle_strip:
439 ref.column.set(ref.index_offset + index + A, index_value[A]);
440 ref.column.set(ref.index_offset + index + B, index_value[B]);
441 ref.column.set(ref.index_offset + index + C, index_value[C]);
442 break;
443 case PrimitiveMode::e_triangle_fan:
444 {
445 uint04 index_fan_location = ref.fan_column.get<uint04>(index + ref.fan_offset);
446 if (!IsInvalid(index_fan_location))
447 {
448 ref.column.set(index_fan_location, index_value[A]);
449 ref.column.set(index + ref.index_offset - 1, index_value[B]);
450 ref.column.set(index + ref.index_offset, index_value[C]);
451 }
452 } break;
453 default:
454 lib_assert(false, "Unknown Primitive Mode for vertex<3>");
455 }
456 }
457 template<class t_vec_type>
458 static t_vec_type OptimizedGetPrimitiveVec(const OptimizedPrimitiveDef& ref, uint04 index)
459 {
460 lib_assert(index < ref.index_max_offset, "Index out of bounds");
461 t_vec_type index_value;
462 switch (ref.mode)
463 {
464 case PrimitiveMode::e_lines:
465 ref.column.get(ref.index_offset + 2 * index + A, index_value[A]);
466 ref.column.get(ref.index_offset + 2 * index + B, index_value[B]);
467 break;
468 case PrimitiveMode::e_polyline:
469 ref.column.get(ref.index_offset + index + A, index_value[A]);
470 ref.column.get(ref.index_offset + index + B, index_value[B]);
471 break;
472 case PrimitiveMode::e_triangle:
473 ref.column.get(ref.index_offset + 3 * index + A, index_value[A]);
474 ref.column.get(ref.index_offset + 3 * index + B, index_value[B]);
475 ref.column.get(ref.index_offset + 3 * index + C, index_value[C]);
476 break;
477 case PrimitiveMode::e_triangle_strip:
478 ref.column.get(ref.index_offset + index + A, index_value[A]);
479 ref.column.get(ref.index_offset + index + B, index_value[B]);
480 ref.column.get(ref.index_offset + index + C, index_value[C]);
481 break;
482 case PrimitiveMode::e_triangle_fan:
483 {
484 uint04 index_fan_location = ref.fan_column.get<uint04>(index + ref.fan_offset);
485 if (IsInvalid(index_fan_location))
486 {
487 index_value = Constant<t_vec_type>::Invalid;
488 }
489 else
490 {
491
492 lib_assert(index_fan_location >= ref.index_offset && index_fan_location - ref.index_offset < ref.index_max_offset, "bad fan location");
493 ref.column.get(index_fan_location, index_value[A]);
494 ref.column.get(index + ref.index_offset - 1, index_value[B]);
495 ref.column.get(index + ref.index_offset, index_value[C]);
496 }
497 } break;
498 default:
499 lib_assert(false, "Unknown Primitive Mode for vertex<3>");
500 }
501 return index_value;
502 }
503 template<class t_type>
504 void setPrimitive(PrimitiveProperty property, uint04 index, Vector<3, t_type> index_value)
505 {
506 setPrimitiveVec<t_type>(property, index, index_value);
507 }
508
509 template<class t_type>
510 void setPrimitive(PrimitiveProperty property, uint04 index, Triangle<1, t_type> index_value)
511 {
512 setPrimitiveVec<t_type>(property, index, index_value);
513 }
514 static constexpr uint04 indicesPerPrimitive(PrimitiveMode property)
515 {
516 switch (property)
517 {
518 case PrimitiveMode::e_no_index:
519 return 0;
520 case PrimitiveMode::e_triangle:
521 return 3;
522 case PrimitiveMode::e_lines:
523 return 2;
524 default:
525 return 1;
526 }
527 }
528 template<class t_type>
529 t_type primitive(PrimitiveProperty property, typename std::enable_if<ObjectInfo<t_type>::Dimensions <= 1, uint04>::type index) const
530 {
531 lib_assert(index < indicesPerPrimitive(mode(property)) * primitiveCount(property), "Out of bounds index request");
532 const uint04 index_offset = indexOffset() + indexOffset(property);
533 t_type index_value = primitiveColumn().get<t_type>(index_offset + index);
534 if (IsInvalid(index_value))
536 return index_value - t_type(vertexOffset());
537 }
538 template<class t_type>
539 t_type primitive(PrimitiveProperty property, typename std::enable_if<ObjectInfo<t_type>::Dimensions == 2, uint04>::type index) const
540 {
541 uint04 primitive_count = primitiveCount(property);
542 if (primitive_count == 0)
543 {
544 lib_assert(index + 1 < vertexCount(), "Out of bounds index request");
545 t_type index_value = { index, index + 1 };
546 return index_value;
547 }
548 else
549 {
550 t_type index_value;
551 const uint04 index_offset = indexOffset() + indexOffset(property);
552 const TableColumn& column = primitiveColumn();
553 switch (mode(property))
554 {
555 case PrimitiveMode::e_lines:
556 lib_assert(index < primitive_count, "Out of bounds index request");
557 index_value = { column.get<uint04>(index_offset + 2 * index), column.get<uint04>(index_offset + 2 * index + 1) };
558 break;
559 case PrimitiveMode::e_polyline:
560 lib_assert(index + 1 < primitive_count, "Out of bounds index request");
561 index_value = { column.get<uint04>(index_offset + index), column.get<uint04>(index_offset + index + 1) };
562 break;
563 default:
564 lib_assert(false, "Bad property fetch mode");
565 }
566
567 if (IsInvalid(index_value))
569 return index_value - t_type(vertexOffset());
570 }
571 }
572 template<class t_type>
573 t_type primitive(PrimitiveProperty property, typename std::enable_if<ObjectInfo<t_type>::Dimensions == 3, uint04>::type index) const
574 {
575 lib_assert(index < primitiveCount(property), "Out of bounds index request");
576 t_type index_value;
577 const uint04 index_offset = indexOffset() + indexOffset(property);
578 const TableColumn& column = primitiveColumn();
579 auto v_mode = mode(property);
580 switch (v_mode)
581 {
582 case PrimitiveMode::e_triangle:
583 index_value = {
584 column.get<uint04>(index_offset + 3 * index + 0)
585 , column.get<uint04>(index_offset + 3 * index + 1)
586 , column.get<uint04>(index_offset + 3 * index + 2) };
587 break;
588 case PrimitiveMode::e_triangle_strip:
589 index += index_offset;
590 index_value = { column.get<uint04>(index + 0), column.get<uint04>(index + 1), column.get<uint04>(index + 2) };
591 break;
592 case PrimitiveMode::e_triangle_fan:
593 {
594 uint04 index_fan_location = primitiveFanColumn().get<uint04>(index + indexFanOffset());
595 if (IsInvalid(index_fan_location))
596 index_value = Constant<t_type>::Invalid;
597 else
598 index_value = {
599 column.get<uint04>(index_fan_location)
600 , column.get<uint04>(index + index_offset - 1)
601 , column.get<uint04>(index + index_offset) };
602 } break;
603 default:
604 lib_assert(false, "Bad property fetch mode");
605 }
606 if (IsInvalid(index_value))
608 return index_value - t_type(vertexOffset());
609 }
610
612 Buffer<uint04> indices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const;
613
615 {
616 return lineIndices(primitive_property, 0, primitiveCount(primitive_property));
617 }
618 Buffer<Vector<2, uint04>> lineIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const;
619
621 {
622 return triIndices(primitive_property, 0, primitiveCount(primitive_property));
623 }
624
625 Buffer<Vector<3, uint04>> triIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const;
626
627
629 {
630 return m_base->geometry_table.get()[m_base->index_mode_offset_column].get<uint04>(m_design_index);
631 }
633 {
634 //lib_assert(hasProperty(property), "tried to access non-existant index property");
635 return m_base->geometry_table.get()[m_base->primitive_property_offset_column[cast<uint04>(property)]].get<uint04>(m_design_index);
636 }
638 {
639 //lib_assert(hasProperty(property), "tried to access non-existant index property");
640 return m_base->geometry_table.get()[m_base->index_fan_offset_column].get<uint04>(m_design_index);
641 }
643 {
644 //lib_assert(hasProperty(property), "tried to access non-existant index property");
645 return m_base->geometry_table.get()[m_base->index_fan_size_column].get<uint04>(m_design_index);
646 }
647 template<class t_type>
648 uint04 addPrimitive(PrimitiveProperty index_property, const t_type& primitive)
649 {
650 const uint04 primitive_count = primitiveCount(index_property);
651 setPrimitiveRange(index_property, indexOffset(index_property), primitive_count + 1);
652 setPrimitive(index_property, primitive_count, primitive);
653 return primitive_count;
654 }
655 uint04 addPrimitives(PrimitiveProperty index_property, uint04 insersion_size)
656 {
657 const uint04 primitive_count = primitiveCount(index_property);
658 setPrimitiveRange(index_property, indexOffset(index_property), primitive_count + insersion_size);
659 return primitive_count;
660 }
662 void autoCalculateIndices(PrimitiveProperty property, const void* lock = nullptr, ProgressInfo* log = nullptr, const Matrix<fltp08>& transform = Matrix<fltp08>(1.0));
663 public:
664 static void SetTriangulationMethod(std::function<void(Geometry& geo, const Matrix<fltp08>& matrix, const void* lock, ProgressInfo* log)> function);
666 {
667 return m_base->geometry_table.get()[m_base->index_mode_size_column].get<uint04>(m_design_index);
668 }
670 {
671 return m_base->geometry_table.get()[m_base->primitive_property_size_column[cast<uint04>(property)]].get<uint04>(m_design_index);
672 }
674 {
675 return indicesPerPrimitive(mode(property)) * primitiveCount(property);
676 }
677
678 //////////////////////////////[General Vertex]////////////////////////////////////
679
681 {
682 const uint04 count = vertexCount();
683 setVertexSize(count + 1);
684 return count;
685 }
687 {
688 const uint04 count = vertexCount();
689 setVertexSize(count + size);
690 return count;
691 }
692 void addVertices(uint04 location, uint04 size);
694 void removeVertex(uint04 location);
695 void removeVertices(uint04 location, uint04 size);
697 void removeVertices(const Buffer<bool>& selection_mask);
698 void removeVertices(uint04 mask_offset, const Buffer<bool>& selection_mask);
699 void removePrimitive(PrimitiveProperty property, uint04 location);
700 void removePrimitive(PrimitiveProperty property, uint04 location, uint04 size);
702 void removePrimitive(PrimitiveProperty property, const Buffer<bool>& selection_mask);
704
706 {
707 return m_base->geometry_table.get()[m_base->vertex_reserved_count_column].get<uint04>(m_design_index);
708 }
710 {
711 return m_base->geometry_table.get()[m_base->vertex_offset_column].get<uint04>(m_design_index);
712 }
714 {
715 return m_base->geometry_table.get()[m_base->vertex_count_column].get<uint04>(m_design_index);
716 }
718 {
719 return m_base->geometry_table.get()[m_base->solid_vertex_offset_column].get<uint04>(m_design_index);
720 }
722 {
723 return m_base->geometry_table.get()[m_base->solid_vertex_reserved_count_column].get<uint04>(m_design_index);
724 }
726 {
727 return m_base->geometry_table.get()[m_base->solid_vertex_count_column].get<uint04>(m_design_index);
728 }
729
730 //////////////////////////////[Property Vertex]////////////////////////////////////
731
732 const String& vertexPropertyName(uint04 property_index) const
733 {
734 return m_base->vertex_table->get(property_index).label();
735 }
737 uint04 vertexPropertyIndex(const String& property_name) const;
738 bool hasVertexProperty(const String& property_name) const;
739 bool hasVertexProperty(const VertexProperty& property) const;
740 TypeInfo vertexPropertyType(uint04 property_index) const
741 {
742 return propertyColumn(property_index).type();
743 }
744
745 template<class t_type>
746 uint04 createVertexProperty(const String& property_name)
747 {
748 return createVertexProperty(property_name, GetTypeInfo<t_type>());
749 }
750 uint04 createVertexProperty(const String& property_name, const TypeInfo& type);
751
752 template<class t_type>
753 t_type vertexProperty(uint04 property_index, uint04 vertex_index) const
754 {
755 return propertyColumn(property_index).get<t_type>(vertexOffset() + vertex_index);
756 }
757 template<class t_type>
758 t_type vertexProperty(const String& property, uint04 vertex_index) const
759 {
760 return propertyColumn(property).get<t_type>(vertexOffset() + vertex_index);
761 }
762 template<class t_type>
763 t_type vertexProperty(uint04 property_index, uint04 vertex_index, uint04 sub_index) const
764 {
765 return propertyColumn(property_index).get<t_type>(vertexOffset() + vertex_index, sub_index);
766 }
767 template<class t_type>
768 t_type vertexProperty(const String& property, uint04 vertex_index, uint04 sub_index) const
769 {
770 return propertyColumn(property).get<t_type>(vertexOffset() + vertex_index, sub_index);
771 }
772
773
774 template<class t_type>
775 void setVertexProperty(uint04 property, uint04 index, const t_type& vector)
776 {
777 lib_assert(index <= vertexCount(), "Out of bounds vertex set");
778 propertyColumn(property).set(vertexOffset() + index, vector);
779 }
780 template<class t_type>
781 void setVertexProperty(const String& property, uint04 index, const t_type& property_value)
782 {
783 lib_assert(index <= vertexCount(), "Out of bounds vertex set");
784 propertyColumn(property).set(vertexOffset() + index, property_value);
785 }
786 template<class t_type>
787 void setVertexProperty(uint04 property, uint04 index, uint04 sub_index, const t_type& vector)
788 {
789 lib_assert(index <= vertexCount(), "Out of bounds vertex set");
790 propertyColumn(property).set(vertexOffset() + index, sub_index, vector);
791 }
792 template<class t_type>
793 void setVertexProperty(const String& property, uint04 index, uint04 sub_index, const t_type& vector)
794 {
795 lib_assert(index <= vertexCount(), "Out of bounds vertex set");
796 propertyColumn(property).set(vertexOffset() + index, sub_index, vector);
797 }
798 template<class t_type>
799 void setVertexProperties(const String& property, const Buffer<t_type>& vertices, uint04 offset = 0)
800 {
801 lib_assert(offset + vertices.size() <= vertexCount(), "Out of bounds vertex set");
802 uint04 vertex_offset = vertexOffset() + offset;
803 auto& col = propertyColumn(property);
804 for (uint04 i = 0; i < vertices.size(); i++)
805 {
806 col.set(vertex_offset + i, vertices[i]);
807 }
808 }
809 //////////////////////////////[Reserved Vertex]////////////////////////////////////
811 {
812 return m_base->vertex_table.get()[property];
813 }
814 const TableColumn& propertyColumn(uint04 property) const
815 {
816 return m_base->vertex_table.get()[property];
817 }
818 bool hasProperty(VertexProperty property) const
819 {
820 return mode(property) != VertexMode::e_no_vertex;
821 }
823 {
824 return m_base->geometry_table.get()[m_base->vertex_mode_column[cast<uint04>(property)]].get<VertexMode>(m_design_index);
825 }
826 void setupVertexTable(uint04 vertex_size
827 , VertexMode position
828 , VertexMode normal = VertexMode::e_no_vertex
829 , VertexMode color = VertexMode::e_no_vertex
830 , VertexMode texture = VertexMode::e_no_vertex
831 , VertexMode tangent = VertexMode::e_no_vertex
832 , VertexMode bitangent = VertexMode::e_no_vertex
833 , VertexMode bones = VertexMode::e_no_vertex);
835 void updateVertexColumn(VertexProperty property, uint04 index, uint04 size);
836 void updateVertexColumn(const String& property);
837 void updateVertexColumn(const String& property, uint04 index, uint04 size);
838 void updateVertexColumns(bool invalidate_bounds = true, bool erase_kd_tree = true);
839 void updateSolidVertexColumns(bool invalidate_bounds = true, bool erase_kd_tree = true);
840 void updateVertexColumns(uint04 index, uint04 size, bool invalidate_bounds = true, bool erase_kd_tree = true);
841
842 fltp08 calculateVolume(const Matrix<fltp08>& parent_transform) const;
843 fltp08 calculateSurfaceArea(const Matrix<fltp08>& parent_transform) const;
844 Vector<2, fltp08> calculateVolumeAndSurfaceArea(const Matrix<fltp08>& transform, const void* lock) const;
845 fltp08 calculateLength(const Matrix<fltp08>& transform) const;
847 Vector<2, fltp08> calculateHVLength(const Matrix<fltp08>& mat) const;//Calculate horizontal and vertical length
848 bool hasTree(PrimitiveProperty primitive_property, VertexProperty vertex_property = VertexProperty::Position) const;
849 DynamicPointer<RTree<3, fltp04>> tree(PrimitiveProperty primitive_property, VertexProperty vertex_property = VertexProperty::Position) const;
850 void setTree(DynamicPointer<RTree<3, fltp04>> tree, PrimitiveProperty primitive_property, VertexProperty vertex_property = VertexProperty::Position) const;
851 void removeTrees(VertexProperty vertex_property = VertexProperty::Position);
852 void removeTree(PrimitiveProperty property, VertexProperty vertex_property = VertexProperty::Position);
853 const Buffer<uint04>& getTreeIndices(PrimitiveProperty primitive_property) const;
854 template<class t_type>
855 Buffer<t_type> getTreeSortedVertices(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
856 {
857 const Buffer<uint04>& indices = getTreeIndices(primitive_property);
858 Buffer<t_type> original_vals = vertices<t_type>(vertex_property);
859 Buffer<t_type> sorted_vertices(indices.size());
860 sorted_vertices.setSize(indices.size(), Constant<t_type>::Invalid);
861 for(uint04 i = 0; i < indices.size(); ++i)
862 {
863 if (indices[i] < original_vals.size())
864 sorted_vertices[i] = original_vals[indices[i]];
865 }
866 return sorted_vertices;
867 }
868 void addToTree(uint04 start, uint04 size, PrimitiveProperty primitive_property, VertexProperty vertex_property) const;
870 template<class t_type>
871 void setVertex(VertexProperty property, uint04 index, const t_type& vector)
872 {
873 lib_assert(index < vertexCount(), "Out of bounds vertex set");
874 column(property).set(vertexOffset() + index, vector);
875 }
876
877 template<class t_type>
878 void setVertex(VertexProperty property, uint04 index, uint04 sub_index, const t_type& vector)
879 {
880 lib_assert(index < vertexCount(), "Out of bounds vertex set");
881 column(property).set(vertexOffset() + index, sub_index, vector);
882 }
883
884 template<class t_type>
885 void setVertices(VertexProperty property, const Buffer<t_type>& vertices, uint04 offset = 0)
886 {
887 lib_assert(offset + vertices.size() <= vertexCount(), "Out of bounds vertex set");
888 uint04 vertex_offset = vertexOffset() + offset;
889 auto& col = column(property);
890 for (uint04 i = 0; i < vertices.size(); i++)
891 {
892 col.set(vertex_offset + i, vertices[i]);
893 }
894 }
895
896 template<class t_type, class t_matrix_type>
897 void setVertices(VertexProperty property, const Buffer<t_type>& vertices, const Matrix<t_matrix_type>& matrix, uint04 offset = 0)
898 {
899 lib_assert(offset + vertices.size() <= vertexCount(), "Out of bounds vertex set");
900 uint04 vertex_offset = vertexOffset() + offset;
901 auto& col = column(property);
902 for (uint04 i = 0; i < vertices.size(); i++)
903 {
904 col.set(vertex_offset + i, matrix * vertices[i].template as<t_type::NumberOfDimensions(), t_matrix_type>());
905 }
906 }
907 template<class t_type>
908 void setVertices(VertexProperty property, const t_type* vertices, uint04 size, uint04 offset = 0)
909 {
910 lib_assert(offset + size <= vertexCount(), "Out of bounds vertex set");
911 uint04 vertex_offset = vertexOffset() + offset;
912 auto& col = column(property);
913 for (uint04 i = 0; i < size; i++)
914 {
915 col.set(vertex_offset + i, vertices[i]);
916 }
917 }
918 template<class t_type>
919 t_type vertex(VertexProperty property, uint04 index) const
920 {
921 lib_assert(index < vertexCount(), "Out of bounds vertex get");
922 return column(property).get<t_type>(vertexOffset() + index);
923 }
924 template<uint01 t_dims, class t_type>
925 LineSegment<t_dims, t_type> lineSegment(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 line_index) const
926 {
927 const Vector<2, uint04> line = primitive<Vector<2, uint04>>(primitive_property, line_index);
928 if (IsInvalid(line))
931 vertex<Vector<t_dims, t_type>>(vertex_property, line[A])
932 , vertex<Vector<t_dims, t_type>>(vertex_property, line[B]));
933 }
934 template<uint01 t_dims, class t_type>
935 Triangle<t_dims, t_type> triangle(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 tri_index) const
936 {
937 const Vector<3, uint04> tri = primitive<Vector<3, uint04>>(primitive_property, tri_index);
938 if (IsInvalid(tri))
939 return Constant<Triangle<t_dims, t_type>>::Invalid;
941 vertex<Vector<t_dims, t_type>>(vertex_property, tri[A])
942 , vertex<Vector<t_dims, t_type>>(vertex_property, tri[B])
943 , vertex<Vector<t_dims, t_type>>(vertex_property, tri[C]));
944 }
945 bool hasColumn(VertexProperty property) const
946 {
947 return m_base->vertex_table->hasColumn(m_base->vertex_property_column[cast<uint04>(property)]);
948 }
949 template<class t_type>
951 {
952 return propertyVertices<t_type>(property, 0, vertexCount());
953 }
954 template<class t_type>
956 {
957 lib_assert(start + size <= vertexCount(), "Out of bounds vertex selection");
958 const uint04 vertex_offset = vertexOffset();
959 return m_base->vertex_table.get()[property].getAll<t_type>(vertex_offset + start, size);
960 }
961 template<class t_type>
963 {
964 return vertices<t_type>(property, 0, vertexCount());
965 }
966 template<class t_type>
968 {
969 lib_assert(start + size <= vertexCount(), "Out of bounds vertex selection");
970 const uint04 vertex_offset = vertexOffset();
971 return column(property).getAll<t_type>(vertex_offset + start, size);
972 }
973
974 template<class t_type>
975 Buffer<t_type> vertices(const String& property) const
976 {
977 return vertices<t_type>(property, 0, vertexCount());
978 }
979 template<class t_type>
980 Buffer<t_type> vertices(const String& property, uint04 start, uint04 size) const
981 {
982 lib_assert(start + size <= vertexCount(), "Out of bounds vertex selection");
983 const uint04 vertex_offset = vertexOffset();
984 return propertyColumn(property).getAll<t_type>(vertex_offset + start, size);
985 }
986
987 template<uint01 t_dims, class t_type>
989 {
990 uint04 size = primitiveCount(primitive_property);
991 switch (mode(primitive_property))
992 {
993 case PrimitiveMode::e_lines:
994 break;
995 case PrimitiveMode::e_polyline:
996 --size;//polylines have 1 less line segment than number of indices
997 break;
998 default:
999 lib_assert(false, "Bad property fetch mode");
1000 }
1002 for (uint04 i = 0; i < size; ++i)
1003 lines.add(lineSegment<t_dims, t_type>(primitive_property, vertex_property, i));
1004 return lines;
1005 }
1006 template<uint01 t_dims, class t_type>
1008 {
1009 return triangles<t_dims, t_type>(primitive_property, vertex_property, 0, primitiveCount(primitive_property));
1010 }
1011 template<uint01 t_dims, class t_type>
1012 Buffer<Triangle<t_dims, t_type>> triangles(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
1013 {
1014 lib_assert(start + size <= primitiveCount(primitive_property), "Out of bounds triangle selection");
1015 const uint04 index_offset = indexOffset() + indexOffset(primitive_property);
1016 const PrimitiveMode index_mode = mode(primitive_property);
1017 const TableColumn& index_column = primitiveColumn();
1018 const TableColumn& fan_column = primitiveFanColumn();
1019 const TableColumn& vertex_column = column(vertex_property);
1020 Buffer<Triangle<t_dims, t_type>> triangles(size);
1021
1022 for (uint04 i = start; i < size + start; i++)
1023 {
1024 Vector<3, uint04> index_value;
1025 switch (index_mode)
1026 {
1027 case PrimitiveMode::e_triangle:
1028 index_value = {
1029 index_column.get<uint04>(index_offset + 3 * i + 0)
1030 , index_column.get<uint04>(index_offset + 3 * i + 1)
1031 , index_column.get<uint04>(index_offset + 3 * i + 2) };
1032 break;
1033 case PrimitiveMode::e_triangle_strip:
1034 index_value = {
1035 index_column.get<uint04>(i + index_offset + 0)
1036 , index_column.get<uint04>(i + index_offset + 1)
1037 , index_column.get<uint04>(i + index_offset + 2) };
1038 break;
1039 case PrimitiveMode::e_triangle_fan:
1040 {
1041 const uint04 fan_offset = indexFanOffset();
1042 uint04 index_fan_location = fan_column.get<uint04>(i + fan_offset);
1043 if (IsInvalid(index_fan_location))
1044 {
1045 index_value = Constant<Vector<3, uint04>>::Invalid;
1046 }
1047 else
1048 {
1049 lib_assert(index_fan_location >= index_offset && index_fan_location - index_offset < primitiveCount(primitive_property), "bad fan location");
1050 index_value = {
1051 index_column.get<uint04>(index_fan_location)
1052 , index_column.get<uint04>(i + index_offset - 1)
1053 , index_column.get<uint04>(i + index_offset) };
1054 }
1055 } break;
1056 default:
1057 lib_assert(false, "Bad property fetch mode");
1058 }
1059 if (IsInvalid(index_value))
1060 {
1061 triangles.add(Constant<Triangle<t_dims, t_type>>::Invalid);
1062 }
1063 else
1064 {
1065 triangles.add(Triangle<t_dims, t_type>(
1066 vertex_column.get<Vector<t_dims, t_type>>(index_value[A])
1067 , vertex_column.get<Vector<t_dims, t_type>>(index_value[B])
1068 , vertex_column.get<Vector<t_dims, t_type>>(index_value[C])));
1069 }
1070 }
1071 return triangles;
1072 }
1074 Buffer<Buffer<uint04>> polyIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const;
1075 template<uint01 t_dims, class t_type>
1077 {
1078 return polygons<t_dims, t_type>(primitive_property, vertex_property, 0, primitiveCount(primitive_property));
1079 }
1080 template<uint01 t_dims, class t_type>
1082 {
1083 lib_assert(start + size <= primitiveCount(primitive_property), "Out of bounds polygon selection");
1084 const uint04 index_offset = indexOffset() + indexOffset(primitive_property);
1085 //const uint04 vertex_offset = vertexOffset();
1086 const PrimitiveMode index_mode = mode(primitive_property);
1087 const TableColumn& index_column = primitiveColumn();
1088 const TableColumn& vertex_column = column(vertex_property);
1090 switch (index_mode)
1091 {
1092 case PrimitiveMode::e_triangle:
1093 case PrimitiveMode::e_triangle_strip:
1094 case PrimitiveMode::e_triangle_fan:
1095 {
1096 const TableColumn& fan_column = primitiveFanColumn();
1097 const uint04 fan_offset = indexFanOffset();
1098 for (uint04 i = start; i < size + start; i++)
1099 {
1100 Vector<3, uint04> index_value;
1101 switch (index_mode)
1102 {
1103 case PrimitiveMode::e_triangle:
1104 index_value = {
1105 index_column.get<uint04>(index_offset + 3 * i + 0)
1106 , index_column.get<uint04>(index_offset + 3 * i + 1)
1107 , index_column.get<uint04>(index_offset + 3 * i + 2) };
1108 break;
1109 case PrimitiveMode::e_triangle_strip:
1110 index_value = {
1111 index_column.get<uint04>(i + index_offset + 0)
1112 , index_column.get<uint04>(i + index_offset + 1)
1113 , index_column.get<uint04>(i + index_offset + 2) };
1114 break;
1115 case PrimitiveMode::e_triangle_fan:
1116 {
1117 uint04 index_fan_location = fan_column.get<uint04>(i + fan_offset);
1118 if (IsInvalid(index_fan_location))
1119 index_value = Constant<Vector<3, uint04>>::Invalid;
1120 else
1121 index_value = {
1122 index_column.get<uint04>(index_fan_location)
1123 , index_column.get<uint04>(i + index_offset - 1)
1124 , index_column.get<uint04>(i + index_offset) };
1125 } break;
1126 default:
1127 lib_assert(false, "Bad property fetch mode");
1128 }
1129 if (!IsInvalid(index_value))
1130 {
1131 polygons.add(Polygon<t_type, Vertex<t_dims, t_type>>(3));
1132 polygons.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[A]));
1133 polygons.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[B]));
1134 polygons.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[C]));
1135
1136 }
1137 }
1138 } break;
1139 case PrimitiveMode::e_polyline:
1140 {
1142 for (uint04 i = start; i < size + start; i++)
1143 {
1144 uint04 index = index_column.get<uint04>(index_offset + i);
1145 if (!IsInvalid(index))
1146 {
1147 poly.add(vertex_column.get<Vector<t_dims, t_type>>(index));
1148 }
1149 else
1150 {
1151 if (poly.vertexCount() > 0)
1152 {
1153 polygons.add(poly);
1154 poly.clear();
1155 }
1156 }
1157 }
1158 if (poly.vertexCount() > 0)
1159 {
1160 polygons.add(poly);
1161 }
1162 } break;
1163 default:
1164 break;
1165 }
1166 return polygons;
1167 }
1168
1169 template<uint01 t_dims, class t_type>
1171 {
1172 uint04 primitive_count = primitiveCount(primitive_property);
1173 if(primitive_count == 0)
1174 return polylines<t_dims, t_type>(primitive_property, vertex_property, 0, vertexCount());
1175 else
1176 return polylines<t_dims, t_type>(primitive_property, vertex_property, 0, primitiveCount(primitive_property));
1177 }
1178 template<uint01 t_dims, class t_type>
1179 Buffer<Polyline<t_dims, t_type>> polylines(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
1180 {
1181 const uint04 primitive_count = primitiveCount(primitive_property);
1182 lib_assert(primitive_count == 0 || start + size <= primitive_count, "Out of bounds polyline selection");
1183 const uint04 index_offset = primitive_count == 0 ? vertexOffset() : indexOffset() + indexOffset(primitive_property);
1184 const PrimitiveMode index_mode = mode(primitive_property);
1185 const TableColumn& index_column = primitiveColumn();
1186 const TableColumn& vertex_column = column(vertex_property);
1187 Buffer<Polyline<t_dims, t_type>> polylines(size);
1188 switch (index_mode)
1189 {
1190 case PrimitiveMode::e_triangle:
1191 case PrimitiveMode::e_triangle_strip:
1192 case PrimitiveMode::e_triangle_fan:
1193 {
1194 if (primitive_count == 0)
1195 return polylines;//not yet finished
1196 const TableColumn& fan_column = primitiveFanColumn();
1197 const uint04 fan_offset = indexFanOffset();
1198 for (uint04 i = start; i < size + start; i++)
1199 {
1200 Vector<3, uint04> index_value;
1201 switch (index_mode)
1202 {
1203 case PrimitiveMode::e_triangle:
1204 index_value = {
1205 index_column.get<uint04>(index_offset + 3 * i + 0)
1206 , index_column.get<uint04>(index_offset + 3 * i + 1)
1207 , index_column.get<uint04>(index_offset + 3 * i + 2) };
1208 break;
1209 case PrimitiveMode::e_triangle_strip:
1210 index_value = {
1211 index_column.get<uint04>(i + index_offset + 0)
1212 , index_column.get<uint04>(i + index_offset + 1)
1213 , index_column.get<uint04>(i + index_offset + 2) };
1214 break;
1215 case PrimitiveMode::e_triangle_fan:
1216 {
1217 uint04 index_fan_location = fan_column.get<uint04>(i + fan_offset);
1218 if (IsInvalid(index_fan_location))
1219 index_value = Constant<Vector<3, uint04>>::Invalid;
1220 else
1221 index_value = {
1222 index_column.get<uint04>(index_fan_location)
1223 , index_column.get<uint04>(i + index_offset - 1)
1224 , index_column.get<uint04>(i + index_offset) };
1225 } break;
1226 default:
1227 lib_assert(false, "Bad property fetch mode");
1228 }
1229 if (!IsInvalid(index_value))
1230 {
1231 polylines.add(Polyline<t_dims, t_type >(4));
1232 polylines.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[A]));
1233 polylines.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[B]));
1234 polylines.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[C]));
1235 polylines.last().add(vertex_column.get<Vector<t_dims, t_type>>(index_value[A]));
1236
1237 }
1238 }
1239 } break;
1240 case PrimitiveMode::e_polyline:
1241 {
1243 for (uint04 i = start; i < size + start; i++)
1244 {
1245 uint04 index = primitive_count > 0 ? index_column.get<uint04>(index_offset + i) : i + index_offset;
1247 if (!IsInvalid(index))
1248 vert = vertex_column.get<Vector<t_dims, t_type>>(index);
1249
1250 if (!IsInvalid(vert))
1251 {
1252 poly.add(vert);
1253 }
1254 else
1255 {
1256 if (poly.vertexCount() > 0)
1257 {
1258 polylines.add(poly);
1259 poly.clear();
1260 }
1261 }
1262 }
1263 if (poly.vertexCount() > 0)
1264 {
1265 polylines.add(poly);
1266 }
1267 } break;
1268 case PrimitiveMode::e_lines:
1269 {
1271 if (primitive_count == 0)
1272 start++;//prevent overflow
1273 for (uint04 i = start; i < size + start; i++)
1274 {
1275 Vector<2, uint04> index;
1276 if (primitive_count == 0)
1277 {
1278 index = Vector<2, uint04>(i - 1, i) + index_offset;
1279 i++;//increment i by one since
1280 }
1281 else
1282 {
1283 index = Vector<2, uint04>(
1284 index_column.get<uint04>(index_offset + 2 * i + 0)
1285 , index_column.get<uint04>(index_offset + 2 * i + 1));
1286 }
1287 if (!IsInvalid(index))
1288 {
1289 Vertex<3, fltp08> vert_a = vertex_column.get<Vector<t_dims, t_type>>(index[A]);
1290 if (IsInvalid(vert_a))
1291 continue;
1292 Vertex<3, fltp08> vert_b = vertex_column.get<Vector<t_dims, t_type>>(index[B]);
1293 if (IsInvalid(vert_b))
1294 continue;
1295 poly.add(vert_a);
1296 poly.add(vert_b);
1297 polylines.add(poly);
1298 poly.clear();
1299 }
1300 }
1301 } break;
1302 default:
1303 break;
1304 }
1305 return polylines;
1306 }
1307
1309
1311 {
1312 return m_base->vertex_table.get()[m_base->vertex_property_column[cast<uint04>(property)]];
1313 }
1314 const TableColumn& column(VertexProperty property) const
1315 {
1316 return m_base->vertex_table.get()[m_base->vertex_property_column[cast<uint04>(property)]];
1317 }
1318 public:
1320 {
1321 return m_base->vertex_table->get(property);
1322 }
1323 const TableColumn& propertyColumn(const String& property) const
1324 {
1325 return m_base->vertex_table->get(property);
1326 }
1328 {
1329 m_base->geometry_table.get()[m_base->solid_vertex_count_column].set(m_design_index, count);
1330 }
1332 {
1333 m_base->geometry_table.get()[m_base->solid_vertex_reserved_count_column].set(m_design_index, count);
1334 }
1336 {
1337 m_base->geometry_table.get()[m_base->solid_vertex_offset_column].set(m_design_index, count);
1338 }
1341 protected:
1342 template<class t_index_type, class t_vec_type>
1343 void setPrimitiveVec(PrimitiveProperty property, uint04 index, t_vec_type& index_value)
1344 {
1345 lib_assert(index < primitiveCount(property), "Bad index set");
1346 if (!IsInvalid(index_value))
1347 {
1348#ifdef _DEBUG
1349 uint04 vertex_count = vertexCount();
1350 lib_assert(index_value[A] < vertex_count, "Bad vertex A");
1351 lib_assert(index_value[B] < vertex_count, "Bad vertex B");
1352 lib_assert(index_value[C] < vertex_count, "Bad vertex C");
1353#endif
1354 index_value += t_vec_type(vertexOffset());
1355 }
1356 else
1357 {
1358 index_value = Constant<t_vec_type>::Invalid;
1359 }
1360 OptimizedPrimitiveDef def = optimizedPrimitiveDef(property);
1361 if (def.mode == PrimitiveMode::e_triangle_fan)
1362 {
1363 def.column.set(primitiveFanColumn().get<uint04>(index + indexFanOffset()), index_value[A]);
1364 def.column.set(def.index_offset + index - 1, index_value[B]);
1365 def.column.set(def.index_offset + index - 0, index_value[C]);
1366 }
1367 else
1368 {
1369 OptimizedSetPrimitiveVec(def, index, index_value);
1370 }
1371 }
1372
1373 ///Index
1375 {
1376 m_base->geometry_table.get()[m_base->index_mode_size_column].set(m_design_index, count);
1377 }
1379 {
1380 m_base->geometry_table.get()[m_base->index_fan_size_column].set(m_design_index, count);
1381 }
1383 {
1384 m_base->geometry_table.get()[m_base->primitive_property_size_column[cast<uint04>(property)]].set(m_design_index, count);
1385 }
1387 {
1388 m_base->geometry_table.get()[m_base->index_fan_offset_column].set(m_design_index, offset);
1389 }
1391 {
1392 m_base->geometry_table.get()[m_base->index_mode_offset_column].set(m_design_index, offset);
1393 }
1395 {
1396 m_base->geometry_table.get()[m_base->primitive_property_offset_column[cast<uint04>(property)]].set(m_design_index, offset);
1397 }
1399 {
1400 m_base->geometry_table.get()[m_base->primitive_property_mode_column[cast<uint04>(property)]].set(m_design_index, mode);
1401 }
1402 ///Vertex
1404 {
1405 m_base->geometry_table.get()[m_base->vertex_count_column].set(m_design_index, count);
1406 }
1408 {
1409 m_base->geometry_table.get()[m_base->vertex_reserved_count_column].set(m_design_index, count);
1410 }
1412 {
1413 m_base->geometry_table.get()[m_base->vertex_offset_column].set(m_design_index, count);
1414 }
1415
1416
1417
1418 void setModeValue(VertexProperty property, VertexMode vert_mode)
1419 {
1420 lib_assert(vert_mode != e_index, "Not yet supported");
1421 m_base->geometry_table.get()[m_base->vertex_mode_column[cast<uint04>(property)]].set(m_design_index, vert_mode);
1422 }
1423
1424 //Should Only be called by Model!
1425 void addFromParent(Model& parent);
1426 void removeParent(const Model& parent);
1427 protected:
1428 static std::function<void(Geometry& geo, const Matrix<fltp08>& matrix, const void* lock, ProgressInfo* log)> s_geometry_triangulation;
1429 };
1430
1431 template<>
1432 struct ObjectInfo<Geometry, false, false>
1433 {
1434 static const uint01 Dimensions = 0;
1435 static const bool Vector = false;
1436 static const bool Buffer = false;
1437 static const bool Primitive = DESIGN_PRIM;
1438 static const bool Pointer = false;
1439 static const bool Unsigned = false;
1440 static const bool Float = false;
1441 static const bool Integer = false;
1442 static const bool Number = false;
1443 static const bool Enum = false;
1444 static const bool String = false;
1445 static const bool Color = false;
1446 static const bool Boolean = false;
1447 static constexpr ObjectInfo<Geometry, false, false> VectorSub() { return ObjectInfo<Geometry, false, false>(); }
1448 };
1449
1450 /**--------------------------------------------------------------------------------------------------
1451 \brief A class to easily iterate each vertex of a Geometry
1452 **/
1453 template<class t_type>
1455 {
1456 public:
1458 : m_geo(geo)
1459 , m_column(geo.column(vertex_property))
1460 , m_flag_column(geo.column(VertexProperty::BitFlag))
1461 , m_vertex_property(vertex_property)
1462 , m_vertex_offset(geo.vertexOffset())
1463 , m_vertex_count(geo.vertexCount())
1464
1465 {}
1466 VertexIterator(const String& vertex_property, Geometry geo)
1467 : m_geo(geo)
1468 , m_column(geo.propertyColumn(vertex_property))
1469 , m_flag_column(geo.column(VertexProperty::BitFlag))
1471 , m_vertex_offset(geo.vertexOffset())
1472 , m_vertex_count(geo.vertexCount())
1473
1474 {}
1475 t_type operator[](uint04 index) const
1476 {
1477 //const BitFlag flag = m_flag_column.get<uint01>(m_vertex_offset + index);
1478 //if (flag[cast<uint01>(VertexBitFlags::e_is_hidden)])
1479 //return Constant<Vertex<t_dims, t_type>>::Invalid;
1480 return m_column.get<t_type>(m_vertex_offset + index);
1481 }
1482 BitFlag flag(uint04 index) const
1483 {
1485 return flag;
1486 }
1487 void setVertex(uint04 index, const t_type& value)
1488 {
1489 return m_column.set(m_vertex_offset + index, value);
1490 }
1491 void setFlag(uint04 index, const BitFlag& value)
1492 {
1493 return m_flag_column.set(m_vertex_offset + index, value);
1494 }
1495 uint04 size() const
1496 {
1497 return m_vertex_count;
1498 }
1502
1503
1507 };
1508
1509
1510 /**--------------------------------------------------------------------------------------------------
1511 \brief A class to easily iterate each line segment over a Geometry of lines.
1512 **/
1513 template<uint01 t_dims, class t_type>
1515 {
1516 public:
1517 LineIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry geo)
1518 : m_primitive_def(geo.optimizedPrimitiveDef(primitive_property))
1519 , m_vertex_column(geo.column(vertex_property))
1520 , m_flag_column(geo.column(VertexProperty::BitFlag))
1521 , m_primitive_count(geo.primitiveCount(primitive_property))
1522 , m_vertex_offset(geo.vertexOffset())
1523 {
1525 m_primitive_count--;//since sending vertex count, segment count is one less
1526 }
1528 {
1529 Vector<2, uint04> index_vert = rawIndex(index);
1530 for (uint04 i = 0; i < 2; i++)
1531 {
1532 if (IsInvalid(index_vert[i]) || isHidden(index_vert[i]))
1533 index_vert[i] = Constant<uint04>::Invalid;
1534 else
1535 index_vert[i] -= m_vertex_offset;
1536 }
1537 return index_vert;
1538 }
1539
1541 {
1542 Vector<2, uint04> index_vert = rawIndex(index);
1544 for (uint01 i = 0; i < 2; i++)
1545 {
1546 if (IsInvalid(index_vert[i]) || isHidden(index_vert[i]))
1548 else
1549 m_vertex_column.get(index_vert[i], seg[i]);
1550
1551 }
1552 return seg;
1553 }
1554 uint04 size() const
1555 {
1556 return m_primitive_count;
1557 }
1558 protected:
1563 bool isHidden(uint04 index) const
1564 {
1565 BitFlag bit_flags = m_flag_column.get<uint01>(index);
1566 return bit_flags[cast<uint01>(VertexFlags::e_is_hidden)];
1567 }
1574 };
1575 /**--------------------------------------------------------------------------------------------------
1576 \brief A class to easily iterate each triangle over a Geometry of triangles or meshes.
1577 **/
1578 template<uint01 t_dims, class t_type>
1580 {
1581 public:
1582 TriangleIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry mesh)
1583 : m_primitive_def(mesh.optimizedPrimitiveDef(primitive_property))
1584 , m_vertex_column(mesh.column(vertex_property))
1585 , m_primitive_count(mesh.primitiveCount(primitive_property))
1586 , m_vertex_offset(mesh.vertexOffset())
1587 {
1589 m_primitive_count -= 2;//primitive count is vertices so minus 2 triangles
1590 }
1591 TriangleIterator(PrimitiveProperty primitive_property, const String& vertex_property, Geometry mesh)
1592 : m_primitive_def(mesh.optimizedPrimitiveDef(primitive_property))
1593 , m_vertex_column(mesh.propertyColumn(vertex_property))
1594 , m_primitive_count(mesh.primitiveCount(primitive_property))
1595 , m_vertex_offset(mesh.vertexOffset())
1596 {
1598 m_primitive_count -= 2;//primitive count is vertices so minus 2 triangles
1599 }
1601 {
1602 Vector<3, uint04> index_vert = rawIndex(index);
1604 for (uint01 i = 0; i < 3; i++)
1605 {
1606 if (IsInvalid(index_vert[i]))
1608 else
1609 m_vertex_column.get(index_vert[i], tri[i]);
1610
1611 }
1612 return tri;
1613 }
1615 {
1616 Vector<3, uint04> index_vert = rawIndex(index);
1617 for (uint01 i = 0; i < 3; i++)
1618 {
1619 if (!IsInvalid(index_vert[i]))
1620 index_vert[i] -= m_vertex_offset;
1621 }
1622 return index_vert;
1623 }
1624 uint04 size() const
1625 {
1626 return m_primitive_count;
1627 }
1628 protected:
1637 };
1638
1639 /**--------------------------------------------------------------------------------------------------
1640 \brief Class to easily restore calculated data in a Geometry after a location altering process.
1641 **/
1643 {
1644 public:
1648 {
1649 store(geo);
1650 }
1651 void store(const Geometry& geo);
1652 void restoreNormals(const void* lock, ProgressInfo* log = nullptr);
1653 void restoreClosed(const void* lock, ProgressInfo* log = nullptr);
1654 void restoreAll(const void* lock, ProgressInfo* log = nullptr, bool restore_tree = true, bool restore_closed = true, bool restore_normals = true, bool restore_smooth = true);
1655 void restoreSmooth(const void* lock, ProgressInfo* log = nullptr);
1656 protected:
1657 void restoreNormals(Geometry& geo, const void* lock, ProgressInfo* log = nullptr);
1658 void restoreClosed(Geometry& geo, const void* lock, ProgressInfo* log = nullptr);
1659 bool m_has_tangent = false;
1660 bool m_has_bitangent = false;
1662 bool m_is_closed = false;
1668 };
1669
1670
1672}
1673
1674namespace std//Define things to allow use within std libs
1675{
1676 template <>
1677 struct hash<NDEVR::Geometry>
1678 {
1679 std::size_t operator()(const NDEVR::Geometry& d) const noexcept
1680 {
1681 NDEVR::UUID s = d.uuid();
1682 std::size_t value = 0;
1683 for (NDEVR::uint01 i = 0; i < 8; i++)
1684 value = value * 256 + (s[i + 0U] ^ s[i + 8U]);
1685 return value;
1686 }
1687 };
1688};
1689
1690
1691
#define NDEVR_DESIGN_API
Definition DLLInfo.h:55
#define lib_assert(expression, message)
Definition LibAssert.h:61
The primary angle storage class for this API. Stores an angle in an optimized format.
Definition StringStream.h:540
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:52
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
void add(t_type &&object)
Adds object to the end of the buffer.
Definition Buffer.hpp:186
constexpr t_index_type size() const
Definition Buffer.hpp:823
decltype(auto) last()
Definition Buffer.hpp:588
void setSize(t_index_type new_size)
Definition Buffer.hpp:803
decltype(auto) get(t_index_type index)
Definition Buffer.hpp:541
The core Color class in the NDEVR API. Colors can be defined in several ways. The ACIColor is compact...
Definition Color.h:41
Provides the underlying data storage for the NDEVR Scene Model heirarchy.
Definition DesignObjectBase.h:150
A low-level database object that can be used to access general stored properties within the NDEVR Mod...
Definition DesignObject.h:67
bool isValid() const
Definition DesignObject.h:355
UUID uuid() const
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
A core class within the model heirarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:64
void fillHolesByNeighbor(PrimitiveProperty property, const void *lock=nullptr, ProgressInfo *log=nullptr)
const TableColumn & column(VertexProperty property) const
Definition Geometry.h:1314
void splitDuplicateVertices()
void setVertexOffsetValue(uint04 count)
Definition Geometry.h:1411
void setSolidVertexOffsetValue(uint04 count)
Definition Geometry.h:1335
void updateSolidVertexColumns(bool invalidate_bounds=true, bool erase_kd_tree=true)
Buffer< t_type > getTreeSortedVertices(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Definition Geometry.h:855
void invalidateBounds()
void split(Geometry &other_geo, const Buffer< bool > &vertex_mask)
TreeMode
Definition Geometry.h:123
void normalExpansion(const Vector< 3, fltp04 > &expansion_vector)
Vector< 2, fltp08 > calculateHVLength(const Matrix< fltp08 > &mat) const
TableColumn & primitiveColumn()
void calculateIndexNeighborList(PrimitiveProperty primitive_property)
uint01 parity(const Matrix< fltp08 > &parent_matrix, PrimitiveMode mode) const
Buffer< Model, uint04, ObjectAllocator< DESIGN_PRIM > > getParents() const
static void OptimizedSetPrimitiveVec(const OptimizedPrimitiveDef &ref, uint04 index, t_vec_type index_value)
Definition Geometry.h:421
const TableColumn & primitiveFlagColumn() const
Definition Geometry.h:288
TableColumn & edgeToFaceColumn()
Definition Geometry.h:301
TableColumn & primitiveFlagColumn()
Definition Geometry.h:284
void setIndexFanCountValue(uint04 count)
Definition Geometry.h:1378
void removeTrees(VertexProperty vertex_property=VertexProperty::Position)
void removeVertices(const Buffer< bool > &selection_mask)
OptimizedPrimitiveDef optimizedPrimitiveDef(PrimitiveProperty property)
Definition Geometry.h:394
void setTransform(const Matrix< fltp08 > &transform)
bool primitiveIndexFlag(PrimitiveProperty property, uint04 primitive_index, PrimitiveBitFlags flag) const
uint04 numberOfParents() const
void setModeValue(VertexProperty property, VertexMode vert_mode)
Definition Geometry.h:1418
Geometry()=default
void updateModifiedTime(Time time=Time::SystemTime())
bool canBeClosedSolid(const void *lock=nullptr) const
Buffer< Triangle< t_dims, t_type > > triangles(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
Definition Geometry.h:1012
fltp08 calculateLength(const Matrix< fltp08 > &transform) const
Buffer< Polyline< t_dims, t_type > > polylines(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
Definition Geometry.h:1179
LineSegment< t_dims, t_type > lineSegment(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 line_index) const
Definition Geometry.h:925
void setPrimitiveVec(PrimitiveProperty property, uint04 index, t_vec_type &index_value)
Definition Geometry.h:1343
bool validate() const
void updateVertexColumns(bool invalidate_bounds=true, bool erase_kd_tree=true)
void calculateTangentSpace(bool calc_tan, bool calc_bitan)
void setPrimitive(PrimitiveProperty property, uint04 index, t_type index_value)
Definition Geometry.h:335
Model getParent(uint04 index) const
uint01 provokingPrimitiveOffset() const
const TableColumn & propertyColumn(const String &property) const
Definition Geometry.h:1323
void setGeometryProperty(GeometryProperty property, const t_type &value)
Definition Geometry.h:147
void removeTree(PrimitiveProperty property, VertexProperty vertex_property=VertexProperty::Position)
void removePrimitive(PrimitiveProperty property, Buffer< uint04 > vertices)
void updatePrimitiveColumn(PrimitiveProperty property, bool remove_tree=true)
void setVertexCountValue(uint04 count)
Vertex.
Definition Geometry.h:1403
static void OptimizedSetPrimitive(const OptimizedPrimitiveDef &ref, uint04 index, t_vec_type index_value)
Definition Geometry.h:408
void setThicknessMode(ThicknessMode mode)
uint04 vertexReservedCount() const
Definition Geometry.h:705
t_type vertex(VertexProperty property, uint04 index) const
Definition Geometry.h:919
TableColumn & primitiveFanColumn()
Definition Geometry.h:276
void setIndexFanOffsetValue(uint04 offset)
Definition Geometry.h:1386
static constexpr uint04 indicesPerPrimitive(PrimitiveMode property)
Definition Geometry.h:514
void setVertices(VertexProperty property, const Buffer< t_type > &vertices, uint04 offset=0)
Definition Geometry.h:885
uint04 addVertices(uint04 size)
Definition Geometry.h:686
TypeInfo vertexPropertyType(uint04 property_index) const
Definition Geometry.h:740
const Buffer< uint04 > & getTreeIndices(PrimitiveProperty primitive_property) const
void setPrimitive(PrimitiveProperty property, uint04 index, Vector< 2, t_type > index_value)
Definition Geometry.h:348
void setVerticesFlagAll(uint01 on_flags, uint01 off_flags)
Buffer< t_type > propertyVertices(uint04 property) const
Definition Geometry.h:950
void updateVertexColumns(uint04 index, uint04 size, bool invalidate_bounds=true, bool erase_kd_tree=true)
void removeVertices(Buffer< uint04 > vertices)
uint04 solidVertexOffset() const
Definition Geometry.h:717
bool hasProperty(VertexProperty property) const
Definition Geometry.h:818
void setTree(DynamicPointer< RTree< 3, fltp04 > > tree, PrimitiveProperty primitive_property, VertexProperty vertex_property=VertexProperty::Position) const
VertexMode
Definition Geometry.h:68
void setPrimitiveIndexFlag(PrimitiveProperty property, uint04 primitive_index, PrimitiveBitFlags flag, bool value)
uint04 indexOffset(PrimitiveProperty property) const
Definition Geometry.h:632
void updateTransform(const Matrix< fltp08 > &transform, const void *lock_ptr=nullptr)
void combine(const Geometry &geo, const Matrix< fltp08 > &conversion, Buffer< bool > vertex_mask)
uint04 vertexCount() const
Definition Geometry.h:713
void setRealThickness(fltp08 real_thickness, const Matrix< fltp08 > &transform, const void *lock, ProgressInfo *log=nullptr)
GeometryType getGeometryType() const
bool canExplode() const
t_type vertexProperty(const String &property, uint04 vertex_index) const
Definition Geometry.h:758
uint04 indexFanCount() const
Definition Geometry.h:642
fltp08 calculateVolume(const Matrix< fltp08 > &parent_transform) const
Geometry(uint04 index, DesignObjectBase *base)
Buffer< t_type > vertices(VertexProperty property, uint04 start, uint04 size) const
Definition Geometry.h:967
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)
void setVertexProperty(uint04 property, uint04 index, uint04 sub_index, const t_type &vector)
Definition Geometry.h:787
void setGeometryType(GeometryType geometry_type)
void addToTree(uint04 start, uint04 size, PrimitiveProperty primitive_property, VertexProperty vertex_property) const
void setIndexCountValue(uint04 count)
Index.
Definition Geometry.h:1374
uint04 indexFanOffset() const
Definition Geometry.h:637
bool operator!=(const Geometry &model) const
Definition Geometry.h:254
void setPrimitive(PrimitiveProperty property, uint04 index, Triangle< 1, t_type > index_value)
Definition Geometry.h:510
bool hasIndexColumn() const
Definition Geometry.h:317
void updateGeometryProperty(GeometryProperty property, const t_type &type, const void *lock_ptr=nullptr)
Definition Geometry.h:164
t_type primitive(PrimitiveProperty property, typename std::enable_if< ObjectInfo< t_type >::Dimensions==3, uint04 >::type index) const
Definition Geometry.h:573
t_type primitive(PrimitiveProperty property, typename std::enable_if< ObjectInfo< t_type >::Dimensions==2, uint04 >::type index) const
Definition Geometry.h:539
static std::function< void(Geometry &geo, const Matrix< fltp08 > &matrix, const void *lock, ProgressInfo *log)> s_geometry_triangulation
Definition Geometry.h:1428
void laplacianSmoothing(const SmoothingParameters &properties)
uint01 parity(const Matrix< fltp04 > &parent_matrix, PrimitiveMode mode) const
TableColumn & propertyColumn(const String &property)
Definition Geometry.h:1319
void setPrimitiveRange(PrimitiveProperty mode, uint04 start, uint04 primitive_count)
void autoCalculateIndices(PrimitiveProperty property, const void *lock=nullptr, ProgressInfo *log=nullptr, const Matrix< fltp08 > &transform=Matrix< fltp08 >(1.0))
void removeParent(const Model &parent)
TableColumn & faceToEdgeColumn()
Definition Geometry.h:292
void removePrimitive(PrimitiveProperty property, const Buffer< bool > &selection_mask)
Buffer< Vector< 2, uint04 > > lineIndices(PrimitiveProperty primitive_property) const
Definition Geometry.h:614
Geometry(const DesignObject &obj)
Buffer< t_type > vertices(VertexProperty property) const
Definition Geometry.h:962
Buffer< uint04 > primitiveIndices(PrimitiveProperty primitive_property) const
bool vertexFlag(uint04 vertex_index, VertexFlags flag) const
Buffer< t_type > vertices(const String &property) const
Definition Geometry.h:975
void removePrimitive(PrimitiveProperty property, uint04 location)
uint04 primitiveCount(PrimitiveProperty property) const
Definition Geometry.h:669
bool hasVertexProperty(const String &property_name) const
void deleteGeometry()
uint04 primitiveIndexCount(PrimitiveProperty property) const
Definition Geometry.h:673
Buffer< Vector< 2, uint04 > > lineIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const
void setVertexFlag(uint04 vertex, VertexFlags flag, bool value)
void setSolidVertexCountValue(uint04 count)
Definition Geometry.h:1327
void updateVertexColumn(VertexProperty property, uint04 index, uint04 size)
void combine(const Geometry &geo, const Matrix< fltp08 > &conversion=Matrix< fltp08 >(1.0))
void setVertexMode(VertexProperty property, VertexMode mode)
void calculateNormals(NormalMode mode, Angle< fltp08 > max_difference, const void *lock=nullptr, ProgressInfo *log=nullptr)
Geometry(DesignObjectBase *base)
void setVerticesFlags(const Buffer< bool > &selection_mask, BitFlag on_flags, BitFlag off_flags)
Bounds< 3, fltp08 > getBounds() const
bool vertexSelected(uint04 vertex) const
VertexMode mode(VertexProperty property) const
Definition Geometry.h:822
Buffer< LineSegment< t_dims, t_type > > lineSegments(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Definition Geometry.h:988
void updatePrimitiveColumns(bool remove_tree=true)
Buffer< uint04 > indices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const
uint04 vertexOffset() const
Definition Geometry.h:709
bool hasIndexFanColumn() const
Definition Geometry.h:321
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)
Vector< 3, fltp08 > calculateAverageDirection(const Matrix< fltp08 > &mat) const
void setVertices(VertexProperty property, const Buffer< t_type > &vertices, const Matrix< t_matrix_type > &matrix, uint04 offset=0)
Definition Geometry.h:897
uint04 vertexPropertyCount() const
void setVertexProperty(const String &property, uint04 index, uint04 sub_index, const t_type &vector)
Definition Geometry.h:793
TableColumn & propertyColumn(uint04 property)
Definition Geometry.h:810
void setVertexProperty(uint04 property, uint04 index, const t_type &vector)
Definition Geometry.h:775
Buffer< LineSegment< 3, fltp08 > > faceEdges(uint04 index) const
void setVertices(VertexProperty property, const t_type *vertices, uint04 size, uint04 offset=0)
Definition Geometry.h:908
void setCountValue(PrimitiveProperty property, uint04 count)
Definition Geometry.h:1382
Buffer< Geometry, uint04, ObjectAllocator< DESIGN_PRIM > > explode() const
void setVertex(VertexProperty property, uint04 index, const t_type &vector)
Definition Geometry.h:871
ThicknessMode
Definition Geometry.h:130
void setVertex(VertexProperty property, uint04 index, uint04 sub_index, const t_type &vector)
Definition Geometry.h:878
void updateVertexColumn(VertexProperty property)
uint04 vertexPropertyIndex(const String &property_name) const
void optimizeVertexLocations()
t_type getGeometryProperty(GeometryProperty property) const
Definition Geometry.h:174
void setWindingMode(WindingMode mode, const void *lock=nullptr)
void copyTraitsFrom(const Geometry &geo)
void removeVertex(uint04 location)
void updateVertexColumn(const String &property)
fltp08 calculateSurfaceArea(const Matrix< fltp08 > &parent_transform) const
const TableColumn & faceToEdgeColumn() const
Definition Geometry.h:296
void removeVertices(uint04 mask_offset, const Buffer< bool > &selection_mask)
void removeDuplicateVertices(fltp08 epsilon, const void *lock, ProgressInfo *log=nullptr)
Buffer< Vector< 3, uint04 > > triIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const
Buffer< Vector< 3, uint04 > > triIndices(PrimitiveProperty primitive_property) const
Definition Geometry.h:620
Vector< 2, fltp08 > calculateVolumeAndSurfaceArea(const Matrix< fltp08 > &transform, const void *lock) const
GeometryProperty
Definition Geometry.h:99
uint04 addPrimitive(PrimitiveProperty index_property, const t_type &primitive)
Definition Geometry.h:648
Triangle< t_dims, t_type > triangle(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 tri_index) const
Definition Geometry.h:935
Plane< 3, fltp08 > calculatePlaneAtVertex(uint04 vertex_index) const
Buffer< Polygon< t_type, Vertex< t_dims, t_type > > > polygons(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Definition Geometry.h:1076
void setVertexProperties(const String &property, const Buffer< t_type > &vertices, uint04 offset=0)
Definition Geometry.h:799
void cotangentLaplacianSmoothing(const SmoothingParameters &properties)
bool hasTree(PrimitiveProperty primitive_property, VertexProperty vertex_property=VertexProperty::Position) const
Buffer< Polyline< t_dims, t_type > > polylines(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Definition Geometry.h:1170
void createDrapedMaterialCoordinates(const Matrix< fltp08 > &mat=Matrix< fltp08 >())
ThicknessMode thicknessMode() const
bool hasHoles(PrimitiveProperty property) const
void setVerticesFlag(const Buffer< uint04 > &vertices, VertexFlags flag, bool value)
void clearSmoothing(const SmoothingParameters &properties)
bool hasColumn(VertexProperty property) const
Definition Geometry.h:945
Buffer< uint04 > getSelectedVertices() const
void setVertexSize(uint04 size)
void removePrimitive(PrimitiveProperty property, uint04 location, uint04 size)
void setVertexProperty(const String &property, uint04 index, const t_type &property_value)
Definition Geometry.h:781
TableColumn & column(VertexProperty property)
Definition Geometry.h:1310
void setVertexReservedValue(uint04 count)
Definition Geometry.h:1407
void clearVerticesAndPrimitives()
Buffer< Buffer< uint04 > > polyIndices(PrimitiveProperty primitive_property) const
bool hasVertexProperty(const VertexProperty &property) const
void setIndexOffsetValue(uint04 offset)
Definition Geometry.h:1390
const String & vertexPropertyName(uint04 property_index) const
Definition Geometry.h:732
Time getAscModifiedTime(bool include_self, bool include_layer=false) const
Buffer< Buffer< uint04 > > polyIndices(PrimitiveProperty primitive_property, uint04 start, uint04 size) const
uint04 createVertexProperty(const String &property_name, const TypeInfo &type)
Ray< 3, fltp08 > surfaceNormal() const
void addFromParent(Model &parent)
Buffer< Polygon< t_type, Vertex< t_dims, t_type > > > polygons(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
Definition Geometry.h:1081
void convertPolarToCartesian(const String &roll_column, const String &pitch_column, const String &distance_column)
static void SetTriangulationMethod(std::function< void(Geometry &geo, const Matrix< fltp08 > &matrix, const void *lock, ProgressInfo *log)> function)
t_type vertexProperty(uint04 property_index, uint04 vertex_index) const
Definition Geometry.h:753
void copyFrom(const Geometry &geo, bool copy_tree=true)
t_type vertexProperty(const String &property, uint04 vertex_index, uint04 sub_index) const
Definition Geometry.h:768
String getGeometryIcon() const
Buffer< t_type > vertices(const String &property, uint04 start, uint04 size) const
Definition Geometry.h:980
Vertex< 3, fltp08 > faceCenter(uint04 index) const
void setPrimitive(PrimitiveProperty property, uint04 index, Vector< 3, t_type > index_value)
Definition Geometry.h:504
void setPrimitiveMode(PrimitiveProperty property, PrimitiveMode mode)
PrimitiveMode mode(PrimitiveProperty property) const
Definition Geometry.h:309
void removeHoleFill(const void *lock=nullptr, ProgressInfo *log=nullptr)
const TableColumn & primitiveColumn() const
Definition Geometry.h:272
const TableColumn & edgeToFaceColumn() const
Definition Geometry.h:305
DynamicPointer< RTree< 3, fltp04 > > tree(PrimitiveProperty primitive_property, VertexProperty vertex_property=VertexProperty::Position) const
void addVertices(uint04 location, uint04 size)
Buffer< Triangle< t_dims, t_type > > triangles(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Definition Geometry.h:1007
void setVerticesFlag(const Buffer< bool > &selection_mask, VertexFlags flag, bool value)
void setOffsetValue(PrimitiveProperty property, uint04 offset)
Definition Geometry.h:1394
void setupIndexFanColumn()
static t_vec_type OptimizedGetPrimitiveVec(const OptimizedPrimitiveDef &ref, uint04 index)
Definition Geometry.h:458
void setNormalMode(NormalMode mode, Angle< fltp08 > max_sep_angle, const void *lock=nullptr, ProgressInfo *log=nullptr)
bool operator==(const Geometry &model) const
Definition Geometry.h:248
const TableColumn & primitiveFanColumn() const
Definition Geometry.h:280
t_type primitive(PrimitiveProperty property, typename std::enable_if< ObjectInfo< t_type >::Dimensions<=1, uint04 >::type index) const
Definition Geometry.h:529
bool hasParent(const Model &model) const
uint04 solidVertexCount() const
Definition Geometry.h:725
uint04 addPrimitives(PrimitiveProperty index_property, uint04 insersion_size)
Definition Geometry.h:655
void setVerticesFlagAll(VertexFlags flag, bool value)
uint04 indexOffset() const
Definition Geometry.h:628
void removeVertices(uint04 location, uint04 size)
void setSolidVertexReservedValue(uint04 count)
Definition Geometry.h:1331
void updateVertexColumn(const String &property, uint04 index, uint04 size)
Buffer< t_type > propertyVertices(uint04 property, uint04 start, uint04 size) const
Definition Geometry.h:955
uint04 addVertex()
Definition Geometry.h:680
uint04 primitiveIndexCount() const
Definition Geometry.h:665
const TableColumn & propertyColumn(uint04 property) const
Definition Geometry.h:814
void reservePrimitiveIndexSpace(uint04 index_size)
t_type vertexProperty(uint04 property_index, uint04 vertex_index, uint04 sub_index) const
Definition Geometry.h:763
uint04 createVertexProperty(const String &property_name)
Definition Geometry.h:746
uint04 solidVertexReservedCount() const
Definition Geometry.h:721
void setModeValue(PrimitiveProperty property, PrimitiveMode mode)
Definition Geometry.h:1398
bool hasProperty(PrimitiveProperty property) const
Definition Geometry.h:313
void closePolyline(PrimitiveProperty property)
Class to easily restore calculated data in a Geometry after a location altering process.
Definition Geometry.h:1643
void store(const Geometry &geo)
GeometryPositionModRestore(const Geometry &geo)
Definition Geometry.h:1647
void restoreNormals(const void *lock, ProgressInfo *log=nullptr)
String m_smoothing_algo
Definition Geometry.h:1665
fltp04 smoothing_angle
Definition Geometry.h:1664
NormalMode normal_mode
Definition Geometry.h:1663
bool m_has_tangent
Definition Geometry.h:1659
GeometryPositionModRestore()
Definition Geometry.h:1645
bool m_is_closed
Definition Geometry.h:1662
void restoreClosed(Geometry &geo, const void *lock, ProgressInfo *log=nullptr)
Geometry m_geo
Definition Geometry.h:1667
void restoreNormals(Geometry &geo, const void *lock, ProgressInfo *log=nullptr)
void restoreClosed(const void *lock, ProgressInfo *log=nullptr)
uint04 m_smoothing_times
Definition Geometry.h:1666
bool m_has_tree[cast< uint04 >(PrimitiveProperty::Index_Property_Size)]
Definition Geometry.h:1661
bool m_has_bitangent
Definition Geometry.h:1660
void restoreSmooth(const void *lock, ProgressInfo *log=nullptr)
void restoreAll(const void *lock, ProgressInfo *log=nullptr, bool restore_tree=true, bool restore_closed=true, bool restore_normals=true, bool restore_smooth=true)
A class to easily iterate each line segment over a Geometry of lines.
Definition Geometry.h:1515
bool isHidden(uint04 index) const
Definition Geometry.h:1563
VertexProperty m_vertex_property
Definition Geometry.h:1568
const uint04 m_vertex_offset
Definition Geometry.h:1573
LineIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry geo)
Definition Geometry.h:1517
Vector< 2, uint04 > rawIndex(uint04 index) const
Definition Geometry.h:1559
Vector< 2, uint04 > vertexIndex(uint04 index) const
Definition Geometry.h:1527
Geometry::OptimizedPrimitiveDef m_primitive_def
Definition Geometry.h:1569
uint04 size() const
Definition Geometry.h:1554
const TableColumn & m_flag_column
Definition Geometry.h:1571
LineSegment< t_dims, t_type > operator[](uint04 index) const
Definition Geometry.h:1540
const TableColumn & m_vertex_column
Definition Geometry.h:1570
uint04 m_primitive_count
Definition Geometry.h:1572
A line segment represented by two vertices, a start and end.
Definition Line.hpp:49
Serves as the primary program interface for processes to report issues and allows any number of LogSt...
Definition Log.h:48
Definition Matrix.hpp:176
A core class that represents a node on model heirarchy. This node may contain a Geometry or one or mo...
Definition Model.h:58
Logic for a given plane or N-dimensions. Planes are coordinate systems of one less dimension than the...
Definition Geometry.h:41
Provides shared ownership of a dynamically allocated object.
Definition Pointer.hpp:71
An N-sided polygon.
Definition Polygon.hpp:53
uint04 vertexCount() const
Definition Polygon.hpp:204
void add(const t_vertex &vertex)
Definition Polygon.hpp:293
void clear()
Definition Polygon.hpp:410
A polyline which stores vertex information for many points along a given path.
Definition CoordinateProjectionManager.h:44
uint04 vertexCount() const
Definition PolyLine.hpp:191
void add(const t_vertex &vertex)
Definition PolyLine.hpp:241
void clear()
Definition PolyLine.hpp:396
A light-weight base class for Log that allows processes to update, without the need for additional in...
Definition ProgressInfo.hpp:48
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
Definition GeometryVertices.h:11
Definition Vertex.hpp:317
The root Model that is responsible for storing the underlying data for all Scene Models.
Definition Model.h:492
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
Definition Selector.h:50
The core String class for the NDEVR API.
Definition String.h:69
Logic for reading or writing to a string or a user friendly, TranslatedString.
Definition StringStream.h:230
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Definition TableColumn.h:76
void get(uint04 index, Vector< 1, t_class > &vector) const
Definition TableColumn.h:236
virtual void set(uint04 index, bool value)=0
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometr...
Definition Triangle.hpp:138
A class to easily iterate each triangle over a Geometry of triangles or meshes.
Definition Geometry.h:1580
Triangle< t_dims, t_type > operator[](uint04 index) const
Definition Geometry.h:1600
const uint04 m_vertex_offset
Definition Geometry.h:1636
Geometry::OptimizedPrimitiveDef m_primitive_def
Definition Geometry.h:1633
uint04 size() const
Definition Geometry.h:1624
const TableColumn & m_vertex_column
Definition Geometry.h:1634
Vector< 3, uint04 > vertexIndex(uint04 index) const
Definition Geometry.h:1614
uint04 m_primitive_count
Definition Geometry.h:1635
TriangleIterator(PrimitiveProperty primitive_property, const String &vertex_property, Geometry mesh)
Definition Geometry.h:1591
TriangleIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry mesh)
Definition Geometry.h:1582
Vector< 3, uint04 > rawIndex(uint04 index) const
Definition Geometry.h:1629
Stores information about a type, relevant for certain templated functions. To get information about a...
Definition TypeInfo.h:43
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
A vertex or point. A specific type of Vector used primarily for spacial location information.
Definition Vertex.hpp:48
A class to easily iterate each vertex of a Geometry.
Definition Geometry.h:1455
const uint04 m_vertex_offset
Definition Geometry.h:1505
void setVertex(uint04 index, const t_type &value)
Definition Geometry.h:1487
const uint04 m_vertex_count
Definition Geometry.h:1506
t_type operator[](uint04 index) const
Definition Geometry.h:1475
TableColumn & m_flag_column
Definition Geometry.h:1501
uint04 size() const
Definition Geometry.h:1495
BitFlag flag(uint04 index) const
Definition Geometry.h:1482
Geometry m_geo
Definition Geometry.h:1499
VertexIterator(const String &vertex_property, Geometry geo)
Definition Geometry.h:1466
void setFlag(uint04 index, const BitFlag &value)
Definition Geometry.h:1491
TableColumn & m_column
Definition Geometry.h:1500
const VertexProperty m_vertex_property
Definition Geometry.h:1504
VertexIterator(VertexProperty vertex_property, Geometry geo)
Definition Geometry.h:1457
Used to lock a particular variable for writing. Only one write lock can be created when no read locks...
Definition RWLock.h:115
Definition ACIColor.h:37
NormalMode
Definition DesignObjectBase.h:105
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
VertexProperty
Definition DesignObjectBase.h:52
constexpr bool DESIGN_PRIM
Definition DesignObject.h:47
GeometryType
Definition DesignObjectBase.h:86
VertexFlags
Definition DesignObjectBase.h:68
PrimitiveProperty
Definition DesignObjectBase.h:44
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
PrimitiveBitFlags
Definition DesignObjectBase.h:78
PrimitiveMode
Used with Geometry to describe how vertices and indices are used to form shapes.
Definition DesignObjectBase.h:116
WindingMode
Definition DesignObjectBase.h:97
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
@ B
Definition BaseValues.hpp:170
@ A
Definition BaseValues.hpp:168
@ C
Definition BaseValues.hpp:172
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Definition File.h:211
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
TableColumn & fan_column
Definition Geometry.h:384
uint04 fan_offset
Definition Geometry.h:386
PrimitiveMode mode
Definition Geometry.h:392
uint04 index_offset
Definition Geometry.h:385
OptimizedPrimitiveDef(TableColumn &column, TableColumn &fan_column)
Definition Geometry.h:379
TableColumn & column
Definition Geometry.h:383
Definition Geometry.h:217
uint04 iterations
Definition Geometry.h:219
PrimitiveProperty property
Definition Geometry.h:218
Information about the object.
Definition ObjectInfo.h:54