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 <Geom_RectangularTrimmedSurface.hxx>
30 #include <BRepBuilderAPI_MakeFace.hxx>
31 #include <GC_MakeTrimmedCone.hxx>
33 static Standard_Integer BUC60857 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** argv)
37 gp_Pnt P0(0,0,0), P1(0,0,20), P2(0,0,45);
39 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
40 if(aContext.IsNull()) {
41 di << "Use vinit command before " << argv[0] << "\n";
45 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
46 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
47 DBRep::Set("BUC60857_BLUE",myshape);
48 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
49 aContext->Display(ais1);
50 aContext->SetColor(ais1, Quantity_NOC_BLUE1);
52 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2, R1, 0).Value();
53 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
54 DBRep::Set("BUC60857_RED",myshape2);
55 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
56 aContext->Display(ais2);
57 aContext->SetColor(ais2, Quantity_NOC_RED);
59 Handle(Geom_RectangularTrimmedSurface) S3 = GC_MakeTrimmedCone (P1, P2, R2, R1).Value();
60 TopoDS_Shape myshape3 = BRepBuilderAPI_MakeFace(S3, Precision::Confusion()).Shape();
61 DBRep::Set("BUC60857_GREEN",myshape3);
62 Handle(AIS_Shape) ais3 = new AIS_Shape(myshape3);
63 aContext->Display(ais3);
64 aContext->SetColor(ais3, Quantity_NOC_GREEN);
69 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
70 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
71 #include <SelectMgr_Selection.hxx>
72 #include <StdSelect_BRepOwner.hxx>
73 #include <SelectBasics_SensitiveEntity.hxx>
75 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
77 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
80 static Standard_Integer OCC137 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
82 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
83 if(aContext.IsNull()) {
84 di << argv[0] << "ERROR : use 'vinit' command before \n";
87 if ( argc < 2 || argc > 3) {
88 di << "ERROR : Usage : " << argv[0] << " highlight_mode [shape]\n";
92 ViewerTest_DoubleMapOfInteractiveAndName aMap ;
94 aMap.Assign(GetMapOfAIS());
96 ViewerTest_DoubleMapOfInteractiveAndName& aMap1 = GetMapOfAIS();
97 TCollection_AsciiString aName(argv[2]);
98 Handle(AIS_InteractiveObject) AISObj;
99 if(!aMap1.IsBound2(aName)) {
100 di << "Use 'vdisplay' before\n";
103 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap1.Find2(aName));
105 di << argv[2] << " : No interactive object\n";
108 aMap.Bind(AISObj,aName);
111 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
112 while ( it.More() ) {
113 Handle(AIS_InteractiveObject) AISObj = Handle(AIS_InteractiveObject)::DownCast(it.Key1());
114 AISObj->SetHilightMode(Draw::Atoi(argv[1]));
115 if(AISObj->HasSelection(4)) {
116 //Handle(SelectMgr_Selection)& aSelection = AISObj->Selection(4);
117 const Handle(SelectMgr_Selection)& aSelection = AISObj->Selection(4);
118 if(!aSelection.IsNull()) {
119 for(aSelection->Init();aSelection->More();aSelection->Next()) {
120 Handle(StdSelect_BRepOwner) aO = Handle(StdSelect_BRepOwner)::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId());
121 aO->SetHilightMode(Draw::Atoi(argv[1]));
131 static Standard_Integer OCC137_z (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
133 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
134 if(aContext.IsNull()) {
135 di << argv[0] << "ERROR : use 'vinit' command before \n";
138 if ( argc != 1 && argc != 2) {
139 di << "ERROR : Usage : " << argv[0] << " [ZDetection_mode]\n";
142 aContext->SetZDetection(((argc == 1 || (argc == 2 && Draw::Atoi(argv[1]) == 1)) ? Standard_True : Standard_False));
146 #include <GccEnt_Position.hxx>
147 #include <Geom2dGcc_QualifiedCurve.hxx>
148 #include <Geom2dGcc_Circ2d2TanRad.hxx>
149 #include <gp_Elips2d.hxx>
150 #include <Geom2d_Ellipse.hxx>
151 #include <Geom2d_Circle.hxx>
152 #include <AIS_InteractiveObject.hxx>
154 static Standard_Integer OCC24303(Draw_Interpretor& di, Standard_Integer n, const char** a)
159 const Standard_Integer SolID = Draw::Atoi(a[1]);
162 Standard_Real majorRadius = 2.0;
163 Standard_Real minorRadius = 1.0;
164 gp_Pnt2d p0(gp::Origin2d());
165 gp_Pnt2d p1(4.0,0.0);
167 gp_Elips2d ellipse1 = gp_Elips2d( gp_Ax2d(p0,gp::DX2d()),majorRadius, minorRadius,true);
168 gp_Elips2d ellipse2 = gp_Elips2d( gp_Ax2d(p1,gp::DX2d()),majorRadius, minorRadius,true);
170 Handle(Geom2d_Curve) curve1 = new Geom2d_Ellipse(ellipse1);
171 Handle(Geom2d_Curve) curve2 = new Geom2d_Ellipse(ellipse2);
172 DrawTrSurf::Set("c1", curve1);
173 DrawTrSurf::Set("c2", curve2);
175 gp_Pnt2d centre(5.0,0.0);
176 Standard_Real radius = 3.0;
177 gp_Circ2d theorical_tangent = gp_Circ2d(gp_Ax2d(centre,gp::DX2d()),radius);
179 //Calculate the tangent with Geom2dGcc_Circ2dTanRan
181 const Geom2dAdaptor_Curve AdaptedCurve1 ( curve1 );
182 const Geom2dAdaptor_Curve AdaptedCurve2 ( curve2 );
184 GccEnt_Position curveQualif1 = GccEnt_unqualified;
185 GccEnt_Position curveQualif2 = GccEnt_unqualified;
187 const Geom2dGcc_QualifiedCurve qualifiedCurve1 ( AdaptedCurve1, curveQualif1 );
188 const Geom2dGcc_QualifiedCurve qualifiedCurve2 ( AdaptedCurve2, curveQualif2 );
190 const Geom2dGcc_Circ2d2TanRad circCalc(qualifiedCurve1,qualifiedCurve2,radius,/*Precision::Approximation()*/ 1.0e-9);
192 const Standard_Integer aNbSol = circCalc.NbSolutions();
193 di << "Solutions " << aNbSol << "\n";
195 if((SolID < 1) || (SolID > aNbSol))
197 di << "Wrong SolID value\n";
201 gp_Circ2d calculated_tangent = circCalc.ThisSolution(SolID);
204 for (Standard_Integer i = 1; i <= aNbSol; i++)
206 gp_Circ2d ct = circCalc.ThisSolution(i);
207 Handle (Geom2d_Circle) GSol = new Geom2d_Circle(ct);
208 Sprintf(Buf, "Sol%d",i);
209 DrawTrSurf::Set(Buf, GSol);
212 //This distance is different in OC 6.5.4 and OC 6.6.0
213 Standard_Real dist = theorical_tangent.Location().Distance(calculated_tangent.Location());
214 di << "Distance = " << dist << "\n";
219 void QABugs::Commands_9(Draw_Interpretor& theCommands) {
220 const char *group = "QABugs";
222 theCommands.Add ("BUC60857", "BUC60857", __FILE__, BUC60857, group);
223 theCommands.Add("OCC137","OCC137 mode [shape]",__FILE__,OCC137,group);
224 theCommands.Add("OCC137_z","OCC137_z [ZDetection_mode]",__FILE__,OCC137_z,group);
225 theCommands.Add("OCC24303", "OCC24303 SolID ", __FILE__, OCC24303,group);