Modification of Location leads to losing of Colors

Hi !
I have one question:
theLabelSequence was created after the reading of a Step-File.
There were a lot of colors;)

after the changing of position, there are no colors ;(

How can I move the shapes without to lost the colors ?

THANK YOU IN ADVANCE
Dmitry Khabi

Code:

static void MakeTransformationForEarchTDFLabel(C_TDF_LabelSequence* theLabelSequence, C_gp_Trsf* theTransformation)
{
if(theLabelSequence!=NULL && theTransformation!=NULL)
{
TopLoc_Location aLocation = TopLoc_Location(theTransformation->itsGp_Trsf);
unsigned long aLength = theLabelSequence->Length();
for(unsigned long i = 1; i {
TDF_Label aLabel = theLabelSequence->itsTDF_LabelSequence->Value(i);
Handle(TNaming_NamedShape) aTNS;
if (aLabel.FindAttribute(TNaming_NamedShape::GetID(), aTNS))
{

TopoDS_Shape aShape = TNaming_Tool::GetShape(aTNS);
TNaming_Builder ABuilder(aLabel);
ABuilder.Replace(aShape, aShape.Moved(aLocation));
}
}
}
}

Dirk B's picture

Hello Dmitry!
I just use the shape tool to set the transformed shape to the label. This way the version gets incremented and the links to the colors aren't changed. Here's the code:
if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aShape)){
TopoDS_Shape shOrig = aShape->Get();
brbaTrafo.Perform(shOrig, true);
TopoDS_Shape shNew = brbaTrafo.Shape();
toolShape->SetShape(aLabel, shNew);
}

Dirk

Dmitry Khabi's picture

Hello Dirk,

I have tried your solution.
After 5 minutes of rebuilding I have got an Exception......
Anyway it takes to much time.
I modified my code, now I use your command
static void toolShape->SetShape(aLabel, shNew);

But the colors are lost.......
Where are the Colors ? Did I destroy the references to the color's labels?
Code:
MakeTransformationForEarchTDFLabel(C_TDF_LabelSequence* theLabelSequence, C_gp_Trsf* theTransformation)
{
if(theLabelSequence!=NULL && theTransformation!=NULL)
{
TopLoc_Location aLocation = TopLoc_Location(theTransformation->itsGp_Trsf);
unsigned long aLength = theLabelSequence->Length();
for(unsigned long i = 1; i<=aLength; i++)
{
TDF_Label aLabel = theLabelSequence->itsTDF_LabelSequence->Value(i);
Handle(TNaming_NamedShape) aTNS;
if (aLabel.FindAttribute(TNaming_NamedShape::GetID(), aTNS))
{
TopoDS_Shape aShape = TNaming_Tool::GetShape(aTNS);
TNaming_Builder ABuilder(aLabel);
TopoDS_Shape aNewShape = aShape.Moved(aLocation);
Handle_XCAFDoc_ShapeTool aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aLabel);
aShapeTool->SetShape(aLabel,aNewShape);
}

}
}
}

Dirk B's picture

What kind of exception? I think you have to call XCAFDoc_DocumentTool::ShapeTool using the document root label, but I'm not sure. In any case what helped me a lot was saving the document before and after any operation using the XmlXCAF format and comparing the files.

Dmitry Khabi's picture

I think , this way ist not efficient. I would like to move the Shape, to change the color of the Shape. And the next time, if I show the same Shape (via the same TDF_Label), i would like to see the same Shape.