closes https://github.com/assimp/assimp/issues/2229: fix count of polylines when only one vertex was indexed.
parent
793694a4b1
commit
9ae8efcf09
|
@ -62,9 +62,7 @@ namespace Assimp {
|
||||||
// to convert the data to the target data type.
|
// to convert the data to the target data type.
|
||||||
class LineReader
|
class LineReader
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LineReader(StreamReaderLE& reader)
|
LineReader(StreamReaderLE& reader)
|
||||||
// do NOT skip empty lines. In DXF files, they count as valid data.
|
// do NOT skip empty lines. In DXF files, they count as valid data.
|
||||||
: splitter(reader,false,true)
|
: splitter(reader,false,true)
|
||||||
|
@ -74,9 +72,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
bool Is(int gc, const char* what) const {
|
bool Is(int gc, const char* what) const {
|
||||||
return groupcode == gc && !strcmp(what,value.c_str());
|
return groupcode == gc && !strcmp(what,value.c_str());
|
||||||
|
@ -102,8 +97,6 @@ public:
|
||||||
return !((bool)*this);
|
return !((bool)*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
unsigned int ValueAsUnsignedInt() const {
|
unsigned int ValueAsUnsignedInt() const {
|
||||||
return strtoul10(value.c_str());
|
return strtoul10(value.c_str());
|
||||||
|
@ -228,9 +221,7 @@ struct FileData
|
||||||
std::vector<Block> blocks;
|
std::vector<Block> blocks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
} // Namespace Assimp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -63,11 +63,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
// AutoCAD Binary DXF<CR><LF><SUB><NULL>
|
// AutoCAD Binary DXF<CR><LF><SUB><NULL>
|
||||||
#define AI_DXF_BINARY_IDENT ("AutoCAD Binary DXF\r\n\x1a\0")
|
const std::string AI_DXF_BINARY_IDENT = std::string("AutoCAD Binary DXF\r\n\x1a\0");
|
||||||
#define AI_DXF_BINARY_IDENT_LEN (24)
|
const size_t AI_DXF_BINARY_IDENT_LEN = 24u;
|
||||||
|
|
||||||
// default vertex color that all uncolored vertices will receive
|
// 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
|
// color indices for DXF - 16 are supported, the table is
|
||||||
// taken directly from the DXF spec.
|
// taken directly from the DXF spec.
|
||||||
|
@ -93,7 +93,6 @@ static aiColor4D g_aclrDxfIndexColors[] =
|
||||||
#define AI_DXF_NUM_INDEX_COLORS (sizeof(g_aclrDxfIndexColors)/sizeof(g_aclrDxfIndexColors[0]))
|
#define AI_DXF_NUM_INDEX_COLORS (sizeof(g_aclrDxfIndexColors)/sizeof(g_aclrDxfIndexColors[0]))
|
||||||
#define AI_DXF_ENTITIES_MAGIC_BLOCK "$ASSIMP_ENTITIES_MAGIC"
|
#define AI_DXF_ENTITIES_MAGIC_BLOCK "$ASSIMP_ENTITIES_MAGIC"
|
||||||
|
|
||||||
|
|
||||||
static const aiImporterDesc desc = {
|
static const aiImporterDesc desc = {
|
||||||
"Drawing Interchange Format (DXF) Importer",
|
"Drawing Interchange Format (DXF) Importer",
|
||||||
"",
|
"",
|
||||||
|
@ -110,24 +109,27 @@ static const aiImporterDesc desc = {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
DXFImporter::DXFImporter()
|
DXFImporter::DXFImporter()
|
||||||
{}
|
: BaseImporter() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
DXFImporter::~DXFImporter()
|
DXFImporter::~DXFImporter() {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// 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& filename, IOSystem* pIOHandler, bool checkSig ) const {
|
||||||
const std::string& extension = GetExtension( pFile );
|
const std::string& extension = GetExtension( filename );
|
||||||
if ( extension == "dxf" ) {
|
if ( extension == "dxf" ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( extension.empty() || checkSig ) {
|
if ( extension.empty() || checkSig ) {
|
||||||
static const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
|
static const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
|
||||||
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 4, 32 );
|
return BaseImporter::SearchFileHeaderForToken(pIOHandler, filename, pTokens, 4, 32 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -157,7 +159,7 @@ void DXFImporter::InternReadFile( const std::string& pFile,
|
||||||
char buff[AI_DXF_BINARY_IDENT_LEN+1] = {0};
|
char buff[AI_DXF_BINARY_IDENT_LEN+1] = {0};
|
||||||
file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);
|
file->Read(buff,AI_DXF_BINARY_IDENT_LEN,1);
|
||||||
|
|
||||||
if (!strncmp(AI_DXF_BINARY_IDENT,buff,AI_DXF_BINARY_IDENT_LEN)) {
|
if (!strncmp(AI_DXF_BINARY_IDENT.c_str(),buff,AI_DXF_BINARY_IDENT_LEN)) {
|
||||||
throw DeadlyImportError("DXF: Binary files are not supported at the moment");
|
throw DeadlyImportError("DXF: Binary files are not supported at the moment");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,9 +736,17 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// VERTEX COORDINATES
|
// VERTEX COORDINATES
|
||||||
case 10: out.x = reader.ValueAsFloat();break;
|
case 10:
|
||||||
case 20: out.y = reader.ValueAsFloat();break;
|
out.x = reader.ValueAsFloat();
|
||||||
case 30: out.z = reader.ValueAsFloat();break;
|
break;
|
||||||
|
|
||||||
|
case 20:
|
||||||
|
out.y = reader.ValueAsFloat();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 30:
|
||||||
|
out.z = reader.ValueAsFloat();
|
||||||
|
break;
|
||||||
|
|
||||||
// POLYFACE vertex indices
|
// POLYFACE vertex indices
|
||||||
case 71:
|
case 71:
|
||||||
|
@ -770,6 +780,9 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
|
||||||
if (indices[i] == 0) {
|
if (indices[i] == 0) {
|
||||||
ASSIMP_LOG_WARN("DXF: invalid vertex index, indices are one-based.");
|
ASSIMP_LOG_WARN("DXF: invalid vertex index, indices are one-based.");
|
||||||
--line.counts.back();
|
--line.counts.back();
|
||||||
|
if (line.counts.back() == 0) {
|
||||||
|
line.counts.pop_back();
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
line.indices.push_back(indices[i]-1);
|
line.indices.push_back(indices[i]-1);
|
||||||
|
|
|
@ -72,10 +72,6 @@ public:
|
||||||
DXFImporter();
|
DXFImporter();
|
||||||
~DXFImporter();
|
~DXFImporter();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the class can handle the format of the given file.
|
/** Returns whether the class can handle the format of the given file.
|
||||||
* See BaseImporter::CanRead() for details. */
|
* See BaseImporter::CanRead() for details. */
|
||||||
|
@ -83,7 +79,6 @@ public:
|
||||||
bool checkSig) const;
|
bool checkSig) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Return importer meta information.
|
/** Return importer meta information.
|
||||||
* See #BaseImporter::GetInfo for the details*/
|
* See #BaseImporter::GetInfo for the details*/
|
||||||
|
|
Loading…
Reference in New Issue