Salome HOME
Merge remote-tracking branch 'origin/BR_SHP_FORMAT' into BR_v14_rc
[modules/hydro.git] / src / HYDROData / HYDROData_Polyline.cxx
index abac653b3d138eecfc95ddddebfaf99e4d32bf60..f9a4d7d5b1ae090795a38bce579cc39839011506 100755 (executable)
@@ -1,3 +1,21 @@
+// Copyright (C) 2014-2015  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 #include <HYDROData_Polyline.h>
 #include <HYDROData_Iterator.h>
 
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Wire.hxx>
+#include <BRep_Builder.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
 
 #include <QStringList>
 
-// tage of the child of my label that contains information about the operator
-static const Standard_GUID GUID_MUST_BE_UPDATED("6647e1f7-1971-4c5a-86c7-11ff0291452d");
-
 #define PYTHON_POLYLINE_ID "KIND_POLYLINE"
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
@@ -62,7 +79,7 @@ QStringList HYDROData_Polyline::DumpToPython( MapOfTreatedObjects& theTreatedObj
 {
   QStringList aResList;
 
-  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
   if ( aDocument.IsNull() )
     return aResList;
                              
@@ -78,7 +95,7 @@ QStringList HYDROData_Polyline::DumpToPython( MapOfTreatedObjects& theTreatedObj
   aResList << QString( "" );
 
   int aDim = GetDimension();
-  aResList << QString( "%1.setDimension( %2 );" )
+  aResList << QString( "%1.SetDimension( %2 );" )
               .arg( aPolylineName ).arg( aDim );
 
   // Set polilyne data
@@ -121,8 +138,9 @@ QStringList HYDROData_Polyline::DumpToPython( MapOfTreatedObjects& theTreatedObj
       aResList << QString( "%1.append( %2 );" )
                   .arg( aPolylineDataName ).arg( aPolylineSectName );
     }
+    aResList << QString( "" );
 
-    aResList << QString( "%1.setPolylineData( %2 );" )
+    aResList << QString( "%1.SetPolylineData( %2 );" )
                   .arg( aPolylineName ).arg( aPolylineDataName );
   }
 
@@ -396,6 +414,8 @@ void HYDROData_Polyline::UpdateWire( const PolylineData& theSections )
 
   double aZValue = ZValue();
 
+  TopTools_ListOfShape aSectionWiresList;
+
   int aSectionCount = theSections.size();
   for( int aSectionId = 0; aSectionId < aSectionCount; aSectionId++ )
   {
@@ -443,10 +463,25 @@ void HYDROData_Polyline::UpdateWire( const PolylineData& theSections )
         aMakeSectionWire.Add( anEdge );
       }
       TopoDS_Wire aSectionWire = aMakeSectionWire.Wire();
+      aSectionWiresList.Append( aSectionWire );
       aMakeWire.Add( aSectionWire );
     }
   }
 
-  TopoDS_Wire aWire = aMakeWire.Wire();
-  SetTopShape( aWire );
+  TopoDS_Shape aShape;
+  if ( aMakeWire.IsDone() ) {
+    aShape = aMakeWire.Shape();
+  } else {
+    // build compound
+    TopoDS_Compound aCompound;
+    BRep_Builder aBuilder;
+    aBuilder.MakeCompound( aCompound );
+    TopTools_ListIteratorOfListOfShape anIter( aSectionWiresList );
+    for ( ; anIter.More(); anIter.Next() ) {
+      aBuilder.Add( aCompound, anIter.Value() );
+    }
+    aShape = aCompound;
+  }
+
+  SetTopShape( aShape );
 }