00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MESH_OF_HEXAHEDRA_HPP
00021 #define MESH_OF_HEXAHEDRA_HPP
00022
00033 #include <Mesh.hpp>
00034
00035 #include <SurfaceMeshOfQuadrangles.hpp>
00036 #include <FacesSet.hpp>
00037
00038 #include <Hexahedron.hpp>
00039
00040 #include <Connectivity.hpp>
00041 #include <Octree.hpp>
00042
00043 #include <list>
00044 #include <map>
00045
00046 class MeshOfHexahedra
00047 : public Mesh
00048 {
00049 public:
00050 typedef Hexahedron CellType;
00051 typedef Hexahedron::FaceType FaceType;
00052
00053 typedef MeshOfHexahedra Transformed;
00054
00055 typedef SurfaceMeshOfQuadrangles BorderMeshType;
00056
00057 enum {
00058 family = Mesh::volume
00059 };
00060 private:
00061 ReferenceCounting<Vector<Hexahedron> > __cells;
00063 ReferenceCounting<BorderMeshType>
00064 __borderMesh;
00066 ReferenceCounting<FacesSet<Quadrangle> >
00067 __facesSet;
00069 Connectivity<MeshOfHexahedra> __connectivity;
00071 ReferenceCounting<Octree<size_t, 3> > __octree;
00073 TinyVector<3,real_t> __a;
00074 TinyVector<3,real_t> __b;
00082 MeshOfHexahedra(const MeshOfHexahedra& m);
00083
00084 public:
00085 std::string typeName() const
00086 {
00087 return "unstructured mesh of hexahedra";
00088 }
00089
00091 inline bool inside(const real_t& x, const real_t& y, const real_t& z) const
00092 {
00093 return not(this->find(x, y, z).end());
00094 }
00095
00097 inline bool inside(const TinyVector<3>& p) const
00098 {
00099 return this->inside(p[0], p[1], p[2]);
00100 }
00101
00102 inline bool hasBorderMesh() const
00103 {
00104 return (__borderMesh != 0);
00105 }
00106
00107 ConstReferenceCounting<BorderMeshType> borderMesh() const
00108 {
00109 return __borderMesh;
00110 }
00111
00112 ConstReferenceCounting<Mesh> borderBaseMesh() const
00113 {
00114 return static_cast<const BorderMeshType*>(__borderMesh);
00115 }
00116
00121 void buildEdges();
00122
00127 bool hasFaces() const
00128 {
00129 return (__facesSet != 0);
00130 }
00131
00136 void buildFaces();
00137
00145 const FaceType& face(const size_t& i) const
00146 {
00147 return (*__facesSet)[i];
00148 }
00149
00150 size_t faceNumber(const FaceType& f) const
00151 {
00152 return (*__facesSet).number(f);
00153 }
00154
00156 inline const size_t& numberOfFaces() const
00157 {
00158 return (*__facesSet).numberOfFaces();
00159 }
00160
00162 inline const size_t& numberOfCells() const
00163 {
00164 return (*__cells).size();
00165 }
00166
00167 size_t cellNumber(const Hexahedron& h) const
00168 {
00169 return (*__cells).number(h);
00170 }
00171
00172 typedef Mesh::T_iterator<MeshOfHexahedra, Hexahedron> iterator;
00173 typedef Mesh::T_iterator<const MeshOfHexahedra, const Hexahedron> const_iterator;
00174
00175 void buildLocalizationTools();
00176
00177 MeshOfHexahedra::const_iterator find(const double& x,
00178 const double& y,
00179 const double& z) const;
00180
00181 MeshOfHexahedra::const_iterator find(const TinyVector<3>& X) const
00182 {
00183 return find(X[0], X[1], X[2]);
00184 }
00185
00193 inline Hexahedron& cell(const size_t& i)
00194 {
00195 return (*__cells)[i];
00196 }
00197
00205 inline const Hexahedron& cell(const size_t& i) const
00206 {
00207 return (*__cells)[i];
00208 }
00209
00215 const Connectivity<MeshOfHexahedra>& connectivity() const
00216 {
00217 return __connectivity;
00218 }
00219
00225 Connectivity<MeshOfHexahedra>& connectivity()
00226 {
00227 return __connectivity;
00228 }
00229
00237 MeshOfHexahedra(const size_t& numberOfVertices,
00238 const size_t& numberOfCells)
00239 : Mesh(Mesh::hexahedraMesh,
00240 Mesh::volume,
00241 numberOfVertices),
00242 __cells(new Vector<Hexahedron>(numberOfCells)),
00243 __borderMesh(0),
00244 __facesSet(0),
00245 __connectivity(*this)
00246 {
00247 this->buildLocalizationTools();
00248 }
00249
00259 MeshOfHexahedra(ReferenceCounting<VerticesSet> vertices,
00260 ReferenceCounting<VerticesCorrespondance> correspondances,
00261 ReferenceCounting<Vector<Hexahedron> > hexahedra,
00262 ReferenceCounting<BorderMeshType> borderMesh)
00263 : Mesh(Mesh::hexahedraMesh,
00264 Mesh::volume,
00265 vertices,
00266 correspondances),
00267 __cells(hexahedra),
00268 __borderMesh(borderMesh),
00269 __facesSet(0),
00270 __connectivity(*this)
00271 {
00272 this->buildLocalizationTools();
00273 }
00274
00283 MeshOfHexahedra(ReferenceCounting<VerticesSet> vertices,
00284 ReferenceCounting<VerticesCorrespondance> correspondances,
00285 ReferenceCounting<Vector<Hexahedron> > hexahedra)
00286 : Mesh(Mesh::hexahedraMesh,
00287 Mesh::volume,
00288 vertices,
00289 correspondances),
00290 __cells(hexahedra),
00291 __borderMesh(0),
00292 __facesSet(0),
00293 __connectivity(*this)
00294 {
00295 this->buildLocalizationTools();
00296 }
00297
00303 ~MeshOfHexahedra()
00304 {
00305 ;
00306 }
00307 };
00308
00309 #endif // MESH_OF_HEXAHEDRA_HPP