HexahedronSetTopologyContainer.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                               SOFA :: Modules                               *
00020 *                                                                             *
00021 * Authors: The SOFA Team and external contributors (see Authors.txt)          *
00022 *                                                                             *
00023 * Contact information: contact@sofa-framework.org                             *
00024 ******************************************************************************/
00025 
00026 // CONVENTION : indices ordering for the vertices of an hexahedron :
00027 //
00028 //     Y  3---------2
00029 //     ^ /         /|
00030 //     |/         / |
00031 //     7---------6  |
00032 //     |         |  |
00033 //     |  0------|--1
00034 //     | /       | /
00035 //     |/        |/
00036 //     4---------5-->X
00037 //    /
00038 //   /
00039 //  Z
00040 
00041 #ifndef SOFA_COMPONENT_TOPOLOGY_HEXAHEDRONSETTOPOLOGYCONTAINER_H
00042 #define SOFA_COMPONENT_TOPOLOGY_HEXAHEDRONSETTOPOLOGYCONTAINER_H
00043 
00044 #include <sofa/component/topology/QuadSetTopologyContainer.h>
00045 
00046 namespace sofa
00047 {
00048 namespace component
00049 {
00050 namespace topology
00051 {
00052     class HexahedronSetTopologyModifier;
00053 
00054     using core::componentmodel::topology::BaseMeshTopology;
00055 
00056     typedef BaseMeshTopology::PointID           PointID;
00057     typedef BaseMeshTopology::EdgeID            EdgeID;
00058     typedef BaseMeshTopology::TriangleID        QuadID;
00059     typedef BaseMeshTopology::HexaID            HexaID;
00060     typedef BaseMeshTopology::Edge              Edge;
00061     typedef BaseMeshTopology::Quad              Quad;
00062     typedef BaseMeshTopology::Hexa              Hexa;
00063     typedef BaseMeshTopology::SeqHexas          SeqHexas;
00064     typedef BaseMeshTopology::VertexHexas       VertexHexas;
00065     typedef BaseMeshTopology::EdgeHexas         EdgeHexas;
00066     typedef BaseMeshTopology::QuadHexas         QuadHexas;
00067     typedef BaseMeshTopology::HexaEdges         HexaEdges;
00068     typedef BaseMeshTopology::HexaQuads         HexaQuads;
00069 
00070     typedef Hexa        Hexahedron;
00071     typedef HexaEdges   HexahedronEdges;
00072     typedef HexaQuads   HexahedronQuads;
00073 
00075     class HexahedronSetTopologyContainer : public QuadSetTopologyContainer 
00076     {
00077         friend class HexahedronSetTopologyModifier;
00078         
00079     public:
00080         typedef Hexa        Hexahedron;
00081         typedef HexaEdges   HexahedronEdges;
00082         typedef HexaQuads   HexahedronQuads;
00083 
00084         HexahedronSetTopologyContainer();
00085 
00086         HexahedronSetTopologyContainer(const sofa::helper::vector< Hexahedron > &hexahedra);
00087 
00088         virtual ~HexahedronSetTopologyContainer() {}
00089 
00092         virtual void clear();
00093         virtual void addHexa( int a, int b, int c, int d, int e, int f, int g, int h );
00095 
00096         virtual void init();
00097 
00100 
00101         const SeqHexas& getHexas()   
00102         {
00103             return getHexahedronArray(); 
00104         }
00105         
00107         const HexaEdges& getEdgeHexaShell(HexaID i)
00108         {
00109             return getHexahedronEdges(i); 
00110         }
00111 
00113         const HexaQuads& getQuadHexaShell(HexaID i) 
00114         {
00115             return getHexahedronQuads(i); 
00116         }
00117 
00119         const VertexHexas& getHexaVertexShell(PointID i)
00120         {
00121             return getHexahedronVertexShell(i); 
00122         }
00123         
00125         const EdgeHexas& getHexaEdgeShell(EdgeID i)
00126         { 
00127             return getHexahedronEdgeShell(i); 
00128         }
00129 
00131         const QuadHexas& getHexaQuadShell(QuadID i)
00132         { 
00133             return getHexahedronQuadShell(i); 
00134         }       
00135 
00137         virtual int getHexahedronIndex(PointID v1, PointID v2, PointID v3, PointID v4, 
00138                                     PointID v5, PointID v6, PointID v7, PointID v8);
00139 
00141 
00146         virtual bool checkTopology() const;
00147 
00151         const sofa::helper::vector<Hexahedron> &getHexahedronArray();
00152 
00156         const Hexahedron &getHexahedron(const unsigned int i);
00157 
00161         unsigned int getNumberOfHexahedra() const;
00162 
00166         const sofa::helper::vector< sofa::helper::vector<unsigned int> > &getHexahedronVertexShellArray() ;
00167 
00171         const sofa::helper::vector< unsigned int > &getHexahedronVertexShell(const unsigned int i) ;
00172 
00176         const sofa::helper::vector< HexahedronEdges > &getHexahedronEdgeArray() ;
00177 
00181         const HexahedronEdges &getHexahedronEdges(const unsigned int i) ;
00182 
00186         Edge getLocalHexahedronEdges (const unsigned int i) const;
00187 
00191         const sofa::helper::vector< HexahedronQuads > &getHexahedronQuadArray() ;
00192 
00196         const HexahedronQuads &getHexahedronQuads(const unsigned int i) ;
00197 
00201         const sofa::helper::vector< sofa::helper::vector<unsigned int> > &getHexahedronEdgeShellArray() ;
00202 
00206         const sofa::helper::vector< unsigned int > &getHexahedronEdgeShell(const unsigned int i) ;
00207 
00208 
00212         const sofa::helper::vector< sofa::helper::vector<unsigned int> > &getHexahedronQuadShellArray() ;
00213 
00217         const sofa::helper::vector< unsigned int > &getHexahedronQuadShell(const unsigned int i) ;
00218 
00220         int getVertexIndexInHexahedron(Hexahedron &t,unsigned int vertexIndex) const;
00221 
00223         int getEdgeIndexInHexahedron(const HexahedronEdges &t,unsigned int edgeIndex) const;
00224 
00226         int getQuadIndexInHexahedron(const HexahedronQuads &t,unsigned int quadIndex) const;
00227 
00228         inline friend std::ostream& operator<< (std::ostream& out, const HexahedronSetTopologyContainer& t)
00229         {
00230             out  << t.m_hexahedron<< " "
00231                 << t.m_hexahedronEdge<< " "
00232                 << t.m_hexahedronQuad;
00233 
00234             out << " "<< t.m_hexahedronVertexShell.size();
00235             for (unsigned int i=0;i<t.m_hexahedronVertexShell.size();i++)
00236             {
00237                 out << " " << t.m_hexahedronVertexShell[i];
00238             }
00239             out <<" "<< t.m_hexahedronEdgeShell.size();
00240             for (unsigned int i=0;i<t.m_hexahedronEdgeShell.size();i++)
00241             {
00242                 out << " " << t.m_hexahedronEdgeShell[i];
00243             }
00244             out <<" "<< t.m_hexahedronQuadShell.size();
00245             for (unsigned int i=0;i<t.m_hexahedronQuadShell.size();i++)
00246             {
00247                 out << " " << t.m_hexahedronQuadShell[i];
00248             }
00249             return out;
00250         }
00251 
00252         inline friend std::istream& operator>>(std::istream& in, HexahedronSetTopologyContainer& t)
00253         {
00254             unsigned int s;
00255             sofa::helper::vector< unsigned int > value;
00256 
00257 
00258             in >> t.m_hexahedron >> t.m_hexahedronEdge >> t.m_hexahedronQuad;
00259 
00260 
00261             in >> s;
00262             for (unsigned int i=0;i<s;i++)
00263             {
00264                 in >> value;
00265                 t.m_hexahedronVertexShell.push_back(value);
00266             }
00267             in >> s;
00268             for (unsigned int i=0;i<s;i++)
00269             {
00270                 in >> value;
00271                 t.m_hexahedronEdgeShell.push_back(value);
00272             }
00273             in >> s;
00274             for (unsigned int i=0;i<s;i++)
00275             {
00276                 in >> value;
00277                 t.m_hexahedronQuadShell.push_back(value);
00278             }
00279             return in;
00280         }
00281 
00282     protected:
00287         virtual void createEdgeSetArray();
00288 
00293         virtual void createQuadSetArray();
00294 
00299         virtual void createHexahedronSetArray();
00300 
00301         bool hasHexahedra() const;
00302 
00303         bool hasHexahedronEdges() const;
00304 
00305         bool hasHexahedronQuads() const;
00306 
00307         bool hasHexahedronVertexShell() const;
00308 
00309         bool hasHexahedronEdgeShell() const;
00310 
00311         bool hasHexahedronQuadShell() const;
00312 
00313         void clearHexahedra();
00314 
00315         void clearHexahedronEdges();
00316 
00317         void clearHexahedronQuads();
00318 
00319         void clearHexahedronVertexShell();
00320 
00321         void clearHexahedronEdgeShell();
00322 
00323         void clearHexahedronQuadShell();
00324 
00325     private:
00331         void createHexahedronEdgeArray();
00332 
00338         void createHexahedronQuadArray();
00339 
00345         void createHexahedronVertexShellArray();
00346 
00352         void createHexahedronEdgeShellArray();
00353 
00359         void createHexahedronQuadShellArray();
00360 
00364         sofa::helper::vector< unsigned int > &getHexahedronVertexShellForModification(const unsigned int vertexIndex); 
00365 
00369         sofa::helper::vector< unsigned int > &getHexahedronEdgeShellForModification(const unsigned int edgeIndex); 
00370 
00371     protected:
00373         sofa::helper::vector<Hexahedron> m_hexahedron;
00375         sofa::helper::vector<HexahedronEdges> m_hexahedronEdge;
00377         sofa::helper::vector<HexahedronQuads> m_hexahedronQuad;
00378 
00380         sofa::helper::vector< sofa::helper::vector< unsigned int > > m_hexahedronVertexShell;
00382         sofa::helper::vector< sofa::helper::vector< unsigned int > > m_hexahedronEdgeShell;
00384         sofa::helper::vector< sofa::helper::vector< unsigned int > > m_hexahedronQuadShell;
00385         virtual void loadFromMeshLoader(sofa::component::MeshLoader* loader);
00386     };
00387 
00388 } // namespace topology
00389 
00390 } // namespace component
00391 
00392 } // namespace sofa
00393 
00394 #endif

Generated on Sun Nov 23 03:44:15 2008 for Sofa by  doxygen 1.5.7.1