Merge branch 'master' into bound

pull/4017/head
Kim Kulling 2021-08-16 20:48:17 +02:00 committed by GitHub
commit 27231c3f52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
192 changed files with 1248 additions and 1222 deletions

View File

@ -103,7 +103,7 @@ namespace XmlTag {
const char* const PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture"; const char* const PACKAGE_TEXTURE_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dtexture";
const char* const PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"; const char* const PACKAGE_CORE_PROPERTIES_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
const char* const PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"; const char* const PACKAGE_THUMBNAIL_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
} }
} // Namespace D3MF } // Namespace D3MF
} // Namespace Assimp } // Namespace Assimp

View File

@ -231,11 +231,7 @@ void ColladaParser::UriDecodePath(aiString &ss) {
// Maxon Cinema Collada Export writes "file:///C:\andsoon" with three slashes... // Maxon Cinema Collada Export writes "file:///C:\andsoon" with three slashes...
// I need to filter it without destroying linux paths starting with "/somewhere" // I need to filter it without destroying linux paths starting with "/somewhere"
#if defined(_MSC_VER)
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') { if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
#else
if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') {
#endif
--ss.length; --ss.length;
::memmove(ss.data, ss.data + 1, ss.length); ::memmove(ss.data, ss.data + 1, ss.length);
ss.data[ss.length] = 0; ss.data[ss.length] = 0;

View File

@ -516,13 +516,13 @@ namespace pmx
stream->read((char*) magic, sizeof(char) * 4); stream->read((char*) magic, sizeof(char) * 4);
if (magic[0] != 0x50 || magic[1] != 0x4d || magic[2] != 0x58 || magic[3] != 0x20) if (magic[0] != 0x50 || magic[1] != 0x4d || magic[2] != 0x58 || magic[3] != 0x20)
{ {
throw DeadlyImportError("MMD: Invalid magic number."); throw DeadlyImportError("MMD: Invalid magic number.");
} }
stream->read((char*) &version, sizeof(float)); stream->read((char*) &version, sizeof(float));
if (version != 2.0f && version != 2.1f) if (version != 2.0f && version != 2.1f)
{ {
throw DeadlyImportError("MMD: Unsupported version (must be 2.0 or 2.1): ", ai_to_string(version)); throw DeadlyImportError("MMD: Unsupported version (must be 2.0 or 2.1): ", ai_to_string(version));
} }
this->setting.Read(stream); this->setting.Read(stream);
this->model_name = ReadString(stream, setting.encoding); this->model_name = ReadString(stream, setting.encoding);

View File

@ -58,13 +58,13 @@ using namespace Assimp;
namespace EXPRESS = STEP::EXPRESS; namespace EXPRESS = STEP::EXPRESS;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
std::string AddLineNumber(const std::string& s,uint64_t line /*= LINE_NOT_SPECIFIED*/, const std::string& prefix = "") std::string AddLineNumber(const std::string& s,uint64_t line /*= LINE_NOT_SPECIFIED*/, const std::string& prefix = std::string())
{ {
return line == STEP::SyntaxError::LINE_NOT_SPECIFIED ? prefix+s : static_cast<std::string>( (Formatter::format(),prefix,"(line ",line,") ",s) ); return line == STEP::SyntaxError::LINE_NOT_SPECIFIED ? prefix+s : static_cast<std::string>( (Formatter::format(),prefix,"(line ",line,") ",s) );
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
std::string AddEntityID(const std::string& s,uint64_t entity /*= ENTITY_NOT_SPECIFIED*/, const std::string& prefix = "") std::string AddEntityID(const std::string& s,uint64_t entity /*= ENTITY_NOT_SPECIFIED*/, const std::string& prefix = std::string())
{ {
return entity == STEP::TypeError::ENTITY_NOT_SPECIFIED ? prefix+s : static_cast<std::string>( (Formatter::format(),prefix,"(entity #",entity,") ",s)); return entity == STEP::TypeError::ENTITY_NOT_SPECIFIED ? prefix+s : static_cast<std::string>( (Formatter::format(),prefix,"(entity #",entity,") ",s));
} }

View File

@ -175,12 +175,11 @@ void StepExporter::WriteFile()
fColor.b = 0.8f; fColor.b = 0.8f;
int ind = 100; // the start index to be used int ind = 100; // the start index to be used
int faceEntryLen = 30; // number of entries for a triangle/face std::vector<int> faceEntryLen; // numbers of entries for a triangle/face
// prepare unique (count triangles and vertices) // prepare unique (count triangles and vertices)
VectorIndexUMap uniqueVerts; // use a map to reduce find complexity to log(n) VectorIndexUMap uniqueVerts; // use a map to reduce find complexity to log(n)
VectorIndexUMap::iterator it; VectorIndexUMap::iterator it;
int countFace = 0;
for (unsigned int i=0; i<mScene->mNumMeshes; ++i) for (unsigned int i=0; i<mScene->mNumMeshes; ++i)
{ {
@ -189,7 +188,7 @@ void StepExporter::WriteFile()
{ {
aiFace* face = &(mesh->mFaces[j]); aiFace* face = &(mesh->mFaces[j]);
if (face->mNumIndices == 3) countFace++; if (face->mNumIndices >= 3) faceEntryLen.push_back(15 + 5 * face->mNumIndices);
} }
for (unsigned int j=0; j<mesh->mNumVertices; ++j) for (unsigned int j=0; j<mesh->mNumVertices; ++j)
{ {
@ -218,10 +217,13 @@ void StepExporter::WriteFile()
// write the top of data // write the top of data
mOutput << "DATA" << endstr; mOutput << "DATA" << endstr;
mOutput << "#1=MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION(' ',("; mOutput << "#1=MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION(' ',(";
for (int i=0; i<countFace; ++i) size_t countFace = faceEntryLen.size();
size_t faceLenIndex = ind + 2 * uniqueVerts.size();
for (size_t i=0; i<countFace; ++i)
{ {
mOutput << "#" << i*faceEntryLen + ind + 2*uniqueVerts.size(); mOutput << "#" << faceLenIndex;
if (i!=countFace-1) mOutput << ","; if (i!=countFace-1) mOutput << ",";
faceLenIndex += faceEntryLen[i];
} }
mOutput << "),#6)" << endstr; mOutput << "),#6)" << endstr;
@ -253,10 +255,12 @@ void StepExporter::WriteFile()
mOutput << "#27=DIRECTION('',(1.0,0.0,0.0))" << endstr; mOutput << "#27=DIRECTION('',(1.0,0.0,0.0))" << endstr;
mOutput << "#28= (NAMED_UNIT(#21)LENGTH_UNIT()SI_UNIT(.MILLI.,.METRE.))" << endstr; mOutput << "#28= (NAMED_UNIT(#21)LENGTH_UNIT()SI_UNIT(.MILLI.,.METRE.))" << endstr;
mOutput << "#29=CLOSED_SHELL('',("; mOutput << "#29=CLOSED_SHELL('',(";
for (int i=0; i<countFace; ++i) faceLenIndex = ind + 2 * uniqueVerts.size() + 8;
for (size_t i=0; i<countFace; ++i)
{ {
mOutput << "#" << i*faceEntryLen + ind + 2*uniqueVerts.size() + 8; mOutput << "#" << faceLenIndex;
if (i!=countFace-1) mOutput << ","; if (i!=countFace-1) mOutput << ",";
faceLenIndex += faceEntryLen[i];
} }
mOutput << "))" << endstr; mOutput << "))" << endstr;
@ -289,28 +293,29 @@ void StepExporter::WriteFile()
{ {
aiFace* face = &(mesh->mFaces[j]); aiFace* face = &(mesh->mFaces[j]);
if (face->mNumIndices != 3) continue; const int numIndices = face->mNumIndices;
if (numIndices < 3) continue;
aiVector3D* v1 = &(mesh->mVertices[face->mIndices[0]]); std::vector<int> pidArray(numIndices, -1); // vertex id
aiVector3D* v2 = &(mesh->mVertices[face->mIndices[1]]); std::vector<aiVector3D> dvArray(numIndices); // edge dir
aiVector3D* v3 = &(mesh->mVertices[face->mIndices[2]]); for (int k = 0; k < numIndices; ++k)
aiVector3D dv12 = *v2 - *v1; {
aiVector3D dv23 = *v3 - *v2; aiVector3D *v1 = &(mesh->mVertices[face->mIndices[k]]);
aiVector3D dv31 = *v1 - *v3; pidArray[k] = uniqueVerts.find(v1)->second;
aiVector3D dv13 = *v3 - *v1;
dv12.Normalize();
dv23.Normalize();
dv31.Normalize();
dv13.Normalize();
aiVector3D dvY = dv12; aiVector3D *v2 = nullptr;
aiVector3D dvX = dvY ^ dv13; if (k + 1 == numIndices)
v2 = &(mesh->mVertices[face->mIndices[0]]);
else
v2 = &(mesh->mVertices[face->mIndices[k + 1]]);
dvArray[k] = *v2 - *v1;
dvArray[k].Normalize();
}
aiVector3D dvY = dvArray[1];
aiVector3D dvX = dvY ^ dvArray[0];
dvX.Normalize(); dvX.Normalize();
int pid1 = uniqueVerts.find(v1)->second;
int pid2 = uniqueVerts.find(v2)->second;
int pid3 = uniqueVerts.find(v3)->second;
// mean vertex color for the face if available // mean vertex color for the face if available
if (mesh->HasVertexColors(0)) if (mesh->HasVertexColors(0))
{ {
@ -339,35 +344,62 @@ void StepExporter::WriteFile()
/* 2 directions of the plane */ /* 2 directions of the plane */
mOutput << "#" << sid+9 << "=PLANE('',#" << sid+10 << ")" << endstr; mOutput << "#" << sid+9 << "=PLANE('',#" << sid+10 << ")" << endstr;
mOutput << "#" << sid+10 << "=AXIS2_PLACEMENT_3D('',#" << pid1 << ", #" << sid+11 << ",#" << sid+12 << ")" << endstr; mOutput << "#" << sid+10 << "=AXIS2_PLACEMENT_3D('',#" << pidArray[0] << ",#" << sid+11 << ",#" << sid+12 << ")" << endstr;
mOutput << "#" << sid + 11 << "=DIRECTION('',(" << dvX.x << "," << dvX.y << "," << dvX.z << "))" << endstr; mOutput << "#" << sid + 11 << "=DIRECTION('',(" << dvX.x << "," << dvX.y << "," << dvX.z << "))" << endstr;
mOutput << "#" << sid + 12 << "=DIRECTION('',(" << dvY.x << "," << dvY.y << "," << dvY.z << "))" << endstr; mOutput << "#" << sid + 12 << "=DIRECTION('',(" << dvY.x << "," << dvY.y << "," << dvY.z << "))" << endstr;
mOutput << "#" << sid+13 << "=FACE_BOUND('',#" << sid+14 << ",.T.)" << endstr; mOutput << "#" << sid+13 << "=FACE_BOUND('',#" << sid+14 << ",.T.)" << endstr;
mOutput << "#" << sid+14 << "=EDGE_LOOP('',(#" << sid+15 << ",#" << sid+16 << ",#" << sid+17 << "))" << endstr; mOutput << "#" << sid+14 << "=EDGE_LOOP('',(";
int edgeLoopStart = sid + 15;
for (int k = 0; k < numIndices; ++k)
{
if (k == 0)
mOutput << "#";
else
mOutput << ",#";
mOutput << edgeLoopStart + k;
}
mOutput << "))" << endstr;
/* edge loop */ /* edge loop */
mOutput << "#" << sid+15 << "=ORIENTED_EDGE('',*,*,#" << sid+18 << ",.T.)" << endstr; int orientedEdgesStart = edgeLoopStart + numIndices;
mOutput << "#" << sid+16 << "=ORIENTED_EDGE('',*,*,#" << sid+19 << ",.T.)" << endstr; for (int k=0; k < numIndices; k++)
mOutput << "#" << sid+17 << "=ORIENTED_EDGE('',*,*,#" << sid+20 << ",.T.)" << endstr; {
mOutput << "#" << edgeLoopStart+k << "=ORIENTED_EDGE('',*,*,#" << orientedEdgesStart + k << ",.T.)" << endstr;
}
/* oriented edges */ /* oriented edges */
mOutput << "#" << sid+18 << "=EDGE_CURVE('',#" << pid1+1 << ",#" << pid2+1 << ",#" << sid+21 << ",.F.)" << endstr; int lineStart = orientedEdgesStart + numIndices;
mOutput << "#" << sid+19 << "=EDGE_CURVE('',#" << pid2+1 << ",#" << pid3+1 << ",#" << sid+22 << ",.T.)" << endstr; for (int k=0; k < numIndices; ++k)
mOutput << "#" << sid+20 << "=EDGE_CURVE('',#" << pid3+1 << ",#" << pid1+1 << ",#" << sid+23 << ",.T.)" << endstr; {
if (k == 0)
mOutput << "#" << orientedEdgesStart+k << "=EDGE_CURVE('',#" << pidArray[k]+1 << ",#" << pidArray[k+1]+1 << ",#" << lineStart+k << ",.F.)" << endstr;
else if (k+1 == numIndices)
mOutput << "#" << orientedEdgesStart+k << "=EDGE_CURVE('',#" << pidArray[k]+1 << ",#" << pidArray[0]+1 << ",#" << lineStart+k << ",.T.)" << endstr;
else
mOutput << "#" << orientedEdgesStart+k << "=EDGE_CURVE('',#" << pidArray[k]+1 << ",#" << pidArray[k+1]+1 << ",#" << lineStart+k << ",.T.)" << endstr;
}
/* 3 lines and 3 vectors for the lines for the 3 edge curves */ /* n lines and n vectors for the lines for the n edge curves */
mOutput << "#" << sid+21 << "=LINE('',#" << pid1 << ",#" << sid+24 << ")" << endstr; int vectorStart = lineStart + numIndices;
mOutput << "#" << sid+22 << "=LINE('',#" << pid2 << ",#" << sid+25 << ")" << endstr; for (int k=0; k < numIndices; ++k)
mOutput << "#" << sid+23 << "=LINE('',#" << pid3 << ",#" << sid+26 << ")" << endstr; {
mOutput << "#" << sid+24 << "=VECTOR('',#" << sid+27 << ",1.0)" << endstr; mOutput << "#" << lineStart+k << "=LINE('',#" << pidArray[k] << ",#" << vectorStart+k << ")" << endstr;
mOutput << "#" << sid+25 << "=VECTOR('',#" << sid+28 << ",1.0)" << endstr; }
mOutput << "#" << sid+26 << "=VECTOR('',#" << sid+29 << ",1.0)" << endstr;
mOutput << "#" << sid+27 << "=DIRECTION('',(" << dv12.x << "," << dv12.y << "," << dv12.z << "))" << endstr; int directionStart = vectorStart + numIndices;
mOutput << "#" << sid+28 << "=DIRECTION('',(" << dv23.x << "," << dv23.y << "," << dv23.z << "))" << endstr; for (int k=0; k < numIndices; ++k)
mOutput << "#" << sid+29 << "=DIRECTION('',(" << dv31.x << "," << dv31.y << "," << dv31.z << "))" << endstr; {
ind += faceEntryLen; // increase counter mOutput << "#" << vectorStart+k << "=VECTOR('',#" << directionStart+k << ",1.0)" << endstr;
}
for (int k=0; k < numIndices; ++k)
{
const aiVector3D &dv = dvArray[k];
mOutput << "#" << directionStart + k << "=DIRECTION('',(" << dv.x << "," << dv.y << "," << dv.z << "))" << endstr;
}
ind += 15 + 5*numIndices; // increase counter
} }
} }

View File

@ -667,9 +667,7 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
// convert to lower case for easier comparison // convert to lower case for easier comparison
for ( unsigned int c = 0; c < sz.length(); ++c ) { for ( unsigned int c = 0; c < sz.length(); ++c ) {
if ( isalpha( (unsigned char) sz[ c ] ) ) { sz[ c ] = (char) tolower( (unsigned char) sz[ c ] );
sz[ c ] = (char) tolower( (unsigned char) sz[ c ] );
}
} }
// Place texture filename property under the corresponding name // Place texture filename property under the corresponding name

View File

@ -196,7 +196,7 @@ inline std::string getCurrentAssetDir(const std::string &pFile) {
std::string path = pFile; std::string path = pFile;
int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\'))); int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\')));
if (pos == int(std::string::npos)) { if (pos == int(std::string::npos)) {
return ""; return std::string();
} }
return pFile.substr(0, pos + 1); return pFile.substr(0, pos + 1);

View File

@ -99,8 +99,8 @@ public:
virtual ~Logger(); virtual ~Logger();
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** @brief Writes a info message /** @brief Writes a debug message
* @param message Info message*/ * @param message Debug message*/
void debug(const char* message); void debug(const char* message);
template<typename... T> template<typename... T>
@ -109,7 +109,7 @@ public:
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** @brief Writes a debug message /** @brief Writes a debug message
* @param message Debug message*/ * @param message Debug message*/
void verboseDebug(const char* message); void verboseDebug(const char* message);
@ -140,7 +140,7 @@ public:
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** @brief Writes an error message /** @brief Writes an error message
* @param message Info message*/ * @param message Error message*/
void error(const char* message); void error(const char* message);
template<typename... T> template<typename... T>

View File

@ -194,7 +194,7 @@ uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_ino
if ( *in < '0' || *in > '9' ) { if ( *in < '0' || *in > '9' ) {
// The string is known to be bad, so don't risk printing the whole thing. // The string is known to be bad, so don't risk printing the whole thing.
throw ExceptionType("The string \"", ai_str_toprintable(in, 30), "\" cannot be converted into a value." ); throw ExceptionType("The string \"", ai_str_toprintable(in, (int)strlen(in)), "\" cannot be converted into a value." );
} }
for ( ;; ) { for ( ;; ) {
@ -294,7 +294,7 @@ const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true)
if (!(c[0] >= '0' && c[0] <= '9') && if (!(c[0] >= '0' && c[0] <= '9') &&
!((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')) { !((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')) {
// The string is known to be bad, so don't risk printing the whole thing. // The string is known to be bad, so don't risk printing the whole thing.
throw ExceptionType("Cannot parse string \"", ai_str_toprintable(c, 30), throw ExceptionType("Cannot parse string \"", ai_str_toprintable(c, (int)strlen(c)),
"\" as a real number: does not start with digit " "\" as a real number: does not start with digit "
"or decimal point followed by digit."); "or decimal point followed by digit.");
} }