00001 /* $NoKeywords: $ */ 00002 /* 00003 // 00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved. 00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert 00006 // McNeel & Associates. 00007 // 00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED. 00011 // 00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>. 00013 // 00015 */ 00016 00018 // 00019 // Definition of NURBS surface 00020 // 00022 00023 #if !defined(OPENNURBS_NURBSSURFACE_INC_) 00024 #define OPENNURBS_NURBSSURFACE_INC_ 00025 00026 #include <pcl/pcl_exports.h> 00027 00028 class ON_CLASS ON_TensorProduct 00029 { 00030 // Pure virtual tensor passed to ON_NurbsSurface::TensorProduct() 00031 public: 00032 ON_TensorProduct(); 00033 00034 virtual 00035 ~ON_TensorProduct(); 00036 00037 // Evaluate() must define a function T:R^dimA X R^dimB -> R^Dimension() 00038 // such that 00039 // 00040 // T(a*A0 + (1-a)*A1, B) = a*T(A0,B) + (1-a)*T(A1,B) and 00041 // T(A, b*B0 + (1-b)*B1) = b*T(A,B0) + (1-b)*T(A,B1). 00042 virtual 00043 int DimensionA() const = 0; // dimension of A space 00044 00045 virtual 00046 int DimensionB() const = 0; // dimension of B space 00047 00048 virtual 00049 int DimensionC() const = 0; // dimension of range space 00050 00051 virtual 00052 bool Evaluate( double, // a 00053 const double*, // A 00054 double, // b 00055 const double*, // B 00056 double* // C 00057 ) = 0; 00058 00059 }; 00060 00061 class ON_Brep; 00062 class ON_NurbsSurface; 00063 00064 class PCL_EXPORTS ON_CLASS ON_NurbsSurface : public ON_Surface 00065 { 00066 ON_OBJECT_DECLARE(ON_NurbsSurface); 00067 00068 public: 00069 /* 00070 Description: 00071 Use ON_NurbsSurface::New(...) instead of new ON_NurbsSurface(...) 00072 Returns: 00073 Pointer to an ON_NurbsSurface. Destroy by calling delete. 00074 Remarks: 00075 See static ON_Brep* ON_Brep::New() for details. 00076 */ 00077 static ON_NurbsSurface* New(); 00078 static ON_NurbsSurface* New( 00079 const ON_NurbsSurface& nurbs_surface 00080 ); 00081 static ON_NurbsSurface* New( 00082 const ON_BezierSurface& bezier_surface 00083 ); 00084 static ON_NurbsSurface* New( 00085 int dimension, 00086 ON_BOOL32 bIsRational, 00087 int order0, 00088 int order1, 00089 int cv_count0, 00090 int cv_count1 00091 ); 00092 00093 ON_NurbsSurface(); 00094 ON_NurbsSurface(const ON_NurbsSurface& nurbs_surface); 00095 ON_NurbsSurface(const ON_BezierSurface& bezier_surface); 00096 ON_NurbsSurface( 00097 int dimension, // dimension (>= 1) 00098 ON_BOOL32 bIsRational, // true to make a rational NURBS 00099 int order0, // order0 (>= 2) 00100 int order1, // order1 (>= 2) 00101 int cv_count0, // cv count0 (>= order0) 00102 int cv_count1 // cv count1 (>= order1) 00103 ); 00104 00105 // virtual ON_Object::SizeOf override 00106 unsigned int SizeOf() const; 00107 00108 // virtual ON_Object::DataCRC override 00109 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const; 00110 00111 /* 00112 Description: 00113 See if this and other are same NURBS geometry. 00114 Parameters: 00115 other - [in] other NURBS surface 00116 bIgnoreParameterization - [in] if true, parameterization 00117 and orientaion are ignored. 00118 tolerance - [in] tolerance to use when comparing 00119 control points. 00120 Returns: 00121 true if curves are tne same. 00122 */ 00123 bool IsDuplicate( 00124 const ON_NurbsSurface& other, 00125 bool bIgnoreParameterization, 00126 double tolerance = ON_ZERO_TOLERANCE 00127 ) const; 00128 00129 void Initialize(void); // zeros all fields 00130 00131 ON_BOOL32 Create( 00132 int dim, // dimension (>= 1) 00133 ON_BOOL32 is_rat, // true to make a rational NURBS 00134 int order0, // order0 (>= 2) 00135 int order1, // order1 (>= 2) 00136 int cv_count0, // cv count0 (>= order0) 00137 int cv_count1 // cv count1 (>= order1) 00138 ); 00139 00140 /* 00141 Description: 00142 Create a ruled surface from two curves. 00143 Parameters: 00144 curveA - [in] (must have same NURBS form knots as curveB) 00145 curveB - [in] (must have same NURBS form knots as curveA) 00146 curveA_domain - [in] if not NULL, then this is a subdomain 00147 of curveA to use for the ruled surface. 00148 curveB_domain - [in] if not NULL, then this is a subdomain 00149 of curveA to use for the ruled surface. 00150 Returns: 00151 @untitled table 00152 0 failure 00153 1 success - parameterization is exact 00154 2 success - parameterization is not exact 00155 Remarks: 00156 The ruling parameter is the second surface parameter and 00157 it is in the interval [0,1]. 00158 The true ruled surface has parameterization 00159 srf(s,t) = (1.0-t)*curveA(s) + t*curveB(s). 00160 The returned NURBS surface has parameterization 00161 srf(s,t) = (1.0-t)*nurbs_curveA(s) + t*nurbs_curveB(s), 00162 where nurbs_curveX is the NURBS form of curveX. If the 00163 parameterization of nurbs_curveX does not match the 00164 parameterization of curveX, then 2 is returned. 00165 */ 00166 virtual 00167 int CreateRuledSurface( 00168 const ON_Curve& curveA, 00169 const ON_Curve& curveB, 00170 const ON_Interval* curveA_domain = NULL, 00171 const ON_Interval* curveB_domain = NULL 00172 ); 00173 00174 /* 00175 Description: 00176 Create a cone surface from a curve to a point. 00177 Parameters: 00178 apex_point - [in] 00179 curve - [in] 00180 curve_domain - [in] if not NULL, then this is a subdomain 00181 of curve to use for the ruled surface. 00182 Returns: 00183 @untitled table 00184 0 failure 00185 1 success - parameterization is exact 00186 2 success - parameterization is not exact 00187 Remarks: 00188 The ruling parameter is the second surface parameter and 00189 it is in the interval [0,1]. 00190 The true cone surface has parameterization 00191 srf(s,t) = (1.0-t)*curve(s) + t*apex_point. 00192 The returned NURBS surface has parameterization 00193 srf(s,t) = (1.0-t)*nurbs_curve(s) + t*apex_point, 00194 where nurbs_curve is the NURBS form of curve. If the 00195 parameterization of nurbs_curve does not match the 00196 parameterization of curve, then 2 is returned. 00197 */ 00198 int CreateConeSurface( 00199 ON_3dPoint apex_point, 00200 const ON_Curve& curve, 00201 const ON_Interval* curve_domain = NULL 00202 ); 00203 00204 /* 00205 Description: 00206 Collapse the side of a NURBS surface to a single point. 00207 Parameters: 00208 side - [in] 0 = south west, 00209 1 = south east, 00210 2 = north east, 00211 3 = north west 00212 point - [in] point to collapse to. If point is ON_unset_point, 00213 the the current location of the start of the side 00214 is used. 00215 Returns: 00216 True if successful. 00217 Remarks: 00218 If the surface is rational, the weights of the side control 00219 points must be set before calling CollapseSide. 00220 */ 00221 bool CollapseSide( 00222 int side, 00223 ON_3dPoint point = ON_unset_point 00224 ); 00225 00226 void Destroy(); 00227 00228 virtual ~ON_NurbsSurface(); 00229 00230 void EmergencyDestroy(); // call if memory used by this class becomes invalid 00231 00232 ON_NurbsSurface& operator=(const ON_NurbsSurface&); 00233 00234 /* 00235 Description: 00236 Set NURBS surface equal to bezier surface with domain [0,1]x[0,1]. 00237 Parameters: 00238 bezier_surface - [in] 00239 */ 00240 ON_NurbsSurface& operator=( 00241 const ON_BezierSurface& bezier_surface 00242 ); 00243 00245 // ON_Object overrides 00246 00247 /* 00248 Description: 00249 Tests an object to see if its data members are correctly 00250 initialized. 00251 Parameters: 00252 text_log - [in] if the object is not valid and text_log 00253 is not NULL, then a brief englis description of the 00254 reason the object is not valid is appened to the log. 00255 The information appended to text_log is suitable for 00256 low-level debugging purposes by programmers and is 00257 not intended to be useful as a high level user 00258 interface tool. 00259 Returns: 00260 @untitled table 00261 true object is valid 00262 false object is invalid, uninitialized, etc. 00263 Remarks: 00264 Overrides virtual ON_Object::IsValid 00265 */ 00266 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 00267 00268 void Dump( ON_TextLog& ) const; // for debugging 00269 00270 ON_BOOL32 Write( 00271 ON_BinaryArchive& // open binary file 00272 ) const; 00273 00274 ON_BOOL32 Read( 00275 ON_BinaryArchive& // open binary file 00276 ); 00277 00279 // ON_Geometry overrides 00280 00281 int Dimension() const; 00282 00283 ON_BOOL32 GetBBox( // returns true if successful 00284 double*, // minimum 00285 double*, // maximum 00286 ON_BOOL32 = false // true means grow box 00287 ) const; 00288 00289 ON_BOOL32 Transform( 00290 const ON_Xform& 00291 ); 00292 00293 // virtual ON_Geometry::IsDeformable() override 00294 bool IsDeformable() const; 00295 00296 // virtual ON_Geometry::MakeDeformable() override 00297 bool MakeDeformable(); 00298 00299 ON_BOOL32 SwapCoordinates( 00300 int, int // indices of coords to swap 00301 ); 00302 00304 // ON_Surface overrides 00305 00306 ON_BOOL32 SetDomain( 00307 int dir, // 0 sets first parameter's domain, 1 gets second parameter's domain 00308 double t0, 00309 double t1 00310 ); 00311 00312 ON_Interval Domain( 00313 int // 0 gets first parameter's domain, 1 gets second parameter's domain 00314 ) const; 00315 00316 00317 /* 00318 Description: 00319 Get an estimate of the size of the rectangle that would 00320 be created if the 3d surface where flattened into a rectangle. 00321 Parameters: 00322 width - [out] (corresponds to the first surface parameter) 00323 height - [out] (corresponds to the first surface parameter) 00324 Remarks: 00325 overrides virtual ON_Surface::GetSurfaceSize 00326 Returns: 00327 true if successful. 00328 */ 00329 ON_BOOL32 GetSurfaceSize( 00330 double* width, 00331 double* height 00332 ) const; 00333 00334 int SpanCount( 00335 int // 0 gets first parameter's domain, 1 gets second parameter's domain 00336 ) const; // number of smooth spans in curve 00337 00338 ON_BOOL32 GetSpanVector( // span "knots" 00339 int, // 0 gets first parameter's domain, 1 gets second parameter's domain 00340 double* // array of length SpanCount() + 1 00341 ) const; // 00342 00343 int Degree( // returns maximum algebraic degree of any span 00344 // ( or a good estimate if curve spans are not algebraic ) 00345 int // 0 gets first parameter's domain, 1 gets second parameter's domain 00346 ) const; 00347 00348 ON_BOOL32 GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus 00349 int, // 0 gets first parameter, 1 gets second parameter 00350 double, // t = parameter in domain 00351 double*, // tminus 00352 double* // tplus 00353 ) const; 00354 00355 /* 00356 Description: 00357 Test a surface to see if it is planar. 00358 Parameters: 00359 plane - [out] if not NULL and true is returned, 00360 the plane parameters are filled in. 00361 tolerance - [in] tolerance to use when checking 00362 Returns: 00363 true if there is a plane such that the maximum distance from 00364 the surface to the plane is <= tolerance. 00365 Remarks: 00366 Overrides virtual ON_Surface::IsPlanar. 00367 */ 00368 ON_BOOL32 IsPlanar( 00369 ON_Plane* plane = NULL, 00370 double tolerance = ON_ZERO_TOLERANCE 00371 ) const; 00372 00373 ON_BOOL32 IsClosed( // true if NURBS surface is closed (either surface has 00374 int // dir // clamped end knots and euclidean location of start 00375 ) const; // CV = euclidean location of end CV, or surface is 00376 // periodic.) 00377 00378 ON_BOOL32 IsPeriodic( // true if NURBS surface is periodic (degree > 1, 00379 int // dir // periodic knot vector, last degree many CVs 00380 ) const; // are duplicates of first degree many CVs.) 00381 00382 ON_BOOL32 IsSingular( // true if surface side is collapsed to a point 00383 int // side of parameter space to test 00384 // 0 = south, 1 = east, 2 = north, 3 = west 00385 ) const; 00386 00387 /* 00388 Description: 00389 Search for a derivatitive, tangent, or curvature 00390 discontinuity. 00391 Parameters: 00392 dir - [in] If 0, then "u" parameter is checked. If 1, then 00393 the "v" parameter is checked. 00394 c - [in] type of continity to test for. 00395 t0 - [in] Search begins at t0. If there is a discontinuity 00396 at t0, it will be ignored. This makes it 00397 possible to repeatedly call GetNextDiscontinuity 00398 and step through the discontinuities. 00399 t1 - [in] (t0 != t1) If there is a discontinuity at t1 is 00400 will be ingored unless c is a locus discontinuity 00401 type and t1 is at the start or end of the curve. 00402 t - [out] if a discontinuity is found, then *t reports the 00403 parameter at the discontinuity. 00404 hint - [in/out] if GetNextDiscontinuity will be called 00405 repeatedly, passing a "hint" with initial value *hint=0 00406 will increase the speed of the search. 00407 dtype - [out] if not NULL, *dtype reports the kind of 00408 discontinuity found at *t. A value of 1 means the first 00409 derivative or unit tangent was discontinuous. A value 00410 of 2 means the second derivative or curvature was 00411 discontinuous. A value of 0 means teh curve is not 00412 closed, a locus discontinuity test was applied, and 00413 t1 is at the start of end of the curve. 00414 cos_angle_tolerance - [in] default = cos(1 degree) Used only 00415 when c is ON::G1_continuous or ON::G2_continuous. If the 00416 cosine of the angle between two tangent vectors is 00417 <= cos_angle_tolerance, then a G1 discontinuity is reported. 00418 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used 00419 only when c is ON::G2_continuous. If K0 and K1 are 00420 curvatures evaluated from above and below and 00421 |K0 - K1| > curvature_tolerance, then a curvature 00422 discontinuity is reported. 00423 Returns: 00424 Parametric continuity tests c = (C0_continuous, ..., G2_continuous): 00425 00426 true if a parametric discontinuity was found strictly 00427 between t0 and t1. Note well that all curves are 00428 parametrically continuous at the ends of their domains. 00429 00430 Locus continuity tests c = (C0_locus_continuous, ...,G2_locus_continuous): 00431 00432 true if a locus discontinuity was found strictly between 00433 t0 and t1 or at t1 is the at the end of a curve. 00434 Note well that all open curves (IsClosed()=false) are locus 00435 discontinuous at the ends of their domains. All closed 00436 curves (IsClosed()=true) are at least C0_locus_continuous at 00437 the ends of their domains. 00438 */ 00439 bool GetNextDiscontinuity( 00440 int dir, 00441 ON::continuity c, 00442 double t0, 00443 double t1, 00444 double* t, 00445 int* hint=NULL, 00446 int* dtype=NULL, 00447 double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE, 00448 double curvature_tolerance=ON_SQRT_EPSILON 00449 ) const; 00450 00451 /* 00452 Description: 00453 Test continuity at a surface parameter value. 00454 Parameters: 00455 c - [in] continuity to test for 00456 s - [in] surface parameter to test 00457 t - [in] surface parameter to test 00458 hint - [in] evaluation hint 00459 point_tolerance - [in] if the distance between two points is 00460 greater than point_tolerance, then the surface is not C0. 00461 d1_tolerance - [in] if the difference between two first derivatives is 00462 greater than d1_tolerance, then the surface is not C1. 00463 d2_tolerance - [in] if the difference between two second derivatives is 00464 greater than d2_tolerance, then the surface is not C2. 00465 cos_angle_tolerance - [in] default = cos(1 degree) Used only when 00466 c is ON::G1_continuous or ON::G2_continuous. If the cosine 00467 of the angle between two normal vectors 00468 is <= cos_angle_tolerance, then a G1 discontinuity is reported. 00469 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when 00470 c is ON::G2_continuous. If K0 and K1 are curvatures evaluated 00471 from above and below and |K0 - K1| > curvature_tolerance, 00472 then a curvature discontinuity is reported. 00473 Returns: 00474 true if the surface has at least the c type continuity at the parameter t. 00475 Remarks: 00476 Overrides virtual ON_Surface::IsContinuous 00477 */ 00478 bool IsContinuous( 00479 ON::continuity c, 00480 double s, 00481 double t, 00482 int* hint = NULL, 00483 double point_tolerance=ON_ZERO_TOLERANCE, 00484 double d1_tolerance=ON_ZERO_TOLERANCE, 00485 double d2_tolerance=ON_ZERO_TOLERANCE, 00486 double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE, 00487 double curvature_tolerance=ON_SQRT_EPSILON 00488 ) const; 00489 00490 ON_BOOL32 Reverse( // reverse parameterizatrion, Domain changes from [a,b] to [-b,-a] 00491 int // dir 0 = "s", 1 = "t" 00492 ); 00493 00494 ON_BOOL32 Transpose(); // transpose surface parameterization (swap "s" and "t") 00495 00496 ON_BOOL32 Evaluate( // returns false if unable to evaluate 00497 double, double, // evaluation parameter 00498 int, // number of derivatives (>=0) 00499 int, // array stride (>=Dimension()) 00500 double*, // array of length stride*(ndir+1)*(ndir+2)/2 00501 int = 0, // optional - determines which quadrant to evaluate from 00502 // 0 = default 00503 // 1 from NE quadrant 00504 // 2 from NW quadrant 00505 // 3 from SW quadrant 00506 // 4 from SE quadrant 00507 int* = 0 // optional - evaluation hint (int[2]) used to speed 00508 // repeated evaluations 00509 ) const; 00510 00511 /* 00512 Description: 00513 Get isoparametric curve. 00514 Overrides virtual ON_Surface::IsoCurve. 00515 Parameters: 00516 dir - [in] 0 first parameter varies and second parameter is constant 00517 e.g., point on IsoCurve(0,c) at t is srf(t,c) 00518 1 first parameter is constant and second parameter varies 00519 e.g., point on IsoCurve(1,c) at t is srf(c,t) 00520 00521 c - [in] value of constant parameter 00522 Returns: 00523 Isoparametric curve. 00524 */ 00525 ON_Curve* IsoCurve( 00526 int dir, 00527 double c 00528 ) const; 00529 00530 /* 00531 Description: 00532 Removes the portions of the surface outside of the specified interval. 00533 Overrides virtual ON_Surface::Trim. 00534 00535 Parameters: 00536 dir - [in] 0 The domain specifies an sub-interval of Domain(0) 00537 (the first surface parameter). 00538 1 The domain specifies an sub-interval of Domain(1) 00539 (the second surface parameter). 00540 domain - [in] interval of the surface to keep. If dir is 0, then 00541 the portions of the surface with parameters (s,t) satisfying 00542 s < Domain(0).Min() or s > Domain(0).Max() are trimmed away. 00543 If dir is 1, then the portions of the surface with parameters 00544 (s,t) satisfying t < Domain(1).Min() or t > Domain(1).Max() 00545 are trimmed away. 00546 */ 00547 ON_BOOL32 Trim( 00548 int dir, 00549 const ON_Interval& domain 00550 ); 00551 00552 /* 00553 Description: 00554 Where possible, analytically extends surface to include domain. 00555 Parameters: 00556 dir - [in] 0 new Domain(0) will include domain. 00557 (the first surface parameter). 00558 1 new Domain(1) will include domain. 00559 (the second surface parameter). 00560 domain - [in] if domain is not included in surface domain, 00561 surface will be extended so that its domain includes domain. 00562 Will not work if surface is closed in direction dir. 00563 Original surface is identical to the restriction of the 00564 resulting surface to the original surface domain, 00565 Returns: 00566 true if successful. 00567 */ 00568 bool Extend( 00569 int dir, 00570 const ON_Interval& domain 00571 ); 00572 00573 00574 /* 00575 Description: 00576 Splits (divides) the surface into two parts at the 00577 specified parameter. 00578 Overrides virtual ON_Surface::Split. 00579 00580 Parameters: 00581 dir - [in] 0 The surface is split vertically. The "west" side 00582 is returned in "west_or_south_side" and the "east" 00583 side is returned in "east_or_north_side". 00584 1 The surface is split horizontally. The "south" side 00585 is returned in "west_or_south_side" and the "north" 00586 side is returned in "east_or_north_side". 00587 c - [in] value of constant parameter in interval returned 00588 by Domain(dir) 00589 west_or_south_side - [out] west/south portion of surface returned here 00590 east_or_north_side - [out] east/north portion of surface returned here 00591 00592 Example: 00593 00594 ON_NurbsSurface srf = ...; 00595 int dir = 1; 00596 ON_NurbsSurface* south_side = 0; 00597 ON_NurbsSurface* north_side = 0; 00598 srf.Split( dir, srf.Domain(dir).Mid() south_side, north_side ); 00599 00600 */ 00601 ON_BOOL32 Split( 00602 int dir, 00603 double c, 00604 ON_Surface*& west_or_south_side, 00605 ON_Surface*& east_or_north_side 00606 ) const; 00607 00608 /* 00609 Description: 00610 Offset surface. 00611 Parameters: 00612 offset_distance - [in] offset distance 00613 tolerance - [in] Some surfaces do not have an exact offset that 00614 can be represented using the same class of surface definition. 00615 In that case, the tolerance specifies the desired accuracy. 00616 max_deviation - [out] If this parameter is not NULL, the maximum 00617 deviation from the returned offset to the true offset is returned 00618 here. This deviation is zero except for cases where an exact 00619 offset cannot be computed using the same class of surface definition. 00620 Returns: 00621 Offset surface. 00622 */ 00623 ON_Surface* Offset( 00624 double offset_distance, 00625 double tolerance, 00626 double* max_deviation = NULL 00627 ) const; 00628 00629 int GetNurbForm( // returns 0: unable to create NURBS representation 00630 // with desired accuracy. 00631 // 1: success - returned NURBS parameterization 00632 // matches the surface's to wthe desired accuracy 00633 // 2: success - returned NURBS point locus matches 00634 // the surfaces's to the desired accuracy but, on 00635 // the interior of the surface's domain, the 00636 // surface's parameterization and the NURBS 00637 // parameterization may not match to the 00638 // desired accuracy. 00639 ON_NurbsSurface&, 00640 double = 0.0 // tolerance 00641 ) const; 00642 00644 // Interface 00645 00646 /* 00647 Description: 00648 Get the maximum length of a nurb surface's control polygon 00649 rows and/or columns 00650 Parameters: 00651 dir - [in] 0 to get "u" direction length, 1 to get "v" 00652 direction length 00653 length - [out] maximum length of a polygon "row" in the 00654 specified direction 00655 Returns: 00656 true if successful. 00657 */ 00658 double ControlPolygonLength( int dir ) const; 00659 00660 00661 bool IsRational( // true if NURBS surface is rational 00662 void 00663 ) const; 00664 00665 int CVSize( // number of doubles per control vertex 00666 void // = IsRational() ? Dim()+1 : Dim() 00667 ) const; 00668 00669 int Order( // order = degree + 1 00670 int // dir 0 = "s", 1 = "t" 00671 ) const; 00672 00673 int CVCount( // number of control vertices 00674 int // dir 0 = "s", 1 = "t" 00675 ) const; 00676 00677 int CVCount( // total number of control vertices 00678 void 00679 ) const; 00680 00681 int KnotCount( // total number of knots in knot vector 00682 int dir // dir 0 = "s", 1 = "t" 00683 ) const; 00684 00685 /* 00686 Description: 00687 Expert user function to get a pointer to control vertex 00688 memory. If you are not an expert user, please use 00689 ON_NurbsSurface::GetCV( ON_3dPoint& ) or 00690 ON_NurbsSurface::GetCV( ON_4dPoint& ). 00691 Parameters: 00692 i - [in] (0 <= i < m_cv_count[0]) 00693 j - [in] (0 <= j < m_cv_count[1]) 00694 Returns: 00695 Pointer to control vertex. 00696 Remarks: 00697 If the NURBS surface is rational, the format of the 00698 returned array is a homogeneos rational point with 00699 length m_dim+1. If the NURBS surface is not rational, 00700 the format of the returned array is a nonrational 00701 euclidean point with length m_dim. 00702 See Also 00703 ON_NurbsSurface::CVStyle 00704 ON_NurbsSurface::GetCV 00705 ON_NurbsSurface::Weight 00706 */ 00707 double* CV( 00708 int i, 00709 int j 00710 ) const; 00711 00712 /* 00713 Description: 00714 Returns the style of control vertices in the m_cv array. 00715 Returns: 00716 @untitled table 00717 ON::not_rational m_is_rat is false 00718 ON::homogeneous_rational m_is_rat is true 00719 */ 00720 ON::point_style CVStyle() const; 00721 00722 double Weight( // get value of control vertex weight 00723 int i, int j // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1) 00724 ) const; 00725 00726 ON_BOOL32 SetWeight( // get value of control vertex weight 00727 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1) 00728 double weight 00729 ); 00730 00731 ON_BOOL32 SetCV( // set a single control vertex 00732 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1) 00733 ON::point_style, // style of input point 00734 const double* cv // value of control vertex 00735 ); 00736 00737 ON_BOOL32 SetCV( // set a single control vertex 00738 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1) 00739 const ON_3dPoint& cv// value of control vertex 00740 // If NURBS is rational, weight 00741 // will be set to 1. 00742 ); 00743 00744 ON_BOOL32 SetCV( // set a single control vertex 00745 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1) 00746 const ON_4dPoint& cv// value of control vertex 00747 ); 00748 00749 ON_BOOL32 SetCVRow( // Sets CV( *, row_index ) 00750 int row_index, // row_index >= 0 and < m_cv_count[1] 00751 const ON_3dPoint& cv // value of control vertex 00752 // If NURBS is rational, weight 00753 // will be set to 1. 00754 ); 00755 00756 ON_BOOL32 SetCVRow( // Sets CV( *, row_index ) 00757 int row_index, // row_index >= 0 and < m_cv_count[1] 00758 int v_stride, // v stride 00759 const double* v // v[] = values (same dim and is_rat as surface) 00760 ); 00761 00762 ON_BOOL32 SetCVColumn( // Sets CV( col_index, * ) 00763 int col_index, // col_index >= 0 and < m_cv_count[0] 00764 const ON_3dPoint& cv // value of control vertex 00765 // If NURBS is rational, weight 00766 // will be set to 1. 00767 ); 00768 00769 ON_BOOL32 SetCVColumn( // Sets CV( col_index, * ) 00770 int col_index, // col_index >= 0 and < m_cv_count[0] 00771 int v_stride, // v stride 00772 const double* v // v[] = values (same dim and is_rat as surface) 00773 ); 00774 00775 ON_BOOL32 GetCV( // get a single control vertex 00776 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1) 00777 ON::point_style, // style to use for output point 00778 double* cv // array of length >= CVSize() 00779 ) const; 00780 00781 ON_BOOL32 GetCV( // get a single control vertex 00782 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1) 00783 ON_3dPoint& cv // gets euclidean cv when NURBS is rational 00784 ) const; 00785 00786 ON_BOOL32 GetCV( // get a single control vertex 00787 int i, int j, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1) 00788 ON_4dPoint& cv // gets homogeneous cv 00789 ) const; 00790 00791 int SetKnot( 00792 int dir, // dir 0 = "s", 1 = "t" 00793 int knot_index, // knot index ( 0 to KnotCount - 1 ) 00794 double knot_value // value for knot 00795 ); 00796 00797 double Knot( 00798 int dir, // dir 0 = "s", 1 = "t" 00799 int knot_index // knot index ( >= 0 and < Order + CV_count - 2 ) 00800 ) const; 00801 00802 int KnotMultiplicity( 00803 int dir, // dir 0 = "s", 1 = "t" 00804 int knot_index // knot index ( >= 0 and < Order + CV_count - 2 ) 00805 ) const; 00806 00807 const double* Knot( // knot[] array 00808 int dir // dir 0 = "s", 1 = "t" 00809 ) const; 00810 00811 // Description: 00812 // Make knot vector a clamped uniform knot vector 00813 // based on the current values of m_order and m_cv_count. 00814 // Does not change values of control vertices. 00815 // Parameters: 00816 // dir - [in] 0 = u knots, 1 = v knots 00817 // delta - [in] (>0.0) knot spacing. 00818 // Returns: 00819 // true if successful. 00820 // Remarks: 00821 // Allocates m_knot[] if it is not big enough. 00822 // See Also: 00823 // ON_MakeClampedUniformKnotVector 00824 bool MakeClampedUniformKnotVector( 00825 int dir, 00826 double delta = 1.0 00827 ); 00828 00829 // Description: 00830 // Make knot vector a periodic uniform knot vector 00831 // based on the current values of m_order and m_cv_count. 00832 // Does not change values of control vertices. 00833 // Parameters: 00834 // dir - [in] 0 = u knots, 1 = v knots 00835 // delta - [in] (>0.0) knot spacing. 00836 // Returns: 00837 // true if successful. 00838 // Remarks: 00839 // Allocates m_knot[] if it is not big enough. 00840 // See Also: 00841 // ON_MakePeriodicUniformKnotVector 00842 bool MakePeriodicUniformKnotVector( 00843 int dir, 00844 double delta = 1.0 00845 ); 00846 00847 00848 bool IsClamped( // determine if knot vector is clamped 00849 int dir, // dir 0 = "s", 1 = "t" 00850 int end = 2 // end to check: 0 = start, 1 = end, 2 = start and end 00851 ) const; 00852 00853 double SuperfluousKnot( 00854 int dir, // dir 0 = "s", 1 = "t" 00855 int end // 0 = start, 1 = end 00856 ) const; 00857 00858 double GrevilleAbcissa( 00859 int dir, // dir 00860 int cv_index // index (0 <= index < CVCount(dir) 00861 ) const; 00862 00863 bool GetGrevilleAbcissae( // see ON_GetGrevilleAbcissa() for details 00864 int dir, // dir 00865 double* g // g[cv count] 00866 ) const; 00867 00868 bool SetClampedGrevilleKnotVector( 00869 int dir, // dir 00870 int g_stride, // g_stride 00871 const double* g // g[], CVCount(dir) many Greville abcissa 00872 ); 00873 00874 bool SetPeriodicGrevilleKnotVector( 00875 int dir, // dir 00876 int g_stride, // g_stride 00877 const double* g // g[], Greville abcissa 00878 ); 00879 00880 bool ZeroCVs(); // zeros all CVs (any weights set to 1); 00881 00882 bool ClampEnd( 00883 int dir, // dir 0 = "s", 1 = "t" 00884 int end // 0 = clamp start, 1 = clamp end, 2 = clamp start and end 00885 ); 00886 00887 bool InsertKnot( 00888 int dir, // dir 0 = "s", 1 = "t" 00889 double knot_value, // value of knot 00890 int knot_multiplicity=1 // multiplicity of knot ( >= 1 and <= degree ) 00891 ); 00892 00893 bool MakeRational(); 00894 00895 bool MakeNonRational(); 00896 00897 bool IncreaseDegree( 00898 int dir, // dir 0 = "s", 1 = "t" 00899 int desired_degree // desired_degree 00900 ); 00901 00902 bool ChangeDimension( 00903 int desired_dimension // desired_dimension 00904 ); 00905 00906 /* 00907 Description: 00908 If the surface is closed in direction dir, then modify it so that 00909 the seam is at parameter t in the dir direction. 00910 Parameters: 00911 dir - [in] must be 0 or 1 00912 t - [in] dir parameter of seam, must have Domain(dir).Includes(t). 00913 The resulting surface domain in the dir direction will start at t. 00914 Returns: 00915 true if successful. 00916 */ 00917 ON_BOOL32 ChangeSurfaceSeam( 00918 int dir, 00919 double t 00920 ); 00921 00922 00923 // Creates a tensor product nurbs surface with srf(s,t) = T(A(s),B(t)); 00924 ON_BOOL32 TensorProduct( 00925 const ON_NurbsCurve&, // A 00926 const ON_NurbsCurve&, // B 00927 ON_TensorProduct& // T 00928 ); 00929 00931 // Tools for managing CV and knot memory 00932 ON_BOOL32 ReserveKnotCapacity( // returns false if allocation fails 00933 // does not change m_order or m_cv_count 00934 int dir, // dir 0 = "s", 1 = "t" 00935 int knot_array_capacity // minimum capacity of m_knot[] array 00936 ); 00937 ON_BOOL32 ReserveCVCapacity( // returns false if allocation fails 00938 // does not change m_order or m_cv_count 00939 int cv_array_capacity // minimum capacity of m_cv[] array 00940 ); 00941 00942 /* 00943 Description: 00944 Convert a NURBS surface bispan into a bezier surface. 00945 Parameters: 00946 span_index0 - [in] Specifies the "u" span and must satisfy 00947 0 <= span_index0 <= m_cv_count[0]-m_order[0] 00948 m_knot[0][span_index0+m_order[0]-2] < m_knot[0][span_index0+m_order[0]-1] 00949 span_index1 - [in] Specifies the "v" span and must satisfy 00950 0 <= span_index1 <= m_cv_count[1]-m_order[1] 00951 m_knot[1][span_index1+m_order[1]-2] < m_knot[1][span_index1+m_order[1]-1] 00952 bezier_surface - [out] bezier surface returned here 00953 Returns: 00954 true if successful 00955 false if input is not valid 00956 */ 00957 ON_BOOL32 ConvertSpanToBezier( 00958 int span_index0, 00959 int span_index1, 00960 ON_BezierSurface& bezier_surface 00961 ) const; 00962 00964 // Implementation 00965 public: 00966 // NOTE: These members are left "public" so that expert users may efficiently 00967 // create NURBS curves using the default constructor and borrow the 00968 // knot and CV arrays from their native NURBS representation. 00969 // No technical support will be provided for users who access these 00970 // members directly. If you can't get your stuff to work, then use 00971 // the constructor with the arguments and the SetKnot() and SetCV() 00972 // functions to fill in the arrays. 00973 00974 int m_dim; // (>=1) 00975 00976 int m_is_rat; // 1 for rational B-splines. (Control vertices 00977 // use homogeneous form.) 00978 // 0 for non-rational B-splines. (Control 00979 // verticies do not have a weight coordinate.) 00980 00981 int m_order[2]; // order = degree+1 (>=2) 00982 00983 int m_cv_count[2]; // number of control vertices ( >= order ) 00984 00985 // knot vector memory 00986 00987 int m_knot_capacity[2]; // If m_knot_capacity > 0, then m_knot[] 00988 // is an array of at least m_knot_capacity 00989 // doubles whose memory is managed by the 00990 // ON_NurbsSurface class using rhmalloc(), 00991 // onrealloc(), and rhfree(). 00992 // If m_knot_capacity is 0 and m_knot is 00993 // not NULL, then m_knot[] is assumed to 00994 // be big enough for any requested operation 00995 // and m_knot[] is not deleted by the 00996 // destructor. 00997 00998 double* m_knot[2]; // Knot vector. ( The knot vector has length 00999 // m_order+m_cv_count-2. ) 01000 01001 // control vertex net memory 01002 01003 int m_cv_stride[2]; // The pointer to start of "CV[i]" is 01004 // m_cv + i*m_cv_stride. 01005 01006 int m_cv_capacity; // If m_cv_capacity > 0, then m_cv[] is an array 01007 // of at least m_cv_capacity doubles whose 01008 // memory is managed by the ON_NurbsSurface 01009 // class using rhmalloc(), onrealloc(), and rhfree(). 01010 // If m_cv_capacity is 0 and m_cv is not 01011 // NULL, then m_cv[] is assumed to be big enough 01012 // for any requested operation and m_cv[] is not 01013 // deleted by the destructor. 01014 01015 double* m_cv; // Control points. 01016 // If m_is_rat is false, then control point is 01017 // 01018 // ( CV(i)[0], ..., CV(i)[m_dim-1] ). 01019 // 01020 // If m_is_rat is true, then the control point 01021 // is stored in HOMOGENEOUS form and is 01022 // 01023 // [ CV(i)[0], ..., CV(i)[m_dim] ]. 01024 // 01025 }; 01026 01027 01028 class PCL_EXPORTS ON_CLASS ON_NurbsCage : public ON_Geometry 01029 { 01030 ON_OBJECT_DECLARE(ON_NurbsCage); 01031 01032 public: 01033 ON_NurbsCage(); 01034 01035 ON_NurbsCage( 01036 int dim, 01037 bool is_rat, 01038 int order0, 01039 int order1, 01040 int order2, 01041 int cv_count0, 01042 int cv_count1, 01043 int cv_count2 01044 ); 01045 01046 ON_NurbsCage( 01047 const ON_BoundingBox& bbox, 01048 int order0, 01049 int order1, 01050 int order2, 01051 int cv_count0, 01052 int cv_count1, 01053 int cv_count2 01054 ); 01055 01056 ON_NurbsCage( 01057 const ON_3dPoint* box_corners, // array of 8 3d points 01058 int order0, 01059 int order1, 01060 int order2, 01061 int cv_count0, 01062 int cv_count1, 01063 int cv_count2 01064 ); 01065 01066 ON_NurbsCage( const ON_BezierCage& src ); 01067 01068 ~ON_NurbsCage(); 01069 01070 ON_NurbsCage(const ON_NurbsCage& src); 01071 01072 ON_NurbsCage& operator=(const ON_NurbsCage& src); 01073 01074 ON_NurbsCage& operator=(const ON_BezierCage& src); 01075 01076 01077 /* 01078 Description: 01079 Overrides the pure virtual ON_Object::IsValid function. 01080 Parameters: 01081 text_log - [in] If not null and the object is invalid, 01082 a brief description of the problem 01083 suitable for debugging C++ code 01084 is printed in this log. 01085 Returns: 01086 True if the orders are at least two, dimension is positive, 01087 knot vectors are valid, and the other fields are valid 01088 for the specified orders and dimension. 01089 */ 01090 ON_BOOL32 IsValid( 01091 ON_TextLog* text_log = NULL 01092 ) const; 01093 01094 /* 01095 Description: 01096 Overrides the pure virtual ON_Object::Dump function. 01097 Parameters: 01098 text_log - [in] A listing of the values of the members. 01099 */ 01100 void Dump( ON_TextLog& text_log) const; 01101 01102 /* 01103 Description: 01104 Overrides the pure virtual ON_Object::SizeOf function. 01105 Returns: 01106 An estimate of the amount of memory used by the class 01107 and its members. 01108 */ 01109 unsigned int SizeOf() const; 01110 01111 // virtual ON_Object::DataCRC override 01112 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const; 01113 01114 /* 01115 Description: 01116 Overrides the pure virtual ON_Object::Read function. 01117 Reads the definition of this class from an 01118 archive previously saved by ON_BezierVolue::Write. 01119 Parameters: 01120 archive - [in] target archive 01121 Returns: 01122 True if successful. 01123 */ 01124 ON_BOOL32 Read( 01125 ON_BinaryArchive& archive 01126 ); 01127 01128 /* 01129 Description: 01130 Overrides the pure virtual ON_Object::Write function. 01131 Saves the definition of this class in serial binary 01132 form that can be read by ON_BezierVolue::Read. 01133 Parameters: 01134 archive - [in] target archive 01135 Returns: 01136 True if successful. 01137 */ 01138 ON_BOOL32 Write( 01139 ON_BinaryArchive& archive 01140 ) const; 01141 01142 /* 01143 Description: 01144 Overrides the pure virtual ON_Object::ObjectType function. 01145 Saves the definition of this class in serial binary 01146 form that can be read by ON_BezierVolue::Read. 01147 Parameters: 01148 archive - [in] target archive 01149 Returns: 01150 True if successful. 01151 */ 01152 ON::object_type ObjectType() const; 01153 01154 /* 01155 Description: 01156 Overrides the pure virtual ON_Object::DestroyRuntimeCache function. 01157 Saves the definition of this class in serial binary 01158 form that can be read by ON_BezierVolue::Read. 01159 Parameters: 01160 bDelete - [in] if true, the cache is deleted. If false, the 01161 pointers to the cache are set to zero; this is done when 01162 the cache memory was allocated from a pool that has 01163 been destroyed and an attempt to free the memory would 01164 result in a crash. 01165 Returns: 01166 True if successful. 01167 */ 01168 void DestroyRuntimeCache( 01169 bool bDelete = true 01170 ); 01171 01172 01173 /* 01174 Description: 01175 Overrides virtual ON_Geometry::Dimension function. 01176 Gets a tight bounding box with respect to the coordinate 01177 system specified by the frame parameter. 01178 Parameters: 01179 bbox - [in/out] 01180 bGrowBox - [in] If true, the input bbox is grown to include 01181 this object's bounding box. 01182 frame - [in] if not null, this specifies the coordinate system 01183 frame. 01184 Returns: 01185 True if successful. 01186 */ 01187 int Dimension() const; 01188 01189 /* 01190 Description: 01191 Overrides virtual ON_Geometry::GetBBox function. 01192 Gets the world axis aligned bounding box that contains 01193 the NURBS volume's control points. The NURBS volume 01194 maps the unit cube into this box. 01195 Parameters: 01196 boxmin - [in] array of Dimension() doubles 01197 boxmax - [in] array of Dimension() doubles 01198 bGrowBox = [in] if true and the input is a valid box 01199 then the input box is grown to 01200 include this object's bounding box. 01201 Returns: 01202 true if successful. 01203 */ 01204 ON_BOOL32 GetBBox( 01205 double* boxmin, 01206 double* boxmax, 01207 int bGrowBox = false 01208 ) const; 01209 01210 /* 01211 Description: 01212 Get tight bounding box. 01213 Parameters: 01214 tight_bbox - [in/out] tight bounding box 01215 bGrowBox -[in] (default=false) 01216 If true and the input tight_bbox is valid, then returned 01217 tight_bbox is the union of the input tight_bbox and the 01218 surface's tight bounding box. 01219 xform -[in] (default=NULL) 01220 If not NULL, the tight bounding box of the transformed 01221 surface is calculated. The surface is not modified. 01222 Returns: 01223 True if a valid tight_bbox is returned. 01224 */ 01225 bool GetTightBoundingBox( 01226 ON_BoundingBox& tight_bbox, 01227 int bGrowBox = false, 01228 const ON_Xform* xform = 0 01229 ) const; 01230 01231 /* 01232 Description: 01233 Overrides virtual ON_Geometry::Transform function. 01234 Transforms NURBS volume. 01235 Parameters: 01236 xform - [in] 01237 Returns: 01238 true if successful. 01239 */ 01240 ON_BOOL32 Transform( 01241 const ON_Xform& xform 01242 ); 01243 01244 /* 01245 Description: 01246 Overrides virtual ON_Geometry::IsDeformable function. 01247 Returns: 01248 True because a NURBS volume can be accuratly modified 01249 with "squishy" transformations like projections, 01250 shears, an non-uniform scaling. 01251 */ 01252 bool IsDeformable() const; 01253 01254 /* 01255 Description: 01256 Overrides virtual ON_Geometry::MakeDeformable function. 01257 Returns: 01258 True because NURBS volumes are deformable. 01259 */ 01260 bool MakeDeformable(); 01261 01262 /* 01263 Returns: 01264 True if the cage is a parallelogram within the tolerance. 01265 This means the cage can be used as a starting point 01266 for cage deformations. 01267 */ 01268 bool IsParallelogram(double tolerance) const; 01269 01270 bool Create( 01271 int dim, 01272 bool is_rat, 01273 int order0, 01274 int order1, 01275 int order2, 01276 int cv_count0, 01277 int cv_count1, 01278 int cv_count2 01279 ); 01280 01281 /* 01282 Description: 01283 Create a Nurbs volume with corners defined by a bounding box. 01284 Parameters: 01285 box_corners - [in] 8 points that define corners of the volume 01286 01287 7______________6 01288 |\ |\ 01289 | \ | \ 01290 | \ _____________\ 01291 | 4 | 5 01292 | | | | 01293 | | | | 01294 3---|----------2 | 01295 \ | \ | 01296 \ |z \ | 01297 y \ | \ | 01298 \0_____________\1 01299 x 01300 01301 */ 01302 bool Create( 01303 const ON_BoundingBox& bbox, 01304 int order0, 01305 int order1, 01306 int order2, 01307 int cv_count0, 01308 int cv_count1, 01309 int cv_count2 01310 ); 01311 01312 /* 01313 Description: 01314 Create a nurbs volume from a 3d box 01315 Parameters: 01316 box_corners - [in] 8 points that define corners of the volume 01317 01318 7______________6 01319 |\ |\ 01320 | \ | \ 01321 | \ _____________\ 01322 | 4 | 5 01323 | | | | 01324 | | | | 01325 3---|----------2 | 01326 \ | \ | 01327 \ |t \ | 01328 s \ | \ | 01329 \0_____________\1 01330 r 01331 01332 */ 01333 bool Create( 01334 const ON_3dPoint* box_corners, 01335 int order0, 01336 int order1, 01337 int order2, 01338 int cv_count0, 01339 int cv_count1, 01340 int cv_count2 01341 ); 01342 01343 void Destroy(); 01344 01345 void EmergencyDestroy(); // call if memory used by ON_NurbsCage becomes invalid 01346 01347 ON_Interval Domain( 01348 int // dir 0 = "r", 1 = "s", 2 = "t" 01349 ) const; 01350 01351 bool Reverse( 01352 int dir // dir 0 = "r", 1 = "s", 2 = "t" 01353 ); 01354 01355 bool Transpose( 01356 int dir0, 01357 int dir1 01358 ); 01359 01360 bool ClampEnd( 01361 int dir, // dir 0 = "r", 1 = "s", 2 = "t" 01362 int end // 0 = clamp start, 1 = clamp end, 2 = clamp start and end 01363 ); 01364 01365 bool InsertKnot( 01366 int dir, // dir 0 = "r", 1 = "s", 2 = "t" 01367 double knot_value, // value of knot 01368 int knot_multiplicity=1 // multiplicity of knot ( >= 1 and <= degree ) 01369 ); 01370 01371 ON_BOOL32 IncreaseDegree( 01372 int dir, // dir 0 = "r", 1 = "s", 2 = "t" 01373 int desired_degree // desired_degree 01374 ); 01375 01376 ON_BOOL32 ChangeDimension( 01377 int desired_dimension // desired_dimension 01378 ); 01379 01380 /* 01381 Description: 01382 Evaluate the NURBS cage 01383 Parameters: 01384 r - [in] 01385 s - [in] 01386 t - [in] (r,s,t) = evaluation parameters 01387 der_count - [in] (>= 0) 01388 v_stride - [in] (>= m_dim) 01389 v - [out] An array of length v_stride*(der_count+1)(der_count+2)*(der_count+3)/6. 01390 The evaluation results are stored in this array. 01391 01392 P = v[0],...,v[m_dim-1] 01393 Dr = v[v_stride],... 01394 Ds = v[2*v_stride],... 01395 Dt = v[3*v_stride],... 01396 01397 In general, Dr^i Ds^j Dt^k is returned in v[n],...,v[n+m_dim-1], where 01398 01399 d = (i+j+k) 01400 n = v_stride*( d*(d+1)*(d+2)/6 + (j+k)*(j+k+1)/2 + k) 01401 01402 side - [in] specifies the span to use for the evaluation 01403 when r, s, or t is at a knot value. 01404 0 = default 01405 1 = from upper NE quadrant 01406 2 = from upper NW quadrant 01407 3 = from upper SW quadrant 01408 4 = from upper SE quadrant 01409 5 = from lower NE quadrant 01410 6 = from lower NW quadrant 01411 7 = from lower SW quadrant 01412 8 = from lower SE quadrant 01413 hint - [in/out] If a bunch of evaluations will be performed that 01414 tend to occur in the same region, then 01415 hint[3] can be used to speed the search for 01416 the evaluation span. The input value is 01417 used as a search hint and the output value 01418 records the span used for that evaluation. 01419 Example: 01420 01421 int der_count = 2; 01422 int v_stride = dim; 01423 double v[v_stride*(der_count+1)*(der_count+2)*(der_count+3)/6]; 01424 int side = 0; 01425 int hint[3]; hint[0] = 0; hint[1] = 0; hint[2] = 0; 01426 bool rc = cage.Evaluate(r,s,t,der_count,v_stride,v,side,hint); 01427 01428 ON_3dPoint P = v; 01429 01430 // first order partial derivatives 01431 ON_3dVector Dr = v + v_stride; 01432 ON_3dVector Ds = v + 2*v_stride; 01433 ON_3dVector Dt = v + 3*v_stride; 01434 01435 // second order partial derivatives 01436 ON_3dVector Drr = v + 4*v_stride; 01437 ON_3dVector Drs = v + 5*v_stride; 01438 ON_3dVector Drt = v + 6*v_stride; 01439 ON_3dVector Dss = v + 7*v_stride; 01440 ON_3dVector Dst = v + 8*v_stride; 01441 ON_3dVector Dtt = v + 8*v_stride; 01442 01443 Returns: 01444 True if successful 01445 See Also: 01446 ON_NurbsCage::PointAt 01447 */ 01448 bool Evaluate( 01449 double r, 01450 double s, 01451 double t, 01452 int der_count, 01453 int v_stride, 01454 double* v, 01455 int side=0, 01456 int* hint=0 01457 ) const; 01458 01459 /* 01460 Description: 01461 Evaluates bezer volume map. 01462 Parameters: 01463 rst - [in] 01464 Returns: 01465 Value of the nurbs volume map at (r,s,t). 01466 */ 01467 ON_3dPoint PointAt( 01468 double r, 01469 double s, 01470 double t 01471 ) const; 01472 01473 ON_NurbsSurface* IsoSurface( 01474 int dir, 01475 double c, 01476 ON_NurbsSurface* srf = 0 01477 ) const; 01478 01479 bool Trim( 01480 int dir, 01481 const ON_Interval& domain 01482 ); 01483 01484 bool Extend( 01485 int dir, 01486 const ON_Interval& domain 01487 ); 01488 01489 /* 01490 Description: 01491 Evaluates bezer volume map. 01492 Parameters: 01493 rst - [in] 01494 Returns: 01495 Value of the nurbs volume map at (rst.x,rst.y,rst.z). 01496 */ 01497 ON_3dPoint PointAt( 01498 ON_3dPoint rst 01499 ) const; 01500 01501 bool IsRational() const; 01502 01503 int CVSize() const; 01504 01505 int Order( 01506 int dir // dir 0 = "r", 1 = "s", 2 = "t" 01507 ) const; 01508 01509 int CVCount( // number of control vertices 01510 int // dir 0 = "r", 1 = "s", 2 = "t" 01511 ) const; 01512 01513 int CVCount( // total number of control vertices 01514 void 01515 ) const; 01516 01517 int KnotCount( // total number of knots in knot vector 01518 int dir // dir 0 = "r", 1 = "s", 2 = "t" 01519 ) const; 01520 01521 int Degree( 01522 int dir 01523 ) const; 01524 01525 01526 int SpanCount( 01527 int dir // dir 0 = "r", 1 = "s", 2 = "t" 01528 ) const; 01529 01530 bool GetSpanVector( 01531 int dir, // dir 0 = "r", 1 = "s", 2 = "t" 01532 double* span_vector 01533 ) const; 01534 01535 /* 01536 Description: 01537 Expert user function to get a pointer to control vertex 01538 memory. If you are not an expert user, please use 01539 ON_NurbsCage::GetCV( ON_3dPoint& ) or 01540 ON_NurbsCage::GetCV( ON_4dPoint& ). 01541 Parameters: 01542 cv_index0 - [in] (0 <= cv_index0 < m_order[0]) 01543 cv_index1 - [in] (0 <= cv_index1 < m_order[1]) 01544 Returns: 01545 Pointer to control vertex. 01546 Remarks: 01547 If the Nurbs surface is rational, the format of the 01548 returned array is a homogeneos rational point with 01549 length m_dim+1. If the Nurbs surface is not rational, 01550 the format of the returned array is a nonrational 01551 euclidean point with length m_dim. 01552 See Also 01553 ON_NurbsCage::CVStyle 01554 ON_NurbsCage::GetCV 01555 ON_NurbsCage::Weight 01556 */ 01557 double* CV( 01558 int i, 01559 int j, 01560 int k 01561 ) const; 01562 01563 /* 01564 Description: 01565 Returns the style of control vertices in the m_cv array. 01566 Returns: 01567 @untitled table 01568 ON::not_rational m_is_rat is false 01569 ON::homogeneous_rational m_is_rat is true 01570 */ 01571 ON::point_style CVStyle() const; 01572 01573 double Weight( // get value of control vertex weight 01574 int i, 01575 int j, 01576 int k 01577 ) const; 01578 01579 bool SetWeight( // get value of control vertex weight 01580 int i, 01581 int j, 01582 int k, 01583 double w 01584 ); 01585 01586 bool SetCV( // set a single control vertex 01587 int i, 01588 int j, 01589 int k, 01590 ON::point_style, // style of input point 01591 const double* // value of control vertex 01592 ); 01593 01594 // set a single control vertex 01595 // If NURBS is rational, weight 01596 // will be set to 1. 01597 bool SetCV( 01598 int i, 01599 int j, 01600 int k, 01601 const ON_3dPoint& point 01602 ); 01603 01604 // set a single control vertex 01605 // value of control vertex 01606 // If NURBS is not rational, euclidean 01607 // location of homogeneous point will 01608 // be used. 01609 bool SetCV( 01610 int i, 01611 int j, 01612 int k, 01613 const ON_4dPoint& hpoint 01614 ); 01615 01616 bool GetCV( // get a single control vertex 01617 int i, 01618 int j, 01619 int k, 01620 ON::point_style, // style to use for output point 01621 double* // array of length >= CVSize() 01622 ) const; 01623 01624 bool GetCV( // get a single control vertex 01625 int i, 01626 int j, 01627 int k, 01628 ON_3dPoint& // gets euclidean cv when NURBS is rational 01629 ) const; 01630 01631 bool GetCV( // get a single control vertex 01632 int i, 01633 int j, 01634 int k, 01635 ON_4dPoint& // gets homogeneous cv 01636 ) const; 01637 01638 /* 01639 Parameters: 01640 dir - [in] 0 = "r", 1 = "s", 2 = "t" 01641 knot_index - [in] 0 <= knot_index < KnotCount(dir) 01642 knot_value - [in] 01643 Returns: 01644 True if dir and knot_index parameters were valid and knot value 01645 was set. 01646 */ 01647 bool SetKnot( 01648 int dir, 01649 int knot_index, 01650 double knot_value 01651 ); 01652 01653 /* 01654 Parameters: 01655 dir - [in] 0 = "r", 1 = "s", 2 = "t" 01656 knot_index - [in] 0 <= knot_index < KnotCount(dir) 01657 Returns: 01658 Value of knot or ON_UNSET_VALUE if input parameters are not valid. 01659 */ 01660 double Knot( 01661 int dir, 01662 int knot_index 01663 ) const; 01664 01665 bool ZeroCVs(); // zeros control vertices and, if rational, sets weights to 1 01666 01667 bool MakeRational(); 01668 01669 bool MakeNonRational(); 01670 01671 bool IsClosed( // true if NURBS cage is closed (either cage has 01672 int // dir // clamped end knots and euclidean location of start 01673 ) const; // CV = euclidean location of end CV, or cage is 01674 // periodic.) 01675 01676 bool IsPeriodic( // true if NURBS cage is periodic (degree > 1, 01677 int // dir // periodic knot vector, last degree many CVs 01678 ) const; // are duplicates of first degree many CVs.) 01679 01680 bool IsSingular( // true if cage side is collapsed to a point 01681 int // side of parameter space to test 01682 // 0 = south, 1 = east, 2 = north, 3 = west 01683 ) const; 01684 01685 double GrevilleAbcissa( 01686 int dir, // dir 01687 int gindex // index (0 <= index < CVCount(dir) 01688 ) const; 01689 01691 // Tools for managing CV and knot memory 01692 01693 /* 01694 Description: 01695 cv_capacity - [in] number of doubles to reserve 01696 */ 01697 bool ReserveCVCapacity( 01698 int cv_capacity 01699 ); 01700 01701 bool ReserveKnotCapacity( 01702 int dir, 01703 int cv_capacity 01704 ); 01705 01707 // Implementation 01708 public: 01709 // NOTE: These members are left "public" so that expert users may efficiently 01710 // create nurbs curves using the default constructor and borrow the 01711 // knot and CV arrays from their native NURBS representation. 01712 // No technical support will be provided for users who access these 01713 // members directly. If you can't get your stuff to work, then use 01714 // the constructor with the arguments and the SetKnot() and SetCV() 01715 // functions to fill in the arrays. 01716 01717 01718 int m_dim; 01719 bool m_is_rat; 01720 int m_order[3]; 01721 int m_cv_count[3]; 01722 int m_knot_capacity[3]; 01723 double* m_knot[3]; 01724 int m_cv_stride[3]; 01725 int m_cv_capacity; 01726 double* m_cv; 01727 }; 01728 01729 ON_DECL 01730 bool ON_GetCageXform( 01731 const ON_NurbsCage& cage, 01732 ON_Xform& cage_xform 01733 ); 01734 01735 01736 class PCL_EXPORTS ON_CLASS ON_MorphControl : public ON_Geometry 01737 { 01738 ON_OBJECT_DECLARE(ON_MorphControl); 01739 01740 public: 01741 ON_MorphControl(); 01742 ~ON_MorphControl(); 01743 // C++ default copy construction and operator= work fine. 01744 01745 01746 void Destroy(); 01747 01748 01750 // 01751 // ON_Object virtual functions 01752 // 01753 01754 void MemoryRelocate(); 01755 01756 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 01757 01758 void Dump( ON_TextLog& ) const; 01759 01760 unsigned int SizeOf() const; 01761 01762 ON_BOOL32 Write( 01763 ON_BinaryArchive& archive 01764 ) const; 01765 01766 ON_BOOL32 Read( 01767 ON_BinaryArchive& archive 01768 ); 01769 01770 ON::object_type ObjectType() const; 01771 01772 void DestroyRuntimeCache( bool bDelete = true ); 01773 01775 // 01776 // ON_Geometry virtual functions 01777 // 01778 01779 int Dimension() const; 01780 01781 ON_BOOL32 GetBBox( 01782 double* boxmin, 01783 double* boxmax, 01784 int bGrowBox = false 01785 ) const; 01786 01787 bool GetTightBoundingBox( 01788 ON_BoundingBox& tight_bbox, 01789 int bGrowBox = false, 01790 const ON_Xform* xform = 0 01791 ) const; 01792 01793 void ClearBoundingBox(); 01794 01795 ON_BOOL32 Transform( 01796 const ON_Xform& xform 01797 ); 01798 01799 ON_BOOL32 HasBrepForm() const; 01800 01801 ON_Brep* BrepForm( ON_Brep* brep = NULL ) const; 01802 01803 01804 /* 01805 Returns: 01806 True if the target NURBS object is rational 01807 */ 01808 bool IsRational() const; 01809 01810 /* 01811 Description: 01812 Makes the target NURBS object rational. 01813 */ 01814 bool MakeRational(); 01815 01816 /* 01817 Description: 01818 Makes the target NURBS object non-rational. 01819 */ 01820 bool MakeNonRational(); 01821 01822 /* 01823 Returns: 01824 Number of control points in the target NURBS object. 01825 */ 01826 int CVCount() const; 01827 01828 int CVCount(int dir) const; 01829 int Order(int dir) const; 01830 const double* Knot(int dir) const; 01831 ON_3dex MaxCVIndex() const; 01832 const double* CV(ON_3dex) const; 01833 double Weight(ON_3dex) const; 01834 01836 // 01837 // Localizers 01838 // 01839 01840 /* 01841 Description: 01842 Adds localizer with support near the controling NURBS object. 01843 Parameters: 01844 support_distance - [in] >= 0 01845 If the distance a point to the controls NURBS 01846 curve/surface/cage is less than or equal to support_distance, 01847 then MorphPoint() deformation has 100% effect. 01848 01849 falloff_distance - [in] > 0 01850 If the distance a point to the controls NURBS 01851 curve/surface/cage is more than support_distance+falloff_distance, 01852 then MorphPoint() deformation does not move the point. 01853 As the distance varies from support_distance to 01854 support_distance+falloff_distance the deformation attenuates 01855 from 100% to 0%. 01856 */ 01857 bool AddControlLocalizer( 01858 double support_distance, 01859 double falloff_distance 01860 ); 01861 01862 bool AddSphereLocalizer( 01863 ON_3dPoint center, 01864 double support_distance, 01865 double falloff_distance 01866 ); 01867 01868 bool AddCylinderLocalizer( 01869 ON_Line axis, 01870 double support_distance, 01871 double falloff_distance 01872 ); 01873 01874 bool AddBoxLocalizer( 01875 ON_BoundingBox bbox, 01876 double support_distance, 01877 double falloff_distance 01878 ); 01879 01880 bool AddPlaneLocalizer( 01881 const ON_Plane& plane, 01882 double support_distance, 01883 double falloff_distance 01884 ); 01885 01886 bool AddConvexPolygonLocalizer( 01887 const ON_SimpleArray<ON_Plane>& planes, 01888 double support_distance, 01889 double falloff_distance 01890 ); 01891 01893 // 01894 // 01895 01896 // Get a cage_morph that can be passed to Morph functions 01897 bool GetCageMorph( class ON_CageMorph& cage_morph ) const; 01898 01899 bool IsIdentity( const ON_BoundingBox& bbox ) const; 01900 01901 int m_varient; // 1= curve, 2 = surface, 3 = cage 01902 01903 // The value of m_varient determines which nurbs object 01904 // controls the cage 01905 ON_NurbsCurve m_nurbs_curve0; 01906 ON_NurbsCurve m_nurbs_curve; 01907 ON_Interval m_nurbs_curve_domain; 01908 01909 ON_NurbsSurface m_nurbs_surface0; 01910 ON_NurbsSurface m_nurbs_surface; 01911 ON_Interval m_nurbs_surface_domain[2]; 01912 01913 ON_Xform m_nurbs_cage0; 01914 ON_NurbsCage m_nurbs_cage; 01915 01916 // Rhino captive object ids 01917 ON_UuidList m_captive_id; 01918 01919 // Use ON_GetCageXform to set m_cage_xform. 01920 01921 // Used to localize the deformation 01922 ON_ClassArray<ON_Localizer> m_localizers; 01923 01924 // ON_SpaceMorphOptions 01925 double m_sporh_tolerance; 01926 bool m_sporh_bQuickPreview; 01927 bool m_sporh_bPreserveStructure; 01928 }; 01929 01930 01931 class PCL_EXPORTS ON_CLASS ON_CageMorph : public ON_SpaceMorph 01932 { 01933 public: 01934 ON_CageMorph(); 01935 ~ON_CageMorph(); 01936 01937 bool IsIdentity( const ON_BoundingBox& bbox ) const; 01938 01939 const ON_MorphControl* m_control; 01940 }; 01941 01942 01943 // Description: 01944 // Get an ON_NurbsSurface definition of a quadrilateral. 01945 // Parameters: 01946 // P - [in] 01947 // Q - [in] 01948 // R - [in] 01949 // S - [in] corners in counter clockwise layer 01950 // nurbs_surface - [in] if this pointer is not NULL, 01951 // then this ON_NurbsSurface is used to return 01952 // the quadrilateral. 01953 // Returns: 01954 // An ON_NurbsSurface representation of the quadrilateral. 01955 ON_DECL 01956 ON_NurbsSurface* ON_NurbsSurfaceQuadrilateral( 01957 const ON_3dPoint& P, 01958 const ON_3dPoint& Q, 01959 const ON_3dPoint& R, 01960 const ON_3dPoint& S, 01961 ON_NurbsSurface* nurbs_surface = NULL 01962 ); 01963 01964 #if defined(ON_DLL_TEMPLATE) 01965 // This stuff is here because of a limitation in the way Microsoft 01966 // handles templates and DLLs. See Microsoft's knowledge base 01967 // article ID Q168958 for details. 01968 #pragma warning( push ) 01969 #pragma warning( disable : 4231 ) 01970 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_NurbsCurve>; 01971 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_NurbsCurve>; 01972 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_NurbsCurve*>; 01973 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_NurbsSurface>; 01974 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_NurbsSurface>; 01975 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_NurbsSurface*>; 01976 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_NurbsCage>; 01977 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_NurbsCage>; 01978 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_NurbsCage*>; 01979 #pragma warning( pop ) 01980 #endif 01981 01982 #endif