1 // Created on: 1996-10-23
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <BRep_Tool.hxx>
21 #include <IntPatch_GLine.hxx>
22 #include <Standard_Type.hxx>
24 #include <TopExp_Explorer.hxx>
26 #include <TopoDS_Edge.hxx>
27 #include <TopoDS_Face.hxx>
28 #include <TopoDS_Shape.hxx>
29 #include <TopOpeBRep.hxx>
30 #include <TopOpeBRep_define.hxx>
31 #include <TopOpeBRep_FacesFiller.hxx>
32 #include <TopOpeBRep_FacesIntersector.hxx>
33 #include <TopOpeBRep_FFDumper.hxx>
34 #include <TopOpeBRep_FFTransitionTool.hxx>
35 #include <TopOpeBRep_LineInter.hxx>
36 #include <TopOpeBRep_VPointInter.hxx>
37 #include <TopOpeBRep_VPointInterIterator.hxx>
38 #include <TopOpeBRepTool_ShapeTool.hxx>
40 IMPLEMENT_STANDARD_RTTIEXT(TopOpeBRep_FFDumper,Standard_Transient)
43 static TCollection_AsciiString PRODINP("dinp ");
46 //=======================================================================
47 //function : TopOpeBRep_FFDumper
49 //=======================================================================
51 TopOpeBRep_FFDumper::TopOpeBRep_FFDumper(const TopOpeBRep_PFacesFiller& )
54 TopOpeBRep_FFDumper::TopOpeBRep_FFDumper(const TopOpeBRep_PFacesFiller& PFF)
60 //=======================================================================
63 //=======================================================================
65 void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& )
67 // just shut up compiler warnings
73 void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& PFF)
76 const TopoDS_Face& fpff1 = myPFF->Face(1);
77 const TopoDS_Face& fpff2 = myPFF->Face(2);
78 Standard_Boolean f1diff = (!myF1.IsEqual(fpff1));
79 Standard_Boolean f2diff = (!myF2.IsEqual(fpff2));
80 Standard_Boolean init = f1diff || f2diff;
82 myF1 = myPFF->Face(1);
83 myF2 = myPFF->Face(2);
84 myEM1.Clear(); myEn1 = 0;
85 myEM2.Clear(); myEn2 = 0;
87 for (x.Init(myF1,TopAbs_EDGE);x.More();x.Next()) myEM1.Bind(x.Current(),++myEn1);
88 for (x.Init(myF2,TopAbs_EDGE);x.More();x.Next()) myEM2.Bind(x.Current(),++myEn2);
94 //=======================================================================
97 //=======================================================================
99 void TopOpeBRep_FFDumper::DumpLine(const Standard_Integer )
102 void TopOpeBRep_FFDumper::DumpLine(const Standard_Integer I)
104 const TopOpeBRep_LineInter& L = myPFF->ChangeFacesIntersector().ChangeLine(I);
109 //=======================================================================
110 //function : DumpLine
112 //=======================================================================
114 void TopOpeBRep_FFDumper::DumpLine(const TopOpeBRep_LineInter& )
117 void TopOpeBRep_FFDumper::DumpLine(const TopOpeBRep_LineInter& LI)
119 Standard_Integer il = LI.Index();
121 Standard_Integer nl = myPFF->ChangeFacesIntersector().NbLines();
122 Standard_Boolean HasVPonR = LI.HasVPonR();
123 Standard_Boolean IsVClosed = LI.IsVClosed();
124 Standard_Boolean IsPeriodic = LI.IsPeriodic();
125 Standard_Boolean isrest = (LI.TypeLineCurve() == TopOpeBRep_RESTRICTION);
127 std::cout<<std::endl<<"--------------------------------------------------"<<std::endl;
128 std::cout<<"line "<<il<<"/"<<nl<<" is a "; LI.DumpType();
130 Standard_Boolean isedge1 = LI.ArcIsEdge(1);
131 Standard_Boolean isedge2 = LI.ArcIsEdge(2);
132 if ( isedge1 ) std::cout<<" of 1";
133 else if ( isedge2 ) std::cout<<" of 2";
134 else std::cout<<"of 0(BUG)";
136 std::cout<<std::endl;
138 const TopoDS_Shape& Erest = LI.Arc();
139 Standard_Boolean FIisrest = myPFF->ChangeFacesIntersector().IsRestriction(Erest);
140 std::cout<<"++++ line restriction";
142 std::cout<<" edge restriction";
143 Standard_Integer iErest = 0;
144 if (myPFF->ChangeDataStructure().HasShape(Erest))
145 iErest = myPFF->ChangeDataStructure().Shape(Erest);
146 std::cout<<" "<<iErest;
148 std::cout<<std::endl;
150 if (HasVPonR) std::cout<<"has vertex on restriction"<<std::endl;
151 else std::cout<<"has no vertex on restriction"<<std::endl;
152 if (IsVClosed) std::cout<<"is closed by vertices"<<std::endl;
153 else std::cout<<"is not closed by vertices"<<std::endl;
154 if (IsPeriodic) std::cout<<"is periodic"<<std::endl;
155 else std::cout<<"is not periodic"<<std::endl;
157 TopOpeBRep_VPointInterIterator VPI;
159 VPI.Init(LI); if (VPI.More()) std::cout<<std::endl;
160 for (;VPI.More();VPI.Next()) {
161 TCollection_AsciiString stol("; #draw ");
162 stol = stol + VPI.CurrentVP().Tolerance() + "\n";
163 LI.DumpVPoint(VPI.CurrentVPIndex(),PRODINP,stol);
167 if (VPI.More()) std::cout<<std::endl;
168 for (;VPI.More();VPI.Next()) {
169 const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
170 Standard_Boolean dump = VP.Keep();
171 if (dump) { DumpVP(VP); std::cout<<std::endl; }
174 if (LI.TypeLineCurve() == TopOpeBRep_LINE) {
175 gp_Dir D = LI.LineG()->Line().Direction();
176 TopOpeBRep::Print(LI.TypeLineCurve(),std::cout); Standard_Real x,y,z; D.Coord(x,y,z);
177 std::cout<<" dir : "<<x<<" "<<y<<" "<<z<<std::endl;
180 LI.DumpLineTransitions(std::cout);
182 std::cout<<std::endl<<"--------------------------------------------------"<<std::endl;
186 //=======================================================================
189 //=======================================================================
191 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& )
194 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& VP)
196 Standard_Integer il = myLineIndex;
197 std::cout<<"VP "<<VP.Index()<<" on "<<VP.ShapeIndex()<<" :";
198 Standard_Real Cpar = VP.ParameterOnLine(); std::cout<<" on curve : "<<Cpar;
199 if (!VP.Keep()) std::cout<<" NOT kept";
200 std::cout<<std::endl;
201 Standard_Boolean k = VP.Keep();
202 const gp_Pnt& P = VP.Value();
203 std::cout<<PRODINP<<"L"<<il<<"P"<<VP.Index();if (k) std::cout<<"K";std::cout<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z();
204 std::cout<<"; #draw"<<std::endl;
206 if (VP.ShapeIndex() == 1)
208 else if (VP.ShapeIndex() == 2)
210 else if (VP.ShapeIndex() == 3) {
217 //=======================================================================
220 //=======================================================================
222 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& ,const Standard_Integer )
225 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& VP,const Standard_Integer ISI)
227 const Handle(TopOpeBRepDS_HDataStructure)& HDS = myPFF->HDataStructure();
228 const TopoDS_Edge& E = TopoDS::Edge(VP.Edge(ISI));
229 Standard_Real Epar = VP.EdgeParameter(ISI);
230 TopAbs_Orientation O = E.Orientation();
231 TopOpeBRep_FFTransitionTool::ProcessLineTransition(VP,ISI,O);
232 const TopoDS_Face F = myPFF->Face(ISI);
233 Standard_Boolean Closed = TopOpeBRepTool_ShapeTool::Closed(E,F);
234 Standard_Boolean Degen = BRep_Tool::Degenerated(E);
235 Standard_Integer exi = ExploreIndex(E,ISI);
236 Standard_Integer dsi = (HDS->HasShape(E)) ? HDS->Shape(E) : 0;
237 Standard_Boolean isv = VP.IsVertex(ISI);
238 if (isv) std::cout<<"is vertex of "<<ISI<<std::endl;
239 if (Closed) std::cout<<"on closing edge "; else std::cout<<"on edge ";
240 if (Degen) std::cout<<" on degenerated edge ";
241 TopAbs::Print(O,std::cout); std::cout<<" (ds"<<dsi<<") (ex"<<exi<<") of face of "<<ISI;
242 std::cout<<" : par : "<<Epar<<std::endl;
243 if (Closed) std::cout<<"on closing edge "; else std::cout<<"on edge ";
244 if (Degen) std::cout<<" on degenerated edge ";
245 TopAbs::Print(O,std::cout); std::cout<<" (ds"<<dsi<<") (ex"<<exi<<") of face of "<<ISI;
249 //=======================================================================
250 //function : ExploreIndex
252 //=======================================================================
254 Standard_Integer TopOpeBRep_FFDumper::ExploreIndex(const TopoDS_Shape& , const Standard_Integer ) const
259 Standard_Integer TopOpeBRep_FFDumper::ExploreIndex(const TopoDS_Shape& S, const Standard_Integer ISI) const
261 Standard_Integer r = 0;
262 if (ISI == 1) r = myEM1.Find(S);
263 if (ISI == 2) r = myEM2.Find(S);
268 //=======================================================================
271 //=======================================================================
273 void TopOpeBRep_FFDumper::DumpDSP(const TopOpeBRep_VPointInter& ,const TopOpeBRepDS_Kind ,const Standard_Integer ,
274 const Standard_Boolean ) const
277 void TopOpeBRep_FFDumper::DumpDSP(const TopOpeBRep_VPointInter& VP,const TopOpeBRepDS_Kind GK,const Standard_Integer G,
278 const Standard_Boolean newinDS) const
280 std::cout<<"VP "<<VP.Index()<<" on "<<VP.ShapeIndex();
282 if (GK == TopOpeBRepDS_VERTEX) std::cout<<" gives new DSV";
283 else if (GK == TopOpeBRepDS_POINT) std::cout<<" gives new DSP";
284 else std::cout<<" gives new DS???";
287 if (GK == TopOpeBRepDS_VERTEX) std::cout<<" equals new DSV";
288 else if (GK == TopOpeBRepDS_POINT) std::cout<<" equals new DSP";
289 else std::cout<<" equals new DS???";
293 const Handle(TopOpeBRepDS_HDataStructure)& HDS = myPFF->HDataStructure();
294 Standard_Real tol = Precision::Confusion();
295 if (GK == TopOpeBRepDS_VERTEX) tol = BRep_Tool::Tolerance(TopoDS::Vertex(HDS->Shape(G)));
296 else if (GK == TopOpeBRepDS_POINT) tol = HDS->Point(G).Tolerance();
297 std::cout<<" tol = "<<tol;
298 std::cout<<std::endl;
302 TopOpeBRep_PFacesFiller TopOpeBRep_FFDumper::PFacesFillerDummy() const {return myPFF;}