1 // Created on: 2004-06-25
2 // Created by: QA Admin (qa)
3 // Copyright (c) 2004-2012 OPEN CASCADE SAS
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.
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.
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.
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>
31 #include <GeomAdaptor_HSurface.hxx>
32 #include <BRepAdaptor_CompCurve.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>
45 static Standard_Integer OCC6001 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
49 di<<"missing parameters"<<"\n";
52 const char *name = argv[1];
53 Handle(Adaptor3d_HCurve) hcurve;
54 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
56 hcurve = new GeomAdaptor_HCurve(curve);
59 TopoDS_Shape wire = DBRep::Get(argv[2]);
60 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
62 di<<"incorrect 1st parameter, curve or wire expected"<<"\n";
65 BRepAdaptor_CompCurve comp_curve(TopoDS::Wire(wire));
66 hcurve = new BRepAdaptor_HCompCurve(comp_curve);
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)
75 di<<"no intersections";
78 for (int i=1; i <= nb; i++)
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";
86 Sprintf(n,"%s_%d",name,i);
87 DrawTrSurf::Set(pname,p);
94 static Standard_Integer OCC5696 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
98 di << "Usage : " << argv[0] << "\n";
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;
111 curve.Edge(par,edge_found,par_edge); // exception is here
112 di << "par_edge = " << par_edge << "\n";
115 catch (Standard_Failure) {di << "OCC5696 Exception \n" ;return 0;}
120 void QABugs::Commands_5(Draw_Interpretor& theCommands) {
121 const char *group = "QABugs";
123 theCommands.Add ("OCC6001", "OCC6001 name curve/wire surface\n\t\tintersect curve by surface",
124 __FILE__, OCC6001, group);
126 theCommands.Add ("OCC5696", "OCC5696",
127 __FILE__, OCC5696, group);