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.
This commit is contained in:
eap 2018-09-05 13:59:48 +03:00
parent 2b52706653
commit ddca8a32b0
2 changed files with 35 additions and 11 deletions

View File

@ -434,6 +434,10 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_BaseObject)& theObject)
if(!_document) if(!_document)
return false; // document is closed... 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 //Remove an object from the map of available objects
TCollection_AsciiString anID = BuildIDFromObject(theObject); TCollection_AsciiString anID = BuildIDFromObject(theObject);
if (_objects.IsBound(anID)) { if (_objects.IsBound(anID)) {
@ -462,7 +466,6 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_BaseObject)& theObject)
aNode->Remove(); aNode->Remove();
} }
TDF_Label aLabel = theObject->GetEntry();
aLabel.ForgetAllAttributes(Standard_True); aLabel.ForgetAllAttributes(Standard_True);
// Remember the label to reuse it then // Remember the label to reuse it then
@ -1360,7 +1363,7 @@ void ReplaceVariables(TCollection_AsciiString& theCommand,
if(MYDEBUG) { if(MYDEBUG) {
cout<<"Variables from SObject:"<<endl; cout<<"Variables from SObject:"<<endl;
for (int i = 0; i < aVariables.size();i++) for (size_t i = 0; i < aVariables.size();i++)
cout<<"\t Variable["<<i<<"] = "<<aVariables[i].myVariable<<endl; cout<<"\t Variable["<<i<<"] = "<<aVariables[i].myVariable<<endl;
} }
@ -1377,7 +1380,7 @@ void ReplaceVariables(TCollection_AsciiString& theCommand,
//Replace parameters by variables //Replace parameters by variables
Standard_Integer aStartPos = 0; Standard_Integer aStartPos = 0;
Standard_Integer aEndPos = 0; Standard_Integer aEndPos = 0;
int iVar = 0; size_t iVar = 0;
TCollection_AsciiString aVar, aReplacedVar; TCollection_AsciiString aVar, aReplacedVar;
for(Standard_Integer i=aFirstParam;i <= aTotalNbParams;i++) { for(Standard_Integer i=aFirstParam;i <= aTotalNbParams;i++) {
//Replace first parameter (bettwen '(' character and first ',' character) //Replace first parameter (bettwen '(' character and first ',' character)
@ -1911,7 +1914,7 @@ ObjectStates::~ObjectStates()
//================================================================================ //================================================================================
TState ObjectStates::GetCurrectState() const TState ObjectStates::GetCurrectState() const
{ {
if(_states.size() > _dumpstate) if((int)_states.size() > _dumpstate)
return _states[_dumpstate]; return _states[_dumpstate];
return TState(); return TState();
} }

View File

@ -1098,6 +1098,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(GEOM::GEOM_Object_ptr theObject,
// Reconstruct arguments and tree of sub-shapes of the arguments // Reconstruct arguments and tree of sub-shapes of the arguments
CORBA::String_var anIOR; CORBA::String_var anIOR;
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
for (Standard_Integer i = 0; i < aLength; i++) for (Standard_Integer i = 0; i < aLength; i++)
{ {
GEOM::GEOM_Object_var anArgO = aList[i]; GEOM::GEOM_Object_var anArgO = aList[i];
@ -1264,7 +1265,10 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(GEOM::GEOM_Object_ptr theObject,
if (!CORBA::is_nil(anArgSO)) { if (!CORBA::is_nil(anArgSO)) {
SALOMEDS::SObject_var aSubSO; SALOMEDS::SObject_var aSubSO;
if (!CORBA::is_nil(theSObject)) if (!CORBA::is_nil(theSObject))
{
aSubSO = aStudyBuilder->NewObject(theSObject); aSubSO = aStudyBuilder->NewObject(theSObject);
useCaseBuilder->AppendTo( theSObject, aSubSO );
}
// Restore published sub-shapes of the argument // Restore published sub-shapes of the argument
GEOM::ListOfGO_var aSubParts = GEOM::ListOfGO_var aSubParts =
@ -1406,6 +1410,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::SObject_ptr th
return aParts._retn(); return aParts._retn();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
// Get interface, containing method, which we will use to reconstruct sub-shapes // Get interface, containing method, which we will use to reconstruct sub-shapes
GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(); GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations();
@ -1524,6 +1529,10 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::SObject_ptr th
if (anOldSubO->GetMarkerType() == GEOM::MT_USER) if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture()); aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
} }
// reference to arg
SALOMEDS::SObject_wrap aReferenceSO = aStudyBuilder->NewObject( aNewSubSO );
aStudyBuilder->Addreference( aReferenceSO, anOldSubSO );
useCaseBuilder->AppendTo( theNewSO, aReferenceSO );
} }
// Restore published sub-shapes of the argument // Restore published sub-shapes of the argument
GEOM::ListOfGO_var aSubParts; GEOM::ListOfGO_var aSubParts;
@ -1540,8 +1549,10 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::SObject_ptr th
else { // GetInPlace failed, try to build from published parts else { // GetInPlace failed, try to build from published parts
SALOMEDS::SObject_var aNewSubSO; SALOMEDS::SObject_var aNewSubSO;
if (!CORBA::is_nil(theNewSO)) if (!CORBA::is_nil(theNewSO))
{
aNewSubSO = aStudyBuilder->NewObject(theNewSO); aNewSubSO = aStudyBuilder->NewObject(theNewSO);
useCaseBuilder->AppendTo( theNewSO, aNewSubSO );
}
// Restore published sub-shapes of the argument // Restore published sub-shapes of the argument
GEOM::ListOfGO_var aSubParts = GEOM::ListOfGO_var aSubParts =
RestoreSubShapesOneLevel(anOldSubSO, aNewSubSO, RestoreSubShapesOneLevel(anOldSubSO, aNewSubSO,
@ -1696,6 +1707,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(GEOM::GEOM_Object_ptr theObj
// Reconstruct arguments and tree of sub-shapes of the arguments // Reconstruct arguments and tree of sub-shapes of the arguments
CORBA::String_var anIOR; CORBA::String_var anIOR;
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
for (Standard_Integer i = 0; i < nbArgsActual; i++) for (Standard_Integer i = 0; i < nbArgsActual; i++)
{ {
GEOM::GEOM_Object_var anArgO = aList[i]; GEOM::GEOM_Object_var anArgO = aList[i];
@ -1814,8 +1826,10 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(GEOM::GEOM_Object_ptr theObj
if (!CORBA::is_nil(anArgSO)) { if (!CORBA::is_nil(anArgSO)) {
SALOMEDS::SObject_var aSubSO; SALOMEDS::SObject_var aSubSO;
if (!CORBA::is_nil(theSObject)) if (!CORBA::is_nil(theSObject))
{
aSubSO = aStudyBuilder->NewObject(theSObject); aSubSO = aStudyBuilder->NewObject(theSObject);
useCaseBuilder->AppendTo( theSObject, aSubSO );
}
// Restore published sub-shapes of the argument // Restore published sub-shapes of the argument
GEOM::ListOfGO_var aSubParts = GEOM::ListOfGO_var aSubParts =
RestoreGivenSubShapesOneLevel(anArgSO, aSubSO, RestoreGivenSubShapesOneLevel(anArgSO, aSubSO,
@ -1950,6 +1964,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesOneLevel (SALOMEDS::SObject_ptr
return aParts._retn(); return aParts._retn();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
// Get interface, containing method, which we will use to reconstruct sub-shapes // Get interface, containing method, which we will use to reconstruct sub-shapes
GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(); GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations();
@ -2073,6 +2088,10 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesOneLevel (SALOMEDS::SObject_ptr
if (anOldSubO->GetMarkerType() == GEOM::MT_USER) if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture()); aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
} }
// reference to arg
SALOMEDS::SObject_wrap aReferenceSO = aStudyBuilder->NewObject( aNewSubSO );
aStudyBuilder->Addreference( aReferenceSO, anOldSubSO );
useCaseBuilder->AppendTo( theNewSO, aReferenceSO );
} }
// Restore published sub-shapes of the argument // Restore published sub-shapes of the argument
GEOM::ListOfGO_var aSubParts; GEOM::ListOfGO_var aSubParts;
@ -2089,8 +2108,10 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesOneLevel (SALOMEDS::SObject_ptr
else { // GetInPlace failed, try to build from published parts else { // GetInPlace failed, try to build from published parts
SALOMEDS::SObject_var aNewSubSO; SALOMEDS::SObject_var aNewSubSO;
if (!CORBA::is_nil(theNewSO)) if (!CORBA::is_nil(theNewSO))
{
aNewSubSO = aStudyBuilder->NewObject(theNewSO); aNewSubSO = aStudyBuilder->NewObject(theNewSO);
useCaseBuilder->AppendTo( theNewSO, aNewSubSO );
}
// Restore published sub-shapes of the argument // Restore published sub-shapes of the argument
GEOM::ListOfGO_var aSubParts = GEOM::ListOfGO_var aSubParts =
RestoreGivenSubShapesOneLevel(anOldSubSO, aNewSubSO, RestoreGivenSubShapesOneLevel(anOldSubSO, aNewSubSO,