MeshEdgeSamplerT.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 6743 $                                                       *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2009-08-05 11:03:10 +0200 (Mi, 05. Aug 2009) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 //=============================================================================
00046 //
00047 //  CLASS MeshEdgeSamplerT
00048 //
00049 //=============================================================================
00050 
00051 
00052 #ifndef ACG_MESHEDGESAMPLERT_HH
00053 #define ACG_MESHEDGESAMPLERT_HH
00054 
00055 
00056 //== INCLUDES =================================================================
00057 
00058 #include <iostream>
00059 #include <vector>
00060 #include "../../Config/ACGDefines.hh"
00061 
00062 //== FORWARDDECLARATIONS ======================================================
00063 
00064 //== NAMESPACES ===============================================================
00065 
00066 namespace ACG {
00067 
00068 //== CLASS DEFINITION =========================================================
00069 
00070 
00071 
00072 
00080 template <class MeshT, class PointT>
00081 class MeshEdgeSamplerT
00082 {
00083 public:
00084 
00085   // typedefs
00086   typedef MeshT                         Mesh;
00087   typedef typename Mesh::VertexHandle   VH;
00088   typedef typename Mesh::FaceHandle     FH;
00089   typedef typename Mesh::EdgeHandle     EH;
00090   typedef typename Mesh::HalfedgeHandle HEH;
00091   typedef PointT                        Point;
00092 
00093 
00095   MeshEdgeSamplerT( Mesh& _mesh) : mesh_(_mesh){}
00096 
00098   ~MeshEdgeSamplerT() {}
00099 
00100 
00101   // compute points on _mesh edges on intersection plane spanned by
00102   // (_p_start - _p_end) and (normal(_fh_start) + normal(_fh_end)
00103   // Finally the shorter possibility of the closed cut is chosen
00104   void edge_points_in_segment( const Point&        _p_start,
00105                                const Point&        _p_end,
00106                                const FH            _fh_start,
00107                                const FH            _fh_end,
00108                                std::vector<Point>& _points,
00109                                std::vector<EH>&    _ehandles );
00110 protected:
00111 
00112   // compute plane spanned by(_p_start - _p_end) and
00113   // (normal(_fh_start) + normal(_fh_end)
00114   void compute_plane( const Point&        _p_start,
00115                       const Point&        _p_end,
00116                       const FH            _fh_start,
00117                       const FH            _fh_end);
00118 
00119   // get two start HaledgeHandles
00120   void get_start_hehs( const Point& /*_p_start*/ ,
00121                        const FH    _fh_start,
00122                              HEH&  _sheh0,
00123                              HEH&  _sheh1 );
00124 
00125   void get_end_fhs_set( const Point&     _p_end,
00126                         const FH         _fh_end,
00127                         std::vector<FH>& _endfhs);
00128 
00129 
00130 
00131   // intersect line _p0,_p1 with stored plane and return intersection point _p_int
00132   // and distance != 0.0 if the intersection point is not in range [_p0, _p1]
00133   double plane_line_intersection( const Point& _p0,
00134                                   const Point& _p1,
00135                                   Point& _p_int);
00136 
00137   double plane_line_intersection( const HEH _heh,
00138                                   Point&    _p_int);
00139 
00140   bool line_in_plane( const Point& _p0,
00141                       const Point& _p1,
00142                       double       _eps);
00143 
00144   bool line_in_plane( const HEH& _heh );
00145 
00146   double plane_dist( const Point& _p0 );
00147 
00148   double line_line_dist(const Point& _p_start,
00149                         const Point& _p_end,
00150                         const HEH&   _heh,
00151                               Point& _p_best);
00152 
00153   HEH get_next_edge_intersection( const HEH& _heh, const Point& _pold, Point& _pint);
00154 
00155 
00156   void sort_intersections( HEH& _heh0, double& _d0, Point& _ip0,
00157                            HEH& _heh1, double& _d1, Point& _ip1,
00158                            HEH& _heh2, double& _d2, Point& _ip2 );
00159 
00160   double epsilon( const FH& _fh);
00161   double epsilon( const HEH& _heh);
00162 
00163   void finish_list( std::vector<Point>& _points,
00164                     std::vector<EH>&    _ehs,
00165                     const HEH           _cur_heh,
00166                     const FH            _fh_end,
00167                     const Point&        _p_end,
00168                     const int           _type);
00169 
00170   void finish_list_old( std::vector<Point>& _points,
00171                         std::vector<EH>&    _ehs,
00172                         const HEH           _cur_heh,
00173                         const FH            _fh_end,
00174                         const Point&        _p_end,
00175                         const int           _t);
00176 
00177 
00178   void circulate_CW(HEH _heh, FH _fh_end, std::vector<EH>& _cw_ehs);
00179 
00180   void circulate_CCW(HEH _heh, FH _fh_end, std::vector<EH>& _ccw_ehs);
00181 
00182 private:
00183 
00184   // reference to triangle mesh
00185   Mesh& mesh_;
00186 
00187   // plane
00188   Point p_plane_;
00189   Point n_plane_;
00190 };
00191 
00192 
00193 //=============================================================================
00194 } // namespace ACG
00195 //=============================================================================
00196 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_MESHEDGESAMPLERT_C)
00197 #define ACG_MESHEDGESAMPLERT_TEMPLATES
00198 #include "MeshEdgeSamplerT.cc"
00199 #endif
00200 //=============================================================================
00201 #endif // ACG_MESHEDGESAMPLERT_HH defined
00202 //=============================================================================
00203 

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .