Salome HOME
quick optimization patch (bytearray for images)
[modules/hydro.git] / src / HYDROData / HYDROData_GeomTool.cxx
index a83258e61f7bff4b896da5ca198a886e923faee6..a152909c98247f0e26f54693bd0f917b820c8ba7 100644 (file)
 
 #include "HYDROData_GeomTool.h"
 
+#ifndef LIGHT_MODE
+
 #include <TopoDS_Shape.hxx>
 
 #include <BRepTools.hxx>
+#include <GEOMBase.h>
+
+#ifdef WIN32
+  #pragma warning ( disable: 4251 )
+#endif
 
 #include <SALOME_NamingService.hxx>
 #include <SALOME_LifeCycleCORBA.hxx>
 
+#include <TopTools_MapOfShape.hxx>
+#include <TopExp_Explorer.hxx>
+
+#ifdef WIN32
+  #pragma warning ( default: 4251 )
+#endif
+
 #include <QStringList>
+#include <QVector>
 #include <QSet>
 
 static int _argc = 0;
@@ -145,6 +160,54 @@ GEOM::GEOM_Object_ptr HYDROData_GeomTool::publishShapeInGEOM(
   return aGeomObj._retn();
 }
 
+
+GEOM::GEOM_Object_ptr HYDROData_GeomTool::ExplodeShapeInGEOMandPublish( GEOM::GEOM_Gen_var theGeomEngine, 
+  SALOMEDS::Study_ptr theStudy, 
+  const TopoDS_Shape& theShape,   
+  const NCollection_IndexedDataMap<TopoDS_Shape, QString, TopTools_ShapeMapHasher>& aFacesToNameModif,  
+  const QString& theName,
+  QString& theGeomObjEntry)
+{ 
+  GEOM::GEOM_Object_ptr aGeomObj = HYDROData_GeomTool::publishShapeInGEOM( theGeomEngine, theStudy, theShape, theName, theGeomObjEntry );
+
+  GEOM::GEOM_IShapesOperations_var anExpOp = theGeomEngine->GetIShapesOperations( theStudy->StudyId() );
+  GEOM::ListOfGO* aFc = anExpOp->MakeExplode(aGeomObj, TopAbs_FACE, false);
+
+  TopTools_MapOfShape mapShape;
+
+  NCollection_IndexedDataMap<TopoDS_Shape, QString, TopTools_ShapeMapHasher> aFF2N;
+  for (int i = 1; i <= aFacesToNameModif.Extent(); i++)
+  {
+    TopExp_Explorer exp (aFacesToNameModif.FindKey(i), TopAbs_FACE);
+    for (;exp.More(); exp.Next())
+      aFF2N.Add(exp.Current(), aFacesToNameModif.FindFromIndex(i));
+  }
+
+  TopExp_Explorer exp (theShape, TopAbs_FACE);
+  QVector<QString> Names;
+  for (; exp.More(); exp.Next())
+  {
+    const TopoDS_Shape& csh = exp.Current();
+    if (mapShape.Add(csh))
+    {
+      //listShape.Append(csh);
+      QString Qstr = aFF2N.FindFromKey(csh);
+      Names.push_back(Qstr);
+    }
+  }
+
+  for (size_t i = 0; i < aFc->length(); i++)
+  {
+    std::string name = Names[i].toStdString();
+    GEOM::GEOM_Object_ptr anObj = aFc->operator[](i);
+    //GEOMBase::PublishSubObject( anObj, name.c_str() );
+    theGeomEngine->AddInStudy( theStudy, anObj, name.c_str(), aGeomObj );
+  }
+
+  return aGeomObj;
+}
+
+
  GEOM::GEOM_Object_ptr HYDROData_GeomTool::createFaceInGEOM( GEOM::GEOM_Gen_var theGeomEngine,
                                                              SALOMEDS::Study_ptr theStudy,
                                                              const int theWidth,
@@ -195,3 +258,5 @@ QString HYDROData_GeomTool::publishGEOMObject( GEOM::GEOM_Gen_var theGeomEngine,
 
   return anEntry;
 }
+
+#endif