//=========================================================================== // 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. //=========================================================================== 00016 #ifndef _CURVEONSURFACE_H 00017 #define _CURVEONSURFACE_H 00018 00019 #include "GoTools/geometry/ParamSurface.h" 00020 #include <boost/smart_ptr.hpp> 00021 #include "GoTools/geometry/ParamCurve.h" 00022 #include "GoTools/geometry/SplineCurve.h" 00023 #include "GoTools/utils/config.h" 00024 00025 namespace Go 00026 { 00027 00028 // class SplineCurve; 00029 00034 class GO_API CurveOnSurface : public ParamCurve 00035 { 00036 public: 00039 CurveOnSurface(); 00040 00053 CurveOnSurface(boost::shared_ptr<ParamSurface> surf, 00054 boost::shared_ptr<ParamCurve> curve, 00055 bool preferparameter); 00056 00058 CurveOnSurface(boost::shared_ptr<ParamSurface> surf, 00059 boost::shared_ptr<ParamCurve> curve, 00060 int constdir, double constpar, int boundary); 00061 00073 00078 CurveOnSurface(boost::shared_ptr<ParamSurface> surf, 00079 boost::shared_ptr<ParamCurve> pcurve, 00080 boost::shared_ptr<ParamCurve> spacecurve, 00081 bool preferparameter, int ccm = 0); 00082 00086 CurveOnSurface(const CurveOnSurface& surface_curve); 00087 00091 CurveOnSurface& operator= (const CurveOnSurface& other); 00092 00095 virtual ~CurveOnSurface(); 00096 00097 00098 // inherited from Streamable 00099 virtual void read (std::istream& is); 00100 virtual void write (std::ostream& os) const; 00101 00102 // inherited from GeomObject 00103 // @afr: This one only returns the bounding box of the underlying surface 00104 virtual BoundingBox boundingBox() const; 00105 virtual DirectionCone directionCone() const; 00106 virtual int dimension() const; 00107 virtual ClassType instanceType() const; 00108 static ClassType classType() 00109 { return Class_CurveOnSurface; } 00110 00111 // The function clone() calls the copy constructor, 00112 // so clone() also makes deep copies of the curves, 00113 // but not the underlying surface. 00114 // #ifdef _MSC_VER 00115 // #if _MSC_VER < 1300 00116 // virtual GeomObject* clone() const 00117 // { return new CurveOnSurface(*this); } 00118 // #else 00119 // virtual CurveOnSurface* clone() const 00120 // { return new CurveOnSurface(*this); } 00121 // #endif // _MSC_VER < 1300 00122 // #else 00123 virtual CurveOnSurface* clone() const 00124 { return new CurveOnSurface(*this); } 00125 // #endif 00126 00127 // inherited from ParamCurve 00128 virtual void point(Point& pt, double tpar) const; 00129 00132 virtual void point(std::vector<Point>& pts, 00133 double tpar, 00134 int derivs, bool from_right = true) const; 00135 00136 // inherited from ParamCurve 00137 virtual double startparam() const; 00138 00139 // inherited from ParamCurve 00140 virtual double endparam() const; 00141 00142 // inherited from ParamCurve 00143 virtual void reverseParameterDirection(bool switchparam = false); 00144 00145 // inherited from ParamCurve 00146 virtual void setParameterInterval(double t1, double t2); 00147 00148 // inherited from ParamCurve 00149 virtual SplineCurve* geometryCurve(); 00150 00151 // inherited from ParamCurve 00152 virtual bool isDegenerate(double degenerate_epsilon); 00153 00154 00155 // #if ((_MSC_VER > 0) && (_MSC_VER < 1300)) 00156 // // inherited from ParamCurve 00157 // virtual ParamCurve* subCurve(double from_par, double to_par, 00158 // double fuzzy = DEFAULT_PARAMETER_EPSILON) const; 00159 // #else 00160 // inherited from ParamCurve 00161 virtual CurveOnSurface* subCurve(double from_par, double to_par, 00162 double fuzzy = 00163 DEFAULT_PARAMETER_EPSILON) const; 00164 // #endif 00165 00166 // inherited from ParamCurve 00167 virtual void closestPoint(const Point& pt, 00168 double tmin, 00169 double tmax, 00170 double& clo_t, 00171 Point& clo_pt, 00172 double& clo_dist, 00173 double const *seed = 0) const; 00174 00175 // Inherited from ParamCurve 00176 // Compute the total length of this curve 00177 virtual double length(double tol); 00178 00179 // inherited from ParamCurve. NB: does not check whether the resulting ParamCurve 00180 // stays inside parameter domain (or that the space curve stays on surface). 00181 virtual void appendCurve(ParamCurve* cv, bool reparam=true); 00182 00183 // inherited from ParamCurve. NB: does not check whether the resulting ParamCurve 00184 // stays inside parameter domain (or that the space curve stays on surface). 00185 virtual void appendCurve(ParamCurve* cv, 00186 int continuity, double& dist, bool reparam=true); 00187 00191 void setUnderlyingSurface(boost::shared_ptr<ParamSurface> surface) 00192 {surface_ = surface;} 00193 00196 void setCurves(boost::shared_ptr<ParamCurve> spacecurve, 00197 boost::shared_ptr<ParamCurve> parametercurve) 00198 { 00199 spacecurve_ = spacecurve; 00200 pcurve_ = parametercurve; 00201 } 00202 00203 void setParameterCurve(boost::shared_ptr<ParamCurve> parametercurve) 00204 { 00205 pcurve_ = parametercurve; 00206 } 00207 00209 bool ensureParCrvExistence(double tol); 00210 00212 bool ensureSpaceCrvExistence(double tol); 00213 00215 void setCurveTypeInfo(int ccm) 00216 { 00217 ccm_ = ccm; 00218 } 00219 00221 bool updateIsoCurves(); 00222 00223 bool updateIsoCurves(int constdir, double constpar, int boundary); 00224 00226 bool updateCurves(double epsge); 00227 00229 bool updateCurves(Point vx1, Point vx2, double epsge); 00230 00236 virtual double nextSegmentVal(double par, bool forward, double tol) const; 00237 00238 00241 boost::shared_ptr<ParamSurface> underlyingSurface() 00242 { return surface_; } 00243 00246 boost::shared_ptr<ParamCurve> parameterCurve() 00247 { return pcurve_; } 00248 00251 boost::shared_ptr<ParamCurve> spaceCurve() 00252 { return spacecurve_; } 00253 00256 boost::shared_ptr<const ParamSurface> underlyingSurface() const 00257 { return surface_; } 00258 00261 boost::shared_ptr<const ParamCurve> parameterCurve() const 00262 { return pcurve_; } 00263 00266 boost::shared_ptr<const ParamCurve> spaceCurve() const 00267 { return spacecurve_; } 00268 00271 bool parPref() const 00272 { return prefer_parameter_; } 00273 00276 RectDomain containingDomain() const; 00277 00279 Point faceParameter(double crv_par) const; 00280 00285 int whichBoundary(double tol, bool& same_orientation) const; 00286 00288 bool sameParameterDomain() const; 00289 00290 bool sameOrientation() const; 00291 00292 bool sameTrace(double tol, int nmb_sample = 5) const; 00293 00294 bool sameCurve(double tol, int nmb_sample = 5) const; 00295 00296 // Make sure that domain and orientation correspond. Routine does 00297 // not check difference between trace of parameter curve and space 00298 // curve. 00299 void makeCurvesConsistent(bool prefer_parameter); 00300 00301 int curveCreationMethod() const; 00302 00303 double maxTraceDiff(int nmb_sample = 5) const; 00304 00305 00306 private: 00308 boost::shared_ptr<ParamSurface> surface_; 00311 boost::shared_ptr<ParamCurve> pcurve_; 00313 boost::shared_ptr<ParamCurve> spacecurve_; 00315 bool prefer_parameter_; 00321 int ccm_; 00322 00324 int constdir_; //1=u_parameter constant, 2=v_parameter constant 00325 double constval_; // Value of constant parameter 00326 int at_bd_; // -1=no, 0=umin, 1=umax, 2=vmin, 3=vmax 00327 bool same_orientation_; // Indicates of the constant parameter curve is 00328 // oriented the same way as the surface in this parameter direction 00329 00330 // Fixes performed to get a legal curve on surface 00331 mutable int fix_performed_; 00332 }; 00333 00334 00335 } // namespace Go 00336 00337 #endif // _CURVEONSURFACE_H 00338