Point Cloud Library (PCL) 1.13.0
opennurbs_sumsurface.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#if !defined(OPENNURBS_SUM_SURFACE_INC_)
18#define OPENNURBS_SUM_SURFACE_INC_
19
20class ON_SumSurface;
21
22// surface of revolution
23class ON_CLASS ON_SumSurface : public ON_Surface
24{
25 ON_OBJECT_DECLARE(ON_SumSurface);
26
27public:
28 // virtual ON_Object::DestroyRuntimeCache override
29 void DestroyRuntimeCache( bool bDelete = true );
30
31public:
32
33 // for expert users
34 // surface-PointAt(s,t)
35 // = m_curve[0]->PointAt(s) + m_curve[1]->PointAt(t) + m_basepoint;
36 ON_Curve* m_curve[2]; // m_curve[0] and m_curve[1] are deleted by ~ON_SumSuface.
37 // Use a ON_ProxyCurve if this is problem.
39 ON_BoundingBox m_bbox; // lazy evaluation used in ON_SumSurface::BoundingBox()
40
41public:
42
43 /*
44 Description:
45 Use ON_SumSurface::New(...) instead of new ON_SumSurface(...)
46 Returns:
47 Pointer to an ON_SumSurface. Destroy by calling delete.
48 Remarks:
49 See static ON_Brep* ON_Brep::New() for details.
50 */
51 static ON_SumSurface* New();
52 static ON_SumSurface* New( const ON_SumSurface& rev_surface );
53
58
59 /*
60 Description:
61 Extrude a curve to create a surface.
62 Parameters:
63 curve - [in] curve is copied.
64 extrusion_vector - [in] extrusion vector (must be nonzero)
65 Returns:
66 true if a valid surface is created.
67 */
68 ON_BOOL32 Create( const ON_Curve& curve, ON_3dVector extrusion_vector );
69
70 /*
71 Description:
72 Extrude a curve to create a surface.
73 Parameters:
74 pCurve - [in] pointer to a curve. This pointer will
75 be assigned to m_curve[0] and will be deleted
76 by ~ON_SumSurface.
77 extrusion_vector - [in] extrusion vector (must be nonzero)
78 Returns:
79 true if a valid surface is created.
80 */
81 ON_BOOL32 Create( ON_Curve* pCurve, ON_3dVector extrusion_vector );
82
83 /*
84 Description:
85 Extrude a curve along a path to create a surface.
86 Parameters:
87 curve - [in] curve is copied.
88 path_curve - [in] path_curve is copied.
89 Returns:
90 true if a valid surface is created.
91 */
92 ON_BOOL32 Create( const ON_Curve& curve,
93 const ON_Curve& path_curve
94 );
95
96 /*
97 Description:
98 Extrude a curve to create a surface.
99 Parameters:
100 pCurve - [in] pointer to a curve. This pointer will
101 be assigned to m_curve[0] and will be deleted
102 by ~ON_SumSurface.
103 pPathCurve - [in] pointer to a path curve. This pointer will
104 be assigned to m_curve[1] and will be deleted
105 by ~ON_SumSurface.
106 Returns:
107 true if a valid surface is created.
108 */
109 ON_BOOL32 Create(
110 ON_Curve* pCurve,
111 ON_Curve* pPathCurve
112 );
113
114 void Destroy();
115
117
118
119 ////////////////////////////////////////////////////////////
120 //
121 // overrides of virtual ON_Object functions
122 //
123
124 // virtual ON_Object::SizeOf override
125 unsigned int SizeOf() const;
126
127 // virtual ON_Object::DataCRC override
128 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
129
130 /*
131 Description:
132 Tests an object to see if its data members are correctly
133 initialized.
134 Parameters:
135 text_log - [in] if the object is not valid and text_log
136 is not NULL, then a brief englis description of the
137 reason the object is not valid is appened to the log.
138 The information appended to text_log is suitable for
139 low-level debugging purposes by programmers and is
140 not intended to be useful as a high level user
141 interface tool.
142 Returns:
143 @untitled table
144 true object is valid
145 false object is invalid, uninitialized, etc.
146 */
147 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
148
149 void Dump( ON_TextLog& ) const; // for debugging
150
151 // Use ON_BinaryArchive::WriteObject() and ON_BinaryArchive::ReadObject()
152 // for top level serialization. These Read()/Write() members should just
153 // write/read specific definitions. In particular, they should not write/
154 // read any chunk typecode or length information. The default
155 // implementations return false and do nothing.
156 ON_BOOL32 Write(
157 ON_BinaryArchive& // serialize definition to binary archive
158 ) const;
159
160 ON_BOOL32 Read(
161 ON_BinaryArchive& // restore definition from binary archive
162 );
163
164 ////////////////////////////////////////////////////////////
165 //
166 // overrides of virtual ON_Geometry functions
167 //
168 int Dimension() const;
169
170 ON_BOOL32 GetBBox(
171 double* boxmin,
172 double* boxmax,
173 int bGrowBox = false
174 ) const;
175
177
178 ON_BOOL32 Transform(
179 const ON_Xform&
180 );
181
182 // virtual ON_Geometry::IsDeformable() override
183 bool IsDeformable() const;
184
185 // virtual ON_Geometry::MakeDeformable() override
187
188 ////////////////////////////////////////////////////////////
189 //
190 // overrides of virtual ON_Surface functions
191 //
192 ON_BOOL32 SetDomain(
193 int dir, // 0 sets first parameter's domain, 1 gets second parameter's domain
194 double t0,
195 double t1
196 );
197
199 int // 0 gets first parameter's domain, 1 gets second parameter's domain
200 ) const;
201
202 /*
203 Description:
204 Get an estimate of the size of the rectangle that would
205 be created if the 3d surface where flattened into a rectangle.
206 Parameters:
207 width - [out] (corresponds to the first surface parameter)
208 height - [out] (corresponds to the first surface parameter)
209 Remarks:
210 overrides virtual ON_Surface::GetSurfaceSize
211 Returns:
212 true if successful.
213 */
214 ON_BOOL32 GetSurfaceSize(
215 double* width,
216 double* height
217 ) const;
218
220 int // 0 gets first parameter's domain, 1 gets second parameter's domain
221 ) const; // number of smooth spans in curve
222
223 ON_BOOL32 GetSpanVector( // span "knots"
224 int, // 0 gets first parameter's domain, 1 gets second parameter's domain
225 double* // array of length SpanCount() + 1
226 ) const; //
227
228 int Degree( // returns maximum algebraic degree of any span
229 // ( or a good estimate if curve spans are not algebraic )
230 int // 0 gets first parameter's domain, 1 gets second parameter's domain
231 ) const;
232
233 ON_BOOL32 GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus
234 int, // 0 gets first parameter, 1 gets second parameter
235 double, // t = parameter in domain
236 double*, // tminus
237 double* // tplus
238 ) const;
239
240 /*
241 Description:
242 Test a surface to see if it is planar.
243 Parameters:
244 plane - [out] if not NULL and true is returned,
245 the plane parameters are filled in.
246 tolerance - [in] tolerance to use when checking
247 Returns:
248 true if there is a plane such that the maximum distance from
249 the surface to the plane is <= tolerance.
250 Remarks:
251 Overrides virtual ON_Surface::IsPlanar.
252 */
253 ON_BOOL32 IsPlanar(
254 ON_Plane* plane = NULL,
255 double tolerance = ON_ZERO_TOLERANCE
256 ) const;
257
258 ON_BOOL32 IsClosed( // true if surface is closed in direction
259 int // dir 0 = "s", 1 = "t"
260 ) const;
261
262 ON_BOOL32 IsPeriodic( // true if surface is periodic in direction
263 int // dir 0 = "s", 1 = "t"
264 ) const;
265
266 ON_BOOL32 IsSingular( // true if surface side is collapsed to a point
267 int // side of parameter space to test
268 // 0 = south, 1 = east, 2 = north, 3 = west
269 ) const;
270
271 /*
272 Description:
273 Search for a derivatitive, tangent, or curvature
274 discontinuity.
275 Parameters:
276 dir - [in] If 0, then "u" parameter is checked. If 1, then
277 the "v" parameter is checked.
278 c - [in] type of continity to test for.
279 t0 - [in] Search begins at t0. If there is a discontinuity
280 at t0, it will be ignored. This makes it
281 possible to repeatedly call GetNextDiscontinuity
282 and step through the discontinuities.
283 t1 - [in] (t0 != t1) If there is a discontinuity at t1 is
284 will be ingored unless c is a locus discontinuity
285 type and t1 is at the start or end of the curve.
286 t - [out] if a discontinuity is found, then *t reports the
287 parameter at the discontinuity.
288 hint - [in/out] if GetNextDiscontinuity will be called
289 repeatedly, passing a "hint" with initial value *hint=0
290 will increase the speed of the search.
291 dtype - [out] if not NULL, *dtype reports the kind of
292 discontinuity found at *t. A value of 1 means the first
293 derivative or unit tangent was discontinuous. A value
294 of 2 means the second derivative or curvature was
295 discontinuous. A value of 0 means teh curve is not
296 closed, a locus discontinuity test was applied, and
297 t1 is at the start of end of the curve.
298 cos_angle_tolerance - [in] default = cos(1 degree) Used only
299 when c is ON::G1_continuous or ON::G2_continuous. If the
300 cosine of the angle between two tangent vectors is
301 <= cos_angle_tolerance, then a G1 discontinuity is reported.
302 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used
303 only when c is ON::G2_continuous. If K0 and K1 are
304 curvatures evaluated from above and below and
305 |K0 - K1| > curvature_tolerance, then a curvature
306 discontinuity is reported.
307 Returns:
308 Parametric continuity tests c = (C0_continuous, ..., G2_continuous):
309
310 true if a parametric discontinuity was found strictly
311 between t0 and t1. Note well that all curves are
312 parametrically continuous at the ends of their domains.
313
314 Locus continuity tests c = (C0_locus_continuous, ...,G2_locus_continuous):
315
316 true if a locus discontinuity was found strictly between
317 t0 and t1 or at t1 is the at the end of a curve.
318 Note well that all open curves (IsClosed()=false) are locus
319 discontinuous at the ends of their domains. All closed
320 curves (IsClosed()=true) are at least C0_locus_continuous at
321 the ends of their domains.
322 */
324 int dir,
325 ON::continuity c,
326 double t0,
327 double t1,
328 double* t,
329 int* hint=NULL,
330 int* dtype=NULL,
331 double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
332 double curvature_tolerance=ON_SQRT_EPSILON
333 ) const;
334
335 /*
336 Description:
337 Test continuity at a surface parameter value.
338 Parameters:
339 c - [in] continuity to test for
340 s - [in] surface parameter to test
341 t - [in] surface parameter to test
342 hint - [in] evaluation hint
343 point_tolerance - [in] if the distance between two points is
344 greater than point_tolerance, then the surface is not C0.
345 d1_tolerance - [in] if the difference between two first derivatives is
346 greater than d1_tolerance, then the surface is not C1.
347 d2_tolerance - [in] if the difference between two second derivatives is
348 greater than d2_tolerance, then the surface is not C2.
349 cos_angle_tolerance - [in] default = cos(1 degree) Used only when
350 c is ON::G1_continuous or ON::G2_continuous. If the cosine
351 of the angle between two normal vectors
352 is <= cos_angle_tolerance, then a G1 discontinuity is reported.
353 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
354 c is ON::G2_continuous. If K0 and K1 are curvatures evaluated
355 from above and below and |K0 - K1| > curvature_tolerance,
356 then a curvature discontinuity is reported.
357 Returns:
358 true if the surface has at least the c type continuity at the parameter t.
359 Remarks:
360 Overrides virtual ON_Surface::IsContinuous
361 */
363 ON::continuity c,
364 double s,
365 double t,
366 int* hint = NULL,
367 double point_tolerance=ON_ZERO_TOLERANCE,
368 double d1_tolerance=ON_ZERO_TOLERANCE,
369 double d2_tolerance=ON_ZERO_TOLERANCE,
370 double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
371 double curvature_tolerance=ON_SQRT_EPSILON
372 ) const;
373
374 ON_BOOL32 Reverse( // reverse parameterizatrion, Domain changes from [a,b] to [-b,-a]
375 int // dir 0 = "s", 1 = "t"
376 );
377
378 ON_BOOL32 Transpose(); // transpose surface parameterization (swap "s" and "t")
379
380 ON_BOOL32 Evaluate( // returns false if unable to evaluate
381 double, double, // evaluation parameters
382 int, // number of derivatives (>=0)
383 int, // array stride (>=Dimension())
384 double*, // array of length stride*(ndir+1)*(ndir+2)/2
385 int = 0, // optional - determines which quadrant to evaluate from
386 // 0 = default
387 // 1 from NE quadrant
388 // 2 from NW quadrant
389 // 3 from SW quadrant
390 // 4 from SE quadrant
391 int* = 0 // optional - evaluation hint (int[2]) used to speed
392 // repeated evaluations
393 ) const;
394
396 int, // 0 first parameter varies and second parameter is constant
397 // e.g., point on IsoCurve(0,c) at t is srf(t,c)
398 // 1 first parameter is constant and second parameter varies
399 // e.g., point on IsoCurve(1,c) at t is srf(c,t)
400 double // value of constant parameter
401 ) const;
402
403 int GetNurbForm( // returns 0: unable to create NURBS representation
404 // with desired accuracy.
405 // 1: success - returned NURBS parameterization
406 // matches the surface's to wthe desired accuracy
407 // 2: success - returned NURBS point locus matches
408 // the surfaces's to the desired accuracy but, on
409 // the interior of the surface's domain, the
410 // surface's parameterization and the NURBS
411 // parameterization may not match to the
412 // desired accuracy.
414 double = 0.0
415 ) const;
416
417 int HasNurbForm( // returns 0: unable to create NURBS representation
418 // with desired accuracy.
419 // 1: success - returned NURBS parameterization
420 // matches the surface's to wthe desired accuracy
421 // 2: success - returned NURBS point locus matches
422 // the surfaces's to the desired accuracy but, on
423 // the interior of the surface's domain, the
424 // surface's parameterization and the NURBS
425 // parameterization may not match to the
426 // desired accuracy.
427 ) const;
428
430 double nurbs_s, double nurbs_t,
431 double* surface_s, double* surface_t
432 ) const;
433
435 double surface_s, double surface_t,
436 double* nurbs_s, double* nurbs_t
437 ) const;
438
439
440 /*
441 Description:
442 Removes the portions of the surface outside of the specified interval.
443
444 Parameters:
445 dir - [in] 0 The domain specifies an sub-interval of Domain(0)
446 (the first surface parameter).
447 1 The domain specifies an sub-interval of Domain(1)
448 (the second surface parameter).
449 domain - [in] interval of the surface to keep. If dir is 0, then
450 the portions of the surface with parameters (s,t) satisfying
451 s < Domain(0).Min() or s > Domain(0).Max() are trimmed away.
452 If dir is 1, then the portions of the surface with parameters
453 (s,t) satisfying t < Domain(1).Min() or t > Domain(1).Max()
454 are trimmed away.
455 */
456 ON_BOOL32 Trim(
457 int dir,
458 const ON_Interval& domain
459 );
460
461 /*
462 Description:
463 Where possible, analytically extends surface to include domain.
464 Parameters:
465 dir - [in] 0 new Domain(0) will include domain.
466 (the first surface parameter).
467 1 new Domain(1) will include domain.
468 (the second surface parameter).
469 domain - [in] if domain is not included in surface domain,
470 surface will be extended so that its domain includes domain.
471 Will not work if surface is closed in direction dir.
472 Original surface is identical to the restriction of the
473 resulting surface to the original surface domain,
474 Returns:
475 true if successful.
476 */
477 bool Extend(
478 int dir,
479 const ON_Interval& domain
480 );
481
482 /*
483 Description:
484 Splits (divides) the surface into two parts at the
485 specified parameter.
486
487 Parameters:
488 dir - [in] 0 The surface is split vertically. The "west" side
489 is returned in "west_or_south_side" and the "east"
490 side is returned in "east_or_north_side".
491 1 The surface is split horizontally. The "south" side
492 is returned in "west_or_south_side" and the "north"
493 side is returned in "east_or_north_side".
494 c - [in] value of constant parameter in interval returned
495 by Domain(dir)
496 west_or_south_side - [out] west/south portion of surface returned here
497 east_or_north_side - [out] east/north portion of surface returned here
498
499 Example:
500
501 ON_SumSurface srf = ...;
502 int dir = 1;
503 ON_SumSurface* south_side = 0;
504 ON_SumSurface* north_side = 0;
505 srf.Split( dir, srf.Domain(dir).Mid() south_side, north_side );
506
507 */
508 ON_BOOL32 Split(
509 int dir,
510 double c,
511 ON_Surface*& west_or_south_side,
512 ON_Surface*& east_or_north_side
513 ) const;
514};
515
516#endif
ON_BOOL32 GetParameterTolerance(int, double, double *, double *) const
bool IsContinuous(ON::continuity c, double s, double t, int *hint=NULL, 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
ON_BOOL32 Create(ON_Curve *pCurve, ON_Curve *pPathCurve)
ON_BOOL32 IsPeriodic(int) const
ON_BOOL32 Split(int dir, double c, ON_Surface *&west_or_south_side, ON_Surface *&east_or_north_side) const
ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const
ON_BoundingBox m_bbox
ON_SumSurface(const ON_SumSurface &)
bool MakeDeformable()
ON_BOOL32 GetBBox(double *boxmin, double *boxmax, int bGrowBox=false) const
ON_BOOL32 GetSurfaceSize(double *width, double *height) const
unsigned int SizeOf() const
ON_3dVector m_basepoint
ON_BOOL32 Transpose()
void Dump(ON_TextLog &) const
bool GetSurfaceParameterFromNurbFormParameter(double nurbs_s, double nurbs_t, double *surface_s, double *surface_t) const
int SpanCount(int) const
ON_Interval Domain(int) const
bool Extend(int dir, const ON_Interval &domain)
bool IsDeformable() const
static ON_SumSurface * New()
ON_BOOL32 Reverse(int)
int GetNurbForm(ON_NurbsSurface &, double=0.0) const
static ON_SumSurface * New(const ON_SumSurface &rev_surface)
int Dimension() const
ON_BOOL32 SetDomain(int dir, double t0, double t1)
ON_BOOL32 Read(ON_BinaryArchive &)
void DestroyRuntimeCache(bool bDelete=true)
ON_BOOL32 IsPlanar(ON_Plane *plane=NULL, double tolerance=ON_ZERO_TOLERANCE) const
ON_Curve * IsoCurve(int, double) const
int Degree(int) const
void EmergencyDestroy()
ON_SumSurface & operator=(const ON_SumSurface &)
bool GetNurbFormParameterFromSurfaceParameter(double surface_s, double surface_t, double *nurbs_s, double *nurbs_t) const
ON_BOOL32 Create(ON_Curve *pCurve, ON_3dVector extrusion_vector)
bool GetNextDiscontinuity(int dir, ON::continuity c, double t0, double t1, double *t, int *hint=NULL, int *dtype=NULL, double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE, double curvature_tolerance=ON_SQRT_EPSILON) const
ON_BOOL32 Evaluate(double, double, int, int, double *, int=0, int *=0) const
void ClearBoundingBox()
ON_BOOL32 Write(ON_BinaryArchive &) const
ON_BOOL32 Create(const ON_Curve &curve, ON_3dVector extrusion_vector)
ON_BOOL32 IsSingular(int) const
ON_BOOL32 Trim(int dir, const ON_Interval &domain)
ON_BOOL32 Create(const ON_Curve &curve, const ON_Curve &path_curve)
ON_BOOL32 Transform(const ON_Xform &)
ON_BOOL32 GetSpanVector(int, double *) const
ON_BOOL32 IsClosed(int) const
int HasNurbForm() const
ON__UINT32 DataCRC(ON__UINT32 current_remainder) const