Mon, 07/13/2020 - 13:54
Forums:
I am trying to convert STP to glTF and it is writing bin file but not writing json file.
Here is my code
const TCollection_AsciiString aFilename = toAsciiString(theFileName);
const TCollection_AsciiString oFilename = toAsciiString("collar-assembly_asm");
Handle(TopTools_HSequenceOfShape) aHSequenceOfShape = new TopTools_HSequenceOfShape();
aHSequenceOfShape->Clear();
Handle(TDocStd_Document) doc;
Handle(XCAFApp_Application) anApp = XCAFApp_Application::GetApplication();
STEPCAFControl_Reader aReader;
aReader.SetColorMode(true);
aReader.SetNameMode(true);
aReader.SetLayerMode(true);
IFSelect_ReturnStatus aStatus = aReader.ReadFile(aFilename.ToCString());
if (aStatus == IFSelect_RetDone)
{
anApp->NewDocument("CONVERTXCAF-DOC", doc);
aReader.Transfer(doc);
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(doc->Main());
Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(doc->Main());
TDF_LabelSequence frshapes;
myAssembly->GetFreeShapes(frshapes);
for (Standard_Integer i = 1; i <= frshapes.Length(); i++) {
const TDF_Label& label = frshapes.Value(i);
TopoDS_Shape shape;
myAssembly->GetShape(label, shape);
BRepMesh_IncrementalMesh(shape, 0.1, Standard_True);
aHSequenceOfShape->Append(shape);
}
TColStd_IndexedDataMapOfStringString gltfMetaData;
RWGltf_CafWriter gltfWrite = RWGltf_CafWriter::RWGltf_CafWriter(oFilename, Standard_False);
gltfWrite.Perform(doc, gltfMetaData, NULL);
}
Mon, 07/13/2020 - 15:18
I have figured it out.
I had not built OCCT with RapidJSON support which is required to write gltf file. I have rebuilt using it and it is fixed.