Salome HOME
0022875: EDF 7690 MED: Creating joints with medpartitioner in the MEDCoupling API
[tools/medcoupling.git] / src / MEDPartitioner / MEDPARTITIONER_Graph.cxx
index 7ae83470dc513f1d7c53847febd93f9bd4642289..62a273a6a1738643e3f21db967b74a482117ad4e 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
 //
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,7 +19,9 @@
 
 #include "MEDPARTITIONER_Graph.hxx"
 
-MEDPARTITIONER::Graph::Graph(MEDPARTITIONER::SkyLineArray *array, int *edgeweight):_graph(array),_partition(0),_edge_weight(edgeweight),_cell_weight(0)
+#include <set>
+
+MEDPARTITIONER::Graph::Graph(ParaMEDMEM::MEDCouplingSkyLineArray *array, int *edgeweight):_graph(array),_partition(0),_edge_weight(edgeweight),_cell_weight(0)
 {
 }
 
@@ -28,3 +30,15 @@ MEDPARTITIONER::Graph::~Graph()
   delete _partition;
   delete _graph;
 }
+
+int MEDPARTITIONER::Graph::nbDomains() const
+{
+  std::set<int> domains;
+  if ( _partition )
+    if ( ParaMEDMEM::DataArrayInt* array = _partition->getValueArray() )
+    {
+      for ( const int * dom = array->begin(); dom != array->end(); ++dom )
+        domains.insert( *dom );
+    }
+  return domains.size();
+}