Salome HOME
Merge branch 'BR_H2018_2' of https://codev-tuleap.cea.fr/plugins/git/salome/hydro...
[modules/hydro.git] / src / HYDROData / HYDROData_ImmersibleZone.cxx
index f3b7d6758a17dda7d0fa43fce4cc9c35a206db17..0c08bffb1f477dd05dbb7e1c4b9e551a8dbcb7df 100644 (file)
@@ -24,7 +24,7 @@
 #include "HYDROData_PolylineXY.h"
 #include "HYDROData_ShapesTool.h"
 
-#include <BRepBuilderAPI_MakeFace.hxx>
+#include <HYDROData_Tool.h>
 
 #include <TopoDS.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
 
-#include <BRep_Builder.hxx>
-#include <BRepAlgo_FaceRestrictor.hxx>
-#include <BRepCheck_Analyzer.hxx>
 
 #include <ShapeAnalysis.hxx>
+#include <ShapeAnalysis_FreeBounds.hxx>
+
 
 #include <QColor>
 #include <QStringList>
 
+#define DEB_IMZ
+#include <BRepTools.hxx>
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
 //#define HYDRODATA_IMZONE_DEB 1
 
-IMPLEMENT_STANDARD_HANDLE(HYDROData_ImmersibleZone,HYDROData_NaturalObject)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ImmersibleZone,HYDROData_NaturalObject)
 
 
@@ -70,9 +74,14 @@ QStringList HYDROData_ImmersibleZone::DumpToPython( const QString& thePyScriptPa
   Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline();
   setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
 
+  if (!this->IsSubmersible())
+    {
+      aResList << QString( "%1.SetIsSubmersible(False)" ).arg( aZoneName );
+    }
+
   aResList << QString( "" );
 
-  aResList << QString( "%1.Update();" ).arg( aZoneName );
+  aResList << QString( "%1.Update()" ).arg( aZoneName );
   aResList << QString( "" );
 
   return aResList;
@@ -93,6 +102,7 @@ void HYDROData_ImmersibleZone::Update()
 {
   HYDROData_NaturalObject::Update();
   
+  RemoveGroupObjects();
   TopoDS_Shape aResShape = generateTopShape();
   SetTopShape( aResShape );
 
@@ -111,71 +121,7 @@ TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape() const
 
 TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape( const Handle(HYDROData_PolylineXY)& aPolyline )
 {
-  TopoDS_Face aResultFace = TopoDS_Face();
-
-  if( !aPolyline.IsNull() )
-  {
-    TopoDS_Shape aPolylineShape = aPolyline->GetShape();
-    TopTools_ListOfShape aWiresList;
-
-    if ( !aPolylineShape.IsNull() && 
-         aPolylineShape.ShapeType() == TopAbs_WIRE ) {
-      const TopoDS_Wire& aPolylineWire = TopoDS::Wire( aPolylineShape );
-      if ( !aPolylineWire.IsNull() ) {
-        BRepBuilderAPI_MakeFace aMakeFace( aPolylineWire, Standard_True );
-        aMakeFace.Build();
-        if( aMakeFace.IsDone() ) {
-          aResultFace = aMakeFace.Face();
-        }
-      }
-    } else {
-      TopExp_Explorer anExp( aPolylineShape, TopAbs_WIRE );
-      for ( ; anExp.More(); anExp.Next() ) {
-        if(!anExp.Current().IsNull()) {
-          const TopoDS_Wire& aWire = TopoDS::Wire( anExp.Current() );
-          aWiresList.Append( aWire );
-        }
-      }
-      if(aWiresList.IsEmpty())
-         return aResultFace;
-
-      BRepAlgo_FaceRestrictor aFR;
-      TopoDS_Face aRefFace;      
-      TopoDS_Shape aS = aWiresList.First();
-      BRepBuilderAPI_MakeFace aMakeFace( TopoDS::Wire(aWiresList.First()), Standard_True );
-      aMakeFace.Build();
-      if( aMakeFace.IsDone() ) {
-        aRefFace = aMakeFace.Face();
-      }
-      if(aRefFace.IsNull())
-        return aResultFace;
-
-      aFR.Init(aRefFace,Standard_False, Standard_True);
-      TopTools_ListIteratorOfListOfShape anIt( aWiresList );
-      for ( ; anIt.More(); anIt.Next() ) {
-        TopoDS_Wire& aWire = TopoDS::Wire( anIt.Value() );
-        if ( aWire.IsNull() ) 
-            continue;
-        aFR.Add(aWire);
-      }
-      aFR.Perform();
-      if (aFR.IsDone()) {
-        for (; aFR.More(); aFR.Next()) {
-          aResultFace = aFR.Current();
-          break;
-        }
-      }
-    }
-  }
-
-  if( aResultFace.IsNull() )
-    return aResultFace;
-
-  BRepCheck_Analyzer anAnalyzer( aResultFace );
-  if( anAnalyzer.IsValid() && aResultFace.ShapeType()==TopAbs_FACE )
-    return aResultFace;
-  else
-    return TopoDS_Face();
+  return HYDROData_Tool::PolyXY2Face(aPolyline);
 }
 
 void HYDROData_ImmersibleZone::createGroupObjects()