Visitor.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef VISITOR_H
00025 #define VISITOR_H
00026
00027 namespace MeshCore {
00028
00029 class MeshFacet;
00030 class MeshKernel;
00031 class MeshFacetVisitor;
00032 class PlaneFit;
00033
00039 class MeshExport MeshFacetVisitor
00040 {
00041 public:
00043 MeshFacetVisitor(void) { }
00045 virtual ~MeshFacetVisitor(void) { }
00052 virtual bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, unsigned long ulFInd,
00053 unsigned long ulLevel) = 0;
00054
00058 virtual bool AllowVisit (const MeshFacet& rclFacet, const MeshFacet& rclFrom,
00059 unsigned long ulFInd, unsigned long ulLevel,
00060 unsigned short neighbourIndex)
00061 {
00062 return true;
00063 }
00064 };
00065
00069 class MeshExport MeshSearchNeighbourFacetsVisitor : public MeshFacetVisitor
00070 {
00071 public:
00072 MeshSearchNeighbourFacetsVisitor (const MeshKernel &rclMesh, float fRadius, unsigned long ulStartFacetIdx);
00073 virtual ~MeshSearchNeighbourFacetsVisitor () {}
00075 inline bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom, unsigned long ulFInd, unsigned long ulLevel);
00077 inline std::vector<unsigned long> GetAndReset (void);
00078
00079 protected:
00080 const MeshKernel& _rclMeshBase;
00081 Base::Vector3f _clCenter;
00082 float _fRadius;
00083 unsigned long _ulCurrentLevel;
00084 bool _bFacetsFoundInCurrentLevel;
00085 std::vector<unsigned long> _vecFacets;
00086 };
00087
00088 inline bool MeshSearchNeighbourFacetsVisitor::Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom,
00089 unsigned long ulFInd, unsigned long ulLevel)
00090 {
00091 if (ulLevel > _ulCurrentLevel) {
00092 if (_bFacetsFoundInCurrentLevel == false)
00093 return false;
00094 _ulCurrentLevel = ulLevel;
00095 _bFacetsFoundInCurrentLevel = false;
00096 }
00097
00098 for (int i = 0; i < 3; i++) {
00099 if (Base::Distance(_clCenter, _rclMeshBase.GetPoint(rclFacet._aulPoints[i])) < _fRadius) {
00100 _vecFacets.push_back(ulFInd);
00101 _bFacetsFoundInCurrentLevel = true;
00102 return true;
00103 }
00104 }
00105
00106 return true;
00107 }
00108
00112 class MeshExport MeshTopFacetVisitor : public MeshFacetVisitor
00113 {
00114 public:
00115 MeshTopFacetVisitor (std::vector<unsigned long> &raulNB) : _raulNeighbours(raulNB) {}
00116 virtual ~MeshTopFacetVisitor () {}
00118 virtual bool Visit (const MeshFacet &rclFacet, const MeshFacet &rclFrom,
00119 unsigned long ulFInd, unsigned long)
00120 {
00121 _raulNeighbours.push_back(ulFInd);
00122 return true;
00123 }
00124
00125 protected:
00126 std::vector<unsigned long> &_raulNeighbours;
00127 };
00128
00129
00130
00135 class MeshPlaneVisitor : public MeshFacetVisitor
00136 {
00137 public:
00138 MeshPlaneVisitor (const MeshKernel& mesh,
00139 unsigned long index,
00140 float deviation,
00141 std::vector<unsigned long> &indices);
00142 virtual ~MeshPlaneVisitor ();
00143 bool AllowVisit (const MeshFacet& face, const MeshFacet&,
00144 unsigned long, unsigned long, unsigned short neighbourIndex);
00145 bool Visit (const MeshFacet & face, const MeshFacet &,
00146 unsigned long ulFInd, unsigned long);
00147
00148 protected:
00149 const MeshKernel& mesh;
00150 std::vector<unsigned long> &indices;
00151 Base::Vector3f basepoint;
00152 Base::Vector3f normal;
00153 float max_deviation;
00154 PlaneFit* fitter;
00155 };
00156
00157
00158
00162 class MeshExport MeshPointVisitor
00163 {
00164 public:
00166 MeshPointVisitor(void) { }
00168 virtual ~MeshPointVisitor(void) { }
00175 virtual bool Visit (const MeshPoint &rclPoint, const MeshPoint &rclFrom,
00176 unsigned long ulPInd, unsigned long ulLevel) = 0;
00177 };
00178
00179 }
00180
00181 #endif // VISITOR_H
00182