Integration of OCCT 6.5.0 from SVN
[occt.git] / src / QAMitutoyoUK / QAMitutoyoUK.cxx
CommitLineData
7fd59977 1// File: QAMitutoyoUK.cxx
2// Created: Tue Mar 19 12:17:16 2002
3// Author: QA Admin
4// <qa@umnox.nnov.matra-dtv.fr>
5
6
7#include <QAMitutoyoUK.hxx>
8
9#include <Draw_Interpretor.hxx>
10#include <DBRep.hxx>
11#include <DrawTrSurf.hxx>
12#include <AIS_InteractiveContext.hxx>
13#include <ViewerTest.hxx>
14#include <AIS_Shape.hxx>
15#include <TopoDS_Shape.hxx>
16
17#include <TColStd_Array2OfReal.hxx>
18#include <V3d_View.hxx>
19#include <Visual3d_View.hxx>
20
21#include <BRepOffsetAPI_Sewing.hxx>
22
23#include <AIS_ListOfInteractive.hxx>
24#include <AIS_ListIteratorOfListOfInteractive.hxx>
25
26#include <BRepPrimAPI_MakeBox.hxx>
27
28static Standard_Integer BUC60753 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
29{
30 if(argc!=3)
31 {
32 di << "Usage : " << argv[0] << " mode (0 <=mode<=5) ratio (0.0<=ration<=1.0)" <<"\n";
33 return -1;
34 }
35
36 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
37 if(myAISContext.IsNull()) {
38 di << "use 'vinit' command before " << argv[0] << "\n";
39 return 1;
40 }
41
42 Standard_Real Alpha = Standard_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);
54 Standard_Integer i,j;
55 for (i=0; i<=3; i++)
56 for (j=0; j<=3; j++)
57 if (i == j) {
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);
65 } else {
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);
73 }
74
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);
80
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);
86
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);
92
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);
98
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);
104
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);
110
111 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
112
113 myV3dView->SetAnimationMode(Standard_True,Standard_True);
114 myAISContext-> SetDegenerateModel((Aspect_TypeOfDegenerateModel) atoi(argv[1]),atof(argv[2]));
115
116// Timer.Reset ();
117// Timer.Start ();
118 myV3dView->SetAnimationModeOn();
119 myV3dView->SetComputedMode ( Standard_False );
120 for (i=0;i<40;i++) {
121 myV3dView->View()->SetTransform (Trsfz);
122 myV3dView->View()->Update ();
123 }
124 myV3dView->SetAnimationModeOff();
125// Timer.Stop ();
126// Timer.Show (cout);
127
128 return 0;
129}
130
131static Standard_Integer OCC162 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
132{
133 if ( argc != 2 ) {
134 di << "Usage : " << argv[0] << " name" << "\n";
135 return 1;
136 }
137
138 TopoDS_Shape aShape = DBRep::Get(argv[1]);
139 if (aShape.IsNull()) return 0;
140
141 Standard_Real tolValue = 0.0001;
142 BRepOffsetAPI_Sewing sew(tolValue);
143 sew.Add(aShape);
144 sew.Perform();
145 TopoDS_Shape aSewed = sew.SewedShape();
146
147 return 0;
148}
149
150static Standard_Integer OCC172 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
151{
152 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
153 if(aContext.IsNull()) {
154 di << "use 'vinit' command before " << argv[0] << "\n";
155 return 1;
156 }
157
158 AIS_ListOfInteractive aListOfIO;
159 aContext->DisplayedObjects(aListOfIO);
160 AIS_ListIteratorOfListOfInteractive It;
161 for (It.Initialize(aListOfIO);It.More();It.Next())
162 {
163 aContext->AddOrRemoveCurrentObject(It.Value());
164 }
165
166 return 0;
167}
168
169static Standard_Integer OCC204 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
170{
171 if ( argc != 2 ) {
172 di << "Usage : " << argv[0] << " updateviewer=0/1" << "\n";
173 return 1;
174 }
175
176 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
177 if (aContext.IsNull()) {
178 di << "use 'vinit' command before " << argv[0] << "\n";
179 return 1;
180 }
181 Standard_Boolean UpdateViewer = Standard_True;
182 Standard_Integer IntegerUpdateViewer = atoi(argv[1]);
183 if (IntegerUpdateViewer == 0) {
184 UpdateViewer = Standard_False;
185 }
186
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));
191
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());
195
196 aContext->Display(ais1);
197 aContext->Display(ais2);
198 aContext->Display(ais3);
199
200 aContext->AddOrRemoveCurrentObject(ais1);
201 aContext->AddOrRemoveCurrentObject(ais2);
202 aContext->AddOrRemoveCurrentObject(ais3);
203
204 //printf("\n No of currents = %d", aContext->NbCurrents());
205
206 aContext->InitCurrent();
207
208 //int count = 1;
209 while(aContext->MoreCurrent())
210 {
211 //printf("\n count is = %d", count++);
212 Handle_AIS_InteractiveObject ais = aContext->Current();
213 aContext->Remove(ais, UpdateViewer);
214 aContext->InitCurrent();
215 }
216
217 return 0;
218}
219
220#include <gp_Lin.hxx>
221#include <BRepClass3d_Intersector3d.hxx>
222#include <TopoDS.hxx>
223static Standard_Integer OCC1651 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
224{
225 if ( argc != 8 ) {
226 di << "Usage : " << argv[0] << " Shape PntX PntY PntZ DirX DirY DirZ" << "\n";
227 return 1;
228 }
229
230 TopoDS_Shape aShape = DBRep::Get(argv[1]);
231 if (aShape.IsNull()) return 0;
232
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]));
235 gp_Lin aL1(aP1,aD1);
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";
241 }
242
243 return 0;
244}
245
246void QAMitutoyoUK::Commands(Draw_Interpretor& theCommands) {
247 char *group = "QAMitutoyoUK";
248
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);
254
255 return;
256}