1 // Created on: 1993-06-24
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License 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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Precision.hxx>
20 #include <TopExp_Explorer.hxx>
22 #include <TopoDS_Face.hxx>
23 #include <TopoDS_Iterator.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <TopOpeBRep_define.hxx>
26 #include <TopOpeBRep_DSFiller.hxx>
27 #include <TopOpeBRep_EdgesFiller.hxx>
28 #include <TopOpeBRep_FaceEdgeFiller.hxx>
29 #include <TopOpeBRep_FacesFiller.hxx>
30 #include <TopOpeBRep_ShapeIntersector.hxx>
31 #include <TopOpeBRep_ShapeIntersector2d.hxx>
32 #include <TopOpeBRepDS_connex.hxx>
33 #include <TopOpeBRepDS_EXPORT.hxx>
34 #include <TopOpeBRepDS_Filter.hxx>
35 #include <TopOpeBRepDS_GapFiller.hxx>
36 #include <TopOpeBRepDS_HDataStructure.hxx>
37 #include <TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx>
38 #include <TopOpeBRepDS_Reducer.hxx>
39 #include <TopOpeBRepDS_samdom.hxx>
40 #include <TopOpeBRepDS_ShapeWithState.hxx>
41 #include <TopOpeBRepTool_2d.hxx>
42 #include <TopOpeBRepTool_box.hxx>
43 #include <TopOpeBRepTool_EXPORT.hxx>
44 #include <TopOpeBRepTool_SC.hxx>
45 #include <TopTools_IndexedMapOfShape.hxx>
47 extern void BREP_sortonparameter(const Handle(TopOpeBRepDS_HDataStructure)& HDS);
48 extern void BREP_mergePDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS);
52 Standard_EXPORT void debcomplete(){};
53 Standard_EXPORT void debcompleteds(){};
54 static int Vdebfillerds=0;void debfillerds(void){Vdebfillerds++;}
55 static int Vdebfillerff=0;void debfillerff(void){Vdebfillerff++;}
56 static int Vdebfillerffsd=0;void debfillerffsd(void){Vdebfillerffsd++;}
57 static int Vdebfilleree=0;void debfilleree(void){Vdebfilleree++;}
58 static int Vdebfillereesd=0;void debfillereesd(void){Vdebfillereesd++;}
59 static int Vdebfilleref=0;void debfilleref(void){Vdebfilleref++;}
60 static int Vdebfillerfe=0;void debfillerfe(void){Vdebfillerfe++;}
61 void debfillerreset(void){Vdebfillerds=Vdebfillerff=Vdebfilleree=Vdebfilleref=Vdebfillerfe=0;}
62 void debfillerss(const Standard_Integer i1,const Standard_Integer i2){cout<<"+ + + + debfillerss "<<i1<<" "<<i2<<endl;}
64 #include <TopOpeBRepTool_KRO.hxx>
65 Standard_EXPORT TOPKRO KRO_DSFILLER_TOTAL("dsfiller");
66 extern TOPKRO KRO_DSFILLER_INTFF;
67 extern TOPKRO KRO_DSFILLER_INTEE;
68 extern TOPKRO KRO_DSFILLER_INTFE;
69 static void FUN_RESET_KRO_DSFILLER()
71 KRO_DSFILLER_TOTAL.Reset();
72 KRO_DSFILLER_INTFF.Reset();
73 KRO_DSFILLER_INTEE.Reset();
74 KRO_DSFILLER_INTFE.Reset();
77 #include <TopOpeBRep_traceSIFF.hxx>
78 #include <BRepTools.hxx>
79 #include <TopOpeBRepDS_ShapeShapeInterference.hxx>
80 #include <TopOpeBRepDS_CurvePointInterference.hxx>
82 extern TopOpeBRep_traceSIFF SIFF;
84 extern Standard_Boolean TopOpeBRepTool_GettraceKRO();
85 extern Standard_Boolean TopOpeBRep_GettraceSIFF();
86 extern Standard_Boolean TopOpeBRepTool_GettraceEND();
87 extern Standard_Boolean TopOpeBRep_GettraceSHA(const Standard_Integer);
88 extern Standard_Boolean TopOpeBRep_GetcontextNONOG();
91 //=======================================================================
92 //function : TopOpeBRep_DSFiller
94 //=======================================================================
95 TopOpeBRep_DSFiller::TopOpeBRep_DSFiller()
97 myPShapeClassifier(NULL)
101 //modified by NIZNHY-PKV Mon Dec 16 11:12:38 2002 f
102 //=======================================================================
103 //function : ~TopOpeBRep_DSFiller
105 //=======================================================================
106 TopOpeBRep_DSFiller::~TopOpeBRep_DSFiller()
108 if (myPShapeClassifier) {
109 delete myPShapeClassifier;
112 //modified by NIZNHY-PKV Mon Dec 16 11:12:41 2002 t
114 //=======================================================================
115 //function : PShapeClassifier
117 //=======================================================================
118 TopOpeBRepTool_PShapeClassifier TopOpeBRep_DSFiller::PShapeClassifier() const
120 return myPShapeClassifier;
123 //modified by NIZNHY-PKV Mon Dec 16 11:30:43 2002 f
125 //=======================================================================
126 //function : SetPShapeClassifier
128 //=======================================================================
129 void TopOpeBRep_DSFiller::SetPShapeClassifier(const TopOpeBRepTool_PShapeClassifier& PSC)
131 myPShapeClassifier = PSC;
134 //modified by NIZNHY-PKV Mon Dec 16 11:30:52 2002 t
136 //=======================================================================
137 //function : BREP_correctgbound
139 //=======================================================================
140 void BREP_correctgbound(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
142 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
143 Standard_Integer i=1,n=BDS.NbShapes();
145 Standard_Boolean ehassiv = Standard_False;
146 const TopoDS_Shape& s = BDS.Shape(i);
147 TopAbs_ShapeEnum t = s.ShapeType();
148 if ( t != TopAbs_EDGE ) continue;
149 TopOpeBRepDS_ListIteratorOfListOfInterference it;
150 it.Initialize(BDS.ChangeShapeInterferences(s));
151 if ( !it.More() ) continue;
152 for (; it.More(); it.Next()) {
153 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
154 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI =
155 Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
156 if ( SSI.IsNull() ) continue;
157 TopOpeBRepDS_Kind GK = SSI->GeometryType();
158 if ( GK != TopOpeBRepDS_VERTEX ) continue;
160 ehassiv = Standard_True;
164 if (! ehassiv ) continue;
166 // l'arete s a au moins une shapeshapeinterference de geometrie VERTEX.
167 // on verifie l'information GBound de toutes ses shapeshapeinterferences.
168 TopTools_IndexedMapOfShape imev;
169 TopExp::MapShapes(s,TopAbs_VERTEX,imev);
171 it.Initialize(BDS.ChangeShapeInterferences(s));
172 for (; it.More(); it.Next()) {
173 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
174 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
175 if ( SSI.IsNull() ) continue;
176 Standard_Integer GI = SSI->Geometry();
177 TopOpeBRepDS_Kind GK = SSI->GeometryType();
178 if ( GK != TopOpeBRepDS_VERTEX ) continue;
180 const TopoDS_Shape& v = BDS.Shape(GI);
181 Standard_Boolean vofe = imev.Contains(v);
182 SSI->SetGBound(vofe);
185 // l'arete s a au moins une shapeshapeinterference de geometrie VERTEX.
186 it.Initialize(BDS.ChangeShapeInterferences(s));
187 for (; it.More(); it.Next()) {
188 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
189 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
190 if ( SSI.IsNull() ) continue;
191 Standard_Integer GI = SSI->Geometry();
192 TopOpeBRepDS_Kind GK = SSI->GeometryType();
193 if ( GK != TopOpeBRepDS_VERTEX ) continue;
194 const TopoDS_Shape& v = BDS.Shape(GI);
195 Standard_Boolean vhassd = HDS->HasSameDomain(v);
196 if (! vhassd ) continue;
197 Standard_Integer ivref = BDS.SameDomainRef(v);
198 if ( ivref == GI ) continue;
200 const TopoDS_Shape& vref = BDS.Shape(ivref);
201 Standard_Boolean vrefofe = imev.Contains(vref);
202 I->SetGeometry(ivref);
203 SSI->SetGBound(vrefofe);
208 //=======================================================================
209 //function : BREP_UnfillSameDomain
211 //=======================================================================
212 Standard_Boolean BREP_UnfillSameDomain(const TopoDS_Shape& F1,
213 const TopoDS_Shape& F2,
214 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
215 TopOpeBRepTool_ShapeClassifier& SC)
217 Standard_Boolean unfill = Standard_True;
218 TopAbs_State st1=TopAbs_UNKNOWN,st2=TopAbs_UNKNOWN;
219 Standard_Integer samdom = 1;
220 st1 = SC.StateShapeShape(F1,F2,samdom);
221 st2 = SC.StateShapeShape(F2,F1,samdom);
222 if (((st1==TopAbs_OUT) && (st2==TopAbs_OUT)) ||
223 ((st1==TopAbs_UNKNOWN) && (st2==TopAbs_UNKNOWN)) ) {
224 unfill = Standard_True; // NYI IN IN aussi
227 unfill = Standard_False;
230 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
231 BDS.UnfillShapesSameDomain(F1,F2);
235 //=======================================================================
236 //function : FUN_shareNOG
238 //=======================================================================
240 Standard_Boolean FUN_shareNOG(const Handle(TopOpeBRepDS_HDataStructure)& HDS,
241 const TopoDS_Shape& lFF1,
242 const TopoDS_Shape& lFF2)
244 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
245 const TopoDS_Face& F1 = TopoDS::Face(lFF1);
246 const TopoDS_Face& F2 = TopoDS::Face(lFF2);
247 TopTools_IndexedMapOfShape map1; TopExp::MapShapes(F1,TopAbs_EDGE,map1);
248 TopTools_IndexedMapOfShape map2; TopExp::MapShapes(F2,TopAbs_EDGE,map2);
249 Standard_Real tola = Precision::Angular();
251 const TopOpeBRepDS_ListOfInterference& lIF1 = BDS.ShapeInterferences(F1);
252 TopOpeBRepDS_ListIteratorOfListOfInterference it1(lIF1);
253 for (; it1.More(); it1.Next()){
254 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
255 Standard_Integer G = I1->Geometry(); TopOpeBRepDS_Kind GT = I1->GeometryType();
256 if (GT != TopOpeBRepDS_EDGE) continue;
257 const TopoDS_Shape& EG = BDS.Shape(G);
258 if (map2.Contains(EG)) return Standard_False;
260 const TopOpeBRepDS_ListOfInterference& lIF2 = BDS.ShapeInterferences(F2);
261 TopOpeBRepDS_ListIteratorOfListOfInterference it2(lIF2);
262 for (; it2.More(); it2.Next()){
263 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
264 Standard_Integer G = I2->Geometry(); TopOpeBRepDS_Kind GT = I2->GeometryType();
265 if (GT != TopOpeBRepDS_EDGE) continue;
266 const TopoDS_Shape& EG = BDS.Shape(G);
267 if (map1.Contains(EG)) return Standard_False;
271 TopExp_Explorer ex1(F1, TopAbs_EDGE);
272 for (; ex1.More(); ex1.Next()){
273 const TopoDS_Edge& e1 = TopoDS::Edge(ex1.Current());
274 Standard_Boolean hsd1 = HDS->HasSameDomain(e1);
276 TopTools_ListIteratorOfListOfShape itsd1(HDS->SameDomain(e1));
277 for (; itsd1.More(); itsd1.Next()){
278 const TopoDS_Shape& e2 = itsd1.Value();
279 if (map2.Contains(e2)) return Standard_False;
283 const TopOpeBRepDS_ListOfInterference& lie1 = BDS.ShapeInterferences(e1);
284 TopOpeBRepDS_ListIteratorOfListOfInterference iter1(lie1);
285 for (; iter1.More(); iter1.Next()){
286 const Handle(TopOpeBRepDS_Interference)& I1 = iter1.Value();
287 Standard_Integer S1 = I1->Support(); TopOpeBRepDS_Kind ST1 = I1->SupportType();
288 if (ST1 != TopOpeBRepDS_EDGE) continue;
289 const TopoDS_Edge& e2 = TopoDS::Edge(BDS.Shape(S1));
290 if (!map2.Contains(e2)) continue;
292 TopOpeBRepDS_Kind GT1 = I1->GeometryType();
293 if (GT1 == TopOpeBRepDS_POINT) {
294 Handle(TopOpeBRepDS_CurvePointInterference) CPI1 = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I1);
295 Standard_Real par1 = CPI1->Parameter();
296 Standard_Real par2; Standard_Boolean ok = FUN_tool_parE(e1,par1,e2,par2);
299 cout<<"**********TopOpeBRep FUN_shareNOG**********"<<endl;
301 return Standard_False;
303 gp_Vec tge1 = FUN_tool_tggeomE(par1,e1);
304 gp_Vec tge2 = FUN_tool_tggeomE(par2,e2);
305 Standard_Real dot = gp_Dir(tge1).Dot(gp_Dir(tge2));
306 Standard_Real x = Abs(1-Abs(dot));
307 if (x > tola) return Standard_False; // e1,e2 not tangent
309 gp_Vec xxF1 = FUN_tool_getgeomxx(F1,e1,par1);
310 gp_Vec xxF2 = FUN_tool_getgeomxx(F2,e2,par2);
311 dot = gp_Dir(xxF1).Dot(gp_Dir(xxF2));
312 if (dot > 0) return Standard_False; // F1,F2 share geometric domain near G1
316 return Standard_True;
320 //=======================================================================
323 //=======================================================================
324 void TopOpeBRep_DSFiller::Insert(const TopoDS_Shape& aS1,
325 const TopoDS_Shape& aS2,
326 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
327 const Standard_Boolean orientFORWARD)
329 InsertIntersection(aS1,aS2,HDS,orientFORWARD);
332 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Insert"<<endl;
336 //=======================================================================
337 //function : InsertIntersection
339 //=======================================================================
340 void TopOpeBRep_DSFiller::InsertIntersection(const TopoDS_Shape& aS1,
341 const TopoDS_Shape& aS2,
342 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
343 const Standard_Boolean orientFORWARD)
346 FC2D_Prepare(aS1,aS2);
348 if (myPShapeClassifier == NULL) myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
349 myFacesFiller.SetPShapeClassifier(myPShapeClassifier);
352 Standard_Boolean tsiff = TopOpeBRep_GettraceSIFF();
353 Standard_Boolean tkro = TopOpeBRepTool_GettraceKRO();
354 if (tsiff) SIFF.Start("DSFiller debut tsif ",cout);
355 if (tkro) { FUN_RESET_KRO_DSFILLER(); KRO_DSFILLER_TOTAL.Start(); }
358 if ( ! CheckInsert(aS1,aS2) ) {
359 HDS->AddAncestors(aS1); // xpu100798 cto902B4 (f24 as face ancestor of e19)
360 HDS->AddAncestors(aS2); // xpu100798
361 FDSCNX_Prepare(aS1,aS2,HDS);
365 TopoDS_Shape S1 = aS1;
366 TopoDS_Shape S2 = aS2;
367 if ( orientFORWARD ) {
368 if ( S1.Orientation() == TopAbs_REVERSED ) {
369 S1.Orientation(TopAbs_FORWARD);
371 if ( S2.Orientation() == TopAbs_REVERSED ) {
372 S2.Orientation(TopAbs_FORWARD);
376 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
379 TopExp_Explorer ex1,ex2;
380 for (ex1.Init(S1,TopAbs_SOLID); ex1.More(); ex1.Next()) {
381 const TopoDS_Shape& so1 = ex1.Current();
382 for (ex2.Init(S2,TopAbs_SOLID); ex2.More(); ex2.Next()) {
383 const TopoDS_Shape& so2 = ex2.Current();
384 BDS.FillShapesSameDomain(so1,so2);
389 debfillerreset(); // debug
392 Standard_Boolean FFsamdom = Standard_True; // xpu060598
393 Standard_Boolean islFFsamdom = Standard_False;
394 Standard_Boolean isFF = Standard_False;
395 Standard_Boolean isFFsamdom = Standard_False;
396 Standard_Boolean isEE = Standard_False;
397 Standard_Boolean unfill = Standard_False;
398 TopoDS_Shape lFF1, lFF2;
400 // Find all Rejected Faces on the Object and on the Tool
401 /////////////// Rejected Faces' Block
402 TopOpeBRepDS_DataStructure& aDataStructure=HDS->ChangeDS();
404 TopTools_IndexedMapOfShape& aMapOfRejectedShapesObj=
405 aDataStructure.ChangeMapOfRejectedShapesObj();
406 TopTools_IndexedMapOfShape& aMapOfRejectedShapesTool=
407 aDataStructure.ChangeMapOfRejectedShapesTool();
408 aMapOfRejectedShapesObj.Clear();
409 aMapOfRejectedShapesTool.Clear();
411 // 1.Find all Rejected Faces on the Object and on the Tool
412 TopTools_ListOfShape aListObj, aListTool;
414 //modified by NIZHNY-MKK Fri Apr 14 09:35:26 2000.BEGIN
415 TopTools_IndexedMapOfShape aMapOfSolids;
417 TopExp::MapShapes(S2, TopAbs_SOLID, aMapOfSolids);
418 if(!aMapOfSolids.IsEmpty())
419 myShapeIntersector.RejectedFaces (S1, S2, aListObj);
421 aMapOfSolids.Clear();
422 TopExp::MapShapes(S1, TopAbs_SOLID, aMapOfSolids);
423 if(!aMapOfSolids.IsEmpty())
424 myShapeIntersector.RejectedFaces (S2, S1, aListTool);
425 //modified by NIZHNY-MKK Fri Apr 14 09:37:32 2000.END
427 // 2.Insert all rejected faces, wires, edges of Object in DS:
428 TopTools_ListIteratorOfListOfShape anIt(aListObj);
430 for (; anIt.More(); anIt.Next()) {
431 const TopoDS_Shape& aS=anIt.Value();
432 aMapOfRejectedShapesObj.Add(aS);
435 TopTools_ListIteratorOfListOfShape anIt1(aListTool);
436 for (; anIt1.More(); anIt1.Next()) {
437 const TopoDS_Shape& aS=anIt1.Value();
438 aMapOfRejectedShapesTool.Add(aS);
442 myShapeIntersector.InitIntersection(S1,S2);
443 while (myShapeIntersector.MoreIntersection()) {
446 Standard_Integer i1deb = myShapeIntersector.Index(1);
447 Standard_Integer i2deb = myShapeIntersector.Index(2);
448 Standard_Boolean b1deb = TopOpeBRep_GettraceSHA(i1deb);
449 Standard_Boolean b2deb = TopOpeBRep_GettraceSHA(i2deb);
450 if (b1deb && b2deb) debfillerss(i1deb,i2deb);
451 debfillerds(); // debug
454 // The two intersecting GeomShapes gs1,gs2 and their types t1,t2
455 const TopoDS_Shape& gs1 = myShapeIntersector.CurrentGeomShape(1);
456 const TopoDS_Shape& gs2 = myShapeIntersector.CurrentGeomShape(2);
457 TopAbs_ShapeEnum t1 = gs1.ShapeType();
458 TopAbs_ShapeEnum t2 = gs2.ShapeType();
460 // si le couple courant apres un couple facefacesamedomain n'est
461 // pas un couple edgeedge ==> facefacesamedomain est deconnecte
462 isFF = ((t1==TopAbs_FACE) && (t2==TopAbs_FACE));
463 isFFsamdom = Standard_False;
464 isEE = ((t1==TopAbs_EDGE) && (t2==TopAbs_EDGE));
465 unfill = (!isEE && islFFsamdom);
468 if (myPShapeClassifier==NULL) myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
469 unfill = BREP_UnfillSameDomain(lFF1,lFF2,HDS,*myPShapeClassifier);
474 if (tsiff) SIFF.Add(i1deb,i2deb); debfillerff();
476 TopOpeBRep_FacesIntersector& FF=myShapeIntersector.ChangeFacesIntersector();
477 isFFsamdom = FF.SameDomain();
478 FFsamdom = FFsamdom && isFFsamdom; //xpu060598
485 if (isFFsamdom) debfillerffsd(); // debug
486 Standard_Integer exf1 = myShapeIntersector.Index(1);
487 Standard_Integer exf2 = myShapeIntersector.Index(2);
488 myFacesFiller.SetTraceIndex(exf1,exf2);
490 myFacesFiller.Insert(gs1,gs2,FF,HDS);
493 else if ((t1 == TopAbs_EDGE) && (t2 == TopAbs_EDGE)) {
495 debfilleree(); // debug
497 TopOpeBRep_EdgesIntersector& EE =
498 myShapeIntersector.ChangeEdgesIntersector();
501 Standard_Boolean EEsamedomain =
505 if (EEsamedomain) debfillereesd(); // debug
508 myEdgesFiller.Face(1,lFF1);
509 myEdgesFiller.Face(2,lFF2);
511 myEdgesFiller.Insert(gs1,gs2,EE,HDS);
514 else if ((t1 == TopAbs_FACE) && (t2 == TopAbs_EDGE)) {
516 debfillerfe(); // debug
518 TopOpeBRep_FaceEdgeIntersector& FE =
519 myShapeIntersector.ChangeFaceEdgeIntersector();
520 myFaceEdgeFiller.Insert(gs1,gs2,FE,HDS);
523 else if ((t1 == TopAbs_EDGE) && (t2 == TopAbs_FACE)) {
525 debfilleref(); // debug
527 TopOpeBRep_FaceEdgeIntersector& FE =
528 myShapeIntersector.ChangeFaceEdgeIntersector();
529 myFaceEdgeFiller.Insert(gs2,gs1,FE,HDS);
532 islFFsamdom = isFFsamdom;
533 myShapeIntersector.NextIntersection();
535 } // while (MoreIntersection())
537 // FFsamdom = true : rien que des faces tangentes
538 // codage des aretes de section des aretes samedomain
539 if (FFsamdom) FUN_ds_FillSDMFaces(HDS);// xpu060598
540 // xpu280199 : On stocke les edges sdm comme edges de section aussi ! - CTS21801 -
541 else FUN_ds_addSEsdm1d(HDS);
543 if (FFsamdom) HDS->ChangeDS().Isfafa(Standard_True);// xpu120598
545 if (islFFsamdom && !isEE) {
546 if (myPShapeClassifier==NULL) myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
547 unfill = BREP_UnfillSameDomain(lFF1,lFF2,HDS,*myPShapeClassifier);
550 BREP_sortonparameter(HDS);
551 BREP_correctgbound(HDS);
554 HDS->AddAncestors(S1); // xpu100798 cto902B4 (f24 as face ancestor of e19)
555 HDS->AddAncestors(S2); // xpu100798
556 FDSCNX_Prepare(aS1,aS2,HDS);
560 if (tkro) KRO_DSFILLER_TOTAL.Stop();if (tsiff) SIFF.End("DSFiller fin tsif ",cout);
563 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::InsertIntersection"<<endl;
566 } // InsertIntersection
568 //=======================================================================
569 //function : Complete
571 //=======================================================================
572 void TopOpeBRep_DSFiller::Complete(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
581 RemoveUnsharedGeometry(HDS);
584 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Complete"<<endl;
588 //=======================================================================
589 //function : GapFiller
591 //=======================================================================
592 void TopOpeBRep_DSFiller::GapFiller(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
594 TopOpeBRepDS_GapFiller GF(HDS); GF.Perform();
596 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::GapFiller"<<endl;
600 //=======================================================================
601 //function : CompleteDS
603 //=======================================================================
604 void TopOpeBRep_DSFiller::CompleteDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
609 const TopoDS_Shape& S1 = myShapeIntersector.Shape(1);
610 const TopoDS_Shape& S2 = myShapeIntersector.Shape(2);
611 if(S1.IsNull() || S2.IsNull()) return;
612 // HDS->AddAncestors(S1); -xpu100798 (is done before FDSCNX_Prepare)
613 // HDS->AddAncestors(S2); -xpu100798
615 // FUN_ds_unkeepEVIonGb1(HDS,TopAbs_IN); //xpu290698
617 FUN_ds_PointToVertex(HDS); // xpu090698, NYI TopOpeBRepDS_Filler
618 FUN_ds_redusamsha(HDS); // xpu201098
619 FUN_ds_PURGEforE9(HDS); // xpu040998,
620 FUN_ds_completeforSE8(HDS); // xpu020998,
621 FUN_ds_completeforSE1(HDS); // xpu160398,
622 FUN_ds_completeforSE2(HDS); // xpu250398,
623 FUN_ds_completeforSE3(HDS); // xpu170498,
624 FUN_ds_completeforSE4(HDS); // xpu160698,
625 FUN_ds_completeforSE5(HDS); // xpu190698,
626 FUN_ds_completeforSE6(HDS); // xpu280798,
627 // FUN_ds_completeforSE7(HDS); // xpu100898,
628 FUN_ds_completeforE7(HDS); // xpu130898,
629 FUN_ds_completeforSE9(HDS); // xpu011098
630 FUN_ds_complete1dForSESDM(HDS); // MSV 25.03.2002 : OCC251
632 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::CompleteDS"<<endl;
636 //=======================================================================
639 //=======================================================================
640 void TopOpeBRep_DSFiller::Filter(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
642 TopOpeBRepDS_Filter F(HDS);
643 F.ProcessEdgeInterferences();
644 F.ProcessCurveInterferences();
646 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Filter"<<endl;
650 //=======================================================================
653 //=======================================================================
654 void TopOpeBRep_DSFiller::Reducer(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
656 TopOpeBRepDS_Reducer R(HDS);
657 R.ProcessEdgeInterferences();
659 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Reducer"<<endl;
663 //=======================================================================
664 //function : RemoveUnsharedGeometry
666 //=======================================================================
667 void TopOpeBRep_DSFiller::RemoveUnsharedGeometry(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
669 Standard_Boolean processNOG = Standard_True;
671 if (TopOpeBRep_GetcontextNONOG()) processNOG = Standard_False;
673 if (!processNOG) return;
675 // xpu290998 : PRO15369 (f5,f20 only share geometric point (vertex))
676 // end processing for all information on shapes is given.
677 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
678 Standard_Integer nbs = BDS.NbShapes();
679 for (Standard_Integer i = 1; i <= nbs; i++) {
680 TopoDS_Shape S = BDS.Shape(i);
681 if (S.ShapeType() != TopAbs_FACE) continue;
682 Standard_Boolean hsd = HDS->HasSameDomain(S);
684 Standard_Integer rkS = BDS.AncestorRank(S);
685 if (rkS != 1) continue;
686 const TopTools_ListOfShape& lSsd = BDS.ShapeSameDomain(S);
687 TopTools_ListIteratorOfListOfShape itsd(lSsd);
688 for (; itsd.More(); itsd.Next()){
689 TopoDS_Shape Ssd = itsd.Value(); //xpuxpu
690 Standard_Integer rkSsd = BDS.AncestorRank(Ssd);
691 if (rkSsd == 1) continue;
693 Standard_Boolean unfill = ::FUN_shareNOG(HDS,S,Ssd);
694 unfill = unfill && FUN_ds_sdm(BDS,S,Ssd) && FUN_ds_sdm(BDS,Ssd,S);
696 if (myPShapeClassifier==NULL) myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
697 unfill = BREP_UnfillSameDomain(S,Ssd,HDS,*myPShapeClassifier);
702 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::RemoveUnsharedGeometry"<<endl;
704 } // RemoveUnsharedGeometry
706 //=======================================================================
709 //=======================================================================
710 void TopOpeBRep_DSFiller::Checker(const Handle(TopOpeBRepDS_HDataStructure)& /*HDS*/) const
712 // TopOpeBRepDS_Checker C(HDS); // NYI
714 // if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Checker"<<endl;
718 //=======================================================================
719 //function : Insert2d
721 //=======================================================================
723 void TopOpeBRep_DSFiller::Insert2d
724 (const TopoDS_Shape& aS1,const TopoDS_Shape& aS2,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
726 InsertIntersection2d(aS1,aS2,HDS);
729 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Insert2d"<<endl;
733 //=======================================================================
734 //function : InsertIntersection2d
736 //=======================================================================
738 void TopOpeBRep_DSFiller::InsertIntersection2d
739 (const TopoDS_Shape& aS1,const TopoDS_Shape& aS2,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
741 if (myPShapeClassifier == NULL) {
742 myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
744 myFacesFiller.SetPShapeClassifier(myPShapeClassifier);
746 if ( ! ClearShapeSameDomain(aS1, aS2, HDS) ) return;
748 TopoDS_Shape S1 = aS1;
749 TopoDS_Shape S2 = aS2;
750 TopOpeBRepDS_DataStructure& BDS1 = HDS->ChangeDS();
754 TopoDS_Shape lFF1, lFF2;
755 Standard_Boolean isFFsamdom = Standard_False;
757 myShapeIntersector2d.InitIntersection(S1,S2);
758 while (myShapeIntersector2d.MoreIntersection()) {
760 // The two intersecting GeomShapes gs1,gs2 and their types t1,t2
761 const TopoDS_Shape& gs1 = myShapeIntersector2d.CurrentGeomShape(1);
762 const TopoDS_Shape& gs2 = myShapeIntersector2d.CurrentGeomShape(2);
763 TopAbs_ShapeEnum t1 = gs1.ShapeType();
764 TopAbs_ShapeEnum t2 = gs2.ShapeType();
766 // si le couple courant apres un couple facefacesamedomain n'est
767 // pas un couple edgeedge ==> facefacesamedomain est deconnecte
768 Standard_Boolean isFF = ((t1==TopAbs_FACE) && (t2==TopAbs_FACE));
769 Standard_Boolean isEE = ((t1==TopAbs_EDGE) && (t2==TopAbs_EDGE));
770 Standard_Boolean unfill = (!isEE && isFFsamdom);
772 if (myPShapeClassifier==NULL)
773 myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
774 // NYI : mettre en champs un ShapeClassifier commun a tous
776 TopAbs_State st1=TopAbs_UNKNOWN,st2=TopAbs_UNKNOWN;
777 Standard_Integer samdom = 1;
778 st1 = myPShapeClassifier->StateShapeShape(lFF1,lFF2,samdom);
779 st2 = myPShapeClassifier->StateShapeShape(lFF2,lFF1,samdom);
780 if ( ((st1 == TopAbs_OUT) && (st2 == TopAbs_OUT)) ||
781 ((st1 == TopAbs_UNKNOWN) && (st2 == TopAbs_UNKNOWN)) ) {
782 unfill = Standard_True; // NYI IN IN aussi
785 unfill = Standard_False;
788 TopOpeBRepDS_DataStructure& BDS2 = HDS->ChangeDS();
789 if(!lFF1.IsNull() && !lFF2.IsNull())
790 BDS2.UnfillShapesSameDomain(lFF1,lFF2);
795 isFFsamdom = Standard_True;
796 myShapeIntersector2d.ChangeEdgesIntersector().SetFaces(gs1,gs2);
797 lFF1 = gs1; lFF2 = gs2;
798 BDS1.FillShapesSameDomain(gs1,gs2);
800 else if ((t1 == TopAbs_EDGE) && (t2 == TopAbs_EDGE)) {
801 TopOpeBRep_EdgesIntersector& EE = myShapeIntersector2d.ChangeEdgesIntersector();
803 myEdgesFiller.Face(1,lFF1);
804 myEdgesFiller.Face(2,lFF2);
805 myEdgesFiller.Insert(gs1,gs2,EE,HDS);
807 myShapeIntersector2d.NextIntersection();
808 } // while (MoreIntersection())
810 BREP_sortonparameter(HDS);
811 BREP_correctgbound(HDS);
815 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::InsertIntersection2d"<<endl;
818 } // InsertIntersection2d
821 //=======================================================================
822 //function : CompleteDS2d
824 //=======================================================================
826 void TopOpeBRep_DSFiller::CompleteDS2d(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
828 const TopoDS_Shape& S1 = myShapeIntersector2d.Shape(1);
829 const TopoDS_Shape& S2 = myShapeIntersector2d.Shape(2);
830 if(S1.IsNull() || S2.IsNull()) return;
831 HDS->AddAncestors(S1);
832 HDS->AddAncestors(S2);
834 TopOpeBRepDS_Filter F(HDS);
835 F.ProcessEdgeInterferences();
836 F.ProcessCurveInterferences();
837 TopOpeBRepDS_Reducer R(HDS);
838 R.ProcessEdgeInterferences();
839 // TopOpeBRepDS_Checker C(HDS); // NYI
841 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::CompleteDS2d"<<endl;
845 //=======================================================================
846 //function : IsMadeOf1d
848 //=======================================================================
850 Standard_Boolean TopOpeBRep_DSFiller::IsMadeOf1d(const TopoDS_Shape& aS) const
852 // vrai si il existe > 1 WIRE et/ou > 1 EDGE sans ascendance de face
853 Standard_Boolean res = Standard_False;
854 TopAbs_ShapeEnum t = aS.ShapeType();
855 if ( t == TopAbs_WIRE ) {
858 else if ( t == TopAbs_EDGE ) {
861 else if ( t == TopAbs_COMPOUND ) {
862 TopoDS_Iterator it(aS);
864 res = Standard_False;
868 for (; it.More(); it.Next()) {
869 const TopoDS_Shape& S = it.Value();
870 Standard_Boolean is1d = IsMadeOf1d(S);
872 res = Standard_False;
878 else { // != COMPOUND,WIRE,EDGE
879 res = Standard_False;
885 //=======================================================================
886 //function : IsContext1d
888 //=======================================================================
890 Standard_Boolean TopOpeBRep_DSFiller::IsContext1d(const TopoDS_Shape& aS) const
892 Standard_Boolean is1d = IsMadeOf1d(aS);
894 if ( is1d ) cout<<"TopOpeBRep_DSFiller : 1d"<<endl;
896 if ( !is1d ) return Standard_False;
897 return Standard_True;
900 //=======================================================================
901 //function : Insert1d
903 //=======================================================================
905 void TopOpeBRep_DSFiller::Insert1d
906 (const TopoDS_Shape& aS1,const TopoDS_Shape& aS2,const TopoDS_Face& aF1,const TopoDS_Face& aF2,
907 const Handle(TopOpeBRepDS_HDataStructure)& HDS,const Standard_Boolean orientFORWARD)
909 if ( ! CheckInsert(aS1,aS2) ) return;
911 TopoDS_Shape S1 = aS1;
912 TopoDS_Shape S2 = aS2;
913 if ( orientFORWARD ) {
914 if ( S1.Orientation() == TopAbs_REVERSED ) S1.Orientation(TopAbs_FORWARD);
915 if ( S2.Orientation() == TopAbs_REVERSED ) S2.Orientation(TopAbs_FORWARD);
917 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
922 myShapeIntersector.InitIntersection(S1,S2,aF1,aF2);
923 for (;myShapeIntersector.MoreIntersection(); myShapeIntersector.NextIntersection()) {
925 // The two intersecting GeomShapes gs1,gs2 and their types t1,t2
926 const TopoDS_Shape& gs1 = myShapeIntersector.CurrentGeomShape(1);
927 const TopoDS_Shape& gs2 = myShapeIntersector.CurrentGeomShape(2);
928 TopAbs_ShapeEnum t1 = gs1.ShapeType(), t2 = gs2.ShapeType();
930 if ((t1 == TopAbs_EDGE) && (t2 == TopAbs_EDGE)) {
931 TopOpeBRep_EdgesIntersector& EE =
932 myShapeIntersector.ChangeEdgesIntersector();
934 myEdgesFiller.Insert(gs1,gs2,EE,HDS);
943 //=======================================================================
944 //function : CheckInsert
946 //=======================================================================
948 Standard_Boolean TopOpeBRep_DSFiller::CheckInsert(const TopoDS_Shape& aS1,const TopoDS_Shape& aS2) const
950 if (aS1.IsEqual(aS2)) {
952 cout<<"TopOpeBRep_DSFiller : CheckInsert : S1 == S2"<<endl;
954 return Standard_False;
956 return Standard_True;
959 //=======================================================================
960 //function : ClearShapeSameDomain
962 //=======================================================================
964 Standard_Boolean TopOpeBRep_DSFiller::ClearShapeSameDomain
965 (const TopoDS_Shape& aS1,const TopoDS_Shape& aS2,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
967 TopOpeBRepDS_DataStructure& DS = HDS->ChangeDS();
968 const Standard_Boolean b = Standard_False;
969 if(!CheckInsert(aS1,aS2))
971 TopExp_Explorer exp1(aS1, TopAbs_FACE), exp2(aS2, TopAbs_FACE);
972 for(; exp1.More(); exp1.Next()) {
973 const TopoDS_Shape& Shape1 = exp1.Current();
974 if(!HDS->HasShape(Shape1))
975 if(HDS->HasSameDomain(Shape1)) {
976 TopTools_ListOfShape& los =
977 DS.ChangeShapeSameDomain(Shape1);
981 for(; exp2.More(); exp2.Next()) {
982 const TopoDS_Shape& Shape2 = exp2.Current();
983 if(HDS->HasShape(Shape2))
984 if(HDS->HasSameDomain(Shape2)) {
985 TopTools_ListOfShape& los =
986 DS.ChangeShapeSameDomain(Shape2);
990 return Standard_True;
994 //=======================================================================
995 //function : ChangeShapeIntersector
997 //=======================================================================
999 TopOpeBRep_ShapeIntersector& TopOpeBRep_DSFiller::ChangeShapeIntersector()
1000 { return myShapeIntersector; }
1002 //=======================================================================
1003 //function : ChangeShapeIntersector2d
1005 //=======================================================================
1007 TopOpeBRep_ShapeIntersector2d& TopOpeBRep_DSFiller::ChangeShapeIntersector2d()
1008 { return myShapeIntersector2d; }
1011 //=======================================================================
1012 //function : ChangeFacesFiller
1014 //=======================================================================
1016 TopOpeBRep_FacesFiller& TopOpeBRep_DSFiller::ChangeFacesFiller()
1017 { return myFacesFiller; }
1020 //=======================================================================
1021 //function : ChangeEdgesFiller
1023 //=======================================================================
1025 TopOpeBRep_EdgesFiller& TopOpeBRep_DSFiller::ChangeEdgesFiller()
1026 { return myEdgesFiller; }
1029 //=======================================================================
1030 //function : ChangeFaceEdgeFiller
1032 //=======================================================================
1034 TopOpeBRep_FaceEdgeFiller& TopOpeBRep_DSFiller::ChangeFaceEdgeFiller()
1035 { return myFaceEdgeFiller; }