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