Coincidence.h

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 _COINCIDENCE_H
00034 #define _COINCIDENCE_H
00035 
00036 #include <boost/shared_ptr.hpp>
00037 #include "Point.h"
00038 #include "ParamObjectInt.h"
00039 #include "GeoTol.h"
00040 #include "ParamFunctionInt.h"
00041 
00042 #include <vector>
00043 
00044 // Coincidence testing
00045 
00046 namespace Go {
00049 
00050 
00051   class ParamCurveInt;
00052   class ParamSurfaceInt;
00053   class SplineSurfaceInt;
00054     class Param1FunctionInt;
00055     class Param0FunctionInt;
00056 
00059     int checkCoincide(ParamCurveInt *curve,
00060                       double start, double end, boost::shared_ptr<GeoTol> tol,
00061                       ParamCurveInt *other,
00062                       double other_start, double other_end);
00063 
00066     int checkCoincide(ParamCurveInt *curve, double start, double end,
00067                       ParamSurfaceInt *surf,
00068                       Point su_start,
00069                       Point su_end,
00070                       boost::shared_ptr<GeoTol> tol);
00071 
00074     int checkCoincide(ParamCurveInt *curve, double start, double end,
00075                       SplineSurfaceInt *surf,
00076                       const Point& su_start,
00077                       const Point& su_end,
00078                       boost::shared_ptr<GeoTol> tol);
00079 
00082     int checkCoincide(Param1FunctionInt *func1, double start, double end,
00083                       Param0FunctionInt *C,
00084                       boost::shared_ptr<GeoTol> tol);
00085 
00088     int checkCoincide(ParamSurfaceInt *surf1, ParamSurfaceInt *surf2,
00089                       std::vector<double>& par_loop, 
00090                       const boost::shared_ptr<GeoTol> tol);
00091 
00092     // Computes the next step along a curve when we are testing if two
00093     // curves coincide. 
00094     int stepLength(const std::vector<Point>& ft, const std::vector<Point>& gs, 
00095                    double delta, bool forward, double& delta_t);
00096 
00097 
00098      // Computes the next step along a curve when we are testing if a
00099     // curve and a surface coincide. 
00100     double stepLength(const std::vector<Point>& ft, const std::vector<Point>& gs, 
00101                       bool forward, std::vector<Point>& cvder,
00102                       double min_step, double max_step, double aepsge); 
00103 
00104  
00105     // Evaluate the curve representing the projection of a spatial curve onto a surface
00106     int evalProjectedCurve(const std::vector<Point>& ft, 
00107                            const std::vector<Point>& gs, 
00108                            std::vector<Point>& res);
00109 
00110     void evalDistCurve(const std::vector<Point>& marching_curve, 
00111                        const std::vector<Point>& other_curve, 
00112                        std::vector<Point>& dist_curve);
00113 
00114     // Start in an intersection point and march along one parameter direction
00115     // as long as there is "coincidence" (within a given tolerance).  Then return the
00116     // parameter value for the last point found that was closer to the other object
00117     // than the tolerance, and the parameter value for the first point found that is
00118     // more distant than the tolerance.  
00119     // 'obj1'                          - the first object, could be a curve or surface
00120     // 'obj2'                          - the second object, could be a curve or surface 
00121     // 'geotol'                        - the geometric tolerance for determining 
00122     //                                   coincidence.
00123     // 'current_params'                - a pointer to the parameter array that specify
00124     //                                   the position of the intersection point on the
00125     //                                   two objects.
00126     // 'dir'                           - specify along which parameter direction to march
00127     // 'forward'                       - specify whether we will be marching forwards or
00128     //                                   backwards.
00129     // 'last_param_val_inside'         - returns the last value found along parameter
00130     //                                   'dir' that corresponded to a position still
00131     //                                   within the given tolerance 'geotol'.
00132     // 'first_param_val_outside'       - returns the last value found along parameter
00133     //                                   'dir' that corresponded to a position outside
00134     //                                   the given tolerance 'geotol'.
00135     // returns: 'true' if it managed to bracket the interval properly, 'false'
00136     //          if it reached the end of the marching curve before the outside
00137     //          bracket was found.
00138     bool determineCoincidenceRegion(const ParamObjectInt* obj1,
00139                                     const ParamObjectInt* obj2,
00140                                     boost::shared_ptr<const GeoTol> tol,
00141                                     const double* current_params,
00142                                     int dir,
00143                                     bool forward,
00144                                     double& last_param_val_inside,
00145                                     double& first_param_val_outside);
00146 
00147     // Special version for 0-dim 2nd object (1st object is 1- or 2-par of dim 1).
00148     bool determineCoincidenceRegion(const ParamFunctionInt* obj_1d,
00149                                     double C,
00150                                     boost::shared_ptr<const GeoTol> tol,
00151                                     const double* current_params,
00152                                     int dir,
00153                                     bool forward,
00154                                     double& last_param_val_inside,
00155                                     double& first_param_val_outside);
00156 
00157 //     void determine_confidence_interval(const ParamCurveInt* const marching_curve,
00158 //                                     const ParamCurveInt* const other_curve,
00159 //                                     double& inside_param_marching,
00160 //                                     double& inside_param_other,
00161 //                                     double& outside_param_marching,
00162 //                                     double& outside_param_other,
00163 //                                     double& inside_val,
00164 //                                     double& outside_val,
00165 //                                     double center_value,
00166 //                                     double bracket,
00167 //                                     bool& succeeded);
00168 
00169 //     // Start in an intersection point and march along two curves in a given
00170 //     // direction as long as they coincide.  Then return the two parameter values
00171 //     // for the last points found that are closer to each other than the tolerance, 
00172 //     // and the two parameter values for the first points found that are more 
00173 //     // distant.
00174 //     // 'marching_curve'                - the first curve, along which we will march
00175 //     // 'other_curve'                   - the second curve
00176 //     // 'isect_param_marching'          - the marching curve's parameter for the
00177 //     //                                   departing intersection point
00178 //     // 'isect_param_other'             - the second curve's parameter for the
00179 //     //                                   departing intersection point
00180 //     // 'step_forward_marching'         - set to 'false' if we want to march in the
00181 //     //                                   inverse parameter direction for the 
00182 //     //                                   marching curve.
00183 //     // 'aepsge'                        - contains the geometric tolerance (aepsge) 
00184 //     //                                   and the bracket interval size (bracket_size)
00185 //     // 'last_param_inside_marching'    - return the last parameter found on the
00186 //     //                                   marching curve that corresponds with a
00187 //     //                                   geometric point on the other curve with
00188 //     //                                   a distance inferior to the geometric 
00189 //     //                                   tolerance. It should be inside 
00190 //     //                                   [(1-bracket_size) * aepsge, aepsge]
00191 //     // 'first_param_outside_marching'  - return the first parameter found on the
00192 //     //                                   marching curve that corresponds with a 
00193 //     //                                   geometric point on the other curve with
00194 //     //                                   a distance superior to the geometric 
00195 //     //                                   tolerance, but still within the interval
00196 //     //                                   [aepsge, (1+bracket_size) * aepsge]
00197 //     // 'last_param_inside_other'       - return the parameter on the second curve
00198 //     //                                   that represents the closest point found
00199 //     //                                   to the point on the marching curve 
00200 //     //                                   represented by 'last_param_inside_marching'
00201 //     // 'first_param_outside_other'     - return the parameter on the second curve
00202 //     //                                   that represents the closest point found to 
00203 //     //                                   the point on the marching curve represented
00204 //     //                                   by 'first_param_outside_marching'.
00205 //     // returns: 'true' if it managed to bracket the interval properly, 'false'
00206 //     //          if it reached the end of the marching curve before the outside
00207 //     //          bracket was found.
00208 //     bool measureCoincidenceRegion(const ParamCurveInt* marching_curve,
00209 //                                const ParamCurveInt* other_curve,
00210 //                                double isect_param_marching,
00211 //                                double isect_param_other,
00212 //                                bool step_forward_marching,
00213 //                                const boost::shared_ptr<const GeoTol> aepsge,
00214 //                                double& last_param_inside_marching,
00215 //                                double& first_param_outside_marching,
00216 //                                double& last_param_inside_other,
00217 //                                double& first_param_outside_other);
00218 
00219 //     // Helper functions for 'measureCoincidenceRegion(...)'
00220 //     void expand_coincidence_region(const ParamCurveInt* const marching_curve,
00221 //                                 const ParamCurveInt* const secondry_curve,
00222 //                                 bool marching_fwd,
00223 //                                 double& marching_par,
00224 //                                 double& secondry_par,
00225 //                                 double& dist,
00226 //                                 double lower_limit, // smaller than eps
00227 //                                 double eps,
00228 //                                 bool& passed_lower_limit);
00229 
00230 
00231  
00233 } // namespace Go
00234 
00235 #endif // _COINCIDENCE_H
00236 

Generated on Fri Nov 23 12:24:32 2007 for GoTools Intersections Library by  doxygen 1.5.1