1 // Created on: 2004-06-25
2 // Created by: QA Admin (qa)
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <QABugs.hxx>
17
18 #include <Draw_Interpretor.hxx>
19 #include <Adaptor3d_Curve.hxx>
20 #include <Geom_Curve.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <GeomAdaptor_Curve.hxx>
23 #include <TopoDS_Shape.hxx>
24 #include <DBRep.hxx>
25 #include <GeomAdaptor_Surface.hxx>
26 #include <BRepAdaptor_CompCurve.hxx>
27 #include <TopoDS.hxx>
28 #include <BRepAdaptor_CompCurve.hxx>
29 #include <IntCurveSurface_HInter.hxx>
30 #include <IntCurveSurface_IntersectionPoint.hxx>
31 #include <TopoDS_Edge.hxx>
32 #include <BRepBuilderAPI_MakeEdge.hxx>
33 #include <BRepBuilderAPI_MakeWire.hxx>
34 #include <Standard_ErrorHandler.hxx>
35
36 #include <stdio.h>
37 #include <stdlib.h>
38
OCC6001(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)39 static Standard_Integer OCC6001 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
40 {
41 if (argc < 4)
42 {
43 di<<"missing parameters\n";
44 return 1;
45 }
46 const char *name = argv[1];
47 Handle(Adaptor3d_Curve) hcurve;
48 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
49 if (!curve.IsNull())
50 hcurve = new GeomAdaptor_Curve(curve);
51 else
52 {
53 TopoDS_Shape wire = DBRep::Get(argv[2]);
54 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
55 {
56 di<<"incorrect 1st parameter, curve or wire expected\n";
57 return 1;
58 }
59 BRepAdaptor_CompCurve comp_curve(TopoDS::Wire(wire));
60 hcurve = new BRepAdaptor_CompCurve(comp_curve);
61 }
62 Handle(Geom_Surface) surf = DrawTrSurf::GetSurface(argv[3]);
63 Handle(GeomAdaptor_Surface) hsurf = new GeomAdaptor_Surface(surf);
64 IntCurveSurface_HInter inter;
65 inter.Perform(hcurve, hsurf);
66 int nb = inter.NbPoints();
67 if (!inter.IsDone() || nb == 0)
68 {
69 di<<"no intersections";
70 return 0;
71 }
72 for (int i=1; i <= nb; i++)
73 {
74 const IntCurveSurface_IntersectionPoint &int_pnt = inter.Point(i);
75 double par = int_pnt.W();
76 gp_Pnt p = int_pnt.Pnt();
77 di<<"inter "<<i<<": W = "<<par<<"\n"
78 <<"\tpnt = "<<p.X()<<" "<<p.Y()<<" "<<p.Z()<<"\n";
79 char n[20], *pname=n;
80 Sprintf(n,"%s_%d",name,i);
81 DrawTrSurf::Set(pname,p);
82 }
83
84 return 0;
85
86 }
87
OCC5696(Draw_Interpretor & di,Standard_Integer argc,const char ** argv)88 static Standard_Integer OCC5696 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
89 {
90 if (argc != 1)
91 {
92 di << "Usage : " << argv[0] << "\n";
93 return 1;
94 }
95 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,0),gp_Pnt(2,0,0));
96 TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edge);
97 BRepAdaptor_CompCurve curve(wire);
98 Standard_Real first = curve.FirstParameter();
99 Standard_Real last = curve.LastParameter();
100 Standard_Real par = (first + last)/2;
101 Standard_Real par_edge;
102 TopoDS_Edge edge_found;
103 try {
104 OCC_CATCH_SIGNALS
105 curve.Edge(par,edge_found,par_edge); // exception is here
106 di << "par_edge = " << par_edge << "\n";
107 }
108
109 catch (Standard_Failure const&) {di << "OCC5696 Exception \n" ;return 0;}
110
111 return 0;
112 }
113
Commands_5(Draw_Interpretor & theCommands)114 void QABugs::Commands_5(Draw_Interpretor& theCommands) {
115 const char *group = "QABugs";
116
117 theCommands.Add ("OCC6001", "OCC6001 name curve/wire surface\n\t\tintersect curve by surface",
118 __FILE__, OCC6001, group);
119
120 theCommands.Add ("OCC5696", "OCC5696",
121 __FILE__, OCC5696, group);
122
123 return;
124 }
125