-
- // Get interface, containing method, which we will use to reconstruct sub-shapes
- GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
- GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
-
- // Reconstruct arguments and tree of sub-shapes of the arguments
- CORBA::String_var anIOR;
- SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
- for (Standard_Integer i = 0; i < aLength; i++)
- {
- GEOM::GEOM_Object_var anArgO = aList[i];
- if (!CORBA::is_nil(anArgO)) {
- anIOR = _orb->object_to_string(anArgO);
- SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
- TCollection_AsciiString anArgName;
- if (CORBA::is_nil(anArgSO)) {
- anArgName = "arg_";
- anArgName += TCollection_AsciiString(i);
- }
- else {
- anArgName = anArgSO->GetName();
- }
-
- // Find a sub-shape of theObject in place of the argument
- GEOM::GEOM_Object_var aSubO;
- switch (theFindMethod) {
- case GEOM::FSM_GetInPlace:
- {
- // Use GetInPlace
- aSubO = aShapesOp->GetInPlace(theObject, anArgO);
- }
- break;
- case GEOM::FSM_Transformed:
- {
- // transformation, cannot use GetInPlace, operate with indices
- GEOM::ListOfLong_var anIDs = anArgO->GetSubShapeIndices();
- if (anIDs->length() > 1) {
- // group
- aSubO = aGroupOp->CreateGroup(theObject, aGroupOp->GetType(anArgO));
- if (!CORBA::is_nil(aSubO))
- aGroupOp->UnionIDs(aSubO, anIDs);
- }
- else {
- // single sub-shape
- aSubO = aShapesOp->GetSubShape(theObject, anIDs[0]);
- }
- }
- break;
- case GEOM::FSM_GetSame:
- {
- // Use GetSame
- aSubO = aShapesOp->GetSame(theObject, anArgO);
- }
- break;
- case GEOM::FSM_GetShapesOnShape:
- {
- // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
- aSubO = aShapesOp->GetShapesOnShapeAsCompound(anArgO, theObject,
- (short)GEOM::SOLID, GEOM::ST_ONIN);
- }
- break;
- case GEOM::FSM_GetInPlaceByHistory:
- {
- // Use GetInPlaceByHistory
- aSubO = aShapesOp->GetInPlaceByHistory(theObject, anArgO);
- }
- break;
- default:
- {}
- }
-
- if (!CORBA::is_nil(aSubO)) {
- // Publish the sub-shape
- TCollection_AsciiString aSubName ("from_");
- aSubName += anArgName;
- SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(theSObject);
- aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
- // Restore color
- aSubO->SetColor(anArgO->GetColor());
-
- if (!CORBA::is_nil(anArgSO)) {
- // Restore published sub-shapes of the argument
- if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
- // pass theObject, because only it has the history
- RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, theObject, theFindMethod);
- else
- RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, aSubO, theFindMethod);
- }
+ else {
+ // Get interface, containing method, which we will use to reconstruct sub-shapes
+ GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
+ GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
+
+ // Reconstruct arguments and tree of sub-shapes of the arguments
+ CORBA::String_var anIOR;
+ SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+ for (Standard_Integer i = 0; i < aLength; i++)
+ {
+ GEOM::GEOM_Object_var anArgO = aList[i];
+ if (!CORBA::is_nil(anArgO)) {
+ anIOR = _orb->object_to_string(anArgO);
+ SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in());
+ TCollection_AsciiString anArgName;
+ if (CORBA::is_nil(anArgSO)) {
+ anArgName = "arg_";
+ anArgName += TCollection_AsciiString(i);
+ }
+ else {
+ anArgName = anArgSO->GetName();
+ }
+
+ // Find a sub-shape of theObject in place of the argument
+ GEOM::GEOM_Object_var aSubO;
+ switch (theFindMethod) {
+ case GEOM::FSM_GetInPlace:
+ {
+ // Use GetInPlace
+ aSubO = aShapesOp->GetInPlace(theObject, anArgO);
+ }
+ break;
+ case GEOM::FSM_Transformed:
+ {
+ // transformation, cannot use GetInPlace, operate with indices
+ GEOM::ListOfLong_var anIDs = anArgO->GetSubShapeIndices();
+ if (anIDs->length() > 1) {
+ // group
+ aSubO = aGroupOp->CreateGroup(theObject, aGroupOp->GetType(anArgO));
+ if (!CORBA::is_nil(aSubO))
+ aGroupOp->UnionIDs(aSubO, anIDs);
+ }
+ else if (anIDs->length() > 0) {
+ // single sub-shape
+ aSubO = aShapesOp->GetSubShape(theObject, anIDs[0]);
+ }
+ }
+ break;
+ case GEOM::FSM_GetSame:
+ {
+ // Use GetSame
+ aSubO = aShapesOp->GetSame(theObject, anArgO);
+ }
+ break;
+ case GEOM::FSM_GetShapesOnShape:
+ {
+ // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
+ aSubO = aShapesOp->GetShapesOnShapeAsCompound(anArgO, theObject,
+ (short)GEOM::SOLID, GEOM::ST_ONIN);
+ }
+ break;
+ case GEOM::FSM_GetInPlaceByHistory:
+ {
+ // Use GetInPlaceByHistory
+ aSubO = aShapesOp->GetInPlaceByHistory(theObject, anArgO);
+ }
+ break;
+ default:
+ {}
+ }
+
+ if (!CORBA::is_nil(aSubO)) {
+ // add to parts list
+ addToListOfGO( aSubO, aParts );
+
+ // Publish the sub-shape
+ SALOMEDS::SObject_var aSubSO;
+ if (!CORBA::is_nil(theSObject)) {
+ TCollection_AsciiString aSubName;
+ if (theAddPrefix) {
+ aSubName = "from_";
+ }
+ aSubName += anArgName;
+ aSubSO = aStudyBuilder->NewObject(theSObject);
+ aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
+ // Restore color
+ aSubO->SetColor(anArgO->GetColor());
+ }
+
+ if (!CORBA::is_nil(anArgSO)) {
+ // Restore published sub-shapes of the argument
+ GEOM::ListOfGO_var aSubParts;
+ if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
+ // pass theObject, because only it has the history
+ aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
+ theObject, theFindMethod, theAddPrefix);
+ else
+ aSubParts = RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
+ aSubO, theFindMethod, theAddPrefix);
+ // add to parts list
+ addToListOfGO( aSubParts, aParts );
+ }
+ }
+ else { // GetInPlace failed, try to build from published parts
+ if (!CORBA::is_nil(anArgSO)) {
+ SALOMEDS::SObject_var aSubSO;
+ if (!CORBA::is_nil(theSObject))
+ aSubSO = aStudyBuilder->NewObject(theSObject);
+
+ // Restore published sub-shapes of the argument
+ GEOM::ListOfGO_var aSubParts =
+ RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO,
+ theObject, theFindMethod, theAddPrefix);
+
+ // add to parts list
+ addToListOfGO( aSubParts, aParts );
+
+ if (aSubParts->length() > 0) {
+ // try to build an argument from a set of its sub-shapes,
+ // that published and will be reconstructed
+ if (aSubParts->length() > 1) {
+ aSubO = aShapesOp->MakeCompound(aSubParts);
+ // add to parts list
+ addToListOfGO( aSubO, aParts );
+ }
+ else {
+ aSubO = aSubParts[0];
+ }
+ if (!CORBA::is_nil(aSubO) && !CORBA::is_nil(aSubSO)) {
+ // Publish the sub-shape
+ TCollection_AsciiString aSubName;
+ if (theAddPrefix) {
+ aSubName = "from_parts_of_";
+ }
+ aSubName += anArgName;
+ aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
+ // Restore color
+ aSubO->SetColor(anArgO->GetColor());
+ }
+ }
+ else if (!CORBA::is_nil(aSubSO)) {
+ // remove created aSubSO, because no parts have been found
+ aStudyBuilder->RemoveObject(aSubSO);
+ }
+ }
+ } // try to build from published parts
+ anArgSO->Destroy();