Import: [skip ci] add support of glTF format (requires OCCT 7.5)
This commit is contained in:
@@ -156,6 +156,8 @@ if(OCC_FOUND)
|
||||
)
|
||||
if(OCC_VERSION_STRING VERSION_LESS 6.7.3)
|
||||
list(APPEND OCC_OCAF_LIBRARIES TKAdvTools)
|
||||
elseif(NOT OCC_VERSION_STRING VERSION_LESS 7.5.0)
|
||||
list(APPEND OCC_OCAF_LIBRARIES TKRWMesh)
|
||||
endif(OCC_VERSION_STRING VERSION_LESS 6.7.3)
|
||||
message(STATUS "-- Found OCE/OpenCASCADE version: ${OCC_VERSION_STRING}")
|
||||
message(STATUS "-- OCE/OpenCASCADE include directory: ${OCC_INCLUDE_DIR}")
|
||||
|
||||
@@ -69,6 +69,11 @@
|
||||
# include <TopoDS_Iterator.hxx>
|
||||
# include <APIHeaderSection_MakeHeader.hxx>
|
||||
# include <OSD_Exception.hxx>
|
||||
# include <TColStd_IndexedDataMapOfStringString.hxx>
|
||||
#if OCC_VERSION_HEX >= 0x070500
|
||||
# include <RWGltf_CafWriter.hxx>
|
||||
# include <Message_ProgressRange.hxx>
|
||||
#endif
|
||||
#if OCC_VERSION_HEX >= 0x060500
|
||||
# include <TDataXtd_Shape.hxx>
|
||||
# else
|
||||
@@ -683,6 +688,22 @@ private:
|
||||
throw Py::Exception();
|
||||
}
|
||||
}
|
||||
else if (file.hasExtension("glb") || file.hasExtension("gltf")) {
|
||||
#if OCC_VERSION_HEX >= 0x070500
|
||||
TColStd_IndexedDataMapOfStringString aMetadata;
|
||||
RWGltf_CafWriter aWriter (name8bit.c_str(), file.hasExtension("glb"));
|
||||
aWriter.SetTransformationFormat (RWGltf_WriterTrsfFormat_Compact);
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (0.001);
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (RWMesh_CoordinateSystem_Zup);
|
||||
Standard_Boolean ret = aWriter.Perform (hDoc, aMetadata, Message_ProgressRange());
|
||||
if (!ret) {
|
||||
PyErr_Format(PyExc_IOError, "Cannot save to file '%s'", Utf8Name.c_str());
|
||||
throw Py::Exception();
|
||||
}
|
||||
#else
|
||||
throw Py::RuntimeError("gITF support requires OCCT 7.5.0 or later");
|
||||
#endif
|
||||
}
|
||||
|
||||
hApp->Close(hDoc);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
# Registered in Part's Init.py file
|
||||
FreeCAD.changeImportModule("STEP with colors (*.step *.stp)","Import","ImportGui")
|
||||
FreeCAD.changeExportModule("STEP with colors (*.step *.stp)","Import","ImportGui")
|
||||
FreeCAD.addExportType("glTF (*.gltf *.glb)","ImportGui")
|
||||
|
||||
"""
|
||||
class ImportWorkbench ( Workbench ):
|
||||
|
||||
Reference in New Issue
Block a user