0024201: Remove TODO "Tcl Exception: File aaa.stl could not be found" and similar...
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_GridEE.cxx
CommitLineData
b311480e 1// Created on: 1996-03-07
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1996-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
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.
10//
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.
13//
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.
20
7fd59977 21
22#include <TopOpeBRepBuild_Builder.ixx>
23#include <TopOpeBRepBuild_define.hxx>
24#include <TopOpeBRepDS_EXPORT.hxx>
25
26#ifdef DRAW
27#include <TopOpeBRepDS_DRAW.hxx>
28#endif
29
30#include <TopOpeBRepDS_EXPORT.hxx>
31#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
32#include <TopOpeBRepTool_EXPORT.hxx>
33#include <TopOpeBRepTool_TOOL.hxx>
34#include <TopOpeBRepDS_TKI.hxx>
35#include <TopOpeBRepDS.hxx>
36#include <BRep_Tool.hxx>
37#include <TopoDS.hxx>
38#include <Geom_Curve.hxx>
39#include <Geom2d_Curve.hxx>
40#include <Geom_Plane.hxx>
41#include <gp_Pnt.hxx>
42#include <gp_Pnt2d.hxx>
43#include <ElCLib.hxx>
44#include <ElSLib.hxx>
45#include <Geom2dAdaptor_Curve.hxx>
46#include <Precision.hxx>
47#include <BRepAdaptor_Curve.hxx>
48#include <TopOpeBRepTool_2d.hxx>
49#include <TopOpeBRepDS_Dumper.hxx>
50#include <Standard_ProgramError.hxx>
51
52#ifdef DEB
53Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextNOSG();
54#endif
55
56#define M_FORWARD(st) (st == TopAbs_FORWARD)
57#define M_REVERSED(st) (st == TopAbs_REVERSED)
58#define M_INTERNAL(st) (st == TopAbs_INTERNAL)
59#define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)
60
1d0a9d4d 61Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom(const TopoDS_Shape& S1,const TopoDS_Shape& S2);
7fd59977 62
63
64//=======================================================================
65//function : GMergeEdges
66//purpose :
67//=======================================================================
68void TopOpeBRepBuild_Builder::GMergeEdges(const TopTools_ListOfShape& LE1,const TopTools_ListOfShape& LE2,const TopOpeBRepBuild_GTopo& G1)
69{
70 if ( LE1.IsEmpty() ) return;
71 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
72
73 const TopoDS_Shape& E1 = LE1.First();
74#ifdef DEB
75 Standard_Integer iE; Standard_Boolean tSPS1 = GtraceSPS(E1,iE);
76 if(tSPS1){
77 cout<<endl;cout<<"--- GMergeEdges "<<endl;
78 GdumpEDG(E1);
79 GdumpSAMDOM(LE1, (char *) "1 : ");
80 GdumpSAMDOM(LE2, (char *) "2 : ");
81 }
82#endif
83
84 myEdgeReference = TopoDS::Edge(E1);
85 TopOpeBRepBuild_PaveSet PVS(E1);
86
87 GFillEdgesPVS(LE1,LE2,G1,PVS);
88
89 // Create a edge builder EBU
90 TopoDS_Shape E1F = LE1.First(); E1F.Orientation(TopAbs_FORWARD);
91 TopOpeBRepBuild_PaveClassifier VCL(E1F);
92 Standard_Boolean equalpar = PVS.HasEqualParameters();
93 if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
94 TopOpeBRepBuild_EdgeBuilder EDBU(PVS,VCL);
95
96 // Build the new edges LEM
97 TopTools_ListOfShape LEM;
98 GEDBUMakeEdges(E1F,EDBU,LEM);
99
100 // connect new edges as edges built TB1 on LE1 edges
101 TopTools_ListIteratorOfListOfShape it1;
102 for (it1.Initialize(LE1); it1.More(); it1.Next()) {
103 const TopoDS_Shape& E11 = it1.Value();
104 ChangeMerged(E11,TB1) = LEM;
105 }
106
107 // connect new edges as edges built TB2 on LE2 edges
108 TopTools_ListIteratorOfListOfShape it2;
109 for (it2.Initialize(LE2); it2.More(); it2.Next()) {
110 const TopoDS_Shape& E2 = it2.Value();
111 ChangeMerged(E2,TB2) = LEM;
112 }
113
114} // GMergeEdges
115
116//=======================================================================
117//function : GFillEdgesPVS
118//purpose :
119//=======================================================================
120void TopOpeBRepBuild_Builder::GFillEdgesPVS(const TopTools_ListOfShape& LE1,const TopTools_ListOfShape& LE2,const TopOpeBRepBuild_GTopo& G1,TopOpeBRepBuild_PaveSet& PVS)
121{
122 if ( LE1.IsEmpty() ) return;
123 TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);
124
125 const TopoDS_Shape& E1 = LE1.First();
126 myEdgeReference = TopoDS::Edge(E1);
127
128 TopTools_ListIteratorOfListOfShape it1;
129 for (it1.Initialize(LE1); it1.More(); it1.Next()) {
130 const TopoDS_Shape& E11 = it1.Value();
131 Standard_Boolean ismerged = IsMerged(E11,TB1);
132
133#ifdef DEB
134 Standard_Integer i1; Standard_Boolean tSPS1 = GtraceSPS(E11,i1);
135 if(tSPS1){
136 cout<<endl;cout<<"--- GFillEdgesPVS ";GdumpSHA(E11);
137 cout<<" ismerged : "<<ismerged<<" ";TopAbs::Print(TB1,cout);cout<<endl;
138 }
139#endif
140
141 if (!ismerged) GFillEdgePVS(E11,LE2,G1,PVS);
142 }
143
144 TopOpeBRepBuild_GTopo G2 = G1.CopyPermuted();
145
146 TopTools_ListIteratorOfListOfShape it2;
147 for (it2.Initialize(LE2); it2.More(); it2.Next() ) {
148 const TopoDS_Shape& E2 = it2.Value();
149 Standard_Boolean ismerged = IsMerged(E2,TB2);
150
151#ifdef DEB
152 Standard_Integer i2; Standard_Boolean tSPS2 = GtraceSPS(E2,i2);
153 if(tSPS2){
154 cout<<endl;
155 cout<<"--- GFillEdgesPVS ";GdumpSHA(E2);
156 cout<<" ismerged : "<<ismerged<<" ";TopAbs::Print(TB2,cout);cout<<endl;
157 }
158#endif
159
160 if (!ismerged) GFillEdgePVS(E2,LE1,G2,PVS);
161 }
162
163} // GFillEdgesPVS
164
165//=======================================================================
166//function : GFillEdgePVS
167//purpose :
168//=======================================================================
169void TopOpeBRepBuild_Builder::GFillEdgePVS(const TopoDS_Shape& E,
170 const TopTools_ListOfShape& /*LE2*/,
171 const TopOpeBRepBuild_GTopo& G,
172 TopOpeBRepBuild_PaveSet& PVS)
173{
174 TopAbs_ShapeEnum t1,t2,ShapeInterf;
175 G.Type(t1,t2);
176 ShapeInterf = t1;
177 TopAbs_State TB1,TB2;
178 G.StatesON(TB1,TB2);
179
180 // work on a FORWARD edge EF
181 TopoDS_Shape EF = E;
182 EF.Orientation(TopAbs_FORWARD);
183 // Add the point/vertex topology build/found on edge EF in PVS
184 GFillPointTopologyPVS(EF,G,PVS);
185
186} // GFillEdgePVS
187
188// --- iterer sur EPit jusqu'a la prochaine interference dont la
189// --- transition est definie sur un shape de type SHA Before et After
190static Standard_Boolean FUN_MoreSHAINT(TopOpeBRepDS_PointIterator& EPit,
191 const TopAbs_ShapeEnum SHA)
192{
193 Standard_Boolean more = Standard_False;
194 while (EPit.More()) {
195 const Handle(TopOpeBRepDS_Interference)& I = EPit.Value();
196 const TopOpeBRepDS_Transition& T = I->Transition();
197 TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S);
198 TopAbs_ShapeEnum SB,SA; Standard_Integer IB,IA; FDS_Tdata(I,SB,IB,SA,IA);
199
200 TopAbs_ShapeEnum b = T.ShapeBefore(), a = T.ShapeAfter();
201 Standard_Boolean rejet = ( (b != SHA) || (a != SHA) );
202 if ( rejet ) EPit.Next();
203 else {
204 more = Standard_True;
205 break;
206 }
207 }
208 return more;
209}
210
211// Unused :
212/*#ifdef DEB
213static Standard_Integer FUN_getTRASHA(const Standard_Integer geti,
214 const TopOpeBRepDS_ListOfInterference& lFOR, const Standard_Integer FOR,
215 const TopOpeBRepDS_ListOfInterference& lREV, const Standard_Integer REV,
216 const TopOpeBRepDS_ListOfInterference& lINT, const Standard_Integer INT)
217{
218 Standard_Integer trasha = 0;
219 if (geti == 1) { // get i before
220 if (REV) trasha = lREV.First()->Transition().Before();
221 if (INT) trasha = lINT.First()->Transition().Before();
222 }
223 if (geti == 2) { // get i after
224 if (FOR) trasha = lFOR.Last()->Transition().After();
225 if (INT) trasha = lINT.Last()->Transition().After();
226 }
227 return trasha;
228}
229#endif*/
230
231#ifdef DEB
232void debfillp(const Standard_Integer i) {cout <<"+ + debfillp "<<i<<endl;}
233void debfillpon(const Standard_Integer i) {cout <<"+ + debfillpon "<<i<<endl;}
234void debfillpin(const Standard_Integer i) {cout <<"+ + debfillpin "<<i<<endl;}
235void debfillpou(const Standard_Integer i) {cout <<"+ + debfillpou "<<i<<endl;}
236void debfillp2(const Standard_Integer i) {cout <<"+ + debfillp2 "<<i<<endl;}
237#endif
238
239//Standard_IMPORT extern Standard_Boolean GLOBAL_faces2d;
1d0a9d4d 240extern Standard_Boolean GLOBAL_faces2d;
7fd59977 241
242Standard_EXPORT Standard_Boolean FDS_SIisGIofIofSBAofTofI(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SI,const Handle(TopOpeBRepDS_Interference)& I);
243//Standard_IMPORT extern Standard_Boolean GLOBAL_IEtoMERGE; // xpu240498
244Standard_IMPORT Standard_Boolean GLOBAL_IEtoMERGE; // xpu240498
245//Standard_IMPORT extern Standard_Integer GLOBAL_issp;
1d0a9d4d 246extern Standard_Integer GLOBAL_issp;
7fd59977 247//Standard_IMPORT extern Standard_Integer GLOBAL_hassd;
248Standard_IMPORT Standard_Integer GLOBAL_hassd;
249
250static Standard_Boolean FUN_isonbound(const Handle(TopOpeBRepDS_HDataStructure)& HDS,
251 const Handle(TopOpeBRepDS_Interference)& I)
252{
253 Standard_Integer G = I->Geometry();
254 TopOpeBRepDS_Kind KG = I->GeometryType();
255 Standard_Boolean Gb1 = (KG == TopOpeBRepDS_VERTEX);
256 if (Gb1) {
257 Handle(TopOpeBRepDS_EdgeVertexInterference) EVI= Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I);
258 Standard_Boolean vhassd = HDS->HasSameDomain(HDS->DS().Shape(G));
259 Gb1 = (EVI.IsNull()) ? Standard_False : EVI->GBound();
260 Gb1 = Gb1 && !vhassd;
261 }
262 return Gb1;
263}
264
265#define TheIN (1)
266#define TheON (2)
267#define TheOUT (3)
268#define HASSD2d (2)
269#define HASSD3d (3)
270#define FIRST (1)
271#define LAST (2)
272
273//=======================================================================
274//function : GFillPointTopologyPVS
275//purpose :
276//=======================================================================
277void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& E,
278 const TopOpeBRepBuild_GTopo& G,
279 TopOpeBRepBuild_PaveSet& PVS)
280{
281#ifdef DEB
282// TopAbs_State TB1,TB2;
283// G.StatesON(TB1,TB2);
284// TopOpeBRepDS_Config GConf1 = G.Config1();
285// TopOpeBRepDS_Config GConf2 = G.Config2();
286#endif
287 TopAbs_ShapeEnum t1,t2,ShapeInterf;
288 G.Type(t1,t2);
289 ShapeInterf = t1;
290 const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
291 const Standard_Integer iEDS = BDS.Shape(E);
292#ifdef DEB
293// Standard_Integer rkE = BDS.AncestorRank(E);
294#endif
295 Standard_Boolean isSE = BDS.IsSectionEdge(TopoDS::Edge(E));
296 Standard_Boolean dgE = BRep_Tool::Degenerated(TopoDS::Edge(E));
297 Standard_Boolean isEd;
298
299 isEd = BRep_Tool::Degenerated(TopoDS::Edge(E));
300#ifdef DEB
301// Standard_Boolean hsd = myDataStructure->HasSameDomain(E); //xpu170498
302#endif
303 Standard_Boolean isfafa = BDS.Isfafa(); //xpu120598
304
305#ifdef DEB
306 Standard_Boolean tSPSE=GtraceSPS(iEDS);
307 TCollection_AsciiString striE=TopOpeBRepDS::SPrint(TopAbs_EDGE,iEDS);
308 const TopoDS_Shape& EPVS=PVS.Edge();Standard_Integer iEPVS;Standard_Boolean tSPSEPVS=GtraceSPS(EPVS,iEPVS);
309 Standard_Boolean tSPS = tSPSE || tSPSEPVS;
310 if(tSPS){
311 cout<<endl;
312 cout<<"--- GFillPointTopologyPVS : ShapeInterf ";TopAbs::Print(ShapeInterf,cout);
313 cout<<",efil ";GdumpSHA(E);cout<<",eref ";GdumpSHA(myEdgeReference);
314 cout<<",ffil ";GdumpSHA(myFaceToFill);cout<<",fref ";GdumpSHA(myFaceReference);
315 cout<<endl;
316 debfillp(iEDS);
317 }
318#endif
319
320 Standard_Boolean isspin=(GLOBAL_issp==TheIN), isspou=(GLOBAL_issp==TheOUT), isspon=(GLOBAL_issp==TheON);
321 if (isSE && (GLOBAL_issp == 0)) return; // splits done in process ProcessSectionEdges
322
323#ifdef DEB
324// Standard_Integer iefil = BDS.Shape(E);
325// Standard_Integer iffil = BDS.Shape(myFaceToFill);
326// Standard_Integer ieref = BDS.Shape(myEdgeReference);
327// Standard_Integer ifref = BDS.Shape(myFaceReference);
328 if(tSPS) {
329 if (isspon) debfillpon(iEDS);
330 if (isspin) debfillpin(iEDS);
331 if (isspou) debfillpou(iEDS);
332 }
333#endif
334
335 // 0.
336 //---
337 const TopOpeBRepDS_ListOfInterference& lIE = BDS.ShapeInterferences(E);
338 Standard_Boolean scanall = (isspin || isspou || isspon); // xpu161198: BUC60382 //xpu011098: CTS21180(e8on); cto900I7(e12on)
339
340 // loiSHAINT = interferences avec les 2 proprietes
341 // - fournies par un PointIterator
342 // - dont la transition est definie / shape = ShapeInterf
343 TopOpeBRepDS_ListOfInterference loiSHAINT;
344 if (scanall) FDS_assign(lIE,loiSHAINT);
345 else {
346 TopOpeBRepDS_PointIterator EPit(lIE);
347 EPit.Init(BDS.ShapeInterferences(E));
348 Standard_Boolean addi = FUN_MoreSHAINT(EPit,ShapeInterf);
349 while (addi) {
350 const Handle(TopOpeBRepDS_Interference)& II = EPit.Value();
351 loiSHAINT.Append(II);
352 EPit.Next();
353 addi = FUN_MoreSHAINT(EPit,ShapeInterf);
354 }
355 }
356
357 TopOpeBRepDS_TKI tki;
358 tki.FillOnGeometry(loiSHAINT); // groupage par geometrie d'interference
359
360 // - kp1 -
361 // BUC60093 : only 2 G : 1 point && 1 vertex
362 // deleting interfs on G = vertex sdm && closingE
363 TopoDS_Vertex vclo; Standard_Boolean closedE = TopOpeBRepTool_TOOL::ClosedE(TopoDS::Edge(E),vclo);
364 Standard_Integer kp1 = 0; Standard_Integer ikp1 = 0;
365 if (closedE) {
366 tki.Init();
367 Standard_Integer nG = 0;
368 while (tki.More()) {
369 nG++;
370 TopOpeBRepDS_Kind Kcur;Standard_Integer Gcur;
371 tki.Value(Kcur,Gcur);
372 if (Kcur == TopOpeBRepDS_POINT) {tki.Next();continue;}
373 const TopoDS_Shape& v = BDS.Shape(Gcur);
374 TopoDS_Shape oov;
375 FUN_ds_getoov(v,myDataStructure,oov);
376 Standard_Boolean samev = v.IsSame(vclo), sameoov = oov.IsSame(vclo);
377 if (samev || sameoov) {ikp1 = Gcur; kp1 = Gcur;}
378 tki.Next();
379 }
380 if (nG == 1) kp1 = 0; // we have only one interf on vGclo -> keep the interf
381 } //kp1
382
383 // - kp6 - nyiReducing
384 // xpu250998 : cto900M5 (e5,p1)
385 // prequesitory : if we have I3d on Gb0 FORWARD or REVERSED, we do NOT need
386 // interference on Gb1 to determinate split IN/OUT of edge.
387 Standard_Boolean kp6 = (!isSE);
388 if (kp6) {
389 kp6 = Standard_False;
390 TopOpeBRepDS_ListIteratorOfListOfInterference it(loiSHAINT);
391 for (; it.More(); it.Next()){
392 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
393 TopOpeBRepDS_Kind ST = I->SupportType();
394 if (ST != TopOpeBRepDS_FACE) continue;
395 TopAbs_Orientation O = I->Transition().Orientation(TopAbs_IN);
396 Standard_Boolean FORREV = (O == TopAbs_FORWARD) || (O == TopAbs_REVERSED);
397 if (!FORREV) continue;
398 Standard_Boolean Gb1 = ::FUN_isonbound(myDataStructure,I);
399 if (!Gb1) {kp6 = Standard_True; break;}
400 } // it(l3dFOR+l3dREV)
401 }
402
403 // 1.
404 //---
405 tki.Init();
406 while (tki.More()) {
407
408 // lieu courant : Kcur,Gcur; Interferences : LICur
409 TopOpeBRepDS_Kind Kcur;
410 Standard_Integer Gcur;
411 const TopOpeBRepDS_ListOfInterference& LICur = tki.Value(Kcur,Gcur);
412 Standard_Boolean point = (Kcur == TopOpeBRepDS_POINT); //xpu170498
413 Standard_Boolean vertex = (Kcur == TopOpeBRepDS_VERTEX);//xpu170498
414#ifdef DEB
415// Standard_Integer nLICur = LICur.Extent();
416 Standard_Boolean trcI = Standard_False;
417 if(trcI) {TopOpeBRepDS_Dumper DSD(myDataStructure); TCollection_AsciiString aa("lI");
418 aa += TCollection_AsciiString(Gcur); DSD.DumpLOI(LICur,cout,aa);}
419#endif
420
421 Standard_Boolean Ghsd = Standard_False; TopoDS_Shape vGsd;
422 if (vertex) Ghsd = FUN_ds_getoov(BDS.Shape(Gcur), myDataStructure, vGsd); //xpu221098
423
424 // recall : I3d=(I3dF,I3dFE) : I3dF=(T(F),G,F), I3dFE=(T(F),G,E)
425 // I2d=I2dFE
426 // I1d=(T(E),V,E)
427
428 if ((Kcur == TopOpeBRepDS_VERTEX) && (kp1 == Gcur)) {tki.Next();continue;}
429 const Handle(TopOpeBRepDS_Interference)& I = LICur.First();
430 Standard_Real parSE = FDS_Parameter(I);
431 TopOpeBRepDS_ListOfInterference LICurcopy;
432 TopOpeBRepDS_ListOfInterference l3dFcur; FDS_assign(LICur,LICurcopy); Standard_Integer n3d=FUN_selectSKinterference(LICurcopy,TopOpeBRepDS_FACE,l3dFcur);
433 TopOpeBRepDS_ListOfInterference l2dFEcur; FDS_assign(LICur,LICurcopy); Standard_Integer n2d=FUN_ds_hasI2d(iEDS,LICurcopy,l2dFEcur);
434 TopOpeBRepDS_ListOfInterference l1dEcur; FDS_assign(LICur,LICurcopy);
435 FUN_selectTRASHAinterference(LICurcopy,TopAbs_EDGE,l1dEcur);
436
437 TopAbs_State stb; Standard_Integer isb; Standard_Integer bdim;
438 TopAbs_State sta; Standard_Integer isa; Standard_Integer adim;
439 FUN_ds_GetTr(BDS,iEDS,Gcur,LICur,
440 stb,isb,bdim,
441 sta,isa,adim);
442 if (isSE) {
443 // before
444 Standard_Boolean bIN1d = (stb==TopAbs_IN)&&(bdim==1);
445 Standard_Boolean bIN2d = (stb==TopAbs_IN)&&(bdim==2);
446 Standard_Boolean bIN3d = (stb==TopAbs_IN)&&(bdim==3);
447
448 Standard_Boolean bOUT2d = (stb==TopAbs_OUT)&&(bdim==2);
449 Standard_Boolean bOUT3d = (stb==TopAbs_OUT)&&(bdim==3);
450 // after
451 Standard_Boolean aIN1d = (sta==TopAbs_IN)&&(adim==1);
452 Standard_Boolean aIN2d = (sta==TopAbs_IN)&&(adim==2);
453 Standard_Boolean aIN3d = (sta==TopAbs_IN)&&(adim==3);
454
455 Standard_Boolean aOUT2d = (sta==TopAbs_OUT)&&(adim==2);
456 Standard_Boolean aOUT3d = (sta==TopAbs_OUT)&&(adim==3);
457
458 TopOpeBRepDS_Transition newT; Standard_Boolean INb=Standard_False,INa=Standard_False;
459 if (isfafa) {
460 if (isspon) {
461 if ((stb == TopAbs_OUT)&&(sta == TopAbs_OUT)) {tki.Next(); continue;}
462 INb = bIN1d;
463 INa = aIN1d;
464 newT.Index(isb); newT.ShapeBefore(TopAbs_EDGE); newT.ShapeAfter(TopAbs_EDGE);
465 } else if (isspin) {
466 INb = bIN2d;
467 INa = aIN2d;
468 newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE);
469 } else if (isspou) {
470 INb = !bOUT2d;
471 INa = !aOUT2d;
472 newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE);
473 }
474 }
475 else {
476 if (isspon) {
477 if ((stb == TopAbs_OUT)&&(sta == TopAbs_OUT)) {tki.Next(); continue;}
478 INb = bIN1d || bIN2d;
479 INa = aIN1d || aIN2d;
480 newT.Index(isb); newT.ShapeBefore(TopAbs_EDGE); newT.ShapeAfter(TopAbs_EDGE);
481 } else if (isspin) {
482 if ((stb == TopAbs_OUT)&&(sta == TopAbs_OUT)) {tki.Next(); continue;}
483 INb = bIN3d;
484 INa = aIN3d;
485 if (INb) newT.Index(isb);
486 else newT.Index(isa);
487 newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE);
488 } else if (isspou) {
489 if ((stb == TopAbs_IN)&&(sta == TopAbs_IN)) {tki.Next(); continue;}
490 INb = !bOUT3d;
491 INa = !aOUT3d;
492 if (bOUT3d) newT.Index(isb);
493 else newT.Index(isa);
494 newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE);
495 }
496 }
497 TopAbs_State sb = INb ? TopAbs_IN : TopAbs_OUT;
498 TopAbs_State sa = INa ? TopAbs_IN : TopAbs_OUT;
499 newT.StateBefore(sb);newT.StateAfter(sa);
500 Standard_Integer S=0; // dummy
501 Standard_Boolean B = (Kcur == TopOpeBRepDS_POINT) ? Standard_False : (Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound());
502 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,S,Gcur,parSE,Kcur,B);
503
504 TopOpeBRepDS_ListOfInterference li; li.Append(newI); TopOpeBRepDS_PointIterator itCur(li);
505 GFillPointTopologyPVS(E,itCur,G,PVS);
506#ifdef DEB
507 if(tSPS) {newI->Dump(cout,"\nnewinterf ","\n\n"); debfillp2(iEDS);}
508#endif
509 {tki.Next(); continue;}
510 } // isSE
511
512 // - kp3 -
513 // xpu200598 interference 2d at GPOINT
514 Standard_Boolean kp3 = (n2d > 0) && point;
515 TopAbs_Orientation Okp3 = TopAbs_EXTERNAL;
516 if (kp3) Okp3=l2dFEcur.First()->Transition().Orientation(TopAbs_IN);
517
518
519 TopOpeBRepDS_PointIterator itCur(LICur); Standard_Integer iICur=0;
520 while ( itCur.More() ) {
521 iICur++;
522 const Handle(TopOpeBRepDS_Interference)& I1=itCur.Value();
523 const TopOpeBRepDS_Transition& T1=I1->Transition();
524 T1.Orientation(TopAbs_IN);
525 TopAbs_ShapeEnum SB1,SA1;Standard_Integer IB1,IA1;TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1;
526 FDS_Idata(I1,SB1,IB1,SA1,IA1,GT1,G1,ST1,S1);
527
528#ifdef DEB
529 if(tSPS) {I1->Dump(cout,"\n? keepinterf ","\n\n"); debfillp2(iEDS);}
530#endif
531
532 Standard_Boolean keepinterf1 = Standard_False;
533 if (isEd) {
534 keepinterf1 = Standard_True;
535 }
536 else {
537 if (GLOBAL_faces2d) { // split 2d
538 Standard_Boolean has2d3d = (n2d >0 && n3d >0); // JYL300998
539 // JYL300998 : traitement correct de cto 100 K1 e27 (chanceux auparavant, schema d'I faux)
540 // e27 n'est PAS arete de section mais doit etre traitee comme telle.
541 // e27 possede des I de nature 2d et 3d en V8
542 // on privilegie l'info 3d
543 if (has2d3d && !isSE) {
544#ifdef DEB
545 const Handle(TopOpeBRepDS_Interference)& i2d =
546#endif
547 l2dFEcur.First();
548 const Handle(TopOpeBRepDS_Interference)& i3d = l3dFcur.First();
549 Standard_Boolean id3d = (I1 == i3d);
550#ifdef DEB
551 Standard_Boolean id2d = (I1 == i2d);
552#endif
553 keepinterf1 = id3d;
554#ifdef DEB
555 if (tSPS) {
556 cout<<"DEB : GFillPointTopologyPVS E"<<iEDS<<" has2d3d"<<endl;
557 i2d->Dump(cout,"2d : ","\n");
558 i3d->Dump(cout,"3d : ","\n");
559 I1->Dump (cout,"I1 : ","\n");
560 if (id3d) cout<<"--> Interference 3d ";
561 if (id2d) cout<<"--> Interference 2d ";
562 if (keepinterf1) cout<<" traitee"<<endl;
563 else cout<<" non traitee"<<endl;
564 cout<<endl;
565 }
566#endif
567 }
568 else {
569 keepinterf1 = Standard_True; // PRO13075 tspIN(e17)
570 }
571 } // split 2d
572 else { // split 3d
573 keepinterf1 = (ST1 == TopOpeBRepDS_FACE); // (iICur == 1);
574 }
575 }
576 if ( keepinterf1 ) {
577 if (kp6) {
578 Standard_Boolean Gb1 = ::FUN_isonbound(myDataStructure,I1);
579 if (!Gb1) GFillPointTopologyPVS(E,itCur,G,PVS);
580 }
581 else {
582 GFillPointTopologyPVS(E,itCur,G,PVS);
583 }
584 if (!dgE) break; // xpu140498
585 } // keepinterf1
586 itCur.Next();
587 } // itCur.More
588
589 tki.Next();
590 } // tki.More()
591}
592
593//=======================================================================
594//function : GFillPointTopologyPVS
595//purpose :
596//=======================================================================
597void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& E,
598 const TopOpeBRepDS_PointIterator& EPit,
599 const TopOpeBRepBuild_GTopo& G1,
600 TopOpeBRepBuild_PaveSet& PVS) const
601{
602 const TopoDS_Shape& EPVS = PVS.Edge();
603
604 //modified by NIZHNY-MZV Mon Feb 21 14:47:34 2000
605 const Handle(TopOpeBRepDS_Interference)& I1=EPit.Value();
606 TopOpeBRepDS_Kind ST1 = I1->SupportType();
607
608#ifdef DEB
609 Standard_Integer iE; Standard_Boolean tSPSE = GtraceSPS(E,iE);
610 Standard_Integer iEPVS; Standard_Boolean tSPSEPVS = GtraceSPS(EPVS,iEPVS);
611 Standard_Boolean tSPS = tSPSE || tSPSEPVS;
612 if ( tSPS ) debfillp(iE);
613#endif
614
615 TopAbs_State TB1,TB2;
616 G1.StatesON(TB1,TB2);
617 TopOpeBRepDS_Config Conf = G1.Config1();
618 TopAbs_State TB = TB1;
619
620 // iG = index of new point or existing vertex
621 Standard_Integer iG = EPit.Current();
622 Standard_Boolean ispoint = EPit.IsPoint();
623 TopoDS_Vertex VIG; // NYI pointer
624 if (ispoint) VIG = TopoDS::Vertex(NewVertex(iG));
625 else VIG = TopoDS::Vertex(myDataStructure->Shape(iG));
626
627 if (VIG.IsNull()) return; //PMN 17/02/99 Nothing to add.
628
629 Standard_Boolean hasVSD = Standard_False;
630 Standard_Integer iVRE = 0; TopoDS_Shape VRE; // NYI pointer
631 if (!ispoint) {
632 hasVSD = myDataStructure->HasSameDomain(VIG);
633 if (hasVSD) { // on prend VRE = vertex reference de VIG
634 iVRE = myDataStructure->SameDomainReference(VIG);
635 VRE = TopoDS::Vertex(myDataStructure->Shape(iVRE));
636 }
637 }
638
639 TopoDS_Vertex VPV; // NYI pointer on VRE or VIG
640 if (hasVSD) VPV = TopoDS::Vertex(VRE);
641 else VPV = VIG;
642// else VPV = TopoDS::Vertex(VIG);
643
644 Standard_Real par = EPit.Parameter();
645 TopAbs_Orientation ori = EPit.Orientation(TB);
646
647#ifdef DEB
648 if ( tSPS ) debfillp(iE);
649#endif
650
651 Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(E,EPVS);
652 if (Conf == TopOpeBRepDS_DIFFORIENTED) ori = TopAbs::Complement(ori);
653#ifdef DEB
654 if (!TopOpeBRepBuild_GetcontextNOSG()) {
655#endif
656 if (!samegeom) ori = TopAbs::Complement(ori);
657#ifdef DEB
658 }
659#endif
660
661
662 Standard_Boolean lesmemes = E.IsEqual(myEdgeReference);
663 if ( !lesmemes ) {
664 Standard_Real parref = par;
665 const TopoDS_Edge& EE = TopoDS::Edge(E);
666 GParamOnReference(VPV,EE,parref);
667#ifdef DEB
668 if(tSPS){
669 cout<<"par "<<par<<" / ";GdumpSHA(E);cout<<" --> parref "<<parref<<" / ";GdumpSHA(EPVS);
670 cout<<endl;
671 }
672#endif
673 par = parref;
674 }
675
676 Standard_Boolean kpbound = Standard_False;
677 {
678 TopoDS_Vertex vclo; Standard_Boolean Eclosed = TopOpeBRepTool_TOOL::ClosedE(myEdgeReference,vclo);
679#ifdef DEB
680// Standard_Integer ivclo = myDataStructure->Shape(vclo);
681#endif
682 TopAbs_Orientation oriI = EPit.Orientation(TopAbs_IN);
683// kpbound = lesmemes && Eclosed && hasVSD && (ori == TopAbs_INTERNAL) && (TB == TopAbs_OUT); -xpu140898
684 // xpu110398 cto 009 L2 : e6ou en v11
685 // xpu140898 USA60111 : e9ou (!=0) + e7ou(=0)
686 Standard_Boolean INTEXT = (oriI == TopAbs_INTERNAL) && (TB == TopAbs_IN);
687 INTEXT = INTEXT || (oriI == TopAbs_EXTERNAL) && (TB == TopAbs_OUT);
688 kpbound = lesmemes && Eclosed && INTEXT;
689 if ( kpbound ) {
690 kpbound = vclo.IsSame(VIG);
691 if (!kpbound) {
692 TopoDS_Shape VSD; Standard_Boolean ok = FUN_ds_getoov(VIG,myDataStructure->DS(),VSD);
693 if (ok) kpbound = vclo.IsSame(VSD);
694 }
695 }
696 }
697
698 if (!kpbound) {
699 VPV.Orientation(ori);
700 Standard_Boolean vofe = Standard_False;
701 Handle(TopOpeBRepBuild_Pave) PV = new TopOpeBRepBuild_Pave(VPV,par,vofe);
702 if (hasVSD) {
703 PV->HasSameDomain(Standard_True);
704 const TopoDS_Shape& VSD = myDataStructure->SameDomain(VPV).Value();
705 Standard_Integer iVSD = myDataStructure->Shape(VSD);
706 if (iVSD == iVRE) PV->SameDomain(VIG);
707 else PV->SameDomain(VSD);
708 }
709 //modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000
710 PV -> InterferenceType() = ST1;
711 PVS.Append(PV);
712
713
714#ifdef DEB
715 gp_Pnt P = BRep_Tool::Pnt(VPV);
716 if(tSPS){cout<<"+";if(ispoint)cout<<" PDS ";else cout<<" VDS ";}
717 if(tSPS){cout<<iG<<" : ";GdumpORIPARPNT(ori,par,P);cout<<endl;}
718 if(tSPS) {
719// Standard_Boolean trc = Standard_False;
720#ifdef DRAW
721 if (trc) {
722 FUN_draw2d(par,TopoDS::Edge(E),myEdgeReference,myFaceReference);
723 FUN_draw(VPV); FUN_draw(E); FUN_draw(myFaceReference);
724 }
725#endif
726 }
727#endif
728 }
729 else {
730 Standard_Real parf,parl; FUN_tool_bounds(myEdgeReference,parf,parl);
731 TopAbs_Orientation ovpv;
732 ovpv = TopAbs_FORWARD;
733 VPV.Orientation(ovpv);
734 Standard_Boolean vfofe = Standard_False;
735 Handle(TopOpeBRepBuild_Pave) PVF = new TopOpeBRepBuild_Pave(VPV,parf,vfofe);
736 if (hasVSD) {
737 PVF->HasSameDomain(Standard_True);
738 const TopoDS_Shape& VSD = myDataStructure->SameDomain(VPV).Value();
739 Standard_Integer iVSD = myDataStructure->Shape(VSD);
740 if (iVSD == iVRE) PVF->SameDomain(VIG);
741 else PVF->SameDomain(VSD);
742 }
743 //modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000
744 PVF -> InterferenceType() = ST1;
745 PVS.Append(PVF);
746
747#ifdef DEB
748 gp_Pnt PF = BRep_Tool::Pnt(VPV);
749 if(tSPS){cout<<"+";if(ispoint)cout<<" PDS ";else cout<<" VDS ";}
750 if(tSPS){cout<<iG<<" : ";GdumpORIPARPNT(ovpv,parf,PF);cout<<endl;}
751#endif
752
753 ovpv = TopAbs_REVERSED;
754 VPV.Orientation(ovpv);
755 Standard_Boolean vrofe = Standard_False;
756 Handle(TopOpeBRepBuild_Pave) PVR = new TopOpeBRepBuild_Pave(VPV,parl,vrofe);
757 if (hasVSD) {
758 PVR->HasSameDomain(Standard_True);
759 const TopoDS_Shape& VSD = myDataStructure->SameDomain(VPV).Value();
760 Standard_Integer iVSD = myDataStructure->Shape(VSD);
761 if (iVSD == iVRE) PVR->SameDomain(VIG);
762 else PVR->SameDomain(VSD);
763 }
764 //modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000
765 PVR -> InterferenceType() = ST1;
766 PVS.Append(PVR);
767#ifdef DEB
768 gp_Pnt PR = BRep_Tool::Pnt(VPV);
769 if(tSPS){cout<<"+";if(ispoint)cout<<" PDS ";else cout<<" VDS ";}
770 if(tSPS){cout<<iG<<" : ";GdumpORIPARPNT(ovpv,parl,PR);cout<<endl;}
771#endif
772
773 PVS.RemovePV(Standard_False); // jyl + 980217
774 }
775
776}
777
778
779//=======================================================================
780//function : GParamOnReference
781//purpose : calcul du parametre de V sur myEdgeReference de myFaceReference
782// V est sur la surface de myFaceReference,
783// V est un vertex de E
784// E est une arete samedomain de myEdgeReference
785// retourne true si ok
786//=======================================================================
787Standard_Boolean TopOpeBRepBuild_Builder::GParamOnReference(const TopoDS_Vertex& V,
788 const TopoDS_Edge& /*E*/,
789 Standard_Real& P) const
790{
791 Handle(Geom_Surface) su = BRep_Tool::Surface(myFaceReference);
792 Handle(Geom_Plane) suplan = Handle(Geom_Plane)::DownCast(su);
793 if ( suplan.IsNull() ) {
794#ifdef DEB
795 cout<<"NYI : GParamOnReference : not planar"<<endl;
796#endif
797 return Standard_False;
798 }
799
800 gp_Pln pln = suplan->Pln(); gp_Pnt p3 = BRep_Tool::Pnt(V);
801 Standard_Real u,v; ElSLib::Parameters(pln,p3,u,v); gp_Pnt2d p2(u,v);
802 Standard_Real f,l,tolpc; Handle(Geom2d_Curve) C2D;
803 C2D = FC2D_CurveOnSurface(myEdgeReference,myFaceReference,f,l,tolpc);
804 if (C2D.IsNull()) Standard_ProgramError::Raise("TopOpeBRepBuild_Builder::GParamOnReference");
805
806// Standard_Real U;
807 Geom2dAdaptor_Curve AC(C2D);
808 switch ( AC.GetType() ) {
809 case GeomAbs_Line:
810 P = ElCLib::Parameter(AC.Line(),p2); break;
811 case GeomAbs_Circle:
812 P = ElCLib::Parameter(AC.Circle(),p2); break;
813 case GeomAbs_Ellipse:
814 P = ElCLib::Parameter(AC.Ellipse(),p2); break;
815 case GeomAbs_Hyperbola:
816 P = ElCLib::Parameter(AC.Hyperbola(),p2); break;
817 case GeomAbs_Parabola:
818 P = ElCLib::Parameter(AC.Parabola(),p2); break;
819 default :
820#ifdef DEB
821 cout<<"NYI : GParamOnReference : OtherCurve on planar surface"<<endl;
822#endif
823 return Standard_False;
824 }
825
826 return Standard_True;
827}