-
Notifications
You must be signed in to change notification settings - Fork 140
/
opennurbs_beam.h
1002 lines (917 loc) · 31.2 KB
/
opennurbs_beam.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>.
//
////////////////////////////////////////////////////////////////
#if !defined(OPENNURBS_EXTRUSION_INC_)
#define OPENNURBS_EXTRUSION_INC_
/*
Description:
Get the transformation that maps the ON_Extrusion
2d xy profile to 3d world space.
Parameters:
P - [in] start or end of path
T - [in] unit tangent to path
U - [in] unit up vector perpendicular to T
Normal - [in] optional unit vector with Normal->z > 0 that
defines the unit normal to the miter plane.
xform - [out]
transformation that maps the profile curve to 3d world space
scale2d - [out]
If not nullptr, this is the scale part of the transformation.
If there is no mitering, then this is the identity.
rot2d - [out]
If not null, this is the part of the transformation
that rotates the xy plane into its 3d world location.
Returns:
true if successful.
*/
ON_DECL
bool ON_GetEndCapTransformation(
ON_3dPoint P,
ON_3dVector T,
ON_3dVector U,
const ON_3dVector* Normal,
ON_Xform& xform, // = rot3d*scale2d
ON_Xform* scale2d,
ON_Xform* rot2d
);
class ON_CLASS ON_Extrusion : public ON_Surface
{
ON_OBJECT_DECLARE(ON_Extrusion);
public:
ON_Extrusion();
ON_Extrusion(const ON_Extrusion& src);
~ON_Extrusion();
ON_Extrusion& operator=(const ON_Extrusion&);
////////////////////////////////////////////////////////////
//
// overrides of virtual ON_Object functions
//
void DestroyRuntimeCache( bool bDelete = true ) override;
bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
void Dump( ON_TextLog& ) const override;
unsigned int SizeOf() const override;
ON__UINT32 DataCRC( ON__UINT32 current_remainder ) const override;
bool Write( ON_BinaryArchive& binary_archive) const override;
bool Read( ON_BinaryArchive& binary_archive ) override;
ON::object_type ObjectType() const override;
////////////////////////////////////////////////////////////
//
// overrides of virtual ON_Geometry functions
//
int Dimension() const override;
// virtual ON_Geometry GetBBox override
bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
// virtual ON_Geometry GetTightBoundingBox override
bool GetTightBoundingBox( class ON_BoundingBox& tight_bbox, bool bGrowBox = false, const class ON_Xform* xform = nullptr ) const override;
bool Transform(
const ON_Xform& xform
) override;
/*
Description:
Build a brep form of the extrusion. The outer profile is always
the first face in the brep. If there are inner profiles,
additional brep faces are created for each profile. If the
outer profile is closed, then end caps are added as the last
two faces in the brep.
Parameters:
brep - [in]
If the brep pointer is not null, then the brep form is constructed
in brep. If the brep pointer is null, then an ON_Brep is allocated
on the heap.
Returns:
If successful, a pointer to the brep form. If unsuccessful, null.
*/
ON_Brep* BrepForm(
ON_Brep* brep = nullptr
) const override;
/*
Description:
Build a brep form of the extrusion. The outer profile is always
the first face in the brep. If there are inner profiles,
additional brep faces are created for each profile. If the
outer profile is closed, then end caps are added as the last
two faces in the brep.
Parameters:
brep - [in]
If the brep pointer is not null, then the brep form is constructed
in brep. If the brep pointer is null, then an ON_Brep is allocated
on the heap.
bSmoothFaces - [in]
If true and the profiles have kinks, then the faces corresponding
to those profiles are split so they will be G1.
Returns:
If successful, a pointer to the brep form. If unsuccessful, null.
*/
ON_Brep* BrepForm(
ON_Brep* brep,
bool bSmoothFaces
) const;
/*
Description:
Build a sum surface form of the extrusion.
Parameters:
sum_surface - [in]
If the sum_surface pointer is not null, then the sum surface
form is constructed in sum_surface. If the sum_surface pointer
is null, then an ON_SumSurface is allocated on the heap.
Returns:
If successful, a pointer to the sum surface form.
If unsuccessful, null. In particular, extrusions with
mitered ends do not have sum surface forms.
*/
ON_SumSurface* SumSurfaceForm(
ON_SumSurface* sum_surface
) const;
/*
Description:
Convert a component index that identifies a part of this extrusion
to a component index that identifies a part of the brep created
by BrepForm(...,false).
Parameters:
extrusion_ci - [in]
extrusion_profile_parameter - [in]
brep_form - [in]
brep created by ON_Extrusion::BrepForm()
bSmoothFaces - [in]
If true and the profiles have kinks, then the faces corresponding
to those profiles are split so they will be G1.
brep_ci - [out]
profile_subdomain - [out]
The subdomain of the profile that contributes to the brep form component index
Returns:
True if successful. False if input is not valid, in which case brep_ci
is set by calling ON_COMPONENT_INDEX::UnSet().
Remarks:
If the wall surfaces have creases, then this function cannot
be used to identify brep components created by BrepForm(...,true).
*/
bool GetBrepFormComponentIndex(
ON_COMPONENT_INDEX extrusion_ci,
ON_COMPONENT_INDEX& brep_ci
) const;
bool GetBrepFormComponentIndex(
ON_COMPONENT_INDEX extrusion_ci,
double extrusion_profile_parameter,
const ON_Brep& brep_form,
ON_COMPONENT_INDEX& brep_ci
) const;
bool GetBrepFormComponentIndex(
ON_COMPONENT_INDEX extrusion_ci,
double extrusion_profile_parameter,
const ON_Brep* brep_form,
ON_COMPONENT_INDEX& brep_ci
) const;
bool GetBrepFormComponentIndex(
ON_COMPONENT_INDEX extrusion_ci,
double extrusion_profile_parameter,
const ON_Brep* brep_form,
bool bSmoothFaces,
ON_COMPONENT_INDEX& brep_ci,
ON_Interval* profile_subdomain
) const;
////////////////////////////////////////////////////////////
//
// overrides of virtual ON_Surface functions
//
bool SetDomain(
int dir,
double t0,
double t1
) override;
ON_Interval Domain(
int dir
) const override;
bool GetSurfaceSize(
double* width,
double* height
) const override;
int SpanCount(
int dir
) const override;
bool GetSpanVector(
int dir,
double* span_vector
) const override;
bool GetSpanVectorIndex(
int dir,
double t,
int side,
int* span_vector_index,
ON_Interval* span_interval
) const override;
int Degree(
int dir
) const override;
bool GetParameterTolerance(
int dir,
double t,
double* tminus,
double* tplus
) const override;
ISO IsIsoparametric(
const ON_Curve& curve,
const ON_Interval* curve_domain = nullptr
) const override;
bool IsPlanar(
ON_Plane* plane = nullptr,
double tolerance = ON_ZERO_TOLERANCE
) const override;
bool IsClosed(
int
) const override;
bool IsPeriodic(
int
) const override;
bool GetNextDiscontinuity(
int dir,
ON::continuity c,
double t0,
double t1,
double* t,
int* hint=nullptr,
int* dtype=nullptr,
double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
double curvature_tolerance=ON_SQRT_EPSILON
) const override;
bool IsContinuous(
ON::continuity c,
double s,
double t,
int* hint = nullptr,
double point_tolerance=ON_ZERO_TOLERANCE,
double d1_tolerance=ON_ZERO_TOLERANCE,
double d2_tolerance=ON_ZERO_TOLERANCE,
double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
double curvature_tolerance=ON_SQRT_EPSILON
) const override;
ISO IsIsoparametric(
const ON_BoundingBox& bbox
) const override;
bool Reverse( int dir ) override;
bool Transpose() override;
bool Evaluate(
double u, double v,
int num_der,
int array_stride,
double* der_array,
int quadrant = 0,
int* hint = 0
) const override;
ON_Curve* IsoCurve(
int dir,
double c
) const override;
bool Trim(
int dir,
const ON_Interval& domain
) override;
bool Extend(
int dir,
const ON_Interval& domain
) override;
bool Split(
int dir,
double c,
ON_Surface*& west_or_south_side,
ON_Surface*& east_or_north_side
) const override;
//ON_Surface* Offset(
// double offset_distance,
// double tolerance,
// double* max_deviation = nullptr
// ) const;
int GetNurbForm(
ON_NurbsSurface& nurbs_surface,
double tolerance = 0.0
) const override;
int HasNurbForm() const override;
bool GetSurfaceParameterFromNurbFormParameter(
double nurbs_s, double nurbs_t,
double* surface_s, double* surface_t
) const override;
bool GetNurbFormParameterFromSurfaceParameter(
double surface_s, double surface_t,
double* nurbs_s, double* nurbs_t
) const override;
////////////////////////////////////////////////////////////
//
// ON_Extrusion mesh interface
//
/*
Description:
Attach a mesh to the ON_Extrusion.
Parameters:
mt - [in]
type of mesh that is being attached.
If mt is ON::render_mesh, ON::analysis_mesh or ON::preview_mesh,
the mesh is attached as that type of mesh.
If mt is ON::default_mesh or ON::any_mesh, then
nothing is done and false is returned.
mesh - [in]
* mesh to attach.
* mesh must be on the heap because ~ON_Extrusion()
will delete it.
* if there is already of mesh of the prescribed type,
it will be deleted.
* if mesh is null, any existing mesh is deleted and
nothing is attached.
*/
bool SetMesh( ON::mesh_type mt, ON_Mesh* mesh );
/*
Description:
Get a mesh attached to the ON_Extrusion.
Parameters:
mt - [in]
type of mesh to get.
ON::render_mesh, ON::analysis_mesh and ON::preview_mesh
remove the meshes of those types.
If mt is ON::default_mesh or ON::any_mesh, then
the first non null mesh is returned.
Returns:
A pointer to a mesh on the ON_Extrusion object.
This mesh will be deleted by ~ON_Extrusion().
If a mesh of the requested type is not available,
then null is returned.
*/
const ON_Mesh* Mesh( ON::mesh_type mt ) const;
/*
Description:
Destroy a mesh attached to the ON_Extrusion.
Parameters:
mt - [in] type of mesh to destroy
If mt is ON::default_mesh or ON::any_mesh, then
all attached meshes of all types are destroyed.
bDeleteMesh - [in] if true, cached mesh is deleted.
If false, pointer to cached mesh is just set to null.
*/
void DestroyMesh( ON::mesh_type mt );
////////////////////////////////////////////////////////////
//
// ON_Extrusion interface
//
void Destroy();
/*
Description:
Sets m_path to (A,B), m_path_domain to [0,Length(AB)],
and m_t to [0,1].
Parameters:
A - [in] path start
B - [in] path end
Returns:
true A and B are valid, the distance from A to B is larger
than ON_ZERO_TOLERANCE, and the path was set.
false A or B is not valid or the distance from A to B is
at most ON_ZERO_TOLERANCE. In this case nothing is set.
Remark:
You must also set the up direction to be perpendicular to the path.
*/
bool SetPath(ON_3dPoint A, ON_3dPoint B);
/*
Description:
Sets m_path to (A,B), m_path_domain to [0,Length(AB)],
m_t to [0,1], and m_up.
Parameters:
A - [in] path start
B - [in] path end
up - [in] up direction
If up is a unit vector and perpendicular to the line
segment from A to B, then m_up is set to up.
Otherwise up will be adjusted so it is perpendicular
to the line segment from A to B and unitized.
Returns:
true A and B are valid, the distance from A to B is larger
than ON_ZERO_TOLERANCE, and the path was set.
false A or B is not valid, or the distance from A to B is
at most ON_ZERO_TOLERANCE, or up is invalid, or up
is zero, or up is parallel to the line segment.
In this case nothing is set.
*/
bool SetPathAndUp(ON_3dPoint A, ON_3dPoint B, ON_3dVector up );
/*
Description:
Get the surface parameter for the path.
Returns:
0: The first surface parameter corresponds to the path direction.
(m_bTransposed = true)
1: The second surface parameter corresponds to the path direction.
(m_bTransposed = false)
Remarks:
The default ON_Extrusion constructor sets
m_bTransposed = false which corresponds to the 1 = PathParameter().
*/
int PathParameter() const;
ON_3dPoint PathStart() const;
ON_3dPoint PathEnd() const;
ON_3dVector PathTangent() const;
/*
Description:
Set miter plane normal.
Parameters:
N - [in] If N = ON_3dVector::UnsetVector or N is parallel to the z-axis,
then the miter plane is the default plane
perpendicular to the path.
If N is valid and the z coordinate of a unitized
N is greater than m_Nz_tol, then the miter plane
normal is set.
end - [in] 0 = set miter plane at the start of the path.
1 = set miter plane at the end of the path.
*/
bool SetMiterPlaneNormal(ON_3dVector N, int end);
void GetMiterPlaneNormal(int end, ON_3dVector& N) const;
/*
Returns:
0: not mitered.
1: start of path is mitered.
2: end of path is mitered.
3: start and end are mitered.
*/
int IsMitered() const;
/*
Returns:
True if extrusion object is a capped solid.
*/
bool IsSolid() const;
/*
Returns:
0: no or profile is open
1: bottom cap
2: top cap
3: both ends capped.
*/
int IsCapped() const;
/*
Returns:
0: no caps
1: extrusion has either a top cap or a bottom cap
2: both ends are capped.
See Also:
ON_Extrusion::ProfileCount()
ON_Extrusion::ProfileSmoothSegmentCount()
*/
int CapCount() const;
/*
Description:
Deprecated function.
Use CapCount() to determine how many end caps there are.
Use ProfileCount() to determine how many profiles there are.
Use ProfileSmoothSegmentCount() to determine how many
smooth subsegments are in a profile. Each smooth subsegment
becomes a wall face in the brep form.
Returns:
Number of "faces" the extrusion has.
0: extrusion is not valid
1: extrusion is not capped
2: extrusion has a closed outer profile and one cap
3: extrusion has a closed outer profile and two caps
Remarks:
This function was written before extrusions supported "holes"
and before the brep form was divided at profile creases.
At this point it simply leads to confusion. See the Description
function replacements.
*/
ON_DEPRECATED_MSG("Use CapCount(), ProfileCount(), or ProfileSmoothSegmentCount()")
int FaceCount() const;
/*
Description:
Get the transformation that maps the xy profile curve
to its 3d location.
Parameters:
s - [in] 0.0 = starting profile
1.0 = ending profile
*/
bool GetProfileTransformation( double s, ON_Xform& xform ) const;
/*
Description:
Get the the 3d plane containing the profile curve at a
normalized path parameter.
Parameters:
s - [in] 0.0 = starting plane
1.0 = ending plane
plane - [out]
Plane containing profile is returned in plane. If
false is returned, then the input value of plane
is not changed.
Returns:
true if plane was set. False if this is invalid and plane
could not be set.
Remarks:
When no mitering is happening, GetPathPlane() and
GetProfilePlane() return the same plane.
*/
bool GetProfilePlane( double s, ON_Plane& plane ) const;
/*
Description:
Get the the 3d plane perpendicular to the path at a
normalized path parameter.
Parameters:
s - [in] 0.0 = starting plane
1.0 = ending plane
plane - [out]
Plane is returned here. If
false is returned, then the input value of plane
is not changed.
Returns:
true if plane was set. False if this is invalid and plane
could not be set.
Remarks:
When no mitering is happening, GetPathPlane() and
GetProfilePlane() return the same plane.
*/
bool GetPathPlane( double s, ON_Plane& plane ) const;
/*
Description:
Set the outer profile of the extrusion.
Parameters:
outer_profile - [in]
curve in the xy plane or a 2d curve.
bCap - [in]
If outer_profile is a closed curve, then bCap
determines if the extrusion has end caps.
If outer_profile is an open curve, bCap is ignored.
Returns:
True if the profile was set. In this case the ON_Extrusion class
manages the curve and ~ON_Extrusion will delete it. If the outer
profile is closed, then the extrusion may also have inner profiles.
If the outer profile is open, the extrusion may not have inner
profiles. If the extrusion already has a profile, the set will
fail.
Remarks:
If needed, outer_profile will be converted to a 2d
curve. If outer_curve is closed but not correctly oriented,
it will reversed so it has a counter-clockwise orientation.
*/
bool SetOuterProfile( ON_Curve* outer_profile, bool bCap );
/*
Description:
Add an inner profile.
Parameters:
inner_profile - [in]
closed curve in the xy plane or a 2d curve.
Returns:
True if the profile was set. In this case the
ON_Extrusion class manages the curve and ~ON_Extrusion will
delete it. The extrusion must already have an outer profile.
If the extrusion already has a profile, the set will
fail.
Remarks:
If needed, inner_profile will be converted to a 2d
curve. If inner_profile is not correctly oriented, it
will be reversed so it has a clockwise orientation.
*/
bool AddInnerProfile( ON_Curve* inner_profile );
/*
Returns:
Number of profile curves.
See Also:
ON_Extrusion::CapCount()
ON_Extrusion::ProfileSmoothSegmentCount()
*/
int ProfileCount() const;
/*
Parameter:
profile_index - [in]
0 <= profile_index < ProfileCount().
The outer profile has index 0.
Returns:
Number of smooth segments in the profile curve.
See Also:
ON_Extrusion::CapCount()
ON_Extrusion::GetProfileKinkParameters()
ON_Extrusion::ProfileCount()
*/
int ProfileSmoothSegmentCount( int profile_index ) const;
/*
Description:
Get the surface parameter for the profile.
Returns:
0: The first surface parameter corresponds to the profile direction.
(m_bTransposed = false)
1: The second surface parameter corresponds to the profile direction.
(m_bTransposed = true)
Remarks:
The default ON_Extrusion constructor sets
m_bTransposed = false which corresponds to the 0 = ProfileParameter().
*/
int ProfileParameter() const;
/*
Parameters:
profile_index - [in]
0 <= profile_index < ProfileCount().
The outer profile has index 0.
Returns:
Pointer to the i-th 2d profile. The ON_Extrusion
class manages this curve. Do not delete it
and do not use the pointer if the ON_Extrusion
class changes.
*/
const ON_Curve* Profile(int profile_index) const;
/*
Parameters:
profile_index - [in]
0 <= profile_index < ProfileCount().
The outer profile has index 0.
s - [in] ( 0.0 <= s <= 1.0 )
A relative parameter controlling which profile
is returned. s = 0.0 returns the bottom profile
and s = 1.0 returns the top profile.
Returns:
nullptr if the input parameters or the ON_Extrusion class is
not valid. Otherwise a pointer to a 3d curve for
the requested profile. This curve is on the heap and
the caller is responsible for deleting this curve.
*/
ON_Curve* Profile3d(int profile_index, double s ) const;
/*
Parameters:
ci - [in]
component index identifying a 3d extrusion profile curve.
Returns:
nullptr if the component index or the ON_Extrusion class is
not valid. Otherwise a pointer to a 3d curve for
the requested profile. This curve is on the heap and
the caller is responsible for deleting this curve.
*/
ON_Curve* Profile3d( ON_COMPONENT_INDEX ci ) const;
/*
Parameters:
ci - [in]
component index identifying a wall edge curve.
Returns:
nullptr if the component index or the ON_Extrusion class is
not valid. Otherwise a pointer to a 3d curve for
the requested wall edge. This curve is on the heap and
the caller is responsible for deleting this curve.
*/
ON_Curve* WallEdge( ON_COMPONENT_INDEX ci ) const;
/*
Parameters:
ci - [in]
component index identifying a wall surface.
Returns:
nullptr if the component index or the ON_Extrusion class is
not valid. Otherwise a pointer to a surface for
the requested wall surface. This curve is on the heap and
the caller is responsible for deleting this curve.
*/
ON_Surface* WallSurface( ON_COMPONENT_INDEX ci ) const;
/*
Parameters:
line_curve - [in]
If null, a line curve will be allocated using new.
Returns:
Null if the extrusion path is not valid. Otherwise
a pointer to an ON_LineCurve that is set to the
extrusion's path. The caller must delete this curve.
*/
ON_LineCurve* PathLineCurve(ON_LineCurve* line_curve) const;
/*
Parameters:
profile_parameter - [in]
parameter on profile curve
Returns:
-1: if the profile_parameter does not correspond
to a point on the profile curve.
>= 0: index of the profile curve with domain containing
this parameter. When the profile_parameter corresponds
to the end of one profile and the beginning of the next
profile, the index of the next profile is returned.
*/
int ProfileIndex( double profile_parameter ) const;
/*
Returns:
If m_profile_count >= 2 and m_profile is an ON_PolyCurve
with m_profile_count segments defining outer and inner
profiles, a pointer to the polycurve is returned.
Otherwise null is returned.
*/
const ON_PolyCurve* PolyProfile() const;
/*
Description:
Get a list of the 2d profile curves.
Returns:
Number of curves appended to the list.
*/
int GetProfileCurves( ON_SimpleArray<const ON_Curve*>& profile_curves ) const;
/*
Description:
Get the parameters where a profile curve has kinks.
Parameters:
profile_index - [in]
profile_kink_parameters - [out]
parameters at internal kinks are appended to this array.
Returns:
Number of parameters appended to profile_kink_parameters[]
Remarks:
This function is used when making the brep form that has
smooth faces.
*/
int GetProfileKinkParameters( int profile_index, ON_SimpleArray<double>& profile_kink_parameters ) const;
int GetProfileKinkParameters( int profile_index, ON_SimpleArray<double>* profile_kink_parameters ) const;
/*
Parameters:
profile_index - [in]
Returns:
True if the profile has at least one kink.
*/
bool ProfileIsKinked( int profile_index ) const;
/*
Description:
Test a polycurve to determine if it meets the necessary
conditions to be used as a multi-segment profile in a extrusion.
Returns:
True if the returned polycurve can be used a a multi-segment
profile in a extrusion.
*/
static bool IsValidPolyCurveProfile( const ON_PolyCurve& polycurve, ON_TextLog* text_log = 0 );
/*
Description:
If possible, modify a polycurve so it meets the necessary conditions
to be used as a multi-segment profile in a extrusion.
Returns:
True if the returned polycurve can be used a a multi-segment
profile in a extrusion.
*/
static bool CleanupPolyCurveProfile( ON_PolyCurve& polycurve );
// path definition:
// The line m_path must have length > m_path_length_min.
// The interval m_t must satisfy 0 <= m_t[0] < m_t[1] <= 1.
// The extrusion starts at m_path.PointAt(m_t[0]) and ends
// at m_path.PointAt(m_t[1]).
// The "up" direction m_up is a unit vector that must
// be perpendicular to m_path.Tangent().
ON_Line m_path;
ON_Interval m_t;
ON_3dVector m_up;
// profile information:
// In general, use SetOuterProfile() and AddInnerProfile()
// to set m_profile_count and m_profile. If you are
// a glutton for punishment, then you might be interested
// in the following.
// The profile curves must be in the x-y plane.
// The profile's "y" axis corresponds to m_up.
// The point (0,0) is extruded along the m_path line.
// If m_profile_count = 1, then m_profile can be any
// type of continuous curve. If m_profile_count > 1,
// then m_profile must be an ON_PolyCurve with
// m_profile_count segments, the domain of each segment
// must exactly match the polycurve's segment domain,
// every segment must be continuous and closed,
// the first segment curve must have counter-clockwise
// orientation, and the rest must have clockwise
// orientations.
int m_profile_count;
ON_Curve* m_profile;
// capped end information:
// If the profile is closed, then m_bCap[] determines
// if the ends are capped.
bool m_bCap[2];
// mitered end information:
// The normals m_N[] are with respect to the xy plane.
// A normal parallel to the z axis has no mitering.
// If m_bHaveN[i] is true, then m_N[i] must be a 3d unit
// vector with m_N[i].z > m_Nz_tol; If m_bHaveN[i]
// is false, then m_N[i] is ignored. The normal m_N[0]
// defines the start miter plane and m_N[1] defines the
// end miter plane.
bool m_bHaveN[2];
ON_3dVector m_N[2];
// Surface parameterization information
ON_Interval m_path_domain;
bool m_bTransposed; // false: (s,t) = (profile,path)
// The z coordinates of miter plane normals must be
// greater than m_Nz_tol
static const double m_Nz_min; // 1/64;
// The length of the m_path line must be greater than
// m_path_length_min
static const double m_path_length_min; // ON_ZERO_TOLERANCE;
// Cached meshes used for rendering, analysis, ...
mutable ON_MeshCache m_mesh_cache = ON_MeshCache::Empty;
/*
Description:
Get an ON_Extrusion form of a cylinder.
Parameters:
cylinder - [in] cylinder.IsFinite() must be true
bCapBottom - [in] if true, the end at cylinder.m_height[0] will be capped
bCapTop - [in] if true, the end at cylinder.m_height[1] will be capped
extrusion - [in]
If the input extrusion pointer is null, one will be allocated on the heap
and it is the caller's responsibility to delete it at an appropriate time.
If the input pointer is not null, this extrusion will be used and the same
pointer will be returned, provided the input is valid.
Returns:
If the input is valid, a pointer to an ON_Extrusion form of the cylinder.
If the input is not valid, then null, even when the input extrusion
object is not null.
Example:
ON_Cylinder cylinder = ...;
bool bCapBottom = true;
bool bCapTop = true;
ON_Extrusion extrusion;
if ( 0 == ON_Extrusion::Cylinder(cylinder,bCapBottom,bCapTop,&extrusion) )
{
// input is not valid - nothing set
...
}
else
{
// extrusion = cylinder
...
}
*/
static ON_Extrusion* Cylinder(
const ON_Cylinder& cylinder,
bool bCapBottom,
bool bCapTop,
ON_Extrusion* extrusion = 0
);
/*
Description:
Get an ON_Extrusion form of a pipe.
Parameters:
cylinder - [in] cylinder.IsFinite() must be true
The cylinder can be either the inner or outer wall of the pipe.
other_radius - [in] ( != cylinder.Radius() )
If cylinder.Radius() < other_radius, then the cylinder will be
the inside of the pipe. If cylinder.Radius() > other_radius, then
the cylinder will be the outside of the pipe.
bCapBottom - [in] if true, the end at cylinder.m_height[0] will be capped
bCapTop - [in] if true, the end at cylinder.m_height[1] will be capped
extrusion - [in]
If the input extrusion pointer is null, one will be allocated on the heap
and it is the caller's responsibility to delete it at an appropriate time.
If the input pointer is not null, this extrusion will be used and the same
pointer will be returned, provided the input is valid.
Returns:
If the input is valid, a pointer to an ON_Extrusion form of the pipe.
If the input is not valid, then null, even when the input extrusion
object is not null.
Example:
ON_Cylinder cylinder = ...;
double other_radius = cylinder.Radius()+1.0;
bool bCapBottom = true;
bool bCapTop = true;
ON_Extrusion extrusion;
if ( 0 == ON_Extrusion::Pipe(cylinder,other_radius,bCapBottom,bCapTop,&extrusion) )
{
// input is not valid - nothing set
...
}
else
{
// extrusion = pipe
...
}
*/
static ON_Extrusion* Pipe(
const ON_Cylinder& cylinder,
double other_radius,
bool bCapBottom,
bool bCapTop,
ON_Extrusion* extrusion = 0
);
/*
Description:
Create an ON_Extrusion from a 3d curve, a plane and a height.
Parameters:
curve - [in]
A continuous 3d curve.
plane - [in]
If plane is null, then the plane returned by curve.IsPlanar() is used.
The 3d curve is projected to this plane and the result is passed to
ON_Extrusion::SetOuterProfile().
height - [in]
If the height > 0, the bottom of the extrusion will be in plane and
the top will be height units above the plane.
If the height < 0, the top of the extrusion will be in plane and
the bottom will be height units below the plane.
bCap - [in]
If the curve is closed and bCap is true, then the resulting extrusion
is capped.
extrusion - [in]
If the input extrusion pointer is null, one will be allocated on the heap
and it is the caller's responsibility to delete it at an appropriate time.
If the input pointer is not null, this extrusion will be used and the same
pointer will be returned, provided the input is valid.
Returns:
If the input is valid, a pointer to an ON_Extrusion form of the pipe.
If the input is not valid, then null, even when the input extrusion
object is not null.
*/
static ON_Extrusion* CreateFrom3dCurve(
const ON_Curve& curve,
const ON_Plane* plane,
double height,
bool bCap,
ON_Extrusion* extrusion = 0
);
};