Salome HOME
Bug #487: dump/load script - problem with obstacle.
[modules/hydro.git] / src / HYDROData / HYDROData_Pipes.cxx
index 5147d01e0edd936c7ed6bcfe4dae975747177463..2427ba03eb3d4ae915ba2f96dca9dfd72d24547e 100644 (file)
@@ -960,7 +960,7 @@ static void addEdgeRelation(TopTools_DataMapOfShapeShape& theMap,
 
 HYDROData_Canal3dAnd2d::HYDROData_Canal3dAnd2d(const TopoDS_Wire& Profile,
                            const TopoDS_Wire& Guideline)
-  : myProfile(Profile), myOriginalGuideline(Guideline)
+  : myProfile(Profile), myOriginalGuideline(Guideline), myStatus(0)
 {
   TopExp::Vertices(myProfile, myLeftVertex, myRightVertex);
   gp_Pnt LeftPoint  = BRep_Tool::Pnt(myLeftVertex);
@@ -971,11 +971,18 @@ HYDROData_Canal3dAnd2d::HYDROData_Canal3dAnd2d(const TopoDS_Wire& Profile,
   MakeSharpVertexList();
   if (!mySharpVertexList.IsEmpty())
     MakeFillet();
+  else
+    myGuideline = myOriginalGuideline;
 
-  ProjectWireOntoXOY(myGuideline, myProjectedGuideline);
-  Make2dProfile();
-  SetMiddlePoint2d();
-  SetMiddlePoint3d();
+  if (myStatus == 0)
+  {
+    if (ProjectWireOntoXOY(myGuideline, myProjectedGuideline))
+    {
+      Make2dProfile();
+      SetMiddlePoint2d();
+      SetMiddlePoint3d();
+    }
+  }
 }
 
 void HYDROData_Canal3dAnd2d::MakeSharpVertexList()
@@ -1040,10 +1047,14 @@ Standard_Boolean HYDROData_Canal3dAnd2d::MakeFillet()
     TopoDS_Wire LocalWire = BRepLib_MakeWire(anEdge1, anEdge2);
     //if ( !takePlane(anEdge1, anEdge2, aV, aPlane) )
     if (!PlaneOfWire(LocalWire, aPlane))
+    {
+      myStatus = 1;
       return Standard_False; // seems edges does not belong to same plane or parallel (fillet can not be build)
+    }
 
     GEOMImpl_Fillet1d aFilletAlgo (anEdge1, anEdge2, aPlane);
     if (!aFilletAlgo.Perform(myFilletRadius)) {
+      myStatus = 2;
       return Standard_False; //can not create fillet at this vertex with given radius
     }
 
@@ -1051,6 +1062,7 @@ Standard_Boolean HYDROData_Canal3dAnd2d::MakeFillet()
     TopoDS_Edge aModifE1, aModifE2;
     TopoDS_Edge aNewE = aFilletAlgo.Result(BRep_Tool::Pnt(aV), aModifE1, aModifE2);
     if (aNewE.IsNull()) {
+      myStatus = 3;
       return Standard_False; //fillet failed at this vertex
     }
 
@@ -1066,6 +1078,7 @@ Standard_Boolean HYDROData_Canal3dAnd2d::MakeFillet()
   }
 
   if (anEdgeToEdgeMap.IsEmpty() && aListOfNewEdge.IsEmpty()) {
+    myStatus = 4;
     return Standard_False; //fillet can't be computed on the given shape with the given radius
   }
 
@@ -1106,7 +1119,10 @@ Standard_Boolean HYDROData_Canal3dAnd2d::ProjectWireOntoXOY(const TopoDS_Wire& a
   OrtProj.BuildWire(Wires);
 
   if (Wires.Extent() != 1)
+  {
+    myStatus = 5;
     return Standard_False;
+  }
   
   ProjectedWire = TopoDS::Wire(Wires.First());
   return Standard_True;
@@ -1218,10 +1234,16 @@ Standard_Boolean HYDROData_Canal3dAnd2d::Create3dPresentation()
   mySweep3d = new BRepOffsetAPI_MakePipeShell(myGuideline);
   mySweep3d->SetMode(gp::DZ()); //optional
   mySweep3d->Add(myTransformedProfile3d);
-  //mySweep3d->SetTransitionMode(BRepBuilderAPI_RightCorner); //optional
+  //Set approx parameters
+  mySweep3d->SetMaxDegree(14);
+  mySweep3d->SetMaxSegments(500);
+  ///////////////////////
   mySweep3d->Build();
   if (!mySweep3d->IsDone())
+  {
+    myStatus = 6;
     return Standard_False;
+  }
 
   myPipe3d = mySweep3d->Shape();
   return Standard_True;
@@ -1234,10 +1256,16 @@ Standard_Boolean HYDROData_Canal3dAnd2d::Create2dPresentation()
   mySweep2d = new BRepOffsetAPI_MakePipeShell(myProjectedGuideline);
   mySweep2d->SetMode(gp::DZ()); //optional
   mySweep2d->Add(myTransformedProfile2d);
-  //mySweep2d->SetTransitionMode(BRepBuilderAPI_RightCorner); //optional
+  //Set approx parameters
+  mySweep2d->SetMaxDegree(14);
+  mySweep2d->SetMaxSegments(500);
+  ///////////////////////
   mySweep2d->Build();
   if (!mySweep2d->IsDone())
+  {
+    myStatus = 7;
     return Standard_False;
+  }
 
   myPipe2d = mySweep2d->Shape();
   myUnifier.Initialize(myPipe2d);
@@ -1276,7 +1304,7 @@ TopoDS_Wire HYDROData_Canal3dAnd2d::GetBank(const TopoDS_Vertex& aFreeVertex)
   return aBankOnUnifiedPipe2d;
 }
 
-TopoDS_Wire Canal3dAnd2d::CreateWireOnUnifiedPipe2d(const TopoDS_Wire& aWireOnPipe2d)
+TopoDS_Wire HYDROData_Canal3dAnd2d::CreateWireOnUnifiedPipe2d(const TopoDS_Wire& aWireOnPipe2d)
 {
   BRepLib_MakeWire MW;
   BRepTools_WireExplorer wexp(aWireOnPipe2d);
@@ -1321,6 +1349,12 @@ TopoDS_Wire HYDROData_Canal3dAnd2d::GetRightBank()
   return GetBank(myRightVertex2d);
 }
 
+Standard_Integer HYDROData_Canal3dAnd2d::GetStatus()
+{
+  return myStatus;
+}
+
+
 /*TopoDS_Wire HYDROData_Canal3dAnd2d::GetRoundedGuideline()
 {
   return myGuideline;