1 // Created on: 2002-05-21
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
18 #include <Draw_Interpretor.hxx>
20 #include <DrawTrSurf.hxx>
21 #include <AIS_InteractiveContext.hxx>
22 #include <ViewerTest.hxx>
23 #include <AIS_Shape.hxx>
24 #include <TopoDS_Shape.hxx>
26 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
27 #include <TColStd_ListIteratorOfListOfInteger.hxx>
28 #include <TColStd_MapOfInteger.hxx>
30 #include <TDocStd_Document.hxx>
31 #include <TDocStd_Application.hxx>
32 #include <DDocStd.hxx>
33 #include <TDocStd_Owner.hxx>
34 #include <TDF_Label.hxx>
36 #include <TPrsStd_AISViewer.hxx>
37 #include <TPrsStd_AISPresentation.hxx>
39 #include <Draw_Viewer.hxx>
43 extern Draw_Viewer dout;
45 Standard_IMPORT Draw_Viewer dout;
48 #include <BRep_Builder.hxx>
49 #include <BRepTools.hxx>
50 #include <TopoDS_Wire.hxx>
51 #include <BRepBuilderAPI_MakeFace.hxx>
55 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
57 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
60 static TColStd_MapOfInteger theactivatedmodes(8);
62 #include <AIS_PlaneTrihedron.hxx>
63 #include <TopoDS_Face.hxx>
64 #include <TopExp_Explorer.hxx>
65 #include <TopoDS_Edge.hxx>
66 #include <BRepAdaptor_Curve.hxx>
67 #include <GC_MakePlane.hxx>
69 static Standard_Integer OCC159bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
72 di << "ERROR : Usage : " << argv[0] << " Doc\n";
76 Handle(TDocStd_Document) D;
77 if (!DDocStd::GetDocument(argv[1],D)) return 1;
79 Standard_Integer DocRefCount1 = D->GetRefCount();
80 di << "DocRefCount1 = " << DocRefCount1 << "\n";
82 Handle(TDocStd_Owner) Owner;
83 if (!D->Main().Root().FindAttribute(TDocStd_Owner::GetID(),Owner)) return 1;
85 Handle(TDocStd_Document) OwnerD1 = Owner->GetDocument();
86 if (OwnerD1.IsNull()) {
87 di << "DocOwner1 = NULL\n";
89 di << "DocOwner1 = NOTNULL\n";
92 Handle(TDocStd_Application) A = DDocStd::GetApplication();
95 Handle(Draw_Drawable3D) DD = Draw::Get(argv[1],Standard_False);
96 dout.RemoveDrawable (DD);
98 Handle(TDocStd_Document) OwnerD2 = Owner->GetDocument();
99 if (OwnerD2.IsNull()) {
100 di << "DocOwner2 = NULL\n";
102 di << "DocOwner2 = NOTNULL\n";
105 Standard_Integer DocRefCount2 = D->GetRefCount();
106 di << "DocRefCount2 = " << DocRefCount2 << "\n";
111 static Standard_Integer OCC145bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
114 di << "ERROR : Usage : " << argv[0] << " Shape MaxNbr\n";
118 TCollection_AsciiString aFileName = argv[1];
119 Standard_Integer aMaxNbr = Draw::Atoi(argv[2]);
124 if (!BRepTools::Read(aShape, aFileName.ToCString(), aBld)) {
125 di << "ERROR :Could not read a shape!!!\n";
130 TopoDS_Wire aWire = TopoDS::Wire(aShape);
132 for (i = 1; i <= aMaxNbr; i++) {
133 BRepBuilderAPI_MakeFace aMF(aWire);
135 di << "ERROR : Could not make a face\n";
143 static Standard_Integer OCC73_SelectionMode (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
146 di << "ERROR : Usage : " << argv[0] << " DOC entry [SelectionMode]\n";
150 Handle(TDocStd_Document) D;
151 //cout << "OCC73_SelectionMode 1" << endl;
152 if (!DDocStd::GetDocument(argv[1],D)) return 1;
154 //cout << "OCC73_SelectionMode 2" << endl;
155 if (!DDF::FindLabel(D->GetData(),argv[2],L)) return 1;
157 Handle(TPrsStd_AISViewer) viewer;
158 //cout << "OCC73_SelectionMode 3" << endl;
159 if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
161 Handle(TPrsStd_AISPresentation) prs;
162 //cout << "OCC73_SelectionMode 4" << endl;
163 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
165 prs->SetSelectionMode((Standard_Integer)Draw::Atoi(argv[3]));
166 TPrsStd_AISViewer::Update(L);
169 Standard_Integer SelectionMode = prs->SelectionMode();
170 //cout << "SelectionMode = " << SelectionMode << endl;
174 //cout << "OCC73_SelectionMode 5" << endl;
179 static Standard_Integer OCC10bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
181 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
182 if(aContext.IsNull()) {
183 di << "use 'vinit' command before " << argv[0] << "\n";
188 di << "Usage : " << argv[0] << " name plane Length\n";
192 TopoDS_Shape S = DBRep::Get( argv[2] );
194 di << "Shape is empty\n";
198 TCollection_AsciiString name(argv[1]);
199 Standard_Real Length = Draw::Atof(argv[3]);
201 // Construction de l'AIS_PlaneTrihedron
202 Handle(AIS_PlaneTrihedron) theAISPlaneTri;
204 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
206 // on recupere la shape dans la map des objets displayes
207 Handle(AIS_InteractiveObject) aShape = GetMapOfAIS().Find2(name);
209 // On verifie que l'AIS InteraciveObject est bien
210 // un AIS_PlaneTrihedron
211 if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==4) {
212 // On downcast aShape de AIS_InteractiveObject a AIS_PlaneTrihedron
213 theAISPlaneTri = Handle(AIS_PlaneTrihedron)::DownCast (aShape);
215 theAISPlaneTri->SetLength(Length);
217 aContext->Redisplay(theAISPlaneTri, Standard_False);
218 aContext->UpdateCurrentViewer();
221 TopoDS_Face FaceB=TopoDS::Face(S);
223 // Construction du Plane
224 // recuperation des edges des faces.
225 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
227 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
231 // si il y a plusieurs edges
232 if (FaceExpB.More() ) {
234 TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() );
235 BRepAdaptor_Curve theCurveB(EdgeB);
236 BRepAdaptor_Curve theCurveC(EdgeC);
237 A=theCurveC.Value(0.1);
238 B=theCurveC.Value(0.9);
239 C=theCurveB.Value(0.5);
242 // FaceB a 1 unique edge courbe
243 BRepAdaptor_Curve theCurveB(EdgeB);
244 A=theCurveB.Value(0.1);
245 B=theCurveB.Value(0.9);
246 C=theCurveB.Value(0.5);
248 // Construction du Geom_Plane
249 GC_MakePlane MkPlane(A,B,C);
250 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
252 // on le display & bind
253 theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
255 theAISPlaneTri->SetLength(Length);
257 GetMapOfAIS().Bind ( theAISPlaneTri, name);
258 aContext->Display (theAISPlaneTri, Standard_True);
261 Standard_Real getLength = theAISPlaneTri->GetLength();
262 di << "Length = " << Length << "\n";
263 di << "getLength = " << getLength << "\n";
265 if (getLength == Length) {
268 di << "OCC10: ERROR\n";
274 static Standard_Integer OCC74bug_set (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
276 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
277 if(aContext.IsNull()) {
278 di << argv[0] << "ERROR : use 'vinit' command before \n";
283 di << "ERROR : Usage : " << argv[0] << " shape mode; set selection mode\n";
287 Standard_Boolean updateviewer = Standard_True;
289 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
291 TCollection_AsciiString aName(argv[1]);
292 Handle(AIS_InteractiveObject) AISObj;
294 Standard_Integer SelectMode = Draw::Atoi(argv[2]);
295 if (!aMap.Find2 (aName, AISObj)
298 di << "Use 'vdisplay' before\n";
302 aContext->Erase(AISObj, updateviewer);
303 aContext->UpdateCurrentViewer();
304 aContext->SetAutoActivateSelection (Standard_False);
305 aContext->Display(AISObj, updateviewer);
306 aContext->Activate (AISObj, SelectMode);
307 aContext->UpdateCurrentViewer();
311 static Standard_Integer OCC74bug_get (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
313 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
314 if(aContext.IsNull()) {
315 di << argv[0] << "ERROR : use 'vinit' command before \n";
320 di << "ERROR : Usage : " << argv[0] << " shape; get selection mode\n";
324 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
326 TCollection_AsciiString aName(argv[1]);
327 Handle(AIS_InteractiveObject) AISObj;
328 if (!aMap.Find2(aName, AISObj)
331 di << "Use 'vdisplay' before\n";
335 TColStd_ListOfInteger anActivatedModes;
336 aContext->ActivatedModes (AISObj, anActivatedModes);
337 Standard_Integer aMode = anActivatedModes.IsEmpty() ? -1 : anActivatedModes.Last();
342 #include <BRepPrimAPI_MakeBox.hxx>
343 #include <TDF_Data.hxx>
344 #include <TNaming_Builder.hxx>
345 #include <TNaming_NamedShape.hxx>
346 #include <AIS_InteractiveObject.hxx>
348 static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
351 di << "ERROR : Usage : " << a[0] << " Doc\n";
356 Handle(TDocStd_Document) D;
357 if (!DDocStd::GetDocument(a[1],D)) {
362 BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
363 TopoDS_Shape aTBox = aBox.Shape();
364 aTBox.Orientation(TopAbs_FORWARD);
366 TDF_Label aTestLabel = D->Main();
368 TNaming_Builder aBuilder(aTestLabel);
369 aBuilder.Generated(aTBox);
371 TopoDS_Shape aTBox1 = aTBox;
372 aTBox1.Orientation(TopAbs_REVERSED);
373 aTestLabel.ForgetAllAttributes();
375 TNaming_Builder aBuilder2(aTestLabel);
376 aBuilder2.Generated( aTBox1);
378 aTBox = aBuilder2.NamedShape()->Get();
379 if(aTBox.Orientation() != TopAbs_REVERSED) {
387 void QABugs::Commands_1(Draw_Interpretor& theCommands) {
388 const char *group = "QABugs";
390 theCommands.Add ("OCC159", "OCC159 Doc", __FILE__, OCC159bug, group);
391 theCommands.Add ("OCC145", "OCC145 Shape MaxNbr", __FILE__, OCC145bug, group);
393 theCommands.Add ("OCC73_SelectionMode", "OCC73_SelectionMode DOC entry [SelectionMode]", __FILE__, OCC73_SelectionMode, group);
395 theCommands.Add ("OCC10", "OCC10 Shape MaxNbr", __FILE__, OCC10bug, group);
397 theCommands.Add ("OCC74_set", "OCC74_set shape mode; set selection mode", __FILE__, OCC74bug_set, group);
398 theCommands.Add ("OCC74_get", "OCC74_get shape; get selection mode", __FILE__, OCC74bug_get, group);
400 theCommands.Add("OCC361", "OCC361 Doc ", __FILE__, OCC361bug, group);