0023870: Integration of new options of sweeping into BRepOffsetAPI_MakePipe algorithm.
authorjgv <jgv@opencascade.com>
Fri, 5 Apr 2013 06:35:38 +0000 (10:35 +0400)
committerjgv <jgv@opencascade.com>
Fri, 5 Apr 2013 06:35:38 +0000 (10:35 +0400)
Adding test cases for this fix
Test cases correction
Correction of instability.

12 files changed:
src/BRepFill/BRepFill_Pipe.cdl
src/BRepFill/BRepFill_Pipe.cxx
src/BRepFill/BRepFill_Sweep.cxx
src/BRepOffsetAPI/BRepOffsetAPI_MakePipe.cdl
src/BRepOffsetAPI/BRepOffsetAPI_MakePipe.cxx
src/BRepTest/BRepTest_SweepCommands.cxx
src/LocOpe/LocOpe_Pipe.cxx
tests/bugs/modalg_5/bug23870_1 [new file with mode: 0755]
tests/bugs/modalg_5/bug23870_2 [new file with mode: 0755]
tests/bugs/modalg_5/bug23870_3 [new file with mode: 0755]
tests/bugs/modalg_5/bug23870_4 [new file with mode: 0755]
tests/bugs/modalg_5/bug23870_5 [new file with mode: 0755]

index 46ee387..8115da6 100755 (executable)
@@ -42,6 +42,7 @@ uses
     Vertex from TopoDS,  
     Pnt    from  gp,
     Trsf   from  gp,
+    Shape  from GeomAbs,
     Trihedron from GeomFill
 
 raises
@@ -54,24 +55,11 @@ is
     
     Create ( Spine   : Wire from TopoDS; 
             Profile : Shape from TopoDS;
+            aMode   : Trihedron from GeomFill = GeomFill_IsCorrectedFrenet;
+            ForceApproxC1 : Boolean from Standard = Standard_False;
              GeneratePartCase : Boolean from Standard = Standard_False) 
     returns Pipe from BRepFill;
     
-    SetMode(me : in out;
-           aMode : Trihedron from GeomFill);
-       ---Purpose: Set the mode of sweeping
-       --          It can be:
-       --          - Frenet
-       --          - Corrected Frenet
-       --          - Discrete Trihedron
-       --          By default the mode is Corrected Frenet
-    
-    SetForceApproxC1(me : in out;
-                    ForceApproxC1 : Boolean from Standard);
-       ---Purpose: Set the flag that indicates attempt to approximate
-       --          a C1-continuous surface if a swept surface proved
-       --          to be C0.
-
     Perform (me : in out;  Spine   : Wire from TopoDS; 
                           Profile : Shape from TopoDS;
                            GeneratePartCase : Boolean from Standard = Standard_False) 
@@ -190,6 +178,7 @@ fields
      
     myDegmax  : Integer from Standard;
     mySegmax  : Integer from Standard;
+    myContinuity : Shape from GeomAbs;
     myMode    : Trihedron from GeomFill;
     myForceApproxC1 : Boolean from Standard;
     
index c27ed8c..74a9336 100755 (executable)
@@ -70,8 +70,9 @@ static Standard_Boolean Affich = 0;
 
 BRepFill_Pipe::BRepFill_Pipe()
 {
-  myDegmax = 10;
+  myDegmax = 11;
   mySegmax = 100;
+  myContinuity = GeomAbs_C2;
   myMode = GeomFill_IsCorrectedFrenet;
   myForceApproxC1 = Standard_False;
 }
@@ -84,42 +85,26 @@ BRepFill_Pipe::BRepFill_Pipe()
 
 BRepFill_Pipe::BRepFill_Pipe(const TopoDS_Wire&  Spine,
                             const TopoDS_Shape& Profile,
+                             const GeomFill_Trihedron aMode,
+                             const Standard_Boolean ForceApproxC1,
                             const Standard_Boolean KPart)
+                             
 {
-  myDegmax = 10;
+  myDegmax = 11;
   mySegmax = 100;
+  
   myMode = GeomFill_IsCorrectedFrenet;
-  myForceApproxC1 = Standard_False;
-  Perform(Spine, Profile, KPart);
-}
-
-//=======================================================================
-//function : SetMode
-//purpose  : Set the mode of sweeping
-//           It can be:
-//           - Frenet
-//           - Corrected Frenet
-//           - Discrete Trihedron
-//=======================================================================
-
-void BRepFill_Pipe::SetMode(const GeomFill_Trihedron aMode)
-{
   if (aMode == GeomFill_IsFrenet ||
       aMode == GeomFill_IsCorrectedFrenet ||
       aMode == GeomFill_IsDiscreteTrihedron)
     myMode = aMode;
-}
-
-//=======================================================================
-//function : SetForceApproxC1
-//purpose  : Set the flag that indicates attempt to approximate
-//           a C1-continuous surface if a swept surface proved
-//           to be C0.
-//=======================================================================
 
-void BRepFill_Pipe::SetForceApproxC1(const Standard_Boolean ForceApproxC1)
-{
+  myContinuity = GeomAbs_C2;
+  if (myMode == GeomFill_IsDiscreteTrihedron)
+    myContinuity = GeomAbs_C0;
+  
   myForceApproxC1 = ForceApproxC1;
+  Perform(Spine, Profile, KPart);
 }
 
 
@@ -411,7 +396,7 @@ TopoDS_Wire BRepFill_Pipe::PipeLine(const gp_Pnt& Point) const
  // Sweeping
  BRepFill_Sweep MkSw(Section, myLoc, Standard_True);
  MkSw.SetForceApproxC1(myForceApproxC1);
- MkSw.Build( BRepFill_Modified, GeomAbs_C2, GeomFill_Location, myDegmax, mySegmax );
+ MkSw.Build( BRepFill_Modified, myContinuity, GeomFill_Location, myDegmax, mySegmax );
  TopoDS_Shape aLocalShape = MkSw.Shape();
  return TopoDS::Wire(aLocalShape);
 // return TopoDS::Wire(MkSw.Shape());
@@ -537,7 +522,7 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
        new (BRepFill_ShapeLaw) (TopoDS::Vertex(TheS));
       BRepFill_Sweep MkSw(Section, myLoc, Standard_True);
       MkSw.SetForceApproxC1(myForceApproxC1);
-      MkSw.Build( BRepFill_Modified, GeomAbs_C2, GeomFill_Location, myDegmax, mySegmax );
+      MkSw.Build( BRepFill_Modified, myContinuity, GeomFill_Location, myDegmax, mySegmax );
       result = MkSw.Shape();
     }
 
@@ -548,7 +533,7 @@ TopoDS_Shape BRepFill_Pipe::MakeShape(const TopoDS_Shape& S,
       MkSw.SetBounds(TopoDS::Wire(TheFirst), 
                     TopoDS::Wire(TheLast));
       MkSw.SetForceApproxC1(myForceApproxC1);
-      MkSw.Build( BRepFill_Modified, GeomAbs_C2, GeomFill_Location, myDegmax, mySegmax );
+      MkSw.Build( BRepFill_Modified, myContinuity, GeomFill_Location, myDegmax, mySegmax );
       result = MkSw.Shape();
 
       // Labeling of elements
index 7df0994..74e5208 100755 (executable)
@@ -282,7 +282,7 @@ static Handle(Geom2d_Curve) Couture(const TopoDS_Edge& E,
 
 static Standard_Boolean CheckSameParameter 
 (const Handle(Adaptor3d_HCurve)&   C3d,
- Handle(Geom2d_Curve)&           Pcurv,
const Handle(Geom2d_Curve)&           Pcurv,
  const Handle(Adaptor3d_HSurface)& S,
  const Standard_Real             tol3d,
  Standard_Real&                  tolreached)
@@ -1458,6 +1458,15 @@ static TopoDS_Edge BuildEdge(const Handle(Geom_Surface)& S,
                    Iso->FirstParameter(), 
                    Iso->LastParameter());
 
+  Standard_Real MaxTol = 1.e-4;
+  Standard_Real theTol;
+  GeomAdaptor_Curve GAiso(Iso);
+  Handle(GeomAdaptor_HCurve) GAHiso = new GeomAdaptor_HCurve(GAiso);
+  GeomAdaptor_Surface GAsurf(S);
+  Handle(GeomAdaptor_HSurface) GAHsurf = new GeomAdaptor_HSurface(GAsurf);
+  CheckSameParameter( GAHiso, L, GAHsurf, MaxTol, theTol);
+  B.UpdateEdge(E, theTol);
+
   return E;
 }
 
index a0f8b4e..7784726 100755 (executable)
@@ -59,21 +59,15 @@ is
        -- composite solid.
     returns MakePipe from BRepOffsetAPI;
     
-    SetMode(me : in out;
-           aMode : Trihedron from GeomFill);
-       ---Purpose: Set the mode of sweeping
-       --          It can be:
-       --          - Frenet
-       --          - Corrected Frenet
-       --          - Discrete Trihedron
-       --          By default the mode is Corrected Frenet
-    
-    SetForceApproxC1(me : in out;
-                    ForceApproxC1 : Boolean from Standard);
-       ---Purpose: Set the flag that indicates attempt to approximate
-       --          a C1-continuous surface if a swept surface proved
-       --          to be C0.
-
+    Create( Spine   : Wire  from TopoDS;
+           Profile : Shape from TopoDS;
+           aMode   : Trihedron from GeomFill;
+           ForceApproxC1 : Boolean from Standard = Standard_False)
+       ---Purpose: the same as previous but with setting of
+       --          mode of sweep and the flag that indicates attempt
+       --          to approximate a C1-continuous surface if a swept
+       --          surface proved to be C0.
+    returns MakePipe from BRepOffsetAPI;
 
     Pipe(me) returns Pipe from BRepFill
        ---C++: return const &
index 5b0374b..7dc1cec 100755 (executable)
 
 //=======================================================================
 //function : BRepOffsetAPI_MakePipe
-//purpose  : 
+//purpose  : constructor
 //=======================================================================
 
 BRepOffsetAPI_MakePipe::BRepOffsetAPI_MakePipe(const TopoDS_Wire&  Spine ,
-                                  const TopoDS_Shape& Profile)
+                                               const TopoDS_Shape& Profile)
      : myPipe(Spine, Profile)
 {
   Build();
 }
 
 //=======================================================================
-//function : SetMode
-//purpose  : Set the mode of sweeping
+//function : BRepOffsetAPI_MakePipe
+//purpose  : constructor
+//           Set the mode of sweeping
 //           It can be:
 //           - Frenet
 //           - Corrected Frenet
 //           - Discrete Trihedron
-//=======================================================================
-
-void BRepOffsetAPI_MakePipe::SetMode(const GeomFill_Trihedron aMode)
-{
-  myPipe.SetMode(aMode);
-}
-
-//=======================================================================
-//function : SetForceApproxC1
-//purpose  : Set the flag that indicates attempt to approximate
+//           Also set the flag that indicates attempt to approximate
 //           a C1-continuous surface if a swept surface proved
 //           to be C0.
 //=======================================================================
 
-void BRepOffsetAPI_MakePipe::SetForceApproxC1(const Standard_Boolean ForceApproxC1)
+BRepOffsetAPI_MakePipe::BRepOffsetAPI_MakePipe(const TopoDS_Wire&  Spine ,
+                                               const TopoDS_Shape& Profile,
+                                               const GeomFill_Trihedron aMode,
+                                               const Standard_Boolean ForceApproxC1)
+  : myPipe(Spine, Profile, aMode, ForceApproxC1)
 {
-  myPipe.SetForceApproxC1(ForceApproxC1);
+  Build();
 }
 
 //=======================================================================
index f493fd7..0c42d08 100755 (executable)
@@ -133,23 +133,51 @@ static Standard_Integer revol(Draw_Interpretor& ,
 // pipe
 //=======================================================================
 
-static Standard_Integer pipe(Draw_Interpretor& ,
+static Standard_Integer pipe(Draw_Interpretor& di,
                             Standard_Integer n, const char** a)
 {
-  if ( n < 4) return 1;
+  if (n == 1)
+  {
+    di << "pipe result Wire_spine Profile [Mode [Approx]]" << "\n";
+    di << "Mode = 0 - CorrectedFrenet," << "\n";
+    di << "     = 1 - Frenet," << "\n";
+    di << "     = 2 - DiscreteTrihedron" << "\n";
+    di << "Approx - force C1-approximation if result is C0" << "\n";
+    return 0;
+  }
+  
+  if (n > 1 && n < 4) return 1;
 
   TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
   if ( Spine.IsNull()) return 1;
 
   TopoDS_Shape Profile = DBRep::Get(a[3]);
   if ( Profile.IsNull()) return 1;
+
+  GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
+  if (n >= 5)
+  {
+    Standard_Integer iMode = atoi(a[4]);
+    if (iMode == 1)
+      Mode = GeomFill_IsFrenet;
+    else if (iMode == 2)
+      Mode = GeomFill_IsDiscreteTrihedron;
+  }
+
+  Standard_Boolean ForceApproxC1 = Standard_False;
+  if (n >= 6)
+    ForceApproxC1 = Standard_True;
   
-  TopoDS_Shape S = BRepOffsetAPI_MakePipe(TopoDS::Wire(Spine),Profile);
+  TopoDS_Shape S = BRepOffsetAPI_MakePipe(TopoDS::Wire(Spine),
+                                          Profile,
+                                          Mode,
+                                          ForceApproxC1);
 
   DBRep::Set(a[1],S);
   
   return 0;
 }
+
 //=======================================================================
 
 static Standard_Integer geompipe(Draw_Interpretor& ,
@@ -827,7 +855,7 @@ void  BRepTest::SweepCommands(Draw_Interpretor& theCommands)
                  __FILE__,revol,g);
   
   theCommands.Add("pipe",
-                 "pipe result Wire_spine Profile",
+                 "pipe result Wire_spine Profile [Mode [Approx]], no args to get help",
                  __FILE__,pipe,g);
   
   theCommands.Add("evolved",
index e64df5e..e565fdb 100755 (executable)
@@ -69,7 +69,7 @@ static TopAbs_Orientation Orientation(const TopoDS_Shape&,
 
 LocOpe_Pipe::LocOpe_Pipe(const TopoDS_Wire& Spine,
                         const TopoDS_Shape& Profile) : 
-          myPipe(Spine,Profile,Standard_False)
+          myPipe(Spine,Profile)
 {
 
   TopoDS_Shape Result = myPipe.Shape();
diff --git a/tests/bugs/modalg_5/bug23870_1 b/tests/bugs/modalg_5/bug23870_1
new file mode 100755 (executable)
index 0000000..8fbda8b
--- /dev/null
@@ -0,0 +1,30 @@
+puts "============"
+puts "OCC23870"
+puts "============"
+puts ""
+#######################################################################
+# Integration of new options of sweeping into BRepOffsetAPI_MakePipe algorithm.
+#######################################################################
+
+set BugNumber OCC23870
+
+restore [locate_data_file bug23824_AXE.brep] spine 
+restore [locate_data_file bug23824_profil.brep] profile 
+
+wire spine spine
+
+pipe result spine profile 2 approx
+
+set square 516.633
+
+set nb_v_good 4
+set nb_e_good 7
+set nb_w_good 3
+set nb_f_good 3
+set nb_sh_good 1
+set nb_sol_good 0
+set nb_compsol_good 0
+set nb_compound_good 0
+set nb_shape_good 18
+
+set 2dviewer 1
diff --git a/tests/bugs/modalg_5/bug23870_2 b/tests/bugs/modalg_5/bug23870_2
new file mode 100755 (executable)
index 0000000..0cc6407
--- /dev/null
@@ -0,0 +1,31 @@
+puts "============"
+puts "OCC23870"
+puts "============"
+puts ""
+#######################################################################
+# Integration of new options of sweeping into BRepOffsetAPI_MakePipe algorithm.
+#######################################################################
+
+set BugNumber OCC23870
+
+restore [locate_data_file bug23824_Case1_Path.brep] spine 
+restore [locate_data_file bug23824_Case1_Profile.brep] profile 
+
+wire spine spine
+wire profile profile
+
+pipe result spine profile 2 approx
+
+set square 8997.97
+
+set nb_v_good 1
+set nb_e_good 2
+set nb_w_good 1
+set nb_f_good 1
+set nb_sh_good 1
+set nb_sol_good 0
+set nb_compsol_good 0
+set nb_compound_good 0
+set nb_shape_good 6
+
+set 2dviewer 1
diff --git a/tests/bugs/modalg_5/bug23870_3 b/tests/bugs/modalg_5/bug23870_3
new file mode 100755 (executable)
index 0000000..ee48b92
--- /dev/null
@@ -0,0 +1,31 @@
+puts "============"
+puts "OCC23870"
+puts "============"
+puts ""
+#######################################################################
+# Integration of new options of sweeping into BRepOffsetAPI_MakePipe algorithm.
+#######################################################################
+
+set BugNumber OCC23870
+
+restore [locate_data_file bug23824_Case2_Path.brep] spine 
+restore [locate_data_file bug23824_Case2_Profile.brep] profile 
+
+wire spine spine
+wire profile profile
+
+pipe result spine profile 2 approx
+
+set square 848.989
+
+set nb_v_good 1
+set nb_e_good 2
+set nb_w_good 1
+set nb_f_good 1
+set nb_sh_good 1
+set nb_sol_good 0
+set nb_compsol_good 0
+set nb_compound_good 0
+set nb_shape_good 6
+
+set 2dviewer 1
diff --git a/tests/bugs/modalg_5/bug23870_4 b/tests/bugs/modalg_5/bug23870_4
new file mode 100755 (executable)
index 0000000..5119482
--- /dev/null
@@ -0,0 +1,32 @@
+puts "============"
+puts "OCC23870"
+puts "============"
+puts ""
+#######################################################################
+# Integration of new options of sweeping into BRepOffsetAPI_MakePipe algorithm.
+#######################################################################
+
+set BugNumber OCC23870
+
+restore [locate_data_file bug23824_Case3_Path.brep] spine 
+restore [locate_data_file bug23824_Case3_Profile.brep] profile 
+
+wire profile profile
+explode spine
+wire spine spine_1
+
+pipe result spine profile 2 approx
+
+set square 38260.5
+
+set nb_v_good 1
+set nb_e_good 2
+set nb_w_good 1
+set nb_f_good 1
+set nb_sh_good 1
+set nb_sol_good 0
+set nb_compsol_good 0
+set nb_compound_good 0
+set nb_shape_good 6
+
+set 2dviewer 1
diff --git a/tests/bugs/modalg_5/bug23870_5 b/tests/bugs/modalg_5/bug23870_5
new file mode 100755 (executable)
index 0000000..8ed112e
--- /dev/null
@@ -0,0 +1,30 @@
+puts "============"
+puts "OCC23870"
+puts "============"
+puts ""
+#######################################################################
+# Integration of new options of sweeping into BRepOffsetAPI_MakePipe algorithm.
+#######################################################################
+
+set BugNumber OCC23870
+
+restore [locate_data_file bug20807_helix_10.brep] spine 
+restore [locate_data_file bug20807_profile.brep] profile 
+
+wire spine spine
+
+pipe result spine profile 1
+
+set square 254837
+
+set nb_v_good 4
+set nb_e_good 8
+set nb_w_good 4
+set nb_f_good 4
+set nb_sh_good 1
+set nb_sol_good 0
+set nb_compsol_good 0
+set nb_compound_good 0
+set nb_shape_good 21
+
+set 2dviewer 1