1 // Created on: 2004-06-25
2 // Created by: QA Admin (qa)
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
18 #include <Draw_Interpretor.hxx>
19 #include <Adaptor3d_HCurve.hxx>
20 #include <Geom_Curve.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <GeomAdaptor_HCurve.hxx>
23 #include <TopoDS_Shape.hxx>
25 #include <GeomAdaptor_HSurface.hxx>
26 #include <BRepAdaptor_CompCurve.hxx>
28 #include <BRepAdaptor_HCompCurve.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>
39 static Standard_Integer OCC6001 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
43 di<<"missing parameters\n";
46 const char *name = argv[1];
47 Handle(Adaptor3d_HCurve) hcurve;
48 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
50 hcurve = new GeomAdaptor_HCurve(curve);
53 TopoDS_Shape wire = DBRep::Get(argv[2]);
54 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
56 di<<"incorrect 1st parameter, curve or wire expected\n";
59 BRepAdaptor_CompCurve comp_curve(TopoDS::Wire(wire));
60 hcurve = new BRepAdaptor_HCompCurve(comp_curve);
62 Handle(Geom_Surface) surf = DrawTrSurf::GetSurface(argv[3]);
63 Handle(GeomAdaptor_HSurface) hsurf = new GeomAdaptor_HSurface(surf);
64 IntCurveSurface_HInter inter;
65 inter.Perform(hcurve, hsurf);
66 int nb = inter.NbPoints();
67 if (!inter.IsDone() || nb == 0)
69 di<<"no intersections";
72 for (int i=1; i <= nb; i++)
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";
80 Sprintf(n,"%s_%d",name,i);
81 DrawTrSurf::Set(pname,p);
88 static Standard_Integer OCC5696 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
92 di << "Usage : " << argv[0] << "\n";
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;
105 curve.Edge(par,edge_found,par_edge); // exception is here
106 di << "par_edge = " << par_edge << "\n";
109 catch (Standard_Failure) {di << "OCC5696 Exception \n" ;return 0;}
114 void QABugs::Commands_5(Draw_Interpretor& theCommands) {
115 const char *group = "QABugs";
117 theCommands.Add ("OCC6001", "OCC6001 name curve/wire surface\n\t\tintersect curve by surface",
118 __FILE__, OCC6001, group);
120 theCommands.Add ("OCC5696", "OCC5696",
121 __FILE__, OCC5696, group);