// File: TestTopOpeDraw_OtherCommands.cxx // Created: Fri Feb 2 15:30:24 1996 // Author: Jean Yves LEBEY // #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_STRINGS_H # include #endif //----------------------------------------------------------------------- // 0 = testtopopedraw_cdinp // 1,2,3,4 = display point p of coords x y z //----------------------------------------------------------------------- Standard_Integer testtopopedraw_cdinp(Draw_Interpretor&,Standard_Integer na,const char** a) { if ( na < 5 ) return 0; TestTopOpeDraw_P3DDisplayer PD(a[1],atof(a[2]),atof(a[3]),atof(a[4])); return 0; } //----------------------------------------------------------------------- // DRAWsuppressarg : remove a[d], modify na-- //----------------------------------------------------------------------- Standard_EXPORT void DRAWsuppressarg(Standard_Integer& na,const char** a,const Standard_Integer d) { for(Standard_Integer i=d;i to , modify na = na - (l - f) //----------------------------------------------------------------------- Standard_EXPORT void DRAWsuppressargs(Standard_Integer& na,const char** a,const Standard_Integer f,const Standard_Integer l) { if(l == f) DRAWsuppressarg(na,a,l); if(l <= f) return; for(Standard_Integer i=0;i to display the name of an edge round a point of "< : on edge , diplay name at t in [0..1]"< : visualize face with isos"< : display name with color col (Draw_blanc, Draw_rouge, ...)"< #include #include #include #include #include #include #include #include #include #include #include #include #include #include class cvx2d { public: cvx2d(Draw_Interpretor& di) { clearall(); mypdi = &di; } const TopoDS_Face& face() const { return myface; } const TCollection_AsciiString& facename() const { return myfacename; } void erasevisible() { TColStd_ListIteratorOfListOfAsciiString i(myvis); Standard_Boolean ya = i.More(); TCollection_AsciiString str = "erase"; for (; i.More(); i.Next()) { const TCollection_AsciiString& s = i.Value(); str = str + " " + s; } if (ya) { TCollection_AsciiString str1 = "erase -mute;"; mypdi->Eval(str1.ToCString()); str = str + ";"; mypdi->Eval(str.ToCString()); } clearvisible(); } void addvisible(const TCollection_AsciiString& N) { myvis.Append(N); } void clearvisible() { myvis.Clear(); } const TopoDS_Edge& edge(const Standard_Integer ie) const { if ( ie >= 1 && ie <= mymapis.Extent()) { const TopoDS_Edge& E = TopoDS::Edge(mymapis.Find(ie)); return E; } return myemptyedge; } Standard_Integer nedge() const { return mymapis.Extent(); } void clearall() { clearvisible(); mymapve.Clear(); mymapsi.Clear(); mymapis.Clear(); mynemap = 0; myiemap = 1; myedgedisplayed = 0; myface.Nullify(); myfacename = ""; } void addedge(const TopoDS_Shape& E) { mynemap++; mymapsi.Bind(E,mynemap); mymapis.Bind(mynemap,E); } void initface(const TopoDS_Face& F,const TCollection_AsciiString& N) { clearall(); myface = F; myfacename = N; TopExp::MapShapesAndAncestors(myface,TopAbs_VERTEX,TopAbs_EDGE,mymapve); TopExp_Explorer e; for (e.Init(F,TopAbs_EDGE);e.More();e.Next()) addedge(e.Current()); // for (TopExp_Explorer e(F,TopAbs_EDGE);e.More();e.Next()) addedge(e.Current()); initedgeiter(); setedgedisplayed(0); } void displayface() const { char s[1000]; mypdi->Eval("info proc vx2d_displayface"); if (mypdi->Result()) { sprintf(s,"vx2d_displayface %s",myfacename.ToCString()); mypdi->Eval(s); } else cout<<"procedure vx2d_displayface non trouvee"<1) && (i%4 == 0) && (i=1 &&i<=mynemap) myiemap = i; } Standard_Integer edgedisplayed() const { return myedgedisplayed; } void setedgedisplayed(const Standard_Integer i) { if (i>=1 &&i<=mynemap) myedgedisplayed = i; } TopoDS_Face myface; TCollection_AsciiString myfacename; TColStd_ListOfAsciiString myvis; TopTools_IndexedDataMapOfShapeListOfShape mymapve; TopTools_DataMapOfOrientedShapeInteger mymapsi; TopTools_DataMapOfIntegerShape mymapis; Standard_Integer mynemap; Standard_Integer myiemap; Standard_Integer myedgedisplayed; Draw_Interpretor* mypdi; TopoDS_Edge myemptyedge; TopTools_ListOfShape myemptylos; }; // cvx2d void cvx2d::nextedgeiter(const Standard_Integer incr) { if (!moreedgeiter()) return; myiemap += incr; if (myiemap>mynemap) myiemap = 1; else if (myiemap<1) myiemap = mynemap; } Standard_Integer cvx2d::displayface(const TopoDS_Shape& S, const TCollection_AsciiString& sta) { TopoDS_Shape aLocalShape = S.Oriented(TopAbs_FORWARD) ; TopoDS_Face F = TopoDS::Face(aLocalShape); // TopoDS_Face F = TopoDS::Face(S.Oriented(TopAbs_FORWARD)); Standard_Boolean init = Standard_True; if (init) initface(F,sta); displayface(); printedges(); return 0; } // displayface Standard_Integer cvx2d::displayedge(const TopoDS_Shape& S) { if (S.IsNull()) return 0; const TopoDS_Edge& E = TopoDS::Edge(S); const TopoDS_Face& F = face(); if (F.IsNull()) return 0; Draw_Color savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_rouge)); Standard_Real u,v,V,U;BRepTools::UVBounds(F,E,u,U,v,V); Standard_Boolean deg = BRep_Tool::Degenerated(E); gp_Pnt2d pe1(u,v);gp_Pnt2d pe2(U,V); gp_Pnt2d p1,p2;BRep_Tool::UVPoints(E,F,p1,p2); TopoDS_Vertex v1,v2; TopExp::Vertices(E,v1,v2); gp_Pnt P1 = BRep_Tool::Pnt(v1); gp_Pnt P2 = BRep_Tool::Pnt(v2); Standard_Real v1v2 = P1.Distance(P2); Standard_Real tole = BRep_Tool::Tolerance(E); Standard_Real tol1 = BRep_Tool::Tolerance(v1); Standard_Real tol2 = BRep_Tool::Tolerance(v2); const TopTools_ListOfShape& l1 = incidentedges(v1); const TopTools_ListOfShape& l2 = incidentedges(v2); Handle(Geom2d_Curve) c2d = curve2d(E); // char sdi[1000]; char stol[1000]; TCollection_AsciiString ste,stc,sv1,sv1a,sv2,sv2a,ste1,ste2; ename(E,ste); stc = "c"; stc = stc + ste; vname(v1,E,sv1); sv1a = "V"; sv1a = sv1a + sv1; vname(v2,E,sv2); sv2a = "V"; sv2a = sv2a + sv2; lenames(l1,ste1); lenames(l2,ste2); cout<edgedisplayed()) pv2d->nextedgeiter(dostep); if (pv2d->moreedgeiter()) pv2d->displayedge(pv2d->edge(pv2d->curredgeiter())); return 0; } else if (doiedge) { pv2d->setcurredgeiter(doiedge); if (pv2d->moreedgeiter()) pv2d->displayedge(pv2d->edge(pv2d->curredgeiter())); return 0; } TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) return 0; TCollection_AsciiString sta1(a[1]); TopAbs_ShapeEnum t = S.ShapeType(); TopAbs_ShapeEnum tt = ( t == TopAbs_FACE) ? TopAbs_EDGE : TopAbs_FACE; Standard_Integer iearg = (na >= 3) ? atoi(a[2]) : 0; TCollection_AsciiString stss; Standard_Integer i = 1; TopExp_Explorer ex; for (ex.Init(S,tt);ex.More();ex.Next(),i++) { // for (TopExp_Explorer ex(S,tt);ex.More();ex.Next(),i++) { Standard_Boolean cond = Standard_False; cond = cond || (!iearg); cond = cond || (iearg && (iearg == i)); if (cond) { pv2d->subshapename(sta1,tt,i,stss); DBRep::Set(stss.ToCString(),ex.Current()); di<<"vx2d "<displayface(S,sta1); else if (t == TopAbs_EDGE) r = pv2d->displayedge(S); return r; } // vx2d //======================================================================= //function : OtherCommands //purpose : //======================================================================= void TestTopOpeDraw::OtherCommands(Draw_Interpretor& theCommands) { const char* g = "Topological Operation other commands"; theCommands.Add("cdinp","cdinp p x y z",__FILE__,testtopopedraw_cdinp,g); theCommands.Add("cdins","cdins s1 ... ",__FILE__,testtopopedraw_cdins,g); theCommands.Add("vx2d","vx2d f",__FILE__,vx2d,g); BoopReadInitFile(theCommands,getenv("BOOPGLOB")); theCommands.Add("ttab","",__FILE__,ttab,g); }