1 // Created on: 2002-03-19
2 // Created by: QA Admin
3 // Copyright (c) 2002-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.
23 #include <Draw_Interpretor.hxx>
25 #include <DrawTrSurf.hxx>
26 #include <AIS_InteractiveContext.hxx>
27 #include <ViewerTest.hxx>
28 #include <AIS_Shape.hxx>
29 #include <TopoDS_Shape.hxx>
31 #include <TColStd_Array2OfReal.hxx>
32 #include <V3d_View.hxx>
33 #include <Visual3d_View.hxx>
35 #include <BRepOffsetAPI_Sewing.hxx>
37 #include <AIS_ListOfInteractive.hxx>
38 #include <AIS_ListIteratorOfListOfInteractive.hxx>
40 #include <BRepPrimAPI_MakeBox.hxx>
42 static Standard_Integer BUC60753 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
46 di << "Usage : " << argv[0] << " mode (0 <=mode<=5) ratio (0.0<=ration<=1.0)" <<"\n";
50 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
51 if(myAISContext.IsNull()) {
52 di << "use 'vinit' command before " << argv[0] << "\n";
56 Standard_Real Alpha = M_PI/10.;
57 Standard_Real CosAlpha = Cos (Alpha);
58 Standard_Real SinAlpha = Sin (Alpha);
59 Standard_Real MoinsCosAlpha = Cos (-Alpha);
60 Standard_Real MoinsSinAlpha = Sin (-Alpha);
61 TColStd_Array2OfReal TrsfI (0, 3, 0, 3);
62 TColStd_Array2OfReal TrsfX (0, 3, 0, 3);
63 TColStd_Array2OfReal TrsfY (0, 3, 0, 3);
64 TColStd_Array2OfReal TrsfZ (0, 3, 0, 3);
65 TColStd_Array2OfReal Trsfx (0, 3, 0, 3);
66 TColStd_Array2OfReal Trsfy (0, 3, 0, 3);
67 TColStd_Array2OfReal Trsfz (0, 3, 0, 3);
72 TrsfX.SetValue (i, j, 1.0);
73 TrsfY.SetValue (i, j, 1.0);
74 TrsfZ.SetValue (i, j, 1.0);
75 Trsfx.SetValue (i, j, 1.0);
76 Trsfy.SetValue (i, j, 1.0);
77 Trsfz.SetValue (i, j, 1.0);
78 TrsfI.SetValue (i, j, 1.0);
80 TrsfX.SetValue (i, j, 0.0);
81 TrsfY.SetValue (i, j, 0.0);
82 TrsfZ.SetValue (i, j, 0.0);
83 Trsfx.SetValue (i, j, 0.0);
84 Trsfy.SetValue (i, j, 0.0);
85 Trsfz.SetValue (i, j, 0.0);
86 TrsfI.SetValue (i, j, 0.0);
89 // Rotation Alpha autour de l'axe X
90 TrsfX.SetValue (1, 1, CosAlpha);
91 TrsfX.SetValue (2, 2, CosAlpha);
92 TrsfX.SetValue (1, 2, -SinAlpha);
93 TrsfX.SetValue (2, 1, SinAlpha);
95 // Rotation Alpha autour de l'axe Y
96 TrsfY.SetValue (0, 0, CosAlpha);
97 TrsfY.SetValue (2, 2, CosAlpha);
98 TrsfY.SetValue (0, 2, SinAlpha);
99 TrsfY.SetValue (2, 0, -SinAlpha);
101 // Rotation Alpha autour de l'axe Z
102 TrsfZ.SetValue (0, 0, CosAlpha);
103 TrsfZ.SetValue (1, 1, CosAlpha);
104 TrsfZ.SetValue (0, 1, -SinAlpha);
105 TrsfZ.SetValue (1, 0, SinAlpha);
107 // Rotation -Alpha autour de l'axe X
108 Trsfx.SetValue (1, 1, MoinsCosAlpha);
109 Trsfx.SetValue (2, 2, MoinsCosAlpha);
110 Trsfx.SetValue (1, 2, -MoinsSinAlpha);
111 Trsfx.SetValue (2, 1, MoinsSinAlpha);
113 // Rotation -Alpha autour de l'axe Y
114 Trsfy.SetValue (0, 0, MoinsCosAlpha);
115 Trsfy.SetValue (2, 2, MoinsCosAlpha);
116 Trsfy.SetValue (0, 2, MoinsSinAlpha);
117 Trsfy.SetValue (2, 0, -MoinsSinAlpha);
119 // Rotation -Alpha autour de l'axe Z
120 Trsfz.SetValue (0, 0, MoinsCosAlpha);
121 Trsfz.SetValue (1, 1, MoinsCosAlpha);
122 Trsfz.SetValue (0, 1, -MoinsSinAlpha);
123 Trsfz.SetValue (1, 0, MoinsSinAlpha);
125 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
127 myV3dView->SetAnimationMode(Standard_True,Standard_True);
128 myAISContext-> SetDegenerateModel((Aspect_TypeOfDegenerateModel) Draw::Atoi(argv[1]),Draw::Atof(argv[2]));
132 myV3dView->SetAnimationModeOn();
133 myV3dView->SetComputedMode ( Standard_False );
135 myV3dView->View()->SetTransform (Trsfz);
136 myV3dView->View()->Update ();
138 myV3dView->SetAnimationModeOff();
140 // Timer.Show (cout);
145 static Standard_Integer OCC162 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
148 di << "Usage : " << argv[0] << " name" << "\n";
152 TopoDS_Shape aShape = DBRep::Get(argv[1]);
153 if (aShape.IsNull()) return 0;
155 Standard_Real tolValue = 0.0001;
156 BRepOffsetAPI_Sewing sew(tolValue);
159 TopoDS_Shape aSewed = sew.SewedShape();
164 static Standard_Integer OCC172 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
166 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
167 if(aContext.IsNull()) {
168 di << "use 'vinit' command before " << argv[0] << "\n";
172 AIS_ListOfInteractive aListOfIO;
173 aContext->DisplayedObjects(aListOfIO);
174 AIS_ListIteratorOfListOfInteractive It;
175 for (It.Initialize(aListOfIO);It.More();It.Next())
177 aContext->AddOrRemoveCurrentObject(It.Value());
183 static Standard_Integer OCC204 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
186 di << "Usage : " << argv[0] << " updateviewer=0/1" << "\n";
190 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
191 if (aContext.IsNull()) {
192 di << "use 'vinit' command before " << argv[0] << "\n";
195 Standard_Boolean UpdateViewer = Standard_True;
196 Standard_Integer IntegerUpdateViewer = Draw::Atoi(argv[1]);
197 if (IntegerUpdateViewer == 0) {
198 UpdateViewer = Standard_False;
201 Standard_Integer deltaY = -500;
202 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0 + deltaY, 0), gp_Pnt(100, 100 + deltaY, 100));
203 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120 + deltaY, 120), gp_Pnt(300, 300 + deltaY,300));
204 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320 + deltaY, 320), gp_Pnt(500, 500 + deltaY,500));
206 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
207 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
208 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
210 aContext->Display(ais1);
211 aContext->Display(ais2);
212 aContext->Display(ais3);
214 aContext->AddOrRemoveCurrentObject(ais1);
215 aContext->AddOrRemoveCurrentObject(ais2);
216 aContext->AddOrRemoveCurrentObject(ais3);
218 //printf("\n No of currents = %d", aContext->NbCurrents());
220 aContext->InitCurrent();
223 while(aContext->MoreCurrent())
225 //printf("\n count is = %d", count++);
226 Handle_AIS_InteractiveObject ais = aContext->Current();
227 aContext->Remove(ais, UpdateViewer);
228 aContext->InitCurrent();
234 #include <gp_Lin.hxx>
235 #include <BRepClass3d_Intersector3d.hxx>
236 #include <TopoDS.hxx>
237 static Standard_Integer OCC1651 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
240 di << "Usage : " << argv[0] << " Shape PntX PntY PntZ DirX DirY DirZ" << "\n";
244 TopoDS_Shape aShape = DBRep::Get(argv[1]);
245 if (aShape.IsNull()) return 0;
247 gp_Pnt aP1(Draw::Atof(argv[2]), Draw::Atof(argv[3]), Draw::Atof(argv[4]));
248 gp_Dir aD1(Draw::Atof(argv[5]), Draw::Atof(argv[6]), Draw::Atof(argv[7]));
250 BRepClass3d_Intersector3d aI1;
251 aI1.Perform(aL1, -250, 1e-7, TopoDS::Face(aShape));
252 if(aI1.IsDone() && aI1.HasAPoint()) {
253 gp_Pnt aR1 = aI1.Pnt();
254 di << aR1.X() << " " << aR1.Y() << " " << aR1.Z() << "\n";
260 void QABugs::Commands_8(Draw_Interpretor& theCommands) {
261 const char *group = "QABugs";
263 theCommands.Add("BUC60753", "BUC60753 mode ratio", __FILE__, BUC60753, group);
264 theCommands.Add("OCC162", "OCC162 name", __FILE__, OCC162, group);
265 theCommands.Add("OCC172", "OCC172", __FILE__, OCC172, group);
266 theCommands.Add("OCC204", "OCC204 updateviewer=0/1", __FILE__, OCC204, group);
267 theCommands.Add("OCC1651", "OCC1651 Shape PntX PntY PntZ DirX DirY DirZ", __FILE__, OCC1651, group);