1 // Created on: 2002-03-18
2 // Created by: QA Admin
3 // Copyright (c) 2002-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.
19 #include <Draw_Interpretor.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <AIS_InteractiveContext.hxx>
23 #include <ViewerTest.hxx>
24 #include <AIS_Shape.hxx>
25 #include <TopoDS_Shape.hxx>
29 #include <BRepBuilderAPI_MakeFace.hxx>
30 #include <GC_MakeTrimmedCone.hxx>
32 static Standard_Integer BUC60857 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** argv)
36 gp_Pnt P0(0,0,0), P1(0,0,20), P2(0,0,45);
38 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
39 if(aContext.IsNull()) {
40 di << "Use vinit command before " << argv[0] << "\n";
44 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
45 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
46 DBRep::Set("BUC60857_BLUE",myshape);
47 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
48 aContext->Display (ais1, Standard_False);
49 aContext->SetColor (ais1, Quantity_NOC_BLUE1, Standard_False);
51 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2, R1, 0).Value();
52 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
53 DBRep::Set("BUC60857_RED",myshape2);
54 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
55 aContext->Display (ais2, Standard_False);
56 aContext->SetColor (ais2, Quantity_NOC_RED, Standard_False);
58 Handle(Geom_RectangularTrimmedSurface) S3 = GC_MakeTrimmedCone (P1, P2, R2, R1).Value();
59 TopoDS_Shape myshape3 = BRepBuilderAPI_MakeFace(S3, Precision::Confusion()).Shape();
60 DBRep::Set("BUC60857_GREEN",myshape3);
61 Handle(AIS_Shape) ais3 = new AIS_Shape(myshape3);
62 aContext->Display (ais3, Standard_False);
63 aContext->SetColor (ais3, Quantity_NOC_GREEN, Standard_True);
68 #include <Geom2dGcc_QualifiedCurve.hxx>
69 #include <Geom2dGcc_Circ2d2TanRad.hxx>
70 #include <gp_Elips2d.hxx>
71 #include <Geom2d_Ellipse.hxx>
72 #include <Geom2d_Circle.hxx>
74 static Standard_Integer OCC24303(Draw_Interpretor& di, Standard_Integer n, const char** a)
79 const Standard_Integer SolID = Draw::Atoi(a[1]);
82 Standard_Real majorRadius = 2.0;
83 Standard_Real minorRadius = 1.0;
84 gp_Pnt2d p0(gp::Origin2d());
87 gp_Elips2d ellipse1 = gp_Elips2d( gp_Ax2d(p0,gp::DX2d()),majorRadius, minorRadius,true);
88 gp_Elips2d ellipse2 = gp_Elips2d( gp_Ax2d(p1,gp::DX2d()),majorRadius, minorRadius,true);
90 Handle(Geom2d_Curve) curve1 = new Geom2d_Ellipse(ellipse1);
91 Handle(Geom2d_Curve) curve2 = new Geom2d_Ellipse(ellipse2);
92 DrawTrSurf::Set("c1", curve1);
93 DrawTrSurf::Set("c2", curve2);
95 gp_Pnt2d centre(5.0,0.0);
96 Standard_Real radius = 3.0;
97 gp_Circ2d theorical_tangent = gp_Circ2d(gp_Ax2d(centre,gp::DX2d()),radius);
99 //Calculate the tangent with Geom2dGcc_Circ2dTanRan
101 const Geom2dAdaptor_Curve AdaptedCurve1 ( curve1 );
102 const Geom2dAdaptor_Curve AdaptedCurve2 ( curve2 );
104 GccEnt_Position curveQualif1 = GccEnt_unqualified;
105 GccEnt_Position curveQualif2 = GccEnt_unqualified;
107 const Geom2dGcc_QualifiedCurve qualifiedCurve1 ( AdaptedCurve1, curveQualif1 );
108 const Geom2dGcc_QualifiedCurve qualifiedCurve2 ( AdaptedCurve2, curveQualif2 );
110 const Geom2dGcc_Circ2d2TanRad circCalc(qualifiedCurve1,qualifiedCurve2,radius,/*Precision::Approximation()*/ 1.0e-9);
112 const Standard_Integer aNbSol = circCalc.NbSolutions();
113 di << "Solutions " << aNbSol << "\n";
115 if((SolID < 1) || (SolID > aNbSol))
117 di << "Wrong SolID value\n";
121 gp_Circ2d calculated_tangent = circCalc.ThisSolution(SolID);
124 for (Standard_Integer i = 1; i <= aNbSol; i++)
126 gp_Circ2d ct = circCalc.ThisSolution(i);
127 Handle (Geom2d_Circle) GSol = new Geom2d_Circle(ct);
128 Sprintf(Buf, "Sol%d",i);
129 DrawTrSurf::Set(Buf, GSol);
132 //This distance is different in OC 6.5.4 and OC 6.6.0
133 Standard_Real dist = theorical_tangent.Location().Distance(calculated_tangent.Location());
134 di << "Distance = " << dist << "\n";
139 void QABugs::Commands_9(Draw_Interpretor& theCommands) {
140 const char *group = "QABugs";
142 theCommands.Add ("BUC60857", "BUC60857", __FILE__, BUC60857, group);
143 theCommands.Add("OCC24303", "OCC24303 SolID ", __FILE__, OCC24303,group);