Salome HOME
Create goups for stream.
[modules/hydro.git] / src / HYDROData / HYDROData_PolylineXY.cxx
index eaea172a650df3981ce37149b8c72b573c54743c..5129d6e8568574edd4844e7e860d59fcf8014475 100755 (executable)
@@ -36,6 +36,7 @@
 #include <TopoDS_Iterator.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_HSequenceOfShape.hxx>
+#include <TopExp_Explorer.hxx>
 #include <ShapeAnalysis_FreeBounds.hxx>
 #include <TopoDS.hxx>
 #include <QColor>
@@ -244,50 +245,40 @@ void HYDROData_PolylineXY::Update()
   Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
   Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
   TopTools_ListIteratorOfListOfShape it(aSectionWiresList);
-  for(;it.More();it.Next()) {
-       TopoDS_Iterator it2(it.Value());
-       for(;it2.More();it2.Next()) 
-          aSeqEdges->Append(it2.Value());
+  for(;it.More();it.Next())
+  {
+         TopExp_Explorer it2(it.Value(), TopAbs_EDGE);
+         for(;it2.More();it2.Next()) 
+           aSeqEdges->Append(it2.Current());
   }
    BRep_Builder aBB;
    TopoDS_Compound aCmp;
+   TopoDS_Shape aResult;
    aBB.MakeCompound(aCmp);
-   if(aSeqEdges->Length() >1) {
-     ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges,Precision::Confusion(),Standard_True,aSeqWires);
-     for (Standard_Integer i = 1; i <= aSeqWires->Length();i++) {
-       const TopoDS_Shape& aS1 = aSeqWires->Value(i);
-       aBB.Add(aCmp, aS1);
+   if(aSeqEdges->Length() >1)
+   {
+     ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges,1E-5,Standard_False,aSeqWires);
+
+     if( aSeqWires->Length()==1 )
+       aResult = aSeqWires->Value( 1 );
+     else
+     {
+       for (Standard_Integer i = 1; i <= aSeqWires->Length();i++)
+       {
+         const TopoDS_Shape& aS1 = aSeqWires->Value(i);
+         aBB.Add(aCmp, aS1);
+       }
+       aResult = aCmp;
+     }
         }
-   } else if (aSeqEdges->Length() == 1) {
+   else if (aSeqEdges->Length() == 1)
+   {
           BRepBuilderAPI_MakeWire mkWire (TopoDS::Edge(aSeqEdges->Value(1)));
-         if (mkWire.IsDone())
-                 aBB.Add(aCmp, mkWire.Wire());
+          if (mkWire.IsDone())
+       aResult = mkWire.Wire();
    }
 
-  
-/*
-  if ( aMakeWire.IsDone() )
-  {
-    aShape = aMakeWire.Shape();
-  }
-  else if ( !aSectionWiresList.IsEmpty() )
-  {
-    // 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;
-  }
-*/
-  setPolylineShape( aCmp );
+  setPolylineShape( aResult );
 }
 
 /**