mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
Updated assimp to latest
This commit is contained in:
parent
25ce4477ce
commit
161bf7f83b
461 changed files with 34662 additions and 30165 deletions
|
|
@ -3,7 +3,8 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -48,9 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
|
||||
|
||||
#include "DXFLoader.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include "fast_atof.h"
|
||||
#include <assimp/fast_atof.h>
|
||||
|
||||
#include "DXFHelper.h"
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
|
@ -62,16 +63,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
using namespace Assimp;
|
||||
|
||||
// AutoCAD Binary DXF<CR><LF><SUB><NULL>
|
||||
#define AI_DXF_BINARY_IDENT ("AutoCAD Binary DXF\r\n\x1a\0")
|
||||
#define AI_DXF_BINARY_IDENT_LEN (24)
|
||||
const std::string AI_DXF_BINARY_IDENT = std::string("AutoCAD Binary DXF\r\n\x1a\0");
|
||||
const size_t AI_DXF_BINARY_IDENT_LEN = 24u;
|
||||
|
||||
// default vertex color that all uncolored vertices will receive
|
||||
#define AI_DXF_DEFAULT_COLOR aiColor4D(0.6f,0.6f,0.6f,0.6f)
|
||||
const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
|
||||
|
||||
// color indices for DXF - 16 are supported, the table is
|
||||
// taken directly from the DXF spec.
|
||||
static aiColor4D g_aclrDxfIndexColors[] =
|
||||
{
|
||||
static aiColor4D g_aclrDxfIndexColors[] = {
|
||||
aiColor4D (0.6f, 0.6f, 0.6f, 1.0f),
|
||||
aiColor4D (1.0f, 0.0f, 0.0f, 1.0f), // red
|
||||
aiColor4D (0.0f, 1.0f, 0.0f, 1.0f), // green
|
||||
|
|
@ -92,6 +92,10 @@ static aiColor4D g_aclrDxfIndexColors[] =
|
|||
#define AI_DXF_NUM_INDEX_COLORS (sizeof(g_aclrDxfIndexColors)/sizeof(g_aclrDxfIndexColors[0]))
|
||||
#define AI_DXF_ENTITIES_MAGIC_BLOCK "$ASSIMP_ENTITIES_MAGIC"
|
||||
|
||||
static const int GroupCode_Name = 2;
|
||||
static const int GroupCode_XComp = 10;
|
||||
static const int GroupCode_YComp = 20;
|
||||
static const int GroupCode_ZComp = 30;
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
"Drawing Interchange Format (DXF) Importer",
|
||||
|
|
@ -109,45 +113,53 @@ static const aiImporterDesc desc = {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
DXFImporter::DXFImporter()
|
||||
{}
|
||||
: BaseImporter() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
DXFImporter::~DXFImporter()
|
||||
{}
|
||||
DXFImporter::~DXFImporter() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool DXFImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const
|
||||
{
|
||||
return SimpleExtensionCheck(pFile,"dxf");
|
||||
bool DXFImporter::CanRead( const std::string& filename, IOSystem* pIOHandler, bool checkSig ) const {
|
||||
const std::string& extension = GetExtension( filename );
|
||||
if ( extension == desc.mFileExtensions ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( extension.empty() || checkSig ) {
|
||||
const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
|
||||
return BaseImporter::SearchFileHeaderForToken(pIOHandler, filename, pTokens, 4, 32 );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a list of all supported file extensions
|
||||
const aiImporterDesc* DXFImporter::GetInfo () const
|
||||
{
|
||||
const aiImporterDesc* DXFImporter::GetInfo () const {
|
||||
return &desc;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void DXFImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene,
|
||||
IOSystem* pIOHandler)
|
||||
{
|
||||
std::shared_ptr<IOStream> file = std::shared_ptr<IOStream>( pIOHandler->Open( pFile) );
|
||||
void DXFImporter::InternReadFile( const std::string& filename, aiScene* pScene, IOSystem* pIOHandler) {
|
||||
std::shared_ptr<IOStream> file = std::shared_ptr<IOStream>( pIOHandler->Open( filename) );
|
||||
|
||||
// Check whether we can read the file
|
||||
if( file.get() == NULL) {
|
||||
throw DeadlyImportError( "Failed to open DXF file " + pFile + "");
|
||||
if( file.get() == nullptr ) {
|
||||
throw DeadlyImportError( "Failed to open DXF file " + filename + "");
|
||||
}
|
||||
|
||||
// check whether this is a binaray DXF file - we can't read binary DXF files :-(
|
||||
// Check whether this is a binary DXF file - we can't read binary DXF files :-(
|
||||
char buff[AI_DXF_BINARY_IDENT_LEN+1] = {0};
|
||||
file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);
|
||||
|
||||
if (!strncmp(AI_DXF_BINARY_IDENT,buff,AI_DXF_BINARY_IDENT_LEN)) {
|
||||
if (0 == strncmp(AI_DXF_BINARY_IDENT.c_str(),buff,AI_DXF_BINARY_IDENT_LEN)) {
|
||||
throw DeadlyImportError("DXF: Binary files are not supported at the moment");
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +202,7 @@ void DXFImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// comments
|
||||
else if (reader.Is(999)) {
|
||||
DefaultLogger::get()->info("DXF Comment: " + reader.Value());
|
||||
ASSIMP_LOG_INFO_F("DXF Comment: ", reader.Value());
|
||||
}
|
||||
|
||||
// don't read past the official EOF sign
|
||||
|
|
@ -202,7 +214,7 @@ void DXFImporter::InternReadFile( const std::string& pFile,
|
|||
++reader;
|
||||
}
|
||||
if (!eof) {
|
||||
DefaultLogger::get()->warn("DXF: EOF reached, but did not encounter DXF EOF marker");
|
||||
ASSIMP_LOG_WARN("DXF: EOF reached, but did not encounter DXF EOF marker");
|
||||
}
|
||||
|
||||
ConvertMeshes(pScene,output);
|
||||
|
|
@ -216,13 +228,11 @@ void DXFImporter::InternReadFile( const std::string& pFile,
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output)
|
||||
{
|
||||
void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output) {
|
||||
// the process of resolving all the INSERT statements can grow the
|
||||
// polycount excessively, so log the original number.
|
||||
// poly-count excessively, so log the original number.
|
||||
// XXX Option to import blocks as separate nodes?
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
|
||||
unsigned int vcount = 0, icount = 0;
|
||||
for (const DXF::Block& bl : output.blocks) {
|
||||
for (std::shared_ptr<const DXF::PolyLine> pl : bl.lines) {
|
||||
|
|
@ -231,16 +241,14 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output)
|
|||
}
|
||||
}
|
||||
|
||||
DefaultLogger::get()->debug((Formatter::format("DXF: Unexpanded polycount is "),
|
||||
icount,", vertex count is ",vcount
|
||||
));
|
||||
ASSIMP_LOG_DEBUG_F("DXF: Unexpanded polycount is ", icount, ", vertex count is ", vcount);
|
||||
}
|
||||
|
||||
if (! output.blocks.size() ) {
|
||||
throw DeadlyImportError("DXF: no data blocks loaded");
|
||||
}
|
||||
|
||||
DXF::Block* entities = 0;
|
||||
DXF::Block* entities( nullptr );
|
||||
|
||||
// index blocks by name
|
||||
DXF::BlockMap blocks_by_name;
|
||||
|
|
@ -285,7 +293,7 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output)
|
|||
}
|
||||
}
|
||||
|
||||
if (!pScene->mNumMeshes) {
|
||||
if ( 0 == pScene->mNumMeshes) {
|
||||
throw DeadlyImportError("DXF: this file contains no 3d data");
|
||||
}
|
||||
|
||||
|
|
@ -358,16 +366,13 @@ void DXFImporter::ConvertMeshes(aiScene* pScene, DXF::FileData& output)
|
|||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& blocks_by_name)
|
||||
{
|
||||
void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& blocks_by_name) {
|
||||
for (const DXF::InsertBlock& insert : bl.insertions) {
|
||||
|
||||
// first check if the referenced blocks exists ...
|
||||
const DXF::BlockMap::const_iterator it = blocks_by_name.find(insert.name);
|
||||
if (it == blocks_by_name.end()) {
|
||||
DefaultLogger::get()->error((Formatter::format("DXF: Failed to resolve block reference: "),
|
||||
insert.name,"; skipping"
|
||||
));
|
||||
ASSIMP_LOG_ERROR_F("DXF: Failed to resolve block reference: ", insert.name,"; skipping" );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -387,7 +392,7 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
|
|||
|
||||
// XXX rotation currently ignored - I didn't find an appropriate sample model.
|
||||
if (insert.angle != 0.f) {
|
||||
DefaultLogger::get()->warn("DXF: BLOCK rotation not currently implemented");
|
||||
ASSIMP_LOG_WARN("DXF: BLOCK rotation not currently implemented");
|
||||
}
|
||||
|
||||
for (aiVector3D& v : pl_out->positions) {
|
||||
|
|
@ -400,10 +405,8 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::GenerateMaterials(aiScene* pScene, DXF::FileData& /*output*/)
|
||||
{
|
||||
void DXFImporter::GenerateMaterials(aiScene* pScene, DXF::FileData& /*output*/) {
|
||||
// generate an almost-white default material. Reason:
|
||||
// the default vertex color is GREY, so we are
|
||||
// already at Assimp's usual default color.
|
||||
|
|
@ -427,10 +430,8 @@ void DXFImporter::GenerateMaterials(aiScene* pScene, DXF::FileData& /*output*/)
|
|||
pScene->mMaterials[0] = pcMat;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::GenerateHierarchy(aiScene* pScene, DXF::FileData& /*output*/)
|
||||
{
|
||||
void DXFImporter::GenerateHierarchy(aiScene* pScene, DXF::FileData& /*output*/) {
|
||||
// generate the output scene graph, which is just the root node with a single child for each layer.
|
||||
pScene->mRootNode = new aiNode();
|
||||
pScene->mRootNode->mName.Set("<DXF_ROOT>");
|
||||
|
|
@ -438,9 +439,7 @@ void DXFImporter::GenerateHierarchy(aiScene* pScene, DXF::FileData& /*output*/)
|
|||
if (1 == pScene->mNumMeshes) {
|
||||
pScene->mRootNode->mMeshes = new unsigned int[ pScene->mRootNode->mNumMeshes = 1 ];
|
||||
pScene->mRootNode->mMeshes[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pScene->mRootNode->mChildren = new aiNode*[ pScene->mRootNode->mNumChildren = pScene->mNumMeshes ];
|
||||
for (unsigned int m = 0; m < pScene->mRootNode->mNumChildren;++m) {
|
||||
aiNode* p = pScene->mRootNode->mChildren[m] = new aiNode();
|
||||
|
|
@ -455,22 +454,17 @@ void DXFImporter::GenerateHierarchy(aiScene* pScene, DXF::FileData& /*output*/)
|
|||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::SkipSection(DXF::LineReader& reader)
|
||||
{
|
||||
void DXFImporter::SkipSection(DXF::LineReader& reader) {
|
||||
for( ;!reader.End() && !reader.Is(0,"ENDSEC"); reader++);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::ParseHeader(DXF::LineReader& reader, DXF::FileData& /*output*/)
|
||||
{
|
||||
void DXFImporter::ParseHeader(DXF::LineReader& reader, DXF::FileData& ) {
|
||||
for( ;!reader.End() && !reader.Is(0,"ENDSEC"); reader++);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output)
|
||||
{
|
||||
void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output) {
|
||||
while( !reader.End() && !reader.Is(0,"ENDSEC")) {
|
||||
if (reader.Is(0,"BLOCK")) {
|
||||
ParseBlock(++reader,output);
|
||||
|
|
@ -479,15 +473,11 @@ void DXFImporter::ParseBlocks(DXF::LineReader& reader, DXF::FileData& output)
|
|||
++reader;
|
||||
}
|
||||
|
||||
DefaultLogger::get()->debug((Formatter::format("DXF: got "),
|
||||
output.blocks.size()," entries in BLOCKS"
|
||||
));
|
||||
ASSIMP_LOG_DEBUG_F("DXF: got ", output.blocks.size()," entries in BLOCKS" );
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output)
|
||||
{
|
||||
void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output) {
|
||||
// push a new block onto the stack.
|
||||
output.blocks.push_back( DXF::Block() );
|
||||
DXF::Block& block = output.blocks.back();
|
||||
|
|
@ -495,17 +485,17 @@ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output)
|
|||
while( !reader.End() && !reader.Is(0,"ENDBLK")) {
|
||||
|
||||
switch(reader.GroupCode()) {
|
||||
case 2:
|
||||
case GroupCode_Name:
|
||||
block.name = reader.Value();
|
||||
break;
|
||||
|
||||
case 10:
|
||||
case GroupCode_XComp:
|
||||
block.base.x = reader.ValueAsFloat();
|
||||
break;
|
||||
case 20:
|
||||
case GroupCode_YComp:
|
||||
block.base.y = reader.ValueAsFloat();
|
||||
break;
|
||||
case 30:
|
||||
case GroupCode_ZComp:
|
||||
block.base.z = reader.ValueAsFloat();
|
||||
break;
|
||||
}
|
||||
|
|
@ -517,7 +507,7 @@ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output)
|
|||
|
||||
// XXX is this a valid case?
|
||||
if (reader.Is(0,"INSERT")) {
|
||||
DefaultLogger::get()->warn("DXF: INSERT within a BLOCK not currently supported; skipping");
|
||||
ASSIMP_LOG_WARN("DXF: INSERT within a BLOCK not currently supported; skipping");
|
||||
for( ;!reader.End() && !reader.Is(0,"ENDBLK"); ++reader);
|
||||
break;
|
||||
}
|
||||
|
|
@ -531,11 +521,9 @@ void DXFImporter::ParseBlock(DXF::LineReader& reader, DXF::FileData& output)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output)
|
||||
{
|
||||
// push a new block onto the stack.
|
||||
void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output) {
|
||||
// Push a new block onto the stack.
|
||||
output.blocks.push_back( DXF::Block() );
|
||||
DXF::Block& block = output.blocks.back();
|
||||
|
||||
|
|
@ -561,34 +549,29 @@ void DXFImporter::ParseEntities(DXF::LineReader& reader, DXF::FileData& output)
|
|||
++reader;
|
||||
}
|
||||
|
||||
DefaultLogger::get()->debug((Formatter::format("DXF: got "),
|
||||
block.lines.size()," polylines and ", block.insertions.size() ," inserted blocks in ENTITIES"
|
||||
));
|
||||
ASSIMP_LOG_DEBUG_F( "DXF: got ", block.lines.size()," polylines and ", block.insertions.size(),
|
||||
" inserted blocks in ENTITIES" );
|
||||
}
|
||||
|
||||
|
||||
void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output)
|
||||
{
|
||||
void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output) {
|
||||
output.blocks.back().insertions.push_back( DXF::InsertBlock() );
|
||||
DXF::InsertBlock& bl = output.blocks.back().insertions.back();
|
||||
|
||||
while( !reader.End() && !reader.Is(0)) {
|
||||
|
||||
switch(reader.GroupCode())
|
||||
{
|
||||
switch(reader.GroupCode()) {
|
||||
// name of referenced block
|
||||
case 2:
|
||||
case GroupCode_Name:
|
||||
bl.name = reader.Value();
|
||||
break;
|
||||
|
||||
// translation
|
||||
case 10:
|
||||
case GroupCode_XComp:
|
||||
bl.pos.x = reader.ValueAsFloat();
|
||||
break;
|
||||
case 20:
|
||||
case GroupCode_YComp:
|
||||
bl.pos.y = reader.ValueAsFloat();
|
||||
break;
|
||||
case 30:
|
||||
case GroupCode_ZComp:
|
||||
bl.pos.z = reader.ValueAsFloat();
|
||||
break;
|
||||
|
||||
|
|
@ -618,8 +601,7 @@ void DXFImporter::ParseInsertion(DXF::LineReader& reader, DXF::FileData& output)
|
|||
#define DXF_POLYLINE_FLAG_POLYFACEMESH 0x40
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
|
||||
{
|
||||
void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output) {
|
||||
output.blocks.back().lines.push_back( std::shared_ptr<DXF::PolyLine>( new DXF::PolyLine() ) );
|
||||
DXF::PolyLine& line = *output.blocks.back().lines.back();
|
||||
|
||||
|
|
@ -672,16 +654,15 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
|
|||
//}
|
||||
|
||||
if (vguess && line.positions.size() != vguess) {
|
||||
DefaultLogger::get()->warn((Formatter::format("DXF: unexpected vertex count in polymesh: "),
|
||||
line.positions.size(),", expected ", vguess
|
||||
));
|
||||
ASSIMP_LOG_WARN_F("DXF: unexpected vertex count in polymesh: ",
|
||||
line.positions.size(),", expected ", vguess );
|
||||
}
|
||||
|
||||
if (line.flags & DXF_POLYLINE_FLAG_POLYFACEMESH ) {
|
||||
if (line.positions.size() < 3 || line.indices.size() < 3) {
|
||||
DefaultLogger::get()->warn("DXF: not enough vertices for polymesh; ignoring");
|
||||
output.blocks.back().lines.pop_back();
|
||||
return;
|
||||
ASSIMP_LOG_WARN("DXF: not enough vertices for polymesh; ignoring");
|
||||
output.blocks.back().lines.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
// if these numbers are wrong, parsing might have gone wild.
|
||||
|
|
@ -689,13 +670,11 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
|
|||
// to set the 71 and 72 fields, respectively, to valid values.
|
||||
// So just fire a warning.
|
||||
if (iguess && line.counts.size() != iguess) {
|
||||
DefaultLogger::get()->warn((Formatter::format("DXF: unexpected face count in polymesh: "),
|
||||
line.counts.size(),", expected ", iguess
|
||||
));
|
||||
ASSIMP_LOG_WARN_F( "DXF: unexpected face count in polymesh: ", line.counts.size(),", expected ", iguess );
|
||||
}
|
||||
}
|
||||
else if (!line.indices.size() && !line.counts.size()) {
|
||||
// a polyline - so there are no indices yet.
|
||||
// a poly-line - so there are no indices yet.
|
||||
size_t guess = line.positions.size() + (line.flags & DXF_POLYLINE_FLAG_CLOSED ? 1 : 0);
|
||||
line.indices.reserve(guess);
|
||||
|
||||
|
|
@ -719,8 +698,7 @@ void DXFImporter::ParsePolyLine(DXF::LineReader& reader, DXF::FileData& output)
|
|||
#define DXF_VERTEX_FLAG_HAS_POSITIONS 0x40
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& line)
|
||||
{
|
||||
void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& line) {
|
||||
unsigned int cnti = 0, flags = 0;
|
||||
unsigned int indices[4];
|
||||
|
||||
|
|
@ -733,14 +711,13 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
|
|||
break;
|
||||
}
|
||||
|
||||
switch (reader.GroupCode())
|
||||
{
|
||||
switch (reader.GroupCode()) {
|
||||
case 8:
|
||||
// layer to which the vertex belongs to - assume that
|
||||
// this is always the layer the top-level polyline
|
||||
// this is always the layer the top-level poly-line
|
||||
// entity resides on as well.
|
||||
if(reader.Value() != line.layer) {
|
||||
DefaultLogger::get()->warn("DXF: expected vertex to be part of a polyface but the 0x128 flag isn't set");
|
||||
ASSIMP_LOG_WARN("DXF: expected vertex to be part of a poly-face but the 0x128 flag isn't set");
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -749,9 +726,17 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
|
|||
break;
|
||||
|
||||
// VERTEX COORDINATES
|
||||
case 10: out.x = reader.ValueAsFloat();break;
|
||||
case 20: out.y = reader.ValueAsFloat();break;
|
||||
case 30: out.z = reader.ValueAsFloat();break;
|
||||
case GroupCode_XComp:
|
||||
out.x = reader.ValueAsFloat();
|
||||
break;
|
||||
|
||||
case GroupCode_YComp:
|
||||
out.y = reader.ValueAsFloat();
|
||||
break;
|
||||
|
||||
case GroupCode_ZComp:
|
||||
out.z = reader.ValueAsFloat();
|
||||
break;
|
||||
|
||||
// POLYFACE vertex indices
|
||||
case 71:
|
||||
|
|
@ -759,7 +744,7 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
|
|||
case 73:
|
||||
case 74:
|
||||
if (cnti == 4) {
|
||||
DefaultLogger::get()->warn("DXF: more than 4 indices per face not supported; ignoring");
|
||||
ASSIMP_LOG_WARN("DXF: more than 4 indices per face not supported; ignoring");
|
||||
break;
|
||||
}
|
||||
indices[cnti++] = reader.ValueAsUnsignedInt();
|
||||
|
|
@ -775,7 +760,7 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
|
|||
}
|
||||
|
||||
if (line.flags & DXF_POLYLINE_FLAG_POLYFACEMESH && !(flags & DXF_VERTEX_FLAG_PART_OF_POLYFACE)) {
|
||||
DefaultLogger::get()->warn("DXF: expected vertex to be part of a polyface but the 0x128 flag isn't set");
|
||||
ASSIMP_LOG_WARN("DXF: expected vertex to be part of a polyface but the 0x128 flag isn't set");
|
||||
}
|
||||
|
||||
if (cnti) {
|
||||
|
|
@ -783,14 +768,17 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
|
|||
for (unsigned int i = 0; i < cnti; ++i) {
|
||||
// IMPORTANT NOTE: POLYMESH indices are ONE-BASED
|
||||
if (indices[i] == 0) {
|
||||
DefaultLogger::get()->warn("DXF: invalid vertex index, indices are one-based.");
|
||||
ASSIMP_LOG_WARN("DXF: invalid vertex index, indices are one-based.");
|
||||
--line.counts.back();
|
||||
// Workaround to fix issue 2229
|
||||
if (line.counts.back() == 0) {
|
||||
line.counts.pop_back();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
line.indices.push_back(indices[i]-1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
line.positions.push_back(out);
|
||||
line.colors.push_back(clr);
|
||||
}
|
||||
|
|
@ -824,62 +812,74 @@ void DXFImporter::Parse3DFace(DXF::LineReader& reader, DXF::FileData& output)
|
|||
break;
|
||||
|
||||
// x position of the first corner
|
||||
case 10: vip[0].x = reader.ValueAsFloat();
|
||||
case 10:
|
||||
vip[0].x = reader.ValueAsFloat();
|
||||
b[2] = true;
|
||||
break;
|
||||
|
||||
// y position of the first corner
|
||||
case 20: vip[0].y = reader.ValueAsFloat();
|
||||
case 20:
|
||||
vip[0].y = reader.ValueAsFloat();
|
||||
b[2] = true;
|
||||
break;
|
||||
|
||||
// z position of the first corner
|
||||
case 30: vip[0].z = reader.ValueAsFloat();
|
||||
case 30:
|
||||
vip[0].z = reader.ValueAsFloat();
|
||||
b[2] = true;
|
||||
break;
|
||||
|
||||
// x position of the second corner
|
||||
case 11: vip[1].x = reader.ValueAsFloat();
|
||||
case 11:
|
||||
vip[1].x = reader.ValueAsFloat();
|
||||
b[3] = true;
|
||||
break;
|
||||
|
||||
// y position of the second corner
|
||||
case 21: vip[1].y = reader.ValueAsFloat();
|
||||
case 21:
|
||||
vip[1].y = reader.ValueAsFloat();
|
||||
b[3] = true;
|
||||
break;
|
||||
|
||||
// z position of the second corner
|
||||
case 31: vip[1].z = reader.ValueAsFloat();
|
||||
case 31:
|
||||
vip[1].z = reader.ValueAsFloat();
|
||||
b[3] = true;
|
||||
break;
|
||||
|
||||
// x position of the third corner
|
||||
case 12: vip[2].x = reader.ValueAsFloat();
|
||||
case 12:
|
||||
vip[2].x = reader.ValueAsFloat();
|
||||
b[0] = true;
|
||||
break;
|
||||
|
||||
// y position of the third corner
|
||||
case 22: vip[2].y = reader.ValueAsFloat();
|
||||
case 22:
|
||||
vip[2].y = reader.ValueAsFloat();
|
||||
b[0] = true;
|
||||
break;
|
||||
|
||||
// z position of the third corner
|
||||
case 32: vip[2].z = reader.ValueAsFloat();
|
||||
case 32:
|
||||
vip[2].z = reader.ValueAsFloat();
|
||||
b[0] = true;
|
||||
break;
|
||||
|
||||
// x position of the fourth corner
|
||||
case 13: vip[3].x = reader.ValueAsFloat();
|
||||
case 13:
|
||||
vip[3].x = reader.ValueAsFloat();
|
||||
b[1] = true;
|
||||
break;
|
||||
|
||||
// y position of the fourth corner
|
||||
case 23: vip[3].y = reader.ValueAsFloat();
|
||||
case 23:
|
||||
vip[3].y = reader.ValueAsFloat();
|
||||
b[1] = true;
|
||||
break;
|
||||
|
||||
// z position of the fourth corner
|
||||
case 33: vip[3].z = reader.ValueAsFloat();
|
||||
case 33:
|
||||
vip[3].z = reader.ValueAsFloat();
|
||||
b[1] = true;
|
||||
break;
|
||||
|
||||
|
|
@ -900,7 +900,7 @@ void DXFImporter::Parse3DFace(DXF::LineReader& reader, DXF::FileData& output)
|
|||
|
||||
// sanity checks to see if we got something meaningful
|
||||
if ((b[1] && !b[0]) || !b[2] || !b[3]) {
|
||||
DefaultLogger::get()->warn("DXF: unexpected vertex setup in 3DFACE/LINE/FACE entity; ignoring");
|
||||
ASSIMP_LOG_WARN("DXF: unexpected vertex setup in 3DFACE/LINE/FACE entity; ignoring");
|
||||
output.blocks.back().lines.pop_back();
|
||||
return;
|
||||
}
|
||||
|
|
@ -916,4 +916,3 @@ void DXFImporter::Parse3DFace(DXF::LineReader& reader, DXF::FileData& output)
|
|||
}
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_DXF_IMPORTER
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue