From: isn Date: Wed, 5 Oct 2016 13:41:31 +0000 (+0300) Subject: lot6 / publish exploded shell right in the hydro X-Git-Tag: v1.6~72 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1ec21a43c69aaa22c485cb0411eeffb5da839f24;p=modules%2Fhydro.git lot6 / publish exploded shell right in the hydro --- diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index f82e4e32..633e063a 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -1074,9 +1074,9 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, // Get faces bool isAllNotSubmersible = true; - TopTools_ListOfShape aFaces; HYDROData_SequenceOfObjects aCaseRegions = GetRegions(); HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions ); + NCollection_IndexedDataMap aFacesToNames; for ( ; aRegionIter.More(); aRegionIter.Next() ) { Handle(HYDROData_Region) aRegion = @@ -1088,7 +1088,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, isAllNotSubmersible = false; TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs ); - aFaces.Append( aRegionShape ); + aFacesToNames.Add( aRegionShape, aRegion->GetName() ); } bool aRes = false; @@ -1098,7 +1098,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, } else if ( isAllNotSubmersible ) { theErrorMsg = QString("there are no submersible regions."); } else { - aRes = Export( theGeomEngine, theStudy, aFaces, aSeqOfGroupsDefs, theGeomObjEntry );; + aRes = Export( theGeomEngine, theStudy, aFacesToNames, aSeqOfGroupsDefs, theGeomObjEntry );; } if( aRes && !GetLandCoverMap().IsNull() && !GetStricklerTable().IsNull() ) @@ -1111,7 +1111,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy, - const TopTools_ListOfShape& theFaces, + const NCollection_IndexedDataMap& aFacesToName, const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs, QString& theGeomObjEntry ) const { @@ -1122,10 +1122,9 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var TCollection_AsciiString aNam("Sh_"); int i=1; #endif - TopTools_ListIteratorOfListOfShape aFaceIter( theFaces ); - for ( ; aFaceIter.More(); aFaceIter.Next() ) + for ( int i = 1; i <= aFacesToName.Extent(); i++ ) { - TopoDS_Shape aShape = aFaceIter.Value(); + const TopoDS_Shape& aShape = aFacesToName.FindKey(i); if ( aShape.IsNull() ) continue; @@ -1157,6 +1156,19 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var aSewing.Perform(); TopoDS_Shape aSewedShape = aSewing.SewedShape(); + NCollection_IndexedDataMap aFacesToNameModif; + + for ( int i = 1; i <= aFacesToName.Extent(); i++ ) + { + const TopoDS_Shape& CurShape = aFacesToName.FindKey(i); + const QString& Qstr = aFacesToName.FindFromIndex(i); + if (aSewing.IsModified(CurShape)) + aFacesToNameModif.Add(aSewing.Modified(CurShape), Qstr); + else + aFacesToNameModif.Add(CurShape, Qstr); + } + + // If the sewed shape is empty - return false if ( aSewedShape.IsNull() || !TopoDS_Iterator( aSewedShape ).More() ) return false; @@ -1167,7 +1179,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var // Publish the sewed shape QString aName = EXPORT_NAME; GEOM::GEOM_Object_ptr aMainShape = - HYDROData_GeomTool::publishShapeInGEOM( theGeomEngine, theStudy, aSewedShape, aName, theGeomObjEntry ); + HYDROData_GeomTool::ExplodeShapeInGEOMandPublish( theGeomEngine, theStudy, aSewedShape, aFacesToNameModif, aName, theGeomObjEntry ); if ( aMainShape->_is_nil() ) return false; diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index ca0fd81c..242a8b68 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -440,7 +440,7 @@ private: #ifndef LIGHT_MODE bool Export( GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy, - const TopTools_ListOfShape& theFaces, + const NCollection_IndexedDataMap& aFacesToName, const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs, QString& theGeomObjEntry ) const; #endif diff --git a/src/HYDROData/HYDROData_GeomTool.cxx b/src/HYDROData/HYDROData_GeomTool.cxx index 7517677a..8423f6d3 100644 --- a/src/HYDROData/HYDROData_GeomTool.cxx +++ b/src/HYDROData/HYDROData_GeomTool.cxx @@ -23,6 +23,7 @@ #include #include +#include #ifdef WIN32 #pragma warning ( disable: 4251 ) @@ -31,11 +32,15 @@ #include #include +#include +#include + #ifdef WIN32 #pragma warning ( default: 4251 ) #endif #include +#include #include static int _argc = 0; @@ -155,6 +160,41 @@ GEOM::GEOM_Object_ptr HYDROData_GeomTool::publishShapeInGEOM( return aGeomObj._retn(); } + +GEOM::GEOM_Object_ptr HYDROData_GeomTool::ExplodeShapeInGEOMandPublish( GEOM::GEOM_Gen_var theGeomEngine, + SALOMEDS::Study_ptr theStudy, + const TopoDS_Shape& theShape, + const NCollection_IndexedDataMap& aFacesToNameModif, + const QString& theName, + QString& theGeomObjEntry) +{ + GEOM::GEOM_Object_ptr aGeomObj = HYDROData_GeomTool::publishShapeInGEOM( theGeomEngine, theStudy, theShape, theName, theGeomObjEntry ); + + GEOM::GEOM_IShapesOperations_var anExpOp = theGeomEngine->GetIShapesOperations( theStudy->StudyId() ); + GEOM::ListOfGO* aFc = anExpOp->MakeExplode(aGeomObj, TopAbs_FACE, false); + + TopTools_MapOfShape mapShape; + + TopExp_Explorer exp (theShape, TopAbs_FACE); + QVector Names; + for (; exp.More(); exp.Next()) + { + const TopoDS_Shape& csh = exp.Current(); + if (mapShape.Add(csh)) + { + //listShape.Append(csh); + QString Qstr = aFacesToNameModif.FindFromKey(csh); + Names.push_back(Qstr); + } + } + + for (size_t i = 0; i < aFc->length(); i++) + GEOMBase::PublishSubObject(aFc->operator[](i), Names[i]); + + return aGeomObj; +} + + GEOM::GEOM_Object_ptr HYDROData_GeomTool::createFaceInGEOM( GEOM::GEOM_Gen_var theGeomEngine, SALOMEDS::Study_ptr theStudy, const int theWidth, diff --git a/src/HYDROData/HYDROData_GeomTool.h b/src/HYDROData/HYDROData_GeomTool.h index 278e6caf..2ffa63cf 100644 --- a/src/HYDROData/HYDROData_GeomTool.h +++ b/src/HYDROData/HYDROData_GeomTool.h @@ -20,6 +20,7 @@ #define HYDROData_GeomTool_HeaderFile #include "HYDROData.h" +#include #ifdef WIN32 #pragma warning ( disable: 4251 ) @@ -113,6 +114,13 @@ public: GEOM::GEOM_Object_ptr theGeomObj, const QString& theName ); + static GEOM::GEOM_Object_ptr ExplodeShapeInGEOMandPublish( GEOM::GEOM_Gen_var theGeomEngine, + SALOMEDS::Study_ptr theStudy, + const TopoDS_Shape& theShape, + const NCollection_IndexedDataMap& aFacesToNameModif, + const QString& theName, + QString& theGeomObjEntry); + }; #endif