opennurbs_surface.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 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 ////////////////////////////////////////////////////////////////
18 //
19 // Definition of virtual parametric surface
20 //
21 ////////////////////////////////////////////////////////////////
22 
23 #if !defined(OPENNURBS_SURFACE_INC_)
24 #define OPENNURBS_SURFACE_INC_
25 
26 class ON_Curve;
27 class ON_NurbsSurface;
28 class ON_SurfaceTree;
29 
30 ////////////////////////////////////////////////////////////////
31 //
32 // Definition of virtual parametric surface
33 //
34 ////////////////////////////////////////////////////////////////
35 
36 class ON_Mesh;
37 class ON_MeshParameters;
38 class ON_PolyCurve;
39 class ON_CurveProxy;
40 class ON_Surface;
41 
42 
43 /* Return codes to be used in operations that attempt to fit to a tolerance.
44  For example ON_Surface::Pullback() and ON_Surface::PushUp().
45 */
46 
47 enum class ON_FitResult: unsigned int
48 
49 {
50  unknown=0,
51  in_tolerance=1,
52  not_in_tolerance=2
53 };
54 
55 
56 class ON_CLASS ON_Surface : public ON_Geometry
57 {
58  ON_OBJECT_DECLARE(ON_Surface);
59 
60 public:
61  // virtual ON_Object::DestroyRuntimeCache override
62  void DestroyRuntimeCache( bool bDelete = true ) override;
63 
64  // pure virtual class for surface objects
65 public:
66 
67  // flags for isoparametric curves
68  // note: odd values are all "x" = constant
69  // and even values > 0 are all "y" = constant
70  // ON_BrepTrim::m_iso uses these flags
71  enum ISO
72  {
73  not_iso = 0, // curve is not an isoparameteric curve
74  x_iso = 1, // curve is a "x" = constant (vertical) isoparametric
75  // curve in the interior of the surface's domain
76  y_iso = 2, // curve is a "y" = constant (horizontal) isoparametric
77  // curve in the interior of the surface's domain
78  W_iso = 3, // curve is a "x" = constant isoparametric curve
79  // along the west side of the surface's domain
80  S_iso = 4, // curve is a "y" = constant isoparametric curve
81  // along the south side of the surface's domain
82  E_iso = 5, // curve is a "x" = constant isoparametric curve
83  // along the east side of the surface's domain
84  N_iso = 6, // curve is a "y" = constant isoparametric curve
85  // along the north side of the surface's domain
86  iso_count = 7
87  };
88 
89 public:
90  ON_Surface();
91  ON_Surface(const ON_Surface&);
92  ON_Surface& operator=(const ON_Surface&);
93  virtual ~ON_Surface();
94 
95  // virtual ON_Object::SizeOf override
96  unsigned int SizeOf() const override;
97 
98  // virtual ON_Geometry override
99  bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const override;
100 
101  /*
102  Description:
103  Get a duplicate of the surface.
104  Returns:
105  A duplicate of the surface.
106  Remarks:
107  The caller must delete the returned surface.
108  For non-ON_SurfaceProxy objects, this simply duplicates the surface using
109  ON_Object::Duplicate.
110  For ON_SurfaceProxy objects, this duplicates the actual proxy surface
111  geometry and, if necessary, transposes the result to that
112  the returned surfaces's parameterization and locus match the proxy surface's.
113  */
114  virtual
115  ON_Surface* DuplicateSurface() const;
116 
117  //////////
118  // override ON_Object::ObjectType() - returns ON::surface_object
119  ON::object_type ObjectType() const override;
120 
121 
122  /////////////////////////////
123  //
124  // virtual ON_Geometry functions
125  //
126 
127  /*
128  Description:
129  Overrides virtual ON_Geometry::HasBrepForm and returns true.
130  Result:
131  Returns true.
132  See Also:
133  ON_Brep::Create( ON_Surface&* )
134  */
135  bool HasBrepForm() const override;
136 
137  /*
138  Description:
139  Overrides virtual ON_Geometry::HasBrepForm.
140  Uses ON_Brep::Create( ON_Surface&* ) to create a brep
141  form. The surface is copied for use in the returned
142  brep.
143  Parameters:
144  brep - [in] if not nullptr, brep is used to store the brep
145  form of the surface.
146  Result:
147  Returns a pointer to on ON_Brep or nullptr. If the brep
148  parameter is not nullptr, then brep is returned if the
149  surface has a brep form and nullptr is returned if the
150  geometry does not have a brep form.
151  Remarks:
152  The caller is responsible for managing the brep memory.
153  */
154  ON_Brep* BrepForm( ON_Brep* brep = nullptr ) const override;
155 
156  ////////////////////////////////////////////////////////////////////
157  // surface interface
158 
159 
160  bool GetDomain(
161  int dir, // 0 gets first parameter, 1 gets second parameter
162  double* t0,
163  double* t1
164  ) const;
165 
166  bool SetDomain(
167  int dir, // 0 sets first parameter's domain, 1 gets second parameter's domain
168  ON_Interval domain
169  );
170 
171  virtual
172  bool SetDomain(
173  int dir, // 0 sets first parameter's domain, 1 gets second parameter's domain
174  double t0,
175  double t1
176  );
177 
178  virtual
179  ON_Interval Domain(
180  int dir // 0 gets first parameter's domain, 1 gets second parameter's domain
181  ) const = 0;
182 
183  /*
184  Description:
185  Get an estimate of the size of the rectangle that would
186  be created if the 3d surface where flattened into a rectangle.
187  Parameters:
188  width - [out] (corresponds to the first surface parameter)
189  height - [out] (corresponds to the first surface parameter)
190  Example:
191 
192  // Reparameterize a surface to minimize distortion
193  // in the map from parameter space to 3d.
194  ON_Surface* surf = ...;
195  double width, height;
196  if ( surf->GetSurfaceSize( &width, &height ) )
197  {
198  srf->SetDomain( 0, ON_Interval( 0.0, width ) );
199  srf->SetDomain( 1, ON_Interval( 0.0, height ) );
200  }
201 
202  Returns:
203  true if successful.
204  */
205  virtual
206  bool GetSurfaceSize(
207  double* width,
208  double* height
209  ) const;
210 
211 
212  virtual
213  int SpanCount(
214  int dir // 0 gets first parameter's domain, 1 gets second parameter's domain
215  ) const = 0; // number of smooth nonempty spans in the parameter direction
216 
217  virtual
218  bool GetSpanVector( // span "knots"
219  int dir, // 0 gets first parameter's domain, 1 gets second parameter's domain
220  double* span_vector // array of length SpanCount() + 1
221  ) const = 0; //
222 
223  //////////
224  // If t is in the domain of the surface, GetSpanVectorIndex() returns the
225  // span vector index "i" such that span_vector[i] <= t <= span_vector[i+1].
226  // The "side" parameter determines which span is selected when t is at the
227  // end of a span.
228  virtual
229  bool GetSpanVectorIndex(
230  int dir , // 0 gets first parameter's domain, 1 gets second parameter's domain
231  double t, // [IN] t = evaluation parameter
232  int side, // [IN] side 0 = default, -1 = from below, +1 = from above
233  int* span_vector_index, // [OUT] span vector index
234  ON_Interval* span_interval // [OUT] domain of the span containing "t"
235  ) const;
236 
237  virtual
238  int Degree( // returns maximum algebraic degree of any span
239  // ( or a good estimate if curve spans are not algebraic )
240  int dir // 0 gets first parameter's domain, 1 gets second parameter's domain
241  ) const = 0;
242 
243  virtual bool GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus
244  int dir, // 0 gets first parameter, 1 gets second parameter
245  double t, // t = parameter in domain
246  double* tminus, // tminus
247  double* tplus // tplus
248  ) const;
249 
250  /*
251  Description:
252  Test a 2d curve to see if it is iso parameteric in the surface's
253  parameter space.
254  Parameters:
255  curve - [in] curve to test
256  curve_domain = [in] optional sub domain of the curve
257  Returns:
258  Isoparametric status of the curve.
259  Remarks:
260  Because it may transpose domains, ON_SurfaceProxy overrides
261  this function. All other surface classes just use
262  the base class implementation.
263  */
264  virtual
265  ISO IsIsoparametric(
266  const ON_Curve& curve,
267  const ON_Interval* curve_domain = nullptr
268  ) const;
269 
270  /*
271  Description:
272  Test a 2d bounding box to see if it is iso parameteric in the surface's
273  parameter space.
274  Parameters:
275  bbox - [in] bounding box to test
276  Returns:
277  Isoparametric status of the bounding box.
278  Remarks:
279  Because it may transpose domains, ON_SurfaceProxy overrides
280  this function. All other surface classes just use
281  the base class implementation.
282  */
283  virtual
284  ISO IsIsoparametric(
285  const ON_BoundingBox& bbox
286  ) const;
287 
288  /*
289  Description:
290  Test a surface to see if it is planar.
291  Parameters:
292  plane - [out] if not nullptr and true is returned,
293  the plane parameters are filled in.
294  tolerance - [in] tolerance to use when checking
295  Returns:
296  true if there is a plane such that the maximum distance from
297  the surface to the plane is <= tolerance.
298  */
299  virtual
300  bool IsPlanar(
301  ON_Plane* plane = nullptr,
302  double tolerance = ON_ZERO_TOLERANCE
303  ) const;
304 
305  /*
306  Description:
307  Determine if the surface is a portion of a sphere.
308  Parameters:
309  sphere - [out] if not nullptr and true is returned,
310  then the sphere definition is returned.
311  tolerance - [in]
312  tolerance to use when checking
313  Returns:
314  True if the surface is a portion of a sphere.
315  */
316  bool IsSphere(
317  ON_Sphere* sphere = nullptr,
318  double tolerance = ON_ZERO_TOLERANCE
319  ) const;
320 
321  /*
322  Description:
323  Determine if the surface is a portion of a cylinder.
324  Parameters:
325  cylinder - [out] if not nullptr and true is returned,
326  then the cylinder definition is returned.
327  tolerance - [in]
328  tolerance to use when checking
329  Returns:
330  True if the surface is a portion of a cylinder.
331  */
332  bool IsCylinder(
333  ON_Cylinder* cylinder = nullptr,
334  double tolerance = ON_ZERO_TOLERANCE
335  ) const;
336 
337  /*
338  Description:
339  Determine if the surface is a portion of a cone.
340  Parameters:
341  cone - [out] if not nullptr and true is returned,
342  then the cone definition is returned.
343  tolerance - [in]
344  tolerance to use when checking
345  Returns:
346  True if the surface is a portion of a cone.
347  */
348  bool IsCone(
349  ON_Cone* cone = nullptr,
350  double tolerance = ON_ZERO_TOLERANCE
351  ) const;
352 
353  /*
354  Description:
355  Determine if the surface is a portion of a torus.
356  Parameters:
357  torus - [out] if not nullptr and true is returned,
358  then the torus definition is returned.
359  tolerance - [in]
360  tolerance to use when checking
361  Returns:
362  True if the surface is a portion of a torus.
363  */
364  bool IsTorus(
365  ON_Torus* torus = nullptr,
366  double tolerance = ON_ZERO_TOLERANCE
367  ) const;
368 
369  virtual
370  bool IsClosed( // true if surface is closed in direction
371  int // dir 0 = "s", 1 = "t"
372  ) const;
373 
374  virtual
375  bool IsPeriodic( // true if surface is periodic in direction (default is false)
376  int // dir 0 = "s", 1 = "t"
377  ) const;
378 
379  virtual
380  bool IsSingular( // true if surface side is collapsed to a point
381  int // side of parameter space to test
382  // 0 = south, 1 = east, 2 = north, 3 = west
383  ) const;
384 
385  /*
386  Returns:
387  True if the surface defines a solid, like a sphere or torus.
388  False if the surface does not define a solid, like a plane or cone.
389  */
390  bool IsSolid() const;
391 
392  /*
393  Description:
394  Test if a surface parameter value is at a singularity.
395  Parameters:
396  s - [in] surface parameter to test
397  t - [in] surface parameter to test
398  bExact - [in] if true, test if s,t is exactly at a singularity
399  if false, test if close enough to cause numerical problems.
400  Returns:
401  true if surface is singular at (s,t)
402  */
403  bool IsAtSingularity(
404  double s,
405  double t,
406  bool bExact = true
407  ) const;
408 
409  /*
410  Description:
411  Test if a surface parameter value is at a seam.
412  Parameters:
413  s - [in] surface parameter to test
414  t - [in] surface parameter to test
415  Returns:
416  0 if not a seam,
417  1 if s == Domain(0)[i] and srf(s, t) == srf(Domain(0)[1-i], t)
418  2 if t == Domain(1)[i] and srf(s, t) == srf(s, Domain(1)[1-i])
419  3 if 1 and 2 are true.
420  */
421  int IsAtSeam(
422  double s,
423  double t
424  ) const;
425 
426  /*
427  Description:
428  Search for a derivatitive, tangent, or curvature
429  discontinuity.
430  Parameters:
431  dir - [in] If 0, then "u" parameter is checked. If 1, then
432  the "v" parameter is checked.
433  c - [in] type of continity to test for.
434  t0 - [in] Search begins at t0. If there is a discontinuity
435  at t0, it will be ignored. This makes it
436  possible to repeatedly call GetNextDiscontinuity
437  and step through the discontinuities.
438  t1 - [in] (t0 != t1) If there is a discontinuity at t1 is
439  will be ingored unless c is a locus discontinuity
440  type and t1 is at the start or end of the curve.
441  t - [out] if a discontinuity is found, then *t reports the
442  parameter at the discontinuity.
443  hint - [in/out] if GetNextDiscontinuity will be called
444  repeatedly, passing a "hint" with initial value *hint=0
445  will increase the speed of the search.
446  dtype - [out] if not nullptr, *dtype reports the kind of
447  discontinuity found at *t. A value of 1 means the first
448  derivative or unit tangent was discontinuous. A value
449  of 2 means the second derivative or curvature was
450  discontinuous. A value of 0 means teh curve is not
451  closed, a locus discontinuity test was applied, and
452  t1 is at the start of end of the curve.
453  cos_angle_tolerance - [in] default = cos(1 degree) Used only
454  when c is ON::continuity::G1_continuous or ON::continuity::G2_continuous. If the
455  cosine of the angle between two tangent vectors is
456  <= cos_angle_tolerance, then a G1 discontinuity is reported.
457  curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used
458  only when c is ON::continuity::G2_continuous. If K0 and K1 are
459  curvatures evaluated from above and below and
460  |K0 - K1| > curvature_tolerance, then a curvature
461  discontinuity is reported.
462  Returns:
463  Parametric continuity tests c = (C0_continuous, ..., G2_continuous):
464 
465  true if a parametric discontinuity was found strictly
466  between t0 and t1. Note well that all curves are
467  parametrically continuous at the ends of their domains.
468 
469  Locus continuity tests c = (C0_locus_continuous, ...,G2_locus_continuous):
470 
471  true if a locus discontinuity was found strictly between
472  t0 and t1 or at t1 is the at the end of a curve.
473  Note well that all open curves (IsClosed()=false) are locus
474  discontinuous at the ends of their domains. All closed
475  curves (IsClosed()=true) are at least C0_locus_continuous at
476  the ends of their domains.
477  */
478  virtual
479  bool GetNextDiscontinuity(
480  int dir,
481  ON::continuity c,
482  double t0,
483  double t1,
484  double* t,
485  int* hint=nullptr,
486  int* dtype=nullptr,
487  double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
488  double curvature_tolerance=ON_SQRT_EPSILON
489  ) const;
490 
491  /*
492  Description:
493  Test continuity at a surface parameter value.
494  Parameters:
495  c - [in] continuity to test for
496  s - [in] surface parameter to test
497  t - [in] surface parameter to test
498  hint - [in] evaluation hint
499  point_tolerance - [in] if the distance between two points is
500  greater than point_tolerance, then the surface is not C0.
501  d1_tolerance - [in] if the difference between two first derivatives is
502  greater than d1_tolerance, then the surface is not C1.
503  d2_tolerance - [in] if the difference between two second derivatives is
504  greater than d2_tolerance, then the surface is not C2.
505  cos_angle_tolerance - [in] default = cos(1 degree) Used only when
506  c is ON::continuity::G1_continuous or ON::continuity::G2_continuous. If the cosine
507  of the angle between two normal vectors
508  is <= cos_angle_tolerance, then a G1 discontinuity is reported.
509  curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
510  c is ON::continuity::G2_continuous. If K0 and K1 are curvatures evaluated
511  from above and below and |K0 - K1| > curvature_tolerance,
512  then a curvature discontinuity is reported.
513  Returns:
514  true if the surface has at least the c type continuity at the parameter t.
515  */
516  virtual
517  bool IsContinuous(
518  ON::continuity c,
519  double s,
520  double t,
521  int* hint = nullptr,
522  double point_tolerance=ON_ZERO_TOLERANCE,
523  double d1_tolerance=ON_ZERO_TOLERANCE,
524  double d2_tolerance=ON_ZERO_TOLERANCE,
525  double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
526  double curvature_tolerance=ON_SQRT_EPSILON
527  ) const;
528 
529  virtual
530  bool Reverse( // reverse parameterizatrion, Domain changes from [a,b] to [-b,-a]
531  int // dir 0 = "s", 1 = "t"
532  ) = 0;
533 
534  virtual
535  bool Transpose() = 0; // transpose surface parameterization (swap "s" and "t")
536 
537  // simple evaluation interface - no error handling
538  ON_3dPoint PointAt( double, double ) const;
539  ON_3dVector NormalAt( double, double ) const;
540  bool FrameAt( double u, double v, ON_Plane& frame) const;
541 
542  bool EvPoint( // returns false if unable to evaluate
543  double u, double v, // evaluation parameters
544  ON_3dPoint& point, // returns value of surface
545  int quadrant = 0, // optional - determines which side to evaluate from
546  // 0 = default
547  // 1 from NE quadrant
548  // 2 from NW quadrant
549  // 3 from SW quadrant
550  // 4 from SE quadrant
551  int* hint = 0 // optional - evaluation hint (int[2]) used to speed
552  // repeated evaluations
553  ) const;
554 
555  bool Ev1Der( // returns false if unable to evaluate
556  double u, double v, // evaluation parameters (s,t)
557  ON_3dPoint& point, // returns value of surface
558  ON_3dVector& du, // first partial derivatives (Ds)
559  ON_3dVector& dv, // (Dt)
560  int quadrant = 0, // optional - determines which side to evaluate from
561  // 0 = default
562  // 1 from NE quadrant
563  // 2 from NW quadrant
564  // 3 from SW quadrant
565  // 4 from SE quadrant
566  int* hint = 0 // optional - evaluation hint (int[2]) used to speed
567  // repeated evaluations
568  ) const;
569 
570  bool Ev2Der( // returns false if unable to evaluate
571  double u, double v, // evaluation parameters (s,t)
572  ON_3dPoint& point, // returns value of surface
573  ON_3dVector& du, // first partial derivatives (Ds)
574  ON_3dVector& dv, // (Dt)
575  ON_3dVector& duu, // second partial derivatives (Dss)
576  ON_3dVector& duv, // (Dst)
577  ON_3dVector& dvv, // (Dtt)
578  int quadrant= 0, // optional - determines which side to evaluate from
579  // 0 = default
580  // 1 from NE quadrant
581  // 2 from NW quadrant
582  // 3 from SW quadrant
583  // 4 from SE quadrant
584  int* hint = 0 // optional - evaluation hint (int[2]) used to speed
585  // repeated evaluations
586  ) const;
587 
588  bool EvNormal( // returns false if unable to evaluate
589  double u, double v, // evaluation parameters (s,t)
590  ON_3dPoint& point, // returns value of surface
591  ON_3dVector& normal, // unit normal
592  int quadrant = 0, // optional - determines which side to evaluate from
593  // 0 = default
594  // 1 from NE quadrant
595  // 2 from NW quadrant
596  // 3 from SW quadrant
597  // 4 from SE quadrant
598  int* hint = 0 // optional - evaluation hint (int[2]) used to speed
599  // repeated evaluations
600  ) const;
601 
602  bool EvNormal( // returns false if unable to evaluate
603  double u, double v, // evaluation parameters (s,t)
604  ON_3dVector& normal, // unit normal
605  int quadrant = 0, // optional - determines which side to evaluate from
606  // 0 = default
607  // 1 from NE quadrant
608  // 2 from NW quadrant
609  // 3 from SW quadrant
610  // 4 from SE quadrant
611  int* hint = 0 // optional - evaluation hint (int[2]) used to speed
612  // repeated evaluations
613  ) const;
614 
615  bool EvNormal( // returns false if unable to evaluate
616  double u, double v, // evaluation parameters (s,t)
617  ON_3dPoint& point, // returns value of surface
618  ON_3dVector& du, // first partial derivatives (Ds)
619  ON_3dVector& dv, // (Dt)
620  ON_3dVector& normal, // unit normal
621  int = 0, // optional - determines which side to evaluate from
622  // 0 = default
623  // 1 from NE quadrant
624  // 2 from NW quadrant
625  // 3 from SW quadrant
626  // 4 from SE quadrant
627  int* = 0 // optional - evaluation hint (int[2]) used to speed
628  // repeated evaluations
629  ) const;
630 
631  // work horse evaluator
632  virtual
633  bool Evaluate( // returns false if unable to evaluate
634  double u, double v, // evaluation parameters
635  int num_der, // number of derivatives (>=0)
636  int array_stride, // array stride (>=Dimension())
637  double* der_array, // array of length stride*(ndir+1)*(ndir+2)/2
638  int quadrant = 0, // optional - determines which quadrant to evaluate from
639  // 0 = default
640  // 1 from NE quadrant
641  // 2 from NW quadrant
642  // 3 from SW quadrant
643  // 4 from SE quadrant
644  int* hint = 0 // optional - evaluation hint (int[2]) used to speed
645  // repeated evaluations
646  ) const = 0;
647 
648  /*
649  Description:
650  Get isoparametric curve.
651  Parameters:
652  dir - [in] 0 first parameter varies and second parameter is constant
653  e.g., point on IsoCurve(0,c) at t is srf(t,c)
654  This is a horizontal line from left to right
655  1 first parameter is constant and second parameter varies
656  e.g., point on IsoCurve(1,c) at t is srf(c,t
657  This is a vertical line from bottom to top
658 
659  c - [in] value of constant parameter
660  Returns:
661  Isoparametric curve.
662  Remarks:
663  In this function "dir" indicates which direction the resulting
664  curve runs. 0: horizontal, 1: vertical
665  In the other ON_Surface functions that take a "dir"
666  argument, "dir" indicates if "c" is a "u" or "v" parameter.
667  */
668  virtual
669  ON_Curve* IsoCurve(
670  int dir,
671  double c
672  ) const;
673 
674 
675  /*
676  Description:
677  Removes the portions of the surface outside of the specified interval.
678 
679  Parameters:
680  dir - [in] 0 The domain specifies an sub-interval of Domain(0)
681  (the first surface parameter).
682  1 The domain specifies an sub-interval of Domain(1)
683  (the second surface parameter).
684  domain - [in] interval of the surface to keep. If dir is 0, then
685  the portions of the surface with parameters (s,t) satisfying
686  s < Domain(0).Min() or s > Domain(0).Max() are trimmed away.
687  If dir is 1, then the portions of the surface with parameters
688  (s,t) satisfying t < Domain(1).Min() or t > Domain(1).Max()
689  are trimmed away.
690  */
691  virtual
692  bool Trim(
693  int dir,
694  const ON_Interval& domain
695  );
696 
697  /*
698  Description:
699  Pure virtual function. Default returns false.
700  Where possible, analytically extends surface to include domain.
701  Parameters:
702  dir - [in] 0 new Domain(0) will include domain.
703  (the first surface parameter).
704  1 new Domain(1) will include domain.
705  (the second surface parameter).
706  domain - [in] if domain is not included in surface domain,
707  surface will be extended so that its domain includes domain.
708  Will not work if surface is closed in direction dir.
709  Original surface is identical to the restriction of the
710  resulting surface to the original surface domain,
711  Returns:
712  true if successful.
713  */
714  virtual
715  bool Extend(
716  int dir,
717  const ON_Interval& domain
718  );
719 
720 
721  /*
722  Description:
723  Splits (divides) the surface into two parts at the
724  specified parameter.
725 
726  Parameters:
727  dir - [in] 0 The surface is split vertically. The "west" side
728  is returned in "west_or_south_side" and the "east"
729  side is returned in "east_or_north_side".
730  1 The surface is split horizontally. The "south" side
731  is returned in "west_or_south_side" and the "north"
732  side is returned in "east_or_north_side".
733  c - [in] value of constant parameter in interval returned
734  by Domain(dir)
735  west_or_south_side - [out] west/south portion of surface returned here
736  east_or_north_side - [out] east/north portion of surface returned here
737 
738  Example:
739 
740  ON_NurbsSurface srf = ...;
741  int dir = 1;
742  ON_NurbsSurface* south_side = 0;
743  ON_NurbsSurface* north_side = 0;
744  srf.Split( dir, srf.Domain(dir).Mid() south_side, north_side );
745 
746  */
747  virtual
748  bool Split(
749  int dir,
750  double c,
751  ON_Surface*& west_or_south_side,
752  ON_Surface*& east_or_north_side
753  ) const;
754 
755 
756  /*
757  Description:
758  Get a NURBS surface representation of this surface.
759  Parameters:
760  nurbs_surface - [out] NURBS representation returned here
761  tolerance - [in] tolerance to use when creating NURBS
762  representation.
763  s_subdomain - [in] if not nullptr, then the NURBS representation
764  for this portion of the surface is returned.
765  t_subdomain - [in] if not nullptr, then the NURBS representation
766  for this portion of the surface is returned.
767  Returns:
768  0 unable to create NURBS representation
769  with desired accuracy.
770  1 success - returned NURBS parameterization
771  matches the surface's to wthe desired accuracy
772  2 success - returned NURBS point locus matches
773  the surface's to the desired accuracy and the
774  domain of the NURBS surface is correct. On
775  However, This surface's parameterization and
776  the NURBS surface parameterization may not
777  match to the desired accuracy. This situation
778  happens when getting NURBS representations of
779  surfaces that have a transendental parameterization
780  like spheres, cylinders, and cones.
781  Remarks:
782  This is a low-level virtual function. If you do not need
783  the parameterization information provided by the return code,
784  then ON_Surface::NurbsSurface may be easier to use.
785  See Also:
786  ON_Surface::NurbsSurface
787  */
788  virtual
789  int GetNurbForm(
790  ON_NurbsSurface& nurbs_surface,
791  double tolerance = 0.0
792  ) const;
793 
794 
795  /*
796  Description:
797  Is there a NURBS surface representation of this surface.
798  Parameters:
799  Returns:
800  0 unable to create NURBS representation
801  with desired accuracy.
802  1 success - NURBS parameterization
803  matches the surface's
804  2 success - NURBS point locus matches
805  the surface's and the
806  domain of the NURBS surface is correct.
807  However, This surface's parameterization and
808  the NURBS surface parameterization may not
809  match. This situation
810  happens when getting NURBS representations of
811  surfaces that have a transendental parameterization
812  like spheres, cylinders, and cones.
813  Remarks:
814  This is a low-level virtual function.
815  See Also:
816  ON_Surface::GetNurbForm
817  ON_Surface::NurbsSurface
818  */
819  virtual
820  int HasNurbForm() const;
821 
822  // Description:
823  // Get a NURBS surface representation of this surface.
824  // Parameters:
825  // pNurbsSurface - [in/out] if not nullptr, this pNurbsSurface
826  // will be used to store the NURBS representation
827  // of the surface and will be returned.
828  // tolerance - [in] tolerance to use when creating NURBS
829  // surface representation.
830  // s_subdomain - [in] if not nullptr, then the NURBS representation
831  // for this portion of the surface is returned.
832  // t_subdomain - [in] if not nullptr, then the NURBS representation
833  // for this portion of the surface is returned.
834  // Returns:
835  // nullptr or a NURBS representation of the surface.
836  // Remarks:
837  // See ON_Surface::GetNurbForm for important details about
838  // the NURBS surface parameterization.
839  // See Also:
840  // ON_Surface::GetNurbForm
841  ON_NurbsSurface* NurbsSurface(
842  ON_NurbsSurface* pNurbsSurface = nullptr,
843  double tolerance = 0.0,
844  const ON_Interval* s_subdomain = nullptr,
845  const ON_Interval* t_subdomain = nullptr
846  ) const;
847 
848  virtual
849  bool GetSurfaceParameterFromNurbFormParameter(
850  double nurbs_s, double nurbs_t,
851  double* surface_s, double* surface_t
852  ) const;
853 
854  virtual
855  bool GetNurbFormParameterFromSurfaceParameter(
856  double surface_s, double surface_t,
857  double* nurbs_s, double* nurbs_t
858  ) const;
859 
860 
861  // If the geometry surface is modified in any way, then
862  // call DestroySurfaceTree().
863  void DestroySurfaceTree();
864 
866 private:
867 
868 public:
869 
870 protected:
871 };
872 
873 class ON_CLASS ON_SurfaceProperties
874 {
875  // Surface properties
876 public:
877  // The constructor sets all fields to zero.
879 
880  /*
881  Parameters:
882  surface - [in]
883  If surface is not null, then it is used to set the surface properties.
884  If surface is null, then all surface properties are set to to zero.
885  Remarks:
886  Does not modify the value of m_tag.
887  */
888  void Set( const ON_Surface* surface );
889 
890  bool m_bIsSet; // True if Set() has been callled with a non-null surface.
891 
892  bool m_bHasSingularity; // true if at least one m_bSingular[] setting is true.
893  bool m_bIsSingular[4]; // m_bSingular[i] = ON_Surface::IsSingular(i)
894 
895  bool m_bHasSeam; // true if at least one m_bClosed[] setting is true.
896  bool m_bIsClosed[2]; // m_bClosed[i] = ON_Surface::IsClosed(i)
897 
898 private:
899  bool m_bReserved[7];
900 
901 public:
902  ON_Interval m_domain[2]; // m_domain[i] = ON_Surface.Domain(i)
904 private:
905  unsigned char m_reserved[16];
906 
907 public:
908  // Last pointer passed to ON_SurfaceProperties::Set().
909  const ON_Surface* m_surface;
911  // The constructor sets this value to zero.
912  // Nothing in opennurbs modifies or uses this value.
913  ON__INT_PTR m_tag;
914 };
915 
916 #if defined(ON_DLL_TEMPLATE)
917 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_Surface*>;
918 #endif
919 
920 class ON_CLASS ON_SurfaceArray : public ON_SimpleArray<ON_Surface*>
921 {
922 public:
923  ON_SurfaceArray( int = 0 );
924  ~ON_SurfaceArray();
925 
926  bool Write( ON_BinaryArchive& ) const;
927  bool Read( ON_BinaryArchive& );
928 
929  void Destroy(); // deletes surfaces in array and sets count to 0
930 
931  bool Duplicate( ON_SurfaceArray& ) const; // operator= copies the pointer values
932  // duplicate copies the surfaces themselves
933 };
934 
935 #endif
Definition: opennurbs_nurbssurface.h:62
Definition: opennurbs_array.h:36
Lightweight right circular cone. Use ON_ConeSurface if you need ON_Cone geometry as a virtual ON_Surf...
Definition: opennurbs_cone.h:27
ON_Curve is a pure virtual class for curve objects
Definition: opennurbs_curve.h:93
ON_Cylinder is a right circular cylinder.
Definition: opennurbs_cylinder.h:27
Base class for all geometry classes that must provide runtime class id. Provides interface for common...
Definition: opennurbs_geometry.h:37
Definition: opennurbs_surface.h:910
Definition: opennurbs_bounding_box.h:25
Definition: opennurbs_mesh.h:24
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
ISO
pure virtual class for surface objects
Definition: opennurbs_surface.h:72
Definition: opennurbs_curveproxy.h:37
Definition: opennurbs_mesh.h:2188
Definition: opennurbs_surface.h:865
Definition: opennurbs_brep.h:1472
The torus is defined by a major circle and minor radius. The torus is parameterized by (major_angle...
Definition: opennurbs_torus.h:28
Definition: opennurbs_archive.h:1783
Definition: opennurbs_objref.h:163
Definition: opennurbs_point.h:460
Definition: opennurbs_plane.h:20
Definition: opennurbs_surface.h:57
Definition: opennurbs_point.h:1152
Definition: opennurbs_point.h:46
Definition: opennurbs_sphere.h:22