Salome HOME
Minor corrections: coding rules
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Sewing.cpp
index 4539b086399653dab79acee6262cf0ab7c27aea3..5d8039cbfc3ca9dbc19ce7a4de5d00115cd1b024 100644 (file)
@@ -38,22 +38,26 @@ void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes)
 
   TopoDS_Shape aResult = aSewingBuilder->SewedShape();
   BRep_Builder aBuilder;
-  TopoDS_Compound aResultCompound;
-  aBuilder.MakeCompound(aResultCompound);
-  for(TopoDS_Iterator anIt(aResult); anIt.More(); anIt.Next()) {
-    const TopoDS_Shape aSubShape = anIt.Value();
-    if(aSubShape.ShapeType() == TopAbs_SHELL) {
-      aBuilder.Add(aResultCompound, aSubShape);
-    } else if (aSubShape.ShapeType() == TopAbs_FACE) {
-      TopoDS_Shell aShell;
-      aBuilder.MakeShell(aShell);
-      aBuilder.Add(aShell, aSubShape);
-      aBuilder.Add(aResultCompound, aShell);
+  if(aResult.ShapeType() == TopAbs_COMPOUND) {
+    TopoDS_Compound aResultCompound;
+    aBuilder.MakeCompound(aResultCompound);
+    for(TopoDS_Iterator anIt(aResult); anIt.More(); anIt.Next()) {
+      const TopoDS_Shape aSubShape = anIt.Value();
+      if(aSubShape.ShapeType() == TopAbs_SHELL) {
+        aBuilder.Add(aResultCompound, aSubShape);
+      } else if (aSubShape.ShapeType() == TopAbs_FACE) {
+        TopoDS_Shell aShell;
+        aBuilder.MakeShell(aShell);
+        aBuilder.Add(aShell, aSubShape);
+        aBuilder.Add(aResultCompound, aShell);
+      }
     }
-  }
-  TopoDS_Iterator anIt(aResultCompound);
-  if(anIt.More()) {
     aResult = aResultCompound;
+  } else if(aResult.ShapeType() == TopAbs_FACE) {
+    TopoDS_Shell aShell;
+    aBuilder.MakeShell(aShell);
+    aBuilder.Add(aShell, aResult);
+    aResult = aShell;
   }
 
   std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());