1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROData_SplitToZonesTool.h"
21 #include "HYDROData_PolylineXY.h"
22 #include "HYDROData_ShapesGroup.h"
23 #include <HYDROData_Transform.h>
24 #include <BRepAlgoAPI_Cut.hxx>
25 #include <BRepAlgoAPI_Common.hxx>
26 #include <BRepBuilderAPI_MakeFace.hxx>
27 #include <BRep_Builder.hxx>
28 #include <TopExp_Explorer.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TopoDS_Compound.hxx>
32 #include <TopoDS_Wire.hxx>
33 #include <TopoDS_Edge.hxx>
34 #include <BRepCheck_Analyzer.hxx>
35 #include <TopTools_ListOfShape.hxx>
36 #include <TopTools_ListIteratorOfListOfShape.hxx>
38 #include <BRepGProp.hxx>
39 #include <GProp_GProps.hxx>
40 #include <Geom_Plane.hxx>
41 #include <BRepBuilderAPI_FindPlane.hxx>
43 #include <BOPAlgo_BOP.hxx>
44 #include <BOPAlgo_Builder.hxx>
46 //#define DEB_SPLIT_TO_ZONES 1
47 //#define DEB_SPLIT_TO_ZONES_CHECK_PARTITION 1
48 #if (defined (DEB_SPLIT_TO_ZONES) || defined(DEB_SPLIT_TO_ZONES_CHECK_PARTITION))
49 #include <BRepTools.hxx>
50 static TCollection_AsciiString fileNameBefore("BeforeTranslation");
54 #include "HYDRO_trace.hxx"
56 TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const
62 if ( Shape.ShapeType() == TopAbs_FACE )
64 aResFace = TopoDS::Face( Shape );
66 else if ( Shape.ShapeType() == TopAbs_WIRE )
68 BRepBuilderAPI_MakeFace aMakeFace( TopoDS::Wire( Shape ), Standard_True );
70 if( aMakeFace.IsDone() )
71 aResFace = aMakeFace.Face();
78 Standard_Boolean buildLimFace(const TopoDS_Wire& theBndWire, TopoDS_Face& outFace)
81 BRepGProp::LinearProperties(theBndWire,G);
82 const gp_Pnt& aCPnt = G.CentreOfMass();
84 BRepBuilderAPI_FindPlane fndPlane (theBndWire, Precision::Confusion());
86 aPln = fndPlane.Plane()->Pln();
88 aPln = gp_Pln(aCPnt, gp::OZ().Direction());
89 BRepBuilderAPI_MakeFace aMkFace(aPln, theBndWire);
90 if(aMkFace.IsDone()) {
91 outFace = aMkFace.Face();
92 if(!outFace.IsNull()) {
93 #ifdef DEB_SPLIT_TO_ZONES
94 // BRepTools::Write(limFace,"FL.brep");
99 return Standard_False;
101 //======================================================================================
103 void HYDROData_SplitToZonesTool::SetFileNames(const QString& theNameBefore, const QString& theNameAfter)
105 #ifdef DEB_SPLIT_TO_ZONES_CHECK_PARTITION
106 if(!theNameBefore.isNull() && !theNameBefore.isEmpty())
108 TCollection_AsciiString aName (theNameBefore.toStdString().data());
109 fileNameBefore = aName;
111 if(!theNameAfter.isNull() && !theNameAfter.isEmpty())
113 TCollection_AsciiString aName (theNameAfter.toStdString().data());
114 HYDROData_Transform::SetFileName (aName);
118 //======================================================================================
119 Standard_Integer HYDROData_SplitToZonesTool::SplitFaces(const TopoDS_Compound& theComp,
120 HYDROData_Transform& theTool)
123 theTool.SetArgument(theComp);
125 const Standard_Boolean bToTransform = theTool.ToTransform();
126 theTool.SetToTransform(bToTransform);
128 Standard_Integer anErr = theTool.ErrorStatus();
132 //======================================================================================
133 HYDROData_SplitToZonesTool::SplitDataList
134 HYDROData_SplitToZonesTool::Split( const HYDROData_SequenceOfObjects& theObjectList,
135 const HYDROData_SequenceOfObjects& theGroupsList,
136 const Handle(HYDROData_PolylineXY)& thePolyline,
137 const HYDROData_SequenceOfObjects& InterPolys)
140 SplitDataList anOutputSplitDataList;
141 if(theObjectList.IsEmpty()) return anOutputSplitDataList;
143 // Collect the object shapes to split. InputDataList will contain elements which will hold shape & name_of_shape.
144 SplitDataList anInputSplitDataList;
145 #ifdef DEB_SPLIT_TO_ZONES
146 TCollection_AsciiString aNam("Faces_");
148 for( int anIndex = 1, aLength = theObjectList.Length(); anIndex <= aLength; anIndex++ )
150 Handle(HYDROData_Entity) anObj = theObjectList.Value( anIndex );
153 Handle(HYDROData_Object) aGeomObj = Handle(HYDROData_Object)::DownCast( anObj );
154 if( !aGeomObj.IsNull() ) {
155 aShape = aGeomObj->GetTopShape();
158 if ( aShape.IsNull() )
160 #ifdef DEB_SPLIT_TO_ZONES
161 TCollection_AsciiString aName = aNam + anIndex + "_a.brep";
162 BRepTools::Write(aShape, aName.ToCString());
164 if ( aShape.ShapeType() == TopAbs_COMPOUND ) {
165 // Create split data for each face contained in the compound
166 TopExp_Explorer anExp( aShape, TopAbs_FACE );
167 for ( ; anExp.More(); anExp.Next() ) {
168 const TopoDS_Face& aFace = TopoDS::Face( anExp.Current() );
169 if ( !aFace.IsNull() ) {
170 SplitData aSplitData( SplitData::Data_Zone, aFace, anObj->GetName() );
171 anInputSplitDataList.append( aSplitData );
175 SplitData aSplitData( SplitData::Data_Zone, aShape, anObj->GetName() );
176 anInputSplitDataList.append( aSplitData );
180 SplitDataList anInputGroupList;
181 for( int anIndex = 1, aLength = theGroupsList.Length(); anIndex <=aLength; anIndex++ )
183 Handle(HYDROData_ShapesGroup) aGeomGroup =
184 Handle(HYDROData_ShapesGroup)::DownCast( theGroupsList.Value( anIndex ) );
185 if( aGeomGroup.IsNull() )
188 TopTools_SequenceOfShape aGroupShapes;
189 aGeomGroup->GetShapes( aGroupShapes );
190 for( int i = 1, aNbShapes = aGroupShapes.Length(); i <= aNbShapes; i++ ) {
191 const TopoDS_Shape& aGroupShape = aGroupShapes.Value( i );
192 if ( aGroupShape.IsNull() )
195 if ( aGroupShape.ShapeType() == TopAbs_COMPOUND ) {
196 TopExp_Explorer anExp( aGroupShape, TopAbs_EDGE );
197 for ( ; anExp.More(); anExp.Next() ) {
198 const TopoDS_Edge& anEdge = TopoDS::Edge( anExp.Current() );
199 if ( !anEdge.IsNull() ) {
200 SplitData aSplitData( SplitData::Data_Edge, anEdge, aGeomGroup->GetName() );
201 anInputGroupList.append( aSplitData );
205 SplitData aSplitData( SplitData::Data_Edge, aGroupShape, aGeomGroup->GetName() );
206 anInputGroupList.append( aSplitData );
207 #ifdef DEB_SPLIT_TO_ZONES
208 QString aStr = aSplitData.ObjectNames.join(" ");
209 DEBTRACE("Group# = " <<anIndex <<" Nmb in grp = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aSplitData.ObjectNames.size());
214 // If only one shape is given we don't split it
215 // algorithm just returns the unpacked input data
216 bool limplus1Object(false);
217 if(theObjectList.Size() == 1 ) {
218 if(thePolyline.IsNull()) {
219 anOutputSplitDataList.append(anInputSplitDataList);
220 if(!theGroupsList.IsEmpty() )
221 anOutputSplitDataList.append(anInputGroupList);
222 return anOutputSplitDataList;
224 limplus1Object = true;// size =1 && hasLimits
226 HYDROData_DataMapOfShapeListOfString aDM3;
227 if(!anInputGroupList.isEmpty()) {// Old edge ==> List_Of_Names
228 QStringList aListOfNames;
229 for (int i=0;i < anInputGroupList.size() ;i++) {
230 const TopoDS_Shape& aSh = anInputGroupList.at(i).Shape;
231 aDM3.Add(aSh, anInputGroupList.at(i).ObjectNames);
235 // Step 1. Prepare Partition structures.
236 TopoDS_Shape aResult;
237 BOPCol_ListOfShape aLS;
238 QStringList aListOfNames;
239 TopoDS_Compound aCmp;
241 aBB.MakeCompound(aCmp);
242 for (int i=0;i < anInputSplitDataList.size() ;i++) {
243 const TopoDS_Shape& aSh = anInputSplitDataList.at(i).Shape;
244 aDM3.Add(aSh, anInputSplitDataList.at(i).ObjectNames);
247 #ifdef DEB_SPLIT_TO_ZONES
248 TCollection_AsciiString aName = aNam + i + "_b.brep";
249 BRepTools::Write(aSh, aName.ToCString());
252 #ifdef DEB_SPLIT_TO_ZONES_CHECK_PARTITION
253 TCollection_AsciiString aNameBefore = fileNameBefore + "_c.brep";
254 BRepTools::Write(aCmp, aNameBefore.ToCString());
257 HYDROData_DataMapOfShapeListOfShape aDM1;
258 if(anInputSplitDataList.size() > 1) {
259 HYDROData_Transform splitTool;
260 const Standard_Integer anErr = SplitFaces(aCmp, splitTool);
262 return anOutputSplitDataList;
263 aResult = splitTool.Shape();
264 if (aResult.IsNull())
265 return anOutputSplitDataList;
266 BRepCheck_Analyzer aCheck (aResult);
267 if(!aCheck.IsValid()) {
268 #ifdef DEB_SPLIT_TO_ZONES
269 DEBTRACE("result is not valid");
270 BRepTools::Write(aResult, "SplitFacesNV.brep");
272 return anOutputSplitDataList;
274 #ifdef DEB_SPLIT_TO_ZONES
275 BRepTools::Write(aResult, "SplitFacesV.brep");
278 // Step 3. Collect history
279 //HYDROData_DataMapOfShapeListOfShape aDM1;
280 BOPCol_ListIteratorOfListOfShape anIt(aLS);
281 #ifdef DEB_SPLIT_TO_ZONES
282 TCollection_AsciiString aNamM ("EdgM_");
283 TCollection_AsciiString aNamG ("EdgG_");
285 for (int i =1;anIt.More();anIt.Next(),i++) {
286 Standard_Boolean foundF(Standard_False);
287 const TopTools_ListOfShape& aListOfNew = splitTool.Modified(anIt.Value());
288 if(!aListOfNew.IsEmpty())
289 foundF = Standard_True;
291 TopTools_ListOfShape aList;
293 TopTools_ListIteratorOfListOfShape it(aListOfNew);
294 for(;it.More();it.Next())
295 aList.Append(it.Value());
296 /* *********************************************************************
297 // Bug in History: partition should give only modified entities! => temporary solution is used
298 //const TopTools_ListOfShape& aListOfGen = splitTool.Generated(anIt.Value());
299 //if(!aListOfGen.IsEmpty())
300 //foundF = Standard_True;
301 //it.Initialize(aListOfGen);
302 //for(;it.More();it.Next())
303 // aList.Append(it.Value());
304 ********************************************************************* */
305 if(!foundF) // face is not modified
306 aList.Append (anIt.Value());
307 aDM1.Add(anIt.Value(), aList);
308 #ifdef DEB_SPLIT_TO_ZONES
309 TCollection_AsciiString aName;
311 if(!anInputGroupList.isEmpty() ) { // 1
312 TopExp_Explorer exp (anIt.Value(), TopAbs_EDGE);
313 for (int j =1;exp.More();exp.Next(),j++) {
315 Standard_Boolean foundE(Standard_False);
316 const TopTools_ListOfShape& aListM = splitTool.Modified(exp.Current());
317 DEBTRACE("NB_EDGE_M = " << aListM.Extent());
318 if(aListM.Extent()) foundE = Standard_True;
319 it.Initialize(aListM);
320 for(int k=1;it.More();it.Next(),k++) {
321 aList.Append(it.Value());
322 #ifdef DEB_SPLIT_TO_ZONES
323 aName = aNamM + i + j +k +"_d.brep";
324 BRepTools::Write(it.Value(),aName.ToCString());
327 /* *********************************************************************
328 //const TopTools_ListOfShape& aListG = splitTool.Generated(exp.Current());
329 //if(aListG.Extent()) foundE = Standard_True;
330 //it.Initialize(aListG);
331 //for(int k=1;it.More();it.Next(),k++)
332 //aList.Append(it.Value());
333 //cout << "NB_EDGE = " << aList.Extent() <<endl;
334 ************************************************************************** */
336 aList.Append (exp.Current());
337 #ifdef DEB_SPLIT_TO_ZONES
338 aName = aNamG + i + j +"_e.brep";
339 BRepTools::Write(exp.Current(),aName.ToCString());
340 DEBTRACE(aName.ToCString()<< " = " << exp.Current().TShape());
343 aDM1.Add(exp.Current(), aList);
348 aResult = anInputSplitDataList.at(0).Shape; // get single input shape
351 // aDM2: NewShape ==> ListOfOldShapes
352 HYDROData_DataMapOfShapeListOfShape aDM2;
353 // make limiting face
354 HYDROData_DataMapOfShapeListOfShape aDM4;
355 Standard_Boolean hasLimits(Standard_False);
357 HYDROData_MapOfShape aBndView;
358 if (! thePolyline.IsNull()) {
359 Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape;
360 int nbWires = thePolyline->GetNbConnectedWires(aConnectedWires);
361 const TopoDS_Wire aBndWire = TopoDS::Wire(aConnectedWires->Value(1));
362 if(!aBndWire.IsNull()) {
364 if(buildLimFace(aBndWire, limFace)) {
365 TopoDS_Shape aComResult;
366 BRepAlgoAPI_Common mkCom(aResult, limFace);
368 aComResult = mkCom.Shape();
369 BRepCheck_Analyzer aCheck (aComResult);
370 if(aCheck.IsValid()) {
371 #ifdef DEB_SPLIT_TO_ZONES
372 BRepTools::Write(aComResult,"CommonV.brep");
373 BRepTools::Write(limFace,"limFace.brep");
375 aBndName = thePolyline->GetName();
376 hasLimits = Standard_True; // DM2 should be filled here
377 TopExp_Explorer exp (limFace, TopAbs_EDGE);
378 for (int i =1;exp.More();exp.Next(),i++) {
379 const TopoDS_Shape& anEdge = exp.Current();
380 if(anEdge.IsNull()) continue;
381 aBndView.Add(anEdge);
382 QStringList aListOfNames;
383 aListOfNames.append(aBndName);
384 aDM3.Add(anEdge, aListOfNames);
385 TopTools_ListOfShape aList;
386 aList.Append(anEdge);
387 aDM1.Add(anEdge,aList);
389 HYDROData_MapOfShape aView;
390 exp.Init (aResult, TopAbs_FACE);
391 for (int i =1;exp.More();exp.Next(),i++) {
392 const TopoDS_Shape& aFace = exp.Current();
393 if(!aFace.IsNull()) {
394 const TopTools_ListOfShape& aListOfNew = mkCom.Modified(aFace);
395 DEBTRACE("Modified: " << aListOfNew.Extent());
396 if(!aListOfNew.IsEmpty()) {
397 aDM4.Add(aFace, aListOfNew);
398 #ifdef DEB_SPLIT_TO_ZONES
399 TCollection_AsciiString aName = aNam + i + "_f.brep";
400 BRepTools::Write(aListOfNew.Last(), aName.ToCString());
404 if(!mkCom.IsDeleted(aFace)) {
405 const TopTools_ListOfShape& aListOfGen = mkCom.Generated(aFace);
406 if(!aListOfGen.IsEmpty()) {
407 /* aDM4.Bind(aFace, aListOfGen); ??? */
408 #ifdef DEB_SPLIT_TO_ZONES
409 TCollection_AsciiString aName = aNam + i + "_g.brep";
410 BRepTools::Write(aListOfGen.Last(), aName.ToCString());
414 TopTools_ListOfShape aList;
416 aDM4.Add(aFace, aList); //the same face - not modified
420 TopExp_Explorer exp2 (aFace, TopAbs_EDGE);
421 for (int j =1;exp2.More();exp2.Next(),j++) {
422 const TopoDS_Shape& anEdge = exp2.Current();
423 if(!anEdge.IsNull()) {
424 if(aView.Contains(anEdge)) continue;
426 const TopTools_ListOfShape& aListOfNewEd = mkCom.Modified(anEdge);
427 if(!aListOfNewEd.IsEmpty())
428 aDM4.Add(anEdge, aListOfNewEd);
430 if(!mkCom.IsDeleted(anEdge)) {
431 const TopTools_ListOfShape& aListOfGenEd = mkCom.Generated(anEdge);
432 if(!aListOfGenEd.IsEmpty()) {
433 /* aDM4.Bind(anEdge, aListOfGenEd); ???*/
435 TopTools_ListOfShape aList;
436 aList.Append(anEdge);
437 aDM4.Add(anEdge, aList);//the same edge - not modified
444 } //end DM4 filling (phase 1)
445 //cout << "DM4 Ext = " <<aDM4.Extent() <<endl;
446 // phase 2 (from tool)
447 #ifdef DEB_SPLIT_TO_ZONES
448 TCollection_AsciiString aNam("BndEd_");
450 TopExp_Explorer expt (limFace, TopAbs_EDGE);
451 for(int i =1;expt.More();expt.Next(),i++) {
452 const TopoDS_Shape& anEdge = expt.Current();
453 if(!anEdge.IsNull()) {
454 const TopTools_ListOfShape& aListOfNewEd = mkCom.Modified(anEdge);
455 #ifdef DEB_SPLIT_TO_ZONES
456 TopTools_ListIteratorOfListOfShape itl(aListOfNewEd);
457 for(int j=1;itl.More();itl.Next(),j++) {
458 TCollection_AsciiString aName = aNam + i + "_" + j + "_j.brep";
459 BRepTools::Write(itl.Value(), aName.ToCString());
460 DEBTRACE(aName.ToCString()<<" = "<< itl.Value().TShape());
463 if(!aListOfNewEd.IsEmpty())
464 aDM4.Add(anEdge, aListOfNewEd);
466 if(!mkCom.IsDeleted(anEdge)) {
467 const TopTools_ListOfShape& aListOfGenEd = mkCom.Generated(anEdge);
468 if(!aListOfGenEd.IsEmpty()) {
469 /* aDM4.Bind(anEdge, aListOfGenEd); ??? */
471 TopTools_ListOfShape aList;
472 aList.Append(anEdge);
473 aDM4.Add(anEdge, aList);//the same edge - not modified
479 //cout << "DM4 Ext = " <<aDM4.Extent() <<endl;
481 // fill DM1 (old - new) and DM2 (new - old)
482 HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape mIt(aDM4);
483 for(;mIt.More();mIt.Next()) {
484 const TopoDS_Shape& aKey = mIt.Key();//old
485 TopTools_ListOfShape aList;
487 const TopTools_ListOfShape& aListOfNew = mIt.Value();
488 aDM1.Add(aKey, aListOfNew);
489 TopTools_ListIteratorOfListOfShape it(aListOfNew);
490 for(;it.More();it.Next()) {
491 if(!aDM2.Contains(it.Value()))
492 aDM2.Add(it.Value(), aList);
494 TopTools_ListOfShape& aList = aDM2.ChangeFromKey(it.Value());
500 HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape aMIt(aDM1);
501 //DM4 contains Old - New after common op. DM1: old - new after Split op.
502 for(;aMIt.More();aMIt.Next()) {
503 const TopoDS_Shape& aKey = aMIt.Key();
504 TopTools_ListOfShape aList;
506 const TopTools_ListOfShape& aListOfNew = aMIt.Value();
507 TopTools_ListIteratorOfListOfShape it(aListOfNew);
508 for(;it.More();it.Next()) {// iterate new: b1, b2, b3...
509 if(!aDM4.Contains(it.Value())) // bi - is deleted
510 continue; // go to the next bi
512 const TopTools_ListOfShape& aListOfNew4 = aDM4.FindFromKey(it.Value());
513 TopTools_ListIteratorOfListOfShape it4(aListOfNew4); // {c1, c2, c3,...}
514 for(;it4.More();it4.Next()) {
515 if(!aDM2.Contains(it4.Value()))
516 aDM2.Add(it4.Value(), aList);
518 TopTools_ListOfShape& aList = aDM2.ChangeFromKey(it4.Value());
527 hasLimits = Standard_False;
528 #ifdef DEB_SPLIT_TO_ZONES
529 BRepTools::Write(aComResult,"CommonNV.brep");
535 }// end limits processing
537 HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape aMIt(aDM1);
538 for(;aMIt.More();aMIt.Next()) {
539 const TopoDS_Shape& aKey = aMIt.Key();
540 TopTools_ListOfShape aList;
542 const TopTools_ListOfShape& aListOfNew = aMIt.Value();
543 TopTools_ListIteratorOfListOfShape it(aListOfNew);
544 for(;it.More();it.Next()) {
545 if(!aDM2.Contains(it.Value()))
546 aDM2.Add(it.Value(), aList);
548 TopTools_ListOfShape& aList = aDM2.ChangeFromKey(it.Value());
555 AddInternalEdges(aDM2, InterPolys);
557 // Step 4. Fill output structure.
558 #ifdef DEB_SPLIT_TO_ZONES
559 TCollection_AsciiString aNam4 ("SC_");
561 HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape aMIt(aDM2);
562 for(int i =1;aMIt.More();aMIt.Next(),i++) {
563 SplitData aDestSplitData;
564 const TopoDS_Shape& aKey = aMIt.Key(); //new
565 aDestSplitData.Shape = aKey;
566 if(aKey.ShapeType() == TopAbs_FACE)
567 aDestSplitData.Type = SplitData::Data_Zone;
569 aDestSplitData.Type = SplitData::Data_Edge;
570 #ifdef DEB_SPLIT_TO_ZONES
571 TCollection_AsciiString aName = aNam4 + i + "_k.brep";
572 BRepTools::Write(aKey,aName.ToCString());
576 QStringList aListOfNames; // names processing
577 const TopTools_ListOfShape& aListOfOld = aMIt.Value();
578 TopTools_ListIteratorOfListOfShape it(aListOfOld);
579 for(int j =1;it.More();it.Next(),j++) {
580 const TopoDS_Shape& aSh = it.Value(); //old
581 if(aDM3.Contains(aSh)) {
582 const QStringList& ObjectNames = aDM3.FindFromKey(aSh);
583 aListOfNames.append(ObjectNames);
584 #ifdef DEB_SPLIT_TO_ZONES
585 TCollection_AsciiString aName = aNam4 + i +"_" + j + "_l.brep";
586 BRepTools::Write(aSh ,aName.ToCString());
589 #ifdef DEB_SPLIT_TO_ZONES
590 TCollection_AsciiString aName = aNam4 +"__" + i +"_" + j + "_m.brep";
591 BRepTools::Write(aSh ,aName.ToCString());
592 DEBTRACE(aName.ToCString()<<" = "<< aSh.TShape());
594 if(aBndView.Contains(aSh) && hasLimits) {
595 aListOfNames.append(aBndName);
596 #ifdef DEB_SPLIT_TO_ZONES
597 DEBTRACE(" BndName = "<<aBndName.toStdString());
603 aDestSplitData.ObjectNames = aListOfNames;
604 anOutputSplitDataList.append(aDestSplitData);
605 #ifdef DEB_SPLIT_TO_ZONES
606 QString aStr = aDestSplitData.ObjectNames.join(" ");
607 DEBTRACE("New# = " << i<< " Names = "<<aStr.toStdString() << " size = " <<aDestSplitData.ObjectNames.size());
611 return anOutputSplitDataList;
614 HYDROData_SplitToZonesTool::SplitDataList
615 HYDROData_SplitToZonesTool::Split( const HYDROData_SequenceOfObjects& theObjectList )
617 HYDROData_SequenceOfObjects aGeomGroups;
618 Handle(HYDROData_PolylineXY) aPolyline;
619 HYDROData_SequenceOfObjects InterPolys;
621 return Split( theObjectList, aGeomGroups, aPolyline, InterPolys );
624 void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOfShape& DM,
625 const HYDROData_SequenceOfObjects& thePolylines)
628 HYDROData_SequenceOfObjects::Iterator it(thePolylines);
629 TopTools_ListOfShape Wires;
630 for (;it.More();it.Next())
632 Handle(HYDROData_PolylineXY) P = Handle(HYDROData_PolylineXY)::DownCast(it.Value());
633 Wires.Append(P->GetShape());
634 //Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape;
635 //if (P->GetNbConnectedWires(aConnectedWires) > 0)
636 // Wires.Append(aConnectedWires->Value(1));
639 HYDROData_DataMapOfShapeListOfShape newDM;
641 for (int i = 1; i <= DM.Extent();i++)
643 const TopoDS_Shape& K = DM.FindKey(i);
644 const TopTools_ListOfShape& V = DM.FindFromIndex(i);
645 TopTools_ListOfShape out;
646 if (K.ShapeType() == TopAbs_FACE)
648 CutByEdges(K, Wires, out);
649 TopTools_ListIteratorOfListOfShape it(out);
650 for (;it.More(); it.Next())
652 const TopoDS_Shape& NF = it.Value();
658 newDM.Add(K, V); // ignore edges, wires...
665 int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InEdges,
666 TopTools_ListOfShape& outShs)
671 if (InEdges.IsEmpty())
677 TopTools_ListIteratorOfListOfShape anIt;
678 BOPAlgo_Builder anAlgo;
679 anAlgo.AddArgument(InSh);
680 anIt.Initialize( InEdges );
681 for( ; anIt.More(); anIt.Next() )
682 anAlgo.AddArgument( anIt.Value() );
685 anError = anAlgo.ErrorStatus();
689 outShs = anAlgo.Modified( InSh );
690 if (outShs.IsEmpty())