opennurbs_polylinecurve.h
Go to the documentation of this file.
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 
00017 #if !defined(OPENNURBS_CURVE_POLYLINE_INC_)
00018 #define OPENNURBS_CURVE_POLYLINE_INC_
00019 
00020 class ON_PolylineCurve;
00021 class ON_CLASS ON_PolylineCurve : public ON_Curve
00022 {
00023   ON_OBJECT_DECLARE(ON_PolylineCurve);
00024 
00025 public:
00026   ON_PolylineCurve();
00027   ON_PolylineCurve(const ON_3dPointArray&);
00028   ON_PolylineCurve(const ON_PolylineCurve&);
00029         ON_PolylineCurve& operator=(const ON_PolylineCurve&);
00030         ON_PolylineCurve& operator=(const ON_3dPointArray&);
00031 
00032   virtual ~ON_PolylineCurve();
00033 
00034   // Description:
00035   //   Call if memory used by ON_PolylineCurve becomes invalid.
00036   void EmergencyDestroy(); 
00037 
00038   
00040   // ON_Object overrides
00041 
00042   // virtual ON_Object::SizeOf override
00043   unsigned int SizeOf() const;
00044 
00045   // virtual ON_Object::DataCRC override
00046   ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
00047 
00048   /*
00049   Description:
00050     Tests an object to see if its data members are correctly
00051     initialized.
00052   Parameters:
00053     text_log - [in] if the object is not valid and text_log
00054         is not NULL, then a brief englis description of the
00055         reason the object is not valid is appened to the log.
00056         The information appended to text_log is suitable for 
00057         low-level debugging purposes by programmers and is 
00058         not intended to be useful as a high level user 
00059         interface tool.
00060   Returns:
00061     @untitled table
00062     true     object is valid
00063     false    object is invalid, uninitialized, etc.
00064   Remarks:
00065     Overrides virtual ON_Object::IsValid
00066   */
00067   ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
00068 
00069   // Description:
00070   //   virtual ON_Object::Dump override
00071   void Dump( 
00072     ON_TextLog& dump
00073     ) const;
00074 
00075   // Description:
00076   //   virtual ON_Object::Write override
00077   ON_BOOL32 Write(
00078          ON_BinaryArchive& binary_archive
00079        ) const;
00080 
00081   // Description:
00082   //   virtual ON_Object::Read override
00083   ON_BOOL32 Read(
00084          ON_BinaryArchive& binary_archive
00085        );
00086 
00088   // ON_Geometry overrides
00089 
00090   // Description:
00091   //   virtual ON_Geometry::Dimension override
00092   // Returns:
00093   //   value of m_dim
00094   int Dimension() const;
00095 
00096   // Description:
00097   //   virtual ON_Geometry::GetBBox override
00098   //   Calculates axis aligned bounding box.
00099   // Parameters:
00100   //   boxmin - [in/out] array of Dimension() doubles
00101   //   boxmax - [in/out] array of Dimension() doubles
00102   //   bGrowBox - [in] (default=false) 
00103   //     If true, then the union of the input bbox and the 
00104   //     object's bounding box is returned in bbox.  
00105   //     If false, the object's bounding box is returned in bbox.
00106   // Returns:
00107   //   true if object has bounding box and calculation was successful
00108   ON_BOOL32 GetBBox( // returns true if successful
00109          double* boxmin,
00110          double* boxmax,
00111          int bGrowBox = false
00112          ) const;
00113 
00114   /*
00115         Description:
00116     Get tight bounding box.
00117         Parameters:
00118                 tight_bbox - [in/out] tight bounding box
00119                 bGrowBox -[in]  (default=false)                 
00120       If true and the input tight_bbox is valid, then returned
00121       tight_bbox is the union of the input tight_bbox and the 
00122       polyline's tight bounding box.
00123                 xform -[in] (default=NULL)
00124       If not NULL, the tight bounding box of the transformed
00125       polyline is calculated.  The polyline is not modified.
00126         Returns:
00127     True if a valid tight_bbox is returned.
00128   */
00129         bool GetTightBoundingBox( 
00130                         ON_BoundingBox& tight_bbox, 
00131       int bGrowBox = false,
00132                         const ON_Xform* xform = 0
00133       ) const;
00134 
00135   // Description:
00136   //   virtual ON_Geometry::Transform override.
00137   //   Transforms the NURBS curve.
00138   //
00139   // Parameters:
00140   //   xform - [in] transformation to apply to object.
00141   //
00142   // Remarks:
00143   //   When overriding this function, be sure to include a call
00144   //   to ON_Object::TransformUserData() which takes care of 
00145   //   transforming any ON_UserData that may be attached to 
00146   //   the object.
00147   ON_BOOL32 Transform( 
00148          const ON_Xform& xform
00149          );
00150 
00151   // virtual ON_Geometry::IsDeformable() override
00152   bool IsDeformable() const;
00153 
00154   // virtual ON_Geometry::MakeDeformable() override
00155   bool MakeDeformable();
00156 
00157   // Description:
00158   //   virtual ON_Geometry::SwapCoordinates override.
00159   //   Swaps control point coordinate values with indices i and j.
00160   // Parameters:
00161   //   i - [in] coordinate index
00162   //   j - [in] coordinate index
00163   ON_BOOL32 SwapCoordinates(
00164         int i, 
00165         int j
00166         );
00167 
00169   // ON_Curve overrides
00170 
00171   // Description:
00172   //   virtual ON_Curve::Domain override.
00173   // Returns:
00174   //   domain of the polyline curve.
00175   ON_Interval Domain() const;
00176 
00177   // Description:
00178   //   virtual ON_Curve::SetDomain override.
00179   //   Set the domain of the curve
00180   // Parameters:
00181   //   t0 - [in]
00182   //   t1 - [in] new domain will be [t0,t1]
00183   // Returns:
00184   //   true if successful.
00185   ON_BOOL32 SetDomain(
00186         double t0, 
00187         double t1 
00188         );
00189 
00190   bool ChangeDimension(
00191           int desired_dimension
00192           );
00193 
00194   /*
00195   Description:
00196     If this curve is closed, then modify it so that
00197     the start/end point is at curve parameter t.
00198   Parameters:
00199     t - [in] curve parameter of new start/end point.  The
00200              returned curves domain will start at t.
00201   Returns:
00202     true if successful.
00203   Remarks:
00204     Overrides virtual ON_Curve::ChangeClosedCurveSeam
00205   */
00206   ON_BOOL32 ChangeClosedCurveSeam( 
00207             double t 
00208             );
00209 
00210   // Description:
00211   //   virtual ON_Curve::SpanCount override.
00212   //   Get number of segments in polyline.
00213   // Returns:
00214   //   Number of segments in polyline.
00215   int SpanCount() const;
00216 
00217   // Description:
00218   //   virtual ON_Curve::GetSpanVector override.
00219   //   Get list of parameters at polyline points.
00220   // Parameters:
00221   //   knot_values - [out] an array of length SpanCount()+1 is 
00222   //       filled in with the parameter values.  knot_values[i]
00223   //       is the parameter for the point m_pline[i].
00224   // Returns:
00225   //   true if successful
00226   ON_BOOL32 GetSpanVector(
00227          double* knot_values
00228          ) const;
00229 
00230   // Description:
00231   //   virtual ON_Curve::Degree override.
00232   // Returns:
00233   //   1
00234   int Degree() const; 
00235 
00236   // Description:
00237   //   virtual ON_Curve::IsLinear override.
00238   // Returns:
00239   //   true if all the polyline points are within tolerance
00240   //   of the line segment connecting the ends of the polyline.
00241   ON_BOOL32 IsLinear(
00242         double tolerance = ON_ZERO_TOLERANCE
00243         ) const;
00244 
00245   /*
00246   Description:
00247     Several types of ON_Curve can have the form of a polyline including
00248     a degree 1 ON_NurbsCurve, an ON_PolylineCurve, and an ON_PolyCurve
00249     all of whose segments are some form of polyline.  IsPolyline tests
00250     a curve to see if it can be represented as a polyline.
00251   Parameters:
00252     pline_points - [out] if not NULL and true is returned, then the
00253         points of the polyline form are returned here.
00254     t - [out] if not NULL and true is returned, then the parameters of
00255         the polyline points are returned here.
00256   Returns:
00257     @untitled table
00258     0        curve is not some form of a polyline
00259     >=2      number of points in polyline form
00260   */
00261   int IsPolyline(
00262         ON_SimpleArray<ON_3dPoint>* pline_points = NULL,
00263         ON_SimpleArray<double>* pline_t = NULL
00264         ) const;
00265 
00266   // Description:
00267   //   virtual ON_Curve::IsArc override.
00268   // Returns:
00269   //   false for all polylines.
00270   ON_BOOL32 IsArc(
00271         const ON_Plane* plane = NULL,
00272         ON_Arc* arc = NULL,
00273         double tolerance = ON_ZERO_TOLERANCE
00274         ) const;
00275 
00276   // Description:
00277   //   virtual ON_Curve::IsPlanar override.
00278   // Returns:
00279   //   true if the polyline is planar.
00280   ON_BOOL32 IsPlanar(
00281         ON_Plane* plane = NULL,
00282         double tolerance = ON_ZERO_TOLERANCE
00283         ) const;
00284 
00285   // Description:
00286   //   virtual ON_Curve::IsInPlane override.
00287   // Returns:
00288   //   true if every point in the polyline is within 
00289   //   tolerance of the test_plane.
00290   ON_BOOL32 IsInPlane(
00291         const ON_Plane& test_plane,
00292         double tolerance = ON_ZERO_TOLERANCE
00293         ) const;
00294 
00295   // Description:
00296   //   virtual ON_Curve::IsClosed override.
00297   // Returns:
00298   //   true if the polyline has 4 or more point, the
00299   //   first point and the last point are equal, and
00300   //   some other point is distinct from the first and
00301   //   last point.
00302   ON_BOOL32 IsClosed() const;
00303 
00304   // Description:
00305   //   virtual ON_Curve::IsPeriodic override.
00306   // Returns:
00307   //   false for all polylines.
00308   ON_BOOL32 IsPeriodic(  // true if curve is a single periodic segment
00309         void 
00310         ) const;
00311   
00312   /*
00313   Description:
00314     Search for a derivatitive, tangent, or curvature discontinuity.
00315   Parameters:
00316     c - [in] type of continity to test for.  If ON::C1_continuous
00317     t0 - [in] search begins at t0
00318     t1 - [in] (t0 < t1) search ends at t1
00319     t - [out] if a discontinuity is found, the *t reports the
00320           parameter at the discontinuity.
00321     hint - [in/out] if GetNextDiscontinuity will be called repeatedly,
00322        passing a "hint" with initial value *hint=0 will increase the speed
00323        of the search.       
00324     dtype - [out] if not NULL, *dtype reports the kind of discontinuity
00325         found at *t.  A value of 1 means the first derivative or unit tangent
00326         was discontinuous.  A value of 2 means the second derivative or
00327         curvature was discontinuous.
00328     cos_angle_tolerance - [in] default = cos(1 degree) Used only when
00329         c is ON::G1_continuous or ON::G2_continuous.  If the cosine
00330         of the angle between two tangent vectors 
00331         is <= cos_angle_tolerance, then a G1 discontinuity is reported.
00332     curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
00333         c is ON::G2_continuous or ON::Gsmooth_continuous.  
00334         ON::G2_continuous:
00335           If K0 and K1 are curvatures evaluated
00336           from above and below and |K0 - K1| > curvature_tolerance,
00337           then a curvature discontinuity is reported.
00338         ON::Gsmooth_continuous:
00339           If K0 and K1 are curvatures evaluated from above and below
00340           and the angle between K0 and K1 is at least twice angle tolerance
00341           or ||K0| - |K1|| > (max(|K0|,|K1|) > curvature_tolerance,
00342           then a curvature discontinuity is reported.
00343   Returns:
00344     true if a discontinuity was found on the interior of the interval (t0,t1).
00345   Remarks:
00346     Overrides ON_Curve::GetNextDiscontinuity.
00347   */
00348   bool GetNextDiscontinuity( 
00349                   ON::continuity c,
00350                   double t0,
00351                   double t1,
00352                   double* t,
00353                   int* hint=NULL,
00354                   int* dtype=NULL,
00355                   double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
00356                   double curvature_tolerance=ON_SQRT_EPSILON
00357                   ) const;
00358 
00359   /*
00360   Description:
00361     Test continuity at a curve parameter value.
00362   Parameters:
00363     c - [in] continuity to test for
00364     t - [in] parameter to test
00365     hint - [in] evaluation hint
00366     point_tolerance - [in] if the distance between two points is
00367         greater than point_tolerance, then the curve is not C0.
00368     d1_tolerance - [in] if the difference between two first derivatives is
00369         greater than d1_tolerance, then the curve is not C1.
00370     d2_tolerance - [in] if the difference between two second derivatives is
00371         greater than d2_tolerance, then the curve is not C2.
00372     cos_angle_tolerance - [in] default = cos(1 degree) Used only when
00373         c is ON::G1_continuous or ON::G2_continuous.  If the cosine
00374         of the angle between two tangent vectors 
00375         is <= cos_angle_tolerance, then a G1 discontinuity is reported.
00376     curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
00377         c is ON::G2_continuous or ON::Gsmooth_continuous.  
00378         ON::G2_continuous:
00379           If K0 and K1 are curvatures evaluated
00380           from above and below and |K0 - K1| > curvature_tolerance,
00381           then a curvature discontinuity is reported.
00382         ON::Gsmooth_continuous:
00383           If K0 and K1 are curvatures evaluated from above and below
00384           and the angle between K0 and K1 is at least twice angle tolerance
00385           or ||K0| - |K1|| > (max(|K0|,|K1|) > curvature_tolerance,
00386           then a curvature discontinuity is reported.
00387   Returns:
00388     true if the curve has at least the c type continuity at the parameter t.
00389   Remarks:
00390     Overrides ON_Curve::IsContinuous.
00391   */
00392   bool IsContinuous(
00393     ON::continuity c,
00394     double t, 
00395     int* hint = NULL,
00396     double point_tolerance=ON_ZERO_TOLERANCE,
00397     double d1_tolerance=ON_ZERO_TOLERANCE,
00398     double d2_tolerance=ON_ZERO_TOLERANCE,
00399     double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
00400     double curvature_tolerance=ON_SQRT_EPSILON
00401     ) const;
00402 
00403   // Description:
00404   //   virtual ON_Curve::Reverse override.
00405   //   Reverse parameterizatrion by negating all m_t values
00406   //   and reversing the order of the m_pline points.
00407   // Remarks:
00408   //   Domain changes from [a,b] to [-b,-a]
00409   ON_BOOL32 Reverse();
00410 
00411   /*
00412   Description:
00413     Force the curve to start at a specified point.
00414   Parameters:
00415     start_point - [in]
00416   Returns:
00417     true if successful.
00418   Remarks:
00419     Some start points cannot be moved.  Be sure to check return
00420     code.
00421   See Also:
00422     ON_Curve::SetEndPoint
00423     ON_Curve::PointAtStart
00424     ON_Curve::PointAtEnd
00425   */
00426   // virtual
00427   ON_BOOL32 SetStartPoint(
00428           ON_3dPoint start_point
00429           );
00430 
00431   /*
00432   Description:
00433     Force the curve to end at a specified point.
00434   Parameters:
00435     end_point - [in]
00436   Returns:
00437     true if successful.
00438   Remarks:
00439     Some end points cannot be moved.  Be sure to check return
00440     code.
00441   See Also:
00442     ON_Curve::SetStartPoint
00443     ON_Curve::PointAtStart
00444     ON_Curve::PointAtEnd
00445   */
00446   //virtual
00447   ON_BOOL32 SetEndPoint(
00448           ON_3dPoint end_point
00449           );
00450 
00451   ON_BOOL32 Evaluate( // returns false if unable to evaluate
00452          double,         // evaluation parameter
00453          int,            // number of derivatives (>=0)
00454          int,            // array stride (>=Dimension())
00455          double*,        // array of length stride*(ndir+1)
00456          int = 0,        // optional - determines which side to evaluate from
00457                          //         0 = default
00458                          //      <  0 to evaluate from below, 
00459                          //      >  0 to evaluate from above
00460          int* = 0        // optional - evaluation hint (int) used to speed
00461                          //            repeated evaluations
00462          ) const;
00463 
00464   // Description:
00465   //   virtual ON_Curve::Trim override.
00466   ON_BOOL32 Trim( const ON_Interval& );
00467 
00468   // Description:
00469   //   Where possible, analytically extends curve to include domain.
00470   // Parameters:
00471   //   domain - [in] if domain is not included in curve domain, 
00472   //   curve will be extended so that its domain includes domain.  
00473   //   Will not work if curve is closed. Original curve is identical
00474   //   to the restriction of the resulting curve to the original curve domain, 
00475   // Returns:
00476   //   true if successful.
00477   bool Extend(
00478     const ON_Interval& domain
00479     );
00480 
00481   // Description:
00482   //   virtual ON_Curve::Split override.
00483   //
00484   // Split() divides the polyline at the specified parameter.  The parameter
00485   // must be in the interior of the curve's domain.  The pointers passed
00486   // to ON_NurbsCurve::Split must either be NULL or point to an ON_NurbsCurve.
00487   // If the pointer is NULL, then a curve will be created
00488   // in Split().  You may pass "this" as one of the pointers to Split().
00489   // For example, 
00490   //
00491   //   ON_NurbsCurve right_side;
00492   //   crv.Split( crv.Domain().Mid() &crv, &right_side );
00493   //
00494   // would split crv at the parametric midpoint, put the left side in crv,
00495   // and return the right side in right_side.
00496   ON_BOOL32 Split(
00497       double,    // t = curve parameter to split curve at
00498       ON_Curve*&, // left portion returned here (must be an ON_NurbsCurve)
00499       ON_Curve*&  // right portion returned here (must be an ON_NurbsCurve)
00500     ) const;
00501 
00502   int GetNurbForm( // returns 0: unable to create NURBS representation
00503                    //            with desired accuracy.
00504                    //         1: success - returned NURBS parameterization
00505                    //            matches the curve's to wthe desired accuracy
00506                    //         2: success - returned NURBS point locus matches
00507                    //            the curve's to the desired accuracy but, on
00508                    //            the interior of the curve's domain, the 
00509                    //            curve's parameterization and the NURBS
00510                    //            parameterization may not match to the 
00511                    //            desired accuracy.
00512         ON_NurbsCurve&,
00513         double = 0.0,
00514         const ON_Interval* = NULL     // OPTIONAL subdomain of polyline
00515         ) const;
00516 
00517   int HasNurbForm( // returns 0: unable to create NURBS representation
00518                    //            with desired accuracy.
00519                    //         1: success - returned NURBS parameterization
00520                    //            matches the curve's to wthe desired accuracy
00521                    //         2: success - returned NURBS point locus matches
00522                    //            the curve's to the desired accuracy but, on
00523                    //            the interior of the curve's domain, the 
00524                    //            curve's parameterization and the NURBS
00525                    //            parameterization may not match to the 
00526                    //            desired accuracy.
00527         ) const;
00528 
00529   // virtual ON_Curve::GetCurveParameterFromNurbFormParameter override
00530   ON_BOOL32 GetCurveParameterFromNurbFormParameter(
00531         double, // nurbs_t
00532         double* // curve_t
00533         ) const;
00534 
00535   // virtual ON_Curve::GetNurbFormParameterFromCurveParameter override
00536   ON_BOOL32 GetNurbFormParameterFromCurveParameter(
00537         double, // curve_t
00538         double* // nurbs_t
00539         ) const;
00540 /*
00541         Description:
00542                 Lookup a parameter in the m_t array, optionally using a built in snap tolerance to 
00543                 snap a parameter value to an element of m_t.
00544         Parameters:
00545                 t - [in]                parameter
00546                 index -[out]    index into m_t such that
00547                                                                 if function returns false then value of index is
00548                                                                    
00549                                                                          @table  
00550                                                                          value of index              condition
00551                                                                           -1                                                                      t<m_t[0] or m_t is empty                              
00552                                                                                   0<=i<=m_t.Count()-2           m_t[i] < t < m_t[i+1]                   
00553                                                                                   m_t.Count()-1                                 t>m_t[ m_t.Count()-1]                    
00554 
00555                                                                         if the function returns true then t is equal to, or is closest to and 
00556                                                                         within  tolerance of m_t[index]. 
00557                                                                         
00558                 bEnableSnap-[in] enable snapping        
00559         Returns:                
00560                 true if the t is exactly equal to, or within tolerance of
00561                 (only if bEnableSnap==true) m_t[index]. 
00562 */ 
00563         bool ParameterSearch(double t, int& index, bool bEnableSnap) const;
00564 
00565   bool Append( const ON_PolylineCurve& );
00566 
00568   // Interface
00569         public:
00570   int PointCount() const; // number of points in polyline
00571 
00572   ON_Polyline            m_pline;
00573   ON_SimpleArray<double> m_t;    // parameters
00574   int                    m_dim;  // 2 or 3 (2 so ON_PolylineCurve can be uses as a trimming curve)
00575 };
00576 
00577 
00578 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:03