Commit | Line | Data |
---|---|---|
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. | |
7fd59977 | 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> | |
7fd59977 | 25 | |
7fd59977 | 26 | #include <V3d_Viewer.hxx> |
27 | #include <V3d_View.hxx> | |
7fd59977 | 28 | |
29 | #include <TDocStd_Application.hxx> | |
30 | #include <TDocStd_Document.hxx> | |
31 | #include <DDocStd.hxx> | |
7fd59977 | 32 | |
33 | #include <Resource_Manager.hxx> | |
7fd59977 | 34 | #include <TopoDS_Wire.hxx> |
35 | #include <BRepTools_WireExplorer.hxx> | |
36 | #include <TopoDS_Vertex.hxx> | |
37 | #include <TopoDS.hxx> | |
38 | #include <BRep_Tool.hxx> | |
39 | #include <TopExp.hxx> | |
40 | #include <Geom_Curve.hxx> | |
41 | #include <GCPnts_UniformAbscissa.hxx> | |
42 | #include <GeomAdaptor_Curve.hxx> | |
91a16bc7 | 43 | #include <Standard_Assert.hxx> |
7fd59977 | 44 | |
45 | #define DEFAULT_COLOR Quantity_NOC_GOLDENROD | |
46 | ||
7fd59977 | 47 | static Standard_Integer OCC267 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
48 | { | |
49 | if ( argc != 3) { | |
586db386 | 50 | di << "ERROR OCC267: Usage : " << argv[0] << " DOC path\n"; |
7fd59977 | 51 | return 1; |
52 | } | |
53 | ||
54 | Handle(TDocStd_Document) D; | |
55 | if (!DDocStd::GetDocument(argv[1],D)) return 1; | |
56 | TCollection_ExtendedString path (argv[2]); | |
6fe96f84 | 57 | Handle(TDocStd_Application) A = DDocStd::GetApplication(); |
7fd59977 | 58 | |
15e8b082 M |
59 | PCDM_StoreStatus theStatus = A->SaveAs(D,path); |
60 | if (theStatus == PCDM_SS_OK ) { | |
586db386 | 61 | di << "OCC267 : PCDM_StoreStatus = PCDM_SS_OK\n"; |
7fd59977 | 62 | } else { |
586db386 | 63 | di << "OCC267 : PCDM_StoreStatus = Bad_Store_Status\n"; |
7fd59977 | 64 | } |
65 | ||
66 | return 0; | |
67 | } | |
68 | ||
69 | static Standard_Integer OCC181 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
70 | { | |
71 | if ( argc != 5) { | |
586db386 | 72 | di << "ERROR OCC181: Usage : " << argv[0] << " FileName path1 path2 verbose=0/1\n"; |
7fd59977 | 73 | return 1; |
74 | } | |
75 | Standard_CString aFileName = argv[1]; | |
76 | Standard_CString aDir1 = argv[2]; | |
77 | Standard_CString aDir2 = argv[3]; | |
91322f44 | 78 | Standard_Integer verboseInt = Draw::Atoi(argv[4]); |
7fd59977 | 79 | |
80 | Standard_Boolean verboseBool = Standard_False; | |
81 | if (verboseInt != 0) { | |
82 | verboseBool = Standard_True; | |
83 | } | |
84 | ||
85 | TCollection_AsciiString Env1, Env2, CSF_ = "set env(CSF_"; | |
86 | Env1 = CSF_ + aFileName + "UserDefaults) " + aDir1; | |
87 | Env2 = CSF_ + aFileName + "UserDefaults) " + aDir2; | |
88 | ||
89 | di.Eval(Env1.ToCString()); | |
90 | ||
91 | Resource_Manager aManager(aFileName, verboseBool); | |
92 | ||
93 | di.Eval(Env2.ToCString()); | |
94 | ||
95 | Standard_Boolean aStatus = aManager.Save(); | |
96 | ||
97 | if (aStatus) { | |
586db386 | 98 | di << "\nOCC181 : Status = TRUE\n"; |
7fd59977 | 99 | } else { |
586db386 | 100 | di << "\nOCC181 : Status = FALSE\n"; |
7fd59977 | 101 | } |
102 | ||
103 | return 0; | |
104 | } | |
105 | ||
f9ac4dc9 | 106 | static Standard_Integer OCC27849 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
107 | { | |
108 | if (argc != 3) { | |
109 | di << "Usage : " << argv[0] << " <environment variable name> <resource name>\n"; | |
110 | return 1; | |
111 | } | |
112 | Standard_CString aEnvName = argv[1]; | |
113 | Standard_CString aResName = argv[2]; | |
114 | ||
115 | Resource_Manager aManager (aEnvName); | |
116 | if (aManager.Find (aResName)) | |
117 | { | |
118 | di << aManager.Value (aResName); | |
119 | } | |
120 | else | |
121 | { | |
122 | di << "Error: could not find resource " << aResName; | |
123 | } | |
124 | ||
125 | return 0; | |
126 | } | |
127 | ||
7fd59977 | 128 | static Standard_Real delta_percent (Standard_Real a, Standard_Real b) |
129 | { | |
130 | Standard_Real result; | |
131 | if (b != 0.) { | |
132 | result = fabs( (a - b) / b ) * 100.; | |
133 | } else if (a != 0.) { | |
134 | result = fabs( (a - b) / a ) * 100.; | |
135 | } else { | |
136 | result = 0.; | |
137 | } | |
138 | return result; | |
139 | } | |
140 | ||
141 | static Standard_Integer OCC367 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
142 | { | |
143 | if ( argc != 7) { | |
586db386 | 144 | di << "ERROR : Usage : " << argv[0] << " shape step goodX goodY goodZ percent_tolerance\n"; |
7fd59977 | 145 | return 1; |
146 | } | |
147 | ||
148 | TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1])); | |
91322f44 | 149 | Standard_Real l = Draw::Atof(argv[2]); |
150 | Standard_Real goodX = Draw::Atof(argv[3]); | |
151 | Standard_Real goodY = Draw::Atof(argv[4]); | |
152 | Standard_Real goodZ = Draw::Atof(argv[5]); | |
153 | Standard_Real percent = Draw::Atof(argv[6]); | |
9fd2d2c3 | 154 | Standard_Boolean aStatus = Standard_False; |
7fd59977 | 155 | |
156 | // Find the first vertex of the wire | |
157 | BRepTools_WireExplorer wire_exp(myTopoDSWire); | |
158 | TopoDS_Vertex vlast; | |
159 | { | |
160 | TopoDS_Vertex vw1, vw2; | |
161 | TopExp::Vertices(myTopoDSWire,vw1,vw2); | |
162 | TopoDS_Vertex ve1, ve2; | |
163 | TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current()); | |
164 | TopExp::Vertices(edge,ve1,ve2); | |
165 | if (vw1.IsSame(ve1) || vw1.IsSame(ve2)) | |
166 | vlast = vw1; | |
167 | else { | |
91a16bc7 | 168 | Standard_ASSERT_RAISE(vw2.IsSame(ve1) || vw2.IsSame(ve2), "Disconnected vertices"); |
7fd59977 | 169 | vlast = vw2; |
170 | } | |
171 | } | |
172 | Standard_Integer EdgeIndex = 0; | |
173 | Standard_Real FirstEdgeX, FirstEdgeY, FirstEdgeZ, deltaX, deltaY, deltaZ; | |
174 | FirstEdgeX = FirstEdgeY = FirstEdgeZ = deltaX = deltaY = deltaZ = 0.; | |
175 | for ( ; wire_exp.More(); wire_exp.Next()) | |
176 | { | |
177 | EdgeIndex++; | |
178 | di << "\n\n New Edge \n" << "\n"; | |
179 | Standard_Real newufirst, newulast; | |
180 | TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current()); | |
181 | Standard_Real ufirst, ulast; | |
182 | Handle(Geom_Curve) acurve; | |
183 | TopoDS_Vertex ve1, ve2; | |
184 | TopExp::Vertices(edge,ve1,ve2); | |
185 | if (ve1.IsSame(vlast)) | |
186 | { | |
187 | acurve = BRep_Tool::Curve(edge, ufirst, ulast); | |
188 | newufirst = ufirst; | |
189 | newulast = ulast; | |
190 | vlast = ve2; | |
191 | } | |
192 | else | |
193 | { | |
91a16bc7 K |
194 | Standard_ASSERT_RAISE(ve2.IsSame(vlast), "Not the same vertex"); |
195 | Standard_ASSERT_RAISE(wire_exp.Orientation() == TopAbs_REVERSED, "Wire should be REVERSED"); | |
7fd59977 | 196 | acurve = BRep_Tool::Curve( edge, ufirst, ulast ); |
197 | newufirst = acurve->ReversedParameter( ufirst ); | |
198 | newulast = acurve->ReversedParameter( ulast ); | |
199 | acurve = acurve->Reversed( ); | |
200 | vlast = ve1; | |
201 | } | |
202 | ||
203 | GeomAdaptor_Curve curve; | |
204 | GCPnts_UniformAbscissa algo; | |
205 | curve.Load(acurve); | |
206 | algo.Initialize( curve, l, newufirst, newulast ); | |
207 | if (!algo.IsDone()) | |
208 | di << "Not Done!!!" << "\n"; | |
209 | Standard_Integer maxIndex =algo.NbPoints(); | |
210 | for (Standard_Integer Index = 1; Index<=maxIndex;Index++) { | |
211 | Standard_Real t = algo.Parameter(Index); | |
212 | gp_Pnt pt3 = curve.Value(t); | |
213 | di << "Parameter t = " << t << "\n"; | |
214 | di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z() << "\n"; | |
215 | if (EdgeIndex == 1 && Index == maxIndex) { | |
216 | FirstEdgeX = pt3.X(); | |
217 | FirstEdgeY = pt3.Y(); | |
218 | FirstEdgeZ = pt3.Z(); | |
219 | deltaX = delta_percent(FirstEdgeX, goodX); | |
220 | deltaY = delta_percent(FirstEdgeY, goodY); | |
221 | deltaZ = delta_percent(FirstEdgeZ, goodZ); | |
222 | if (deltaX <= percent && deltaY <= percent && deltaZ <= percent) { | |
9fd2d2c3 | 223 | aStatus = Standard_True; |
7fd59977 | 224 | } |
225 | } | |
226 | } | |
227 | } | |
228 | di << "\n\nFirstEdge = " << FirstEdgeX <<" " << FirstEdgeY <<" " << FirstEdgeZ << "\n"; | |
229 | di << "deltaX = " << deltaX << " deltaY = " << deltaY << " deltaZ = " << deltaZ << "\n"; | |
9fd2d2c3 | 230 | if (aStatus) { |
586db386 | 231 | di << argv[0] << " : OK\n"; |
7fd59977 | 232 | } else { |
586db386 | 233 | di << argv[0] << " : ERROR\n"; |
7fd59977 | 234 | } |
235 | ||
236 | return 0; | |
237 | } | |
238 | ||
1cd84fee | 239 | void QABugs::Commands_18(Draw_Interpretor& theCommands) { |
1365140b | 240 | const char *group = "QABugs"; |
7fd59977 | 241 | |
7fd59977 | 242 | theCommands.Add("OCC267", "OCC267 DOC path", __FILE__, OCC267, group); |
243 | theCommands.Add("OCC181", "OCC181 FileName path1 path2 verbose=0/1", __FILE__, OCC181, group); | |
f9ac4dc9 | 244 | theCommands.Add("OCC27849", "OCC27849 <resource env name> <resource name>", __FILE__, OCC27849, group); |
7fd59977 | 245 | theCommands.Add("OCC367", "OCC367 shape step goodX goodY goodZ percent_tolerance", __FILE__, OCC367, group); |
7fd59977 | 246 | |
247 | return; | |
248 | } |