0023771: Writing offset-based surfaces of revolution to IGES
authorika <ika@opencascade.com>
Thu, 16 May 2013 07:14:51 +0000 (11:14 +0400)
committerika <ika@opencascade.com>
Thu, 16 May 2013 07:14:51 +0000 (11:14 +0400)
Parameter to write offset curves like b-splines was added
Change function, which convert offset curves to b-splines
Added test command "test_offset"
Added test cases bugs/xde/bug23771_1 bug23771_2

src/GeomToIGES/GeomToIGES_GeomCurve.cxx
src/IGESData/IGESData.cxx
src/QABugs/QABugs_19.cxx
tests/bugs/xde/bug23771_1 [new file with mode: 0644]
tests/bugs/xde/bug23771_2 [new file with mode: 0644]

index 748c4bf..2697ce8 100755 (executable)
@@ -79,6 +79,7 @@
 #include <IGESGeom_TransformationMatrix.hxx>
 
 #include <Interface_Macros.hxx>
+#include <Interface_Static.hxx>
 
 #include <Precision.hxx>
 
@@ -90,6 +91,8 @@
 #include <BSplCLib.hxx>
 #include <GeomConvert_ApproxCurve.hxx>
 
+#include <ShapeCustom_BSplineRestriction.hxx>
+
 // Pour toutes les courbes infinies soit 
 // Udeb <= -Precision::Infinite() et/ou Ufin >= Precision::Infinite()
 // on choisit arbitrairement de les construire entre 
@@ -827,6 +830,12 @@ Handle(IGESData_IGESEntity) GeomToIGES_GeomCurve::TransferCurve
   if (Precision::IsNegativeInfinite(Udeb)) U1 = -Precision::Infinite();
   if (Precision::IsPositiveInfinite(Ufin)) U2 = Precision::Infinite();
 
+  if (Interface_Static::IVal("write.iges.offset.mode") == 0)
+  {
+    res = TransferCurve(GeomConvert::CurveToBSplineCurve(start),U1,U2);
+    return res;
+  }
+
   Handle(Geom_Curve) Curve = start->BasisCurve();
   Standard_Real Deb = Curve->FirstParameter();
   Standard_Real Fin = Curve->LastParameter();
index 06e812f..1c4d933 100755 (executable)
@@ -132,6 +132,13 @@ static Handle(IGESData_DefaultSpecific)   speci;
   Interface_Static::Init ("XSTEP","write.iges.plane.mode",'&',"eval Plane");
   Interface_Static::Init ("XSTEP","write.iges.plane.mode",'&',"eval BSpline");
   Interface_Static::SetIVal ("write.iges.plane.mode",0);
+
+   //ika added parameter for writing offset curves like BSplines 12.04.2013 
+  Interface_Static::Init ("XSTEP","write.iges.offset.mode",'e',"");
+  Interface_Static::Init ("XSTEP","write.iges.offset.mode",'&',"ematch 0");
+  Interface_Static::Init ("XSTEP","write.iges.offset.mode",'&',"eval On");
+  Interface_Static::Init ("XSTEP","write.iges.offset.mode",'&',"eval Off");
+  Interface_Static::SetIVal ("write.iges.offset.mode",0);
   // Message File for IGES
   // -----------------
 
index 595a9a7..492b375 100755 (executable)
@@ -409,6 +409,63 @@ static Standard_Integer OCC23683 (Draw_Interpretor& di, Standard_Integer argc,co
   return 0;
 }
 
+#include <gp_Ax1.hxx>
+#include <gp_Ax22d.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom2d_Circle.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepPrimAPI_MakeRevol.hxx>
+#include <Geom2d_OffsetCurve.hxx>
+
+static int test_offset(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  // Check the command arguments
+  if ( argc != 1 )
+  {
+    di << "Error: " << argv[0] << " - invalid number of arguments" << "\n";
+    di << "Usage: type help " << argv[0] << "\n";
+    return 1; // TCL_ERROR
+  }
+
+  gp_Ax1 RotoAx( gp::Origin(), gp::DZ() );
+  gp_Ax22d Ax2( gp::Origin2d(), gp::DY2d(), gp::DX2d() );
+  Handle(Geom_Surface) Plane = new Geom_Plane( gp::YOZ() );
+
+  di << "<<<< Preparing sample surface of revolution based on trimmed curve >>>>" << "\n";
+  di << "-----------------------------------------------------------------------" << "\n";
+
+  Handle(Geom2d_Circle) C2d1 = new Geom2d_Circle(Ax2, 1.0);
+  Handle(Geom2d_TrimmedCurve) C2d1Trimmed = new Geom2d_TrimmedCurve(C2d1, 0.0, M_PI/2.0);
+  TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(C2d1Trimmed, Plane);
+
+  DBRep::Set("e1", E1);
+
+  BRepPrimAPI_MakeRevol aRevolBuilder1(E1, RotoAx);
+  TopoDS_Face F1 = TopoDS::Face( aRevolBuilder1.Shape() );
+
+  DBRep::Set("f1", F1);
+
+  di << "Result: f1" << "\n";
+
+  di << "<<<< Preparing sample surface of revolution based on offset curve  >>>>" << "\n";
+  di << "-----------------------------------------------------------------------" << "\n";
+
+  Handle(Geom2d_OffsetCurve) C2d2Offset = new Geom2d_OffsetCurve(C2d1Trimmed, -0.5);
+  TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(C2d2Offset, Plane);
+
+  DBRep::Set("e2", E2);
+
+  BRepPrimAPI_MakeRevol aRevolBuilder2(E2, RotoAx);
+  TopoDS_Face F2 = TopoDS::Face( aRevolBuilder2.Shape() );
+
+  DBRep::Set("f2", F2);
+
+  di << "Result: f2" << "\n";
+
+  return 0;
+}
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -422,6 +479,7 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC22595", "OCC22595", __FILE__, OCC22595, group);
   theCommands.Add ("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
   theCommands.Add ("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
+  theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group);
 
   return;
 }
diff --git a/tests/bugs/xde/bug23771_1 b/tests/bugs/xde/bug23771_1
new file mode 100644 (file)
index 0000000..d26c224
--- /dev/null
@@ -0,0 +1,16 @@
+puts "==========="
+puts "OCC23771"
+puts "==========="
+
+#########################################################
+# Writing offset-based surface of revolution to IGES
+#########################################################
+
+pload QAcommands
+
+test_offset
+brepiges f1 ${imagedir}/f1.igs
+igesread ${imagedir}/f1.igs result *
+
+set 2dviewer 0
+
diff --git a/tests/bugs/xde/bug23771_2 b/tests/bugs/xde/bug23771_2
new file mode 100644 (file)
index 0000000..a023cef
--- /dev/null
@@ -0,0 +1,17 @@
+puts "==========="
+puts "OCC23771"
+puts "==========="
+
+#########################################################
+# Writing offset-based surface of revolution to IGES
+#########################################################
+
+pload QAcommands
+
+test_offset
+brepiges f2 ${imagedir}/f2.igs
+igesread ${imagedir}/f2.igs result *
+
+set 2dviewer 0
+
+