//=========================================================================== // 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 _TORUS_H 00016 #define _TORUS_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 00052 00053 class Torus : public ElementarySurface 00054 { 00055 public: 00058 Torus() 00059 {}; 00060 00066 Torus(double major_radius, double minor_radius, 00067 Point location, Point z_axis, Point x_axis, 00068 bool select_outer = true); 00069 00071 virtual ~Torus(); 00072 00075 virtual void read (std::istream& is); 00078 virtual void write (std::ostream& os) const; 00079 00080 // Inherited from GeomObject 00081 virtual int dimension() const; 00082 00083 // Inherited from GeomObject 00084 virtual ClassType instanceType() const; 00085 00086 // Inherited from GeomObject 00087 static ClassType classType() 00088 { return Class_Torus; } 00089 00090 // Inherited from GeomObject 00091 virtual BoundingBox boundingBox() const; 00092 00093 // Inherited from GeomObject 00094 virtual Torus* clone() const 00095 { return new Torus(major_radius_, minor_radius_, 00096 location_, z_axis_, x_axis_, select_outer_); } 00097 00098 00099 // --- Functions inherited from ParamSurface --- 00100 00101 const RectDomain& parameterDomain() const; 00102 00103 CurveLoop outerBoundaryLoop(double degenerate_epsilon 00104 = DEFAULT_SPACE_EPSILON) const; 00105 std::vector<CurveLoop> allBoundaryLoops(double degenerate_epsilon 00106 = DEFAULT_SPACE_EPSILON) const; 00107 00108 DirectionCone normalCone() const; 00109 DirectionCone tangentCone(bool pardir_is_u) const; 00110 00111 void point(Point& pt, double upar, double vpar) const; 00112 void point(std::vector<Point>& pts, 00113 double upar, double vpar, 00114 int derivs, 00115 bool u_from_right = true, 00116 bool v_from_right = true, 00117 double resolution = 1.0e-12) const; 00118 00125 void normal(Point& n, double upar, double vpar) const; 00126 00127 std::vector<boost::shared_ptr<ParamCurve> > 00128 constParamCurves(double parameter, bool pardir_is_u) const; 00129 00130 std::vector<boost::shared_ptr<ParamSurface> > 00131 subSurfaces(double from_upar, double from_vpar, 00132 double to_upar, double to_vpar, 00133 double fuzzy = DEFAULT_PARAMETER_EPSILON) const; 00134 00135 double nextSegmentVal(int dir, double par, bool forward, double tol) const; 00136 00137 void closestPoint(const Point& pt, 00138 double& clo_u, 00139 double& clo_v, 00140 Point& clo_pt, 00141 double& clo_dist, 00142 double epsilon, 00143 const RectDomain* domain_of_interest = NULL, 00144 double *seed = 0) const; 00145 00146 void closestBoundaryPoint(const Point& pt, 00147 double& clo_u, 00148 double& clo_v, 00149 Point& clo_pt, 00150 double& clo_dist, 00151 double epsilon, 00152 const RectDomain* rd = NULL, 00153 double *seed = 0) const; 00154 00155 void getBoundaryInfo(Point& pt1, Point& pt2, 00156 double epsilon, SplineCurve*& cv, 00157 SplineCurve*& crosscv, double knot_tol = 1e-05) const; 00158 00159 void turnOrientation(); 00160 00161 void reverseParameterDirection(bool direction_is_u); 00162 00163 void swapParameterDirection(); 00164 00165 bool isDegenerate(bool& b, bool& r, 00166 bool& t, bool& l, double tolerance) const; 00167 00168 00170 virtual void getDegenerateCorners(std::vector<Point>& deg_corners, double tol) const; 00171 00172 // --- Functions specific to Torus --- 00173 00174 double getMajorRadius() const 00175 { return major_radius_; } 00176 00177 double getMinorRadius() const 00178 { return minor_radius_; } 00179 00180 Point getLocation() const 00181 { return location_; } 00182 00183 void getCoordinateAxes(Point& x_axis, Point& y_axis, Point& z_axis) const 00184 { 00185 x_axis = x_axis_; 00186 y_axis = y_axis_; 00187 z_axis = z_axis_; 00188 } 00189 00190 bool getSelectOuter() const 00191 { return select_outer_; } 00192 00197 void setSelectOuter(bool select_outer); 00198 00199 double getPhi() const 00200 { return phi_; } 00201 00206 bool isDegenerateTorus() const 00207 { return is_degenerate_torus_; } 00208 00209 void setParameterBounds(double from_upar, double from_vpar, 00210 double to_upar, double to_vpar); 00211 00212 Torus* subSurface(double from_upar, double from_vpar, 00213 double to_upar, double to_vpar, 00214 double fuzzy = DEFAULT_PARAMETER_EPSILON) const; 00215 00216 virtual SplineSurface* geometrySurface() const; 00217 00223 boost::shared_ptr<Circle> getMajorCircle(double vpar) const; 00224 00230 boost::shared_ptr<Circle> getMinorCircle(double upar) const; 00231 00232 protected: 00233 00234 double major_radius_; 00235 double minor_radius_; 00236 Point location_; 00237 Point z_axis_; 00238 Point x_axis_; 00239 Point y_axis_; 00240 bool is_degenerate_torus_; // Function of the radii 00241 bool select_outer_; 00242 double phi_; // Function of the radii 00243 00244 RectDomain domain_; 00245 00246 void setCoordinateAxes(); 00247 void setDegenerateInfo(); 00248 void setDefaultDomain(); 00249 00250 }; 00251 00252 } // namespace Go 00253 00254 00255 #endif // _TORUS_H 00256
Generated on Tue Sep 21 15:44:17 2010 for GoTools Core by  doxygen 1.6.3