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 poly curve (composite curve) 00020 // 00022 00023 #if !defined(OPENNURBS_POLYCURVE_INC_) 00024 #define OPENNURBS_POLYCURVE_INC_ 00025 00026 /* 00027 Description: 00028 An ON_PolyCurve is an ON_Curve represented by a sequence of 00029 contiguous ON_Curve segments. A valid polycurve is represented 00030 by an array m_segment of Count()>=1 curve objects and a strictly 00031 increasing array m_t of Count()+1 parameter values. The i-th 00032 curve segment, when considered as part of the polycurve, is affinely 00033 reparamaterized from m_t[i] to m_t[i+1], i.e., m_segment[i].Domain()[0] 00034 is mapped to m_t[i] and m_segment[i].Domain()[1] is mapped to m_t[i+1]. 00035 */ 00036 class ON_PolyCurve; 00037 class ON_CLASS ON_PolyCurve : public ON_Curve 00038 { 00039 ON_OBJECT_DECLARE(ON_PolyCurve); 00040 00041 public: 00042 // virtual ON_Object::DestroyRuntimeCache override 00043 void DestroyRuntimeCache( bool bDelete = true ); 00044 00045 public: 00046 ON_PolyCurve(); 00047 ON_PolyCurve( int ); // int = initial capacity - use when a good estimate 00048 // of the number of segments is known. 00049 ON_PolyCurve(const ON_PolyCurve&); 00050 00051 void Destroy(); 00052 00053 virtual ~ON_PolyCurve(); 00054 00055 void EmergencyDestroy(); // call if memory used by ON_PolyCurve becomes invalid 00056 00057 ON_PolyCurve& operator=(const ON_PolyCurve&); 00058 00060 // ON_Object overrides 00061 00062 // virtual ON_Object::SizeOf override 00063 unsigned int SizeOf() const; 00064 00065 // virtual ON_Object::DataCRC override 00066 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const; 00067 00068 /* 00069 Description: 00070 Tests an object to see if its data members are correctly 00071 initialized. 00072 Parameters: 00073 text_log - [in] if the object is not valid and text_log 00074 is not NULL, then a brief englis description of the 00075 reason the object is not valid is appened to the log. 00076 The information appended to text_log is suitable for 00077 low-level debugging purposes by programmers and is 00078 not intended to be useful as a high level user 00079 interface tool. 00080 Returns: 00081 @untitled table 00082 true object is valid 00083 false object is invalid, uninitialized, etc. 00084 Remarks: 00085 Overrides virtual ON_Object::IsValid 00086 */ 00087 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 00088 00089 /* 00090 Description: 00091 Tests an object to see if its data members are correctly 00092 initialized. 00093 Parameters: 00094 bAllowGaps - [in] 00095 If true, gaps are allowed between polycurve segments. 00096 If false, gaps are not allowed between polycurve segments. 00097 text_log - [in] if the object is not valid and text_log 00098 is not NULL, then a brief englis description of the 00099 reason the object is not valid is appened to the log. 00100 The information appended to text_log is suitable for 00101 low-level debugging purposes by programmers and is 00102 not intended to be useful as a high level user 00103 interface tool. 00104 Returns: 00105 @untitled table 00106 true object is valid 00107 false object is invalid, uninitialized, etc. 00108 Remarks: 00109 Overrides virtual ON_Object::IsValid 00110 */ 00111 bool IsValid( bool bAllowGaps, ON_TextLog* text_log ) const; 00112 00113 00114 void Dump( ON_TextLog& ) const; // for debugging 00115 00116 ON_BOOL32 Write( 00117 ON_BinaryArchive& // open binary file 00118 ) const; 00119 00120 ON_BOOL32 Read( 00121 ON_BinaryArchive& // open binary file 00122 ); 00123 00125 // ON_Geometry overrides 00126 00127 int Dimension() const; 00128 00129 ON_BOOL32 GetBBox( // returns true if successful 00130 double*, // minimum 00131 double*, // maximum 00132 ON_BOOL32 = false // true means grow box 00133 ) const; 00134 00135 /* 00136 Description: 00137 Get tight bounding box. 00138 Parameters: 00139 tight_bbox - [in/out] tight bounding box 00140 bGrowBox -[in] (default=false) 00141 If true and the input tight_bbox is valid, then returned 00142 tight_bbox is the union of the input tight_bbox and the 00143 curve's tight bounding box. 00144 xform -[in] (default=NULL) 00145 If not NULL, the tight bounding box of the transformed 00146 curve is calculated. The curve is not modified. 00147 Returns: 00148 True if a valid tight_bbox is returned. 00149 */ 00150 bool GetTightBoundingBox( 00151 ON_BoundingBox& tight_bbox, 00152 int bGrowBox = false, 00153 const ON_Xform* xform = 0 00154 ) const; 00155 00156 ON_BOOL32 Transform( 00157 const ON_Xform& 00158 ); 00159 00160 // virtual ON_Geometry::IsDeformable() override 00161 bool IsDeformable() const; 00162 00163 // virtual ON_Geometry::MakeDeformable() override 00164 bool MakeDeformable(); 00165 00166 ON_BOOL32 SwapCoordinates( 00167 int, int // indices of coords to swap 00168 ); 00169 00170 // virtual ON_Geometry override 00171 bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const; 00172 00174 // ON_Curve overrides 00175 00176 ON_Curve* DuplicateCurve() const; 00177 00178 ON_Interval Domain() const; 00179 00180 // Description: 00181 // virtual ON_Curve::SetDomain override. 00182 // Set the domain of the curve 00183 // Parameters: 00184 // t0 - [in] 00185 // t1 - [in] new domain will be [t0,t1] 00186 // Returns: 00187 // true if successful. 00188 ON_BOOL32 SetDomain( 00189 double t0, 00190 double t1 00191 ); 00192 00193 bool ChangeDimension( 00194 int desired_dimension 00195 ); 00196 00197 /* 00198 Description: 00199 If this curve is closed, then modify it so that 00200 the start/end point is at curve parameter t. 00201 Parameters: 00202 t - [in] curve parameter of new start/end point. The 00203 returned curves domain will start at t. 00204 Returns: 00205 true if successful. 00206 Remarks: 00207 Overrides virtual ON_Curve::ChangeClosedCurveSeam 00208 */ 00209 ON_BOOL32 ChangeClosedCurveSeam( 00210 double t 00211 ); 00212 00213 int SpanCount() const; // number of smooth spans in curve 00214 00215 ON_BOOL32 GetSpanVector( // span "knots" 00216 double* // array of length SpanCount() + 1 00217 ) const; // 00218 00219 int Degree( // returns maximum algebraic degree of any span 00220 // ( or a good estimate if curve spans are not algebraic ) 00221 ) const; 00222 00223 ON_BOOL32 IsLinear( // true if curve locus is a line segment between 00224 // between specified points 00225 double = ON_ZERO_TOLERANCE // tolerance to use when checking linearity 00226 ) const; 00227 00228 /* 00229 Description: 00230 Several types of ON_Curve can have the form of a polyline including 00231 a degree 1 ON_NurbsCurve, an ON_PolylineCurve, and an ON_PolyCurve 00232 all of whose segments are some form of polyline. IsPolyline tests 00233 a curve to see if it can be represented as a polyline. 00234 Parameters: 00235 pline_points - [out] if not NULL and true is returned, then the 00236 points of the polyline form are returned here. 00237 t - [out] if not NULL and true is returned, then the parameters of 00238 the polyline points are returned here. 00239 Returns: 00240 @untitled table 00241 0 curve is not some form of a polyline 00242 >=2 number of points in polyline form 00243 */ 00244 int IsPolyline( 00245 ON_SimpleArray<ON_3dPoint>* pline_points = NULL, 00246 ON_SimpleArray<double>* pline_t = NULL 00247 ) const; 00248 00249 ON_BOOL32 IsArc( // ON_Arc.m_angle > 0 if curve locus is an arc between 00250 // specified points 00251 const ON_Plane* = NULL, // if not NULL, test is performed in this plane 00252 ON_Arc* = NULL, // if not NULL and true is returned, then arc parameters 00253 // are filled in 00254 double = ON_ZERO_TOLERANCE // tolerance to use when checking 00255 ) const; 00256 00257 ON_BOOL32 IsPlanar( 00258 ON_Plane* = NULL, // if not NULL and true is returned, then plane parameters 00259 // are filled in 00260 double = ON_ZERO_TOLERANCE // tolerance to use when checking 00261 ) const; 00262 00263 ON_BOOL32 IsInPlane( 00264 const ON_Plane&, // plane to test 00265 double = ON_ZERO_TOLERANCE // tolerance to use when checking 00266 ) const; 00267 00268 ON_BOOL32 IsClosed( // true if curve is closed (either curve has 00269 void // clamped end knots and euclidean location of start 00270 ) const; // CV = euclidean location of end CV, or curve is 00271 // periodic.) 00272 00273 ON_BOOL32 IsPeriodic( // true if curve is a single periodic segment 00274 void 00275 ) const; 00276 00277 /* 00278 Description: 00279 Search for a derivatitive, tangent, or curvature discontinuity. 00280 Parameters: 00281 c - [in] type of continity to test for. If ON::C1_continuous 00282 t0 - [in] search begins at t0 00283 t1 - [in] (t0 < t1) search ends at t1 00284 t - [out] if a discontinuity is found, the *t reports the 00285 parameter at the discontinuity. 00286 hint - [in/out] if GetNextDiscontinuity will be called repeatedly, 00287 passing a "hint" with initial value *hint=0 will increase the speed 00288 of the search. 00289 dtype - [out] if not NULL, *dtype reports the kind of discontinuity 00290 found at *t. A value of 1 means the first derivative or unit tangent 00291 was discontinuous. A value of 2 means the second derivative or 00292 curvature was discontinuous. 00293 cos_angle_tolerance - [in] default = cos(1 degree) Used only when 00294 c is ON::G1_continuous or ON::G2_continuous. If the cosine 00295 of the angle between two tangent vectors 00296 is <= cos_angle_tolerance, then a G1 discontinuity is reported. 00297 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when 00298 c is ON::G2_continuous or ON::Gsmooth_continuous. 00299 ON::G2_continuous: 00300 If K0 and K1 are curvatures evaluated 00301 from above and below and |K0 - K1| > curvature_tolerance, 00302 then a curvature discontinuity is reported. 00303 ON::Gsmooth_continuous: 00304 If K0 and K1 are curvatures evaluated from above and below 00305 and the angle between K0 and K1 is at least twice angle tolerance 00306 or ||K0| - |K1|| > (max(|K0|,|K1|) > curvature_tolerance, 00307 then a curvature discontinuity is reported. 00308 Returns: 00309 true if a discontinuity was found on the interior of the interval (t0,t1). 00310 Remarks: 00311 Overrides ON_Curve::GetNextDiscontinuity. 00312 */ 00313 bool GetNextDiscontinuity( 00314 ON::continuity c, 00315 double t0, 00316 double t1, 00317 double* t, 00318 int* hint=NULL, 00319 int* dtype=NULL, 00320 double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE, 00321 double curvature_tolerance=ON_SQRT_EPSILON 00322 ) const; 00323 00324 /* 00325 Description: 00326 Test continuity at a curve parameter value. 00327 Parameters: 00328 c - [in] continuity to test for 00329 t - [in] parameter to test 00330 hint - [in] evaluation hint 00331 point_tolerance - [in] if the distance between two points is 00332 greater than point_tolerance, then the curve is not C0. 00333 d1_tolerance - [in] if the difference between two first derivatives is 00334 greater than d1_tolerance, then the curve is not C1. 00335 d2_tolerance - [in] if the difference between two second derivatives is 00336 greater than d2_tolerance, then the curve is not C2. 00337 cos_angle_tolerance - [in] default = cos(1 degree) Used only when 00338 c is ON::G1_continuous or ON::G2_continuous. If the cosine 00339 of the angle between two tangent vectors 00340 is <= cos_angle_tolerance, then a G1 discontinuity is reported. 00341 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when 00342 c is ON::G2_continuous or ON::Gsmooth_continuous. 00343 ON::G2_continuous: 00344 If K0 and K1 are curvatures evaluated 00345 from above and below and |K0 - K1| > curvature_tolerance, 00346 then a curvature discontinuity is reported. 00347 ON::Gsmooth_continuous: 00348 If K0 and K1 are curvatures evaluated from above and below 00349 and the angle between K0 and K1 is at least twice angle tolerance 00350 or ||K0| - |K1|| > (max(|K0|,|K1|) > curvature_tolerance, 00351 then a curvature discontinuity is reported. 00352 Returns: 00353 true if the curve has at least the c type continuity at the parameter t. 00354 Remarks: 00355 Overrides ON_Curve::IsContinuous. 00356 */ 00357 bool IsContinuous( 00358 ON::continuity c, 00359 double t, 00360 int* hint = NULL, 00361 double point_tolerance=ON_ZERO_TOLERANCE, 00362 double d1_tolerance=ON_ZERO_TOLERANCE, 00363 double d2_tolerance=ON_ZERO_TOLERANCE, 00364 double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE, 00365 double curvature_tolerance=ON_SQRT_EPSILON 00366 ) const; 00367 00368 ON_BOOL32 Reverse(); // reverse parameterizatrion 00369 // Domain changes from [a,b] to [-b,-a] 00370 00371 /* 00372 Description: 00373 Force the curve to start at a specified point. 00374 Parameters: 00375 start_point - [in] 00376 Returns: 00377 true if successful. 00378 Remarks: 00379 Some start points cannot be moved. Be sure to check return 00380 code. 00381 See Also: 00382 ON_Curve::SetEndPoint 00383 ON_Curve::PointAtStart 00384 ON_Curve::PointAtEnd 00385 */ 00386 // virtual 00387 ON_BOOL32 SetStartPoint( 00388 ON_3dPoint start_point 00389 ); 00390 00391 /* 00392 Description: 00393 Force the curve to end at a specified point. 00394 Parameters: 00395 end_point - [in] 00396 Returns: 00397 true if successful. 00398 Remarks: 00399 Some end points cannot be moved. Be sure to check return 00400 code. 00401 See Also: 00402 ON_Curve::SetStartPoint 00403 ON_Curve::PointAtStart 00404 ON_Curve::PointAtEnd 00405 */ 00406 //virtual 00407 ON_BOOL32 SetEndPoint( 00408 ON_3dPoint end_point 00409 ); 00410 00411 ON_BOOL32 Evaluate( // returns false if unable to evaluate 00412 double, // evaluation parameter 00413 int, // number of derivatives (>=0) 00414 int, // array stride (>=Dimension()) 00415 double*, // array of length stride*(ndir+1) 00416 int = 0, // optional - determines which side to evaluate from 00417 // 0 = default 00418 // < 0 to evaluate from below, 00419 // > 0 to evaluate from above 00420 int* = 0 // optional - evaluation hint (int) used to speed 00421 // repeated evaluations 00422 ) const; 00423 00424 // Description: 00425 // virtual ON_Curve::Trim override. 00426 // Removes portions of the curve outside the specified interval. 00427 // Parameters: 00428 // domain - [in] interval of the curve to keep. Portions of the 00429 // curve before curve(domain[0]) and after curve(domain[1]) are 00430 // removed. 00431 // Returns: 00432 // true if successful. 00433 ON_BOOL32 Trim( 00434 const ON_Interval& domain 00435 ); 00436 00437 // Description: 00438 // Where possible, analytically extends curve to include domain. 00439 // Parameters: 00440 // domain - [in] if domain is not included in curve domain, 00441 // curve will be extended so that its domain includes domain. 00442 // Will not work if curve is closed. Original curve is identical 00443 // to the restriction of the resulting curve to the original curve domain, 00444 // Returns: 00445 // true if successful. 00446 bool Extend( 00447 const ON_Interval& domain 00448 ); 00449 00450 // Description: 00451 // virtual ON_Curve::Split override. 00452 // Divide the curve at the specified parameter. The parameter 00453 // must be in the interior of the curve's domain. The pointers 00454 // passed to Split must either be NULL or point to an ON_Curve 00455 // object of the same of the same type. If the pointer is NULL, 00456 // then a curve will be created in Split(). You may pass "this" 00457 // as one of the pointers to Split(). 00458 // Parameters: 00459 // t - [in] parameter in interval Domain(). 00460 // left_side - [out] left portion of curve 00461 // right_side - [out] right portion of curve 00462 // Example: 00463 // For example, if crv were an ON_NurbsCurve, then 00464 // 00465 // ON_NurbsCurve right_side; 00466 // crv.Split( crv.Domain().Mid() &crv, &right_side ); 00467 // 00468 // would split crv at the parametric midpoint, put the left side 00469 // in crv, and return the right side in right_side. 00470 ON_BOOL32 Split( 00471 double t, // t = curve parameter to split curve at 00472 ON_Curve*& left_side, // left portion returned here 00473 ON_Curve*& right_side // right portion returned here 00474 ) const; 00475 00476 int GetNurbForm( // returns 0: unable to create NURBS representation 00477 // with desired accuracy. 00478 // 1: success - returned NURBS parameterization 00479 // matches the curve's to wthe desired accuracy 00480 // 2: success - returned NURBS point locus matches 00481 // the curve's to the desired accuracy but, on 00482 // the interior of the curve's domain, the 00483 // curve's parameterization and the NURBS 00484 // parameterization may not match to the 00485 // desired accuracy. 00486 ON_NurbsCurve&, 00487 double = 0.0, 00488 const ON_Interval* = NULL // OPTIONAL subdomain of polycurve 00489 ) const; 00490 00491 int HasNurbForm( // returns 0: unable to create NURBS representation 00492 // with desired accuracy. 00493 // 1: success - returned NURBS parameterization 00494 // matches the curve's to wthe desired accuracy 00495 // 2: success - returned NURBS point locus matches 00496 // the curve's to the desired accuracy but, on 00497 // the interior of the curve's domain, the 00498 // curve's parameterization and the NURBS 00499 // parameterization may not match to the 00500 // desired accuracy. 00501 ) const; 00502 00503 // virtual ON_Curve::GetCurveParameterFromNurbFormParameter override 00504 ON_BOOL32 GetCurveParameterFromNurbFormParameter( 00505 double, // nurbs_t 00506 double* // curve_t 00507 ) const; 00508 00509 // virtual ON_Curve::GetNurbFormParameterFromCurveParameter override 00510 ON_BOOL32 GetNurbFormParameterFromCurveParameter( 00511 double, // curve_t 00512 double* // nurbs_t 00513 ) const; 00514 00516 // Interface 00517 00518 int Count() const; // number of segment curves 00519 00520 // These operator[] functions return NULL if index is out of range 00521 ON_Curve* operator[](int) const; 00522 00523 /* 00524 Description: 00525 Returns a pointer to a segment curve. 00526 Parameters: 00527 segment_index - [in] 0 based index (0 <= segment_index < Count() ) 00528 Returns: 00529 A pointer to the segment curve. Returns NULL if segment_index < 0 00530 or segment_index >= Count(). 00531 */ 00532 ON_Curve* SegmentCurve( 00533 int segment_index 00534 ) const; 00535 00536 /* 00537 Description: 00538 Converts a polycurve parameter to a segment curve parameter. 00539 Parameters: 00540 polycurve_parameter - [in] 00541 Returns: 00542 Segment curve evaluation parameter or ON_UNSET_VALUE if the 00543 segment curve parameter cannot be computed. 00544 See Also: 00545 ON_PolyCurve::PolyCurveParameter 00546 */ 00547 double SegmentCurveParameter( 00548 double polycurve_parameter 00549 ) const; 00550 00551 /* 00552 Description: 00553 Converts a segment curve parameter to a polycurve parameter. 00554 Parameters: 00555 segment_index - [in] 00556 segmentcurve_parameter - [in] 00557 Returns: 00558 Polycurve evaluation parameter or ON_UNSET_VALUE if the 00559 polycurve curve parameter cannot be computed. 00560 See Also: 00561 ON_PolyCurve::SegmentCurveParameter 00562 */ 00563 double PolyCurveParameter( 00564 int segment_index, 00565 double segmentcurve_parameter 00566 ) const; 00567 00568 /* 00569 Description: 00570 Returns the polycurve subdomain assigned to a segment curve. 00571 Parameters: 00572 segment_index - [in] 0 based index (0 <= segment_index < Count() ) 00573 Returns: 00574 The polycurve subdomain assigned to a segment curve. 00575 Returns ([ON_UNSET_VALUE,ON_UNSET_VALUE) if segment_index < 0 00576 or segment_index >= Count(). 00577 */ 00578 ON_Interval SegmentDomain( 00579 int segment_index 00580 ) const; 00581 00582 /* 00583 Description: 00584 Find the segment used for evaluation at polycurve_parameter. 00585 Parameters: 00586 polycurve_parameter - [in] 00587 Returns: 00588 index of the segment used for evaluation at polycurve_parameter. 00589 If polycurve_parameter < Domain.Min(), then 0 is returned. 00590 If polycurve_parameter > Domain.Max(), then Count()-1 is returned. 00591 */ 00592 int SegmentIndex( 00593 double polycurve_parameter 00594 ) const; 00595 00596 /* 00597 Description: 00598 Find the segments with support on sub_domain. 00599 Parameters: 00600 sub_domain - [in] increasing interval 00601 segment_index0 - [out] 00602 segment_index1 - [out] segments with index i where 00603 *segment_index0 <= i < *segment_index1 are the segments 00604 with support on the sub_domain 00605 Returns: 00606 number of segments with support on sub_domain. 00607 */ 00608 int SegmentIndex( 00609 ON_Interval sub_domain, 00610 int* segment_index0, 00611 int* segment_index1 00612 ) const; 00613 00614 ON_Curve* FirstSegmentCurve() const; // returns NULL if count = 0 00615 00616 ON_Curve* LastSegmentCurve() const; // returns NULL if count = 0 00617 00618 /* 00619 Description: 00620 Search the curve for gaps between the sub curve segments. 00621 Parameters: 00622 segment_index0 - [in] 00623 The search for gaps starts at with the comparing 00624 the end of segment[segment_index0] and the start of 00625 segment[segment_index0+1]. 00626 Returns: 00627 0: 00628 No gaps were found. 00629 i > segment_index0: 00630 The end of polycuve segment[i-1] is not coincident 00631 with the start of polycurve segment[i]. 00632 */ 00633 int FindNextGap( int segment_index0 ) const; 00634 00635 /* 00636 Description: 00637 Determine if there is a gap between the end of 00638 segment[segment_index] and the start of segment[segment_index+1]. 00639 Parameters: 00640 segment_index - [in] 00641 >= 0 00642 Returns: 00643 true: 00644 segment_index was valid and there is a gap between 00645 the end of segment[segment_index] and the start of 00646 segment[segment_index+1]. 00647 */ 00648 bool HasGapAt( int segment_index ) const; 00649 00650 // Replace calls to HasGap() with FindNextGap(0) 00651 ON_DEPRECATED int HasGap() const; 00652 00653 /* 00654 Description: 00655 Modify the one or both locations at the end of 00656 segment[gap_index-1] and the start of segment[gap_index] 00657 so they are coindicent. 00658 Parameters: 00659 gap_index - [in] 1 <= gap_index < Count() 00660 If the locations at the end of segment[gap_index-1] and 00661 the start of segment[gap_index] are not identical, then 00662 an attempt is made to modify the segments so these 00663 locations are closer. 00664 ends_to_modify - [in] 00665 0: (suggested) 00666 The code will decide what segments to modify. 00667 1: 00668 modify the end location of segment[gap_index-1] 00669 2: 00670 modify the start location of segment[gap_index] 00671 Returns: 00672 True if a modification was performed and HasGap(gap_index-1) 00673 returns 0 after the modification. 00674 False if no modification was preformed because there 00675 was no gap or because one could not be performed. 00676 Remarks: 00677 Note that passing the return value from FindNextGap() will 00678 close the gap found by FindNextGap(). 00679 */ 00680 bool CloseGap( int gap_index, int segments_to_modify ); 00681 00682 /* 00683 Description: 00684 Searches for and closes all gaps that can be found. 00685 Returns: 00686 Number of gaps that were closed. 00687 */ 00688 int CloseGaps(); 00689 00690 void Reserve( int ); // make sure capacity is at least the specified count 00691 00692 // ON_Curve pointers added with Prepend(), Append(), PrependAndMatch(), AppendANdMatch(),and Insert() are deleted 00693 // by ~ON_PolyCurve(). Use ON_CurveProxy( ON_Curve*) if you want 00694 // the original curve segment to survive ~ON_PolyCurve(). 00695 ON_BOOL32 Prepend( ON_Curve* ); // Prepend curve. 00696 ON_BOOL32 Append( ON_Curve* ); // Append curve. 00697 ON_BOOL32 Insert( 00698 int, // segment_index, 00699 ON_Curve* 00700 ); 00701 00702 //PrependAndMatch() and AppendAndMatch() return false if this->IsCLosed() or 00703 //this->Count() > 0 and curve is closed 00704 ON_BOOL32 PrependAndMatch(ON_Curve*); //Prepend and match end of curve to start of polycurve 00705 ON_BOOL32 AppendAndMatch(ON_Curve*); //Append and match start of curve to end of polycurve 00706 00707 ON_BOOL32 Remove(); // delete last segment and reduce count by 1 00708 ON_BOOL32 Remove( int ); // delete specified segment and reduce count by 1 00709 00711 // Use the HarvestSegment() function when you want to prevent a 00712 // segment from being destroyed by ~ON_PolyCurve(). HarvestSegment() 00713 // replaces the polycurve segment with a NULL. Count() and parameter 00714 // information remains unchanged. 00715 ON_Curve* HarvestSegment( int ); 00716 00717 /* 00718 Returns: 00719 True if a curve in the m_segment[] array is an ON_PolyCurve. 00720 */ 00721 bool IsNested() const; 00722 00723 /* 00724 Description: 00725 Same as RemoveNestingEx(). 00726 Remarks: 00727 RemoveNestingEx was added to avoid breaking the SDK. 00728 */ 00729 void RemoveNesting(); 00730 00731 /* 00732 Description: 00733 Removes the nested of polycurves. The result will have not 00734 have an ON_PolyCurve as a segment but will have identical 00735 locus and parameterization. 00736 Returns: 00737 True if a nested polycurve was removed. False 00738 if no nested polycurves were found. 00739 */ 00740 bool RemoveNestingEx(); 00741 00742 /* 00743 Returns: 00744 True if the domains of the curves in the m_segment[] array exactly 00745 match the domains of the segments specified in the m_t[] array. 00746 Put another way, returns true if SegmentDomain(i) = SegmentCurve(i).Domain() 00747 for every segment index. 00748 */ 00749 bool HasSynchronizedSegmentDomains() const; 00750 00751 /* 00752 Description: 00753 Sets the domain of the curve int the m_segment[] array to exactly 00754 match the domain defined in the m_t[] array. This is not required, 00755 but can simplify some coding situations. 00756 Returns: 00757 True if at least one segment was reparameterized. False if no 00758 changes were made. 00759 */ 00760 bool SynchronizeSegmentDomains(); 00761 00762 00763 00764 00766 // Expert user function 00767 // Sets the m_segment[index] to crv. 00768 void SetSegment(int index, ON_Curve* crv); 00769 00771 /* 00772 Description: 00773 Expert user function to set the m_t[] array. 00774 Parameters: 00775 t - [in] increasing array of SegmentCount()+1 parameters. 00776 Returns 00777 True if successful. 00778 */ 00779 bool SetParameterization( const double* t ); 00780 00781 /* 00782 Description: 00783 Lookup a parameter in the m_t array, optionally using a built in snap tolerance to 00784 snap a parameter value to an element of m_t. 00785 Parameters: 00786 t - [in] parameter 00787 index -[out] index into m_t such that if the function returns true then t is equal 00788 to, or is within tolerance of m_t[index]. 00789 if function returns false then the value of index is 00790 00791 @table 00792 condition value of index 00793 t<m_t[0] or m_t is empty -1 00794 m_t[i] < t < m_t[i+1] i for 0<=i<=m_t.Count()-2 00795 t>m_t[ m_t.Count()-1] m_t.Count()-1 00796 00797 bEnableSnap -[in] if true use tolerance when comparing to m_t values 00798 Returns 00799 true if the t is exactly equal to, or within tolerance of 00800 (only if bEnableSnap==true) m_t[index]. 00801 */ 00802 bool ParameterSearch(double t, int& index, bool bEnableSnap) const; 00803 00804 /* 00805 Returns: 00806 Reference to m_segment. 00807 */ 00808 const ON_CurveArray& SegmentCurves() const; 00809 00810 /* 00811 Returns: 00812 Reference to m_t. 00813 */ 00814 const ON_SimpleArray<double>& SegmentParameters() const; 00815 00817 // Implementation 00818 private: 00819 // The curves in this array are deleted by ~ON_PolyCurve(). 00820 // Use ON_CurveProxy classes if you don't want ON_PolyCurve() 00821 // to destroy the curve. 00822 00823 ON_CurveArray m_segment; // array of pointers to curves 00824 // all have the same dimension 00825 // and are contiguous to tolerance 00826 00827 ON_SimpleArray<double> m_t; // ON_PolyCurve segment parameterizations 00828 }; 00829 00830 00831 #endif