TriangleSetTopologyChange.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_TRIANGLESETTOPOLOGYCHANGE_H
00026 #define SOFA_COMPONENT_TOPOLOGY_TRIANGLESETTOPOLOGYCHANGE_H
00027 
00028 #include <sofa/core/componentmodel/topology/Topology.h>     // TopologyChange
00029 #include <sofa/helper/vector.h>
00030 
00031 namespace sofa
00032 {
00033 namespace component
00034 {
00035 namespace topology
00036 {
00037     using core::componentmodel::topology::BaseMeshTopology;
00038     typedef BaseMeshTopology::Triangle Triangle;
00039 
00041     class TrianglesAdded : public core::componentmodel::topology::TopologyChange  
00042     {
00043     public:
00044         TrianglesAdded(const unsigned int nT) 
00045         : core::componentmodel::topology::TopologyChange(core::componentmodel::topology::TRIANGLESADDED), 
00046         nTriangles(nT)
00047         { }
00048 
00049         TrianglesAdded(const unsigned int nT, 
00050                         const sofa::helper::vector< Triangle >& _triangleArray,
00051                         const sofa::helper::vector< unsigned int >& trianglesIndex) 
00052         : core::componentmodel::topology::TopologyChange(core::componentmodel::topology::TRIANGLESADDED), 
00053         nTriangles(nT), 
00054         triangleArray(_triangleArray), 
00055         triangleIndexArray(trianglesIndex)
00056         { }
00057 
00058         TrianglesAdded(const unsigned int nT, 
00059                         const sofa::helper::vector< Triangle >& _triangleArray,
00060                         const sofa::helper::vector< unsigned int >& trianglesIndex,
00061                         const sofa::helper::vector< sofa::helper::vector< unsigned int > >& ancestors,
00062                         const sofa::helper::vector< sofa::helper::vector< double > >& baryCoefs) 
00063         : core::componentmodel::topology::TopologyChange(core::componentmodel::topology::TRIANGLESADDED), 
00064         nTriangles(nT), 
00065         triangleArray(_triangleArray), 
00066         triangleIndexArray(trianglesIndex),
00067         ancestorsList(ancestors), 
00068         coefs(baryCoefs) 
00069         { }
00070 
00071         unsigned int getNbAddedTriangles() const 
00072         {
00073             return nTriangles;
00074         }
00075 
00076         const sofa::helper::vector<unsigned int> &getArray() const 
00077         {
00078             return triangleIndexArray;
00079         }   
00080 
00081         const Triangle &getTriangle(const unsigned int i)
00082         {
00083             return triangleArray[i];
00084         }
00085 
00086     public:
00087         unsigned int nTriangles;
00088         sofa::helper::vector< Triangle > triangleArray;
00089         sofa::helper::vector< unsigned int > triangleIndexArray;
00090         sofa::helper::vector< sofa::helper::vector< unsigned int > > ancestorsList;
00091         sofa::helper::vector< sofa::helper::vector< double > > coefs;               
00092     };
00093 
00095     class TrianglesRemoved : public core::componentmodel::topology::TopologyChange  
00096     {
00097     public:
00098         TrianglesRemoved(const sofa::helper::vector<unsigned int> _tArray) 
00099         : core::componentmodel::topology::TopologyChange(core::componentmodel::topology::TRIANGLESREMOVED), 
00100         removedTrianglesArray(_tArray) 
00101         {}
00102 
00103         unsigned int getNbRemovedTriangles() const 
00104         {
00105             return removedTrianglesArray.size();
00106         }
00107 
00108         const sofa::helper::vector<unsigned int> &getArray() const 
00109         {
00110             return removedTrianglesArray;
00111         }
00112 
00113         unsigned int &getTriangleIndices(const unsigned int i)
00114         {
00115             return removedTrianglesArray[i];
00116         }
00117     
00118     protected:
00119         sofa::helper::vector<unsigned int> removedTrianglesArray;
00120     };
00121 
00122 } // namespace topology
00123 
00124 } // namespace component
00125 
00126 } // namespace sofa
00127 
00128 #endif

Generated on Sun Nov 23 03:47:40 2008 for Sofa by  doxygen 1.5.7.1