From 5d596454037e662a3f2706be9c716118ec96bc3a Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 5 Sep 2018 14:21:30 +0300 Subject: [PATCH 1/2] 23586: [EDF] HYDRO: Copy mesh to new geometry --- GEOM_Gen_i.cc --- In order to assure safe and fast search of initial groups by groups of the new geometry, behavior of GEOM_Gen operations that implement searching and publishing of new groups corresponding to initial groups, is slightly modified. A reference to an initial sub-object is published under a corresponding new sub-object. The modified functions are RestoreSubShapesO(), RestoreGivenSubShapesO() and RestoreSubShapesSO(). --- GEOM_Engine.cxx --- Avoid double removal of GEOM_BaseObject that leads to removal of all attributes from the root TDF label. That caused some regression, don't remember which. --- src/GEOM/GEOM_Engine.cxx | 11 +++++++---- src/GEOM_I/GEOM_Gen_i.cc | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index dd4bc1012..e0fb46fe2 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -482,6 +482,10 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_BaseObject)& theObject) if(!_mapIDDocument.IsBound(aDocID)) return false; // document is closed... + TDF_Label aLabel = theObject->GetEntry(); + if ( aLabel == aLabel.Root() ) + return false; // already removed object + //Remove an object from the map of available objects TCollection_AsciiString anID = BuildIDFromObject(theObject); if (_objects.IsBound(anID)) { @@ -510,7 +514,6 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_BaseObject)& theObject) aNode->Remove(); } - TDF_Label aLabel = theObject->GetEntry(); aLabel.ForgetAllAttributes(Standard_True); // Remember the label to reuse it then @@ -1432,7 +1435,7 @@ void ReplaceVariables(TCollection_AsciiString& theCommand, if(MYDEBUG) { cout<<"Variables from SObject:"< #include +#include class GEOM_Engine; class GEOM_Object; @@ -329,6 +330,10 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere, Handle(GEOM_Object) theShapeWhat); + Standard_EXPORT void GetInPlaceMap (Handle(GEOM_Object) theShapeWhere, + Handle(GEOM_Object) theShapeWhat, + std::vector< std::vector< int > > & theResVec); + /*! * \brief Searches a shape equal to theWhat in the context of theWhere * \param theShapeWhere - a context shap diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc index 6aa10a803..c9f451328 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.cc +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -35,6 +35,8 @@ #include #include +#include + /** * This function converts GEOM::comparison_condition type into * GEOMUtils::ComparisonCondition type. @@ -1985,6 +1987,39 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory return GetObject(anObject); } +//============================================================================= +/*! + * GetInPlaceMap + */ +//============================================================================= +GEOM::ListOfListOfLong* +GEOM_IShapesOperations_i::GetInPlaceMap (GEOM::GEOM_Object_ptr theShapeWhere, + GEOM::GEOM_Object_ptr theShapeWhat) +{ + GEOM::ListOfListOfLong_var aResult = new GEOM::ListOfListOfLong(); + + //Get the reference objects + Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere); + Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat); + + if (!aShapeWhere.IsNull() && + !aShapeWhat.IsNull()) + { + std::vector< std::vector< int > > resVec; + GetOperations()->GetInPlaceMap(aShapeWhere, aShapeWhat, resVec); + + aResult->length( resVec.size() ); + for ( size_t i = 0; i < resVec.size(); ++i ) + { + //if ( !resVec[i].empty() ) + aResult[i].length( resVec[i].size() ); + for ( size_t j = 0; j < resVec[i].size(); ++j ) + aResult[i][j] = resVec[i][j]; + } + } + return aResult._retn(); +} + //============================================================================= /*! * GetSame diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.hh b/src/GEOM_I/GEOM_IShapesOperations_i.hh index c48e6b7e1..f9e457629 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.hh +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -279,6 +279,9 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : GEOM::GEOM_Object_ptr GetInPlaceByHistory (GEOM::GEOM_Object_ptr theShapeWhere, GEOM::GEOM_Object_ptr theShapeWhat); + GEOM::ListOfListOfLong* GetInPlaceMap(GEOM::GEOM_Object_ptr theShapeWhere, + GEOM::GEOM_Object_ptr theShapeWhat); + GEOM::GEOM_Object_ptr GetSame (GEOM::GEOM_Object_ptr theShapeWhere, GEOM::GEOM_Object_ptr theShapeWhat); diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index e3b56a228..b28117581 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -5960,6 +5960,38 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(anObj, theName, "inplace") return anObj + ## A sort of GetInPlace functionality, returning IDs of sub-shapes. + # For each sub-shape ID of @a theShapeWhat return a list of corresponding sub-shape + # IDs of @a theShapeWhere. + # For example, if theShapeWhat is a box and theShapeWhere is this box cut into + # two parts by a plane, then the result can be as this: + # len( result_list ) = 35, + # result_list[ 1 ] = [ 2, 36 ], which means that the box (ID 1) turned into two + # solids with IDs 2 and 36 within theShapeWhere + # + # @param theShapeWhere Shape to find sub-shapes of. + # @param theShapeWhat Shape, specifying what to find. + # @return List of lists of sub-shape IDS of theShapeWhere. + def GetInPlaceMap(self, theShapeWhere, theShapeWhat): + """ + A sort of GetInPlace functionality, returning IDs of sub-shapes. + For each sub-shape ID of @a theShapeWhat return a list of corresponding sub-shape + IDs of @a theShapeWhere. + For example, if theShapeWhat is a box and theShapeWhere is this box cut into + two parts by a plane, then the result can be as this: + len( result_list ) = 35, + result_list[ 1 ] = [ 2, 36 ], which means that the box (ID 1) turned into two + solids with IDs 2 and 36 within theShapeWhere + + Parameters: + theShapeWhere Shape to find sub-shapes of. + theShapeWhat Shape, specifying what to find. + + Returns: + List of lists of sub-shape IDS of theShapeWhere. + """ + return self.ShapesOp.GetInPlaceMap(theShapeWhere, theShapeWhat) + ## Get sub-shape of theShapeWhere, which is # equal to \a theShapeWhat. # @param theShapeWhere Shape to find sub-shape of.