1 // Created on: 2002-05-21
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.
22 #include <QAAlcatel.hxx>
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 <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
33 #include <TColStd_ListIteratorOfListOfInteger.hxx>
34 #include <TColStd_MapOfInteger.hxx>
36 #include <TDocStd_Document.hxx>
37 #include <TDocStd_Application.hxx>
38 #include <DDocStd.hxx>
39 #include <TDocStd_Owner.hxx>
40 #include <TDF_Label.hxx>
42 #include <TPrsStd_AISViewer.hxx>
43 #include <TPrsStd_AISPresentation.hxx>
45 #include <Draw_Viewer.hxx>
49 extern Draw_Viewer dout;
51 Standard_IMPORT Draw_Viewer dout;
54 #include <BRep_Builder.hxx>
55 #include <BRepTools.hxx>
56 #include <TopoDS_Wire.hxx>
57 #include <BRepBuilderAPI_MakeFace.hxx>
61 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
63 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
66 static TColStd_MapOfInteger theactivatedmodes(8);
68 #include <AIS_PlaneTrihedron.hxx>
69 #include <TopoDS_Face.hxx>
70 #include <TopExp_Explorer.hxx>
71 #include <TopoDS_Edge.hxx>
72 #include <BRepAdaptor_Curve.hxx>
73 #include <GC_MakePlane.hxx>
75 static Standard_Integer OCC328bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
77 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
78 if(aContext.IsNull()) {
79 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
84 di << "ERROR : Usage : " << argv[0] << " shape mode" << "\n";
88 Standard_Integer ChoosingMode = -1;
89 if ( strcmp (argv [2], "VERTEX") == 0 ) {
92 if ( strcmp (argv [2], "EDGE") == 0 ) {
95 if ( strcmp (argv [2], "WIRE") == 0 ) {
98 if ( strcmp (argv [2], "FACE") == 0 ) {
101 if ( strcmp (argv [2], "SHELL") == 0 ) {
104 if ( strcmp (argv [2], "SOLID") == 0 ) {
107 if ( strcmp (argv [2], "COMPOUND") == 0 ) {
110 if ( ChoosingMode == -1 ) {
111 di << "ERROR : " << argv[1] << " : vrong value of a mode" << "\n";
115 Standard_Boolean updateviewer = Standard_True, PutInCollector = Standard_True;
117 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
119 TCollection_AsciiString aName(argv[1]);
120 Handle(AIS_InteractiveObject) AISObj;
122 if(!aMap.IsBound2(aName)) {
123 di << "Use 'vdisplay' before" << "\n";
126 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
128 di << argv[1] << " : No interactive object" << "\n";
132 if (!aContext->HasOpenedContext()) {
133 aContext->OpenLocalContext();
136 if(!theactivatedmodes.Contains(ChoosingMode)) {
137 aContext->ActivateStandardMode(AIS_Shape::SelectionType(ChoosingMode));
138 theactivatedmodes.Add(ChoosingMode);
140 aContext->Erase(AISObj, updateviewer, PutInCollector);
141 aContext->UpdateCurrentViewer();
143 aContext->Display(AISObj, updateviewer);
144 aContext->UpdateCurrentViewer();
146 const TColStd_ListOfInteger& aList = aContext->ActivatedStandardModes();
147 Standard_Integer SelectMode;
148 TCollection_AsciiString SelectModeString;
149 TColStd_ListIteratorOfListOfInteger itr(aList);
150 for (; itr.More(); itr.Next()) {
151 SelectMode = itr.Value();
152 //cout << "SelectMode = " << SelectMode << endl;
157 SelectModeString.Copy("VERTEX");
160 SelectModeString.Copy("EDGE");
163 SelectModeString.Copy("WIRE");
166 SelectModeString.Copy("FACE");
169 SelectModeString.Copy("SHELL");
172 SelectModeString.Copy("SOLID");
175 SelectModeString.Copy("COMPOUND");
178 SelectModeString.Copy("UNKNOWN");
180 di << "SelectMode = " << SelectModeString.ToCString() << "\n";
188 static Standard_Integer OCC159bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
191 di << "ERROR : Usage : " << argv[0] << " Doc" << "\n";
195 Handle(TDocStd_Document) D;
196 if (!DDocStd::GetDocument(argv[1],D)) return 1;
198 Standard_Integer DocRefCount1 = D->GetRefCount();
199 di << "DocRefCount1 = " << DocRefCount1 << "\n";
201 Handle(TDocStd_Owner) Owner;
202 if (!D->Main().Root().FindAttribute(TDocStd_Owner::GetID(),Owner)) return 1;
204 Handle(TDocStd_Document) OwnerD1 = Owner->GetDocument();
205 if (OwnerD1.IsNull()) {
206 di << "DocOwner1 = NULL" << "\n";
208 di << "DocOwner1 = NOTNULL" << "\n";
211 Handle(TDocStd_Application) A;
212 if (!DDocStd::Find(A)) return 1;
215 Handle(Draw_Drawable3D) DD = Draw::Get(argv[1],Standard_False);
216 dout.RemoveDrawable (DD);
218 Handle(TDocStd_Document) OwnerD2 = Owner->GetDocument();
219 if (OwnerD2.IsNull()) {
220 di << "DocOwner2 = NULL" << "\n";
222 di << "DocOwner2 = NOTNULL" << "\n";
225 Standard_Integer DocRefCount2 = D->GetRefCount();
226 di << "DocRefCount2 = " << DocRefCount2 << "\n";
231 static Standard_Integer OCC145bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
234 di << "ERROR : Usage : " << argv[0] << " Shape MaxNbr" << "\n";
238 TCollection_AsciiString aFileName = argv[1];
239 Standard_Integer aMaxNbr = atoi(argv[2]);
244 if (!BRepTools::Read(aShape, aFileName.ToCString(), aBld)) {
245 di << "ERROR :Could not read a shape!!!" << "\n";
250 TopoDS_Wire aWire = TopoDS::Wire(aShape);
252 for (i = 1; i <= aMaxNbr; i++) {
253 BRepBuilderAPI_MakeFace aMF(aWire);
255 di << "ERROR : Could not make a face" << "\n";
263 static Standard_Integer OCC73_SelectionMode (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
266 di << "ERROR : Usage : " << argv[0] << " DOC entry [SelectionMode]" << "\n";
270 Handle(TDocStd_Document) D;
271 //cout << "OCC73_SelectionMode 1" << endl;
272 if (!DDocStd::GetDocument(argv[1],D)) return 1;
274 //cout << "OCC73_SelectionMode 2" << endl;
275 if (!DDF::FindLabel(D->GetData(),argv[2],L)) return 1;
277 Handle(TPrsStd_AISViewer) viewer;
278 //cout << "OCC73_SelectionMode 3" << endl;
279 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
281 Handle(TPrsStd_AISPresentation) prs;
282 //cout << "OCC73_SelectionMode 4" << endl;
283 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
285 prs->SetSelectionMode((Standard_Integer)atoi(argv[3]));
286 TPrsStd_AISViewer::Update(L);
289 Standard_Integer SelectionMode = prs->SelectionMode();
290 //cout << "SelectionMode = " << SelectionMode << endl;
294 //cout << "OCC73_SelectionMode 5" << endl;
299 static Standard_Integer OCC10bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
301 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
302 if(aContext.IsNull()) {
303 di << "use 'vinit' command before " << argv[0] << "\n";
308 di << "Usage : " << argv[0] << " name plane Length" << "\n";
312 TopoDS_Shape S = DBRep::Get( argv[2] );
314 di << "Shape is empty" << "\n";
318 TCollection_AsciiString name(argv[1]);
319 Standard_Real Length = atof(argv[3]);
321 // Construction de l'AIS_PlaneTrihedron
322 Handle(AIS_PlaneTrihedron) theAISPlaneTri;
324 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
326 // on recupere la shape dans la map des objets displayes
327 Handle(AIS_InteractiveObject) aShape =
328 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
330 // On verifie que l'AIS InteraciveObject est bien
331 // un AIS_PlaneTrihedron
332 if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==4) {
333 // On downcast aShape de AIS_InteractiveObject a AIS_PlaneTrihedron
334 theAISPlaneTri = *(Handle(AIS_PlaneTrihedron)*) &aShape;
336 theAISPlaneTri->SetLength(Length);
338 aContext->Redisplay(theAISPlaneTri, Standard_False);
339 aContext->UpdateCurrentViewer();
342 TopoDS_Face FaceB=TopoDS::Face(S);
344 // Construction du Plane
345 // recuperation des edges des faces.
346 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
348 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
352 // si il y a plusieurs edges
353 if (FaceExpB.More() ) {
355 TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() );
356 BRepAdaptor_Curve theCurveB(EdgeB);
357 BRepAdaptor_Curve theCurveC(EdgeC);
358 A=theCurveC.Value(0.1);
359 B=theCurveC.Value(0.9);
360 C=theCurveB.Value(0.5);
363 // FaceB a 1 unique edge courbe
364 BRepAdaptor_Curve theCurveB(EdgeB);
365 A=theCurveB.Value(0.1);
366 B=theCurveB.Value(0.9);
367 C=theCurveB.Value(0.5);
369 // Construction du Geom_Plane
370 GC_MakePlane MkPlane(A,B,C);
371 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
373 // on le display & bind
374 theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
376 theAISPlaneTri->SetLength(Length);
378 GetMapOfAIS().Bind ( theAISPlaneTri, name);
379 aContext->Display(theAISPlaneTri );
382 Standard_Real getLength = theAISPlaneTri->GetLength();
383 di << "Length = " << Length << "\n";
384 di << "getLength = " << getLength << "\n";
386 if (getLength == Length) {
387 di << "OCC10: OK" << "\n";
389 di << "OCC10: ERROR" << "\n";
395 static Standard_Integer OCC74bug_set (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
397 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
398 if(aContext.IsNull()) {
399 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
404 di << "ERROR : Usage : " << argv[0] << " shape mode; set selection mode" << "\n";
408 Standard_Boolean updateviewer = Standard_True, PutInCollector = Standard_True;
410 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
412 TCollection_AsciiString aName(argv[1]);
413 Handle(AIS_InteractiveObject) AISObj;
415 Standard_Integer SelectMode = atoi(argv[2]);
417 if(!aMap.IsBound2(aName)) {
418 di << "Use 'vdisplay' before" << "\n";
421 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
423 di << argv[1] << " : No interactive object" << "\n";
426 AISObj->SetSelectionMode(SelectMode);
427 if (!aContext->HasOpenedContext()) {
428 aContext->OpenLocalContext();
430 aContext->Erase(AISObj, updateviewer, PutInCollector);
431 aContext->UpdateCurrentViewer();
432 aContext->Display(AISObj, updateviewer);
433 aContext->UpdateCurrentViewer();
438 static Standard_Integer OCC74bug_get (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
440 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
441 if(aContext.IsNull()) {
442 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
447 di << "ERROR : Usage : " << argv[0] << " shape; get selection mode" << "\n";
451 Standard_Boolean updateviewer = Standard_True, PutInCollector = Standard_True;
453 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
455 TCollection_AsciiString aName(argv[1]);
456 Handle(AIS_InteractiveObject) AISObj;
458 if(!aMap.IsBound2(aName)) {
459 di << "Use 'vdisplay' before" << "\n";
462 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
464 di << argv[1] << " : No interactive object" << "\n";
467 Standard_Integer SelectMode = AISObj->SelectionMode();
468 di << SelectMode << "\n";
474 #include <BRepPrimAPI_MakeBox.hxx>
475 #include <TDF_Data.hxx>
476 #include <TNaming_Builder.hxx>
477 #include <TNaming_NamedShape.hxx>
479 static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
482 di << "ERROR : Usage : " << a[0] << " Doc" << "\n";
487 Handle(TDocStd_Document) D;
488 if (!DDocStd::GetDocument(a[1],D)) {
493 BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
494 TopoDS_Shape aTBox = aBox.Shape();
495 aTBox.Orientation(TopAbs_FORWARD);
497 TDF_Label aTestLabel = D->GetData()->Root();
499 TNaming_Builder aBuilder(aTestLabel);
500 aBuilder.Generated(aTBox);
502 TopoDS_Shape aTBox1 = aTBox;
503 aTBox1.Orientation(TopAbs_REVERSED);
504 aTestLabel.ForgetAllAttributes();
505 aBuilder.Generated( aTBox1);
507 aTBox = aBuilder.NamedShape()->Get();
508 if(aTBox.Orientation() != TopAbs_REVERSED) {
516 void QAAlcatel::Commands(Draw_Interpretor& theCommands) {
517 const char *group = "QAAlcatel";
519 theCommands.Add ("OCC328", "OCC328 shape mode", __FILE__, OCC328bug, group);
521 theCommands.Add ("OCC159", "OCC159 Doc", __FILE__, OCC159bug, group);
522 theCommands.Add ("OCC145", "OCC145 Shape MaxNbr", __FILE__, OCC145bug, group);
524 theCommands.Add ("OCC73_SelectionMode", "OCC73_SelectionMode DOC entry [SelectionMode]", __FILE__, OCC73_SelectionMode, group);
526 theCommands.Add ("OCC10", "OCC10 Shape MaxNbr", __FILE__, OCC10bug, group);
528 theCommands.Add ("OCC74_set", "OCC74_set shape mode; set selection mode", __FILE__, OCC74bug_set, group);
529 theCommands.Add ("OCC74_get", "OCC74_get shape; get selection mode", __FILE__, OCC74bug_get, group);
531 theCommands.Add("OCC361", "OCC361 Doc ", __FILE__, OCC361bug, group);