X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Region.cxx;h=aad021e74f81fa9feae5bd5af3aff69549abb288;hb=2f217128f8d34b2082de78d2af90bf243bf9e8b1;hp=b5e05cb7e779dc7403f9303924f987c6d0190f5e;hpb=29527ae70e9cc00e9f7017f9ab4f7af4091dbf7f;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index b5e05cb7..aad021e7 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -4,8 +4,10 @@ #include "HYDROData_CalculationCase.h" #include "HYDROData_Document.h" #include "HYDROData_Iterator.h" +#include "HYDROData_Object.h" #include "HYDROData_ShapesTool.h" #include "HYDROData_Zone.h" +#include "HYDROData_Tool.h" #include #include @@ -41,25 +43,6 @@ HYDROData_Region::~HYDROData_Region() { } -QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const -{ - QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aRegionName = GetName(); - - HYDROData_SequenceOfObjects aZones = GetZones(); - HYDROData_SequenceOfObjects::Iterator anIter( aZones ); - for ( ; anIter.More(); anIter.Next() ) - { - Handle(HYDROData_Zone) aRefZone = - Handle(HYDROData_Zone)::DownCast( anIter.Value() ); - if ( !aRefZone.IsNull() ) - setPythonReferenceObject( theTreatedObjects, aResList, aRefZone, "AddZone" ); - } - aResList << QString( "" ); - - return aResList; -} - bool HYDROData_Region::CanBeUpdated() const { return false; @@ -93,6 +76,8 @@ HYDROData_SequenceOfObjects HYDROData_Region::GetAllReferenceObjects() const bool HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone ) { + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if ( theZone.IsNull() ) return false; @@ -104,7 +89,7 @@ bool HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone ) Handle(HYDROData_Region)::DownCast( theZone->GetFatherObject() ); if ( !aFatherRegion.IsNull() && aFatherRegion->Label() != myLab ) { - Handle(HYDROData_Zone) aNewZone = addNewZone(); + Handle(HYDROData_Zone) aNewZone = addNewZone( aDocument, "", TopoDS_Face(), QStringList() ); theZone->CopyTo( aNewZone ); // To prevent changing of stored shape @@ -152,7 +137,10 @@ void HYDROData_Region::RemoveZones() myLab.FindChild( DataTag_ChildZone ).ForgetAllAttributes( true ); } -Handle(HYDROData_Zone) HYDROData_Region::addNewZone() +Handle(HYDROData_Zone) HYDROData_Region::addNewZone( const Handle(HYDROData_Document)& theDoc, + const QString& thePrefix, + const TopoDS_Face& theFace, + const QStringList& theRefObjects ) { TDF_Label aNewLab = myLab.FindChild( DataTag_ChildZone ).NewChild(); @@ -160,6 +148,23 @@ Handle(HYDROData_Zone) HYDROData_Region::addNewZone() Handle(HYDROData_Zone)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_ZONE ) ); AddZone( aNewZone ); + QString aZoneName = HYDROData_Tool::GenerateObjectName( theDoc, thePrefix ); + aNewZone->SetName( aZoneName ); + + aNewZone->SetShape( theFace ); + + // Add the reference object for zone + for ( int i = 0, n = theRefObjects.length(); i < n; ++i ) + { + const QString& anObjName = theRefObjects.at( i ); + Handle(HYDROData_Object) aRefObject = + Handle(HYDROData_Object)::DownCast( theDoc->FindObjectByName( anObjName ) ); + if ( aRefObject.IsNull() ) + continue; + + aNewZone->AddGeometryObject( aRefObject ); + } + return aNewZone; } @@ -185,17 +190,8 @@ void getUsedGroups( const TopoDS_Shape& theShape, { TopoDS_Shape aGroupEdge = anOriGroupDef.Shapes.Value( i ); - bool anIsFound = false; - for ( int anIndex = 1; anIndex <= aMapOfSubShapes.Extent(); anIndex++ ) - { - if ( aGroupEdge.IsPartner( aMapOfSubShapes.FindKey( anIndex ) ) ) - { - anIsFound = true; - break; - } - } - - if ( !anIsFound ) + int aShapeIndex = aMapOfSubShapes.FindIndex( aGroupEdge ); + if ( aShapeIndex <= 0 ) continue; anOriGroupDef.Shapes.Remove( i );