0027525: Coding - eliminate warnings on Windows for OCCT with static type of libraries
[occt.git] / src / TopOpeBRep / TopOpeBRep_FFDumper.cxx
CommitLineData
b311480e 1// Created on: 1996-10-23
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1996-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <BRep_Tool.hxx>
19#include <gp_Dir.hxx>
20#include <gp_Pnt.hxx>
21#include <IntPatch_GLine.hxx>
22#include <Standard_Type.hxx>
7fd59977 23#include <TopAbs.hxx>
42cf5bc1 24#include <TopExp_Explorer.hxx>
7fd59977 25#include <TopoDS.hxx>
26#include <TopoDS_Edge.hxx>
27#include <TopoDS_Face.hxx>
28#include <TopoDS_Shape.hxx>
42cf5bc1 29#include <TopOpeBRep.hxx>
7fd59977 30#include <TopOpeBRep_define.hxx>
42cf5bc1 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>
7fd59977 39
92efcf78 40IMPLEMENT_STANDARD_RTTIEXT(TopOpeBRep_FFDumper,MMgt_TShared)
41
0797d9d3 42#ifdef OCCT_DEBUG
7fd59977 43static TCollection_AsciiString PRODINP("dinp ");
44#endif
45
46//=======================================================================
47//function : TopOpeBRep_FFDumper
48//purpose :
49//=======================================================================
0797d9d3 50#ifndef OCCT_DEBUG
7fd59977 51TopOpeBRep_FFDumper::TopOpeBRep_FFDumper(const TopOpeBRep_PFacesFiller& )
52{
53#else
54TopOpeBRep_FFDumper::TopOpeBRep_FFDumper(const TopOpeBRep_PFacesFiller& PFF)
55{
56 Init(PFF);
57#endif
58}
59
60//=======================================================================
61//function : Init
62//purpose :
63//=======================================================================
0797d9d3 64#ifndef OCCT_DEBUG
7fd59977 65void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& )
66{
f2139a7f 67 // just shut up compiler warnings
68 (void)myEn1;
69 (void)myEn2;
70 (void)myLineIndex;
71}
7fd59977 72#else
73void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& PFF)
74{
75 myPFF = 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;
81 if (init) {
82 myF1 = myPFF->Face(1);
83 myF2 = myPFF->Face(2);
84 myEM1.Clear(); myEn1 = 0;
85 myEM2.Clear(); myEn2 = 0;
86 TopExp_Explorer x;
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);
89 myLineIndex = 0;
90 }
7fd59977 91}
f2139a7f 92#endif
7fd59977 93
94//=======================================================================
95//function : DumpLine
96//purpose :
97//=======================================================================
0797d9d3 98#ifndef OCCT_DEBUG
7fd59977 99void TopOpeBRep_FFDumper::DumpLine(const Standard_Integer )
100{
101#else
102void TopOpeBRep_FFDumper::DumpLine(const Standard_Integer I)
103{
104 const TopOpeBRep_LineInter& L = myPFF->ChangeFacesIntersector().ChangeLine(I);
105 DumpLine(L);
106#endif
107}
108
109//=======================================================================
110//function : DumpLine
111//purpose :
112//=======================================================================
0797d9d3 113#ifndef OCCT_DEBUG
7fd59977 114void TopOpeBRep_FFDumper::DumpLine(const TopOpeBRep_LineInter& )
115{
116#else
117void TopOpeBRep_FFDumper::DumpLine(const TopOpeBRep_LineInter& LI)
118{
119 Standard_Integer il = LI.Index();
120 myLineIndex = il;
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);
126
127 cout<<endl<<"--------------------------------------------------"<<endl;
128 cout<<"line "<<il<<"/"<<nl<<" is a "; LI.DumpType();
129 if ( isrest) {
130 Standard_Boolean isedge1 = LI.ArcIsEdge(1);
131 Standard_Boolean isedge2 = LI.ArcIsEdge(2);
132 if ( isedge1 ) cout<<" of 1";
133 else if ( isedge2 ) cout<<" of 2";
134 else cout<<"of 0(BUG)";
135 }
136 cout<<endl;
137 if ( isrest) {
138 const TopoDS_Shape& Erest = LI.Arc();
139 Standard_Boolean FIisrest = myPFF->ChangeFacesIntersector().IsRestriction(Erest);
140 cout<<"++++ line restriction";
141 if (FIisrest) {
142 cout<<" edge restriction";
143 Standard_Integer iErest = 0;
144 if (myPFF->ChangeDataStructure().HasShape(Erest))
145 iErest = myPFF->ChangeDataStructure().Shape(Erest);
146 cout<<" "<<iErest;
147 }
148 cout<<endl;
149 }
150 if (HasVPonR) cout<<"has vertex on restriction"<<endl;
151 else cout<<"has no vertex on restriction"<<endl;
152 if (IsVClosed) cout<<"is closed by vertices"<<endl;
153 else cout<<"is not closed by vertices"<<endl;
154 if (IsPeriodic) cout<<"is periodic"<<endl;
155 else cout<<"is not periodic"<<endl;
156
157 TopOpeBRep_VPointInterIterator VPI;
158
159 VPI.Init(LI); if (VPI.More()) cout<<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);
164 }
165
166 VPI.Init(LI);
167 if (VPI.More()) cout<<endl;
168 for (;VPI.More();VPI.Next()) {
169 const TopOpeBRep_VPointInter& VP = VPI.CurrentVP();
536a3cb8 170 Standard_Boolean dump = VP.Keep();
7fd59977 171 if (dump) { DumpVP(VP); cout<<endl; }
172 }
173
174 if (LI.TypeLineCurve() == TopOpeBRep_LINE) {
175 gp_Dir D = LI.LineG()->Line().Direction();
176 TopOpeBRep::Print(LI.TypeLineCurve(),cout); Standard_Real x,y,z; D.Coord(x,y,z);
177 cout<<" dir : "<<x<<" "<<y<<" "<<z<<endl;
178 }
179
180 LI.DumpLineTransitions(cout);
181
182 cout<<endl<<"--------------------------------------------------"<<endl;
183#endif
184}
185
186//=======================================================================
187//function : DumpVP
188//purpose :
189//=======================================================================
0797d9d3 190#ifndef OCCT_DEBUG
7fd59977 191void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& )
192{
193#else
194void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& VP)
195{
196 Standard_Integer il = myLineIndex;
197 cout<<"VP "<<VP.Index()<<" on "<<VP.ShapeIndex()<<" :";
198 Standard_Real Cpar = VP.ParameterOnLine(); cout<<" on curve : "<<Cpar;
199 if (!VP.Keep()) cout<<" NOT kept";
200 cout<<endl;
201 Standard_Boolean k = VP.Keep();
202 const gp_Pnt& P = VP.Value();
203 cout<<PRODINP<<"L"<<il<<"P"<<VP.Index();if (k) cout<<"K";cout<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z();
204 cout<<"; #draw"<<endl;
205
7fd59977 206 if (VP.ShapeIndex() == 1)
207 DumpVP(VP,1);
208 else if (VP.ShapeIndex() == 2)
209 DumpVP(VP,2);
210 else if (VP.ShapeIndex() == 3) {
211 DumpVP(VP,1);
212 DumpVP(VP,2);
213 }
214#endif
215}
216
217//=======================================================================
218//function : DumpVP
219//purpose :
220//=======================================================================
0797d9d3 221#ifndef OCCT_DEBUG
7fd59977 222void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& ,const Standard_Integer )
223{
224#else
225void TopOpeBRep_FFDumper::DumpVP(const TopOpeBRep_VPointInter& VP,const Standard_Integer ISI)
226{
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();
536a3cb8 231 TopOpeBRep_FFTransitionTool::ProcessLineTransition(VP,ISI,O);
7fd59977 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) cout<<"is vertex of "<<ISI<<endl;
239 if (Closed) cout<<"on closing edge "; else cout<<"on edge ";
240 if (Degen) cout<<" on degenerated edge ";
241 TopAbs::Print(O,cout); cout<<" (ds"<<dsi<<") (ex"<<exi<<") of face of "<<ISI;
242 cout<<" : par : "<<Epar<<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;
7fd59977 246#endif
247}
248
249//=======================================================================
250//function : ExploreIndex
251//purpose :
252//=======================================================================
0797d9d3 253#ifndef OCCT_DEBUG
7fd59977 254Standard_Integer TopOpeBRep_FFDumper::ExploreIndex(const TopoDS_Shape& , const Standard_Integer ) const
255{
d3f26155 256 return 0;
257}
7fd59977 258#else
259Standard_Integer TopOpeBRep_FFDumper::ExploreIndex(const TopoDS_Shape& S, const Standard_Integer ISI) const
260{
261 Standard_Integer r = 0;
262 if (ISI == 1) r = myEM1.Find(S);
263 if (ISI == 2) r = myEM2.Find(S);
264 return r;
7fd59977 265}
d3f26155 266#endif
7fd59977 267
268//=======================================================================
269//function : DumpDSP
270//purpose :
271//=======================================================================
0797d9d3 272#ifndef OCCT_DEBUG
7fd59977 273void TopOpeBRep_FFDumper::DumpDSP(const TopOpeBRep_VPointInter& ,const TopOpeBRepDS_Kind ,const Standard_Integer ,
274 const Standard_Boolean ) const
275{
276#else
277void TopOpeBRep_FFDumper::DumpDSP(const TopOpeBRep_VPointInter& VP,const TopOpeBRepDS_Kind GK,const Standard_Integer G,
278 const Standard_Boolean newinDS) const
279{
280 cout<<"VP "<<VP.Index()<<" on "<<VP.ShapeIndex();
281 if (newinDS) {
282 if (GK == TopOpeBRepDS_VERTEX) cout<<" gives new DSV";
283 else if (GK == TopOpeBRepDS_POINT) cout<<" gives new DSP";
284 else cout<<" gives new DS???";
285 }
286 else {
287 if (GK == TopOpeBRepDS_VERTEX) cout<<" equals new DSV";
288 else if (GK == TopOpeBRepDS_POINT) cout<<" equals new DSP";
289 else cout<<" equals new DS???";
290 }
291 cout<<" "<<G;
292
293 const Handle(TopOpeBRepDS_HDataStructure)& HDS = myPFF->HDataStructure();
1d47d8d0 294 Standard_Real tol = Precision::Confusion();
7fd59977 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 cout<<" tol = "<<tol;
298 cout<<endl;
299#endif
300}
301
302TopOpeBRep_PFacesFiller TopOpeBRep_FFDumper::PFacesFillerDummy() const {return myPFF;}