Salome HOME
Fix 32bits config bug
[tools/medcoupling.git] / src / MEDPartitioner / MEDPARTITIONER_Graph.cxx
index a2a4b2feb7713e13081162931e000d8df5d98c05..d9a7369a8ad60f14ba2bafaab57c699a7928abfb 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020  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
 
 #include "MEDPARTITIONER_Graph.hxx"
 
-MEDPARTITIONER::Graph::Graph(MEDPARTITIONER::SkyLineArray *array, int *edgeweight):_graph(array),_partition(0),_edge_weight(edgeweight),_cell_weight(0)
-{
-}
+#include "MEDCouplingSkyLineArray.hxx"
+
+#include <set>
 
-MEDPARTITIONER::Graph::~Graph()
+namespace MEDPARTITIONER
 {
-  delete _partition;
-  delete _graph;
-}
+  Graph::Graph():
+    _graph(0),_partition(0),
+    _edge_weight(0),_cell_weight(0)
+  {
+  }
+
+  Graph::Graph(MEDCoupling::MEDCouplingSkyLineArray *array, int *edgeweight):
+    _graph(array),_partition(0),
+    _edge_weight(edgeweight),_cell_weight(0)
+  {
+  }
+
+  Graph::~Graph()
+  {
+  }
+
+  int Graph::nbDomains() const
+  {
+    std::set<mcIdType> domains;
+    if ( _partition.isNotNull() )
+      if ( MEDCoupling::DataArrayIdType* array = _partition->getValuesArray() )
+      {
+        for ( const mcIdType * dom = array->begin(); dom != array->end(); ++dom )
+          domains.insert( *dom );
+      }
+    return (int)domains.size();
+  }
+
+  const mcIdType *Graph::getPart() const
+  {
+    return _partition->getValues();
+  }
+
+  mcIdType Graph::nbVertices() const
+  {
+    return _graph->getNumberOf();
+  }
+
+};