1 // File: ChFi3d_Debug.cxx
2 // Created: Wed Sep 21 12:49:56 1994
3 // Author: Laurent BOURESCHE
8 #include <TopOpeBRepDS_DataStructure.hxx>
9 #include <ChFiDS_SurfData.hxx>
10 #include <TopOpeBRepDS_Surface.hxx>
11 #include <BRep_Builder.hxx>
12 #include <TopoDS_Vertex.hxx>
13 #include <TopoDS_Edge.hxx>
14 #include <TopoDS_Wire.hxx>
15 #include <TopoDS_Face.hxx>
16 #include <Geom_Surface.hxx>
17 #include <Geom2d_Line.hxx>
19 #include <gp_Pnt2d.hxx>
21 #include <gp_Dir2d.hxx>
23 #include <gp_Vec2d.hxx>
25 #include <OSD_Chronometer.hxx>
32 OSD_Chronometer simul,elspine,chemine;
35 //*********************************
36 // timing of the simulation
37 //*********************************
39 static Standard_Boolean ChFi3d_traceCHRON = Standard_False;
40 void ChFi3d_SettraceCHRON(const Standard_Boolean b)
41 { ChFi3d_traceCHRON = b; }
42 Standard_Boolean ChFi3d_GettraceCHRON()
43 { return ChFi3d_traceCHRON; }
45 //*********************************
46 // trace a line of path
47 //*********************************
49 static Standard_Boolean ChFi3d_traceDRAWWALK = Standard_False;
50 void ChFi3d_SettraceDRAWWALK(const Standard_Boolean b)
51 { ChFi3d_traceDRAWWALK = b; }
52 Standard_Boolean ChFi3d_GettraceDRAWWALK()
53 { return ChFi3d_traceDRAWWALK; }
55 //**********************************
56 // trace a line of intersection
57 //**********************************
59 static Standard_Boolean ChFi3d_traceDRAWINT = Standard_False;
60 void ChFi3d_SettraceDRAWINT(const Standard_Boolean b)
61 { ChFi3d_traceDRAWINT = b; }
62 Standard_Boolean ChFi3d_GettraceDRAWINT()
63 { return ChFi3d_traceDRAWINT; }
65 //*************************************************
66 // return surfaces of approximated fillets.
67 //*************************************************
69 static Standard_Boolean ChFi3d_traceDRAWFIL = Standard_False;
70 void ChFi3d_SettraceDRAWFIL(const Standard_Boolean b)
71 { ChFi3d_traceDRAWFIL = b; }
72 Standard_Boolean ChFi3d_GettraceDRAWFIL()
73 { return ChFi3d_traceDRAWFIL; }
76 //*************************************************
77 // return extended faces for the path.
78 //*************************************************
80 static Standard_Boolean ChFi3d_traceDRAWENLARGE = Standard_False;
81 void ChFi3d_SettraceDRAWENLARGE(const Standard_Boolean b)
82 { ChFi3d_traceDRAWENLARGE = b; }
83 Standard_Boolean ChFi3d_GettraceDRAWENLARGE()
84 { return ChFi3d_traceDRAWENLARGE; }
86 //*************************************************
87 // return the guideline for the triple corners.
88 //*************************************************
90 static Standard_Boolean ChFi3d_traceDRAWSPINE = Standard_False;
91 void ChFi3d_SettraceDRAWSPINE(const Standard_Boolean b)
92 { ChFi3d_traceDRAWSPINE = b; }
93 Standard_Boolean ChFi3d_GettraceDRAWSPINE()
94 { return ChFi3d_traceDRAWSPINE; }
96 //*************************************************
97 // set the type of guideline for the triple corners.
98 //*************************************************
100 void ChFi3d_SetcontextSPINEBEZIER(const Standard_Boolean b);
101 void ChFi3d_SetcontextSPINECIRCLE(const Standard_Boolean b);
102 void ChFi3d_SetcontextSPINECE(const Standard_Boolean b);
104 static Standard_Boolean ChFi3d_contextSPINEBEZIER = Standard_False;
105 void ChFi3d_SetcontextSPINEBEZIER(const Standard_Boolean b){
106 ChFi3d_contextSPINEBEZIER = b;
108 ChFi3d_SetcontextSPINECIRCLE(Standard_False);
109 ChFi3d_SetcontextSPINECE(Standard_False);
112 Standard_Boolean ChFi3d_GetcontextSPINEBEZIER()
113 { return ChFi3d_contextSPINEBEZIER; }
115 static Standard_Boolean ChFi3d_contextSPINECIRCLE = Standard_False;
116 void ChFi3d_SetcontextSPINECIRCLE(const Standard_Boolean b){
117 ChFi3d_contextSPINECIRCLE = b;
119 ChFi3d_SetcontextSPINEBEZIER(Standard_False);
120 ChFi3d_SetcontextSPINECE(Standard_False);
123 Standard_Boolean ChFi3d_GetcontextSPINECIRCLE()
124 { return ChFi3d_contextSPINECIRCLE; }
126 static Standard_Boolean ChFi3d_contextSPINECE = Standard_False;
127 void ChFi3d_SetcontextSPINECE(const Standard_Boolean b){
128 ChFi3d_contextSPINECE = b;
130 ChFi3d_SetcontextSPINEBEZIER(Standard_False);
131 ChFi3d_SetcontextSPINECIRCLE(Standard_False);
134 Standard_Boolean ChFi3d_GetcontextSPINECE()
135 { return ChFi3d_contextSPINECE; }
137 //*************************************************
138 // Forced passage by the path for KPart
139 //*************************************************
140 static Standard_Boolean ChFi3d_contextFORCEBLEND = Standard_False;
141 void ChFi3d_SetcontextFORCEBLEND(const Standard_Boolean b)
142 { ChFi3d_contextFORCEBLEND = b; }
143 Standard_Boolean ChFi3d_GetcontextFORCEBLEND()
144 { return ChFi3d_contextFORCEBLEND; }
146 static Standard_Boolean ChFi3d_contextFORCEFILLING = Standard_False;
147 void ChFi3d_SetcontextFORCEFILLING(const Standard_Boolean b)
148 { ChFi3d_contextFORCEFILLING = b; }
149 Standard_Boolean ChFi3d_GetcontextFORCEFILLING()
150 { return ChFi3d_contextFORCEFILLING; }
152 //*************************************************
153 // No optimization for approx
154 //*************************************************
155 static Standard_Boolean ChFi3d_contextNOOPT = Standard_False;
156 void ChFi3d_SetcontextNOOPT(const Standard_Boolean b)
157 { ChFi3d_contextNOOPT = b; }
158 Standard_Boolean ChFi3d_GetcontextNOOPT()
159 { return ChFi3d_contextNOOPT; }
161 // ***********************************************
162 // initialization and result of a chrono
163 //************************************************
164 Standard_EXPORT void ChFi3d_InitChron(OSD_Chronometer& ch)
170 Standard_EXPORT void ChFi3d_ResultChron( OSD_Chronometer & ch,
171 Standard_Real & time)
180 //==============================================================
181 // function : ChFi3d_CheckSurfData
182 // purpose : function allows to trace SurfData to check
183 // construction of all elements, namely pcurves
184 //==============================================================
186 static Standard_Integer NbSD = 0;
188 void ChFi3d_CheckSurfData(const TopOpeBRepDS_DataStructure& DStr,
189 const Handle(ChFiDS_SurfData)& Data)
191 //trace of the surface defined by the chamfer or the fillet
192 // corresponding to SurfData
194 Handle(Geom_Surface) surf = (DStr.Surface( Data->Surf())).Surface();
198 B.MakeFace(F,surf,0.);
202 TopoDS_Vertex V1,V2,V3,V4;
203 B.MakeVertex(V1,Data->VertexFirstOnS1().Point(),0.);
204 B.MakeVertex(V2,Data->VertexLastOnS1().Point(),0.);
205 B.MakeVertex(V3,Data->VertexLastOnS2().Point(),0.);
206 B.MakeVertex(V4,Data->VertexFirstOnS2().Point(),0.);
208 TopoDS_Edge E1,E2,E3,E4;
214 B.UpdateEdge(E1,Data->InterferenceOnS1().PCurveOnSurf(),F,0.);
215 B.UpdateEdge(E3,Data->InterferenceOnS2().PCurveOnSurf(),F,0.);
216 V1.Orientation(TopAbs_FORWARD);
218 B.UpdateVertex(V1,Data->InterferenceOnS1().FirstParameter(),E1,0.);
219 V2.Orientation(TopAbs_REVERSED);
221 B.UpdateVertex(V2,Data->InterferenceOnS1().LastParameter(),E1,0.);
224 V4.Orientation(TopAbs_FORWARD);
226 B.UpdateVertex(V4,Data->InterferenceOnS2().FirstParameter(),E3,0.);
227 V3.Orientation(TopAbs_REVERSED);
229 B.UpdateVertex(V3,Data->InterferenceOnS2().LastParameter(),E3,0.);
231 gp_Pnt2d pp1,pp2,pp3,pp4;
232 pp1 = Data->InterferenceOnS1().PCurveOnSurf()->
233 Value(Data->InterferenceOnS1().FirstParameter());
234 pp2 = Data->InterferenceOnS1().PCurveOnSurf()->
235 Value(Data->InterferenceOnS1().LastParameter());
236 pp3 = Data->InterferenceOnS2().PCurveOnSurf()->
237 Value(Data->InterferenceOnS2().LastParameter());
238 pp4 = Data->InterferenceOnS2().PCurveOnSurf()->
239 Value(Data->InterferenceOnS2().FirstParameter());
240 gp_Dir2d d1(gp_Vec2d(pp1,pp4));
241 gp_Dir2d d2(gp_Vec2d(pp2,pp3));
242 Handle(Geom2d_Line) l1 = new Geom2d_Line(pp1,d1);
243 Handle(Geom2d_Line) l2 = new Geom2d_Line(pp2,d2);
245 B.UpdateEdge(E4,l1,F,0.);
246 V1.Orientation(TopAbs_FORWARD);
248 B.UpdateVertex(V1,0.,E4,0.);
249 V4.Orientation(TopAbs_REVERSED);
251 B.UpdateVertex(V4,pp4.Distance(pp1),E4,0.);
253 B.UpdateEdge(E2,l2,F,0.);
254 V2.Orientation(TopAbs_FORWARD);
256 B.UpdateVertex(V2,0.,E2,0.);
257 V3.Orientation(TopAbs_REVERSED);
259 B.UpdateVertex(V3,pp3.Distance(pp2),E2,0.);
262 ppp = surf->Value(pp1.X(),pp1.Y());
263 pw1 = surf->Value(0.9*pp1.X()+0.1*pp2.X(),0.9*pp1.Y()+0.1*pp2.Y());
264 pw2 = surf->Value(0.9*pp1.X()+0.1*pp4.X(),0.9*pp1.Y()+0.1*pp4.Y());
267 gp_Vec Vwire = vv1^vv2;
269 surf->D1(pp1.X(),pp1.Y(),pw1,vv1,vv2);
270 gp_Vec Vsurf = vv1^vv2;
271 Standard_Boolean rev = Vsurf.Dot(Vwire)<=0.;
273 E1.Orientation(TopAbs_FORWARD);
274 E2.Orientation(TopAbs_FORWARD);
275 E3.Orientation(TopAbs_REVERSED);
276 E4.Orientation(TopAbs_REVERSED);
278 E1.Orientation(TopAbs_REVERSED);
279 E2.Orientation(TopAbs_REVERSED);
280 E3.Orientation(TopAbs_FORWARD);
281 E4.Orientation(TopAbs_FORWARD);
288 W.Orientation(TopAbs_FORWARD);
293 char* name = new char[100];
294 sprintf(name,"fillet_%d",NbSD++);