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>
41 extern Standard_Boolean TopOpeBRepDS_GettraceDSNC();
42 extern Standard_Boolean TopOpeBRepDS_GettraceDSF();
43 extern Standard_Boolean TopOpeBRepDS_GettraceDSFK();
44 static TCollection_AsciiString PRODINP("dinp ");
47 //=======================================================================
48 //function : TopOpeBRep_FFDumper
50 //=======================================================================
52 TopOpeBRep_FFDumper::TopOpeBRep_FFDumper(const TopOpeBRep_PFacesFiller& )
55 TopOpeBRep_FFDumper::TopOpeBRep_FFDumper(const TopOpeBRep_PFacesFiller& PFF)
61 //=======================================================================
64 //=======================================================================
66 void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& )
69 void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& PFF)
72 const TopoDS_Face& fpff1 = myPFF->Face(1);
73 const TopoDS_Face& fpff2 = myPFF->Face(2);
74 Standard_Boolean f1diff = (!myF1.IsEqual(fpff1));
75 Standard_Boolean f2diff = (!myF2.IsEqual(fpff2));
76 Standard_Boolean init = f1diff || f2diff;
78 myF1 = myPFF->Face(1);
79 myF2 = myPFF->Face(2);
80 myEM1.Clear(); myEn1 = 0;
81 myEM2.Clear(); myEn2 = 0;
83 for (x.Init(myF1,TopAbs_EDGE);x.More();x.Next()) myEM1.Bind(x.Current(),++myEn1);
84 for (x.Init(myF2,TopAbs_EDGE);x.More();x.Next()) myEM2.Bind(x.Current(),++myEn2);
90 //=======================================================================
93 //=======================================================================
95 void TopOpeBRep_FFDumper::DumpLine(const Standard_Integer )
98 void TopOpeBRep_FFDumper::DumpLine(const Standard_Integer I)
100 const TopOpeBRep_LineInter& L = myPFF->ChangeFacesIntersector().ChangeLine(I);
105 //=======================================================================
106 //function : DumpLine
108 //=======================================================================
110 void TopOpeBRep_FFDumper::DumpLine(const TopOpeBRep_LineInter& )
113 void TopOpeBRep_FFDumper::DumpLine(const TopOpeBRep_LineInter& LI)
115 Standard_Integer il = LI.Index();
117 Standard_Integer nl = myPFF->ChangeFacesIntersector().NbLines();
118 Standard_Boolean HasVPonR = LI.HasVPonR();
119 Standard_Boolean IsVClosed = LI.IsVClosed();
120 Standard_Boolean IsPeriodic = LI.IsPeriodic();
121 Standard_Boolean isrest = (LI.TypeLineCurve() == TopOpeBRep_RESTRICTION);
123 cout<<endl<<"--------------------------------------------------"<<endl;
124 cout<<"line "<<il<<"/"<<nl<<" is a "; LI.DumpType();
126 Standard_Boolean isedge1 = LI.ArcIsEdge(1);
127 Standard_Boolean isedge2 = LI.ArcIsEdge(2);
128 if ( isedge1 ) cout<<" of 1";
129 else if ( isedge2 ) cout<<" of 2";
130 else cout<<"of 0(BUG)";
134 const TopoDS_Shape& Erest = LI.Arc();
135 Standard_Boolean FIisrest = myPFF->ChangeFacesIntersector().IsRestriction(Erest);
136 cout<<"++++ line restriction";
138 cout<<" edge restriction";
139 Standard_Integer iErest = 0;
140 if (myPFF->ChangeDataStructure().HasShape(Erest))
141 iErest = myPFF->ChangeDataStructure().Shape(Erest);
146 if (HasVPonR) cout<<"has vertex on restriction"<<endl;
147 else cout<<"has no vertex on restriction"<<endl;
148 if (IsVClosed) cout<<"is closed by vertices"<<endl;
149 else cout<<"is not closed by vertices"<<endl;
150 if (IsPeriodic) cout<<"is periodic"<<endl;
151 else cout<<"is not periodic"<<endl;
153 TopOpeBRep_VPointInterIterator VPI;
155 VPI.Init(LI); if (VPI.More()) cout<<endl;
156 for (;VPI.More();VPI.Next()) {
157 TCollection_AsciiString stol("; #draw ");
158 stol = stol + VPI.CurrentVP().Tolerance() + "\n";
159 LI.DumpVPoint(VPI.CurrentVPIndex(),PRODINP,stol);
163 if (VPI.More()) cout<<endl;
164 for (;VPI.More();VPI.Next()) {
165 const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
166 Standard_Boolean dump = VP.Keep() || TopOpeBRepDS_GettraceDSFK();
167 if (dump) { DumpVP(VP); cout<<endl; }
170 if (LI.TypeLineCurve() == TopOpeBRep_LINE) {
171 gp_Dir D = LI.LineG()->Line().Direction();
172 TopOpeBRep::Print(LI.TypeLineCurve(),cout); Standard_Real x,y,z; D.Coord(x,y,z);
173 cout<<" dir : "<<x<<" "<<y<<" "<<z<<endl;
176 LI.DumpLineTransitions(cout);
178 cout<<endl<<"--------------------------------------------------"<<endl;
182 //=======================================================================
185 //=======================================================================
187 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& )
190 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& VP)
192 Standard_Integer il = myLineIndex;
193 cout<<"VP "<<VP.Index()<<" on "<<VP.ShapeIndex()<<" :";
194 Standard_Real Cpar = VP.ParameterOnLine(); cout<<" on curve : "<<Cpar;
195 if (!VP.Keep()) cout<<" NOT kept";
197 Standard_Boolean k = VP.Keep();
198 const gp_Pnt& P = VP.Value();
199 cout<<PRODINP<<"L"<<il<<"P"<<VP.Index();if (k) cout<<"K";cout<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z();
200 cout<<"; #draw"<<endl;
202 if (TopOpeBRepDS_GettraceDSFK()) {
204 VP.ParametersOnS1(u,v); cout<<"u1,v1 : "<<u<<" "<<v; cout<<" ";
205 VP.ParametersOnS2(u,v); cout<<"u2,v2 : "<<u<<" "<<v; cout<<endl;
208 if (VP.ShapeIndex() == 1)
210 else if (VP.ShapeIndex() == 2)
212 else if (VP.ShapeIndex() == 3) {
219 //=======================================================================
222 //=======================================================================
224 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& ,const Standard_Integer )
227 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& VP,const Standard_Integer ISI)
229 const Handle(TopOpeBRepDS_HDataStructure)& HDS = myPFF->HDataStructure();
230 const TopoDS_Edge& E = TopoDS::Edge(VP.Edge(ISI));
231 Standard_Real Epar = VP.EdgeParameter(ISI);
232 TopAbs_Orientation O = E.Orientation();
233 TopOpeBRepDS_Transition T = TopOpeBRep_FFTransitionTool::ProcessLineTransition(VP,ISI,O);
234 const TopoDS_Face F = myPFF->Face(ISI);
235 Standard_Boolean Closed = TopOpeBRepTool_ShapeTool::Closed(E,F);
236 Standard_Boolean Degen = BRep_Tool::Degenerated(E);
237 Standard_Integer exi = ExploreIndex(E,ISI);
238 Standard_Integer dsi = (HDS->HasShape(E)) ? HDS->Shape(E) : 0;
239 Standard_Boolean isv = VP.IsVertex(ISI);
240 if (isv) cout<<"is vertex of "<<ISI<<endl;
241 if (Closed) cout<<"on closing edge "; else cout<<"on edge ";
242 if (Degen) cout<<" on degenerated edge ";
243 TopAbs::Print(O,cout); cout<<" (ds"<<dsi<<") (ex"<<exi<<") of face of "<<ISI;
244 cout<<" : par : "<<Epar<<endl;
245 if (Closed) cout<<"on closing edge "; else cout<<"on edge ";
246 if (Degen) cout<<" on degenerated edge ";
247 TopAbs::Print(O,cout); cout<<" (ds"<<dsi<<") (ex"<<exi<<") of face of "<<ISI;
248 cout<<" : line transition : ";T.Dump(cout);cout<<endl;
252 //=======================================================================
253 //function : ExploreIndex
255 //=======================================================================
257 Standard_Integer TopOpeBRep_FFDumper::ExploreIndex(const TopoDS_Shape& , const Standard_Integer ) const
262 Standard_Integer TopOpeBRep_FFDumper::ExploreIndex(const TopoDS_Shape& S, const Standard_Integer ISI) const
264 Standard_Integer r = 0;
265 if (ISI == 1) r = myEM1.Find(S);
266 if (ISI == 2) r = myEM2.Find(S);
271 //=======================================================================
274 //=======================================================================
276 void TopOpeBRep_FFDumper::DumpDSP(const TopOpeBRep_VPointInter& ,const TopOpeBRepDS_Kind ,const Standard_Integer ,
277 const Standard_Boolean ) const
280 void TopOpeBRep_FFDumper::DumpDSP(const TopOpeBRep_VPointInter& VP,const TopOpeBRepDS_Kind GK,const Standard_Integer G,
281 const Standard_Boolean newinDS) const
283 cout<<"VP "<<VP.Index()<<" on "<<VP.ShapeIndex();
285 if (GK == TopOpeBRepDS_VERTEX) cout<<" gives new DSV";
286 else if (GK == TopOpeBRepDS_POINT) cout<<" gives new DSP";
287 else cout<<" gives new DS???";
290 if (GK == TopOpeBRepDS_VERTEX) cout<<" equals new DSV";
291 else if (GK == TopOpeBRepDS_POINT) cout<<" equals new DSP";
292 else cout<<" equals new DS???";
296 const Handle(TopOpeBRepDS_HDataStructure)& HDS = myPFF->HDataStructure();
297 Standard_Real tol = Precision::Confusion();
298 if (GK == TopOpeBRepDS_VERTEX) tol = BRep_Tool::Tolerance(TopoDS::Vertex(HDS->Shape(G)));
299 else if (GK == TopOpeBRepDS_POINT) tol = HDS->Point(G).Tolerance();
300 cout<<" tol = "<<tol;
305 TopOpeBRep_PFacesFiller TopOpeBRep_FFDumper::PFacesFillerDummy() const {return myPFF;}