1 // File: TopOpeBRep_DSFiller.cxx
2 // Created: Thu Jun 24 11:15:21 1993
3 // Author: Jean Yves LEBEY
6 #include <TopOpeBRep_DSFiller.ixx>
8 #include <TopExp_Explorer.hxx>
9 #include <TopoDS_Iterator.hxx>
12 #include <TopOpeBRepDS_GapFiller.hxx>
13 #include <TopOpeBRepDS_Filter.hxx>
14 #include <TopOpeBRepDS_Reducer.hxx>
15 #include <TopOpeBRepDS_connex.hxx>
16 #include <TopOpeBRepDS_samdom.hxx>
17 #include <TopOpeBRepDS_EXPORT.hxx>
18 #include <TopOpeBRepTool_2d.hxx>
19 #include <TopOpeBRepTool_box.hxx>
20 #include <TopOpeBRepTool_SC.hxx>
21 #include <TopOpeBRepTool_EXPORT.hxx>
22 #include <Precision.hxx>
24 #include <TopOpeBRep_define.hxx>
26 #include <TopOpeBRepDS_IndexedDataMapOfShapeWithState.hxx>
27 #include <TopOpeBRepDS_ShapeWithState.hxx>
28 #include <TopTools_IndexedMapOfShape.hxx>
30 Standard_IMPORT void BREP_sortonparameter(const Handle(TopOpeBRepDS_HDataStructure)& HDS);
31 Standard_IMPORT void BREP_mergePDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS);
35 Standard_EXPORT void debcomplete(){};
36 Standard_EXPORT void debcompleteds(){};
37 static int Vdebfillerds=0;void debfillerds(void){Vdebfillerds++;}
38 static int Vdebfillerff=0;void debfillerff(void){Vdebfillerff++;}
39 static int Vdebfillerffsd=0;void debfillerffsd(void){Vdebfillerffsd++;}
40 static int Vdebfilleree=0;void debfilleree(void){Vdebfilleree++;}
41 static int Vdebfillereesd=0;void debfillereesd(void){Vdebfillereesd++;}
42 static int Vdebfilleref=0;void debfilleref(void){Vdebfilleref++;}
43 static int Vdebfillerfe=0;void debfillerfe(void){Vdebfillerfe++;}
44 void debfillerreset(void){Vdebfillerds=Vdebfillerff=Vdebfilleree=Vdebfilleref=Vdebfillerfe=0;}
45 void debfillerss(const Standard_Integer i1,const Standard_Integer i2){cout<<"+ + + + debfillerss "<<i1<<" "<<i2<<endl;}
47 #include <TopOpeBRepTool_KRO.hxx>
48 Standard_EXPORT TOPKRO KRO_DSFILLER_TOTAL("dsfiller");
49 Standard_IMPORT TOPKRO KRO_DSFILLER_INTFF;
50 Standard_IMPORT TOPKRO KRO_DSFILLER_INTEE;
51 Standard_IMPORT TOPKRO KRO_DSFILLER_INTFE;
52 static void FUN_RESET_KRO_DSFILLER()
54 KRO_DSFILLER_TOTAL.Reset();
55 KRO_DSFILLER_INTFF.Reset();
56 KRO_DSFILLER_INTEE.Reset();
57 KRO_DSFILLER_INTFE.Reset();
60 #include <TopOpeBRep_traceSIFF.hxx>
61 #include <BRepTools.hxx>
63 Standard_IMPORT TopOpeBRep_traceSIFF SIFF;
65 Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceKRO();
66 Standard_IMPORT Standard_Boolean TopOpeBRep_GettraceSIFF();
67 Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceEND();
68 Standard_IMPORT Standard_Boolean TopOpeBRep_GettraceSHA(const Standard_Integer);
69 Standard_IMPORT Standard_Boolean TopOpeBRep_GetcontextNONOG();
72 //=======================================================================
73 //function : TopOpeBRep_DSFiller
75 //=======================================================================
76 TopOpeBRep_DSFiller::TopOpeBRep_DSFiller()
78 myPShapeClassifier(NULL)
82 //modified by NIZNHY-PKV Mon Dec 16 11:12:38 2002 f
83 //=======================================================================
85 //purpose : alias ~TopOpeBRep_DSFiller
86 //=======================================================================
87 void TopOpeBRep_DSFiller::Destroy()
89 if (myPShapeClassifier) {
90 delete myPShapeClassifier;
93 //modified by NIZNHY-PKV Mon Dec 16 11:12:41 2002 t
95 //=======================================================================
96 //function : PShapeClassifier
98 //=======================================================================
99 TopOpeBRepTool_PShapeClassifier TopOpeBRep_DSFiller::PShapeClassifier() const
101 return myPShapeClassifier;
104 //modified by NIZNHY-PKV Mon Dec 16 11:30:43 2002 f
106 //=======================================================================
107 //function : SetPShapeClassifier
109 //=======================================================================
110 void TopOpeBRep_DSFiller::SetPShapeClassifier(const TopOpeBRepTool_PShapeClassifier& PSC)
112 myPShapeClassifier = PSC;
115 //modified by NIZNHY-PKV Mon Dec 16 11:30:52 2002 t
117 //=======================================================================
118 //function : BREP_correctgbound
120 //=======================================================================
121 void BREP_correctgbound(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
123 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
124 Standard_Integer i=1,n=BDS.NbShapes();
126 Standard_Boolean ehassiv = Standard_False;
127 const TopoDS_Shape& s = BDS.Shape(i);
128 TopAbs_ShapeEnum t = s.ShapeType();
129 if ( t != TopAbs_EDGE ) continue;
130 TopOpeBRepDS_ListIteratorOfListOfInterference it;
131 it.Initialize(BDS.ChangeShapeInterferences(s));
132 if ( !it.More() ) continue;
133 for (; it.More(); it.Next()) {
134 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
135 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI =
136 Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
137 if ( SSI.IsNull() ) continue;
138 TopOpeBRepDS_Kind GK = SSI->GeometryType();
139 if ( GK != TopOpeBRepDS_VERTEX ) continue;
141 ehassiv = Standard_True;
145 if (! ehassiv ) continue;
147 // l'arete s a au moins une shapeshapeinterference de geometrie VERTEX.
148 // on verifie l'information GBound de toutes ses shapeshapeinterferences.
149 TopTools_IndexedMapOfShape imev;
150 TopExp::MapShapes(s,TopAbs_VERTEX,imev);
152 it.Initialize(BDS.ChangeShapeInterferences(s));
153 for (; it.More(); it.Next()) {
154 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
155 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
156 if ( SSI.IsNull() ) continue;
157 Standard_Integer GI = SSI->Geometry();
158 TopOpeBRepDS_Kind GK = SSI->GeometryType();
159 if ( GK != TopOpeBRepDS_VERTEX ) continue;
161 const TopoDS_Shape& v = BDS.Shape(GI);
162 Standard_Boolean vofe = imev.Contains(v);
163 SSI->SetGBound(vofe);
166 // l'arete s a au moins une shapeshapeinterference de geometrie VERTEX.
167 it.Initialize(BDS.ChangeShapeInterferences(s));
168 for (; it.More(); it.Next()) {
169 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
170 Handle(TopOpeBRepDS_ShapeShapeInterference) SSI = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
171 if ( SSI.IsNull() ) continue;
172 Standard_Integer GI = SSI->Geometry();
173 TopOpeBRepDS_Kind GK = SSI->GeometryType();
174 if ( GK != TopOpeBRepDS_VERTEX ) continue;
175 const TopoDS_Shape& v = BDS.Shape(GI);
176 Standard_Boolean vhassd = HDS->HasSameDomain(v);
177 if (! vhassd ) continue;
178 Standard_Integer ivref = BDS.SameDomainRef(v);
179 if ( ivref == GI ) continue;
181 const TopoDS_Shape& vref = BDS.Shape(ivref);
182 Standard_Boolean vrefofe = imev.Contains(vref);
183 I->SetGeometry(ivref);
184 SSI->SetGBound(vrefofe);
189 //=======================================================================
190 //function : BREP_UnfillSameDomain
192 //=======================================================================
193 Standard_Boolean BREP_UnfillSameDomain(const TopoDS_Shape& F1,
194 const TopoDS_Shape& F2,
195 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
196 TopOpeBRepTool_ShapeClassifier& SC)
198 Standard_Boolean unfill = Standard_True;
199 TopAbs_State st1=TopAbs_UNKNOWN,st2=TopAbs_UNKNOWN;
200 Standard_Integer samdom = 1;
201 st1 = SC.StateShapeShape(F1,F2,samdom);
202 st2 = SC.StateShapeShape(F2,F1,samdom);
203 if (((st1==TopAbs_OUT) && (st2==TopAbs_OUT)) ||
204 ((st1==TopAbs_UNKNOWN) && (st2==TopAbs_UNKNOWN)) ) {
205 unfill = Standard_True; // NYI IN IN aussi
208 unfill = Standard_False;
211 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
212 BDS.UnfillShapesSameDomain(F1,F2);
216 //=======================================================================
217 //function : FUN_shareNOG
219 //=======================================================================
221 Standard_Boolean FUN_shareNOG(const Handle(TopOpeBRepDS_HDataStructure)& HDS,
222 const TopoDS_Shape& lFF1,
223 const TopoDS_Shape& lFF2)
225 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
226 const TopoDS_Face& F1 = TopoDS::Face(lFF1);
227 const TopoDS_Face& F2 = TopoDS::Face(lFF2);
228 TopTools_IndexedMapOfShape map1; TopExp::MapShapes(F1,TopAbs_EDGE,map1);
229 TopTools_IndexedMapOfShape map2; TopExp::MapShapes(F2,TopAbs_EDGE,map2);
230 Standard_Real tola = Precision::Angular();
232 const TopOpeBRepDS_ListOfInterference& lIF1 = BDS.ShapeInterferences(F1);
233 TopOpeBRepDS_ListIteratorOfListOfInterference it1(lIF1);
234 for (; it1.More(); it1.Next()){
235 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
236 Standard_Integer G = I1->Geometry(); TopOpeBRepDS_Kind GT = I1->GeometryType();
237 if (GT != TopOpeBRepDS_EDGE) continue;
238 const TopoDS_Shape& EG = BDS.Shape(G);
239 if (map2.Contains(EG)) return Standard_False;
241 const TopOpeBRepDS_ListOfInterference& lIF2 = BDS.ShapeInterferences(F2);
242 TopOpeBRepDS_ListIteratorOfListOfInterference it2(lIF2);
243 for (; it2.More(); it2.Next()){
244 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
245 Standard_Integer G = I2->Geometry(); TopOpeBRepDS_Kind GT = I2->GeometryType();
246 if (GT != TopOpeBRepDS_EDGE) continue;
247 const TopoDS_Shape& EG = BDS.Shape(G);
248 if (map1.Contains(EG)) return Standard_False;
252 TopExp_Explorer ex1(F1, TopAbs_EDGE);
253 for (; ex1.More(); ex1.Next()){
254 const TopoDS_Edge& e1 = TopoDS::Edge(ex1.Current());
255 Standard_Boolean hsd1 = HDS->HasSameDomain(e1);
257 TopTools_ListIteratorOfListOfShape itsd1(HDS->SameDomain(e1));
258 for (; itsd1.More(); itsd1.Next()){
259 const TopoDS_Shape& e2 = itsd1.Value();
260 if (map2.Contains(e2)) return Standard_False;
264 const TopOpeBRepDS_ListOfInterference& lie1 = BDS.ShapeInterferences(e1);
265 TopOpeBRepDS_ListIteratorOfListOfInterference it1(lie1);
266 for (; it1.More(); it1.Next()){
267 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
268 Standard_Integer S1 = I1->Support(); TopOpeBRepDS_Kind ST1 = I1->SupportType();
269 if (ST1 != TopOpeBRepDS_EDGE) continue;
270 const TopoDS_Edge& e2 = TopoDS::Edge(BDS.Shape(S1));
271 if (!map2.Contains(e2)) continue;
273 TopOpeBRepDS_Kind GT1 = I1->GeometryType();
274 if (GT1 == TopOpeBRepDS_POINT) {
275 Handle(TopOpeBRepDS_CurvePointInterference) CPI1 = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I1);
276 Standard_Real par1 = CPI1->Parameter();
277 Standard_Real par2; Standard_Boolean ok = FUN_tool_parE(e1,par1,e2,par2);
280 cout<<"**********TopOpeBRep FUN_shareNOG**********"<<endl;
282 return Standard_False;
284 gp_Vec tge1 = FUN_tool_tggeomE(par1,e1);
285 gp_Vec tge2 = FUN_tool_tggeomE(par2,e2);
286 Standard_Real dot = gp_Dir(tge1).Dot(gp_Dir(tge2));
287 Standard_Real x = Abs(1-Abs(dot));
288 if (x > tola) return Standard_False; // e1,e2 not tangent
290 gp_Vec xxF1 = FUN_tool_getgeomxx(F1,e1,par1);
291 gp_Vec xxF2 = FUN_tool_getgeomxx(F2,e2,par2);
292 dot = gp_Dir(xxF1).Dot(gp_Dir(xxF2));
293 if (dot > 0) return Standard_False; // F1,F2 share geometric domain near G1
297 return Standard_True;
301 Standard_IMPORT TopoDS_Shape GLOBALDS_shape1;
302 Standard_IMPORT TopoDS_Shape GLOBALDS_shape2;
304 //=======================================================================
307 //=======================================================================
308 void TopOpeBRep_DSFiller::Insert(const TopoDS_Shape& aS1,
309 const TopoDS_Shape& aS2,
310 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
311 const Standard_Boolean orientFORWARD)
313 InsertIntersection(aS1,aS2,HDS,orientFORWARD);
316 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Insert"<<endl;
320 //=======================================================================
321 //function : InsertIntersection
323 //=======================================================================
324 void TopOpeBRep_DSFiller::InsertIntersection(const TopoDS_Shape& aS1,
325 const TopoDS_Shape& aS2,
326 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
327 const Standard_Boolean orientFORWARD)
330 FC2D_Prepare(aS1,aS2);
332 GLOBALDS_shape1 = aS1;
333 GLOBALDS_shape2 = aS2;
335 if (myPShapeClassifier == NULL) myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
336 myFacesFiller.SetPShapeClassifier(myPShapeClassifier);
339 Standard_Boolean tsiff = TopOpeBRep_GettraceSIFF();
340 Standard_Boolean tkro = TopOpeBRepTool_GettraceKRO();
341 if (tsiff) SIFF.Start("DSFiller debut tsif ",cout);
342 if (tkro) { FUN_RESET_KRO_DSFILLER(); KRO_DSFILLER_TOTAL.Start(); }
345 if ( ! CheckInsert(aS1,aS2) ) {
346 HDS->AddAncestors(aS1); // xpu100798 cto902B4 (f24 as face ancestor of e19)
347 HDS->AddAncestors(aS2); // xpu100798
348 FDSCNX_Prepare(aS1,aS2,HDS);
352 TopoDS_Shape S1 = aS1;
353 TopoDS_Shape S2 = aS2;
354 if ( orientFORWARD ) {
355 if ( S1.Orientation() == TopAbs_REVERSED ) {
356 S1.Orientation(TopAbs_FORWARD);
358 if ( S2.Orientation() == TopAbs_REVERSED ) {
359 S2.Orientation(TopAbs_FORWARD);
363 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
366 TopExp_Explorer ex1,ex2;
367 for (ex1.Init(S1,TopAbs_SOLID); ex1.More(); ex1.Next()) {
368 const TopoDS_Shape& so1 = ex1.Current();
369 for (ex2.Init(S2,TopAbs_SOLID); ex2.More(); ex2.Next()) {
370 const TopoDS_Shape& so2 = ex2.Current();
371 BDS.FillShapesSameDomain(so1,so2);
376 debfillerreset(); // debug
379 Standard_Boolean FFsamdom = Standard_True; // xpu060598
380 Standard_Boolean islFFsamdom = Standard_False;
381 Standard_Boolean isFF = Standard_False;
382 Standard_Boolean isFFsamdom = Standard_False;
383 Standard_Boolean isEE = Standard_False;
384 Standard_Boolean unfill = Standard_False;
385 TopoDS_Shape lFF1, lFF2;
387 // Find all Rejected Faces on the Object and on the Tool
388 /////////////// Rejected Faces' Block
389 TopOpeBRepDS_DataStructure& aDataStructure=HDS->ChangeDS();
391 TopTools_IndexedMapOfShape& aMapOfRejectedShapesObj=
392 aDataStructure.ChangeMapOfRejectedShapesObj();
393 TopTools_IndexedMapOfShape& aMapOfRejectedShapesTool=
394 aDataStructure.ChangeMapOfRejectedShapesTool();
395 aMapOfRejectedShapesObj.Clear();
396 aMapOfRejectedShapesTool.Clear();
398 // 1.Find all Rejected Faces on the Object and on the Tool
399 TopTools_ListOfShape aListObj, aListTool;
401 //modified by NIZHNY-MKK Fri Apr 14 09:35:26 2000.BEGIN
402 TopTools_IndexedMapOfShape aMapOfSolids;
404 TopExp::MapShapes(S2, TopAbs_SOLID, aMapOfSolids);
405 if(!aMapOfSolids.IsEmpty())
406 myShapeIntersector.RejectedFaces (S1, S2, aListObj);
408 aMapOfSolids.Clear();
409 TopExp::MapShapes(S1, TopAbs_SOLID, aMapOfSolids);
410 if(!aMapOfSolids.IsEmpty())
411 myShapeIntersector.RejectedFaces (S2, S1, aListTool);
412 //modified by NIZHNY-MKK Fri Apr 14 09:37:32 2000.END
414 // 2.Insert all rejected faces, wires, edges of Object in DS:
415 TopTools_ListIteratorOfListOfShape anIt(aListObj);
417 for (; anIt.More(); anIt.Next()) {
418 const TopoDS_Shape& aS=anIt.Value();
419 aMapOfRejectedShapesObj.Add(aS);
422 TopTools_ListIteratorOfListOfShape anIt1(aListTool);
423 for (; anIt1.More(); anIt1.Next()) {
424 const TopoDS_Shape& aS=anIt1.Value();
425 aMapOfRejectedShapesTool.Add(aS);
429 myShapeIntersector.InitIntersection(S1,S2);
430 while (myShapeIntersector.MoreIntersection()) {
433 Standard_Integer i1deb = myShapeIntersector.Index(1);
434 Standard_Integer i2deb = myShapeIntersector.Index(2);
435 Standard_Boolean b1deb = TopOpeBRep_GettraceSHA(i1deb);
436 Standard_Boolean b2deb = TopOpeBRep_GettraceSHA(i2deb);
437 if (b1deb && b2deb) debfillerss(i1deb,i2deb);
438 debfillerds(); // debug
441 // The two intersecting GeomShapes gs1,gs2 and their types t1,t2
442 const TopoDS_Shape& gs1 = myShapeIntersector.CurrentGeomShape(1);
443 const TopoDS_Shape& gs2 = myShapeIntersector.CurrentGeomShape(2);
444 TopAbs_ShapeEnum t1 = gs1.ShapeType();
445 TopAbs_ShapeEnum t2 = gs2.ShapeType();
447 // si le couple courant apres un couple facefacesamedomain n'est
448 // pas un couple edgeedge ==> facefacesamedomain est deconnecte
449 isFF = ((t1==TopAbs_FACE) && (t2==TopAbs_FACE));
450 isFFsamdom = Standard_False;
451 isEE = ((t1==TopAbs_EDGE) && (t2==TopAbs_EDGE));
452 unfill = (!isEE && islFFsamdom);
455 if (myPShapeClassifier==NULL) myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
456 unfill = BREP_UnfillSameDomain(lFF1,lFF2,HDS,*myPShapeClassifier);
461 if (tsiff) SIFF.Add(i1deb,i2deb); debfillerff();
463 TopOpeBRep_FacesIntersector& FF=myShapeIntersector.ChangeFacesIntersector();
464 isFFsamdom = FF.SameDomain();
465 FFsamdom = FFsamdom && isFFsamdom; //xpu060598
472 if (isFFsamdom) debfillerffsd(); // debug
473 Standard_Integer exf1 = myShapeIntersector.Index(1);
474 Standard_Integer exf2 = myShapeIntersector.Index(2);
475 myFacesFiller.SetTraceIndex(exf1,exf2);
477 myFacesFiller.Insert(gs1,gs2,FF,HDS);
480 else if ((t1 == TopAbs_EDGE) && (t2 == TopAbs_EDGE)) {
482 debfilleree(); // debug
484 TopOpeBRep_EdgesIntersector& EE =
485 myShapeIntersector.ChangeEdgesIntersector();
488 Standard_Boolean EEsamedomain =
492 if (EEsamedomain) debfillereesd(); // debug
495 myEdgesFiller.Face(1,lFF1);
496 myEdgesFiller.Face(2,lFF2);
498 myEdgesFiller.Insert(gs1,gs2,EE,HDS);
501 else if ((t1 == TopAbs_FACE) && (t2 == TopAbs_EDGE)) {
503 debfillerfe(); // debug
505 TopOpeBRep_FaceEdgeIntersector& FE =
506 myShapeIntersector.ChangeFaceEdgeIntersector();
507 myFaceEdgeFiller.Insert(gs1,gs2,FE,HDS);
510 else if ((t1 == TopAbs_EDGE) && (t2 == TopAbs_FACE)) {
512 debfilleref(); // debug
514 TopOpeBRep_FaceEdgeIntersector& FE =
515 myShapeIntersector.ChangeFaceEdgeIntersector();
516 myFaceEdgeFiller.Insert(gs2,gs1,FE,HDS);
519 islFFsamdom = isFFsamdom;
520 myShapeIntersector.NextIntersection();
522 } // while (MoreIntersection())
524 // FFsamdom = true : rien que des faces tangentes
525 // codage des aretes de section des aretes samedomain
526 if (FFsamdom) FUN_ds_FillSDMFaces(HDS);// xpu060598
527 // xpu280199 : On stocke les edges sdm comme edges de section aussi ! - CTS21801 -
528 else FUN_ds_addSEsdm1d(HDS);
530 if (FFsamdom) HDS->ChangeDS().Isfafa(Standard_True);// xpu120598
532 if (islFFsamdom && !isEE) {
533 if (myPShapeClassifier==NULL) myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
534 unfill = BREP_UnfillSameDomain(lFF1,lFF2,HDS,*myPShapeClassifier);
537 BREP_sortonparameter(HDS);
538 BREP_correctgbound(HDS);
541 HDS->AddAncestors(S1); // xpu100798 cto902B4 (f24 as face ancestor of e19)
542 HDS->AddAncestors(S2); // xpu100798
543 FDSCNX_Prepare(aS1,aS2,HDS);
547 if (tkro) KRO_DSFILLER_TOTAL.Stop();if (tsiff) SIFF.End("DSFiller fin tsif ",cout);
550 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::InsertIntersection"<<endl;
553 } // InsertIntersection
555 //=======================================================================
556 //function : Complete
558 //=======================================================================
559 void TopOpeBRep_DSFiller::Complete(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
568 RemoveUnsharedGeometry(HDS);
571 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Complete"<<endl;
575 //=======================================================================
576 //function : GapFiller
578 //=======================================================================
579 void TopOpeBRep_DSFiller::GapFiller(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
581 TopOpeBRepDS_GapFiller GF(HDS); GF.Perform();
583 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::GapFiller"<<endl;
587 //=======================================================================
588 //function : CompleteDS
590 //=======================================================================
591 void TopOpeBRep_DSFiller::CompleteDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
596 const TopoDS_Shape& S1 = myShapeIntersector.Shape(1);
597 const TopoDS_Shape& S2 = myShapeIntersector.Shape(2);
598 if(S1.IsNull() || S2.IsNull()) return;
599 // HDS->AddAncestors(S1); -xpu100798 (is done before FDSCNX_Prepare)
600 // HDS->AddAncestors(S2); -xpu100798
602 // FUN_ds_unkeepEVIonGb1(HDS,TopAbs_IN); //xpu290698
604 FUN_ds_PointToVertex(HDS); // xpu090698, NYI TopOpeBRepDS_Filler
605 FUN_ds_redusamsha(HDS); // xpu201098
606 FUN_ds_PURGEforE9(HDS); // xpu040998,
607 FUN_ds_completeforSE8(HDS); // xpu020998,
608 FUN_ds_completeforSE1(HDS); // xpu160398,
609 FUN_ds_completeforSE2(HDS); // xpu250398,
610 FUN_ds_completeforSE3(HDS); // xpu170498,
611 FUN_ds_completeforSE4(HDS); // xpu160698,
612 FUN_ds_completeforSE5(HDS); // xpu190698,
613 FUN_ds_completeforSE6(HDS); // xpu280798,
614 // FUN_ds_completeforSE7(HDS); // xpu100898,
615 FUN_ds_completeforE7(HDS); // xpu130898,
616 FUN_ds_completeforSE9(HDS); // xpu011098
617 FUN_ds_complete1dForSESDM(HDS); // MSV 25.03.2002 : OCC251
619 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::CompleteDS"<<endl;
623 //=======================================================================
626 //=======================================================================
627 void TopOpeBRep_DSFiller::Filter(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
629 TopOpeBRepDS_Filter F(HDS);
630 F.ProcessEdgeInterferences();
631 F.ProcessCurveInterferences();
633 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Filter"<<endl;
637 //=======================================================================
640 //=======================================================================
641 void TopOpeBRep_DSFiller::Reducer(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
643 TopOpeBRepDS_Reducer R(HDS);
644 R.ProcessEdgeInterferences();
646 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Reducer"<<endl;
650 //=======================================================================
651 //function : RemoveUnsharedGeometry
653 //=======================================================================
654 void TopOpeBRep_DSFiller::RemoveUnsharedGeometry(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
656 Standard_Boolean processNOG = Standard_True;
658 if (TopOpeBRep_GetcontextNONOG()) processNOG = Standard_False;
660 if (!processNOG) return;
662 // xpu290998 : PRO15369 (f5,f20 only share geometric point (vertex))
663 // end processing for all information on shapes is given.
664 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
665 Standard_Integer nbs = BDS.NbShapes();
666 for (Standard_Integer i = 1; i <= nbs; i++) {
667 TopoDS_Shape S = BDS.Shape(i);
668 if (S.ShapeType() != TopAbs_FACE) continue;
669 Standard_Boolean hsd = HDS->HasSameDomain(S);
671 Standard_Integer rkS = BDS.AncestorRank(S);
672 if (rkS != 1) continue;
673 const TopTools_ListOfShape& lSsd = BDS.ShapeSameDomain(S);
674 TopTools_ListIteratorOfListOfShape itsd(lSsd);
675 for (; itsd.More(); itsd.Next()){
676 TopoDS_Shape Ssd = itsd.Value(); //xpuxpu
677 Standard_Integer rkSsd = BDS.AncestorRank(Ssd);
678 if (rkSsd == 1) continue;
680 Standard_Boolean unfill = ::FUN_shareNOG(HDS,S,Ssd);
681 unfill = unfill && FUN_ds_sdm(BDS,S,Ssd) && FUN_ds_sdm(BDS,Ssd,S);
683 if (myPShapeClassifier==NULL) myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
684 unfill = BREP_UnfillSameDomain(S,Ssd,HDS,*myPShapeClassifier);
689 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::RemoveUnsharedGeometry"<<endl;
691 } // RemoveUnsharedGeometry
693 //=======================================================================
696 //=======================================================================
697 void TopOpeBRep_DSFiller::Checker(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
699 // TopOpeBRepDS_Checker C(HDS); // NYI
701 // if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Checker"<<endl;
705 //=======================================================================
706 //function : Insert2d
708 //=======================================================================
710 void TopOpeBRep_DSFiller::Insert2d
711 (const TopoDS_Shape& aS1,const TopoDS_Shape& aS2,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
713 InsertIntersection2d(aS1,aS2,HDS);
716 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::Insert2d"<<endl;
720 //=======================================================================
721 //function : InsertIntersection2d
723 //=======================================================================
725 void TopOpeBRep_DSFiller::InsertIntersection2d
726 (const TopoDS_Shape& aS1,const TopoDS_Shape& aS2,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
728 if (myPShapeClassifier == NULL) {
729 myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
731 myFacesFiller.SetPShapeClassifier(myPShapeClassifier);
733 if ( ! ClearShapeSameDomain(aS1, aS2, HDS) ) return;
735 TopoDS_Shape S1 = aS1;
736 TopoDS_Shape S2 = aS2;
737 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
741 TopoDS_Shape lFF1, lFF2;
742 Standard_Boolean isFFsamdom = Standard_False;
744 myShapeIntersector2d.InitIntersection(S1,S2);
745 while (myShapeIntersector2d.MoreIntersection()) {
747 // The two intersecting GeomShapes gs1,gs2 and their types t1,t2
748 const TopoDS_Shape& gs1 = myShapeIntersector2d.CurrentGeomShape(1);
749 const TopoDS_Shape& gs2 = myShapeIntersector2d.CurrentGeomShape(2);
750 TopAbs_ShapeEnum t1 = gs1.ShapeType();
751 TopAbs_ShapeEnum t2 = gs2.ShapeType();
753 // si le couple courant apres un couple facefacesamedomain n'est
754 // pas un couple edgeedge ==> facefacesamedomain est deconnecte
755 Standard_Boolean isFF = ((t1==TopAbs_FACE) && (t2==TopAbs_FACE));
756 Standard_Boolean isEE = ((t1==TopAbs_EDGE) && (t2==TopAbs_EDGE));
757 Standard_Boolean unfill = (!isEE && isFFsamdom);
759 if (myPShapeClassifier==NULL)
760 myPShapeClassifier = new TopOpeBRepTool_ShapeClassifier();
761 // NYI : mettre en champs un ShapeClassifier commun a tous
763 TopAbs_State st1=TopAbs_UNKNOWN,st2=TopAbs_UNKNOWN;
764 Standard_Integer samdom = 1;
765 st1 = myPShapeClassifier->StateShapeShape(lFF1,lFF2,samdom);
766 st2 = myPShapeClassifier->StateShapeShape(lFF2,lFF1,samdom);
767 if ( ((st1 == TopAbs_OUT) && (st2 == TopAbs_OUT)) ||
768 ((st1 == TopAbs_UNKNOWN) && (st2 == TopAbs_UNKNOWN)) ) {
769 unfill = Standard_True; // NYI IN IN aussi
772 unfill = Standard_False;
775 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
776 if(!lFF1.IsNull() && !lFF2.IsNull())
777 BDS.UnfillShapesSameDomain(lFF1,lFF2);
782 isFFsamdom = Standard_True;
783 myShapeIntersector2d.ChangeEdgesIntersector().SetFaces(gs1,gs2);
784 lFF1 = gs1; lFF2 = gs2;
785 BDS.FillShapesSameDomain(gs1,gs2);
787 else if ((t1 == TopAbs_EDGE) && (t2 == TopAbs_EDGE)) {
788 TopOpeBRep_EdgesIntersector& EE = myShapeIntersector2d.ChangeEdgesIntersector();
790 myEdgesFiller.Face(1,lFF1);
791 myEdgesFiller.Face(2,lFF2);
792 myEdgesFiller.Insert(gs1,gs2,EE,HDS);
794 myShapeIntersector2d.NextIntersection();
795 } // while (MoreIntersection())
797 BREP_sortonparameter(HDS);
798 BREP_correctgbound(HDS);
802 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::InsertIntersection2d"<<endl;
805 } // InsertIntersection2d
808 //=======================================================================
809 //function : CompleteDS2d
811 //=======================================================================
813 void TopOpeBRep_DSFiller::CompleteDS2d(const Handle(TopOpeBRepDS_HDataStructure)& HDS) const
815 const TopoDS_Shape& S1 = myShapeIntersector2d.Shape(1);
816 const TopoDS_Shape& S2 = myShapeIntersector2d.Shape(2);
817 if(S1.IsNull() || S2.IsNull()) return;
818 HDS->AddAncestors(S1);
819 HDS->AddAncestors(S2);
821 TopOpeBRepDS_Filter F(HDS);
822 F.ProcessEdgeInterferences();
823 F.ProcessCurveInterferences();
824 TopOpeBRepDS_Reducer R(HDS);
825 R.ProcessEdgeInterferences();
826 // TopOpeBRepDS_Checker C(HDS); // NYI
828 if (TopOpeBRepTool_GettraceEND()) cout<<"DSFiller::CompleteDS2d"<<endl;
832 //=======================================================================
833 //function : IsMadeOf1d
835 //=======================================================================
837 Standard_Boolean TopOpeBRep_DSFiller::IsMadeOf1d(const TopoDS_Shape& aS) const
839 // vrai si il existe > 1 WIRE et/ou > 1 EDGE sans ascendance de face
840 Standard_Boolean res = Standard_False;
841 TopAbs_ShapeEnum t = aS.ShapeType();
842 if ( t == TopAbs_WIRE ) {
845 else if ( t == TopAbs_EDGE ) {
848 else if ( t == TopAbs_COMPOUND ) {
849 TopoDS_Iterator it(aS);
851 res = Standard_False;
855 for (; it.More(); it.Next()) {
856 const TopoDS_Shape& S = it.Value();
857 Standard_Boolean is1d = IsMadeOf1d(S);
859 res = Standard_False;
865 else { // != COMPOUND,WIRE,EDGE
866 res = Standard_False;
872 //=======================================================================
873 //function : IsContext1d
875 //=======================================================================
877 Standard_Boolean TopOpeBRep_DSFiller::IsContext1d(const TopoDS_Shape& aS) const
879 Standard_Boolean is1d = IsMadeOf1d(aS);
881 if ( is1d ) cout<<"TopOpeBRep_DSFiller : 1d"<<endl;
883 if ( !is1d ) return Standard_False;
884 return Standard_True;
887 //=======================================================================
888 //function : Insert1d
890 //=======================================================================
892 void TopOpeBRep_DSFiller::Insert1d
893 (const TopoDS_Shape& aS1,const TopoDS_Shape& aS2,const TopoDS_Face& aF1,const TopoDS_Face& aF2,
894 const Handle(TopOpeBRepDS_HDataStructure)& HDS,const Standard_Boolean orientFORWARD)
896 if ( ! CheckInsert(aS1,aS2) ) return;
898 TopoDS_Shape S1 = aS1;
899 TopoDS_Shape S2 = aS2;
900 if ( orientFORWARD ) {
901 if ( S1.Orientation() == TopAbs_REVERSED ) S1.Orientation(TopAbs_FORWARD);
902 if ( S2.Orientation() == TopAbs_REVERSED ) S2.Orientation(TopAbs_FORWARD);
904 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
909 myShapeIntersector.InitIntersection(S1,S2,aF1,aF2);
910 for (;myShapeIntersector.MoreIntersection(); myShapeIntersector.NextIntersection()) {
912 // The two intersecting GeomShapes gs1,gs2 and their types t1,t2
913 const TopoDS_Shape& gs1 = myShapeIntersector.CurrentGeomShape(1);
914 const TopoDS_Shape& gs2 = myShapeIntersector.CurrentGeomShape(2);
915 TopAbs_ShapeEnum t1 = gs1.ShapeType(), t2 = gs2.ShapeType();
917 if ((t1 == TopAbs_EDGE) && (t2 == TopAbs_EDGE)) {
918 TopOpeBRep_EdgesIntersector& EE =
919 myShapeIntersector.ChangeEdgesIntersector();
921 myEdgesFiller.Insert(gs1,gs2,EE,HDS);
930 //=======================================================================
931 //function : CheckInsert
933 //=======================================================================
935 Standard_Boolean TopOpeBRep_DSFiller::CheckInsert(const TopoDS_Shape& aS1,const TopoDS_Shape& aS2) const
937 if (aS1.IsEqual(aS2)) {
939 cout<<"TopOpeBRep_DSFiller : CheckInsert : S1 == S2"<<endl;
941 return Standard_False;
943 return Standard_True;
946 //=======================================================================
947 //function : ClearShapeSameDomain
949 //=======================================================================
951 Standard_Boolean TopOpeBRep_DSFiller::ClearShapeSameDomain
952 (const TopoDS_Shape& aS1,const TopoDS_Shape& aS2,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
954 TopOpeBRepDS_DataStructure& DS = HDS->ChangeDS();
955 const Standard_Boolean b = Standard_False;
956 if(!CheckInsert(aS1,aS2))
958 TopExp_Explorer exp1(aS1, TopAbs_FACE), exp2(aS2, TopAbs_FACE);
959 for(; exp1.More(); exp1.Next()) {
960 const TopoDS_Shape& Shape1 = exp1.Current();
961 if(!HDS->HasShape(Shape1))
962 if(HDS->HasSameDomain(Shape1)) {
963 TopTools_ListOfShape& los =
964 DS.ChangeShapeSameDomain(Shape1);
968 for(; exp2.More(); exp2.Next()) {
969 const TopoDS_Shape& Shape2 = exp2.Current();
970 if(HDS->HasShape(Shape2))
971 if(HDS->HasSameDomain(Shape2)) {
972 TopTools_ListOfShape& los =
973 DS.ChangeShapeSameDomain(Shape2);
977 return Standard_True;
981 //=======================================================================
982 //function : ChangeShapeIntersector
984 //=======================================================================
986 TopOpeBRep_ShapeIntersector& TopOpeBRep_DSFiller::ChangeShapeIntersector()
987 { return myShapeIntersector; }
989 //=======================================================================
990 //function : ChangeShapeIntersector2d
992 //=======================================================================
994 TopOpeBRep_ShapeIntersector2d& TopOpeBRep_DSFiller::ChangeShapeIntersector2d()
995 { return myShapeIntersector2d; }
998 //=======================================================================
999 //function : ChangeFacesFiller
1001 //=======================================================================
1003 TopOpeBRep_FacesFiller& TopOpeBRep_DSFiller::ChangeFacesFiller()
1004 { return myFacesFiller; }
1007 //=======================================================================
1008 //function : ChangeEdgesFiller
1010 //=======================================================================
1012 TopOpeBRep_EdgesFiller& TopOpeBRep_DSFiller::ChangeEdgesFiller()
1013 { return myEdgesFiller; }
1016 //=======================================================================
1017 //function : ChangeFaceEdgeFiller
1019 //=======================================================================
1021 TopOpeBRep_FaceEdgeFiller& TopOpeBRep_DSFiller::ChangeFaceEdgeFiller()
1022 { return myFaceEdgeFiller; }