Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1994-10-24 |
2 | // Created by: Jean Yves LEBEY | |
3 | // Copyright (c) 1994-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
7fd59977 | 17 | #include <TestTopOpe.hxx> |
18 | #include <TestTopOpe_HDSDisplayer.hxx> | |
19 | #include <TestTopOpeDraw_DrawableSHA.hxx> | |
20 | #include <TestTopOpeDraw_DrawableP3D.hxx> | |
21 | #include <TestTopOpeDraw_DrawableC3D.hxx> | |
22 | #include <TestTopOpeDraw_TTOT.hxx> | |
23 | #include <TestTopOpeDraw_Displayer.hxx> | |
24 | #include <TopOpeBRepDS_connex.hxx> | |
25 | #include <TopOpeBRepDS_Point.hxx> | |
26 | #include <TopOpeBRepDS_Curve.hxx> | |
27 | #include <TopOpeBRepDS_PointIterator.hxx> | |
28 | #include <TopOpeBRepDS_PointExplorer.hxx> | |
29 | #include <TopOpeBRepDS_CurveExplorer.hxx> | |
30 | #include <TopOpeBRepDS_Explorer.hxx> | |
31 | #include <TopOpeBRepDS_TKI.hxx> | |
32 | #include <TopOpeBRepDS_Check.hxx> | |
33 | #include <TopOpeBRepDS_Dumper.hxx> | |
34 | #include <TopOpeBRepDS.hxx> | |
35 | #include <Geom_TrimmedCurve.hxx> | |
36 | #include <BRep_Tool.hxx> | |
37 | #include <TopoDS.hxx> | |
38 | #include <TopLoc_Location.hxx> | |
39 | #include <Geom_Curve.hxx> | |
40 | #include <GeomAdaptor_Curve.hxx> | |
41 | #include <GeomAbs_CurveType.hxx> | |
42 | #include <GeomAdaptor_Surface.hxx> | |
43 | #include <GeomAbs_SurfaceType.hxx> | |
44 | #include <GeomAPI_ProjectPointOnCurve.hxx> | |
45 | #include <BRepAdaptor_Curve.hxx> | |
46 | #include <TColStd_ListOfInteger.hxx> | |
47 | #include <TColStd_ListIteratorOfListOfInteger.hxx> | |
48 | #include <TopOpeBRepDS_define.hxx> | |
49 | #include <DBRep.hxx> | |
50 | #include <Draw_Appli.hxx> | |
51 | #include <DrawTrSurf_Curve.hxx> | |
52 | #include <Draw_Interpretor.hxx> | |
53 | #include <DrawTrSurf.hxx> | |
ec357c5c | 54 | #include <Draw_Marker3D.hxx> |
7fd59977 | 55 | |
7fd59977 | 56 | class TSEEpar { |
57 | public: | |
58 | TSEEpar(const TCollection_AsciiString& s) { set(s); } | |
59 | void set(const TCollection_AsciiString& s) { | |
60 | miskind = misshap = misgeom = missect = misdege = misafev = misedcu = Standard_False; | |
61 | mTK = TopOpeBRepDS_UNKNOWN; mTS = TopAbs_SHAPE; | |
62 | char* sK = (char *)s.ToCString(); | |
63 | miskind = TestTopOpeDraw_TTOT::StringToKind(s,mTK); | |
64 | if ( miskind ) { | |
65 | misshap = TopOpeBRepDS::IsTopology(mTK); | |
66 | if (misshap) mTS = TopOpeBRepDS::KindToShape(mTK); | |
67 | else misgeom = TopOpeBRepDS::IsGeometry(mTK); | |
68 | } | |
69 | else if ( ! strcasecmp(sK,"s") ) { | |
70 | misshap = Standard_True; mTS = TopAbs_SHAPE; | |
71 | } | |
72 | else if ( ! strcasecmp(sK,"se") ) { | |
73 | missect = Standard_True; mTK = TopOpeBRepDS_EDGE; | |
74 | } | |
75 | else if ( ! strcasecmp(sK,"de") ) { | |
76 | misdege = Standard_True; mTK = TopOpeBRepDS_EDGE; | |
77 | } | |
78 | else if ( ! strcasecmp(sK,"fev") ) { | |
79 | misafev = Standard_True; | |
80 | } | |
81 | else if ( ! strcasecmp(sK,"ec") ) { | |
82 | misedcu = Standard_True; | |
83 | } | |
84 | } | |
85 | Standard_Boolean iskind() { return miskind;} | |
86 | Standard_Boolean isshap() { return misshap;} | |
87 | Standard_Boolean isgeom() { return misgeom;} | |
88 | Standard_Boolean issect() { return missect;} | |
89 | Standard_Boolean isdege() { return misdege;} | |
90 | Standard_Boolean isafev() { return misafev;} | |
91 | Standard_Boolean isedcu() { return misedcu;} | |
92 | TopOpeBRepDS_Kind TK() {return mTK;} | |
93 | TopAbs_ShapeEnum TS() {return mTS;} | |
94 | private: | |
95 | Standard_Boolean miskind,misshap,misgeom,missect,misdege,misafev,misedcu; | |
96 | TopOpeBRepDS_Kind mTK; TopAbs_ShapeEnum mTS; | |
97 | }; | |
98 | ||
99 | class TDSpar : public TSEEpar { | |
100 | public: | |
101 | TDSpar(const TCollection_AsciiString& s) : TSEEpar(s) {} | |
102 | }; | |
103 | ||
104 | #define ISINTEGER(MMstr) ((strspn((MMstr),"0123456789") == strlen((MMstr)))) | |
105 | ||
1d0a9d4d | 106 | TestTopOpe_HDSDisplayer* PHDSD = NULL; |
107 | static TestTopOpeDraw_Displayer* POCD = NULL; | |
7fd59977 | 108 | //Standard_IMPORT extern Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector; |
109 | Standard_IMPORT Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector; | |
110 | ||
111 | static Standard_Boolean SFindKeep = Standard_False; | |
112 | static Standard_Boolean GFindKeep = Standard_False; | |
113 | static Standard_Boolean PrintDistancePP = Standard_False; | |
114 | static Standard_Integer SelectRankShape = 0; | |
115 | static Standard_Boolean DisOri = Standard_False; | |
116 | static Standard_Boolean TolFlag = Standard_False; | |
117 | static Standard_Real OldParFlag = -1.0; | |
118 | static Standard_Real ParFlag = -1.0; | |
119 | ||
120 | class tsee_entity { | |
121 | public: | |
122 | Standard_Boolean myEOK; | |
123 | TestTopOpe_HDSDisplayer* myEPHDSD; | |
124 | Handle(TopOpeBRepDS_HDataStructure) myEHDS; TopOpeBRepDS_DataStructure *myEPDS; | |
125 | TopOpeBRepDS_Kind myETK;TopAbs_ShapeEnum myETS;Standard_Integer myEindex; | |
126 | Standard_Boolean myEiskind,myEisshape,myEisgeome,myEissect; | |
127 | TCollection_AsciiString myEnamedbrep,myEnamedisp; Draw_ColorKind myEnamecolor; | |
128 | ||
129 | //JR/Hp : | |
130 | tsee_entity() { | |
131 | // tsee_entity::tsee_entity() { | |
132 | myEOK = Standard_False; | |
133 | if (PHDSD == NULL) return; myEPHDSD = PHDSD; | |
134 | myEHDS = myEPHDSD->CurrentHDS(); myEPDS = (TopOpeBRepDS_DataStructure*)&myEHDS->ChangeDS(); | |
135 | myETK = TopOpeBRepDS_UNKNOWN;myETS = TopAbs_SHAPE; myEindex = 0; | |
136 | myEiskind = myEisshape = myEisgeome = myEissect = Standard_False; | |
137 | myEnamedbrep = ""; myEnamedisp = ""; myEnamecolor = Draw_blanc; | |
138 | myEOK = Standard_True; | |
139 | } | |
140 | ||
141 | Standard_Boolean IsP() const { return (myETK == TopOpeBRepDS_POINT); } | |
142 | Standard_Boolean IsV() const { return (myETK == TopOpeBRepDS_VERTEX); } | |
143 | Standard_Boolean Is0() const { return IsP() || IsV(); } | |
144 | Standard_Integer Set(Standard_Integer na,const char** a,Standard_Integer iargK,Standard_Integer iargI); | |
96f3bacc | 145 | |
146 | virtual ~tsee_entity() {} | |
7fd59977 | 147 | void virtual Dump() const; |
148 | void virtual See() = 0; | |
149 | }; | |
150 | ||
7fd59977 | 151 | Standard_Integer tsee_entity::Set(Standard_Integer na,const char** a,Standard_Integer iargK,Standard_Integer iargI) { |
152 | myEOK = Standard_False; | |
153 | if (iargK>=na) return 1; if (iargI>=na) return 1; | |
91322f44 | 154 | TCollection_AsciiString ascK = a[iargK]; myEindex = Draw::Atoi(a[iargI]); |
7fd59977 | 155 | myEiskind = TestTopOpeDraw_TTOT::StringToKind(ascK,myETK); |
156 | if (!myEiskind) return 1; if (myETK == TopOpeBRepDS_UNKNOWN) return 1; | |
157 | ||
158 | myEisshape = TopOpeBRepDS::IsTopology(myETK); | |
159 | if (myEisshape) { | |
160 | if ((myEindex < 1) || (myEindex > myEPDS->NbShapes())) return 0; | |
161 | myETS = TopOpeBRepDS::KindToShape(myETK); | |
162 | const TopoDS_Shape& S = myEPDS->Shape(myEindex); | |
163 | if (myETS != S.ShapeType()) return 0; | |
164 | myEPHDSD->ShapeName(myEindex,S,myEnamedbrep); | |
165 | myEPHDSD->ShapeDisplayName(myEindex,S,myEnamedisp); | |
166 | } | |
167 | ||
168 | myEisgeome = TopOpeBRepDS::IsGeometry(myETK); | |
169 | if (myEisgeome) { | |
170 | if (IsP()) { | |
171 | TopOpeBRepDS_PointExplorer pex(myEHDS->DS()); | |
172 | if (!pex.IsPoint(myEindex)) return 1; | |
173 | } | |
174 | TestTopOpeDraw_TTOT::GeometryName(myEindex,myETK,myEnamedbrep); | |
175 | myEPHDSD->GeometryDisplayName(myEindex,myETK,myEnamedisp); | |
176 | } | |
177 | ||
178 | myEnamecolor = TestTopOpeDraw_TTOT::GeometryColor(myETK); | |
179 | myEOK = Standard_True; | |
180 | return 0; | |
181 | } | |
182 | ||
183 | void tsee_entity::Dump() const { | |
184 | TopOpeBRepDS_Dumper Dumper(myEHDS); | |
185 | if (myEisgeome) Dumper.DumpGeometry(myETK,myEindex,cout); | |
186 | if (myEisshape) Dumper.DumpTopology(myETK,myEindex,cout); | |
187 | } | |
188 | ||
189 | class tsee_entity0 : public tsee_entity { | |
190 | public: | |
96f3bacc | 191 | gp_Pnt Pnt() const; |
7fd59977 | 192 | void See(); |
7fd59977 | 193 | }; |
194 | ||
195 | gp_Pnt tsee_entity0::Pnt() const | |
196 | { | |
b3a7aa39 | 197 | if (!Is0()) Standard_Failure::Raise("not 0d"); |
7fd59977 | 198 | gp_Pnt P; |
199 | if (IsP()) P = myEPDS->Point(myEindex).Point(); | |
200 | else if (IsV()) P = BRep_Tool::Pnt(TopoDS::Vertex(myEPDS->Shape(myEindex))); | |
201 | return P; | |
202 | } | |
203 | ||
204 | static void SetPoint | |
205 | (const TCollection_AsciiString& namedbrep,const TCollection_AsciiString& namedisp,const Draw_Color& namecolor,const TopOpeBRepDS_Point& P) | |
206 | { | |
207 | Handle(TestTopOpeDraw_DrawableP3D) D; | |
208 | if(TolFlag) { | |
209 | D = new TestTopOpeDraw_DrawableP3D(P.Point(),Draw_CircleZoom,namecolor, | |
210 | namedisp.ToCString(),namecolor, | |
211 | P.Tolerance()); | |
212 | } else { | |
213 | D = new TestTopOpeDraw_DrawableP3D(P.Point(),Draw_Square,namecolor, | |
214 | namedisp.ToCString(),namecolor); | |
215 | } | |
216 | char *pname = (char *)namedbrep.ToCString(); | |
217 | Draw::Set(pname,Handle(Draw_Marker3D)::DownCast(D)); | |
218 | ||
219 | } | |
220 | void tsee_entity0::See() | |
221 | { | |
222 | if (IsP()) ::SetPoint(myEnamedbrep,myEnamedisp,myEnamecolor,myEPDS->Point(myEindex)); | |
223 | if (IsV()) POCD->DisplayShape(myEnamedbrep,myEnamedisp,myEPDS->Shape(myEindex)); | |
224 | } | |
225 | ||
226 | //----------------------------------------------- | |
227 | static void SetCurve | |
228 | //----------------------------------------------- | |
229 | (const TCollection_AsciiString& namedbrep, | |
230 | const TCollection_AsciiString& namedisp, | |
231 | const Draw_Color& namecolor, | |
232 | const TopOpeBRepDS_Curve& DSC, | |
233 | const Standard_Integer iC) | |
234 | { | |
235 | if ( !PHDSD ) return; | |
236 | const Handle(Geom_Curve) GC = DSC.Curve(); | |
237 | if ( GC.IsNull() ) { cout<<"Curve() nulle"<<endl; return; } | |
238 | ||
7fd59977 | 239 | Standard_Real f = GC->FirstParameter(); |
240 | Standard_Real l = GC->LastParameter(); | |
241 | ||
242 | GeomAdaptor_Curve GAC(GC); | |
243 | GeomAbs_CurveType GACt = GAC.GetType(); | |
244 | if ( GACt == GeomAbs_Line ) { | |
245 | Standard_Real fline = RealLast(),lline = RealFirst(); | |
246 | Standard_Integer imother = DSC.Mother(),igood; | |
247 | if(imother) igood = imother; | |
248 | else igood = iC; | |
249 | TopOpeBRepDS_PointIterator it = PHDSD->CurrentHDS()->CurvePoints(igood); | |
250 | for(; it.More(); it.Next()) { | |
251 | Standard_Real p = it.Parameter(); | |
252 | fline = Min(fline,p); lline = Max(fline,p); | |
253 | } | |
254 | f = fline; | |
255 | l = lline; | |
256 | } | |
257 | ||
258 | Handle(Geom_TrimmedCurve) GTC = new Geom_TrimmedCurve(GC,f,l); | |
259 | Handle(TestTopOpeDraw_DrawableC3D) D; | |
260 | D = new TestTopOpeDraw_DrawableC3D(GTC,namecolor,namedisp.ToCString(),namecolor); | |
261 | char *pname = (char *)namedbrep.ToCString(); | |
262 | Draw::Set(pname,Handle(DrawTrSurf_Curve)::DownCast(D)); | |
263 | } | |
264 | ||
265 | static TopoDS_Shape bidbid; | |
266 | static const TopoDS_Shape& GetShape(const Standard_Integer IS,const TopAbs_ShapeEnum TS) | |
267 | { | |
268 | Standard_Boolean TypeControl = Standard_True; | |
269 | if ( !PHDSD ) return bidbid; | |
270 | ||
271 | static TopoDS_Shape ShapeNull; | |
272 | const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS(); | |
273 | ||
274 | // check on shape index and on shape kind if kind differs from TopAbs_SHAPE | |
275 | Standard_Integer ns = BDS.NbShapes(); | |
276 | if ( IS < 1 || IS > ns) { | |
277 | TopAbs::Print(TS,cout);cout<<" "<<IS<<" does not exist in DS"<<endl; | |
278 | return ShapeNull; | |
279 | } | |
280 | else if ( !PHDSD->ShapeKind(IS,TS) ) { | |
281 | if ( TypeControl ) { | |
282 | cout<<"Shape "<<IS; | |
283 | cout<<" is not a ";TopAbs::Print(TS,cout); | |
284 | cout<<" but a "; TopAbs::Print(BDS.Shape(IS,SFindKeep).ShapeType(),cout); | |
285 | cout<<endl; | |
286 | } | |
287 | return ShapeNull; | |
288 | } | |
289 | ||
290 | const TopoDS_Shape& S = BDS.Shape(IS,SFindKeep); | |
291 | return S; | |
292 | } | |
293 | ||
294 | static const TopoDS_Shape& GetShape(const Standard_Integer IS) | |
295 | { | |
296 | if ( !PHDSD ) return bidbid; | |
297 | const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS(); | |
298 | const TopoDS_Shape& S = BDS.Shape(IS); | |
299 | return S; | |
300 | } | |
301 | ||
7fd59977 | 302 | //----------------------------------------------------------------------- |
303 | // SeeSectionEdge | |
304 | //----------------------------------------------------------------------- | |
305 | static Standard_Integer SeeSectionEdge(const Standard_Integer ISE) | |
306 | { | |
307 | if ( !PHDSD || !POCD ) return 0; | |
308 | ||
309 | Standard_Integer nse = PHDSD->CurrentBDS().NbSectionEdges(); | |
310 | if ( ISE < 1 || ISE > nse ) return 0; | |
311 | const TopoDS_Shape& SE = PHDSD->CurrentBDS().SectionEdge(ISE); | |
312 | if (SE.IsNull()) return 0; | |
7fd59977 | 313 | |
314 | TCollection_AsciiString namedbrep; PHDSD->SectionEdgeName(ISE,SE,namedbrep); | |
315 | TCollection_AsciiString namedisp; PHDSD->SectionEdgeDisplayName(ISE,SE,namedisp); | |
316 | POCD->DisplayGeometry(Standard_True); | |
317 | POCD->DisplayShape(namedbrep,namedisp,SE); | |
318 | return 0; | |
319 | } | |
320 | ||
321 | //----------------------------------------------------------------------- | |
322 | // SeeShapeIS | |
323 | //----------------------------------------------------------------------- | |
324 | Standard_Integer SeeShapeIS(const Standard_Integer I,const TopoDS_Shape& S) | |
325 | { | |
326 | if ( !PHDSD || !POCD) return 0; | |
327 | ||
328 | if (S.IsNull()) return 0; | |
329 | TCollection_AsciiString namedbrep; PHDSD->ShapeName(I,S,namedbrep); | |
330 | TCollection_AsciiString namedisp = namedbrep; | |
331 | // NameDisplay = *name/name* if S subshape of shape1/shape2 | |
332 | TCollection_AsciiString ast = "*"; | |
333 | const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS(); | |
334 | // if the Shape was removed from the DS, "*" is replaced by "~" | |
335 | if(!BDS.HasShape(S)) | |
336 | ast = "~"; | |
337 | Standard_Boolean of1 = PHDSD->SubShape(S,1);if(of1) namedisp = ast+namedisp; | |
338 | Standard_Boolean of2 = PHDSD->SubShape(S,2);if(of2) namedisp = namedisp+ast; | |
339 | if (SelectRankShape == 1 && !of1) return 0; | |
340 | if (SelectRankShape == 2 && !of2) return 0; | |
341 | ||
342 | if (S.ShapeType()==TopAbs_EDGE) POCD->DisplayGeometry(Standard_True); | |
343 | else POCD->DisplayGeometry(DisOri); | |
344 | if((S.ShapeType()==TopAbs_VERTEX) && TolFlag) { | |
345 | const TopoDS_Vertex& V = TopoDS::Vertex(S); | |
346 | Standard_Real Tol = BRep_Tool::Tolerance(V); | |
347 | POCD->SetTol(Tol); | |
348 | } | |
349 | POCD->DisplayShape(namedbrep,namedisp,S); | |
350 | ||
351 | return 0; | |
352 | } | |
353 | ||
354 | ||
355 | //----------------------------------------------------------------------- | |
356 | // SeeShape | |
357 | //----------------------------------------------------------------------- | |
358 | static Standard_Integer SeeShape(TCollection_AsciiString namedbrep) | |
359 | { | |
360 | if ( !PHDSD || !POCD ) return 0; | |
361 | ||
362 | const char* pname = (const char *)namedbrep.ToCString(); | |
363 | TopoDS_Shape S = DBRep::Get(pname); | |
364 | if ( S.IsNull() ) return 0; | |
365 | TCollection_AsciiString namedisp; | |
366 | PHDSD->ShapeDisplayName(namedbrep,S,namedisp); | |
367 | POCD->DisplayShape(namedbrep,namedisp,S); | |
368 | return 0; | |
369 | } | |
370 | ||
371 | //----------------------------------------------------------------------- | |
372 | // SeePoint | |
373 | //----------------------------------------------------------------------- | |
374 | static Standard_Integer SeePoint(const Standard_Integer I) | |
375 | { | |
376 | if ( !PHDSD ) return 0; | |
377 | ||
378 | const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS(); | |
379 | if (I < 1 || I > BDS.NbPoints()) return 0; | |
380 | ||
381 | TopOpeBRepDS_PointExplorer pex(BDS); | |
382 | Standard_Boolean isp = pex.IsPoint(I); | |
383 | if (!isp) return 0; | |
384 | ||
385 | const TopOpeBRepDS_Point& P = BDS.Point(I); | |
386 | TopOpeBRepDS_Kind K = TopOpeBRepDS_POINT; | |
387 | TCollection_AsciiString namedbrep; TestTopOpeDraw_TTOT::GeometryName(I,K,namedbrep); | |
388 | TCollection_AsciiString namedisp; PHDSD->GeometryDisplayName(I,K,namedisp); | |
389 | Draw_ColorKind namecolor = TestTopOpeDraw_TTOT::GeometryColor(K); | |
390 | SetPoint(namedbrep,namedisp,namecolor,P); | |
391 | return 0; | |
392 | } | |
393 | ||
394 | //----------------------------------------------------------------------- | |
395 | // SeeCurve | |
396 | //----------------------------------------------------------------------- | |
397 | static Standard_Integer SeeCurve(const Standard_Integer I) | |
398 | { | |
399 | if ( !PHDSD ) return 0; | |
400 | ||
401 | const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS(); | |
402 | if (I < 1 || I > BDS.NbCurves()) return 0; | |
403 | ||
404 | TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep); | |
405 | Standard_Boolean isc = cex.IsCurve(I); | |
406 | if (!isc) return 0; | |
407 | ||
408 | const TopOpeBRepDS_Curve& C = BDS.Curve(I); | |
409 | TopOpeBRepDS_Kind K = TopOpeBRepDS_CURVE; | |
410 | TCollection_AsciiString namedbrep; TestTopOpeDraw_TTOT::GeometryName(I,K,namedbrep); | |
411 | TCollection_AsciiString namedisp; PHDSD->GeometryDisplayName(I,K,namedisp); | |
412 | Draw_ColorKind namecolor = TestTopOpeDraw_TTOT::GeometryColor(K); | |
413 | SetCurve(namedbrep,namedisp,namecolor,C,I); | |
414 | return 0; | |
415 | } | |
416 | ||
417 | ||
418 | //----------------------------------------------------------------------- | |
419 | // SeeSurface NYI | |
420 | //----------------------------------------------------------------------- | |
421 | Standard_Integer SeeSurface(const Standard_Integer I) // NYI | |
422 | { | |
423 | if ( !PHDSD ) return 0; | |
424 | ||
425 | const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS(); | |
426 | if (I < 1 || I > BDS.NbSurfaces()) return 0; | |
427 | return 0; | |
428 | } | |
429 | ||
430 | //----------------------------------------------------------------------- | |
431 | // SeeEdgeCurve | |
432 | //----------------------------------------------------------------------- | |
433 | static Standard_Integer SeeEdgeCurve(const Standard_Integer IE,const TopoDS_Shape& SE) | |
434 | { | |
435 | if ( !POCD ) return 0; | |
436 | ||
437 | if (SE.IsNull()) return 0; | |
438 | const TopoDS_Edge& E = TopoDS::Edge(SE); | |
439 | TopLoc_Location L;Standard_Real f,l;Handle(Geom_Curve) GC=BRep_Tool::Curve(E,L,f,l); | |
440 | TCollection_AsciiString namedbrep="E";TestTopOpeDraw_TTOT::CatCurveName(IE,namedbrep); | |
441 | TCollection_AsciiString namedisp="E";TestTopOpeDraw_TTOT::CatCurveDisplayName(IE,GC,namedisp); | |
442 | POCD->DisplayGeometry(Standard_True); | |
443 | POCD->DisplayShape(namedbrep,namedisp,SE); | |
444 | return 0; | |
445 | } | |
446 | ||
447 | //----------------------------------------------------------------------- | |
448 | // SeeGeometry | |
449 | //----------------------------------------------------------------------- | |
450 | static Standard_Integer SeeGeometry(const Standard_Integer IG,const TopOpeBRepDS_Kind TK) | |
451 | { | |
452 | if (TK == TopOpeBRepDS_POINT) return SeePoint(IG); | |
453 | else if (TK == TopOpeBRepDS_CURVE) return SeeCurve(IG); | |
454 | else if (TK == TopOpeBRepDS_SURFACE) return SeeSurface(IG); | |
455 | return 0; | |
456 | } | |
457 | ||
7fd59977 | 458 | //----------------------------------------------------------------------- |
459 | // SeeGeometry | |
460 | //----------------------------------------------------------------------- | |
461 | static Standard_Integer SeeGeometry(const TopOpeBRepDS_Kind TK) | |
462 | { | |
463 | if ( !PHDSD ) return 0; | |
464 | ||
465 | const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS(); | |
466 | ||
7fd59977 | 467 | if (TK == TopOpeBRepDS_POINT) { |
468 | TopOpeBRepDS_PointExplorer pex(BDS,GFindKeep); | |
469 | for (; pex.More(); pex.Next()) { | |
470 | Standard_Integer ig = pex.Index(); | |
471 | SeeGeometry(ig,TK); | |
472 | } | |
473 | } | |
474 | else if (TK == TopOpeBRepDS_CURVE) { | |
475 | TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep); | |
476 | for (; cex.More(); cex.Next()) { | |
477 | Standard_Integer ig = cex.Index(); | |
478 | SeeGeometry(ig,TK); | |
479 | } | |
480 | } | |
481 | else if (TK == TopOpeBRepDS_SURFACE) { //NYI | |
482 | } | |
483 | return 0; | |
484 | } | |
485 | ||
486 | //----------------------------------------------------------------------- | |
487 | // TOPOPE_SeeShape | |
488 | //----------------------------------------------------------------------- | |
489 | Standard_Integer TOPOPE_SeeShape(char* name) | |
490 | { | |
491 | TCollection_AsciiString asc = name; | |
492 | Standard_Integer res = SeeShape(asc); | |
493 | return res; | |
494 | } | |
495 | ||
7fd59977 | 496 | //----------------------------------------------------------------------- |
497 | // suppressarg : remove a[d],modify na-- | |
498 | //----------------------------------------------------------------------- | |
1d0a9d4d | 499 | void suppressarg(Standard_Integer& na,const char** a,const Standard_Integer d) |
7fd59977 | 500 | { |
501 | for(Standard_Integer i=d;i<na;i++) { | |
502 | a[i]=a[i+1]; | |
503 | a[i+1]=NULL; | |
504 | } | |
505 | na--; | |
506 | } | |
507 | ||
508 | //----------------------------------------------------------------------- | |
509 | // suppressargs : remove a[*] from <f> to <l>,modify na = na - (l - f) | |
510 | //----------------------------------------------------------------------- | |
511 | Standard_EXPORT void suppressargs(Standard_Integer& na,const char** a,const Standard_Integer f,const Standard_Integer l) | |
512 | { | |
513 | if(l == f) | |
514 | suppressarg(na,a,l); | |
515 | if(l <= f) return; | |
516 | for(Standard_Integer i=0;i<na-l;i++) { | |
517 | a[i+f]=a[i+l+1]; | |
518 | a[i+l+1]=NULL; | |
519 | } | |
520 | na -= l-f+1; | |
521 | } | |
522 | ||
7fd59977 | 523 | //----------------------------------------------------------------------- |
524 | // tsee_flags | |
525 | //----------------------------------------------------------------------- | |
526 | static void tsee_flags(Standard_Integer& na,const char** a) { | |
527 | GFindKeep = Standard_False; | |
528 | PrintDistancePP = Standard_False; | |
529 | SelectRankShape = 0; | |
530 | ||
531 | for (Standard_Integer ia = 1; ia < na; ia++) { | |
532 | if (!strcasecmp(a[ia],"-k")) { | |
533 | suppressarg(na,a,ia); | |
534 | GFindKeep = Standard_True; | |
535 | } | |
536 | else if (!strcasecmp(a[ia],"-d")) { | |
537 | // tsee -d p 4 7 : display p_4,p_7 + tds p 4 7 + calculate distance (p_4,p_7) | |
538 | suppressarg(na,a,ia); | |
539 | PrintDistancePP = Standard_True; | |
540 | } | |
541 | else if (!strcasecmp(a[ia],"-1")) { | |
542 | // tsee -1 s 4 : display s_4 <=> s_4 is subshape of the 1st argument | |
543 | suppressarg(na,a,ia); | |
544 | SelectRankShape = 1; | |
545 | } | |
546 | else if (!strcasecmp(a[ia],"-2")) { | |
547 | // tsee -2 s 4 : display s_4 <=> s_4 is subshape of the 2nd argument | |
548 | suppressarg(na,a,ia); | |
549 | SelectRankShape = 2; | |
550 | } | |
551 | else if (!strcasecmp(a[ia],"-p") && (ia < na-1)) { | |
552 | suppressargs(na,a,ia,ia+1); | |
91322f44 | 553 | Standard_Real t = Draw::Atof(a[ia+1]); |
7fd59977 | 554 | if (t >= 0. && t <= 1.) { |
555 | OldParFlag = ParFlag; ParFlag = t; | |
556 | } | |
557 | } | |
558 | } | |
559 | } | |
560 | ||
561 | void OthersCommands_help(const char* CommandName,const char* syntaxe = ""); | |
562 | //----------------------------------------------------------------------- | |
563 | // tsee_help | |
564 | //----------------------------------------------------------------------- | |
565 | static void tsee_help(const char* CommandName, Draw_Interpretor& di) | |
566 | { | |
567 | di<<""<<"\n"; | |
568 | di<<"tsee : Draw entities of data structure (DS) loaded by TestTopOpe::CurrentDS()."<<"\n"; | |
569 | di<<"DS entities are shapes and geometries accessed by a <type> and an <index>."<<"\n"; | |
570 | di<<"basic usage :"<<"\n"; | |
571 | di<<" tsee <type> <index1 index2 ...>"<<"\n"; | |
572 | di<<"<type> = so sh f w e v s for solid/shell/face/wire/edge/vertex/shape"<<"\n"; | |
573 | di<<" su cu p for surface/curve/point (N.B : su is NYI)"<<"\n"; | |
574 | di<<"<index> = integer"<<"\n"; | |
575 | di<<"example : 'tsee e 3' will draw the edge of index 3"<<"\n"; | |
576 | di<<" 'tsee e 3 6' will draw the edges of index 3 and 6"<<"\n"; | |
577 | di<<" 'tsee e' will draw all the edges."<<"\n"; | |
578 | di<<""<<"\n"; | |
579 | di<<"Index values of DS entities may be given by the 'tds' command which prints"<<"\n"; | |
580 | di<<"the content of the DS for each shape and geometry type."<<"\n"; | |
581 | di<<"Entities are drawn with a specific color according to their type."<<"\n"; | |
582 | di<<""<<"\n"; | |
583 | di<<"Naming : "<<"\n"; | |
584 | di<<"'tsee <t> <i>' creates the drawable object named <t>_<i>."<<"\n"; | |
585 | di<<"This name is displayed near the entity in one if the forms : "<<"\n"; | |
586 | di<<" *<t>_<i> meaning entity belongs to the first shape of current operation."<<"\n"; | |
587 | di<<" <t>_<i>* meaning entity belongs to the second shape of current operation."<<"\n"; | |
588 | di<<""<<"\n"; | |
589 | di<<"Same Domain shapes : "<<"\n"; | |
590 | di<<"'tsee <type> sd' to display all shapes of <type> having same domain data."<<"\n"; | |
591 | di<<"example : 'tsee e sd' to display all edges sharing a 1d geometric domain"<<"\n"; | |
592 | di<<" with other edges."<<"\n"; | |
593 | di<<""<<"\n"; | |
594 | di<<"Optional flags :"<<"\n"; | |
595 | OthersCommands_help(CommandName); | |
596 | di<<"Other types :"<<"\n"; | |
597 | di<<"'tsee fev' : displays all faces,then edges,then vertices."<<"\n"; | |
598 | di<<"'tsee es <i>' displays edge described as section edge <i>."<<"\n"; | |
599 | di<<" The name of a section edge likes t_i<j>,where :"<<"\n"; | |
600 | di<<" - i is the edge index in the set of section edge,"<<"\n"; | |
601 | di<<" - j is edge index in the DS (as any edge)."<<"\n"; | |
602 | di<<""<<"\n"; | |
603 | } | |
604 | ||
605 | static void tseei_help(Draw_Interpretor& di) | |
606 | { | |
607 | di<<""<<"\n"; | |
608 | di<<"tseei : Draws entities of data structure (DS) loaded by TestTopOpe::CurrentDS()."<<"\n"; | |
609 | di<<"Draws the objects appearing in interferences DS objects."<<"\n"; | |
610 | di<<"See command 'tsee' for discussion about DS objects."<<"\n"; | |
611 | di<<"\n"; | |
612 | } | |
613 | ||
614 | static void tki_help(Draw_Interpretor& di) | |
615 | { | |
616 | di<<""<<"\n"; | |
617 | di<<"tki,tkig,tkis : Groups interferences of DS objects"<<"\n"; | |
618 | di<<" by geometry (g),or support (s),and index."<<"\n"; | |
619 | di<<"See command 'tsee' for discussion about DS objects."<<"\n"; | |
620 | di<<"(Test of class TopOpeBRepDS_TKI)"<<"\n"; | |
621 | di<<"\n"; | |
622 | } | |
623 | ||
624 | static void tds_help(Draw_Interpretor& di) | |
625 | { | |
626 | di<<""<<"\n"; | |
627 | di<<"tds : dump current DS (loaded by CurrentDS())"<<"\n"; | |
628 | di<<"basic usage : tds <-arg> type <index1 index2 ...>"<<"\n"; | |
629 | di<<"\n"; | |
630 | di<<"Description of curve geometry (type = c) : <-arg> = -t -k -s -l"<<"\n"; | |
631 | di<<"\t-k : print only the curve with keep = Standard_True"<<"\n"; | |
632 | di<<"\t-l : (long) print all poles and knots for BSplines curves"<<"\n"; | |
633 | di<<"\t-s : (short) print only 4 poles and 4 knots for BSplines curves"<<"\n"; | |
634 | di<<"on shapes (type = s|so|sh|f|w|e|v) : <-arg> = -ssi"<<"\n"; | |
635 | di<<"\t-ssi : print only ShapeShapeInterferences"<<"\n"; | |
636 | di<<""<<"\n"; | |
637 | di<<"See command 'tsee' for discussion about type and <index1 index2 ...>."<<"\n"; | |
638 | di<<"\n"; | |
639 | } | |
640 | ||
641 | typedef Standard_Integer (*tf_SeeShape)(const Standard_Integer I,const TopoDS_Shape& S); | |
1d0a9d4d | 642 | extern void OthersCommands_flags(Standard_Integer& na,const char** a,TestTopOpeDraw_Displayer& TD); |
7fd59977 | 643 | void COUTNOHDS(Draw_Interpretor& di) {di<<"no current HDS"<<"\n";} |
644 | Standard_Integer tsee_SeeShapefunc(Draw_Interpretor& di,Standard_Integer na_in,const char** a,tf_SeeShape SeeShapefunc) | |
645 | { | |
646 | if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) { | |
647 | tsee_help(a[0], di); | |
648 | return 0; | |
649 | } | |
650 | ||
651 | Standard_Integer na = na_in; | |
652 | if ((PHDSD == NULL) || (POCD == NULL)) return 0; | |
653 | ||
654 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS(); | |
655 | if (HDS.IsNull()) { COUTNOHDS(di); return 0; } | |
656 | if (na < 2) return 1; | |
657 | const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS(); | |
658 | ||
659 | POCD->InitDisplayer(); | |
660 | TolFlag = Standard_False; | |
661 | tsee_flags(na,a); | |
662 | OthersCommands_flags(na,a,*POCD); | |
663 | TolFlag = POCD->TolIs(); | |
664 | DisOri = POCD->DisplayGeometry(); | |
665 | ||
666 | Standard_Integer i1arg = 1; | |
667 | TSEEpar Tpar(a[i1arg]); | |
668 | ||
669 | // Standard_Integer ia,is,ig; | |
670 | Standard_Integer ia,is; | |
671 | ||
672 | if ( PrintDistancePP ) { | |
673 | tsee_entity0 E1,E2; | |
674 | if (na == 4) { // tsee p 3 4 | |
675 | if (E1.Set(na,a,i1arg+0,i1arg+1)) return 1; | |
676 | if (E2.Set(na,a,i1arg+0,i1arg+2)) return 1; | |
677 | } | |
678 | else if (na == 5) { // tsee p 3 v 4 | |
679 | if (E1.Set(na,a,i1arg+0,i1arg+1)) return 1; | |
680 | if (E2.Set(na,a,i1arg+2,i1arg+3)) return 1; | |
681 | } | |
682 | if (!E1.myEOK || !E2.myEOK) return 1; | |
683 | ||
684 | E1.See();E2.See(); | |
685 | E1.Dump();E2.Dump(); | |
686 | di<<"Distance "<<E1.myEnamedbrep.ToCString()<<" "<<E2.myEnamedbrep.ToCString()<<" : "<<E1.Pnt().Distance(E2.Pnt())<<"\n"; | |
687 | ||
688 | } // PrintDistancePP | |
689 | ||
690 | else if ( Tpar.isshap() ) { | |
691 | // na == 2 : display all DS shapes of type TS | |
91322f44 | 692 | // na > 2 : display DS shapes of type TS of index Draw::Atoi(a[2]..a[narg-1]) |
7fd59977 | 693 | if (na == 2 ) { |
694 | TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False); | |
695 | for(;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current()); | |
696 | } | |
697 | else { | |
698 | if ( !strcmp(a[i1arg+1],"sd") ) { // shapes HasSameDomain of type TS | |
699 | TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False); | |
700 | for (;x.More();x.Next()) { | |
701 | Standard_Boolean isSsd = HDS->HasSameDomain(x.Current()); | |
702 | if (isSsd ) (*SeeShapefunc)(x.Index(),x.Current()); | |
703 | } | |
704 | } | |
705 | else if (Tpar.isshap() && (Tpar.TS() == TopAbs_EDGE) && (na>=2) && POCD->ParIs()) { | |
706 | // see edges [4..na[ with of the name in t in [0..1] / range | |
707 | if (na == 2) { | |
708 | TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False); | |
709 | for (;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current()); | |
710 | } | |
711 | else { | |
712 | for (ia = i1arg+1; ia < na; ia++) { | |
91322f44 | 713 | is = Draw::Atoi(a[ia]); |
7fd59977 | 714 | (*SeeShapefunc)(is,GetShape(is,Tpar.TS())); |
715 | } | |
716 | } | |
717 | ParFlag = OldParFlag; | |
718 | } | |
719 | else { | |
720 | for (ia = i1arg+1; ia < na; ia++) { | |
91322f44 | 721 | is = Draw::Atoi(a[ia]); |
7fd59977 | 722 | (*SeeShapefunc)(is,GetShape(is,Tpar.TS())); |
723 | } | |
724 | } | |
725 | } | |
726 | } // isshap | |
727 | ||
728 | else if ( Tpar.isgeom() ) { | |
729 | // na == 2 : display all DS geometries of type TK | |
91322f44 | 730 | // na > 2 : display DS geometries of type TK index Draw::Atoi(a[2])..a[narg-1]) |
7fd59977 | 731 | if (na == 2 ) SeeGeometry(Tpar.TK()); |
91322f44 | 732 | else for (ia = i1arg+1; ia < na; ia++) SeeGeometry(Standard_Integer(Draw::Atoi(a[ia])),Tpar.TK()); |
7fd59977 | 733 | } |
734 | ||
735 | else if ( Tpar.isafev() ) { | |
736 | // faces then edges then vertices | |
737 | TopOpeBRepDS_Explorer x; | |
738 | for (x.Init(HDS,TopAbs_FACE,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index())); | |
739 | for (x.Init(HDS,TopAbs_EDGE,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index())); | |
740 | for (x.Init(HDS,TopAbs_VERTEX,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index())); | |
741 | } | |
742 | ||
743 | else if ( Tpar.isedcu() ) { | |
744 | // na == 2 : display curves of all DS edges | |
91322f44 | 745 | // na > 2 : display curve of DS edges index Draw::Atoi(a[2])..a[narg-1]) |
7fd59977 | 746 | if ( na == 2 ) { |
747 | TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False); | |
748 | for (;x.More();x.Next()) SeeEdgeCurve(x.Index(),x.Edge()); | |
749 | } | |
750 | else { | |
751 | for (ia = i1arg+1; ia < na; ia++) { | |
91322f44 | 752 | is = Draw::Atoi(a[ia]); |
7fd59977 | 753 | SeeEdgeCurve(is,GetShape(is,TopAbs_EDGE)); |
754 | } | |
755 | } | |
756 | } | |
757 | ||
758 | else if ( Tpar.issect() ) { // na=2 all section edges,na>2 section edges (a[2]..a[na-1]) | |
759 | Standard_Integer ise,nse = BDS.NbSectionEdges(); | |
760 | if (na == 2) for (ise = 1; ise<=nse; ise++) SeeSectionEdge(ise); | |
91322f44 | 761 | else for (ia = i1arg+1; ia<na; ia++) SeeSectionEdge(Draw::Atoi(a[ia])); |
7fd59977 | 762 | } |
763 | ||
764 | else if (Tpar.isdege()) { | |
765 | TopOpeBRepDS_Explorer x; | |
766 | for (x.Init(HDS,TopAbs_EDGE);x.More();x.Next()) { | |
767 | if (BRep_Tool::Degenerated(x.Edge())) (*SeeShapefunc)(x.Index(),GetShape(x.Index())); | |
768 | } | |
769 | } | |
770 | ||
771 | return 0; | |
772 | } // tsee_SeeShapefunc | |
773 | ||
774 | //----------------------------------------------------------------------- | |
775 | // tsee | |
776 | //----------------------------------------------------------------------- | |
777 | Standard_Integer tsee(Draw_Interpretor& di,Standard_Integer na_in,const char** a) | |
778 | { | |
779 | if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) { | |
780 | tsee_help(a[0],di); | |
781 | return 0; | |
782 | } | |
783 | tf_SeeShape ssf = (tf_SeeShape)SeeShapeIS; | |
784 | Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf); | |
785 | return r; | |
786 | } // tsee | |
787 | ||
788 | //----------------------------------------------------------------------- | |
789 | // SeeAnyKI | |
790 | //----------------------------------------------------------------------- | |
791 | Standard_Integer SeeAnyKI(const TopOpeBRepDS_Kind TK,const Standard_Integer I) { | |
7fd59977 | 792 | TopAbs_ShapeEnum TS = TopAbs_COMPOUND; |
7fd59977 | 793 | Standard_Boolean isshape,isgeome; isshape = isgeome = Standard_False; |
794 | isshape = TopOpeBRepDS::IsTopology(TK); | |
795 | if (isshape) TS = TopOpeBRepDS::KindToShape(TK); | |
796 | else isgeome = TopOpeBRepDS::IsGeometry(TK); | |
797 | if (isshape) SeeShapeIS(I,GetShape(I,TS)); | |
798 | else if (isgeome) SeeGeometry(I,TK); | |
799 | return 0; | |
800 | } | |
801 | ||
802 | //----------------------------------------------------------------------- | |
803 | void AddShapeKI | |
804 | //----------------------------------------------------------------------- | |
805 | (TColStd_ListOfInteger& LOK,TColStd_ListOfInteger& LOI, | |
806 | const TopOpeBRepDS_Kind K,const Standard_Integer I) | |
807 | { | |
7fd59977 | 808 | Standard_Boolean isshape,isgeome; isshape = isgeome = Standard_False; |
809 | isshape = TopOpeBRepDS::IsTopology(K); | |
96a95605 DB |
810 | if (!isshape) |
811 | isgeome = TopOpeBRepDS::IsGeometry(K); | |
7fd59977 | 812 | |
813 | if (LOK.IsEmpty() && LOI.IsEmpty()) { | |
814 | LOK.Append((Standard_Integer)K); LOI.Append(I); | |
815 | return; | |
816 | } | |
817 | ||
818 | // to sort, it is considered that : | |
819 | // POINT == VERTEX,CURVE == EDGE,SURFACE == FACE | |
820 | ||
7fd59977 | 821 | TopAbs_ShapeEnum SKtri=TopAbs_COMPOUND; |
1d47d8d0 | 822 | |
7fd59977 | 823 | if (isshape) SKtri = TopOpeBRepDS::KindToShape(K); |
824 | else if (isgeome) { | |
825 | if (K == TopOpeBRepDS_POINT) SKtri = TopAbs_VERTEX; | |
826 | else if (K == TopOpeBRepDS_CURVE) SKtri = TopAbs_EDGE; | |
827 | else if (K == TopOpeBRepDS_SURFACE) SKtri = TopAbs_FACE; | |
828 | } | |
829 | else return; | |
830 | ||
831 | TColStd_ListIteratorOfListOfInteger ITLOK(LOK); | |
832 | TColStd_ListIteratorOfListOfInteger ITLOI(LOI); | |
833 | Standard_Boolean equa = Standard_False; | |
834 | for (; ITLOK.More(),ITLOI.More(); ITLOK.Next(),ITLOI.Next()) { | |
835 | //JR/Hp | |
836 | Standard_Integer ifK = ITLOK.Value() ; | |
837 | TopOpeBRepDS_Kind fK = (TopOpeBRepDS_Kind) ifK ; | |
838 | TopAbs_ShapeEnum fSK = TopOpeBRepDS::KindToShape(fK); | |
839 | // TopOpeBRepDS_Kind fK = (TopOpeBRepDS_Kind)ITLOK.Value(); TopAbs_ShapeEnum fSK = TopOpeBRepDS::KindToShape(fK); | |
840 | Standard_Integer fI = ITLOI.Value(); | |
841 | if (SKtri == fSK && I == fI) { | |
842 | equa = Standard_True; | |
843 | break; | |
844 | } | |
845 | if (SKtri <= fSK) { | |
846 | LOK.InsertBefore((Standard_Integer)K,ITLOK); | |
847 | LOI.InsertBefore(I,ITLOI); | |
848 | break; | |
849 | } | |
850 | } | |
851 | if ( !ITLOK.More() && !equa) { | |
852 | LOK.Append((Standard_Integer)K); | |
853 | LOI.Append(I); | |
854 | } | |
855 | } | |
856 | ||
857 | //----------------------------------------------------------------------- | |
858 | // SeeShapeISI | |
859 | //----------------------------------------------------------------------- | |
860 | Standard_Integer SeeShapeISI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di) | |
861 | { | |
862 | if ( !PHDSD ) return 0; | |
863 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS(); | |
864 | if (S.IsNull()) return 0; | |
865 | SeeShapeIS(I,S); | |
866 | ||
867 | TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType()); | |
868 | const TopOpeBRepDS_DataStructure& BDS = HDS->DS(); | |
869 | const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(S); | |
870 | TopOpeBRepDS_ListIteratorOfListOfInterference ITLOI(LOI); | |
871 | TColStd_ListOfInteger LOKK,LOII; | |
872 | ||
873 | for (;ITLOI.More();ITLOI.Next()) { | |
874 | const Handle(TopOpeBRepDS_Interference)& HI = ITLOI.Value(); | |
875 | const TopOpeBRepDS_Transition& T = HI->Transition(); | |
876 | ||
877 | TopAbs_ShapeEnum sb = T.ShapeBefore();TopOpeBRepDS_Kind sbk = TopOpeBRepDS::ShapeToKind(sb); | |
878 | Standard_Integer sbi = T.IndexBefore(); | |
879 | TopAbs_ShapeEnum sa = T.ShapeAfter();TopOpeBRepDS_Kind sak = TopOpeBRepDS::ShapeToKind(sa); | |
880 | Standard_Integer sai = T.IndexAfter(); | |
881 | TopOpeBRepDS_Kind gk,sk; Standard_Integer gi,si; HI->GKGSKS(gk,gi,sk,si); | |
882 | ||
883 | AddShapeKI(LOKK,LOII,sbk,sbi); | |
884 | AddShapeKI(LOKK,LOII,sak,sai); | |
885 | AddShapeKI(LOKK,LOII,gk,gi); | |
886 | AddShapeKI(LOKK,LOII,sk,si); | |
887 | } | |
888 | ||
889 | TColStd_ListIteratorOfListOfInteger ITLOKK,ITLOII; | |
890 | ||
891 | ITLOKK.Initialize(LOKK); ITLOII.Initialize(LOII); | |
892 | Standard_Boolean ya = ITLOKK.More(); | |
893 | TopOpeBRepDS::Print(SK,I,cout,""," : "); | |
894 | for(; ITLOKK.More(),ITLOII.More(); ITLOKK.Next(),ITLOII.Next()) { | |
895 | //JR/Hp | |
896 | Standard_Integer ikk = ITLOKK.Value() ; | |
897 | TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind) ikk ; | |
898 | Standard_Integer ii = ITLOII.Value(); | |
899 | // TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind)ITLOKK.Value(); Standard_Integer ii = ITLOII.Value(); | |
900 | TopOpeBRepDS::Print(kk,ii,cout,""," "); | |
901 | } | |
902 | if (ya) di<<"\n"; else di<<"no shape interference"<<"\n"; | |
903 | ||
904 | ITLOKK.Initialize(LOKK); ITLOII.Initialize(LOII); | |
905 | for(; ITLOKK.More(),ITLOII.More(); ITLOKK.Next(),ITLOII.Next()) { | |
906 | //JR/Hp | |
907 | Standard_Integer ikk =ITLOKK.Value() ; | |
908 | TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind) ikk ; | |
909 | Standard_Integer ii = ITLOII.Value(); | |
910 | // TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind)ITLOKK.Value(); Standard_Integer ii = ITLOII.Value(); | |
911 | SeeAnyKI(kk,ii); | |
912 | } | |
913 | //POP pour WNT | |
914 | return 0; | |
915 | ||
916 | } // SeeShapeISI | |
917 | ||
918 | //----------------------------------------------------------------------- | |
919 | // SeeShapeTKIG | |
920 | //----------------------------------------------------------------------- | |
921 | Standard_Integer SeeShapeTKIG(const Standard_Integer I,const TopoDS_Shape& S) | |
922 | { | |
923 | if ( !PHDSD ) return 0; | |
924 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS(); | |
925 | if (S.IsNull()) return 0; | |
926 | SeeShapeIS(I,S); | |
927 | ||
928 | TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType()); | |
929 | const TopOpeBRepDS_ListOfInterference& LOI = HDS->DS().ShapeInterferences(S); | |
930 | TopOpeBRepDS_TKI tki; | |
931 | TCollection_AsciiString s1,s2; | |
932 | ||
933 | tki.Clear(); | |
934 | tki.FillOnGeometry(LOI); | |
935 | s1=TopOpeBRepDS::SPrint(SK,I,""," by G : \n"); | |
936 | tki.Init();if (tki.More()) s2="\n";else s2=""; | |
937 | tki.DumpTKIIterator(s1,s2); | |
938 | ||
939 | return 0; | |
940 | } // SeeShapeTKIG | |
941 | ||
942 | //----------------------------------------------------------------------- | |
943 | // SeeShapeTKIS | |
944 | //----------------------------------------------------------------------- | |
945 | Standard_Integer SeeShapeTKIS(const Standard_Integer I,const TopoDS_Shape& S) | |
946 | { | |
947 | if ( !PHDSD ) return 0; | |
948 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS(); | |
949 | if (S.IsNull()) return 0; | |
950 | SeeShapeIS(I,S); | |
951 | ||
952 | TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType()); | |
953 | const TopOpeBRepDS_ListOfInterference& LOI = HDS->DS().ShapeInterferences(S); | |
954 | TopOpeBRepDS_TKI tki; | |
955 | TCollection_AsciiString s1,s2; | |
956 | ||
957 | tki.Clear(); | |
958 | tki.FillOnSupport(LOI); | |
959 | s1=TopOpeBRepDS::SPrint(SK,I,""," by S : \n"); | |
960 | tki.Init();if (tki.More()) s2="\n";else s2=""; | |
961 | tki.DumpTKIIterator(s1,s2); | |
962 | ||
963 | return 0; | |
964 | } // SeeShapeTKIS | |
965 | ||
966 | //----------------------------------------------------------------------- | |
967 | // SeeShapeTKI | |
968 | //----------------------------------------------------------------------- | |
969 | Standard_Integer SeeShapeTKI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di) | |
970 | { | |
971 | di<<"\n"; | |
972 | SeeShapeTKIG(I,S); | |
973 | SeeShapeTKIS(I,S); | |
974 | return 0; | |
975 | } // SeeShapeTKI | |
976 | ||
977 | //----------------------------------------------------------------------- | |
978 | // tseei | |
979 | //----------------------------------------------------------------------- | |
980 | Standard_Integer tseei(Draw_Interpretor& di,Standard_Integer na_in,const char** a) | |
981 | { | |
982 | if (na_in == 1) { tseei_help(di); return 0; } | |
983 | tf_SeeShape ssf = (tf_SeeShape)SeeShapeISI; | |
984 | Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf); | |
985 | return r; | |
986 | } // tseei | |
987 | ||
988 | //----------------------------------------------------------------------- | |
989 | // tki | |
990 | //----------------------------------------------------------------------- | |
991 | Standard_Integer tki(Draw_Interpretor& di,Standard_Integer na_in,const char** a) | |
992 | { | |
993 | if (na_in == 1) { tki_help(di); return 0; } | |
994 | ||
995 | tf_SeeShape ssf = NULL; | |
996 | if ( !strcasecmp(a[0],"tki") ) ssf = (tf_SeeShape)SeeShapeTKI; | |
997 | else if ( !strcasecmp(a[0],"tkig") ) ssf = (tf_SeeShape)SeeShapeTKIG; | |
998 | else if ( !strcasecmp(a[0],"tkis") ) ssf = (tf_SeeShape)SeeShapeTKIS; | |
999 | if (ssf == NULL) return 0; | |
1000 | ||
1001 | Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf); | |
1002 | return r; | |
1003 | } // tki | |
1004 | ||
1005 | //----------------------------------------------------------------------- | |
1006 | // 0 = tds | |
1007 | // 1 = kind of DS object to dump = [s] [so sh f w e v] [se] [su c p] | |
1008 | // 2,3 ... = [i1,i2 ...] = indices of DS object to see | |
1009 | //----------------------------------------------------------------------- | |
1010 | Standard_Integer tds(Draw_Interpretor& di,Standard_Integer na,const char** a) | |
1011 | { | |
1012 | Standard_Boolean TDSkeep,TDScompact; TDSkeep = TDScompact = Standard_False; | |
1013 | TopOpeBRepDS_GLOBALHDSinterfselector = 0; | |
1014 | ||
1015 | Standard_Integer ia ; | |
1016 | for ( ia = 0; ia < na; ia++) { | |
1017 | if (!strcasecmp(a[ia],"-ssi")) { | |
1018 | TopOpeBRepDS_GLOBALHDSinterfselector = 1; | |
1019 | suppressarg(na,a,ia); | |
1020 | continue; | |
1021 | } | |
1022 | else if (!strncmp(a[ia],"-",1)) { | |
1023 | TCollection_AsciiString as = a[ia]; | |
1024 | as.Remove(1,1); | |
1025 | for(Standard_Integer i = 1;i <= as.Length(); i++) { | |
1026 | if (as.Value(i) == 'k') TDSkeep = Standard_True; | |
1027 | else if(as.Value(i) == 'l') TDScompact = Standard_False; | |
1028 | else if(as.Value(i) == 's') TDScompact = Standard_True; | |
1029 | else if(as.Value(i) == 'h') { tds_help(di); return 0; } | |
1030 | } | |
1031 | suppressarg(na,a,ia); | |
1032 | } | |
1033 | } | |
1034 | ||
1035 | if (PHDSD == NULL) return 0; | |
1036 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS(); | |
1037 | if (HDS.IsNull()) {COUTNOHDS(di);return 0;} | |
6e6cd5d9 | 1038 | PHDSD->CurrentBDS(); |
7fd59977 | 1039 | |
1040 | TopOpeBRepDS_Dumper Dumper(HDS); | |
1041 | if ( na == 1 ) { Dumper.Dump(cout,TDSkeep,TDScompact); return 0; } | |
1042 | ||
1043 | TDSpar Tpar(a[1]); | |
1044 | Standard_Integer ids; | |
1045 | ||
1046 | if (na == 2) { | |
1047 | if (Tpar.isshap()) { | |
1048 | if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),cout); | |
1049 | else Dumper.DumpTopology(cout); | |
1050 | } | |
1051 | else if (Tpar.isgeom()) { | |
1052 | Dumper.DumpGeometry(Tpar.TK(),cout,TDSkeep,TDScompact); | |
1053 | } | |
1054 | else if (Tpar.issect()) { | |
1055 | Dumper.DumpSectionEdge(Tpar.TK(),cout); | |
1056 | } | |
1057 | else if (Tpar.isafev()) { | |
1058 | TopOpeBRepDS_Explorer x; | |
1059 | for (x.Init(HDS,TopAbs_FACE,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout); | |
1060 | for (x.Init(HDS,TopAbs_EDGE,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout); | |
1061 | for (x.Init(HDS,TopAbs_VERTEX,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout); | |
1062 | } | |
1063 | ||
1064 | else if (Tpar.isdege()) { | |
1065 | TopOpeBRepDS_Explorer x; | |
1066 | for (x.Init(HDS,TopAbs_EDGE,TDSkeep);x.More();x.Next()) { | |
1067 | if (BRep_Tool::Degenerated(x.Edge())) Dumper.DumpTopology(x.Type(),x.Index(),cout); | |
1068 | } | |
1069 | } | |
1070 | return 0; | |
1071 | } // (na == 2) | |
1072 | ||
91322f44 | 1073 | // nna > 2 : dump DS entities of type TK index Draw::Atoi(a[2])..a[narg-1]) |
7fd59977 | 1074 | for (ia = 2; ia < na; ia++) { |
1075 | ||
1076 | if ( !strcmp(a[ia],"sd") ) { // dump all shapes HasSameDomain of type TS | |
1077 | for (TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);x.More();x.Next()) { | |
1078 | Standard_Boolean isSsd = HDS->HasSameDomain(x.Current()); | |
1079 | if (isSsd ) Dumper.DumpTopology(Tpar.TK(),x.Index(),cout); | |
1080 | } | |
1081 | } | |
1082 | else { | |
91322f44 | 1083 | ids = Draw::Atoi(a[ia]); |
7fd59977 | 1084 | if ( Tpar.isshap() ) { |
1085 | if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),ids,cout); | |
1086 | else { | |
1087 | TopAbs_ShapeEnum t = HDS->Shape(ids,SFindKeep).ShapeType(); | |
1088 | TopOpeBRepDS_Kind k = TopOpeBRepDS::ShapeToKind(t); | |
1089 | Dumper.DumpTopology(k,ids,cout); | |
1090 | } | |
1091 | } | |
1092 | else if ( Tpar.isgeom() ) { | |
1093 | Dumper.DumpGeometry(Tpar.TK(),ids,cout,TDSkeep,TDScompact); | |
1094 | } | |
1095 | else if ( Tpar.issect() ) { | |
1096 | Dumper.DumpSectionEdge(TopOpeBRepDS_EDGE,ids,cout); | |
1097 | } | |
1098 | } | |
1099 | } // ia < na | |
1100 | ||
1101 | return 0; | |
1102 | } | |
1103 | ||
1104 | Standard_Integer TPPE(Draw_Interpretor& di,Standard_Integer na,const char** a) | |
1105 | { | |
1106 | if (PHDSD == NULL) return 0; | |
1107 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS(); | |
1108 | if ( HDS.IsNull() ) { COUTNOHDS(di); return 0; } | |
1109 | ||
1110 | if (na != 5) return 1; | |
1111 | Standard_Boolean ok = Standard_True; | |
1112 | ||
1113 | gp_Pnt pds; | |
1114 | TopoDS_Edge ed; | |
1115 | ||
91322f44 | 1116 | Standard_Integer ip = Draw::Atoi(a[2]); |
1117 | Standard_Integer ie = Draw::Atoi(a[4]); | |
7fd59977 | 1118 | ok = ok && (ip >= 1); ok = ok && (ie >= 1); |
1119 | if (!ok) { | |
1120 | di <<" bad data"<<"\n"; | |
1121 | return 1; | |
1122 | } | |
1123 | ||
1124 | ok = Standard_False; | |
1125 | if (!strcmp("p",a[1])){ | |
1126 | ok = Standard_True; | |
1127 | ok = ok && (ip <= HDS->NbPoints()); | |
1128 | if (ok) pds = HDS->Point(ip).Point(); | |
1129 | if (!ok) di<<" geometry "<<ip<<" is not a point"<<"\n"; | |
1130 | } | |
1131 | if (!strcmp("v",a[1])){ | |
1132 | ok = Standard_True; | |
1133 | ok = ok && (ip <= HDS->NbShapes()); | |
1134 | if (ok) { | |
1135 | TopoDS_Shape sh = HDS->Shape(ip,SFindKeep); | |
1136 | ok = ok && (sh.ShapeType() == TopAbs_VERTEX); | |
1137 | if (ok) pds =BRep_Tool::Pnt(TopoDS::Vertex(sh)); | |
1138 | } | |
1139 | if (!ok) di<<" shape "<<ip<<" is not a vertex"<<"\n"; | |
1140 | } | |
1141 | if (!strcmp("e",a[3])){ | |
1142 | ok = ok && (ie <= HDS->NbShapes()); | |
1143 | if (ok) { | |
1144 | TopoDS_Shape sh = HDS->Shape(ie,SFindKeep); | |
1145 | ok = ok && (sh.ShapeType() == TopAbs_EDGE); | |
1146 | if (ok) ed = TopoDS::Edge(sh); | |
1147 | } | |
1148 | if (!ok) di<<" shape "<<ie<<" is not an edge"<<"\n"; | |
1149 | ||
1150 | } else ok = Standard_False; | |
1151 | ||
1152 | Standard_Real dmin=0; | |
1153 | gp_Pnt pproj; | |
1154 | if (ok) { | |
1155 | Standard_Real f,l; | |
1156 | Handle(Geom_Curve) cu = BRep_Tool::Curve(ed,f,l); | |
1157 | GeomAPI_ProjectPointOnCurve ponc(pds,cu,f,l); | |
1158 | ok = ponc.NbPoints() >= 1; | |
1159 | ||
1160 | if (ok) { | |
1161 | dmin = ponc.LowerDistance(); | |
1162 | Standard_Real par = ponc.LowerDistanceParameter(); | |
1163 | BRepAdaptor_Curve bc(ed); | |
1164 | pproj = bc.Value(par); | |
1165 | } | |
1166 | } | |
1167 | ||
1168 | if (ok) { | |
1169 | TCollection_AsciiString pp("p"); | |
1170 | pp.AssignCat(ip); pp.AssignCat("e"); pp.AssignCat(ie); | |
1171 | char* ppp = (char *)pp.ToCString(); | |
1172 | DrawTrSurf::Set(ppp,pproj); | |
1173 | di<<"dist point "<<ip<<" on edge "<<ie<<" = "<<dmin<<"\n"; | |
1174 | } else di<<"projection failed"<<"\n"; | |
1175 | ||
1176 | return ok; | |
1177 | } // TPPE | |
1178 | ||
1179 | void FUN_ChkIntgInterf(Draw_Interpretor& di) //***Check Integrity Interference | |
1180 | { | |
1181 | if ( PHDSD == NULL ) return; | |
1182 | PHDSD->CurrentHDS()->ChkIntg(); | |
1183 | di<<"Check interference integrity completed"<<"\n"; | |
1184 | } | |
1185 | ||
1186 | void FUN_ChkIntgSamDomain(Draw_Interpretor& di) //***Check Integrity SameDomain | |
1187 | { | |
1188 | if ( PHDSD == NULL ) return; | |
1189 | TopOpeBRepDS_Check C(PHDSD->CurrentHDS()); | |
1190 | if(C.ChkIntgSamDom()) | |
1191 | di<<"Check SameDomain integrity completed"<<"\n"; | |
1192 | } | |
1193 | ||
1194 | void FUN_ChkIntg(Draw_Interpretor& di) //***Check Integrity | |
1195 | { | |
1196 | if ( PHDSD == NULL ) return; | |
1197 | FUN_ChkIntgInterf(di); | |
1198 | FUN_ChkIntgSamDomain(di); | |
1199 | } | |
1200 | ||
1201 | void FUN_ChkVertex(Draw_Interpretor& di) //***Check Vertex SameDomain | |
1202 | { | |
1203 | if ( PHDSD == NULL ) return; | |
1204 | TopOpeBRepDS_Check C(PHDSD->CurrentHDS()); | |
1205 | if(C.OneVertexOnPnt()) | |
1206 | di<<"Check Structure Vertex SameDomain Complete"<<"\n"; | |
1207 | } | |
1208 | ||
1209 | //--------------------------------------------------------- | |
1210 | Standard_Integer topochk(Draw_Interpretor& di,Standard_Integer na,const char** a) | |
1211 | { | |
1212 | if (strcmp(a[0],"topochk")) return 1; | |
1213 | ||
1214 | if(na < 2) { | |
1215 | ::FUN_ChkIntg(di); | |
1216 | ::FUN_ChkVertex(di); | |
1217 | } | |
1218 | else if(na > 2) return 1; | |
1219 | else if(!strcmp (a[1],"-i")) ::FUN_ChkIntg(di); | |
1220 | else if(!strncmp(a[1],"-i",2)) { | |
1221 | if (!strcmp(a[1],"-ii")) ::FUN_ChkIntgInterf(di); | |
1222 | else if(!strcmp(a[1],"-isd")) ::FUN_ChkIntgSamDomain(di); | |
1223 | } | |
1224 | else if(!strcmp (a[1],"-s")) ::FUN_ChkVertex(di); | |
1225 | else { | |
1226 | di<<"option : -i = check DS full integrity"<<"\n"; | |
1227 | di<<"option : -ii = check only interferences"<<"\n"; | |
1228 | di<<"option : -isd = check only SameDomain data"<<"\n"<<"\n"; | |
1229 | di<<"option : -s = check only SameDomain data on vertex"<<"\n"; | |
1230 | return 1; | |
1231 | } | |
1232 | return 0; | |
1233 | } | |
1234 | ||
1235 | //----------------------------------------------------------------------- | |
1236 | // SeeShapeTCX | |
1237 | //----------------------------------------------------------------------- | |
1238 | Standard_Integer SeeShapeTCX(const Standard_Integer I,const TopoDS_Shape& S) | |
1239 | { | |
1240 | if ( !PHDSD ) return 0; | |
1241 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS(); | |
1242 | if (S.IsNull()) return 0; | |
1243 | FDSCNX_Dump(HDS,I); | |
1244 | return 0; | |
1245 | } // SeeShapeTCX | |
1246 | ||
1247 | static void tcx_help(Draw_Interpretor& di) | |
1248 | { | |
1249 | di<<"tcx : function not documented"<<"\n"; | |
1250 | } | |
1251 | ||
1252 | //----------------------------------------------------------------------- | |
1253 | // tcx | |
1254 | //----------------------------------------------------------------------- | |
1255 | Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na_in,const char** a) | |
1256 | { | |
1257 | if (na_in == 1) { tcx_help(di); return 0; } | |
1258 | Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,SeeShapeTCX); | |
1259 | return r; | |
1260 | } // tcx | |
1261 | ||
1262 | #if 0 | |
1263 | //--------------------------------------------------------- | |
1264 | Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na,const char** a) | |
1265 | { | |
1266 | if (PHDSD == NULL) return 0; | |
1267 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS(); | |
1268 | if ( HDS.IsNull() ) { COUTNOHDS(di); return 0; } | |
1269 | if (na == 1) FDSCNX_Dump(HDS); | |
1270 | else if (na == 2) { | |
91322f44 | 1271 | if (ISINTEGER(a[1])) FDSCNX_Dump(HDS,Draw::Atoi(a[1])); |
7fd59977 | 1272 | else |
1273 | } | |
1274 | return 0; | |
1275 | } | |
1276 | #endif | |
1277 | ||
1278 | //----------------------------------------------------------------------- | |
1279 | Standard_Integer tdsri(Draw_Interpretor& di,Standard_Integer na_in,const char** a) | |
1280 | { | |
1281 | if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) { | |
1282 | tsee_help(a[0],di); | |
1283 | return 0; | |
1284 | } | |
1285 | Standard_Integer na = na_in; | |
1286 | if ((PHDSD == NULL) || (POCD == NULL)) return 0; | |
1287 | const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS(); | |
1288 | if (HDS.IsNull()) { COUTNOHDS(di); return 0; } | |
1289 | if (na < 5) return 1; | |
1290 | TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS(); | |
1291 | ||
1292 | Standard_Integer i1arg = 1; | |
1293 | TDSpar Tpar(a[i1arg]); | |
1294 | ||
1295 | if ( strcasecmp(a[i1arg + 2],"i") ) return 0; | |
91322f44 | 1296 | Standard_Integer ii = Draw::Atoi(a[i1arg + 3]); |
7fd59977 | 1297 | // Standard_Integer ia,is,ig; |
96a95605 | 1298 | Standard_Integer is; |
7fd59977 | 1299 | if ( Tpar.isshap() ) { |
91322f44 | 1300 | is = Draw::Atoi(a[i1arg + 1]); |
7fd59977 | 1301 | const TopoDS_Shape& s = GetShape(is,Tpar.TS()); if (s.IsNull()) return 0; |
1302 | TopOpeBRepDS_ListOfInterference& li = BDS.ChangeShapeInterferences(is); | |
1303 | Standard_Integer i=0; TopOpeBRepDS_ListIteratorOfListOfInterference it(li); | |
1304 | while (it.More()) { | |
1305 | if(++i == ii) { | |
1306 | it.Value()->Dump(cout,"\n--> remove ","\n"); | |
1307 | li.Remove(it); | |
1308 | } | |
1309 | else it.Next(); | |
1310 | } | |
1311 | } | |
7fd59977 | 1312 | return 0; |
1313 | } // tdsri | |
1314 | ||
1315 | //======================================================================= | |
1316 | //function : DSCommands | |
1317 | //purpose : | |
1318 | //======================================================================= | |
1319 | void TestTopOpe::HDSCommands(Draw_Interpretor& theCommands) | |
1320 | { | |
1321 | static Standard_Boolean done = Standard_False; | |
1322 | if (done) return; | |
1323 | done = Standard_True; | |
1324 | PHDSD = (TestTopOpe_HDSDisplayer*) new (TestTopOpe_HDSDisplayer); | |
1325 | POCD = (TestTopOpeDraw_Displayer*) new (TestTopOpeDraw_Displayer); | |
1326 | ||
1327 | const char* g = "Topological operation data structure commands"; | |
1328 | theCommands.Add("tseei","no args to get help",__FILE__,tseei,g); | |
1329 | theCommands.Add("tsee","no args to get help ",__FILE__,tsee,g); | |
1330 | theCommands.Add("tki","no args to get help ",__FILE__,tki,g); | |
1331 | theCommands.Add("tkig","no args to get help ",__FILE__,tki,g); | |
1332 | theCommands.Add("tkis","no args to get help ",__FILE__,tki,g); | |
1333 | theCommands.Add("tds","-h to get help ",__FILE__,tds,g); | |
1334 | theCommands.Add("tppe","tppe p/v <ip> e <ie>",__FILE__,TPPE); | |
1335 | theCommands.Add("topochk","check current DS (loaded by CurrentDS()",__FILE__,topochk,g); | |
1336 | theCommands.Add("tcx","dump connexity information",__FILE__,tcx,g); | |
1337 | theCommands.Add("tdsri","remove interference : tdsri type itype iinterf",__FILE__,tdsri,g); | |
1338 | } |