00001 //=========================================================================== 00002 // GoTools - SINTEF Geometry Tools 00003 // 00004 // GoTools module: Intersections, version 1.0 00005 // 00006 // Copyright (C) 2000-2007 SINTEF ICT, Applied Mathematics, Norway. 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License 00010 // as published by the Free Software Foundation version 2 of the License. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 00020 // 59 Temple Place - Suite 330, 00021 // Boston, MA 02111-1307, USA. 00022 // 00023 // Contact information: E-mail: tor.dokken@sintef.no 00024 // SINTEF ICT, Department of Applied Mathematics, 00025 // P.O. Box 124 Blindern, 00026 // 0314 Oslo, Norway. 00027 // 00028 // Other licenses are also available for this software, notably licenses 00029 // for: 00030 // - Building commercial software. 00031 // - Building software whose source code you wish to keep private. 00032 //=========================================================================== 00033 #ifndef _INTERSECTOR_H 00034 #define _INTERSECTOR_H 00035 00036 00037 #include "SubdivisionClassification.h" 00038 #include "SingularityClassification.h" 00039 #include "SingularityInfo.h" 00040 #include "ComplexityInfo.h" 00041 #include "Point.h" 00042 #include "RectDomain.h" 00043 #include <vector> 00044 #include <boost/shared_ptr.hpp> 00045 00046 00047 namespace Go { 00050 00051 00052 00053 class IntersectionPoint; 00054 class IntersectionCurve; 00055 class IntersectionPool; 00056 class GeoTol; 00057 struct BoundaryGeomInt; 00058 00059 00062 00063 class Intersector { 00064 public: 00065 00067 Intersector() : prev_intersector_(0) {} 00068 00072 Intersector(double epsge, Intersector *prev = 0); 00073 00077 Intersector(boost::shared_ptr<GeoTol> epsge, Intersector *prev = 0); 00078 00080 virtual ~Intersector(){}; 00081 00085 virtual void compute(bool compute_at_boundary=true); 00086 00091 virtual void 00092 getResult(std::vector<boost::shared_ptr<IntersectionPoint> >& int_points, 00093 std::vector<boost::shared_ptr<IntersectionCurve> >& int_curves); 00094 00095 // // Validation of given intersection results 00096 // virtual void validate(int level, ValidationStat status); 00097 00100 boost::shared_ptr<IntersectionPool> getIntPool() 00101 { return int_results_; } 00102 00106 bool validateSiblingPools(); 00107 00108 00111 boost::shared_ptr<GeoTol> getTolerance() 00112 { return epsge_;} 00113 00116 bool hasSingularityInfo() 00117 { return (singularity_info_.get() != 0); } 00118 00121 boost::shared_ptr<SingularityInfo> getSingularityInfo() 00122 { return singularity_info_; } 00123 00130 void setSingularityInfo(boost::shared_ptr<SingularityInfo> previous, 00131 int missing_dir) 00132 { 00133 if (missing_dir < 0) 00134 singularity_info_ = (boost::shared_ptr<SingularityInfo>) 00135 (new SingularityInfo(previous)); 00136 else 00137 singularity_info_ = (boost::shared_ptr<SingularityInfo>) 00138 (new SingularityInfo(previous, missing_dir)); 00139 } 00140 00144 void setHighPriSing(double* par); 00145 00149 bool hasComplexityInfo() 00150 { return (complexity_info_.get() != 0); } 00151 00154 boost::shared_ptr<ComplexityInfo> getComplexityInfo() 00155 { return complexity_info_; } 00156 00160 virtual int numParams() const = 0; 00161 00166 virtual int nmbBdObj(int idx) const 00167 { return 0; } 00168 00175 virtual BoundaryGeomInt* getBoundaryObject(int idx, int bd_idx) const 00176 { return 0; } 00177 00180 int nmbRecursions() 00181 { 00182 if (prev_intersector_ == 0) 00183 return 0; 00184 else 00185 return prev_intersector_->nmbRecursions() + 1; 00186 } 00187 00190 virtual bool isSelfIntersection() 00191 { return false; } // Default 00192 00195 virtual int isSelfintCase() 00196 { return 0; } // Default behaviour 00197 00198 virtual void addComplexDomain(RectDomain dom) 00199 { ; } 00200 00202 void writeIntersectionPoints() const; 00203 00204 friend class SfSfIntersector; 00205 friend class IntersectionPool; 00206 00207 protected: 00208 // Data members 00209 00210 // @ Logical problem here? An IntersectionPool refers to 2 objects, 00211 // @ while an Intersector does not (need Intersector2Obj to do 00212 // @ that...) 00213 boost::shared_ptr<IntersectionPool> int_results_; 00214 std::vector<boost::shared_ptr<Intersector> > sub_intersectors_; 00215 Intersector *prev_intersector_; 00216 boost::shared_ptr<GeoTol> epsge_; 00217 boost::shared_ptr<SingularityInfo> singularity_info_; 00218 boost::shared_ptr<ComplexityInfo> complexity_info_; 00219 00220 // virtual boost::shared_ptr<Intersector> 00221 // lowerOrderIntersector(boost::shared_ptr<ParamObjectInt> obj1, 00222 // boost::shared_ptr<ParamObjectInt> obj2, 00223 // Intersector* prev = 0, 00224 // int eliminated_parameter = -1, 00225 // double eliminated_value = 0) = 0; 00226 00227 virtual void print_objs() = 0; 00228 00229 virtual int getBoundaryIntersections() = 0; 00230 00231 virtual int performInterception() = 0; 00232 00233 virtual int simpleCase() = 0; 00234 00235 virtual bool isLinear() = 0; 00236 00237 virtual bool degTriangleSimple() 00238 { 00239 // Default implementation that is OK for most sub classes 00240 return false; 00241 } 00242 00243 virtual bool complexityReduced() = 0; 00244 00245 virtual void handleComplexity() = 0; 00246 00247 virtual int checkCoincidence() = 0; 00248 00249 virtual void microCase() = 0; 00250 00251 virtual int updateIntersections() = 0; 00252 00253 virtual int repairIntersections() = 0; 00254 00255 virtual int linearCase() = 0; 00256 00257 virtual int doSubdivide() = 0; 00258 00259 virtual int complexIntercept() 00260 { 00261 return 0; // Overridden when required 00262 } 00263 00264 virtual int complexSimpleCase() 00265 { 00266 return 0; // Overridden when required 00267 } 00268 00269 virtual void doPostIterate() 00270 { 00271 ; // Overridden when required 00272 } 00273 00274 virtual void printDebugInfo() = 0; 00275 private: 00276 00277 }; 00278 00279 00281 } // namespace Go 00282 00283 00284 #endif // _INTERSECTOR_H 00285