//=========================================================================== // 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 _CYLINDER_H 00016 #define _CYLINDER_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 Cylinder : public ElementarySurface 00044 { 00045 public: 00048 Cylinder() 00049 {}; 00050 00055 Cylinder(double radius, Point location, Point z_axis, Point x_axis); 00056 00058 virtual ~Cylinder(); 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_Cylinder; } 00076 00078 virtual BoundingBox boundingBox() const; 00079 00080 // Inherited from GeomObject 00081 virtual Cylinder* clone() const 00082 { return new Cylinder(radius_, location_, z_axis_, x_axis_); } 00083 00084 00085 // --- Functions inherited from ParamSurface --- 00086 00087 const Domain& 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 Cylinder --- 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 00173 bool isBounded() const; 00174 00175 Cylinder* subSurface(double from_upar, double from_vpar, 00176 double to_upar, double to_vpar, 00177 double fuzzy = DEFAULT_PARAMETER_EPSILON) const; 00178 00179 virtual SplineSurface* geometrySurface() const; 00180 00186 boost::shared_ptr<Circle> getCircle(double vpar) const; 00187 00188 protected: 00189 00190 double radius_; 00191 Point location_; 00192 Point z_axis_; 00193 Point x_axis_; 00194 Point y_axis_; 00195 00196 RectDomain domain_; 00197 00198 void setCoordinateAxes(); 00199 00200 }; 00201 00202 } // namespace Go 00203 00204 00205 #endif // _CYLINDER_H 00206