MeshKit  1.0
AF2Rule.hpp
Go to the documentation of this file.
00001 /*
00002  * AF2Rule.hpp
00003  *
00004  * \brief An AF2Rule defines a two-dimensional pattern for advancing the front
00005  * of a two-dimensional advancing front algorithm.
00006  *
00007  * The pattern consists of a number of existing edges and existing vertices,
00008  * a free zone definition, new vertices, new edges, and new faces.
00009  * In order for the advancing algorithm to apply the pattern, there must
00010  * be edges and points on the advancing front in the neighborhood
00011  * of some baseline edge that match the defined existing edges and existing
00012  * vertices of the pattern.  Depending on the particular binding of
00013  * existing edges and vertices to edges and points in the neighborhood,
00014  * as well as the quality level, the free zone definition will define
00015  * a free zone.  This free zone must not contain any of the neighborhood's
00016  * points or intersect any of its edges, or the algorithm will not apply
00017  * the pattern.
00018  *
00019  * There is also a maximum quality defined on the rule.  If the baseline
00020  * edge is currently of higher quality than the specified maximum quality,
00021  * i.e., if the quality level number is smaller than the defined maximum
00022  * quality level number, then the rule may not be applied.
00023  *
00024  * If the pattern can be successfully applied, then applying the pattern
00025  * involves adding the new vertices, new edges, and new faces of the pattern
00026  * to the mesh.  Since there may be several different ways to apply
00027  * the pattern or several different patterns that could be applied,
00028  * each potential successful application of the pattern is handed off
00029  * to a visitor for processing.  The rule makes no guarantee that
00030  * the new faces are not inverted, and the visitor should verify any
00031  * desired properties before committing the results to the mesh.
00032  */
00033 #ifndef AF2RULE_HPP
00034 #define AF2RULE_HPP
00035 
00036 // C++
00037 #include <list>
00038 #include <map>
00039 #include <string>
00040 
00041 // MeshKit
00042 #include "meshkit/AF2Edge2D.hpp"
00043 #include "meshkit/AF2FreeZoneDef.hpp"
00044 #include "meshkit/AF2Neighborhood.hpp"
00045 #include "meshkit/AF2Point2D.hpp"
00046 #include "meshkit/AF2RuleAppVisitor.hpp"
00047 #include "meshkit/AF2RuleExistEdge.hpp"
00048 #include "meshkit/AF2RuleExistVertex.hpp"
00049 #include "meshkit/AF2RuleNewEdge.hpp"
00050 #include "meshkit/AF2RuleNewFace.hpp"
00051 #include "meshkit/AF2RuleNewVertex.hpp"
00052 
00053 class AF2Rule
00054 {
00055   private:
00056 
00057     const std::string ruleName;
00058     const unsigned int maxQualityLevel;
00059     const unsigned int numExVertices, numExEdges;
00060     const AF2FreeZoneDef* const freeZoneDef;
00061     const unsigned int numNewVertices, numNewEdges, numNewFaces;
00062     const AF2RuleExistVertex** exVertices;
00063     const AF2RuleExistEdge** exEdges;
00064     const AF2RuleNewVertex** newVertices;
00065     const AF2RuleNewEdge** newEdges;
00066     const AF2RuleNewFace** newFaces;
00067     unsigned int numExIsoVertices;
00068     const AF2RuleExistVertex** exIsoVertices;
00069 
00089     void applyRuleStageTwo(AF2Neighborhood const & ngbhd,
00090         unsigned int matchQuality, AF2RuleAppVisitor & visitor,
00091         std::map<const AF2RuleExistVertex*,
00092         std::list<const AF2Point2D*>*>* const & matchingVerticesMap,
00093         AF2Binding & binding) const;
00094 
00115     void applyRuleStageThree(AF2Neighborhood const & ngbhd,
00116         unsigned int matchQuality, AF2RuleAppVisitor & visitor,
00117         AF2Binding const & binding) const;
00118 
00126     std::map<const AF2RuleExistEdge*, std::list<const AF2Edge2D*>*>*
00127         findPotentialEdgeMatches(AF2Neighborhood const & ngbhd,
00128         unsigned int matchQuality) const;
00129 
00138     std::map<const AF2RuleExistVertex*, std::list<const AF2Point2D*>*>*
00139         findPotentialVertexMatches(AF2Neighborhood const & ngbhd,
00140         unsigned int matchQuality) const;
00141 
00154     void checkExEndpointsAndFindIsolatedVertices();
00155 
00172     bool isMatchingEdge(AF2Edge2D const & edge,
00173         AF2RuleExistEdge const & ruleEdge, unsigned int matchQuality) const;
00174 
00191     bool isMatchingVertex(AF2Point2D const & point,
00192         AF2RuleExistVertex const & ruleVertex, unsigned int matchQuality) const;
00193 
00194   public:
00195 
00245     AF2Rule(std::string const & ruleNameArg, unsigned int maxQuality,
00246         std::list<const AF2RuleExistVertex*> const & ruleVertices,
00247         const AF2RuleExistEdge* baselineEdge,
00248         std::list<const AF2RuleExistEdge*> const & otherRuleEdges,
00249         const AF2FreeZoneDef* freeZoneDef,
00250         std::list<const AF2RuleNewVertex*> const & ruleNewVertices,
00251         std::list<const AF2RuleNewEdge*> const & ruleNewEdges,
00252         std::list<const AF2RuleNewFace*> const & ruleNewFaces);
00253 
00257     ~AF2Rule();
00258 
00265     AF2Rule(const AF2Rule & toCopy);
00266 
00273     AF2Rule& operator=(const AF2Rule & rhs);
00274 
00292     void applyRule(AF2Neighborhood const & ngbhd, unsigned int matchQuality,
00293         AF2RuleAppVisitor & visitor) const;
00294 
00300     std::string getName() const;
00301 };
00302 
00303 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines