PAL13703: addition to previous integration (see GEOM_Object.cxx, GEOM_Function.cxx) to provide right treatment of groups

This commit is contained in:
jfa 2006-12-11 10:29:28 +00:00
parent a25fd83519
commit e33d834b6e

View File

@ -17,6 +17,7 @@
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
#include <GEOMImpl_IGroupOperations.hxx> #include <GEOMImpl_IGroupOperations.hxx>
@ -81,7 +82,7 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1);
anArray->SetValue(1, -1); anArray->SetValue(1, -1);
//Add a new Fillet object //Add a new Sub-shape object
Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theMainShape, anArray); Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theMainShape, anArray);
//Set a GROUP type //Set a GROUP type
@ -119,9 +120,9 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS
// Check sub-shape index validity // Check sub-shape index validity
TDF_Label aLabel = aSSI.GetMainShape()->GetOwnerEntry(); TDF_Label aLabel = aSSI.GetMainShape()->GetOwnerEntry();
if (aLabel.IsRoot()) return; if (aLabel.IsRoot()) return;
Handle(GEOM_Object) anObj = GEOM_Object::GetObject(aLabel); Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
if (anObj.IsNull()) return; if (aMainObj.IsNull()) return;
TopoDS_Shape aMainShape = anObj->GetValue(); TopoDS_Shape aMainShape = aMainObj->GetValue();
if (aMainShape.IsNull()) return; if (aMainShape.IsNull()) return;
TopTools_IndexedMapOfShape aMapOfShapes; TopTools_IndexedMapOfShape aMapOfShapes;
@ -152,6 +153,10 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS
aSSI.SetIndices(aNewSeq); aSSI.SetIndices(aNewSeq);
} }
// As we do not recompute here our group, lets mark it as Modified
Standard_Integer aTic = aMainObj->GetTic(); // tic of main shape
theGroup->SetTic(aTic - 1);
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction, /*append=*/true) GEOM::TPythonDump(aFunction, /*append=*/true)
<< "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")"; << "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")";
@ -176,44 +181,52 @@ void GEOMImpl_IGroupOperations::RemoveObject (Handle(GEOM_Object) theGroup, int
GEOM_ISubShape aSSI(aFunction); GEOM_ISubShape aSSI(aFunction);
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices(); Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
if(aSeq.IsNull()) return; if(aSeq.IsNull()) return;
if(aSeq->Length() == 1 && aSeq->Value(1) == -1) { if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
SetErrorCode(NOT_EXISTS); SetErrorCode(NOT_EXISTS);
return; return;
} }
else {
Handle(TColStd_HArray1OfInteger) aNewSeq; Handle(TColStd_HArray1OfInteger) aNewSeq;
Standard_Integer aLength = aSeq->Length(); Standard_Integer aLength = aSeq->Length();
if(aLength == 1) { if(aLength == 1) {
if(aSeq->Value(1) != theSubShapeID) { if(aSeq->Value(1) != theSubShapeID) {
SetErrorCode(NOT_EXISTS); SetErrorCode(NOT_EXISTS);
return; return;
}
aNewSeq = new TColStd_HArray1OfInteger(1,1);
aNewSeq->SetValue(1, -1);
} }
else { aNewSeq = new TColStd_HArray1OfInteger(1,1);
aNewSeq = new TColStd_HArray1OfInteger(1, aLength-1); aNewSeq->SetValue(1, -1);
Standard_Boolean isFound = Standard_False; }
for (Standard_Integer i = 1, k = 1; i <= aLength; i++) { else {
if (aSeq->Value(i) == theSubShapeID) { aNewSeq = new TColStd_HArray1OfInteger(1, aLength-1);
isFound = Standard_True; Standard_Boolean isFound = Standard_False;
} else { for (Standard_Integer i = 1, k = 1; i <= aLength; i++) {
if (k < aLength) { // this check is to avoid sequence <aNewSeq> overflow if (aSeq->Value(i) == theSubShapeID) {
aNewSeq->SetValue(k, aSeq->Value(i)); isFound = Standard_True;
k++; } else {
} if (k < aLength) { // this check is to avoid sequence <aNewSeq> overflow
aNewSeq->SetValue(k, aSeq->Value(i));
k++;
} }
} }
if (!isFound) {
SetErrorCode(NOT_EXISTS);
return;
}
} }
aSSI.SetIndices(aNewSeq); if (!isFound) {
SetErrorCode(NOT_EXISTS);
return;
}
} }
aSSI.SetIndices(aNewSeq);
// As we do not recompute here our group, lets mark it as Modified
TDF_Label aLabel = aSSI.GetMainShape()->GetOwnerEntry();
if (aLabel.IsRoot()) return;
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
if (aMainObj.IsNull()) return;
Standard_Integer aTic = aMainObj->GetTic(); // tic of main shape
theGroup->SetTic(aTic - 1);
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction, /*append=*/true) GEOM::TPythonDump(aFunction, /*append=*/true)
<< "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")"; << "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")";
@ -346,6 +359,10 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
} }
aSSI.SetIndices(aNewSeq); aSSI.SetIndices(aNewSeq);
// As we do not recompute here our group, lets mark it as Modified
Standard_Integer aTic = aMainObj->GetTic(); // tic of main shape
theGroup->SetTic(aTic - 1);
} }
//Make a Python command //Make a Python command
@ -476,6 +493,10 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
} }
aSSI.SetIndices(aNewSeq); aSSI.SetIndices(aNewSeq);
// As we do not recompute here our group, lets mark it as Modified
Standard_Integer aTic = aMainObj->GetTic(); // tic of main shape
theGroup->SetTic(aTic - 1);
} }
//Make a Python command //Make a Python command
@ -566,6 +587,10 @@ void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
} }
aSSI.SetIndices(aNewSeq); aSSI.SetIndices(aNewSeq);
// As we do not recompute here our group, lets mark it as Modified
Standard_Integer aTic = aMainObj->GetTic(); // tic of main shape
theGroup->SetTic(aTic - 1);
} }
//Make a Python command //Make a Python command
@ -651,6 +676,10 @@ void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
} }
aSSI.SetIndices(aNewSeq); aSSI.SetIndices(aNewSeq);
// As we do not recompute here our group, lets mark it as Modified
Standard_Integer aTic = aMainObj->GetTic(); // tic of main shape
theGroup->SetTic(aTic - 1);
} }
//Make a Python command //Make a Python command