MeshKit
1.0
|
00001 /* 00002 * AF2Binding.hpp 00003 * 00004 * An AF2Binding is an object that manages binding the edges and vertices 00005 * that a rule has specified must exist (i.e., AF2RuleExistingEdge and 00006 * AF2RuleExistingVertex) to edges and vertices (i.e., AF2Edge2D 00007 * and AF2Point2D) that actually do exist in some AF2Neighborhood. 00008 * 00009 * The AF2Binding provides methods to bind an edge or a vertex and to check 00010 * whether binding an edge or vertex is consistent with what has already 00011 * been bound. Binding an edge implies binding the endpoint vertices 00012 * of that edge. Attempting to bind an edge or vertex that is not 00013 * consistent with what is already bound will result in an exception. 00014 * Attempting to bind an edge or vertex that is already bound will succeed 00015 * if the binding is consistent. 00016 * 00017 * AF2Binding also provides methods to release edges or vertices that are 00018 * bound. Attempting to release an edge or vertex that is not bound 00019 * will result in an exception. The model for binding a vertex tracks 00020 * both whether the vertex has been explicitly bound with a call to the 00021 * method that binds vertices and whether it is implicitly bound because it 00022 * is an endpoint of an edge that is bound. Attempting to release a vertex 00023 * that has been bound in both ways will release the explicit bound, but not 00024 * the implicit bound. Attempting to release a vertex that is implicitly 00025 * bound but not explicitly bound will result in an exception. 00026 */ 00027 00028 #ifndef AF2BINDING_HPP 00029 #define AF2BINDING_HPP 00030 00031 // C++ 00032 #include <map> 00033 #include <set> 00034 00035 // MeshKit 00036 #include "meshkit/AF2Edge2D.hpp" 00037 #include "meshkit/AF2Point2D.hpp" 00038 #include "meshkit/AF2RuleExistEdge.hpp" 00039 #include "meshkit/AF2RuleExistVertex.hpp" 00040 00041 class AF2Binding 00042 { 00043 private: 00044 00045 struct VtxBindRec 00046 { 00047 const AF2Point2D* pointPtr; 00048 unsigned int numBoundEdges; 00049 bool xplctBound; 00050 00054 VtxBindRec(); 00055 }; 00056 00057 std::map<const AF2RuleExistVertex*, VtxBindRec> vertexBindMap; 00058 std::set<const AF2Point2D*> verticesInUse; 00059 std::map<const AF2RuleExistEdge*, const AF2Edge2D*> edgeBindMap; 00060 std::set<const AF2Edge2D*> edgesInUse; 00061 00069 void bind(const AF2RuleExistVertex* ruleVertexPtr, 00070 const AF2Point2D* ngbhdVertexPtr, bool isExplicit); 00071 00080 void release(const AF2RuleExistVertex* ruleVertexPtr, bool isExplicit); 00081 00082 public: 00083 00102 void bind(const AF2RuleExistEdge* ruleEdgePtr, 00103 const AF2Edge2D* ngbhdEdgePtr); 00104 00122 void bind(const AF2RuleExistVertex* ruleVertexPtr, 00123 const AF2Point2D* ngbhdVertexPtr); 00124 00125 00141 const AF2Point2D* getBoundValue( 00142 const AF2RuleExistVertex* ruleVertexPtr) const; 00143 00162 bool isConsistent(const AF2RuleExistEdge* ruleEdgePtr, 00163 const AF2Edge2D* ngbhdEdgePtr) const; 00164 00181 bool isConsistent(const AF2RuleExistVertex* ruleVertexPtr, 00182 const AF2Point2D* ngbhdVertexPtr) const; 00183 00200 void release(const AF2RuleExistEdge* ruleEdgePtr); 00201 00215 void release(const AF2RuleExistVertex* ruleVertexPtr); 00216 }; 00217 00218 #endif