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.
24 #include <Draw_Interpretor.hxx>
26 #include <DrawTrSurf.hxx>
27 #include <AIS_InteractiveContext.hxx>
28 #include <ViewerTest.hxx>
29 #include <AIS_Shape.hxx>
30 #include <TopoDS_Shape.hxx>
32 #include <TColStd_Array2OfReal.hxx>
33 #include <V3d_View.hxx>
34 #include <Visual3d_View.hxx>
36 #include <BRepOffsetAPI_Sewing.hxx>
38 #include <AIS_ListOfInteractive.hxx>
39 #include <AIS_ListIteratorOfListOfInteractive.hxx>
41 #include <BRepPrimAPI_MakeBox.hxx>
43 static Standard_Integer BUC60753 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
47 di << "Usage : " << argv[0] << " mode (0 <=mode<=5) ratio (0.0<=ration<=1.0)" <<"\n";
51 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
52 if(myAISContext.IsNull()) {
53 di << "use 'vinit' command before " << argv[0] << "\n";
57 Standard_Real Alpha = M_PI/10.;
58 Standard_Real CosAlpha = Cos (Alpha);
59 Standard_Real SinAlpha = Sin (Alpha);
60 Standard_Real MoinsCosAlpha = Cos (-Alpha);
61 Standard_Real MoinsSinAlpha = Sin (-Alpha);
62 TColStd_Array2OfReal TrsfI (0, 3, 0, 3);
63 TColStd_Array2OfReal TrsfX (0, 3, 0, 3);
64 TColStd_Array2OfReal TrsfY (0, 3, 0, 3);
65 TColStd_Array2OfReal TrsfZ (0, 3, 0, 3);
66 TColStd_Array2OfReal Trsfx (0, 3, 0, 3);
67 TColStd_Array2OfReal Trsfy (0, 3, 0, 3);
68 TColStd_Array2OfReal Trsfz (0, 3, 0, 3);
73 TrsfX.SetValue (i, j, 1.0);
74 TrsfY.SetValue (i, j, 1.0);
75 TrsfZ.SetValue (i, j, 1.0);
76 Trsfx.SetValue (i, j, 1.0);
77 Trsfy.SetValue (i, j, 1.0);
78 Trsfz.SetValue (i, j, 1.0);
79 TrsfI.SetValue (i, j, 1.0);
81 TrsfX.SetValue (i, j, 0.0);
82 TrsfY.SetValue (i, j, 0.0);
83 TrsfZ.SetValue (i, j, 0.0);
84 Trsfx.SetValue (i, j, 0.0);
85 Trsfy.SetValue (i, j, 0.0);
86 Trsfz.SetValue (i, j, 0.0);
87 TrsfI.SetValue (i, j, 0.0);
90 // Rotation Alpha autour de l'axe X
91 TrsfX.SetValue (1, 1, CosAlpha);
92 TrsfX.SetValue (2, 2, CosAlpha);
93 TrsfX.SetValue (1, 2, -SinAlpha);
94 TrsfX.SetValue (2, 1, SinAlpha);
96 // Rotation Alpha autour de l'axe Y
97 TrsfY.SetValue (0, 0, CosAlpha);
98 TrsfY.SetValue (2, 2, CosAlpha);
99 TrsfY.SetValue (0, 2, SinAlpha);
100 TrsfY.SetValue (2, 0, -SinAlpha);
102 // Rotation Alpha autour de l'axe Z
103 TrsfZ.SetValue (0, 0, CosAlpha);
104 TrsfZ.SetValue (1, 1, CosAlpha);
105 TrsfZ.SetValue (0, 1, -SinAlpha);
106 TrsfZ.SetValue (1, 0, SinAlpha);
108 // Rotation -Alpha autour de l'axe X
109 Trsfx.SetValue (1, 1, MoinsCosAlpha);
110 Trsfx.SetValue (2, 2, MoinsCosAlpha);
111 Trsfx.SetValue (1, 2, -MoinsSinAlpha);
112 Trsfx.SetValue (2, 1, MoinsSinAlpha);
114 // Rotation -Alpha autour de l'axe Y
115 Trsfy.SetValue (0, 0, MoinsCosAlpha);
116 Trsfy.SetValue (2, 2, MoinsCosAlpha);
117 Trsfy.SetValue (0, 2, MoinsSinAlpha);
118 Trsfy.SetValue (2, 0, -MoinsSinAlpha);
120 // Rotation -Alpha autour de l'axe Z
121 Trsfz.SetValue (0, 0, MoinsCosAlpha);
122 Trsfz.SetValue (1, 1, MoinsCosAlpha);
123 Trsfz.SetValue (0, 1, -MoinsSinAlpha);
124 Trsfz.SetValue (1, 0, MoinsSinAlpha);
126 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
128 myV3dView->SetAnimationMode(Standard_True,Standard_True);
129 myAISContext-> SetDegenerateModel((Aspect_TypeOfDegenerateModel) atoi(argv[1]),atof(argv[2]));
133 myV3dView->SetAnimationModeOn();
134 myV3dView->SetComputedMode ( Standard_False );
136 myV3dView->View()->SetTransform (Trsfz);
137 myV3dView->View()->Update ();
139 myV3dView->SetAnimationModeOff();
141 // Timer.Show (cout);
146 static Standard_Integer OCC162 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
149 di << "Usage : " << argv[0] << " name" << "\n";
153 TopoDS_Shape aShape = DBRep::Get(argv[1]);
154 if (aShape.IsNull()) return 0;
156 Standard_Real tolValue = 0.0001;
157 BRepOffsetAPI_Sewing sew(tolValue);
160 TopoDS_Shape aSewed = sew.SewedShape();
165 static Standard_Integer OCC172 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
167 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
168 if(aContext.IsNull()) {
169 di << "use 'vinit' command before " << argv[0] << "\n";
173 AIS_ListOfInteractive aListOfIO;
174 aContext->DisplayedObjects(aListOfIO);
175 AIS_ListIteratorOfListOfInteractive It;
176 for (It.Initialize(aListOfIO);It.More();It.Next())
178 aContext->AddOrRemoveCurrentObject(It.Value());
184 static Standard_Integer OCC204 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
187 di << "Usage : " << argv[0] << " updateviewer=0/1" << "\n";
191 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
192 if (aContext.IsNull()) {
193 di << "use 'vinit' command before " << argv[0] << "\n";
196 Standard_Boolean UpdateViewer = Standard_True;
197 Standard_Integer IntegerUpdateViewer = atoi(argv[1]);
198 if (IntegerUpdateViewer == 0) {
199 UpdateViewer = Standard_False;
202 Standard_Integer deltaY = -500;
203 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0 + deltaY, 0), gp_Pnt(100, 100 + deltaY, 100));
204 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120 + deltaY, 120), gp_Pnt(300, 300 + deltaY,300));
205 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320 + deltaY, 320), gp_Pnt(500, 500 + deltaY,500));
207 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
208 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
209 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
211 aContext->Display(ais1);
212 aContext->Display(ais2);
213 aContext->Display(ais3);
215 aContext->AddOrRemoveCurrentObject(ais1);
216 aContext->AddOrRemoveCurrentObject(ais2);
217 aContext->AddOrRemoveCurrentObject(ais3);
219 //printf("\n No of currents = %d", aContext->NbCurrents());
221 aContext->InitCurrent();
224 while(aContext->MoreCurrent())
226 //printf("\n count is = %d", count++);
227 Handle_AIS_InteractiveObject ais = aContext->Current();
228 aContext->Remove(ais, UpdateViewer);
229 aContext->InitCurrent();
235 #include <gp_Lin.hxx>
236 #include <BRepClass3d_Intersector3d.hxx>
237 #include <TopoDS.hxx>
238 static Standard_Integer OCC1651 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
241 di << "Usage : " << argv[0] << " Shape PntX PntY PntZ DirX DirY DirZ" << "\n";
245 TopoDS_Shape aShape = DBRep::Get(argv[1]);
246 if (aShape.IsNull()) return 0;
248 gp_Pnt aP1(atof(argv[2]), atof(argv[3]), atof(argv[4]));
249 gp_Dir aD1(atof(argv[5]), atof(argv[6]), atof(argv[7]));
251 BRepClass3d_Intersector3d aI1;
252 aI1.Perform(aL1, -250, 1e-7, TopoDS::Face(aShape));
253 if(aI1.IsDone() && aI1.HasAPoint()) {
254 gp_Pnt aR1 = aI1.Pnt();
255 di << aR1.X() << " " << aR1.Y() << " " << aR1.Z() << "\n";
261 void QABugs::Commands_8(Draw_Interpretor& theCommands) {
262 char *group = "QABugs";
264 theCommands.Add("BUC60753", "BUC60753 mode ratio", __FILE__, BUC60753, group);
265 theCommands.Add("OCC162", "OCC162 name", __FILE__, OCC162, group);
266 theCommands.Add("OCC172", "OCC172", __FILE__, OCC172, group);
267 theCommands.Add("OCC204", "OCC204 updateviewer=0/1", __FILE__, OCC204, group);
268 theCommands.Add("OCC1651", "OCC1651 Shape PntX PntY PntZ DirX DirY DirZ", __FILE__, OCC1651, group);