00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SURFACE_MESH_OF_QUADRANGLES_HPP
00021 #define SURFACE_MESH_OF_QUADRANGLES_HPP
00022
00023 #include <Vector.hpp>
00024 #include <Quadrangle.hpp>
00025
00026 #include <SurfaceMesh.hpp>
00027 #include <NormalManager.hpp>
00028
00029 #include <ErrorHandler.hpp>
00030 #include <EdgesBuilder.hpp>
00031
00032 class SurfaceMeshOfQuadrangles
00033 : public SurfaceMesh
00034 {
00035 public:
00036 typedef Quadrangle CellType;
00037 typedef Edge FaceType;
00038
00039 typedef SurfaceMeshOfQuadrangles Transformed;
00040
00041 typedef struct {} BorderMeshType;
00043 class iterator
00044 : public Mesh::T_iterator<SurfaceMeshOfQuadrangles, Quadrangle>
00045 {
00046 private:
00047 typedef Mesh::T_iterator<SurfaceMeshOfQuadrangles, Quadrangle> iterator_base;
00048
00049 public:
00050 iterator&
00051 operator=(const iterator& i)
00052 {
00053 iterator_base::operator=(i);
00054 NormalManager::instance().update(__iterator);
00055
00056 return *this;
00057 }
00058
00059 iterator&
00060 operator=(CellType* cell)
00061 {
00062 iterator_base::operator=(cell);
00063 NormalManager::instance().update(__iterator);
00064
00065 return *this;
00066 }
00067
00068 inline iterator_base operator++(int)
00069 {
00070 iterator_base i = *this;
00071 (*this)++;
00072 return i;
00073 }
00074
00075 inline iterator& operator++()
00076 {
00077 this->iterator_base::operator++();
00078 NormalManager::instance().update(__iterator);
00079 return *this;
00080 }
00081
00082 iterator(SurfaceMeshOfQuadrangles& m,
00083 iterator_base::Position position = iterator_base::Begin)
00084 : iterator_base(m, position)
00085 {
00086 NormalManager::instance().subscribe(__iterator);
00087 }
00088
00089 iterator(SurfaceMeshOfQuadrangles& m,
00090 const size_t& cellNumber)
00091 : iterator_base(m,cellNumber)
00092 {
00093 NormalManager::instance().subscribe(__iterator);
00094 }
00095
00096 iterator(const iterator& i)
00097 : iterator_base(i)
00098 {
00099 NormalManager::instance().subscribe(__iterator);
00100 }
00101
00102 ~iterator()
00103 {
00104 NormalManager::instance().unsubscribe();
00105 }
00106 };
00107
00108 class const_iterator
00109 : public Mesh::T_iterator<const SurfaceMeshOfQuadrangles, const Quadrangle>
00110 {
00111 private:
00112 typedef Mesh::T_iterator<const SurfaceMeshOfQuadrangles, const Quadrangle> const_iterator_base;
00113
00114 public:
00115 const_iterator&
00116 operator=(const const_iterator& i)
00117 {
00118 const_iterator_base::operator=(i);
00119 NormalManager::instance().update(__iterator);
00120
00121 return *this;
00122 }
00123
00124 const_iterator&
00125 operator=(CellType* iterator)
00126 {
00127 const_iterator_base::operator=(iterator);
00128 NormalManager::instance().update(__iterator);
00129
00130 return *this;
00131 }
00132
00133 inline const_iterator_base operator++(int)
00134 {
00135 const_iterator_base i = *this;
00136 (*this)++;
00137 return i;
00138 }
00139
00140 inline const_iterator& operator++()
00141 {
00142 this->const_iterator_base::operator++();
00143 NormalManager::instance().update(__iterator);
00144 return *this;
00145 }
00146
00147 const_iterator(const SurfaceMeshOfQuadrangles& m,
00148 const_iterator_base::Position position = const_iterator_base::Begin)
00149 : const_iterator_base(m, position)
00150 {
00151 NormalManager::instance().subscribe(__iterator);
00152 }
00153
00154 const_iterator(SurfaceMeshOfQuadrangles& m,
00155 const size_t& cellNumber)
00156 : const_iterator_base(m,cellNumber)
00157 {
00158 NormalManager::instance().subscribe(__iterator);
00159 }
00160
00161 const_iterator(const const_iterator& i)
00162 : const_iterator_base(i)
00163 {
00164 NormalManager::instance().subscribe(__iterator);
00165 }
00166
00167 ~const_iterator()
00168 {
00169 NormalManager::instance().unsubscribe();
00170 }
00171 };
00172
00173 private:
00174 ReferenceCounting<Vector<Quadrangle> > __cells;
00175
00176 public:
00177 bool hasBorderMesh() const
00178 {
00179 return false;
00180 }
00181
00182 ConstReferenceCounting<Mesh> borderBaseMesh() const
00183 {
00184 throw ErrorHandler(__FILE__,__LINE__,
00185 "not implemented yet",
00186 ErrorHandler::unexpected);
00187
00188 return 0;
00189 }
00190
00191 std::string typeName() const
00192 {
00193 return "surface mesh of quadrilaterals";
00194 }
00195
00196
00197 void buildEdges()
00198 {
00199 EdgesBuilder<SurfaceMeshOfQuadrangles> edgesBuilder(*this);
00200 __edgesSet = edgesBuilder.edgesSet();
00201 }
00202
00204 inline bool inside(const real_t& x, const real_t& y, const real_t& z) const
00205 {
00206 throw ErrorHandler(__FILE__,__LINE__,
00207 "Trying to find 3d point on a surface mesh",
00208 ErrorHandler::normal);
00209 return false;
00210 }
00211
00213 inline bool inside(const TinyVector<3>& p) const
00214 {
00215 return this->inside(p[0], p[1], p[2]);
00216 }
00217
00218 void computesFictitiousCells() const
00219 {
00220 this->__computesFictitiousCells<Quadrangle>(*__cells);
00221 }
00222
00223 Quadrangle& cell(size_t i)
00224 {
00225 return (*__cells)[i];
00226 }
00227
00228 const Quadrangle& cell(size_t i) const
00229 {
00230 return (*__cells)[i];
00231 }
00232
00233 size_t cellNumber(const Quadrangle& c) const
00234 {
00235 return (*__cells).number(c);
00236 }
00237
00239 inline void setNumberOfCells(const int n)
00240 {
00241 (*__cells).resize(n);
00242 }
00243
00245 inline const size_t& numberOfCells() const
00246 {
00247 return (*__cells).size();
00248 }
00249
00257 const FaceType& face(const size_t& i) const
00258 {
00259 return (*__edgesSet)[i];
00260 }
00261
00262 SurfaceMeshOfQuadrangles(const size_t theNumberOfCells)
00263 : SurfaceMesh(Mesh::surfaceMeshQuadrangles),
00264 __cells(new Vector<Quadrangle>(theNumberOfCells))
00265 {
00266 ;
00267 }
00268
00269 SurfaceMeshOfQuadrangles(ReferenceCounting<VerticesSet> vertices,
00270 ReferenceCounting<VerticesCorrespondance> correspondances,
00271 ReferenceCounting<Vector<Quadrangle> > quadrangles)
00272 : SurfaceMesh(Mesh::surfaceMeshQuadrangles,
00273 vertices,
00274 correspondances),
00275 __cells(quadrangles)
00276 {
00277 ;
00278 }
00279
00280 SurfaceMeshOfQuadrangles()
00281 : SurfaceMesh(Mesh::surfaceMeshQuadrangles)
00282 {
00283 ;
00284 }
00285
00286 ~SurfaceMeshOfQuadrangles()
00287 {
00288 ;
00289 }
00290 };
00291
00292 #endif // SURFACE_MESH_OF_QUADRANGLES_HPP
00293