opennurbs_beam.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2014 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_EXTRUSION_INC_)
18 #define OPENNURBS_EXTRUSION_INC_
19 
20 /*
21 Description:
22  Get the transformation that maps the ON_Extrusion
23  2d xy profile to 3d world space.
24 Parameters:
25  P - [in] start or end of path
26  T - [in] unit tanget to path
27  U - [in] unit up vector perpendicular to T
28  Normal - [in] optional unit vector with Normal->z > 0 that
29  defines the unit normal to the miter plane.
30  xform - [out]
31  transformation that maps the profile curve to 3d world space
32  scale2d - [out]
33  If not nullptr, this is the scale part of the transformation.
34  If there is no mitering, then this is the identity.
35  rot2d - [out]
36  If not null, this is the part of the transformation
37  that rotates the xy plane into its 3d world location.
38 Returns:
39  true if successful.
40 */
41 ON_DECL
42 bool ON_GetEndCapTransformation(
43  ON_3dPoint P,
44  ON_3dVector T,
45  ON_3dVector U,
46  const ON_3dVector* Normal,
47  ON_Xform& xform, // = rot3d*scale2d
48  ON_Xform* scale2d,
49  ON_Xform* rot2d
50  );
51 
52 class ON_CLASS ON_Extrusion : public ON_Surface
53 {
54  ON_OBJECT_DECLARE(ON_Extrusion);
55 public:
56  ON_Extrusion();
57  ON_Extrusion(const ON_Extrusion& src);
58  ~ON_Extrusion();
59 
61 
62  ////////////////////////////////////////////////////////////
63  //
64  // overrides of virtual ON_Object functions
65  //
66  void DestroyRuntimeCache( bool bDelete = true ) override;
67 
68  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
69  void Dump( ON_TextLog& ) const override;
70  unsigned int SizeOf() const override;
71  ON__UINT32 DataCRC( ON__UINT32 current_remainder ) const override;
72  bool Write( ON_BinaryArchive& binary_archive) const override;
73  bool Read( ON_BinaryArchive& binary_archive ) override;
74  ON::object_type ObjectType() const override;
75 
76  ////////////////////////////////////////////////////////////
77  //
78  // overrides of virtual ON_Geometry functions
79  //
80  int Dimension() const override;
81 
82  // virtual ON_Geometry GetBBox override
83  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
84 
85  // virtual ON_Geometry GetTightBoundingBox override
86  bool GetTightBoundingBox( class ON_BoundingBox& tight_bbox, bool bGrowBox = false, const class ON_Xform* xform = nullptr ) const override;
87 
88  bool Transform(
89  const ON_Xform& xform
90  ) override;
91 
92  /*
93  Description:
94  Build a brep form of the extrusion. The outer profile is always
95  the first face in the brep. If there are inner profiles,
96  additional brep faces are created for each profile. If the
97  outer profile is closed, then end caps are added as the last
98  two faces in the brep.
99  Parameters:
100  brep - [in]
101  If the brep pointer is not null, then the brep form is constructed
102  in brep. If the brep pointer is null, then an ON_Brep is allocated
103  on the heap.
104  Returns:
105  If successful, a pointer to the brep form. If unsuccessful, null.
106  */
107  ON_Brep* BrepForm(
108  ON_Brep* brep = nullptr
109  ) const override;
110 
111  /*
112  Description:
113  Build a brep form of the extrusion. The outer profile is always
114  the first face in the brep. If there are inner profiles,
115  additional brep faces are created for each profile. If the
116  outer profile is closed, then end caps are added as the last
117  two faces in the brep.
118  Parameters:
119  brep - [in]
120  If the brep pointer is not null, then the brep form is constructed
121  in brep. If the brep pointer is null, then an ON_Brep is allocated
122  on the heap.
123  bSmoothFaces - [in]
124  If true and the profiles have kinks, then the faces corresponding
125  to those profiles are split so they will be G1.
126  Returns:
127  If successful, a pointer to the brep form. If unsuccessful, null.
128  */
129  ON_Brep* BrepForm(
130  ON_Brep* brep,
131  bool bSmoothFaces
132  ) const;
133 
134  /*
135  Description:
136  Build a sum surface form of the extrusion.
137  Parameters:
138  sum_surface - [in]
139  If the sum_surface pointer is not null, then the sum surface
140  form is constructed in sum_surface. If the sum_surface pointer
141  is null, then an ON_SumSurface is allocated on the heap.
142  Returns:
143  If successful, a pointer to the sum surface form.
144  If unsuccessful, null. In particular, extrusions with
145  mitered ends do not have sum surface forms.
146  */
147  ON_SumSurface* SumSurfaceForm(
148  ON_SumSurface* sum_surface
149  ) const;
150 
151  /*
152  Description:
153  Convert a component index that identifies a part of this extrusion
154  to a component index that identifies a part of the brep created
155  by BrepForm(...,false).
156  Parameters:
157  extrusion_ci - [in]
158  extrusion_profile_parameter - [in]
159  brep_form - [in]
160  brep created by ON_Extrusion::BrepForm()
161  brep_ci - [out]
162  Returns:
163  True if successful. False if input is not valid, in which case brep_ci
164  is set by calling ON_COMPONENT_INDEX::UnSet().
165  Remarks:
166  If the wall surfaces have creases, then this function cannot
167  be used to identify brep components created by BrepForm(...,true).
168  */
169  bool GetBrepFormComponentIndex(
170  ON_COMPONENT_INDEX extrusion_ci,
171  ON_COMPONENT_INDEX& brep_ci
172  ) const;
173 
174  bool GetBrepFormComponentIndex(
175  ON_COMPONENT_INDEX extrusion_ci,
176  double extrusion_profile_parameter,
177  const ON_Brep& brep_form,
178  ON_COMPONENT_INDEX& brep_ci
179  ) const;
180 
181  bool GetBrepFormComponentIndex(
182  ON_COMPONENT_INDEX extrusion_ci,
183  double extrusion_profile_parameter,
184  const ON_Brep* brep_form,
185  ON_COMPONENT_INDEX& brep_ci
186  ) const;
187 
188  ////////////////////////////////////////////////////////////
189  //
190  // overrides of virtual ON_Surface functions
191  //
192 
193  bool SetDomain(
194  int dir,
195  double t0,
196  double t1
197  ) override;
199  int dir
200  ) const override;
201  bool GetSurfaceSize(
202  double* width,
203  double* height
204  ) const override;
205  int SpanCount(
206  int dir
207  ) const override;
208  bool GetSpanVector(
209  int dir,
210  double* span_vector
211  ) const override;
212  bool GetSpanVectorIndex(
213  int dir,
214  double t,
215  int side,
216  int* span_vector_index,
217  ON_Interval* span_interval
218  ) const override;
219  int Degree(
220  int dir
221  ) const override;
223  int dir,
224  double t,
225  double* tminus,
226  double* tplus
227  ) const override;
229  const ON_Curve& curve,
230  const ON_Interval* curve_domain = nullptr
231  ) const override;
232  bool IsPlanar(
233  ON_Plane* plane = nullptr,
234  double tolerance = ON_ZERO_TOLERANCE
235  ) const override;
236  bool IsClosed(
237  int
238  ) const override;
239  bool IsPeriodic(
240  int
241  ) const override;
242  bool GetNextDiscontinuity(
243  int dir,
244  ON::continuity c,
245  double t0,
246  double t1,
247  double* t,
248  int* hint=nullptr,
249  int* dtype=nullptr,
250  double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
251  double curvature_tolerance=ON_SQRT_EPSILON
252  ) const override;
253  bool IsContinuous(
254  ON::continuity c,
255  double s,
256  double t,
257  int* hint = nullptr,
258  double point_tolerance=ON_ZERO_TOLERANCE,
259  double d1_tolerance=ON_ZERO_TOLERANCE,
260  double d2_tolerance=ON_ZERO_TOLERANCE,
261  double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
262  double curvature_tolerance=ON_SQRT_EPSILON
263  ) const override;
265  const ON_BoundingBox& bbox
266  ) const override;
267  bool Reverse( int dir ) override;
268  bool Transpose() override;
269  bool Evaluate(
270  double u, double v,
271  int num_der,
272  int array_stride,
273  double* der_array,
274  int quadrant = 0,
275  int* hint = 0
276  ) const override;
278  int dir,
279  double c
280  ) const override;
281 
282 
283  bool Trim(
284  int dir,
285  const ON_Interval& domain
286  ) override;
287  bool Extend(
288  int dir,
289  const ON_Interval& domain
290  ) override;
291  bool Split(
292  int dir,
293  double c,
294  ON_Surface*& west_or_south_side,
295  ON_Surface*& east_or_north_side
296  ) const override;
297 
298 
299  //ON_Surface* Offset(
300  // double offset_distance,
301  // double tolerance,
302  // double* max_deviation = nullptr
303  // ) const;
304 
305  int GetNurbForm(
306  ON_NurbsSurface& nurbs_surface,
307  double tolerance = 0.0
308  ) const override;
309  int HasNurbForm() const override;
311  double nurbs_s, double nurbs_t,
312  double* surface_s, double* surface_t
313  ) const override;
315  double surface_s, double surface_t,
316  double* nurbs_s, double* nurbs_t
317  ) const override;
318 
319 
320  ////////////////////////////////////////////////////////////
321  //
322  // ON_Extrusion mesh interface
323  //
324 
325  /*
326  Description:
327  Attach a mesh to the ON_Extrusion.
328  Parameters:
329  mt - [in]
330  type of mesh that is being attached.
331  If mt is ON::render_mesh, ON::analysis_mesh or ON::preview_mesh,
332  the mesh is attached as that type of mesh.
333  If mt is ON::default_mesh or ON::any_mesh, then
334  nothing is done and false is returned.
335  mesh - [in]
336  * mesh to attach.
337  * mesh must be on the heap because ~ON_Extrusion()
338  will delete it.
339  * if there is already of mesh of the prescribed type,
340  it will be deleted.
341  * if mesh is null, any existing mesh is deleted and
342  nothing is attached.
343  Remarks:
344  DEPRECATED. Use ON_Extrusion.m_mesh_cache to managed chached meshes.
345  */
346  ON_DEPRECATED_MSG("Use ON_Extrusion.m_mesh_cache to managed chached meshes")
347  bool SetMesh( ON::mesh_type mt, ON_Mesh* mesh );
348 
349  /*
350  Description:
351  Get a mesh attached to the ON_Extrusion.
352  Parameters:
353  mt - [in]
354  type of mesh to get.
355  ON::render_mesh, ON::analysis_mesh and ON::preview_mesh
356  remove the meshes of those types.
357  If mt is ON::default_mesh or ON::any_mesh, then
358  the first non null mesh is returned.
359  Returns:
360  A pointer to a mesh on the ON_Extusion object.
361  This mesh will be deleted by ~ON_Extrusion().
362  If a mesh of the requested type is not available,
363  then null is returned.
364  Remarks:
365  DEPRECATED. Use ON_Extrusion.m_mesh_cache to managed chached meshes.
366  */
367  ON_DEPRECATED_MSG("Use ON_Extrusion.m_mesh_cache to managed chached meshes")
368  const ON_Mesh* Mesh( ON::mesh_type mt ) const;
369 
370  /*
371  Description:
372  Destroy a mesh attached to the ON_Extrusion.
373  Parameters:
374  mt - [in] type of mesh to destroy
375  If mt is ON::default_mesh or ON::any_mesh, then
376  all attached meshes of all types are destroyed.
377  bDeleteMesh - [in] if true, cached mesh is deleted.
378  If false, pointer to cached mesh is just set to null.
379  Remarks:
380  DEPRECATED. Use ON_Extrusion.m_mesh_cache to managed chached meshes.
381  */
382  ON_DEPRECATED_MSG("Use ON_Extrusion.m_mesh_cache to managed chached meshes")
383  void DestroyMesh( ON::mesh_type mt );
384 
385  ////////////////////////////////////////////////////////////
386  //
387  // ON_Extrusion interface
388  //
389  void Destroy();
390 
391  /*
392  Description:
393  Sets m_path to (A,B), m_path_domain to [0,Length(AB)],
394  and m_t to [0,1].
395  Parameters:
396  A - [in] path start
397  B - [in] path end
398  Returns:
399  true A and B are valid, the distance from A to B is larger
400  than ON_ZERO_TOLERANCE, and the path was set.
401  false A or B is not valid or the distance from A to B is
402  at most ON_ZERO_TOLERANCE. In this case nothing is set.
403  Remark:
404  You must also set the up direction to be perpendicular to the path.
405  */
406  bool SetPath(ON_3dPoint A, ON_3dPoint B);
407 
408  /*
409  Description:
410  Sets m_path to (A,B), m_path_domain to [0,Length(AB)],
411  m_t to [0,1], and m_up.
412  Parameters:
413  A - [in] path start
414  B - [in] path end
415  up - [in] up direction
416  If up is a unit vector and perpendicular to the line
417  segment from A to B, then m_up is set to up.
418  Otherwise up will be adjusted so it is perpendicular
419  to the line segment from A to B and unitized.
420  Returns:
421  true A and B are valid, the distance from A to B is larger
422  than ON_ZERO_TOLERANCE, and the path was set.
423  false A or B is not valid, or the distance from A to B is
424  at most ON_ZERO_TOLERANCE, or up is invalid, or up
425  is zero, or up is parallel to the line segment.
426  In this case nothing is set.
427  */
428  bool SetPathAndUp(ON_3dPoint A, ON_3dPoint B, ON_3dVector up );
429 
430  /*
431  Description:
432  Get the surface parameter for the path.
433  Returns:
434  0: The first surface parameter corresponds to the path direction.
435  (m_bTransposed = true)
436  1: The second surface parameter corresponds to the path direction.
437  (m_bTransposed = false)
438  Remarks:
439  The default ON_Extrusion constructor sets
440  m_bTransposed = false which corresponds to the 1 = PathParameter().
441  */
442  int PathParameter() const;
443 
444  ON_3dPoint PathStart() const;
445  ON_3dPoint PathEnd() const;
446  ON_3dVector PathTangent() const;
447 
448  /*
449  Description:
450  Set miter plane normal.
451  Parameters:
452  N - [in] If N = ON_3dVector::UnsetVector or N is parallel to the z-axis,
453  then the miter plane is the default plane
454  perpendicular to the path.
455  If N is valid and the z coordinate of a unitized
456  N is greater than m_Nz_tol, then the miter plane
457  normal is set.
458  end - [in] 0 = set miter plane at the start of the path.
459  1 = set miter plane at the end of the path.
460  */
461  bool SetMiterPlaneNormal(ON_3dVector N, int end);
462 
463  void GetMiterPlaneNormal(int end, ON_3dVector& N) const;
464 
465  /*
466  Returns:
467  0: not mitered.
468  1: start of path is mitered.
469  2: end of path is mitered.
470  3: start and end are mitered.
471  */
472  int IsMitered() const;
473 
474  /*
475  Returns:
476  True if extrusion object is a capped solid.
477  */
478  bool IsSolid() const;
479 
480  /*
481  Returns:
482  0: no or profile is open
483  1: bottom cap
484  2: top cap
485  3: both ends capped.
486  */
487  int IsCapped() const;
488 
489  /*
490  Returns:
491  0: no caps
492  1: exrusion has either a top cap or a bottom cap
493  2: both ends are capped.
494  See Also:
495  ON_Extrusion::ProfileCount()
496  ON_Extrusion::ProfileSmoothSegmentCount()
497  */
498  int CapCount() const;
499 
500  /*
501  Description:
502  Deprecated function.
503 
504  Use CapCount() to determine how many end caps there are.
505  Use ProfileCount() to determine how many profiles there are.
506  Use ProfileSmoothSegmentCount() to determine how many
507  smooth subsegments are in a profile. Each smooth subsegment
508  becomes a wall face in the brep form.
509 
510  Returns:
511  Number of "faces" the extrusion has.
512  0: extrusion is not valid
513  1: extrusion is not capped
514  2: extrusion has a closed outer profile and one cap
515  3: extrusion has a closed outer profile and two caps
516 
517  Remarks:
518  This function was written before extrusions supported "holes"
519  and before the brep form was divided at profile creases.
520  At this point it simply leads to confusion. See the Description
521  function replacements.
522  */
523  ON_DEPRECATED_MSG("Use CapCount(), ProfileCount(), or ProfileSmoothSegmentCount()")
524  int FaceCount() const;
525 
526  /*
527  Description:
528  Get the transformation that maps the xy profile curve
529  to its 3d location.
530  Parameters:
531  s - [in] 0.0 = starting profile
532  1.0 = ending profile
533  */
534  bool GetProfileTransformation( double s, ON_Xform& xform ) const;
535 
536  /*
537  Description:
538  Get the the 3d plane containing the profile curve at a
539  normalized path parameter.
540  Parameters:
541  s - [in] 0.0 = starting plane
542  1.0 = ending plane
543  plane - [out]
544  Plane containing profile is returned in plane. If
545  false is returned, then the input value of plane
546  is not changed.
547  Returns:
548  true if plane was set. False if this is invalid and plane
549  could not be set.
550  Remarks:
551  When no mitering is happening, GetPathPlane() and
552  GetProfilePlane() return the same plane.
553  */
554  bool GetProfilePlane( double s, ON_Plane& plane ) const;
555 
556 
557  /*
558  Description:
559  Get the the 3d plane perpendicular to the path at a
560  normalized path parameter.
561  Parameters:
562  s - [in] 0.0 = starting plane
563  1.0 = ending plane
564  plane - [out]
565  Plane is returned here. If
566  false is returned, then the input value of plane
567  is not changed.
568  Returns:
569  true if plane was set. False if this is invalid and plane
570  could not be set.
571  Remarks:
572  When no mitering is happening, GetPathPlane() and
573  GetProfilePlane() return the same plane.
574  */
575  bool GetPathPlane( double s, ON_Plane& plane ) const;
576 
577  /*
578  Description:
579  Set the outer profile of the extrusion.
580  Paramters:
581  outer_profile - [in]
582  curve in the xy plane or a 2d curve.
583  bCap - [in]
584  If outer_profile is a closed curve, then bCap
585  determines if the extrusion has end caps.
586  If outer_profile is an open curve, bCap is ignored.
587  Returns:
588  True if the profile was set. In this case the ON_Extrusion class
589  manages the curve and ~ON_Extrusion will delete it. If the outer
590  profile is closed, then the extrusion may also have inner profiles.
591  If the outer profile is open, the extrusion may not have inner
592  profiles. If the extrusion already has a profile, the set will
593  fail.
594  Remarks:
595  If needed, outer_profile will be converted to a 2d
596  curve. If outer_curve is closed but not correctly oriented,
597  it will reversed so it has a counter-clockwise orientation.
598  */
599  bool SetOuterProfile( ON_Curve* outer_profile, bool bCap );
600 
601  /*
602  Description:
603  Add an inner profile.
604  Paramters:
605  inner_profile - [in]
606  closed curve in the xy plane or a 2d curve.
607  Returns:
608  True if the profile was set. In this case the
609  ON_Extrusion class manages the curve and ~ON_Extrusion will
610  delete it. The extrusion must already have an outer profile.
611  If the extrusion already has a profile, the set will
612  fail.
613  Remarks:
614  If needed, innter_profile will be converted to a 2d
615  curve. If inner_profile is not correctly oriented, it
616  will be reversed so it has a clockwise orientation.
617  */
618  bool AddInnerProfile( ON_Curve* inner_profile );
619 
620  /*
621  Returns:
622  Number of profile curves.
623  See Also:
624  ON_Extrusion::CapCount()
625  ON_Extrusion::ProfileSmoothSegmentCount()
626  */
627  int ProfileCount() const;
628 
629  /*
630  Parameter:
631  profile_index - [in]
632  0 <= profile_index < ProfileCount().
633  The outer profile has index 0.
634  Returns:
635  Number of smooth segments in the profile curve.
636  See Also:
637  ON_Extrusion::CapCount()
638  ON_Extrusion::GetProfileKinkParameters()
639  ON_Extrusion::ProfileCount()
640  */
641  int ProfileSmoothSegmentCount( int profile_index ) const;
642 
643  /*
644  Description:
645  Get the surface parameter for the profile.
646  Returns:
647  0: The first surface parameter corresponds to the profile direction.
648  (m_bTransposed = false)
649  1: The second surface parameter corresponds to the profile direction.
650  (m_bTransposed = true)
651  Remarks:
652  The default ON_Extrusion constructor sets
653  m_bTransposed = false which corresponds to the 0 = ProfileParameter().
654  */
655  int ProfileParameter() const;
656 
657  /*
658  Paramters:
659  profile_index - [in]
660  0 <= profile_index < ProfileCount().
661  The outer profile has index 0.
662  Returns:
663  Pointer to the i-th 2d profile. The ON_Extrusion
664  class manages this curve. Do not delete it
665  and do not use the pointer if the ON_Extrusion
666  class changes.
667  */
668  const ON_Curve* Profile(int profile_index) const;
669 
670  /*
671  Paramters:
672  profile_index - [in]
673  0 <= profile_index < ProfileCount().
674  The outer profile has index 0.
675  s - [in] ( 0.0 <= s <= 1.0 )
676  A relative parameter controling which priofile
677  is returned. s = 0.0 returns the bottom profile
678  and s = 1.0 returns the top profile.
679  Returns:
680  nullptr if the input parameters or the ON_Extrusion class is
681  not valid. Otherwise a pointer to a 3d curve for
682  the requested profile. This curve is on the heap and
683  the caller is responsible for deleting this curve.
684  */
685  ON_Curve* Profile3d(int profile_index, double s ) const;
686 
687  /*
688  Paramters:
689  ci - [in]
690  component index identifying a 3d extrusion profile curve.
691  Returns:
692  nullptr if the component index or the ON_Extrusion class is
693  not valid. Otherwise a pointer to a 3d curve for
694  the requested profile. This curve is on the heap and
695  the caller is responsible for deleting this curve.
696  */
697  ON_Curve* Profile3d( ON_COMPONENT_INDEX ci ) const;
698 
699  /*
700  Paramters:
701  ci - [in]
702  component index identifying a wall edge curve.
703  Returns:
704  nullptr if the component index or the ON_Extrusion class is
705  not valid. Otherwise a pointer to a 3d curve for
706  the requested wall edge. This curve is on the heap and
707  the caller is responsible for deleting this curve.
708  */
709  ON_Curve* WallEdge( ON_COMPONENT_INDEX ci ) const;
710 
711  /*
712  Paramters:
713  ci - [in]
714  component index identifying a wall surface.
715  Returns:
716  nullptr if the component index or the ON_Extrusion class is
717  not valid. Otherwise a pointer to a surface for
718  the requested wall surface. This curve is on the heap and
719  the caller is responsible for deleting this curve.
720  */
721  ON_Surface* WallSurface( ON_COMPONENT_INDEX ci ) const;
722 
723  /*
724  Paramters:
725  line_curve - [in]
726  If null, a line curve will be allocated using new.
727  Returns:
728  Null if the extrusion path is not valid. Otherwise
729  a pointer to an ON_LineCurve that is set to the
730  extrusion's path. The caller must delete this curve.
731  */
732  ON_LineCurve* PathLineCurve(ON_LineCurve* line_curve) const;
733 
734  /*
735  Paramters:
736  profile_parameter - [in]
737  parameter on profile curve
738  Returns:
739  -1: if the profile_parameter does not correspond
740  to a point on the profile curve.
741  >= 0: index of the profile curve with domain containing
742  this paramter. When the profile_parameter corresponds
743  to the end of one profile and the beginning of the next
744  profile, the index of the next profile is returned.
745  */
746  int ProfileIndex( double profile_parameter ) const;
747 
748 
749  /*
750  Returns:
751  If m_profile_count >= 2 and m_profile is an ON_PolyCurve
752  with m_profile_count segments defining outer and inner
753  profiles, a pointer to the polycurve is returned.
754  Otherwise null is returned.
755  */
756  const ON_PolyCurve* PolyProfile() const;
757 
758  /*
759  Description:
760  Get a list of the 2d profile curves.
761  Returns:
762  Number of curves appended to the list.
763  */
764  int GetProfileCurves( ON_SimpleArray<const ON_Curve*>& profile_curves ) const;
765 
766 
767  /*
768  Description:
769  Get the parameters where a profile curve has kinks.
770  Parameters:
771  profile_index - [in]
772  profile_kink_parameters - [out]
773  parameters at internal kinks are appended to this array.
774  Returns:
775  Number of parameters appended to profile_kink_parameters[]
776  Remarks:
777  This function is used when making the brep form that has
778  smooth faces.
779  */
780  int GetProfileKinkParameters( int profile_index, ON_SimpleArray<double>& profile_kink_parameters ) const;
781  int GetProfileKinkParameters( int profile_index, ON_SimpleArray<double>* profile_kink_parameters ) const;
782 
783  /*
784  Parameters:
785  profile_index - [in]
786  Returns:
787  True if the profile has at least one kink.
788  */
789  bool ProfileIsKinked( int profile_index ) const;
790 
791  /*
792  Description:
793  Test a polycurve to determine if it meets the necessary
794  conditions to be used as a multi-segment profile in a extrusion.
795  Returns:
796  True if the returned polycurve can be used a a multi-segment
797  profile in a extrusion.
798  */
799  static bool IsValidPolyCurveProfile( const ON_PolyCurve& polycurve, ON_TextLog* text_log = 0 );
800 
801  /*
802  Description:
803  If possible, modify a polycurve so it meets the necessary conditions
804  to be used as a multi-segment profile in a extrusion.
805  Returns:
806  True if the returned polycurve can be used a a multi-segment
807  profile in a extrusion.
808  */
809  static bool CleanupPolyCurveProfile( ON_PolyCurve& polycurve );
810 
811  // path definition:
812  // The line m_path must have length > m_path_length_min.
813  // The interval m_t must statisfy 0 <= m_t[0] < m_t[1] <= 1.
814  // The extrusion starts at m_path.PointAt(m_t[0]) and ends
815  // at m_path.PointAt(m_t[1]).
816  // The "up" direction m_up is a unit vector that must
817  // be perpendicular to m_path.Tangent().
818  ON_Line m_path;
819  ON_Interval m_t;
820  ON_3dVector m_up;
821 
822  // profile information:
823  // In general, use SetOuterProfile() and AddInnerProfile()
824  // to set m_profile_count and m_profile. If you are
825  // a glutton for punishment, then you might be interested
826  // in the following.
827  // The profile curves must be in the x-y plane.
828  // The profile's "y" axis corresponds to m_up.
829  // The point (0,0) is extruded along the m_path line.
830  // If m_profile_count = 1, then m_profile can be any
831  // type of continous curve. If m_profile_count > 1,
832  // then m_profile must be an ON_PolyCurve with
833  // m_profile_count segments, the domain of each segment
834  // must exactly match the polycurve's segment domain,
835  // every segment must be continuous and closed,
836  // the first segement curve must have counter-clockwise
837  // orientation, and the rest must have clockwise
838  // orientations.
839  int m_profile_count;
840  ON_Curve* m_profile;
842  // capped end information:
843  // If the profile is closed, then m_bCap[] determines
844  // if the ends are capped.
845  bool m_bCap[2];
846 
847  // mitered end information:
848  // The normals m_N[] are with respect to the xy plane.
849  // A normal parallel to the z axis has no mitering.
850  // If m_bHaveN[i] is true, then m_N[i] must be a 3d unit
851  // vector with m_N[i].z > m_Nz_tol; If m_bHaveN[i]
852  // is false, then m_N[i] is ignored. The normal m_N[0]
853  // defines the start miter plane and m_N[1] defines the
854  // end miter plane.
855  bool m_bHaveN[2];
856  ON_3dVector m_N[2];
858  // Surface parameterization information
859  ON_Interval m_path_domain;
860  bool m_bTransposed; // false: (s,t) = (profile,path)
862  // The z coordinates of miter plane normals must be
863  // greater than m_Nz_tol
864  static const double m_Nz_min; // 1/64;
866  // The length of the m_path line must be greater than
867  // m_path_length_min
868  static const double m_path_length_min; // ON_ZERO_TOLERANCE;
869 
870  // Cached meshes used for rendering, analysis, ...
871  mutable ON_MeshCache m_mesh_cache = ON_MeshCache::Empty;
872 
873  /*
874  Description:
875  Get an ON_Exrusion form of a cylinder.
876  Parameters:
877  cylinder - [in] cylinder.IsFinite() must be true
878  bCapBottom - [in] if true, the end at cylinder.m_height[0] will be capped
879  bCapTop - [in] if true, the end at cylinder.m_height[1] will be capped
880  extrusion - [in]
881  If the input extrusion pointer is null, one will be allocated on the heap
882  and it is the caller's responsibility to delte it at an appropriate time.
883  If the input pointer is not null, this extrusion will be used and the same
884  pointer will be returned, provided the input is valid.
885  Returns:
886  If the input is valid, a pointer to an ON_Exrusion form of the cylinder.
887  If the input is not valid, then null, even when the input extrusion
888  object is not null.
889  Example:
890 
891  ON_Cylinder cylinder = ...;
892  bool bCapBottom = true;
893  bool bCapTop = true;
894  ON_Extrusion extrusion;
895  if ( 0 == ON_Extrusion::Cylinder(cylinder,bCapBottom,bCapTop,&extrusion) )
896  {
897  // input is not valid - nothing set
898  ...
899  }
900  else
901  {
902  // extrusion = cylinder
903  ...
904  }
905  */
906  static ON_Extrusion* Cylinder(
907  const ON_Cylinder& cylinder,
908  bool bCapBottom,
909  bool bCapTop,
910  ON_Extrusion* extrusion = 0
911  );
912 
913  /*
914  Description:
915  Get an ON_Exrusion form of a pipe.
916  Parameters:
917  cylinder - [in] cylinder.IsFinite() must be true
918  The cylinder can be either the inner or outer wall of the pipe.
919  other_radius - [in] ( != cylinder.Radius() )
920  If cylinder.Radius() < other_radius, then the cylinder will be
921  the inside of the pipe. If cylinder.Radius() > other_radius, then
922  the cylinder will be the outside of the pipe.
923  bCapBottom - [in] if true, the end at cylinder.m_height[0] will be capped
924  bCapTop - [in] if true, the end at cylinder.m_height[1] will be capped
925  extrusion - [in]
926  If the input extrusion pointer is null, one will be allocated on the heap
927  and it is the caller's responsibility to delte it at an appropriate time.
928  If the input pointer is not null, this extrusion will be used and the same
929  pointer will be returned, provided the input is valid.
930  Returns:
931  If the input is valid, a pointer to an ON_Exrusion form of the pipe.
932  If the input is not valid, then null, even when the input extrusion
933  object is not null.
934  Example:
935 
936  ON_Cylinder cylinder = ...;
937  double other_radius = cylinder.Radius()+1.0;
938  bool bCapBottom = true;
939  bool bCapTop = true;
940  ON_Extrusion extrusion;
941  if ( 0 == ON_Extrusion::Pipe(cylinder,other_radius,bCapBottom,bCapTop,&extrusion) )
942  {
943  // input is not valid - nothing set
944  ...
945  }
946  else
947  {
948  // extrusion = pipe
949  ...
950  }
951  */
952  static ON_Extrusion* Pipe(
953  const ON_Cylinder& cylinder,
954  double other_radius,
955  bool bCapBottom,
956  bool bCapTop,
957  ON_Extrusion* extrusion = 0
958  );
959 
960  /*
961  Description:
962  Create an ON_Exrusion from a 3d curve, a plane and a height.
963  Parameters:
964  curve - [in]
965  A continuous 3d curve.
966  plane - [in]
967  If plane is null, then the plane returned by curve.IsPlanar() is used.
968  The 3d curve is projected to this plane and the result is passed to
969  ON_Extrusion::SetOuterProfile().
970  height - [in]
971  If the height > 0, the bottom of the extrusion will be in plane and
972  the top will be height units above the plane.
973  If the height < 0, the top of the extrusion will be in plane and
974  the bottom will be height units below the plane.
975  bCap - [in]
976  If the curve is closed and bCap is true, then the resulting extrusion
977  is capped.
978  extrusion - [in]
979  If the input extrusion pointer is null, one will be allocated on the heap
980  and it is the caller's responsibility to delte it at an appropriate time.
981  If the input pointer is not null, this extrusion will be used and the same
982  pointer will be returned, provided the input is valid.
983  Returns:
984  If the input is valid, a pointer to an ON_Exrusion form of the pipe.
985  If the input is not valid, then null, even when the input extrusion
986  object is not null.
987  */
988  static ON_Extrusion* CreateFrom3dCurve(
989  const ON_Curve& curve,
990  const ON_Plane* plane,
991  double height,
992  bool bCap,
993  ON_Extrusion* extrusion = 0
994  );
995 
996 };
997 
998 
999 #endif
1000 
virtual bool Transpose()=0
virtual bool Transform(const ON_Xform &xform)
Transforms the object.
virtual bool IsClosed(int) const
bool IsSolid() const
bool SetDomain(int dir, ON_Interval domain)
ON_Surface & operator=(const ON_Surface &)
virtual bool IsPeriodic(int) const
virtual int Dimension() const
Dimension of the object.
virtual int GetNurbForm(ON_NurbsSurface &nurbs_surface, double tolerance=0.0) const
Get a NURBS surface representation of this surface.
Definition: opennurbs_nurbssurface.h:62
virtual bool GetBBox(double *boxmin, double *boxmax, bool bGrowBox=false) const
This is the virtual function that actually calculates axis aligned bounding boxes.
Definition: opennurbs_array.h:36
virtual bool GetSpanVector(int dir, double *span_vector) const =0
ON_Curve is a pure virtual class for curve objects
Definition: opennurbs_curve.h:93
Definition: opennurbs_linecurve.h:21
Definition: opennurbs_mesh.h:4193
virtual bool GetSurfaceParameterFromNurbFormParameter(double nurbs_s, double nurbs_t, double *surface_s, double *surface_t) const
ON_Cylinder is a right circular cylinder.
Definition: opennurbs_cylinder.h:27
virtual bool IsPlanar(ON_Plane *plane=nullptr, double tolerance=ON_ZERO_TOLERANCE) const
Test a surface to see if it is planar.
virtual ON_Interval Domain(int dir) const =0
ON_Brep * BrepForm(ON_Brep *brep=nullptr) const override
Overrides virtual ON_Geometry::HasBrepForm. Uses ON_Brep::Create( ON_Surface&* ) to create a brep for...
virtual bool GetTightBoundingBox(class ON_BoundingBox &tight_bbox, bool bGrowBox=false, const class ON_Xform *xform=nullptr) const
Get tight bounding box.
virtual int Degree(int dir) const =0
virtual ISO IsIsoparametric(const ON_Curve &curve, const ON_Interval *curve_domain=nullptr) const
Test a 2d curve to see if it is iso parameteric in the surface&#39;s parameter space. ...
Definition: opennurbs_bounding_box.h:25
virtual int SpanCount(int dir) const =0
virtual bool GetNurbFormParameterFromSurfaceParameter(double surface_s, double surface_t, double *nurbs_s, double *nurbs_t) const
Definition: opennurbs_xform.h:28
An ON_PolyCurve is an ON_Curve represented by a sequence of contiguous ON_Curve segments. A valid polycurve is represented by an array m_segment of Count()>=1 curve objects and a strictly increasing array m_t of Count()+1 parameter values. The i-th curve segment, when considered as part of the polycurve, is affinely reparamaterized from m_t[i] to m_t[i+1], i.e., m_segment[i].Domain()[0] is mapped to m_t[i] and m_segment[i].Domain()[1] is mapped to m_t[i+1].
Definition: opennurbs_polycurve.h:35
virtual bool Split(int dir, double c, ON_Surface *&west_or_south_side, ON_Surface *&east_or_north_side) const
Splits (divides) the surface into two parts at the specified parameter.
virtual bool Trim(int dir, const ON_Interval &domain)
Removes the portions of the surface outside of the specified interval.
ISO
pure virtual class for surface objects
Definition: opennurbs_surface.h:72
virtual void Dump(ON_TextLog &) const
Creates a text dump of the object.
Definition: opennurbs_beam.h:51
Definition: opennurbs_mesh.h:2188
unsigned int SizeOf() const override
virtual ON_Object::SizeOf override
Definition: opennurbs_line.h:20
void DestroyRuntimeCache(bool bDelete=true) override
virtual ON_Object::DestroyRuntimeCache override
virtual bool Extend(int dir, const ON_Interval &domain)
Pure virtual function. Default returns false. Where possible, analytically extends surface to include...
surface of revolution
Definition: opennurbs_sumsurface.h:23
virtual ON_Curve * IsoCurve(int dir, double c) const
Get isoparametric curve.
Definition: opennurbs_brep.h:1472
virtual bool GetParameterTolerance(int dir, double t, double *tminus, double *tplus) const
static const ON_MeshCache Empty
Definition: opennurbs_mesh.h:4196
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
virtual bool Read(ON_BinaryArchive &binary_archive)
Low level archive writing tool used by ON_BinaryArchive::ReadObject().
Definition: opennurbs_point.h:460
bool IsValid(class ON_TextLog *text_log=nullptr) const override
Tests an object to see if its data members are correctly initialized.
virtual bool Write(ON_BinaryArchive &binary_archive) const
Low level archive writing tool used by ON_BinaryArchive::WriteObject().
virtual ON__UINT32 DataCRC(ON__UINT32 current_remainder) const
Returns a CRC calculated from the information that defines the object. This CRC can be used as a quic...
Definition: opennurbs_plane.h:20
Definition: opennurbs_surface.h:57
virtual bool Reverse(int)=0
virtual bool GetSpanVectorIndex(int dir, double t, int side, int *span_vector_index, ON_Interval *span_interval) const
virtual bool GetSurfaceSize(double *width, double *height) const
Get an estimate of the size of the rectangle that would be created if the 3d surface where flattened ...
Definition: opennurbs_point.h:1152
Definition: opennurbs_point.h:46
virtual int HasNurbForm() const
Is there a NURBS surface representation of this surface.
ON::object_type ObjectType() const override
override ON_Object::ObjectType() - returns ON::surface_object
virtual bool Evaluate(double u, double v, int num_der, int array_stride, double *der_array, int quadrant=0, int *hint=0) const =0
work horse evaluator
virtual 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
Search for a derivatitive, tangent, or curvature discontinuity.
virtual 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
Test continuity at a surface parameter value.