GeometryTools.h

Go to the documentation of this file.
00001 //===========================================================================
00002 // GoTools - SINTEF Geometry Tools version 1.1
00003 //
00004 // GoTools module: CORE
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 _GEOMETRYTOOLS_H
00034 #define _GEOMETRYTOOLS_H
00035 
00036 #include "SplineCurve.h"
00037 #include "SplineSurface.h"
00038 #include "LineCloud.h"
00039 #include "Array.h"
00040 #include <boost/smart_ptr.hpp>
00041 #include <vector>
00042 
00049 
00050 
00051 namespace Go
00052 {
00055 
00056 
00057     //-----------------------------------------------------------------------
00058     //
00059     //  Tool functions in alphabetical order.
00060     //
00061     //-----------------------------------------------------------------------
00062 
00063 
00074     int analyzePeriodicity(const SplineCurve& cv, double knot_tol = 1e-12);
00075 
00090     int analyzePeriodicity(const SplineSurface& sf, int direction, double knot_tol = 1e-12);
00091 
00103     int analyzePeriodicity(const BsplineBasis& basis,
00104                            double knot_tol = 1e-12);
00105 
00120     int analyzePeriodicityDerivs(const ParamCurve& cv,
00121                                  int max_derivs,
00122                                  double tol = 1e-14);
00123 
00141     int analyzePeriodicityDerivs(const SplineSurface& sf,
00142                                  int direction,
00143                                  int max_derivs,
00144                                  double tol = 1e-14);
00145 
00158     boost::shared_ptr<SplineCurve>
00159     curveSum(const SplineCurve& crv1, double fac1,
00160              const SplineCurve& crv2, double fac2,
00161              double num_tol = 1e-05);
00162 
00163     // The same requirements as in curveSum().
00164     boost::shared_ptr<SplineSurface>
00165     surfaceSum(const SplineSurface& sf1, double fac1,
00166                const SplineSurface& sf2, double fac2,
00167                double num_tol = 1e-05);
00168 
00175     void estimateSurfaceSize(const SplineSurface& srf, double& length_u, 
00176                              double& length_v);
00177 
00184     void estimateIsoCurveLength(const SplineSurface& srf, bool dir_u, 
00185                                 double par, double& length);
00186 
00189     bool degenerateToCurve(const SplineSurface& srf, bool dir_u, double tol);
00190 
00192     void makeBdDegenerate(SplineSurface& srf, int bd_idx);   // left, right, bottom, top
00193 
00196     bool checkConstantCoef(SplineCurve& cv, int idx, double val, double max_dist, double tol);
00197 
00200     void setSfBdCoefToConst(SplineSurface& srf, int bd_idx, int idx_d, double val,
00201                             double deg_tol);
00202 
00209     void findDominant(const SplineSurface& surface,
00210                       Vector3D& dominant_u, 
00211                       Vector3D& dominant_v);
00212 
00223     void getGnJoints(const ParamCurve& curve,
00224                      const std::vector<double>& cont,
00225                      std::vector<double>& gn_joints);
00226 
00245     void getGnJoints(const CurveLoop& loop,
00246                      const std::vector<double>& cont,
00247                      std::vector<std::vector<double> >& gn_joints);
00248 
00259     bool isCoincident(const ParamCurve& cv1, const ParamCurve& cv2, double epsge);
00260 
00271     bool negativeProj(const SplineSurface& surface,
00272                       const Array<Vector3D, 2>& refvector,
00273                       const double eps = 0.0);
00274 
00284     boost::shared_ptr<SplineCurve> projectCurve(const SplineCurve& incurve,
00285                                                 const Point& normal,
00286                                                 bool planar);
00287 
00288 //     /// Project the input pt onto space defined by leg1 & leg2.
00289 //     /// The projected pt is given as: proj_pt = coef1*leg1 + coef2*leg2.
00290 //     void projectPoint(Point pt, Point leg1, Point leg2,
00291 //                    double& coef1, double& coef2);
00292 
00305     boost::shared_ptr<SplineCurve>
00306     representSurfaceAsCurve(const SplineSurface& surface,
00307                             int cv_dir);
00308 
00312 
00325     boost::shared_ptr<SplineSurface>
00326     representCurveAsSurface(const SplineCurve& curve,
00327                             int cv_dir,
00328                             const BsplineBasis& other_bas,
00329                             bool rational);
00330 
00338     std::vector<double> getRotationMatrix(const Point& unit_axis_dir, double alpha);
00339 
00345     void rotateSplineSurf(Point rot_axis, double alpha, SplineSurface& sf);
00346 
00352     void rotateSplineCurve(Point rot_axis, double alpha, SplineCurve& cv);
00353 
00359     void rotateLineCloud(Point rot_axis, double alpha, LineCloud& lc);
00360 
00368     void rotatePoint(Point rot_axis, double alpha, double* space_pt);
00369 
00370 
00372     void splitCurveIntoSegments(const SplineCurve& cv,
00373                                    std::vector<SplineCurve>& seg);
00374 
00375 
00377     std::vector<boost::shared_ptr<SplineSurface> > 
00378     splitInKinks(const SplineSurface& sf,
00379                  const std::vector<double>& u_kinks,
00380                  const std::vector<double>& v_kinks);
00381 
00382 
00384     void splitSurfaceIntoPatches(const SplineSurface& sf,
00385                                  std::vector<SplineSurface>& pat);
00386 
00387 
00390     void surfaceKinks(const SplineSurface& sf, double max_normal_angle,
00391                       std::vector<double>& g1_disc_u, 
00392                       std::vector<double>& g1_disc_v);
00393 
00395     void translateSplineSurf(const Point& trans_vec, SplineSurface& sf);
00396 
00398     void translateSplineCurve(const Point& trans_vec, SplineCurve& cv);
00399 
00401     void translateLineCloud(const Point& trans_vec, LineCloud& lc);
00402 
00405     void
00406         averageBoundaryCoefs(boost::shared_ptr<SplineSurface>& srf1, int bd1, bool keep_first,
00407                              boost::shared_ptr<SplineSurface>& srf2, int bd2, bool keep_second,
00408                              bool found_corner1, Point corner1, bool found_corner2,
00409                              Point corner2, bool opposite);
00410 
00415     void
00416     unifyCurveSplineSpace(std::vector<boost::shared_ptr<SplineCurve> >& curves,
00417                           double tol);
00418 
00424     void
00425     unifySurfaceSplineSpace(std::vector<boost::
00426                             shared_ptr<SplineSurface> >& surfaces,
00427                             double tol, int dir = 0);
00428 
00433     boost::shared_ptr<SplineSurface>
00434     joinPatches(const std::vector<boost::shared_ptr<SplineSurface> >& patches,
00435                 const SplineSurface& spline_space);
00436 
00437     void insertKnotsEvenly(BsplineBasis& basis, int num_knots);
00438     void insertKnotsEvenly(BsplineBasis& basis, double tmin, double tmax,
00439                            int num_knots, double knot_diff_tol = 1e-05);
00440 
00441     double getKnotAtLargestInterval(const BsplineBasis& basis);
00442 
00443     std::pair<double, double>
00444     getLargestParameterInterval(const BsplineBasis& basis);
00445 
00446 
00448 } // namespace Go
00449 
00450 
00451 
00452 
00453 
00454 #endif // _GEOMETRYTOOLS_H
00455 
00456 

Generated on Mon Jun 11 14:48:18 2007 for GoTools Core Library by  doxygen 1.5.1