1 // File: TopOpeBRep_FacesFiller_VPonR.cxx
2 // Created: Fri Aug 4 10:57:30 1995
3 // Author: Jean Yves LEBEY
6 #include <TopOpeBRep_FacesFiller.ixx>
9 #include <TopOpeBRepDS_DRAW.hxx>
12 #include <Geom_Curve.hxx>
13 #include <Geom2d_Line.hxx>
14 #include <Geom2d_Curve.hxx>
18 #include <BRepAdaptor_Surface.hxx>
19 #include <BRepAdaptor_Curve.hxx>
20 //#include <BRepAdaptor_Curve2d.hxx>
22 #include <BRep_Tool.hxx>
25 #include <Precision.hxx>
27 #include <TopOpeBRepDS_EXPORT.hxx>
28 #include <TopOpeBRep.hxx>
29 #include <TopOpeBRep_define.hxx>
30 #include <TopOpeBRepTool_ShapeTool.hxx>
31 #include <TopOpeBRepTool_TOOL.hxx>
32 #include <TopOpeBRepTool_EXPORT.hxx>
33 #include <TopOpeBRepTool_mkTondgE.hxx>
35 #define M_ON(st) (st == TopAbs_ON)
36 #define M_REVERSED(st) (st == TopAbs_REVERSED)
38 // modified by NIZHNY-MKK Tue Nov 21 17:30:23 2000.BEGIN
39 static TopTools_DataMapOfShapeListOfShape aMapOfTreatedVertexListOfEdge;
40 static TopOpeBRep_PLineInter localCurrentLine=NULL;
42 static Standard_Boolean local_FindTreatedEdgeOnVertex(const TopoDS_Edge& theEdge,
43 const TopoDS_Vertex& theVertex);
45 static void local_ReduceMapOfTreatedVertices(const TopOpeBRep_PLineInter& theCurrentLine);
47 static Standard_Boolean local_FindVertex(const TopOpeBRep_VPointInter& theVP,
48 const TopTools_IndexedDataMapOfShapeListOfShape& theMapOfVertexEdges,
49 TopoDS_Vertex& theVertex);
50 // modified by NIZHNY-MKK Tue Nov 21 17:30:27 2000.END
53 void static FUN_debdegeneR() {}
54 void static FUN_debdegeneF() {}
55 Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDEGEN();
56 Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceDSF();
57 Standard_EXPORT Standard_Boolean FUN_debnull(const TopoDS_Shape& s);
60 Standard_EXPORT Handle(TopOpeBRepDS_Interference) MakeEPVInterference
61 (const TopOpeBRepDS_Transition& T, // transition
62 const Standard_Integer S, // curve/edge index
63 const Standard_Integer G, // point/vertex index
64 const Standard_Real P, // parameter of G on S
65 const TopOpeBRepDS_Kind GK,
66 const Standard_Boolean B); // G is a vertex (or not) of the interference master
68 Standard_EXPORT Handle(TopOpeBRepDS_Interference) MakeEPVInterference
69 (const TopOpeBRepDS_Transition& T, // transition
70 const Standard_Integer S, // curve/edge index
71 const Standard_Integer G, // point/vertex index
72 const Standard_Real P, // parameter of G on S
73 const TopOpeBRepDS_Kind GK, // POINT/VERTEX
74 const TopOpeBRepDS_Kind SK,
75 const Standard_Boolean B); // G is a vertex (or not) of the interference master
78 #define M_FINDVP (0) // only look for new vp
79 #define M_MKNEWVP (1) // only make newvp
80 #define M_GETVP (2) // steps (0) [+(1) if (O) fails]
81 Standard_EXPORT void FUN_VPIndex
82 (TopOpeBRep_FacesFiller& FF,
83 const TopOpeBRep_LineInter& L,
84 const TopOpeBRep_VPointInter& VP,
85 const Standard_Integer ShapeIndex,
86 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
87 const TopOpeBRepDS_ListOfInterference& DSCIL,
88 TopOpeBRepDS_Kind& PVKind, Standard_Integer& PVIndex, // out
89 Standard_Boolean& EPIfound, Handle(TopOpeBRepDS_Interference)& IEPI, // out
90 Standard_Boolean& CPIfound, Handle(TopOpeBRepDS_Interference)& ICPI, // out
91 const Standard_Integer mkVP);
95 // ******************* methods for the compute **********************
96 // ****************** of interferences on degenerated edge **********
98 // UVonEofF(par) = 2d point of parameter par on edge E in F's 2d representation.
99 // UVonF(E) = E's pcurve on F
100 // UVonF(V) = V's UV on F's 2d representation.
106 static void FUN_GetVectors(const TopoDS_Face& Fe, const TopoDS_Face& Fi,
107 const TopoDS_Edge& Ec,
108 const gp_Pnt2d& p2di, const gp_Pnt2d& p2de,
109 const TopoDS_Vertex& ve,
110 gp_Vec& ngFe, gp_Vec& ngFi,
111 gp_Vec& a, gp_Vec& x)
113 // geometric normals to Fe and Fi : ngFe,ngFi
114 ngFi = FUN_tool_nggeomF(p2di, Fi);
115 ngFe = FUN_tool_nggeomF(p2de, Fe);
118 // Standard_Integer orivine = FUN_tool_orientVinE(ve,Ec);
119 // Standard_Real parOnEc = BRep_Tool::Parameter(ve,Ec);
120 // tgEc = FUN_tool_tggeomE(parOnEc,Ec);
121 // a = tgEc; if (orivine == LAST) a.Reverse();
122 Standard_Integer ovine; Standard_Boolean ok = TopOpeBRepTool_TOOL::TgINSIDE(ve,Ec,a,ovine);
127 static void FUN_getEofFwithV(const TopoDS_Vertex& v, const TopoDS_Face& Fi, TopTools_ListOfShape& los)
129 // get <los>, the edges of <Fi> binding vertex <V>
130 los.Clear(); Standard_Integer ned = 0;
132 TopExp_Explorer exe(Fi, TopAbs_EDGE);
133 for (; exe.More(); exe.Next()) {
134 const TopoDS_Shape& edge = exe.Current();
135 TopExp_Explorer exv(edge, TopAbs_VERTEX);
136 for (; exv.More(); exv.Next()) {
137 if (exv.Current().IsSame(v)) {
142 if (ned == 2) return;
146 static Standard_Real FUN_getpar(const gp_Dir& a, const gp_Dir& x, const gp_Dir& y,
147 const Standard_Boolean& complement)
149 // Computes the parameter on degenerated edge (on circle) :
150 // <Fe> on spherical surface
151 // <Fi> the incident face
152 // watching our system in a XY space normal to ngFe :
153 // <a> : tangent with tgEc, going OUT the sphere, while
154 // following the geometry of <Ec>
155 // <x> : normal to ngFi, oriented INSIDE Fi
156 // <y> : normal to <x>, oriented OUTSIDE the matter delimited
157 // by the oriented face <Fi>.
158 // <par> is the oriented angle (<a>,<x>), computed in the
159 // anti-trigonometric sense (defined by RONd (<x>,<y>,<z>).
161 // If <complement>, nrotation has a direction opposite to z,
162 // parameter on sphere = 2PI - parameter computed.
164 Standard_Real x1 = a.Dot(x);
165 Standard_Real x2 = a.Dot(y);
167 Standard_Real tol = Precision::Angular();
168 Standard_Boolean x1null = (Abs(x1) <= tol);
169 Standard_Boolean x2null = (Abs(x2) <= tol);
171 if (x1null) par = (x2 > 0.) ? 3.*PI*.5 : PI*.5;
172 else if (x2null) par = (x1 > 0.) ? 2.*PI : PI;
174 Standard_Real ac = ACos(Abs(x1));
175 Standard_Boolean x1pos = (x1 > tol);
176 Standard_Boolean x2pos = (x2 > tol);
177 if (x1pos && x2pos) par = 2.*PI-ac;
178 if (x1pos && !x2pos) par = ac;
179 if (!x1pos && x2pos) par = PI+ac;
180 if (!x1pos && !x2pos) par = PI-ac;
183 if (complement) par = 2.*PI - par;
187 static void FUN_getloEi(const gp_Pnt2d& p2d, const TopoDS_Shape& F, TopTools_ListOfShape& loE)
189 loE.Clear(); Standard_Integer nsol = 0;
190 // looking for restrictions of <F> / <p2d> is ON these restrictions.
191 // if <onlyoneE>, looks get the first restriction solution,
192 // else looks among all the restrictions for edges solutions
193 Standard_Real tol = Precision::Parametric(Precision::Confusion());
194 TopExp_Explorer ex(F, TopAbs_EDGE);
195 for (; ex.More(); ex.Next()){
196 const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
197 if ( E.Orientation() == TopAbs_INTERNAL ) continue;
198 if ( BRep_Tool::IsClosed(E,TopoDS::Face(F)) ) continue;
200 Standard_Real par,dist;
201 Standard_Boolean ok = TopOpeBRepTool_TOOL::ParE2d(p2d,E,TopoDS::Face(F), par,dist);
203 Standard_Real tolp = TopOpeBRepTool_TOOL::TolP(E,TopoDS::Face(F));
204 if (dist < tolp) {loE.Append(E); nsol++;}
205 if (nsol == 2) return;
209 static Standard_Boolean FUN_paronE(const gp_Pnt2d& p2d, const TopoDS_Shape& E, const TopoDS_Shape& F,
210 Standard_Real& paronE)
212 // <p2d> on UVon<F>(<E>)
213 // Purpose : finding out paronE / UVon<E>(paronE) = <p2d>
214 Standard_Real par,dist;
215 Standard_Boolean ok = TopOpeBRepTool_TOOL::ParE2d(p2d,TopoDS::Edge(E),TopoDS::Face(F), par,dist);
216 if (!ok) return Standard_False;
217 Standard_Real tolp = TopOpeBRepTool_TOOL::TolP(TopoDS::Edge(E),TopoDS::Face(F));
218 if (dist < tolp) {paronE = par; return Standard_True;}
219 else return Standard_False;
222 static Standard_Boolean FUN_nullx(const gp_Vec& x)
224 Standard_Real tola = Precision::Confusion();
225 Standard_Real mag = x.Magnitude();
226 Standard_Boolean isnull = (mag < tola);
230 static Standard_Boolean FUN_OOEi(const gp_Pnt2d& p2di, const TopoDS_Face& Fi,
231 TopoDS_Edge& OOEi, Standard_Real& paronOOEi)
233 // ngFe // ngFi : <Fi> is tangent to the sphere on its
235 // vertex is on <Ec> (sphere's closing edge) and <OOEi> (on <Fi>).
236 // <p2di> = UVon<Fi>(<ve>)
237 Standard_Boolean isplane = FUN_tool_plane(Fi); if (isplane) return Standard_False;
239 // --------------------------------------------------
240 // SUPPLYING INTPATCH :
241 // The geometry of <ve> is on 2 edges <Ec> and <OOEi>
242 // and <OOEi> is not found touched.
243 // --------------------------------------------------
244 // <loEi> is the list of edges of <Fi> not INTERNAL
246 TopTools_ListOfShape loEi; FUN_getloEi(p2di,Fi,loEi);
247 if (loEi.Extent() != 1) return Standard_False;
249 OOEi = TopoDS::Edge(loEi.First());
250 Standard_Boolean done = FUN_paronE(p2di,OOEi,Fi,paronOOEi);
254 static void FUN_transitiononedge
255 (const TopAbs_State& staB, const TopAbs_State& staA, TopOpeBRepDS_Transition& T)
257 T = TopOpeBRepDS_Transition(staB,staA,TopAbs_EDGE,TopAbs_EDGE);
260 static Standard_Boolean FUN_IEcOOEi
261 (const TopoDS_Vertex& ve, const Standard_Real& paronOOEi, const TopoDS_Edge& OOEi, const TopoDS_Edge& Ec,
262 TopOpeBRepDS_Transition& TOOEi)
264 FUN_transitiononedge(TopAbs_UNKNOWN,TopAbs_UNKNOWN,TOOEi);
265 // ------------------------------------------------------------
266 // SUPPLYING INTPATCH :
267 // when tg<OOEi> and tg<Ec> are tangent,
268 // the interference <OOEi> with <Ec> at vertex <v> is not found
269 // => we have to compute the transition <T> :
270 // following <OOEi>'s geometry, we cross <Ec> at vertex <ve>
271 // and describe the transition <T>.
272 // ------------------------------------------------------------
273 gp_Vec dirOOEi = FUN_tool_tggeomE(paronOOEi,OOEi);
275 Standard_Real paronEc;
276 Standard_Boolean ok = FUN_tool_parVonE(ve,Ec,paronEc); if (!ok) return Standard_False;
277 gp_Vec dirEc = FUN_tool_tggeomE(paronEc,Ec);
279 Standard_Real prod = dirOOEi.Dot(dirEc);
280 Standard_Real tola = Precision::Angular();
281 Standard_Boolean dEctgdOOEi = (Abs(1-Abs(prod)) < tola);
282 if (!dEctgdOOEi) return Standard_False;
285 // compute <paronOOEi> = point of <OOEi> at param=paronOOEi+dparonOOEi
286 Standard_Real f,l; Handle(Geom_Curve) C = BRep_Tool::Curve(OOEi,f,l);
287 Standard_Real dparonOOEi = (l-f)*0.05; // NYI : find a better value
288 Standard_Real tol = Precision::Parametric( Precision::Confusion());
289 Standard_Boolean islast = (Abs(paronOOEi-l) < tol);
290 Standard_Boolean isfirst = (Abs(paronOOEi-f) < tol);
291 if (islast || isfirst) return Standard_False;
292 Standard_Real param = paronOOEi+dparonOOEi;
293 gp_Pnt ptonOOEi = C->Value(param);
295 // classify <paronOOEi> IN <Ec>
296 TopAbs_State sta = FUN_tool_staPinE(ptonOOEi,Ec);
297 if (sta == TopAbs_IN) FUN_transitiononedge(TopAbs_OUT,TopAbs_IN,TOOEi);
298 if (sta == TopAbs_OUT) FUN_transitiononedge(TopAbs_IN,TopAbs_OUT,TOOEi);
299 return Standard_True;
302 #define s_NOTdgE (0) // do NOT compute any transition
303 #define s_TdgE (1) // compute transition on dgE
304 #define s_TOOEi (2) // compute transition on OOEi
306 // case VP is ON the boundary of <Fi> (on edge <Ei>)
307 static Standard_Integer FUN_parondgEONFi
308 (const TopOpeBRep_VPointInter& VP,
309 const Standard_Boolean visvon12,
310 const TopoDS_Vertex& ve,
311 const TopoDS_Vertex& vi, // dummy if !visvon12
312 const Standard_Integer is, // rank of <Fe>
313 const TopoDS_Face& Fe, // contains Ed, Ec
314 const TopoDS_Face& Fi, // face of shape is, contains Ei
315 const TopoDS_Edge& Ed, // degenerated edge
316 const TopoDS_Edge& Ei, // incident edge
317 const TopoDS_Edge& Ec, // couture edge
318 Standard_Real& paronEd,TopOpeBRepDS_Transition& T, // !s_NOTdgE
319 TopoDS_Edge& OOEi, Standard_Real& paronOOEi, TopOpeBRepDS_Transition& TOOEi) // s_TOOEi
321 // <Fe>, <Ed>, <ve> are of rank <is>, <Ed> is on face <Fe>
322 // <Fi>, <Ei>, <vi> are of rank <ioo>, <Ei> is on face <Fi>
323 Standard_Integer ioo = (is == 1) ? 2 : 1;
324 Standard_Integer sind = VP.ShapeIndex();
327 gp_Pnt2d p2de = VP.SurfaceParameters(is);
329 gp_Pnt2d p2di = VP.SurfaceParameters(ioo);
330 Standard_Real parOnEi;
331 Standard_Boolean ok = VP.ParonE(Ei,parOnEi);
334 if (visvon12) voo = vi;
335 else voo = ve; // is of rank <is> or <ioo>!
336 ok = FUN_tool_parVonE(voo,Ei,parOnEi);
338 if (!ok) return s_NOTdgE;
340 // Getting caracteristic vectors describing our system (a,x,y).
341 // The system is in the plane normal to ngFe :
342 // * <a> is the direction of the tangent vector tgEc, going OUT
343 // the sphere while following <Ec>
344 // * <x> is normal to ngFi.
345 // <x> is oriented INSIDE <Fi> (the matter limited by <Fi>'s boundaries)
346 // * (<x>,<y>,<z>) describe a RONd such that
347 // the geometry of the degenerated edge <Ed> follows (<x>,<y>,<z>),
348 // <y> is oriented OUTSIDE the matter limited by the oriented face <Fi>.
349 // (<Fi> is a plane : <z> is parallel to ngFe)
351 gp_Vec ngFe,ngFi,x,a;
352 FUN_GetVectors(Fe,Fi,Ec,p2di,p2de,ve,ngFe,ngFi,a,x);
355 Standard_Boolean nullx = FUN_nullx(x);
357 Standard_Boolean mTOOEi = Standard_False;
358 Standard_Boolean getOOEi = FUN_OOEi(p2di,Fi,OOEi,paronOOEi);
359 if (getOOEi && !OOEi.IsSame(Ei)) mTOOEi = FUN_IEcOOEi(ve,paronOOEi,OOEi,Ec,TOOEi);
361 if (!mTOOEi) return s_NOTdgE;
366 gp_Vec xx = FUN_tool_getgeomxx(Fi,Ei,parOnEi,ngFi);
367 TopAbs_Orientation oriEi; ok = FUN_tool_orientEinFFORWARD(Ei,Fi,oriEi);
368 if (!ok) return s_NOTdgE; // NYI : Raise Error
369 if (oriEi == TopAbs_REVERSED) xx.Reverse();
371 if (x.Dot(xx) < 0.) x.Reverse();
373 // when the edge <Ei> is tangent to <Fe> at vertex <v>,
374 // the degenerated edge is not splitted.
375 Standard_Boolean EitangenttoFe = FUN_tool_EitangenttoFe(ngFe,Ei,parOnEi);
376 if (EitangenttoFe) return s_NOTdgE;
379 if (Fi.Orientation() == TopAbs_FORWARD) y = ngFi;
380 else y = ngFi.Reversed();
384 Standard_Boolean trc = Standard_False;
386 gp_Pnt p = BRep_Tool::Pnt(ve);
388 TCollection_AsciiString aax("x"); FUN_brep_draw(aax,p,x);
389 TCollection_AsciiString aay("y"); FUN_brep_draw(aay,p,y);
390 TCollection_AsciiString aang("ngFi"); FUN_brep_draw(aang,p,ngFi);
391 TCollection_AsciiString aaa("a"); FUN_brep_draw(aaa,p,a);
396 // nrotation = axis describing the sphere's parametrization
397 Standard_Integer orivine = FUN_tool_orientVinE(ve,Ec);
399 if (orivine == LAST) nrotation = ngFe;
400 else nrotation = ngFe.Reversed();
401 Standard_Boolean complement = (z.Dot(nrotation) < 0.);
402 paronEd = FUN_getpar(gp_Dir(a),gp_Dir(x),gp_Dir(y),complement);
405 // in referential (x,y), following trigonometric sense, while
406 // crossing axis x (describing Fi), the transition is IN/OUT
408 // if parametrization follows the trigonometric sense: transition IN/OUT
409 // else, it is OUT/IN.
411 Standard_Boolean inout = !complement;
412 if (inout) T.Set(TopAbs_IN,TopAbs_OUT);
413 else T.Set(TopAbs_OUT,TopAbs_IN);
417 static Standard_Boolean FUN_0or2PI(Standard_Real& paronEd, const Standard_Boolean& inout)
419 Standard_Real tol = Precision::Parametric(Precision::Confusion());
420 Standard_Boolean extre = (Abs(paronEd) < tol);
421 extre = extre && (Abs(2.*PI-paronEd) < tol);
422 if (!extre) return Standard_False;
423 paronEd = (inout) ? 2.*PI : 0.;
424 return Standard_True;
427 // case VP is IN <Fi>
428 static Standard_Integer FUN_parondgEINFi(const TopOpeBRep_VPointInter& VP,
429 const TopoDS_Face& Fe,
430 const TopoDS_Face& Fi,
431 const TopoDS_Edge& Ed,
432 const TopoDS_Edge& Ec,
433 Standard_Real& par1OnEd,
434 Standard_Real& par2OnEd,
435 TopOpeBRepDS_Transition& T1,
436 TopOpeBRepDS_Transition& T2, // !s_NOTdgE
437 TopoDS_Edge& OOEi, Standard_Real& paronOOEi, TopOpeBRepDS_Transition& TOOEi) // s_TdgEandTOOEi
439 Standard_Integer is = VP.ShapeIndex();
440 Standard_Integer ioo = (is == 1) ? 2 : 1;
441 Standard_Boolean iis1 = (is == 1) ? Standard_True : Standard_False;
443 // VP is on the restriction of shape <i>
444 // and IN the face <Fi>.
445 Standard_Boolean isVon1 = VP.IsVertexOnS1();
446 Standard_Boolean isVon2 = VP.IsVertexOnS2();
447 if (iis1 && !isVon1) return s_NOTdgE;
448 if (!iis1 && !isVon2) return s_NOTdgE;
450 if (iis1) v = TopoDS::Vertex(VP.VertexOnS1());
451 else v = TopoDS::Vertex(VP.VertexOnS2());
454 gp_Pnt2d p2de = VP.SurfaceParameters(is);
455 gp_Pnt2d p2di = VP.SurfaceParameters(ioo);
457 gp_Vec ngFe,ngFi,x,a;
458 FUN_GetVectors(Fe,Fi,Ec,p2di,p2de,v,ngFe,ngFi,a,x);
461 Standard_Boolean nullx = FUN_nullx(x);
463 Standard_Boolean mTOOEi = Standard_False;
464 Standard_Boolean getOOEi = FUN_OOEi(p2di,Fi,OOEi,paronOOEi);
465 if (getOOEi) mTOOEi = FUN_IEcOOEi(v,paronOOEi,OOEi,Ec,TOOEi);
467 if (!mTOOEi) return s_NOTdgE;
473 if (Fi.Orientation() == TopAbs_FORWARD) y = ngFi;
474 else y = ngFi.Reversed();
478 Standard_Boolean trc = Standard_False;
480 gp_Pnt p = BRep_Tool::Pnt(v);
482 TCollection_AsciiString aax("x"); FUN_brep_draw(aax,p,x);
483 TCollection_AsciiString aay("y"); FUN_brep_draw(aay,p,y);
484 TCollection_AsciiString aang("ngFi"); FUN_brep_draw(aang,p,ngFi);
485 TCollection_AsciiString aaa("a"); FUN_brep_draw(aaa,p,a);
490 // parameters on <Ed>
491 Standard_Integer orivine = FUN_tool_orientVinE(v,Ec);
493 if (orivine == LAST) nrotation = ngFe;
494 else nrotation = ngFe.Reversed();
495 Standard_Boolean complement = (z.Dot(nrotation) < 0.);
497 Standard_Boolean T1inout = !complement;
498 if (T1inout) T1.Set(TopAbs_IN,TopAbs_OUT);
499 else T1.Set(TopAbs_OUT,TopAbs_IN);
500 T2 = T1.Complement();
502 Standard_Real par = FUN_getpar(a,x,y,complement);
504 par2OnEd = (par > PI) ? par-PI : par+PI;
507 Standard_Boolean changedpar1 = FUN_0or2PI(par1OnEd,T1inout);
508 Standard_Boolean changedpar2 = FUN_0or2PI(par2OnEd,!T1inout);
513 static Standard_Boolean FUN_PInDegenEd(const Standard_Real& paronEd, const TopoDS_Edge& Ec)
516 TopExp::Vertices(Ec,vf,vl);
517 Standard_Real pf = BRep_Tool::Parameter(vf,Ec);
518 Standard_Real pl = BRep_Tool::Parameter(vl,Ec);
519 Standard_Real tol = Precision::Parametric(Precision::Confusion());
521 Standard_Boolean kept = (paronEd < pl-tol) || (paronEd > pl+tol);
522 kept = kept || (paronEd < pf-tol) || (paronEd > pf+tol);
526 static Standard_Integer FUN_putInterfonDegenEd
527 (const TopOpeBRep_VPointInter& VP,
528 const TopoDS_Face& F1,
529 const TopoDS_Face& F2,
530 TopTools_DataMapOfShapeListOfShape& DataforDegenEd, // const but for copy &
531 const Handle(TopOpeBRepDS_HDataStructure) HDS,
532 Standard_Integer& is,
533 Standard_Integer& makeinterf, // 1,2,3 : compute interf1, or2 or the 2 interfs
534 TopOpeBRepDS_Transition& Trans1, Standard_Real& param1,
535 TopOpeBRepDS_Transition& Trans2, Standard_Real& param2,
536 TopoDS_Edge& OOEi, Standard_Real& paronOOEi, TopOpeBRepDS_Transition& TOOEi)
538 // IMPORTANT : NYI : xpu :
539 // -----------------------
540 // The following process is valid when ngFe is normal to ngFi.
541 // It may be unsufficient elsewhere.
543 // (kpart : sphere/box, with one sphere's degenerated edge lying on one boxe's
544 // face, IN or ON the face)
546 // Ed append EVI of transition(FACE Fi) on G=(VERTEX,V), S=(EDGE,Ei) par = paronEd.
548 // Ed append EVI of transition(FACE Fi) on G=(VERTEX,V), S=(FACE,Fi) par = paronEd1
549 // Ed append EVI of transition(FACE Fi) on G=(VERTEX,V), S=(FACE,Fi) par = paronEd2
550 // with Ed the degenerated edge, Ei of Fi interfers with Ed at vertex V.
553 Standard_Boolean traceDSF = TopOpeBRepDS_GettraceDSF();
554 Standard_Boolean traceDEGEN = TopOpeBRepDS_GettraceDEGEN();
555 Standard_Boolean trace = traceDSF || traceDEGEN;
558 TopOpeBRepDS_DataStructure& DS = HDS->ChangeDS();
559 Standard_Boolean isvon1 = VP.IsVertexOnS1();
560 Standard_Boolean isvon2 = VP.IsVertexOnS2();
561 Standard_Boolean isvon12 = isvon1 && isvon2;
562 if (!isvon1 && !isvon2) return s_NOTdgE;
563 Standard_Boolean ison1 = VP.IsOnDomS1();
564 Standard_Boolean ison2 = VP.IsOnDomS2();
566 TopoDS_Vertex v1, v2;
567 if (isvon1) v1 = TopoDS::Vertex(VP.VertexOnS1());
568 if (isvon2) v2 = TopoDS::Vertex(VP.VertexOnS2());
571 Standard_Boolean trcd = Standard_False;
572 if (trcd && isvon1) {TCollection_AsciiString aa("v1"); FUN_brep_draw(aa,v1);}
573 if (trcd && isvon2) {TCollection_AsciiString aa("v2"); FUN_brep_draw(aa,v2);}
574 if (trcd) FUN_DrawMap(DataforDegenEd);
577 // VP is lying on at least one vertex vi
578 // !!! : even if isvon1 && isvon2, v1 and v2 are NOT SAME !
579 Standard_Boolean visvon12 = isvon1 ? HDS->HasSameDomain(v1) : HDS->HasSameDomain(v2);
580 if (visvon12 && !isvon12) {
583 Standard_Boolean ok = FUN_ds_getoov(v1,HDS,oov);
584 if (!ok) return s_NOTdgE;
585 v2 = TopoDS::Vertex(oov);
588 Standard_Boolean ok = FUN_ds_getoov(v2,HDS,oov);
589 if (!ok) return s_NOTdgE;
590 v1 = TopoDS::Vertex(oov);
592 // now, if visvon12, v1 and v2 are defined
596 Standard_Boolean hasdegened;
599 hasdegened = DataforDegenEd.IsBound(v);
600 if (!hasdegened && visvon12) {
601 // DataforDegenEd can either bind v1 or v2.
602 if (isvon1) hasdegened = DataforDegenEd.IsBound(v2);
603 else hasdegened = DataforDegenEd.IsBound(v1);
609 if (!hasdegened) return s_NOTdgE;
611 Standard_Boolean on2edges = (VP.ShapeIndex() == 3);
612 on2edges = on2edges || visvon12;
614 TopTools_ListIteratorOfListOfShape itoflos(DataforDegenEd.Find(v));
615 if (!itoflos.More()) return s_NOTdgE;
616 TopoDS_Edge Ec = TopoDS::Edge(itoflos.Value());
617 itoflos.Next(); if (!itoflos.More()) return s_NOTdgE;
618 TopoDS_Edge Ed = TopoDS::Edge(itoflos.Value());
620 // -----------------------------------------
621 // Fe, Ec, Ed and v are on shape <is>,
622 // Fi, Ei are on shape <ioo> = (is == 1) ? 2 :1
623 // -----------------------------------------
625 Standard_Boolean e1isEd = Standard_False, e2isEd = Standard_False;
626 if (ison1) { e1 = TopoDS::Edge(VP.ArcOnS1()); e1isEd = BRep_Tool::Degenerated(e1); }
627 if (ison2) { e2 = TopoDS::Edge(VP.ArcOnS2()); e2isEd = BRep_Tool::Degenerated(e2); }
629 if (!e1isEd && !e2isEd) return s_NOTdgE; // computes transitions only ONCE
630 is = (e1isEd) ? 1 : 2;
631 Standard_Integer ioo = (is == 1) ? 2 : 1;
633 if (is == 1) Fe = F1;
636 if (ioo == 1) Fi = F1;
638 Standard_Integer iv = 0;
641 if (FUN_debnull(Fe)) cout<<"Fe is null"<<endl;
642 if (FUN_debnull(Fi)) cout<<"Fi is null"<<endl;
643 if (FUN_debnull(Ec)) cout<<"Ec is null"<<endl;
644 if (FUN_debnull(Ed)) cout<<"Ed is null"<<endl;
646 TopAbs_Orientation Edori = Ed.Orientation();
647 if (Edori == TopAbs_FORWARD) FUN_debdegeneF();
648 if (Edori == TopAbs_REVERSED) FUN_debdegeneR();
650 Standard_Boolean trace3d = Standard_False;
652 if (trace3d) {TCollection_AsciiString afe("Fe");TCollection_AsciiString afi("Fi");TCollection_AsciiString aec("Ec");
653 FUN_brep_draw(afe,Fe); FUN_brep_draw(afi,Fi); FUN_brep_draw(aec,Ec);}
657 Standard_Integer makeI = s_NOTdgE;
662 TopTools_ListOfShape loEi;
663 TopoDS_Vertex vi,ve; // vertex on shape ioo sharing same domain with v
664 // dummy if !visvon12
666 // if isvon12, we have two choices for <Ei>,
667 // we choose the one for which FUN_parondgEONFi returns True.
668 // (recall that prequesitory : ngFi is normal to ngFe)
669 if (is == 1) ve = v1;
671 if (ioo == 1) vi = v1;
673 FUN_getEofFwithV(vi,Fi,loEi);
676 if (is == 2) loEi.Append (e1);
677 else loEi.Append (e2);
680 Standard_Real paronEd;
681 TopOpeBRepDS_Transition T;
682 TopTools_ListIteratorOfListOfShape itloei(loEi);
684 TopoDS_Edge tmpOOEi; Standard_Real tmpparonOOEi; TopOpeBRepDS_Transition tmpTOOEi;
685 for (;itloei.More(); itloei.Next()) {
688 if (FUN_debnull(itloei.Value())) cout<<"Ei is null"<<endl;
690 if (trace3d) {TCollection_AsciiString aa("ecur");FUN_brep_draw(aa,itloei.Value());}
692 TopAbs_ShapeEnum typ = itloei.Value().ShapeType();
693 if (typ != TopAbs_EDGE) cout<<"shape not edge"<<endl;
696 TopoDS_Edge Ei = TopoDS::Edge(itloei.Value());
697 if (visvon12) v = ve;
698 makeI = FUN_parondgEONFi (VP,visvon12,v,vi,
699 is,Fe,Fi,Ed,Ei,Ec,paronEd,T,
700 tmpOOEi,tmpparonOOEi,tmpTOOEi);
701 if (makeI == s_NOTdgE) continue;
702 if (makeI == s_TOOEi) {
703 tmpOOEi = OOEi; tmpparonOOEi = paronOOEi; tmpTOOEi = TOOEi;
707 Standard_Boolean keepI = FUN_PInDegenEd(paronEd,Ed);
711 Trans1.Set(T.Before(), T.After());
719 Standard_Real paronEd1, paronEd2;
720 TopOpeBRepDS_Transition T1, T2;
722 makeI = FUN_parondgEINFi (VP,Fe,Fi,Ed,Ec,paronEd1,paronEd2,T1,T2,
723 OOEi,paronOOEi,TOOEi);
724 if (makeI == s_NOTdgE) return makeI;
725 if (makeI == s_TOOEi) return makeI;
727 Standard_Boolean keepI1 = FUN_PInDegenEd(paronEd1,Ed);
728 Standard_Boolean keepI2 = FUN_PInDegenEd(paronEd2,Ed);
733 Trans1.Set(T1.Before(), T1.After());
736 makeinterf = (makeinterf == 1) ? 3 : 2;
738 Trans2.Set(T2.Before(), T2.After());
745 static Standard_Boolean FUN_getEc
746 (const TopOpeBRep_VPointInter& VP,
747 TopTools_DataMapOfShapeListOfShape& DataforDegenEd,
748 const Handle(TopOpeBRepDS_HDataStructure)& HDS, TopoDS_Shape& Ec)
751 Standard_Boolean isvon1 = VP.IsVertexOnS1();
752 Standard_Boolean isvon2 = VP.IsVertexOnS2();
753 if (!isvon1 && !isvon2) return Standard_False;
754 if (isvon1) v = TopoDS::Vertex(VP.VertexOnS1());
755 if (isvon2) v = TopoDS::Vertex(VP.VertexOnS2());
756 Standard_Boolean inmap = DataforDegenEd.IsBound(v);
758 if (HDS->HasSameDomain(v))
759 {Standard_Boolean ok = FUN_ds_getoov(v,HDS,v); if (!ok) return Standard_False;}
760 inmap = DataforDegenEd.IsBound(v);
761 if (!inmap) return s_NOTdgE;
763 const TopTools_ListOfShape& los = DataforDegenEd.Find(v);
764 if (los.Extent() < 2) return Standard_False;
766 return Standard_True;
769 Standard_EXPORT void FUN_FillVof12
770 (const TopOpeBRep_LineInter& L,
771 TopOpeBRepDS_PDataStructure pDS)
773 TopOpeBRep_VPointInterIterator itvp(L);
774 for (; itvp.More(); itvp.Next()) {
775 const TopOpeBRep_VPointInter& vp = itvp.CurrentVP();
776 Standard_Integer sind = vp.ShapeIndex();
777 if (sind != 3) continue;
778 Standard_Boolean isvon1 = vp.IsVertexOnS1();
779 Standard_Boolean isvon2 = vp.IsVertexOnS2();
780 Standard_Boolean isvon12 = isvon1 && isvon2;
781 if (!isvon12) continue;
782 const TopoDS_Shape& v1 = vp.VertexOnS1();
783 const TopoDS_Shape& v2 = vp.VertexOnS2();
784 pDS->FillShapesSameDomain(v1,v2);
788 static void FUN_addmapve(TopTools_DataMapOfShapeListOfShape& mapve, const TopoDS_Shape& v, const TopoDS_Shape& e)
790 Standard_Boolean visb = mapve.IsBound(v);
791 Standard_Boolean eisb = mapve.IsBound(e);
793 {TopTools_ListOfShape le;le.Append(e);mapve.Bind(v,le);
794 TopTools_ListOfShape lv;lv.Append(v);mapve.Bind(e,lv);}
795 else if (visb && !eisb)
796 {mapve.ChangeFind(v).Append(e);
797 TopTools_ListOfShape lv;lv.Append(v);mapve.Bind(e,lv);}
798 else if (!visb && eisb)
799 {mapve.ChangeFind(e).Append(v);
800 TopTools_ListOfShape le;le.Append(e);mapve.Bind(v,le);}
802 Standard_Boolean found = Standard_False;
803 TopTools_ListIteratorOfListOfShape it(mapve.Find(v));
804 for (; it.More(); it.Next())
805 if (it.Value().IsSame(e)) {found = Standard_True; break;}
806 if (!found) {mapve.ChangeFind(v).Append(e); mapve.ChangeFind(e).Append(v);}
810 Standard_EXPORT void FUN_GetdgData(TopOpeBRepDS_PDataStructure& pDS,const TopOpeBRep_LineInter& L,
811 const TopoDS_Face& F1,const TopoDS_Face& F2, TopTools_DataMapOfShapeListOfShape& datamap)
813 // purpose : fills up map datamap = {(v, (closinge,degeneratede))}
814 // with shapes with same rank
816 TopTools_DataMapOfShapeInteger shaperk; // rkshape = {shape,rank=1,2}
817 TopTools_DataMapOfShapeListOfShape mapvec, mapved; // mapvec = {(v,lec),(ec,lv)}, mapved = {(v,led),(ed,lv)}
818 TopTools_DataMapOfShapeShape mapvvsd; // mapvvsd = {(v,v)}
820 TopOpeBRep_VPointInterIterator itvp(L);
821 for (; itvp.More(); itvp.Next()) {
822 const TopOpeBRep_VPointInter& vp = itvp.CurrentVP();
823 Standard_Boolean isv1 = vp.IsVertex(1), isv2 = vp.IsVertex(2);
824 Standard_Boolean isv = isv1 || isv2;
827 Standard_Integer sind = vp.ShapeIndex();
828 TopoDS_Shape v = isv1 ? vp.Vertex(1): vp.Vertex(2);
829 for (Standard_Integer i = 1; i <= 2; i++) {
830 TopoDS_Face f = (i == 1)? F1: F2;
832 Standard_Boolean isvi = vp.IsVertex(i);
838 TopoDS_Edge e; Standard_Boolean isdg, iscl; isdg = iscl = Standard_False;
839 Standard_Boolean ison = (sind == i)||(sind == 3);
841 e = TopoDS::Edge( vp.Edge(i) );
844 isdg = BRep_Tool::Degenerated(e);
845 if (!isdg) iscl = TopOpeBRepTool_ShapeTool::Closed(e,f);
846 if (isdg) FUN_addmapve(mapved,v,e);
847 if (iscl) FUN_addmapve(mapvec,v,e);
852 // filling up map mapvvsd
853 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(mapved);
854 for (; itm.More(); itm.Next()){
855 const TopoDS_Shape& v = itm.Key();
856 if (v.ShapeType() != TopAbs_VERTEX) continue;
857 Standard_Integer rkv = shaperk.Find(v);
859 TopTools_ListIteratorOfListOfShape ite(itm.Value());
860 for (; ite.More(); ite.Next()){
861 const TopoDS_Edge& e = TopoDS::Edge( ite.Value() );
862 Standard_Integer rke = shaperk.Find(e);
864 TopExp_Explorer ex(e, TopAbs_VERTEX);
865 const TopoDS_Shape& vsd = ex.Current();
866 // recall : if vsd is not bound in shaperk,
867 // it is not bound in <L> either
868 mapvvsd.Bind(v,vsd); mapvvsd.Bind(vsd,v);
873 itm.Initialize(mapved);
874 for (; itm.More(); itm.Next()){
875 const TopoDS_Shape& dge = itm.Key();
876 Standard_Integer rk = shaperk.Find(dge);
877 TopoDS_Face f = (rk == 1)? F1: F2;
878 if (dge.ShapeType() != TopAbs_EDGE) continue;
880 TopExp_Explorer ex(dge, TopAbs_VERTEX);
881 const TopoDS_Vertex& v = TopoDS::Vertex( ex.Current() );
882 Standard_Integer rkv = shaperk.Find(v);
883 Standard_Boolean hassd = mapvvsd.IsBound(v);
884 TopoDS_Vertex vsd; if (hassd) vsd = TopoDS::Vertex( mapvvsd.Find(v) );
886 Standard_Boolean hasecl = Standard_False; TopoDS_Shape cle;
887 Standard_Boolean isbv = mapvec.IsBound(v), isbvsd= hassd ? mapvec.IsBound(vsd) : Standard_False;
888 if (!isbv && !isbvsd) {
889 // **************************************************
890 // interference with closing edge is not found,
891 // adding new information to the ds
892 // **************************************************
893 TopTools_IndexedDataMapOfShapeListOfShape mapve; TopExp::MapShapesAndAncestors(f,TopAbs_VERTEX,TopAbs_EDGE,mapve);
894 TopTools_ListIteratorOfListOfShape iteds(mapve.FindFromKey(v));
895 for (; iteds.More(); iteds.Next()){
896 const TopoDS_Edge& ee = TopoDS::Edge(iteds.Value());
897 if (ee.IsSame(dge)) continue;
898 Standard_Boolean iscl = TopOpeBRepTool_ShapeTool::Closed(ee,f);
900 isbv = Standard_True; cle = ee; hasecl = Standard_True; break;
903 if (!hasecl && (isbv || isbvsd)) {
904 TopoDS_Vertex vv = isbv ? v : vsd;
905 TopTools_ListIteratorOfListOfShape ite;
906 if (isbv) ite.Initialize(mapvec.Find(v));
907 for (; ite.More(); ite.Next()){
908 const TopoDS_Shape& e = ite.Value();
909 Standard_Integer rke = shaperk.Find(e);
910 if (rke == rk) {cle = e; hasecl = Standard_True; break;}
913 if (!hasecl) continue;
915 TopoDS_Vertex vv = (rkv == rk) ? v : vsd;
916 TopTools_ListOfShape ls; ls.Append(cle); ls.Append(dge);
920 // filling sdm shapes
921 TopTools_DataMapIteratorOfDataMapOfShapeShape ittm(mapvvsd);
922 for (; ittm.More(); ittm.Next()){
923 const TopoDS_Vertex& v = TopoDS::Vertex( ittm.Value() );
924 const TopoDS_Vertex& ov = TopoDS::Vertex( mapvvsd.Find(v) );
925 Standard_Integer rkv = shaperk.Find(v);
926 TopoDS_Vertex v1 = (rkv == 1) ? v : ov;
927 TopoDS_Vertex v2 = (rkv == 2) ? v : ov;
928 pDS->FillShapesSameDomain(v1,v2);
937 static Standard_Integer FUN_putInterfonDegenEd
938 (const TopOpeBRep_VPointInter& VP,
939 const TopoDS_Face& F1, const TopoDS_Face& F2,
940 TopTools_DataMapOfShapeListOfShape& DataforDegenEd, // const but for copy &
941 Handle(TopOpeBRepDS_HDataStructure)& HDS,
942 Standard_Integer& is, TopoDS_Edge& dgE,
943 // Standard_Integer& makeinterf, // 1,2,3 : compute interf1, or2 or the 2 interfs
944 Standard_Integer& , // 1,2,3 : compute interf1, or2 or the 2 interfs
945 TopOpeBRepDS_Transition& Trans1, Standard_Real& param1,
946 TopOpeBRepDS_Transition& Trans2, Standard_Real& param2,
947 TopoDS_Edge& OOEi, Standard_Real& paronOOEi, Standard_Boolean hasOOEi,
948 Standard_Boolean& isT2d)
951 Standard_Boolean traceDSF = TopOpeBRepDS_GettraceDSF();
952 Standard_Boolean traceDEGEN = TopOpeBRepDS_GettraceDEGEN();
953 Standard_Boolean trace = traceDSF || traceDEGEN;
957 Standard_Boolean on3 = (VP.ShapeIndex() == 3);// <VP> is shared by edge of 1 and edge of 2.
958 Standard_Boolean onv12 = VP.IsVertexOnS1() && VP.IsVertexOnS2();
960 const TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
961 TopoDS_Vertex v; Standard_Integer rkv = 0;
962 // Standard_Integer iv;
964 for (Standard_Integer ShapeIndex = 1; ShapeIndex <= 2; ShapeIndex++) {
965 Standard_Boolean isv = (ShapeIndex == 1) ? (VP.IsVertexOnS1()) : (VP.IsVertexOnS2());
967 v = (ShapeIndex == 1) ? TopoDS::Vertex(VP.VertexOnS1()) : TopoDS::Vertex(VP.VertexOnS2());
968 Standard_Boolean hasdegened = DataforDegenEd.IsBound(v);
969 if (!hasdegened) continue;
970 rkv = ShapeIndex; break;
972 if (rkv == 0) return NOI;// compute interference once only.
973 Standard_Boolean isvsd = HDS->HasSameDomain(v);
975 // edges dge, cle on shape<rkdg>
976 const TopTools_ListOfShape& loe = DataforDegenEd.Find(v);
977 const TopoDS_Edge& cle = TopoDS::Edge(loe.First());
978 const TopoDS_Edge& dge = TopoDS::Edge(loe.Last()); dgE = dge;
979 Standard_Integer rkdg = 0;
980 if (BDS.HasShape(dge)) rkdg = BDS.AncestorRank(dge);
982 Standard_Boolean vindge = FUN_tool_inS(v,dge);
983 if (vindge) rkdg = rkv;
984 else rkdg = (rkv == 1) ? 2 : 1;
987 Standard_Integer rki = (rkdg == 1) ? 2 : 1;
989 gp_Pnt2d uvi; TopoDS_Face fi,f;
991 // Standard_Real u,v;
992 // if (rki == 1) VP.ParametersOnS1(u,v);
993 // else VP.ParametersOnS2(u,v);
994 // uvi = gp_Pnt2d(u,v);
995 // modified by NIZHNY-MKK Tue Nov 21 17:44:56 2000.BEGIN
996 Standard_Real upar, vpar;
997 if (rki == 1) VP.ParametersOnS1(upar, vpar);
998 else VP.ParametersOnS2(upar, vpar);
999 uvi = gp_Pnt2d(upar, vpar);
1000 // modified by NIZHNY-MKK Tue Nov 21 17:44:59 2000.END
1001 fi = (rki == 1) ? F1 : F2;
1002 f = (rkdg == 1) ? F1 : F2;
1004 TopOpeBRepTool_mkTondgE mktdg;
1005 Standard_Boolean ok = mktdg.Initialize(dge, f, uvi, fi);
1006 if (!ok) return NOI;
1007 ok = mktdg.SetclE(cle);
1008 if (!ok) return NOI;
1010 if (onv12 || isvsd) {
1012 ov = (rkv == 2) ? TopoDS::Vertex(VP.VertexOnS1()) : TopoDS::Vertex(VP.VertexOnS2());
1014 // modified by NIZHNY-MKK Tue Nov 21 17:45:46 2000.BEGIN
1015 // Standard_Boolean ok = FUN_ds_getoov(v,HDS,ov);
1016 // if (!ok) return Standard_False;
1017 Standard_Boolean found = FUN_ds_getoov(v,HDS,ov);
1018 if (!found) return NOI;
1019 // modified by NIZHNY-MKK Tue Nov 21 17:45:50 2000.END
1021 if (rkv != rkdg) {TopoDS_Vertex tmp = v; v = ov; ov = tmp; rkv = rkdg;} // ensure v is vertex of dge
1024 Standard_Boolean setrest = Standard_False;
1025 Standard_Integer mkt = 0; Standard_Real par1,par2;
1027 TopoDS_Edge ei = (rki == 1) ? TopoDS::Edge(VP.ArcOnS1()) : TopoDS::Edge(VP.ArcOnS2());
1028 Standard_Real pari = (rki == 1) ? VP.ParameterOnArc1() : VP.ParameterOnArc2();
1029 // if okrest, ei interfers in the compute of transitions for dge
1030 setrest = mktdg.SetRest(pari,ei);
1031 ok = mktdg.MkTonE(ei,mkt, par1,par2);
1032 if ((!ok) || (mkt == NOI)) return NOI;
1033 OOEi = ei; paronOOEi = pari; hasOOEi = Standard_True;
1036 // modified by NIZHNY-MKK Tue Nov 21 17:31:14 2000.BEGIN
1037 // This search, compute and check the data which was not computed by intersector.
1038 if((rki == 1 && VP.IsOnDomS1()) || (rki == 2 && VP.IsOnDomS2())) {
1039 TopoDS_Edge ei = (rki == 1) ? TopoDS::Edge(VP.ArcOnS1()) : TopoDS::Edge(VP.ArcOnS2());
1040 Standard_Real pari = (rki == 1) ? VP.ParameterOnArc1() : VP.ParameterOnArc2();
1041 mktdg.SetRest(pari,ei);
1042 ok = mktdg.MkTonE(ei,mkt, par1,par2);
1043 if(ok && mkt!=NOI) {
1044 OOEi = ei; paronOOEi = pari; hasOOEi = Standard_True;
1048 Standard_Boolean edgefound = Standard_False;
1049 TopoDS_Face aFace = (rki == 1) ? F1 : F2;
1050 TopTools_IndexedDataMapOfShapeListOfShape aMapOfVertexEdges;
1051 TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, aMapOfVertexEdges);
1052 TopoDS_Vertex aVertex;
1053 Standard_Boolean vertexfound = local_FindVertex(VP, aMapOfVertexEdges, aVertex);
1055 if(vertexfound && !aVertex.IsNull()) {
1056 TopTools_ListIteratorOfListOfShape anIt(aMapOfVertexEdges.FindFromKey(aVertex));
1057 for(; !edgefound && anIt.More(); anIt.Next()) {
1058 const TopoDS_Edge& ei = TopoDS::Edge(anIt.Value());
1059 Standard_Real pari = BRep_Tool::Parameter(aVertex, ei);
1060 if(!BRep_Tool::Degenerated(ei)) {
1061 edgefound = !local_FindTreatedEdgeOnVertex(ei, aVertex);
1064 mktdg.SetRest(pari,ei);
1065 ok = mktdg.MkTonE(ei,mkt, par1,par2);
1066 if(ok && mkt!=NOI) {
1067 OOEi = ei; paronOOEi = pari; hasOOEi = Standard_True;
1069 if(!aMapOfTreatedVertexListOfEdge.IsBound(aVertex)) {
1070 TopTools_ListOfShape thelist;
1071 aMapOfTreatedVertexListOfEdge.Bind(aVertex, thelist);
1073 aMapOfTreatedVertexListOfEdge(aVertex).Append(ei);
1078 ok = mktdg.MkTonE(mkt, par1,par2);
1081 // modified by NIZHNY-MKK Tue Nov 21 17:31:36 2000.END
1082 if ((!ok) || (mkt == NOI)) return NOI;
1084 isT2d = mktdg.IsT2d();
1086 if ((mkt == MKI1)||(mkt == MKI12)) {Trans1.Set(TopAbs_FORWARD); param1 = par1;}
1087 if ((mkt == MKI2)||(mkt == MKI12)) {Trans2.Set(TopAbs_REVERSED); param2 = par2;}
1089 // ********** iterate on restrictions of fi **********
1090 // TopTools_ListOfShape lei; mktdg.GetAllRest(lei);
1091 // TopTools_ListIteratorOfListOfShape ite(lei);
1092 // for (; ite.More(); ite.Next()){
1093 // Standard_Boolean oki = mktdg.MkTonE(ei,mkt,par1,par2);
1096 }//FUN_putInterfonDegenEd
1098 //=======================================================================
1099 //function : ProcessVPondgE
1100 //purpose : SUPPLYING INTPATCH when a degenerated edge is touched.
1101 //=======================================================================
1103 #define s_NOIdgE (0) // do NOT compute any interference
1104 #define s_IdgE (1) // compute interference(s) on dgE
1105 #define s_IOOEi (2) // compute interference(s) on OOEi
1107 Standard_Boolean TopOpeBRep_FacesFiller::ProcessVPondgE
1108 (const TopOpeBRep_VPointInter& VP,
1109 const Standard_Integer ShapeIndex,
1110 TopOpeBRepDS_Kind& PVKind, Standard_Integer& PVIndex, // out
1111 Standard_Boolean& EPIfound, Handle(TopOpeBRepDS_Interference)& IEPI, // out
1112 Standard_Boolean& CPIfound, Handle(TopOpeBRepDS_Interference)& ICPI) // out
1115 Standard_Boolean traceDSF = TopOpeBRepDS_GettraceDSF();
1116 Standard_Boolean traceDEGEN = TopOpeBRepDS_GettraceDEGEN();
1119 if (PVIndex == 0) FUN_VPIndex ((*this),(*myLine),VP,ShapeIndex,myHDS,myDSCIL, //in
1120 PVKind,PVIndex, // out
1121 EPIfound,IEPI, // out
1122 CPIfound,ICPI, // out
1125 // kpart : sphere/box, with one sphere's degenerated edge lying on one boxe's
1126 // face, IN or ON the face
1127 // if (mIdgEorOOEi), adds interferences on degenerated edge
1129 // If interferences should be added, finds out <VP>'s geometry
1130 // in existing interferences (see out parameters <EPIfound>..);
1131 // adds a new point/vertex to the DS if necessary.
1134 Standard_Boolean hasOOEi=Standard_False; TopoDS_Edge OOEi; Standard_Real parOOEi;
1135 TopOpeBRepDS_Transition T1ondg, T2ondg;
1136 Standard_Integer rankdg=0, Iiondg=0;
1137 Standard_Real par1ondg, par2ondg;
1138 Standard_Boolean hasdgdata = !myDataforDegenEd.IsEmpty();
1140 return Standard_False;
1143 // modified by NIZHNY-MKK Tue Nov 21 17:35:29 2000
1144 local_ReduceMapOfTreatedVertices(myLine);
1146 Standard_Boolean isT2d = Standard_False; TopoDS_Edge dgEd;
1147 Standard_Integer makeI = FUN_putInterfonDegenEd (VP,myF1,myF2,myDataforDegenEd,myHDS,
1148 rankdg,dgEd, Iiondg,T1ondg,par1ondg,T2ondg,par2ondg,
1149 OOEi,parOOEi,hasOOEi, isT2d);
1151 return Standard_False;
1154 // -------------------------------------------------------------------
1155 // --- DS geometry Management ---
1156 // -------------------------------------------------------------------
1158 if (PVIndex == 0) FUN_VPIndex ((*this),(*myLine),VP,ShapeIndex,myHDS,myDSCIL, //in
1159 PVKind,PVIndex, // out
1160 EPIfound,IEPI, // out
1161 CPIfound,ICPI, // out
1164 // -------------------------------------------------------------------
1165 // --- EVI on degenerated edge ---
1167 // -------------------------------------------------------------------
1169 Standard_Integer rankFi = (rankdg == 1) ? 2 : 1;
1170 // TopoDS_Shape dgEd = VP.Edge(rankdg);
1172 if (rankFi == 1) Fi = myF1;
1174 Standard_Integer iFi = myDS->AddShape(Fi,rankFi);
1176 Standard_Integer iEd =
1178 myDS->AddShape(dgEd,rankdg);
1179 Standard_Integer iOOEi = 0;
1180 if (hasOOEi) iOOEi = myDS->AddShape(OOEi,rankFi);
1183 Standard_Boolean trace = traceDSF || traceDEGEN;
1184 if (trace) cout<<" VP is on degenerated edge "<<iEd<<" :"<<endl;
1186 Standard_Integer rkv = myDS->AncestorRank(myDS->Shape(PVIndex));
1188 if ((makeI == MKI1)||(makeI == MKI12)) {
1190 Standard_Boolean isvertex1 = (rkv == 1);
1193 Handle(TopOpeBRepDS_Interference) EVI1i = ::MakeEPVInterference(T1ondg,iOOEi,PVIndex,par1ondg,
1194 TopOpeBRepDS_VERTEX,TopOpeBRepDS_EDGE,isvertex1);
1195 myHDS->StoreInterference(EVI1i,dgEd);
1198 Handle(TopOpeBRepDS_Interference) EVI1 = ::MakeEPVInterference(T1ondg,iFi,PVIndex,par1ondg,
1199 TopOpeBRepDS_VERTEX,TopOpeBRepDS_FACE,isvertex1);
1200 myHDS->StoreInterference(EVI1,dgEd);
1203 if ((makeI == MKI2)||(makeI == MKI12)) {
1205 Standard_Boolean isvertex2 = (rkv == 2);
1208 Handle(TopOpeBRepDS_Interference) EVI2i = ::MakeEPVInterference(T2ondg,iOOEi,PVIndex,par2ondg,
1209 TopOpeBRepDS_VERTEX,TopOpeBRepDS_EDGE,isvertex2);
1210 myHDS->StoreInterference(EVI2i,dgEd);
1213 Handle(TopOpeBRepDS_Interference) EVI2 = ::MakeEPVInterference(T2ondg,iFi,PVIndex,par2ondg,
1214 TopOpeBRepDS_VERTEX,TopOpeBRepDS_FACE,isvertex2);
1215 myHDS->StoreInterference(EVI2,dgEd);
1219 return Standard_True;
1223 // modified by NIZHNY-MKK Tue Nov 21 17:32:52 2000.BEGIN
1224 static Standard_Boolean local_FindTreatedEdgeOnVertex(const TopoDS_Edge& theEdge,
1225 const TopoDS_Vertex& theVertex) {
1226 Standard_Boolean found = Standard_False;
1227 if(aMapOfTreatedVertexListOfEdge.IsBound(theVertex)) {
1228 TopTools_ListIteratorOfListOfShape anIt(aMapOfTreatedVertexListOfEdge(theVertex));
1229 for(; !found && anIt.More(); anIt.Next()) {
1230 if(theEdge.IsSame(anIt.Value())) {
1231 found = Standard_True;
1238 static Standard_Boolean local_FindVertex(const TopOpeBRep_VPointInter& theVP,
1239 const TopTools_IndexedDataMapOfShapeListOfShape& theMapOfVertexEdges,
1240 TopoDS_Vertex& theVertex) {
1241 gp_Pnt aVPPoint = theVP.Value();
1242 Standard_Real aVPTolerance = theVP.Tolerance();
1243 Standard_Boolean vertexfound = Standard_False;
1244 for(Standard_Integer itVertex=1; !vertexfound && itVertex<=theMapOfVertexEdges.Extent(); itVertex++) {
1245 theVertex = TopoDS::Vertex(theMapOfVertexEdges.FindKey(itVertex));
1246 gp_Pnt aPoint = BRep_Tool::Pnt(theVertex);
1247 if(aVPPoint.IsEqual(aPoint, aVPTolerance)) {
1248 vertexfound = Standard_True;
1254 static void local_ReduceMapOfTreatedVertices(const TopOpeBRep_PLineInter& theCurrentLine) {
1256 if(localCurrentLine==NULL) {
1257 localCurrentLine = theCurrentLine;
1258 aMapOfTreatedVertexListOfEdge.Clear();
1261 if(localCurrentLine != theCurrentLine) {
1262 localCurrentLine = theCurrentLine;
1263 aMapOfTreatedVertexListOfEdge.Clear();
1267 // modified by NIZHNY-MKK Tue Nov 21 17:32:55 2000.END