This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathopennurbs_dimension.h
1117 lines (936 loc) · 34.1 KB
/
opennurbs_dimension.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* $NoKeywords: $ */
/*
//
// Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
*/
#if !defined(OPENNURBS_DIMENSION_INC_)
#define OPENNURBS_DIMENSION_INC_
#if defined(ON_DLL_TEMPLATE)
ON_DLL_TEMPLATE template ON_ClassArray< class ON_DimStyle >;
#endif
class ON_CLASS ON_Dimension : public ON_Annotation
{
ON_OBJECT_DECLARE(ON_Dimension);
public:
#pragma region RH_C_SHARED_ENUM [ON_Dimension::ForceArrow] [Rhino.Geometry.Dimension.ForceArrow] [nested:int]
/// <summary>
/// Arrowheads forced Inside, or Outside of extension lines, or moved to fit.
/// </summary>
enum class ForceArrow : unsigned int
{
/// <summary> </summary>
Auto = 0,
/// <summary> </summary>
Inside = 1,
/// <summary> </summary>
Outside = 2,
};
#pragma endregion
static ON_Dimension::ForceArrow ForceArrowFromUnsigned(
unsigned int force_arrow_as_unsigned);
#pragma region RH_C_SHARED_ENUM [ON_Dimension::ForceText] [Rhino.Geometry.Dimension.ForceText] [nested:int]
/// <summary>
/// Text forced Inside, Right or Left of extension lines, or moved to fit (Auto).
/// </summary>
enum class ForceText : unsigned int
{
/// <summary> </summary>
Auto = 0,
/// <summary> </summary>
Inside = 1,
/// <summary> </summary>
Right = 2,
/// <summary> </summary>
Left = 3,
/// <summary> If override isn't specified and text doesn't fit, move it right </summary>
HintRight = 4,
/// <summary> If override isn't specified and text doesn't fit, move it left </summary>
HintLeft = 5,
};
#pragma endregion
static ON_Dimension::ForceText ForceTextFromUnsigned(
unsigned int force_text_as_unsigned);
protected:
ON_Dimension( ON::AnnotationType annotation_type );
~ON_Dimension();
ON_Dimension(const ON_Dimension& src);
ON_Dimension& operator=(const ON_Dimension& src);
private:
ON_Dimension() = delete;
void Internal_Destroy();
void Internal_CopyFrom(const ON_Dimension& src);
public:
bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
virtual ON_2dPoint DefaultTextPoint() const;
virtual bool UseDefaultTextPoint() const;
virtual void SetUseDefaultTextPoint(bool usedefault);
// Text center-midpoint in dimension plane
ON_2dPoint TextPoint() const;
void Set2dTextPoint(const ON_2dPoint& textpoint);
const wchar_t* UserText() const;
void SetUserText(const wchar_t* text);
const wchar_t* PlainUserText() const;
// Computes measurement value as a number
virtual double Measurement() const = 0;
// Add to natural rotation
ON_DEPRECATED_MSG("ON_Dimension::TextRotation() is a mistake. Use ON_Annotation::TextRotationRadians().")
double TextRotation() const;
ON_DEPRECATED_MSG("ON_Dimension::SetTextRotation() is a mistake. Use ON_Annotation::SetTextRotationRadians().")
void SetTextRotation(double rotation_radians);
bool ArrowIsFlipped(int i) const;
void FlipArrow(int i, bool flip) const;
// If the dimension is a paper space object and the geometry being dimensioned is in
// model space, in a detail viewport, DetailMeasured() will have the UUID of the detail
// that the dimension references. Otherwise DetailMeasured() will be ON_nil_uuid.
ON_UUID DetailMeasured() const;
void SetDetailMeasured(ON_UUID uuid);
// If DetailMeasured() returns ON_nil_uuid, DistanceScale() has no meaning
// If the dimension is in page space and measures model space geometry,
// DistanceScale() is the conversion from the model space distance being measured
// to the paper space distance spanned by the dimension geometry.
// When the zoom factor of the detail view changes, the distance scale will change
double DistanceScale() const;
void SetDistanceScale(double distance_scale) const;
//virtual bool GetBBox(
// const ON_Viewport* vp,
// double dimscale,
// const ON_DimStyle* dimstyle,
// double* boxmin,
// double* boxmax,
// bool bGrow = 0) const = 0;
virtual bool GetTextRect(ON_3dPoint text_rect[4]) const;
// Remakes dimension text geometry object and sets it on the dimension
virtual bool UpdateDimensionText(
ON::LengthUnitSystem units_in,
const ON_DimStyle* dimstyle
) const;
// Makes text geometry for a dimension
ON_TextContent* RebuildDimensionText(
ON::LengthUnitSystem units_in,
const ON_DimStyle* dimstyle,
bool expandanglebrackets // replace <> with the formatted distance
) const;
virtual bool GetDistanceDisplayText(
ON::LengthUnitSystem units_in,
const ON_DimStyle* dimstyle,
ON_wString& displaytext) const;
static bool GetCentermarkDisplay(
const ON_Plane& plane,
const ON_2dPoint center,
double marksize,
double radius,
ON_DimStyle::centermark_style style,
ON_Line lines[6],
bool isline[6],
int maxlines
);
static bool GetCentermarkSnapPoints(
const ON_Plane& plane,
const ON_2dPoint center,
double marksize,
double radius,
ON_DimStyle::centermark_style style,
ON_3dPoint points[13],
bool ispoint[13]);
ON_Dimension::ForceArrow ForceArrowPosition() const;
void SetForceArrowPosition(ForceArrow force);
ON_Dimension::ForceText ForceTextPosition() const;
void SetForceTextPosition(ForceText force);
protected:
ON_wString m_user_text = L"<>"; // If user overridden, or "<>" to use default
double m_reserved = 0.0;
mutable ON_wString m_plain_user_text;
bool m_use_default_text_point = true;
ON_2dPoint m_user_text_point = ON_2dPoint::UnsetPoint; // Text point if default isn't used
mutable bool m_flip_arrow_1 = false;
mutable bool m_flip_arrow_2 = false;
mutable bool m_text_outside = false;
ForceArrow m_force_arrows = ForceArrow::Auto;
ForceText m_force_textpos = ForceText::Auto;
// UUID of detail if dimension is in page space measuring model space geometry
ON_UUID m_detail_measured = ON_nil_uuid;
// Conversion from model space size to paper space size if dimension is in page space measuring model space geometry
mutable double m_distance_scale = 1.0;
bool Internal_WriteDimension(
ON_BinaryArchive& // serialize definition to binary archive
) const;
bool Internal_ReadDimension(
ON_BinaryArchive& // restore definition from binary archive
);
};
class ON_CLASS ON_DimLinear : public ON_Dimension
{
ON_OBJECT_DECLARE(ON_DimLinear);
public:
ON_DimLinear();
~ON_DimLinear() = default;
ON_DimLinear(const ON_DimLinear& src) = default;
ON_DimLinear& operator=(const ON_DimLinear& src) = default;
static const ON_DimLinear Empty;
/*
Description:
Create a V6 linear dimension from a V5 linear dimension
The function is used when reading V5 files.
Parameters:
V5_linear_dimension -[in]
annotation_context - [in]
Dimstyle and other information referenced by V5_linear_dimension or nullptr if not available.
destination - [in]
If destination is not nullptr, then the V6 linear dimension is constructed
in destination. If destination is nullptr, then the new V6 linear dimension
is allocated with a call to new ON_DimLinear().
*/
static ON_DimLinear* CreateFromV5DimLinear(
const class ON_OBSOLETE_V5_DimLinear& V5_linear_dimension,
const class ON_3dmAnnotationContext* annotation_context,
ON_DimLinear* destination
);
/*
Parameters:
annotation_type - [in]
annotation type to test
Returns:
True if input parameter is one of the valid linear dimension types
ON::AnnotationType::Aligned or ON::AnnotationType::Rotated.
*/
static bool IsValidLinearDimensionType(
ON::AnnotationType annotation_type
);
/*
Parameters:
linear_dimension_type - [in]
ON::AnnotationType::Aligned or ON::AnnotationType::Rotated.
Returns:
True if input parameter is valid and type is set.
*/
bool SetLinearDimensionType(
ON::AnnotationType linear_dimension_type
);
bool Write(
ON_BinaryArchive& // serialize definition to binary archive
) const override;
bool Read(
ON_BinaryArchive& // restore definition from binary archive
) override;
bool Transform(const ON_Xform& xform) override;
// virtual ON_Geometry GetBBox override
bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
bool GetAnnotationBoundingBox(
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
double* boxmin,
double* boxmax,
bool bGrow = false
) const override; // ON_Annotation override
// Gets transform for dimension text from ON_xy_plane to 3d display location
bool GetTextXform(
const ON_Xform* model_xform,
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
ON_Xform& text_xform_out
) const;
bool GetTextXform(
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
ON_Xform& text_xform_out
) const override;
bool Create(
ON::AnnotationType dim_type,
const ON_UUID style_id,
const ON_Plane& plane,
const ON_3dVector& ref_horizontal,
const ON_3dPoint& def_pt1,
const ON_3dPoint& def_pt2,
const ON_3dPoint& dimline_pt,
double rotation_in_plane = 0.0
);
/*
Description:
Create an aligned linear dimension. The dimension line is
parallel to the segment connecting the extension points.
Parameters:
extension_point0 - [in]
extension_point1 - [in]
locations of one of the points being dimensioned.
The dimension line will be parallel to the segment
connecting these points.
dimension_line_point - [in]
a point on the linear dimension line.
plane_normal - [in]
A vector perpindcular to the line between the extension points
that defines the orientation of the dimension's plane.
dim_style_id - [in]
destination - [in]
If nullptr, the returned ON_DimLinear is allocated by operator new.
Otherwise, the reuturned ON_DimLinear is created in destination.
*/
static ON_DimLinear* CreateAligned(
ON_3dPoint extension_point0,
ON_3dPoint extension_point1,
ON_3dPoint dimension_line_point,
ON_3dVector plane_normal,
ON_UUID style_id,
ON_DimLinear* destination
);
/*
Description:
Create a rotated linear dimension to the document.
The dimension line is explicitly specified.
Parameters:
extension_point0 - [in]
extension_point1 - [in]
locations of one of the points being dimensioned.
The dimension line will be parallel to the segment
connecting these points.
dimension_line - [in]
the dimension line. This is treated as an infinite
line and the points are automatically calculated.
plane_normal - [in]
A vector perpindcular to the line between the extension points
that defines the orientation of the dimension's plane.
The dimension line is projected to this plane.
dim_style_id - [in]
destination - [in]
If nullptr, the returned ON_DimLinear is allocated by operator new.
Otherwise, the reuturned ON_DimLinear is created in destination.
*/
static ON_DimLinear* CreateRotated(
ON_3dPoint extension_point0,
ON_3dPoint extension_point1,
ON_Line dimension_line,
ON_3dVector plane_normal,
ON_UUID style_id,
ON_DimLinear* destination
);
// virtual
double Measurement() const override;
ON_2dPoint DefaultTextPoint() const override;
// DefPoint1 is m_plane.origin
// Meaasurement is between DefPoint1 and DefPoint2
// parallel to the m_plane x-axis.
ON_2dPoint DefPoint1() const;
ON_2dPoint DefPoint2() const;
ON_2dPoint DimlinePoint() const;
void Set2dDefPoint1(ON_2dPoint pt);
void Set2dDefPoint2(ON_2dPoint pt);
void Set2dDimlinePoint(ON_2dPoint pt);
void Set3dDefPoint1(ON_3dPoint pt);
void Set3dDefPoint2(ON_3dPoint pt);
void Set3dDimlinePoint(ON_3dPoint pt);
ON_2dPoint ArrowPoint1() const; // Calculated
ON_2dPoint ArrowPoint2() const; // Calculated
bool Get3dPoints(
ON_3dPoint* defpt1,
ON_3dPoint* defpt2,
ON_3dPoint* arrowpt1,
ON_3dPoint* arrowpt2,
ON_3dPoint* dimline,
ON_3dPoint* textpt) const;
bool GetDisplayLines(
const ON_Viewport* vp,
const ON_DimStyle* style,
double dimscale,
ON_3dPoint text_rect[4],
ON_Line lines[4],
bool isline[4],
int maxlines) const;
void GetArrowXform(
int which_end,
double scale,
bool arrowflipped,
bool from_the_back,
ON_Xform& arrow_xform_out) const;
protected:
ON_2dPoint m_def_pt_2 = ON_2dPoint::UnsetPoint;
ON_2dPoint m_dimline_pt = ON_2dPoint::UnsetPoint;
};
//---------------------------------------------------------------------
class ON_CLASS ON_DimAngular : public ON_Dimension
{
ON_OBJECT_DECLARE(ON_DimAngular);
public:
ON_DimAngular();
~ON_DimAngular() = default;
ON_DimAngular(const ON_DimAngular& src) = default;
ON_DimAngular& operator=(const ON_DimAngular& src) = default;
static const ON_DimAngular Empty;
/*
Parameters:
annotation_type - [in]
annotation type to test
Returns:
True if input parameter is one of the valid linear dimension types
ON::AnnotationType::Angular or ON::AnnotationType::Angular3pt.
*/
static bool IsValidAngularDimensionType(
ON::AnnotationType annotation_type
);
/*
Parameters:
angular_dimension_type - [in]
ON::AnnotationType::Angular or ON::AnnotationType::Angular3pt.
Returns:
True if input parameter is valid and type is set.
*/
bool SetAngularDimensionType(
ON::AnnotationType angular_dimension_type
);
static ON_DimAngular* CreateFromV5DimAngular(
const class ON_OBSOLETE_V5_DimAngular& V5_dim_angle,
const class ON_3dmAnnotationContext* annotation_context,
ON_DimAngular* destination
);
bool Write(
ON_BinaryArchive& // serialize definition to binary archive
) const override;
bool Read(
ON_BinaryArchive& // restore definition from binary archive
) override;
bool Transform(const ON_Xform& xform) override;
// virtual ON_Geometry GetBBox override
bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
bool GetAnnotationBoundingBox(
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
double* boxmin,
double* boxmax,
bool bGrow = false
) const override; // ON_Annotation override
// Gets transform for dimension text from ON_xy_plane to 3d display location
bool GetTextXform(
const ON_Xform* model_xform,
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
ON_Xform& text_xform_out
) const;
bool GetTextXform(
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
ON_Xform& text_xform_out
) const override;
/*
Parameters:
dim_style - [in]
Pass nullptr if a dim_style is not available.
arc - [in]
arc being dimensioned
offset - [in]
distance from the arc being dimensioned to the angular dimension arc.
When offset > 0, the dimension is outside the arc's circle.
When offset < 0 and > - arc.Radius(), the dimension is inside the arc's circle.
In all other cases, the angular dimension arc is on the arc.
Returns:
True if successful.
False if input is not valid. In this case ON_DimAngle::Empty settings are returned.
*/
bool Create(
const ON_DimStyle* dim_style,
ON_Arc arc,
double offset
);
/*
Description:
The angle between the lines is dimensioned.
If the lines intersect in a single point, that point is used as the center
of the angular dimension arc. In this case, there are eight possible angles
to dimension. The point_on_angular_dimension_arc and point_on_line parameters
are used to select the correct angle to dimension. If a point_on_line parameter
is not set, the corresponding line's midpoint is used.
If the lines are colinear, the point on the line closest to
point_on_angular_dimension_arc is the center of the angular dimension arc.
Parameters:
dim_style - [in]
Pass nullptr if a dim_style is not available.
line1 - [in]
point_on_line1 - [in]
If point_on_line1 is specified, it inidicates which semi-infinite portion of line1 to dimension.
Otherwise the midpoint of lne1 as a segment is used.
When in doubt, pass ON_3dPoint::UnsetPoint.
line2 - [in]
point_on_line2 - [in]
If point_on_line2 is specified, it inidicates which semi-infinite portion of line2 to dimension.
Otherwise the midpoint of line2 as a segment is used.
When in doubt, pass ON_3dPoint::UnsetPoint.
point_on_angular_dimension_arc - [in]
A point on the interior of the angular dimension arc.
bSetExtensionPoints - [in]
If bSetExtensionPoints is true, and a point_on_line parameter is valid, that point
is used as the extension point. Otherwise the angular dimension arc endpoint is used.
Returns:
True if successful.
False if input is not valid. In this case ON_DimAngle::Empty settings are returned.
*/
bool Create(
const ON_DimStyle* dim_style,
ON_Line line1,
ON_3dPoint point_on_line1,
ON_Line line2,
ON_3dPoint point_on_line2,
ON_3dPoint point_on_angular_dimension_arc,
bool bSetExtensionPoints
);
bool Create(
const ON_UUID style_id,
const ON_Plane& plane,
const ON_3dVector& ref_horizontal,
const ON_3dPoint& center_pt,
const ON_3dPoint& extension_pt1, // point on first extension vector
const ON_3dPoint& extension_pt2, // point on second extension vector
const ON_3dPoint& dimline_pt // point on dimension line
);
bool Create(
const ON_UUID style_id,
const ON_Plane& plane,
const ON_3dVector& ref_horizontal,
const ON_3dPoint& extension_pt1, // start of first extension line
const ON_3dPoint& extension_pt2, // start of second extension line
const ON_3dPoint& direction_pt1, // point on first extension vector
const ON_3dPoint& direction_pt2, // point on second extension vector
const ON_3dPoint& dimline_pt // point on dimension line
);
bool AdjustFromPoints(
const ON_Plane& plane,
const ON_3dPoint& center_pt,
const ON_3dPoint& extension_pt1, // point on first extension vector
const ON_3dPoint& extension_pt2, // point on second extension vector
const ON_3dPoint& dimline_pt // point on dimension line
);
bool AdjustFromPoints(
const ON_Plane& plane,
const ON_3dPoint& extension_pt1, // start of first extension line
const ON_3dPoint& extension_pt2, // start of second extension line
const ON_3dPoint& direction_pt1, // point on first extension vector
const ON_3dPoint& direction_pt2, // point on second extension vector
const ON_3dPoint& dimline_pt // point on dimension line
);
static bool FindAngleVertex(
ON_Line lines[2],
ON_3dPoint pickpoints[2],
const ON_Plane& plane,
ON_3dPoint& centerpoint_out);
bool UpdateDimensionText(const ON_DimStyle* dimstyle) const;
bool GetAngleDisplayText(const ON_DimStyle* dimstyle, ON_wString& displaytext) const;
// virtual
double Measurement() const override; // angle in radians
ON_2dPoint DefaultTextPoint() const override;
bool GetAngles(double* start_ang, double* end_ang, double* mid_ang) const;
double Radius() const;
// CenterPoint is m_plane.origin
// Measurement is angle between m_vec_1 & m_vec_2 in radians
ON_2dPoint CenterPoint() const;
ON_2dPoint DefPoint1() const; // Start of first extension
ON_2dPoint DefPoint2() const; // Start of second extension
ON_2dPoint DimlinePoint() const; // Point on dimension arc
ON_2dPoint UserTextPoint() const; // Text point if user positioned
ON_2dVector ExtDir1() const; // Direction of first extension
ON_2dVector ExtDir2() const; // Direction of second extension
void SetExtDir1(const ON_2dVector& dir1);
void SetExtDir2(const ON_2dVector& dir2);
void SetUserTextPoint(const ON_3dPoint& point);
void Set2dCenterPoint(ON_2dPoint pt); // Apex of angle
void Set2dDefPoint1(ON_2dPoint pt); // Point where first extension starts
void Set2dDefPoint2(ON_2dPoint pt); // Point where second extension starts
void Set2dDimlinePoint(ON_2dPoint pt); // Point on dimension arc
//void Set2dDefPoint1(ON_2dPoint pt); // Point where first extension starts
//void Set2dDefPoint2(ON_2dPoint pt); // Point where second extension starts
//void Set2dDimlinePoint(ON_2dPoint pt); // Point on dimension arc
//void Set3dCenterPoint(ON_3dPoint pt);
//void Set3dDefPoint1(ON_3dPoint pt);
//void Set3dDefPoint2(ON_3dPoint pt);
//void Set3dDimlinePoint(ON_3dPoint pt);
ON_2dPoint ArrowPoint1() const; // Calculated - start of arc
ON_2dPoint ArrowPoint2() const; // Calculated - end of arc
bool Get3dPoints(
ON_3dPoint* center,
ON_3dPoint* defpt1,
ON_3dPoint* defpt2,
ON_3dPoint* arrowpt1,
ON_3dPoint* arrowpt2,
ON_3dPoint* dimline,
ON_3dPoint* textpt) const;
bool GetDisplayLines(
const ON_Viewport* vp,
const ON_DimStyle* style,
double dimscale,
const ON_3dPoint text_rect[4],
ON_Line lines[2],
bool isline[2],
ON_Arc arcs[2],
bool isarc[2],
int maxlines,
int maxarcs) const;
void GetArrowXform(
int which_end,
double arrowlength,
bool arrowflipped,
bool from_the_back,
ON_Xform& arrow_xform_out) const;
bool UpdateDimensionText(
ON::LengthUnitSystem units_in,
const ON_DimStyle* dimstyle) const override;
bool GetDistanceDisplayText(
ON::LengthUnitSystem units_in,
const ON_DimStyle* dimstyle,
ON_wString& displaytext) const override;
protected:
// Center point is at plane origin (0,0)
ON_2dVector m_vec_1 = ON_2dVector::XAxis;
ON_2dVector m_vec_2 = ON_2dVector::YAxis;
double m_ext_offset_1 = 0.0; // distance along m_vec_1 to start extension line 1
double m_ext_offset_2 = 0.0; // distance along m_vec_2 to start extension line 2
ON_2dPoint m_dimline_pt = ON_2dPoint(1.0, 1.0); // point on interior of dimension arc
};
//---------------------------------------------------------------------
class ON_CLASS ON_DimRadial : public ON_Dimension
{
ON_OBJECT_DECLARE(ON_DimRadial);
public:
ON_DimRadial();
~ON_DimRadial() = default;
ON_DimRadial(const ON_DimRadial& src) = default;
ON_DimRadial& operator=(const ON_DimRadial& src) = default;
static const ON_DimRadial Empty;
/*
Description:
Create a V6 radial dimension from a V5 radial dimension
The function is used when reading V5 files.
Parameters:
V5_radial_dimension -[in]
annotation_context - [in]
Dimstyle and other information referenced by V5_radial_dimension or nullptr if not available.
destination - [in]
If destination is not nullptr, then the V6 radial dimension is constructed
in destination. If destination is nullptr, then the new V6 radial dimension
is allocated with a call to new ON_DimRadial().
*/
static ON_DimRadial* CreateFromV5DimRadial(
const class ON_OBSOLETE_V5_DimRadial& V5_radial_dimension,
const class ON_3dmAnnotationContext* annotation_context,
ON_DimRadial* destination
);
/*
Parameters:
annotation_type - [in]
annotation type to test
Returns:
True if input parameter is one of the valid radial dimension types
ON::AnnotationType::Radius or ON::AnnotationType::Diameter.
*/
static bool IsValidRadialDimensionType(
ON::AnnotationType annotation_type
);
/*
Parameters:
radial_dimension_type - [in]
ON::AnnotationType::Radius or ON::AnnotationType::Diameter.
Returns:
True if input parameter is valid and type is set.
*/
bool SetRadialDimensionType(
ON::AnnotationType radial_dimension_type
);
bool Write(
ON_BinaryArchive& // serialize definition to binary archive
) const override;
bool Read(
ON_BinaryArchive& // restore definition from binary archive
) override;
bool Transform(const ON_Xform& xform) override;
// virtual ON_Geometry GetBBox override
bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
bool GetAnnotationBoundingBox(
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
double* boxmin,
double* boxmax,
bool bGrow = false
) const override; // ON_Annotation override
// Gets transform for dimension text from ON_xy_plane to 3d display location
bool GetTextXform(
const ON_Xform* model_xform,
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
ON_Xform& text_xform_out
) const;
bool GetTextXform(
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
ON_Xform& text_xform_out
) const override;
bool Create(
ON::AnnotationType type,
const ON_UUID style_id,
const ON_Plane& plane,
const ON_3dPoint& center_pt,
const ON_3dPoint& radius_pt,
const ON_3dPoint& dimline_pt
);
bool AdjustFromPoints(
const ON_Plane& plane,
const ON_3dPoint& center_pt,
const ON_3dPoint& radius_pt,
const ON_3dPoint& dimline_pt
);
double Measurement() const override;
ON_2dPoint DefaultTextPoint() const override;
ON_2dPoint CenterPoint() const;
ON_2dPoint RadiusPoint() const; // Point on arc being measured
ON_2dPoint DimlinePoint() const; // Endpoint of leader tail, not including landing
ON_2dPoint KneePoint() const; // Point where leader tail bends
void Set2dCenterPoint(ON_2dPoint pt);
void Set2dRadiusPoint(ON_2dPoint pt);
void Set2dDimlinePoint(ON_2dPoint pt);
void Set3dCenterPoint(ON_3dPoint pt);
void Set3dRadiusPoint(ON_3dPoint pt);
void Set3dDimlinePoint(ON_3dPoint pt);
bool Get3dPoints(
ON_3dPoint* center_pt,
ON_3dPoint* radius_pt,
ON_3dPoint* dimline_pt,
ON_3dPoint* knee_pt) const;
bool GetDisplayLines(
const ON_DimStyle* style,
double dimscale,
ON_3dPoint text_rect[4],
ON_Line lines[9],
bool isline[9],
int maxlines) const;
void GetArrowXform(
double scale,
ON_Xform& arrow_xform_out) const;
protected:
ON_2dPoint m_radius_pt = ON_2dPoint::UnsetPoint;
ON_2dPoint m_dimline_pt = ON_2dPoint::UnsetPoint;
};
//---------------------------------------------------------------------
// + dimpt
// |
// |
// |
// + kinkpt2
// \
// \ kinkoffset2
// \
// + kinkpt1
// |
// | kinkoffset1
// |
// + ldrpt
// 1
// 2
// 3
class ON_CLASS ON_DimOrdinate : public ON_Dimension
{
ON_OBJECT_DECLARE(ON_DimOrdinate);
public:
ON_DimOrdinate();
~ON_DimOrdinate() = default;
ON_DimOrdinate(const ON_DimOrdinate& src) = default;
ON_DimOrdinate& operator=(const ON_DimOrdinate& src) = default;
static const ON_DimOrdinate Empty;
#pragma region RH_C_SHARED_ENUM [ON_DimOrdinate::MeasuredDirection] [Rhino.Geometry.OrdinateDimension.MeasuredDirection] [nested:byte]
/// <summary>
/// Ordinate dimension measures x or y direction
/// </summary>
enum class MeasuredDirection : unsigned char
{
/// <summary> </summary>
Unset = 0,
/// <summary> Measures horizontal distance </summary>
Xaxis = 1,
/// <summary> Measures vertical distance </summary>
Yaxis = 2,
};
#pragma endregion
static ON_DimOrdinate::MeasuredDirection MeasuredDirectionFromUnsigned(
unsigned int measured_direction_as_unsigned
);
static ON_DimOrdinate* CreateFromV5DimOrdinate(
const class ON_OBSOLETE_V5_DimOrdinate& V5_dim_ordinate,
const class ON_3dmAnnotationContext* annotation_context,
ON_DimOrdinate* destination
);
bool Write(
ON_BinaryArchive& archive
) const override;
bool Read(
ON_BinaryArchive& archive
) override;
bool Transform(const ON_Xform& xform) override;
// virtual ON_Geometry GetBBox override
bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
bool GetAnnotationBoundingBox(
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
double* boxmin,
double* boxmax,
bool bGrow = false
) const override; // ON_Annotation override
// Gets transform for dimension text from ON_xy_plane to 3d display location
bool GetTextXform(
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
ON_Xform& text_xform_out
) const override;
bool GetTextXform(
const ON_Xform* model_xform,
const ON_Viewport* vp,
const ON_DimStyle* dimstyle,
double dimscale,
ON_Xform& text_xform_out
) const;
bool Create(
const ON_UUID style_id,
const ON_Plane& plane,
MeasuredDirection direction,
const ON_3dPoint& basept,
const ON_3dPoint& defpt,
const ON_3dPoint& ldrpt,
double kinkoffset1,
double kinkoffset2
);
bool AdjustFromPoints(
const ON_Plane& plane,
MeasuredDirection direction,
const ON_3dPoint& basept,
const ON_3dPoint& defpt,
const ON_3dPoint& ldrpt,
double kinkoffset1,
double kinkoffset2
);
ON_2dPoint DefPt() const;
ON_2dPoint LeaderPt() const;
ON_2dPoint KinkPt1() const;
ON_2dPoint KinkPt2() const;
double KinkOffset1() const;
double KinkOffset2() const;
void Set2dDefPt(ON_2dPoint pt);
void Set2dLeaderPt(ON_2dPoint pt);
void SetKinkOffset1(double d);
void SetKinkOffset2(double d);
void Set3dBasePoint(ON_3dPoint pt);
void Set3dDefPt(ON_3dPoint pt);
void Set3dLeaderPt(ON_3dPoint pt);
ON_3dPoint Get3dBasePoint() const;
ON_3dPoint Get3dDefPt() const;
ON_3dPoint Get3dLeaderPt() const;
ON_3dPoint Get3dKinkPt1(double default_kink_offset = 1.0) const;
ON_3dPoint Get3dKinkPt2(double default_kink_offset = 1.0) const;
bool Get3dPoints(
ON_3dPoint* base_pt,
ON_3dPoint* def_pt,
ON_3dPoint* ldr_pt,
ON_3dPoint* kink_pt1,
ON_3dPoint* kink_pt2,
double default_kink_offset = 1.0) const;
bool GetDisplayLines(
const ON_DimStyle* style,
double dimscale,