contrib/gel/vsol/vsol_curve_3d.h
Go to the documentation of this file.
00001 #ifndef vsol_curve_3d_h_
00002 #define vsol_curve_3d_h_
00003 //*****************************************************************************
00004 //:
00005 // \file
00006 // \brief Abstract curve in a 3D space
00007 //
00008 // \author
00009 // François BERTEL
00010 //
00011 // \verbatim
00012 //  Modifications
00013 //   2000/05/03 François BERTEL Creation
00014 //   2000/06/17 Peter Vanroose  Implemented all operator==()s and type info
00015 //   2004/09/10 Peter Vanroose  Inlined all 1-line methods in class decl
00016 //   2004/09/17 MingChing Chang Add cast_to stuffs and endpoints_equal()
00017 // \endverbatim
00018 //*****************************************************************************
00019 
00020 #include <vsol/vsol_spatial_object_3d.h>
00021 #include <vsol/vsol_point_3d_sptr.h>
00022 
00023 class vsol_line_3d;
00024 class vsol_conic_3d;
00025 class vsol_polyline_3d;
00026 class vsol_digital_curve_3d;
00027 class vdgl_digital_curve;
00028 
00029 class vsol_curve_3d : public vsol_spatial_object_3d
00030 {
00031  protected:
00032   enum vsol_curve_3d_type
00033   { CURVE_NO_TYPE=0,
00034     LINE,
00035     CONIC,
00036     POLYLINE,
00037     DIGITAL_CURVE,
00038     NUM_REGION_TYPES
00039   };
00040 
00041   //***************************************************************************
00042   // Initialization
00043   //***************************************************************************
00044  public:
00045   //---------------------------------------------------------------------------
00046   //: Destructor
00047   //---------------------------------------------------------------------------
00048   virtual ~vsol_curve_3d() {}
00049 
00050   //***************************************************************************
00051   // Access
00052   //***************************************************************************
00053 
00054   //---------------------------------------------------------------------------
00055   //: Return the spatial type
00056   //---------------------------------------------------------------------------
00057   vsol_spatial_object_3d_type spatial_type() const { return vsol_spatial_object_3d::CURVE; }
00058 
00059  private: // has been superseded by is_a()
00060   //: Return the curve type
00061   virtual vsol_curve_3d_type curve_type() const { return vsol_curve_3d::CURVE_NO_TYPE; }
00062 
00063  public:
00064   //---------------------------------------------------------------------------
00065   //: Return the first point of `this'; pure virtual function
00066   //---------------------------------------------------------------------------
00067   virtual vsol_point_3d_sptr p0() const=0;
00068 
00069   //---------------------------------------------------------------------------
00070   //: Return the last point of `this'; pure virtual function
00071   //---------------------------------------------------------------------------
00072   virtual vsol_point_3d_sptr p1() const=0;
00073 
00074   //***************************************************************************
00075   // Replaces dynamic_cast<T>
00076   //***************************************************************************
00077 
00078   //---------------------------------------------------------------------------
00079   //: Return `this' if `this' is a curve, 0 otherwise
00080   //---------------------------------------------------------------------------
00081   virtual vsol_curve_3d *cast_to_curve() {return this;}
00082   virtual const vsol_curve_3d *cast_to_curve() const {return this;}
00083 
00084   //---------------------------------------------------------------------------
00085   //: Return `this' if `this' is a line, 0 otherwise
00086   //---------------------------------------------------------------------------
00087   virtual vsol_line_3d const*cast_to_line()const{return 0;}
00088   virtual vsol_line_3d *cast_to_line() {return 0;}
00089 
00090   //---------------------------------------------------------------------------
00091   //: Return `this' if `this' is a conic, 0 otherwise
00092   //---------------------------------------------------------------------------
00093   virtual vsol_conic_3d const*cast_to_conic()const{return 0;}
00094   virtual vsol_conic_3d *cast_to_conic() {return 0;}
00095 
00096   //---------------------------------------------------------------------------
00097   //: Return `this' if `this' is a polyline, 0 otherwise
00098   //---------------------------------------------------------------------------
00099   virtual vsol_polyline_3d const*cast_to_polyline()const{return 0;}
00100   virtual vsol_polyline_3d *cast_to_polyline() {return 0;}
00101 
00102   //---------------------------------------------------------------------------
00103   //: Return `this' if `this' is a digital_curve_3d, 0 otherwise
00104   //---------------------------------------------------------------------------
00105   virtual vsol_digital_curve_3d const*cast_to_digital_curve()const{return 0;}
00106   virtual vsol_digital_curve_3d *cast_to_digital_curve() {return 0;}
00107 
00108   //***************************************************************************
00109   // Status report
00110   //***************************************************************************
00111 
00112   //---------------------------------------------------------------------------
00113   //: Return the length of `this'
00114   //---------------------------------------------------------------------------
00115   virtual double length() const=0;
00116 
00117   //***************************************************************************
00118   // Status setting
00119   //***************************************************************************
00120 
00121   //---------------------------------------------------------------------------
00122   //: Set the first point of the curve
00123   //---------------------------------------------------------------------------
00124   virtual void set_p0(const vsol_point_3d_sptr &new_p0)=0;
00125 
00126   //---------------------------------------------------------------------------
00127   //: Set the last point of the curve
00128   //---------------------------------------------------------------------------
00129   virtual void set_p1(const vsol_point_3d_sptr &new_p1)=0;
00130 
00131  protected:
00132   //: Helper function to determine if curve endpoints are equal (in any order).
00133   // Useful for curve equality tests.
00134   bool endpoints_equal(const vsol_curve_3d &other) const;
00135 };
00136 
00137 #endif // vsol_curve_3d_h_