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 TestTopOpe_HDSDisplayer* PHDSD = NULL;
118 static 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 = Draw::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);
325 //-----------------------------------------------------------------------
327 //-----------------------------------------------------------------------
328 static Standard_Integer SeeSectionEdge(const Standard_Integer ISE)
330 if ( !PHDSD || !POCD ) return 0;
332 Standard_Integer nse = PHDSD->CurrentBDS().NbSectionEdges();
333 if ( ISE < 1 || ISE > nse ) return 0;
334 const TopoDS_Shape& SE = PHDSD->CurrentBDS().SectionEdge(ISE);
335 if (SE.IsNull()) return 0;
337 TCollection_AsciiString namedbrep; PHDSD->SectionEdgeName(ISE,SE,namedbrep);
338 TCollection_AsciiString namedisp; PHDSD->SectionEdgeDisplayName(ISE,SE,namedisp);
339 POCD->DisplayGeometry(Standard_True);
340 POCD->DisplayShape(namedbrep,namedisp,SE);
344 //-----------------------------------------------------------------------
346 //-----------------------------------------------------------------------
347 Standard_Integer SeeShapeIS(const Standard_Integer I,const TopoDS_Shape& S)
349 if ( !PHDSD || !POCD) return 0;
351 if (S.IsNull()) return 0;
352 TCollection_AsciiString namedbrep; PHDSD->ShapeName(I,S,namedbrep);
353 TCollection_AsciiString namedisp = namedbrep;
354 // NameDisplay = *name/name* if S subshape of shape1/shape2
355 TCollection_AsciiString ast = "*";
356 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
357 // if the Shape was removed from the DS, "*" is replaced by "~"
360 Standard_Boolean of1 = PHDSD->SubShape(S,1);if(of1) namedisp = ast+namedisp;
361 Standard_Boolean of2 = PHDSD->SubShape(S,2);if(of2) namedisp = namedisp+ast;
362 if (SelectRankShape == 1 && !of1) return 0;
363 if (SelectRankShape == 2 && !of2) return 0;
365 if (S.ShapeType()==TopAbs_EDGE) POCD->DisplayGeometry(Standard_True);
366 else POCD->DisplayGeometry(DisOri);
367 if((S.ShapeType()==TopAbs_VERTEX) && TolFlag) {
368 const TopoDS_Vertex& V = TopoDS::Vertex(S);
369 Standard_Real Tol = BRep_Tool::Tolerance(V);
372 POCD->DisplayShape(namedbrep,namedisp,S);
378 //-----------------------------------------------------------------------
380 //-----------------------------------------------------------------------
381 static Standard_Integer SeeShape(TCollection_AsciiString namedbrep)
383 if ( !PHDSD || !POCD ) return 0;
385 const char* pname = (const char *)namedbrep.ToCString();
386 TopoDS_Shape S = DBRep::Get(pname);
387 if ( S.IsNull() ) return 0;
388 TCollection_AsciiString namedisp;
389 PHDSD->ShapeDisplayName(namedbrep,S,namedisp);
390 POCD->DisplayShape(namedbrep,namedisp,S);
394 //-----------------------------------------------------------------------
396 //-----------------------------------------------------------------------
397 static Standard_Integer SeePoint(const Standard_Integer I)
399 if ( !PHDSD ) return 0;
401 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
402 if (I < 1 || I > BDS.NbPoints()) return 0;
404 TopOpeBRepDS_PointExplorer pex(BDS);
405 Standard_Boolean isp = pex.IsPoint(I);
408 const TopOpeBRepDS_Point& P = BDS.Point(I);
409 TopOpeBRepDS_Kind K = TopOpeBRepDS_POINT;
410 TCollection_AsciiString namedbrep; TestTopOpeDraw_TTOT::GeometryName(I,K,namedbrep);
411 TCollection_AsciiString namedisp; PHDSD->GeometryDisplayName(I,K,namedisp);
412 Draw_ColorKind namecolor = TestTopOpeDraw_TTOT::GeometryColor(K);
413 SetPoint(namedbrep,namedisp,namecolor,P);
417 //-----------------------------------------------------------------------
419 //-----------------------------------------------------------------------
420 static Standard_Integer SeeCurve(const Standard_Integer I)
422 if ( !PHDSD ) return 0;
424 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
425 if (I < 1 || I > BDS.NbCurves()) return 0;
427 TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep);
428 Standard_Boolean isc = cex.IsCurve(I);
431 const TopOpeBRepDS_Curve& C = BDS.Curve(I);
432 TopOpeBRepDS_Kind K = TopOpeBRepDS_CURVE;
433 TCollection_AsciiString namedbrep; TestTopOpeDraw_TTOT::GeometryName(I,K,namedbrep);
434 TCollection_AsciiString namedisp; PHDSD->GeometryDisplayName(I,K,namedisp);
435 Draw_ColorKind namecolor = TestTopOpeDraw_TTOT::GeometryColor(K);
436 SetCurve(namedbrep,namedisp,namecolor,C,I);
441 //-----------------------------------------------------------------------
443 //-----------------------------------------------------------------------
444 Standard_Integer SeeSurface(const Standard_Integer I) // NYI
446 if ( !PHDSD ) return 0;
448 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
449 if (I < 1 || I > BDS.NbSurfaces()) return 0;
453 //-----------------------------------------------------------------------
455 //-----------------------------------------------------------------------
456 static Standard_Integer SeeEdgeCurve(const Standard_Integer IE,const TopoDS_Shape& SE)
458 if ( !POCD ) return 0;
460 if (SE.IsNull()) return 0;
461 const TopoDS_Edge& E = TopoDS::Edge(SE);
462 TopLoc_Location L;Standard_Real f,l;Handle(Geom_Curve) GC=BRep_Tool::Curve(E,L,f,l);
463 TCollection_AsciiString namedbrep="E";TestTopOpeDraw_TTOT::CatCurveName(IE,namedbrep);
464 TCollection_AsciiString namedisp="E";TestTopOpeDraw_TTOT::CatCurveDisplayName(IE,GC,namedisp);
465 POCD->DisplayGeometry(Standard_True);
466 POCD->DisplayShape(namedbrep,namedisp,SE);
470 //-----------------------------------------------------------------------
472 //-----------------------------------------------------------------------
473 static Standard_Integer SeeGeometry(const Standard_Integer IG,const TopOpeBRepDS_Kind TK)
475 if (TK == TopOpeBRepDS_POINT) return SeePoint(IG);
476 else if (TK == TopOpeBRepDS_CURVE) return SeeCurve(IG);
477 else if (TK == TopOpeBRepDS_SURFACE) return SeeSurface(IG);
481 //-----------------------------------------------------------------------
483 //-----------------------------------------------------------------------
484 static Standard_Integer SeeGeometry(const TopOpeBRepDS_Kind TK)
486 if ( !PHDSD ) return 0;
488 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
490 if (TK == TopOpeBRepDS_POINT) {
491 TopOpeBRepDS_PointExplorer pex(BDS,GFindKeep);
492 for (; pex.More(); pex.Next()) {
493 Standard_Integer ig = pex.Index();
497 else if (TK == TopOpeBRepDS_CURVE) {
498 TopOpeBRepDS_CurveExplorer cex(BDS,GFindKeep);
499 for (; cex.More(); cex.Next()) {
500 Standard_Integer ig = cex.Index();
504 else if (TK == TopOpeBRepDS_SURFACE) { //NYI
509 //-----------------------------------------------------------------------
511 //-----------------------------------------------------------------------
512 Standard_Integer TOPOPE_SeeShape(char* name)
514 TCollection_AsciiString asc = name;
515 Standard_Integer res = SeeShape(asc);
519 //-----------------------------------------------------------------------
520 // suppressarg : remove a[d],modify na--
521 //-----------------------------------------------------------------------
522 void suppressarg(Standard_Integer& na,const char** a,const Standard_Integer d)
524 for(Standard_Integer i=d;i<na;i++) {
531 //-----------------------------------------------------------------------
532 // suppressargs : remove a[*] from <f> to <l>,modify na = na - (l - f)
533 //-----------------------------------------------------------------------
534 Standard_EXPORT void suppressargs(Standard_Integer& na,const char** a,const Standard_Integer f,const Standard_Integer l)
539 for(Standard_Integer i=0;i<na-l;i++) {
546 //-----------------------------------------------------------------------
548 //-----------------------------------------------------------------------
549 static void tsee_flags(Standard_Integer& na,const char** a) {
550 GFindKeep = Standard_False;
551 PrintDistancePP = Standard_False;
554 for (Standard_Integer ia = 1; ia < na; ia++) {
555 if (!strcasecmp(a[ia],"-k")) {
556 suppressarg(na,a,ia);
557 GFindKeep = Standard_True;
559 else if (!strcasecmp(a[ia],"-d")) {
560 // tsee -d p 4 7 : display p_4,p_7 + tds p 4 7 + calculate distance (p_4,p_7)
561 suppressarg(na,a,ia);
562 PrintDistancePP = Standard_True;
564 else if (!strcasecmp(a[ia],"-1")) {
565 // tsee -1 s 4 : display s_4 <=> s_4 is subshape of the 1st argument
566 suppressarg(na,a,ia);
569 else if (!strcasecmp(a[ia],"-2")) {
570 // tsee -2 s 4 : display s_4 <=> s_4 is subshape of the 2nd argument
571 suppressarg(na,a,ia);
574 else if (!strcasecmp(a[ia],"-p") && (ia < na-1)) {
575 suppressargs(na,a,ia,ia+1);
576 Standard_Real t = Draw::Atof(a[ia+1]);
577 if (t >= 0. && t <= 1.) {
578 OldParFlag = ParFlag; ParFlag = t;
584 void OthersCommands_help(const char* CommandName,const char* syntaxe = "");
585 //-----------------------------------------------------------------------
587 //-----------------------------------------------------------------------
588 static void tsee_help(const char* CommandName, Draw_Interpretor& di)
591 di<<"tsee : Draw entities of data structure (DS) loaded by TestTopOpe::CurrentDS()."<<"\n";
592 di<<"DS entities are shapes and geometries accessed by a <type> and an <index>."<<"\n";
593 di<<"basic usage :"<<"\n";
594 di<<" tsee <type> <index1 index2 ...>"<<"\n";
595 di<<"<type> = so sh f w e v s for solid/shell/face/wire/edge/vertex/shape"<<"\n";
596 di<<" su cu p for surface/curve/point (N.B : su is NYI)"<<"\n";
597 di<<"<index> = integer"<<"\n";
598 di<<"example : 'tsee e 3' will draw the edge of index 3"<<"\n";
599 di<<" 'tsee e 3 6' will draw the edges of index 3 and 6"<<"\n";
600 di<<" 'tsee e' will draw all the edges."<<"\n";
602 di<<"Index values of DS entities may be given by the 'tds' command which prints"<<"\n";
603 di<<"the content of the DS for each shape and geometry type."<<"\n";
604 di<<"Entities are drawn with a specific color according to their type."<<"\n";
606 di<<"Naming : "<<"\n";
607 di<<"'tsee <t> <i>' creates the drawable object named <t>_<i>."<<"\n";
608 di<<"This name is displayed near the entity in one if the forms : "<<"\n";
609 di<<" *<t>_<i> meaning entity belongs to the first shape of current operation."<<"\n";
610 di<<" <t>_<i>* meaning entity belongs to the second shape of current operation."<<"\n";
612 di<<"Same Domain shapes : "<<"\n";
613 di<<"'tsee <type> sd' to display all shapes of <type> having same domain data."<<"\n";
614 di<<"example : 'tsee e sd' to display all edges sharing a 1d geometric domain"<<"\n";
615 di<<" with other edges."<<"\n";
617 di<<"Optional flags :"<<"\n";
618 OthersCommands_help(CommandName);
619 di<<"Other types :"<<"\n";
620 di<<"'tsee fev' : displays all faces,then edges,then vertices."<<"\n";
621 di<<"'tsee es <i>' displays edge described as section edge <i>."<<"\n";
622 di<<" The name of a section edge likes t_i<j>,where :"<<"\n";
623 di<<" - i is the edge index in the set of section edge,"<<"\n";
624 di<<" - j is edge index in the DS (as any edge)."<<"\n";
628 static void tseei_help(Draw_Interpretor& di)
631 di<<"tseei : Draws entities of data structure (DS) loaded by TestTopOpe::CurrentDS()."<<"\n";
632 di<<"Draws the objects appearing in interferences DS objects."<<"\n";
633 di<<"See command 'tsee' for discussion about DS objects."<<"\n";
637 static void tki_help(Draw_Interpretor& di)
640 di<<"tki,tkig,tkis : Groups interferences of DS objects"<<"\n";
641 di<<" by geometry (g),or support (s),and index."<<"\n";
642 di<<"See command 'tsee' for discussion about DS objects."<<"\n";
643 di<<"(Test of class TopOpeBRepDS_TKI)"<<"\n";
647 static void tds_help(Draw_Interpretor& di)
650 di<<"tds : dump current DS (loaded by CurrentDS())"<<"\n";
651 di<<"basic usage : tds <-arg> type <index1 index2 ...>"<<"\n";
653 di<<"Description of curve geometry (type = c) : <-arg> = -t -k -s -l"<<"\n";
654 di<<"\t-k : print only the curve with keep = Standard_True"<<"\n";
655 di<<"\t-l : (long) print all poles and knots for BSplines curves"<<"\n";
656 di<<"\t-s : (short) print only 4 poles and 4 knots for BSplines curves"<<"\n";
657 di<<"on shapes (type = s|so|sh|f|w|e|v) : <-arg> = -ssi"<<"\n";
658 di<<"\t-ssi : print only ShapeShapeInterferences"<<"\n";
660 di<<"See command 'tsee' for discussion about type and <index1 index2 ...>."<<"\n";
664 typedef Standard_Integer (*tf_SeeShape)(const Standard_Integer I,const TopoDS_Shape& S);
665 extern void OthersCommands_flags(Standard_Integer& na,const char** a,TestTopOpeDraw_Displayer& TD);
666 void COUTNOHDS(Draw_Interpretor& di) {di<<"no current HDS"<<"\n";}
667 Standard_Integer tsee_SeeShapefunc(Draw_Interpretor& di,Standard_Integer na_in,const char** a,tf_SeeShape SeeShapefunc)
669 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
674 Standard_Integer na = na_in;
675 if ((PHDSD == NULL) || (POCD == NULL)) return 0;
677 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
678 if (HDS.IsNull()) { COUTNOHDS(di); return 0; }
679 if (na < 2) return 1;
680 const TopOpeBRepDS_DataStructure& BDS = PHDSD->CurrentBDS();
682 POCD->InitDisplayer();
683 TolFlag = Standard_False;
685 OthersCommands_flags(na,a,*POCD);
686 TolFlag = POCD->TolIs();
687 DisOri = POCD->DisplayGeometry();
689 Standard_Integer i1arg = 1;
690 TSEEpar Tpar(a[i1arg]);
692 // Standard_Integer ia,is,ig;
693 Standard_Integer ia,is;
695 if ( PrintDistancePP ) {
697 if (na == 4) { // tsee p 3 4
698 if (E1.Set(na,a,i1arg+0,i1arg+1)) return 1;
699 if (E2.Set(na,a,i1arg+0,i1arg+2)) return 1;
701 else if (na == 5) { // tsee p 3 v 4
702 if (E1.Set(na,a,i1arg+0,i1arg+1)) return 1;
703 if (E2.Set(na,a,i1arg+2,i1arg+3)) return 1;
705 if (!E1.myEOK || !E2.myEOK) return 1;
709 di<<"Distance "<<E1.myEnamedbrep.ToCString()<<" "<<E2.myEnamedbrep.ToCString()<<" : "<<E1.Pnt().Distance(E2.Pnt())<<"\n";
713 else if ( Tpar.isshap() ) {
714 // na == 2 : display all DS shapes of type TS
715 // na > 2 : display DS shapes of type TS of index Draw::Atoi(a[2]..a[narg-1])
717 TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);
718 for(;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current());
721 if ( !strcmp(a[i1arg+1],"sd") ) { // shapes HasSameDomain of type TS
722 TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);
723 for (;x.More();x.Next()) {
724 Standard_Boolean isSsd = HDS->HasSameDomain(x.Current());
725 if (isSsd ) (*SeeShapefunc)(x.Index(),x.Current());
728 else if (Tpar.isshap() && (Tpar.TS() == TopAbs_EDGE) && (na>=2) && POCD->ParIs()) {
729 // see edges [4..na[ with of the name in t in [0..1] / range
731 TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False);
732 for (;x.More();x.Next()) (*SeeShapefunc)(x.Index(),x.Current());
735 for (ia = i1arg+1; ia < na; ia++) {
736 is = Draw::Atoi(a[ia]);
737 (*SeeShapefunc)(is,GetShape(is,Tpar.TS()));
740 ParFlag = OldParFlag;
743 for (ia = i1arg+1; ia < na; ia++) {
744 is = Draw::Atoi(a[ia]);
745 (*SeeShapefunc)(is,GetShape(is,Tpar.TS()));
751 else if ( Tpar.isgeom() ) {
752 // na == 2 : display all DS geometries of type TK
753 // na > 2 : display DS geometries of type TK index Draw::Atoi(a[2])..a[narg-1])
754 if (na == 2 ) SeeGeometry(Tpar.TK());
755 else for (ia = i1arg+1; ia < na; ia++) SeeGeometry(Standard_Integer(Draw::Atoi(a[ia])),Tpar.TK());
758 else if ( Tpar.isafev() ) {
759 // faces then edges then vertices
760 TopOpeBRepDS_Explorer x;
761 for (x.Init(HDS,TopAbs_FACE,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
762 for (x.Init(HDS,TopAbs_EDGE,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
763 for (x.Init(HDS,TopAbs_VERTEX,Standard_False);x.More();x.Next()) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
766 else if ( Tpar.isedcu() ) {
767 // na == 2 : display curves of all DS edges
768 // na > 2 : display curve of DS edges index Draw::Atoi(a[2])..a[narg-1])
770 TopOpeBRepDS_Explorer x(HDS,TopAbs_EDGE,Standard_False);
771 for (;x.More();x.Next()) SeeEdgeCurve(x.Index(),x.Edge());
774 for (ia = i1arg+1; ia < na; ia++) {
775 is = Draw::Atoi(a[ia]);
776 SeeEdgeCurve(is,GetShape(is,TopAbs_EDGE));
781 else if ( Tpar.issect() ) { // na=2 all section edges,na>2 section edges (a[2]..a[na-1])
782 Standard_Integer ise,nse = BDS.NbSectionEdges();
783 if (na == 2) for (ise = 1; ise<=nse; ise++) SeeSectionEdge(ise);
784 else for (ia = i1arg+1; ia<na; ia++) SeeSectionEdge(Draw::Atoi(a[ia]));
787 else if (Tpar.isdege()) {
788 TopOpeBRepDS_Explorer x;
789 for (x.Init(HDS,TopAbs_EDGE);x.More();x.Next()) {
790 if (BRep_Tool::Degenerated(x.Edge())) (*SeeShapefunc)(x.Index(),GetShape(x.Index()));
795 } // tsee_SeeShapefunc
797 //-----------------------------------------------------------------------
799 //-----------------------------------------------------------------------
800 Standard_Integer tsee(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
802 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
806 tf_SeeShape ssf = (tf_SeeShape)SeeShapeIS;
807 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
811 //-----------------------------------------------------------------------
813 //-----------------------------------------------------------------------
814 Standard_Integer SeeAnyKI(const TopOpeBRepDS_Kind TK,const Standard_Integer I) {
815 TopAbs_ShapeEnum TS = TopAbs_COMPOUND;
816 Standard_Boolean isshape,isgeome; isshape = isgeome = Standard_False;
817 isshape = TopOpeBRepDS::IsTopology(TK);
818 if (isshape) TS = TopOpeBRepDS::KindToShape(TK);
819 else isgeome = TopOpeBRepDS::IsGeometry(TK);
820 if (isshape) SeeShapeIS(I,GetShape(I,TS));
821 else if (isgeome) SeeGeometry(I,TK);
825 //-----------------------------------------------------------------------
827 //-----------------------------------------------------------------------
828 (TColStd_ListOfInteger& LOK,TColStd_ListOfInteger& LOI,
829 const TopOpeBRepDS_Kind K,const Standard_Integer I)
832 Standard_Boolean isshape,isgeome; isshape = isgeome = Standard_False;
833 isshape = TopOpeBRepDS::IsTopology(K);
834 if (isshape) TS = TopOpeBRepDS::KindToShape(K);
835 else isgeome = TopOpeBRepDS::IsGeometry(K);
837 if (LOK.IsEmpty() && LOI.IsEmpty()) {
838 LOK.Append((Standard_Integer)K); LOI.Append(I);
842 // to sort, it is considered that :
843 // POINT == VERTEX,CURVE == EDGE,SURFACE == FACE
846 TopAbs_ShapeEnum SKtri;
848 TopAbs_ShapeEnum SKtri=TopAbs_COMPOUND;
850 if (isshape) SKtri = TopOpeBRepDS::KindToShape(K);
852 if (K == TopOpeBRepDS_POINT) SKtri = TopAbs_VERTEX;
853 else if (K == TopOpeBRepDS_CURVE) SKtri = TopAbs_EDGE;
854 else if (K == TopOpeBRepDS_SURFACE) SKtri = TopAbs_FACE;
858 TColStd_ListIteratorOfListOfInteger ITLOK(LOK);
859 TColStd_ListIteratorOfListOfInteger ITLOI(LOI);
860 Standard_Boolean equa = Standard_False;
861 for (; ITLOK.More(),ITLOI.More(); ITLOK.Next(),ITLOI.Next()) {
863 Standard_Integer ifK = ITLOK.Value() ;
864 TopOpeBRepDS_Kind fK = (TopOpeBRepDS_Kind) ifK ;
865 TopAbs_ShapeEnum fSK = TopOpeBRepDS::KindToShape(fK);
866 // TopOpeBRepDS_Kind fK = (TopOpeBRepDS_Kind)ITLOK.Value(); TopAbs_ShapeEnum fSK = TopOpeBRepDS::KindToShape(fK);
867 Standard_Integer fI = ITLOI.Value();
868 if (SKtri == fSK && I == fI) {
869 equa = Standard_True;
873 LOK.InsertBefore((Standard_Integer)K,ITLOK);
874 LOI.InsertBefore(I,ITLOI);
878 if ( !ITLOK.More() && !equa) {
879 LOK.Append((Standard_Integer)K);
884 //-----------------------------------------------------------------------
886 //-----------------------------------------------------------------------
887 Standard_Integer SeeShapeISI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di)
889 if ( !PHDSD ) return 0;
890 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
891 if (S.IsNull()) return 0;
894 TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType());
895 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
896 const TopOpeBRepDS_ListOfInterference& LOI = BDS.ShapeInterferences(S);
897 TopOpeBRepDS_ListIteratorOfListOfInterference ITLOI(LOI);
898 TColStd_ListOfInteger LOKK,LOII;
900 for (;ITLOI.More();ITLOI.Next()) {
901 const Handle(TopOpeBRepDS_Interference)& HI = ITLOI.Value();
902 const TopOpeBRepDS_Transition& T = HI->Transition();
904 TopAbs_ShapeEnum sb = T.ShapeBefore();TopOpeBRepDS_Kind sbk = TopOpeBRepDS::ShapeToKind(sb);
905 Standard_Integer sbi = T.IndexBefore();
906 TopAbs_ShapeEnum sa = T.ShapeAfter();TopOpeBRepDS_Kind sak = TopOpeBRepDS::ShapeToKind(sa);
907 Standard_Integer sai = T.IndexAfter();
908 TopOpeBRepDS_Kind gk,sk; Standard_Integer gi,si; HI->GKGSKS(gk,gi,sk,si);
910 AddShapeKI(LOKK,LOII,sbk,sbi);
911 AddShapeKI(LOKK,LOII,sak,sai);
912 AddShapeKI(LOKK,LOII,gk,gi);
913 AddShapeKI(LOKK,LOII,sk,si);
916 TColStd_ListIteratorOfListOfInteger ITLOKK,ITLOII;
918 ITLOKK.Initialize(LOKK); ITLOII.Initialize(LOII);
919 Standard_Boolean ya = ITLOKK.More();
920 TopOpeBRepDS::Print(SK,I,cout,""," : ");
921 for(; ITLOKK.More(),ITLOII.More(); ITLOKK.Next(),ITLOII.Next()) {
923 Standard_Integer ikk = ITLOKK.Value() ;
924 TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind) ikk ;
925 Standard_Integer ii = ITLOII.Value();
926 // TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind)ITLOKK.Value(); Standard_Integer ii = ITLOII.Value();
927 TopOpeBRepDS::Print(kk,ii,cout,""," ");
929 if (ya) di<<"\n"; else di<<"no shape interference"<<"\n";
931 ITLOKK.Initialize(LOKK); ITLOII.Initialize(LOII);
932 for(; ITLOKK.More(),ITLOII.More(); ITLOKK.Next(),ITLOII.Next()) {
934 Standard_Integer ikk =ITLOKK.Value() ;
935 TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind) ikk ;
936 Standard_Integer ii = ITLOII.Value();
937 // TopOpeBRepDS_Kind kk = (TopOpeBRepDS_Kind)ITLOKK.Value(); Standard_Integer ii = ITLOII.Value();
945 //-----------------------------------------------------------------------
947 //-----------------------------------------------------------------------
948 Standard_Integer SeeShapeTKIG(const Standard_Integer I,const TopoDS_Shape& S)
950 if ( !PHDSD ) return 0;
951 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
952 if (S.IsNull()) return 0;
955 TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType());
956 const TopOpeBRepDS_ListOfInterference& LOI = HDS->DS().ShapeInterferences(S);
957 TopOpeBRepDS_TKI tki;
958 TCollection_AsciiString s1,s2;
961 tki.FillOnGeometry(LOI);
962 s1=TopOpeBRepDS::SPrint(SK,I,""," by G : \n");
963 tki.Init();if (tki.More()) s2="\n";else s2="";
964 tki.DumpTKIIterator(s1,s2);
969 //-----------------------------------------------------------------------
971 //-----------------------------------------------------------------------
972 Standard_Integer SeeShapeTKIS(const Standard_Integer I,const TopoDS_Shape& S)
974 if ( !PHDSD ) return 0;
975 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
976 if (S.IsNull()) return 0;
979 TopOpeBRepDS_Kind SK = TopOpeBRepDS::ShapeToKind(S.ShapeType());
980 const TopOpeBRepDS_ListOfInterference& LOI = HDS->DS().ShapeInterferences(S);
981 TopOpeBRepDS_TKI tki;
982 TCollection_AsciiString s1,s2;
985 tki.FillOnSupport(LOI);
986 s1=TopOpeBRepDS::SPrint(SK,I,""," by S : \n");
987 tki.Init();if (tki.More()) s2="\n";else s2="";
988 tki.DumpTKIIterator(s1,s2);
993 //-----------------------------------------------------------------------
995 //-----------------------------------------------------------------------
996 Standard_Integer SeeShapeTKI(const Standard_Integer I,const TopoDS_Shape& S,Draw_Interpretor& di)
1004 //-----------------------------------------------------------------------
1006 //-----------------------------------------------------------------------
1007 Standard_Integer tseei(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1009 if (na_in == 1) { tseei_help(di); return 0; }
1010 tf_SeeShape ssf = (tf_SeeShape)SeeShapeISI;
1011 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
1015 //-----------------------------------------------------------------------
1017 //-----------------------------------------------------------------------
1018 Standard_Integer tki(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1020 if (na_in == 1) { tki_help(di); return 0; }
1022 tf_SeeShape ssf = NULL;
1023 if ( !strcasecmp(a[0],"tki") ) ssf = (tf_SeeShape)SeeShapeTKI;
1024 else if ( !strcasecmp(a[0],"tkig") ) ssf = (tf_SeeShape)SeeShapeTKIG;
1025 else if ( !strcasecmp(a[0],"tkis") ) ssf = (tf_SeeShape)SeeShapeTKIS;
1026 if (ssf == NULL) return 0;
1028 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,ssf);
1032 //-----------------------------------------------------------------------
1034 // 1 = kind of DS object to dump = [s] [so sh f w e v] [se] [su c p]
1035 // 2,3 ... = [i1,i2 ...] = indices of DS object to see
1036 //-----------------------------------------------------------------------
1037 Standard_Integer tds(Draw_Interpretor& di,Standard_Integer na,const char** a)
1039 Standard_Boolean TDSkeep,TDScompact; TDSkeep = TDScompact = Standard_False;
1040 TopOpeBRepDS_GLOBALHDSinterfselector = 0;
1042 Standard_Integer ia ;
1043 for ( ia = 0; ia < na; ia++) {
1044 if (!strcasecmp(a[ia],"-ssi")) {
1045 TopOpeBRepDS_GLOBALHDSinterfselector = 1;
1046 suppressarg(na,a,ia);
1049 else if (!strncmp(a[ia],"-",1)) {
1050 TCollection_AsciiString as = a[ia];
1052 for(Standard_Integer i = 1;i <= as.Length(); i++) {
1053 if (as.Value(i) == 'k') TDSkeep = Standard_True;
1054 else if(as.Value(i) == 'l') TDScompact = Standard_False;
1055 else if(as.Value(i) == 's') TDScompact = Standard_True;
1056 else if(as.Value(i) == 'h') { tds_help(di); return 0; }
1058 suppressarg(na,a,ia);
1062 if (PHDSD == NULL) return 0;
1063 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1064 if (HDS.IsNull()) {COUTNOHDS(di);return 0;}
1065 PHDSD->CurrentBDS();
1067 TopOpeBRepDS_Dumper Dumper(HDS);
1068 if ( na == 1 ) { Dumper.Dump(cout,TDSkeep,TDScompact); return 0; }
1071 Standard_Integer ids;
1074 if (Tpar.isshap()) {
1075 if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),cout);
1076 else Dumper.DumpTopology(cout);
1078 else if (Tpar.isgeom()) {
1079 Dumper.DumpGeometry(Tpar.TK(),cout,TDSkeep,TDScompact);
1081 else if (Tpar.issect()) {
1082 Dumper.DumpSectionEdge(Tpar.TK(),cout);
1084 else if (Tpar.isafev()) {
1085 TopOpeBRepDS_Explorer x;
1086 for (x.Init(HDS,TopAbs_FACE,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1087 for (x.Init(HDS,TopAbs_EDGE,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1088 for (x.Init(HDS,TopAbs_VERTEX,TDSkeep);x.More();x.Next()) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1091 else if (Tpar.isdege()) {
1092 TopOpeBRepDS_Explorer x;
1093 for (x.Init(HDS,TopAbs_EDGE,TDSkeep);x.More();x.Next()) {
1094 if (BRep_Tool::Degenerated(x.Edge())) Dumper.DumpTopology(x.Type(),x.Index(),cout);
1100 // nna > 2 : dump DS entities of type TK index Draw::Atoi(a[2])..a[narg-1])
1101 for (ia = 2; ia < na; ia++) {
1103 if ( !strcmp(a[ia],"sd") ) { // dump all shapes HasSameDomain of type TS
1104 for (TopOpeBRepDS_Explorer x(HDS,Tpar.TS(),Standard_False);x.More();x.Next()) {
1105 Standard_Boolean isSsd = HDS->HasSameDomain(x.Current());
1106 if (isSsd ) Dumper.DumpTopology(Tpar.TK(),x.Index(),cout);
1110 ids = Draw::Atoi(a[ia]);
1111 if ( Tpar.isshap() ) {
1112 if (Tpar.TS() != TopAbs_SHAPE) Dumper.DumpTopology(Tpar.TK(),ids,cout);
1114 TopAbs_ShapeEnum t = HDS->Shape(ids,SFindKeep).ShapeType();
1115 TopOpeBRepDS_Kind k = TopOpeBRepDS::ShapeToKind(t);
1116 Dumper.DumpTopology(k,ids,cout);
1119 else if ( Tpar.isgeom() ) {
1120 Dumper.DumpGeometry(Tpar.TK(),ids,cout,TDSkeep,TDScompact);
1122 else if ( Tpar.issect() ) {
1123 Dumper.DumpSectionEdge(TopOpeBRepDS_EDGE,ids,cout);
1131 Standard_Integer TPPE(Draw_Interpretor& di,Standard_Integer na,const char** a)
1133 if (PHDSD == NULL) return 0;
1134 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1135 if ( HDS.IsNull() ) { COUTNOHDS(di); return 0; }
1137 if (na != 5) return 1;
1138 Standard_Boolean ok = Standard_True;
1143 Standard_Integer ip = Draw::Atoi(a[2]);
1144 Standard_Integer ie = Draw::Atoi(a[4]);
1145 ok = ok && (ip >= 1); ok = ok && (ie >= 1);
1147 di <<" bad data"<<"\n";
1151 ok = Standard_False;
1152 if (!strcmp("p",a[1])){
1154 ok = ok && (ip <= HDS->NbPoints());
1155 if (ok) pds = HDS->Point(ip).Point();
1156 if (!ok) di<<" geometry "<<ip<<" is not a point"<<"\n";
1158 if (!strcmp("v",a[1])){
1160 ok = ok && (ip <= HDS->NbShapes());
1162 TopoDS_Shape sh = HDS->Shape(ip,SFindKeep);
1163 ok = ok && (sh.ShapeType() == TopAbs_VERTEX);
1164 if (ok) pds =BRep_Tool::Pnt(TopoDS::Vertex(sh));
1166 if (!ok) di<<" shape "<<ip<<" is not a vertex"<<"\n";
1168 if (!strcmp("e",a[3])){
1169 ok = ok && (ie <= HDS->NbShapes());
1171 TopoDS_Shape sh = HDS->Shape(ie,SFindKeep);
1172 ok = ok && (sh.ShapeType() == TopAbs_EDGE);
1173 if (ok) ed = TopoDS::Edge(sh);
1175 if (!ok) di<<" shape "<<ie<<" is not an edge"<<"\n";
1177 } else ok = Standard_False;
1179 Standard_Real dmin=0;
1183 Handle(Geom_Curve) cu = BRep_Tool::Curve(ed,f,l);
1184 GeomAPI_ProjectPointOnCurve ponc(pds,cu,f,l);
1185 ok = ponc.NbPoints() >= 1;
1188 dmin = ponc.LowerDistance();
1189 Standard_Real par = ponc.LowerDistanceParameter();
1190 BRepAdaptor_Curve bc(ed);
1191 pproj = bc.Value(par);
1196 TCollection_AsciiString pp("p");
1197 pp.AssignCat(ip); pp.AssignCat("e"); pp.AssignCat(ie);
1198 char* ppp = (char *)pp.ToCString();
1199 DrawTrSurf::Set(ppp,pproj);
1200 di<<"dist point "<<ip<<" on edge "<<ie<<" = "<<dmin<<"\n";
1201 } else di<<"projection failed"<<"\n";
1206 void FUN_ChkIntgInterf(Draw_Interpretor& di) //***Check Integrity Interference
1208 if ( PHDSD == NULL ) return;
1209 PHDSD->CurrentHDS()->ChkIntg();
1210 di<<"Check interference integrity completed"<<"\n";
1213 void FUN_ChkIntgSamDomain(Draw_Interpretor& di) //***Check Integrity SameDomain
1215 if ( PHDSD == NULL ) return;
1216 TopOpeBRepDS_Check C(PHDSD->CurrentHDS());
1217 if(C.ChkIntgSamDom())
1218 di<<"Check SameDomain integrity completed"<<"\n";
1221 void FUN_ChkIntg(Draw_Interpretor& di) //***Check Integrity
1223 if ( PHDSD == NULL ) return;
1224 FUN_ChkIntgInterf(di);
1225 FUN_ChkIntgSamDomain(di);
1228 void FUN_ChkVertex(Draw_Interpretor& di) //***Check Vertex SameDomain
1230 if ( PHDSD == NULL ) return;
1231 TopOpeBRepDS_Check C(PHDSD->CurrentHDS());
1232 if(C.OneVertexOnPnt())
1233 di<<"Check Structure Vertex SameDomain Complete"<<"\n";
1236 //---------------------------------------------------------
1237 Standard_Integer topochk(Draw_Interpretor& di,Standard_Integer na,const char** a)
1239 if (strcmp(a[0],"topochk")) return 1;
1243 ::FUN_ChkVertex(di);
1245 else if(na > 2) return 1;
1246 else if(!strcmp (a[1],"-i")) ::FUN_ChkIntg(di);
1247 else if(!strncmp(a[1],"-i",2)) {
1248 if (!strcmp(a[1],"-ii")) ::FUN_ChkIntgInterf(di);
1249 else if(!strcmp(a[1],"-isd")) ::FUN_ChkIntgSamDomain(di);
1251 else if(!strcmp (a[1],"-s")) ::FUN_ChkVertex(di);
1253 di<<"option : -i = check DS full integrity"<<"\n";
1254 di<<"option : -ii = check only interferences"<<"\n";
1255 di<<"option : -isd = check only SameDomain data"<<"\n"<<"\n";
1256 di<<"option : -s = check only SameDomain data on vertex"<<"\n";
1262 //-----------------------------------------------------------------------
1264 //-----------------------------------------------------------------------
1265 Standard_Integer SeeShapeTCX(const Standard_Integer I,const TopoDS_Shape& S)
1267 if ( !PHDSD ) return 0;
1268 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1269 if (S.IsNull()) return 0;
1274 static void tcx_help(Draw_Interpretor& di)
1276 di<<"tcx : function not documented"<<"\n";
1279 //-----------------------------------------------------------------------
1281 //-----------------------------------------------------------------------
1282 Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1284 if (na_in == 1) { tcx_help(di); return 0; }
1285 Standard_Integer r = tsee_SeeShapefunc(di,na_in,a,SeeShapeTCX);
1290 //---------------------------------------------------------
1291 Standard_Integer tcx(Draw_Interpretor& di,Standard_Integer na,const char** a)
1293 if (PHDSD == NULL) return 0;
1294 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1295 if ( HDS.IsNull() ) { COUTNOHDS(di); return 0; }
1296 if (na == 1) FDSCNX_Dump(HDS);
1298 if (ISINTEGER(a[1])) FDSCNX_Dump(HDS,Draw::Atoi(a[1]));
1305 //-----------------------------------------------------------------------
1306 Standard_Integer tdsri(Draw_Interpretor& di,Standard_Integer na_in,const char** a)
1308 if (na_in == 1 || (na_in == 2 && !strcasecmp(a[1],"-h"))) {
1312 Standard_Integer na = na_in;
1313 if ((PHDSD == NULL) || (POCD == NULL)) return 0;
1314 const Handle(TopOpeBRepDS_HDataStructure)& HDS = PHDSD->CurrentHDS();
1315 if (HDS.IsNull()) { COUTNOHDS(di); return 0; }
1316 if (na < 5) return 1;
1317 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
1319 Standard_Integer i1arg = 1;
1320 TDSpar Tpar(a[i1arg]);
1322 if ( strcasecmp(a[i1arg + 2],"i") ) return 0;
1323 Standard_Integer ii = Draw::Atoi(a[i1arg + 3]);
1324 // Standard_Integer ia,is,ig;
1325 Standard_Integer is,ig;
1326 if ( Tpar.isshap() ) {
1327 is = Draw::Atoi(a[i1arg + 1]);
1328 const TopoDS_Shape& s = GetShape(is,Tpar.TS()); if (s.IsNull()) return 0;
1329 TopOpeBRepDS_ListOfInterference& li = BDS.ChangeShapeInterferences(is);
1330 Standard_Integer i=0; TopOpeBRepDS_ListIteratorOfListOfInterference it(li);
1333 it.Value()->Dump(cout,"\n--> remove ","\n");
1339 else if ( Tpar.isgeom() ) {
1340 ig = Draw::Atoi(a[i1arg + 1]);
1345 //=======================================================================
1346 //function : DSCommands
1348 //=======================================================================
1349 void TestTopOpe::HDSCommands(Draw_Interpretor& theCommands)
1351 static Standard_Boolean done = Standard_False;
1353 done = Standard_True;
1354 PHDSD = (TestTopOpe_HDSDisplayer*) new (TestTopOpe_HDSDisplayer);
1355 POCD = (TestTopOpeDraw_Displayer*) new (TestTopOpeDraw_Displayer);
1357 const char* g = "Topological operation data structure commands";
1358 theCommands.Add("tseei","no args to get help",__FILE__,tseei,g);
1359 theCommands.Add("tsee","no args to get help ",__FILE__,tsee,g);
1360 theCommands.Add("tki","no args to get help ",__FILE__,tki,g);
1361 theCommands.Add("tkig","no args to get help ",__FILE__,tki,g);
1362 theCommands.Add("tkis","no args to get help ",__FILE__,tki,g);
1363 theCommands.Add("tds","-h to get help ",__FILE__,tds,g);
1364 theCommands.Add("tppe","tppe p/v <ip> e <ie>",__FILE__,TPPE);
1365 theCommands.Add("topochk","check current DS (loaded by CurrentDS()",__FILE__,topochk,g);
1366 theCommands.Add("tcx","dump connexity information",__FILE__,tcx,g);
1367 theCommands.Add("tdsri","remove interference : tdsri type itype iinterf",__FILE__,tdsri,g);