EdgeSetTopologyContainer.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 #ifndef SOFA_COMPONENT_TOPOLOGY_EDGESETTOPOLOGYCONTAINER_H
00026 #define SOFA_COMPONENT_TOPOLOGY_EDGESETTOPOLOGYCONTAINER_H
00027 
00028 #include <sofa/component/topology/PointSetTopologyContainer.h>
00029 
00030 namespace sofa
00031 {
00032 
00033 namespace component
00034 {
00035 
00036 namespace topology
00037 {   
00038     using core::componentmodel::topology::BaseMeshTopology;
00039 
00040     typedef BaseMeshTopology::PointID           PointID;
00041     typedef BaseMeshTopology::EdgeID            EdgeID;
00042     typedef BaseMeshTopology::Edge              Edge;
00043     typedef BaseMeshTopology::SeqEdges          SeqEdges;
00044     typedef BaseMeshTopology::VertexEdges       VertexEdges;
00045 
00047     class EdgeSetTopologyContainer : public PointSetTopologyContainer 
00048     {
00049         friend class EdgeSetTopologyModifier;
00050 
00051     public:        
00052         EdgeSetTopologyContainer();
00053 
00054         EdgeSetTopologyContainer(const sofa::helper::vector< Edge > &edges);
00055 
00056         virtual ~EdgeSetTopologyContainer() {}
00057 
00060         virtual void clear();
00061         virtual void addEdge( int a, int b );
00063 
00064         virtual void init();
00065 
00068 
00069         virtual const SeqEdges& getEdges()
00070         {
00071             return getEdgeArray();
00072         }
00073 
00077         virtual const VertexEdges& getEdgeVertexShell(PointID i);
00078 
00082         virtual int getEdgeIndex(PointID v1, PointID v2);
00083 
00085 
00090         virtual bool checkTopology() const;
00091 
00095         unsigned int getNumberOfEdges() const; 
00096 
00100         virtual const sofa::helper::vector<Edge> &getEdgeArray();
00101 
00102 
00106         virtual const sofa::helper::vector< sofa::helper::vector<unsigned int> > &getEdgeVertexShellArray();
00107 
00108 
00112         virtual int getNumberConnectedComponents(sofa::helper::vector<unsigned int>& components); 
00113 
00114         inline friend std::ostream& operator<< (std::ostream& out, const EdgeSetTopologyContainer& t)
00115         {
00116             out << t.m_edge.size();
00117             for (unsigned int i=0; i<t.m_edge.size(); i++)
00118                 out << " " << t.m_edge[i][0] << " " << t.m_edge[i][1] ;
00119 
00120             return out;
00121         }
00122 
00124         inline friend std::istream& operator>>(std::istream& in, EdgeSetTopologyContainer& t)
00125         {
00126             unsigned int s;
00127             in >> s;
00128             for (unsigned int i=0; i<s; i++)
00129             {
00130                 Edge T; in >> T;
00131                 t.m_edge.push_back(T);
00132             }
00133             return in;
00134         }
00135 
00139         virtual sofa::helper::vector< unsigned int > &getEdgeVertexShellForModification(const unsigned int i); 
00140 
00145         virtual void createEdgeSetArray();
00146 
00153         virtual void createEdgeVertexShellArray();
00154 
00155         bool hasEdges() const;
00156 
00157         bool hasEdgeVertexShell() const;
00158 
00159         void clearEdges();
00160         
00161         void clearEdgeVertexShell();
00162 
00163     protected:
00164         /*** The array that stores the set of edges in the edge set */
00165         sofa::helper::vector<Edge> m_edge;
00166 
00168         sofa::helper::vector< sofa::helper::vector< unsigned int > > m_edgeVertexShell;
00169 
00170         virtual void loadFromMeshLoader(sofa::component::MeshLoader* loader);
00171     };
00172 
00173 } // namespace topology
00174 
00175 } // namespace component
00176 
00177 } // namespace sofa
00178 
00179 #endif

Generated on Sun Nov 23 03:43:31 2008 for Sofa by  doxygen 1.5.7.1