1 // Created on: 1994-10-24
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
25 #include <TestTopOpe.hxx>
26 #include <TestTopOpe_HDSDisplayer.hxx>
27 #include <TestTopOpeDraw_DrawableSHA.hxx>
28 #include <TestTopOpeDraw_DrawableP3D.hxx>
29 #include <TestTopOpeDraw_DrawableC3D.hxx>
30 #include <TestTopOpeDraw_TTOT.hxx>
31 #include <TestTopOpeDraw_Displayer.hxx>
32 #include <TopOpeBRepDS_connex.hxx>
33 #include <TopOpeBRepDS_Point.hxx>
34 #include <TopOpeBRepDS_Curve.hxx>
35 #include <TopOpeBRepDS_PointIterator.hxx>
36 #include <TopOpeBRepDS_PointExplorer.hxx>
37 #include <TopOpeBRepDS_CurveExplorer.hxx>
38 #include <TopOpeBRepDS_Explorer.hxx>
39 #include <TopOpeBRepDS_TKI.hxx>
40 #include <TopOpeBRepDS_Check.hxx>
41 #include <TopOpeBRepDS_Dumper.hxx>
42 #include <TopOpeBRepDS.hxx>
43 #include <Geom_TrimmedCurve.hxx>
44 #include <BRep_Tool.hxx>
46 #include <TopLoc_Location.hxx>
47 #include <Geom_Curve.hxx>
48 #include <GeomAdaptor_Curve.hxx>
49 #include <GeomAbs_CurveType.hxx>
50 #include <GeomAdaptor_Surface.hxx>
51 #include <GeomAbs_SurfaceType.hxx>
52 #include <GeomAPI_ProjectPointOnCurve.hxx>
53 #include <BRepAdaptor_Curve.hxx>
54 #include <TColStd_ListOfInteger.hxx>
55 #include <TColStd_ListIteratorOfListOfInteger.hxx>
56 #include <TopOpeBRepDS_define.hxx>
58 #include <Draw_Appli.hxx>
59 #include <DrawTrSurf_Curve.hxx>
60 #include <Draw_Interpretor.hxx>
61 #include <DrawTrSurf.hxx>
69 TSEEpar(const TCollection_AsciiString& s) { set(s); }
70 void set(const TCollection_AsciiString& s) {
71 miskind = misshap = misgeom = missect = misdege = misafev = misedcu = Standard_False;
72 mTK = TopOpeBRepDS_UNKNOWN; mTS = TopAbs_SHAPE;
73 char* sK = (char *)s.ToCString();
74 miskind = TestTopOpeDraw_TTOT::StringToKind(s,mTK);
76 misshap = TopOpeBRepDS::IsTopology(mTK);
77 if (misshap) mTS = TopOpeBRepDS::KindToShape(mTK);
78 else misgeom = TopOpeBRepDS::IsGeometry(mTK);
80 else if ( ! strcasecmp(sK,"s") ) {
81 misshap = Standard_True; mTS = TopAbs_SHAPE;
83 else if ( ! strcasecmp(sK,"se") ) {
84 missect = Standard_True; mTK = TopOpeBRepDS_EDGE;
86 else if ( ! strcasecmp(sK,"de") ) {
87 misdege = Standard_True; mTK = TopOpeBRepDS_EDGE;
89 else if ( ! strcasecmp(sK,"fev") ) {
90 misafev = Standard_True;
92 else if ( ! strcasecmp(sK,"ec") ) {
93 misedcu = Standard_True;
96 Standard_Boolean iskind() { return miskind;}
97 Standard_Boolean isshap() { return misshap;}
98 Standard_Boolean isgeom() { return misgeom;}
99 Standard_Boolean issect() { return missect;}
100 Standard_Boolean isdege() { return misdege;}
101 Standard_Boolean isafev() { return misafev;}
102 Standard_Boolean isedcu() { return misedcu;}
103 TopOpeBRepDS_Kind TK() {return mTK;}
104 TopAbs_ShapeEnum TS() {return mTS;}
106 Standard_Boolean miskind,misshap,misgeom,missect,misdege,misafev,misedcu;
107 TopOpeBRepDS_Kind mTK; TopAbs_ShapeEnum mTS;
110 class TDSpar : public TSEEpar {
112 TDSpar(const TCollection_AsciiString& s) : TSEEpar(s) {}
115 #define ISINTEGER(MMstr) ((strspn((MMstr),"0123456789") == strlen((MMstr))))
117 Standard_EXPORT TestTopOpe_HDSDisplayer* PHDSD = NULL;
118 Standard_EXPORT TestTopOpeDraw_Displayer* POCD = NULL;
119 //Standard_IMPORT extern Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector;
120 Standard_IMPORT Standard_Integer TopOpeBRepDS_GLOBALHDSinterfselector;
122 static Standard_Boolean SFindKeep = Standard_False;
123 static Standard_Boolean GFindKeep = Standard_False;
124 static Standard_Boolean PrintDistancePP = Standard_False;
125 static Standard_Integer SelectRankShape = 0;
126 static Standard_Boolean DisOri = Standard_False;
127 static Standard_Boolean TolFlag = Standard_False;
128 static Standard_Real OldParFlag = -1.0;
129 static Standard_Real ParFlag = -1.0;
133 Standard_Boolean myEOK;
134 TestTopOpe_HDSDisplayer* myEPHDSD;
135 Handle(TopOpeBRepDS_HDataStructure) myEHDS; TopOpeBRepDS_DataStructure *myEPDS;
136 TopOpeBRepDS_Kind myETK;TopAbs_ShapeEnum myETS;Standard_Integer myEindex;
137 Standard_Boolean myEiskind,myEisshape,myEisgeome,myEissect;
138 TCollection_AsciiString myEnamedbrep,myEnamedisp; Draw_ColorKind myEnamecolor;
142 // tsee_entity::tsee_entity() {
143 myEOK = Standard_False;
144 if (PHDSD == NULL) return; myEPHDSD = PHDSD;
145 myEHDS = myEPHDSD->CurrentHDS(); myEPDS = (TopOpeBRepDS_DataStructure*)&myEHDS->ChangeDS();
146 myETK = TopOpeBRepDS_UNKNOWN;myETS = TopAbs_SHAPE; myEindex = 0;
147 myEiskind = myEisshape = myEisgeome = myEissect = Standard_False;
148 myEnamedbrep = ""; myEnamedisp = ""; myEnamecolor = Draw_blanc;
149 myEOK = Standard_True;
152 Standard_Boolean IsP() const { return (myETK == TopOpeBRepDS_POINT); }
153 Standard_Boolean IsV() const { return (myETK == TopOpeBRepDS_VERTEX); }
154 Standard_Boolean Is0() const { return IsP() || IsV(); }
155 Standard_Integer Set(Standard_Integer na,const char** a,Standard_Integer iargK,Standard_Integer iargI);
157 Standard_EXPORT virtual ~tsee_entity() {Delete() ;} ;
158 void virtual Dump() const;
159 void virtual See() = 0;
162 void tsee_entity::Delete()
165 Standard_Integer tsee_entity::Set(Standard_Integer na,const char** a,Standard_Integer iargK,Standard_Integer iargI) {
166 myEOK = Standard_False;
167 if (iargK>=na) return 1; if (iargI>=na) return 1;
168 TCollection_AsciiString ascK = a[iargK]; myEindex = atoi(a[iargI]);
169 myEiskind = TestTopOpeDraw_TTOT::StringToKind(ascK,myETK);
170 if (!myEiskind) return 1; if (myETK == TopOpeBRepDS_UNKNOWN) return 1;
172 myEisshape = TopOpeBRepDS::IsTopology(myETK);
174 if ((myEindex < 1) || (myEindex > myEPDS->NbShapes())) return 0;
175 myETS = TopOpeBRepDS::KindToShape(myETK);
176 const TopoDS_Shape& S = myEPDS->Shape(myEindex);
177 if (myETS != S.ShapeType()) return 0;
178 myEPHDSD->ShapeName(myEindex,S,myEnamedbrep);
179 myEPHDSD->ShapeDisplayName(myEindex,S,myEnamedisp);
182 myEisgeome = TopOpeBRepDS::IsGeometry(myETK);
185 TopOpeBRepDS_PointExplorer pex(myEHDS->DS());
186 if (!pex.IsPoint(myEindex)) return 1;
188 TestTopOpeDraw_TTOT::GeometryName(myEindex,myETK,myEnamedbrep);
189 myEPHDSD->GeometryDisplayName(myEindex,myETK,myEnamedisp);
192 myEnamecolor = TestTopOpeDraw_TTOT::GeometryColor(myETK);
193 myEOK = Standard_True;
197 void tsee_entity::Dump() const {
198 TopOpeBRepDS_Dumper Dumper(myEHDS);
199 if (myEisgeome) Dumper.DumpGeometry(myETK,myEindex,cout);
200 if (myEisshape) Dumper.DumpTopology(myETK,myEindex,cout);
203 class tsee_entity0 : public tsee_entity {
211 gp_Pnt tsee_entity0::Pnt() const
213 if (!Is0()) Standard_Failure("not 0d");
215 if (IsP()) P = myEPDS->Point(myEindex).Point();
216 else if (IsV()) P = BRep_Tool::Pnt(TopoDS::Vertex(myEPDS->Shape(myEindex)));
221 (const TCollection_AsciiString& namedbrep,const TCollection_AsciiString& namedisp,const Draw_Color& namecolor,const TopOpeBRepDS_Point& P)
223 Handle(TestTopOpeDraw_DrawableP3D) D;
225 D = new TestTopOpeDraw_DrawableP3D(P.Point(),Draw_CircleZoom,namecolor,
226 namedisp.ToCString(),namecolor,
229 D = new TestTopOpeDraw_DrawableP3D(P.Point(),Draw_Square,namecolor,
230 namedisp.ToCString(),namecolor);
232 char *pname = (char *)namedbrep.ToCString();
233 Draw::Set(pname,Handle(Draw_Marker3D)::DownCast(D));
236 void tsee_entity0::See()
238 if (IsP()) ::SetPoint(myEnamedbrep,myEnamedisp,myEnamecolor,myEPDS->Point(myEindex));
239 if (IsV()) POCD->DisplayShape(myEnamedbrep,myEnamedisp,myEPDS->Shape(myEindex));
242 //-----------------------------------------------
244 //-----------------------------------------------
245 (const TCollection_AsciiString& namedbrep,
246 const TCollection_AsciiString& namedisp,
247 const Draw_Color& namecolor,
248 const TopOpeBRepDS_Curve& DSC,
249 const Standard_Integer iC)
251 if ( !PHDSD ) return;
252 const Handle(Geom_Curve) GC = DSC.Curve();
253 if ( GC.IsNull() ) { cout<<"Curve() nulle"<<endl; return; }
256 static Standard_Integer Cdiscret = 16;
257 static Standard_Real Cdeflect = 0.01;
258 static Standard_Integer Cdrawmod = 1;
259 static Standard_Boolean Cdisplayorigin = Standard_True;
262 Standard_Real f = GC->FirstParameter();
263 Standard_Real l = GC->LastParameter();
265 GeomAdaptor_Curve GAC(GC);
266 GeomAbs_CurveType GACt = GAC.GetType();
267 if ( GACt == GeomAbs_Line ) {
268 Standard_Real fline = RealLast(),lline = RealFirst();
269 Standard_Integer imother = DSC.Mother(),igood;
270 if(imother) igood = imother;
272 TopOpeBRepDS_PointIterator it = PHDSD->CurrentHDS()->CurvePoints(igood);
273 for(; it.More(); it.Next()) {
274 Standard_Real p = it.Parameter();
275 fline = Min(fline,p); lline = Max(fline,p);
281 Handle(Geom_TrimmedCurve) GTC = new Geom_TrimmedCurve(GC,f,l);
282 Handle(TestTopOpeDraw_DrawableC3D) D;
283 D = new TestTopOpeDraw_DrawableC3D(GTC,namecolor,namedisp.ToCString(),namecolor);
284 char *pname = (char *)namedbrep.ToCString();
285 Draw::Set(pname,Handle(DrawTrSurf_Curve)::DownCast(D));
288 static TopoDS_Shape bidbid;
289 static const TopoDS_Shape& GetShape(const Standard_Integer IS,const TopAbs_ShapeEnum TS)
291 Standard_Boolean TypeControl = Standard_True;
292 if ( !PHDSD ) return bidbid;
294 static TopoDS_Shape ShapeNull;
295 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
297 // check on shape index and on shape kind if kind differs from TopAbs_SHAPE
298 Standard_Integer ns = BDS.NbShapes();
299 if ( IS < 1 || IS > ns) {
300 TopAbs::Print(TS,cout);cout<<" "<<IS<<" does not exist in DS"<<endl;
303 else if ( !PHDSD->ShapeKind(IS,TS) ) {
306 cout<<" is not a ";TopAbs::Print(TS,cout);
307 cout<<" but a "; TopAbs::Print(BDS.Shape(IS,SFindKeep).ShapeType(),cout);
313 const TopoDS_Shape& S = BDS.Shape(IS,SFindKeep);
317 static const TopoDS_Shape& GetShape(const Standard_Integer IS)
319 if ( !PHDSD ) return bidbid;
320 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
321 const TopoDS_Shape& S = BDS.Shape(IS);
326 static const TopoDS_Shape& GetShapeSameDomain
327 (const Standard_Integer IS,const TopAbs_ShapeEnum TS,const TCollection_AsciiString& pre = "");
329 //-----------------------------------------------------------------------
330 // GetShapeSameDomain IS = shape index,TS = shape kind
331 //-----------------------------------------------------------------------
332 static const TopoDS_Shape& GetShapeSameDomain(const Standard_Integer IS,const TopAbs_ShapeEnum TS,const TCollection_AsciiString& pre)
334 Standard_Boolean TypeControl = Standard_True;
335 if ( !PHDSD ) return bidbid;
337 static TopoDS_Shape ShapeNull;
338 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
339 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
341 // check on shape index and on shape kind if kind differs from TopAbs_SHAPE
342 Standard_Integer ns = BDS.NbShapes();
343 if ( IS < 1 || IS > ns) {
344 TopAbs::Print(TS,cout);cout<<" "<<IS<<" does not exist in DS"<<endl;
347 else if ( !PHDSD->ShapeKind(IS,TS) ) {
349 cout<<"Shape "<<IS<<" is not a ";TopAbs::Print(TS,cout);
350 cout<<" but a ";TopAbs::Print(BDS.Shape(IS,SFindKeep).ShapeType(),cout);
355 else if ( !HDS->HasSameDomain(HDS->Shape(IS,SFindKeep)) ) {
356 if ( TypeControl ) cout<<"Shape "<<IS<<" is not HasSameDomain"<<endl;
360 // shape index <IS> ok : get shape <S> of index <IS>
361 const TopoDS_Shape& S = BDS.Shape(IS,SFindKeep);
362 TopOpeBRepDS_Dumper Dumper(HDS);
363 TCollection_AsciiString sse = Dumper.SPrintShape(S);
364 TCollection_AsciiString sor = TopOpeBRepDS::SPrint(S.Orientation());
365 TCollection_AsciiString str;str=str+pre+sse+" is "+sor+"\n";
366 cout<<str;cout.flush();
372 //-----------------------------------------------------------------------
374 //-----------------------------------------------------------------------
375 static Standard_Integer SeeSectionEdge(const Standard_Integer ISE)
377 if ( !PHDSD || !POCD ) return 0;
379 Standard_Integer nse = PHDSD->CurrentBDS().NbSectionEdges();
380 if ( ISE < 1 || ISE > nse ) return 0;
381 const TopoDS_Shape& SE = PHDSD->CurrentBDS().SectionEdge(ISE);
382 if (SE.IsNull()) return 0;
384 TCollection_AsciiString namedbrep; PHDSD->SectionEdgeName(ISE,SE,namedbrep);
385 TCollection_AsciiString namedisp; PHDSD->SectionEdgeDisplayName(ISE,SE,namedisp);
386 POCD->DisplayGeometry(Standard_True);
387 POCD->DisplayShape(namedbrep,namedisp,SE);
391 //-----------------------------------------------------------------------
393 //-----------------------------------------------------------------------
394 Standard_Integer SeeShapeIS(const Standard_Integer I,const TopoDS_Shape& S)
396 if ( !PHDSD || !POCD) return 0;
398 if (S.IsNull()) return 0;
399 TCollection_AsciiString namedbrep; PHDSD->ShapeName(I,S,namedbrep);
400 TCollection_AsciiString namedisp = namedbrep;
401 // NameDisplay = *name/name* if S subshape of shape1/shape2
402 TCollection_AsciiString ast = "*";
403 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
404 // if the Shape was removed from the DS, "*" is replaced by "~"
407 Standard_Boolean of1 = PHDSD->SubShape(S,1);if(of1) namedisp = ast+namedisp;
408 Standard_Boolean of2 = PHDSD->SubShape(S,2);if(of2) namedisp = namedisp+ast;
409 if (SelectRankShape == 1 && !of1) return 0;
410 if (SelectRankShape == 2 && !of2) return 0;
412 if (S.ShapeType()==TopAbs_EDGE) POCD->DisplayGeometry(Standard_True);
413 else POCD->DisplayGeometry(DisOri);
414 if((S.ShapeType()==TopAbs_VERTEX) && TolFlag) {
415 const TopoDS_Vertex& V = TopoDS::Vertex(S);
416 Standard_Real Tol = BRep_Tool::Tolerance(V);
419 POCD->DisplayShape(namedbrep,namedisp,S);
425 //-----------------------------------------------------------------------
427 //-----------------------------------------------------------------------
428 static Standard_Integer SeeShape(TCollection_AsciiString namedbrep)
430 if ( !PHDSD || !POCD ) return 0;
432 const char* pname = (const char *)namedbrep.ToCString();
433 TopoDS_Shape S = DBRep::Get(pname);
434 if ( S.IsNull() ) return 0;
435 TCollection_AsciiString namedisp;
436 PHDSD->ShapeDisplayName(namedbrep,S,namedisp);
437 POCD->DisplayShape(namedbrep,namedisp,S);
441 //-----------------------------------------------------------------------
443 //-----------------------------------------------------------------------
444 static Standard_Integer SeePoint(const Standard_Integer I)
446 if ( !PHDSD ) return 0;
448 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
449 if (I < 1 || I > BDS.NbPoints()) return 0;
451 TopOpeBRepDS_PointExplorer pex(BDS);
452 Standard_Boolean isp = pex.IsPoint(I);
455 const TopOpeBRepDS_Point& P = BDS.Point(I);
456 TopOpeBRepDS_Kind K = TopOpeBRepDS_POINT;
457 TCollection_AsciiString namedbrep; TestTopOpeDraw_TTOT::GeometryName(I,K,namedbrep);
458 TCollection_AsciiString namedisp; PHDSD->GeometryDisplayName(I,K,namedisp);
459 Draw_ColorKind namecolor = TestTopOpeDraw_TTOT::GeometryColor(K);
460 SetPoint(namedbrep,namedisp,namecolor,P);
464 //-----------------------------------------------------------------------
466 //-----------------------------------------------------------------------
467 static Standard_Integer SeeCurve(const Standard_Integer I)
469 if ( !PHDSD ) return 0;
471 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
472 if (I < 1 || I > BDS.NbCurves()) return 0;
474 TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep);
475 Standard_Boolean isc = cex.IsCurve(I);
478 const TopOpeBRepDS_Curve& C = BDS.Curve(I);
479 TopOpeBRepDS_Kind K = TopOpeBRepDS_CURVE;
480 TCollection_AsciiString namedbrep; TestTopOpeDraw_TTOT::GeometryName(I,K,namedbrep);
481 TCollection_AsciiString namedisp; PHDSD->GeometryDisplayName(I,K,namedisp);
482 Draw_ColorKind namecolor = TestTopOpeDraw_TTOT::GeometryColor(K);
483 SetCurve(namedbrep,namedisp,namecolor,C,I);
488 //-----------------------------------------------------------------------
490 //-----------------------------------------------------------------------
491 Standard_Integer SeeSurface(const Standard_Integer I) // NYI
493 if ( !PHDSD ) return 0;
495 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
496 if (I < 1 || I > BDS.NbSurfaces()) return 0;
500 //-----------------------------------------------------------------------
502 //-----------------------------------------------------------------------
503 static Standard_Integer SeeEdgeCurve(const Standard_Integer IE,const TopoDS_Shape& SE)
505 if ( !POCD ) return 0;
507 if (SE.IsNull()) return 0;
508 const TopoDS_Edge& E = TopoDS::Edge(SE);
509 TopLoc_Location L;Standard_Real f,l;Handle(Geom_Curve) GC=BRep_Tool::Curve(E,L,f,l);
510 TCollection_AsciiString namedbrep="E";TestTopOpeDraw_TTOT::CatCurveName(IE,namedbrep);
511 TCollection_AsciiString namedisp="E";TestTopOpeDraw_TTOT::CatCurveDisplayName(IE,GC,namedisp);
512 POCD->DisplayGeometry(Standard_True);
513 POCD->DisplayShape(namedbrep,namedisp,SE);
517 //-----------------------------------------------------------------------
519 //-----------------------------------------------------------------------
520 static Standard_Integer SeeGeometry(const Standard_Integer IG,const TopOpeBRepDS_Kind TK)
522 if (TK == TopOpeBRepDS_POINT) return SeePoint(IG);
523 else if (TK == TopOpeBRepDS_CURVE) return SeeCurve(IG);
524 else if (TK == TopOpeBRepDS_SURFACE) return SeeSurface(IG);
528 //-----------------------------------------------------------------------
530 //-----------------------------------------------------------------------
533 static Standard_Integer SeeGeometry(const tsee_entity& E)
535 if (!E.myEOK) return 0;
536 return SeeGeometry(E.myEindex,E.myETK);
540 //-----------------------------------------------------------------------
542 //-----------------------------------------------------------------------
543 static Standard_Integer SeeGeometry(const TopOpeBRepDS_Kind TK)
545 if ( !PHDSD ) return 0;
547 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
549 if (TK == TopOpeBRepDS_POINT) {
550 TopOpeBRepDS_PointExplorer pex(BDS,GFindKeep);
551 for (; pex.More(); pex.Next()) {
552 Standard_Integer ig = pex.Index();
556 else if (TK == TopOpeBRepDS_CURVE) {
557 TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep);
558 for (; cex.More(); cex.Next()) {
559 Standard_Integer ig = cex.Index();
563 else if (TK == TopOpeBRepDS_SURFACE) { //NYI
568 //-----------------------------------------------------------------------
570 //-----------------------------------------------------------------------
571 Standard_Integer TOPOPE_SeeShape(char* name)
573 TCollection_AsciiString asc = name;
574 Standard_Integer res = SeeShape(asc);
578 //-----------------------------------------------------------------------
579 // decalargs : shift a[*] from <-d>,modify na = na - deca
580 //-----------------------------------------------------------------------
583 static void decalargs(Standard_Integer& na,const char** a,const Standard_Integer d)
584 {for(Standard_Integer i=1;i<na;i++)a[i]=a[i+d];na-=d;}
587 //-----------------------------------------------------------------------
588 // suppressarg : remove a[d],modify na--
589 //-----------------------------------------------------------------------
590 Standard_EXPORT void suppressarg(Standard_Integer& na,const char** a,const Standard_Integer d)
592 for(Standard_Integer i=d;i<na;i++) {
599 //-----------------------------------------------------------------------
600 // suppressargs : remove a[*] from <f> to <l>,modify na = na - (l - f)
601 //-----------------------------------------------------------------------
602 Standard_EXPORT void suppressargs(Standard_Integer& na,const char** a,const Standard_Integer f,const Standard_Integer l)
607 for(Standard_Integer i=0;i<na-l;i++) {
614 //-----------------------------------------------------------------------
616 //-----------------------------------------------------------------------
619 static Standard_Boolean SetTolFlag(Standard_Integer& na,const char** a) { decalargs(na,a,1); return Standard_True; }
622 //-----------------------------------------------------------------------
624 //-----------------------------------------------------------------------
625 static void tsee_flags(Standard_Integer& na,const char** a) {
626 GFindKeep = Standard_False;
627 PrintDistancePP = Standard_False;
630 for (Standard_Integer ia = 1; ia < na; ia++) {
631 if (!strcasecmp(a[ia],"-k")) {
632 suppressarg(na,a,ia);
633 GFindKeep = Standard_True;
635 else if (!strcasecmp(a[ia],"-d")) {
636 // tsee -d p 4 7 : display p_4,p_7 + tds p 4 7 + calculate distance (p_4,p_7)
637 suppressarg(na,a,ia);
638 PrintDistancePP = Standard_True;
640 else if (!strcasecmp(a[ia],"-1")) {
641 // tsee -1 s 4 : display s_4 <=> s_4 is subshape of the 1st argument
642 suppressarg(na,a,ia);
645 else if (!strcasecmp(a[ia],"-2")) {
646 // tsee -2 s 4 : display s_4 <=> s_4 is subshape of the 2nd argument
647 suppressarg(na,a,ia);
650 else if (!strcasecmp(a[ia],"-p") && (ia < na-1)) {
651 suppressargs(na,a,ia,ia+1);
652 Standard_Real t = atof(a[ia+1]);
653 if (t >= 0. && t <= 1.) {
654 OldParFlag = ParFlag; ParFlag = t;
660 void OthersCommands_help(const char* CommandName,const char* syntaxe = "");
661 //-----------------------------------------------------------------------
663 //-----------------------------------------------------------------------
664 static void tsee_help(const char* CommandName, Draw_Interpretor& di)
667 di<<"tsee : Draw entities of data structure (DS) loaded by TestTopOpe::CurrentDS()."<<"\n";
668 di<<"DS entities are shapes and geometries accessed by a <type> and an <index>."<<"\n";
669 di<<"basic usage :"<<"\n";
670 di<<" tsee <type> <index1 index2 ...>"<<"\n";
671 di<<"<type> = so sh f w e v s for solid/shell/face/wire/edge/vertex/shape"<<"\n";
672 di<<" su cu p for surface/curve/point (N.B : su is NYI)"<<"\n";
673 di<<"<index> = integer"<<"\n";
674 di<<"example : 'tsee e 3' will draw the edge of index 3"<<"\n";
675 di<<" 'tsee e 3 6' will draw the edges of index 3 and 6"<<"\n";
676 di<<" 'tsee e' will draw all the edges."<<"\n";
678 di<<"Index values of DS entities may be given by the 'tds' command which prints"<<"\n";
679 di<<"the content of the DS for each shape and geometry type."<<"\n";
680 di<<"Entities are drawn with a specific color according to their type."<<"\n";
682 di<<"Naming : "<<"\n";
683 di<<"'tsee <t> <i>' creates the drawable object named <t>_<i>."<<"\n";
684 di<<"This name is displayed near the entity in one if the forms : "<<"\n";
685 di<<" *<t>_<i> meaning entity belongs to the first shape of current operation."<<"\n";
686 di<<" <t>_<i>* meaning entity belongs to the second shape of current operation."<<"\n";
688 di<<"Same Domain shapes : "<<"\n";
689 di<<"'tsee <type> sd' to display all shapes of <type> having same domain data."<<"\n";
690 di<<"example : 'tsee e sd' to display all edges sharing a 1d geometric domain"<<"\n";
691 di<<" with other edges."<<"\n";
693 di<<"Optional flags :"<<"\n";
694 OthersCommands_help(CommandName);
695 di<<"Other types :"<<"\n";
696 di<<"'tsee fev' : displays all faces,then edges,then vertices."<<"\n";
697 di<<"'tsee es <i>' displays edge described as section edge <i>."<<"\n";
698 di<<" The name of a section edge likes t_i<j>,where :"<<"\n";
699 di<<" - i is the edge index in the set of section edge,"<<"\n";
700 di<<" - j is edge index in the DS (as any edge)."<<"\n";
704 static void tseei_help(Draw_Interpretor& di)
707 di<<"tseei : Draws entities of data structure (DS) loaded by TestTopOpe::CurrentDS()."<<"\n";
708 di<<"Draws the objects appearing in interferences DS objects."<<"\n";
709 di<<"See command 'tsee' for discussion about DS objects."<<"\n";
713 static void tki_help(Draw_Interpretor& di)
716 di<<"tki,tkig,tkis : Groups interferences of DS objects"<<"\n";
717 di<<" by geometry (g),or support (s),and index."<<"\n";
718 di<<"See command 'tsee' for discussion about DS objects."<<"\n";
719 di<<"(Test of class TopOpeBRepDS_TKI)"<<"\n";
723 static void tds_help(Draw_Interpretor& di)
726 di<<"tds : dump current DS (loaded by CurrentDS())"<<"\n";
727 di<<"basic usage : tds <-arg> type <index1 index2 ...>"<<"\n";
729 di<<"Description of curve geometry (type = c) : <-arg> = -t -k -s -l"<<"\n";
730 di<<"\t-k : print only the curve with keep = Standard_True"<<"\n";
731 di<<"\t-l : (long) print all poles and knots for BSplines curves"<<"\n";
732 di<<"\t-s : (short) print only 4 poles and 4 knots for BSplines curves"<<"\n";
733 di<<"on shapes (type = s|so|sh|f|w|e|v) : <-arg> = -ssi"<<"\n";
734 di<<"\t-ssi : print only ShapeShapeInterferences"<<"\n";
736 di<<"See command 'tsee' for discussion about type and <index1 index2 ...>."<<"\n";
740 typedef Standard_Integer (*tf_SeeShape)(const Standard_Integer I,const TopoDS_Shape& S);
741 Standard_IMPORT void OthersCommands_flags(Standard_Integer& na,const char** a,TestTopOpeDraw_Displayer& TD);
742 void COUTNOHDS(Draw_Interpretor& di) {di<<"no current HDS"<<"\n";}
743 Standard_Integer tsee_SeeShapefunc(Draw_Interpretor& di,Standard_Integer na_in,const char** a,tf_SeeShape SeeShapefunc)
745 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
750 Standard_Integer na = na_in;
751 if ((PHDSD == NULL) || (POCD == NULL)) return 0;
753 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
754 if (HDS.IsNull()) { COUTNOHDS(di); return 0; }
755 if (na < 2) return 1;
756 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
758 POCD->InitDisplayer();
759 TolFlag = Standard_False;
761 OthersCommands_flags(na,a,*POCD);
762 TolFlag = POCD->TolIs();
763 DisOri = POCD->DisplayGeometry();
765 Standard_Integer i1arg = 1;
766 TSEEpar Tpar(a[i1arg]);
768 // Standard_Integer ia,is,ig;
769 Standard_Integer ia,is;
771 if ( PrintDistancePP ) {
773 if (na == 4) { // tsee p 3 4
774 if (E1.Set(na,a,i1arg+0,i1arg+1)) return 1;
775 if (E2.Set(na,a,i1arg+0,i1arg+2)) return 1;
777 else if (na == 5) { // tsee p 3 v 4
778 if (E1.Set(na,a,i1arg+0,i1arg+1)) return 1;
779 if (E2.Set(na,a,i1arg+2,i1arg+3)) return 1;
781 if (!E1.myEOK || !E2.myEOK) return 1;
785 di<<"Distance "<<E1.myEnamedbrep.ToCString()<<" "<<E2.myEnamedbrep.ToCString()<<" : "<<E1.Pnt().Distance(E2.Pnt())<<"\n";
789 else if ( Tpar.isshap() ) {
790 // na == 2 : display all DS shapes of type TS
791 // na > 2 : display DS shapes of type TS of index atoi(a[2]..a[narg-1])
793 TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);
794 for(;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current());
797 if ( !strcmp(a[i1arg+1],"sd") ) { // shapes HasSameDomain of type TS
798 TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);
799 for (;x.More();x.Next()) {
800 Standard_Boolean isSsd = HDS->HasSameDomain(x.Current());
801 if (isSsd ) (*SeeShapefunc)(x.Index(),x.Current());
804 else if (Tpar.isshap() && (Tpar.TS() == TopAbs_EDGE) && (na>=2) && POCD->ParIs()) {
805 // see edges [4..na[ with of the name in t in [0..1] / range
807 TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False);
808 for (;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current());
811 for (ia = i1arg+1; ia < na; ia++) {
813 (*SeeShapefunc)(is,GetShape(is,Tpar.TS()));
816 ParFlag = OldParFlag;
819 for (ia = i1arg+1; ia < na; ia++) {
821 (*SeeShapefunc)(is,GetShape(is,Tpar.TS()));
827 else if ( Tpar.isgeom() ) {
828 // na == 2 : display all DS geometries of type TK
829 // na > 2 : display DS geometries of type TK index atoi(a[2])..a[narg-1])
830 if (na == 2 ) SeeGeometry(Tpar.TK());
831 else for (ia = i1arg+1; ia < na; ia++) SeeGeometry(Standard_Integer(atoi(a[ia])),Tpar.TK());
834 else if ( Tpar.isafev() ) {
835 // faces then edges then vertices
836 TopOpeBRepDS_Explorer x;
837 for (x.Init(HDS,TopAbs_FACE,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
838 for (x.Init(HDS,TopAbs_EDGE,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
839 for (x.Init(HDS,TopAbs_VERTEX,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
842 else if ( Tpar.isedcu() ) {
843 // na == 2 : display curves of all DS edges
844 // na > 2 : display curve of DS edges index atoi(a[2])..a[narg-1])
846 TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False);
847 for (;x.More();x.Next()) SeeEdgeCurve(x.Index(),x.Edge());
850 for (ia = i1arg+1; ia < na; ia++) {
852 SeeEdgeCurve(is,GetShape(is,TopAbs_EDGE));
857 else if ( Tpar.issect() ) { // na=2 all section edges,na>2 section edges (a[2]..a[na-1])
858 Standard_Integer ise,nse = BDS.NbSectionEdges();
859 if (na == 2) for (ise = 1; ise<=nse; ise++) SeeSectionEdge(ise);
860 else for (ia = i1arg+1; ia<na; ia++) SeeSectionEdge(atoi(a[ia]));
863 else if (Tpar.isdege()) {
864 TopOpeBRepDS_Explorer x;
865 for (x.Init(HDS,TopAbs_EDGE);x.More();x.Next()) {
866 if (BRep_Tool::Degenerated(x.Edge())) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
871 } // tsee_SeeShapefunc
873 //-----------------------------------------------------------------------
875 //-----------------------------------------------------------------------
876 Standard_Integer tsee(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
878 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
882 tf_SeeShape ssf = (tf_SeeShape)SeeShapeIS;
883 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
887 //-----------------------------------------------------------------------
889 //-----------------------------------------------------------------------
890 Standard_Integer SeeAnyKI(const TopOpeBRepDS_Kind TK,const Standard_Integer I) {
892 TopAbs_ShapeEnum TS = TopAbs_COMPOUND;
896 Standard_Boolean isshape,isgeome; isshape = isgeome = Standard_False;
897 isshape = TopOpeBRepDS::IsTopology(TK);
898 if (isshape) TS = TopOpeBRepDS::KindToShape(TK);
899 else isgeome = TopOpeBRepDS::IsGeometry(TK);
900 if (isshape) SeeShapeIS(I,GetShape(I,TS));
901 else if (isgeome) SeeGeometry(I,TK);
905 //-----------------------------------------------------------------------
907 //-----------------------------------------------------------------------
908 (TColStd_ListOfInteger& LOK,TColStd_ListOfInteger& LOI,
909 const TopOpeBRepDS_Kind K,const Standard_Integer I)
912 Standard_Boolean isshape,isgeome; isshape = isgeome = Standard_False;
913 isshape = TopOpeBRepDS::IsTopology(K);
914 if (isshape) TS = TopOpeBRepDS::KindToShape(K);
915 else isgeome = TopOpeBRepDS::IsGeometry(K);
917 if (LOK.IsEmpty() && LOI.IsEmpty()) {
918 LOK.Append((Standard_Integer)K); LOI.Append(I);
922 // to sort, it is considered that :
923 // POINT == VERTEX,CURVE == EDGE,SURFACE == FACE
926 TopAbs_ShapeEnum SKtri;
928 TopAbs_ShapeEnum SKtri=TopAbs_COMPOUND;
930 if (isshape) SKtri = TopOpeBRepDS::KindToShape(K);
932 if (K == TopOpeBRepDS_POINT) SKtri = TopAbs_VERTEX;
933 else if (K == TopOpeBRepDS_CURVE) SKtri = TopAbs_EDGE;
934 else if (K == TopOpeBRepDS_SURFACE) SKtri = TopAbs_FACE;
938 TColStd_ListIteratorOfListOfInteger ITLOK(LOK);
939 TColStd_ListIteratorOfListOfInteger ITLOI(LOI);
940 Standard_Boolean equa = Standard_False;
941 for (; ITLOK.More(),ITLOI.More(); ITLOK.Next(),ITLOI.Next()) {
943 Standard_Integer ifK = ITLOK.Value() ;
944 TopOpeBRepDS_Kind fK = (TopOpeBRepDS_Kind) ifK ;
945 TopAbs_ShapeEnum fSK = TopOpeBRepDS::KindToShape(fK);
946 // TopOpeBRepDS_Kind fK = (TopOpeBRepDS_Kind)ITLOK.Value(); TopAbs_ShapeEnum fSK = TopOpeBRepDS::KindToShape(fK);
947 Standard_Integer fI = ITLOI.Value();
948 if (SKtri == fSK && I == fI) {
949 equa = Standard_True;
953 LOK.InsertBefore((Standard_Integer)K,ITLOK);
954 LOI.InsertBefore(I,ITLOI);
958 if ( !ITLOK.More() && !equa) {
959 LOK.Append((Standard_Integer)K);
964 //-----------------------------------------------------------------------
966 //-----------------------------------------------------------------------
967 Standard_Integer SeeShapeISI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di)
969 if ( !PHDSD ) return 0;
970 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
971 if (S.IsNull()) return 0;
974 TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType());
975 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
976 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(S);
977 TopOpeBRepDS_ListIteratorOfListOfInterference ITLOI(LOI);
978 TColStd_ListOfInteger LOKK,LOII;
980 for (;ITLOI.More();ITLOI.Next()) {
981 const Handle(TopOpeBRepDS_Interference)& HI = ITLOI.Value();
982 const TopOpeBRepDS_Transition& T = HI->Transition();
984 TopAbs_ShapeEnum sb = T.ShapeBefore();TopOpeBRepDS_Kind sbk = TopOpeBRepDS::ShapeToKind(sb);
985 Standard_Integer sbi = T.IndexBefore();
986 TopAbs_ShapeEnum sa = T.ShapeAfter();TopOpeBRepDS_Kind sak = TopOpeBRepDS::ShapeToKind(sa);
987 Standard_Integer sai = T.IndexAfter();
988 TopOpeBRepDS_Kind gk,sk; Standard_Integer gi,si; HI->GKGSKS(gk,gi,sk,si);
990 AddShapeKI(LOKK,LOII,sbk,sbi);
991 AddShapeKI(LOKK,LOII,sak,sai);
992 AddShapeKI(LOKK,LOII,gk,gi);
993 AddShapeKI(LOKK,LOII,sk,si);
996 TColStd_ListIteratorOfListOfInteger ITLOKK,ITLOII;
998 ITLOKK.Initialize(LOKK); ITLOII.Initialize(LOII);
999 Standard_Boolean ya = ITLOKK.More();
1000 TopOpeBRepDS::Print(SK,I,cout,""," : ");
1001 for(; ITLOKK.More(),ITLOII.More(); ITLOKK.Next(),ITLOII.Next()) {
1003 Standard_Integer ikk = ITLOKK.Value() ;
1004 TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind) ikk ;
1005 Standard_Integer ii = ITLOII.Value();
1006 // TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind)ITLOKK.Value(); Standard_Integer ii = ITLOII.Value();
1007 TopOpeBRepDS::Print(kk,ii,cout,""," ");
1009 if (ya) di<<"\n"; else di<<"no shape interference"<<"\n";
1011 ITLOKK.Initialize(LOKK); ITLOII.Initialize(LOII);
1012 for(; ITLOKK.More(),ITLOII.More(); ITLOKK.Next(),ITLOII.Next()) {
1014 Standard_Integer ikk =ITLOKK.Value() ;
1015 TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind) ikk ;
1016 Standard_Integer ii = ITLOII.Value();
1017 // TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind)ITLOKK.Value(); Standard_Integer ii = ITLOII.Value();
1025 //-----------------------------------------------------------------------
1027 //-----------------------------------------------------------------------
1028 Standard_Integer SeeShapeTKIG(const Standard_Integer I,const TopoDS_Shape& S)
1030 if ( !PHDSD ) return 0;
1031 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1032 if (S.IsNull()) return 0;
1035 TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType());
1036 const TopOpeBRepDS_ListOfInterference& LOI = HDS->DS().ShapeInterferences(S);
1037 TopOpeBRepDS_TKI tki;
1038 TCollection_AsciiString s1,s2;
1041 tki.FillOnGeometry(LOI);
1042 s1=TopOpeBRepDS::SPrint(SK,I,""," by G : \n");
1043 tki.Init();if (tki.More()) s2="\n";else s2="";
1044 tki.DumpTKIIterator(s1,s2);
1049 //-----------------------------------------------------------------------
1051 //-----------------------------------------------------------------------
1052 Standard_Integer SeeShapeTKIS(const Standard_Integer I,const TopoDS_Shape& S)
1054 if ( !PHDSD ) return 0;
1055 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1056 if (S.IsNull()) return 0;
1059 TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType());
1060 const TopOpeBRepDS_ListOfInterference& LOI = HDS->DS().ShapeInterferences(S);
1061 TopOpeBRepDS_TKI tki;
1062 TCollection_AsciiString s1,s2;
1065 tki.FillOnSupport(LOI);
1066 s1=TopOpeBRepDS::SPrint(SK,I,""," by S : \n");
1067 tki.Init();if (tki.More()) s2="\n";else s2="";
1068 tki.DumpTKIIterator(s1,s2);
1073 //-----------------------------------------------------------------------
1075 //-----------------------------------------------------------------------
1076 Standard_Integer SeeShapeTKI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di)
1084 //-----------------------------------------------------------------------
1086 //-----------------------------------------------------------------------
1087 Standard_Integer tseei(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1089 if (na_in == 1) { tseei_help(di); return 0; }
1090 tf_SeeShape ssf = (tf_SeeShape)SeeShapeISI;
1091 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
1095 //-----------------------------------------------------------------------
1097 //-----------------------------------------------------------------------
1098 Standard_Integer tki(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1100 if (na_in == 1) { tki_help(di); return 0; }
1102 tf_SeeShape ssf = NULL;
1103 if ( !strcasecmp(a[0],"tki") ) ssf = (tf_SeeShape)SeeShapeTKI;
1104 else if ( !strcasecmp(a[0],"tkig") ) ssf = (tf_SeeShape)SeeShapeTKIG;
1105 else if ( !strcasecmp(a[0],"tkis") ) ssf = (tf_SeeShape)SeeShapeTKIS;
1106 if (ssf == NULL) return 0;
1108 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
1112 //-----------------------------------------------------------------------
1114 // 1 = kind of DS object to dump = [s] [so sh f w e v] [se] [su c p]
1115 // 2,3 ... = [i1,i2 ...] = indices of DS object to see
1116 //-----------------------------------------------------------------------
1117 Standard_Integer tds(Draw_Interpretor& di,Standard_Integer na,const char** a)
1119 Standard_Boolean TDSkeep,TDScompact; TDSkeep = TDScompact = Standard_False;
1120 TopOpeBRepDS_GLOBALHDSinterfselector = 0;
1122 Standard_Integer ia ;
1123 for ( ia = 0; ia < na; ia++) {
1124 if (!strcasecmp(a[ia],"-ssi")) {
1125 TopOpeBRepDS_GLOBALHDSinterfselector = 1;
1126 suppressarg(na,a,ia);
1129 else if (!strncmp(a[ia],"-",1)) {
1130 TCollection_AsciiString as = a[ia];
1132 for(Standard_Integer i = 1;i <= as.Length(); i++) {
1133 if (as.Value(i) == 'k') TDSkeep = Standard_True;
1134 else if(as.Value(i) == 'l') TDScompact = Standard_False;
1135 else if(as.Value(i) == 's') TDScompact = Standard_True;
1136 else if(as.Value(i) == 'h') { tds_help(di); return 0; }
1138 suppressarg(na,a,ia);
1142 if (PHDSD == NULL) return 0;
1143 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1144 if (HDS.IsNull()) {COUTNOHDS(di);return 0;}
1145 PHDSD->CurrentBDS();
1147 TopOpeBRepDS_Dumper Dumper(HDS);
1148 if ( na == 1 ) { Dumper.Dump(cout,TDSkeep,TDScompact); return 0; }
1151 Standard_Integer ids;
1154 if (Tpar.isshap()) {
1155 if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),cout);
1156 else Dumper.DumpTopology(cout);
1158 else if (Tpar.isgeom()) {
1159 Dumper.DumpGeometry(Tpar.TK(),cout,TDSkeep,TDScompact);
1161 else if (Tpar.issect()) {
1162 Dumper.DumpSectionEdge(Tpar.TK(),cout);
1164 else if (Tpar.isafev()) {
1165 TopOpeBRepDS_Explorer x;
1166 for (x.Init(HDS,TopAbs_FACE,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1167 for (x.Init(HDS,TopAbs_EDGE,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1168 for (x.Init(HDS,TopAbs_VERTEX,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1171 else if (Tpar.isdege()) {
1172 TopOpeBRepDS_Explorer x;
1173 for (x.Init(HDS,TopAbs_EDGE,TDSkeep);x.More();x.Next()) {
1174 if (BRep_Tool::Degenerated(x.Edge())) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1180 // nna > 2 : dump DS entities of type TK index atoi(a[2])..a[narg-1])
1181 for (ia = 2; ia < na; ia++) {
1183 if ( !strcmp(a[ia],"sd") ) { // dump all shapes HasSameDomain of type TS
1184 for (TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);x.More();x.Next()) {
1185 Standard_Boolean isSsd = HDS->HasSameDomain(x.Current());
1186 if (isSsd ) Dumper.DumpTopology(Tpar.TK(),x.Index(),cout);
1191 if ( Tpar.isshap() ) {
1192 if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),ids,cout);
1194 TopAbs_ShapeEnum t = HDS->Shape(ids,SFindKeep).ShapeType();
1195 TopOpeBRepDS_Kind k = TopOpeBRepDS::ShapeToKind(t);
1196 Dumper.DumpTopology(k,ids,cout);
1199 else if ( Tpar.isgeom() ) {
1200 Dumper.DumpGeometry(Tpar.TK(),ids,cout,TDSkeep,TDScompact);
1202 else if ( Tpar.issect() ) {
1203 Dumper.DumpSectionEdge(TopOpeBRepDS_EDGE,ids,cout);
1211 Standard_Integer TPPE(Draw_Interpretor& di,Standard_Integer na,const char** a)
1213 if (PHDSD == NULL) return 0;
1214 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1215 if ( HDS.IsNull() ) { COUTNOHDS(di); return 0; }
1217 if (na != 5) return 1;
1218 Standard_Boolean ok = Standard_True;
1223 Standard_Integer ip = atoi(a[2]);
1224 Standard_Integer ie = atoi(a[4]);
1225 ok = ok && (ip >= 1); ok = ok && (ie >= 1);
1227 di <<" bad data"<<"\n";
1231 ok = Standard_False;
1232 if (!strcmp("p",a[1])){
1234 ok = ok && (ip <= HDS->NbPoints());
1235 if (ok) pds = HDS->Point(ip).Point();
1236 if (!ok) di<<" geometry "<<ip<<" is not a point"<<"\n";
1238 if (!strcmp("v",a[1])){
1240 ok = ok && (ip <= HDS->NbShapes());
1242 TopoDS_Shape sh = HDS->Shape(ip,SFindKeep);
1243 ok = ok && (sh.ShapeType() == TopAbs_VERTEX);
1244 if (ok) pds =BRep_Tool::Pnt(TopoDS::Vertex(sh));
1246 if (!ok) di<<" shape "<<ip<<" is not a vertex"<<"\n";
1248 if (!strcmp("e",a[3])){
1249 ok = ok && (ie <= HDS->NbShapes());
1251 TopoDS_Shape sh = HDS->Shape(ie,SFindKeep);
1252 ok = ok && (sh.ShapeType() == TopAbs_EDGE);
1253 if (ok) ed = TopoDS::Edge(sh);
1255 if (!ok) di<<" shape "<<ie<<" is not an edge"<<"\n";
1257 } else ok = Standard_False;
1259 Standard_Real dmin=0;
1263 Handle(Geom_Curve) cu = BRep_Tool::Curve(ed,f,l);
1264 GeomAPI_ProjectPointOnCurve ponc(pds,cu,f,l);
1265 ok = ponc.NbPoints() >= 1;
1268 dmin = ponc.LowerDistance();
1269 Standard_Real par = ponc.LowerDistanceParameter();
1270 BRepAdaptor_Curve bc(ed);
1271 pproj = bc.Value(par);
1276 TCollection_AsciiString pp("p");
1277 pp.AssignCat(ip); pp.AssignCat("e"); pp.AssignCat(ie);
1278 char* ppp = (char *)pp.ToCString();
1279 DrawTrSurf::Set(ppp,pproj);
1280 di<<"dist point "<<ip<<" on edge "<<ie<<" = "<<dmin<<"\n";
1281 } else di<<"projection failed"<<"\n";
1286 void FUN_ChkIntgInterf(Draw_Interpretor& di) //***Check Integrity Interference
1288 if ( PHDSD == NULL ) return;
1289 PHDSD->CurrentHDS()->ChkIntg();
1290 di<<"Check interference integrity completed"<<"\n";
1293 void FUN_ChkIntgSamDomain(Draw_Interpretor& di) //***Check Integrity SameDomain
1295 if ( PHDSD == NULL ) return;
1296 TopOpeBRepDS_Check C(PHDSD->CurrentHDS());
1297 if(C.ChkIntgSamDom())
1298 di<<"Check SameDomain integrity completed"<<"\n";
1301 void FUN_ChkIntg(Draw_Interpretor& di) //***Check Integrity
1303 if ( PHDSD == NULL ) return;
1304 FUN_ChkIntgInterf(di);
1305 FUN_ChkIntgSamDomain(di);
1308 void FUN_ChkVertex(Draw_Interpretor& di) //***Check Vertex SameDomain
1310 if ( PHDSD == NULL ) return;
1311 TopOpeBRepDS_Check C(PHDSD->CurrentHDS());
1312 if(C.OneVertexOnPnt())
1313 di<<"Check Structure Vertex SameDomain Complete"<<"\n";
1316 //---------------------------------------------------------
1317 Standard_Integer topochk(Draw_Interpretor& di,Standard_Integer na,const char** a)
1319 if (strcmp(a[0],"topochk")) return 1;
1323 ::FUN_ChkVertex(di);
1325 else if(na > 2) return 1;
1326 else if(!strcmp (a[1],"-i")) ::FUN_ChkIntg(di);
1327 else if(!strncmp(a[1],"-i",2)) {
1328 if (!strcmp(a[1],"-ii")) ::FUN_ChkIntgInterf(di);
1329 else if(!strcmp(a[1],"-isd")) ::FUN_ChkIntgSamDomain(di);
1331 else if(!strcmp (a[1],"-s")) ::FUN_ChkVertex(di);
1333 di<<"option : -i = check DS full integrity"<<"\n";
1334 di<<"option : -ii = check only interferences"<<"\n";
1335 di<<"option : -isd = check only SameDomain data"<<"\n"<<"\n";
1336 di<<"option : -s = check only SameDomain data on vertex"<<"\n";
1342 //-----------------------------------------------------------------------
1344 //-----------------------------------------------------------------------
1345 Standard_Integer SeeShapeTCX(const Standard_Integer I,const TopoDS_Shape& S)
1347 if ( !PHDSD ) return 0;
1348 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1349 if (S.IsNull()) return 0;
1354 static void tcx_help(Draw_Interpretor& di)
1356 di<<"tcx : function not documented"<<"\n";
1359 //-----------------------------------------------------------------------
1361 //-----------------------------------------------------------------------
1362 Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1364 if (na_in == 1) { tcx_help(di); return 0; }
1365 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,SeeShapeTCX);
1370 //---------------------------------------------------------
1371 Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na,const char** a)
1373 if (PHDSD == NULL) return 0;
1374 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1375 if ( HDS.IsNull() ) { COUTNOHDS(di); return 0; }
1376 if (na == 1) FDSCNX_Dump(HDS);
1378 if (ISINTEGER(a[1])) FDSCNX_Dump(HDS,atoi(a[1]));
1385 //-----------------------------------------------------------------------
1386 Standard_Integer tdsri(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1388 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
1392 Standard_Integer na = na_in;
1393 if ((PHDSD == NULL) || (POCD == NULL)) return 0;
1394 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1395 if (HDS.IsNull()) { COUTNOHDS(di); return 0; }
1396 if (na < 5) return 1;
1397 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1399 Standard_Integer i1arg = 1;
1400 TDSpar Tpar(a[i1arg]);
1402 if ( strcasecmp(a[i1arg + 2],"i") ) return 0;
1403 Standard_Integer ii = atoi(a[i1arg + 3]);
1404 // Standard_Integer ia,is,ig;
1405 Standard_Integer is,ig;
1406 if ( Tpar.isshap() ) {
1407 is = atoi(a[i1arg + 1]);
1408 const TopoDS_Shape& s = GetShape(is,Tpar.TS()); if (s.IsNull()) return 0;
1409 TopOpeBRepDS_ListOfInterference& li = BDS.ChangeShapeInterferences(is);
1410 Standard_Integer i=0; TopOpeBRepDS_ListIteratorOfListOfInterference it(li);
1413 it.Value()->Dump(cout,"\n--> remove ","\n");
1419 else if ( Tpar.isgeom() ) {
1420 ig = atoi(a[i1arg + 1]);
1425 //=======================================================================
1426 //function : DSCommands
1428 //=======================================================================
1429 void TestTopOpe::HDSCommands(Draw_Interpretor& theCommands)
1431 static Standard_Boolean done = Standard_False;
1433 done = Standard_True;
1434 PHDSD = (TestTopOpe_HDSDisplayer*) new (TestTopOpe_HDSDisplayer);
1435 POCD = (TestTopOpeDraw_Displayer*) new (TestTopOpeDraw_Displayer);
1437 const char* g = "Topological operation data structure commands";
1438 theCommands.Add("tseei","no args to get help",__FILE__,tseei,g);
1439 theCommands.Add("tsee","no args to get help ",__FILE__,tsee,g);
1440 theCommands.Add("tki","no args to get help ",__FILE__,tki,g);
1441 theCommands.Add("tkig","no args to get help ",__FILE__,tki,g);
1442 theCommands.Add("tkis","no args to get help ",__FILE__,tki,g);
1443 theCommands.Add("tds","-h to get help ",__FILE__,tds,g);
1444 theCommands.Add("tppe","tppe p/v <ip> e <ie>",__FILE__,TPPE);
1445 theCommands.Add("topochk","check current DS (loaded by CurrentDS()",__FILE__,topochk,g);
1446 theCommands.Add("tcx","dump connexity information",__FILE__,tcx,g);
1447 theCommands.Add("tdsri","remove interference : tdsri type itype iinterf",__FILE__,tdsri,g);