//=========================================================================== // GoTools Core - SINTEF Geometry Tools Core library, version 2.0.1 // // Copyright (C) 2000-2007, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== 00015 #ifndef _ELLIPSE_H 00016 #define _ELLIPSE_H 00017 00018 00019 #include "GoTools/geometry/ElementaryCurve.h" 00020 00021 00022 namespace Go { 00023 00024 00031 00032 class Ellipse : public ElementaryCurve 00033 { 00034 public: 00037 Ellipse() 00038 {}; 00039 00042 Ellipse(Point centre, Point direction, Point normal, 00043 double r1, double r2); 00044 00046 virtual ~Ellipse(); 00047 00050 virtual void read (std::istream& is); 00053 virtual void write (std::ostream& os) const; 00054 00055 00056 // --- Functions inherited from GeomObject --- 00057 00058 virtual BoundingBox boundingBox() const; 00059 00060 virtual int dimension() const; 00061 00062 virtual ClassType instanceType() const; 00063 00064 static ClassType classType(); 00065 00066 virtual Ellipse* clone() const; 00067 00068 // --- Functions inherited from ParamCurve --- 00069 00070 virtual void point(Point& pt, double tpar) const; 00071 00072 virtual void point(std::vector<Point>& pts, 00073 double tpar, 00074 int derivs, 00075 bool from_right = true) const; 00076 00077 virtual double startparam() const; 00078 virtual double endparam() const; 00079 00080 virtual void reverseParameterDirection(bool switchparam = false); 00081 00082 virtual void setParameterInterval(double t1, double t2); 00083 00084 virtual SplineCurve* geometryCurve(); 00085 00086 virtual bool isDegenerate(double degenerate_epsilon); 00087 00088 virtual bool isClosed(); 00089 00090 virtual 00091 Ellipse* subCurve(double from_par, double to_par, 00092 double fuzzy = DEFAULT_PARAMETER_EPSILON) const; 00093 00094 virtual DirectionCone directionCone() const; 00095 00096 virtual void appendCurve(ParamCurve* cv, bool reparam=true); 00097 00098 virtual void appendCurve(ParamCurve* cv, 00099 int continuity, double& dist, bool reparam=true); 00100 00101 virtual void closestPoint(const Point& pt, 00102 double tmin, 00103 double tmax, 00104 double& clo_t, 00105 Point& clo_pt, 00106 double& clo_dist, 00107 double const *seed = 0) const; 00108 00109 virtual double length(double tol); 00110 00111 // --- Functions specific to Ellipse --- 00112 00116 void setParamBounds(double startpar, double endpar); 00117 00118 00119 protected: 00120 00121 Point centre_; // Center of the ellipse. 00122 Point vec1_; // The axis wrt r1_. 00123 Point vec2_; // The axis wrt r2_. 00124 Point normal_; 00125 00126 double r1_; // semi_axis_1; 00127 double r2_; // semi_axis_2; 00128 00129 double startparam_; // At least 0.0. 00130 double endparam_; // At most 2.0*M_PI. 00131 00132 void setSpanningVectors(); 00133 00134 }; 00135 00136 00137 } // namespace Go 00138 00139 00140 00141 #endif // _ELLIPSE_H 00142