MeshKit  1.0
SwapTriEdge.hpp
Go to the documentation of this file.
00001 #ifndef EDGEFLIP_H
00002 #define EDGEFLIP_H
00003 
00004 #include "meshkit/Mesh.hpp"
00005 
00006 using namespace Jaal;
00007 
00008 class SwapTriEdge : public MeshOptimization {
00009 
00010 public:
00011      static const int  DELAUNAY_RULE = 0;
00012      static const int  DEGREE_REDUCTION_RULE = 1;
00013      static const int  ADVANCE_FRONT_RULE = 2;
00014 
00016 
00017      SwapTriEdge(Mesh *m, double angle = 10.0) {
00018           mesh = m;
00019           creaseAngle = angle;
00020      }
00021 
00022      ~SwapTriEdge() {
00023      }
00024 
00025      void setCreaseAngle(double a) {
00026           creaseAngle = a;
00027      }
00028 
00029      void setConstraintEdges(vector<Edge*> &edges) {
00030           //      constraint_edges.add(emesh);
00031      }
00032 
00033      size_t get_number_of_edges_flipped() const {
00034           return num_edges_flipped;
00035      }
00036 
00037      int apply_rule(int r = DELAUNAY_RULE);
00038 
00039 private:
00040      Mesh *mesh;
00041      double creaseAngle;
00042      size_t num_edges_flipped;
00043 
00044      int apply_advance_front_rule();
00045 
00046      bool  isIdeal( const Vertex *v)  const {
00047           int ideal_degree = v->get_ideal_face_degree(3);
00048           int curr_degree  = v->getNumRelations(2);
00049           if( curr_degree == ideal_degree ) return 1;
00050           return 0;
00051      }
00052 
00053      bool unchecked( const Face *f ) const {
00054           int lid = 0;
00055           for( int i = 0; i < 3; i++) {
00056                Vertex *v = f->getNodeAt(i);
00057                v->getAttribute("Layer", lid );
00058                if( lid == INT_MAX) return 1;
00059           }
00060           return 0;
00061      }
00062 
00063      struct FlipEdge : public Edge {
00064 
00065           FlipEdge() {
00066           }
00067 
00068           FlipEdge(Vertex *v1, Vertex * v2) {
00069                process(v1, v2);
00070           }
00071 
00072           ~FlipEdge() {
00073           }
00074 
00075           bool isValid() const {
00076                if( faces[0] == NULL || faces[1] == NULL ) return 0;
00077                if( opposite_nodes[0] == NULL || opposite_nodes[1] == NULL ) return 0;
00078                return 1;
00079           }
00080 
00081           bool isSharp(double creseAngle) const;
00082           bool isConcave() const;
00083 
00084           Face * faces[2];
00085           Vertex * opposite_nodes[2];
00086 private:
00087           void process(Vertex *v1, Vertex * v2);
00088      };
00089      int one_sweep( int entity, int r);
00090      int atomicOp(const Face *face, int r);
00091      int atomicOp(Vertex *v, int r);
00092      virtual int commit(const FlipEdge &edge);
00093      virtual bool is_edge_flip_allowed(const FlipEdge &edge, int r ) const;
00094 };
00095 
00096 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines