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>
57 TSEEpar(const TCollection_AsciiString& s) { set(s); }
58 void set(const TCollection_AsciiString& s) {
59 miskind = misshap = misgeom = missect = misdege = misafev = misedcu = Standard_False;
60 mTK = TopOpeBRepDS_UNKNOWN; mTS = TopAbs_SHAPE;
61 char* sK = (char *)s.ToCString();
62 miskind = TestTopOpeDraw_TTOT::StringToKind(s,mTK);
64 misshap = TopOpeBRepDS::IsTopology(mTK);
65 if (misshap) mTS = TopOpeBRepDS::KindToShape(mTK);
66 else misgeom = TopOpeBRepDS::IsGeometry(mTK);
68 else if ( ! strcasecmp(sK,"s") ) {
69 misshap = Standard_True; mTS = TopAbs_SHAPE;
71 else if ( ! strcasecmp(sK,"se") ) {
72 missect = Standard_True; mTK = TopOpeBRepDS_EDGE;
74 else if ( ! strcasecmp(sK,"de") ) {
75 misdege = Standard_True; mTK = TopOpeBRepDS_EDGE;
77 else if ( ! strcasecmp(sK,"fev") ) {
78 misafev = Standard_True;
80 else if ( ! strcasecmp(sK,"ec") ) {
81 misedcu = Standard_True;
84 Standard_Boolean iskind() { return miskind;}
85 Standard_Boolean isshap() { return misshap;}
86 Standard_Boolean isgeom() { return misgeom;}
87 Standard_Boolean issect() { return missect;}
88 Standard_Boolean isdege() { return misdege;}
89 Standard_Boolean isafev() { return misafev;}
90 Standard_Boolean isedcu() { return misedcu;}
91 TopOpeBRepDS_Kind TK() {return mTK;}
92 TopAbs_ShapeEnum TS() {return mTS;}
94 Standard_Boolean miskind,misshap,misgeom,missect,misdege,misafev,misedcu;
95 TopOpeBRepDS_Kind mTK; TopAbs_ShapeEnum mTS;
98 class TDSpar : public TSEEpar {
100 TDSpar(const TCollection_AsciiString& s) : TSEEpar(s) {}
103 #define ISINTEGER(MMstr) ((strspn((MMstr),"0123456789") == strlen((MMstr))))
105 TestTopOpe_HDSDisplayer* PHDSD = NULL;
106 static TestTopOpeDraw_Displayer* POCD = NULL;
107 //Standard_IMPORT extern Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector;
108 Standard_IMPORT Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector;
110 static Standard_Boolean SFindKeep = Standard_False;
111 static Standard_Boolean GFindKeep = Standard_False;
112 static Standard_Boolean PrintDistancePP = Standard_False;
113 static Standard_Integer SelectRankShape = 0;
114 static Standard_Boolean DisOri = Standard_False;
115 static Standard_Boolean TolFlag = Standard_False;
116 static Standard_Real OldParFlag = -1.0;
117 static Standard_Real ParFlag = -1.0;
121 Standard_Boolean myEOK;
122 TestTopOpe_HDSDisplayer* myEPHDSD;
123 Handle(TopOpeBRepDS_HDataStructure) myEHDS; TopOpeBRepDS_DataStructure *myEPDS;
124 TopOpeBRepDS_Kind myETK;TopAbs_ShapeEnum myETS;Standard_Integer myEindex;
125 Standard_Boolean myEiskind,myEisshape,myEisgeome,myEissect;
126 TCollection_AsciiString myEnamedbrep,myEnamedisp; Draw_ColorKind myEnamecolor;
130 // tsee_entity::tsee_entity() {
131 myEOK = Standard_False;
132 if (PHDSD == NULL) return; myEPHDSD = PHDSD;
133 myEHDS = myEPHDSD->CurrentHDS(); myEPDS = (TopOpeBRepDS_DataStructure*)&myEHDS->ChangeDS();
134 myETK = TopOpeBRepDS_UNKNOWN;myETS = TopAbs_SHAPE; myEindex = 0;
135 myEiskind = myEisshape = myEisgeome = myEissect = Standard_False;
136 myEnamedbrep = ""; myEnamedisp = ""; myEnamecolor = Draw_blanc;
137 myEOK = Standard_True;
140 Standard_Boolean IsP() const { return (myETK == TopOpeBRepDS_POINT); }
141 Standard_Boolean IsV() const { return (myETK == TopOpeBRepDS_VERTEX); }
142 Standard_Boolean Is0() const { return IsP() || IsV(); }
143 Standard_Integer Set(Standard_Integer na,const char** a,Standard_Integer iargK,Standard_Integer iargI);
145 Standard_EXPORT virtual ~tsee_entity() {Delete() ;} ;
146 void virtual Dump() const;
147 void virtual See() = 0;
150 void tsee_entity::Delete()
153 Standard_Integer tsee_entity::Set(Standard_Integer na,const char** a,Standard_Integer iargK,Standard_Integer iargI) {
154 myEOK = Standard_False;
155 if (iargK>=na) return 1; if (iargI>=na) return 1;
156 TCollection_AsciiString ascK = a[iargK]; myEindex = Draw::Atoi(a[iargI]);
157 myEiskind = TestTopOpeDraw_TTOT::StringToKind(ascK,myETK);
158 if (!myEiskind) return 1; if (myETK == TopOpeBRepDS_UNKNOWN) return 1;
160 myEisshape = TopOpeBRepDS::IsTopology(myETK);
162 if ((myEindex < 1) || (myEindex > myEPDS->NbShapes())) return 0;
163 myETS = TopOpeBRepDS::KindToShape(myETK);
164 const TopoDS_Shape& S = myEPDS->Shape(myEindex);
165 if (myETS != S.ShapeType()) return 0;
166 myEPHDSD->ShapeName(myEindex,S,myEnamedbrep);
167 myEPHDSD->ShapeDisplayName(myEindex,S,myEnamedisp);
170 myEisgeome = TopOpeBRepDS::IsGeometry(myETK);
173 TopOpeBRepDS_PointExplorer pex(myEHDS->DS());
174 if (!pex.IsPoint(myEindex)) return 1;
176 TestTopOpeDraw_TTOT::GeometryName(myEindex,myETK,myEnamedbrep);
177 myEPHDSD->GeometryDisplayName(myEindex,myETK,myEnamedisp);
180 myEnamecolor = TestTopOpeDraw_TTOT::GeometryColor(myETK);
181 myEOK = Standard_True;
185 void tsee_entity::Dump() const {
186 TopOpeBRepDS_Dumper Dumper(myEHDS);
187 if (myEisgeome) Dumper.DumpGeometry(myETK,myEindex,cout);
188 if (myEisshape) Dumper.DumpTopology(myETK,myEindex,cout);
191 class tsee_entity0 : public tsee_entity {
199 gp_Pnt tsee_entity0::Pnt() const
201 if (!Is0()) Standard_Failure::Raise("not 0d");
203 if (IsP()) P = myEPDS->Point(myEindex).Point();
204 else if (IsV()) P = BRep_Tool::Pnt(TopoDS::Vertex(myEPDS->Shape(myEindex)));
209 (const TCollection_AsciiString& namedbrep,const TCollection_AsciiString& namedisp,const Draw_Color& namecolor,const TopOpeBRepDS_Point& P)
211 Handle(TestTopOpeDraw_DrawableP3D) D;
213 D = new TestTopOpeDraw_DrawableP3D(P.Point(),Draw_CircleZoom,namecolor,
214 namedisp.ToCString(),namecolor,
217 D = new TestTopOpeDraw_DrawableP3D(P.Point(),Draw_Square,namecolor,
218 namedisp.ToCString(),namecolor);
220 char *pname = (char *)namedbrep.ToCString();
221 Draw::Set(pname,Handle(Draw_Marker3D)::DownCast(D));
224 void tsee_entity0::See()
226 if (IsP()) ::SetPoint(myEnamedbrep,myEnamedisp,myEnamecolor,myEPDS->Point(myEindex));
227 if (IsV()) POCD->DisplayShape(myEnamedbrep,myEnamedisp,myEPDS->Shape(myEindex));
230 //-----------------------------------------------
232 //-----------------------------------------------
233 (const TCollection_AsciiString& namedbrep,
234 const TCollection_AsciiString& namedisp,
235 const Draw_Color& namecolor,
236 const TopOpeBRepDS_Curve& DSC,
237 const Standard_Integer iC)
239 if ( !PHDSD ) return;
240 const Handle(Geom_Curve) GC = DSC.Curve();
241 if ( GC.IsNull() ) { cout<<"Curve() nulle"<<endl; return; }
243 Standard_Real f = GC->FirstParameter();
244 Standard_Real l = GC->LastParameter();
246 GeomAdaptor_Curve GAC(GC);
247 GeomAbs_CurveType GACt = GAC.GetType();
248 if ( GACt == GeomAbs_Line ) {
249 Standard_Real fline = RealLast(),lline = RealFirst();
250 Standard_Integer imother = DSC.Mother(),igood;
251 if(imother) igood = imother;
253 TopOpeBRepDS_PointIterator it = PHDSD->CurrentHDS()->CurvePoints(igood);
254 for(; it.More(); it.Next()) {
255 Standard_Real p = it.Parameter();
256 fline = Min(fline,p); lline = Max(fline,p);
262 Handle(Geom_TrimmedCurve) GTC = new Geom_TrimmedCurve(GC,f,l);
263 Handle(TestTopOpeDraw_DrawableC3D) D;
264 D = new TestTopOpeDraw_DrawableC3D(GTC,namecolor,namedisp.ToCString(),namecolor);
265 char *pname = (char *)namedbrep.ToCString();
266 Draw::Set(pname,Handle(DrawTrSurf_Curve)::DownCast(D));
269 static TopoDS_Shape bidbid;
270 static const TopoDS_Shape& GetShape(const Standard_Integer IS,const TopAbs_ShapeEnum TS)
272 Standard_Boolean TypeControl = Standard_True;
273 if ( !PHDSD ) return bidbid;
275 static TopoDS_Shape ShapeNull;
276 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
278 // check on shape index and on shape kind if kind differs from TopAbs_SHAPE
279 Standard_Integer ns = BDS.NbShapes();
280 if ( IS < 1 || IS > ns) {
281 TopAbs::Print(TS,cout);cout<<" "<<IS<<" does not exist in DS"<<endl;
284 else if ( !PHDSD->ShapeKind(IS,TS) ) {
287 cout<<" is not a ";TopAbs::Print(TS,cout);
288 cout<<" but a "; TopAbs::Print(BDS.Shape(IS,SFindKeep).ShapeType(),cout);
294 const TopoDS_Shape& S = BDS.Shape(IS,SFindKeep);
298 static const TopoDS_Shape& GetShape(const Standard_Integer IS)
300 if ( !PHDSD ) return bidbid;
301 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
302 const TopoDS_Shape& S = BDS.Shape(IS);
306 //-----------------------------------------------------------------------
308 //-----------------------------------------------------------------------
309 static Standard_Integer SeeSectionEdge(const Standard_Integer ISE)
311 if ( !PHDSD || !POCD ) return 0;
313 Standard_Integer nse = PHDSD->CurrentBDS().NbSectionEdges();
314 if ( ISE < 1 || ISE > nse ) return 0;
315 const TopoDS_Shape& SE = PHDSD->CurrentBDS().SectionEdge(ISE);
316 if (SE.IsNull()) return 0;
318 TCollection_AsciiString namedbrep; PHDSD->SectionEdgeName(ISE,SE,namedbrep);
319 TCollection_AsciiString namedisp; PHDSD->SectionEdgeDisplayName(ISE,SE,namedisp);
320 POCD->DisplayGeometry(Standard_True);
321 POCD->DisplayShape(namedbrep,namedisp,SE);
325 //-----------------------------------------------------------------------
327 //-----------------------------------------------------------------------
328 Standard_Integer SeeShapeIS(const Standard_Integer I,const TopoDS_Shape& S)
330 if ( !PHDSD || !POCD) return 0;
332 if (S.IsNull()) return 0;
333 TCollection_AsciiString namedbrep; PHDSD->ShapeName(I,S,namedbrep);
334 TCollection_AsciiString namedisp = namedbrep;
335 // NameDisplay = *name/name* if S subshape of shape1/shape2
336 TCollection_AsciiString ast = "*";
337 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
338 // if the Shape was removed from the DS, "*" is replaced by "~"
341 Standard_Boolean of1 = PHDSD->SubShape(S,1);if(of1) namedisp = ast+namedisp;
342 Standard_Boolean of2 = PHDSD->SubShape(S,2);if(of2) namedisp = namedisp+ast;
343 if (SelectRankShape == 1 && !of1) return 0;
344 if (SelectRankShape == 2 && !of2) return 0;
346 if (S.ShapeType()==TopAbs_EDGE) POCD->DisplayGeometry(Standard_True);
347 else POCD->DisplayGeometry(DisOri);
348 if((S.ShapeType()==TopAbs_VERTEX) && TolFlag) {
349 const TopoDS_Vertex& V = TopoDS::Vertex(S);
350 Standard_Real Tol = BRep_Tool::Tolerance(V);
353 POCD->DisplayShape(namedbrep,namedisp,S);
359 //-----------------------------------------------------------------------
361 //-----------------------------------------------------------------------
362 static Standard_Integer SeeShape(TCollection_AsciiString namedbrep)
364 if ( !PHDSD || !POCD ) return 0;
366 const char* pname = (const char *)namedbrep.ToCString();
367 TopoDS_Shape S = DBRep::Get(pname);
368 if ( S.IsNull() ) return 0;
369 TCollection_AsciiString namedisp;
370 PHDSD->ShapeDisplayName(namedbrep,S,namedisp);
371 POCD->DisplayShape(namedbrep,namedisp,S);
375 //-----------------------------------------------------------------------
377 //-----------------------------------------------------------------------
378 static Standard_Integer SeePoint(const Standard_Integer I)
380 if ( !PHDSD ) return 0;
382 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
383 if (I < 1 || I > BDS.NbPoints()) return 0;
385 TopOpeBRepDS_PointExplorer pex(BDS);
386 Standard_Boolean isp = pex.IsPoint(I);
389 const TopOpeBRepDS_Point& P = BDS.Point(I);
390 TopOpeBRepDS_Kind K = TopOpeBRepDS_POINT;
391 TCollection_AsciiString namedbrep; TestTopOpeDraw_TTOT::GeometryName(I,K,namedbrep);
392 TCollection_AsciiString namedisp; PHDSD->GeometryDisplayName(I,K,namedisp);
393 Draw_ColorKind namecolor = TestTopOpeDraw_TTOT::GeometryColor(K);
394 SetPoint(namedbrep,namedisp,namecolor,P);
398 //-----------------------------------------------------------------------
400 //-----------------------------------------------------------------------
401 static Standard_Integer SeeCurve(const Standard_Integer I)
403 if ( !PHDSD ) return 0;
405 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
406 if (I < 1 || I > BDS.NbCurves()) return 0;
408 TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep);
409 Standard_Boolean isc = cex.IsCurve(I);
412 const TopOpeBRepDS_Curve& C = BDS.Curve(I);
413 TopOpeBRepDS_Kind K = TopOpeBRepDS_CURVE;
414 TCollection_AsciiString namedbrep; TestTopOpeDraw_TTOT::GeometryName(I,K,namedbrep);
415 TCollection_AsciiString namedisp; PHDSD->GeometryDisplayName(I,K,namedisp);
416 Draw_ColorKind namecolor = TestTopOpeDraw_TTOT::GeometryColor(K);
417 SetCurve(namedbrep,namedisp,namecolor,C,I);
422 //-----------------------------------------------------------------------
424 //-----------------------------------------------------------------------
425 Standard_Integer SeeSurface(const Standard_Integer I) // NYI
427 if ( !PHDSD ) return 0;
429 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
430 if (I < 1 || I > BDS.NbSurfaces()) return 0;
434 //-----------------------------------------------------------------------
436 //-----------------------------------------------------------------------
437 static Standard_Integer SeeEdgeCurve(const Standard_Integer IE,const TopoDS_Shape& SE)
439 if ( !POCD ) return 0;
441 if (SE.IsNull()) return 0;
442 const TopoDS_Edge& E = TopoDS::Edge(SE);
443 TopLoc_Location L;Standard_Real f,l;Handle(Geom_Curve) GC=BRep_Tool::Curve(E,L,f,l);
444 TCollection_AsciiString namedbrep="E";TestTopOpeDraw_TTOT::CatCurveName(IE,namedbrep);
445 TCollection_AsciiString namedisp="E";TestTopOpeDraw_TTOT::CatCurveDisplayName(IE,GC,namedisp);
446 POCD->DisplayGeometry(Standard_True);
447 POCD->DisplayShape(namedbrep,namedisp,SE);
451 //-----------------------------------------------------------------------
453 //-----------------------------------------------------------------------
454 static Standard_Integer SeeGeometry(const Standard_Integer IG,const TopOpeBRepDS_Kind TK)
456 if (TK == TopOpeBRepDS_POINT) return SeePoint(IG);
457 else if (TK == TopOpeBRepDS_CURVE) return SeeCurve(IG);
458 else if (TK == TopOpeBRepDS_SURFACE) return SeeSurface(IG);
462 //-----------------------------------------------------------------------
464 //-----------------------------------------------------------------------
465 static Standard_Integer SeeGeometry(const TopOpeBRepDS_Kind TK)
467 if ( !PHDSD ) return 0;
469 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
471 if (TK == TopOpeBRepDS_POINT) {
472 TopOpeBRepDS_PointExplorer pex(BDS,GFindKeep);
473 for (; pex.More(); pex.Next()) {
474 Standard_Integer ig = pex.Index();
478 else if (TK == TopOpeBRepDS_CURVE) {
479 TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep);
480 for (; cex.More(); cex.Next()) {
481 Standard_Integer ig = cex.Index();
485 else if (TK == TopOpeBRepDS_SURFACE) { //NYI
490 //-----------------------------------------------------------------------
492 //-----------------------------------------------------------------------
493 Standard_Integer TOPOPE_SeeShape(char* name)
495 TCollection_AsciiString asc = name;
496 Standard_Integer res = SeeShape(asc);
500 //-----------------------------------------------------------------------
501 // suppressarg : remove a[d],modify na--
502 //-----------------------------------------------------------------------
503 void suppressarg(Standard_Integer& na,const char** a,const Standard_Integer d)
505 for(Standard_Integer i=d;i<na;i++) {
512 //-----------------------------------------------------------------------
513 // suppressargs : remove a[*] from <f> to <l>,modify na = na - (l - f)
514 //-----------------------------------------------------------------------
515 Standard_EXPORT void suppressargs(Standard_Integer& na,const char** a,const Standard_Integer f,const Standard_Integer l)
520 for(Standard_Integer i=0;i<na-l;i++) {
527 //-----------------------------------------------------------------------
529 //-----------------------------------------------------------------------
530 static void tsee_flags(Standard_Integer& na,const char** a) {
531 GFindKeep = Standard_False;
532 PrintDistancePP = Standard_False;
535 for (Standard_Integer ia = 1; ia < na; ia++) {
536 if (!strcasecmp(a[ia],"-k")) {
537 suppressarg(na,a,ia);
538 GFindKeep = Standard_True;
540 else if (!strcasecmp(a[ia],"-d")) {
541 // tsee -d p 4 7 : display p_4,p_7 + tds p 4 7 + calculate distance (p_4,p_7)
542 suppressarg(na,a,ia);
543 PrintDistancePP = Standard_True;
545 else if (!strcasecmp(a[ia],"-1")) {
546 // tsee -1 s 4 : display s_4 <=> s_4 is subshape of the 1st argument
547 suppressarg(na,a,ia);
550 else if (!strcasecmp(a[ia],"-2")) {
551 // tsee -2 s 4 : display s_4 <=> s_4 is subshape of the 2nd argument
552 suppressarg(na,a,ia);
555 else if (!strcasecmp(a[ia],"-p") && (ia < na-1)) {
556 suppressargs(na,a,ia,ia+1);
557 Standard_Real t = Draw::Atof(a[ia+1]);
558 if (t >= 0. && t <= 1.) {
559 OldParFlag = ParFlag; ParFlag = t;
565 void OthersCommands_help(const char* CommandName,const char* syntaxe = "");
566 //-----------------------------------------------------------------------
568 //-----------------------------------------------------------------------
569 static void tsee_help(const char* CommandName, Draw_Interpretor& di)
572 di<<"tsee : Draw entities of data structure (DS) loaded by TestTopOpe::CurrentDS()."<<"\n";
573 di<<"DS entities are shapes and geometries accessed by a <type> and an <index>."<<"\n";
574 di<<"basic usage :"<<"\n";
575 di<<" tsee <type> <index1 index2 ...>"<<"\n";
576 di<<"<type> = so sh f w e v s for solid/shell/face/wire/edge/vertex/shape"<<"\n";
577 di<<" su cu p for surface/curve/point (N.B : su is NYI)"<<"\n";
578 di<<"<index> = integer"<<"\n";
579 di<<"example : 'tsee e 3' will draw the edge of index 3"<<"\n";
580 di<<" 'tsee e 3 6' will draw the edges of index 3 and 6"<<"\n";
581 di<<" 'tsee e' will draw all the edges."<<"\n";
583 di<<"Index values of DS entities may be given by the 'tds' command which prints"<<"\n";
584 di<<"the content of the DS for each shape and geometry type."<<"\n";
585 di<<"Entities are drawn with a specific color according to their type."<<"\n";
587 di<<"Naming : "<<"\n";
588 di<<"'tsee <t> <i>' creates the drawable object named <t>_<i>."<<"\n";
589 di<<"This name is displayed near the entity in one if the forms : "<<"\n";
590 di<<" *<t>_<i> meaning entity belongs to the first shape of current operation."<<"\n";
591 di<<" <t>_<i>* meaning entity belongs to the second shape of current operation."<<"\n";
593 di<<"Same Domain shapes : "<<"\n";
594 di<<"'tsee <type> sd' to display all shapes of <type> having same domain data."<<"\n";
595 di<<"example : 'tsee e sd' to display all edges sharing a 1d geometric domain"<<"\n";
596 di<<" with other edges."<<"\n";
598 di<<"Optional flags :"<<"\n";
599 OthersCommands_help(CommandName);
600 di<<"Other types :"<<"\n";
601 di<<"'tsee fev' : displays all faces,then edges,then vertices."<<"\n";
602 di<<"'tsee es <i>' displays edge described as section edge <i>."<<"\n";
603 di<<" The name of a section edge likes t_i<j>,where :"<<"\n";
604 di<<" - i is the edge index in the set of section edge,"<<"\n";
605 di<<" - j is edge index in the DS (as any edge)."<<"\n";
609 static void tseei_help(Draw_Interpretor& di)
612 di<<"tseei : Draws entities of data structure (DS) loaded by TestTopOpe::CurrentDS()."<<"\n";
613 di<<"Draws the objects appearing in interferences DS objects."<<"\n";
614 di<<"See command 'tsee' for discussion about DS objects."<<"\n";
618 static void tki_help(Draw_Interpretor& di)
621 di<<"tki,tkig,tkis : Groups interferences of DS objects"<<"\n";
622 di<<" by geometry (g),or support (s),and index."<<"\n";
623 di<<"See command 'tsee' for discussion about DS objects."<<"\n";
624 di<<"(Test of class TopOpeBRepDS_TKI)"<<"\n";
628 static void tds_help(Draw_Interpretor& di)
631 di<<"tds : dump current DS (loaded by CurrentDS())"<<"\n";
632 di<<"basic usage : tds <-arg> type <index1 index2 ...>"<<"\n";
634 di<<"Description of curve geometry (type = c) : <-arg> = -t -k -s -l"<<"\n";
635 di<<"\t-k : print only the curve with keep = Standard_True"<<"\n";
636 di<<"\t-l : (long) print all poles and knots for BSplines curves"<<"\n";
637 di<<"\t-s : (short) print only 4 poles and 4 knots for BSplines curves"<<"\n";
638 di<<"on shapes (type = s|so|sh|f|w|e|v) : <-arg> = -ssi"<<"\n";
639 di<<"\t-ssi : print only ShapeShapeInterferences"<<"\n";
641 di<<"See command 'tsee' for discussion about type and <index1 index2 ...>."<<"\n";
645 typedef Standard_Integer (*tf_SeeShape)(const Standard_Integer I,const TopoDS_Shape& S);
646 extern void OthersCommands_flags(Standard_Integer& na,const char** a,TestTopOpeDraw_Displayer& TD);
647 void COUTNOHDS(Draw_Interpretor& di) {di<<"no current HDS"<<"\n";}
648 Standard_Integer tsee_SeeShapefunc(Draw_Interpretor& di,Standard_Integer na_in,const char** a,tf_SeeShape SeeShapefunc)
650 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
655 Standard_Integer na = na_in;
656 if ((PHDSD == NULL) || (POCD == NULL)) return 0;
658 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
659 if (HDS.IsNull()) { COUTNOHDS(di); return 0; }
660 if (na < 2) return 1;
661 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
663 POCD->InitDisplayer();
664 TolFlag = Standard_False;
666 OthersCommands_flags(na,a,*POCD);
667 TolFlag = POCD->TolIs();
668 DisOri = POCD->DisplayGeometry();
670 Standard_Integer i1arg = 1;
671 TSEEpar Tpar(a[i1arg]);
673 // Standard_Integer ia,is,ig;
674 Standard_Integer ia,is;
676 if ( PrintDistancePP ) {
678 if (na == 4) { // tsee p 3 4
679 if (E1.Set(na,a,i1arg+0,i1arg+1)) return 1;
680 if (E2.Set(na,a,i1arg+0,i1arg+2)) return 1;
682 else if (na == 5) { // tsee p 3 v 4
683 if (E1.Set(na,a,i1arg+0,i1arg+1)) return 1;
684 if (E2.Set(na,a,i1arg+2,i1arg+3)) return 1;
686 if (!E1.myEOK || !E2.myEOK) return 1;
690 di<<"Distance "<<E1.myEnamedbrep.ToCString()<<" "<<E2.myEnamedbrep.ToCString()<<" : "<<E1.Pnt().Distance(E2.Pnt())<<"\n";
694 else if ( Tpar.isshap() ) {
695 // na == 2 : display all DS shapes of type TS
696 // na > 2 : display DS shapes of type TS of index Draw::Atoi(a[2]..a[narg-1])
698 TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);
699 for(;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current());
702 if ( !strcmp(a[i1arg+1],"sd") ) { // shapes HasSameDomain of type TS
703 TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);
704 for (;x.More();x.Next()) {
705 Standard_Boolean isSsd = HDS->HasSameDomain(x.Current());
706 if (isSsd ) (*SeeShapefunc)(x.Index(),x.Current());
709 else if (Tpar.isshap() && (Tpar.TS() == TopAbs_EDGE) && (na>=2) && POCD->ParIs()) {
710 // see edges [4..na[ with of the name in t in [0..1] / range
712 TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False);
713 for (;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current());
716 for (ia = i1arg+1; ia < na; ia++) {
717 is = Draw::Atoi(a[ia]);
718 (*SeeShapefunc)(is,GetShape(is,Tpar.TS()));
721 ParFlag = OldParFlag;
724 for (ia = i1arg+1; ia < na; ia++) {
725 is = Draw::Atoi(a[ia]);
726 (*SeeShapefunc)(is,GetShape(is,Tpar.TS()));
732 else if ( Tpar.isgeom() ) {
733 // na == 2 : display all DS geometries of type TK
734 // na > 2 : display DS geometries of type TK index Draw::Atoi(a[2])..a[narg-1])
735 if (na == 2 ) SeeGeometry(Tpar.TK());
736 else for (ia = i1arg+1; ia < na; ia++) SeeGeometry(Standard_Integer(Draw::Atoi(a[ia])),Tpar.TK());
739 else if ( Tpar.isafev() ) {
740 // faces then edges then vertices
741 TopOpeBRepDS_Explorer x;
742 for (x.Init(HDS,TopAbs_FACE,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
743 for (x.Init(HDS,TopAbs_EDGE,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
744 for (x.Init(HDS,TopAbs_VERTEX,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
747 else if ( Tpar.isedcu() ) {
748 // na == 2 : display curves of all DS edges
749 // na > 2 : display curve of DS edges index Draw::Atoi(a[2])..a[narg-1])
751 TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False);
752 for (;x.More();x.Next()) SeeEdgeCurve(x.Index(),x.Edge());
755 for (ia = i1arg+1; ia < na; ia++) {
756 is = Draw::Atoi(a[ia]);
757 SeeEdgeCurve(is,GetShape(is,TopAbs_EDGE));
762 else if ( Tpar.issect() ) { // na=2 all section edges,na>2 section edges (a[2]..a[na-1])
763 Standard_Integer ise,nse = BDS.NbSectionEdges();
764 if (na == 2) for (ise = 1; ise<=nse; ise++) SeeSectionEdge(ise);
765 else for (ia = i1arg+1; ia<na; ia++) SeeSectionEdge(Draw::Atoi(a[ia]));
768 else if (Tpar.isdege()) {
769 TopOpeBRepDS_Explorer x;
770 for (x.Init(HDS,TopAbs_EDGE);x.More();x.Next()) {
771 if (BRep_Tool::Degenerated(x.Edge())) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
776 } // tsee_SeeShapefunc
778 //-----------------------------------------------------------------------
780 //-----------------------------------------------------------------------
781 Standard_Integer tsee(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
783 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
787 tf_SeeShape ssf = (tf_SeeShape)SeeShapeIS;
788 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
792 //-----------------------------------------------------------------------
794 //-----------------------------------------------------------------------
795 Standard_Integer SeeAnyKI(const TopOpeBRepDS_Kind TK,const Standard_Integer I) {
796 TopAbs_ShapeEnum TS = TopAbs_COMPOUND;
797 Standard_Boolean isshape,isgeome; isshape = isgeome = Standard_False;
798 isshape = TopOpeBRepDS::IsTopology(TK);
799 if (isshape) TS = TopOpeBRepDS::KindToShape(TK);
800 else isgeome = TopOpeBRepDS::IsGeometry(TK);
801 if (isshape) SeeShapeIS(I,GetShape(I,TS));
802 else if (isgeome) SeeGeometry(I,TK);
806 //-----------------------------------------------------------------------
808 //-----------------------------------------------------------------------
809 (TColStd_ListOfInteger& LOK,TColStd_ListOfInteger& LOI,
810 const TopOpeBRepDS_Kind K,const Standard_Integer I)
812 Standard_Boolean isshape,isgeome; isshape = isgeome = Standard_False;
813 isshape = TopOpeBRepDS::IsTopology(K);
815 isgeome = TopOpeBRepDS::IsGeometry(K);
817 if (LOK.IsEmpty() && LOI.IsEmpty()) {
818 LOK.Append((Standard_Integer)K); LOI.Append(I);
822 // to sort, it is considered that :
823 // POINT == VERTEX,CURVE == EDGE,SURFACE == FACE
825 TopAbs_ShapeEnum SKtri=TopAbs_COMPOUND;
827 if (isshape) SKtri = TopOpeBRepDS::KindToShape(K);
829 if (K == TopOpeBRepDS_POINT) SKtri = TopAbs_VERTEX;
830 else if (K == TopOpeBRepDS_CURVE) SKtri = TopAbs_EDGE;
831 else if (K == TopOpeBRepDS_SURFACE) SKtri = TopAbs_FACE;
835 TColStd_ListIteratorOfListOfInteger ITLOK(LOK);
836 TColStd_ListIteratorOfListOfInteger ITLOI(LOI);
837 Standard_Boolean equa = Standard_False;
838 for (; ITLOK.More(),ITLOI.More(); ITLOK.Next(),ITLOI.Next()) {
840 Standard_Integer ifK = ITLOK.Value() ;
841 TopOpeBRepDS_Kind fK = (TopOpeBRepDS_Kind) ifK ;
842 TopAbs_ShapeEnum fSK = TopOpeBRepDS::KindToShape(fK);
843 // TopOpeBRepDS_Kind fK = (TopOpeBRepDS_Kind)ITLOK.Value(); TopAbs_ShapeEnum fSK = TopOpeBRepDS::KindToShape(fK);
844 Standard_Integer fI = ITLOI.Value();
845 if (SKtri == fSK && I == fI) {
846 equa = Standard_True;
850 LOK.InsertBefore((Standard_Integer)K,ITLOK);
851 LOI.InsertBefore(I,ITLOI);
855 if ( !ITLOK.More() && !equa) {
856 LOK.Append((Standard_Integer)K);
861 //-----------------------------------------------------------------------
863 //-----------------------------------------------------------------------
864 Standard_Integer SeeShapeISI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di)
866 if ( !PHDSD ) return 0;
867 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
868 if (S.IsNull()) return 0;
871 TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType());
872 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
873 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(S);
874 TopOpeBRepDS_ListIteratorOfListOfInterference ITLOI(LOI);
875 TColStd_ListOfInteger LOKK,LOII;
877 for (;ITLOI.More();ITLOI.Next()) {
878 const Handle(TopOpeBRepDS_Interference)& HI = ITLOI.Value();
879 const TopOpeBRepDS_Transition& T = HI->Transition();
881 TopAbs_ShapeEnum sb = T.ShapeBefore();TopOpeBRepDS_Kind sbk = TopOpeBRepDS::ShapeToKind(sb);
882 Standard_Integer sbi = T.IndexBefore();
883 TopAbs_ShapeEnum sa = T.ShapeAfter();TopOpeBRepDS_Kind sak = TopOpeBRepDS::ShapeToKind(sa);
884 Standard_Integer sai = T.IndexAfter();
885 TopOpeBRepDS_Kind gk,sk; Standard_Integer gi,si; HI->GKGSKS(gk,gi,sk,si);
887 AddShapeKI(LOKK,LOII,sbk,sbi);
888 AddShapeKI(LOKK,LOII,sak,sai);
889 AddShapeKI(LOKK,LOII,gk,gi);
890 AddShapeKI(LOKK,LOII,sk,si);
893 TColStd_ListIteratorOfListOfInteger ITLOKK,ITLOII;
895 ITLOKK.Initialize(LOKK); ITLOII.Initialize(LOII);
896 Standard_Boolean ya = ITLOKK.More();
897 TopOpeBRepDS::Print(SK,I,cout,""," : ");
898 for(; ITLOKK.More(),ITLOII.More(); ITLOKK.Next(),ITLOII.Next()) {
900 Standard_Integer ikk = ITLOKK.Value() ;
901 TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind) ikk ;
902 Standard_Integer ii = ITLOII.Value();
903 // TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind)ITLOKK.Value(); Standard_Integer ii = ITLOII.Value();
904 TopOpeBRepDS::Print(kk,ii,cout,""," ");
906 if (ya) di<<"\n"; else di<<"no shape interference"<<"\n";
908 ITLOKK.Initialize(LOKK); ITLOII.Initialize(LOII);
909 for(; ITLOKK.More(),ITLOII.More(); ITLOKK.Next(),ITLOII.Next()) {
911 Standard_Integer ikk =ITLOKK.Value() ;
912 TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind) ikk ;
913 Standard_Integer ii = ITLOII.Value();
914 // TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind)ITLOKK.Value(); Standard_Integer ii = ITLOII.Value();
922 //-----------------------------------------------------------------------
924 //-----------------------------------------------------------------------
925 Standard_Integer SeeShapeTKIG(const Standard_Integer I,const TopoDS_Shape& S)
927 if ( !PHDSD ) return 0;
928 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
929 if (S.IsNull()) return 0;
932 TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType());
933 const TopOpeBRepDS_ListOfInterference& LOI = HDS->DS().ShapeInterferences(S);
934 TopOpeBRepDS_TKI tki;
935 TCollection_AsciiString s1,s2;
938 tki.FillOnGeometry(LOI);
939 s1=TopOpeBRepDS::SPrint(SK,I,""," by G : \n");
940 tki.Init();if (tki.More()) s2="\n";else s2="";
941 tki.DumpTKIIterator(s1,s2);
946 //-----------------------------------------------------------------------
948 //-----------------------------------------------------------------------
949 Standard_Integer SeeShapeTKIS(const Standard_Integer I,const TopoDS_Shape& S)
951 if ( !PHDSD ) return 0;
952 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
953 if (S.IsNull()) return 0;
956 TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType());
957 const TopOpeBRepDS_ListOfInterference& LOI = HDS->DS().ShapeInterferences(S);
958 TopOpeBRepDS_TKI tki;
959 TCollection_AsciiString s1,s2;
962 tki.FillOnSupport(LOI);
963 s1=TopOpeBRepDS::SPrint(SK,I,""," by S : \n");
964 tki.Init();if (tki.More()) s2="\n";else s2="";
965 tki.DumpTKIIterator(s1,s2);
970 //-----------------------------------------------------------------------
972 //-----------------------------------------------------------------------
973 Standard_Integer SeeShapeTKI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di)
981 //-----------------------------------------------------------------------
983 //-----------------------------------------------------------------------
984 Standard_Integer tseei(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
986 if (na_in == 1) { tseei_help(di); return 0; }
987 tf_SeeShape ssf = (tf_SeeShape)SeeShapeISI;
988 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
992 //-----------------------------------------------------------------------
994 //-----------------------------------------------------------------------
995 Standard_Integer tki(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
997 if (na_in == 1) { tki_help(di); return 0; }
999 tf_SeeShape ssf = NULL;
1000 if ( !strcasecmp(a[0],"tki") ) ssf = (tf_SeeShape)SeeShapeTKI;
1001 else if ( !strcasecmp(a[0],"tkig") ) ssf = (tf_SeeShape)SeeShapeTKIG;
1002 else if ( !strcasecmp(a[0],"tkis") ) ssf = (tf_SeeShape)SeeShapeTKIS;
1003 if (ssf == NULL) return 0;
1005 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
1009 //-----------------------------------------------------------------------
1011 // 1 = kind of DS object to dump = [s] [so sh f w e v] [se] [su c p]
1012 // 2,3 ... = [i1,i2 ...] = indices of DS object to see
1013 //-----------------------------------------------------------------------
1014 Standard_Integer tds(Draw_Interpretor& di,Standard_Integer na,const char** a)
1016 Standard_Boolean TDSkeep,TDScompact; TDSkeep = TDScompact = Standard_False;
1017 TopOpeBRepDS_GLOBALHDSinterfselector = 0;
1019 Standard_Integer ia ;
1020 for ( ia = 0; ia < na; ia++) {
1021 if (!strcasecmp(a[ia],"-ssi")) {
1022 TopOpeBRepDS_GLOBALHDSinterfselector = 1;
1023 suppressarg(na,a,ia);
1026 else if (!strncmp(a[ia],"-",1)) {
1027 TCollection_AsciiString as = a[ia];
1029 for(Standard_Integer i = 1;i <= as.Length(); i++) {
1030 if (as.Value(i) == 'k') TDSkeep = Standard_True;
1031 else if(as.Value(i) == 'l') TDScompact = Standard_False;
1032 else if(as.Value(i) == 's') TDScompact = Standard_True;
1033 else if(as.Value(i) == 'h') { tds_help(di); return 0; }
1035 suppressarg(na,a,ia);
1039 if (PHDSD == NULL) return 0;
1040 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1041 if (HDS.IsNull()) {COUTNOHDS(di);return 0;}
1042 PHDSD->CurrentBDS();
1044 TopOpeBRepDS_Dumper Dumper(HDS);
1045 if ( na == 1 ) { Dumper.Dump(cout,TDSkeep,TDScompact); return 0; }
1048 Standard_Integer ids;
1051 if (Tpar.isshap()) {
1052 if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),cout);
1053 else Dumper.DumpTopology(cout);
1055 else if (Tpar.isgeom()) {
1056 Dumper.DumpGeometry(Tpar.TK(),cout,TDSkeep,TDScompact);
1058 else if (Tpar.issect()) {
1059 Dumper.DumpSectionEdge(Tpar.TK(),cout);
1061 else if (Tpar.isafev()) {
1062 TopOpeBRepDS_Explorer x;
1063 for (x.Init(HDS,TopAbs_FACE,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1064 for (x.Init(HDS,TopAbs_EDGE,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1065 for (x.Init(HDS,TopAbs_VERTEX,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1068 else if (Tpar.isdege()) {
1069 TopOpeBRepDS_Explorer x;
1070 for (x.Init(HDS,TopAbs_EDGE,TDSkeep);x.More();x.Next()) {
1071 if (BRep_Tool::Degenerated(x.Edge())) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1077 // nna > 2 : dump DS entities of type TK index Draw::Atoi(a[2])..a[narg-1])
1078 for (ia = 2; ia < na; ia++) {
1080 if ( !strcmp(a[ia],"sd") ) { // dump all shapes HasSameDomain of type TS
1081 for (TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);x.More();x.Next()) {
1082 Standard_Boolean isSsd = HDS->HasSameDomain(x.Current());
1083 if (isSsd ) Dumper.DumpTopology(Tpar.TK(),x.Index(),cout);
1087 ids = Draw::Atoi(a[ia]);
1088 if ( Tpar.isshap() ) {
1089 if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),ids,cout);
1091 TopAbs_ShapeEnum t = HDS->Shape(ids,SFindKeep).ShapeType();
1092 TopOpeBRepDS_Kind k = TopOpeBRepDS::ShapeToKind(t);
1093 Dumper.DumpTopology(k,ids,cout);
1096 else if ( Tpar.isgeom() ) {
1097 Dumper.DumpGeometry(Tpar.TK(),ids,cout,TDSkeep,TDScompact);
1099 else if ( Tpar.issect() ) {
1100 Dumper.DumpSectionEdge(TopOpeBRepDS_EDGE,ids,cout);
1108 Standard_Integer TPPE(Draw_Interpretor& di,Standard_Integer na,const char** a)
1110 if (PHDSD == NULL) return 0;
1111 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1112 if ( HDS.IsNull() ) { COUTNOHDS(di); return 0; }
1114 if (na != 5) return 1;
1115 Standard_Boolean ok = Standard_True;
1120 Standard_Integer ip = Draw::Atoi(a[2]);
1121 Standard_Integer ie = Draw::Atoi(a[4]);
1122 ok = ok && (ip >= 1); ok = ok && (ie >= 1);
1124 di <<" bad data"<<"\n";
1128 ok = Standard_False;
1129 if (!strcmp("p",a[1])){
1131 ok = ok && (ip <= HDS->NbPoints());
1132 if (ok) pds = HDS->Point(ip).Point();
1133 if (!ok) di<<" geometry "<<ip<<" is not a point"<<"\n";
1135 if (!strcmp("v",a[1])){
1137 ok = ok && (ip <= HDS->NbShapes());
1139 TopoDS_Shape sh = HDS->Shape(ip,SFindKeep);
1140 ok = ok && (sh.ShapeType() == TopAbs_VERTEX);
1141 if (ok) pds =BRep_Tool::Pnt(TopoDS::Vertex(sh));
1143 if (!ok) di<<" shape "<<ip<<" is not a vertex"<<"\n";
1145 if (!strcmp("e",a[3])){
1146 ok = ok && (ie <= HDS->NbShapes());
1148 TopoDS_Shape sh = HDS->Shape(ie,SFindKeep);
1149 ok = ok && (sh.ShapeType() == TopAbs_EDGE);
1150 if (ok) ed = TopoDS::Edge(sh);
1152 if (!ok) di<<" shape "<<ie<<" is not an edge"<<"\n";
1154 } else ok = Standard_False;
1156 Standard_Real dmin=0;
1160 Handle(Geom_Curve) cu = BRep_Tool::Curve(ed,f,l);
1161 GeomAPI_ProjectPointOnCurve ponc(pds,cu,f,l);
1162 ok = ponc.NbPoints() >= 1;
1165 dmin = ponc.LowerDistance();
1166 Standard_Real par = ponc.LowerDistanceParameter();
1167 BRepAdaptor_Curve bc(ed);
1168 pproj = bc.Value(par);
1173 TCollection_AsciiString pp("p");
1174 pp.AssignCat(ip); pp.AssignCat("e"); pp.AssignCat(ie);
1175 char* ppp = (char *)pp.ToCString();
1176 DrawTrSurf::Set(ppp,pproj);
1177 di<<"dist point "<<ip<<" on edge "<<ie<<" = "<<dmin<<"\n";
1178 } else di<<"projection failed"<<"\n";
1183 void FUN_ChkIntgInterf(Draw_Interpretor& di) //***Check Integrity Interference
1185 if ( PHDSD == NULL ) return;
1186 PHDSD->CurrentHDS()->ChkIntg();
1187 di<<"Check interference integrity completed"<<"\n";
1190 void FUN_ChkIntgSamDomain(Draw_Interpretor& di) //***Check Integrity SameDomain
1192 if ( PHDSD == NULL ) return;
1193 TopOpeBRepDS_Check C(PHDSD->CurrentHDS());
1194 if(C.ChkIntgSamDom())
1195 di<<"Check SameDomain integrity completed"<<"\n";
1198 void FUN_ChkIntg(Draw_Interpretor& di) //***Check Integrity
1200 if ( PHDSD == NULL ) return;
1201 FUN_ChkIntgInterf(di);
1202 FUN_ChkIntgSamDomain(di);
1205 void FUN_ChkVertex(Draw_Interpretor& di) //***Check Vertex SameDomain
1207 if ( PHDSD == NULL ) return;
1208 TopOpeBRepDS_Check C(PHDSD->CurrentHDS());
1209 if(C.OneVertexOnPnt())
1210 di<<"Check Structure Vertex SameDomain Complete"<<"\n";
1213 //---------------------------------------------------------
1214 Standard_Integer topochk(Draw_Interpretor& di,Standard_Integer na,const char** a)
1216 if (strcmp(a[0],"topochk")) return 1;
1220 ::FUN_ChkVertex(di);
1222 else if(na > 2) return 1;
1223 else if(!strcmp (a[1],"-i")) ::FUN_ChkIntg(di);
1224 else if(!strncmp(a[1],"-i",2)) {
1225 if (!strcmp(a[1],"-ii")) ::FUN_ChkIntgInterf(di);
1226 else if(!strcmp(a[1],"-isd")) ::FUN_ChkIntgSamDomain(di);
1228 else if(!strcmp (a[1],"-s")) ::FUN_ChkVertex(di);
1230 di<<"option : -i = check DS full integrity"<<"\n";
1231 di<<"option : -ii = check only interferences"<<"\n";
1232 di<<"option : -isd = check only SameDomain data"<<"\n"<<"\n";
1233 di<<"option : -s = check only SameDomain data on vertex"<<"\n";
1239 //-----------------------------------------------------------------------
1241 //-----------------------------------------------------------------------
1242 Standard_Integer SeeShapeTCX(const Standard_Integer I,const TopoDS_Shape& S)
1244 if ( !PHDSD ) return 0;
1245 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1246 if (S.IsNull()) return 0;
1251 static void tcx_help(Draw_Interpretor& di)
1253 di<<"tcx : function not documented"<<"\n";
1256 //-----------------------------------------------------------------------
1258 //-----------------------------------------------------------------------
1259 Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1261 if (na_in == 1) { tcx_help(di); return 0; }
1262 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,SeeShapeTCX);
1267 //---------------------------------------------------------
1268 Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na,const char** a)
1270 if (PHDSD == NULL) return 0;
1271 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1272 if ( HDS.IsNull() ) { COUTNOHDS(di); return 0; }
1273 if (na == 1) FDSCNX_Dump(HDS);
1275 if (ISINTEGER(a[1])) FDSCNX_Dump(HDS,Draw::Atoi(a[1]));
1282 //-----------------------------------------------------------------------
1283 Standard_Integer tdsri(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1285 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
1289 Standard_Integer na = na_in;
1290 if ((PHDSD == NULL) || (POCD == NULL)) return 0;
1291 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1292 if (HDS.IsNull()) { COUTNOHDS(di); return 0; }
1293 if (na < 5) return 1;
1294 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1296 Standard_Integer i1arg = 1;
1297 TDSpar Tpar(a[i1arg]);
1299 if ( strcasecmp(a[i1arg + 2],"i") ) return 0;
1300 Standard_Integer ii = Draw::Atoi(a[i1arg + 3]);
1301 // Standard_Integer ia,is,ig;
1302 Standard_Integer is;
1303 if ( Tpar.isshap() ) {
1304 is = Draw::Atoi(a[i1arg + 1]);
1305 const TopoDS_Shape& s = GetShape(is,Tpar.TS()); if (s.IsNull()) return 0;
1306 TopOpeBRepDS_ListOfInterference& li = BDS.ChangeShapeInterferences(is);
1307 Standard_Integer i=0; TopOpeBRepDS_ListIteratorOfListOfInterference it(li);
1310 it.Value()->Dump(cout,"\n--> remove ","\n");
1319 //=======================================================================
1320 //function : DSCommands
1322 //=======================================================================
1323 void TestTopOpe::HDSCommands(Draw_Interpretor& theCommands)
1325 static Standard_Boolean done = Standard_False;
1327 done = Standard_True;
1328 PHDSD = (TestTopOpe_HDSDisplayer*) new (TestTopOpe_HDSDisplayer);
1329 POCD = (TestTopOpeDraw_Displayer*) new (TestTopOpeDraw_Displayer);
1331 const char* g = "Topological operation data structure commands";
1332 theCommands.Add("tseei","no args to get help",__FILE__,tseei,g);
1333 theCommands.Add("tsee","no args to get help ",__FILE__,tsee,g);
1334 theCommands.Add("tki","no args to get help ",__FILE__,tki,g);
1335 theCommands.Add("tkig","no args to get help ",__FILE__,tki,g);
1336 theCommands.Add("tkis","no args to get help ",__FILE__,tki,g);
1337 theCommands.Add("tds","-h to get help ",__FILE__,tds,g);
1338 theCommands.Add("tppe","tppe p/v <ip> e <ie>",__FILE__,TPPE);
1339 theCommands.Add("topochk","check current DS (loaded by CurrentDS()",__FILE__,topochk,g);
1340 theCommands.Add("tcx","dump connexity information",__FILE__,tcx,g);
1341 theCommands.Add("tdsri","remove interference : tdsri type itype iinterf",__FILE__,tdsri,g);