]> SALOME platform Git repositories - tools/medcoupling.git/blobdiff - doc/MEDMEM/MESHconnectivities.cxx
Salome HOME
Join modifications from branch CEAFor_V3_2_0
[tools/medcoupling.git] / doc / MEDMEM / MESHconnectivities.cxx
index 2964ff9f8e6737a195bad7cdf1463637f9067c1b..947cd859836f0acec5b14df993425b794614cf6c 100644 (file)
@@ -1,8 +1,34 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
 #include "MEDMEM_Mesh.hxx"
 #include "MEDMEM_CellModel.hxx"
 
+using namespace MEDMEM ;
+using namespace MED_EN ;
+
 int main (int argc, char ** argv) {
 
+//   const string MedFile = "polyedres.med" ;
+//   const string MeshName = "Erreur orientation" ;
+//   const string MedFile = "polygones.med" ;
+//   const string MeshName = "Bord" ;
   const string MedFile = "pointe.med" ;
   const string MeshName = "maa1" ;
   MESH myMesh(MED_DRIVER,MedFile,MeshName) ;
@@ -128,5 +154,43 @@ int main (int argc, char ** argv) {
     cout << endl ;
   }
 
+  int nbPolygons = myMesh.getNumberOfPolygons();
+  if ( nbPolygons > 0 )
+  {
+    cout << "Show Connectivity (Nodal) of POLYGONS:" << endl ;
+    const int* Connectivity = myMesh.getPolygonsConnectivity(MED_NODAL,MED_CELL);
+    const int* ConnectivityIndex = myMesh.getPolygonsConnectivityIndex(MED_NODAL,MED_CELL);
+    for (int j=0; j<nbPolygons; j++){
+      cout << "Polygon "<< j+1 <<" : " ;
+    int IndexBegin = ConnectivityIndex[j];
+    int IndexEnd   = ConnectivityIndex[j+1];
+      for (int k=IndexBegin; k<IndexEnd; k++)
+       cout << Connectivity[k-1]<<" ";
+      cout << endl ;
+    }
+  }
+
+  int nbPolyhedrons = myMesh.getNumberOfPolyhedron();
+  if ( nbPolyhedrons > 0 )
+  {
+    cout << "Show Connectivity (Nodal) of POLYHEDRONS:" << endl ;
+    const int* Connectivity = myMesh.getPolyhedronConnectivity(MED_NODAL);
+    const int* FaceIndex    = myMesh.getPolyhedronFacesIndex();
+    const int* Index        = myMesh.getPolyhedronIndex(MED_NODAL);
+    for (int j=0; j<nbPolyhedrons; j++){
+      cout << "Polyhedron "<< j+1 <<" : " << endl;
+      int FaceIndexBegin = Index[j];
+      int FaceIndexEnd = Index[j+1];
+      for (int k=FaceIndexBegin; k<FaceIndexEnd; k++) {
+        cout << "  Face " << k - FaceIndexBegin + 1 << " : ";
+        int IndexBegin = FaceIndex[k-1];
+        int IndexEnd   = FaceIndex[k];
+        for (int i=IndexBegin; i<IndexEnd; i++)
+          cout << Connectivity[i-1]<<" ";
+        cout << endl ;
+      }
+    }
+  }
+
   return 0 ;
 }