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