#undef _NCollection_MapHasher
#define DEB_SPLIT_TO_ZONES 1
-#ifdef DEB_SPLIT_TO_ZONES
+#ifdef DEB_SPLIT_TO_ZONES
#include <BRepTools.hxx>
#endif
TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const
Handle(HYDROData_ShapesGroup)::DownCast( theGroupsList.Value( anIndex ) );
if( aGeomGroup.IsNull() )
continue;
-
+
TopTools_SequenceOfShape aGroupShapes;
aGeomGroup->GetShapes( aGroupShapes );
for( int i = 1, aNbShapes = aGroupShapes.Length(); i <= aNbShapes; i++ ) {
SplitData aSplitData( SplitData::Data_Edge, anEdge, aGeomGroup->GetName() );
anInputGroupList.append( aSplitData );
}
- }
+ }
} else {
SplitData aSplitData( SplitData::Data_Edge, aGroupShape, aGeomGroup->GetName() );
anInputGroupList.append( aSplitData );
}
}
+ // If is only one shape is given we do not process the intersection
+ // algorithm but just return the unpacked input data
+ if ( theObjectList.Length() == 1 )
+ {
+ anOutputSplitDataList << anInputSplitDataList << anInputGroupList;
+ return anOutputSplitDataList;
+ }
+
HYDROData_DataMapOfShapeListOfString aDM3;
- if(!anInputGroupList.isEmpty()) { // Old edge ==> List_Of_Names
+ if(!anInputGroupList.isEmpty()) {// Old edge ==> List_Of_Names
QStringList aListOfNames;
for (int i=0;i < anInputGroupList.size() ;i++) {
- const TopoDS_Shape& aSh = anInputGroupList.at(i).Shape;
- aDM3.Bind(aSh, anInputGroupList.at(i).ObjectNames);
- }
+ const TopoDS_Shape& aSh = anInputGroupList.at(i).Shape;
+ aDM3.Bind(aSh, anInputGroupList.at(i).ObjectNames);
+ }
}
// Step 1. Prepare Partition structures.
Handle(NCollection_BaseAllocator) pA1 = new NCollection_IncAllocator, pA2 = new NCollection_IncAllocator;
BOPCol_ListOfShape aLS;
QStringList aListOfNames;
for (int i=0;i < anInputSplitDataList.size() ;i++) {
- const TopoDS_Shape& aSh = anInputSplitDataList.at(i).Shape;
- aDM3.Bind(aSh, anInputSplitDataList.at(i).ObjectNames);
- aLS.Append(aSh);
+ const TopoDS_Shape& aSh = anInputSplitDataList.at(i).Shape;
+ aDM3.Bind(aSh, anInputSplitDataList.at(i).ObjectNames);
+ aLS.Append(aSh);
}
aPaveFiller->SetArguments(aLS);
aPaveFiller->Perform();
return anOutputSplitDataList;
BRepCheck_Analyzer aCheck (aResult);
if(!aCheck.IsValid()) {
-#ifdef DEB_SPLIT_TO_ZONES
- cout << "result is not valid" <<endl;
+#ifdef DEB_SPLIT_TO_ZONES
+ cout << "result is not valid" <<endl;
BRepTools::Write(aResult, "SplitFacesNV.brep");
#endif
return anOutputSplitDataList;
}
-#ifdef DEB_SPLIT_TO_ZONES
+#ifdef DEB_SPLIT_TO_ZONES
//BRepTools::Write(aResult, "SplitFacesV.brep");
#endif
//TCollection_AsciiString aNamM ("EdgM_");
//TCollection_AsciiString aNamG ("EdgG_");
for (int i =1;anIt.More();anIt.Next(),i++) {
- const TopTools_ListOfShape& aListOfNew = aBuilder->Modified(anIt.Value());
+ const TopTools_ListOfShape& aListOfNew = aBuilder->Modified(anIt.Value());
TopTools_ListOfShape aList;
- TopTools_ListIteratorOfListOfShape it(aListOfNew);
- for(;it.More();it.Next())
- aList.Append(it.Value());
- // Bug in History: partition should give only modified entities! => temporary solution is used
+ TopTools_ListIteratorOfListOfShape it(aListOfNew);
+ for(;it.More();it.Next())
+ aList.Append(it.Value());
+ // Bug in History: partition should give only modified entities! => temporary solution is used
const TopTools_ListOfShape& aListOfGen = aBuilder->Generated(anIt.Value());
- it.Initialize(aListOfGen);
- for(;it.More();it.Next())
- aList.Append(it.Value());
+ it.Initialize(aListOfGen);
+ for(;it.More();it.Next())
+ aList.Append(it.Value());
- aDM1.Bind(anIt.Value(), aList);
- //TCollection_AsciiString aName;
- if(!anInputGroupList.isEmpty()) { /* 1 */
+ aDM1.Bind(anIt.Value(), aList);
+ //TCollection_AsciiString aName;
+ if(!anInputGroupList.isEmpty()) { /* 1 */
aList.Clear();
- TopExp_Explorer exp (anIt.Value(), TopAbs_EDGE);
- for (int j =1;exp.More();exp.Next(),j++) {
- const TopTools_ListOfShape& aListM = aBuilder->Modified(exp.Current());
- //cout << "NB_EDGE_M = " << aListM.Extent() <<endl;
- it.Initialize(aListM);
- for(int k=1;it.More();it.Next(),k++) {
- aList.Append(it.Value());
- //aName = aNamM + i + j +k +".brep";
- //BRepTools::Write(it.Value(),aName.ToCString());
- }
- const TopTools_ListOfShape& aListG = aBuilder->Generated(exp.Current());
- it.Initialize(aListG);
- for(int k=1;it.More();it.Next(),k++) {
- aList.Append(it.Value());
- //aName = aNamG + i + j +k +".brep";
- //BRepTools::Write(it.Value(),aName.ToCString());
- }
- //cout << "NB_EDGE = " << aList.Extent() <<endl;
- aDM1.Bind(exp.Current(), aList);
- }
- }
+ TopExp_Explorer exp (anIt.Value(), TopAbs_EDGE);
+ for (int j =1;exp.More();exp.Next(),j++) {
+ const TopTools_ListOfShape& aListM = aBuilder->Modified(exp.Current());
+ //cout << "NB_EDGE_M = " << aListM.Extent() <<endl;
+ it.Initialize(aListM);
+ for(int k=1;it.More();it.Next(),k++) {
+ aList.Append(it.Value());
+ //aName = aNamM + i + j +k +".brep";
+ //BRepTools::Write(it.Value(),aName.ToCString());
+ }
+ const TopTools_ListOfShape& aListG = aBuilder->Generated(exp.Current());
+ it.Initialize(aListG);
+ for(int k=1;it.More();it.Next(),k++) {
+ aList.Append(it.Value());
+ //aName = aNamG + i + j +k +".brep";
+ //BRepTools::Write(it.Value(),aName.ToCString());
+ }
+ //cout << "NB_EDGE = " << aList.Extent() <<endl;
+ aDM1.Bind(exp.Current(), aList);
+ }
+ }
}
// aDM2: NewShape ==> ListOfOldShapes
HYDROData_DataMapOfShapeListOfShape aDM2;
HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape aMIt(aDM1);
for(;aMIt.More();aMIt.Next()) {
- const TopoDS_Shape& aKey = aMIt.Key();
- TopTools_ListOfShape aList;
- aList.Append(aKey);
- const TopTools_ListOfShape& aListOfNew = aMIt.Value();
- TopTools_ListIteratorOfListOfShape it(aListOfNew);
- for(;it.More();it.Next()) {
- if(!aDM2.IsBound(it.Value()))
- aDM2.Bind(it.Value(), aList);
- else {
- TopTools_ListOfShape& aList = aDM2.ChangeFind(it.Value());
- aList.Prepend(aKey);
- }
- }
+ const TopoDS_Shape& aKey = aMIt.Key();
+ TopTools_ListOfShape aList;
+ aList.Append(aKey);
+ const TopTools_ListOfShape& aListOfNew = aMIt.Value();
+ TopTools_ListIteratorOfListOfShape it(aListOfNew);
+ for(;it.More();it.Next()) {
+ if(!aDM2.IsBound(it.Value()))
+ aDM2.Bind(it.Value(), aList);
+ else {
+ TopTools_ListOfShape& aList = aDM2.ChangeFind(it.Value());
+ aList.Prepend(aKey);
+ }
+ }
}
//cout << "DM2 Ext = " <<aDM2.Extent() <<endl;
// Step 4. Fill output structure.
aMIt.Initialize(aDM2);
for(int i =1;aMIt.More();aMIt.Next(),i++) {
SplitData aDestSplitData;
- const TopoDS_Shape& aKey = aMIt.Key(); //new
- aDestSplitData.Shape = aKey;
- if(aKey.ShapeType() == TopAbs_FACE)
- aDestSplitData.Type = SplitData::Data_Zone;
- else
+ const TopoDS_Shape& aKey = aMIt.Key(); //new
+ aDestSplitData.Shape = aKey;
+ if(aKey.ShapeType() == TopAbs_FACE)
+ aDestSplitData.Type = SplitData::Data_Zone;
+ else
aDestSplitData.Type = SplitData::Data_Edge;
- QStringList aListOfNames; // names processing
+ QStringList aListOfNames; // names processing
const TopTools_ListOfShape& aListOfOld = aMIt.Value();
TopTools_ListIteratorOfListOfShape it(aListOfOld);
- for(;it.More();it.Next()) {
- const TopoDS_Shape& aSh = it.Value(); //old
- if(aDM3.IsBound(aSh)) {
- const QStringList& ObjectNames = aDM3.Find(aSh);
- aListOfNames.append(ObjectNames);
- }
- }
-/*
- if(aKey.ShapeType() == TopAbs_EDGE) {
- QString aStr("EDGE_Of_Face_");
- aStr = aStr.append(TCollection_AsciiString(i).ToCString());
- const QStringList& ObjectNames = QStringList( aStr);
- cout << "EDGE ==> " << ObjectNames.size() <<" " << aStr.toStdString()<<endl;
- aListOfNames.append(ObjectNames);
- }*/
- aDestSplitData.ObjectNames = aListOfNames;
- anOutputSplitDataList.append(aDestSplitData);
+ for(;it.More();it.Next()) {
+ const TopoDS_Shape& aSh = it.Value(); //old
+ if(aDM3.IsBound(aSh)) {
+ const QStringList& ObjectNames = aDM3.Find(aSh);
+ aListOfNames.append(ObjectNames);
+ }
+ }
+/*
+ if(aKey.ShapeType() == TopAbs_EDGE) {
+ QString aStr("EDGE_Of_Face_");
+ aStr = aStr.append(TCollection_AsciiString(i).ToCString());
+ const QStringList& ObjectNames = QStringList( aStr);
+ cout << "EDGE ==> " << ObjectNames.size() <<" " << aStr.toStdString()<<endl;
+ aListOfNames.append(ObjectNames);
+ }*/
+ aDestSplitData.ObjectNames = aListOfNames;
+ anOutputSplitDataList.append(aDestSplitData);
}
//cout << "anOutputSplitDataList = " <<anOutputSplitDataList.size() <<endl;
return anOutputSplitDataList;