0022898: IGES import fails in german environment
[occt.git] / src / QABugs / QABugs_5.cxx
1 // Created on: 2004-06-25
2 // Created by: QA Admin (qa)
3 // Copyright (c) 2004-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21
22 #include <QABugs.hxx>
23
24 #include <Draw_Interpretor.hxx>
25 #include <Adaptor3d_HCurve.hxx>
26 #include <Geom_Curve.hxx>
27 #include <DrawTrSurf.hxx>
28 #include <GeomAdaptor_HCurve.hxx>
29 #include <TopoDS_Shape.hxx>
30 #include <DBRep.hxx>
31 #include <GeomAdaptor_HSurface.hxx>
32 #include <BRepAdaptor_CompCurve.hxx>
33 #include <TopoDS.hxx>
34 #include <BRepAdaptor_HCompCurve.hxx>
35 #include <IntCurveSurface_HInter.hxx>
36 #include <IntCurveSurface_IntersectionPoint.hxx>
37 #include <TopoDS_Edge.hxx>
38 #include <BRepBuilderAPI_MakeEdge.hxx>
39 #include <BRepBuilderAPI_MakeWire.hxx>
40 #include <Standard_ErrorHandler.hxx>
41
42 #include <stdio.h>
43 #include <stdlib.h>
44
45 static Standard_Integer OCC6001 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
46 {
47   if (argc < 4)
48   {
49     di<<"missing parameters"<<"\n";
50     return 1;
51   }
52   const char *name = argv[1];
53   Handle(Adaptor3d_HCurve) hcurve;
54   Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
55   if (!curve.IsNull())
56     hcurve = new GeomAdaptor_HCurve(curve);
57   else
58   {
59     TopoDS_Shape wire = DBRep::Get(argv[2]);
60     if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
61     {
62       di<<"incorrect 1st parameter, curve or wire expected"<<"\n";
63       return 1;
64     }
65     BRepAdaptor_CompCurve comp_curve(TopoDS::Wire(wire));
66     hcurve = new BRepAdaptor_HCompCurve(comp_curve);
67   }
68   Handle(Geom_Surface) surf = DrawTrSurf::GetSurface(argv[3]);
69   Handle(GeomAdaptor_HSurface) hsurf = new GeomAdaptor_HSurface(surf);
70   IntCurveSurface_HInter inter;
71   inter.Perform(hcurve, hsurf);
72   int nb = inter.NbPoints();
73   if (!inter.IsDone() || nb == 0)
74   {
75     di<<"no intersections";
76     return 0;
77   }
78   for (int i=1; i <= nb; i++)
79   {
80     const IntCurveSurface_IntersectionPoint &int_pnt = inter.Point(i);
81     double par = int_pnt.W();
82     gp_Pnt p = int_pnt.Pnt();
83     di<<"inter "<<i<<": W = "<<par<<"\n"
84       <<"\tpnt = "<<p.X()<<" "<<p.Y()<<" "<<p.Z()<<"\n";
85     char n[20], *pname=n;
86     Sprintf(n,"%s_%d",name,i);
87     DrawTrSurf::Set(pname,p);
88   }
89
90   return 0;
91
92 }
93
94 static Standard_Integer OCC5696 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
95 {
96   if (argc != 1)
97   {
98     di << "Usage : " << argv[0] << "\n";
99     return 1;
100   }
101   TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,0),gp_Pnt(2,0,0));
102   TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edge);
103   BRepAdaptor_CompCurve curve(wire);
104   Standard_Real first = curve.FirstParameter();
105   Standard_Real last = curve.LastParameter();
106   Standard_Real par = (first + last)/2;
107   Standard_Real par_edge;
108   TopoDS_Edge edge_found;
109   try {
110     OCC_CATCH_SIGNALS
111     curve.Edge(par,edge_found,par_edge);  // exception is here
112     di << "par_edge = " << par_edge << "\n";
113   }
114
115   catch (Standard_Failure) {di << "OCC5696 Exception \n" ;return 0;}
116
117   return 0;
118 }
119
120 void QABugs::Commands_5(Draw_Interpretor& theCommands) {
121   const char *group = "QABugs";
122
123   theCommands.Add ("OCC6001", "OCC6001 name curve/wire surface\n\t\tintersect curve by surface", 
124                    __FILE__, OCC6001, group);
125
126   theCommands.Add ("OCC5696", "OCC5696", 
127                    __FILE__, OCC5696, group);
128
129   return;
130 }