1 // Created on: 1996-10-23
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1996-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.
22 #include <TopOpeBRep_FFDumper.ixx>
23 #include <TopExp_Explorer.hxx>
25 #include <TopOpeBRep_FacesIntersector.hxx>
26 #include <TopOpeBRep_VPointInterIterator.hxx>
27 #include <TopOpeBRep_VPointInter.hxx>
28 #include <TopOpeBRep.hxx>
30 #include <TopoDS_Edge.hxx>
31 #include <TopoDS_Face.hxx>
32 #include <TopoDS_Shape.hxx>
33 #include <TopOpeBRepTool_ShapeTool.hxx>
34 #include <BRep_Tool.hxx>
35 #include <TopOpeBRep_FFTransitionTool.hxx>
38 #include <TopOpeBRep_FacesFiller.hxx>
39 #include <TopOpeBRep_define.hxx>
40 #include <IntPatch_GLine.hxx>
43 extern Standard_Boolean TopOpeBRepDS_GettraceDSNC();
44 extern Standard_Boolean TopOpeBRepDS_GettraceDSF();
45 extern Standard_Boolean TopOpeBRepDS_GettraceDSFK();
46 static TCollection_AsciiString PRODINP("dinp ");
49 //=======================================================================
50 //function : TopOpeBRep_FFDumper
52 //=======================================================================
54 TopOpeBRep_FFDumper::TopOpeBRep_FFDumper(const TopOpeBRep_PFacesFiller& )
57 TopOpeBRep_FFDumper::TopOpeBRep_FFDumper(const TopOpeBRep_PFacesFiller& PFF)
63 //=======================================================================
66 //=======================================================================
68 void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& )
71 void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& PFF)
74 const TopoDS_Face& fpff1 = myPFF->Face(1);
75 const TopoDS_Face& fpff2 = myPFF->Face(2);
76 Standard_Boolean f1diff = (!myF1.IsEqual(fpff1));
77 Standard_Boolean f2diff = (!myF2.IsEqual(fpff2));
78 Standard_Boolean init = f1diff || f2diff;
80 myF1 = myPFF->Face(1);
81 myF2 = myPFF->Face(2);
82 myEM1.Clear(); myEn1 = 0;
83 myEM2.Clear(); myEn2 = 0;
85 for (x.Init(myF1,TopAbs_EDGE);x.More();x.Next()) myEM1.Bind(x.Current(),++myEn1);
86 for (x.Init(myF2,TopAbs_EDGE);x.More();x.Next()) myEM2.Bind(x.Current(),++myEn2);
92 //=======================================================================
95 //=======================================================================
97 void TopOpeBRep_FFDumper::DumpLine(const Standard_Integer )
100 void TopOpeBRep_FFDumper::DumpLine(const Standard_Integer I)
102 const TopOpeBRep_LineInter& L = myPFF->ChangeFacesIntersector().ChangeLine(I);
107 //=======================================================================
108 //function : DumpLine
110 //=======================================================================
112 void TopOpeBRep_FFDumper::DumpLine(const TopOpeBRep_LineInter& )
115 void TopOpeBRep_FFDumper::DumpLine(const TopOpeBRep_LineInter& LI)
117 Standard_Integer il = LI.Index();
119 Standard_Integer nl = myPFF->ChangeFacesIntersector().NbLines();
120 Standard_Boolean HasVPonR = LI.HasVPonR();
121 Standard_Boolean IsVClosed = LI.IsVClosed();
122 Standard_Boolean IsPeriodic = LI.IsPeriodic();
123 Standard_Boolean isrest = (LI.TypeLineCurve() == TopOpeBRep_RESTRICTION);
125 cout<<endl<<"--------------------------------------------------"<<endl;
126 cout<<"line "<<il<<"/"<<nl<<" is a "; LI.DumpType();
128 Standard_Boolean isedge1 = LI.ArcIsEdge(1);
129 Standard_Boolean isedge2 = LI.ArcIsEdge(2);
130 if ( isedge1 ) cout<<" of 1";
131 else if ( isedge2 ) cout<<" of 2";
132 else cout<<"of 0(BUG)";
136 const TopoDS_Shape& Erest = LI.Arc();
137 Standard_Boolean FIisrest = myPFF->ChangeFacesIntersector().IsRestriction(Erest);
138 cout<<"++++ line restriction";
140 cout<<" edge restriction";
141 Standard_Integer iErest = 0;
142 if (myPFF->ChangeDataStructure().HasShape(Erest))
143 iErest = myPFF->ChangeDataStructure().Shape(Erest);
148 if (HasVPonR) cout<<"has vertex on restriction"<<endl;
149 else cout<<"has no vertex on restriction"<<endl;
150 if (IsVClosed) cout<<"is closed by vertices"<<endl;
151 else cout<<"is not closed by vertices"<<endl;
152 if (IsPeriodic) cout<<"is periodic"<<endl;
153 else cout<<"is not periodic"<<endl;
155 TopOpeBRep_VPointInterIterator VPI;
157 VPI.Init(LI); if (VPI.More()) cout<<endl;
158 for (;VPI.More();VPI.Next()) {
159 TCollection_AsciiString stol("; #draw ");
160 stol = stol + VPI.CurrentVP().Tolerance() + "\n";
161 LI.DumpVPoint(VPI.CurrentVPIndex(),PRODINP,stol);
165 if (VPI.More()) cout<<endl;
166 for (;VPI.More();VPI.Next()) {
167 const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
168 Standard_Boolean dump = VP.Keep() || TopOpeBRepDS_GettraceDSFK();
169 if (dump) { DumpVP(VP); cout<<endl; }
172 if (LI.TypeLineCurve() == TopOpeBRep_LINE) {
173 gp_Dir D = LI.LineG()->Line().Direction();
174 TopOpeBRep::Print(LI.TypeLineCurve(),cout); Standard_Real x,y,z; D.Coord(x,y,z);
175 cout<<" dir : "<<x<<" "<<y<<" "<<z<<endl;
178 LI.DumpLineTransitions(cout);
180 cout<<endl<<"--------------------------------------------------"<<endl;
184 //=======================================================================
187 //=======================================================================
189 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& )
192 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& VP)
194 Standard_Integer il = myLineIndex;
195 cout<<"VP "<<VP.Index()<<" on "<<VP.ShapeIndex()<<" :";
196 Standard_Real Cpar = VP.ParameterOnLine(); cout<<" on curve : "<<Cpar;
197 if (!VP.Keep()) cout<<" NOT kept";
199 Standard_Boolean k = VP.Keep();
200 const gp_Pnt& P = VP.Value();
201 cout<<PRODINP<<"L"<<il<<"P"<<VP.Index();if (k) cout<<"K";cout<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z();
202 cout<<"; #draw"<<endl;
204 if (TopOpeBRepDS_GettraceDSFK()) {
206 VP.ParametersOnS1(u,v); cout<<"u1,v1 : "<<u<<" "<<v; cout<<" ";
207 VP.ParametersOnS2(u,v); cout<<"u2,v2 : "<<u<<" "<<v; cout<<endl;
210 if (VP.ShapeIndex() == 1)
212 else if (VP.ShapeIndex() == 2)
214 else if (VP.ShapeIndex() == 3) {
221 //=======================================================================
224 //=======================================================================
226 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& ,const Standard_Integer )
229 void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& VP,const Standard_Integer ISI)
231 const Handle(TopOpeBRepDS_HDataStructure)& HDS = myPFF->HDataStructure();
232 const TopoDS_Edge& E = TopoDS::Edge(VP.Edge(ISI));
233 Standard_Real Epar = VP.EdgeParameter(ISI);
234 TopAbs_Orientation O = E.Orientation();
235 TopOpeBRepDS_Transition T = TopOpeBRep_FFTransitionTool::ProcessLineTransition(VP,ISI,O);
236 const TopoDS_Face F = myPFF->Face(ISI);
237 Standard_Boolean Closed = TopOpeBRepTool_ShapeTool::Closed(E,F);
238 Standard_Boolean Degen = BRep_Tool::Degenerated(E);
239 Standard_Integer exi = ExploreIndex(E,ISI);
240 Standard_Integer dsi = (HDS->HasShape(E)) ? HDS->Shape(E) : 0;
241 Standard_Boolean isv = VP.IsVertex(ISI);
242 if (isv) cout<<"is vertex of "<<ISI<<endl;
243 if (Closed) cout<<"on closing edge "; else cout<<"on edge ";
244 if (Degen) cout<<" on degenerated edge ";
245 TopAbs::Print(O,cout); cout<<" (ds"<<dsi<<") (ex"<<exi<<") of face of "<<ISI;
246 cout<<" : par : "<<Epar<<endl;
247 if (Closed) cout<<"on closing edge "; else cout<<"on edge ";
248 if (Degen) cout<<" on degenerated edge ";
249 TopAbs::Print(O,cout); cout<<" (ds"<<dsi<<") (ex"<<exi<<") of face of "<<ISI;
250 cout<<" : line transition : ";T.Dump(cout);cout<<endl;
254 //=======================================================================
255 //function : ExploreIndex
257 //=======================================================================
259 Standard_Integer TopOpeBRep_FFDumper::ExploreIndex(const TopoDS_Shape& , const Standard_Integer ) const
264 Standard_Integer TopOpeBRep_FFDumper::ExploreIndex(const TopoDS_Shape& S, const Standard_Integer ISI) const
266 Standard_Integer r = 0;
267 if (ISI == 1) r = myEM1.Find(S);
268 if (ISI == 2) r = myEM2.Find(S);
273 //=======================================================================
276 //=======================================================================
278 void TopOpeBRep_FFDumper::DumpDSP(const TopOpeBRep_VPointInter& ,const TopOpeBRepDS_Kind ,const Standard_Integer ,
279 const Standard_Boolean ) const
282 void TopOpeBRep_FFDumper::DumpDSP(const TopOpeBRep_VPointInter& VP,const TopOpeBRepDS_Kind GK,const Standard_Integer G,
283 const Standard_Boolean newinDS) const
285 cout<<"VP "<<VP.Index()<<" on "<<VP.ShapeIndex();
287 if (GK == TopOpeBRepDS_VERTEX) cout<<" gives new DSV";
288 else if (GK == TopOpeBRepDS_POINT) cout<<" gives new DSP";
289 else cout<<" gives new DS???";
292 if (GK == TopOpeBRepDS_VERTEX) cout<<" equals new DSV";
293 else if (GK == TopOpeBRepDS_POINT) cout<<" equals new DSP";
294 else cout<<" equals new DS???";
298 const Handle(TopOpeBRepDS_HDataStructure)& HDS = myPFF->HDataStructure();
299 Standard_Real tol = Precision::Confusion();
300 if (GK == TopOpeBRepDS_VERTEX) tol = BRep_Tool::Tolerance(TopoDS::Vertex(HDS->Shape(G)));
301 else if (GK == TopOpeBRepDS_POINT) tol = HDS->Point(G).Tolerance();
302 cout<<" tol = "<<tol;
307 TopOpeBRep_PFacesFiller TopOpeBRep_FFDumper::PFacesFillerDummy() const {return myPFF;}