QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_surfaceproxy.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
17//
18// Definition of surface proxy object
19//
21
22#if !defined(OPENNURBS_SURFACEPROXY_INC_)
23#define OPENNURBS_SURFACEPROXY_INC_
24
25class ON_Curve;
26class ON_NurbsSurface;
28{
29public:
30 // virtual ON_Object::DestroyRuntimeCache override
31 void DestroyRuntimeCache( bool bDelete = true );
32
33public:
38
39 virtual ~ON_SurfaceProxy();
40
41 void SetProxySurface( const ON_Surface* proxy_surface );
42 const ON_Surface* ProxySurface() const;
43 bool ProxySurfaceIsTransposed() const;
44
45private:
47 bool m_bTransposed; // proxy surface parameterization is transpose of m_surface
48
49public:
50 /*
51 Description:
52 Get a duplicate of the surface.
53 Returns:
54 A duplicate of the surface.
55 Remarks:
56 The caller must delete the returned surface.
57 For non-ON_SurfaceProxy objects, this simply duplicates the surface using
58 ON_Object::Duplicate.
59 For ON_SurfaceProxy objects, this duplicates the actual proxy surface
60 geometry and, if necessary, transposes the result to that
61 the returned surfaces's parameterization and locus match the proxy surface's.
62 */
63 virtual
65
67 // ON_Object overrides
68
69 // virtual ON_Object::SizeOf override
70 unsigned int SizeOf() const;
71
72 // virtual ON_Object::DataCRC override
73 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
74
75 /*
76 Description:
77 Tests an object to see if its data members are correctly
78 initialized.
79 Parameters:
80 text_log - [in] if the object is not valid and text_log
81 is not NULL, then a brief englis description of the
82 reason the object is not valid is appened to the log.
83 The information appended to text_log is suitable for
84 low-level debugging purposes by programmers and is
85 not intended to be useful as a high level user
86 interface tool.
87 Returns:
88 @untitled table
89 true object is valid
90 false object is invalid, uninitialized, etc.
91 Remarks:
92 Overrides virtual ON_Object::IsValid
93 */
94 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
95
96 void Dump( ON_TextLog& ) const; // for debugging
97
99 ON_BinaryArchive& // open binary file
100 ) const;
101
103 ON_BinaryArchive& // open binary file
104 );
105
107 // ON_Geometry overrides
108
109 int Dimension() const;
110
111 ON_BOOL32 GetBBox( // returns true if successful
112 double*, // minimum
113 double*, // maximum
114 ON_BOOL32 = false // true means grow box
115 ) const;
116
118 const ON_Xform&
119 );
120
122 // ON_Surface overrides
124 const ON_MeshParameters& mp,
125 ON_Mesh* mesh = NULL
126 ) const;
127
129 int // 0 gets first parameter's domain, 1 gets second parameter's domain
130 ) const;
131
132
133 /*
134 Description:
135 Get an estimate of the size of the rectangle that would
136 be created if the 3d surface where flattened into a rectangle.
137 Parameters:
138 width - [out] (corresponds to the first surface parameter)
139 height - [out] (corresponds to the first surface parameter)
140 Remarks:
141 overrides virtual ON_Surface::GetSurfaceSize
142 Returns:
143 true if successful.
144 */
146 double* width,
147 double* height
148 ) const;
149
150 int SpanCount(
151 int // 0 gets first parameter's domain, 1 gets second parameter's domain
152 ) const; // number of smooth spans in curve
153
154 ON_BOOL32 GetSpanVector( // span "knots"
155 int, // 0 gets first parameter's domain, 1 gets second parameter's domain
156 double* // array of length SpanCount() + 1
157 ) const; //
158
159 int Degree( // returns maximum algebraic degree of any span
160 // ( or a good estimate if curve spans are not algebraic )
161 int // 0 gets first parameter's domain, 1 gets second parameter's domain
162 ) const;
163
164
165 ON_BOOL32 GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus
166 int, // 0 gets first parameter, 1 gets second parameter
167 double, // t = parameter in domain
168 double*, // tminus
169 double* // tplus
170 ) const;
171
172 // override virtual ON_Surface::IsIsoparametric
174 const ON_Curve& curve,
175 const ON_Interval* curve_domain = NULL
176 ) const;
177
178 // override virtual ON_Surface::IsIsoparametric
180 const ON_BoundingBox& bbox
181 ) const;
182
183 /*
184 Description:
185 Test a surface to see if it is planar.
186 Parameters:
187 plane - [out] if not NULL and true is returned,
188 the plane parameters are filled in.
189 tolerance - [in] tolerance to use when checking
190 Returns:
191 true if there is a plane such that the maximum distance from
192 the surface to the plane is <= tolerance.
193 Remarks:
194 Overrides virtual ON_Surface::IsPlanar.
195 */
197 ON_Plane* plane = NULL,
198 double tolerance = ON_ZERO_TOLERANCE
199 ) const;
200
201 ON_BOOL32 IsClosed( // true if surface is closed in direction
202 int // dir 0 = "s", 1 = "t"
203 ) const;
204
205 ON_BOOL32 IsPeriodic( // true if surface is periodic in direction
206 int // dir 0 = "s", 1 = "t"
207 ) const;
208
209 ON_BOOL32 IsSingular( // true if surface side is collapsed to a point
210 int // side of parameter space to test
211 // 0 = south, 1 = east, 2 = north, 3 = west
212 ) const;
213
214 /*
215 Description:
216 Search for a derivatitive, tangent, or curvature
217 discontinuity.
218 Parameters:
219 dir - [in] If 0, then "u" parameter is checked. If 1, then
220 the "v" parameter is checked.
221 c - [in] type of continity to test for.
222 t0 - [in] Search begins at t0. If there is a discontinuity
223 at t0, it will be ignored. This makes it
224 possible to repeatedly call GetNextDiscontinuity
225 and step through the discontinuities.
226 t1 - [in] (t0 != t1) If there is a discontinuity at t1 is
227 will be ingored unless c is a locus discontinuity
228 type and t1 is at the start or end of the curve.
229 t - [out] if a discontinuity is found, then *t reports the
230 parameter at the discontinuity.
231 hint - [in/out] if GetNextDiscontinuity will be called
232 repeatedly, passing a "hint" with initial value *hint=0
233 will increase the speed of the search.
234 dtype - [out] if not NULL, *dtype reports the kind of
235 discontinuity found at *t. A value of 1 means the first
236 derivative or unit tangent was discontinuous. A value
237 of 2 means the second derivative or curvature was
238 discontinuous. A value of 0 means teh curve is not
239 closed, a locus discontinuity test was applied, and
240 t1 is at the start of end of the curve.
241 cos_angle_tolerance - [in] default = cos(1 degree) Used only
242 when c is ON::G1_continuous or ON::G2_continuous. If the
243 cosine of the angle between two tangent vectors is
244 <= cos_angle_tolerance, then a G1 discontinuity is reported.
245 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used
246 only when c is ON::G2_continuous. If K0 and K1 are
247 curvatures evaluated from above and below and
248 |K0 - K1| > curvature_tolerance, then a curvature
249 discontinuity is reported.
250 Returns:
251 Parametric continuity tests c = (C0_continuous, ..., G2_continuous):
252
253 true if a parametric discontinuity was found strictly
254 between t0 and t1. Note well that all curves are
255 parametrically continuous at the ends of their domains.
256
257 Locus continuity tests c = (C0_locus_continuous, ...,G2_locus_continuous):
258
259 true if a locus discontinuity was found strictly between
260 t0 and t1 or at t1 is the at the end of a curve.
261 Note well that all open curves (IsClosed()=false) are locus
262 discontinuous at the ends of their domains. All closed
263 curves (IsClosed()=true) are at least C0_locus_continuous at
264 the ends of their domains.
265 */
267 int dir,
268 ON::continuity c,
269 double t0,
270 double t1,
271 double* t,
272 int* hint=NULL,
273 int* dtype=NULL,
274 double cos_angle_tolerance=0.99984769515639123915701155881391,
275 double curvature_tolerance=ON_SQRT_EPSILON
276 ) const;
277
278 /*
279 Description:
280 Test continuity at a surface parameter value.
281 Parameters:
282 c - [in] continuity to test for
283 s - [in] surface parameter to test
284 t - [in] surface parameter to test
285 hint - [in] evaluation hint
286 point_tolerance - [in] if the distance between two points is
287 greater than point_tolerance, then the surface is not C0.
288 d1_tolerance - [in] if the difference between two first derivatives is
289 greater than d1_tolerance, then the surface is not C1.
290 d2_tolerance - [in] if the difference between two second derivatives is
291 greater than d2_tolerance, then the surface is not C2.
292 cos_angle_tolerance - [in] default = cos(1 degree) Used only when
293 c is ON::G1_continuous or ON::G2_continuous. If the cosine
294 of the angle between two normal vectors
295 is <= cos_angle_tolerance, then a G1 discontinuity is reported.
296 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
297 c is ON::G2_continuous. If K0 and K1 are curvatures evaluated
298 from above and below and |K0 - K1| > curvature_tolerance,
299 then a curvature discontinuity is reported.
300 Returns:
301 true if the surface has at least the c type continuity at the parameter t.
302 Remarks:
303 Overrides virtual ON_Surface::IsContinuous
304 */
305 bool IsContinuous(
306 ON::continuity c,
307 double s,
308 double t,
309 int* hint = NULL,
310 double point_tolerance=ON_ZERO_TOLERANCE,
311 double d1_tolerance=ON_ZERO_TOLERANCE,
312 double d2_tolerance=ON_ZERO_TOLERANCE,
313 double cos_angle_tolerance=0.99984769515639123915701155881391,
314 double curvature_tolerance=ON_SQRT_EPSILON
315 ) const;
316
317 ON_BOOL32 Reverse( // reverse parameterizatrion, Domain changes from [a,b] to [-b,-a]
318 int // dir 0 = "s", 1 = "t"
319 );
320
321 ON_BOOL32 Transpose(); // transpose surface parameterization (swap "s" and "t")
322
323 // work horse evaluator
324 ON_BOOL32 Evaluate( // returns false if unable to evaluate
325 double, double, // evaluation parameters
326 int, // number of derivatives (>=0)
327 int, // array stride (>=Dimension())
328 double*, // array of length stride*(ndir+1)*(ndir+2)/2
329 int = 0, // optional - determines which quadrant to evaluate from
330 // 0 = default
331 // 1 from NE quadrant
332 // 2 from NW quadrant
333 // 3 from SW quadrant
334 // 4 from SE quadrant
335 int* = 0 // optional - evaluation hint (int[2]) used to speed
336 // repeated evaluations
337 ) const;
338
339
341 int dir,
342 double c
343 ) const;
344
345 ON_Curve* Pushup( const ON_Curve& curve_2d,
346 double tolerance,
347 const ON_Interval* curve_2d_subdomain = NULL
348 ) const;
349
350 ON_Curve* Pullback( const ON_Curve& curve_3d,
351 double tolerance,
352 const ON_Interval* curve_3d_subdomain = NULL,
353 ON_3dPoint start_uv = ON_UNSET_POINT,
355 ) const;
356
357
358 /*
359 Description:
360 Get the parameters of the point on the surface that is closest to P.
361 Parameters:
362 P - [in]
363 test point
364 s - [out]
365 t - [out]
366 (*s,*t) = parameters of the surface point that
367 is closest to P.
368 maximum_distance = 0.0 - [in]
369 optional upper bound on the distance from P to
370 the surface. If you are only interested in
371 finding a point Q on the surface when
372 P.DistanceTo(Q) < maximum_distance, then set
373 maximum_distance to that value.
374 sdomain = 0 - [in] optional domain restriction
375 tdomain = 0 - [in] optional domain restriction
376 Returns:
377 True if successful. If false, the values of *s and *t
378 are undefined.
379 See Also:
380 ON_Surface::GetLocalClosestPoint.
381 */
382 bool GetClosestPoint(
383 const ON_3dPoint& P,
384 double* s,
385 double* t,
386 double maximum_distance = 0.0,
387 const ON_Interval* sdomain = 0,
388 const ON_Interval* tdomain = 0
389 ) const;
390
392 // Find parameters of the point on a surface that is locally closest to
393 // the test_point. The search for a local close point starts at
394 // seed parameters. If a sub_domain parameter is not NULL, then
395 // the search is restricted to the specified portion of the surface.
396 //
397 // true if returned if the search is successful. false is returned if
398 // the search fails.
399 ON_BOOL32 GetLocalClosestPoint( const ON_3dPoint&, // test_point
400 double,double, // seed_parameters
401 double*,double*, // parameters of local closest point returned here
402 const ON_Interval* = NULL, // first parameter sub_domain
403 const ON_Interval* = NULL // second parameter sub_domain
404 ) const;
405
406 /*
407 Description:
408 Offset surface.
409 Parameters:
410 offset_distance - [in] offset distance
411 tolerance - [in] Some surfaces do not have an exact offset that
412 can be represented using the same class of surface definition.
413 In that case, the tolerance specifies the desired accuracy.
414 max_deviation - [out] If this parameter is not NULL, the maximum
415 deviation from the returned offset to the true offset is returned
416 here. This deviation is zero except for cases where an exact
417 offset cannot be computed using the same class of surface definition.
418 Remarks:
419 Overrides virtual ON_Surface::Offset.
420 Returns:
421 Offset surface.
422 */
424 double offset_distance,
425 double tolerance,
426 double* max_deviation = NULL
427 ) const;
428
429 int GetNurbForm( // returns 0: unable to create NURBS representation
430 // with desired accuracy.
431 // 1: success - returned NURBS parameterization
432 // matches the surface's to wthe desired accuracy
433 // 2: success - returned NURBS point locus matches
434 // the surfaces's to the desired accuracy but, on
435 // the interior of the surface's domain, the
436 // surface's parameterization and the NURBS
437 // parameterization may not match to the
438 // desired accuracy.
440 double = 0.0
441 ) const;
442
443 int HasNurbForm( // returns 0: unable to create NURBS representation
444 // with desired accuracy.
445 // 1: success - returned NURBS parameterization
446 // matches the surface's to wthe desired accuracy
447 // 2: success - returned NURBS point locus matches
448 // the surfaces's to the desired accuracy but, on
449 // the interior of the surface's domain, the
450 // surface's parameterization and the NURBS
451 // parameterization may not match to the
452 // desired accuracy.
453 ) const;
454
456 double nurbs_s, double nurbs_t,
457 double* surface_s, double* surface_t
458 ) const;
459
461 double surface_s, double surface_t,
462 double* nurbs_s, double* nurbs_t
463 ) const;
464
465private:
466
468};
469
470#endif
@ Transform
Definition RSMetaType.h:67
Definition opennurbs_point.h:403
Definition opennurbs_archive.h:152
Definition opennurbs_bounding_box.h:25
Definition opennurbs_curve.h:88
virtual ON_BOOL32 GetBBox(double *boxmin, double *boxmax, int bGrowBox=false) const =0
virtual int Dimension() const =0
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_surface.h:58
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_Surface * Offset(double offset_distance, double tolerance, double *max_deviation=NULL) const
Definition opennurbs_surface.cpp:2081
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 ON_Curve * Pushup(const ON_Curve &curve_2d, double tolerance, const ON_Interval *curve_2d_subdomain=NULL) const
Definition opennurbs_surface.cpp:1224
virtual ON_BOOL32 GetSurfaceSize(double *width, double *height) const
Definition opennurbs_surface.cpp:81
ISO
Definition opennurbs_surface.h:73
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_Curve * Pullback(const ON_Curve &curve_3d, double tolerance, const ON_Interval *curve_3d_subdomain=NULL, ON_3dPoint start_uv=ON_UNSET_POINT, ON_3dPoint end_uv=ON_UNSET_POINT) const
Definition opennurbs_surface.cpp:1441
virtual ISO IsIsoparametric(const ON_Curve &curve, const ON_Interval *curve_domain=NULL) const
Definition opennurbs_surface.cpp:162
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 ON_BOOL32 GetLocalClosestPoint(const ON_3dPoint &, double, double, double *, double *, const ON_Interval *=NULL, const ON_Interval *=NULL) const
Definition opennurbs_surface.cpp:2053
virtual bool GetClosestPoint(const ON_3dPoint &P, double *s, double *t, double maximum_distance=0.0, const ON_Interval *sdomain=0, const ON_Interval *tdomain=0) const
Definition opennurbs_surface.cpp:1967
virtual bool GetNurbFormParameterFromSurfaceParameter(double surface_s, double surface_t, double *nurbs_s, double *nurbs_t) const
Definition opennurbs_surface.cpp:2136
virtual ON_Surface * DuplicateSurface() const
Definition opennurbs_surface.cpp:63
Definition opennurbs_surfaceproxy.h:28
ON_OBJECT_DECLARE(ON_SurfaceProxy)
bool m_bTransposed
Definition opennurbs_surfaceproxy.h:47
const ON_Surface * m_surface
Definition opennurbs_surfaceproxy.h:46
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
const ON_3dPoint ON_UNSET_POINT(ON_UNSET_VALUE, ON_UNSET_VALUE, ON_UNSET_VALUE)
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