Giter Club home page Giter Club logo

meshio's Introduction

CloudCompare Plugin License

MeshIO

This is a plugin for CloudCompare for reading 3D model files (meshes). It uses the Open Asset Import Library (Assimp).

Currently MeshIO supports reading the following formats:

Building

Unfortunately, because of the way CloudCompare is set up, you have to build all of CloudCompare before you can build a plugin for it. So the first thing to do is to get the CloudCompare source and build CloudCompare.

Once you have it building properly:

  • clone this repository into the CloudCompare/plugins/private directory:

    cd CloudCompare/plugins/private
    git clone --recursive https://github.com/asmaloney/MeshIO.git
    
  • re-run CloudCompare's cmake

  • turn on PLUGIN-3rdParty_MESH_IO in the CloudCompare cmake options

  • build CloudCompare

Note: If you are building for CloudCompare 2.11.x, use the tagged version of MeshIO at cloudcompare-2.11.x

Adding Another Format

As long as it is a format supported by Assimp, getting the basics implemented is fairly straightforward (a bunch of copy-paste).

For example, to add a new format "Foo":

  • copy and rename the header & source file of an existing importer (e.g. glTF)
  • add the header & source files to the appropriate CMakeLists.txt files
  • change the FilterInfo info in the constructor for the new format (details of the struct are found in CloudCompare's FileIOFilter.h) - the id should start with MeshIO
    FooFilter::FooFilter() :
        // clang-format off
        mioAbstractLoader( {
            "MeshIO Foo Filter",
            FileIOFilter::DEFAULT_PRIORITY,
            QStringList{ "foo", "bar" },
            "foo",
            QStringList{ "MeshIO - Foo file (*.foo *.bar)" },
            QStringList(),
            Import
        } )
    {
    }
  • add the new importer to MeshIO::getFilters() in MeshIO.cpp:
    ccIOPluginInterface::FilterList MeshIO::getFilters()
    {
      // clang-format off
      return {
          FileIOFilter::Shared( new COLLADAFilter ),
          FileIOFilter::Shared( new glTFFilter ),
          FileIOFilter::Shared( new IFCFilter ),
          FileIOFilter::Shared( new FooFilter ),  // <--
      };
    }
  • set the CMake variable in CMakeLists.txt so that Assimp builds the format:
    set( ASSIMP_BUILD_FOO_IMPORTER TRUE CACHE INTERNAL "override ASSIMP flags" FORCE )

This should result in the basic geometry and materials being loaded.

Next Steps

You may need to massage the data a bit to make it suitable for working with in CloudCompare. For example the IFC importer cleans up some naming, and you might need to clean up object hierarchies. This can be done by overriding mioAbstractLoader::_postProcess().

Once you have it working, please consider contributing it using a pull request.

Caveat

This plugin is using another library to read these file formats. There will be problems with some files (e.g. IFC-SPF is not 100% implemented). It also means that some mesh names might be lost when importing some formats.

Because this plugin is basically translating the Assimp data into something CloudCompare understands, it can be tricky to figure out where the problem lies since it could involve any or all of the three components.

If you find files that do not work as expected, please add an issue here and attach the smallest example you have that isn't working. I will try to assess where the problem lies and either report it to the Assimp project or CloudCompare project as necessary.

Icon

The icon is by qubodup (Public Domain).

License

This project is licensed under the BSD 3-Clause license - see LICENSE file for details.

Individual source files contain the following tag instead of the full license text:

SPDX-License-Identifier: BSD-3-Clause

This enables machine processing of license information based on SPDX License Identifiers.

meshio's People

Contributors

asmaloney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

meshio's Issues

Convert aiCamera to cc2DViewportObject

Describe the solution you'd like

When reading files that have cameras, convert them to cc2DViewportObjects in CC.

Additional context

Should implement something like this in mioUtils:

ccViewportParameters convertCameraToViewport( const aiCamera *inCamera, const aiMatrix4x4 &inTransform );

and then use it in mioAbstractLoader to create the cc2DViewportObjects.

Problems with version modified to use vcpkg

Question
Hello, thank you for your work.
I add the plugin as described by the readme. However, when I load the cloudcompare.exe, the plugin label is disabled(grey), and I can not load the dae and gltf file.

Screenshots
image

Additional context
Add any other context about the problem here.

Your Environment

  • CloudCompare version (2.11.3):
  • OS & Version: windows vs 2015
  • Qt Version: 5.7.0

Ambiguous cast in meta-variant conversion

On CC build, I get

~/src/CloudCompare/plugins/3rdParty/MeshIO/src/mioUtils.cpp: In function ‘QVariant mioUtils::convertMetaValueToVariant(aiMetadata*, unsigned int)’:
~/src/CloudCompare/plugins/3rdParty/MeshIO/src/mioUtils.cpp:388:25: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘QVariant’ is ambiguous
  388 |             metaValue = value;
      |                         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qregularexpression.h:49,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/QRegularExpression:1,
                 from ~/src/CloudCompare/plugins/3rdParty/MeshIO/src/mioUtils.cpp:5:

Reproduction
Follow README build instructions

Expected behavior
No build error

Fix
Simply changing the line to metaValue = (qulonglong) value; fixes it

Environment

  • CloudCompare: 6c2993a
  • OS: Ubuntu 19.10
  • Qt: 5.12.4
  • GCC: 9.2.1

Model disappearing after loading

(By @zyx-99) I'm sorry to bother you again. I use the plug-in to run in cloudcompare2.11.3. When loading COLLADA and glTF model files, the model will only be displayed at the beginning. When I click, rotate, and other operations, it will disappear and become transparent. How should I handle this? Thank you.

When I open the. dae file
1

When I rotate an angle. The model disappear.
2

Originally posted by @zyx-99 in #5 (comment)

Build failed: inflate_fast referenced (zlib issue via assimp lib)

I succeded building CloudCompare alone, but the building process stops rapidly when adding MeshIO throwing codes LNK2019, LNK2001, LNK1120 and MSB3073. Here is the output of Visual Studio 15 2017 x64:

1>------ Build started: Project: translations, Configuration: Release x64 ------
2>------ Build started: Project: translations_fr, Configuration: Release x64 ------
3>------ Build started: Project: translations_ja, Configuration: Release x64 ------
4>------ Build started: Project: translations_ru, Configuration: Release x64 ------
5>------ Build started: Project: zlib, Configuration: Release x64 ------
6>------ Build started: Project: MeshIO, Configuration: Release x64 ------
5>Automatic MOC for target zlib
5> Creating library D:/bouj1a/CCbuild/plugins/3rdParty/MeshIO-master/extern/assimp/contrib/zlib/Release/zlib.lib and object D:/bouj1a/CCbuild/plugins/3rdParty/MeshIO-master/extern/assimp/contrib/zlib/Release/zlib.exp
6>Automatic MOC for target MeshIO
5>inflate.obj : error LNK2019: unresolved external symbol inflate_fast referenced in function inflate
5>infback.obj : error LNK2001: unresolved external symbol inflate_fast
5>D:\bouj1a\CCbuild\plugins\3rdParty\MeshIO-master\extern\assimp\contrib\zlib\Release\zlib.dll : fatal error LNK1120: 1 unresolved externals
5>Done building project "zlib.vcxproj" -- FAILED.
6> Creating library D:/bouj1a/CCbuild/plugins/3rdParty/MeshIO-master/Release/MeshIO.lib and object D:/bouj1a/CCbuild/plugins/3rdParty/MeshIO-master/Release/MeshIO.exp
6>zlibstatic.lib(inflate.obj) : error LNK2019: unresolved external symbol inflate_fast referenced in function inflate
6>D:\bouj1a\CCbuild\plugins\3rdParty\MeshIO-master\Release\MeshIO.dll : fatal error LNK1120: 1 unresolved externals
6>Done building project "MeshIO.vcxproj" -- FAILED.
7>------ Build started: Project: INSTALL, Configuration: Release x64 ------
7>-- Install configuration: "Release"
7>-- Installing: D:/bouj1a/cmake_install_prefix/CloudCompare/CC_CORE_LIB.dll
7>-- Installing: D:/bouj1a/cmake_install_prefix/ccViewer/CC_CORE_LIB.dll
7>-- Installing: D:/bouj1a/cmake_install_prefix/CloudCompare/QCC_DB_LIB.dll
7>-- Installing: D:/bouj1a/cmake_install_prefix/ccViewer/QCC_DB_LIB.dll
7>-- Installing: D:/bouj1a/cmake_install_prefix/CloudCompare/QCC_IO_LIB.dll
7>-- Installing: D:/bouj1a/cmake_install_prefix/ccViewer/QCC_IO_LIB.dll
7>CMake Error at plugins/3rdParty/MeshIO-master/cmake_install.cmake:37 (file):
7> file INSTALL cannot find
7> "D:/bouj1a/CCbuild/plugins/3rdParty/MeshIO-master/Release/MeshIO.dll".
7>Call Stack (most recent call first):
7> plugins/3rdParty/cmake_install.cmake:37 (include)
7> plugins/cmake_install.cmake:39 (include)
7> cmake_install.cmake:43 (include)
7>
7>
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: The command "setlocal
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: :cmEnd
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: :cmErrorLevel
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: exit /b %1
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: :cmDone
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
7>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(138,5): error MSB3073: :VCEnd" exited with code 1.
7>Done building project "INSTALL.vcxproj" -- FAILED.
========== Build: 4 succeeded, 3 failed, 13 up-to-date, 0 skipped ==========

Installation with CMake

I have several errors when i try to install the Plugin via CMake.
The latest error is:
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
CMake Error at CMakeLists.txt:9 (AddPlugin):
Unknown CMake command "AddPlugin".

How To Reproduce

  • Start CMake as Admin on Win10

  • Browse "Where is the Source Code" to C:/Program Files/CloudCompare/plugins/private/MeshIO

  • Browse "Where to build the binaries" to C:/Program Files/CloudCompare/plugins

  • Click on Configure and check "PLUGIN-3rdParty_MESH_IO

  • Click on Configure again and see the following Error:
    Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
    The C compiler identification is MSVC 19.28.29913.0
    The CXX compiler identification is MSVC 19.28.29913.0
    Detecting C compiler ABI info
    Detecting C compiler ABI info - done
    Check for working C compiler: C:/Program Files (x86)/Microsoft Visual
    Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
    Detecting C compile features
    Detecting C compile features - done
    Detecting CXX compiler ABI info
    Detecting CXX compiler ABI info - done
    Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
    Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
    Detecting CXX compile features
    Detecting CXX compile features - done
    CMake Error at CMakeLists.txt:9 (AddPlugin):
    Unknown CMake command "AddPlugin".

    CMake Warning (dev) in CMakeLists.txt:
    No cmake_minimum_required command is present. A line of code such as

    cmake_minimum_required(VERSION 3.20)

    should be added at the top of the file. The version specified may be lower
    if you wish to support older CMake versions for this project. For more
    information run "cmake --help-policy CMP0000".
    This warning is for project developers. Use -Wno-dev to suppress it.

    Configuring incomplete, errors occurred!
    See also "C:/Program Files/CloudCompare/plugins/CMakeFiles/CMakeOutput.log".

Screenshots
Screenshot 2021-04-09 211429

Your Environment

  • CloudCompare version (git hash/tag): v2.11.3
  • OS & Version: Win10 Pro
  • Qt Version: I dont know what QT means

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.