forked from mcneel/opennurbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opennurbs_brep.h
4904 lines (4324 loc) · 149 KB
/
opennurbs_brep.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
//
// Copyright (c) 1993-2022 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>.
//
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//
// Definition of b-rep and its parts
//
////////////////////////////////////////////////////////////////
#if !defined(OPENNURBS_BREP_INC_)
#define OPENNURBS_BREP_INC_
class ON_BrepTrim;
class ON_BrepEdge;
class ON_BrepLoop;
class ON_BrepFace;
// TEMPORARY DEFINES SO I DON'T BREAK THE BUILD
//#define m_vertex_user_i m_vertex_user.i
//#define m_trim_user_i m_trim_user.i
//#define m_edge_user_i m_edge_user.i
//#define m_loop_user_i m_loop_user.i
//#define m_face_user_i m_face_user.i
// Description:
// Brep vertex information is stored in ON_BrepVertex classes.
// ON_Brep.m_V[] is an array of all the vertices in the brep.
//
// If a vertex is a point on a face, then brep.m_E[m_ei]
// will be an edge with no 3d curve. This edge will have
// a single trim with type ON_BrepTrim::ptonsrf. There
// will be a loop containing this single trim.
// Use ON_Brep::NewPointOnFace() to create vertices that are
// points on faces.
class ON_CLASS ON_BrepVertex : public ON_Point
{
ON_OBJECT_DECLARE(ON_BrepVertex);
public:
// Union available for application use.
// The constructor zeros m_vertex_user.
// The value is of m_vertex_user is not saved in 3DM
// archives and may be changed by some computations.
mutable ON_U m_vertex_user;
public:
mutable ON_ComponentStatus m_status = ON_ComponentStatus::NoneSet;
private:
ON__UINT16 m_reserved1 = 0U;
public:
// index of the vertex in the ON_Brep.m_V[] array
int m_vertex_index = -1;
/////////////////////////////////////////////////////////////////
// Construction
//
// In general, you should not directly create ON_BrepVertex classes.
// Use ON_Brep::NewVertex instead.
ON_BrepVertex();
ON_BrepVertex(
int // vertex index
);
ON_BrepVertex& operator=(const ON_BrepVertex&);
// virtual ON_Object::SizeOf override
unsigned int SizeOf() const override;
// virtual ON_Object::DataCRC override
ON__UINT32 DataCRC(ON__UINT32 current_remainder) const override;
bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
// virtual ON_Object::Dump() override
void Dump( ON_TextLog& ) const override; // for debugging
// virtual ON_Object::Write() override
bool Write( ON_BinaryArchive& ) const override;
// virtual ON_Object::Read() override
bool Read( ON_BinaryArchive& ) override;
// virtual ON_Geometry::ComponentIndex() override
ON_COMPONENT_INDEX ComponentIndex() const override;
/////////////////////////////////////////////////////////////////
// Interface
// Description:
// Set vertex location.
// Parameters:
// point - [in] 3d vertex location
bool SetPoint(
const ON_3dPoint& // point
);
// Returns:
// Vertex location.
ON_3dPoint Point() const;
// Returns:
// value of ON_BrepVertex::m_tolerance
// Remarks:
// Use ON_Brep::SetVertexTolerance( ON_BrepVertex& ) to set tolerances.
double Tolerance() const;
// Returns:
// number of edges that begin or end at this vertex.
int EdgeCount() const;
/////////////////////////////////////////////////////////////////
// Implementation
// indices of edges starting/ending at this vertex
//
// For closed edges, edge.m_vi[0] = edge.m_vi[1] and
// edge.m_edge_index appears twice in the m_ei[] array.
// The first occurrence of edge.m_edge_index in m_ei[]
// is for the closed edge starting the vertex.
// The second occurrence of edge,m_edge_index in m_ei[]
// is for the closed edge ending at the vertex.
// C.f. ON_Brep::Next/PrevEdge().
ON_SimpleArray<int> m_ei;
// accuracy of vertex point (>=0.0 or ON_UNSET_VALUE)
//
// A value of ON_UNSET_VALUE indicates that the
// tolerance should be computed.
//
// A value of 0.0 indicates that the distance
// from the vertex to any applicable edge or trim
// end is <= ON_ZERO_TOLERANCE
//
// If an edge begins or ends at this vertex,
// then the distance from the vertex's
// 3d point to the appropriate end of the
// edge's 3d curve must be <= this tolerance.
//
// If a trim begins or ends at this vertex,
// then the distance from the vertex's 3d point
// to the 3d point on the surface obtained by
// evaluating the surface at the appropriate
// end of the trimming curve must be <= this
// tolerance.
double m_tolerance = ON_UNSET_VALUE;
private:
ON_BrepVertex( const ON_BrepVertex& ) = delete;
};
/*
Description:
Brep edge information is stored in ON_BrepEdge classes.
ON_Brep.m_E[] is an array of all the edges in the brep.
An ON_BrepEdge is derived from ON_CurveProxy so the the
edge can supply easy to use evaluation tools via
the ON_Curve virtual member functions.
Note well that the domains and orientations of the curve
m_C3[edge.m_c3i] and the edge as a curve may not
agree.
*/
// April 24, 2017 Dale Lear
// ON_Curve::Trim(const ON_Interval&) is a virtual function and ON_BrepEdge derives
// from ON_CurveProxy which derives from ON_Curve. The ON_Brep::Trim(int) function was
// added and mistakenly named "Trim". This all happened about twenty years ago.
//
// Both the virtual ON_Curve::Trim(const ON_Interval&) and ON_BrepEdge::Trim(int) functions
// are widely used. At some point the functionON_Brep::Trim() will be deprecated and the 4263
// warning ON_Brep::Trim(int) generates will be disabled for the definition of class ON_BrepEdge.
// In version 7, ON_Brep::Trim(int) will be deleted and the warning will no longer be disabled.
#pragma ON_PRAGMA_WARNING_PUSH
#pragma ON_PRAGMA_WARNING_DISABLE_MSC(4263)
#pragma ON_PRAGMA_WARNING_DISABLE_MSC(4264)
class ON_CLASS ON_BrepEdge : public ON_CurveProxy
{
ON_OBJECT_DECLARE(ON_BrepEdge);
public:
// Union available for application use.
// The constructor zeros m_edge_user.
// The value is of m_edge_user is not saved in 3DM
// archives and may be changed by some computations.
mutable ON_U m_edge_user;
public:
mutable ON_ComponentStatus m_status = ON_ComponentStatus::NoneSet;
private:
ON__UINT16 m_reserved1 = 0U;
public:
// index of edge in ON_Brep.m_E[] array
int m_edge_index = -1;
// virtual ON_Curve::IsClosed override
bool IsClosed() const override;
/////////////////////////////////////////////////////////////////
// Construction
//
// In general, you should not directly create ON_BrepEdge classes.
// Use ON_Brep::NewVertex instead.
ON_BrepEdge();
ON_BrepEdge(int); // edge index
ON_BrepEdge& operator=(const ON_BrepEdge&);
// virtual ON_Object function
// The ON_BrepEdge override returns ON::curve_object.
ON::object_type ObjectType() const override;
/*
Returns:
Brep this edge belongs to.
*/
ON_Brep* Brep() const;
/*
Parameters:
eti - [in] index into the edge's m_ti[] array.
Returns:
The trim brep.m_T[edge.m_ti[eti]];
Remarks:
This version of "Trim" hides the virtual function ON_CurveProxy::Trim(const ON_Interval&),
which is a good thing. Special care must be taken when changing the geometry
of a brep edge to insure vertex, trim, and edge information remains valid.
*/
ON_BrepTrim* Trim( int eti ) const;
/*
Returns:
Number of trims attached to this edge.
*/
int TrimCount() const;
/*
Parameters:
evi - [in] 0 or 1
Returns:
Brep vertex at specified end of the edge.
*/
ON_BrepVertex* Vertex(int evi) const;
// virtual ON_Object::SizeOf override
unsigned int SizeOf() const override;
// virtual ON_Object::DataCRC override
ON__UINT32 DataCRC(ON__UINT32 current_remainder) const override;
bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
// virtual ON_Object::Dump() override
void Dump( ON_TextLog& ) const override; // for debugging
// virtual ON_Object::Write() override
bool Write( ON_BinaryArchive& ) const override;
// virtual ON_Object::Read() override
bool Read( ON_BinaryArchive& ) override;
// virtual ON_Geometry::ComponentIndex() override
ON_COMPONENT_INDEX ComponentIndex() const override;
// virtual ON_Curve::Reverse override
bool Reverse() override;
/* Not necessary. Base class does the right thing. ON_CurveProxy does not have an override.
// virtual ON_Curve::SetStartPoint override
bool SetStartPoint(
ON_3dPoint start_point
);
// virtual ON_Curve::SetEndPoint override
bool SetEndPoint(
ON_3dPoint end_point
);
*/
/////////////////////////////////////////////////////////////////
// Implementation
/*
Returns:
brep.m_C3[] index of the 3d curve geometry used by this edge
or -1.
*/
int EdgeCurveIndexOf() const;
/*
Returns:
3d curve geometry used by this edge or nullptr.
*/
const ON_Curve* EdgeCurveOf() const;
/*
Description:
Expert user tool that replaces the 3d curve geometry
of an edge
Parameters;
c3i - [in] brep 3d curve index of new curve
Returns:
True if successful.
Example:
ON_Curve* pCurve = ...;
int c3i = brep.AddEdgeCurve(pCurve);
edge.ChangeEdgeCurve(c3i);
Remarks:
Sets m_c3i, calls SetProxyCurve, cleans runtime caches.
*/
bool ChangeEdgeCurve(
int c3i
);
/*
Description:
When an edge is modified, the m_pline[].e values need
to be set to ON_UNSET_VALUE by calling UnsetPlineEdgeParameters().
*/
void UnsetPlineEdgeParameters();
// index of 3d curve in m_C3[] array
// (edge.m_curve also points to m_C3[m_c3i])
int m_c3i = -1;
// indices of starting/ending vertex
//
// For closed edges, m_vi[0] = m_vi[1] and m_edge_index
// appears twice in the m_V[m_vi[0]].m_ei[] array.
// The first occurrence of m_edge_index in m_V[m_vi[0]].m_ei[]
// is for the closed edge starting the vertex. The second
// occurrence of m_edge_index in m_V[m_vi[0]].m_ei[]
// is for the closed edge edge ending at the vertex.
// C.f. ON_Brep::Next/PrevEdge().
int m_vi[2];
// indices of Trims that use this edge
ON_SimpleArray<int> m_ti;
// accuracy of edge curve (>=0.0 or ON_UNSET_VALUE)
//
// A value of ON_UNSET_VALUE indicates that the
// tolerance should be computed.
//
// The maximum distance from the edge's 3d curve
// to any surface of a face that has this edge as
// a portion of its boundary must be <= this
// tolerance.
double m_tolerance = ON_UNSET_VALUE;
private:
friend class ON_Brep;
ON_Brep* m_brep = nullptr; // so isolated edge class edge can get at it's 3d curve
ON_BrepEdge( const ON_BrepEdge& ) = delete;
};
#pragma ON_PRAGMA_WARNING_POP
struct ON_BrepTrimPoint
{
ON_2dPoint p; // 2d surface parameter space point
double t; // corresponding trim curve parameter
double e; // corresponding edge curve parameter (ON_UNSET_VALUE if unknown)
};
#if defined(ON_DLL_TEMPLATE)
ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_BrepTrimPoint>;
#endif
/*
Description:
Brep trim information is stored in ON_BrepTrim classes.
ON_Brep.m_T[] is an array of all the trim in the brep.
An ON_BrepTrim is derived from ON_CurveProxy so the the
trim can supply easy to use evaluation tools via
the ON_Curve virtual member functions.
Note well that the domains and orientations of the curve
m_C2[trim.m_c2i] and the trim as a curve may not
agree.
*/
class ON_CLASS ON_BrepTrim : public ON_CurveProxy
{
ON_OBJECT_DECLARE(ON_BrepTrim);
public:
void DestroyRuntimeCache( bool bDelete = true ) override;
// virtual ON_Object::SizeOf override
unsigned int SizeOf() const override;
// Union available for application use.
// The constructor zeros m_trim_user.
// The value is of m_trim_user is not saved in 3DM
// archives and may be changed by some computations.
mutable ON_U m_trim_user;
public:
mutable ON_ComponentStatus m_status = ON_ComponentStatus::NoneSet;
private:
ON__UINT16 m_reserved1 = 0U;
public:
int m_trim_index = -1; // index of trim in ON_Brep.m_T[] array
// types of trim - access through m_type member. Also see m_iso and ON_Surface::ISO
enum TYPE
{
unknown = 0,
boundary = 1, // trim is connected to an edge, is part of an outer,
// inner or slit loop, and is the only trim connected
// to the edge.
mated = 2, // trim is connected to an edge, is part of an outer,
// inner or slit loop, no other trim from the same
// loop is connected to the edge, and at least one
// trim from a different loop is connected to the edge.
seam = 3, // trim is connected to an edge, is part of an outer loop,
// and exactly one other trim from the same loop is
// also connected to the edge. The trims are domain side
// iso's on opposite sides of the surface (e.g E_iso and W_iso)
// (There can be other mated trims that are also
// connected to the edge. For example, the non-manifold
// edge that results when a surface edge lies along
// the seam of another surface.)
singular = 4, // trim is part of an outer loop, the trim's 2d curve
// runs along the singular side of a surface, and the
// trim is NOT connected to an edge. (There is no 3d
// edge because the surface side is singular.)
crvonsrf = 5, // trim is connected to an edge, is the only trim in
// a crfonsrf loop, and is the only trim connected to
// the edge.
ptonsrf = 6, // trim is a point on a surface, trim.m_pbox is records
// surface parameters, and is the only trim
// in a ptonsrf loop. This trim is not connected
// to an edge and has no 2d curve.
slit = 7, // 17 Nov 2006 - reserved for future use
// currently an invalid value
trim_type_count = 8,
force_32_bit_trim_type = 0xFFFFFFFF
};
/////////////////////////////////////////////////////////////////
// Construction
//
// In general, you should not directly create ON_BrepTrim classes.
// Use ON_Brep::NewTrim instead.
ON_BrepTrim();
ON_BrepTrim(int); // trim index
ON_BrepTrim& operator=(const ON_BrepTrim&);
/*
Returns:
Brep that this trim belongs to.
*/
ON_Brep* Brep() const;
/*
Returns:
Brep loop that this trim belongs to.
*/
ON_BrepLoop* Loop() const;
/*
Returns:
Brep face this trim belongs to.
*/
ON_BrepFace* Face() const;
/*
Returns:
Brep edge this trim uses or belongs to. This will
be nullptr for singular trims.
*/
ON_BrepEdge* Edge() const;
/*
Parameters:
tvi - [in] 0 or 1
Returns:
Brep vertex at specified end of the trim.
*/
ON_BrepVertex* Vertex(int tvi) const;
/////////////////////////////////////////////////////////////////
// ON_Object overrides
//
// (Trims are purely topological - geometry queries should be
// directed at the trim's 2d curve or the trim's edge's 3d curve.)
bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
void Dump( ON_TextLog& ) const override; // for debugging
bool Write( ON_BinaryArchive& ) const override;
bool Read( ON_BinaryArchive& ) override;
// virtual ON_Geometry::ComponentIndex() override
ON_COMPONENT_INDEX ComponentIndex() const override;
// virtual ON_Curve::Reverse override
// Reverses curve - caller must make sure trim's m_bRev3d
// flags are properly updated. Use
// ON_Brep::FlipTrim to reverse and trim and update all
// m_bRev3d information.
bool Reverse() override;
/* Not necessary Base class does the same.
// virtual ON_Curve::SetStartPoint override
bool SetStartPoint(
ON_3dPoint start_point
) override;
// virtual ON_Curve::SetEndPoint override
bool SetEndPoint(
ON_3dPoint end_point
) override;
*/
/////////////////////////////////////////////////////////////////
// Interface
/*
Description:
Expert user tool that replaces the 2d curve geometry
of a trim
Parameters;
c2i - [in] brep 2d curve index of new curve
Returns:
True if successful.
Example:
ON_Curve* pCurve = ...;
int c2i = brep.AddTrimCurve(pCurve);
trim.ChangeTrimCurve(c2i);
Remarks:
Sets m_c2i, calls SetProxyCurve, cleans runtime caches,
and updates m_pbox.
*/
bool ChangeTrimCurve( int c2i );
/*
Description:
Destroy parameter space information.
Currently, this involves destroying m_pline
and m_pbox. Parameter space information should
be destroyed when the location of a trim
curve is changed.
*/
void DestroyPspaceInformation();
/*
Description:
Expert user function.
Removes a trim from an edge.
Parameters:
bRemoveFromStartVertex - [in] if true, the trim
is removed from its start vertex by setting
m_vi[0] to -1.
bRemoveFromEndVertex - [in] if true, the trim
is removed from its start vertex by setting
m_vi[1] to -1.
Remarks:
If the trim is attached to an edge (m_ei>=0), then
the trim is removed from the edge and the edge's
m_ti[] list. The trim's m_bRev3d and tolerance values
are not changed.
*/
bool RemoveFromEdge(
bool bRemoveFromStartVertex,
bool bRemoveFromEndVertex
);
/*
Description:
Expert user function.
Attaches a trim to an edge.
Parameters:
edge_index - [in] index of an edge.
bRev3d - [in] value for trim's m_bRev3d field.
Remarks:
If the trim is attached to an edge (m_ei>=0), then
the trim is removed from the edge and the edge's
m_ti[] list. The trim's tolerance values are not
changed.
*/
bool AttachToEdge(
int edge_index,
bool bRev3d
);
/*
Returns:
2d curve geometry used by this trim or nullptr
*/
const ON_Curve* TrimCurveOf() const;
/*
Returns:
3d curve geometry used by this trim or nullptr.
*/
const ON_Curve* EdgeCurveOf() const;
/*
Returns:
3d surface geometry used by this trim or nullptr
*/
const ON_Surface* SurfaceOf() const;
/*
Returns:
brep.m_C2[] 2d curve index of the 2d curve geometry used by
this trim or -1.
*/
int TrimCurveIndexOf() const;
/*
Returns:
brep.m_C3[] 3d curve index of the 3d curve geometry used by
this trim or -1.
*/
int EdgeCurveIndexOf() const;
/*
Returns:
brep.m_S[] surface index of the 3d surface geometry used by
this trim or -1.
*/
int SurfaceIndexOf() const;
/*
Returns:
brep.m_F[] face index of the face used by this trim or -1.
*/
int FaceIndexOf() const;
/*
Returns:
True if the trim satisfies these four criteria.
1) is part of a loop
2) is connected to a 3d edge
3) one other trim from the same loop is connected to the edge
4) The 2d trim curve for the other trim is the reverse
of the 2d trim curve for this trim.
Remarks:
In order for IsSlit() to work correctly, the m_type and m_iso
fields must be set correctly. In V4 SR1, this function will
be removed and ON_BrepTrim::slit will be added as a type.
*/
bool IsSlit() const;
/*
Returns:
True if the trim satisfies these four criteria.
1) is part of a loop
2) is connected to a 3d edge
3) one other trim from the same loop is connected to the edge
4) the 2d trim curve for this trim lies along the side of
the face's parameter space and the 2d curve for the other
trim lies on the opposite side of the face's parameter
space.
Remarks:
In order for IsSeam() to work correctly, the m_type and m_iso
fields must be set correctly. In V4 SR1, this function will
be removed and ON_BrepTrim::slit will be added as a type.
*/
bool IsSeam() const;
/*
Description:
Expert user tool that transforms all the parameter space (2d)
trimming curves in this loop. Only 2d curve geometry is
changed. The caller is responsible for reversing loops,
toggle m_bRev, flags, etc.
Parameters:
xform - [in] Transformation applied to 2d curve geometry.
Returns
True if successful. If false is returned, the brep
may be invalid.
*/
bool TransformTrim( const ON_Xform& xform );
// index of the 2d parameter space trimming curve
int m_c2i = -1;
// index of 3d edge (-1 if ON_BrepTrim is singular)
int m_ei = -1;
// Indices of start/end vertices. Trims along singular
// sides and trims that correspond to closed 3d edges
// have m_vi[0] = m_vi[1]. Note that singular trims
// and trims on the closed edge of a closed surface can
// have an open 2d trimming curve and still have
// m_vi[0] = m_vi[1].
int m_vi[2];
// true if the 2d trim and 3d edge have opposite orientations.
bool m_bRev3d = false;
TYPE m_type = ON_BrepTrim::unknown;
ON_Surface::ISO m_iso = ON_Surface::not_iso;
// index of loop that uses this trim
int m_li = -1;
// The values in m_tolerance[] record the accuracy of
// the parameter space trimming curves.
//
// Remarks:
// m_tolerance[0] = accuracy of parameter space curve
// in first ( "u" ) parameter
//
// m_tolerance[1] = accuracy of parameter space curve
// in second ( "v" ) parameter
//
// A value of ON_UNSET_VALUE indicates that the
// tolerance should be computed. If the value >= 0.0,
// then the tolerance is set. If the value is
// ON_UNSET_VALUE, then the tolerance needs to be
// computed.
//
// If the trim is not singular, then the trim must
// have an edge. If P is a 3d point on the edge's
// curve and surface(u,v) = Q is the point on the
// surface that is closest to P, then there must
// be a parameter t in the interval [m_t[0], m_t[1]]
// such that
//
// |u - curve2d(t)[0]| <= m_tolerance[0]
//
// and
//
// |v - curve2d(t)[1]| <= m_tolerance[1]
//
// If P is the 3d point for the vertex brep.m_V[m_vi[k]]
// and (uk,vk) is the corresponding end of the trim's
// parameter space curve, then there must be a surface
// parameter (u,v) such that:
//
// * the distance from the 3d point surface(u,v) to P
// is <= brep.m_V[m_vi[k]].m_tolerance,
// * |u-uk| <= m_tolerance[0].
// * |v-vk| <= m_tolerance[1].
double m_tolerance[2];
// Runtime polyline approximation of trimming curve.
// This information is not saved in 3DM archives.
ON_SimpleArray<ON_BrepTrimPoint> m_pline;
/*
Description:
When an edge is modified, the m_pline[].e values need
to be set to ON_UNSET_VALUE by calling UnsetPlineEdgeParameters().
*/
void UnsetPlineEdgeParameters();
// Runtime parameter space trimming curve bounding box.
// This information is not saved in 3DM archives.
ON_BoundingBox m_pbox;
public:
// values stored in legacy file formats - ignore
void m__legacy_flags_Set(int,int); // used internally - ignore
bool m__legacy_flags_Get(int*,int*) const; // used internally - ignore
double m__legacy_2d_tol = ON_UNSET_VALUE; // used internally - ignore
double m__legacy_3d_tol = ON_UNSET_VALUE; // used internally - ignore
int m__legacy_flags = 0; // used internally - ignore
private:
friend class ON_Brep;
ON_Brep* m_brep = nullptr; // so isolated edge class edge can get at it's 3d curve
ON_BrepTrim( const ON_BrepTrim& ) = delete;
};
class ON_CLASS ON_BrepLoop : public ON_Geometry
{
ON_OBJECT_DECLARE(ON_BrepLoop);
public:
void DestroyRuntimeCache( bool bDelete = true ) override;
// virtual ON_Geometry overrides
// A loop is derived from ON_Geometry so that is can
// be passed around to things that expect ON_Geometry
// pointers. It is not a very useful stand-alone object.
/*
Description:
virtual ON_Geometry::Dimension() override.
Returns:
2
*/
int Dimension() const override;
// virtual ON_Geometry GetBBox override
bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
// virtual ON_Geometry::Transform() override.
bool Transform(
const ON_Xform& xform
) override;
public:
/*
Returns:
Brep that the loop belongs to.
*/
ON_Brep* Brep() const;
/*
Returns:
Brep face this loop belongs to.
*/
ON_BrepFace* Face() const;
/*
Parameters:
lti - [in] index into the loop's m_ti[] array.
Returns:
The trim brep.m_T[loop.m_ti[lti]];
*/
ON_BrepTrim* Trim( int lti ) const;
/*
Returns:
Number of trims in this loop.
*/
int TrimCount() const;
// Union available for application use.
// The constructor zeros m_loop_user.
// The value is of m_loop_user is not saved in 3DM
// archives and may be changed by some computations.
mutable ON_U m_loop_user;
public:
mutable ON_ComponentStatus m_status = ON_ComponentStatus::NoneSet;
private:
ON__UINT16 m_reserved1 = 0U;
public:
int m_loop_index = -1; // index of loop in ON_Brep.m_L[] array
enum TYPE {
unknown = 0,
outer = 1, // 2d loop curves form a simple closed curve with a counterclockwise orientation
inner = 2, // 2d loop curves form a simple closed curve with a clockwise orientation
slit = 3, // always closed - used internally during splitting operations
crvonsrf = 4, // "loop" is a curveonsrf made from a single
// (open or closed) trim that is has type ON_BrepTrim::crvonsrf.
ptonsrf = 5, // "loop" is a ptonsrf made from a single
// trim that is has type ON_BrepTrim::ptonsrf.
type_count = 6
};
ON_BrepLoop();
ON_BrepLoop(int); // loop index
ON_BrepLoop& operator=(const ON_BrepLoop&);
/////////////////////////////////////////////////////////////////
// ON_Object overrides
//
// (Loops and trims are purely topological - geometry queries should be
// directed at the trim's 2d curve or the trim's edge's 3d curve.)
// virtual ON_Object::SizeOf override
unsigned int SizeOf() const override;
bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
void Dump( ON_TextLog& ) const override; // for debugging
bool Write( ON_BinaryArchive& ) const override;
bool Read( ON_BinaryArchive& ) override;
// virtual ON_Geometry::ComponentIndex() override
ON_COMPONENT_INDEX ComponentIndex() const override;
/////////////////////////////////////////////////////////////////
// Interface
//////////
// Returns the index i such that loop.m_ti[i] = trim.m_trim_index.
// Returns -1 if the trim is not in this loop
int IndexOfTrim( const ON_BrepTrim& ) const;
/*
Returns:
brep.m_S[] surface index of the 3d surface geometry used by
this loop or -1.
*/
int SurfaceIndexOf() const;
/*
Returns:
Pointer to the surface geometry used by the loop.
*/
const ON_Surface* SurfaceOf() const;
/*
Description:
Expert user tool that transforms all the parameter space (2d)
trimming curves in this loop. Only 2d curve geometry is
changed. The caller is responsible for reversing loops,
toggle m_bRev, flags, etc.
Parameters:
xform - [in] Transformation applied to 2d curve geometry.
Returns
True if successful. If false is returned, the brep
may be invalid.
*/
bool TransformTrim( const ON_Xform& xform );
ON_SimpleArray<int> m_ti; // trim indices
TYPE m_type = ON_BrepLoop::unknown;
int m_fi = -1; // index of face that uses this loop
//////////
// parameter space trimming loop bounding box
// runtime information - not saved
ON_BoundingBox m_pbox;
private:
friend class ON_Brep;
ON_Brep* m_brep = nullptr;
ON_BrepLoop(const ON_BrepLoop&) = delete;
};
class ON_CLASS ON_BrepFace : public ON_SurfaceProxy
{
ON_OBJECT_DECLARE(ON_BrepFace);
public:
void DestroyRuntimeCache( bool bDelete = true ) override;
// Union available for application use.
// The constructor zeros m_face_user.
// The value is of m_face_user is not saved in 3DM
// archives and may be changed by some computations.
mutable ON_U m_face_user;
public:
mutable ON_ComponentStatus m_status = ON_ComponentStatus::NoneSet;
private:
// the 4 byte pack id is stored as 2 ON__UINT16 values to prevent breaking the C++ SDK.
ON__UINT16 m_pack_id_low = 0; // PackId() = 0x10000*m_pack_id_high + m_pack_id_low;
public:
int m_face_index = -1; // index of face in ON_Brep.m_F[] array
ON_BrepFace();
~ON_BrepFace();
ON_BrepFace(int);
ON_BrepFace& operator=(const ON_BrepFace&);
/*
Returns:
Brep that the face belongs to.
*/
ON_Brep* Brep() const;
/*
Parameters:
fli - [in] index into the face's m_li[] array.
Returns:
The loop brep.m_L[face.m_li[fli]];
*/
ON_BrepLoop* Loop( int fli ) const;
/*
Returns:
Number of loops in this face.