//=========================================================================== // 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 _SPHERE_H 00016 #define _SPHERE_H 00017 00018 00019 #include "GoTools/geometry/ElementarySurface.h" 00020 #include "GoTools/geometry/Circle.h" 00021 00022 00023 namespace Go 00024 { 00025 00026 00027 class SplineSurface; 00028 00029 00042 00043 class Sphere : public ElementarySurface 00044 { 00045 public: 00048 Sphere() 00049 {}; 00050 00055 Sphere(double radius, Point location, Point z_axis, Point x_axis); 00056 00058 virtual ~Sphere(); 00059 00062 virtual void read (std::istream& is); 00065 virtual void write (std::ostream& os) const; 00066 00067 // Inherited from GeomObject 00068 virtual int dimension() const; 00069 00070 // Inherited from GeomObject 00071 virtual ClassType instanceType() const; 00072 00073 // Inherited from GeomObject 00074 static ClassType classType() 00075 { return Class_Sphere; } 00076 00077 // Inherited from GeomObject 00078 virtual BoundingBox boundingBox() const; 00079 00080 // Inherited from GeomObject 00081 virtual Sphere* clone() const 00082 { return new Sphere(radius_, location_, z_axis_, x_axis_); } 00083 00084 00085 // --- Functions inherited from ParamSurface --- 00086 00087 const RectDomain& parameterDomain() const; 00088 00089 CurveLoop outerBoundaryLoop(double degenerate_epsilon 00090 = DEFAULT_SPACE_EPSILON) const; 00091 std::vector<CurveLoop> allBoundaryLoops(double degenerate_epsilon 00092 = DEFAULT_SPACE_EPSILON) const; 00093 00094 DirectionCone normalCone() const; 00095 DirectionCone tangentCone(bool pardir_is_u) const; 00096 00097 void point(Point& pt, double upar, double vpar) const; 00098 void point(std::vector<Point>& pts, 00099 double upar, double vpar, 00100 int derivs, 00101 bool u_from_right = true, 00102 bool v_from_right = true, 00103 double resolution = 1.0e-12) const; 00104 00105 void normal(Point& n, double upar, double vpar) const; 00106 00107 std::vector<boost::shared_ptr<ParamCurve> > 00108 constParamCurves(double parameter, bool pardir_is_u) const; 00109 00110 std::vector<boost::shared_ptr<ParamSurface> > 00111 subSurfaces(double from_upar, double from_vpar, 00112 double to_upar, double to_vpar, 00113 double fuzzy = DEFAULT_PARAMETER_EPSILON) const; 00114 00115 double nextSegmentVal(int dir, double par, bool forward, double tol) const; 00116 00117 void closestPoint(const Point& pt, 00118 double& clo_u, 00119 double& clo_v, 00120 Point& clo_pt, 00121 double& clo_dist, 00122 double epsilon, 00123 const RectDomain* domain_of_interest = NULL, 00124 double *seed = 0) const; 00125 00126 void closestBoundaryPoint(const Point& pt, 00127 double& clo_u, 00128 double& clo_v, 00129 Point& clo_pt, 00130 double& clo_dist, 00131 double epsilon, 00132 const RectDomain* rd = NULL, 00133 double *seed = 0) const; 00134 00135 void getBoundaryInfo(Point& pt1, Point& pt2, 00136 double epsilon, SplineCurve*& cv, 00137 SplineCurve*& crosscv, double knot_tol = 1e-05) const; 00138 00139 void turnOrientation(); 00140 00141 void reverseParameterDirection(bool direction_is_u); 00142 00143 void swapParameterDirection(); 00144 00145 bool isDegenerate(bool& b, bool& r, 00146 bool& t, bool& l, double tolerance) const; 00147 00148 00150 virtual void getDegenerateCorners(std::vector<Point>& deg_corners, double tol) const; 00151 00152 // --- Functions specific to Sphere --- 00153 00154 double getRadius() const 00155 { return radius_; } 00156 00157 Point getLocation() const 00158 { return location_; } 00159 00160 void getCoordinateAxes(Point& x_axis, Point& y_axis, Point& z_axis) const 00161 { 00162 x_axis = x_axis_; 00163 y_axis = y_axis_; 00164 z_axis = z_axis_; 00165 } 00166 00167 void setParameterBounds(double from_upar, double from_vpar, 00168 double to_upar, double to_vpar); 00169 00170 Sphere* subSurface(double from_upar, double from_vpar, 00171 double to_upar, double to_vpar, 00172 double fuzzy = DEFAULT_PARAMETER_EPSILON) const; 00173 00174 virtual SplineSurface* geometrySurface() const; 00175 00181 boost::shared_ptr<Circle> getLatitudinalCircle(double vpar) const; 00182 00188 boost::shared_ptr<Circle> getLongitudinalCircle(double upar) const; 00189 00190 protected: 00191 00192 double radius_; 00193 Point location_; 00194 Point z_axis_; 00195 Point x_axis_; 00196 Point y_axis_; 00197 00198 RectDomain domain_; 00199 00200 void setCoordinateAxes(); 00201 00202 }; 00203 00204 } // namespace Go 00205 00206 00207 #endif // _SPHERE_H 00208