NDEVR
API Documentation
CADEntities.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: CAD
28File: CADEntities
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <utility>
34#include <NDEVR/File.h>
35#include <NDEVR/Angle.h>
36#include <NDEVR/LineSegment.h>
37#include <NDEVR/Font.h>
38#include <NDEVR/RGBColor.h>
39namespace NDEVR
40{
45 {
46 e_use
47 , e_by_block
48 , e_by_layer
49 , e_background_contrast//aci = 7
50 };
51
55 {
56 Bounds<3, fltp08> model_space_bounds = Bounds<3, fltp08>(Constant<Vertex<3, fltp08>>::Invalid);
57 Bounds<3, fltp08> paper_space_bounds = Bounds<3, fltp08>(Constant<Vertex<3, fltp08>>::Invalid);
58 Vertex<3, fltp08> paper_space_origin = Vertex<3, fltp08>(0.0);
59 Matrix<fltp08> paperToModelMatrix() const
60 {
61 Matrix<fltp08> mat(1.0);
62 if (IsInvalid(model_space_bounds) || IsInvalid(paper_space_bounds))
63 return mat;
64 mat = mat.offset(model_space_bounds[MIN]);
65 Vector<3, fltp08> scale = model_space_bounds.span() / paper_space_bounds.span();
66 if (paper_space_bounds.span()[Z] == 0.0 || scale[Z] == 0.0)
67 scale[Z] = 0.0001;
68 mat = mat.scale(scale);
69 mat = mat.offset(paper_space_origin);
70 return mat;
71 }
72 };
73
77 {
78 ColorMode mode = e_use;
79 RGBColor color = Constant<RGBColor>::Invalid;
80 bool operator==(const CADColorInfo& other) const
81 {
82 return mode == other.mode && color == other.color;
83 }
84 bool operator!=(const CADColorInfo& other) const
85 {
86 return mode != other.mode || color != other.color;
87 }
88 };
89
93 struct CADVariable
94 {
95 enum CADVARType
96 {
97 e_double
98 , e_int
99 , e_string
100 };
101 CADVariable()
102 : var_type(e_string)
103 {}
104 CADVariable(const StringView& label)
105 : label(label)
106 {}
107 CADVariable(const StringView& label, sint04 key_label, const fltp08& value)
108 : label(label)
109 {
110 var_type = CADVARType::e_double;
111 values.add({key_label , String(value) });
112 }
113 CADVariable(const StringView& label, sint04 key_label, const uint04& value)
114 : label(label)
115 {
116 var_type = CADVARType::e_int;
117 values.add({ key_label , String(value) });
118 }
119 CADVariable(const StringView& label, sint04 key_label, const StringView& value)
120 : label(label)
121 {
122 var_type = CADVARType::e_string;
123 values.add({ key_label , String(value) });
124 }
125 CADVariable(const StringView& label, Vector<2, fltp08> data)
126 : label(label)
127 {
128 var_type = CADVARType::e_double;
129 values.add({ 10 , String(data[X]) });
130 values.add({ 20 , String(data[Y]) });
131 }
132 CADVariable(const StringView& label, Vector<3, fltp08> data)
133 : label(label)
134 {
135 var_type = CADVARType::e_double;
136 values.add({ 10 , String(data[X]) });
137 values.add({ 20 , String(data[Y]) });
138 values.add({ 30 , String(data[Z]) });
139 }
140 String label;
142 CADVARType var_type;
143 };
144
148 {
149 uint04 handle = Constant<uint04>::Invalid;
150 uint04 parent_handle = Constant<uint04>::Invalid;
151 uint04 file_line_number = Constant<uint04>::Invalid;
152 };
153
157 struct EntityData : public HandleData
158 {
164 uint04 material_handle = Constant<uint04>::Invalid;
165 uint04 file_line_number = Constant<uint04>::Invalid;
166 bool is_off = false;
167 bool visible = true;
168 bool paper_space = false;
169 };
170
174 struct LayerData : public EntityData
175 {
176 enum LayerFlags
177 {
178 e_frozen
179 , e_frozen_by_default
180 , e_locked
181 };
182 LayerData()
183 {}
184 LayerData(StringView name, const Vector<8, bool>& flags)
185 : name(name)
186 , flags(flags)
187 {}
188 String name;
189 Vector<8, bool> flags = Vector<8, bool>(false);
190 };
191
195 struct BlockData : public LayerData
196 {
197 BlockData()
198 {}
199 BlockData(StringView name, const Vector<8, bool>& flags)
200 : LayerData(name, flags)
201 {}
203 String description;
204 };
205
213
217 struct LineTypeData
218 {
219 LineTypeData(const String& name, const String& description, int flags, uint04 numberOfDashes, double patternLength)
220 : name(name)
221 , description(description)
222 , flags(flags)
223 , number_of_dashes(numberOfDashes)
224 , pattern_length(patternLength)
225 {}
226 LineTypeData(const String& name, const String& description, int flags, uint04 numberOfDashes, double patternLength, const Buffer<fltp08>& pattern)
227 : name(name)
228 , description(description)
229 , flags(flags)
230 , number_of_dashes(numberOfDashes)
231 , pattern_length(patternLength)
232 , pattern(pattern)
233 {}
234 String name;
235 String description;
236 Vector<32, bool> flags;
237 uint04 number_of_dashes;
238 fltp08 pattern_length;
239 Buffer<fltp08> pattern;
240 };
241
244 struct StyleData
245 {
246 StyleData()
247 : name()
248 , flags(0)
249 , fixed_text_height(Constant<fltp08>::Invalid)
250 , width_factor(1.0)
251 , oblique_angle(0.0)
252 , text_generation_flags(0)
253 , last_height_used(Constant<fltp08>::Invalid)
254 , primary_font_file(File())
255 , big_font_file(File())
256 , bold(false)
257 , italic(false)
258 {}
259 StyleData(const String& name, int flags, double fixedTextHeight, double widthFactor, double obliqueAngle,
260 int textGenerationFlags, double lastHeightUsed, const String& primaryFontFile, const String& bigFontFile)
261 : name(name)
262 , flags(flags)
263 , fixed_text_height(fixedTextHeight)
264 , width_factor(widthFactor)
265 , oblique_angle(obliqueAngle)
266 , text_generation_flags(textGenerationFlags)
267 , last_height_used(lastHeightUsed)
268 , primary_font_file(primaryFontFile)
269 , big_font_file(bigFontFile)
270 , bold(false)
271 , italic(false)
272 {}
273
274 bool operator==(const StyleData& other) const
275 {
276 // ignore lastHeightUsed:
277 return (name == other.name && flags == other.flags && fixed_text_height == other.fixed_text_height &&
278 width_factor == other.width_factor && oblique_angle == other.oblique_angle && /*textGenerationFlags == other.textGenerationFlags &&*/
279 primary_font_file == other.primary_font_file && big_font_file == other.big_font_file);
280 }
281 String name;
282 int flags;
283 fltp08 fixed_text_height;
284 fltp08 width_factor;
285 fltp08 oblique_angle;
286 Vector<32, bool> text_generation_flags;
287 fltp08 last_height_used;
288 String primary_font_file;
289 String big_font_file;
290 bool bold;
291 bool italic;
292 };
293
296 struct ArcData : public ExtrusionData, public EntityData
297 {
298 ArcData(const Vector<3, fltp08>& center_point, fltp08 aRadius, Angle<fltp08> aAngle1, Angle<fltp08> aAngle2)
299 : offset(center_point)
300 , radius(aRadius)
301 , thickness(Constant<fltp08>::Invalid)
302 , angle1(aAngle1)
303 , angle2(aAngle2)
304 {}
305
306 Vector<3, fltp08> offset;
307 fltp08 radius;
308 fltp08 thickness;
309 Angle<fltp08> angle1;
310 Angle<fltp08> angle2;
311 };
312
316 struct PolylineData : public ExtrusionData, public EntityData
317 {
318 enum PolyFlags
319 {
320 e_closed//This is a closed polyline (or a polygon mesh closed in the M direction).
321 , e_curve_fits//Curve-fit vertices have been added.
322 , e_spline_fits//Spline-fit vertices have been added.
323 , e_is_3D_polyline//This is a 3D polyline.
324 , e_is_3D_polygon//This is a 3D polygon mesh.
325 , e_is_closed_n//The polygon mesh is closed in the N direction.
326 , e_is_polyface_mesh//The polyline is a polyface mesh.
327 , e_line_continuous//The linetype pattern is generated continuously around the vertices of this polyline.
328 };
329 enum CurveType
330 {
331 e_no_smooth = 0
332 , e_quadratic_b = 5
333 , e_cubic = 6
334 , e_bezier = 8
335 };
336 fltp08 thickness = 0.0;
337 fltp08 start_width = 0.0;
338 fltp08 end_width = 0.0;
339 CurveType curve_type = CurveType::e_no_smooth;
340 uint04 vertex_count = Constant<uint04>::Invalid;
341 uint04 m = Constant<uint04>::Invalid;//Number of vertices in m direction if polyline is a polygon mesh.
342 uint04 n = Constant<uint04>::Invalid;//Number of vertices in n direction if polyline is a polygon mesh.
343 Vector<32, bool> flags = Vector<32, bool>(false);
344 };
345
348 struct TraceData : public ExtrusionData, public EntityData
349 {
350 TraceData()
351 : thickness(0.0)
352 , is_solid(false)
353 {}
355 fltp08 thickness = 0.0;
356 bool is_solid = false;
357 };
358
361 struct SplineData : public EntityData
362 {
363 SplineData(uint01 degree, const Vector<32, bool>& flags)
364 : degree(degree)
365 , flags(flags)
366 {
367
368 }
369
370 uint01 degree;
371 Vector<32, bool> flags;
372 Vector<3, fltp08> tangent_start;
373 Vector<3, fltp08> tangent_end;
374 };
375
378 struct CADMeshData : public EntityData
379 {
380 enum PropertyOverrideType
381 {
382 e_color = 0
383 , e_material = 1
384 , e_transparency = 2
385 , e_material_mapper = 3
386 };
387 CADMeshData()
388 {}
389 struct MeshOverride
390 {
391 uint04 sub_entity_marker = 0;
392 PropertyOverrideType type = e_color;
393 Buffer<fltp08> values;
394
395 };
396 Buffer<Vertex<3, fltp08>> vertices;
398 Buffer<Vertex<3, fltp08>> textures;
399 Buffer<RGBColor> colors;
400 Buffer<uint04> face_points;
401 Buffer<uint04> edge_points;
402 Buffer<fltp08> edge_crease_values;
403 Buffer<MeshOverride> property_overrides;
404 uint04 version_number = 2;
405 uint04 subdivide_level = 0;
406 uint04 data_dictionary_reference = Constant<uint04>::Invalid;
407 bool bend_crease = false;//72
408
409 };
410
413 struct MTextData
414 {
415 MTextData(Vector<3, fltp08> insertion_point, Vector<3, fltp08> direction,
416 Vector<2, fltp08> size, int attachmentPoint, int drawingDirection,
417 int lineSpacingStyle, fltp04 lineSpacingFactor, const String& text, const String& style, Angle<fltp08> angle)
418 : insertion_point(insertion_point)
419 , direction_vector(direction)
420 , text_size(size)
421 , attachment_point(attachmentPoint)
422 , drawing_direction(drawingDirection)
423 , line_spacing_style(lineSpacingStyle)
424 , line_spacing_factor(lineSpacingFactor)
425 , text(text)
426 , style(style)
427 , angle(angle)
428 {}
429 Vector<3, fltp08> insertion_point;
430 Vector<3, fltp08> direction_vector;
431 Vector<2, fltp08> text_size;
440 int drawing_direction;//1 = left to right, 3 = top to bottom, 5 = by style
441 int line_spacing_style;//1 = at least, 2 = exact
442 fltp04 line_spacing_factor;//0.25 - 4.0
443 String text;
444 String style;
445 Angle<fltp08> angle;
446 };
447
450 struct TextData : public ExtrusionData, public EntityData
451 {
452 String text;
453 String style;
456 fltp08 height = Constant<fltp08>::Invalid;
457 fltp08 reference_width = Constant<fltp08>::Invalid;
458 fltp08 thickness = Constant<fltp08>::Invalid;
459 Angle<fltp08> rotation = Angle<fltp08>(0);
460 Angle<fltp08> oblique_angle = Angle<fltp08>(0);
461 fltp08 x_scale = 1.0;
462 fltp08 line_spacing_factor = 1.0;
463 uint01 flags = 0;
464 uint01 alignment = 0;
465 bool is_m_text = false;
466 };
467
470 struct Attrib : public TextData
471 {
472 enum Flags
473 {
474 e_attribute_invisible
475 , e_constant_attribute
476 , e_verification_required
477 , e_no_prompt_on_insertion
478 };
479 String tag;
480 String default_value;
481 BitFlag attrib_flags = BitFlag(0);
482 bool is_locked = false;
483 };
484
487 struct CircleData : public ExtrusionData, public EntityData
488 {
490 fltp08 thickness = Constant<fltp08>::Invalid;
491 };
492
496 struct EllipseData : public ExtrusionData, public EntityData
497 {
498 Vertex<3, fltp08> center;
499 Vertex<3, fltp08> endpoint_of_major_axis;
500 fltp08 thickness = Constant<fltp08>::Invalid;
501 fltp08 minor_to_major_ratio;
502 Angle<fltp08> angle1;
503 Angle<fltp08> angle2;
504 };
505
509 struct LineData : public ExtrusionData, public EntityData
510 {
512 fltp08 thickness = 0.0;
513 };
514
519 {
522 Angle<fltp08> azimuth = Constant<Angle<fltp08>>::Invalid;
523 };
524
528 struct BlockInsert : public PlacementData, public EntityData
529 {
530 String block_name;
531 Vector<2, uint04> grid_count = Constant<Vector<2, uint04>>::Invalid;
532 Vector<2, fltp08> grid_spacing = Constant<Vector<2, fltp08>>::Invalid;
533 bool attribute_to_follow;
534 };
535
539 struct PointData : public ExtrusionData, public EntityData
540 {
541 Vector<3, fltp08> location;
542 Angle<fltp08> effect_angle = Angle<fltp08>(DEGREES, 0.0f);
543 fltp08 thickness = 0.0;
544 };
545
549 struct DimensionData : public ExtrusionData, public EntityData
550 {
551 Vector<3, fltp08> definition_point;
552 Vector<3, fltp08> text_middle_point;
572 int type;
573 uint01 attachment_point_align = 5;
574 int line_spacing_style;//1 = at least, 2 = exact
575 fltp08 line_spacing_factor;//line spacing factor 0.25-4.0
576 String text;//Text string entered explicitly by user or "<>" for the actual measurement or " " (one blank space). for supressing the text.
577 String dimension_style;// Dimension style (font name)
578 Angle<fltp08> angle;//Rotation angle of dimension text away from default orientation.
579 double linear_factor;//style override.
580 double dim_scale;//scale
581 Angle<fltp08> text_angle;
582 Angle<fltp08> dim_hor_angle;
583 String dimension_block_name;
584 };
585
589 struct DimAlignedData : public DimensionData
590 {
591
592 DimAlignedData()
593 {}
594
595 LineSegment<3, fltp08> alignment_data;
596 };
597
600 struct LinearDimension : public DimensionData
601 {
602 LinearDimension()
603 { }
604
605 LineSegment<3, fltp08> alignment_data;
606
607 Angle<fltp08> line_angle; //Rotation angle of dimension line.
608 Angle<fltp08> oblique_angle;
609 };
610
615 {
616 uint04 handle = Constant<uint04>::Invalid;
617 uint04 parent_handle = 0;
618 bool hard_owned = true;
620 void clear()
621 {
622 handle = Constant<uint04>::Invalid;
623 parent_handle = 0;
624 data.clear();
625 }
626 };
627
630 struct RadialDimension : public DimensionData
631 {
632 RadialDimension(const Vector<3, fltp08>& coordinate, fltp08 dleader)
633 : coordinate(coordinate)
634 , leader(dleader)
635 {}
636
637 Vector<3, fltp08> coordinate;
638 fltp08 leader;//Leader length
639 };
640
643 struct DiametricDimension : public DimensionData
644 {
645 DiametricDimension(const Vector<3, fltp08>& def_point, double dleader)
646 : def_point(def_point)
647 , leader(dleader)
648 {}
649 Vector<3, fltp08> def_point;
650 fltp08 leader;//Leader length
651 };
652
656 template<uint04 t_data_count>
657 struct AngularDimensionData : public DimensionData
658 {
659 AngularDimensionData(const Vector<3, fltp08>& def_point_1, const Vector<3, fltp08>& def_point_2, const Vector<3, fltp08>& def_point_3)
660 {
661 static_assert(t_data_count == 3, "Wrong Argument Count");
662 def_points[0] = def_point_1;
663 def_points[1] = def_point_2;
664 def_points[2] = def_point_3;
665 }
666 AngularDimensionData(const Vector<3, fltp08>& def_point_1, const Vector<3, fltp08>& def_point_2,
667 const Vector<3, fltp08>& def_point_3, const Vector<3, fltp08>& def_point_4)
668 {
669 static_assert(t_data_count == 4, "Wrong Argument Count");
670 def_points[0] = def_point_1;
671 def_points[1] = def_point_2;
672 def_points[2] = def_point_3;
673 def_points[3] = def_point_4;
674 }
675 Vector<3, fltp08> def_points[t_data_count];
676 };
677
680 struct DimOrdinateData : public LineSegment<3, fltp08>, public DimensionData
681 {
682 DimOrdinateData(const Vector<3, fltp08>& p1, const Vector<3, fltp08>& p2, bool type)
683 : LineSegment<3, fltp08>(p1, p2)
684 , xtype(type)
685 {}
686
687 DimOrdinateData(LineSegment<3, fltp08>& dimension, bool type)
688 : LineSegment<3, fltp08>(dimension)
689 , xtype(type)
690 {}
691 bool xtype;//True if the dimension indicates the X-value, false for Y-value
692 };
693
696 struct LeaderData : public EntityData
697 {
698 enum LeaderPathType
699 {
700 e_segments = 0
701 , e_spline = 1
702 };
703 LeaderData()
704 : text_annotation_size(Constant<fltp08>::Invalid)
705 , use_arrowhead(false)
706 , leader_path_type(e_segments)
707 , leader_creation_flag(BitFlag(0))
708 , hookline_direction_flag(BitFlag(0))
709 , hookline_flag(BitFlag(0))
710 {}
711 LeaderData(bool lArrowHeadFlag, LeaderPathType lLeaderPathType, int lLeaderCreationFlag, int lHooklineDirectionFlag
712 , int lHooklineFlag, fltp08 lTextAnnotationHeight, fltp08 lTextAnnotationWidth)
713 : text_annotation_size(lTextAnnotationWidth, lTextAnnotationHeight)
714 , use_arrowhead(lArrowHeadFlag)
715 , leader_path_type(lLeaderPathType)
716 , leader_creation_flag(lLeaderCreationFlag)
717 , hookline_direction_flag(lHooklineDirectionFlag)
718 , hookline_flag(lHooklineFlag)
719 {}
720
721 Vector<2, fltp08> text_annotation_size;//Text annotation size
722 bool use_arrowhead;//Arrow head flag
723 LeaderPathType leader_path_type;//Leader path type
724 BitFlag leader_creation_flag;//Leader creation flag
725 BitFlag hookline_direction_flag;//direction flag
726 BitFlag hookline_flag;//Hookline flag
727 };
728
735 struct HatchData
736 {
737 HatchData()
738 : pattern_origin(Constant<Vector<2, fltp08>>::Invalid)
739 , scale(Constant<fltp08>::Invalid)
740 , num_loops(Constant<uint04>::Invalid)
741 , is_solid(false)
742 {}
743
744 HatchData(uint04 numLoops, bool solid, fltp08 scale, const Angle<fltp08>& angle, String pattern, const Vector<2, fltp08>& origin)
745 : pattern_origin(origin)
746 , pattern_name(std::move(pattern))
747 , scale(scale)
748 , num_loops(numLoops)
749 , angle(angle)
750 , is_solid(solid)
751 {}
752 Vector<2, fltp08> pattern_origin;
753 String pattern_name;
754 fltp08 scale;
755 uint04 num_loops;
756 Angle<fltp08> angle;
757 bool is_solid;
758 };
759
762 struct HatchLoopData
763 {
764 HatchLoopData()
765 : num_of_edges(Constant<uint04>::Invalid)
766 {}
767 HatchLoopData(uint04 num_edges)
768 : num_of_edges(num_edges)
769 {}
770 uint04 num_of_edges;
771 };
772
775 struct HatchEdgeData
776 {
777 HatchEdgeData()
778 : line(Constant<LineSegment<2, fltp08>>::Invalid)
779 , center_point(Constant<Vector<2, fltp08>>::Invalid)
780 , start_tangent(Constant<Vector<2, fltp08>>::Invalid)
781 , end_tangent(Constant<Vector<2, fltp08>>::Invalid)
782 , axis_major_point(Constant<Vector<2, fltp08>>::Invalid)
783 , radius(Constant<fltp08>::Invalid)
784 , axis_ratio(Constant<fltp08>::Invalid)
785 , type(e_undefined)
786 , degree(0)
787 , rational(false)
788 , periodic(false)
789 , is_ccw(false)
790 {}
791 explicit HatchEdgeData(LineSegment<2, fltp08> line)
792 : line(std::move(line))
793 , center_point(Constant<Vector<2, fltp08>>::Invalid)
794 , start_tangent(Constant<Vector<2, fltp08>>::Invalid)
795 , end_tangent(Constant<Vector<2, fltp08>>::Invalid)
796 , axis_major_point(Constant<Vector<2, fltp08>>::Invalid)
797 , radius(Constant<fltp08>::Invalid)
798 , axis_ratio(Constant<fltp08>::Invalid)
799 , type(e_line)
800 , degree(0)
801 , rational(false)
802 , periodic(false)
803 , is_ccw(false)
804 {}
805
806 HatchEdgeData(const Vector<2, fltp08>& arc_center, fltp08 radius, Angle<fltp08> angle_start, Angle<fltp08> angle_end, bool ccw)
807 : line(Constant<LineSegment<2, fltp08>>::Invalid)
808 , center_point(arc_center)
809 , start_tangent(Constant<Vector<2, fltp08>>::Invalid)
810 , end_tangent(Constant<Vector<2, fltp08>>::Invalid)
811 , axis_major_point(Constant<Vector<2, fltp08>>::Invalid)
812 , radius(radius)
813 , angle_start(angle_start)
814 , angle_end(angle_end)
815 , axis_ratio(Constant<fltp08>::Invalid)
816 , type(e_arc)
817 , degree(0)
818 , rational(false)
819 , periodic(false)
820 , is_ccw(ccw)
821 {}
822
823 HatchEdgeData(const Vector<2, fltp08>& center, const Vector<2, fltp08>& axis_major_point, double ratio, Angle<fltp08> angle1, Angle<fltp08> angle2, bool ccw)
824 : line(Constant<Vector<2, fltp08>>::Invalid, Constant<Vector<2, fltp08>>::Invalid)
825 , center_point(center)
826 , start_tangent(Constant<Vector<2, fltp08>>::Invalid)
827 , end_tangent(Constant<Vector<2, fltp08>>::Invalid)
828 , axis_major_point(axis_major_point)
829 , radius(Constant<fltp08>::Invalid)
830 , angle_start(angle1)
831 , angle_end(angle2)
832 , axis_ratio(ratio)
833 , type(e_elliptic_arc)
834 , degree(0)
835 , rational(false)
836 , periodic(false)
837 , is_ccw(ccw)
838 {}
839
840 HatchEdgeData(uint01 degree, bool rational, bool periodic,
841 Buffer<fltp08> knots,
842 Buffer<Buffer<fltp08>> controlPoints,
843 Buffer<Buffer<fltp08>> fitPoints,
844 Buffer<fltp08> weights,
845 const Vector<2, fltp08>& start_tangent,
846 const Vector<2, fltp08>& end_tangent)
847 : control_points(std::move(controlPoints))
848 , fit_points(std::move(fitPoints))
849 , knots(std::move(knots))
850 , weights(std::move(weights))
851 , line(Constant<LineSegment<2, fltp08>>::Invalid)
852 , center_point(Constant<Vector<2, fltp08>>::Invalid)
853 , start_tangent(start_tangent)
854 , end_tangent(end_tangent)
855 , axis_major_point(Constant<Vector<2, fltp08>>::Invalid)
856 , radius(Constant<fltp08>::Invalid)
857 , axis_ratio(Constant<fltp08>::Invalid)
858 , type(e_spline)
859 , degree(degree)
860 , rational(rational)
861 , periodic(periodic)
862 , is_ccw(false)
863 {}
864 enum EdgeType
865 {
866 e_undefined = 0
867 , e_line = 1
868 , e_arc = 2
869 , e_elliptic_arc = 3
870 , e_spline = 4
871 };
872 Buffer<Buffer<fltp08>> control_points;
873 Buffer<Buffer<fltp08>> fit_points;
874 Buffer<Buffer<fltp08>> vertices;
875
876 Buffer<fltp08> knots;
877 Buffer<fltp08> weights;
878
880 Vector<2, fltp08> center_point;
881 Vector<2, fltp08> start_tangent;
882 Vector<2, fltp08> end_tangent;
883 Vector<2, fltp08> axis_major_point;
884
885 fltp08 radius;
886 Angle<fltp08> angle_start;
887 Angle<fltp08> angle_end;
888 fltp08 axis_ratio;
889
890 EdgeType type;
891 uint01 degree;
892 bool rational;
893 bool periodic;
894 bool is_ccw;
895
896 };
897
901 struct ViewportData : public EntityData
902 {
903 uint04 handle = Constant<uint04>::Invalid;
904 Vector<3, fltp08> wcs_center_point = Constant<Vector<3, fltp08>>::Invalid;
905 Vector<2, fltp08> dcs_center_point = Constant<Vector<2, fltp08>>::Invalid;
906 Bounds<2, fltp08> screen_bounds = Bounds<2, fltp08>(0.0, 1.0);
907 Vector<2, fltp08> snap_spacing = Vector<2, fltp08>(0.5);
908 Vector<2, fltp08> grid_spacing = Vector<2, fltp08>(0.5);
909 Vector<3, fltp08> view_direction = Vector<3, fltp08>(0.0, 0.0, 1.0);//View Direction FROM target point
910 Vector<3, fltp08> target_point = Vector<3, fltp08>(0.0, 0.0, 0.0);
911 Vector<3, fltp08> ucs_origin = Constant<Vector<3, fltp08>>::Invalid;
912 Vector<3, fltp08> ucs_x_axis = Constant<Vector<3, fltp08>>::Invalid;
913 Vector<3, fltp08> ucs_y_axis = Constant<Vector<3, fltp08>>::Invalid;
914 fltp08 perspective_lens_length = 1.0;
915 fltp08 elevation = Constant<fltp08>::Invalid;
916 Vector<2, fltp08> clip_planes = Vector<2, fltp08>(0.0, 1.0);
917 Vector<2, fltp08> wcs_view_size = Constant<Vector<2, fltp08>>::Invalid;
918 Vector<2, fltp08> ps_view_size = Constant<Vector<2, fltp08>>::Invalid;
919 Angle<fltp08> twist_angle = Angle<fltp08>(0);
920 String id = String("*Active");
921 enum Flags
922 {
923 e_perspective //1 (0x1) = Enables perspective mode
924 , e_enable_front_clipping //2 (0x2) = Enables front clipping
925 , e_enable_back_clipping // 4 (0x4) = Enables back clipping
926 , e_enable_ucs_follow //8 (0x8) = Enables UCS follow
927 , e_enable_front_clip // 16 (0x10) = Enables front clip not at eye
928 , e_enable_icon_visible // 32 (0x20) = Enables UCS icon visibility
929 , e_enable_ucs_icon_at_origin// 64 (0x40) = Enables UCS icon at origin
930 , e_enable_fast_zoom //128 (0x80) = Enables fast zoom
931 , e_enable_snaps // 256 (0x100) = Enables snap mode
932 , e_enable_grids // 512 (0x200) = Enables grid mode
933 , e_enable_iso_snap //1024 (0x400) = Enables isometric snap style
934 , e_enable_hide_plot // 2048 (0x800) = Enables hide plot mode
935 , e_is_pair_top // 4096 (0x1000) = kIsoPairTop.If set and kIsoPairRight is not set, then isopair top is enabled.If both kIsoPairTop and kIsoPairRight are set, then isopair left is enabled
936 , e_iso_pair_right // 8192 (0x2000) = kIsoPairRight.If set and kIsoPairTop is not set, then isopair right is enabled
937 , e_enable_viewport_zoom_lock //16384 (0x4000) = Enables viewport zoom locking
938 , e_always_enabled // 32768 (0x8000) = Currently always enabled
939 , e_enable_non_rect_clipping // 65536 (0x10000) = Enables non - rectangular clipping
940 , e_viewport_off // 131072 (0x20000) = Turns the viewport off
941 , e_grid_beyond_limits // 262144 (0x40000) = Enables the display of the grid beyond the drawing limits
942 , e_adaptive_grid // 524288 (0x80000) = Enable adaptive grid display
943 , e_grid_subdivide // 1048576 (0x100000) = Enables subdivision of the grid below the set grid spacing when the grid display is adaptive
944 , e_grid_follows_workplane // 2097152 (0x200000) = Enables grid follows workplane switching
945 };
946 Vector<16, bool> flags = Vector<16, bool>(false);
947 enum RenderMode
948 {
949 e_2D_optimized = 0//2D Optimized(classic 2D)
950 , e_wireframe = 1
951 , e_hidden_line = 2
952 , e_flat_shaded = 3
953 , e_gouraud_shaded = 4
954 , e_flat_shaded_with_wireframe = 5
955 , e_gouraud_shaded_with_wireframe = 6
956 };
957 enum ViewMode
958 {
959 e_perspective_view = 0
960 , e_front_clipping = 1
961 , e_back_clipping = 2
962 , e_ucs_follow_mode = 3
963 , e_front_clipping_not_at_camera = 4
964 };
965 enum OrthographicMode
966 {
967 e_not_orthographic = 0//2D Optimized(classic 2D)
968 , e_top = 1
969 , e_bottom = 2
970 , e_front = 3
971 , e_back = 4
972 , e_left = 5
973 , e_right = 6
974 };
975 bool has_grid = false;
976 bool is_vport = false;
977 BitFlag view_mode = BitFlag(0);
978 RenderMode render_mode = e_2D_optimized;
979 };
980
984 struct CADImageData
985 {
986 CADImageData(const File& iref, Vector<3, fltp08> insertion_point, Vector<3, fltp08> bottom_vector
987 , Vector<3, fltp08> left_side, uint02 iwidth, uint02 iheight, uint01 ibrightness = 50, uint01 icontrast = 50, uint01 ifade = 0)
988 : ref(iref)
989 , insertion_point(insertion_point)
990 , bottom_vector(bottom_vector)
991 , left_side(left_side)
992 , image_size(iwidth, iheight)
993 , brightness(ibrightness)
994 , contrast(icontrast)
995 , fade(ifade)
996 {}
997
998 File ref;
999 Vector<3, fltp08> insertion_point;
1000 Vector<3, fltp08> bottom_vector;
1001 Vector<3, fltp08> left_side;
1002 Vector<2, uint02> image_size;
1003
1004 uint01 brightness; //Brightness (0-100, default = 50).
1005 uint01 contrast;//Contrast (0-100, default = 50).
1006 uint01 fade;//Fade (0-100, default = 0)
1007 };
1008
1013 {
1014 bool use_value = false;
1015 fltp08 color_intensity = 1.0;
1016 RGBColor color = Constant<RGBColor>::Invalid;
1017 };
1018
1022 {
1023 fltp08 map_blend_factor = 1.0;
1024 bool use_current_scene = true;
1025 File map_file;
1026 RGBColor color = Constant<RGBColor>::Invalid;
1027 };
1028
1032 struct DXFMaterial : public HandleData
1033 {
1034 String name;
1035 String description;
1036 MaterialUVOptions ambient;
1037 MaterialUVImageOptions diffuse;
1038 MaterialUVImageOptions specular;
1039 fltp08 specular_gloss_factor = 0.5;
1040 fltp08 opacity_percent = 1.0;
1041 Matrix<fltp08> mat_matrix = Matrix<fltp08>(1.0);
1042
1043 };
1044
1048 struct DXFGroup : public EntityData
1049 {
1050 String name;
1051 String description;
1052 bool is_named = false;
1053 bool selectable = false;
1054 Buffer<uint04> group_objects;
1055 };
1056
1060 struct ImageDefData
1061 {
1062 ImageDefData(const StringView& iref, const File& ifile)
1063 : ref(iref)
1064 , file(ifile)
1065 {}
1066 String ref;//Reference to the image file (unique, used to refer to the image def object).
1067 File file;
1068 };
1069
1072 class Extrusion
1073 {
1074 public:
1075 Extrusion()
1076 : m_direction(0)
1077 , m_elevation(0)
1078 {}
1079
1080 Extrusion(Vector<3, fltp08> direction, fltp08 elevation)
1081 : m_direction(direction)
1082 , m_elevation(elevation)
1083 {}
1084
1085 void setDirection(fltp08 dx, fltp08 dy, fltp08 dz)
1086 {
1087 m_direction[0] = dx;
1088 m_direction[1] = dy;
1089 m_direction[2] = dz;
1090 }
1091
1092 Vector<3, fltp08> getDirection() const { return m_direction; }
1093 void setElevation(double elevation) { m_elevation = elevation; }
1094 fltp08 getElevation() const { return m_elevation; }
1095 private:
1096 Vector<3, fltp08> m_direction;
1097 fltp08 m_elevation;
1098 };
1099}
1100
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Definition Angle.h:83
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
Class: LineSegment.
Definition Line.hpp:52
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
A radial object.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
@ BitFlag
Per-vertex bit flags (selected, hidden, etc.).
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
@ DEGREES
Angle measured in degrees (0 to 360 for a full circle).
Definition Angle.h:58
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
Definition Angle.h:388
ColorMode
Modes that CAD can use to color objects.
Definition CADEntities.h:45
Logic for storing attribute data in a CAD-friendly way for exporting and importing.
Information for how to place a CAD block within a scene (Similar to Model).
Stores color information for interfacing with CAD.
Definition CADEntities.h:77
A container for information pointing to a CAD dictionary in CAD memory.
logic for storing a circle data in a CAD-friendly way for exporting and importing.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
A type of entity in CAD representing several entities grouped together.
A DXF friendly material class which contains UV properties similar to a Material object.
Dimensional measurements stored in a CAD-friendly way.
int type
Dimension type.
Stores Ellipse information for interfacing with CAD.
An entity in CAD which has a layer and other handle information.
uint04 file_line_number
Line number in the source file.
CADColorInfo color_info
Color information for this entity.
bool is_off
Whether the entity layer is off.
String layer
The layer this entity belongs to.
uint04 material_handle
Handle to the associated material.
PaperSpace paper_space_info
Paper space configuration for this entity.
bool visible
Whether this entity is visible.
fltp08 line_type_scale
Scale factor for the line type pattern.
bool paper_space
Whether this entity is in paper space.
String line_type
The line type name for this entity.
Data for extruding an object onto a plane in CAD.
fltp08 elevation
The elevation above the extrusion plane.
Vector< 3, fltp08 > extrusion
The extrusion direction vector.
A handle used to reference an object in CAD.
uint04 handle
The handle of this object.
uint04 file_line_number
The line number in the source file.
uint04 parent_handle
The handle of the parent object.
A CAD-friendly way to store line segment information.
int attachment_point
Attachment point.
Provides CAD information for managing images attached to a Material.
UVOptions used for interfacing with CAD, similar to those used by a Material object.
Stores CAD details about PaperSpace or 2D document space.
Definition CADEntities.h:55
Data about where to place an object, used for interfacing with CAD.
Point data stored in a friendly way for interfacing with CAD.
logic for storing a polyline data in a CAD-friendly way for exporting and importing.
logic for storing a text data in a CAD-friendly way for exporting and importing.
logic for storing a viewport in a CAD-friendly way for exporting and importing.