From 183224f045ba93f9e93d7a8c5e880aa38feaaf22 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 6 Apr 2018 20:51:07 +0200 Subject: [PATCH 1/3] closes https://github.com/assimp/assimp/issues/1621: add file check for dxf file without extensions. --- code/DXFLoader.cpp | 9 +++++++-- doc/dox.h | 48 ++++------------------------------------------ 2 files changed, 11 insertions(+), 46 deletions(-) diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp index 9a13caa33..e4529097d 100644 --- a/code/DXFLoader.cpp +++ b/code/DXFLoader.cpp @@ -119,9 +119,14 @@ DXFImporter::~DXFImporter() // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool DXFImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const +bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const { - return SimpleExtensionCheck(pFile,"dxf"); + if ( checkSig ) { + return SimpleExtensionCheck(pFile,"dxf"); + } else { + static const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" }; + return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 4 ); + } } // ------------------------------------------------------------------------------------------------ diff --git a/doc/dox.h b/doc/dox.h index 5c6de51f1..ece3e31d9 100644 --- a/doc/dox.h +++ b/doc/dox.h @@ -206,56 +206,16 @@ the library files. Alternatively you can simply add the assimp project to your p your solution. -@section use_noboost Building without boost. - -The Boost-Workaround consists of dummy replacements for some boost utility templates. Currently there are replacements for - - - boost.scoped_ptr - - boost.scoped_array - - boost.format - - boost.random - - boost.common_factor - - boost.foreach - - boost.tuple - - boost.make_shared - -These implementations are very limited and are not intended for use outside assimp. A compiler -with full support for partial template specializations is required. To enable the workaround, put the following in -your compiler's list of predefined macros: -@code -#define ASSIMP_BUILD_BOOST_WORKAROUND -@endcode -
-If you're working with the provided solutions for Visual Studio use the -noboost build configs.
- -assimp_BUILD_BOOST_WORKAROUND implies assimp_BUILD_SINGLETHREADED.
-See the @ref assimp_st section -for more details. - - - @section assimp_dll Windows DLL Build -assimp can be built as DLL. You just need to select a -dll config from the list of project -configs and you're fine. +The Assimp-package can be built as DLL. You just need to run the default cmake run. -NOTE: Theoretically, assimp-dll can be used with multithreaded (non-dll) runtime libraries, -as long as you don't utilize any non-public stuff from the code folder. However, if you happen -to encounter *very* strange problems, try changing the runtime to Multithreaded (Debug) DLL. -@section assimp_stlport Building against STLport +@section assimp static lib -STLport is a free, fast and secure STL replacement that works with -all major compilers and platforms. To get it, download the latest release from -. -Usually you'll just need to run 'configure' + a makefile (see their README for more details). -Don't miss to add /stlport to your compiler's default include paths - prior -to the directory where your compiler vendor's headers lie. Do the same for /lib and -recompile assimp. To ensure you're really building against STLport see aiGetCompileFlags(). -
-In our testing, STLport builds tend to be a bit faster than builds against Microsoft's -C++ Standard Library. +The Assimp-package can be build as a static library as well. Do do so just set the configuration variable BUILD_SHARED_LIBS +to off during the cmake run. */ From 5319974fe17f5c02c7e44041c8432cd977b31d8a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 11 Apr 2018 21:16:20 +0200 Subject: [PATCH 2/3] Use correct check to do a tokensearch. --- code/DXFLoader.cpp | 14 +++++++++----- test/unit/utDXFImporterExporter.cpp | 7 +++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/code/DXFLoader.cpp b/code/DXFLoader.cpp index e4529097d..c8aee18dd 100644 --- a/code/DXFLoader.cpp +++ b/code/DXFLoader.cpp @@ -119,14 +119,18 @@ DXFImporter::~DXFImporter() // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const -{ - if ( checkSig ) { - return SimpleExtensionCheck(pFile,"dxf"); - } else { +bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig ) const { + const std::string& extension = GetExtension( pFile ); + if ( extension == "dxf" ) { + return true; + } + + if ( extension.empty() || checkSig ) { static const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" }; return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 4 ); } + + return false; } // ------------------------------------------------------------------------------------------------ diff --git a/test/unit/utDXFImporterExporter.cpp b/test/unit/utDXFImporterExporter.cpp index 1cb23cccf..ee6f34ecd 100644 --- a/test/unit/utDXFImporterExporter.cpp +++ b/test/unit/utDXFImporterExporter.cpp @@ -62,3 +62,10 @@ public: TEST_F( utDXFImporterExporter, importDXFFromFileTest ) { EXPECT_TRUE( importerTest() ); } + +TEST_F( utDXFImporterExporter, importerWithoutExtensionTest ) { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/DXF/lineTest", aiProcess_ValidateDataStructure ); + EXPECT_NE( nullptr, scene ); +} + From 42dcf8c14c19cf737aec0070ba1e21aa2b1da122 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 11 Apr 2018 23:11:13 +0200 Subject: [PATCH 3/3] Add missing test DXF-file. --- test/models/DXF/lineTest | 190 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 test/models/DXF/lineTest diff --git a/test/models/DXF/lineTest b/test/models/DXF/lineTest new file mode 100644 index 000000000..2e16f69fd --- /dev/null +++ b/test/models/DXF/lineTest @@ -0,0 +1,190 @@ +999 +VISION3D DXF +0 +SECTION +2 +HEADER +9 +$ACADVER +1 +AC1006 +9 +$INSBASE +10 +0.0 +20 +0.0 +30 +0.0 +9 +$EXTMIN +10 +0.0 +20 +0.0 +9 +$EXTMAX +10 +1000.0 +20 +1000.0 +9 +$LINMIN +10 +0.0 +20 +0.0 +9 +$LINMAX +10 +1000.0 +20 +1000.0 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +LTYPE +70 +1 +0 +LTYPE +2 +CONTINUOUS +70 +64 +3 +Solid line +72 +65 +73 +0 +40 +0.000000 +0 +ENDTAB +0 +TABLE +2 +LAYER +70 +6 +0 +LAYER +2 +1 +70 +64 +62 +7 +6 +CONTINUOUS +0 +ENDTAB +0 +TABLE +2 +STYLE +70 +0 +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +BLOCKS +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +3DFACE +8 +1 +62 +1 +10 +-0.5 +20 +-0.5 +30 +-0.5 +11 +-0.5 +21 +0.5 +31 +-0.5 +12 +0.5 +22 +0.5 +32 +-0.5 +13 +0.5 +23 +-0.5 +33 +-0.5 +0 +3DFACE +8 +1 +62 +1 +10 +-0.5 +20 +-0.5 +30 +-0.5 +11 +0.5 +21 +-0.5 +31 +-0.5 +12 +0 +22 +-0.5 +32 +0.5 +13 +0 +23 +-0.5 +33 +0.5 +0 +LINE +8 +1 +62 +1 +10 +0 +20 +-0.5 +30 +0.5 +11 +0 +21 +0.5 +31 +-0.5 +0 +ENDSEC +0 +EOF