7fd59977 |
1 | // File: TopOpeBRep_FacesFiller_VPonR.cxx |
2 | // Created: Fri Aug 4 10:57:30 1995 |
3 | // Author: Jean Yves LEBEY |
4 | // <jyl@meteox> |
5 | |
6 | #include <TopOpeBRep_FacesFiller.ixx> |
7 | |
8 | #ifdef DRAW |
9 | #include <TopOpeBRepDS_DRAW.hxx> |
10 | #endif |
11 | |
12 | #include <Standard_DomainError.hxx> |
13 | #include <Geom_Surface.hxx> |
14 | #include <Geom_Curve.hxx> |
15 | #include <Geom2d_Curve.hxx> |
16 | #include <Precision.hxx> |
17 | #include <TopoDS.hxx> |
18 | #include <TopExp.hxx> |
19 | #include <BRep_Tool.hxx> |
20 | #include <gp_Vec.hxx> |
21 | |
22 | #include <TopOpeBRepTool_EXPORT.hxx> |
23 | #include <TopOpeBRepTool_SC.hxx> |
24 | #include <TopOpeBRepTool_TOOL.hxx> |
25 | #include <TopOpeBRepTool_ShapeTool.hxx> |
26 | #include <TopOpeBRepTool_makeTransition.hxx> |
27 | |
28 | #include <TopOpeBRepDS_define.hxx> |
29 | #include <TopOpeBRepDS_EXPORT.hxx> |
30 | #include <TopOpeBRepDS_ProcessInterferencesTool.hxx> |
31 | #include <TopOpeBRepDS_Config.hxx> |
32 | #include <TopOpeBRepDS_Curve.hxx> |
33 | #include <TopOpeBRepDS_PointIterator.hxx> |
34 | #include <TopOpeBRepDS_Dumper.hxx> |
35 | |
36 | #include <TopOpeBRep_define.hxx> |
37 | #include <TopOpeBRep_FFTransitionTool.hxx> |
38 | #include <TopOpeBRep_PointGeomTool.hxx> |
39 | #include <TopOpeBRep.hxx> |
40 | |
41 | #define M_ON(st) (st == TopAbs_ON) |
42 | #define M_UNKNOWN(st) (st == TopAbs_UNKNOWN) |
43 | #define M_REVERSED(st) (st == TopAbs_REVERSED) |
44 | |
45 | #ifdef DEB |
46 | Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceISTO(); |
47 | Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDSF(); |
48 | Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDSP(); |
49 | Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer i); |
50 | Standard_EXPORT Standard_Boolean TopOpeBRep_GettraceNVP(Standard_Integer a,Standard_Integer b,Standard_Integer c,Standard_Integer d,Standard_Integer e); |
51 | Standard_EXPORT Standard_Boolean GLOBAL_bvpr = Standard_False;void debvpr(){}; |
52 | Standard_EXPORT void debvprmess(Standard_Integer f1,Standard_Integer f2,Standard_Integer il,Standard_Integer vp,Standard_Integer si) |
53 | {cout<<"f1,f2,il,vp,si : "<<f1<<","<<f2<<","<<il<<","<<vp<<","<<si<<endl;cout.flush();debvpr();} |
54 | void debpoint(Standard_Integer i) {cout<<"+ debpoint"<<i<<endl;} |
55 | void debvertex(Standard_Integer i){cout<<"+ debvertex"<<i<<endl;} |
56 | static void FUN_Raise() {cout <<"FAILURE IN TopOpeBRep_FacesFiller::ProcessVPonR"<<endl;} |
57 | |
58 | Standard_EXPORT void debarc(const Standard_Integer i) {cout<<"+ debarc "<<i<<endl;} |
59 | Standard_EXPORT void debooarc(const Standard_Integer i) {cout<<"+ debooarc "<<i<<endl;} |
60 | #endif |
61 | |
62 | Standard_EXPORT Standard_Boolean FDS_LOIinfsup(const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Edge& E,const Standard_Real pE,const Standard_Integer GIP, |
63 | const TopOpeBRepDS_ListOfInterference& LOI, Standard_Real& pbef, Standard_Real& paft, Standard_Boolean& isonboundper); |
64 | Standard_EXPORT Standard_Boolean FUNBREP_topokpart |
65 | (const Handle(TopOpeBRepDS_Interference)& Ifound,const TopOpeBRepDS_ListOfInterference& DSCIL, |
66 | const TopOpeBRep_LineInter& L,const TopOpeBRep_VPointInter& VP, |
67 | const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& E,const TopoDS_Shape& F,const Standard_Real toluv, |
68 | Standard_Real& parline,TopOpeBRepDS_Transition& transLine); |
69 | |
70 | //----------------------------------------------------------------------- |
71 | // Search, among a list of interferences accessed by the iterator <IT>, |
72 | // a geometry whose parameter on edge point is identical to <par>. |
73 | // return True if such an interference has been found, False else. |
74 | // if True, iterator <IT> points (by the Value() method) on the first |
75 | // interference found. |
76 | //----------------------------------------------------------------------- |
77 | |
78 | Standard_EXPORT Standard_Boolean FUN_GetGonParameter |
79 | (TopOpeBRepDS_ListIteratorOfListOfInterference& it, const Standard_Real& par, const Standard_Real& tolp, |
80 | Standard_Integer& G, TopOpeBRepDS_Kind& GT) |
81 | { |
82 | while (it.More()) { |
83 | const Handle(TopOpeBRepDS_Interference)& I = it.Value(); |
84 | Standard_Real ipar; Standard_Boolean haspar = FDS_Parameter(I,ipar); |
85 | if (!haspar) {it.Next(); continue;} |
86 | Standard_Boolean samepar = (Abs(par-ipar) < tolp); |
87 | if (!samepar){it.Next(); continue;} |
88 | TopOpeBRepDS_Kind ST; Standard_Integer S; FDS_data(I,GT,G,ST,S); |
89 | return Standard_True; |
90 | } |
91 | return Standard_False; |
92 | } |
93 | |
94 | static Standard_Boolean FUN_INlos(const TopoDS_Shape& S, const TopTools_ListOfShape& loS) |
95 | { |
96 | TopTools_ListIteratorOfListOfShape it(loS); |
97 | for (; it.More(); it.Next()) |
98 | if (it.Value().IsSame(S)) return Standard_True; |
99 | return Standard_False; |
100 | } |
101 | |
102 | //======================================================================= |
103 | //function : ProcessVPIonR |
104 | //purpose : |
105 | //======================================================================= |
106 | |
107 | void TopOpeBRep_FacesFiller::ProcessVPIonR |
108 | (TopOpeBRep_VPointInterIterator& VPI, |
109 | const TopOpeBRepDS_Transition& Trans, |
110 | const TopoDS_Shape& Face, |
111 | const Standard_Integer ShapeIndex) //1,2 |
112 | { |
113 | const TopOpeBRep_VPointInter& VP = VPI.CurrentVP(); |
114 | ProcessVPonR(VP,Trans,Face,ShapeIndex); |
115 | } // ProcessVPIonR |
116 | |
117 | //----------------------------------------------------------------------- |
118 | static void FUN_transForWL |
119 | (const TopOpeBRep_LineInter& L, |
120 | const Standard_Integer iVP, |
121 | const Standard_Integer ShapeIndex, |
122 | TopOpeBRepDS_Transition& transLine) |
123 | //----------------------------------------------------------------------- |
124 | { |
125 | // premier VP avec indetermine : on prend le complement |
126 | // du suivant determine |
127 | TopOpeBRep_VPointInterIterator VPIbis; |
128 | for (VPIbis.Init(L); |
129 | VPIbis.More(); VPIbis.Next()) { |
130 | const TopOpeBRep_VPointInter& VPbis = VPIbis.CurrentVP(); |
131 | Standard_Boolean tokeep = VPbis.Keep(); |
132 | if ( !tokeep ) continue; |
133 | Standard_Integer iVPbis = VPIbis.CurrentVPIndex(); |
134 | if ( iVPbis <= iVP ) continue; |
135 | Standard_Integer absindexbis = VPbis.ShapeIndex(); // 0,1,2,3 |
136 | Standard_Integer shapeindexbis = (absindexbis == 3) ? ShapeIndex : absindexbis; |
137 | if ( shapeindexbis == 0 ) continue; |
138 | const TopoDS_Shape& edgebis = VPbis.Edge(shapeindexbis); |
139 | TopAbs_Orientation edgeoribis = edgebis.Orientation(); |
140 | TopOpeBRepDS_Transition transLinebis; |
141 | transLinebis = |
142 | TopOpeBRep_FFTransitionTool::ProcessLineTransition |
143 | (VPbis,shapeindexbis,edgeoribis); |
144 | Standard_Boolean trliunkbis = transLinebis.IsUnknown(); |
145 | if ( trliunkbis ) continue; |
146 | transLine = transLinebis.Complement(); |
147 | break; |
148 | } |
149 | } |
150 | |
151 | //----------------------------------------------------------------------- |
152 | static void FUN_VPgeometryfound |
153 | (TopOpeBRep_FacesFiller& FF, |
154 | const TopOpeBRep_LineInter& L, |
155 | const TopOpeBRep_VPointInter& VP, |
156 | const Standard_Integer ShapeIndex, |
157 | const Handle(TopOpeBRepDS_HDataStructure)& HDS, |
158 | const TopOpeBRepDS_ListOfInterference& DSCIL, |
159 | TopOpeBRepDS_Kind& PVKind, Standard_Integer& PVIndex, |
160 | Standard_Boolean& EPIfound, Handle(TopOpeBRepDS_Interference)& IEPI, |
161 | Standard_Boolean& CPIfound, Handle(TopOpeBRepDS_Interference)& ICPI, |
162 | Standard_Boolean& OOEPIfound, Handle(TopOpeBRepDS_Interference)& IOOEPI) // (only if on2edges) |
163 | //----------------------------------------------------------------------- |
164 | { |
165 | Standard_Boolean Lrest = (L.TypeLineCurve() == TopOpeBRep_RESTRICTION); |
166 | TopoDS_Shape Erest; Standard_Real parErest=0; Standard_Integer rkErest=0; |
167 | if (Lrest) { |
168 | Erest = L.Arc(); parErest = VP.ParameterOnLine(); |
169 | Standard_Boolean isedge1 = L.ArcIsEdge(1); Standard_Boolean isedge2 = L.ArcIsEdge(2); |
170 | rkErest = (isedge1) ? 1 : (isedge2) ? 2 : 0; |
171 | } |
172 | |
173 | Standard_Integer absindex = VP.ShapeIndex(); |
174 | Standard_Integer OOabsindex = (absindex == 1) ? 2 : 1; |
175 | Standard_Boolean OOShapeIndex = (ShapeIndex == 1) ? 2 : 1; |
176 | Standard_Boolean on2edges = (absindex == 3) || (Lrest && (rkErest == OOabsindex)); |
177 | TopoDS_Shape edge = (rkErest == ShapeIndex)? Erest : VP.Edge(ShapeIndex); |
178 | |
179 | PVIndex = 0; // POINT or VERTEX index |
180 | EPIfound = CPIfound = OOEPIfound = Standard_False; |
181 | Standard_Real par = (rkErest == ShapeIndex)? parErest : VP.EdgeParameter(ShapeIndex); |
182 | Standard_Real tole = FUN_tool_maxtol(edge); |
183 | Standard_Real tolp = Precision::Parametric(tole); |
184 | |
185 | const TopOpeBRepDS_DataStructure& BDS = HDS->DS(); |
186 | if (BDS.HasShape(edge)) { |
7fd59977 |
187 | const TopOpeBRepDS_ListOfInterference& EPIL = BDS.ShapeInterferences(edge); |
188 | TopOpeBRepDS_ListIteratorOfListOfInterference itEPIL(EPIL); |
189 | EPIfound = FF.GetGeometry(itEPIL,VP,PVIndex,PVKind); |
190 | if (!EPIfound) { |
191 | itEPIL.Initialize(EPIL); |
192 | EPIfound = FUN_GetGonParameter(itEPIL,par,tolp,PVIndex,PVKind); |
193 | } |
194 | if (EPIfound) IEPI = itEPIL.Value(); |
195 | } |
196 | |
197 | TopOpeBRepDS_ListIteratorOfListOfInterference itCPIL(DSCIL); |
198 | #ifdef DEB |
199 | Standard_Boolean trc = Standard_False; |
200 | if (trc) {TopOpeBRepDS_Dumper DSD(HDS); TCollection_AsciiString aa("DSCIL :"); |
201 | DSD.DumpLOI(DSCIL,cout,aa);} |
202 | #endif |
203 | CPIfound = FF.GetGeometry(itCPIL,VP,PVIndex,PVKind); |
204 | if (CPIfound) ICPI = itCPIL.Value(); |
205 | |
206 | // - <VP> is of shapeindex 3 : is on <edge> and <OOedge>, |
207 | // - <VP> is of shapeindex <ShapeIndex> and <VP> is given ON another edge <OOedge> |
208 | // If <OOedge> is defined, we look among the list of interferences attached |
209 | // to the other edge <OOedge> for an interference of geometry falling into <VP>'s. |
210 | |
211 | Standard_Boolean hasOOedge = Standard_True; |
212 | if (on2edges) hasOOedge = Standard_True; |
213 | else hasOOedge = (VP.State(OOShapeIndex) == TopAbs_ON); |
214 | if ( hasOOedge ) { |
215 | TopoDS_Shape OOedge; |
216 | #ifndef DEB |
217 | if (on2edges) OOedge = ((signed) rkErest == (signed) OOShapeIndex)? Erest : VP.Edge(OOShapeIndex); |
218 | #else |
219 | if (on2edges) OOedge = (rkErest == OOShapeIndex)? Erest : VP.Edge(OOShapeIndex); |
220 | #endif |
221 | else OOedge = VP.EdgeON(OOShapeIndex); |
222 | Standard_Real OOpar = 0.; |
223 | #ifndef DEB |
224 | if (on2edges) OOpar = ((signed) rkErest == (signed) OOShapeIndex)? parErest : VP.EdgeParameter(OOShapeIndex); |
225 | #else |
226 | if (on2edges) OOpar = (rkErest == OOShapeIndex)? parErest : VP.EdgeParameter(OOShapeIndex); |
227 | #endif |
228 | else OOpar = VP.EdgeONParameter(OOShapeIndex); |
229 | Standard_Real tolOOe = FUN_tool_maxtol(OOedge); |
230 | Standard_Real OOtolp = Precision::Parametric(tolOOe); |
231 | if (BDS.HasShape(OOedge)) { |
7fd59977 |
232 | const TopOpeBRepDS_ListOfInterference& OOEPIL = BDS.ShapeInterferences(OOedge); |
233 | TopOpeBRepDS_ListIteratorOfListOfInterference OOitEPIL(OOEPIL); |
234 | OOEPIfound = FF.GetGeometry(OOitEPIL,VP,PVIndex,PVKind); |
235 | if (!OOEPIfound) { |
236 | OOitEPIL.Initialize(OOEPIL); |
237 | FUN_GetGonParameter(OOitEPIL,OOpar,OOtolp,PVIndex,PVKind); |
238 | } |
239 | if (OOEPIfound) IOOEPI = OOitEPIL.Value(); |
240 | } |
241 | } |
242 | } |
243 | |
244 | #define M_FINDVP (0) // only look for new vp |
245 | #define M_MKNEWVP (1) // only make newvp |
246 | #define M_GETVP (2) // steps (0) [+(1) if (O) fails] |
247 | |
248 | //----------------------------------------------------------------------- |
249 | Standard_EXPORT void FUN_VPIndex |
250 | (TopOpeBRep_FacesFiller& FF, |
251 | const TopOpeBRep_LineInter& L, |
252 | const TopOpeBRep_VPointInter& VP, |
253 | const Standard_Integer ShapeIndex, |
254 | const Handle(TopOpeBRepDS_HDataStructure)& HDS, |
255 | const TopOpeBRepDS_ListOfInterference& DSCIL, |
256 | TopOpeBRepDS_Kind& PVKind, Standard_Integer& PVIndex, // out |
257 | Standard_Boolean& EPIfound, Handle(TopOpeBRepDS_Interference)& IEPI, // out |
258 | Standard_Boolean& CPIfound, Handle(TopOpeBRepDS_Interference)& ICPI, // out |
259 | const Standard_Integer mkVP) |
260 | //----------------------------------------------------------------------- |
261 | { |
262 | PVIndex = 0; // POINT or VERTEX index |
263 | Standard_Integer OOShapeIndex = (ShapeIndex == 1) ? 2 : 1; |
264 | Standard_Boolean SIisvertex = VP.IsVertex(ShapeIndex); |
265 | Standard_Boolean OOisvertex = VP.IsVertex(OOShapeIndex); |
266 | |
267 | // search for an interference with a equal 3D geometry |
268 | // if found, set PVIndex to index of geometry found |
269 | // if not found, make a new geometry PVIndex with 3d point or vertex |
270 | |
271 | Standard_Boolean OOEPIfound = Standard_False; |
272 | Handle(TopOpeBRepDS_Interference) IOOEPI; |
273 | if ((mkVP == M_FINDVP)||(mkVP == M_GETVP)) { |
274 | FUN_VPgeometryfound (FF,L,VP,ShapeIndex,HDS,DSCIL, //in |
275 | PVKind,PVIndex, // out |
276 | EPIfound,IEPI, // out |
277 | CPIfound,ICPI, // out |
278 | OOEPIfound,IOOEPI); // out (only if on2edges) |
279 | if (mkVP == M_FINDVP) { |
280 | //JMB 27 Dec 1999 |
281 | //modified by NIZHNY-MZV Tue Apr 25 09:27:15 2000 |
282 | if (!EPIfound && !CPIfound && !OOEPIfound) |
283 | PVIndex = 0; // if we just want to find (M_FINDVP) then we must readjust PVIndex to 0 |
284 | // because OOEPIfound is not treated in the upper function. The upper function |
285 | // will detect that we found a geometry because PVIndex != 0 but as EPIfound and |
286 | // CPIfound are FALSE, the resulting VP geometry give unpredictable results. |
287 | return; |
288 | } |
289 | } |
290 | // Gfound = VP corresponds with an existing geometry of ShapeIndex |
291 | Standard_Boolean Gfound = ( EPIfound || CPIfound); |
292 | // Gfound = or with an existing geometry of OOShapeIndex |
293 | Gfound = Gfound || OOEPIfound; |
294 | |
295 | Standard_Boolean on2edges = (VP.ShapeIndex() == 3); |
296 | Standard_Boolean hasOOedge = Standard_True; |
297 | if (on2edges) hasOOedge = Standard_True; |
298 | else hasOOedge = (VP.State(OOShapeIndex) == TopAbs_ON); |
299 | // If v shares same domain with a vertex of the other shape, |
300 | // v has already been stored in the DS |
301 | |
302 | if (PVIndex == 0) PVKind = (SIisvertex || OOisvertex) ? TopOpeBRepDS_VERTEX : TopOpeBRepDS_POINT; |
303 | |
304 | if ( hasOOedge && !Gfound ) { |
305 | if ( !OOEPIfound ) { |
306 | if ( SIisvertex ) PVIndex = FF.MakeGeometry(VP,ShapeIndex,PVKind); |
307 | else if ( OOisvertex ) PVIndex = FF.MakeGeometry(VP,OOShapeIndex,PVKind); |
308 | else PVIndex = FF.MakeGeometry(VP,ShapeIndex,PVKind); |
309 | } |
310 | } |
311 | if ( !hasOOedge && !Gfound ) { |
312 | Standard_Boolean found = FF.GetFFGeometry(VP,PVKind,PVIndex); |
313 | if ( !found) { |
314 | if ( SIisvertex ) PVIndex = FF.MakeGeometry(VP,ShapeIndex,PVKind); |
315 | else if ( OOisvertex ) PVIndex = FF.MakeGeometry(VP,OOShapeIndex,PVKind); |
316 | else PVIndex = FF.MakeGeometry(VP,ShapeIndex,PVKind); |
317 | } |
318 | } |
319 | } // FUN_VPIndex |
320 | |
321 | //----------------------------------------------------------------------- |
322 | static Standard_Boolean FUN_LineRestF |
323 | (const TopoDS_Face& F, const TopOpeBRep_LineInter& L, |
324 | const TopTools_ListOfShape& ERL, TopoDS_Edge& ER) |
325 | //----------------------------------------------------------------------- |
326 | { |
327 | // returns true if <L> is ON a restriction <ER> of <F> |
328 | // <ERL> is the list of the faces intersector. |
329 | // prequesitory : <L> is on edge |
330 | TopTools_IndexedMapOfShape mapE; |
331 | TopExp::MapShapes(F,TopAbs_EDGE,mapE); |
332 | TopTools_ListIteratorOfListOfShape itER(ERL); |
333 | TopTools_ListOfShape ERLonF; |
334 | for (; itER.More(); itER.Next()){ |
335 | const TopoDS_Shape& e = itER.Value(); |
336 | if (mapE.Contains(e)) ERLonF.Append(e); |
337 | } |
338 | itER.Initialize(ERLonF); |
339 | TopTools_ListOfShape ERLonFonL; |
340 | for (; itER.More(); itER.Next()){ |
341 | const TopoDS_Shape& e = itER.Value(); |
342 | TopTools_ListOfShape eL; eL.Append(e); |
343 | Standard_Boolean isonL = TopOpeBRep_FacesFiller::LSameDomainERL(L,eL); |
344 | if (isonL) ERLonFonL.Append(e); |
345 | } |
346 | // <L> is on at most one edge restriction. |
347 | if (ERLonFonL.Extent() != 1) return Standard_False; |
348 | ER = TopoDS::Edge(ERLonFonL.First()); |
349 | return Standard_True; |
350 | } |
351 | |
352 | //----------------------------------------------------------------------- |
353 | Standard_EXPORT Standard_Boolean FUN_newtransEdge |
354 | (const Handle(TopOpeBRepDS_HDataStructure) HDS, |
355 | const TopOpeBRep_FacesFiller& FF, |
356 | const TopOpeBRep_LineInter& L, |
357 | const Standard_Boolean& Lonrest, |
358 | const TopOpeBRep_VPointInter& VP, |
359 | const TopOpeBRepDS_Kind PVKind,const Standard_Integer PVIndex, |
360 | const Standard_Integer& OOShapeIndex, |
361 | const TopoDS_Edge& edge, const TopTools_ListOfShape& ERL, TopOpeBRepDS_Transition& T) |
362 | //----------------------------------------------------------------------- |
363 | { |
364 | T.Before(TopAbs_UNKNOWN); T.After(TopAbs_UNKNOWN); |
365 | const TopoDS_Face& OOface = FF.Face(OOShapeIndex); |
366 | TopoDS_Face FIE = OOface; |
367 | { |
368 | TopAbs_Orientation oFIE = FIE.Orientation(); |
369 | if (oFIE == TopAbs_INTERNAL || oFIE == TopAbs_EXTERNAL) { |
370 | T.Set(oFIE); |
371 | return Standard_True; |
372 | } |
373 | } |
374 | |
375 | // compute of transition on edge <edge> while crossing <VP>. |
376 | // <VP> given by <paredge> on <edge>, <uv> on <OOface>, |
377 | // <paronline> on Line. |
378 | |
379 | // <C>, <pf>, <pl>, <paredge> : |
380 | Standard_Real paredge; Standard_Boolean ok = VP.ParonE(edge,paredge); if (!ok) return Standard_False; |
381 | |
382 | Standard_Real par1,par2; |
383 | if (HDS->HasShape(edge)) { |
384 | Standard_Boolean isonper; |
385 | if (PVIndex == 0) FDS_getupperlower(HDS,HDS->DS().Shape(edge),paredge,par1,par2); |
386 | else FDS_LOIinfsup(HDS->DS(),edge,paredge,PVKind,PVIndex, |
387 | HDS->DS().ShapeInterferences(edge), |
388 | par1,par2,isonper); |
389 | } |
390 | else |
391 | FUN_tool_bounds(edge,par1,par2); |
392 | |
393 | gp_Pnt2d uv = VP.SurfaceParameters(OOShapeIndex); |
394 | |
395 | #ifdef DEB |
396 | TopOpeBRepDS_Transition Tr; |
397 | #endif |
398 | // <Tr> relative to 3d <OOface> matter, |
399 | // we take into account <Tr> / 2d <OOface> only if <edge> is normal to <OOface> |
400 | Standard_Real tola = Precision::Angular()*1.e+4; //dealing with tolerances |
401 | Standard_Boolean EtgOOF = FUN_tool_EtgF(paredge,edge,uv,OOface,tola); |
402 | Standard_Boolean inERL = FUN_INlos(edge,ERL); |
403 | Standard_Boolean isse = HDS->DS().IsSectionEdge(edge); |
404 | Standard_Boolean rest = inERL || isse; |
405 | Standard_Boolean interf2d = EtgOOF && Lonrest && rest; |
406 | Standard_Boolean interf3dtg = EtgOOF && rest && !interf2d; // xpu260898 :cto902D6,(e15,p3,f9) |
7fd59977 |
407 | |
408 | Standard_Real factor = 1.e-2; |
409 | TopOpeBRepTool_makeTransition MKT; |
410 | ok = MKT.Initialize(edge,par1,par2,paredge, OOface,uv, factor); |
411 | if (!ok) return Standard_False; |
412 | Standard_Boolean isT2d = MKT.IsT2d(); |
413 | interf2d = interf2d && isT2d; |
414 | |
415 | TopAbs_State stb,sta; |
416 | if (interf2d) { |
417 | // <tgLine> : |
418 | TopoDS_Edge OOER; Standard_Boolean onOOface = Standard_False; |
419 | TopOpeBRep_TypeLineCurve typL = L.TypeLineCurve(); |
420 | if (typL == TopOpeBRep_RESTRICTION) {onOOface = Standard_True; OOER = TopoDS::Edge(L.Arc());} |
421 | else {onOOface = ::FUN_LineRestF(OOface,L,ERL,OOER);} |
422 | if (!onOOface) return Standard_False; |
423 | |
424 | Standard_Real OOpar; ok = VP.ParonE(OOER,OOpar); |
425 | if (!ok) ok = FUN_tool_parE(edge,paredge,OOER,OOpar); |
426 | if (!ok) return Standard_False; |
427 | |
428 | //xpu051098 : cto900L4 (edge18,OOface5) |
429 | ok = MKT.SetRest(OOER,OOpar); |
430 | if (!ok) return Standard_False; |
431 | } |
432 | else if (interf3dtg) { |
433 | Standard_Integer absindex = VP.ShapeIndex(); // 0,1,2,3 |
434 | Standard_Boolean on2edges = (absindex == 3); |
435 | Standard_Boolean hasONedge = (VP.State(OOShapeIndex) == TopAbs_ON); |
436 | Standard_Boolean hasOOedge = (on2edges) ? Standard_True : hasONedge; |
437 | |
438 | if ( hasOOedge ) { |
439 | TopoDS_Edge OOedge; Standard_Real OOpar = 1.e7; |
440 | if (on2edges) |
441 | {OOedge = TopoDS::Edge(VP.Edge(OOShapeIndex)); OOpar = VP.EdgeParameter(OOShapeIndex);} |
442 | else |
443 | {OOedge = TopoDS::Edge(VP.EdgeON(OOShapeIndex)); OOpar = VP.EdgeONParameter(OOShapeIndex);} |
444 | |
445 | ok = MKT.SetRest(OOedge,OOpar); |
446 | if (!ok) return Standard_False; |
447 | } |
448 | } |
449 | |
450 | ok = MKT.MkTonE(stb,sta); |
451 | if (!ok) return Standard_False; |
452 | T.Before(stb); T.After(sta); |
453 | return Standard_True; |
454 | } // FUN_newtransEdge |
455 | |
456 | //----------------------------------------------------------------------- |
457 | static void FUN_ScanInterfList(const TopOpeBRepDS_Point& PDS, const Handle(TopOpeBRepDS_HDataStructure) HDS, |
458 | const TopOpeBRepDS_ListOfInterference& loI, TopOpeBRepDS_ListOfInterference& loIfound) |
459 | //----------------------------------------------------------------------- |
460 | { |
461 | // looks among the list of interferences <loI> for interferences |
462 | // of geometry falling into <PDS>, add them to <loIfound> |
463 | TopOpeBRepDS_ListIteratorOfListOfInterference it(loI); |
464 | while ( it.More()) { |
465 | Standard_Boolean found = HDS->ScanInterfList(it,PDS); |
466 | if (found) { |
467 | loIfound.Append(it.Value()); |
468 | if (it.More()) it.Next(); |
469 | } |
470 | else return; |
471 | } |
472 | } |
473 | |
474 | static Standard_Boolean FUN_selectTRAISHAinterference(const TopOpeBRepDS_ListOfInterference& lI, const Standard_Integer ITRASHA, |
475 | TopOpeBRepDS_ListOfInterference& lITRAonISHA) |
476 | // purpose : <lITRAonISHA> = {I = (T on ITRASHA,G,S)} |
477 | { |
478 | lITRAonISHA.Clear(); |
479 | TopOpeBRepDS_ListIteratorOfListOfInterference it(lI); |
480 | for (; it.More(); it.Next()) { |
481 | const Handle(TopOpeBRepDS_Interference)& I = it.Value(); |
482 | const TopOpeBRepDS_Transition& T = I->Transition(); |
483 | Standard_Integer iTRASHA = T.Index(); |
484 | // BUG : |
485 | //POP : pb : comparaison entre 2 enum differentes : on prend la valeur correspondante |
486 | if (T.Orientation(TopAbs_IN) == TopAbs_EXTERNAL) continue; //xpu030998 |
487 | // if (T.Orientation(TopAbs_IN) == TopAbs_UNKNOWN) continue; //xpu030998 |
488 | if (iTRASHA == ITRASHA) lITRAonISHA.Append(I); |
489 | } |
490 | Standard_Boolean noIfound = lITRAonISHA.IsEmpty(); |
491 | return !noIfound; |
492 | } |
493 | |
494 | static Standard_Boolean FUN_selectGinterference(const TopOpeBRepDS_ListOfInterference& lI, const Standard_Integer G, |
495 | TopOpeBRepDS_ListOfInterference& lIonG) |
496 | { |
497 | lIonG.Clear(); |
498 | TopOpeBRepDS_ListIteratorOfListOfInterference it(lI); |
499 | for (; it.More(); it.Next()) { |
500 | const Handle(TopOpeBRepDS_Interference)& I = it.Value(); |
501 | if (I->Geometry() == G) lIonG.Append(I); |
502 | } |
503 | Standard_Boolean noIfound = lIonG.IsEmpty(); |
504 | return !noIfound; |
505 | } |
506 | |
507 | static Standard_Boolean FUN_sameGsameS(const TopOpeBRepDS_ListOfInterference& loI, const Standard_Integer& G, const Standard_Integer& S, |
508 | TopOpeBRepDS_ListOfInterference& loIfound) |
509 | { |
510 | loIfound.Clear(); |
511 | // Gets among the list <loI> the interferences of : |
512 | // geometry <G>, and support <S> |
513 | TopOpeBRepDS_PointIterator PI(loI); |
514 | for (; PI.More(); PI.Next()) { |
515 | Handle(TopOpeBRepDS_Interference) EPI = PI.Value(); |
516 | Standard_Integer GEPI = EPI->Geometry(); Standard_Integer SEPI = EPI->Support(); |
517 | if (GEPI == G && SEPI == S) loIfound.Append(EPI); |
518 | } |
519 | return (loIfound.Extent() > 0); |
520 | } |
521 | |
522 | //----------------------------------------------------------------------- |
523 | static void FUN_processCPI |
524 | (TopOpeBRep_FacesFiller& FF, |
525 | const TopOpeBRep_VPointInter& VP, |
526 | const TopoDS_Shape& F, |
527 | const Standard_Integer ShapeIndex, |
528 | const TopOpeBRep_LineInter& L, |
529 | TopOpeBRepDS_PDataStructure pDS, |
530 | const TopOpeBRepDS_Transition& transLine, |
531 | const TopOpeBRepDS_ListOfInterference& DSCIL, |
532 | const Handle(TopOpeBRepDS_Interference)& Ifound, |
533 | const Standard_Boolean& Gfound, |
534 | const TopOpeBRepDS_Kind& PVKind,const Standard_Integer& PVIndex, |
535 | Standard_Integer& keptVPnbr) |
536 | //----------------------------------------------------------------------- |
537 | { |
7fd59977 |
538 | Standard_Integer OOShapeIndex = (ShapeIndex == 1) ? 2 : 1; |
539 | |
540 | TopOpeBRepDS_Transition ttransLine = transLine; |
541 | // prequesitory : current line is not on edge. |
542 | Standard_Real parline = VP.ParameterOnLine(); |
543 | Standard_Boolean SIisvertex = VP.IsVertex(ShapeIndex); |
544 | Standard_Boolean OOisvertex = VP.IsVertex(OOShapeIndex); |
545 | const TopoDS_Shape& E = VP.Edge(ShapeIndex); |
546 | |
547 | // xpu010299 : we do not keep interferences with same parameters on curve |
548 | // PRO16120(f3,f4 -> null c1) |
549 | if (!DSCIL.IsEmpty()) { |
550 | Standard_Real par = FDS_Parameter(DSCIL.Last()); // parameter on curve |
551 | Standard_Real dd = Abs(par-parline); // en fait, ce sont des entiers |
552 | if (dd == 0) return; |
553 | } |
554 | |
555 | // dist(p2d1,p2d2) < toluv => p2d1, p2d2 are considered equal. |
556 | // NYI : compute uvtol with the original faces. By default, we set toluv = TolClass |
557 | Standard_Real toluv = 1.e-8; |
558 | Standard_Boolean keep = FUNBREP_topokpart(Ifound,DSCIL,L,VP,(*pDS),E,F,toluv,parline,ttransLine); |
559 | |
560 | #ifdef DEB |
561 | Standard_Integer trc=TopOpeBRepDS_GettraceDSF(); |
562 | if (trc){if(keep)cout<<"\t-> on garde";else cout<<"\t-> on jette";cout<<endl;} |
563 | #endif |
564 | |
565 | if (keep) { |
566 | keptVPnbr++; |
567 | if (keptVPnbr > 2) keep = Standard_False; |
568 | } |
569 | if (!keep) return; |
570 | |
571 | Handle(TopOpeBRepDS_Interference) CPI; |
572 | { |
573 | TopOpeBRepDS_Kind GKCPV; |
574 | if (Gfound) GKCPV = PVKind; |
575 | else GKCPV = (SIisvertex || OOisvertex) ? TopOpeBRepDS_VERTEX : TopOpeBRepDS_POINT; |
576 | |
577 | CPI = ::MakeCPVInterference(ttransLine,0,PVIndex,parline,GKCPV); |
578 | FF.StoreCurveInterference(CPI); |
579 | } |
580 | } |
581 | |
582 | static Standard_Boolean FUN_onedge(const TopOpeBRepDS_Point& PDS, const TopoDS_Edge& E) |
583 | { |
584 | gp_Pnt P = PDS.Point(); |
585 | Standard_Real tolP = PDS.Tolerance(); Standard_Real tolE = BRep_Tool::Tolerance(E); |
586 | Standard_Real tol = Max(tolP,tolE); |
587 | TopoDS_Vertex vf,vl; TopExp::Vertices(E,vf,vl); |
588 | gp_Pnt pf = BRep_Tool::Pnt(vf); Standard_Boolean isonf = P.IsEqual(pf,tol); |
589 | gp_Pnt pl = BRep_Tool::Pnt(vl); Standard_Boolean isonl = P.IsEqual(pl,tol); |
590 | return isonf || isonl; |
591 | } |
592 | |
593 | #ifdef DEB |
594 | Standard_EXPORT void funraise() {cout<<"!!!!!!!!!! PVIndex = 0 !!!!!!!!!!"<<endl;} |
595 | #endif |
596 | |
597 | //======================================================================= |
598 | //function : ProcessVPonR |
599 | //purpose : |
600 | //======================================================================= |
601 | |
602 | void TopOpeBRep_FacesFiller::ProcessVPonR |
603 | (const TopOpeBRep_VPointInter& VP, |
604 | const TopOpeBRepDS_Transition& Trans, |
605 | // const TopoDS_Shape& GFace, |
606 | const TopoDS_Shape& , |
607 | const Standard_Integer ShapeIndex) //1,2 |
608 | { |
609 | Standard_Integer absindex = VP.ShapeIndex(); // 0,1,2,3 |
610 | Standard_Integer iVP = VP.Index(); |
611 | Standard_Boolean OOShapeIndex = (ShapeIndex == 1) ? 2 : 1; |
612 | Standard_Boolean on2edges = (absindex == 3); |
613 | Standard_Boolean hasONedge = (VP.State(OOShapeIndex) == TopAbs_ON); |
614 | Standard_Boolean hasOOedge = (on2edges) ? Standard_True : hasONedge; |
615 | |
616 | TopoDS_Face Face = (*this).Face(ShapeIndex); |
617 | Standard_Integer iSIFace = myDS->Shape(Face); |
618 | if (iSIFace == 0) iSIFace = myDS->AddShape(Face,ShapeIndex); |
619 | TopoDS_Face OOFace = (*this).Face(OOShapeIndex); |
620 | Standard_Integer iOOFace = myDS->Shape(OOFace); |
621 | if (iOOFace == 0) iOOFace = myDS->AddShape(OOFace,OOShapeIndex); |
622 | |
623 | // current VPoint is on <edge> |
624 | Standard_Integer SIedgeIndex = 0; |
625 | const TopoDS_Edge& edge = TopoDS::Edge(VP.Edge(ShapeIndex)); |
626 | if (myDS->HasShape(edge)) SIedgeIndex = myDS->Shape(edge); |
627 | Standard_Real paredge = VP.EdgeParameter(ShapeIndex); |
628 | Standard_Boolean isrest = myDS->IsSectionEdge(edge); |
629 | Standard_Boolean closing = TopOpeBRepTool_ShapeTool::Closed(edge,Face); |
630 | Standard_Boolean dge = BRep_Tool::Degenerated(edge); |
631 | |
632 | // dummy if !<hasOOedge> |
633 | Standard_Integer OOedgeIndex = 0; |
634 | Standard_Boolean OOclosing,OOisrest; OOclosing = OOisrest = Standard_False; |
635 | TopoDS_Edge OOedge; Standard_Real OOparedge = 0.; Standard_Boolean dgOOe = Standard_False; |
636 | if ( hasOOedge ) { |
637 | if (on2edges) OOparedge = VP.EdgeParameter(OOShapeIndex); |
638 | else OOparedge = VP.EdgeONParameter(OOShapeIndex); |
639 | TopoDS_Shape OOe; |
640 | if (on2edges) OOe = VP.Edge(OOShapeIndex); |
641 | else OOe = VP.EdgeON(OOShapeIndex); |
642 | OOedge = TopoDS::Edge(OOe); |
643 | if (myDS->HasShape(OOedge)) OOedgeIndex = myDS->Shape(OOedge); |
644 | OOisrest = myDS->IsSectionEdge(OOedge); |
645 | OOclosing = TopOpeBRepTool_ShapeTool::Closed(OOedge,OOFace); |
646 | dgOOe = BRep_Tool::Degenerated(OOedge); |
647 | } |
648 | |
649 | #ifdef DEB |
650 | Standard_Boolean traceDSF = TopOpeBRepDS_GettraceDSF(); |
651 | Standard_Boolean traceDSP = TopOpeBRepDS_GettraceDSP(); |
652 | Standard_Integer ili=myLine->Index(),ivp=iVP,isi=ShapeIndex; |
653 | if(traceDSF || traceDSP){ |
654 | cout<<endl; |
655 | cout<<"trc tnvp 1 "<<myexF1<<" "<<myexF2<<" "<<ili<<" "<<ivp<<" "<<isi; |
656 | cout<<"; # VPonR "<<iVP<<" on "<<ShapeIndex<<" from "<<absindex<<endl; |
657 | } |
658 | GLOBAL_bvpr = TopOpeBRep_GettraceNVP(myexF1,myexF2,ili,ivp,isi); |
659 | if (TopOpeBRepDS_GettraceISTO()) { |
660 | cout<<"f1,f2,l,vp,si : "; |
661 | cout<<myexF1<<","<<myexF2<<","<<ili<<","<<ivp<<","<<isi<<endl; |
662 | } |
663 | if (GLOBAL_bvpr) debvprmess(myexF1,myexF2,ili,ivp,isi); |
664 | if (traceDSF){ |
665 | cout<<"VP is on";if (closing) cout<<" CLOSING"; |
666 | cout<<" edge "<<SIedgeIndex; |
667 | if(isrest) cout<<" RESTRICTION"; cout<<endl; |
668 | if (OOclosing) cout<<" on CLOSING OOedge "<<OOedgeIndex; |
669 | if(OOisrest) cout<<" RESTRICTION"; cout<<endl; |
670 | } |
671 | #endif |
672 | |
673 | // degenerated edge processing |
674 | // --------------------------- |
675 | Standard_Integer PVIndex = 0; // POINT or VERTEX index |
676 | TopOpeBRepDS_Kind PVKind; |
677 | Standard_Boolean EPIfound,CPIfound; |
678 | EPIfound = CPIfound = Standard_False; |
679 | Handle(TopOpeBRepDS_Interference) IEPI,ICPI; |
680 | ProcessVPondgE(VP, ShapeIndex, |
681 | PVKind,PVIndex, // out |
682 | EPIfound,IEPI, // out |
683 | CPIfound,ICPI); // out |
684 | Standard_Boolean foundPVIndex = (PVIndex != 0); |
685 | |
686 | |
687 | // =================================================================== |
688 | // <TransLine>, <transEdge> |
689 | // =================================================================== |
690 | |
691 | Standard_Boolean wline = (myLine->TypeLineCurve() == TopOpeBRep_WALKING); |
692 | Standard_Boolean grestriction = (myLine->TypeLineCurve() == TopOpeBRep_RESTRICTION); |
693 | Standard_Boolean glinenotoned = !wline && !grestriction && !myLineIsonEdge; |
694 | |
695 | // lasttransLine (for walking line) |
696 | // ------------- |
697 | // set lasttransLine for a WALKING line |
698 | Standard_Boolean dscilempty = myDSCIL.IsEmpty(); |
699 | Standard_Boolean setlastonwl = wline && !dscilempty; |
700 | if (setlastonwl) { //xpu171198, FRA61896 (f7,f13-> null DSC1) |
701 | Standard_Real parline = VP.ParameterOnLine(); |
702 | Standard_Real par = FDS_Parameter(myDSCIL.Last()); // parameter on curve |
703 | Standard_Real dd = Abs(par-parline); // en fait, ce sont des entiers |
704 | if (dd == 0) setlastonwl=Standard_False; |
705 | } |
706 | TopOpeBRepDS_Transition lasttransLine; if (setlastonwl) lasttransLine = myDSCIL.Last()->Transition(); |
707 | |
708 | // edgeori, transLine |
709 | // ------------------ |
710 | TopAbs_Orientation edgeori = edge.Orientation(); |
711 | TopOpeBRepDS_Transition transLine; |
712 | transLine = TopOpeBRep_FFTransitionTool::ProcessLineTransition |
713 | (VP,ShapeIndex,edgeori); |
714 | Standard_Boolean trliunk = transLine.IsUnknown(); |
715 | |
716 | // 1_ If vpmin has transition OUT/IN, and vpmax is UNKNOWN, |
717 | // we change vpmax transition as IN/OUT |
718 | // |
719 | // 2_ If vpmin is UNKNOWN (if vp is first on line and transition is UNKNOWN, |
720 | // vpmin's transition is ON/ON the OOshape) |
721 | // we change vpmin transition as OUT/IN |
722 | // |
723 | // (kpart : sphere/box, with the sphere's sewing edge lying on one boxe's |
724 | // face and one of the edge's vertices IN the same face) |
725 | |
726 | Standard_Integer iINON1,iINONn,nINON; myLine->VPBounds(iINON1,iINONn,nINON); |
727 | Standard_Boolean islastvp = (iVP == iINONn); |
728 | Standard_Boolean isfirstvp = (iVP == iINON1); |
729 | |
730 | Standard_Boolean keepvp = Standard_False; |
731 | Standard_Boolean ret1 = Standard_False; |
732 | if ( trliunk ) { |
733 | // <transLine> is unknown : |
734 | // for a walking -> |
735 | // - if <myDSCIL> is not empty, |
736 | // we set it as the last transition complemented |
737 | // - else, |
738 | // we look after an determinate transition on VP(i>iVP) |
739 | // and set transLine as this last complemented. |
740 | // |
741 | // for a gline not on edge -> |
742 | // - if the transition on edge is unknown too and !<keepvp>, |
743 | // we do not keep it. |
744 | // elsewhere -> we do not keep <VP> |
745 | |
746 | if ( wline ) { |
747 | if (setlastonwl) transLine = lasttransLine.Complement(); |
748 | else ::FUN_transForWL(*myLine,iVP,ShapeIndex,transLine); |
749 | |
750 | // walki vpfirst on 3, vplast on 0, nvpkept = 2 kept |
751 | if (transLine.IsUnknown()) { |
752 | //modified by NIZHNY-MKK Mon Jul 3 11:30:03 2000.BEGIN |
753 | Standard_Boolean keepvpfirst = dscilempty && isfirstvp && (nINON == 2); |
754 | if(absindex==3) |
755 | keepvpfirst = keepvpfirst && myLastVPison0; |
756 | //modified by NIZHNY-MKK Mon Jul 3 11:30:21 2000.END |
757 | if (keepvpfirst) transLine.Set(TopAbs_FORWARD); |
758 | #ifdef DEB |
759 | if (traceDSF) cout<<"myLastVPison0 ->"<<endl; |
760 | #endif |
761 | ret1 = Standard_False; |
762 | } |
763 | } |
764 | else if ( glinenotoned ) { |
765 | // if (islastvp) keepvp = !dscilempty; |
766 | // if (isfirstvp) keepvp = Standard_True; |
767 | if (isfirstvp) keepvp = Standard_True; |
768 | else { |
769 | if (islastvp) keepvp = !dscilempty; |
770 | else { |
771 | if(!dge && !dgOOe && (VP.IsVertexOnS1() || VP.IsVertexOnS2())) { |
772 | // If VP is on vertex we should compute at least one interference for the edge. |
773 | // This interference is necessary at least to indicate that the edge intersect something. |
774 | const TopOpeBRep_VPointInter& aFirstPoint = myLine->VPoint(iINON1); |
775 | const TopOpeBRep_VPointInter& aLastPoint = myLine->VPoint(iINONn); |
776 | |
777 | for(Standard_Integer faceindex = 1; !keepvp && faceindex <=2; faceindex++) { |
778 | Standard_Boolean VPIsVertex = (faceindex==1) ? VP.IsVertexOnS1() : VP.IsVertexOnS2(); |
779 | Standard_Boolean FirstPointIsVertex = (faceindex==1) ? aFirstPoint.IsVertexOnS1() : aFirstPoint.IsVertexOnS2(); |
780 | Standard_Boolean LastPointIsVertex = (faceindex==1) ? aLastPoint.IsVertexOnS1() : aLastPoint.IsVertexOnS2(); |
781 | if(VPIsVertex) { |
782 | const TopoDS_Shape& aV1 = (faceindex==1) ? VP.VertexOnS1() : VP.VertexOnS2(); |
783 | if(FirstPointIsVertex) { |
784 | const TopoDS_Shape& aV2 = (faceindex==1) ? aFirstPoint.VertexOnS1(): aFirstPoint.VertexOnS2(); |
785 | if(aV1.IsSame(aV2)) { |
786 | keepvp = Standard_True; |
787 | } |
788 | } |
789 | if(!keepvp && LastPointIsVertex) { |
790 | const TopoDS_Shape& aV2 = (faceindex==1) ? aLastPoint.VertexOnS1() : aLastPoint.VertexOnS2(); |
791 | if(aV1.IsSame(aV2)) { |
792 | keepvp = !dscilempty; |
793 | } |
794 | } |
795 | } |
796 | } |
797 | } |
798 | } |
799 | } |
800 | ret1 = !keepvp; |
801 | } |
802 | else |
803 | ret1 = Standard_True; |
804 | } |
805 | trliunk = transLine.IsUnknown(); |
806 | if (ret1) return; |
807 | |
808 | // Transori, transEdge |
809 | // ------------------- |
810 | TopAbs_Orientation Transori = Trans.Orientation(TopAbs_IN); |
811 | TopOpeBRepDS_Transition transEdge = TopOpeBRep_FFTransitionTool::ProcessEdgeTransition(VP,ShapeIndex,Transori); |
812 | #ifdef DEB |
813 | if(traceDSF){cout<<"trans edge on f"<<ShapeIndex<<" / f"<<OOShapeIndex<<" : "; |
814 | transEdge.Dump(cout);cout<<endl;} |
815 | #endif |
816 | |
817 | Standard_Boolean Tunknown = FDS_hasUNK(transEdge); |
818 | TopOpeBRepDS_Point PDS = TopOpeBRep_PointGeomTool::MakePoint(VP);// <VP>'s geometry |
819 | TopOpeBRepDS_ListOfInterference lITOOFonVP; // {I on <edge> = (T on <OOface>, G on <VP>, S)} |
820 | Standard_Boolean found = Standard_False; |
821 | if (SIedgeIndex != 0) { |
822 | TopOpeBRepDS_ListOfInterference lI; |
823 | const TopOpeBRepDS_ListOfInterference& lIedge = myDS->ShapeInterferences(edge); |
824 | if (PVIndex == 0) ::FUN_ScanInterfList(PDS,myHDS,lIedge,lI); |
825 | else ::FUN_selectGinterference(lIedge,PVIndex,lI); |
826 | found = ::FUN_selectTRAISHAinterference(lI,iOOFace,lITOOFonVP); |
827 | } |
828 | |
829 | // if (found && myLineINL && Tunknown) return; //xpu220998 : cto cylcong A1 (edge8,OOface4) |
830 | |
831 | // <Transori> = INTERNAL or EXTERNAL (tangent cases), compute <transEdge> |
832 | Standard_Boolean newtransEdge = (Transori == TopAbs_INTERNAL) || (Transori == TopAbs_EXTERNAL); |
833 | TopAbs_Orientation otransEdge = transEdge.Orientation(TopAbs_IN); |
834 | Standard_Boolean allINT = (Transori == TopAbs_INTERNAL) || (otransEdge == TopAbs_INTERNAL); |
835 | Standard_Boolean allEXT = (Transori == TopAbs_EXTERNAL) || (otransEdge == TopAbs_EXTERNAL); |
836 | |
837 | |
838 | newtransEdge = newtransEdge && (!allINT) && (!allEXT); |
839 | newtransEdge = newtransEdge || Tunknown; |
840 | // -> intersection fails for closing edges |
841 | // 1. <edge> touches closing <OOedge> at <VP> && <OOedge> is tangent to <OOFace>, |
842 | // intersection -> 1 forward && 1 reversed instead of internal/external. |
843 | // 2. if <edge> is tangent to <OOFace> at <VP> on walking |
844 | newtransEdge = newtransEdge || closing || OOclosing; |
845 | newtransEdge = newtransEdge && (!myLineINL); |
846 | if (newtransEdge){ |
847 | #ifdef DEB |
848 | Standard_Integer iedge = |
849 | #endif |
850 | myDS->Shape(edge); |
851 | newtransEdge = !found; |
852 | if (found) { |
853 | // Getting first transition found |
854 | // prequesitory : transition on edge / <OOF> on same geometry point is unchanged |
855 | TopOpeBRepDS_Transition Tr = lITOOFonVP.First()->Transition(); |
856 | transEdge.Before(Tr.Before()); transEdge.After(Tr.After()); |
857 | } |
858 | if (newtransEdge) { |
859 | // Compute of <transEdge> : transition on <edge> at geometry <VP> / <OOface> |
860 | // if line on a restriction OOedge of <OOface> : gets <edge> transition/<OOface> when |
861 | // at <VP> on OOedge. |
862 | // if line is not on restriction : gets <edge> transition/<OOface>. |
863 | TopOpeBRepDS_Transition Tr; |
864 | Standard_Boolean ok = FUN_newtransEdge(myHDS,(*this),(*myLine),myLineIsonEdge,VP, |
865 | PVKind,PVIndex,OOShapeIndex,edge,myERL,Tr); |
866 | if (ok) {transEdge.Before(Tr.Before()); transEdge.After(Tr.After());} |
867 | newtransEdge = ok; |
868 | } |
869 | #ifdef DEB |
870 | if (traceDSF && (found || newtransEdge)) |
871 | {if (found) cout<<"*-> found "; if (newtransEdge) cout<<"*-> new "; |
872 | cout<<"transEdge (edge "<<iedge<<",face"<<iOOFace<<") = "; TopAbs::Print(transEdge.Before(),cout); |
873 | cout<<" ";TopAbs::Print(transEdge.After(),cout);cout<<endl;} |
874 | #endif |
875 | } // newtransEdge |
876 | |
877 | Standard_Boolean tredunk = transEdge.IsUnknown(); |
878 | Standard_Boolean ret2 = Standard_False; |
879 | if ( tredunk ) { |
880 | if (!trliunk) transEdge = transLine.Complement(); |
881 | if (trliunk && !keepvp) ret2 = Standard_True; |
882 | } |
883 | if (ret2) return; |
884 | tredunk = transEdge.IsUnknown(); |
885 | |
886 | // =================================================================== |
887 | // DS geometry Management |
888 | // =================================================================== |
889 | // SI*** : data issued from shape ShapeIndex |
890 | // OO*** : data issued from other shape |
891 | |
892 | if (SIedgeIndex == 0) SIedgeIndex = myDS->AddShape(edge,ShapeIndex); |
893 | #ifdef DEB |
894 | Standard_Boolean trce = TopOpeBRepDS_GettraceSPSX(SIedgeIndex); if(trce) debarc(SIedgeIndex); |
895 | #endif |
896 | |
897 | Standard_Boolean SIisvertex = VP.IsVertex(ShapeIndex); |
898 | Standard_Boolean OOisvertex = VP.IsVertex(OOShapeIndex); |
899 | |
900 | // <PVIndex>, <PVKind> : |
901 | // -------------------- |
902 | // search for an interference with a equal 3D geometry |
903 | // if found, set <PVIndex> to index of geometry found |
904 | // if not found, make a new geometry PVIndex with 3d point or vertex |
905 | |
906 | // modified by NIZHNY-MKK Tue Apr 3 12:08:38 2001.BEGIN |
907 | Standard_Boolean ismultiplekind = foundPVIndex && !EPIfound && !CPIfound && |
908 | (SIisvertex || OOisvertex) && (PVKind == TopOpeBRepDS_POINT); |
909 | |
910 | // if (!foundPVIndex) FUN_VPIndex ((*this),(*myLine),VP,ShapeIndex,myHDS,myDSCIL, //in |
911 | if (!foundPVIndex || ismultiplekind) FUN_VPIndex ((*this),(*myLine),VP,ShapeIndex,myHDS,myDSCIL, //in |
912 | // modified by NIZHNY-MKK Tue Apr 3 12:13:17 2001.END |
913 | PVKind,PVIndex, // out |
914 | EPIfound,IEPI, // out |
915 | CPIfound,ICPI, // out |
916 | M_MKNEWVP); |
917 | if (PVIndex == 0){ |
918 | #ifdef DEB |
919 | funraise(); |
920 | #endif |
921 | } |
922 | |
923 | Standard_Boolean VPonedge=Standard_False; if (PVKind == TopOpeBRepDS_VERTEX) VPonedge=::FUN_onedge(PDS,edge); |
924 | if (myLineINL) { |
925 | Standard_Real tolang = Precision::Angular()*1.e5;//=1.e-7 NYITOLXPU |
926 | |
927 | gp_Vec tgE = FUN_tool_tggeomE(paredge,edge); |
928 | gp_Pnt2d OOuv; Standard_Boolean ok = Standard_False; |
929 | if (VPonedge) {OOuv = VP.SurfaceParameters(OOShapeIndex); ok = Standard_True;} |
930 | else {ok = FUN_tool_paronEF(OOedge,OOparedge,OOFace, OOuv);} |
931 | gp_Vec ntOOF; |
932 | if (ok) ntOOF = FUN_tool_nggeomF(OOuv,OOFace); |
933 | if (OOFace.Orientation() == TopAbs_REVERSED) ntOOF.Reverse(); |
934 | |
935 | Standard_Real tol = 1.e-7; |
936 | if (ok) ok = (tgE.Magnitude() > tol)&&(ntOOF.Magnitude() > tol); |
937 | Standard_Real dot = 1.e7; if (ok) dot = gp_Dir(tgE).Dot(gp_Dir(ntOOF)); |
938 | |
939 | |
940 | Handle(Geom_Surface) su = BRep_Tool::Surface(OOFace); |
941 | Standard_Boolean apex = FUN_tool_onapex(OOuv,su); |
942 | TopOpeBRepDS_Transition T; |
943 | if (!apex && ok && (Abs(dot) > tolang)) { |
944 | TopAbs_Orientation ori = (dot < 0.) ? TopAbs_FORWARD : TopAbs_REVERSED; |
945 | T.Set(ori); |
946 | } |
947 | |
948 | if (VPonedge && (!dge)) { |
949 | //xpu231098 : cto904C8(edge11) |
950 | // xpu131198 : CTS21802(edge31) |
951 | if (iOOFace == 0) iOOFace = myDS->AddShape(OOFace,OOShapeIndex); |
952 | Handle(TopOpeBRepDS_Interference) EPIf; |
953 | { |
954 | T.Index(iOOFace); |
955 | EPIf = MakeEPVInterference(T,iOOFace,PVIndex,paredge,PVKind,TopOpeBRepDS_FACE,SIisvertex); |
956 | } |
957 | myHDS->StoreInterference(EPIf,edge); |
958 | if (on2edges || hasONedge) { |
959 | if (OOedgeIndex == 0) OOedgeIndex = myDS->AddShape(OOedge,OOShapeIndex); |
960 | Handle(TopOpeBRepDS_Interference) EPI; |
961 | { |
962 | T.Index(iOOFace); |
963 | EPI = MakeEPVInterference(T,OOedgeIndex,PVIndex,paredge,PVKind,SIisvertex); |
964 | } |
965 | myHDS->StoreInterference(EPI,edge); |
966 | } |
967 | return; |
968 | }//VPonedge |
969 | else { |
970 | // compute interferences later on |
971 | //modified by NIZHNY-MZV Thu Dec 23 13:27:10 1999 |
972 | if(!T.IsUnknown()) { |
973 | transEdge.Before(T.Before()); |
974 | transEdge.After(T.After()); |
975 | } |
976 | } |
977 | }//myLineINL |
978 | |
7fd59977 |
979 | TopOpeBRepDS_Kind SKEPI; if(EPIfound) SKEPI=IEPI->SupportType(); |
7fd59977 |
980 | TopOpeBRepDS_Kind SKCPI; if(CPIfound) SKCPI=ICPI->SupportType(); |
981 | |
982 | // Gfound = VP corresponds with an existing geometry of ShapeIndex |
983 | Standard_Boolean Gfound = ( EPIfound || CPIfound ); |
984 | #ifdef DEB |
985 | Standard_Boolean trcpv = TopOpeBRepDS_GettraceSPSX(PVIndex); |
986 | Standard_Boolean ispoint = (PVKind == TopOpeBRepDS_POINT); |
987 | if(trcpv && ispoint) debpoint(PVIndex); |
988 | if(trcpv && !ispoint) debvertex(PVIndex); |
989 | if (GLOBAL_bvpr) debvprmess(myexF1,myexF2,ili,ivp,isi); |
990 | #endif |
991 | |
992 | // =================================================================== |
993 | // Current VPoint VP is kept |
994 | // =================================================================== |
995 | |
996 | // ------------------------------------------ |
997 | // -- Curve/(POINT,VERTEX) Interference (CPI) |
998 | // ------------------------------------------ |
999 | |
1000 | Standard_Boolean noCPI = myLineIsonEdge; |
1001 | noCPI = noCPI || (!on2edges && hasOOedge && (OOisrest || isrest)); |
1002 | |
1003 | Standard_Boolean condi = (!noCPI); |
1004 | condi = condi && (!myLineINL); // INL |
1005 | if (condi) { |
1006 | Standard_Integer keptVPnbr = mykeptVPnbr; |
1007 | FUN_processCPI((*this),VP,Face,ShapeIndex,(*myLine),myDS, |
1008 | transLine,myDSCIL,ICPI,Gfound,PVKind,PVIndex, |
1009 | keptVPnbr); |
1010 | mykeptVPnbr = keptVPnbr; |
1011 | } |
1012 | |
1013 | // ------------------------------------------ |
1014 | // --- Edge/(POINT,VERTEX) Interference (EPI) |
1015 | // ------------------------------------------ |
1016 | |
1017 | // if (on2edges && !Gfound && !closing) { |
1018 | Standard_Boolean condi2 = (on2edges && !closing); |
1019 | condi2 = condi2 || (hasONedge && !closing); |
1020 | if (condi2 && (!dge)) { |
1021 | if (OOedgeIndex == 0) OOedgeIndex = myDS->AddShape(OOedge,OOShapeIndex); |
1022 | |
1023 | Handle(TopOpeBRepDS_Interference) EPI; |
1024 | { |
1025 | TopOpeBRepDS_Transition T = transEdge; |
1026 | if (iOOFace == 0) iOOFace = myDS->AddShape(OOFace,OOShapeIndex); |
1027 | T.Index(iOOFace); |
1028 | EPI = MakeEPVInterference(T,OOedgeIndex,PVIndex,paredge,PVKind,SIisvertex); |
1029 | } |
1030 | myHDS->StoreInterference(EPI,edge); |
1031 | } //condi2 |
1032 | |
1033 | // =================================================================== |
1034 | // manip corrective d'un pb. d'intersection |
1035 | // - le VPoint est donne sur une restriction de ShapeIndex (1 ou 2), |
1036 | // - le VPoint est ON une restriction de l'autre shape (OOShapeIndex) |
1037 | // --> le VPoint n'est PAS donne sur restriction de OOShapeIndex NYI |
1038 | // par les intersections (a ameliorer). NYI |
1039 | // L'etat ON sur OOShapeIndex indique que le point est sur une |
1040 | // de ses restrictions : |
1041 | // - on ne met PAS le point dans les CPIs |
1042 | // - on met le point dans les EPIs de l'arete de OOShapeIndex |
1043 | // =================================================================== |
1044 | |
1045 | Standard_Boolean correctON = !on2edges && hasONedge && !dgOOe; |
1046 | Standard_Boolean correctedON = Standard_False; |
1047 | if ( correctON ) { |
1048 | TopOpeBRepDS_ListOfInterference lITFonVP; Standard_Boolean OOfound = Standard_False; |
1049 | if (OOedgeIndex != 0) { |
1050 | const TopOpeBRepDS_ListOfInterference& lIOOedge = myDS->ShapeInterferences(OOedge); |
1051 | TopOpeBRepDS_ListOfInterference lI; ::FUN_ScanInterfList(PDS,myHDS,lIOOedge,lI); |
1052 | OOfound = ::FUN_selectTRAISHAinterference(lI,iSIFace,lITFonVP); |
1053 | correctON = !OOfound; |
1054 | } |
1055 | } |
1056 | if ( correctON ) { |
1057 | #ifdef DEB |
1058 | Standard_Boolean trcooe=TopOpeBRepDS_GettraceSPSX(OOedgeIndex);if (trcooe) debooarc(OOedgeIndex); |
1059 | #endif |
1060 | if (OOedgeIndex == 0) OOedgeIndex = myDS->AddShape(OOedge,OOShapeIndex); |
1061 | |
1062 | // VP a ete classifie ON sur l'edge <OOedge>. |
1063 | // calcul de la transition <tOOedge> sur l'arete <OOedge> |
1064 | // (de l'autre face en jeu, OOShapeIndex) ou le VP est donne ON. |
1065 | // On tient compte de l'orientation de <edge> dans <Face>. |
1066 | // (bug IntPatch_Line : VP n'a pas de donnees en OOShapeIndex |
1067 | // alors qu'il est dessus) |
1068 | |
1069 | TopOpeBRepDS_Transition tOOedge; |
1070 | // distinguish wether OOedge is the edge on which geometric line lies. |
1071 | // OOedge == edge(line) ==> tOOedge = f(orientation of <edge> in <Face> FORWARD) |
1072 | // OOedge != edge(line) ==> tOOedge = f(orientation of <Face>) |
1073 | Standard_Real OOpar1,OOpar2; Standard_Boolean isonper; FDS_LOIinfsup((*myDS),OOedge,OOparedge,PVKind,PVIndex, |
1074 | myDS->ShapeInterferences(OOedge), |
1075 | OOpar1,OOpar2,isonper); |
1076 | //FDS_getupperlower(myHDS,OOedgeIndex,OOparedge,par1,par2); |
1077 | gp_Pnt2d OOuv = VP.SurfaceParameters(ShapeIndex); |
1078 | |
1079 | // <Tr> relative to 3d <OOface> matter, |
1080 | // we take into account <Tr> / 2d <OOface> only if <edge> is normal to <OOface> |
1081 | Standard_Real tola = Precision::Angular()*1.e+2; //dealing with tolerances |
1082 | |
1083 | // KK : supplying tolerances pbm (tola too small) |
1084 | Standard_Boolean EsdmEofF = myHDS->HasSameDomain(OOedge); |
1085 | if (EsdmEofF) { |
1086 | TopExp_Explorer ex; |
1087 | for (ex.Init(Face, TopAbs_EDGE); ex.More(); ex.Next()) |
1088 | if (FUN_ds_sdm(*myDS,ex.Current(),OOedge)) {EsdmEofF = Standard_True; break;} |
1089 | } |
1090 | Standard_Boolean OOEtgF = Standard_True; |
1091 | if (!EsdmEofF) OOEtgF = FUN_tool_EtgF(OOparedge,OOedge,OOuv,Face,tola); |
1092 | Standard_Boolean OOrest = FUN_INlos(edge,myERL); |
1093 | Standard_Boolean interf2d = OOEtgF && (OOisrest || OOrest); |
1094 | |
1095 | Standard_Real factor = 1.e-2; |
1096 | TopOpeBRepTool_makeTransition MKT; |
1097 | Standard_Boolean ok = MKT.Initialize(OOedge,OOpar1,OOpar2,OOparedge,Face,OOuv, factor); |
1098 | |
1099 | if (ok && !(interf2d && !MKT.IsT2d())) { |
1100 | MKT.SetRest(edge,paredge); |
1101 | TopAbs_State stb,sta; ok = MKT.MkTonE(stb,sta); |
1102 | if (ok) { |
1103 | tOOedge.Before(stb); tOOedge.After(sta); |
1104 | #ifdef DEB |
1105 | if(traceDSF){ |
1106 | cout<<"* !on2edges && TopAbs_ON *\n"; |
1107 | if(OOisrest) cout<<"* edge "<<OOedgeIndex<<" RESTRICTION *\n"; |
1108 | cout<<"Transition sur <OOedge> "<<OOedgeIndex<<" croisant <edge> "<<SIedgeIndex<<" "; |
1109 | TopAbs::Print(edgeori,cout);cout<<" ";tOOedge.Dump(cout);cout<<endl;} |
1110 | #endif |
1111 | Handle(TopOpeBRepDS_Interference) OOEPIe; |
1112 | { |
1113 | if (iSIFace == 0) iSIFace = myDS->AddShape(Face,ShapeIndex); |
1114 | TopOpeBRepDS_Transition OOT = tOOedge; OOT.Index(iSIFace); |
1115 | OOEPIe = MakeEPVInterference(OOT,SIedgeIndex,PVIndex,OOparedge,PVKind,OOisvertex); |
1116 | } |
1117 | myHDS->StoreInterference(OOEPIe,OOedge); |
1118 | |
1119 | // xpu : 09-03-98 |
1120 | // hsd3d => interf2d : only IwithSkEDGE interf |
1121 | // elsewhere : add an IwithSkFACE interference. |
1122 | Standard_Boolean addEPIf = !myLineIsonEdge; |
1123 | TopTools_ListOfShape dummy; Standard_Boolean hsd3d = FDS_HasSameDomain3d(*myDS,OOedge,&dummy); |
1124 | if (hsd3d) addEPIf = Standard_False; |
1125 | if (addEPIf) { |
1126 | TopOpeBRepDS_Transition OOT = tOOedge; OOT.Index(iSIFace); |
1127 | Handle(TopOpeBRepDS_Interference) OOEPIf = MakeEPVInterference(OOT,iSIFace,PVIndex,OOparedge,PVKind, |
1128 | TopOpeBRepDS_FACE,OOisvertex); |
1129 | myHDS->StoreInterference(OOEPIf,OOedge); |
1130 | } |
1131 | // xpu : 09-03-98 |
1132 | correctedON = Standard_True; |
1133 | } // ok |
1134 | } |
1135 | } // correctON |
1136 | |
1137 | if (correctON && !correctedON && noCPI && !myLineIsonEdge) { |
1138 | // MSV: correct ON failed, so store CPI |
1139 | Standard_Integer keptVPnbr = mykeptVPnbr; |
1140 | FUN_processCPI((*this),VP,Face,ShapeIndex,(*myLine),myDS, |
1141 | transLine,myDSCIL,ICPI,Gfound,PVKind,PVIndex, |
1142 | keptVPnbr); |
1143 | mykeptVPnbr = keptVPnbr; |
1144 | } |
1145 | |
1146 | // closing edge processing |
1147 | // ----------------------- |
1148 | if ((OOclosing || closing)&& !found) { |
1149 | ProcessVPonclosingR(VP,Face,ShapeIndex, |
1150 | transEdge, |
1151 | PVKind,PVIndex, |
1152 | EPIfound,IEPI); |
1153 | return; |
1154 | } |
1155 | |
1156 | // VP processing |
1157 | // ------------- |
1158 | |
1159 | Standard_Boolean addEPI = Standard_False; |
1160 | if (!Gfound) { |
1161 | addEPI = Standard_True; |
1162 | } |
1163 | else { // EPIfound |
1164 | TopAbs_Orientation otransEdge = transEdge.Orientation(TopAbs_IN); |
1165 | |
1166 | Standard_Boolean opporifound,memorifound; opporifound = memorifound = Standard_False; |
1167 | TopOpeBRepDS_ListOfInterference loIfound; |
1168 | const TopOpeBRepDS_ListOfInterference& EPIL = myDS->ShapeInterferences(edge); |
1169 | Standard_Boolean ok = FUN_sameGsameS(EPIL,PVIndex,iOOFace,loIfound); |
1170 | if (ok) { |
1171 | TopOpeBRepDS_PointIterator PI(loIfound); |
1172 | // on cree une EPI orientee <transEdge> ssi : |
1173 | // - il en existe deja une d'orientation opposee a TransEdge |
1174 | // - il n'en existe pas deja une d'orientation identique a TransEdge |
1175 | for (; PI.More(); PI.Next()){ |
1176 | TopAbs_Orientation oEPI = PI.Value()->Transition().Orientation(TopAbs_IN); |
1177 | if (!memorifound) memorifound = ( oEPI == otransEdge ); |
1178 | if (!opporifound) opporifound = ( oEPI == TopAbs::Complement(otransEdge) ); |
1179 | addEPI = (opporifound && ! memorifound); |
1180 | if (addEPI) break; |
1181 | } |
1182 | } |
1183 | if (!ok) addEPI = Standard_True; |
1184 | } // EPIfound |
1185 | |
1186 | #ifdef DEB |
1187 | if (GLOBAL_bvpr) debvprmess(myexF1,myexF2,ili,ivp,isi); |
1188 | #endif |
1189 | |
1190 | // xpu030998 : edge has restriction on OOface, do NOT append EPIf |
1191 | // cto904A3 (edge19,OOface14,vG16), |
1192 | if (myLineINL) { |
1193 | Standard_Real tola = Precision::Angular()*1.e+4; //dealing with tolerances |
1194 | gp_Pnt2d uv = VP.SurfaceParameters(OOShapeIndex); |
1195 | Standard_Boolean EtgOOF = FUN_tool_EtgF(paredge,edge,uv,OOFace,tola); |
1196 | Standard_Boolean inERL = FUN_INlos(edge,myERL); |
1197 | if (EtgOOF && inERL) return; // cto904A3 |
1198 | } |
1199 | |
1200 | if ( addEPI && (!dge)) { |
1201 | // ShapeIndex = 1,2 --> OOShapeIndex = 2,1 |
1202 | // point est sur une seule arete <edge> de <ShapeIndex> |
1203 | // le Support de l'interference est l'autre |
1204 | // face (OOShapeIndex) / ShapeIndex |
1205 | if (iOOFace == 0) iOOFace = myDS->AddShape(OOFace,OOShapeIndex); |
1206 | Handle(TopOpeBRepDS_Interference) EPIf; |
1207 | { |
1208 | TopOpeBRepDS_Transition T = transEdge; T.Index(iOOFace); |
1209 | EPIf = MakeEPVInterference(T,iOOFace,PVIndex,paredge,PVKind,TopOpeBRepDS_FACE,SIisvertex); |
1210 | } |
1211 | myHDS->StoreInterference(EPIf,edge); |
1212 | } // addEPI |
1213 | |
1214 | } // ProcessVPonR |