
Fri, 12/23/2022 - 13:22
Forums:
I'd like to modify the Step file in the loading part. I want to change SetMaterial.
bool ImportStep(const TCollection_AsciiString& theFileName)
{
STEPControl_Reader aReader;
IFSelect_ReturnStatus aStatus = aReader.ReadFile(theFileName.ToCString());
if (aStatus == IFSelect_RetDone)
{
bool isFailsonly = false;
aReader.PrintCheckLoad(isFailsonly, IFSelect_ItemsByEntity);
int aNbRoot = aReader.NbRootsForTransfer();
aReader.PrintCheckTransfer(isFailsonly, IFSelect_ItemsByEntity);
for (Standard_Integer n = 1; n <= aNbRoot; n++)
{
Standard_Boolean ok = aReader.TransferRoot(n);
int aNbShap = aReader.NbShapes();
if (aNbShap > 0)
{
//Handle(AIS_Shape) aModel;
for (int i = 1; i <= aNbShap; i++)
{
TopoDS_Shape aShape = aReader.Shape(i);
myAISContext()->Display(new AIS_Shape(aShape), Standard_False);
myAISContext()->SetMaterial(new AIS_Shape(aShape), Graphic3d_NameOfMaterial_Silver, Standard_True); //Add Code
}
SetDisplayMode(AIS_Shaded); // Add Code
myAISContext()->UpdateCurrentViewer();
}
}
}
else
{
return false;
}
return true;
}