0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / QABugs / QABugs_8.cxx
CommitLineData
b311480e 1// Created on: 2002-03-19
2// Created by: QA Admin
973c2be1 3// Copyright (c) 2002-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
1cd84fee 16#include <QABugs.hxx>
7fd59977 17
91322f44 18#include <Draw.hxx>
7fd59977 19#include <Draw_Interpretor.hxx>
20#include <DBRep.hxx>
21#include <DrawTrSurf.hxx>
22#include <AIS_InteractiveContext.hxx>
23#include <ViewerTest.hxx>
24#include <AIS_Shape.hxx>
25#include <TopoDS_Shape.hxx>
26
27#include <TColStd_Array2OfReal.hxx>
28#include <V3d_View.hxx>
7fd59977 29
30#include <BRepOffsetAPI_Sewing.hxx>
31
32#include <AIS_ListOfInteractive.hxx>
33#include <AIS_ListIteratorOfListOfInteractive.hxx>
34
35#include <BRepPrimAPI_MakeBox.hxx>
36
7fd59977 37static Standard_Integer OCC162 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
38{
39 if ( argc != 2 ) {
586db386 40 di << "Usage : " << argv[0] << " name\n";
7fd59977 41 return 1;
42 }
43
44 TopoDS_Shape aShape = DBRep::Get(argv[1]);
45 if (aShape.IsNull()) return 0;
46
47 Standard_Real tolValue = 0.0001;
48 BRepOffsetAPI_Sewing sew(tolValue);
49 sew.Add(aShape);
50 sew.Perform();
51 TopoDS_Shape aSewed = sew.SewedShape();
52
53 return 0;
54}
55
56static Standard_Integer OCC172 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
57{
58 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
59 if(aContext.IsNull()) {
60 di << "use 'vinit' command before " << argv[0] << "\n";
61 return 1;
62 }
63
64 AIS_ListOfInteractive aListOfIO;
65 aContext->DisplayedObjects(aListOfIO);
66 AIS_ListIteratorOfListOfInteractive It;
67 for (It.Initialize(aListOfIO);It.More();It.Next())
68 {
0577ae8c 69 aContext->AddOrRemoveSelected (It.Value(), Standard_False);
7fd59977 70 }
0577ae8c 71 aContext->UpdateCurrentViewer();
7fd59977 72 return 0;
73}
74
75static Standard_Integer OCC204 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
76{
77 if ( argc != 2 ) {
586db386 78 di << "Usage : " << argv[0] << " updateviewer=0/1\n";
7fd59977 79 return 1;
80 }
81
82 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
83 if (aContext.IsNull()) {
84 di << "use 'vinit' command before " << argv[0] << "\n";
85 return 1;
86 }
87 Standard_Boolean UpdateViewer = Standard_True;
91322f44 88 Standard_Integer IntegerUpdateViewer = Draw::Atoi(argv[1]);
7fd59977 89 if (IntegerUpdateViewer == 0) {
90 UpdateViewer = Standard_False;
91 }
92
93 Standard_Integer deltaY = -500;
94 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0 + deltaY, 0), gp_Pnt(100, 100 + deltaY, 100));
95 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120 + deltaY, 120), gp_Pnt(300, 300 + deltaY,300));
96 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320 + deltaY, 320), gp_Pnt(500, 500 + deltaY,500));
97
c3282ec1 98 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
99 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
100 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
7fd59977 101
0577ae8c 102 aContext->Display (ais1, Standard_False);
103 aContext->Display (ais2, Standard_False);
104 aContext->Display (ais3, Standard_False);
105
106 aContext->AddOrRemoveSelected (ais1, Standard_False);
107 aContext->AddOrRemoveSelected (ais2, Standard_False);
108 aContext->AddOrRemoveSelected (ais3, Standard_False);
7fd59977 109
0577ae8c 110 aContext->UpdateCurrentViewer();
7fd59977 111
112 //printf("\n No of currents = %d", aContext->NbCurrents());
113
c3282ec1 114 aContext->InitSelected();
7fd59977 115
116 //int count = 1;
c3282ec1 117 while(aContext->MoreSelected())
7fd59977 118 {
119 //printf("\n count is = %d", count++);
c3282ec1 120 Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive();
7fd59977 121 aContext->Remove(ais, UpdateViewer);
c3282ec1 122 aContext->InitSelected();
7fd59977 123 }
124
125 return 0;
126}
127
128#include <gp_Lin.hxx>
129#include <BRepClass3d_Intersector3d.hxx>
130#include <TopoDS.hxx>
131static Standard_Integer OCC1651 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
132{
133 if ( argc != 8 ) {
586db386 134 di << "Usage : " << argv[0] << " Shape PntX PntY PntZ DirX DirY DirZ\n";
7fd59977 135 return 1;
136 }
137
138 TopoDS_Shape aShape = DBRep::Get(argv[1]);
139 if (aShape.IsNull()) return 0;
140
91322f44 141 gp_Pnt aP1(Draw::Atof(argv[2]), Draw::Atof(argv[3]), Draw::Atof(argv[4]));
142 gp_Dir aD1(Draw::Atof(argv[5]), Draw::Atof(argv[6]), Draw::Atof(argv[7]));
7fd59977 143 gp_Lin aL1(aP1,aD1);
144 BRepClass3d_Intersector3d aI1;
145 aI1.Perform(aL1, -250, 1e-7, TopoDS::Face(aShape));
146 if(aI1.IsDone() && aI1.HasAPoint()) {
147 gp_Pnt aR1 = aI1.Pnt();
148 di << aR1.X() << " " << aR1.Y() << " " << aR1.Z() << "\n";
149 }
150
151 return 0;
152}
153
1cd84fee 154void QABugs::Commands_8(Draw_Interpretor& theCommands) {
1365140b 155 const char *group = "QABugs";
7fd59977 156
7fd59977 157 theCommands.Add("OCC162", "OCC162 name", __FILE__, OCC162, group);
158 theCommands.Add("OCC172", "OCC172", __FILE__, OCC172, group);
159 theCommands.Add("OCC204", "OCC204 updateviewer=0/1", __FILE__, OCC204, group);
160 theCommands.Add("OCC1651", "OCC1651 Shape PntX PntY PntZ DirX DirY DirZ", __FILE__, OCC1651, group);
161
162 return;
163}