vtf-logo

EdgeRemoval.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_mesh_simplicial_EdgeRemoval_h__)
00009 #define __geom_mesh_simplicial_EdgeRemoval_h__
00010 
00011 #if defined(DEBUG_geom) && !defined(DEBUG_EdgeRemoval)
00012 #define DEBUG_EdgeRemoval
00013 #endif
00014 
00015 #include "../simplex/SimplexModCondNum.h"
00016 
00017 #include "../../../ads/array/Array.h"
00018 
00019 #include <cassert>
00020 
00021 
00022 BEGIN_NAMESPACE_GEOM
00023 
00024 
00026 template<class _QualityMetric = SimplexModCondNum<3>,
00027          class _Point = ads::FixedArray<3>,
00028          typename _Number = typename _Point::value_type>
00029 class EdgeRemoval {
00030 
00031 public:
00032 
00033   //
00034   // Public types.
00035   //
00036 
00038   typedef _QualityMetric QualityMetric;
00040   typedef _Point Point;
00042   typedef _Number Number;
00043 
00044 private:
00045       
00046   //
00047   // Private types.
00048   //
00049 
00050   typedef ads::Array<2,Number> NumberArray;
00051   typedef ads::Array<2,int> IntegerArray;
00052   typedef IntegerArray::index_type Index;
00053   typedef IntegerArray::size_type SizeType;
00054   typedef typename QualityMetric::Simplex Simplex;
00055 
00056   //
00057   // Data
00058   //
00059 
00060   // The source and target of the edge.
00061   Point _source, _target;
00062   // The ring of vertices around the edge. Let there be N vertices in the ring.
00063   std::vector<Point> _ring;
00064   // An N-1 x N table for calculating the quality of the tetrahedralization.
00065   NumberArray _quality;
00066   // An N-1 x N table for calculating the indices of the tetrahedralization.
00067   IntegerArray _index;
00068   // The triangle indices of the triangulation of the ring.
00069   std::vector<ads::FixedArray<3,int> > _triangles;
00070   // The quality function.
00071   mutable QualityMetric _qualityFunction;
00072   
00073   //
00074   // Not implemented.
00075   //
00076 
00077   // Copy constructor not implemented.
00078   EdgeRemoval(const EdgeRemoval&);
00079 
00080   // Assignment operator.
00081   EdgeRemoval& 
00082   operator=(const EdgeRemoval&);
00083 
00084 public:
00085 
00086   //--------------------------------------------------------------------------
00089 
00091   EdgeRemoval() :
00092     _source(),
00093     _target(),
00094     _ring(),
00095     _quality(),
00096     _index(),
00097     _triangles(),
00098     _qualityFunction()
00099   {}
00100 
00102   ~EdgeRemoval()
00103   {}
00104 
00106   //--------------------------------------------------------------------------
00109 
00111   int
00112   getNumberOfTriangles() const {
00113     return int(_triangles.size());
00114   }
00115 
00117   const ads::FixedArray<3,int>&
00118   getTriangle(const int n) const {
00119     return _triangles[n];
00120   }
00121 
00123   //--------------------------------------------------------------------------
00126 
00128   void
00129   setSource(const Point& src) {
00130     _source = src;
00131   }
00132 
00134   void
00135   setTarget(const Point& tgt) {
00136     _target = tgt;
00137   }
00138 
00140 
00143   template<typename InputIterator>
00144   void
00145   setRing(InputIterator begin, InputIterator end) {
00146     _ring.clear();
00147     _ring.insert(_ring.end(), begin, end);
00148     assert(_ring.size() >= 3);
00149     // Make sure that the quality and triangulation arrays are big enough.
00150     if (_quality.extent(1) < SizeType(_ring.size())) {
00151       _quality.resize(Index(int(_ring.size()) - 2, 
00152                                    int(_ring.size())));
00153       _index.resize(Index(int(_ring.size()) - 2, int(_ring.size())));
00154     }
00155   }
00156 
00158   //--------------------------------------------------------------------------
00161 
00163 
00167   bool
00168   solve();
00169 
00171 
00172   //
00173   // Private member functions.
00174   //
00175   // CONTINUE: Should these be private?
00176 
00178   void
00179   fillTables();
00180 
00182   void
00183   buildTriangles();
00184 
00186   void
00187   buildTrianglesRecurse(const int i, const int j);
00188 
00189   // Return the worse quality of the tetrahedra: 
00190   // _ring[i], _ring[k], _ring[j], _target
00191   // and
00192   // _source, _ring[i], _ring[k], _ring[j]
00194   Number
00195   computeQuality(const int i, const int k, const int j) const;
00196 
00197   // Return the quality of the complex with the center edge.
00198   // The quality of the complex is the quality of the worst tetrahedron.
00200   Number
00201   computeQualityWithEdge() const;
00202 
00203   // Return the quality of the tetrahedra: 
00204   // _source, _target, _ring[i], _ring[i+1]
00206   Number
00207   computeQuality(const int i) const;
00208 };
00209 
00210 
00211 END_NAMESPACE_GEOM
00212 
00213 
00214 #define __geom_mesh_simplicial_EdgeRemoval_ipp__
00215 #include "EdgeRemoval.ipp"
00216 #undef __geom_mesh_simplicial_EdgeRemoval_ipp__
00217 
00218 #endif

Generated on Fri Aug 24 12:55:52 2007 for Computational Geometry Package by  doxygen 1.4.7