Merge branch 'master' into master

pull/3598/head
thomasbiang 2021-01-22 13:25:31 -08:00 committed by GitHub
commit 91dc904ed1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 69 additions and 45 deletions

View File

@ -1,6 +1,6 @@
# Build Instructions # Build / Install Instructions
## Build on all platforms using vcpkg ## Install on all platforms using vcpkg
You can download and install assimp using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager: You can download and install assimp using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
```bash ```bash
git clone https://github.com/Microsoft/vcpkg.git git clone https://github.com/Microsoft/vcpkg.git
@ -11,6 +11,18 @@ You can download and install assimp using the [vcpkg](https://github.com/Microso
``` ```
The assimp port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. The assimp port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
## Install on Ubuntu
You can install the Asset-Importer-Lib via apt:
```
sudo apt-get install assimp
```
## Install pyassimp
You need to have pip installed:
```
pip install pyassimp
```
## Manual build instructions ## Manual build instructions
### Install CMake ### Install CMake
@ -24,6 +36,12 @@ Make sure you have a working git-installation. Open a command prompt and clone t
```bash ```bash
git clone https://github.com/assimp/assimp.git git clone https://github.com/assimp/assimp.git
``` ```
### Build from source:
```bash
cd assimp
cmake CMakeLists.txt
cmake --build .
```
### Build instructions for Windows with Visual-Studio ### Build instructions for Windows with Visual-Studio

View File

@ -266,6 +266,7 @@ void Discreet3DSImporter::ParseMainChunk() {
case Discreet3DS::CHUNK_PRJ: case Discreet3DS::CHUNK_PRJ:
bIsPrj = true; bIsPrj = true;
break;
case Discreet3DS::CHUNK_MAIN: case Discreet3DS::CHUNK_MAIN:
ParseEditorChunk(); ParseEditorChunk();
break; break;

View File

@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef ASSIMP_BUILD_NO_COB_IMPORTER #ifndef ASSIMP_BUILD_NO_COB_IMPORTER
#include "AssetLib/COB/COBLoader.h" #include "AssetLib/COB/COBLoader.h"
#include "AssetLib/COB/COBScene.h" #include "AssetLib/COB/COBScene.h"
#include "PostProcessing/ConvertToLHProcess.h" #include "PostProcessing/ConvertToLHProcess.h"
@ -90,11 +91,15 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
COBImporter::COBImporter() {} COBImporter::COBImporter() {
// empty
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Destructor, private as well // Destructor, private as well
COBImporter::~COBImporter() {} COBImporter::~COBImporter() {
// 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.
@ -466,8 +471,9 @@ void COBImporter::UnsupportedChunk_Ascii(LineSplitter &splitter, const ChunkInfo
// missing the next line. // missing the next line.
splitter.get_stream().IncPtr(nfo.size); splitter.get_stream().IncPtr(nfo.size);
splitter.swallow_next_increment(); splitter.swallow_next_increment();
} else } else {
ThrowException(error); ThrowException(error);
}
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -790,25 +796,12 @@ void COBImporter::ReadBitM_Ascii(Scene & /*out*/, LineSplitter &splitter, const
if (nfo.version > 1) { if (nfo.version > 1) {
return UnsupportedChunk_Ascii(splitter, nfo, "BitM"); return UnsupportedChunk_Ascii(splitter, nfo, "BitM");
} }
/*
"\nThumbNailHdrSize %ld"
"\nThumbHeader: %02hx 02hx %02hx "
"\nColorBufSize %ld"
"\nColorBufZipSize %ld"
"\nZippedThumbnail: %02hx 02hx %02hx "
*/
const unsigned int head = strtoul10((++splitter)[1]); const unsigned int head = strtoul10((++splitter)[1]);
if (head != sizeof(Bitmap::BitmapHeader)) { if (head != sizeof(Bitmap::BitmapHeader)) {
ASSIMP_LOG_WARN("Unexpected ThumbNailHdrSize, skipping this chunk"); ASSIMP_LOG_WARN("Unexpected ThumbNailHdrSize, skipping this chunk");
return; return;
} }
/*union {
Bitmap::BitmapHeader data;
char opaq[sizeof Bitmap::BitmapHeader()];
};*/
// ReadHexOctets(opaq,head,(++splitter)[1]);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -884,7 +877,10 @@ void COBImporter::ReadBinaryFile(Scene &out, StreamReaderLE *reader) {
while (1) { while (1) {
std::string type; std::string type;
type += reader->GetI1(), type += reader->GetI1(), type += reader->GetI1(), type += reader->GetI1(); type += reader->GetI1();
type += reader->GetI1();
type += reader->GetI1();
type += reader->GetI1();
ChunkInfo nfo; ChunkInfo nfo;
nfo.version = reader->GetI2() * 10; nfo.version = reader->GetI2() * 10;
@ -906,14 +902,7 @@ void COBImporter::ReadBinaryFile(Scene &out, StreamReaderLE *reader) {
ReadCame_Binary(out, *reader, nfo); ReadCame_Binary(out, *reader, nfo);
} else if (type == "Mat1") { } else if (type == "Mat1") {
ReadMat1_Binary(out, *reader, nfo); ReadMat1_Binary(out, *reader, nfo);
} } else if (type == "Unit") {
/* else if (type == "Bone") {
ReadBone_Binary(out,*reader,nfo);
}
else if (type == "Chan") {
ReadChan_Binary(out,*reader,nfo);
}*/
else if (type == "Unit") {
ReadUnit_Binary(out, *reader, nfo); ReadUnit_Binary(out, *reader, nfo);
} else if (type == "OLay") { } else if (type == "OLay") {
// ignore layer index silently. // ignore layer index silently.
@ -923,8 +912,9 @@ void COBImporter::ReadBinaryFile(Scene &out, StreamReaderLE *reader) {
return UnsupportedChunk_Binary(*reader, nfo, type.c_str()); return UnsupportedChunk_Binary(*reader, nfo, type.c_str());
} else if (type == "END ") { } else if (type == "END ") {
return; return;
} else } else {
UnsupportedChunk_Binary(*reader, nfo, type.c_str()); UnsupportedChunk_Binary(*reader, nfo, type.c_str());
}
} }
} }

View File

@ -656,7 +656,7 @@ void ProcessExtrudedArea(const Schema_2x3::IfcExtrudedAreaSolid& solid, const Te
} }
} }
if( openings && ((sides_with_openings == 1 && sides_with_openings) || (sides_with_v_openings == 2 && sides_with_v_openings)) ) { if( openings && (sides_with_openings == 1 || sides_with_v_openings == 2 ) ) {
IFCImporter::LogWarn("failed to resolve all openings, presumably their topology is not supported by Assimp"); IFCImporter::LogWarn("failed to resolve all openings, presumably their topology is not supported by Assimp");
} }

View File

@ -1189,20 +1189,9 @@ bool GenerateOpenings(std::vector<TempOpening>& openings,
TempMesh* profile_data = opening.profileMesh.get(); TempMesh* profile_data = opening.profileMesh.get();
bool is_2d_source = false; bool is_2d_source = false;
if (opening.profileMesh2D && norm_extrusion_dir.SquareLength() > 0) { if (opening.profileMesh2D && norm_extrusion_dir.SquareLength() > 0) {
if (std::fabs(norm_extrusion_dir * nor) > 0.9) {
if(std::fabs(norm_extrusion_dir * wall_extrusion_axis_norm) < 0.1) { profile_data = opening.profileMesh2D.get();
// horizontal extrusion is_2d_source = true;
if (std::fabs(norm_extrusion_dir * nor) > 0.9) {
profile_data = opening.profileMesh2D.get();
is_2d_source = true;
}
}
else {
// vertical extrusion
if (std::fabs(norm_extrusion_dir * nor) > 0.9) {
profile_data = opening.profileMesh2D.get();
is_2d_source = true;
}
} }
} }
std::vector<IfcVector3> profile_verts = profile_data->mVerts; std::vector<IfcVector3> profile_verts = profile_data->mVerts;

View File

@ -147,7 +147,7 @@ STLExporter::STLExporter(const char* _filename, const aiScene* pScene, bool expo
for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) { for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
WriteMesh(pScene->mMeshes[ i ]); WriteMesh(pScene->mMeshes[ i ]);
} }
mOutput << EndSolidToken << name << endl; mOutput << EndSolidToken << " " << name << endl;
} }
} }

View File

@ -383,6 +383,22 @@ static inline bool CheckValidFacesIndices(aiFace *faces, unsigned nFaces, unsign
} }
#endif // ASSIMP_BUILD_DEBUG #endif // ASSIMP_BUILD_DEBUG
template<typename T>
aiColor4D* GetVertexColorsForType(glTF2::Ref<glTF2::Accessor> input) {
float max = std::numeric_limits<T>::max();
aiColor4t<T>* colors;
input->ExtractData(colors);
auto output = new aiColor4D[input->count];
for (size_t i = 0; i < input->count; i++) {
output[i] = aiColor4D(
colors[i].r / max, colors[i].g / max,
colors[i].b / max, colors[i].a / max
);
}
delete[] colors;
return output;
}
void glTF2Importer::ImportMeshes(glTF2::Asset &r) { void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
ASSIMP_LOG_DEBUG_F("Importing ", r.meshes.Size(), " meshes"); ASSIMP_LOG_DEBUG_F("Importing ", r.meshes.Size(), " meshes");
std::vector<std::unique_ptr<aiMesh>> meshes; std::vector<std::unique_ptr<aiMesh>> meshes;
@ -463,7 +479,17 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
"\" does not match the vertex count"); "\" does not match the vertex count");
continue; continue;
} }
attr.color[c]->ExtractData(aim->mColors[c]);
auto componentType = attr.color[c]->componentType;
if (componentType == glTF2::ComponentType_FLOAT) {
attr.color[c]->ExtractData(aim->mColors[c]);
} else {
if (componentType == glTF2::ComponentType_UNSIGNED_BYTE) {
aim->mColors[c] = GetVertexColorsForType<unsigned char>(attr.color[c]);
} else if (componentType == glTF2::ComponentType_UNSIGNED_SHORT) {
aim->mColors[c] = GetVertexColorsForType<unsigned short>(attr.color[c]);
}
}
} }
for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) { for (size_t tc = 0; tc < attr.texcoord.size() && tc < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++tc) {
if (!attr.texcoord[tc]) { if (!attr.texcoord[tc]) {