X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Region.cxx;h=60210bbc30e700e689d31d8d9f0f40faac5b8262;hb=cde2ec476486fcd7c9b7b38ce814c648d73e7fd3;hp=aad021e74f81fa9feae5bd5af3aff69549abb288;hpb=e989e0f3cdd230307b28ed0128a49978b27096ef;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index aad021e7..60210bbc 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -1,3 +1,20 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "HYDROData_Region.h" @@ -35,7 +52,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Region, HYDROData_Entity) HYDROData_Region::HYDROData_Region() - : HYDROData_Entity() + : HYDROData_Entity( Geom_2d ) { } @@ -90,7 +107,7 @@ bool HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone ) if ( !aFatherRegion.IsNull() && aFatherRegion->Label() != myLab ) { Handle(HYDROData_Zone) aNewZone = addNewZone( aDocument, "", TopoDS_Face(), QStringList() ); - theZone->CopyTo( aNewZone ); + theZone->CopyTo( aNewZone, false ); // To prevent changing of stored shape aNewZone->SetShape( theZone->GetShape() ); @@ -157,12 +174,11 @@ Handle(HYDROData_Zone) HYDROData_Region::addNewZone( const Handle(HYDROData_Docu 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 ) ); + Handle(HYDROData_Entity) aRefObject = theDoc->FindObjectByName( anObjName ); if ( aRefObject.IsNull() ) continue; - aNewZone->AddGeometryObject( aRefObject ); + aNewZone->AddObject( aRefObject ); } return aNewZone; @@ -371,3 +387,69 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* return aResShape; } + +QStringList HYDROData_Region::DumpToPython( const QString& thePyScriptPath, + MapOfTreatedObjects& theTreatedObjects ) const +{ + QStringList aResList; + + // Find region + findPythonReferenceObject( theTreatedObjects, aResList ); + + // Add zones + HYDROData_SequenceOfObjects aZones = GetZones(); + HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones ); + for ( ; aZonesIter.More(); aZonesIter.Next() ) { + Handle(HYDROData_Zone) aZone = + Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() ); + if ( aZone.IsNull() ) { + continue; + } + + // find zone + aZone->findPythonReferenceObject( theTreatedObjects, aResList ); + theTreatedObjects.insert( aZone->GetName(), aZone ); + + // set zone merge type + QString aMergeTypeStr; + HYDROData_Zone::MergeType aMergeType = aZone->GetMergeType(); + if ( aMergeType == HYDROData_Zone::Merge_ZMIN ) { + aMergeTypeStr = "HYDROData_Zone.Merge_ZMIN"; + } else if ( aMergeType == HYDROData_Zone::Merge_ZMAX ) { + aMergeTypeStr = "HYDROData_Zone.Merge_ZMAX"; + } else if ( aMergeType == HYDROData_Zone::Merge_Object ) { + aMergeTypeStr = "HYDROData_Zone.Merge_Object"; + } + + if ( !aMergeTypeStr.isEmpty() ) { + aResList << QString( "%1.SetMergeType( %2 )" ).arg( aZone->GetObjPyName() ).arg( aMergeTypeStr ); + } + if ( aMergeType == HYDROData_Zone::Merge_Object ) { + Handle(HYDROData_Entity) aMergeObject = aZone->GetMergeObject(); + if ( !aMergeObject.IsNull() ) { + aMergeObject->findPythonReferenceObject( theTreatedObjects, aResList ); + aResList << QString( "%1.SetMergeObject( %2 )" ).arg( aZone->GetObjPyName() ) + .arg( aMergeObject->GetObjPyName() ); + } + } + + // add zone + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aZone, "AddZone" ); + } + + return aResList; +} + +bool HYDROData_Region::IsSubmersible() const +{ + HYDROData_SequenceOfObjects aZones = GetZones(); + HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones ); + for ( ; aZonesIter.More(); aZonesIter.Next() ) + { + Handle(HYDROData_Zone) aZone = + Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() ); + if ( !aZone->IsSubmersible() ) + return false; //if one of zones is not submersible the region is considered as not submersible + } + return true; +}