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 /**--------------------------------------------------------------------------------------------------
51 Class: Geometry
52
53 The equivelent of std::vector but with a bit more control. The basic array unit of the library.
54
55 t_type = what the buffer holds
56 t_index_type = the index reference (default uint04 but can be made uint08 for large buffer support)
57 t_memory_allocator = The object in charge of object allocation when creating space
58 t_memory_manager = The thing that actually stores the memory
59 Author: Tyler Parke
60
61 Date: 2021-04-08
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;
141 Geometry(uint04 index, DesignObjectBase* base);
142 explicit Geometry(const DesignObject& obj);
143 void setGeometryType(GeometryType geometry_type);
144 GeometryType getGeometryType() const;
145 void clearVerticesAndPrimitives();
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(isNaN(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
184 uint04 numberOfParents() const;
185 Vertex<3, fltp08> faceCenter(uint04 index) const;
186 Buffer<LineSegment<3, fltp08>> faceEdges(uint04 index) const;
188 Model getParent(uint04 index) const;
189 void deleteGeometry();
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);
195 void optimizeVertexLocations();
196 void centerAlign();
197 void invalidateBounds();
198 bool canBeClosedSolid(const void* lock = nullptr) const;
199 bool hasParent(const Model& model) const;
200 void calculateIndexNeighborList(PrimitiveProperty primitive_property);
201 Bounds<3, fltp08> getBounds() 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);
208 void setThicknessMode(ThicknessMode mode);
209 ThicknessMode thicknessMode() const;
210 void flipNormals();
211 void removeDuplicateVertices(fltp08 epsilon, const void* lock, ProgressInfo* log = nullptr);
212 void splitDuplicateVertices();
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 };
225 void laplacianSmoothing(const SmoothingParameters& properties);
226 void cotangentLaplacianSmoothing(const SmoothingParameters& properties);
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;
243 Buffer<uint04> getSelectedVertices() 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);
247 String getGeometryIcon() const;
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 protected:
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]////////////////////////////////////
271 TableColumn& primitiveColumn();
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 }
325 void reservePrimitiveIndexSpace(uint04 index_size);
326
327 void setPrimitiveRange(PrimitiveProperty mode, uint04 start, uint04 primitive_count);
328
329 void setPrimitiveMode(PrimitiveProperty property, PrimitiveMode mode);
330 void updatePrimitiveColumn(PrimitiveProperty property, bool remove_tree = true);
331 void updatePrimitiveColumns(bool remove_tree = true);
332 void updateModifiedTime(Time time = Time::SystemTime());
333 Plane<3, fltp08> calculatePlaneAtVertex(uint04 vertex_index) const;
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 (!isNaN(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>::NaN);
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 (!isNaN(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>>::NaN;
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(isNaN(index_value) || index_value >= ref.min_vertex_index, "Index out of bounds");
415 lib_assert(isNaN(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(isNaN(index_value[i]) || index_value[i] >= ref.min_vertex_index, "Index out of bounds");
428 lib_assert(isNaN(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 (!isNaN(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 (isNaN(index_fan_location))
486 {
487 index_value = Constant<t_vec_type>::NaN;
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 (isNaN(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 (isNaN(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 (isNaN(index_fan_location))
596 index_value = Constant<t_type>::NaN;
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 (isNaN(index_value))
608 return index_value - t_type(vertexOffset());
609 }
610
611 Buffer<uint04> primitiveIndices(PrimitiveProperty primitive_property) const;
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 }
661 void closePolyline(PrimitiveProperty property);
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);
693 void setVertexSize(uint04 size);
694 void removeVertex(uint04 location);
695 void removeVertices(uint04 location, uint04 size);
696 void removeVertices(Buffer<uint04> vertices);
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);
701 void removePrimitive(PrimitiveProperty property, Buffer<uint04> vertices);
702 void removePrimitive(PrimitiveProperty property, const Buffer<bool>& selection_mask);
703 void createDrapedMaterialCoordinates(const Matrix<fltp08>& mat = Matrix<fltp08>());
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 }
736 uint04 vertexPropertyCount() const;
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);
834 void updateVertexColumn(VertexProperty property);
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;
846 Vector<3, fltp08> calculateAverageDirection(const Matrix<fltp08>& mat) 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>::NaN);
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;
869 Ray<3, fltp08> surfaceNormal() 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 (isNaN(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 (isNaN(tri))
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 (isNaN(index_fan_location))
1044 {
1045 index_value = Constant<Vector<3, uint04>>::NaN;
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 (isNaN(index_value))
1060 {
1061 triangles.add(Constant<Triangle<t_dims, t_type>>::NaN);
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 }
1073 Buffer<Buffer<uint04>> polyIndices(PrimitiveProperty primitive_property) const;
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 (isNaN(index_fan_location))
1119 index_value = Constant<Vector<3, uint04>>::NaN;
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 (!isNaN(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 (!isNaN(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 (isNaN(index_fan_location))
1219 index_value = Constant<Vector<3, uint04>>::NaN;
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 (!isNaN(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 (!isNaN(index))
1248 vert = vertex_column.get<Vector<t_dims, t_type>>(index);
1249
1250 if (!isNaN(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 (!isNaN(index))
1288 {
1289 Vertex<3, fltp08> vert_a = vertex_column.get<Vector<t_dims, t_type>>(index[A]);
1290 if (isNaN(vert_a))
1291 continue;
1292 Vertex<3, fltp08> vert_b = vertex_column.get<Vector<t_dims, t_type>>(index[B]);
1293 if (isNaN(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
1308 void setVertexMode(VertexProperty property, VertexMode mode);
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 }
1339 void setupIndexFanColumn();
1340 uint01 provokingPrimitiveOffset() const;
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 (!isNaN(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>::NaN;
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;
1448 };
1449
1450 template<class t_type>
1452 {
1453 public:
1455 : m_geo(geo)
1456 , m_column(geo.column(vertex_property))
1457 , m_flag_column(geo.column(VertexProperty::BitFlag))
1458 , m_vertex_property(vertex_property)
1459 , m_vertex_offset(geo.vertexOffset())
1460 , m_vertex_count(geo.vertexCount())
1461
1462 {}
1463 VertexIterator(const String& vertex_property, Geometry geo)
1464 : m_geo(geo)
1465 , m_column(geo.propertyColumn(vertex_property))
1466 , m_flag_column(geo.column(VertexProperty::BitFlag))
1468 , m_vertex_offset(geo.vertexOffset())
1469 , m_vertex_count(geo.vertexCount())
1470
1471 {}
1472 t_type operator[](uint04 index) const
1473 {
1474 //const BitFlag flag = m_flag_column.get<uint01>(m_vertex_offset + index);
1475 //if (flag[cast<uint01>(VertexBitFlags::e_is_hidden)])
1476 //return Constant<Vertex<t_dims, t_type>>::NaN;
1477 return m_column.get<t_type>(m_vertex_offset + index);
1478 }
1479 BitFlag flag(uint04 index) const
1480 {
1482 return flag;
1483 }
1484 void setVertex(uint04 index, const t_type& value)
1485 {
1486 return m_column.set(m_vertex_offset + index, value);
1487 }
1488 void setFlag(uint04 index, const BitFlag& value)
1489 {
1490 return m_flag_column.set(m_vertex_offset + index, value);
1491 }
1492 uint04 size() const
1493 {
1494 return m_vertex_count;
1495 }
1499
1500
1504 };
1505
1506
1507 template<uint01 t_dims, class t_type>
1509 {
1510 public:
1511 LineIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry geo)
1512 : m_primitive_def(geo.optimizedPrimitiveDef(primitive_property))
1513 , m_vertex_column(geo.column(vertex_property))
1514 , m_flag_column(geo.column(VertexProperty::BitFlag))
1515 , m_primitive_count(geo.primitiveCount(primitive_property))
1516 , m_vertex_offset(geo.vertexOffset())
1517 {
1519 m_primitive_count--;//since sending vertex count, segment count is one less
1520 }
1522 {
1523 Vector<2, uint04> index_vert = rawIndex(index);
1524 for (uint04 i = 0; i < 2; i++)
1525 {
1526 if (isNaN(index_vert[i]) || isHidden(index_vert[i]))
1527 index_vert[i] = Constant<uint04>::NaN;
1528 else
1529 index_vert[i] -= m_vertex_offset;
1530 }
1531 return index_vert;
1532 }
1533
1535 {
1536 Vector<2, uint04> index_vert = rawIndex(index);
1538 for (uint01 i = 0; i < 2; i++)
1539 {
1540 if (isNaN(index_vert[i]) || isHidden(index_vert[i]))
1541 seg[i] = Constant<t_type>::NaN;
1542 else
1543 m_vertex_column.get(index_vert[i], seg[i]);
1544
1545 }
1546 return seg;
1547 }
1548 uint04 size() const
1549 {
1550 return m_primitive_count;
1551 }
1552 protected:
1557 bool isHidden(uint04 index) const
1558 {
1559 BitFlag bit_flags = m_flag_column.get<uint01>(index);
1560 return bit_flags[cast<uint01>(VertexFlags::e_is_hidden)];
1561 }
1568 };
1569 template<uint01 t_dims, class t_type>
1571 {
1572 public:
1573 TriangleIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry mesh)
1574 : m_primitive_def(mesh.optimizedPrimitiveDef(primitive_property))
1575 , m_vertex_column(mesh.column(vertex_property))
1576 , m_primitive_count(mesh.primitiveCount(primitive_property))
1577 , m_vertex_offset(mesh.vertexOffset())
1578 {
1580 m_primitive_count -= 2;//primitive count is vertices so minus 2 triangles
1581 }
1582 TriangleIterator(PrimitiveProperty primitive_property, const String& vertex_property, Geometry mesh)
1583 : m_primitive_def(mesh.optimizedPrimitiveDef(primitive_property))
1584 , m_vertex_column(mesh.propertyColumn(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 }
1592 {
1593 Vector<3, uint04> index_vert = rawIndex(index);
1595 for (uint01 i = 0; i < 3; i++)
1596 {
1597 if (isNaN(index_vert[i]))
1598 tri[i] = Constant<t_type>::NaN;
1599 else
1600 m_vertex_column.get(index_vert[i], tri[i]);
1601
1602 }
1603 return tri;
1604 }
1606 {
1607 Vector<3, uint04> index_vert = rawIndex(index);
1608 for (uint01 i = 0; i < 3; i++)
1609 {
1610 if (!isNaN(index_vert[i]))
1611 index_vert[i] -= m_vertex_offset;
1612 }
1613 return index_vert;
1614 }
1615 uint04 size() const
1616 {
1617 return m_primitive_count;
1618 }
1619 protected:
1628 };
1629
1631 {
1632 public:
1636 {
1637 store(geo);
1638 }
1639 void store(const Geometry& geo);
1640 void restoreNormals(const void* lock, ProgressInfo* log = nullptr);
1641 void restoreClosed(const void* lock, ProgressInfo* log = nullptr);
1642 void restoreAll(const void* lock, ProgressInfo* log = nullptr, bool restore_tree = true, bool restore_closed = true, bool restore_normals = true, bool restore_smooth = true);
1643 void restoreSmooth(const void* lock, ProgressInfo* log = nullptr);
1644 protected:
1645 void restoreNormals(Geometry& geo, const void* lock, ProgressInfo* log = nullptr);
1646 void restoreClosed(Geometry& geo, const void* lock, ProgressInfo* log = nullptr);
1647 bool m_has_tangent = false;
1648 bool m_has_bitangent = false;
1650 bool m_is_closed = false;
1656 };
1657
1658
1660}
1661
1662namespace std//Define things to allow use within std libs
1663{
1664 template <>
1665 struct hash<NDEVR::Geometry>
1666 {
1667 std::size_t operator()(const NDEVR::Geometry& d) const noexcept
1668 {
1669 NDEVR::UUID s = d.uuid();
1670 std::size_t value = 0;
1671 for (NDEVR::uint01 i = 0; i < 8; i++)
1672 value = value * 256 + (s[i + 0U] ^ s[i + 8U]);
1673 return value;
1674 }
1675 };
1676};
1677
1678
1679
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
Stores an angle in an optimized format.
Definition StringStream.h:352
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:68
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:57
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
void add(t_type &&object)
Definition Buffer.hpp:199
constexpr t_index_type size() const
Definition Buffer.hpp:1461
decltype(auto) last()
Definition Buffer.hpp:977
void setSize(t_index_type new_size)
Definition Buffer.hpp:1413
decltype(auto) get(t_index_type index)
Definition Buffer.hpp:857
Definition Color.h:36
Definition DesignObjectBase.h:140
Definition DesignObject.h:66
bool isValid() const
Definition DesignObject.h:362
UUID uuid() const
Definition DesignObject.cpp:533
Definition Pointer.hpp:303
Definition Geometry.h:64
const TableColumn & column(VertexProperty property) const
Definition Geometry.h:1314
void setVertexOffsetValue(uint04 count)
Definition Geometry.h:1411
void setSolidVertexOffsetValue(uint04 count)
Definition Geometry.h:1335
Buffer< t_type > getTreeSortedVertices(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Definition Geometry.h:855
TreeMode
Definition Geometry.h:123
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
OptimizedPrimitiveDef optimizedPrimitiveDef(PrimitiveProperty property)
Definition Geometry.h:394
void setModeValue(VertexProperty property, VertexMode vert_mode)
Definition Geometry.h:1418
Geometry()=default
Buffer< Triangle< t_dims, t_type > > triangles(PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 start, uint04 size) const
Definition Geometry.h:1012
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
void setPrimitive(PrimitiveProperty property, uint04 index, t_type index_value)
Definition Geometry.h:335
const TableColumn & propertyColumn(const String &property) const
Definition Geometry.h:1323
void setGeometryProperty(GeometryProperty property, const t_type &value)
Definition Geometry.h:147
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
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
void setPrimitive(PrimitiveProperty property, uint04 index, Vector< 2, t_type > index_value)
Definition Geometry.h:348
Buffer< t_type > propertyVertices(uint04 property) const
Definition Geometry.h:950
uint04 solidVertexOffset() const
Definition Geometry.h:717
bool hasProperty(VertexProperty property) const
Definition Geometry.h:818
VertexMode
Definition Geometry.h:68
uint04 indexOffset(PrimitiveProperty property) const
Definition Geometry.h:632
uint04 vertexCount() const
Definition Geometry.h:713
t_type vertexProperty(const String &property, uint04 vertex_index) const
Definition Geometry.h:758
uint04 indexFanCount() const
Definition Geometry.h:642
Buffer< t_type > vertices(VertexProperty property, uint04 start, uint04 size) const
Definition Geometry.h:967
void setVertexProperty(uint04 property, uint04 index, uint04 sub_index, const t_type &vector)
Definition Geometry.h:787
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
TableColumn & propertyColumn(const String &property)
Definition Geometry.h:1319
TableColumn & faceToEdgeColumn()
Definition Geometry.h:292
Buffer< Vector< 2, uint04 > > lineIndices(PrimitiveProperty primitive_property) const
Definition Geometry.h:614
Buffer< t_type > vertices(VertexProperty property) const
Definition Geometry.h:962
Buffer< t_type > vertices(const String &property) const
Definition Geometry.h:975
uint04 primitiveCount(PrimitiveProperty property) const
Definition Geometry.h:669
uint04 primitiveIndexCount(PrimitiveProperty property) const
Definition Geometry.h:673
void setSolidVertexCountValue(uint04 count)
Definition Geometry.h:1327
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
uint04 vertexOffset() const
Definition Geometry.h:709
bool hasIndexFanColumn() const
Definition Geometry.h:321
void setVertices(VertexProperty property, const Buffer< t_type > &vertices, const Matrix< t_matrix_type > &matrix, uint04 offset=0)
Definition Geometry.h:897
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
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
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
t_type getGeometryProperty(GeometryProperty property) const
Definition Geometry.h:174
const TableColumn & faceToEdgeColumn() const
Definition Geometry.h:296
Buffer< Vector< 3, uint04 > > triIndices(PrimitiveProperty primitive_property) const
Definition Geometry.h:620
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
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
Buffer< Polyline< t_dims, t_type > > polylines(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Definition Geometry.h:1170
bool hasColumn(VertexProperty property) const
Definition Geometry.h:945
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 setIndexOffsetValue(uint04 offset)
Definition Geometry.h:1390
const String & vertexPropertyName(uint04 property_index) const
Definition Geometry.h:732
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
t_type vertexProperty(uint04 property_index, uint04 vertex_index) const
Definition Geometry.h:753
t_type vertexProperty(const String &property, uint04 vertex_index, uint04 sub_index) const
Definition Geometry.h:768
Buffer< t_type > vertices(const String &property, uint04 start, uint04 size) const
Definition Geometry.h:980
void setPrimitive(PrimitiveProperty property, uint04 index, Vector< 3, t_type > index_value)
Definition Geometry.h:504
PrimitiveMode mode(PrimitiveProperty property) const
Definition Geometry.h:309
const TableColumn & primitiveColumn() const
Definition Geometry.h:272
const TableColumn & edgeToFaceColumn() const
Definition Geometry.h:305
Buffer< Triangle< t_dims, t_type > > triangles(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Definition Geometry.h:1007
void setOffsetValue(PrimitiveProperty property, uint04 offset)
Definition Geometry.h:1394
static std::function< void(Geometry &geo, const Matrix< fltp08 > &matrix, const void *lock, ProgressInfo *log)> s_geometry_triangulation
Definition Geometry.h:1428
static t_vec_type OptimizedGetPrimitiveVec(const OptimizedPrimitiveDef &ref, uint04 index)
Definition Geometry.h:458
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
uint04 solidVertexCount() const
Definition Geometry.h:725
uint04 addPrimitives(PrimitiveProperty index_property, uint04 insersion_size)
Definition Geometry.h:655
uint04 indexOffset() const
Definition Geometry.h:628
void setSolidVertexReservedValue(uint04 count)
Definition Geometry.h:1331
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
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
Definition Geometry.h:1631
void store(const Geometry &geo)
Definition Geometry.cpp:3222
GeometryPositionModRestore(const Geometry &geo)
Definition Geometry.h:1635
void restoreNormals(const void *lock, ProgressInfo *log=nullptr)
Definition Geometry.cpp:3246
String m_smoothing_algo
Definition Geometry.h:1653
fltp04 smoothing_angle
Definition Geometry.h:1652
NormalMode normal_mode
Definition Geometry.h:1651
bool m_has_tangent
Definition Geometry.h:1647
GeometryPositionModRestore()
Definition Geometry.h:1633
bool m_is_closed
Definition Geometry.h:1650
Geometry m_geo
Definition Geometry.h:1655
void restoreClosed(const void *lock, ProgressInfo *log=nullptr)
Definition Geometry.cpp:3251
uint04 m_smoothing_times
Definition Geometry.h:1654
bool m_has_tree[cast< uint04 >(PrimitiveProperty::Index_Property_Size)]
Definition Geometry.h:1649
bool m_has_bitangent
Definition Geometry.h:1648
void restoreSmooth(const void *lock, ProgressInfo *log=nullptr)
Definition Geometry.cpp:3266
void restoreAll(const void *lock, ProgressInfo *log=nullptr, bool restore_tree=true, bool restore_closed=true, bool restore_normals=true, bool restore_smooth=true)
Definition Geometry.cpp:3256
Definition Geometry.h:1509
bool isHidden(uint04 index) const
Definition Geometry.h:1557
VertexProperty m_vertex_property
Definition Geometry.h:1562
const uint04 m_vertex_offset
Definition Geometry.h:1567
LineIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry geo)
Definition Geometry.h:1511
Vector< 2, uint04 > rawIndex(uint04 index) const
Definition Geometry.h:1553
Vector< 2, uint04 > vertexIndex(uint04 index) const
Definition Geometry.h:1521
Geometry::OptimizedPrimitiveDef m_primitive_def
Definition Geometry.h:1563
uint04 size() const
Definition Geometry.h:1548
const TableColumn & m_flag_column
Definition Geometry.h:1565
LineSegment< t_dims, t_type > operator[](uint04 index) const
Definition Geometry.h:1534
const TableColumn & m_vertex_column
Definition Geometry.h:1564
uint04 m_primitive_count
Definition Geometry.h:1566
A line segment represented by two vertices, a start and end.
Definition Line.hpp:55
Definition Log.h:43
Definition Matrix.hpp:173
Definition Model.h:54
Definition Geometry.h:41
Definition Pointer.hpp:62
An N-sided polygon.
Definition Polygon.hpp:58
uint04 vertexCount() const
Definition Polygon.hpp:219
void add(const t_vertex &vertex)
Definition Polygon.hpp:314
void clear()
Definition Polygon.hpp:441
A polyline which stores vertex information for many points along a given path.
Definition CoordinateProjectionManager.h:44
uint04 vertexCount() const
Definition PolyLine.hpp:209
void add(const t_vertex &vertex)
Definition PolyLine.hpp:265
void clear()
Definition PolyLine.hpp:434
Definition ProgressInfo.hpp:43
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
Definition RTree.hpp:1014
Definition Vertex.hpp:341
Definition Model.h:491
Definition Selector.h:46
Definition String.h:40
Definition StringStream.h:62
Definition TableColumn.h:68
void get(uint04 index, Vector< 1, t_class > &vector) const
Definition TableColumn.h:228
virtual void set(uint04 index, bool value)=0
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
Definition Triangle.hpp:143
Definition Geometry.h:1571
Triangle< t_dims, t_type > operator[](uint04 index) const
Definition Geometry.h:1591
const uint04 m_vertex_offset
Definition Geometry.h:1627
Geometry::OptimizedPrimitiveDef m_primitive_def
Definition Geometry.h:1624
uint04 size() const
Definition Geometry.h:1615
const TableColumn & m_vertex_column
Definition Geometry.h:1625
Vector< 3, uint04 > vertexIndex(uint04 index) const
Definition Geometry.h:1605
uint04 m_primitive_count
Definition Geometry.h:1626
TriangleIterator(PrimitiveProperty primitive_property, const String &vertex_property, Geometry mesh)
Definition Geometry.h:1582
TriangleIterator(PrimitiveProperty primitive_property, VertexProperty vertex_property, Geometry mesh)
Definition Geometry.h:1573
Vector< 3, uint04 > rawIndex(uint04 index) const
Definition Geometry.h:1620
Definition TypeInfo.h:39
Definition UUID.h:66
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
A vertex.
Definition Vertex.hpp:54
Definition Geometry.h:1452
const uint04 m_vertex_offset
Definition Geometry.h:1502
void setVertex(uint04 index, const t_type &value)
Definition Geometry.h:1484
const uint04 m_vertex_count
Definition Geometry.h:1503
t_type operator[](uint04 index) const
Definition Geometry.h:1472
TableColumn & m_flag_column
Definition Geometry.h:1498
uint04 size() const
Definition Geometry.h:1492
BitFlag flag(uint04 index) const
Definition Geometry.h:1479
Geometry m_geo
Definition Geometry.h:1496
VertexIterator(const String &vertex_property, Geometry geo)
Definition Geometry.h:1463
void setFlag(uint04 index, const BitFlag &value)
Definition Geometry.h:1488
TableColumn & m_column
Definition Geometry.h:1497
const VertexProperty m_vertex_property
Definition Geometry.h:1501
VertexIterator(VertexProperty vertex_property, Geometry geo)
Definition Geometry.h:1454
Definition RWLock.h:99
Definition ACIColor.h:37
NormalMode
Definition DesignObjectBase.h:105
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.
Definition BaseValues.hpp:157
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
PrimitiveBitFlags
Definition DesignObjectBase.h:78
PrimitiveMode
Definition DesignObjectBase.h:113
QAction * explode(nullptr)
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:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
QAction * mesh(nullptr)
@ B
Definition BaseValues.hpp:203
@ A
Definition BaseValues.hpp:201
@ C
Definition BaseValues.hpp:205
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition File.h:213
Definition BaseValues.hpp:272
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
static constexpr ObjectInfo< Geometry, false, false > VectorSub()
Definition Geometry.h:1447
Information about the object.
Definition ObjectInfo.h:56
std::size_t operator()(const NDEVR::Geometry &d) const noexcept
Definition Geometry.h:1667