Back to index

salome-smesh  6.5.0
SMDS_Mesh.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH SMDS : implementaion of Salome mesh data structure
00024 //  File   : SMDS_Mesh.hxx
00025 //  Module : SMESH
00026 //
00027 #ifndef _SMDS_Mesh_HeaderFile
00028 #define _SMDS_Mesh_HeaderFile
00029 
00030 #include "SMESH_SMDS.hxx"
00031 
00032 #include "SMDS_MeshNode.hxx"
00033 #include "SMDS_MeshCell.hxx"
00034 #include "SMDS_Mesh0DElement.hxx"
00035 #include "SMDS_MeshEdge.hxx"
00036 #include "SMDS_MeshFace.hxx"
00037 #include "SMDS_MeshVolume.hxx"
00038 #include "SMDS_MeshNodeIDFactory.hxx"
00039 #include "SMDS_MeshElementIDFactory.hxx"
00040 #include "SMDS_MeshInfo.hxx"
00041 #include "SMDS_ElemIterator.hxx"
00042 #include "SMDS_VolumeOfNodes.hxx"
00043 #include "SMDS_VtkEdge.hxx"
00044 #include "SMDS_VtkFace.hxx"
00045 #include "SMDS_VtkVolume.hxx"
00046 #include "ObjectPool.hxx"
00047 #include "SMDS_UnstructuredGrid.hxx"
00048 
00049 #include <boost/shared_ptr.hpp>
00050 #include <set>
00051 #include <list>
00052 #include <vector>
00053 #include <vtkSystemIncludes.h>
00054 #include <cassert>
00055 
00056 #include "Utils_SALOME_Exception.hxx"
00057 #define MYASSERT(val) if (!(val)) throw SALOME_Exception(LOCALIZED("assertion not verified"));
00058 
00059 class SMDS_EXPORT SMDS_Mesh:public SMDS_MeshObject{
00060 public:
00061   friend class SMDS_MeshIDFactory;
00062   friend class SMDS_MeshNodeIDFactory;
00063   friend class SMDS_MeshElementIDFactory;
00064   friend class SMDS_MeshVolumeVtkNodes;
00065   friend class SMDS_MeshNode;
00066 
00067   SMDS_Mesh();
00068   
00070   static std::vector<SMDS_Mesh*> _meshList;
00071 
00073   inline SMDS_UnstructuredGrid* getGrid() {return myGrid; }
00074   inline int getMeshId() {return myMeshId; }
00075 
00076   virtual SMDS_NodeIteratorPtr      nodesIterator     (bool idInceasingOrder=false) const;
00077   virtual SMDS_0DElementIteratorPtr elements0dIterator(bool idInceasingOrder=false) const;
00078   virtual SMDS_EdgeIteratorPtr      edgesIterator     (bool idInceasingOrder=false) const;
00079   virtual SMDS_FaceIteratorPtr      facesIterator     (bool idInceasingOrder=false) const;
00080   virtual SMDS_VolumeIteratorPtr    volumesIterator   (bool idInceasingOrder=false) const;
00081 
00082   virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type=SMDSAbs_All) const;
00083 
00084   SMDSAbs_ElementType GetElementType( const int id, const bool iselem ) const;
00085 
00086   SMDS_Mesh *AddSubMesh();
00087 
00088   virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
00089   virtual SMDS_MeshNode* AddNode(double x, double y, double z);
00090 
00091   virtual SMDS_Mesh0DElement* Add0DElementWithID(int n, int ID);
00092   virtual SMDS_Mesh0DElement* Add0DElementWithID(const SMDS_MeshNode * n, int ID);
00093   virtual SMDS_Mesh0DElement* Add0DElement      (const SMDS_MeshNode * n);
00094 
00095   virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
00096   virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
00097                                        const SMDS_MeshNode * n2,
00098                                        int ID);
00099   virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
00100                                  const SMDS_MeshNode * n2);
00101 
00102   // 2d order edge with 3 nodes: n12 - node between n1 and n2
00103   virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int n12, int ID);
00104   virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
00105                                        const SMDS_MeshNode * n2,
00106                                        const SMDS_MeshNode * n12,
00107                                        int ID);
00108   virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
00109                                  const SMDS_MeshNode * n2,
00110                                  const SMDS_MeshNode * n12);
00111 
00112   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
00113   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
00114                                        const SMDS_MeshNode * n2,
00115                                        const SMDS_MeshNode * n3,
00116                                        int ID);
00117   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
00118                                  const SMDS_MeshNode * n2,
00119                                  const SMDS_MeshNode * n3);
00120 
00121   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4, int ID);
00122   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
00123                                        const SMDS_MeshNode * n2,
00124                                        const SMDS_MeshNode * n3,
00125                                        const SMDS_MeshNode * n4,
00126                                        int ID);
00127   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
00128                                  const SMDS_MeshNode * n2,
00129                                  const SMDS_MeshNode * n3,
00130                                  const SMDS_MeshNode * n4);
00131 
00132   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
00133                                        const SMDS_MeshEdge * e2,
00134                                        const SMDS_MeshEdge * e3, int ID);
00135   virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
00136                                  const SMDS_MeshEdge * e2,
00137                                  const SMDS_MeshEdge * e3);
00138 
00139   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshEdge * e1,
00140                                        const SMDS_MeshEdge * e2,
00141                                        const SMDS_MeshEdge * e3,
00142                                        const SMDS_MeshEdge * e4, int ID);
00143   virtual SMDS_MeshFace* AddFace(const SMDS_MeshEdge * e1,
00144                                  const SMDS_MeshEdge * e2,
00145                                  const SMDS_MeshEdge * e3,
00146                                  const SMDS_MeshEdge * e4);
00147 
00148   // 2d order triangle of 6 nodes
00149   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
00150                                        int n12,int n23,int n31, int ID);
00151   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
00152                                        const SMDS_MeshNode * n2,
00153                                        const SMDS_MeshNode * n3,
00154                                        const SMDS_MeshNode * n12,
00155                                        const SMDS_MeshNode * n23,
00156                                        const SMDS_MeshNode * n31,
00157                                        int ID);
00158   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
00159                                  const SMDS_MeshNode * n2,
00160                                  const SMDS_MeshNode * n3,
00161                                  const SMDS_MeshNode * n12,
00162                                  const SMDS_MeshNode * n23,
00163                                  const SMDS_MeshNode * n31);
00164 
00165   // 2d order quadrangle
00166   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
00167                                        int n12,int n23,int n34,int n41, int ID);
00168   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
00169                                        const SMDS_MeshNode * n2,
00170                                        const SMDS_MeshNode * n3,
00171                                        const SMDS_MeshNode * n4,
00172                                        const SMDS_MeshNode * n12,
00173                                        const SMDS_MeshNode * n23,
00174                                        const SMDS_MeshNode * n34,
00175                                        const SMDS_MeshNode * n41,
00176                                        int ID);
00177   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
00178                                  const SMDS_MeshNode * n2,
00179                                  const SMDS_MeshNode * n3,
00180                                  const SMDS_MeshNode * n4,
00181                                  const SMDS_MeshNode * n12,
00182                                  const SMDS_MeshNode * n23,
00183                                  const SMDS_MeshNode * n34,
00184                                  const SMDS_MeshNode * n41);
00185 
00186   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
00187                                        int n12,int n23,int n34,int n41, int nCenter, int ID);
00188   virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
00189                                        const SMDS_MeshNode * n2,
00190                                        const SMDS_MeshNode * n3,
00191                                        const SMDS_MeshNode * n4,
00192                                        const SMDS_MeshNode * n12,
00193                                        const SMDS_MeshNode * n23,
00194                                        const SMDS_MeshNode * n34,
00195                                        const SMDS_MeshNode * n41,
00196                                        const SMDS_MeshNode * nCenter,
00197                                        int ID);
00198   virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
00199                                  const SMDS_MeshNode * n2,
00200                                  const SMDS_MeshNode * n3,
00201                                  const SMDS_MeshNode * n4,
00202                                  const SMDS_MeshNode * n12,
00203                                  const SMDS_MeshNode * n23,
00204                                  const SMDS_MeshNode * n34,
00205                                  const SMDS_MeshNode * n41,
00206                                  const SMDS_MeshNode * nCenter);
00207 
00208   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
00209   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00210                                            const SMDS_MeshNode * n2,
00211                                            const SMDS_MeshNode * n3,
00212                                            const SMDS_MeshNode * n4,
00213                                            int ID);
00214   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00215                                      const SMDS_MeshNode * n2,
00216                                      const SMDS_MeshNode * n3,
00217                                      const SMDS_MeshNode * n4);
00218 
00219   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
00220                                            int n5, int ID);
00221   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00222                                            const SMDS_MeshNode * n2,
00223                                            const SMDS_MeshNode * n3,
00224                                            const SMDS_MeshNode * n4,
00225                                            const SMDS_MeshNode * n5,
00226                                            int ID);
00227   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00228                                      const SMDS_MeshNode * n2,
00229                                      const SMDS_MeshNode * n3,
00230                                      const SMDS_MeshNode * n4,
00231                                      const SMDS_MeshNode * n5);
00232 
00233   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
00234                                            int n5, int n6, int ID);
00235   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00236                                            const SMDS_MeshNode * n2,
00237                                            const SMDS_MeshNode * n3,
00238                                            const SMDS_MeshNode * n4,
00239                                            const SMDS_MeshNode * n5,
00240                                            const SMDS_MeshNode * n6,
00241                                            int ID);
00242   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00243                                      const SMDS_MeshNode * n2,
00244                                      const SMDS_MeshNode * n3,
00245                                      const SMDS_MeshNode * n4,
00246                                      const SMDS_MeshNode * n5,
00247                                      const SMDS_MeshNode * n6);
00248 
00249   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
00250                                            int n5, int n6, int n7, int n8, int ID);
00251   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00252                                            const SMDS_MeshNode * n2,
00253                                            const SMDS_MeshNode * n3,
00254                                            const SMDS_MeshNode * n4,
00255                                            const SMDS_MeshNode * n5,
00256                                            const SMDS_MeshNode * n6,
00257                                            const SMDS_MeshNode * n7,
00258                                            const SMDS_MeshNode * n8,
00259                                            int ID);
00260   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00261                                      const SMDS_MeshNode * n2,
00262                                      const SMDS_MeshNode * n3,
00263                                      const SMDS_MeshNode * n4,
00264                                      const SMDS_MeshNode * n5,
00265                                      const SMDS_MeshNode * n6,
00266                                      const SMDS_MeshNode * n7,
00267                                      const SMDS_MeshNode * n8);
00268 
00269   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
00270                                            const SMDS_MeshFace * f2,
00271                                            const SMDS_MeshFace * f3,
00272                                            const SMDS_MeshFace * f4, int ID);
00273   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
00274                                      const SMDS_MeshFace * f2,
00275                                      const SMDS_MeshFace * f3,
00276                                      const SMDS_MeshFace * f4);
00277 
00278   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
00279                                            const SMDS_MeshFace * f2,
00280                                            const SMDS_MeshFace * f3,
00281                                            const SMDS_MeshFace * f4,
00282                                            const SMDS_MeshFace * f5, int ID);
00283   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
00284                                      const SMDS_MeshFace * f2,
00285                                      const SMDS_MeshFace * f3,
00286                                      const SMDS_MeshFace * f4,
00287                                      const SMDS_MeshFace * f5);
00288 
00289   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshFace * f1,
00290                                            const SMDS_MeshFace * f2,
00291                                            const SMDS_MeshFace * f3,
00292                                            const SMDS_MeshFace * f4,
00293                                            const SMDS_MeshFace * f5,
00294                                            const SMDS_MeshFace * f6, int ID);
00295   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshFace * f1,
00296                                      const SMDS_MeshFace * f2,
00297                                      const SMDS_MeshFace * f3,
00298                                      const SMDS_MeshFace * f4,
00299                                      const SMDS_MeshFace * f5,
00300                                      const SMDS_MeshFace * f6);
00301 
00302   // hexagonal prism
00303   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6,
00304                                            int n7, int n8, int n9, int n10, int n11, int n12,
00305                                            int ID);
00306   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00307                                            const SMDS_MeshNode * n2,
00308                                            const SMDS_MeshNode * n3,
00309                                            const SMDS_MeshNode * n4,
00310                                            const SMDS_MeshNode * n5,
00311                                            const SMDS_MeshNode * n6,
00312                                            const SMDS_MeshNode * n7,
00313                                            const SMDS_MeshNode * n8,
00314                                            const SMDS_MeshNode * n9,
00315                                            const SMDS_MeshNode * n10,
00316                                            const SMDS_MeshNode * n11,
00317                                            const SMDS_MeshNode * n12,
00318                                            int ID);
00319   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00320                                      const SMDS_MeshNode * n2,
00321                                      const SMDS_MeshNode * n3,
00322                                      const SMDS_MeshNode * n4,
00323                                      const SMDS_MeshNode * n5,
00324                                      const SMDS_MeshNode * n6,
00325                                      const SMDS_MeshNode * n7,
00326                                      const SMDS_MeshNode * n8,
00327                                      const SMDS_MeshNode * n9,
00328                                      const SMDS_MeshNode * n10,
00329                                      const SMDS_MeshNode * n11,
00330                                      const SMDS_MeshNode * n12);
00331 
00332   // 2d order tetrahedron of 10 nodes
00333   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
00334                                            int n12,int n23,int n31,
00335                                            int n14,int n24,int n34, int ID);
00336   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00337                                            const SMDS_MeshNode * n2,
00338                                            const SMDS_MeshNode * n3,
00339                                            const SMDS_MeshNode * n4,
00340                                            const SMDS_MeshNode * n12,
00341                                            const SMDS_MeshNode * n23,
00342                                            const SMDS_MeshNode * n31,
00343                                            const SMDS_MeshNode * n14,
00344                                            const SMDS_MeshNode * n24,
00345                                            const SMDS_MeshNode * n34,
00346                                            int ID);
00347   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00348                                      const SMDS_MeshNode * n2,
00349                                      const SMDS_MeshNode * n3,
00350                                      const SMDS_MeshNode * n4,
00351                                      const SMDS_MeshNode * n12,
00352                                      const SMDS_MeshNode * n23,
00353                                      const SMDS_MeshNode * n31,
00354                                      const SMDS_MeshNode * n14,
00355                                      const SMDS_MeshNode * n24,
00356                                      const SMDS_MeshNode * n34);
00357 
00358   // 2d order pyramid of 13 nodes
00359   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
00360                                            int n12,int n23,int n34,int n41,
00361                                            int n15,int n25,int n35,int n45,
00362                                            int ID);
00363   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00364                                            const SMDS_MeshNode * n2,
00365                                            const SMDS_MeshNode * n3,
00366                                            const SMDS_MeshNode * n4,
00367                                            const SMDS_MeshNode * n5,
00368                                            const SMDS_MeshNode * n12,
00369                                            const SMDS_MeshNode * n23,
00370                                            const SMDS_MeshNode * n34,
00371                                            const SMDS_MeshNode * n41,
00372                                            const SMDS_MeshNode * n15,
00373                                            const SMDS_MeshNode * n25,
00374                                            const SMDS_MeshNode * n35,
00375                                            const SMDS_MeshNode * n45,
00376                                            int ID);
00377   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00378                                      const SMDS_MeshNode * n2,
00379                                      const SMDS_MeshNode * n3,
00380                                      const SMDS_MeshNode * n4,
00381                                      const SMDS_MeshNode * n5,
00382                                      const SMDS_MeshNode * n12,
00383                                      const SMDS_MeshNode * n23,
00384                                      const SMDS_MeshNode * n34,
00385                                      const SMDS_MeshNode * n41,
00386                                      const SMDS_MeshNode * n15,
00387                                      const SMDS_MeshNode * n25,
00388                                      const SMDS_MeshNode * n35,
00389                                      const SMDS_MeshNode * n45);
00390 
00391   // 2d order Pentahedron with 15 nodes
00392   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3,
00393                                            int n4, int n5, int n6,
00394                                            int n12,int n23,int n31,
00395                                            int n45,int n56,int n64,
00396                                            int n14,int n25,int n36,
00397                                            int ID);
00398   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00399                                            const SMDS_MeshNode * n2,
00400                                            const SMDS_MeshNode * n3,
00401                                            const SMDS_MeshNode * n4,
00402                                            const SMDS_MeshNode * n5,
00403                                            const SMDS_MeshNode * n6,
00404                                            const SMDS_MeshNode * n12,
00405                                            const SMDS_MeshNode * n23,
00406                                            const SMDS_MeshNode * n31,
00407                                            const SMDS_MeshNode * n45,
00408                                            const SMDS_MeshNode * n56,
00409                                            const SMDS_MeshNode * n64,
00410                                            const SMDS_MeshNode * n14,
00411                                            const SMDS_MeshNode * n25,
00412                                            const SMDS_MeshNode * n36,
00413                                            int ID);
00414   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00415                                      const SMDS_MeshNode * n2,
00416                                      const SMDS_MeshNode * n3,
00417                                      const SMDS_MeshNode * n4,
00418                                      const SMDS_MeshNode * n5,
00419                                      const SMDS_MeshNode * n6,
00420                                      const SMDS_MeshNode * n12,
00421                                      const SMDS_MeshNode * n23,
00422                                      const SMDS_MeshNode * n31,
00423                                      const SMDS_MeshNode * n45,
00424                                      const SMDS_MeshNode * n56,
00425                                      const SMDS_MeshNode * n64,
00426                                      const SMDS_MeshNode * n14,
00427                                      const SMDS_MeshNode * n25,
00428                                      const SMDS_MeshNode * n36);
00429 
00430   // 2d oreder Hexahedrons with 20 nodes
00431   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
00432                                            int n5, int n6, int n7, int n8,
00433                                            int n12,int n23,int n34,int n41,
00434                                            int n56,int n67,int n78,int n85,
00435                                            int n15,int n26,int n37,int n48,
00436                                            int ID);
00437   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00438                                            const SMDS_MeshNode * n2,
00439                                            const SMDS_MeshNode * n3,
00440                                            const SMDS_MeshNode * n4,
00441                                            const SMDS_MeshNode * n5,
00442                                            const SMDS_MeshNode * n6,
00443                                            const SMDS_MeshNode * n7,
00444                                            const SMDS_MeshNode * n8,
00445                                            const SMDS_MeshNode * n12,
00446                                            const SMDS_MeshNode * n23,
00447                                            const SMDS_MeshNode * n34,
00448                                            const SMDS_MeshNode * n41,
00449                                            const SMDS_MeshNode * n56,
00450                                            const SMDS_MeshNode * n67,
00451                                            const SMDS_MeshNode * n78,
00452                                            const SMDS_MeshNode * n85,
00453                                            const SMDS_MeshNode * n15,
00454                                            const SMDS_MeshNode * n26,
00455                                            const SMDS_MeshNode * n37,
00456                                            const SMDS_MeshNode * n48,
00457                                            int ID);
00458   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00459                                      const SMDS_MeshNode * n2,
00460                                      const SMDS_MeshNode * n3,
00461                                      const SMDS_MeshNode * n4,
00462                                      const SMDS_MeshNode * n5,
00463                                      const SMDS_MeshNode * n6,
00464                                      const SMDS_MeshNode * n7,
00465                                      const SMDS_MeshNode * n8,
00466                                      const SMDS_MeshNode * n12,
00467                                      const SMDS_MeshNode * n23,
00468                                      const SMDS_MeshNode * n34,
00469                                      const SMDS_MeshNode * n41,
00470                                      const SMDS_MeshNode * n56,
00471                                      const SMDS_MeshNode * n67,
00472                                      const SMDS_MeshNode * n78,
00473                                      const SMDS_MeshNode * n85,
00474                                      const SMDS_MeshNode * n15,
00475                                      const SMDS_MeshNode * n26,
00476                                      const SMDS_MeshNode * n37,
00477                                      const SMDS_MeshNode * n48);
00478 
00479   // 2d oreder Hexahedrons with 27 nodes
00480   virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
00481                                            int n5, int n6, int n7, int n8,
00482                                            int n12,int n23,int n34,int n41,
00483                                            int n56,int n67,int n78,int n85,
00484                                            int n15,int n26,int n37,int n48,
00485                                            int n1234,int n1256,int n2367,int n3478,
00486                                            int n1458,int n5678,int nCenter,
00487                                            int ID);
00488   virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
00489                                            const SMDS_MeshNode * n2,
00490                                            const SMDS_MeshNode * n3,
00491                                            const SMDS_MeshNode * n4,
00492                                            const SMDS_MeshNode * n5,
00493                                            const SMDS_MeshNode * n6,
00494                                            const SMDS_MeshNode * n7,
00495                                            const SMDS_MeshNode * n8,
00496                                            const SMDS_MeshNode * n12,
00497                                            const SMDS_MeshNode * n23,
00498                                            const SMDS_MeshNode * n34,
00499                                            const SMDS_MeshNode * n41,
00500                                            const SMDS_MeshNode * n56,
00501                                            const SMDS_MeshNode * n67,
00502                                            const SMDS_MeshNode * n78,
00503                                            const SMDS_MeshNode * n85,
00504                                            const SMDS_MeshNode * n15,
00505                                            const SMDS_MeshNode * n26,
00506                                            const SMDS_MeshNode * n37,
00507                                            const SMDS_MeshNode * n48,
00508                                            const SMDS_MeshNode * n1234,
00509                                            const SMDS_MeshNode * n1256,
00510                                            const SMDS_MeshNode * n2367,
00511                                            const SMDS_MeshNode * n3478,
00512                                            const SMDS_MeshNode * n1458,
00513                                            const SMDS_MeshNode * n5678,
00514                                            const SMDS_MeshNode * nCenter,
00515                                            int ID);
00516   virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
00517                                      const SMDS_MeshNode * n2,
00518                                      const SMDS_MeshNode * n3,
00519                                      const SMDS_MeshNode * n4,
00520                                      const SMDS_MeshNode * n5,
00521                                      const SMDS_MeshNode * n6,
00522                                      const SMDS_MeshNode * n7,
00523                                      const SMDS_MeshNode * n8,
00524                                      const SMDS_MeshNode * n12,
00525                                      const SMDS_MeshNode * n23,
00526                                      const SMDS_MeshNode * n34,
00527                                      const SMDS_MeshNode * n41,
00528                                      const SMDS_MeshNode * n56,
00529                                      const SMDS_MeshNode * n67,
00530                                      const SMDS_MeshNode * n78,
00531                                      const SMDS_MeshNode * n85,
00532                                      const SMDS_MeshNode * n15,
00533                                      const SMDS_MeshNode * n26,
00534                                      const SMDS_MeshNode * n37,
00535                                      const SMDS_MeshNode * n48,
00536                                      const SMDS_MeshNode * n1234,
00537                                      const SMDS_MeshNode * n1256,
00538                                      const SMDS_MeshNode * n2367,
00539                                      const SMDS_MeshNode * n3478,
00540                                      const SMDS_MeshNode * n1458,
00541                                      const SMDS_MeshNode * n5678,
00542                                      const SMDS_MeshNode * nCenter);
00543 
00544   virtual SMDS_MeshFace* AddPolygonalFaceWithID (const std::vector<int> & nodes_ids,
00545                                                  const int                ID);
00546 
00547   virtual SMDS_MeshFace* AddPolygonalFaceWithID (const std::vector<const SMDS_MeshNode*> & nodes,
00548                                                  const int                                 ID);
00549 
00550   virtual SMDS_MeshFace* AddPolygonalFace (const std::vector<const SMDS_MeshNode*> & nodes);
00551 
00552   virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
00553                            (const std::vector<int> & nodes_ids,
00554                             const std::vector<int> & quantities,
00555                             const int                ID);
00556 
00557   virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
00558                            (const std::vector<const SMDS_MeshNode*> & nodes,
00559                             const std::vector<int>                  & quantities,
00560                             const int                                 ID);
00561 
00562   virtual SMDS_MeshVolume* AddPolyhedralVolume
00563                            (const std::vector<const SMDS_MeshNode*> & nodes,
00564                             const std::vector<int>                  & quantities);
00565 
00566   virtual SMDS_MeshVolume* AddVolumeFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds);
00567 
00568   virtual SMDS_MeshVolume* AddVolumeFromVtkIdsWithID(const std::vector<vtkIdType>& vtkNodeIds,
00569                                                      const int ID);
00570 
00571   virtual SMDS_MeshFace* AddFaceFromVtkIds(const std::vector<vtkIdType>& vtkNodeIds);
00572 
00573   virtual SMDS_MeshFace* AddFaceFromVtkIdsWithID(const std::vector<vtkIdType>& vtkNodeIds,
00574                                                      const int ID);
00575 
00576   virtual void RemoveElement(const SMDS_MeshElement *        elem,
00577                              std::list<const SMDS_MeshElement *>& removedElems,
00578                              std::list<const SMDS_MeshElement *>& removedNodes,
00579                              const bool                      removenodes = false);
00580   virtual void RemoveElement(const SMDS_MeshElement * elem, bool removenodes = false);
00581   virtual void RemoveNode(const SMDS_MeshNode * node);
00582   virtual void Remove0DElement(const SMDS_Mesh0DElement * elem0d);
00583   virtual void RemoveEdge(const SMDS_MeshEdge * edge);
00584   virtual void RemoveFace(const SMDS_MeshFace * face);
00585   virtual void RemoveVolume(const SMDS_MeshVolume * volume);
00586 
00591   virtual void RemoveFreeElement(const SMDS_MeshElement * elem);
00592 
00593   virtual void Clear();
00594 
00595   virtual bool RemoveFromParent();
00596   virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
00597 
00598   bool ChangeElementNodes(const SMDS_MeshElement * elem,
00599                           const SMDS_MeshNode    * nodes[],
00600                           const int                nbnodes);
00601   bool ChangePolyhedronNodes(const SMDS_MeshElement *                 elem,
00602                              const std::vector<const SMDS_MeshNode*>& nodes,
00603                              const std::vector<int> &                 quantities);
00604 
00605   virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
00606   // Renumber all nodes or elements.
00607   virtual void compactMesh();
00608 
00609   const SMDS_MeshNode *FindNode(int idnode) const;
00610   const SMDS_MeshNode *FindNodeVtk(int idnode) const;
00611   const SMDS_Mesh0DElement* Find0DElement(int idnode) const;
00612   const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
00613   const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const;
00614   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const;
00615   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const;
00616   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3,
00617                                 int idnode4, int idnode5, int idnode6) const;
00618   const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4,
00619                                 int idnode5, int idnode6, int idnode7, int idnode8) const;
00620   const SMDS_MeshElement *FindElement(int IDelem) const;
00621   static const SMDS_Mesh0DElement* Find0DElement(const SMDS_MeshNode * n);
00622   static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
00623                                        const SMDS_MeshNode * n2);
00624   static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
00625                                        const SMDS_MeshNode * n2,
00626                                        const SMDS_MeshNode * n3);
00627   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
00628                                        const SMDS_MeshNode *n2,
00629                                        const SMDS_MeshNode *n3);
00630   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
00631                                        const SMDS_MeshNode *n2,
00632                                        const SMDS_MeshNode *n3,
00633                                        const SMDS_MeshNode *n4);
00634   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
00635                                        const SMDS_MeshNode *n2,
00636                                        const SMDS_MeshNode *n3,
00637                                        const SMDS_MeshNode *n4,
00638                                        const SMDS_MeshNode *n5,
00639                                        const SMDS_MeshNode *n6);
00640   static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
00641                                        const SMDS_MeshNode *n2,
00642                                        const SMDS_MeshNode *n3,
00643                                        const SMDS_MeshNode *n4,
00644                                        const SMDS_MeshNode *n5,
00645                                        const SMDS_MeshNode *n6,
00646                                        const SMDS_MeshNode *n7,
00647                                        const SMDS_MeshNode *n8);
00648 
00649   const SMDS_MeshFace *FindFace(const std::vector<int>& nodes_ids) const;
00650   static const SMDS_MeshFace* FindFace(const std::vector<const SMDS_MeshNode *>& nodes);
00651   static const SMDS_MeshElement* FindElement(const std::vector<const SMDS_MeshNode *>& nodes,
00652                                              const SMDSAbs_ElementType                 type=SMDSAbs_All,
00653                                              const bool                                noMedium=true);
00654 
00660   static int CheckMemory(const bool doNotRaise=false) throw (std::bad_alloc);
00661 
00662   int MaxNodeID() const;
00663   int MinNodeID() const;
00664   int MaxElementID() const;
00665   int MinElementID() const;
00666 
00667   const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; }
00668 
00669   virtual int NbNodes() const;
00670   virtual int Nb0DElements() const;
00671   virtual int NbEdges() const;
00672   virtual int NbFaces() const;
00673   virtual int NbVolumes() const;
00674   virtual int NbSubMesh() const;
00675 
00676   void DumpNodes() const;
00677   void Dump0DElements() const;
00678   void DumpEdges() const;
00679   void DumpFaces() const;
00680   void DumpVolumes() const;
00681   void DebugStats() const;
00682 
00683   virtual ~SMDS_Mesh();
00684 
00685   bool hasConstructionEdges();
00686   bool hasConstructionFaces();
00687   bool hasInverseElements();
00688   void setConstructionEdges(bool);
00689   void setConstructionFaces(bool);
00690   void setInverseElements(bool);
00691 
00698   bool Contains (const SMDS_MeshElement* elem) const;
00699 
00700   typedef std::vector<SMDS_MeshNode *> SetOfNodes;
00701   typedef std::vector<SMDS_MeshCell *> SetOfCells;
00702 
00703   void updateNodeMinMax();
00704   void updateBoundingBox();
00705   double getMaxDim();
00706   int fromVtkToSmds(int vtkid);
00707 
00708   void incrementNodesCapacity(int nbNodes);
00709   void incrementCellsCapacity(int nbCells);
00710   void adjustStructure();
00711   void dumpGrid(string ficdump="dumpGrid");
00712   static int chunkSize;
00713 
00715   inline void setMyModified() { this->myModified = true; }
00716 
00717   void Modified();
00718   unsigned long GetMTime() const;
00719   bool isCompacted();
00720 
00721 protected:
00722   SMDS_Mesh(SMDS_Mesh * parent);
00723 
00724   SMDS_MeshFace * createTriangle(const SMDS_MeshNode * node1,
00725                                  const SMDS_MeshNode * node2,
00726                                  const SMDS_MeshNode * node3,
00727                                  int ID);
00728   SMDS_MeshFace * createQuadrangle(const SMDS_MeshNode * node1,
00729                                    const SMDS_MeshNode * node2,
00730                                    const SMDS_MeshNode * node3,
00731                                    const SMDS_MeshNode * node4,
00732                                    int ID);
00733 //  SMDS_Mesh0DElement* Find0DElementOrCreate(const SMDS_MeshNode * n);
00734   SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1,
00735                                   const SMDS_MeshNode * n2);
00736   SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
00737                                   const SMDS_MeshNode *n2,
00738                                   const SMDS_MeshNode *n3);
00739   SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
00740                                   const SMDS_MeshNode *n2,
00741                                   const SMDS_MeshNode *n3,
00742                                   const SMDS_MeshNode *n4);
00743 
00744   bool registerElement(int ID, SMDS_MeshElement * element);
00745 
00746   void addChildrenWithNodes(std::set<const SMDS_MeshElement*>& setOfChildren,
00747                             const SMDS_MeshElement * element,
00748                             std::set<const SMDS_MeshElement*>& nodes);
00749 
00750   inline void adjustmyCellsCapacity(int ID)
00751   {
00752     assert(ID >= 0);
00753     myElementIDFactory->adjustMaxId(ID);
00754     if (ID >= myCells.size())
00755       myCells.resize(ID+SMDS_Mesh::chunkSize,0);
00756   }
00757 
00758   inline void adjustBoundingBox(double x, double y, double z)
00759   {
00760     if (x > xmax) xmax = x;
00761     else if (x < xmin) xmin = x;
00762     if (y > ymax) ymax = y;
00763     else if (y < ymin) ymin = y;
00764     if (z > zmax) zmax = z;
00765     else if (z < zmin) zmin = z;
00766   }
00767 
00768   // Fields PRIVATE
00769 
00771   int myMeshId;
00772 
00774   SMDS_UnstructuredGrid*      myGrid;
00775 
00777   ObjectPool<SMDS_MeshNode>* myNodePool;
00778 
00780   ObjectPool<SMDS_VtkVolume>* myVolumePool;
00781   ObjectPool<SMDS_VtkFace>* myFacePool;
00782   ObjectPool<SMDS_VtkEdge>* myEdgePool;
00783 
00785   SetOfNodes             myNodes;
00786 
00788   SetOfCells             myCells;
00789 
00791   //std::vector<int>       myCellIdSmdsToVtk;
00792 
00794   std::vector<int>       myCellIdVtkToSmds;
00795 
00796   SMDS_Mesh *            myParent;
00797   std::list<SMDS_Mesh *> myChildren;
00798   SMDS_MeshNodeIDFactory *myNodeIDFactory;
00799   SMDS_MeshElementIDFactory *myElementIDFactory;
00800   SMDS_MeshInfo          myInfo;
00801 
00803   unsigned long myModifTime, myCompactTime;
00804 
00805   int myNodeMin;
00806   int myNodeMax;
00807 
00808   bool myHasConstructionEdges;
00809   bool myHasConstructionFaces;
00810   bool myHasInverseElements;
00811 
00813   bool myModified;
00814 
00815   double xmin;
00816   double xmax;
00817   double ymin;
00818   double ymax;
00819   double zmin;
00820   double zmax;
00821 };
00822 
00823 
00824 #endif