vtf-logo

PointsOnManifold321.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_PointsOnManifold321_h__)
00009 #define __geom_PointsOnManifold321_h__
00010 
00011 
00012 BEGIN_NAMESPACE_GEOM
00013 
00014 // CONTINUE:  I need the ability to have corner features defined only by
00015 // the solid angle and at the same time have edge features that fall below
00016 // that solid angle.  Do this by defining a vertex with small solid angle
00017 // and two incident edges as on edge feature.
00018 
00019 // CONTINUE: Replace the term surface feature with smooth feature.
00020 
00021 // CONTINUE: Consider a node with two incident edge features in which
00022 // the angle between these two edges has a large deviation from pi.  In
00023 // this case the node should be a corner feature.  Add this functionality
00024 // to the code and the documentation.
00025 
00027 
00261 template<typename T>
00262 class PointsOnManifold<3,2,1,T> {
00263   //
00264   // Public enumerations.
00265   //
00266 
00267 public:
00268 
00270   enum {N = 3, M = 2, SD = 1};
00271 
00272   //
00273   // Private enumerations.
00274   //
00275 
00276   // CONTINUE: With the Intel compiler, private members are not accessible in
00277   // nested classes.
00278 #ifdef __INTEL_COMPILER
00279 public:
00280 #else
00281 private:
00282 #endif
00283 
00285   enum Feature {NullFeature, CornerFeature, EdgeFeature, SurfaceFeature};
00286 
00287   //
00288   // Nested classes.
00289   //
00290 
00291 private:
00292   
00294   class FaceHandle {
00295   private:
00296 
00297     Feature _feature;
00298     int _index;
00299 
00300   public:
00301 
00302     //
00303     // Constructors, etc.
00304     //
00305 
00307     FaceHandle() :
00308       _feature(NullFeature),
00309       _index(-1)
00310     {}
00311 
00313     FaceHandle(const FaceHandle& other) :
00314       _feature(other._feature),
00315       _index(other._index)
00316     {}
00317 
00319     FaceHandle&
00320     operator=(const FaceHandle& other) {
00321       // Avoid assignment to self.
00322       if (this != &other) {
00323         _feature = other._feature;
00324         _index = other._index;
00325       }
00326       // Return a reference to this so assignments can chain.
00327       return *this;
00328     }
00329     
00331     FaceHandle(const Feature feature, const int index) :
00332       _feature(feature),
00333       _index(index)
00334     {}
00335 
00337     ~FaceHandle()
00338     {}
00339 
00340     //
00341     // Accessors.
00342     //
00343 
00345     Feature
00346     getFeature() const {
00347       return _feature;
00348     }
00349 
00351     int
00352     getIndex() const {
00353       return _index;
00354     }
00355 
00356     //
00357     // Manipulators
00358     //
00359 
00361     void
00362     setFeature(const Feature feature) {
00363       _feature = feature;
00364     }
00365 
00367     void
00368     setIndex(const int index) {
00369       _index = index;
00370     }
00371 
00373     void
00374     setToNull() {
00375       _feature = NullFeature;
00376       _index = -1;
00377     }
00378   };
00379 
00380   //
00381   // Private types.
00382   //
00383 
00384 private:
00385 
00387   typedef IndSimpSetIncAdj<N,M,true,T> SurfaceManifold;
00389   typedef typename SurfaceManifold::Face SurfaceEdge;
00391   typedef int SizeType;
00393   typedef std::map<int,FaceHandle> PointMap;
00395   typedef ads::OrderedPair<int> RegisteredEdge;
00397   typedef std::set<RegisteredEdge> EdgeSet;
00399   typedef typename PointMap::value_type Point;
00400 
00401   //
00402   // Public types.
00403   //
00404 
00405 public:
00406 
00408   typedef T Number;
00410   typedef typename SurfaceManifold::Vertex Vertex;
00411   // CONTINUE: I could wrap the vertex array from the surface to save memory.
00413   typedef IndSimpSetIncAdj<N,M-1,true,T> EdgeManifold;
00414 
00415   //
00416   // Member data.
00417   //
00418 
00419 private:
00420   
00422   SurfaceManifold _surfaceManifold;
00424 
00427   ads::Array<2,bool> _isAnEdge;
00429   EdgeManifold _edgeManifold;
00431   ads::Array<1,int> _cornerIndices;
00433   ads::Array<1,Feature> _vertexFeatures;
00435   PointMap _points;
00437   EdgeSet _edges;
00439   ISS_SimplexQuery<SurfaceManifold> _surfaceQuery;
00441   ISS_SimplexQuery<EdgeManifold> _edgeQuery;
00443   Number _maxCornerDistance;
00445   Number _maxEdgeDistance;
00446 
00448   mutable int _cachedIdentifier;
00450   mutable FaceHandle _cachedFace;
00451 
00452   //
00453   // Not implemented.
00454   //
00455 
00456 private:
00457 
00459   PointsOnManifold();
00460 
00462   PointsOnManifold(const PointsOnManifold&);
00463 
00465   PointsOnManifold& 
00466   operator=(const PointsOnManifold&);
00467 
00468 public:
00469 
00470   //--------------------------------------------------------------------------
00473 
00475 
00492   template<bool A, typename V, typename IS, typename EdgeInIter,
00493            typename IntInIter>
00494   PointsOnManifold(const IndSimpSet<N,M,A,T,V,IS>& iss,
00495                    EdgeInIter edgesBegin, EdgeInIter edgesEnd,
00496                    IntInIter cornersBegin, IntInIter cornersEnd);
00497 
00499 
00517   template<bool A, typename V, typename IS>
00518   PointsOnManifold(const IndSimpSet<N,M,A,T,V,IS>& iss,
00519                    Number maxDihedralAngleDeviation = -1,
00520                    Number maxSolidAngleDeviation = -1,
00521                    Number maxBoundaryAngleDeviation = -1);
00522 
00524   ~PointsOnManifold()
00525   {}
00526 
00528   //--------------------------------------------------------------------------
00531 
00533   SizeType
00534   countNumberOfPoints() const {
00535     return _points.size();
00536   }
00537 
00539   void
00540   countNumberOfPointsOnFeatures(SizeType* surfaceCount, SizeType* edgeCount, 
00541                                 SizeType* cornerCount) const;
00542 
00544   SizeType
00545   countNumberOfSurfacePoints() const;
00546 
00548   SizeType
00549   countNumberOfEdgePoints() const;
00550 
00552   SizeType
00553   countNumberOfCornerPoints() const;
00554 
00556   SizeType
00557   countNumberOfEdges() const {
00558     return _edges.size();
00559   }
00560 
00562   bool
00563   isVertexASurfaceFeature(const int n) const {
00564     return _vertexFeatures[n] == SurfaceFeature;
00565   }
00566 
00568   bool
00569   isVertexAnEdgeFeature(const int n) const {
00570     return _vertexFeatures[n] == EdgeFeature;
00571   }
00572 
00574   bool
00575   isVertexACornerFeature(const int n) const {
00576     return _vertexFeatures[n] == CornerFeature;
00577   }
00578 
00580   bool
00581   isOnSurface(const int identifier) const {
00582     return isOnFeature(identifier, SurfaceFeature);
00583   }
00584   
00586   bool
00587   isOnEdge(const int identifier) const {
00588     return isOnFeature(identifier, EdgeFeature);
00589   }
00590   
00592   bool
00593   isOnCorner(const int identifier) const {
00594     return isOnFeature(identifier, CornerFeature);
00595   }
00596 
00598   bool
00599   hasPoint(const int identifier) const {
00600     return _points.count(identifier) == 1;
00601   }
00602 
00604   bool
00605   hasEdge(int pointId1, int pointId2) const;
00606 
00608 
00611   int
00612   getSurfaceSimplexIndex(const int identifier) const;
00613   
00615 
00618   int
00619   getEdgeSimplexIndex(const int identifier) const;
00620   
00622 
00625   int
00626   getVertexIndex(const int identifier) const;
00627 
00629   Number
00630   getMaxCornerDistance() const {
00631     return _maxCornerDistance;
00632   }
00633 
00635   Number
00636   getMaxEdgeDistance() const {
00637     return _maxEdgeDistance;
00638   }
00639 
00641   template<typename IntInsertIterator>
00642   void
00643   getNeighborhood(const int identifier, IntInsertIterator iter) const {
00644     // If the vertex is a corner feature.
00645     if (isOnCorner(identifier)) {
00646       getCornerNeighborhood(getVertexIndex(identifier), iter);
00647     }
00648     // If the vertex is an edge feature.
00649     else if (isOnEdge(identifier)) {
00650       getEdgeNeighborhood(getEdgeSimplexIndex(identifier), iter);
00651     }
00652     // Otherwise, it is a surface feature.
00653     else {
00654       getSurfaceNeighborhood(getSurfaceSimplexIndex(identifier), iter);
00655     }
00656   }
00657 
00659   const Vertex&
00660   getEdgeSimplexVertex(const int simplexIndex, const int m) const {
00661     // No need to test the validity of the parameters.  This is done in the
00662     // following call.
00663     return _edgeManifold.getSimplexVertex(simplexIndex, m);
00664   }
00665 
00667   const Vertex&
00668   getSurfaceSimplexVertex(const int simplexIndex, const int m) const {
00669     // No need to test the validity of the parameters.  This is done in the
00670     // following call.
00671     return _surfaceManifold.getSimplexVertex(simplexIndex, m);
00672   }
00673 
00675   const EdgeManifold&
00676   getEdgeManifold() const {
00677     return _edgeManifold;
00678   }
00679 
00681   const ads::Array<1,int>&
00682   getCornerIndices() const {
00683     return _cornerIndices;
00684   }
00685 
00687 
00691   template<bool A33, typename V33, typename IS33, typename V31, typename IS31>
00692   void
00693   getEdgesOnEdgeFeatures(const IndSimpSet<3,3,A33,Number,V33,IS33>& solidMesh,
00694                          IndSimpSet<3,1,true,Number,V31,IS31>* edgeMesh) const;
00695 
00697   //--------------------------------------------------------------------------
00700 
00702 
00707   void
00708   setMaxCornerDistance(const Number x) {
00709     _maxCornerDistance = x;
00710   }
00711 
00713 
00718   void
00719   setMaxEdgeDistance(const Number x) {
00720     _maxEdgeDistance = x;
00721   }
00722 
00724   void
00725   changeIdentifier(int existingIdentifier, int newIdentifier);
00726 
00728 
00731   Vertex
00732   changeLocation(int pointIdentifier, const Vertex& newLocation);
00733 
00735   void
00736   changeSurfaceSimplex(int pointIdentifier, int simplexIndex);
00737 
00739   void
00740   changeEdgeSimplex(int pointIdentifier, int simplexIndex);
00741 
00743   //--------------------------------------------------------------------------
00746 
00748   void
00749   insertAtVertex(int pointIdentifier, int vertexIndex);
00750 
00752 
00755   void
00756   insertAtVertices();
00757 
00759 
00762   void
00763   insertAtVerticesAndEdges();
00764 
00765 // CONTINUE: Implement this or something like it.
00766 #if 0
00768 
00771   Vertex
00772   insertNearPoint(int newPointID, const Vertex& position, int existingPointID);
00773 #endif
00774 
00776   Vertex
00777   insertOnAnEdge(int pointIdentifier, const Vertex& position);
00778 
00780 
00784   Vertex
00785   insertOnAnEdgeOrCorner(int pointIdentifier, const Vertex& position);
00786 
00788   Vertex
00789   insertOnASurface(int pointIdentifier, const Vertex& position);
00790 
00792 
00795   Vertex
00796   insert(int pointIdentifier, const Vertex& position);
00797 
00799 
00804   template<typename PointInputIterator, typename PointOutputIterator>
00805   void
00806   insert(PointInputIterator locationsBegin, PointInputIterator locationsEnd,
00807          PointOutputIterator closestPoints);
00808 
00810 
00822   template<bool A, typename V, typename IS>
00823   void
00824   insertBoundaryVerticesAndEdges(IndSimpSetIncAdj<N,M+1,A,T,V,IS>* mesh,
00825                                  Number maxDihedralAngleDeviation = -1);
00826 
00828 
00840   template<template<class> class Node,
00841            template<class> class Cell,
00842            template<class,class> class Container>
00843   void
00844   insertBoundaryVerticesAndEdges
00845   (SimpMeshRed<N,M+1,T,Node,Cell,Container>* mesh,
00846    Number maxDihedralAngleDeviation = -1);
00847 
00849 
00861   template<template<class> class Node,
00862            template<class> class Cell,
00863            template<class,class> class Container>
00864   void
00865   insertVerticesAndEdges(SimpMeshRed<N,M,T,Node,Cell,Container>* mesh,
00866                          Number maxDihedralAngleDeviation = -1);
00867 
00869   void
00870   erase(int pointIdentifier);
00871 
00873   void
00874   clearPoints() {
00875     _points.clear();
00876   }
00877 
00879   //--------------------------------------------------------------------------
00882 
00884   void
00885   insert(int pointId1, int pointId2);
00886 
00888 
00891   void
00892   insertAtEdges();
00893 
00895   void
00896   erase(int pointId1, int pointId2);
00897 
00899   void
00900   clearEdges() {
00901     _edges.clear();
00902   }
00903 
00905 
00909   void
00910   splitEdge(int source, int target, int middle);
00911 
00913   //--------------------------------------------------------------------------
00916 
00918 
00924   Vertex
00925   computeClosestPoint(int pointIdentifier, const Vertex& position) const;
00926 
00928   void
00929   updatePoint();
00930 
00932   //--------------------------------------------------------------------------
00935 
00937   void
00938   printInformation(std::ostream& out) const;
00939 
00941 
00942   //--------------------------------------------------------------------------
00943   // Private member functions.
00944   //
00945 
00946 private:
00947 
00949 
00958   template<typename EdgeInIter, typename IntInIter>
00959   void
00960   buildEdgesAndCorners(EdgeInIter edgesBegin, EdgeInIter edgesEnd,
00961                        IntInIter cornersBegin, IntInIter cornersEnd);
00962 
00964 
00967   Vertex
00968   insertInSurfaceSimplex(int pointIdentifier, const Vertex& position, 
00969                          int simplexIndex);
00970 
00972 
00975   Vertex
00976   insertInEdgeSimplex(int pointIdentifier, const Vertex& position, 
00977                       int simplexIndex);
00978 
00980 
00984   int
00985   findCornerVertex(const Vertex& position) const;
00986 
00988 
00992   int
00993   findEdgeSimplex(const Vertex& position) const;
00994 
00996 
00999   template<typename IntInputIterator>
01000   Vertex
01001   computeClosestPointInSurfaceSimplices(IntInputIterator indicesBegin, 
01002                                         IntInputIterator indicesEnd, 
01003                                         const Vertex& position) const;
01004 
01006 
01009   template<typename IntInputIterator>
01010   Vertex
01011   computeClosestPointInEdgeSimplices(IntInputIterator indicesBegin, 
01012                                      IntInputIterator indicesEnd, 
01013                                      const Vertex& position) const;
01014 
01016   Number
01017   computeClosestPointInSurfaceSimplex(int simplexIndex, const Vertex& x, 
01018                                       Vertex* closestPoint) const;
01019 
01021   Number
01022   computeClosestPointInEdgeSimplex(int simplexIndex, const Vertex& x, 
01023                                    Vertex* closestPoint) const;
01024 
01026   Vertex
01027   computeClosestPointInSurfaceSimplex(int simplexIndex, const Vertex& x) const;
01028 
01030   Vertex
01031   computeClosestPointInEdgeSimplex(int simplexIndex, const Vertex& x) const;
01032 
01034   bool
01035   isOnFeature(int identifier, Feature feature) const;
01036 
01038   bool
01039   isValid(const FaceHandle& face) const;
01040   
01042   template<typename IntInsertIterator>
01043   void
01044   getNeighborhood(const FaceHandle& face, IntInsertIterator iter) const;
01045 
01047 
01051   template<typename IntInsertIterator>
01052   void
01053   getSurfaceNeighborhood(const int simplexIndex, IntInsertIterator iter) const;
01054 
01056 
01059   template<typename IntInsertIterator>
01060   void
01061   getEdgeNeighborhood(const int simplexIndex, IntInsertIterator iter) const;
01062 
01064   template<typename IntInsertIterator>
01065   void
01066   getCornerNeighborhood(const int vertexIndex, IntInsertIterator iter) const;
01067 };
01068 
01069 END_NAMESPACE_GEOM
01070 
01071 #define __geom_PointsOnManifold321_ipp__
01072 #include "PointsOnManifold321.ipp"
01073 #undef __geom_PointsOnManifold321_ipp__
01074 
01075 #endif

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