1 // Created on: 1994-10-24
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
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>
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>
50 #include <Draw_Appli.hxx>
51 #include <DrawTrSurf_Curve.hxx>
52 #include <Draw_Interpretor.hxx>
53 #include <DrawTrSurf.hxx>
54 #include <Draw_Marker3D.hxx>
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);
65 misshap = TopOpeBRepDS::IsTopology(mTK);
66 if (misshap) mTS = TopOpeBRepDS::KindToShape(mTK);
67 else misgeom = TopOpeBRepDS::IsGeometry(mTK);
69 else if ( ! strcasecmp(sK,"s") ) {
70 misshap = Standard_True; mTS = TopAbs_SHAPE;
72 else if ( ! strcasecmp(sK,"se") ) {
73 missect = Standard_True; mTK = TopOpeBRepDS_EDGE;
75 else if ( ! strcasecmp(sK,"de") ) {
76 misdege = Standard_True; mTK = TopOpeBRepDS_EDGE;
78 else if ( ! strcasecmp(sK,"fev") ) {
79 misafev = Standard_True;
81 else if ( ! strcasecmp(sK,"ec") ) {
82 misedcu = Standard_True;
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;}
95 Standard_Boolean miskind,misshap,misgeom,missect,misdege,misafev,misedcu;
96 TopOpeBRepDS_Kind mTK; TopAbs_ShapeEnum mTS;
99 class TDSpar : public TSEEpar {
101 TDSpar(const TCollection_AsciiString& s) : TSEEpar(s) {}
104 #define ISINTEGER(MMstr) ((strspn((MMstr),"0123456789") == strlen((MMstr))))
106 TestTopOpe_HDSDisplayer* PHDSD = NULL;
107 static TestTopOpeDraw_Displayer* POCD = NULL;
108 //Standard_IMPORT extern Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector;
109 Standard_IMPORT Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector;
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;
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;
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;
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);
146 virtual ~tsee_entity() {}
147 void virtual Dump() const;
148 void virtual See() = 0;
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;
154 TCollection_AsciiString ascK = a[iargK]; myEindex = Draw::Atoi(a[iargI]);
155 myEiskind = TestTopOpeDraw_TTOT::StringToKind(ascK,myETK);
156 if (!myEiskind) return 1; if (myETK == TopOpeBRepDS_UNKNOWN) return 1;
158 myEisshape = TopOpeBRepDS::IsTopology(myETK);
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);
168 myEisgeome = TopOpeBRepDS::IsGeometry(myETK);
171 TopOpeBRepDS_PointExplorer pex(myEHDS->DS());
172 if (!pex.IsPoint(myEindex)) return 1;
174 TestTopOpeDraw_TTOT::GeometryName(myEindex,myETK,myEnamedbrep);
175 myEPHDSD->GeometryDisplayName(myEindex,myETK,myEnamedisp);
178 myEnamecolor = TestTopOpeDraw_TTOT::GeometryColor(myETK);
179 myEOK = Standard_True;
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);
189 class tsee_entity0 : public tsee_entity {
195 gp_Pnt tsee_entity0::Pnt() const
197 if (!Is0()) Standard_Failure::Raise("not 0d");
199 if (IsP()) P = myEPDS->Point(myEindex).Point();
200 else if (IsV()) P = BRep_Tool::Pnt(TopoDS::Vertex(myEPDS->Shape(myEindex)));
205 (const TCollection_AsciiString& namedbrep,const TCollection_AsciiString& namedisp,const Draw_Color& namecolor,const TopOpeBRepDS_Point& P)
207 Handle(TestTopOpeDraw_DrawableP3D) D;
209 D = new TestTopOpeDraw_DrawableP3D(P.Point(),Draw_CircleZoom,namecolor,
210 namedisp.ToCString(),namecolor,
213 D = new TestTopOpeDraw_DrawableP3D(P.Point(),Draw_Square,namecolor,
214 namedisp.ToCString(),namecolor);
216 char *pname = (char *)namedbrep.ToCString();
220 void tsee_entity0::See()
222 if (IsP()) ::SetPoint(myEnamedbrep,myEnamedisp,myEnamecolor,myEPDS->Point(myEindex));
223 if (IsV()) POCD->DisplayShape(myEnamedbrep,myEnamedisp,myEPDS->Shape(myEindex));
226 //-----------------------------------------------
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)
235 if ( !PHDSD ) return;
236 const Handle(Geom_Curve) GC = DSC.Curve();
237 if ( GC.IsNull() ) { cout<<"Curve() nulle"<<endl; return; }
239 Standard_Real f = GC->FirstParameter();
240 Standard_Real l = GC->LastParameter();
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;
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);
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();
265 static TopoDS_Shape bidbid;
266 static const TopoDS_Shape& GetShape(const Standard_Integer IS,const TopAbs_ShapeEnum TS)
268 Standard_Boolean TypeControl = Standard_True;
269 if ( !PHDSD ) return bidbid;
271 static TopoDS_Shape ShapeNull;
272 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
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;
280 else if ( !PHDSD->ShapeKind(IS,TS) ) {
283 cout<<" is not a ";TopAbs::Print(TS,cout);
284 cout<<" but a "; TopAbs::Print(BDS.Shape(IS,SFindKeep).ShapeType(),cout);
290 const TopoDS_Shape& S = BDS.Shape(IS,SFindKeep);
294 static const TopoDS_Shape& GetShape(const Standard_Integer IS)
296 if ( !PHDSD ) return bidbid;
297 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
298 const TopoDS_Shape& S = BDS.Shape(IS);
302 //-----------------------------------------------------------------------
304 //-----------------------------------------------------------------------
305 static Standard_Integer SeeSectionEdge(const Standard_Integer ISE)
307 if ( !PHDSD || !POCD ) return 0;
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;
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);
321 //-----------------------------------------------------------------------
323 //-----------------------------------------------------------------------
324 Standard_Integer SeeShapeIS(const Standard_Integer I,const TopoDS_Shape& S)
326 if ( !PHDSD || !POCD) return 0;
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 "~"
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;
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);
349 POCD->DisplayShape(namedbrep,namedisp,S);
355 //-----------------------------------------------------------------------
357 //-----------------------------------------------------------------------
358 static Standard_Integer SeeShape(TCollection_AsciiString namedbrep)
360 if ( !PHDSD || !POCD ) return 0;
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);
371 //-----------------------------------------------------------------------
373 //-----------------------------------------------------------------------
374 static Standard_Integer SeePoint(const Standard_Integer I)
376 if ( !PHDSD ) return 0;
378 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
379 if (I < 1 || I > BDS.NbPoints()) return 0;
381 TopOpeBRepDS_PointExplorer pex(BDS);
382 Standard_Boolean isp = pex.IsPoint(I);
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);
394 //-----------------------------------------------------------------------
396 //-----------------------------------------------------------------------
397 static Standard_Integer SeeCurve(const Standard_Integer I)
399 if ( !PHDSD ) return 0;
401 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
402 if (I < 1 || I > BDS.NbCurves()) return 0;
404 TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep);
405 Standard_Boolean isc = cex.IsCurve(I);
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);
418 //-----------------------------------------------------------------------
420 //-----------------------------------------------------------------------
421 Standard_Integer SeeSurface(const Standard_Integer I) // NYI
423 if ( !PHDSD ) return 0;
425 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
426 if (I < 1 || I > BDS.NbSurfaces()) return 0;
430 //-----------------------------------------------------------------------
432 //-----------------------------------------------------------------------
433 static Standard_Integer SeeEdgeCurve(const Standard_Integer IE,const TopoDS_Shape& SE)
435 if ( !POCD ) return 0;
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);
447 //-----------------------------------------------------------------------
449 //-----------------------------------------------------------------------
450 static Standard_Integer SeeGeometry(const Standard_Integer IG,const TopOpeBRepDS_Kind TK)
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);
458 //-----------------------------------------------------------------------
460 //-----------------------------------------------------------------------
461 static Standard_Integer SeeGeometry(const TopOpeBRepDS_Kind TK)
463 if ( !PHDSD ) return 0;
465 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
467 if (TK == TopOpeBRepDS_POINT) {
468 TopOpeBRepDS_PointExplorer pex(BDS,GFindKeep);
469 for (; pex.More(); pex.Next()) {
470 Standard_Integer ig = pex.Index();
474 else if (TK == TopOpeBRepDS_CURVE) {
475 TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep);
476 for (; cex.More(); cex.Next()) {
477 Standard_Integer ig = cex.Index();
481 else if (TK == TopOpeBRepDS_SURFACE) { //NYI
486 //-----------------------------------------------------------------------
488 //-----------------------------------------------------------------------
489 Standard_Integer TOPOPE_SeeShape(char* name)
491 TCollection_AsciiString asc = name;
492 Standard_Integer res = SeeShape(asc);
496 //-----------------------------------------------------------------------
497 // suppressarg : remove a[d],modify na--
498 //-----------------------------------------------------------------------
499 void suppressarg(Standard_Integer& na,const char** a,const Standard_Integer d)
501 for(Standard_Integer i=d;i<na;i++) {
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)
516 for(Standard_Integer i=0;i<na-l;i++) {
523 //-----------------------------------------------------------------------
525 //-----------------------------------------------------------------------
526 static void tsee_flags(Standard_Integer& na,const char** a) {
527 GFindKeep = Standard_False;
528 PrintDistancePP = Standard_False;
531 for (Standard_Integer ia = 1; ia < na; ia++) {
532 if (!strcasecmp(a[ia],"-k")) {
533 suppressarg(na,a,ia);
534 GFindKeep = Standard_True;
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;
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);
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);
551 else if (!strcasecmp(a[ia],"-p") && (ia < na-1)) {
552 suppressargs(na,a,ia,ia+1);
553 Standard_Real t = Draw::Atof(a[ia+1]);
554 if (t >= 0. && t <= 1.) {
555 OldParFlag = ParFlag; ParFlag = t;
561 void OthersCommands_help(const char* CommandName,const char* syntaxe = "");
562 //-----------------------------------------------------------------------
564 //-----------------------------------------------------------------------
565 static void tsee_help(const char* CommandName, Draw_Interpretor& di)
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";
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";
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";
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";
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";
605 static void tseei_help(Draw_Interpretor& di)
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";
614 static void tki_help(Draw_Interpretor& di)
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";
624 static void tds_help(Draw_Interpretor& di)
627 di<<"tds : dump current DS (loaded by CurrentDS())\n";
628 di<<"basic usage : tds <-arg> type <index1 index2 ...>\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";
637 di<<"See command 'tsee' for discussion about type and <index1 index2 ...>.\n";
641 typedef Standard_Integer (*tf_SeeShape)(const Standard_Integer I,const TopoDS_Shape& S);
642 extern void OthersCommands_flags(Standard_Integer& na,const char** a,TestTopOpeDraw_Displayer& TD);
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)
646 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
651 Standard_Integer na = na_in;
652 if ((PHDSD == NULL) || (POCD == NULL)) return 0;
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();
659 POCD->InitDisplayer();
660 TolFlag = Standard_False;
662 OthersCommands_flags(na,a,*POCD);
663 TolFlag = POCD->TolIs();
664 DisOri = POCD->DisplayGeometry();
666 Standard_Integer i1arg = 1;
667 TSEEpar Tpar(a[i1arg]);
669 // Standard_Integer ia,is,ig;
670 Standard_Integer ia,is;
672 if ( PrintDistancePP ) {
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;
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;
682 if (!E1.myEOK || !E2.myEOK) return 1;
686 di<<"Distance "<<E1.myEnamedbrep.ToCString()<<" "<<E2.myEnamedbrep.ToCString()<<" : "<<E1.Pnt().Distance(E2.Pnt())<<"\n";
690 else if ( Tpar.isshap() ) {
691 // na == 2 : display all DS shapes of type TS
692 // na > 2 : display DS shapes of type TS of index Draw::Atoi(a[2]..a[narg-1])
694 TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);
695 for(;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current());
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());
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
708 TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False);
709 for (;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current());
712 for (ia = i1arg+1; ia < na; ia++) {
713 is = Draw::Atoi(a[ia]);
714 (*SeeShapefunc)(is,GetShape(is,Tpar.TS()));
717 ParFlag = OldParFlag;
720 for (ia = i1arg+1; ia < na; ia++) {
721 is = Draw::Atoi(a[ia]);
722 (*SeeShapefunc)(is,GetShape(is,Tpar.TS()));
728 else if ( Tpar.isgeom() ) {
729 // na == 2 : display all DS geometries of type TK
730 // na > 2 : display DS geometries of type TK index Draw::Atoi(a[2])..a[narg-1])
731 if (na == 2 ) SeeGeometry(Tpar.TK());
732 else for (ia = i1arg+1; ia < na; ia++) SeeGeometry(Standard_Integer(Draw::Atoi(a[ia])),Tpar.TK());
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()));
743 else if ( Tpar.isedcu() ) {
744 // na == 2 : display curves of all DS edges
745 // na > 2 : display curve of DS edges index Draw::Atoi(a[2])..a[narg-1])
747 TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False);
748 for (;x.More();x.Next()) SeeEdgeCurve(x.Index(),x.Edge());
751 for (ia = i1arg+1; ia < na; ia++) {
752 is = Draw::Atoi(a[ia]);
753 SeeEdgeCurve(is,GetShape(is,TopAbs_EDGE));
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);
761 else for (ia = i1arg+1; ia<na; ia++) SeeSectionEdge(Draw::Atoi(a[ia]));
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()));
772 } // tsee_SeeShapefunc
774 //-----------------------------------------------------------------------
776 //-----------------------------------------------------------------------
777 Standard_Integer tsee(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
779 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
783 tf_SeeShape ssf = (tf_SeeShape)SeeShapeIS;
784 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
788 //-----------------------------------------------------------------------
790 //-----------------------------------------------------------------------
791 Standard_Integer SeeAnyKI(const TopOpeBRepDS_Kind TK,const Standard_Integer I) {
792 TopAbs_ShapeEnum TS = TopAbs_COMPOUND;
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);
802 //-----------------------------------------------------------------------
804 //-----------------------------------------------------------------------
805 (TColStd_ListOfInteger& LOK,TColStd_ListOfInteger& LOI,
806 const TopOpeBRepDS_Kind K,const Standard_Integer I)
808 Standard_Boolean isshape,isgeome; isshape = isgeome = Standard_False;
809 isshape = TopOpeBRepDS::IsTopology(K);
811 isgeome = TopOpeBRepDS::IsGeometry(K);
813 if (LOK.IsEmpty() && LOI.IsEmpty()) {
814 LOK.Append((Standard_Integer)K); LOI.Append(I);
818 // to sort, it is considered that :
819 // POINT == VERTEX,CURVE == EDGE,SURFACE == FACE
821 TopAbs_ShapeEnum SKtri=TopAbs_COMPOUND;
823 if (isshape) SKtri = TopOpeBRepDS::KindToShape(K);
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;
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()) {
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;
846 LOK.InsertBefore((Standard_Integer)K,ITLOK);
847 LOI.InsertBefore(I,ITLOI);
851 if ( !ITLOK.More() && !equa) {
852 LOK.Append((Standard_Integer)K);
857 //-----------------------------------------------------------------------
859 //-----------------------------------------------------------------------
860 Standard_Integer SeeShapeISI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di)
862 if ( !PHDSD ) return 0;
863 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
864 if (S.IsNull()) return 0;
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;
873 for (;ITLOI.More();ITLOI.Next()) {
874 const Handle(TopOpeBRepDS_Interference)& HI = ITLOI.Value();
875 const TopOpeBRepDS_Transition& T = HI->Transition();
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);
883 AddShapeKI(LOKK,LOII,sbk,sbi);
884 AddShapeKI(LOKK,LOII,sak,sai);
885 AddShapeKI(LOKK,LOII,gk,gi);
886 AddShapeKI(LOKK,LOII,sk,si);
889 TColStd_ListIteratorOfListOfInteger ITLOKK,ITLOII;
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()) {
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,""," ");
902 if (ya) di<<"\n"; else di<<"no shape interference\n";
904 ITLOKK.Initialize(LOKK); ITLOII.Initialize(LOII);
905 for(; ITLOKK.More(),ITLOII.More(); ITLOKK.Next(),ITLOII.Next()) {
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();
918 //-----------------------------------------------------------------------
920 //-----------------------------------------------------------------------
921 Standard_Integer SeeShapeTKIG(const Standard_Integer I,const TopoDS_Shape& S)
923 if ( !PHDSD ) return 0;
924 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
925 if (S.IsNull()) return 0;
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;
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);
942 //-----------------------------------------------------------------------
944 //-----------------------------------------------------------------------
945 Standard_Integer SeeShapeTKIS(const Standard_Integer I,const TopoDS_Shape& S)
947 if ( !PHDSD ) return 0;
948 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
949 if (S.IsNull()) return 0;
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;
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);
966 //-----------------------------------------------------------------------
968 //-----------------------------------------------------------------------
969 Standard_Integer SeeShapeTKI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di)
977 //-----------------------------------------------------------------------
979 //-----------------------------------------------------------------------
980 Standard_Integer tseei(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
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);
988 //-----------------------------------------------------------------------
990 //-----------------------------------------------------------------------
991 Standard_Integer tki(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
993 if (na_in == 1) { tki_help(di); return 0; }
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;
1001 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
1005 //-----------------------------------------------------------------------
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)
1012 Standard_Boolean TDSkeep,TDScompact; TDSkeep = TDScompact = Standard_False;
1013 TopOpeBRepDS_GLOBALHDSinterfselector = 0;
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);
1022 else if (!strncmp(a[ia],"-",1)) {
1023 TCollection_AsciiString as = a[ia];
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; }
1031 suppressarg(na,a,ia);
1035 if (PHDSD == NULL) return 0;
1036 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1037 if (HDS.IsNull()) {COUTNOHDS(di);return 0;}
1038 PHDSD->CurrentBDS();
1040 TopOpeBRepDS_Dumper Dumper(HDS);
1041 if ( na == 1 ) { Dumper.Dump(cout,TDSkeep,TDScompact); return 0; }
1044 Standard_Integer ids;
1047 if (Tpar.isshap()) {
1048 if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),cout);
1049 else Dumper.DumpTopology(cout);
1051 else if (Tpar.isgeom()) {
1052 Dumper.DumpGeometry(Tpar.TK(),cout,TDSkeep,TDScompact);
1054 else if (Tpar.issect()) {
1055 Dumper.DumpSectionEdge(Tpar.TK(),cout);
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);
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);
1073 // nna > 2 : dump DS entities of type TK index Draw::Atoi(a[2])..a[narg-1])
1074 for (ia = 2; ia < na; ia++) {
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);
1083 ids = Draw::Atoi(a[ia]);
1084 if ( Tpar.isshap() ) {
1085 if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),ids,cout);
1087 TopAbs_ShapeEnum t = HDS->Shape(ids,SFindKeep).ShapeType();
1088 TopOpeBRepDS_Kind k = TopOpeBRepDS::ShapeToKind(t);
1089 Dumper.DumpTopology(k,ids,cout);
1092 else if ( Tpar.isgeom() ) {
1093 Dumper.DumpGeometry(Tpar.TK(),ids,cout,TDSkeep,TDScompact);
1095 else if ( Tpar.issect() ) {
1096 Dumper.DumpSectionEdge(TopOpeBRepDS_EDGE,ids,cout);
1104 Standard_Integer TPPE(Draw_Interpretor& di,Standard_Integer na,const char** a)
1106 if (PHDSD == NULL) return 0;
1107 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1108 if ( HDS.IsNull() ) { COUTNOHDS(di); return 0; }
1110 if (na != 5) return 1;
1111 Standard_Boolean ok = Standard_True;
1116 Standard_Integer ip = Draw::Atoi(a[2]);
1117 Standard_Integer ie = Draw::Atoi(a[4]);
1118 ok = ok && (ip >= 1); ok = ok && (ie >= 1);
1124 ok = Standard_False;
1125 if (!strcmp("p",a[1])){
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";
1131 if (!strcmp("v",a[1])){
1133 ok = ok && (ip <= HDS->NbShapes());
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));
1139 if (!ok) di<<" shape "<<ip<<" is not a vertex\n";
1141 if (!strcmp("e",a[3])){
1142 ok = ok && (ie <= HDS->NbShapes());
1144 TopoDS_Shape sh = HDS->Shape(ie,SFindKeep);
1145 ok = ok && (sh.ShapeType() == TopAbs_EDGE);
1146 if (ok) ed = TopoDS::Edge(sh);
1148 if (!ok) di<<" shape "<<ie<<" is not an edge\n";
1150 } else ok = Standard_False;
1152 Standard_Real dmin=0;
1156 Handle(Geom_Curve) cu = BRep_Tool::Curve(ed,f,l);
1157 GeomAPI_ProjectPointOnCurve ponc(pds,cu,f,l);
1158 ok = ponc.NbPoints() >= 1;
1161 dmin = ponc.LowerDistance();
1162 Standard_Real par = ponc.LowerDistanceParameter();
1163 BRepAdaptor_Curve bc(ed);
1164 pproj = bc.Value(par);
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";
1179 void FUN_ChkIntgInterf(Draw_Interpretor& di) //***Check Integrity Interference
1181 if ( PHDSD == NULL ) return;
1182 PHDSD->CurrentHDS()->ChkIntg();
1183 di<<"Check interference integrity completed\n";
1186 void FUN_ChkIntgSamDomain(Draw_Interpretor& di) //***Check Integrity SameDomain
1188 if ( PHDSD == NULL ) return;
1189 TopOpeBRepDS_Check C(PHDSD->CurrentHDS());
1190 if(C.ChkIntgSamDom())
1191 di<<"Check SameDomain integrity completed\n";
1194 void FUN_ChkIntg(Draw_Interpretor& di) //***Check Integrity
1196 if ( PHDSD == NULL ) return;
1197 FUN_ChkIntgInterf(di);
1198 FUN_ChkIntgSamDomain(di);
1201 void FUN_ChkVertex(Draw_Interpretor& di) //***Check Vertex SameDomain
1203 if ( PHDSD == NULL ) return;
1204 TopOpeBRepDS_Check C(PHDSD->CurrentHDS());
1205 if(C.OneVertexOnPnt())
1206 di<<"Check Structure Vertex SameDomain Complete\n";
1209 //---------------------------------------------------------
1210 Standard_Integer topochk(Draw_Interpretor& di,Standard_Integer na,const char** a)
1212 if (strcmp(a[0],"topochk")) return 1;
1216 ::FUN_ChkVertex(di);
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);
1224 else if(!strcmp (a[1],"-s")) ::FUN_ChkVertex(di);
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";
1235 //-----------------------------------------------------------------------
1237 //-----------------------------------------------------------------------
1238 Standard_Integer SeeShapeTCX(const Standard_Integer I,const TopoDS_Shape& S)
1240 if ( !PHDSD ) return 0;
1241 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1242 if (S.IsNull()) return 0;
1247 static void tcx_help(Draw_Interpretor& di)
1249 di<<"tcx : function not documented\n";
1252 //-----------------------------------------------------------------------
1254 //-----------------------------------------------------------------------
1255 Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1257 if (na_in == 1) { tcx_help(di); return 0; }
1258 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,SeeShapeTCX);
1263 //---------------------------------------------------------
1264 Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na,const char** a)
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);
1271 if (ISINTEGER(a[1])) FDSCNX_Dump(HDS,Draw::Atoi(a[1]));
1278 //-----------------------------------------------------------------------
1279 Standard_Integer tdsri(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1281 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
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();
1292 Standard_Integer i1arg = 1;
1293 TDSpar Tpar(a[i1arg]);
1295 if ( strcasecmp(a[i1arg + 2],"i") ) return 0;
1296 Standard_Integer ii = Draw::Atoi(a[i1arg + 3]);
1297 // Standard_Integer ia,is,ig;
1298 Standard_Integer is;
1299 if ( Tpar.isshap() ) {
1300 is = Draw::Atoi(a[i1arg + 1]);
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);
1306 it.Value()->Dump(cout,"\n--> remove ","\n");
1315 //=======================================================================
1316 //function : DSCommands
1318 //=======================================================================
1319 void TestTopOpe::HDSCommands(Draw_Interpretor& theCommands)
1321 static Standard_Boolean done = Standard_False;
1323 done = Standard_True;
1324 PHDSD = (TestTopOpe_HDSDisplayer*) new (TestTopOpe_HDSDisplayer);
1325 POCD = (TestTopOpeDraw_Displayer*) new (TestTopOpeDraw_Displayer);
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);