Salome HOME
#18963 Minimize compiler warnings
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ProjectionDriver.cxx
index 966ebc824b40a7a967141c01013d2b987150f6c8..20f006b34d51e35a06e594fcdbef8bc337051b23 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -220,9 +220,8 @@ Standard_Integer GEOMImpl_ProjectionDriver::Execute(Handle(TFunction_Logbook)& l
 
       try {
         OrtProj.Build();
-      } catch (Standard_Failure) {
-        Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-        TCollection_AsciiString aMsg (aFail->GetMessageString());
+      } catch (Standard_Failure& aFail) {
+        TCollection_AsciiString aMsg (aFail.GetMessageString());
         if (!aMsg.Length())
           aMsg = "Projection aborted : possibly the source shape intersects the cylinder's axis";
         Standard_ConstructionError::Raise(aMsg.ToCString());
@@ -236,11 +235,23 @@ Standard_Integer GEOMImpl_ProjectionDriver::Execute(Handle(TFunction_Logbook)& l
 
       // check that the result shape is an empty compound
       // (IPAL22905: TC650: Projection on face dialog problems)
-      if( !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND )
+      if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND)
       {
-        TopoDS_Iterator anIter( aShape );
-        if( !anIter.More() )
+        TopoDS_Iterator anIter(aShape);
+        if (!anIter.More())
           Standard_ConstructionError::Raise("Projection aborted : empty compound produced");
+
+        if (anOriginal.ShapeType() == TopAbs_WIRE) {
+          // Make wire from resulting compound (Mantis issue 0023497)
+          TopTools_ListOfShape anEdgesList;
+          for (; anIter.More(); anIter.Next()) {
+            anEdgesList.Append(anIter.Value());
+          }
+          BRepBuilderAPI_MakeWire aMkWire;
+          aMkWire.Add(anEdgesList);
+          if (aMkWire.IsDone())
+            aShape = aMkWire.Wire();
+        }
       }
     }
 
@@ -799,4 +810,4 @@ TopoDS_Shape GEOMImpl_ProjectionDriver::projectOnCylinder
   return aResult;
 }
 
-IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_ProjectionDriver,GEOM_BaseDriver);
+IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_ProjectionDriver,GEOM_BaseDriver)