From 6e2ed1c49b2d2a60386c3081b157b2623dbf6802 Mon Sep 17 00:00:00 2001 From: Hugues Delorme Date: Thu, 9 Nov 2023 09:15:11 +0100 Subject: [PATCH] IO_Assimp: WIP3 --- mayo.pro | 16 +++++++++++++++- src/io_assimp/io_assimp_reader.cpp | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/mayo.pro b/mayo.pro index 98bf21e8..1a876640 100644 --- a/mayo.pro +++ b/mayo.pro @@ -191,27 +191,41 @@ versionAtLeast(OCC_VERSION_STR, 7.4.0) { src/io_occ/io_occ_base_mesh.cpp \ src/io_occ/io_occ_gltf_reader.cpp \ src/io_occ/io_occ_obj_reader.cpp + + message(glTF reader disabled because OpenCascade < v7.4) + message(OBJ reader disabled because OpenCascade < v7.4) } !versionAtLeast(OCC_VERSION_STR, 7.5.0) { SOURCES -= src/io_occ/io_occ_gltf_writer.cpp + message(glTF writer disabled because OpenCascade < v7.5) } !versionAtLeast(OCC_VERSION_STR, 7.6.0) { SOURCES -= src/io_occ/io_occ_obj_writer.cpp + message(OBJ writer disabled because OpenCascade < v7.6) } # -- VRML support LIBS += -lTKVRML !versionAtLeast(OCC_VERSION_STR, 7.7.0) { SOURCES -= src/io_occ/io_occ_vrml_reader.cpp + message(VRML reader disabled because OpenCascade < v7.7) } # assimp isEmpty(ASSIMP_INC_DIR) | isEmpty(ASSIMP_LIB_DIR) { message(assimp OFF) } else { - message(assimp ON) + !versionAtLeast(OCC_VERSION_STR, 7.5.0) { + message(assimp reader disabled because OpenCascade < v7.5) + } + else { + message(assimp ON) + ASSIMP_IS_ON = 1 + } +} +defined(ASSIMP_IS_ON, var) { HEADERS += $$files(src/io_assimp/*.h) SOURCES += $$files(src/io_assimp/*.cpp) diff --git a/src/io_assimp/io_assimp_reader.cpp b/src/io_assimp/io_assimp_reader.cpp index d70fd212..e7d39af4 100644 --- a/src/io_assimp/io_assimp_reader.cpp +++ b/src/io_assimp/io_assimp_reader.cpp @@ -59,7 +59,13 @@ aiVector3D aiMatrixScaling(const aiMatrix4x4& trsf) bool hasScaleFactor(const gp_Trsf& trsf) { - return (Abs(Abs(trsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec()) || trsf.IsNegative(); + const double topLocationScalePrec = +#if OCC_VERSION_HEX >= OCC_VERSION_CHECK(7, 6, 0) + TopLoc_Location::ScalePrec(); +#else + 1.e-14; +#endif + return (Abs(Abs(trsf.ScaleFactor()) - 1.) > topLocationScalePrec) || trsf.IsNegative(); } bool hasScaleFactor(const aiVector3D& scaling) @@ -443,11 +449,15 @@ Handle(XCAFDoc_VisMaterial) AssimpReader::createOccVisMaterial( { int flag; if (material->Get(AI_MATKEY_TWOSIDED, flag) == aiReturn_SUCCESS) { +#if OCC_VERSION_HEX >= OCC_VERSION_CHECK(7, 6, 0) mat->SetFaceCulling( flag ? Graphic3d_TypeOfBackfacingModel_DoubleSided : Graphic3d_TypeOfBackfacingModel_BackCulled - ); + ); +#else + mat->SetDoubleSided(flag != 0); +#endif } }