Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2002-03-19 |
2 | // Created by: QA Admin | |
3 | // Copyright (c) 2002-2012 OPEN CASCADE SAS | |
4 | // | |
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. | |
9 | // | |
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. | |
12 | // | |
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. | |
19 | ||
7fd59977 | 20 | |
1cd84fee | 21 | #include <QABugs.hxx> |
7fd59977 | 22 | |
91322f44 | 23 | #include <Draw.hxx> |
7fd59977 | 24 | #include <Draw_Interpretor.hxx> |
25 | #include <DBRep.hxx> | |
26 | #include <DrawTrSurf.hxx> | |
27 | #include <AIS_InteractiveContext.hxx> | |
28 | #include <ViewerTest.hxx> | |
29 | #include <AIS_Shape.hxx> | |
30 | #include <TopoDS_Shape.hxx> | |
31 | ||
32 | #include <ViewerTest_Tool.hxx> | |
33 | #include <V3d_Viewer.hxx> | |
34 | #include <V3d_View.hxx> | |
35 | ||
36 | #include <ViewerTest_Tool.hxx> | |
37 | #include <V3d_Viewer.hxx> | |
38 | #include <V3d_View.hxx> | |
39 | #include <PCollection_HExtendedString.hxx> | |
40 | ||
41 | #include <TDocStd_Application.hxx> | |
42 | #include <TDocStd_Document.hxx> | |
43 | #include <DDocStd.hxx> | |
44 | #include <CDF.hxx> | |
45 | ||
46 | #include <Resource_Manager.hxx> | |
7fd59977 | 47 | #include <TopoDS_Wire.hxx> |
48 | #include <BRepTools_WireExplorer.hxx> | |
49 | #include <TopoDS_Vertex.hxx> | |
50 | #include <TopoDS.hxx> | |
51 | #include <BRep_Tool.hxx> | |
52 | #include <TopExp.hxx> | |
53 | #include <Geom_Curve.hxx> | |
54 | #include <GCPnts_UniformAbscissa.hxx> | |
55 | #include <GeomAdaptor_Curve.hxx> | |
91a16bc7 | 56 | #include <Standard_Assert.hxx> |
7fd59977 | 57 | |
58 | #define DEFAULT_COLOR Quantity_NOC_GOLDENROD | |
59 | ||
60 | static Quantity_NameOfColor GetColorFromName( const char *name, Standard_Boolean& Found) | |
61 | { | |
62 | Quantity_NameOfColor ret = DEFAULT_COLOR; | |
63 | ||
64 | Found = Standard_False; | |
65 | Standard_CString colstring; | |
66 | for(Standard_Integer i=0;i<=514 && !Found;i++) | |
67 | { | |
68 | colstring = Quantity_Color::StringName(Quantity_NameOfColor(i)); | |
69 | if (!strcasecmp(name,colstring)) { | |
70 | ret = (Quantity_NameOfColor)i; | |
71 | Found = Standard_True; | |
72 | break; | |
73 | } | |
74 | } | |
75 | ||
76 | return ret; | |
77 | } | |
78 | ||
7fd59977 | 79 | static Standard_Integer BUC60851 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
80 | { | |
81 | Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("buc60851"); | |
82 | ViewerTest_Tool::InitViewerTest (context); | |
83 | Handle(V3d_Viewer) aV3dViewer= context->CurrentViewer(); | |
84 | Handle(V3d_View) aV3d_View = aV3dViewer->ActiveView(); | |
85 | for (Standard_Integer i=0;i<1000;++i) { | |
86 | aV3d_View->TriedronDisplay(); | |
87 | aV3d_View->TriedronErase(); | |
88 | } | |
89 | aV3d_View->TriedronDisplay(); | |
90 | ||
91 | return 0; | |
92 | } | |
93 | ||
94 | static Standard_Integer OCC216 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) | |
95 | { | |
96 | Handle(PCollection_HExtendedString) HExtendedString = new PCollection_HExtendedString(""); | |
97 | HExtendedString.Nullify(); | |
98 | di << "OCC216: Deleting PCollection_HExtendedString initialized by empty string : OK" <<"\n"; | |
99 | ||
100 | return 0; | |
101 | } | |
102 | ||
103 | static Standard_Integer OCC267 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
104 | { | |
105 | if ( argc != 3) { | |
106 | di << "ERROR OCC267: Usage : " << argv[0] << " DOC path" << "\n"; | |
107 | return 1; | |
108 | } | |
109 | ||
110 | Handle(TDocStd_Document) D; | |
111 | if (!DDocStd::GetDocument(argv[1],D)) return 1; | |
112 | TCollection_ExtendedString path (argv[2]); | |
113 | Handle(TDocStd_Application) A; | |
114 | if (!DDocStd::Find(A)) return 1; | |
115 | ||
15e8b082 M |
116 | PCDM_StoreStatus theStatus = A->SaveAs(D,path); |
117 | if (theStatus == PCDM_SS_OK ) { | |
118 | di << "OCC267 : PCDM_StoreStatus = PCDM_SS_OK" << "\n"; | |
7fd59977 | 119 | } else { |
15e8b082 | 120 | di << "OCC267 : PCDM_StoreStatus = Bad_Store_Status" << "\n"; |
7fd59977 | 121 | } |
122 | ||
123 | return 0; | |
124 | } | |
125 | ||
126 | static Standard_Integer OCC181 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
127 | { | |
128 | if ( argc != 5) { | |
129 | di << "ERROR OCC181: Usage : " << argv[0] << " FileName path1 path2 verbose=0/1" << "\n"; | |
130 | return 1; | |
131 | } | |
132 | Standard_CString aFileName = argv[1]; | |
133 | Standard_CString aDir1 = argv[2]; | |
134 | Standard_CString aDir2 = argv[3]; | |
91322f44 | 135 | Standard_Integer verboseInt = Draw::Atoi(argv[4]); |
7fd59977 | 136 | |
137 | Standard_Boolean verboseBool = Standard_False; | |
138 | if (verboseInt != 0) { | |
139 | verboseBool = Standard_True; | |
140 | } | |
141 | ||
142 | TCollection_AsciiString Env1, Env2, CSF_ = "set env(CSF_"; | |
143 | Env1 = CSF_ + aFileName + "UserDefaults) " + aDir1; | |
144 | Env2 = CSF_ + aFileName + "UserDefaults) " + aDir2; | |
145 | ||
146 | di.Eval(Env1.ToCString()); | |
147 | ||
148 | Resource_Manager aManager(aFileName, verboseBool); | |
149 | ||
150 | di.Eval(Env2.ToCString()); | |
151 | ||
152 | Standard_Boolean aStatus = aManager.Save(); | |
153 | ||
154 | if (aStatus) { | |
155 | di << "\nOCC181 : Status = TRUE" << "\n"; | |
156 | } else { | |
157 | di << "\nOCC181 : Status = FALSE" << "\n"; | |
158 | } | |
159 | ||
160 | return 0; | |
161 | } | |
162 | ||
7fd59977 | 163 | static Standard_Real delta_percent (Standard_Real a, Standard_Real b) |
164 | { | |
165 | Standard_Real result; | |
166 | if (b != 0.) { | |
167 | result = fabs( (a - b) / b ) * 100.; | |
168 | } else if (a != 0.) { | |
169 | result = fabs( (a - b) / a ) * 100.; | |
170 | } else { | |
171 | result = 0.; | |
172 | } | |
173 | return result; | |
174 | } | |
175 | ||
176 | static Standard_Integer OCC367 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
177 | { | |
178 | if ( argc != 7) { | |
179 | di << "ERROR : Usage : " << argv[0] << " shape step goodX goodY goodZ percent_tolerance" << "\n"; | |
180 | return 1; | |
181 | } | |
182 | ||
183 | TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1])); | |
91322f44 | 184 | Standard_Real l = Draw::Atof(argv[2]); |
185 | Standard_Real goodX = Draw::Atof(argv[3]); | |
186 | Standard_Real goodY = Draw::Atof(argv[4]); | |
187 | Standard_Real goodZ = Draw::Atof(argv[5]); | |
188 | Standard_Real percent = Draw::Atof(argv[6]); | |
7fd59977 | 189 | Standard_Boolean Status = Standard_False; |
190 | ||
191 | // Find the first vertex of the wire | |
192 | BRepTools_WireExplorer wire_exp(myTopoDSWire); | |
193 | TopoDS_Vertex vlast; | |
194 | { | |
195 | TopoDS_Vertex vw1, vw2; | |
196 | TopExp::Vertices(myTopoDSWire,vw1,vw2); | |
197 | TopoDS_Vertex ve1, ve2; | |
198 | TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current()); | |
199 | TopExp::Vertices(edge,ve1,ve2); | |
200 | if (vw1.IsSame(ve1) || vw1.IsSame(ve2)) | |
201 | vlast = vw1; | |
202 | else { | |
91a16bc7 | 203 | Standard_ASSERT_RAISE(vw2.IsSame(ve1) || vw2.IsSame(ve2), "Disconnected vertices"); |
7fd59977 | 204 | vlast = vw2; |
205 | } | |
206 | } | |
207 | Standard_Integer EdgeIndex = 0; | |
208 | Standard_Real FirstEdgeX, FirstEdgeY, FirstEdgeZ, deltaX, deltaY, deltaZ; | |
209 | FirstEdgeX = FirstEdgeY = FirstEdgeZ = deltaX = deltaY = deltaZ = 0.; | |
210 | for ( ; wire_exp.More(); wire_exp.Next()) | |
211 | { | |
212 | EdgeIndex++; | |
213 | di << "\n\n New Edge \n" << "\n"; | |
214 | Standard_Real newufirst, newulast; | |
215 | TopoDS_Edge edge = TopoDS::Edge(wire_exp.Current()); | |
216 | Standard_Real ufirst, ulast; | |
217 | Handle(Geom_Curve) acurve; | |
218 | TopoDS_Vertex ve1, ve2; | |
219 | TopExp::Vertices(edge,ve1,ve2); | |
220 | if (ve1.IsSame(vlast)) | |
221 | { | |
222 | acurve = BRep_Tool::Curve(edge, ufirst, ulast); | |
223 | newufirst = ufirst; | |
224 | newulast = ulast; | |
225 | vlast = ve2; | |
226 | } | |
227 | else | |
228 | { | |
91a16bc7 K |
229 | Standard_ASSERT_RAISE(ve2.IsSame(vlast), "Not the same vertex"); |
230 | Standard_ASSERT_RAISE(wire_exp.Orientation() == TopAbs_REVERSED, "Wire should be REVERSED"); | |
7fd59977 | 231 | acurve = BRep_Tool::Curve( edge, ufirst, ulast ); |
232 | newufirst = acurve->ReversedParameter( ufirst ); | |
233 | newulast = acurve->ReversedParameter( ulast ); | |
234 | acurve = acurve->Reversed( ); | |
235 | vlast = ve1; | |
236 | } | |
237 | ||
238 | GeomAdaptor_Curve curve; | |
239 | GCPnts_UniformAbscissa algo; | |
240 | curve.Load(acurve); | |
241 | algo.Initialize( curve, l, newufirst, newulast ); | |
242 | if (!algo.IsDone()) | |
243 | di << "Not Done!!!" << "\n"; | |
244 | Standard_Integer maxIndex =algo.NbPoints(); | |
245 | for (Standard_Integer Index = 1; Index<=maxIndex;Index++) { | |
246 | Standard_Real t = algo.Parameter(Index); | |
247 | gp_Pnt pt3 = curve.Value(t); | |
248 | di << "Parameter t = " << t << "\n"; | |
249 | di << "Value Pnt = " << pt3.X()<<" " <<pt3.Y()<<" " << pt3.Z() << "\n"; | |
250 | if (EdgeIndex == 1 && Index == maxIndex) { | |
251 | FirstEdgeX = pt3.X(); | |
252 | FirstEdgeY = pt3.Y(); | |
253 | FirstEdgeZ = pt3.Z(); | |
254 | deltaX = delta_percent(FirstEdgeX, goodX); | |
255 | deltaY = delta_percent(FirstEdgeY, goodY); | |
256 | deltaZ = delta_percent(FirstEdgeZ, goodZ); | |
257 | if (deltaX <= percent && deltaY <= percent && deltaZ <= percent) { | |
258 | Status = Standard_True; | |
259 | } | |
260 | } | |
261 | } | |
262 | } | |
263 | di << "\n\nFirstEdge = " << FirstEdgeX <<" " << FirstEdgeY <<" " << FirstEdgeZ << "\n"; | |
264 | di << "deltaX = " << deltaX << " deltaY = " << deltaY << " deltaZ = " << deltaZ << "\n"; | |
265 | if (Status) { | |
266 | di << argv[0] << " : OK" << "\n"; | |
267 | } else { | |
268 | di << argv[0] << " : ERROR" << "\n"; | |
269 | } | |
270 | ||
271 | return 0; | |
272 | } | |
273 | ||
274 | static Standard_Integer OCC71bug (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv) | |
275 | { | |
276 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
277 | if(aContext.IsNull()) { | |
278 | di << argv[0] << "ERROR : use 'vinit' command before " << "\n"; | |
279 | return 1; | |
280 | } | |
281 | ||
282 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); | |
283 | V3dView->EnableGLLight( Standard_False ); | |
284 | V3dView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.07); | |
285 | aContext->UpdateCurrentViewer(); | |
286 | return 0; | |
287 | } | |
288 | ||
1cd84fee | 289 | void QABugs::Commands_18(Draw_Interpretor& theCommands) { |
1365140b | 290 | const char *group = "QABugs"; |
7fd59977 | 291 | |
292 | theCommands.Add("BUC60851", "BUC60851", __FILE__, BUC60851, group); | |
293 | theCommands.Add("OCC216", "OCC216", __FILE__, OCC216, group); | |
294 | theCommands.Add("OCC267", "OCC267 DOC path", __FILE__, OCC267, group); | |
295 | theCommands.Add("OCC181", "OCC181 FileName path1 path2 verbose=0/1", __FILE__, OCC181, group); | |
7fd59977 | 296 | theCommands.Add("OCC367", "OCC367 shape step goodX goodY goodZ percent_tolerance", __FILE__, OCC367, group); |
297 | theCommands.Add("OCC71", "OCC71", __FILE__, OCC71bug, group); | |
7fd59977 | 298 | |
299 | return; | |
300 | } |