#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Iterator.hxx>
{
SplitDataList anOutputSplitDataList;
- // Preparation. Collect the object shapes to split. InputDataList will contain elements which will hold shape & name_of_shape.
+ // Preparation.
+ // Collect the object shapes to split. InputDataList will contain elements which will hold shape & name_of_shape.
SplitDataList anInputSplitDataList;
for( int anIndex = 1, aLength = theObjectList.Length(); anIndex <= aLength; anIndex++ )
{
TopoDS_Shape aShape = aGeomObj->GetTopShape();
if ( aShape.IsNull() )
- continue;
-
+ continue;
+
if ( aShape.ShapeType() == TopAbs_COMPOUND ) {
// Create split data for each face contained in the compound
TopExp_Explorer anExp( aShape, TopAbs_FACE );
for ( ; anExp.More(); anExp.Next() ) {
- TopoDS_Face aFace = TopoDS::Face( anExp.Current() );
+ const TopoDS_Face& aFace = TopoDS::Face( anExp.Current() );
if ( !aFace.IsNull() ) {
SplitData aSplitData( SplitData::Data_Zone, aFace, aGeomObj->GetName() );
anInputSplitDataList.append( aSplitData );
anInputSplitDataList.append( aSplitData );
}
}
+ //
+ SplitDataList anInputGroupList;
+ for( int anIndex = 1; anIndex <= theGroupsList.Length(); anIndex++ )
+ {
+ Handle(HYDROData_Object) aGeomGroup =
+ Handle(HYDROData_Object)::DownCast( theGroupsList.Value( anIndex ) );
+ if( aGeomGroup.IsNull() )
+ continue;
+ const TopoDS_Shape& aShape = aGeomGroup->GetTopShape();
+ if ( aShape.IsNull() )
+ continue;
+ if ( aShape.ShapeType() == TopAbs_COMPOUND ) {
+ TopExp_Explorer anExp( aShape, TopAbs_EDGE );
+ for ( ; anExp.More(); anExp.Next() ) {
+ const TopoDS_Edge& anEdge = TopoDS::Edge( anExp.Current() );
+ if ( !anEdge.IsNull() ) {
+ SplitData aSplitData( SplitData::Data_Edge, anEdge, aGeomGroup->GetName() );
+ anInputGroupList.append( aSplitData );
+ }
+ }
+ } else {
+ SplitData aSplitData( SplitData::Data_Edge, aShape, aGeomGroup->GetName() );
+ anInputGroupList.append( aSplitData );
+ }
+ }
+ HYDROData_DataMapOfShapeListOfString aDM3;
+ 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);
+ }
+ }
// Step 1. Prepare Partition structures.
Handle(NCollection_BaseAllocator) pA1 = new NCollection_IncAllocator, pA2 = new NCollection_IncAllocator;
BOPAlgo_PaveFiller* aPaveFiller = new BOPAlgo_PaveFiller(pA1);
BOPAlgo_Builder* aBuilder = new BOPAlgo_Builder(pA2);
BOPCol_ListOfShape aLS;
- HYDROData_DataMapOfShapeListOfString aDM3;
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);
}
- aPaveFiller->SetArguments(aLS);
- aPaveFiller->Perform();
- Standard_Integer anErr = aPaveFiller->ErrorStatus();
- if(anErr)
- return anOutputSplitDataList;
- BOPDS_PDS pDS = aPaveFiller->PDS();
- if (!pDS)
- return anOutputSplitDataList;
- aBuilder->Clear();
-
- // Step 2. Split faces
- BOPCol_ListIteratorOfListOfShape anIt(aPaveFiller->Arguments());
- for (; anIt.More(); anIt.Next()) {
- const TopoDS_Shape& aS = anIt.Value();
- aBuilder->AddArgument(aS);
- }
- aBuilder->PerformWithFiller(*aPaveFiller);
- anErr = aBuilder->ErrorStatus();
- if(anErr)
- return anOutputSplitDataList;
- const TopoDS_Shape& aResult = aBuilder->Shape();
+ aPaveFiller->SetArguments(aLS);
+ aPaveFiller->Perform();
+ Standard_Integer anErr = aPaveFiller->ErrorStatus();
+ if(anErr)
+ return anOutputSplitDataList;
+ BOPDS_PDS pDS = aPaveFiller->PDS();
+ if (!pDS)
+ return anOutputSplitDataList;
+ aBuilder->Clear();
+
+ // Step 2. Split faces
+ BOPCol_ListIteratorOfListOfShape anIt(aPaveFiller->Arguments());
+ for (; anIt.More(); anIt.Next()) {
+ const TopoDS_Shape& aS = anIt.Value();
+ aBuilder->AddArgument(aS);
+ }
+ aBuilder->PerformWithFiller(*aPaveFiller);
+ anErr = aBuilder->ErrorStatus();
+ if(anErr)
+ return anOutputSplitDataList;
+ const TopoDS_Shape& aResult = aBuilder->Shape();
if (aResult.IsNull())
return anOutputSplitDataList;
BRepCheck_Analyzer aCheck (aResult);
if(!aCheck.IsValid()) {
#ifdef DEB_SPLIT_TO_ZONES
- cout << "result is not valid" <<endl;
- BRepTools::Write(aResult, "SplitFacesNV.brep");
+ cout << "result is not valid" <<endl;
+ BRepTools::Write(aResult, "SplitFacesNV.brep");
#endif
- return anOutputSplitDataList;
+ return anOutputSplitDataList;
}
#ifdef DEB_SPLIT_TO_ZONES
- BRepTools::Write(aResult, "SplitFacesV.brep");
+ //BRepTools::Write(aResult, "SplitFacesV.brep");
#endif
// Step 3. Collect history
HYDROData_DataMapOfShapeListOfShape aDM1;
anIt.Init(aLS);
- for (;anIt.More();anIt.Next()) {
+ //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());
TopTools_ListOfShape aList;
- TopTools_ListIteratorOfListOfShape it1(aListOfNew);
- for(;it1.More();it1.Next())
- aList.Append(it1.Value());
+ 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());
- TopTools_ListIteratorOfListOfShape it2(aListOfGen);
- for(;it2.More();it2.Next())
- aList.Append(it2.Value());
+ it.Initialize(aListOfGen);
+ for(;it.More();it.Next())
+ aList.Append(it.Value());
aDM1.Bind(anIt.Value(), aList);
- //cout << "NB_Face = " << aList.Extent() <<endl;
- //TopExp_Explorer exp (anIt.Value(), TopAbs_EDGE);
- //for (;exp.More();exp.Next()) {
- //const TopTools_ListOfShape& aList2 = aBuilder->Modified(exp.Current());
- // cout << "NB_EDGE = " << aList2.Extent() <<endl;
- //}
+ //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);
+ }
+ }
}
// aDM2: NewShape ==> ListOfOldShapes
//cout << "DM2 Ext = " <<aDM2.Extent() <<endl;
// Step 4. Fill output structure.
aMIt.Initialize(aDM2);
- for(;aMIt.More();aMIt.Next()) {
+ 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
+ aDestSplitData.Type = SplitData::Data_Edge;
+
+ QStringList aListOfNames; // names processing
const TopTools_ListOfShape& aListOfOld = aMIt.Value();
- SplitData aDestSplitData;
- QStringList aListOfNames;
TopTools_ListIteratorOfListOfShape it(aListOfOld);
for(;it.More();it.Next()) {
const TopoDS_Shape& aSh = it.Value(); //old
aListOfNames.append(ObjectNames);
}
}
- aDestSplitData.Shape = aKey;
- aDestSplitData.ObjectNames = aListOfNames;
- aDestSplitData.Type = SplitData::Data_Zone;
+/*
+ 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;
+
/*
SplitDataListIterator anInputIter( anInputSplitDataList );
while( anInputIter.hasNext() )