Fri, 12/09/2016 - 17:46
Hello,
I have compiled this sample and it could work now.The problem is ,all the shapes' color was Quantity_Color(1.0, 0.73, 0.2, Quantity_TOC_RGB),which set by aShapePrs in your code after I imported an iges file.
I tried the IGESCAFControl_Reader like this:
IGESCAFControl_Reader Reader;//(XSDRAW::Session(), Standard_False);no libTKXSDRAW.so in the ARM's compiled result.
Standard_Integer status = Reader.ReadFile(strFile.c_str());
if (status != IFSelect_RetDone)
{
return status;
}
WriteLog("transfer begin!");
Reader.SetColorMode(Standard_True);
Handle(TDocStd_Document) aDoc;//how to initialize this document in the Qt's android platform?
Standard_Boolean ok = Reader.Transfer(aDoc);
if(ok == Standard_False)
{
WriteLog("transfer failed!");
Reader.TransferRoots();
}
else
{
WriteLog("transfer succeed!");
}
aShape = Reader.OneShape();
Then it crashed in the method "Transfer(aDoc)".
So,what's the problem? Is it related to those questions I asked in the notes? How to display the elements' color in this sample?
Need your help very badly. Thanks very much!
Fri, 12/09/2016 - 18:09
Please erase the extra topic,dear administrator,it is just because the broken network between us.
Sat, 12/10/2016 - 05:05
The last situation is,crash has been fixed by define doc like this:
Handle(TDocStd_Document) aDoc = new TDocStd_Document("IgesReader");
But the shapes' color was still Quantity_Color(1.0, 0.73, 0.2, Quantity_TOC_RGB),although I erased this line:
aShapePrs->SetColor (Quantity_Color(1.0, 0.73, 0.2, Quantity_TOC_RGB));
Sat, 12/10/2016 - 12:08
I have solved this problem according to the chm document.The answer is like this:
Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(aDoc->Main());
myContext->EraseAll (Standard_False);
int iSize(0);
TDF_LabelSequence cls;
myColors->GetColors(cls);
TDF_LabelSequence frshapes;
myAssembly->GetShapes(frshapes);
Standard_Integer iShapesCount = frshapes.Length();
for(Standard_Integer i = 1;i<= iShapesCount;i++)
{
const TDF_Label& slabel = frshapes.Value(i);
if (myColors->IsSet (slabel,XCAFDoc_ColorGen))
{
Quantity_Color col;
if ( !myColors->GetColor(slabel, XCAFDoc_ColorGen, col) )
{
continue;
}
TopoDS_Shape TmpShape = myAssembly->GetShape(slabel);
if(TmpShape.IsNull())
{
continue;
}
Handle(AIS_Shape) aShapePrs = new AIS_Shape (TmpShape);
aShapePrs->SetColor (col);
myContext->Display(aShapePrs, Standard_False);
myContext->SetDisplayMode (aShapePrs, AIS_Shaded, Standard_False);
iSize++;
}
}
I must say that opencascade is great!