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