QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_nurbssurface.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 NURBS surface
19//
21
22#if !defined(OPENNURBS_NURBSSURFACE_INC_)
23#define OPENNURBS_NURBSSURFACE_INC_
24
26{
27 // Pure virtual tensor passed to ON_NurbsSurface::TensorProduct()
28public:
30
31 virtual
33
34 // Evaluate() must define a function T:R^dimA X R^dimB -> R^Dimension()
35 // such that
36 //
37 // T(a*A0 + (1-a)*A1, B) = a*T(A0,B) + (1-a)*T(A1,B) and
38 // T(A, b*B0 + (1-b)*B1) = b*T(A,B0) + (1-b)*T(A,B1).
39 virtual
40 int DimensionA() const = 0; // dimension of A space
41
42 virtual
43 int DimensionB() const = 0; // dimension of B space
44
45 virtual
46 int DimensionC() const = 0; // dimension of range space
47
48 virtual
49 bool Evaluate( double, // a
50 const double*, // A
51 double, // b
52 const double*, // B
53 double* // C
54 ) = 0;
55
56};
57
58class ON_Brep;
59class ON_NurbsSurface;
60
62{
64
65public:
66 /*
67 Description:
68 Use ON_NurbsSurface::New(...) instead of new ON_NurbsSurface(...)
69 Returns:
70 Pointer to an ON_NurbsSurface. Destroy by calling delete.
71 Remarks:
72 See static ON_Brep* ON_Brep::New() for details.
73 */
74 static ON_NurbsSurface* New();
75 static ON_NurbsSurface* New(
76 const ON_NurbsSurface& nurbs_surface
77 );
78 static ON_NurbsSurface* New(
79 const ON_BezierSurface& bezier_surface
80 );
81 static ON_NurbsSurface* New(
82 int dimension,
83 ON_BOOL32 bIsRational,
84 int order0,
85 int order1,
86 int cv_count0,
87 int cv_count1
88 );
89
91 ON_NurbsSurface(const ON_NurbsSurface& nurbs_surface);
92 ON_NurbsSurface(const ON_BezierSurface& bezier_surface);
94 int dimension, // dimension (>= 1)
95 ON_BOOL32 bIsRational, // true to make a rational NURBS
96 int order0, // order0 (>= 2)
97 int order1, // order1 (>= 2)
98 int cv_count0, // cv count0 (>= order0)
99 int cv_count1 // cv count1 (>= order1)
100 );
101
102 // virtual ON_Object::SizeOf override
103 unsigned int SizeOf() const;
104
105 // virtual ON_Object::DataCRC override
106 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
107
108 /*
109 Description:
110 See if this and other are same NURBS geometry.
111 Parameters:
112 other - [in] other NURBS surface
113 bIgnoreParameterization - [in] if true, parameterization
114 and orientaion are ignored.
115 tolerance - [in] tolerance to use when comparing
116 control points.
117 Returns:
118 true if curves are tne same.
119 */
120 bool IsDuplicate(
121 const ON_NurbsSurface& other,
122 bool bIgnoreParameterization,
123 double tolerance = ON_ZERO_TOLERANCE
124 ) const;
125
126 void Initialize(void); // zeros all fields
127
128 ON_BOOL32 Create(
129 int dim, // dimension (>= 1)
130 ON_BOOL32 is_rat, // true to make a rational NURBS
131 int order0, // order0 (>= 2)
132 int order1, // order1 (>= 2)
133 int cv_count0, // cv count0 (>= order0)
134 int cv_count1 // cv count1 (>= order1)
135 );
136
137 /*
138 Description:
139 Create a ruled surface from two curves.
140 Parameters:
141 curveA - [in] (must have same NURBS form knots as curveB)
142 curveB - [in] (must have same NURBS form knots as curveA)
143 curveA_domain - [in] if not NULL, then this is a subdomain
144 of curveA to use for the ruled surface.
145 curveB_domain - [in] if not NULL, then this is a subdomain
146 of curveA to use for the ruled surface.
147 Returns:
148 @untitled table
149 0 failure
150 1 success - parameterization is exact
151 2 success - parameterization is not exact
152 Remarks:
153 The ruling parameter is the second surface parameter and
154 it is in the interval [0,1].
155 The true ruled surface has parameterization
156 srf(s,t) = (1.0-t)*curveA(s) + t*curveB(s).
157 The returned NURBS surface has parameterization
158 srf(s,t) = (1.0-t)*nurbs_curveA(s) + t*nurbs_curveB(s),
159 where nurbs_curveX is the NURBS form of curveX. If the
160 parameterization of nurbs_curveX does not match the
161 parameterization of curveX, then 2 is returned.
162 */
163 virtual
164 int CreateRuledSurface(
165 const ON_Curve& curveA,
166 const ON_Curve& curveB,
167 const ON_Interval* curveA_domain = NULL,
168 const ON_Interval* curveB_domain = NULL
169 );
170
171 /*
172 Description:
173 Create a cone surface from a curve to a point.
174 Parameters:
175 apex_point - [in]
176 curve - [in]
177 curve_domain - [in] if not NULL, then this is a subdomain
178 of curve to use for the ruled surface.
179 Returns:
180 @untitled table
181 0 failure
182 1 success - parameterization is exact
183 2 success - parameterization is not exact
184 Remarks:
185 The ruling parameter is the second surface parameter and
186 it is in the interval [0,1].
187 The true cone surface has parameterization
188 srf(s,t) = (1.0-t)*curve(s) + t*apex_point.
189 The returned NURBS surface has parameterization
190 srf(s,t) = (1.0-t)*nurbs_curve(s) + t*apex_point,
191 where nurbs_curve is the NURBS form of curve. If the
192 parameterization of nurbs_curve does not match the
193 parameterization of curve, then 2 is returned.
194 */
195 int CreateConeSurface(
196 ON_3dPoint apex_point,
197 const ON_Curve& curve,
198 const ON_Interval* curve_domain = NULL
199 );
200
201 /*
202 Description:
203 Collapse the side of a NURBS surface to a single point.
204 Parameters:
205 side - [in] 0 = south west,
206 1 = south east,
207 2 = north east,
208 3 = north west
209 point - [in] point to collapse to. If point is ON_unset_point,
210 the the current location of the start of the side
211 is used.
212 Returns:
213 True if successful.
214 Remarks:
215 If the surface is rational, the weights of the side control
216 points must be set before calling CollapseSide.
217 */
218 bool CollapseSide(
219 int side,
221 );
222
223 void Destroy();
224
225 virtual ~ON_NurbsSurface();
226
227 void EmergencyDestroy(); // call if memory used by this class becomes invalid
228
229 ON_NurbsSurface& operator=(const ON_NurbsSurface&);
230
231 /*
232 Description:
233 Set NURBS surface equal to bezier surface with domain [0,1]x[0,1].
234 Parameters:
235 bezier_surface - [in]
236 */
237 ON_NurbsSurface& operator=(
238 const ON_BezierSurface& bezier_surface
239 );
240
242 // ON_Object overrides
243
244 /*
245 Description:
246 Tests an object to see if its data members are correctly
247 initialized.
248 Parameters:
249 text_log - [in] if the object is not valid and text_log
250 is not NULL, then a brief englis description of the
251 reason the object is not valid is appened to the log.
252 The information appended to text_log is suitable for
253 low-level debugging purposes by programmers and is
254 not intended to be useful as a high level user
255 interface tool.
256 Returns:
257 @untitled table
258 true object is valid
259 false object is invalid, uninitialized, etc.
260 Remarks:
261 Overrides virtual ON_Object::IsValid
262 */
263 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
264
265 void Dump( ON_TextLog& ) const; // for debugging
266
267 ON_BOOL32 Write(
268 ON_BinaryArchive& // open binary file
269 ) const;
270
271 ON_BOOL32 Read(
272 ON_BinaryArchive& // open binary file
273 );
274
276 // ON_Geometry overrides
277
278 int Dimension() const;
279
280 ON_BOOL32 GetBBox( // returns true if successful
281 double*, // minimum
282 double*, // maximum
283 ON_BOOL32 = false // true means grow box
284 ) const;
285
287 const ON_Xform&
288 );
289
290 // virtual ON_Geometry::IsDeformable() override
291 bool IsDeformable() const;
292
293 // virtual ON_Geometry::MakeDeformable() override
294 bool MakeDeformable();
295
296 ON_BOOL32 SwapCoordinates(
297 int, int // indices of coords to swap
298 );
299
300 // virtual ON_Geometry override
301 bool Morph( const ON_SpaceMorph& morph );
302
303 // virtual ON_Geometry override
304 bool IsMorphable() const;
305
307 // ON_Surface overrides
308
309 ON_Mesh* CreateMesh(
310 const ON_MeshParameters& mp,
311 ON_Mesh* mesh = NULL
312 ) const;
313
314 ON_BOOL32 SetDomain(
315 int dir, // 0 sets first parameter's domain, 1 gets second parameter's domain
316 double t0,
317 double t1
318 );
319
320 ON_Interval Domain(
321 int // 0 gets first parameter's domain, 1 gets second parameter's domain
322 ) const;
323
324
325 /*
326 Description:
327 Get an estimate of the size of the rectangle that would
328 be created if the 3d surface where flattened into a rectangle.
329 Parameters:
330 width - [out] (corresponds to the first surface parameter)
331 height - [out] (corresponds to the first surface parameter)
332 Remarks:
333 overrides virtual ON_Surface::GetSurfaceSize
334 Returns:
335 true if successful.
336 */
337 ON_BOOL32 GetSurfaceSize(
338 double* width,
339 double* height
340 ) const;
341
342 int SpanCount(
343 int // 0 gets first parameter's domain, 1 gets second parameter's domain
344 ) const; // number of smooth spans in curve
345
346 ON_BOOL32 GetSpanVector( // span "knots"
347 int, // 0 gets first parameter's domain, 1 gets second parameter's domain
348 double* // array of length SpanCount() + 1
349 ) const; //
350
351 int Degree( // returns maximum algebraic degree of any span
352 // ( or a good estimate if curve spans are not algebraic )
353 int // 0 gets first parameter's domain, 1 gets second parameter's domain
354 ) const;
355
356 ON_BOOL32 GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus
357 int, // 0 gets first parameter, 1 gets second parameter
358 double, // t = parameter in domain
359 double*, // tminus
360 double* // tplus
361 ) const;
362
363 /*
364 Description:
365 Test a surface to see if it is planar.
366 Parameters:
367 plane - [out] if not NULL and true is returned,
368 the plane parameters are filled in.
369 tolerance - [in] tolerance to use when checking
370 Returns:
371 true if there is a plane such that the maximum distance from
372 the surface to the plane is <= tolerance.
373 Remarks:
374 Overrides virtual ON_Surface::IsPlanar.
375 */
376 ON_BOOL32 IsPlanar(
377 ON_Plane* plane = NULL,
378 double tolerance = ON_ZERO_TOLERANCE
379 ) const;
380
381 ON_BOOL32 IsClosed( // true if NURBS surface is closed (either surface has
382 int // dir // clamped end knots and euclidean location of start
383 ) const; // CV = euclidean location of end CV, or surface is
384 // periodic.)
385
386 ON_BOOL32 IsPeriodic( // true if NURBS surface is periodic (degree > 1,
387 int // dir // periodic knot vector, last degree many CVs
388 ) const; // are duplicates of first degree many CVs.)
389
390 ON_BOOL32 IsSingular( // true if surface side is collapsed to a point
391 int // side of parameter space to test
392 // 0 = south, 1 = east, 2 = north, 3 = west
393 ) const;
394
395 /*
396 Description:
397 Search for a derivatitive, tangent, or curvature
398 discontinuity.
399 Parameters:
400 dir - [in] If 0, then "u" parameter is checked. If 1, then
401 the "v" parameter is checked.
402 c - [in] type of continity to test for.
403 t0 - [in] Search begins at t0. If there is a discontinuity
404 at t0, it will be ignored. This makes it
405 possible to repeatedly call GetNextDiscontinuity
406 and step through the discontinuities.
407 t1 - [in] (t0 != t1) If there is a discontinuity at t1 is
408 will be ingored unless c is a locus discontinuity
409 type and t1 is at the start or end of the curve.
410 t - [out] if a discontinuity is found, then *t reports the
411 parameter at the discontinuity.
412 hint - [in/out] if GetNextDiscontinuity will be called
413 repeatedly, passing a "hint" with initial value *hint=0
414 will increase the speed of the search.
415 dtype - [out] if not NULL, *dtype reports the kind of
416 discontinuity found at *t. A value of 1 means the first
417 derivative or unit tangent was discontinuous. A value
418 of 2 means the second derivative or curvature was
419 discontinuous. A value of 0 means teh curve is not
420 closed, a locus discontinuity test was applied, and
421 t1 is at the start of end of the curve.
422 cos_angle_tolerance - [in] default = cos(1 degree) Used only
423 when c is ON::G1_continuous or ON::G2_continuous. If the
424 cosine of the angle between two tangent vectors is
425 <= cos_angle_tolerance, then a G1 discontinuity is reported.
426 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used
427 only when c is ON::G2_continuous. If K0 and K1 are
428 curvatures evaluated from above and below and
429 |K0 - K1| > curvature_tolerance, then a curvature
430 discontinuity is reported.
431 Returns:
432 Parametric continuity tests c = (C0_continuous, ..., G2_continuous):
433
434 true if a parametric discontinuity was found strictly
435 between t0 and t1. Note well that all curves are
436 parametrically continuous at the ends of their domains.
437
438 Locus continuity tests c = (C0_locus_continuous, ...,G2_locus_continuous):
439
440 true if a locus discontinuity was found strictly between
441 t0 and t1 or at t1 is the at the end of a curve.
442 Note well that all open curves (IsClosed()=false) are locus
443 discontinuous at the ends of their domains. All closed
444 curves (IsClosed()=true) are at least C0_locus_continuous at
445 the ends of their domains.
446 */
447 bool GetNextDiscontinuity(
448 int dir,
449 ON::continuity c,
450 double t0,
451 double t1,
452 double* t,
453 int* hint=NULL,
454 int* dtype=NULL,
455 double cos_angle_tolerance=0.99984769515639123915701155881391,
456 double curvature_tolerance=ON_SQRT_EPSILON
457 ) const;
458
459 /*
460 Description:
461 Test continuity at a surface parameter value.
462 Parameters:
463 c - [in] continuity to test for
464 s - [in] surface parameter to test
465 t - [in] surface parameter to test
466 hint - [in] evaluation hint
467 point_tolerance - [in] if the distance between two points is
468 greater than point_tolerance, then the surface is not C0.
469 d1_tolerance - [in] if the difference between two first derivatives is
470 greater than d1_tolerance, then the surface is not C1.
471 d2_tolerance - [in] if the difference between two second derivatives is
472 greater than d2_tolerance, then the surface is not C2.
473 cos_angle_tolerance - [in] default = cos(1 degree) Used only when
474 c is ON::G1_continuous or ON::G2_continuous. If the cosine
475 of the angle between two normal vectors
476 is <= cos_angle_tolerance, then a G1 discontinuity is reported.
477 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
478 c is ON::G2_continuous. If K0 and K1 are curvatures evaluated
479 from above and below and |K0 - K1| > curvature_tolerance,
480 then a curvature discontinuity is reported.
481 Returns:
482 true if the surface has at least the c type continuity at the parameter t.
483 Remarks:
484 Overrides virtual ON_Surface::IsContinuous
485 */
486 bool IsContinuous(
487 ON::continuity c,
488 double s,
489 double t,
490 int* hint = NULL,
491 double point_tolerance=ON_ZERO_TOLERANCE,
492 double d1_tolerance=ON_ZERO_TOLERANCE,
493 double d2_tolerance=ON_ZERO_TOLERANCE,
494 double cos_angle_tolerance=0.99984769515639123915701155881391,
495 double curvature_tolerance=ON_SQRT_EPSILON
496 ) const;
497
498 ON_BOOL32 Reverse( // reverse parameterizatrion, Domain changes from [a,b] to [-b,-a]
499 int // dir 0 = "s", 1 = "t"
500 );
501
502 ON_BOOL32 Transpose(); // transpose surface parameterization (swap "s" and "t")
503
504 ON_BOOL32 Evaluate( // returns false if unable to evaluate
505 double, double, // evaluation parameter
506 int, // number of derivatives (>=0)
507 int, // array stride (>=Dimension())
508 double*, // array of length stride*(ndir+1)*(ndir+2)/2
509 int = 0, // optional - determines which quadrant to evaluate from
510 // 0 = default
511 // 1 from NE quadrant
512 // 2 from NW quadrant
513 // 3 from SW quadrant
514 // 4 from SE quadrant
515 int* = 0 // optional - evaluation hint (int[2]) used to speed
516 // repeated evaluations
517 ) const;
518
519 /*
520 Description:
521 Get isoparametric curve.
522 Overrides virtual ON_Surface::IsoCurve.
523 Parameters:
524 dir - [in] 0 first parameter varies and second parameter is constant
525 e.g., point on IsoCurve(0,c) at t is srf(t,c)
526 1 first parameter is constant and second parameter varies
527 e.g., point on IsoCurve(1,c) at t is srf(c,t)
528
529 c - [in] value of constant parameter
530 Returns:
531 Isoparametric curve.
532 */
533 ON_Curve* IsoCurve(
534 int dir,
535 double c
536 ) const;
537
538 /*
539 Description:
540 Removes the portions of the surface outside of the specified interval.
541 Overrides virtual ON_Surface::Trim.
542
543 Parameters:
544 dir - [in] 0 The domain specifies an sub-interval of Domain(0)
545 (the first surface parameter).
546 1 The domain specifies an sub-interval of Domain(1)
547 (the second surface parameter).
548 domain - [in] interval of the surface to keep. If dir is 0, then
549 the portions of the surface with parameters (s,t) satisfying
550 s < Domain(0).Min() or s > Domain(0).Max() are trimmed away.
551 If dir is 1, then the portions of the surface with parameters
552 (s,t) satisfying t < Domain(1).Min() or t > Domain(1).Max()
553 are trimmed away.
554 */
556 int dir,
557 const ON_Interval& domain
558 );
559
560 /*
561 Description:
562 Where possible, analytically extends surface to include domain.
563 Parameters:
564 dir - [in] 0 new Domain(0) will include domain.
565 (the first surface parameter).
566 1 new Domain(1) will include domain.
567 (the second surface parameter).
568 domain - [in] if domain is not included in surface domain,
569 surface will be extended so that its domain includes domain.
570 Will not work if surface is closed in direction dir.
571 Original surface is identical to the restriction of the
572 resulting surface to the original surface domain,
573 Returns:
574 true if successful.
575 */
576 bool Extend(
577 int dir,
578 const ON_Interval& domain
579 );
580
581
582 /*
583 Description:
584 Splits (divides) the surface into two parts at the
585 specified parameter.
586 Overrides virtual ON_Surface::Split.
587
588 Parameters:
589 dir - [in] 0 The surface is split vertically. The "west" side
590 is returned in "west_or_south_side" and the "east"
591 side is returned in "east_or_north_side".
592 1 The surface is split horizontally. The "south" side
593 is returned in "west_or_south_side" and the "north"
594 side is returned in "east_or_north_side".
595 c - [in] value of constant parameter in interval returned
596 by Domain(dir)
597 west_or_south_side - [out] west/south portion of surface returned here
598 east_or_north_side - [out] east/north portion of surface returned here
599
600 Example:
601
602 ON_NurbsSurface srf = ...;
603 int dir = 1;
604 ON_NurbsSurface* south_side = 0;
605 ON_NurbsSurface* north_side = 0;
606 srf.Split( dir, srf.Domain(dir).Mid() south_side, north_side );
607
608 */
609 ON_BOOL32 Split(
610 int dir,
611 double c,
612 ON_Surface*& west_or_south_side,
613 ON_Surface*& east_or_north_side
614 ) const;
615
616 /*
617 Description:
618 Offset surface.
619 Parameters:
620 offset_distance - [in] offset distance
621 tolerance - [in] Some surfaces do not have an exact offset that
622 can be represented using the same class of surface definition.
623 In that case, the tolerance specifies the desired accuracy.
624 max_deviation - [out] If this parameter is not NULL, the maximum
625 deviation from the returned offset to the true offset is returned
626 here. This deviation is zero except for cases where an exact
627 offset cannot be computed using the same class of surface definition.
628 Returns:
629 Offset surface.
630 */
632 double offset_distance,
633 double tolerance,
634 double* max_deviation = NULL
635 ) const;
636
637 int GetNurbForm( // returns 0: unable to create NURBS representation
638 // with desired accuracy.
639 // 1: success - returned NURBS parameterization
640 // matches the surface's to wthe desired accuracy
641 // 2: success - returned NURBS point locus matches
642 // the surfaces's to the desired accuracy but, on
643 // the interior of the surface's domain, the
644 // surface's parameterization and the NURBS
645 // parameterization may not match to the
646 // desired accuracy.
648 double = 0.0 // tolerance
649 ) const;
650
652 // Interface
653
654 /*
655 Description:
656 Get the maximum length of a nurb surface's control polygon
657 rows and/or columns
658 Parameters:
659 dir - [in] 0 to get "u" direction length, 1 to get "v"
660 direction length
661 length - [out] maximum length of a polygon "row" in the
662 specified direction
663 Returns:
664 true if successful.
665 */
666 double ControlPolygonLength( int dir ) const;
667
668
669 bool IsRational( // true if NURBS surface is rational
670 void
671 ) const;
672
673 int CVSize( // number of doubles per control vertex
674 void // = IsRational() ? Dim()+1 : Dim()
675 ) const;
676
677 int Order( // order = degree + 1
678 int // dir 0 = "s", 1 = "t"
679 ) const;
680
681 int CVCount( // number of control vertices
682 int // dir 0 = "s", 1 = "t"
683 ) const;
684
685 int CVCount( // total number of control vertices
686 void
687 ) const;
688
689 int KnotCount( // total number of knots in knot vector
690 int dir // dir 0 = "s", 1 = "t"
691 ) const;
692
693 /*
694 Description:
695 Expert user function to get a pointer to control vertex
696 memory. If you are not an expert user, please use
697 ON_NurbsSurface::GetCV( ON_3dPoint& ) or
698 ON_NurbsSurface::GetCV( ON_4dPoint& ).
699 Parameters:
700 i - [in] (0 <= i < m_cv_count[0])
701 j - [in] (0 <= j < m_cv_count[1])
702 Returns:
703 Pointer to control vertex.
704 Remarks:
705 If the NURBS surface is rational, the format of the
706 returned array is a homogeneos rational point with
707 length m_dim+1. If the NURBS surface is not rational,
708 the format of the returned array is a nonrational
709 euclidean point with length m_dim.
710 See Also
711 ON_NurbsSurface::CVStyle
712 ON_NurbsSurface::GetCV
713 ON_NurbsSurface::Weight
714 */
715 double* CV(
716 int i,
717 int j
718 ) const;
719
720 /*
721 Description:
722 Returns the style of control vertices in the m_cv array.
723 Returns:
724 @untitled table
725 ON::not_rational m_is_rat is false
726 ON::homogeneous_rational m_is_rat is true
727 */
728 ON::point_style CVStyle() const;
729
730 double Weight( // get value of control vertex weight
731 int i, int j // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1)
732 ) const;
733
734 ON_BOOL32 SetWeight( // get value of control vertex weight
735 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1)
736 double weight
737 );
738
739 ON_BOOL32 SetCV( // set a single control vertex
740 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1)
741 ON::point_style, // style of input point
742 const double* cv // value of control vertex
743 );
744
745 ON_BOOL32 SetCV( // set a single control vertex
746 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1)
747 const ON_3dPoint& cv// value of control vertex
748 // If NURBS is rational, weight
749 // will be set to 1.
750 );
751
752 ON_BOOL32 SetCV( // set a single control vertex
753 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1)
754 const ON_4dPoint& cv// value of control vertex
755 );
756
757 ON_BOOL32 SetCVRow( // Sets CV( *, row_index )
758 int row_index, // row_index >= 0 and < m_cv_count[1]
759 const ON_3dPoint& cv // value of control vertex
760 // If NURBS is rational, weight
761 // will be set to 1.
762 );
763
764 ON_BOOL32 SetCVRow( // Sets CV( *, row_index )
765 int row_index, // row_index >= 0 and < m_cv_count[1]
766 int v_stride, // v stride
767 const double* v // v[] = values (same dim and is_rat as surface)
768 );
769
770 ON_BOOL32 SetCVColumn( // Sets CV( col_index, * )
771 int col_index, // col_index >= 0 and < m_cv_count[0]
772 const ON_3dPoint& cv // value of control vertex
773 // If NURBS is rational, weight
774 // will be set to 1.
775 );
776
777 ON_BOOL32 SetCVColumn( // Sets CV( col_index, * )
778 int col_index, // col_index >= 0 and < m_cv_count[0]
779 int v_stride, // v stride
780 const double* v // v[] = values (same dim and is_rat as surface)
781 );
782
783 ON_BOOL32 GetCV( // get a single control vertex
784 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1)
785 ON::point_style, // style to use for output point
786 double* cv // array of length >= CVSize()
787 ) const;
788
789 ON_BOOL32 GetCV( // get a single control vertex
790 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1)
791 ON_3dPoint& cv // gets euclidean cv when NURBS is rational
792 ) const;
793
794 ON_BOOL32 GetCV( // get a single control vertex
795 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1)
796 ON_4dPoint& cv // gets homogeneous cv
797 ) const;
798
799 int SetKnot(
800 int dir, // dir 0 = "s", 1 = "t"
801 int knot_index, // knot index ( 0 to KnotCount - 1 )
802 double knot_value // value for knot
803 );
804
805 double Knot(
806 int dir, // dir 0 = "s", 1 = "t"
807 int knot_index // knot index ( >= 0 and < Order + CV_count - 2 )
808 ) const;
809
810 int KnotMultiplicity(
811 int dir, // dir 0 = "s", 1 = "t"
812 int knot_index // knot index ( >= 0 and < Order + CV_count - 2 )
813 ) const;
814
815 const double* Knot( // knot[] array
816 int dir // dir 0 = "s", 1 = "t"
817 ) const;
818
819 // Description:
820 // Make knot vector a clamped uniform knot vector
821 // based on the current values of m_order and m_cv_count.
822 // Does not change values of control vertices.
823 // Parameters:
824 // dir - [in] 0 = u knots, 1 = v knots
825 // delta - [in] (>0.0) knot spacing.
826 // Returns:
827 // true if successful.
828 // Remarks:
829 // Allocates m_knot[] if it is not big enough.
830 // See Also:
831 // ON_MakeClampedUniformKnotVector
832 bool MakeClampedUniformKnotVector(
833 int dir,
834 double delta = 1.0
835 );
836
837 // Description:
838 // Make knot vector a periodic uniform knot vector
839 // based on the current values of m_order and m_cv_count.
840 // Does not change values of control vertices.
841 // Parameters:
842 // dir - [in] 0 = u knots, 1 = v knots
843 // delta - [in] (>0.0) knot spacing.
844 // Returns:
845 // true if successful.
846 // Remarks:
847 // Allocates m_knot[] if it is not big enough.
848 // See Also:
849 // ON_MakePeriodicUniformKnotVector
850 bool MakePeriodicUniformKnotVector(
851 int dir,
852 double delta = 1.0
853 );
854
855
856 bool IsClamped( // determine if knot vector is clamped
857 int dir, // dir 0 = "s", 1 = "t"
858 int end = 2 // end to check: 0 = start, 1 = end, 2 = start and end
859 ) const;
860
861 double SuperfluousKnot(
862 int dir, // dir 0 = "s", 1 = "t"
863 int end // 0 = start, 1 = end
864 ) const;
865
866 double GrevilleAbcissa(
867 int dir, // dir
868 int cv_index // index (0 <= index < CVCount(dir)
869 ) const;
870
871 bool GetGrevilleAbcissae( // see ON_GetGrevilleAbcissa() for details
872 int dir, // dir
873 double* g // g[cv count]
874 ) const;
875
876 bool SetClampedGrevilleKnotVector(
877 int dir, // dir
878 int g_stride, // g_stride
879 const double* g // g[], CVCount(dir) many Greville abcissa
880 );
881
882 bool SetPeriodicGrevilleKnotVector(
883 int dir, // dir
884 int g_stride, // g_stride
885 const double* g // g[], Greville abcissa
886 );
887
888 bool ZeroCVs(); // zeros all CVs (any weights set to 1);
889
890 bool ClampEnd(
891 int dir, // dir 0 = "s", 1 = "t"
892 int end // 0 = clamp start, 1 = clamp end, 2 = clamp start and end
893 );
894
895 bool InsertKnot(
896 int dir, // dir 0 = "s", 1 = "t"
897 double knot_value, // value of knot
898 int knot_multiplicity=1 // multiplicity of knot ( >= 1 and <= degree )
899 );
900
901 bool MakeRational();
902
903 bool MakeNonRational();
904
905 bool IncreaseDegree(
906 int dir, // dir 0 = "s", 1 = "t"
907 int desired_degree // desired_degree
908 );
909
910 bool ChangeDimension(
911 int desired_dimension // desired_dimension
912 );
913
914 /*
915 Description:
916 If the surface is closed in direction dir, then modify it so that
917 the seam is at parameter t in the dir direction.
918 Parameters:
919 dir - [in] must be 0 or 1
920 t - [in] dir parameter of seam, must have Domain(dir).Includes(t).
921 The resulting surface domain in the dir direction will start at t.
922 Returns:
923 true if successful.
924 */
925 ON_BOOL32 ChangeSurfaceSeam(
926 int dir,
927 double t
928 );
929
930
931 // Creates a tensor product nurbs surface with srf(s,t) = T(A(s),B(t));
932 ON_BOOL32 TensorProduct(
933 const ON_NurbsCurve&, // A
934 const ON_NurbsCurve&, // B
935 ON_TensorProduct& // T
936 );
937
939 // Tools for managing CV and knot memory
940 ON_BOOL32 ReserveKnotCapacity( // returns false if allocation fails
941 // does not change m_order or m_cv_count
942 int dir, // dir 0 = "s", 1 = "t"
943 int knot_array_capacity // minimum capacity of m_knot[] array
944 );
945 ON_BOOL32 ReserveCVCapacity( // returns false if allocation fails
946 // does not change m_order or m_cv_count
947 int cv_array_capacity // minimum capacity of m_cv[] array
948 );
949
950 /*
951 Description:
952 Convert a NURBS surface bispan into a bezier surface.
953 Parameters:
954 span_index0 - [in] Specifies the "u" span and must satisfy
955 0 <= span_index0 <= m_cv_count[0]-m_order[0]
956 m_knot[0][span_index0+m_order[0]-2] < m_knot[0][span_index0+m_order[0]-1]
957 span_index1 - [in] Specifies the "v" span and must satisfy
958 0 <= span_index1 <= m_cv_count[1]-m_order[1]
959 m_knot[1][span_index1+m_order[1]-2] < m_knot[1][span_index1+m_order[1]-1]
960 bezier_surface - [out] bezier surface returned here
961 Returns:
962 true if successful
963 false if input is not valid
964 */
965 ON_BOOL32 ConvertSpanToBezier(
966 int span_index0,
967 int span_index1,
968 ON_BezierSurface& bezier_surface
969 ) const;
970
972 // Implementation
973public:
974 // NOTE: These members are left "public" so that expert users may efficiently
975 // create NURBS curves using the default constructor and borrow the
976 // knot and CV arrays from their native NURBS representation.
977 // No technical support will be provided for users who access these
978 // members directly. If you can't get your stuff to work, then use
979 // the constructor with the arguments and the SetKnot() and SetCV()
980 // functions to fill in the arrays.
981
982 int m_dim; // (>=1)
983
984 int m_is_rat; // 1 for rational B-splines. (Control vertices
985 // use homogeneous form.)
986 // 0 for non-rational B-splines. (Control
987 // verticies do not have a weight coordinate.)
988
989 int m_order[2]; // order = degree+1 (>=2)
990
991 int m_cv_count[2]; // number of control vertices ( >= order )
992
993 // knot vector memory
994
995 int m_knot_capacity[2]; // If m_knot_capacity > 0, then m_knot[]
996 // is an array of at least m_knot_capacity
997 // doubles whose memory is managed by the
998 // ON_NurbsSurface class using rhmalloc(),
999 // onrealloc(), and rhfree().
1000 // If m_knot_capacity is 0 and m_knot is
1001 // not NULL, then m_knot[] is assumed to
1002 // be big enough for any requested operation
1003 // and m_knot[] is not deleted by the
1004 // destructor.
1005
1006 double* m_knot[2]; // Knot vector. ( The knot vector has length
1007 // m_order+m_cv_count-2. )
1008
1009 // control vertex net memory
1010
1011 int m_cv_stride[2]; // The pointer to start of "CV[i]" is
1012 // m_cv + i*m_cv_stride.
1013
1014 int m_cv_capacity; // If m_cv_capacity > 0, then m_cv[] is an array
1015 // of at least m_cv_capacity doubles whose
1016 // memory is managed by the ON_NurbsSurface
1017 // class using rhmalloc(), onrealloc(), and rhfree().
1018 // If m_cv_capacity is 0 and m_cv is not
1019 // NULL, then m_cv[] is assumed to be big enough
1020 // for any requested operation and m_cv[] is not
1021 // deleted by the destructor.
1022
1023 double* m_cv; // Control points.
1024 // If m_is_rat is false, then control point is
1025 //
1026 // ( CV(i)[0], ..., CV(i)[m_dim-1] ).
1027 //
1028 // If m_is_rat is true, then the control point
1029 // is stored in HOMOGENEOUS form and is
1030 //
1031 // [ CV(i)[0], ..., CV(i)[m_dim] ].
1032 //
1033};
1034
1035
1037{
1039
1040public:
1041 ON_NurbsCage();
1042
1044 int dim,
1045 bool is_rat,
1046 int order0,
1047 int order1,
1048 int order2,
1049 int cv_count0,
1050 int cv_count1,
1051 int cv_count2
1052 );
1053
1054 ON_NurbsCage(
1055 const ON_BoundingBox& bbox,
1056 int order0,
1057 int order1,
1058 int order2,
1059 int cv_count0,
1060 int cv_count1,
1061 int cv_count2
1062 );
1063
1064 ON_NurbsCage(
1065 const ON_3dPoint* box_corners, // array of 8 3d points
1066 int order0,
1067 int order1,
1068 int order2,
1069 int cv_count0,
1070 int cv_count1,
1071 int cv_count2
1072 );
1073
1074 ON_NurbsCage( const ON_BezierCage& src );
1075
1076 ~ON_NurbsCage();
1077
1078 ON_NurbsCage(const ON_NurbsCage& src);
1079
1080 ON_NurbsCage& operator=(const ON_NurbsCage& src);
1081
1082 ON_NurbsCage& operator=(const ON_BezierCage& src);
1083
1084
1085 /*
1086 Description:
1087 Overrides the pure virtual ON_Object::IsValid function.
1088 Parameters:
1089 text_log - [in] If not null and the object is invalid,
1090 a brief description of the problem
1091 suitable for debugging C++ code
1092 is printed in this log.
1093 Returns:
1094 True if the orders are at least two, dimension is positive,
1095 knot vectors are valid, and the other fields are valid
1096 for the specified orders and dimension.
1097 */
1098 ON_BOOL32 IsValid(
1099 ON_TextLog* text_log = NULL
1100 ) const;
1101
1102 /*
1103 Description:
1104 Overrides the pure virtual ON_Object::Dump function.
1105 Parameters:
1106 text_log - [in] A listing of the values of the members.
1107 */
1108 void Dump( ON_TextLog& text_log) const;
1109
1110 /*
1111 Description:
1112 Overrides the pure virtual ON_Object::SizeOf function.
1113 Returns:
1114 An estimate of the amount of memory used by the class
1115 and its members.
1116 */
1117 unsigned int SizeOf() const;
1118
1119 // virtual ON_Object::DataCRC override
1120 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
1121
1122 /*
1123 Description:
1124 Overrides the pure virtual ON_Object::Read function.
1125 Reads the definition of this class from an
1126 archive previously saved by ON_BezierVolue::Write.
1127 Parameters:
1128 archive - [in] target archive
1129 Returns:
1130 True if successful.
1131 */
1132 ON_BOOL32 Read(
1133 ON_BinaryArchive& archive
1134 );
1135
1136 /*
1137 Description:
1138 Overrides the pure virtual ON_Object::Write function.
1139 Saves the definition of this class in serial binary
1140 form that can be read by ON_BezierVolue::Read.
1141 Parameters:
1142 archive - [in] target archive
1143 Returns:
1144 True if successful.
1145 */
1146 ON_BOOL32 Write(
1147 ON_BinaryArchive& archive
1148 ) const;
1149
1150 /*
1151 Description:
1152 Overrides the pure virtual ON_Object::ObjectType function.
1153 Saves the definition of this class in serial binary
1154 form that can be read by ON_BezierVolue::Read.
1155 Parameters:
1156 archive - [in] target archive
1157 Returns:
1158 True if successful.
1159 */
1160 ON::object_type ObjectType() const;
1161
1162 /*
1163 Description:
1164 Overrides the pure virtual ON_Object::DestroyRuntimeCache function.
1165 Saves the definition of this class in serial binary
1166 form that can be read by ON_BezierVolue::Read.
1167 Parameters:
1168 bDelete - [in] if true, the cache is deleted. If false, the
1169 pointers to the cache are set to zero; this is done when
1170 the cache memory was allocated from a pool that has
1171 been destroyed and an attempt to free the memory would
1172 result in a crash.
1173 Returns:
1174 True if successful.
1175 */
1176 void DestroyRuntimeCache(
1177 bool bDelete = true
1178 );
1179
1180
1181 /*
1182 Description:
1183 Overrides virtual ON_Geometry::Dimension function.
1184 Gets a tight bounding box with respect to the coordinate
1185 system specified by the frame parameter.
1186 Parameters:
1187 bbox - [in/out]
1188 bGrowBox - [in] If true, the input bbox is grown to include
1189 this object's bounding box.
1190 frame - [in] if not null, this specifies the coordinate system
1191 frame.
1192 Returns:
1193 True if successful.
1194 */
1195 int Dimension() const;
1196
1197 /*
1198 Description:
1199 Overrides virtual ON_Geometry::GetBBox function.
1200 Gets the world axis aligned bounding box that contains
1201 the NURBS volume's control points. The NURBS volume
1202 maps the unit cube into this box.
1203 Parameters:
1204 boxmin - [in] array of Dimension() doubles
1205 boxmax - [in] array of Dimension() doubles
1206 bGrowBox = [in] if true and the input is a valid box
1207 then the input box is grown to
1208 include this object's bounding box.
1209 Returns:
1210 true if successful.
1211 */
1212 ON_BOOL32 GetBBox(
1213 double* boxmin,
1214 double* boxmax,
1215 int bGrowBox = false
1216 ) const;
1217
1218 /*
1219 Description:
1220 Get tight bounding box.
1221 Parameters:
1222 tight_bbox - [in/out] tight bounding box
1223 bGrowBox -[in] (default=false)
1224 If true and the input tight_bbox is valid, then returned
1225 tight_bbox is the union of the input tight_bbox and the
1226 surface's tight bounding box.
1227 xform -[in] (default=NULL)
1228 If not NULL, the tight bounding box of the transformed
1229 surface is calculated. The surface is not modified.
1230 Returns:
1231 True if a valid tight_bbox is returned.
1232 */
1233 bool GetTightBoundingBox(
1234 ON_BoundingBox& tight_bbox,
1235 int bGrowBox = false,
1236 const ON_Xform* xform = 0
1237 ) const;
1238
1239 /*
1240 Description:
1241 Overrides virtual ON_Geometry::Transform function.
1242 Transforms NURBS volume.
1243 Parameters:
1244 xform - [in]
1245 Returns:
1246 true if successful.
1247 */
1249 const ON_Xform& xform
1250 );
1251
1252 /*
1253 Description:
1254 Overrides virtual ON_Geometry::IsDeformable function.
1255 Returns:
1256 True because a NURBS volume can be accuratly modified
1257 with "squishy" transformations like projections,
1258 shears, an non-uniform scaling.
1259 */
1260 bool IsDeformable() const;
1261
1262 /*
1263 Description:
1264 Overrides virtual ON_Geometry::MakeDeformable function.
1265 Returns:
1266 True because NURBS volumes are deformable.
1267 */
1268 bool MakeDeformable();
1269
1270 /*
1271 Description:
1272 Overrides virtual ON_Geometry::Morph function.
1273 Applies the space morph to the NURBS volume's control points.
1274 Parameters:
1275 morph - [in]
1276 Returns:
1277 True is successful.
1278 */
1279 bool Morph(
1280 const ON_SpaceMorph& morph
1281 );
1282
1283 /*
1284 Description:
1285 Overrides virtual ON_Geometry::IsMorphable function.
1286 Returns:
1287 True because NURBS volumes can be morphed by calling Morph().
1288 */
1289 bool IsMorphable() const;
1290
1291 /*
1292 Returns:
1293 True if the cage is a parallelogram within the tolerance.
1294 This means the cage can be used as a starting point
1295 for cage deformations.
1296 */
1297 bool IsParallelogram(double tolerance) const;
1298
1299 bool Create(
1300 int dim,
1301 bool is_rat,
1302 int order0,
1303 int order1,
1304 int order2,
1305 int cv_count0,
1306 int cv_count1,
1307 int cv_count2
1308 );
1309
1310 /*
1311 Description:
1312 Create a Nurbs volume with corners defined by a bounding box.
1313 Parameters:
1314 box_corners - [in] 8 points that define corners of the volume
1315
1316 7______________6
1317 |\ |\
1318 | \ | \
1319 | \ _____________\
1320 | 4 | 5
1321 | | | |
1322 | | | |
1323 3---|----------2 |
1324 \ | \ |
1325 \ |z \ |
1326 y \ | \ |
1327 \0_____________\1
1328 x
1329
1330 */
1331 bool Create(
1332 const ON_BoundingBox& bbox,
1333 int order0,
1334 int order1,
1335 int order2,
1336 int cv_count0,
1337 int cv_count1,
1338 int cv_count2
1339 );
1340
1341 /*
1342 Description:
1343 Create a nurbs volume from a 3d box
1344 Parameters:
1345 box_corners - [in] 8 points that define corners of the volume
1346
1347 7______________6
1348 |\ |\
1349 | \ | \
1350 | \ _____________\
1351 | 4 | 5
1352 | | | |
1353 | | | |
1354 3---|----------2 |
1355 \ | \ |
1356 \ |t \ |
1357 s \ | \ |
1358 \0_____________\1
1359 r
1360
1361 */
1362 bool Create(
1363 const ON_3dPoint* box_corners,
1364 int order0,
1365 int order1,
1366 int order2,
1367 int cv_count0,
1368 int cv_count1,
1369 int cv_count2
1370 );
1371
1372 void Destroy();
1373
1374 void EmergencyDestroy(); // call if memory used by ON_NurbsCage becomes invalid
1375
1376 ON_Interval Domain(
1377 int // dir 0 = "r", 1 = "s", 2 = "t"
1378 ) const;
1379
1380 bool Reverse(
1381 int dir // dir 0 = "r", 1 = "s", 2 = "t"
1382 );
1383
1385 int dir0,
1386 int dir1
1387 );
1388
1390 int dir, // dir 0 = "r", 1 = "s", 2 = "t"
1391 int end // 0 = clamp start, 1 = clamp end, 2 = clamp start and end
1392 );
1393
1395 int dir, // dir 0 = "r", 1 = "s", 2 = "t"
1396 double knot_value, // value of knot
1397 int knot_multiplicity=1 // multiplicity of knot ( >= 1 and <= degree )
1398 );
1399
1401 int dir, // dir 0 = "r", 1 = "s", 2 = "t"
1402 int desired_degree // desired_degree
1403 );
1404
1406 int desired_dimension // desired_dimension
1407 );
1408
1409 /*
1410 Description:
1411 Evaluate the NURBS cage
1412 Parameters:
1413 r - [in]
1414 s - [in]
1415 t - [in] (r,s,t) = evaluation parameters
1416 der_count - [in] (>= 0)
1417 v_stride - [in] (>= m_dim)
1418 v - [out] An array of length v_stride*(der_count+1)(der_count+2)*(der_count+3)/6.
1419 The evaluation results are stored in this array.
1420
1421 P = v[0],...,v[m_dim-1]
1422 Dr = v[v_stride],...
1423 Ds = v[2*v_stride],...
1424 Dt = v[3*v_stride],...
1425
1426 In general, Dr^i Ds^j Dt^k is returned in v[n],...,v[n+m_dim-1], where
1427
1428 d = (i+j+k)
1429 n = v_stride*( d*(d+1)*(d+2)/6 + (j+k)*(j+k+1)/2 + k)
1430
1431 side - [in] specifies the span to use for the evaluation
1432 when r, s, or t is at a knot value.
1433 0 = default
1434 1 = from upper NE quadrant
1435 2 = from upper NW quadrant
1436 3 = from upper SW quadrant
1437 4 = from upper SE quadrant
1438 5 = from lower NE quadrant
1439 6 = from lower NW quadrant
1440 7 = from lower SW quadrant
1441 8 = from lower SE quadrant
1442 hint - [in/out] If a bunch of evaluations will be performed that
1443 tend to occur in the same region, then
1444 hint[3] can be used to speed the search for
1445 the evaluation span. The input value is
1446 used as a search hint and the output value
1447 records the span used for that evaluation.
1448 Example:
1449
1450 int der_count = 2;
1451 int v_stride = dim;
1452 double v[v_stride*(der_count+1)*(der_count+2)*(der_count+3)/6];
1453 int side = 0;
1454 int hint[3]; hint[0] = 0; hint[1] = 0; hint[2] = 0;
1455 bool rc = cage.Evaluate(r,s,t,der_count,v_stride,v,side,hint);
1456
1457 ON_3dPoint P = v;
1458
1459 // first order partial derivatives
1460 ON_3dVector Dr = v + v_stride;
1461 ON_3dVector Ds = v + 2*v_stride;
1462 ON_3dVector Dt = v + 3*v_stride;
1463
1464 // second order partial derivatives
1465 ON_3dVector Drr = v + 4*v_stride;
1466 ON_3dVector Drs = v + 5*v_stride;
1467 ON_3dVector Drt = v + 6*v_stride;
1468 ON_3dVector Dss = v + 7*v_stride;
1469 ON_3dVector Dst = v + 8*v_stride;
1470 ON_3dVector Dtt = v + 8*v_stride;
1471
1472 Returns:
1473 True if successful
1474 See Also:
1475 ON_NurbsCage::PointAt
1476 */
1477 bool Evaluate(
1478 double r,
1479 double s,
1480 double t,
1481 int der_count,
1482 int v_stride,
1483 double* v,
1484 int side=0,
1485 int* hint=0
1486 ) const;
1487
1488 /*
1489 Description:
1490 Evaluates bezer volume map.
1491 Parameters:
1492 rst - [in]
1493 Returns:
1494 Value of the nurbs volume map at (r,s,t).
1495 */
1496 ON_3dPoint PointAt(
1497 double r,
1498 double s,
1499 double t
1500 ) const;
1501
1502 ON_NurbsSurface* IsoSurface(
1503 int dir,
1504 double c,
1505 ON_NurbsSurface* srf = 0
1506 ) const;
1507
1508 bool Trim(
1509 int dir,
1510 const ON_Interval& domain
1511 );
1512
1514 int dir,
1515 const ON_Interval& domain
1516 );
1517
1518 /*
1519 Description:
1520 Evaluates bezer volume map.
1521 Parameters:
1522 rst - [in]
1523 Returns:
1524 Value of the nurbs volume map at (rst.x,rst.y,rst.z).
1525 */
1526 ON_3dPoint PointAt(
1527 ON_3dPoint rst
1528 ) const;
1529
1530 bool IsRational() const;
1531
1532 int CVSize() const;
1533
1534 int Order(
1535 int dir // dir 0 = "r", 1 = "s", 2 = "t"
1536 ) const;
1537
1538 int CVCount( // number of control vertices
1539 int // dir 0 = "r", 1 = "s", 2 = "t"
1540 ) const;
1541
1542 int CVCount( // total number of control vertices
1543 void
1544 ) const;
1545
1546 int KnotCount( // total number of knots in knot vector
1547 int dir // dir 0 = "r", 1 = "s", 2 = "t"
1548 ) const;
1549
1550 int Degree(
1551 int dir
1552 ) const;
1553
1554
1556 int dir // dir 0 = "r", 1 = "s", 2 = "t"
1557 ) const;
1558
1560 int dir, // dir 0 = "r", 1 = "s", 2 = "t"
1561 double* span_vector
1562 ) const;
1563
1564 /*
1565 Description:
1566 Expert user function to get a pointer to control vertex
1567 memory. If you are not an expert user, please use
1568 ON_NurbsCage::GetCV( ON_3dPoint& ) or
1569 ON_NurbsCage::GetCV( ON_4dPoint& ).
1570 Parameters:
1571 cv_index0 - [in] (0 <= cv_index0 < m_order[0])
1572 cv_index1 - [in] (0 <= cv_index1 < m_order[1])
1573 Returns:
1574 Pointer to control vertex.
1575 Remarks:
1576 If the Nurbs surface is rational, the format of the
1577 returned array is a homogeneos rational point with
1578 length m_dim+1. If the Nurbs surface is not rational,
1579 the format of the returned array is a nonrational
1580 euclidean point with length m_dim.
1581 See Also
1582 ON_NurbsCage::CVStyle
1583 ON_NurbsCage::GetCV
1584 ON_NurbsCage::Weight
1585 */
1586 double* CV(
1587 int i,
1588 int j,
1589 int k
1590 ) const;
1591
1592 /*
1593 Description:
1594 Returns the style of control vertices in the m_cv array.
1595 Returns:
1596 @untitled table
1597 ON::not_rational m_is_rat is false
1598 ON::homogeneous_rational m_is_rat is true
1599 */
1600 ON::point_style CVStyle() const;
1601
1602 double Weight( // get value of control vertex weight
1603 int i,
1604 int j,
1605 int k
1606 ) const;
1607
1608 bool SetWeight( // get value of control vertex weight
1609 int i,
1610 int j,
1611 int k,
1612 double w
1613 );
1614
1615 bool SetCV( // set a single control vertex
1616 int i,
1617 int j,
1618 int k,
1619 ON::point_style, // style of input point
1620 const double* // value of control vertex
1621 );
1622
1623 // set a single control vertex
1624 // If NURBS is rational, weight
1625 // will be set to 1.
1626 bool SetCV(
1627 int i,
1628 int j,
1629 int k,
1630 const ON_3dPoint& point
1631 );
1632
1633 // set a single control vertex
1634 // value of control vertex
1635 // If NURBS is not rational, euclidean
1636 // location of homogeneous point will
1637 // be used.
1638 bool SetCV(
1639 int i,
1640 int j,
1641 int k,
1642 const ON_4dPoint& hpoint
1643 );
1644
1645 bool GetCV( // get a single control vertex
1646 int i,
1647 int j,
1648 int k,
1649 ON::point_style, // style to use for output point
1650 double* // array of length >= CVSize()
1651 ) const;
1652
1653 bool GetCV( // get a single control vertex
1654 int i,
1655 int j,
1656 int k,
1657 ON_3dPoint& // gets euclidean cv when NURBS is rational
1658 ) const;
1659
1660 bool GetCV( // get a single control vertex
1661 int i,
1662 int j,
1663 int k,
1664 ON_4dPoint& // gets homogeneous cv
1665 ) const;
1666
1667 /*
1668 Parameters:
1669 dir - [in] 0 = "r", 1 = "s", 2 = "t"
1670 knot_index - [in] 0 <= knot_index < KnotCount(dir)
1671 knot_value - [in]
1672 Returns:
1673 True if dir and knot_index parameters were valid and knot value
1674 was set.
1675 */
1676 bool SetKnot(
1677 int dir,
1678 int knot_index,
1679 double knot_value
1680 );
1681
1682 /*
1683 Parameters:
1684 dir - [in] 0 = "r", 1 = "s", 2 = "t"
1685 knot_index - [in] 0 <= knot_index < KnotCount(dir)
1686 Returns:
1687 Value of knot or ON_UNSET_VALUE if input parameters are not valid.
1688 */
1689 double Knot(
1690 int dir,
1691 int knot_index
1692 ) const;
1693
1694 bool ZeroCVs(); // zeros control vertices and, if rational, sets weights to 1
1695
1696 bool MakeRational();
1697
1698 bool MakeNonRational();
1699
1700 bool IsClosed( // true if NURBS cage is closed (either cage has
1701 int // dir // clamped end knots and euclidean location of start
1702 ) const; // CV = euclidean location of end CV, or cage is
1703 // periodic.)
1704
1705 bool IsPeriodic( // true if NURBS cage is periodic (degree > 1,
1706 int // dir // periodic knot vector, last degree many CVs
1707 ) const; // are duplicates of first degree many CVs.)
1708
1709 bool IsSingular( // true if cage side is collapsed to a point
1710 int // side of parameter space to test
1711 // 0 = south, 1 = east, 2 = north, 3 = west
1712 ) const;
1713
1714 double GrevilleAbcissa(
1715 int dir, // dir
1716 int gindex // index (0 <= index < CVCount(dir)
1717 ) const;
1718
1720 // Tools for managing CV and knot memory
1721
1722 /*
1723 Description:
1724 cv_capacity - [in] number of doubles to reserve
1725 */
1726 bool ReserveCVCapacity(
1727 int cv_capacity
1728 );
1729
1730 bool ReserveKnotCapacity(
1731 int dir,
1732 int cv_capacity
1733 );
1734
1736 // Implementation
1737public:
1738 // NOTE: These members are left "public" so that expert users may efficiently
1739 // create nurbs curves using the default constructor and borrow the
1740 // knot and CV arrays from their native NURBS representation.
1741 // No technical support will be provided for users who access these
1742 // members directly. If you can't get your stuff to work, then use
1743 // the constructor with the arguments and the SetKnot() and SetCV()
1744 // functions to fill in the arrays.
1745
1746
1749 int m_order[3];
1750 int m_cv_count[3];
1751 int m_knot_capacity[3];
1752 double* m_knot[3];
1753 int m_cv_stride[3];
1755 double* m_cv;
1756};
1757
1758ON_DECL
1759bool ON_GetCageXform(
1760 const ON_NurbsCage& cage,
1761 ON_Xform& cage_xform
1762 );
1763
1764
1766{
1768
1769public:
1772 // C++ default copy construction and operator= work fine.
1773
1774
1775 void Destroy();
1776
1777
1779 //
1780 // ON_Object virtual functions
1781 //
1782
1783 void MemoryRelocate();
1784
1785 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
1786
1787 void Dump( ON_TextLog& ) const;
1788
1789 unsigned int SizeOf() const;
1790
1791 ON_BOOL32 Write(
1792 ON_BinaryArchive& archive
1793 ) const;
1794
1795 ON_BOOL32 Read(
1796 ON_BinaryArchive& archive
1797 );
1798
1799 ON::object_type ObjectType() const;
1800
1801 void DestroyRuntimeCache( bool bDelete = true );
1802
1804 //
1805 // ON_Geometry virtual functions
1806 //
1807
1808 int Dimension() const;
1809
1810 ON_BOOL32 GetBBox(
1811 double* boxmin,
1812 double* boxmax,
1813 int bGrowBox = false
1814 ) const;
1815
1816 bool GetTightBoundingBox(
1817 ON_BoundingBox& tight_bbox,
1818 int bGrowBox = false,
1819 const ON_Xform* xform = 0
1820 ) const;
1821
1822 void ClearBoundingBox();
1823
1825 const ON_Xform& xform
1826 );
1827
1828 bool Morph( const ON_SpaceMorph& morph );
1829
1830 bool IsMorphable() const;
1831
1832 ON_BOOL32 HasBrepForm() const;
1833
1834 ON_Brep* BrepForm( ON_Brep* brep = NULL ) const;
1835
1836
1837 /*
1838 Returns:
1839 True if the target NURBS object is rational
1840 */
1841 bool IsRational() const;
1842
1843 /*
1844 Description:
1845 Makes the target NURBS object rational.
1846 */
1847 bool MakeRational();
1848
1849 /*
1850 Description:
1851 Makes the target NURBS object non-rational.
1852 */
1853 bool MakeNonRational();
1854
1855 /*
1856 Returns:
1857 Number of control points in the target NURBS object.
1858 */
1859 int CVCount() const;
1860
1861 int CVCount(int dir) const;
1862 int Order(int dir) const;
1863 const double* Knot(int dir) const;
1864 ON_3dex MaxCVIndex() const;
1865 const double* CV(ON_3dex) const;
1866 double Weight(ON_3dex) const;
1867
1869 //
1870 // Localizers
1871 //
1872
1873 /*
1874 Description:
1875 Adds localizer with support near the controling NURBS object.
1876 Parameters:
1877 support_distance - [in] >= 0
1878 If the distance a point to the controls NURBS
1879 curve/surface/cage is less than or equal to support_distance,
1880 then MorphPoint() deformation has 100% effect.
1881
1882 falloff_distance - [in] > 0
1883 If the distance a point to the controls NURBS
1884 curve/surface/cage is more than support_distance+falloff_distance,
1885 then MorphPoint() deformation does not move the point.
1886 As the distance varies from support_distance to
1887 support_distance+falloff_distance the deformation attenuates
1888 from 100% to 0%.
1889 */
1890 bool AddControlLocalizer(
1891 double support_distance,
1892 double falloff_distance
1893 );
1894
1895 bool AddSphereLocalizer(
1896 ON_3dPoint center,
1897 double support_distance,
1898 double falloff_distance
1899 );
1900
1901 bool AddCylinderLocalizer(
1902 ON_Line axis,
1903 double support_distance,
1904 double falloff_distance
1905 );
1906
1907 bool AddBoxLocalizer(
1908 ON_BoundingBox bbox,
1909 double support_distance,
1910 double falloff_distance
1911 );
1912
1913 bool AddPlaneLocalizer(
1914 const ON_Plane& plane,
1915 double support_distance,
1916 double falloff_distance
1917 );
1918
1919 bool AddConvexPolygonLocalizer(
1920 const ON_SimpleArray<ON_Plane>& planes,
1921 double support_distance,
1922 double falloff_distance
1923 );
1924
1926 //
1927 //
1928
1929 // Get a cage_morph that can be passed to Morph functions
1930 bool GetCageMorph( class ON_CageMorph& cage_morph ) const;
1931
1932 /*
1933 Description:
1934 Evaluates the deformation. Used by ON_CageMorph::MorphPoint().
1935 */
1936 ON_3dPoint MorphPoint( ON_3dPoint point ) const;
1937
1938 /*
1939 Description:
1940 Get localizer settings needed in MorphPoint().
1941 */
1942 void MorphPointLocalizerHelper(
1943 const ON_3dPoint& point,
1944 double& w,
1945 double& clspt_max_dist,
1946 const ON_Localizer*& distloc
1947 ) const;
1948
1949 void MorphPointVarient1Helper(
1950 double t,
1951 double w,
1952 const ON_Localizer* distloc,
1953 ON_3dPoint& Q,
1954 ON_3dVector* N
1955 ) const;
1956
1957 void MorphPointVarient2Helper(
1958 double s,
1959 double t,
1960 double w,
1961 const ON_Localizer* distloc,
1962 ON_3dPoint& Q,
1963 ON_3dVector* N
1964 ) const;
1965
1966
1967 bool IsIdentity( const ON_BoundingBox& bbox ) const;
1968
1969 int m_varient; // 1= curve, 2 = surface, 3 = cage
1970
1971 // The value of m_varient determines which nurbs object
1972 // controls the cage
1976
1979 ON_Interval m_nurbs_surface_domain[2];
1980
1983
1984 // Rhino captive object ids
1986
1987 // Use ON_GetCageXform to set m_cage_xform.
1988
1989 // Used to localize the deformation
1991
1992 // ON_SpaceMorphOptions
1996};
1997
1998
2000{
2001public:
2002 ON_CageMorph();
2003 ~ON_CageMorph();
2004
2005 ON_3dPoint MorphPoint( ON_3dPoint point ) const;
2006 bool IsIdentity( const ON_BoundingBox& bbox ) const;
2007
2009};
2010
2011
2012// Description:
2013// Get an ON_NurbsSurface definition of a quadrilateral.
2014// Parameters:
2015// P - [in]
2016// Q - [in]
2017// R - [in]
2018// S - [in] corners in counter clockwise layer
2019// nurbs_surface - [in] if this pointer is not NULL,
2020// then this ON_NurbsSurface is used to return
2021// the quadrilateral.
2022// Returns:
2023// An ON_NurbsSurface representation of the quadrilateral.
2024ON_DECL
2026 const ON_3dPoint& P,
2027 const ON_3dPoint& Q,
2028 const ON_3dPoint& R,
2029 const ON_3dPoint& S,
2030 ON_NurbsSurface* nurbs_surface = NULL
2031 );
2032
2033#if defined(ON_DLL_TEMPLATE)
2034// This stuff is here because of a limitation in the way Microsoft
2035// handles templates and DLLs. See Microsoft's knowledge base
2036// article ID Q168958 for details.
2037#pragma warning( push )
2038#pragma warning( disable : 4231 )
2039ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_NurbsCurve>;
2040ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_NurbsCurve>;
2041ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_NurbsCurve*>;
2042ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_NurbsSurface>;
2043ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_NurbsSurface>;
2044ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_NurbsSurface*>;
2045ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_NurbsCage>;
2046ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_NurbsCage>;
2047ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_NurbsCage*>;
2048#pragma warning( pop )
2049#endif
2050
2051#endif
@ Transform
Definition RSMetaType.h:67
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Base class for all dimensioning tools.
Definition Dimension.js:18
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_point.h:555
Definition opennurbs_bezier.h:1592
Definition opennurbs_bezier.h:1198
Definition opennurbs_archive.h:152
Definition opennurbs_bounding_box.h:25
Definition opennurbs_brep.h:1585
Definition opennurbs_nurbssurface.h:2000
const ON_MorphControl * m_control
Definition opennurbs_nurbssurface.h:2008
Definition opennurbs_array.h:760
Definition opennurbs_curve.h:88
Definition opennurbs_geometry.h:36
Definition opennurbs_point.h:46
Definition opennurbs_line.h:20
Definition opennurbs_xform.h:1000
Definition opennurbs_mesh.h:795
Definition opennurbs_mesh.h:33
Definition opennurbs_nurbssurface.h:1766
int m_varient
Definition opennurbs_nurbssurface.h:1969
ON_NurbsCurve m_nurbs_curve
Definition opennurbs_nurbssurface.h:1974
bool m_sporh_bQuickPreview
Definition opennurbs_nurbssurface.h:1994
ON_OBJECT_DECLARE(ON_MorphControl)
ON_UuidList m_captive_id
Definition opennurbs_nurbssurface.h:1985
ON_NurbsCage m_nurbs_cage
Definition opennurbs_nurbssurface.h:1982
ON_NurbsSurface m_nurbs_surface0
Definition opennurbs_nurbssurface.h:1977
ON_Interval m_nurbs_curve_domain
Definition opennurbs_nurbssurface.h:1975
ON_ClassArray< ON_Localizer > m_localizers
Definition opennurbs_nurbssurface.h:1990
bool m_sporh_bPreserveStructure
Definition opennurbs_nurbssurface.h:1995
ON_Xform m_nurbs_cage0
Definition opennurbs_nurbssurface.h:1981
ON_NurbsCurve m_nurbs_curve0
Definition opennurbs_nurbssurface.h:1973
ON_NurbsSurface m_nurbs_surface
Definition opennurbs_nurbssurface.h:1978
double m_sporh_tolerance
Definition opennurbs_nurbssurface.h:1993
Definition opennurbs_nurbssurface.h:1037
int m_dim
Definition opennurbs_nurbssurface.h:1747
bool GetSpanVector(int dir, double *span_vector) const
double * m_cv
Definition opennurbs_nurbssurface.h:1755
ON_BOOL32 IncreaseDegree(int dir, int desired_degree)
bool m_is_rat
Definition opennurbs_nurbssurface.h:1748
ON_BOOL32 ChangeDimension(int desired_dimension)
bool Trim(int dir, const ON_Interval &domain)
bool Transpose(int dir0, int dir1)
bool InsertKnot(int dir, double knot_value, int knot_multiplicity=1)
int m_cv_capacity
Definition opennurbs_nurbssurface.h:1754
bool Extend(int dir, const ON_Interval &domain)
int SpanCount(int dir) const
ON_OBJECT_DECLARE(ON_NurbsCage)
bool Reverse(int dir)
bool ClampEnd(int dir, int end)
Definition opennurbs_nurbscurve.h:27
Definition opennurbs_nurbssurface.h:62
int m_dim
Definition opennurbs_nurbssurface.h:982
double * m_cv
Definition opennurbs_nurbssurface.h:1023
int m_cv_capacity
Definition opennurbs_nurbssurface.h:1014
ON_OBJECT_DECLARE(ON_NurbsSurface)
int m_is_rat
Definition opennurbs_nurbssurface.h:984
Definition opennurbs_array.h:998
Definition opennurbs_plane.h:20
Definition opennurbs_array.h:46
Definition opennurbs_xform.h:1146
Definition opennurbs_surface.h:58
Definition opennurbs_nurbssurface.h:26
virtual int DimensionA() const =0
virtual bool Evaluate(double, const double *, double, const double *, double *)=0
virtual int DimensionB() const =0
virtual int DimensionC() const =0
Definition opennurbs_textlog.h:20
Definition opennurbs_array.h:1079
Definition opennurbs_xform.h:28
Parallel lines, concentric arcs, circles, equidistant curve to ellipses.
Definition Offset.js:11
Reverses all selected entities which support reversing (lines, arcs, splines).
Definition Reverse.js:11
Trims an entity to another entity or trims both entities if this.trimBoth is true.
Definition Trim.js:12
#define ON_ZERO_TOLERANCE
Definition opennurbs_defines.h:238
#define ON_DECL
Definition opennurbs_defines.h:92
#define ON_CLASS
Definition opennurbs_defines.h:91
#define ON_SQRT_EPSILON
Definition opennurbs_defines.h:147
ON_DECL ON_NurbsSurface * ON_NurbsSurfaceQuadrilateral(const ON_3dPoint &P, const ON_3dPoint &Q, const ON_3dPoint &R, const ON_3dPoint &S, ON_NurbsSurface *nurbs_surface=NULL)
Definition opennurbs_nurbssurface.cpp:3022
ON_DECL bool ON_GetCageXform(const ON_NurbsCage &cage, ON_Xform &cage_xform)
Definition opennurbs_nurbsvolume.cpp:2060
#define ON_unset_point
Definition opennurbs_point.h:1506
#define N
Definition opennurbs_rand.cpp:70
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
Definition opennurbs_defines.h:261