Commit | Line | Data |
---|---|---|
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 | // |
d5f74e42 | 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 | |
973c2be1 | 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 | |
7fd59977 | 17 | |
7fd59977 | 18 | #include <BRep_Tool.hxx> |
42cf5bc1 | 19 | #include <gp_Pnt.hxx> |
20 | #include <Standard_NoSuchObject.hxx> | |
21 | #include <TCollection_AsciiString.hxx> | |
7fd59977 | 22 | #include <TopExp.hxx> |
42cf5bc1 | 23 | #include <TopoDS.hxx> |
24 | #include <TopoDS_Edge.hxx> | |
25 | #include <TopoDS_Face.hxx> | |
26 | #include <TopoDS_Shape.hxx> | |
27 | #include <TopoDS_Vertex.hxx> | |
28 | #include <TopOpeBRepBuild_Builder.hxx> | |
29 | #include <TopOpeBRepBuild_define.hxx> | |
30 | #include <TopOpeBRepBuild_EdgeBuilder.hxx> | |
31 | #include <TopOpeBRepBuild_FaceBuilder.hxx> | |
32 | #include <TopOpeBRepBuild_GTopo.hxx> | |
33 | #include <TopOpeBRepBuild_HBuilder.hxx> | |
34 | #include <TopOpeBRepBuild_PaveSet.hxx> | |
35 | #include <TopOpeBRepBuild_ShapeSet.hxx> | |
36 | #include <TopOpeBRepBuild_ShellFaceSet.hxx> | |
37 | #include <TopOpeBRepBuild_SolidBuilder.hxx> | |
38 | #include <TopOpeBRepBuild_WireEdgeSet.hxx> | |
39 | #include <TopOpeBRepDS.hxx> | |
40 | #include <TopOpeBRepDS_BuildTool.hxx> | |
41 | #include <TopOpeBRepDS_CurveIterator.hxx> | |
7fd59977 | 42 | #include <TopOpeBRepDS_EXPORT.hxx> |
42cf5bc1 | 43 | #include <TopOpeBRepDS_HDataStructure.hxx> |
44 | #include <TopOpeBRepDS_InterferenceTool.hxx> | |
45 | #include <TopOpeBRepDS_PointIterator.hxx> | |
7fd59977 | 46 | #include <TopOpeBRepDS_ProcessInterferencesTool.hxx> |
42cf5bc1 | 47 | #include <TopOpeBRepDS_SurfaceIterator.hxx> |
48 | #include <TopOpeBRepTool_2d.hxx> | |
49 | #include <TopOpeBRepTool_EXPORT.hxx> | |
50 | #include <TopOpeBRepTool_ShapeExplorer.hxx> | |
51 | #include <TopOpeBRepTool_ShapeTool.hxx> | |
52 | #include <TopOpeBRepTool_TOOL.hxx> | |
7fd59977 | 53 | |
54 | #ifdef DRAW | |
7fd59977 | 55 | Standard_IMPORT void FUN_draw(const TopoDS_Shape& s); |
56 | Standard_IMPORT void FUN_draw2de (const TopoDS_Shape& ed,const TopoDS_Shape& fa); | |
57 | #endif | |
58 | ||
0797d9d3 | 59 | #ifdef OCCT_DEBUG |
60 | #include <TopOpeBRepDS_DSX.hxx> | |
1d0a9d4d | 61 | extern void* GFABUMAKEFACEPWES_DEB; |
7fd59977 | 62 | #define DEBSHASET(sarg,meth,shaset,str) TCollection_AsciiString sarg((meth));(sarg)=(sarg)+(shaset).DEBNumber()+(str); |
1d0a9d4d | 63 | Standard_Integer GLOBAL_iexE = 0; |
7fd59977 | 64 | Standard_EXPORT void debfillw(const Standard_Integer /*i*/) {} |
65 | Standard_EXPORT void debfille(const Standard_Integer /*i*/) {} | |
66 | Standard_EXPORT void debffwesON(const Standard_Integer i) {cout<<"++ debffwesON "<<i<<endl;} | |
67 | Standard_EXPORT void debffwesmf(const Standard_Integer i) {cout<<"++ debffwesmf "<<i<<endl;} | |
68 | Standard_EXPORT void debfillf(const Standard_Integer i) {cout<<"++ debfillf "<<i<<endl;} | |
69 | Standard_EXPORT void debsplite(const Standard_Integer i) {cout<<"++ debsplite "<<i<<endl;} | |
70 | Standard_EXPORT void debmergef(const Standard_Integer i) {cout<<"++ debmergef "<<i<<endl;} | |
71 | Standard_IMPORT void debfctwesmess(const Standard_Integer i, | |
72 | const TCollection_AsciiString& s = ""); | |
1d0a9d4d | 73 | extern void debaddpwes(const Standard_Integer iFOR, const TopAbs_State TB1, const Standard_Integer iEG, |
74 | const TopAbs_Orientation neworiE, const TopOpeBRepBuild_PBuilder& PB, | |
75 | const TopOpeBRepBuild_PWireEdgeSet& PWES, const TCollection_AsciiString& str1, | |
76 | const TCollection_AsciiString& str2); | |
7fd59977 | 77 | #endif |
78 | ||
1d0a9d4d | 79 | Standard_Boolean GLOBAL_faces2d = Standard_False; |
7fd59977 | 80 | Standard_EXPORT Standard_Boolean GLOBAL_classifysplitedge = Standard_False; |
81 | ||
82 | #define M_IN(st ) (st == TopAbs_IN) | |
83 | #define M_OUT(st) (st == TopAbs_OUT) | |
84 | #define M_FORWARD(st ) (st == TopAbs_FORWARD) | |
85 | #define M_REVERSED(st) (st == TopAbs_REVERSED) | |
86 | #define M_INTERNAL(st) (st == TopAbs_INTERNAL) | |
87 | #define M_EXTERNAL(st) (st == TopAbs_EXTERNAL) | |
88 | ||
89 | Standard_IMPORT Standard_Boolean FUN_HDS_FACESINTERFER(const TopoDS_Shape& F1, | |
90 | const TopoDS_Shape& F2, | |
91 | const Handle(TopOpeBRepDS_HDataStructure)& HDS); | |
92 | ||
93 | static | |
94 | TopAbs_State ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& E, | |
95 | const TopoDS_Shape& Ref); | |
96 | static | |
97 | Standard_Boolean FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, | |
98 | const TopoDS_Face& F, | |
99 | const TopoDS_Edge& E, | |
100 | TopOpeBRepDS_PDataStructure& pDS2d); | |
101 | static | |
102 | Standard_Boolean FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, | |
103 | const TopoDS_Face& F, | |
104 | TopOpeBRepDS_PDataStructure& pDS2d); | |
105 | ||
106 | //------------------------------------------------------------- | |
107 | // Unused : | |
0797d9d3 | 108 | /*#ifdef OCCT_DEBUG |
7fd59977 | 109 | //======================================================================= |
110 | //function :FUN_BUI_FACESINTERFER | |
111 | //purpose : | |
112 | //======================================================================= | |
113 | static Standard_Boolean FUN_BUI_FACESINTERFER(const TopoDS_Shape& F1, | |
114 | const TopoDS_Shape& F2, | |
115 | const TopOpeBRepBuild_Builder& B) | |
116 | { | |
117 | Standard_Boolean yainterf = Standard_False; | |
118 | Handle(TopOpeBRepDS_HDataStructure) HDS = B.DataStructure(); | |
119 | ||
120 | ||
121 | ||
122 | Standard_Boolean ya1 = FUN_HDS_FACESINTERFER(F1,F2,HDS); | |
123 | Standard_Boolean ya2 = FUN_HDS_FACESINTERFER(F2,F1,HDS); | |
124 | yainterf = (ya1 && ya2); | |
125 | return yainterf; | |
126 | } | |
127 | #endif*/ | |
128 | ||
129 | //======================================================================= | |
130 | //function :TopOpeBRepBuild_FUN_aresamegeom | |
131 | //purpose : | |
132 | //======================================================================= | |
1d0a9d4d | 133 | Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom (const TopoDS_Shape& S1, |
134 | const TopoDS_Shape& S2) | |
7fd59977 | 135 | { |
136 | TopoDS_Shape SF1 = S1; | |
137 | SF1.Orientation(TopAbs_FORWARD); | |
138 | TopoDS_Shape SF2 = S2; | |
139 | SF2.Orientation(TopAbs_FORWARD); | |
140 | Standard_Boolean same = TopOpeBRepTool_ShapeTool::ShapesSameOriented(SF1,SF2); | |
141 | return same; | |
142 | } | |
143 | ||
144 | //======================================================================= | |
145 | //function :FUN_computeLIFfaces2d | |
146 | //purpose : | |
147 | //======================================================================= | |
148 | Standard_Boolean FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, | |
149 | const TopoDS_Face& F, | |
150 | const TopoDS_Edge& E, | |
151 | TopOpeBRepDS_PDataStructure& pDS2d) | |
152 | // purpose : compute new face/face interferences F FTRA, | |
153 | // {I = (T(F),ES,FTRA)} / Fsdm F and ES interfers with E which has splits ON | |
154 | // E is edge of F | |
155 | { | |
0797d9d3 | 156 | #ifdef OCCT_DEBUG |
7fd59977 | 157 | Standard_Integer iF;Standard_Boolean tF=BU.GtraceSPS(F,iF); |
158 | #endif | |
159 | ||
160 | const TopOpeBRepDS_DataStructure& BDS = BU.DataStructure()->DS(); | |
161 | const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(E); | |
162 | Standard_Integer IE = BDS.Shape(E); | |
163 | Standard_Integer IF = BDS.Shape(F); | |
164 | Standard_Integer rkF = BDS.AncestorRank(F); | |
165 | Standard_Boolean hasspE = BU.IsSplit(E,TopAbs_ON); | |
166 | if (hasspE) hasspE = (BU.Splits(E,TopAbs_ON).Extent() > 0); | |
167 | TopTools_MapOfShape Ffound; | |
168 | ||
169 | TopTools_ListOfShape Fsdm; TopTools_ListIteratorOfListOfShape itf(BDS.ShapeSameDomain(F)); | |
170 | for (; itf.More(); itf.Next()){ | |
171 | const TopoDS_Shape& f = itf.Value(); | |
172 | Standard_Integer rkf = BDS.AncestorRank(f); | |
173 | if (rkf == rkF) continue; | |
174 | Fsdm.Append(f); | |
175 | } | |
176 | ||
177 | for (TopOpeBRepDS_ListIteratorOfListOfInterference itI(LI); itI.More(); itI.Next()){ | |
178 | const Handle(TopOpeBRepDS_Interference)& I = itI.Value(); | |
179 | // const TopOpeBRepDS_Transition& T = I->Transition(); | |
180 | TopAbs_ShapeEnum SB,SA;Standard_Integer IB,IA;TopOpeBRepDS_Kind GT,ST;Standard_Integer G,S; | |
181 | FDS_Idata(I,SB,IB,SA,IA,GT,G,ST,S); | |
182 | if (ST != TopOpeBRepDS_EDGE) return Standard_False; | |
183 | ||
184 | TopoDS_Face FTRA; Standard_Integer ITRA = IB; | |
185 | if (SB == TopAbs_FACE) FTRA = TopoDS::Face(BDS.Shape(IB)); | |
186 | else if (SB == TopAbs_EDGE) { | |
187 | Standard_Boolean ok = FUN_tool_findAncestor(Fsdm,TopoDS::Edge(BDS.Shape(S)),FTRA); | |
188 | ITRA = BDS.Shape(FTRA); | |
189 | if (!ok) return Standard_False; | |
190 | } | |
191 | Standard_Boolean found = Ffound.Contains(FTRA); | |
192 | ||
193 | // prequesitory : F and FTRA are SDSO | |
194 | // ------------- | |
195 | ||
196 | // attached to E : I = (T(FTRA),G,ES), | |
197 | // ES : support edge | |
198 | // GP : geometric point | |
199 | // recall : rankE = rankF | |
200 | // rankTRA = rankS != rankE | |
201 | Standard_Real parE = FDS_Parameter(I); | |
202 | const TopoDS_Edge& ES = TopoDS::Edge(BDS.Shape(S)); | |
203 | Standard_Boolean hasspES = BU.IsSplit(ES,TopAbs_ON); | |
204 | if (hasspES) hasspE = (BU.Splits(ES,TopAbs_ON).Extent() > 0); | |
205 | ||
206 | Standard_Boolean sdm = FUN_ds_sdm(BDS,E,ES); | |
207 | Standard_Boolean mkTonEsdm = sdm && hasspE && !found; | |
208 | Standard_Boolean hasfeiF_E_FTRA = FUN_ds_hasFEI(pDS2d,F,IE,ITRA); //xpu120698 | |
209 | mkTonEsdm = mkTonEsdm && !hasfeiF_E_FTRA; //xpu120698 | |
210 | if (mkTonEsdm) { | |
211 | Ffound.Add(FTRA); | |
212 | TopoDS_Edge dummy; TopOpeBRepDS_Transition newT; | |
213 | Standard_Boolean ok = FUN_ds_mkTonFsdm(BU.DataStructure(),IF,ITRA,S,IE,parE,dummy,Standard_True,newT); | |
214 | ||
215 | if (ok) { | |
216 | newT.Index(ITRA); TopOpeBRepDS_Config C = TopOpeBRepDS_SAMEORIENTED; | |
217 | Handle(TopOpeBRepDS_Interference) newI = TopOpeBRepDS_InterferenceTool::MakeFaceEdgeInterference(newT,ITRA,IE,Standard_True,C); | |
0797d9d3 | 218 | #ifdef OCCT_DEBUG |
7fd59977 | 219 | if (tF) {cout<<"f"<<IF<<" + ";newI->Dump(cout);cout<<endl;} |
220 | #endif | |
221 | pDS2d->AddShapeInterference(F,newI); | |
222 | } | |
223 | } | |
224 | Standard_Boolean mkTonESsdm = sdm && hasspES; | |
225 | Standard_Boolean hasfeiFRA_E_F = FUN_ds_hasFEI(pDS2d,FTRA,IE,IF); //xpu120698 | |
226 | mkTonESsdm = mkTonESsdm && !hasfeiFRA_E_F; //xpu120698 | |
227 | if (mkTonESsdm) { // ff1, IE=3 has interferences, S=8 has none | |
228 | TopoDS_Edge dummy; TopOpeBRepDS_Transition newT; | |
229 | ||
230 | Standard_Real parES; Standard_Boolean ok = FUN_tool_parE(E,parE,ES,parES); | |
231 | if (!ok) continue; | |
232 | ok = FUN_ds_mkTonFsdm(BU.DataStructure(),ITRA,IF,IE,S,parES,dummy,Standard_True,newT); | |
233 | if (ok) { | |
234 | newT.Index(IF); TopOpeBRepDS_Config C = TopOpeBRepDS_SAMEORIENTED; | |
235 | Handle(TopOpeBRepDS_Interference) newI = TopOpeBRepDS_InterferenceTool::MakeFaceEdgeInterference(newT,IF,IE,Standard_False,C); | |
0797d9d3 | 236 | #ifdef OCCT_DEBUG |
7fd59977 | 237 | if (tF) {cout<<"f"<<ITRA<<" + ";newI->Dump(cout);cout<<endl;} |
238 | #endif | |
239 | pDS2d->AddShapeInterference(FTRA,newI); | |
240 | } | |
241 | ||
242 | ok = FUN_ds_mkTonFsdm(BU.DataStructure(),ITRA,IF,IE,IE,parE,dummy,Standard_True,newT); | |
243 | if (ok) { | |
244 | newT.Index(IF); TopOpeBRepDS_Config C = TopOpeBRepDS_SAMEORIENTED; | |
245 | Handle(TopOpeBRepDS_Interference) newI = TopOpeBRepDS_InterferenceTool::MakeFaceEdgeInterference(newT,IF,S,Standard_True,C); | |
0797d9d3 | 246 | #ifdef OCCT_DEBUG |
7fd59977 | 247 | if (tF) {cout<<endl<<"f"<<ITRA<<" + ";newI->Dump(cout);cout<<endl;} |
248 | #endif | |
249 | pDS2d->AddShapeInterference(FTRA,newI); | |
250 | } | |
251 | ||
252 | } | |
253 | ||
254 | Standard_Boolean mkTonES = hasspES; | |
255 | Standard_Boolean hasfeiF_S_FTRA = FUN_ds_hasFEI(pDS2d,F,S,ITRA); //xpu120698 | |
256 | mkTonES = mkTonES && !hasfeiF_S_FTRA; | |
257 | if (mkTonES) { | |
258 | Standard_Real parES; Standard_Boolean ok = FUN_tool_parE(E,parE,ES,parES); | |
259 | if (!ok) continue; | |
260 | ||
261 | TopoDS_Edge dummy; TopOpeBRepDS_Transition newT; | |
262 | ok = FUN_ds_mkTonFsdm(BU.DataStructure(),IF,ITRA,S,S,parES,dummy,Standard_True,newT); | |
263 | ||
264 | if (ok) { | |
265 | newT.Index(ITRA); TopOpeBRepDS_Config C = TopOpeBRepDS_SAMEORIENTED; | |
266 | Handle(TopOpeBRepDS_Interference) newI = TopOpeBRepDS_InterferenceTool::MakeFaceEdgeInterference(newT,ITRA,S,Standard_False,C); | |
0797d9d3 | 267 | #ifdef OCCT_DEBUG |
7fd59977 | 268 | if (tF) {cout<<"f"<<iF<<" + ";newI->Dump(cout);cout<<endl;} |
269 | #endif | |
270 | pDS2d->AddShapeInterference(F,newI); | |
271 | } | |
272 | } | |
273 | } // itI(LI) | |
274 | ||
275 | return Standard_True; | |
276 | } | |
277 | //======================================================================= | |
278 | //function :FUN_computeLIFfaces2d | |
279 | //purpose : | |
280 | //======================================================================= | |
281 | Standard_Boolean FUN_computeLIFfaces2d(const TopOpeBRepBuild_Builder& BU, | |
282 | const TopoDS_Face& F, | |
283 | TopOpeBRepDS_PDataStructure& pDS2d) | |
284 | { | |
285 | TopExp_Explorer ex(F, TopAbs_EDGE); | |
286 | for (; ex.More(); ex.Next()){ | |
287 | const TopoDS_Edge& E = TopoDS::Edge(ex.Current()); | |
288 | Standard_Boolean ok = FUN_computeLIFfaces2d(BU,F,E,pDS2d); | |
289 | if (!ok) return Standard_False; | |
290 | } | |
291 | return Standard_True; | |
292 | } | |
293 | //======================================================================= | |
294 | //variable : Standard_EXPORT TopOpeBRepDS_PDataStructure GLOBAL_DS2d | |
295 | //purpose : | |
296 | //======================================================================= | |
297 | Standard_EXPORT TopOpeBRepDS_PDataStructure GLOBAL_DS2d = NULL; | |
298 | ||
299 | //======================================================================= | |
300 | //function : GMergeFaces | |
301 | //purpose : | |
302 | //======================================================================= | |
303 | void TopOpeBRepBuild_Builder::GMergeFaces(const TopTools_ListOfShape& LF1, | |
304 | const TopTools_ListOfShape& LF2, | |
305 | const TopOpeBRepBuild_GTopo& G1) | |
306 | { | |
307 | if ( LF1.IsEmpty() ) return; | |
308 | if (GLOBAL_DS2d == NULL) GLOBAL_DS2d = (TopOpeBRepDS_PDataStructure)new TopOpeBRepDS_DataStructure(); | |
309 | GLOBAL_DS2d->Init(); | |
310 | ||
311 | TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); | |
312 | ||
313 | const TopoDS_Shape& F1 = LF1.First(); | |
0797d9d3 | 314 | #ifdef OCCT_DEBUG |
7fd59977 | 315 | Standard_Integer iF; Standard_Boolean tSPS = GtraceSPS(F1,iF); |
316 | if(tSPS){ | |
317 | cout<<endl<<"--- GMergeFaces "<<endl; | |
318 | GdumpSAMDOM(LF1, (char *) "1 : "); | |
319 | GdumpSAMDOM(LF2, (char *) "2 : "); | |
320 | debmergef(iF); | |
321 | } | |
322 | #endif | |
323 | ||
324 | // xpu070598 : filling up DS2 | |
325 | // for (TopTools_ListIteratorOfListOfShape itF1(LF1); itF1.More(); itF1.Next()) GLOBAL_DS2d->AddShape(itF1.Value(),1); | |
326 | TopTools_ListIteratorOfListOfShape itF1(LF1) ; | |
327 | for ( ; itF1.More(); itF1.Next()) GLOBAL_DS2d->AddShape(itF1.Value(),1); | |
328 | // for (TopTools_ListIteratorOfListOfShape itF2(LF2); itF2.More(); itF2.Next()) GLOBAL_DS2d->AddShape(itF2.Value(),2); | |
329 | TopTools_ListIteratorOfListOfShape itF2(LF2) ; | |
330 | for ( ; itF2.More(); itF2.Next()) GLOBAL_DS2d->AddShape(itF2.Value(),2); | |
331 | ||
332 | // for (itF1.Initialize(LF1); itF1.More(); itF1.Next()){ | |
333 | itF1.Initialize(LF1) ; | |
334 | for ( ; itF1.More(); itF1.Next()){ | |
335 | const TopoDS_Face& FF1 = TopoDS::Face(itF1.Value()); | |
336 | FUN_computeLIFfaces2d((*this),TopoDS::Face(FF1),GLOBAL_DS2d); | |
337 | } | |
338 | // for (itF2.Initialize(LF2); itF2.More(); itF2.Next()){ | |
339 | itF2.Initialize(LF2) ; | |
340 | for ( ; itF2.More(); itF2.Next()){ | |
341 | const TopoDS_Face& FF2 = TopoDS::Face(itF2.Value()); | |
342 | FUN_computeLIFfaces2d((*this),TopoDS::Face(FF2),GLOBAL_DS2d); | |
343 | } | |
344 | // xpu070598 | |
345 | ||
346 | { | |
347 | for (Standard_Integer ii=1; ii<=GLOBAL_DS2d->NbShapes(); ii++) { | |
348 | TopOpeBRepDS_ListOfInterference& LI = GLOBAL_DS2d->ChangeShapeInterferences(ii); | |
349 | FUN_reducedoublons(LI,(*GLOBAL_DS2d),ii); | |
350 | } | |
351 | } | |
352 | ||
353 | myFaceReference = TopoDS::Face(F1); | |
354 | TopOpeBRepBuild_WireEdgeSet WES(F1,this); | |
355 | ||
356 | GLOBAL_faces2d = Standard_True; | |
357 | Standard_Integer K1=1; GFillFacesWESK(LF1,LF2,G1,WES,K1); | |
358 | Standard_Integer K3=3; GFillFacesWESK(LF1,LF2,G1,WES,K3); // xpu060598 | |
359 | GLOBAL_faces2d = Standard_False; | |
360 | ||
361 | // Create a face builder FABU | |
362 | TopoDS_Shape F1F = LF1.First(); F1F.Orientation(TopAbs_FORWARD); | |
363 | Standard_Boolean ForceClass = Standard_True; | |
364 | TopOpeBRepBuild_FaceBuilder FABU; | |
365 | FABU.InitFaceBuilder(WES,F1F,ForceClass); | |
366 | ||
367 | // Build new faces LFM | |
368 | TopTools_ListOfShape LFM; | |
369 | ||
0797d9d3 | 370 | #ifdef OCCT_DEBUG |
7fd59977 | 371 | GFABUMAKEFACEPWES_DEB = (void*)&WES; |
372 | #endif | |
373 | ||
374 | TopTools_DataMapOfShapeInteger MWisOld; | |
375 | GFABUMakeFaces(F1F,FABU,LFM,MWisOld); | |
376 | ||
377 | // xpu281098 : regularisation after GFABUMakeFaces | |
378 | TopTools_ListOfShape newLFM; RegularizeFaces(F1F,LFM,newLFM); | |
379 | LFM.Clear(); LFM.Assign(newLFM); | |
380 | ||
381 | // connect new faces as faces built TB1 on LF1 faces | |
382 | TopTools_ListIteratorOfListOfShape it1; | |
383 | for (it1.Initialize(LF1); it1.More(); it1.Next()) { | |
384 | const TopoDS_Shape& F1x = it1.Value(); | |
385 | Standard_Boolean tomerge = !IsMerged(F1x,TB1); | |
386 | if (tomerge) { | |
387 | ChangeMerged(F1x, TB1) = LFM; | |
388 | } | |
389 | } | |
390 | ||
391 | // connect new faces as faces built TB2 on LF2 faces | |
392 | TopTools_ListIteratorOfListOfShape it2; | |
393 | for (it2.Initialize(LF2); it2.More(); it2.Next()) { | |
394 | const TopoDS_Shape& F2 = it2.Value(); | |
395 | Standard_Boolean tomerge = !IsMerged(F2,TB2); | |
396 | if (tomerge) ChangeMerged(F2,TB2) = LFM; | |
397 | } | |
398 | ||
399 | } // GMergeFaces | |
400 | ||
401 | //======================================================================= | |
402 | //function : GFillFacesWES | |
403 | //purpose : | |
404 | //======================================================================= | |
405 | void TopOpeBRepBuild_Builder::GFillFacesWES(const TopTools_ListOfShape& , | |
406 | const TopTools_ListOfShape& , | |
407 | const TopOpeBRepBuild_GTopo& , | |
408 | TopOpeBRepBuild_WireEdgeSet& ) | |
409 | { | |
410 | } // GFillFacesWES | |
411 | ||
412 | static Standard_Boolean FUN_validF1edge(const TopoDS_Shape& F) | |
413 | { | |
414 | Standard_Integer nE = 0; | |
415 | TopTools_IndexedMapOfShape mEt; | |
416 | TopExp_Explorer exE(F, TopAbs_EDGE); | |
417 | // for ( exE ; exE.More(); exE.Next()) { | |
418 | for ( ; exE.More(); exE.Next()) { | |
419 | const TopoDS_Shape& e = exE.Current(); | |
420 | if (mEt.Contains(e)) continue; | |
421 | mEt.Add(e); | |
422 | nE++; | |
423 | if (nE > 2) break; | |
424 | } | |
425 | if (nE > 1) return Standard_True; | |
426 | if (nE == 1) { | |
427 | exE.Init(F, TopAbs_EDGE); | |
428 | const TopoDS_Edge& e = TopoDS::Edge(exE.Current()); | |
429 | TopoDS_Vertex dummy; Standard_Boolean closed = TopOpeBRepTool_TOOL::ClosedE(e,dummy); | |
430 | return closed; | |
431 | } | |
432 | return Standard_False; | |
433 | } | |
434 | ||
435 | //======================================================================= | |
436 | //function : GFillFacesWESMakeFaces | |
437 | //purpose : | |
438 | //======================================================================= | |
439 | void TopOpeBRepBuild_Builder::GFillFacesWESMakeFaces(const TopTools_ListOfShape& LLF1, | |
440 | const TopTools_ListOfShape& LF2, | |
441 | const TopTools_ListOfShape& ,//LSO, | |
442 | const TopOpeBRepBuild_GTopo& GM) | |
443 | { | |
444 | TopAbs_State TB1,TB2; GM.StatesON(TB1,TB2); | |
445 | if (LLF1.IsEmpty()) return; | |
446 | ||
447 | // xpu270898 : cto905E2 split(fref6,f33,f16) must be built on fref6 | |
448 | TopTools_ListOfShape LF1; | |
449 | TopTools_ListIteratorOfListOfShape itf(LLF1); | |
450 | const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); | |
451 | Standard_Integer iref = 0; | |
452 | for (; itf.More(); itf.Next()){ | |
453 | const TopoDS_Shape& fcur = itf.Value(); | |
454 | Standard_Integer icur = BDS.Shape(fcur); | |
455 | iref = BDS.SameDomainRef(fcur); | |
456 | if (icur == iref) LF1.Prepend(fcur); | |
457 | else LF1.Append(fcur); | |
458 | } | |
459 | // xpu270898 : cto905I1 split(f6,f30,fref14) must be built on fref6, f6 is in LFDO1 | |
460 | // Standard_Boolean FFinDO1 = (iFF == iref); | |
461 | // const TopoDS_Shape& FF = BDS.Shape(iref); | |
462 | const TopoDS_Shape& FF = LF1.First().Oriented(TopAbs_FORWARD); | |
463 | Standard_Integer iFF = BDS.Shape(FF); | |
464 | ||
465 | TopOpeBRepBuild_WireEdgeSet WES(FF,this); | |
466 | ||
0797d9d3 | 467 | #ifdef OCCT_DEBUG |
7fd59977 | 468 | Standard_Integer iF; Standard_Boolean tSPS = GtraceSPS(FF,iF); |
469 | if(tSPS) GdumpSHASTA(iF,TB1,WES,"\n--- GFillFacesWESMakeFaces"); | |
470 | if(tSPS) debfillf(iF); | |
471 | if(tSPS) debffwesmf(iF); | |
472 | #endif | |
473 | ||
474 | Standard_Integer n1 = 0; | |
475 | GLOBAL_faces2d = Standard_True; | |
476 | Standard_Integer K1=1; GFillFacesWESK(LF1,LF2,GM,WES,K1); | |
477 | GLOBAL_faces2d = Standard_False; | |
478 | n1 = WES.StartElements().Extent(); | |
479 | ||
480 | Standard_Integer K2=2; GFillFacesWESK(LF1,LF2,GM,WES,K2); | |
481 | n1 = WES.StartElements().Extent(); | |
482 | ||
483 | Standard_Integer K3=3; GFillFacesWESK(LF1,LF2,GM,WES,K3); | |
484 | n1 = WES.StartElements().Extent(); | |
485 | ||
486 | Standard_Integer n2 = WES.StartElements().Extent(); | |
487 | myEdgeAvoid.Clear(); // Start edges dues a GFillCurveTopologyWES | |
488 | GCopyList(WES.StartElements(),(n1+1),n2,myEdgeAvoid); | |
489 | TopTools_ListOfShape LOF; // LOF : toutes les faces construites sur WES | |
490 | GWESMakeFaces(FF,WES,LOF); | |
491 | ||
492 | // xpu290498 | |
493 | //cto 001 F2 : spIN(f18) | |
494 | TopTools_ListIteratorOfListOfShape itF(LOF); | |
495 | while (itF.More()){ | |
496 | const TopoDS_Shape& F = itF.Value(); | |
497 | Standard_Boolean valid = ::FUN_validF1edge(F); | |
498 | if (!valid) LOF.Remove(itF); | |
499 | else itF.Next(); | |
500 | } | |
501 | // xpu290498 | |
502 | ||
503 | TopTools_ListOfShape LOFS; // LOFS : LOF faces situees TB1/LSO2 | |
504 | GKeepShapes(FF,myEmptyShapeList,TB1,LOF,LOFS); | |
505 | ||
506 | // les faces construites (LOFS) prennent l'orientation originale de FF | |
507 | TopAbs_Orientation odsFF = myDataStructure->Shape(iFF).Orientation(); | |
508 | for(TopTools_ListIteratorOfListOfShape itt(LOFS);itt.More();itt.Next()) itt.Value().Orientation(odsFF); | |
509 | ||
510 | TopTools_ListIteratorOfListOfShape it1; | |
511 | for (it1.Initialize(LF1); it1.More(); it1.Next()) { | |
512 | const TopoDS_Shape& S = it1.Value(); | |
0797d9d3 | 513 | #ifdef OCCT_DEBUG |
7fd59977 | 514 | Standard_Integer iS; GtraceSPS(S,iS); |
515 | #endif | |
516 | MarkSplit(S,TB1); | |
517 | TopTools_ListOfShape& LS1 = ChangeSplit(S,TB1); | |
518 | GCopyList(LOFS,LS1); | |
519 | } | |
520 | ||
521 | TopTools_ListIteratorOfListOfShape it2; | |
522 | for (it2.Initialize(LF2); it2.More(); it2.Next()) { | |
523 | const TopoDS_Shape& S = it2.Value(); | |
0797d9d3 | 524 | #ifdef OCCT_DEBUG |
7fd59977 | 525 | Standard_Integer iS; GtraceSPS(S,iS); |
526 | #endif | |
527 | MarkSplit(S,TB2); | |
528 | TopTools_ListOfShape& LS2 = ChangeSplit(S,TB2); | |
529 | GCopyList(LOFS,LS2); | |
530 | } | |
531 | } // GFillFacesWESMakeFaces | |
532 | ||
533 | //======================================================================= | |
534 | //function : GFillFaceWES | |
535 | //purpose : | |
536 | //======================================================================= | |
537 | void TopOpeBRepBuild_Builder::GFillFaceWES(const TopoDS_Shape& FOR1, | |
538 | const TopTools_ListOfShape& LFclass, | |
539 | const TopOpeBRepBuild_GTopo& G1, | |
540 | TopOpeBRepBuild_WireEdgeSet& WES) | |
541 | { | |
542 | TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); | |
543 | Standard_Boolean RevOri1 = G1.IsToReverse1(); | |
544 | ||
0797d9d3 | 545 | #ifdef OCCT_DEBUG |
7fd59977 | 546 | Standard_Integer iF; Standard_Boolean tSPS = GtraceSPS(FOR1,iF); |
547 | if(tSPS) GdumpSHASTA(iF,TB1,WES,"--- GFillFaceWES","START"); | |
548 | if(tSPS) debfillf(iF); | |
549 | #endif | |
550 | ||
551 | // xpu200598 bcl1;bcl2; tsp(f9) | |
552 | Standard_Boolean opeCut = Opec12() || Opec21(); //xpu200598 | |
553 | Standard_Boolean ComOfCut = opeCut && (TB1 == TB2) && (TB1 == TopAbs_IN); //xpu200598 | |
554 | Standard_Boolean hsdm = myDataStructure->HasSameDomain(FOR1);//xpu200598 | |
555 | if (hsdm && ComOfCut) return; //xpu200598 | |
556 | ||
557 | // work on a FORWARD face FF | |
558 | TopoDS_Shape FF = FOR1; FF.Orientation(TopAbs_FORWARD); | |
559 | myFaceToFill = TopoDS::Face(FF); | |
560 | ||
561 | TopOpeBRepTool_ShapeExplorer exWire(FF,TopAbs_WIRE); | |
562 | for (; exWire.More(); exWire.Next()) { | |
563 | TopoDS_Shape W = exWire.Current(); | |
564 | Standard_Boolean hasshape = myDataStructure->HasShape(W); | |
565 | ||
566 | if ( ! hasshape ) { | |
567 | // wire W is not in DS : classify it with LFclass faces | |
568 | TopAbs_State pos; | |
569 | Standard_Boolean keep = GKeepShape1(W,LFclass,TB1,pos); | |
570 | if (keep) { | |
571 | TopAbs_Orientation oriW = W.Orientation(); | |
572 | TopAbs_Orientation neworiW = Orient(oriW,RevOri1); | |
573 | W.Orientation(neworiW); | |
574 | WES.AddShape(W); | |
575 | } | |
576 | else if (myProcessON && pos == TopAbs_ON) | |
577 | myONElemMap.Add(W); | |
578 | } | |
579 | else { // wire W has edges(s) with geometry : split W edges | |
580 | GFillWireWES(W,LFclass,G1,WES); | |
581 | } | |
582 | } | |
583 | ||
0797d9d3 | 584 | #ifdef OCCT_DEBUG |
7fd59977 | 585 | if(tSPS) GdumpSHASTA(iF,TB1,WES,"--- GFillFaceWES","END"); |
586 | #endif | |
587 | ||
588 | return; | |
589 | } // GFillFaceWES | |
590 | ||
591 | //======================================================================= | |
592 | //function : GFillWireWES | |
593 | //purpose : | |
594 | //======================================================================= | |
595 | void TopOpeBRepBuild_Builder::GFillWireWES(const TopoDS_Shape& W, | |
596 | const TopTools_ListOfShape& LSclass, | |
597 | const TopOpeBRepBuild_GTopo& G1, | |
598 | TopOpeBRepBuild_WireEdgeSet& WES) | |
599 | { | |
600 | TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); | |
601 | ||
0797d9d3 | 602 | #ifdef OCCT_DEBUG |
7fd59977 | 603 | Standard_Integer iW; Standard_Boolean tSPS = GtraceSPS(W,iW); |
604 | if(tSPS){ | |
605 | cout<<endl;DEBSHASET(s,"--- GFillWireWES ",WES," "); | |
606 | GdumpSHA(W,(Standard_Address)s.ToCString()); cout<<endl; | |
607 | Standard_Integer nbe = 0; | |
608 | TopOpeBRepTool_ShapeExplorer exE(W,TopAbs_EDGE);for (;exE.More(); exE.Next()) nbe++; | |
609 | cout<<"--- GFillWireWES on W "<<iW<<" with "<<nbe<<" edges "<<endl; | |
610 | debfillw(iW); | |
611 | } | |
612 | GLOBAL_iexE = 0; | |
613 | #endif | |
614 | ||
615 | TopOpeBRepTool_ShapeExplorer exEdge(W,TopAbs_EDGE); | |
616 | for (; exEdge.More(); exEdge.Next()) { | |
617 | const TopoDS_Shape& EOR = exEdge.Current(); | |
618 | ||
0797d9d3 | 619 | #ifdef OCCT_DEBUG |
7fd59977 | 620 | GLOBAL_iexE++; |
621 | if (tSPS) { | |
622 | // const TopoDS_Edge& ed = TopoDS::Edge(EOR); | |
623 | // Standard_Boolean isdegen = BRep_Tool::Degenerated(ed); | |
624 | // TopLoc_Location L; | |
625 | // Handle(Geom_Surface) S = BRep_Tool::Surface(myFaceToFill,L); | |
626 | // Standard_Boolean isclosed = BRep_Tool::IsClosed(ed,S,L); | |
627 | // TopAbs_Orientation oried = ed.Orientation(); | |
628 | // Standard_Boolean trc = Standard_False; | |
629 | #ifdef DRAW | |
630 | // if (trc) {FUN_draw(ed); FUN_draw2de(ed,myFaceReference);} | |
631 | #endif | |
632 | } | |
633 | #endif | |
634 | ||
635 | GFillEdgeWES(EOR,LSclass,G1,WES); | |
636 | } | |
637 | } // GFillWireWES | |
638 | ||
639 | ||
640 | //======================================================================= | |
641 | //function : GFillEdgeWES | |
642 | //purpose : | |
643 | //======================================================================= | |
644 | void TopOpeBRepBuild_Builder::GFillEdgeWES(const TopoDS_Shape& EOR, | |
645 | const TopTools_ListOfShape& LSclass, | |
646 | const TopOpeBRepBuild_GTopo& G1, | |
647 | TopOpeBRepBuild_WireEdgeSet& WES) | |
648 | { | |
649 | TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); | |
650 | ||
0797d9d3 | 651 | #ifdef OCCT_DEBUG |
7fd59977 | 652 | Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(EOR,iE); |
653 | if(tSPS)cout<<endl; | |
654 | #endif | |
655 | ||
0797d9d3 | 656 | #ifdef OCCT_DEBUG |
7fd59977 | 657 | Standard_Boolean tosplit = |
658 | #endif | |
659 | GToSplit(EOR,TB1); | |
0797d9d3 | 660 | #ifdef OCCT_DEBUG |
7fd59977 | 661 | Standard_Boolean tomerge = |
662 | #endif | |
663 | GToMerge(EOR); | |
664 | ||
0797d9d3 | 665 | #ifdef OCCT_DEBUG |
7fd59977 | 666 | if(tSPS) GdumpSHASTA(iE,TB1,WES,"--- GFillEdgeWES "); |
667 | if(tSPS) cout<<" tosplit "<<tosplit<<" tomerge "<<tomerge<<endl; | |
668 | if(tSPS) debfille(iE); | |
669 | #endif | |
670 | ||
671 | TopOpeBRepBuild_GTopo GME = G1; | |
672 | GMergeEdgeWES(EOR,GME,WES); | |
673 | ||
674 | TopOpeBRepBuild_GTopo GSE = G1; | |
675 | GSE.ChangeConfig(TopOpeBRepDS_UNSHGEOMETRY,TopOpeBRepDS_UNSHGEOMETRY); | |
676 | GSplitEdgeWES(EOR,LSclass,GSE,WES); | |
677 | ||
678 | } // GFillEdgeWES | |
679 | ||
680 | static void FUN_samgeomori(const TopOpeBRepDS_DataStructure& BDS, const Standard_Integer iref, const Standard_Integer ifil, | |
681 | Standard_Boolean& samgeomori) | |
682 | { | |
683 | TopOpeBRepDS_Config cfill = BDS.SameDomainOri(ifil); | |
684 | TopAbs_Orientation oref=BDS.Shape(iref).Orientation(), ofil=BDS.Shape(ifil).Orientation(); | |
685 | samgeomori = (cfill == TopOpeBRepDS_SAMEORIENTED); | |
686 | if (oref == TopAbs::Complement(ofil)) samgeomori = !samgeomori; | |
687 | } | |
688 | ||
689 | #define UNKNOWN (0) | |
690 | #define ONSAMESHA (1) | |
691 | #define CLOSESAME (11) | |
692 | #define ONOPPOSHA (2) | |
693 | #define CLOSEOPPO (22) | |
694 | #define FORREVOPPO (222) | |
695 | ||
696 | //======================================================================= | |
697 | //function : GSplitEdgeWES | |
698 | //purpose : | |
699 | //======================================================================= | |
700 | void TopOpeBRepBuild_Builder::GSplitEdgeWES(const TopoDS_Shape& EOR, | |
701 | const TopTools_ListOfShape& LSclass, | |
702 | const TopOpeBRepBuild_GTopo& G1, | |
703 | TopOpeBRepBuild_WireEdgeSet& WES) | |
704 | { | |
705 | TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); | |
706 | Standard_Boolean RevOri1 = G1.IsToReverse1(); | |
707 | TopAbs_Orientation oriE = EOR.Orientation(); | |
708 | TopAbs_Orientation neworiE = Orient(oriE,RevOri1); | |
709 | const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); | |
710 | ||
711 | TopAbs_Orientation oEinF; | |
712 | Standard_Integer Oinref = 0; | |
713 | Standard_Boolean hsdm = myDataStructure->HasSameDomain(myFaceToFill); | |
714 | Standard_Boolean hsdmE = myDataStructure->HasSameDomain(EOR); | |
715 | Standard_Integer ifil = myDataStructure->Shape(myFaceToFill); | |
716 | Standard_Integer iref = myDataStructure->Shape(myFaceReference); | |
717 | if (hsdm) { | |
718 | Oinref = FUN_ds_oriEinF(BDS,TopoDS::Edge(EOR),myFaceReference,oEinF); //xpu060598 | |
719 | ||
720 | // xpu150998 : cto900P6 : e35ou added to fref34,f53, oEinF=REVERSED, oEinfill=FORWARD | |
721 | TopAbs_Orientation oEinfill; | |
722 | Standard_Integer Oinfill = FUN_ds_oriEinF(BDS,TopoDS::Edge(EOR),myFaceToFill,oEinfill); | |
723 | if (Oinref == Oinfill) { | |
724 | ||
725 | Standard_Boolean reverse = Standard_False; | |
726 | if (iref != ifil) { | |
727 | // xpu230299 : FRA60275 (e6,fref4,ffill7) + PRO16297 | |
728 | TopAbs_Orientation oref = myFaceReference.Orientation(); | |
729 | Standard_Boolean samegeomori; FUN_samgeomori(BDS,iref,ifil,samegeomori); | |
730 | reverse = (!samegeomori); | |
731 | if (oref == TopAbs_REVERSED) reverse = !reverse; | |
732 | } | |
733 | // TopAbs_Orientation oref=myFaceReference.Orientation(), ofill=myFaceToFill.Orientation(); | |
734 | // Standard_Boolean reverse = (oref != ofill); | |
735 | ||
736 | TopAbs_Orientation oEinfillTOref = reverse ? TopAbs::Complement(oEinfill) : oEinfill; | |
737 | Standard_Boolean same = (oEinF == oEinfillTOref); | |
738 | if (!same && (oEinF!=TopAbs_INTERNAL) && (oEinF!=TopAbs_EXTERNAL)) oEinF = oEinfillTOref; | |
739 | } | |
740 | } | |
741 | else Oinref = FUN_ds_oriEinF(BDS,TopoDS::Edge(EOR),myFaceToFill,oEinF); //xpu060598 | |
742 | Standard_Boolean newO = (Oinref == ONSAMESHA) || (Oinref == ONOPPOSHA); //xpu060598 | |
743 | ||
744 | Standard_Boolean isfafa = (myIsKPart == 3); | |
745 | if (isfafa) newO = Standard_False;// xpu110598 | |
746 | ||
747 | // if (fus) : faces are SDSO : we keep original edge's orientation | |
748 | // if (com) : faces are SDSO : we keep original edge's orientation | |
749 | // if (cut && TBToFill==OUT) : myFaceToFill is the reference face, | |
750 | // we keep original edge's orientation | |
751 | ||
0797d9d3 | 752 | #ifdef OCCT_DEBUG |
7fd59977 | 753 | Standard_Integer iEOR; Standard_Boolean tSPS = GtraceSPS(EOR,iEOR); |
754 | Standard_Integer iWESF; /*Standard_Boolean tSPSW = */GtraceSPS(WES.Face(),iWESF); | |
755 | if(tSPS) GdumpSHASTA(iEOR,TB1,WES,"\n--- GSplitEdgeWES","START"); | |
756 | if(tSPS) cout<<" RevOri1 : "<<RevOri1<<endl; | |
757 | if(tSPS) debsplite(iEOR); | |
758 | #endif | |
759 | ||
760 | Standard_Boolean tosplit = GToSplit(EOR,TB1); | |
761 | if (tosplit) { | |
762 | GSplitEdge(EOR,G1,LSclass); | |
763 | //modified by NIZNHY-PKV Mon Mar 19 16:53:40 2001 f | |
764 | if (myIsKPart==4) { | |
765 | // Only solids are available here | |
766 | TopAbs_State aState; | |
767 | Standard_Integer aRank1; | |
768 | TopTools_ListOfShape anAuxList; | |
769 | ||
770 | aRank1=ShapeRank(EOR); | |
771 | const TopoDS_Shape& aSolid=(aRank1==1) ? myShape2 : myShape1; | |
772 | ||
773 | TopTools_ListOfShape& aSplitList = ChangeSplit (EOR, TB1); | |
774 | TopTools_ListIteratorOfListOfShape anIt(aSplitList); | |
775 | for (; anIt.More(); anIt.Next()) { | |
776 | const TopoDS_Edge& aSplitEdge=TopoDS::Edge (anIt.Value()); | |
777 | aState=ClassifyEdgeToSolidByOnePoint (aSplitEdge, aSolid); | |
778 | if (aState==TB1) { | |
779 | anAuxList.Append (aSplitEdge); | |
780 | } | |
781 | } | |
782 | ||
783 | aSplitList.Clear(); | |
784 | ||
785 | anIt.Initialize(anAuxList); | |
786 | for (; anIt.More(); anIt.Next()) { | |
787 | const TopoDS_Shape& aShape=anIt.Value(); | |
788 | aSplitList.Append(aShape); | |
789 | } | |
790 | } | |
791 | //modified by NIZNHY-PKV Mon Mar 19 16:53:44 2001 t | |
792 | } | |
793 | ||
794 | //xpu200598 : never add spIN in fusion | |
795 | Standard_Boolean opeFus = Opefus(); //xpu200598 | |
796 | if (opeFus) //xpu200598 | |
797 | if (TB1 == TopAbs_IN) return; //xpu200598 | |
798 | ||
799 | Standard_Boolean issplit = IsSplit(EOR,TB1); | |
800 | if ( issplit ) { | |
801 | const TopTools_ListOfShape& LSE = Splits(EOR,TB1); | |
802 | ||
0797d9d3 | 803 | #ifdef OCCT_DEBUG |
7fd59977 | 804 | if(tSPS) { |
805 | GdumpSHASTA(iEOR,TB1,WES,"--- GSplitEdgeWES","WES+ Split"); | |
806 | cout<<" ";TopAbs::Print(TB1,cout)<<" : "<<LSE.Extent()<<" edge(s) "; | |
807 | TopAbs::Print(neworiE,cout); cout<<endl; | |
808 | } | |
809 | #endif | |
810 | ||
811 | for (TopTools_ListIteratorOfListOfShape it(LSE); | |
812 | it.More(); it.Next()) { | |
813 | TopoDS_Edge newE = TopoDS::Edge(it.Value()); | |
814 | if (newO) {// xpu060598 | |
815 | // PRO13075 tspIN(f18), tspIN(e17) | |
816 | // we add sp(EOR) to myFaceToFill with its orientation | |
817 | newE.Orientation(oEinF); | |
818 | Standard_Boolean dgE = BRep_Tool::Degenerated(TopoDS::Edge(EOR)); | |
819 | if (!dgE && hsdmE) { | |
820 | Standard_Real f,l; FUN_tool_bounds(newE,f,l); | |
821 | Standard_Real x = 0.45678; Standard_Real par = (1-x)*f + x*l; | |
822 | Standard_Boolean so = Standard_True; | |
823 | Standard_Boolean ok = FUN_tool_curvesSO(newE,par,TopoDS::Edge(EOR),so); | |
824 | if (!ok) { | |
0797d9d3 | 825 | #ifdef OCCT_DEBUG |
7fd59977 | 826 | cout<<"GSplitEdgeWES: cannot orient SDM split of an edge"<<endl; |
827 | #endif | |
828 | //return; // nyiFUNRAISE | |
829 | } | |
830 | if (!so) { | |
831 | newE.Reverse(); | |
832 | } | |
833 | } //!dgE && hsdmE | |
834 | }// xpu060598 | |
835 | else newE.Orientation(neworiE); | |
836 | ||
0797d9d3 | 837 | #ifdef OCCT_DEBUG |
7fd59977 | 838 | if (tSPS) debaddpwes(iWESF,TB1,iEOR,neworiE,(TopOpeBRepBuild_Builder* const)this,&WES,"GSplitEdgeWES " ,"WES+ Eisspl "); |
839 | #endif | |
840 | ||
841 | WES.AddStartElement(newE); | |
842 | } | |
843 | } // issplit | |
844 | ||
845 | else { | |
846 | // EOR sans devenir de Split par TB1 : on la garde si elle est situee TB1 / LSclass | |
847 | Standard_Boolean se = BDS.IsSectionEdge(TopoDS::Edge(EOR)); | |
848 | Standard_Boolean hs = myDataStructure->HasShape(EOR); | |
849 | Standard_Boolean hg = myDataStructure->HasGeometry(EOR); | |
850 | Standard_Boolean add = Standard_False; | |
851 | Standard_Boolean addON = Standard_False; | |
852 | ||
853 | Standard_Boolean isstart = Standard_False; | |
854 | isstart = hs; | |
855 | ||
856 | if (se) { | |
857 | Standard_Boolean ftg = !LSclass.IsEmpty(); | |
858 | TopAbs_ShapeEnum tclass = LSclass.First().ShapeType(); | |
859 | ftg = ftg && (tclass == TopAbs_FACE); | |
860 | if (!ftg) { | |
861 | TopAbs_State pos; | |
862 | Standard_Boolean keepse = GKeepShape1(EOR,LSclass,TB1,pos); | |
863 | if (keepse) | |
864 | add = Standard_True; | |
865 | else if (myProcessON && pos == TopAbs_ON) | |
866 | addON = Standard_True; | |
867 | } | |
868 | ||
0797d9d3 | 869 | #ifdef OCCT_DEBUG |
7fd59977 | 870 | cout<<"o-o GridFF ffil F"<<ifil<<" se E"<<iEOR<<" / "<<iWESF<<" "; |
871 | TopAbs::Print(TB1,cout);cout.flush(); | |
872 | Standard_Boolean tse = TopOpeBRepDS_GettraceSPSX(iEOR); | |
873 | TopOpeBRepDS_SettraceSPSX(iEOR,Standard_True); | |
874 | if (!ftg) {cout<<" : !ftg --> "; GKeepShape(EOR,LSclass,TB1);cout.flush();} | |
875 | else {cout<<" : ftg --> non gardee"<<endl;cout.flush();} | |
876 | TopOpeBRepDS_SettraceSPSX(iEOR,tse); | |
877 | #endif | |
878 | ||
879 | } | |
880 | else { | |
881 | add = Standard_True; | |
882 | Standard_Boolean testkeep = Standard_True; | |
883 | testkeep = hs && (!hg); | |
884 | if (testkeep) { | |
0797d9d3 | 885 | #ifdef OCCT_DEBUG |
7fd59977 | 886 | if(tSPS){cout<<"--- GSplitEdgeWES ";} |
887 | #endif | |
888 | TopAbs_State pos; | |
889 | Standard_Boolean keep = GKeepShape1(EOR,LSclass,TB1,pos); | |
890 | if ( !keep ) { | |
891 | Standard_Boolean testON = (!LSclass.IsEmpty()); | |
892 | if (testON) testON = (LSclass.First().ShapeType() == TopAbs_SOLID); | |
893 | if (testON) keep = (pos == TopAbs_ON); | |
894 | addON = myProcessON && keep; | |
895 | } | |
896 | add = keep; | |
897 | } | |
898 | } // !se | |
899 | ||
900 | if (add) { | |
901 | TopoDS_Shape newE = EOR; | |
902 | ||
903 | if (newO) newE.Orientation(oEinF);// xpu060598 | |
904 | else if (Oinref == FORREVOPPO) newE.Orientation(TopAbs_INTERNAL);// xpu120898 (PRO14785 : e36 shared by f34 & f39, | |
905 | // faces sdm with f16) | |
906 | else newE.Orientation(neworiE); | |
0797d9d3 | 907 | #ifdef OCCT_DEBUG |
7fd59977 | 908 | if(tSPS){ |
909 | DEBSHASET(ss,"--- GSplitEdgeWES ",WES," WES+ edge "); | |
910 | GdumpSHA(newE,(Standard_Address)ss.ToCString()); | |
911 | cout<<" ";TopAbs::Print(TB1,cout)<<" : 1 edge "; | |
912 | TopAbs::Print(neworiE,cout); cout<<endl; | |
913 | } | |
914 | #endif | |
915 | ||
916 | if (isstart) { | |
0797d9d3 | 917 | #ifdef OCCT_DEBUG |
7fd59977 | 918 | if (tSPS) debaddpwes(iWESF,TB1,iEOR,neworiE,(TopOpeBRepBuild_Builder* const)this,&WES,"GSplitEdgeWES " ,"WES+ Enospl "); |
919 | #endif | |
920 | WES.AddStartElement(newE); | |
921 | } | |
922 | else { | |
923 | WES.AddElement(newE); | |
924 | } | |
925 | } // add | |
926 | ||
927 | if (addON) { | |
928 | TopoDS_Shape newE = EOR; | |
929 | newE.Orientation(neworiE); | |
930 | myONElemMap.Add(newE); | |
931 | } | |
932 | } // !issplit | |
933 | ||
934 | if (myProcessON && IsSplit(EOR,TopAbs_ON)) { | |
935 | const TopTools_ListOfShape& LSE = Splits(EOR,TopAbs_ON); | |
936 | TopTools_ListIteratorOfListOfShape it(LSE); | |
937 | for (; it.More(); it.Next()) { | |
938 | TopoDS_Edge newE = TopoDS::Edge(it.Value()); | |
939 | if (newO) { | |
940 | newE.Orientation(oEinF); | |
941 | Standard_Boolean dgE = BRep_Tool::Degenerated(TopoDS::Edge(EOR)); | |
942 | if (!dgE && hsdmE) { | |
943 | Standard_Real f,l; FUN_tool_bounds(newE,f,l); | |
944 | Standard_Real x = 0.45678; Standard_Real par = (1-x)*f + x*l; | |
945 | Standard_Boolean so = Standard_True; | |
946 | Standard_Boolean ok = FUN_tool_curvesSO(newE,par,TopoDS::Edge(EOR),so); | |
947 | if (!ok) { | |
0797d9d3 | 948 | #ifdef OCCT_DEBUG |
7fd59977 | 949 | cout<<"GSplitEdgeWES: cannot orient SDM split of an edge"<<endl; |
950 | #endif | |
951 | } | |
952 | if (!so) newE.Reverse(); | |
953 | } | |
954 | } | |
955 | else newE.Orientation(neworiE); | |
956 | myONElemMap.Add(newE); | |
957 | } | |
958 | } | |
959 | ||
0797d9d3 | 960 | #ifdef OCCT_DEBUG |
7fd59977 | 961 | if(tSPS) GdumpSHASTA(iEOR,TB1,WES,"--- GSplitEdgeWES","END"); |
962 | #endif | |
963 | ||
964 | return; | |
965 | } // GSplitEdgeWES | |
966 | ||
967 | Standard_IMPORT Standard_Boolean FUN_ismotheropedef(); | |
968 | Standard_IMPORT const TopOpeBRepBuild_GTopo& FUN_motherope(); | |
969 | Standard_EXPORT Standard_Boolean GLOBAL_IEtoMERGE = 0; // xpu240498 | |
970 | ||
0797d9d3 | 971 | #ifdef OCCT_DEBUG |
7fd59977 | 972 | void debmergee(const Standard_Integer /*i*/) {} |
973 | #endif | |
974 | ||
975 | //======================================================================= | |
976 | //function : GMergeEdgeWES | |
977 | //purpose : | |
978 | //======================================================================= | |
979 | void TopOpeBRepBuild_Builder::GMergeEdgeWES(const TopoDS_Shape& EOR, | |
980 | const TopOpeBRepBuild_GTopo& G1, | |
981 | TopOpeBRepBuild_WireEdgeSet& WES) | |
982 | { | |
0797d9d3 | 983 | #ifdef OCCT_DEBUG |
7fd59977 | 984 | Standard_Integer iWESF; /*Standard_Boolean tSPSW = */GtraceSPS(WES.Face(),iWESF); |
985 | Standard_Integer iEOR; Standard_Boolean tSPS = GtraceSPS(EOR,iEOR); | |
986 | if(tSPS){ debmergee(iEOR); | |
987 | DEBSHASET(s,"\n--- GMergeEdgeWES ",WES," START "); | |
988 | GdumpSHAORIGEO(EOR,(Standard_Address)s.ToCString()); cout<<endl; | |
989 | } | |
990 | #endif | |
991 | ||
992 | Standard_Boolean closing = BRep_Tool::IsClosed(TopoDS::Edge(EOR),myFaceToFill); // xpu050598 | |
993 | if (closing) return; // xpu050598 | |
994 | ||
995 | if (Opefus()) return; | |
996 | ||
997 | // const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); | |
998 | TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); | |
999 | Standard_Boolean RevOri1 = G1.IsToReverse1(); | |
1000 | TopAbs_Orientation oriE = EOR.Orientation(); | |
1001 | TopAbs_Orientation neworiE = Orient(oriE,RevOri1); | |
1002 | ||
1003 | Standard_Boolean hassame = myDataStructure->HasSameDomain(EOR); | |
1004 | if (!hassame) return; | |
1005 | ||
1006 | Standard_Boolean Eisref = Standard_False; | |
1007 | if (hassame) { | |
1008 | Standard_Integer iEref = myDataStructure->SameDomainReference(EOR); | |
1009 | const TopoDS_Shape& Eref = myDataStructure->Shape(iEref); | |
1010 | Eisref = EOR.IsSame(Eref); | |
1011 | } | |
1012 | ||
1013 | TopAbs_State TBEOR = (Eisref) ? TB1 : TB2; | |
1014 | if (TBEOR == TopAbs_OUT) return; //xpu040598 | |
1015 | ||
1016 | Standard_Boolean ismerged = IsMerged(EOR,TBEOR); | |
1017 | if (ismerged) { | |
1018 | if (!Eisref) return; | |
1019 | ||
1020 | const TopTools_ListOfShape& ME = Merged(EOR,TBEOR); | |
1021 | TopTools_ListIteratorOfListOfShape it(ME); | |
1022 | for(; it.More(); it.Next()) { | |
1023 | TopoDS_Shape newE = it.Value(); | |
1024 | newE.Orientation(neworiE); | |
1025 | ||
0797d9d3 | 1026 | #ifdef OCCT_DEBUG |
7fd59977 | 1027 | if (tSPS) debaddpwes(iWESF,TB1,iEOR,neworiE,(TopOpeBRepBuild_Builder* const)this,&WES,"GMergeEdgeWES " ,"WES+ Emerge "); |
1028 | #endif | |
1029 | ||
1030 | WES.AddStartElement(newE); | |
1031 | } | |
1032 | return; | |
1033 | } | |
1034 | ||
1035 | ChangeMerged(EOR,TBEOR) = myEmptyShapeList; | |
1036 | TopAbs_State stspEOR; | |
1037 | // if (isfafa) stspEOR = TBEOR; // xpu110598 | |
1038 | // else stspEOR = (TBEOR == TopAbs_IN) ? TopAbs_ON : TopAbs_OUT; | |
1039 | stspEOR = TBEOR; // xpu120598 | |
1040 | ||
1041 | Standard_Boolean issplit = IsSplit(EOR,stspEOR); | |
1042 | if (!issplit) return; | |
1043 | ||
1044 | ChangeMerged(EOR,TBEOR) = Splits(EOR,stspEOR); | |
1045 | ||
1046 | const TopTools_ListOfShape& ME = Merged(EOR,TBEOR); | |
0797d9d3 | 1047 | #ifdef OCCT_DEBUG |
7fd59977 | 1048 | if(tSPS){ |
1049 | DEBSHASET(s,"GMergeEdgeWES(1) ",WES," WES+ Merged "); | |
1050 | GdumpSHA(EOR,(Standard_Address)s.ToCString()); | |
1051 | cout<<" ";TopAbs::Print(TBEOR,cout); | |
1052 | cout<<" : "<<ME.Extent()<<" edge"<<endl; | |
1053 | } | |
1054 | #endif | |
1055 | for(TopTools_ListIteratorOfListOfShape it(ME);it.More();it.Next()) { | |
1056 | TopoDS_Shape newE = it.Value(); | |
1057 | newE.Orientation(neworiE); | |
1058 | WES.AddStartElement(newE); | |
1059 | } | |
1060 | ||
0797d9d3 | 1061 | #ifdef OCCT_DEBUG |
7fd59977 | 1062 | if(tSPS){ |
1063 | DEBSHASET(sss,"GMergeEdgeWES ",WES," END "); | |
1064 | GdumpSHA(EOR,(Standard_Address)sss.ToCString());cout<<endl; | |
1065 | } | |
1066 | #endif | |
1067 | ||
1068 | } // GMergeEdgeWES | |
1069 | ||
1070 | //======================================================================= | |
1071 | //function : GSplitEdge | |
1072 | //purpose : | |
1073 | //======================================================================= | |
1074 | void TopOpeBRepBuild_Builder::GSplitEdge(const TopoDS_Shape& EOR, | |
1075 | const TopOpeBRepBuild_GTopo& G1, | |
1076 | const TopTools_ListOfShape& LSclass) | |
1077 | { | |
96a95605 DB |
1078 | TopAbs_ShapeEnum t1,t2; |
1079 | G1.Type(t1,t2); | |
7fd59977 | 1080 | TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); |
1081 | // work on a FORWARD edge <EF> | |
1082 | TopoDS_Shape EF = EOR; EF.Orientation(TopAbs_FORWARD); | |
1083 | ||
0797d9d3 | 1084 | #ifdef OCCT_DEBUG |
7fd59977 | 1085 | Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(EOR,iE); |
1086 | if (tSPS) GdumpSHASTA(EOR,TB1,"--- GSplitEdge ","\n"); | |
1087 | if (tSPS) GdumpEDG(EF); | |
1088 | if (tSPS) debsplite(iE); | |
1089 | #endif | |
1090 | ||
1091 | const TopoDS_Edge& EEF = TopoDS::Edge(EF); | |
1092 | Standard_Boolean isse = myDataStructure->DS().IsSectionEdge(EEF); | |
1093 | Standard_Boolean issplitON = IsSplit(EEF,TopAbs_ON); | |
1094 | Standard_Boolean takeON = (TB1 == TopAbs_IN) && (isse) && (issplitON); | |
1095 | takeON = Standard_False; | |
0797d9d3 | 1096 | #ifdef OCCT_DEBUG |
7fd59977 | 1097 | if (tSPS) cout<<"---- takeON mis a 0"<<endl; |
1098 | #endif | |
1099 | ||
1100 | if ( takeON ) { | |
1101 | ||
0797d9d3 | 1102 | #ifdef OCCT_DEBUG |
7fd59977 | 1103 | if (tSPS) GdumpSHASTA(EOR,TB1,"--- GSplitEdge takeON ","\n"); |
1104 | #endif | |
1105 | ||
1106 | MarkSplit(EF,TB1); | |
1107 | TopTools_ListOfShape& SSEL = ChangeSplit(EF,TB1); | |
1108 | SSEL.Clear(); | |
1109 | SSEL = Splits(EEF,TopAbs_ON); | |
1110 | return; | |
1111 | } | |
1112 | ||
1113 | TopTools_ListOfShape LOE; | |
1114 | ||
1115 | // Make a PaveSet PVS on edge EF | |
1116 | TopOpeBRepBuild_PaveSet PVS(EF); | |
1117 | ||
1118 | // Add the point topology found on edge EF in PVS | |
1119 | myEdgeReference = TopoDS::Edge(EF); | |
1120 | GFillPointTopologyPVS(EF,G1,PVS); | |
1121 | ||
1122 | // mark EF as split TB1 | |
1123 | MarkSplit(EF,TB1); | |
1124 | ||
1125 | // build the new edges LOE on EF from the Parametrized Vertex set PVS | |
1126 | GPVSMakeEdges(EF,PVS,LOE); | |
1127 | ||
1128 | Standard_Boolean novertex = LOE.IsEmpty(); | |
1129 | if (novertex) return; | |
1130 | ||
1131 | TopTools_ListOfShape& SEL = ChangeSplit(EF,TB1); | |
1132 | SEL.Clear(); | |
1133 | // NYI ne pas faire de classification des aretes reconstruites / liste de solides | |
1134 | // NYI dans le cas ou l'appel a SplitEdge est utilise pour construire les parties | |
1135 | // NYI (TopAbs_ON,SOLID) (i.e par la construction des parties (TopAbs_IN,FACE)). | |
1136 | TopOpeBRepDS_Config c1 = G1.Config1(),c2 = G1.Config2(); | |
1137 | Standard_Boolean UUFACE = (c1==TopOpeBRepDS_UNSHGEOMETRY && c2==TopOpeBRepDS_UNSHGEOMETRY); | |
1138 | ||
1139 | Standard_Boolean ONSOLID = Standard_False; | |
1140 | if ( ! LSclass.IsEmpty() ) { | |
1141 | TopAbs_ShapeEnum t = LSclass.First().ShapeType(); | |
1142 | ONSOLID = (t == TopAbs_SOLID); | |
1143 | } | |
1144 | ||
1145 | Standard_Boolean toclass = UUFACE; | |
1146 | toclass = ! ONSOLID; | |
1147 | ||
1148 | TopTools_ListOfShape loos; | |
1149 | const TopTools_ListOfShape* pls; | |
1150 | if (GLOBAL_classifysplitedge) { | |
1151 | Standard_Integer r=GShapeRank(EOR); | |
1152 | TopoDS_Shape oos=myShape1; | |
1153 | if (r==1) oos = myShape2; | |
1154 | if (!oos.IsNull()) loos.Append(oos); // PMN 5/03/99 Nothing to append | |
1155 | pls = &loos; | |
1156 | } | |
1157 | else if (toclass) { | |
1158 | pls = &LSclass; | |
1159 | } | |
1160 | else { | |
1161 | pls = &myEmptyShapeList; | |
1162 | } | |
1163 | ||
1164 | TopTools_ListOfShape aLON; | |
1165 | TopTools_ListIteratorOfListOfShape it(LOE); | |
1166 | for(;it.More();it.Next()) { | |
1167 | const TopoDS_Shape& aE = it.Value(); | |
1168 | TopAbs_State pos; | |
1169 | if (GKeepShape1(aE,*pls,TB1,pos)) | |
1170 | SEL.Append(aE); | |
1171 | else if (myProcessON && pos == TopAbs_ON) | |
1172 | aLON.Append(aE); | |
1173 | } | |
1174 | ||
1175 | if (!aLON.IsEmpty()) { | |
1176 | MarkSplit(EF,TopAbs_ON); | |
1177 | TopTools_ListOfShape& aSLON = ChangeSplit(EF,TopAbs_ON); | |
1178 | aSLON.Clear(); | |
1179 | aSLON.Append(aLON); | |
1180 | } | |
1181 | ||
1182 | } // GSplitEdge | |
1183 | ||
1184 | //modified by NIZNHY-PKV Mon Mar 19 16:50:33 2001 f | |
1185 | #include <BRepClass3d_SolidClassifier.hxx> | |
1186 | //======================================================================= | |
1187 | //function : ClassifyEdgeToSolidByOnePoint | |
1188 | //purpose : | |
1189 | //======================================================================= | |
1190 | TopAbs_State ClassifyEdgeToSolidByOnePoint(const TopoDS_Edge& E, | |
1191 | const TopoDS_Shape& Ref) | |
1192 | { | |
1193 | const Standard_Real PAR_T = 0.43213918;//10.*e^-PI | |
1194 | Standard_Real f2 = 0., l2 = 0., par = 0.; | |
1195 | ||
1196 | Handle(Geom_Curve) C3D = BRep_Tool::Curve(E, f2, l2); | |
1197 | gp_Pnt aP3d; | |
1198 | ||
1199 | if(C3D.IsNull()) { | |
1200 | //it means that we are in degenerated edge | |
1201 | const TopoDS_Vertex& fv = TopExp::FirstVertex(E); | |
1202 | if(fv.IsNull()) | |
1203 | return TopAbs_UNKNOWN; | |
1204 | aP3d = BRep_Tool::Pnt(fv); | |
1205 | } | |
1206 | else {//usual case | |
1207 | par = f2*PAR_T + (1 - PAR_T)*l2; | |
1208 | C3D -> D0(par, aP3d); | |
1209 | } | |
1210 | ||
1211 | BRepClass3d_SolidClassifier SC(Ref); | |
1212 | SC.Perform(aP3d, 1e-7); | |
1213 | ||
1214 | return SC.State(); | |
1215 | } | |
1216 | //modified by NIZNHY-PKV Mon Mar 19 16:50:36 2001 t |