1 // File: QAMitutoyoUK.cxx
2 // Created: Tue Mar 19 12:17:16 2002
4 // <qa@umnox.nnov.matra-dtv.fr>
7 #include <QAMitutoyoUK.hxx>
9 #include <Draw_Interpretor.hxx>
11 #include <DrawTrSurf.hxx>
12 #include <AIS_InteractiveContext.hxx>
13 #include <ViewerTest.hxx>
14 #include <AIS_Shape.hxx>
15 #include <TopoDS_Shape.hxx>
17 #include <TColStd_Array2OfReal.hxx>
18 #include <V3d_View.hxx>
19 #include <Visual3d_View.hxx>
21 #include <BRepOffsetAPI_Sewing.hxx>
23 #include <AIS_ListOfInteractive.hxx>
24 #include <AIS_ListIteratorOfListOfInteractive.hxx>
26 #include <BRepPrimAPI_MakeBox.hxx>
28 static Standard_Integer BUC60753 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
32 di << "Usage : " << argv[0] << " mode (0 <=mode<=5) ratio (0.0<=ration<=1.0)" <<"\n";
36 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
37 if(myAISContext.IsNull()) {
38 di << "use 'vinit' command before " << argv[0] << "\n";
42 Standard_Real Alpha = M_PI/10.;
43 Standard_Real CosAlpha = Cos (Alpha);
44 Standard_Real SinAlpha = Sin (Alpha);
45 Standard_Real MoinsCosAlpha = Cos (-Alpha);
46 Standard_Real MoinsSinAlpha = Sin (-Alpha);
47 TColStd_Array2OfReal TrsfI (0, 3, 0, 3);
48 TColStd_Array2OfReal TrsfX (0, 3, 0, 3);
49 TColStd_Array2OfReal TrsfY (0, 3, 0, 3);
50 TColStd_Array2OfReal TrsfZ (0, 3, 0, 3);
51 TColStd_Array2OfReal Trsfx (0, 3, 0, 3);
52 TColStd_Array2OfReal Trsfy (0, 3, 0, 3);
53 TColStd_Array2OfReal Trsfz (0, 3, 0, 3);
58 TrsfX.SetValue (i, j, 1.0);
59 TrsfY.SetValue (i, j, 1.0);
60 TrsfZ.SetValue (i, j, 1.0);
61 Trsfx.SetValue (i, j, 1.0);
62 Trsfy.SetValue (i, j, 1.0);
63 Trsfz.SetValue (i, j, 1.0);
64 TrsfI.SetValue (i, j, 1.0);
66 TrsfX.SetValue (i, j, 0.0);
67 TrsfY.SetValue (i, j, 0.0);
68 TrsfZ.SetValue (i, j, 0.0);
69 Trsfx.SetValue (i, j, 0.0);
70 Trsfy.SetValue (i, j, 0.0);
71 Trsfz.SetValue (i, j, 0.0);
72 TrsfI.SetValue (i, j, 0.0);
75 // Rotation Alpha autour de l'axe X
76 TrsfX.SetValue (1, 1, CosAlpha);
77 TrsfX.SetValue (2, 2, CosAlpha);
78 TrsfX.SetValue (1, 2, -SinAlpha);
79 TrsfX.SetValue (2, 1, SinAlpha);
81 // Rotation Alpha autour de l'axe Y
82 TrsfY.SetValue (0, 0, CosAlpha);
83 TrsfY.SetValue (2, 2, CosAlpha);
84 TrsfY.SetValue (0, 2, SinAlpha);
85 TrsfY.SetValue (2, 0, -SinAlpha);
87 // Rotation Alpha autour de l'axe Z
88 TrsfZ.SetValue (0, 0, CosAlpha);
89 TrsfZ.SetValue (1, 1, CosAlpha);
90 TrsfZ.SetValue (0, 1, -SinAlpha);
91 TrsfZ.SetValue (1, 0, SinAlpha);
93 // Rotation -Alpha autour de l'axe X
94 Trsfx.SetValue (1, 1, MoinsCosAlpha);
95 Trsfx.SetValue (2, 2, MoinsCosAlpha);
96 Trsfx.SetValue (1, 2, -MoinsSinAlpha);
97 Trsfx.SetValue (2, 1, MoinsSinAlpha);
99 // Rotation -Alpha autour de l'axe Y
100 Trsfy.SetValue (0, 0, MoinsCosAlpha);
101 Trsfy.SetValue (2, 2, MoinsCosAlpha);
102 Trsfy.SetValue (0, 2, MoinsSinAlpha);
103 Trsfy.SetValue (2, 0, -MoinsSinAlpha);
105 // Rotation -Alpha autour de l'axe Z
106 Trsfz.SetValue (0, 0, MoinsCosAlpha);
107 Trsfz.SetValue (1, 1, MoinsCosAlpha);
108 Trsfz.SetValue (0, 1, -MoinsSinAlpha);
109 Trsfz.SetValue (1, 0, MoinsSinAlpha);
111 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
113 myV3dView->SetAnimationMode(Standard_True,Standard_True);
114 myAISContext-> SetDegenerateModel((Aspect_TypeOfDegenerateModel) atoi(argv[1]),atof(argv[2]));
118 myV3dView->SetAnimationModeOn();
119 myV3dView->SetComputedMode ( Standard_False );
121 myV3dView->View()->SetTransform (Trsfz);
122 myV3dView->View()->Update ();
124 myV3dView->SetAnimationModeOff();
126 // Timer.Show (cout);
131 static Standard_Integer OCC162 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
134 di << "Usage : " << argv[0] << " name" << "\n";
138 TopoDS_Shape aShape = DBRep::Get(argv[1]);
139 if (aShape.IsNull()) return 0;
141 Standard_Real tolValue = 0.0001;
142 BRepOffsetAPI_Sewing sew(tolValue);
145 TopoDS_Shape aSewed = sew.SewedShape();
150 static Standard_Integer OCC172 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
152 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
153 if(aContext.IsNull()) {
154 di << "use 'vinit' command before " << argv[0] << "\n";
158 AIS_ListOfInteractive aListOfIO;
159 aContext->DisplayedObjects(aListOfIO);
160 AIS_ListIteratorOfListOfInteractive It;
161 for (It.Initialize(aListOfIO);It.More();It.Next())
163 aContext->AddOrRemoveCurrentObject(It.Value());
169 static Standard_Integer OCC204 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
172 di << "Usage : " << argv[0] << " updateviewer=0/1" << "\n";
176 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
177 if (aContext.IsNull()) {
178 di << "use 'vinit' command before " << argv[0] << "\n";
181 Standard_Boolean UpdateViewer = Standard_True;
182 Standard_Integer IntegerUpdateViewer = atoi(argv[1]);
183 if (IntegerUpdateViewer == 0) {
184 UpdateViewer = Standard_False;
187 Standard_Integer deltaY = -500;
188 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0 + deltaY, 0), gp_Pnt(100, 100 + deltaY, 100));
189 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120 + deltaY, 120), gp_Pnt(300, 300 + deltaY,300));
190 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320 + deltaY, 320), gp_Pnt(500, 500 + deltaY,500));
192 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
193 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
194 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
196 aContext->Display(ais1);
197 aContext->Display(ais2);
198 aContext->Display(ais3);
200 aContext->AddOrRemoveCurrentObject(ais1);
201 aContext->AddOrRemoveCurrentObject(ais2);
202 aContext->AddOrRemoveCurrentObject(ais3);
204 //printf("\n No of currents = %d", aContext->NbCurrents());
206 aContext->InitCurrent();
209 while(aContext->MoreCurrent())
211 //printf("\n count is = %d", count++);
212 Handle_AIS_InteractiveObject ais = aContext->Current();
213 aContext->Remove(ais, UpdateViewer);
214 aContext->InitCurrent();
220 #include <gp_Lin.hxx>
221 #include <BRepClass3d_Intersector3d.hxx>
222 #include <TopoDS.hxx>
223 static Standard_Integer OCC1651 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
226 di << "Usage : " << argv[0] << " Shape PntX PntY PntZ DirX DirY DirZ" << "\n";
230 TopoDS_Shape aShape = DBRep::Get(argv[1]);
231 if (aShape.IsNull()) return 0;
233 gp_Pnt aP1(atof(argv[2]), atof(argv[3]), atof(argv[4]));
234 gp_Dir aD1(atof(argv[5]), atof(argv[6]), atof(argv[7]));
236 BRepClass3d_Intersector3d aI1;
237 aI1.Perform(aL1, -250, 1e-7, TopoDS::Face(aShape));
238 if(aI1.IsDone() && aI1.HasAPoint()) {
239 gp_Pnt aR1 = aI1.Pnt();
240 di << aR1.X() << " " << aR1.Y() << " " << aR1.Z() << "\n";
246 void QAMitutoyoUK::Commands(Draw_Interpretor& theCommands) {
247 char *group = "QAMitutoyoUK";
249 theCommands.Add("BUC60753", "BUC60753 mode ratio", __FILE__, BUC60753, group);
250 theCommands.Add("OCC162", "OCC162 name", __FILE__, OCC162, group);
251 theCommands.Add("OCC172", "OCC172", __FILE__, OCC172, group);
252 theCommands.Add("OCC204", "OCC204 updateviewer=0/1", __FILE__, OCC204, group);
253 theCommands.Add("OCC1651", "OCC1651 Shape PntX PntY PntZ DirX DirY DirZ", __FILE__, OCC1651, group);