Salome HOME
0022746: [EDF] Improvement of Glue Faces and Glue Edges operations
[modules/geom.git] / src / GEOMImpl / GEOMImpl_GlueDriver.cxx
index 1f03275c5a6da57af76f42aaa621f16523b4a4f3..4b3dfba96fa486ed5fb90e6d74d3f9d8ffea2253 100644 (file)
 
 #include "utilities.h"
 
+#include <BRep_Builder.hxx>
+#include <ShapeFix_Shape.hxx>
 #include <TDataStd_IntegerArray.hxx>
-
 #include <TopExp.hxx>
-#include <TopoDS_Shape.hxx>
 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
-
-#include <ShapeFix_Shape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopoDS_Shape.hxx>
 
 #include <Standard_NullObject.hxx>
 #include <Standard_Failure.hxx>
@@ -729,8 +728,36 @@ Standard_Integer GEOMImpl_GlueDriver::Execute(TFunction_Logbook& log) const
   TopoDS_Shape aShape;
   TCollection_AsciiString aWrn;
 
-  Handle(GEOM_Function) aRefBase = aCI.GetBase();
-  TopoDS_Shape aShapeBase = aRefBase->GetValue();
+  TopoDS_Shape aShapeBase;
+  Handle(TColStd_HSequenceOfTransient) aRefBases = aCI.GetBase();
+  if ( aRefBases && !aRefBases->IsEmpty() )
+  {
+    if ( aRefBases->Length() == 1 )
+    {
+      Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRefBases->Value(1));
+      if ( !aRefShape.IsNull() )
+        aShapeBase = aRefShape->GetValue();
+    }
+    else
+    {
+      TopoDS_Compound compound;
+      BRep_Builder builder;
+      builder.MakeCompound( compound );
+      int ind = 1;
+      for ( ; ind <= aRefBases->Length(); ind++)
+      {
+        Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRefBases->Value(ind));
+        if ( aRefShape.IsNull() ) break;
+        TopoDS_Shape aShape = aRefShape->GetValue();
+        if (aShape.IsNull()) break;
+        builder.Add( compound, aShape );
+      }
+      if ( ind > aRefBases->Length() )
+        aShapeBase = compound;
+      else
+        aShapeBase.Nullify();
+    }
+  }
   if (aShapeBase.IsNull()) {
     Standard_NullObject::Raise("Shape for gluing is null");
   }
@@ -803,18 +830,18 @@ GetCreationInformation(std::string&             theOperationName,
   switch ( aType ) {
   case GLUE_FACES:
     theOperationName = "GLUE_FACES";
-    AddParam( theParams, "Selected shape", aCI.GetBase() );
+    AddParam( theParams, "Selected shapes", aCI.GetBase() );
     AddParam( theParams, "Tolerance", aCI.GetTolerance() );
     AddParam( theParams, "To keep non solids", aCI.GetKeepNonSolids() );
     break;
   case GLUE_EDGES:
     theOperationName = "GLUE_EDGES";
-    AddParam( theParams, "Selected shape", aCI.GetBase() );
+    AddParam( theParams, "Selected shapes", aCI.GetBase() );
     AddParam( theParams, "Tolerance", aCI.GetTolerance() );
     break;
   case GLUE_FACES_BY_LIST:
     theOperationName = "GLUE_FACES";
-    AddParam( theParams, "Selected shape", aCI.GetBase() );
+    AddParam( theParams, "Selected shapes", aCI.GetBase() );
     AddParam( theParams, "Tolerance", aCI.GetTolerance() );
     AddParam( theParams, "Faces", aCI.GetFaces() );
     AddParam( theParams, "To keep non solids", aCI.GetKeepNonSolids() );
@@ -822,7 +849,7 @@ GetCreationInformation(std::string&             theOperationName,
     break;
   case GLUE_EDGES_BY_LIST:
     theOperationName = "GLUE_EDGES";
-    AddParam( theParams, "Selected shape", aCI.GetBase() );
+    AddParam( theParams, "Selected shapes", aCI.GetBase() );
     AddParam( theParams, "Tolerance", aCI.GetTolerance() );
     AddParam( theParams, "Edges", aCI.GetFaces() );
     break;