]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
polylines with several sections allowed for calculation case limit
authorPaul RASCLE <paul.rascle@edf.fr>
Fri, 24 Jun 2016 18:11:04 +0000 (20:11 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Fri, 24 Jun 2016 18:11:04 +0000 (20:11 +0200)
src/HYDROData/HYDROData_PolylineXY.cxx
src/HYDROData/HYDROData_PolylineXY.h
src/HYDROData/HYDROData_SplitToZonesTool.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.cxx

index 4c223307635e1e50ce1d753099c394e41498a836..c36a6c7ff77edba8f13997fdc979e8fc4a74b633 100644 (file)
@@ -882,35 +882,99 @@ void HYDROData_PolylineXY::setEditable( const bool theIsEditable )
 /**
  * Returns true if polyline is closed
  */
-bool HYDROData_PolylineXY::IsClosed( const bool theIsSimpleCheck ) const
+bool HYDROData_PolylineXY::IsClosed(const bool theIsSimpleCheck) const
 {
+  //DEBTRACE("IsClosed " << theIsSimpleCheck << " " << GetName());
   bool anIsClosed = false;
 
   TopoDS_Shape aShape = GetShape();
-  if ( aShape.IsNull() )
+  if (aShape.IsNull())
     return anIsClosed;
 
   TopTools_SequenceOfShape aWires;
-  HYDROData_ShapesTool::ExploreShapeToShapes( aShape, TopAbs_WIRE, aWires );
+  HYDROData_ShapesTool::ExploreShapeToShapes(aShape, TopAbs_WIRE, aWires);
 
   int aNbWires = aWires.Length();
-  if ( theIsSimpleCheck )
-  {
-    anIsClosed = aNbWires > 0;
-    for ( int i = 1; i <= aNbWires && anIsClosed; ++i )
+  if (theIsSimpleCheck)
     {
-      const TopoDS_Shape& aWire = aWires.Value( i );
-      anIsClosed = BRep_Tool::IsClosed( aWire );
+      anIsClosed = aNbWires > 0;
+      for (int i = 1; i <= aNbWires && anIsClosed; ++i)
+        {
+          const TopoDS_Shape& aWire = aWires.Value(i);
+          anIsClosed = BRep_Tool::IsClosed(aWire);
+        }
     }
-  }
   else
-  {
-    anIsClosed = aNbWires == 1 && BRep_Tool::IsClosed( aWires.First() );
-  }
+    {
+      if (aNbWires == 1)
+        anIsClosed = BRep_Tool::IsClosed(aWires.First());
+      else
+        {
+          //DEBTRACE("aNbWires " << aNbWires);
+          Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
+          Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
+          for (int i = 1; i <= aNbWires; ++i)
+            {
+              const TopoDS_Shape& aWire = aWires.Value(i);
+              TopExp_Explorer it2(aWire, TopAbs_EDGE);
+              for (; it2.More(); it2.Next())
+                aSeqEdges->Append(it2.Current());
+            }
+          if (aSeqEdges->Length() > 1)
+            {
+              //DEBTRACE(aSeqEdges->Length());
+              ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, 1E-5, Standard_False, aSeqWires);
+              if (aSeqWires->Length() == 1)
+                {
+                  //DEBTRACE(aSeqWires->Length());
+                  const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aSeqWires->Value(1));
+                  anIsClosed = BRep_Tool::IsClosed(aPolylineWire);
+                }
+            }
+        }
+    }
 
   return anIsClosed;
 }
 
+int HYDROData_PolylineXY::GetNbConnectedWires(Handle(TopTools_HSequenceOfShape)& aConnectedWires) const
+{
+  TopoDS_Shape aShape = GetShape();
+  if (aShape.IsNull())
+    return 0;
+  int aNbconnectedWires = 0;
+  TopTools_SequenceOfShape aWires;
+  HYDROData_ShapesTool::ExploreShapeToShapes(aShape, TopAbs_WIRE, aWires);
+  int aNbWires = aWires.Length();
+  if (aNbWires == 1)
+    {
+      aNbconnectedWires = aNbWires;
+      aConnectedWires->Append(aWires.First());
+    }
+  else
+    {
+      //DEBTRACE("aNbWires " << aNbWires);
+      Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
+      Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
+      for (int i = 1; i <= aNbWires; ++i)
+        {
+          const TopoDS_Shape& aWire = aWires.Value(i);
+          TopExp_Explorer it2(aWire, TopAbs_EDGE);
+          for (; it2.More(); it2.Next())
+            aSeqEdges->Append(it2.Current());
+        }
+      if (aSeqEdges->Length() > 1)
+        {
+          //DEBTRACE(aSeqEdges->Length());
+          ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, 1E-5, Standard_False, aSeqWires);
+        }
+      aConnectedWires = aSeqWires;
+      aNbconnectedWires = aConnectedWires->Length();
+      DEBTRACE("aNbconnectedWires " << aNbconnectedWires);
+    }
+return aNbconnectedWires;
+}
+
 double HYDROData_PolylineXY::GetDistance( const int theSectionIndex,
                                           const int thePointIndex ) const
 {
index cbf5657baaa9d2f66ab18501f6a56a5117c28136..d67f0ad5ad781a3b0c0694742f8057927b769c68 100644 (file)
@@ -20,6 +20,7 @@
 #define HYDROData_PolylineXY_HeaderFile
 
 #include "HYDROData_IPolyline.h"
+#include <TopTools_HSequenceOfShape.hxx>
 
 DEFINE_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
 
@@ -151,6 +152,11 @@ public:
    */
   HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
 
+  /**
+   * Returns connected wires and their number, by rebuild of the wires from the edges, looking for connections
+   */
+  HYDRODATA_EXPORT int GetNbConnectedWires(Handle(TopTools_HSequenceOfShape)& aConnectedWires) const;
+
    /**
    * Returns the distance between first and point with index thePointIndex
    * at the section with index theSectionIndex. -1 is returned if error is occurred.
index f91732cd2fcdba0a6ae49707008b8b684b76dee3..bef3e9a222b8dc9889fcad84385a75f56ea3cefb 100644 (file)
@@ -347,8 +347,10 @@ HYDROData_SplitToZonesTool::SplitDataList
   Standard_Boolean hasLimits(Standard_False);
   QString aBndName;
   HYDROData_MapOfShape aBndView;
-  if (! thePolyline.IsNull()) {    
-    const TopoDS_Wire aBndWire = TopoDS::Wire(thePolyline->GetShape());
+  if (! thePolyline.IsNull()) {
+    Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape;
+    int nbWires = thePolyline->GetNbConnectedWires(aConnectedWires);
+    const TopoDS_Wire aBndWire = TopoDS::Wire(aConnectedWires->Value(1));
     if(!aBndWire.IsNull()) {
       TopoDS_Face limFace;       
       if(buildLimFace(aBndWire, limFace)) {
@@ -605,4 +607,4 @@ HYDROData_SplitToZonesTool::SplitDataList
   Handle(HYDROData_PolylineXY) aPolyline;
 
   return Split( theObjectList, aGeomGroups, aPolyline );
-}
\ No newline at end of file
+}
index b06fbb3b80eb9a134167b908e68ce5089de34b51..0af2109beca5c87a95531b072d709da9c1e8a64f 100644 (file)
@@ -110,18 +110,18 @@ void HYDROGUI_CalculationOp::startOperation()
   {
     aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() );
 
-    if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed() )
+    if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed(false) )
     { 
-      // Check the polyline shape
-      TopoDS_Shape aPolylineShape = aPolylineObj->GetShape();
-      if ( !aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE ) {
+//      // Check the polyline shape
+//      TopoDS_Shape aPolylineShape = aPolylineObj->GetShape();
+//      if ( !aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE ) {
         aPolylineName = aPolylineObj->GetName();
         if ( !aPolylineName.isEmpty() )
         {
           aList.append( aPolylineName );
           anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ) );
         }
-      }
+//      }
     }
   }
   aPanel->setPolylineNames( aList, anEntryList );