|
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|
|
|
|
|
Copyright (c) 2006-2022, assimp team
|
|
Copyright (c) 2006-2022, assimp team
|
|
|
|
|
|
-
|
|
|
|
All rights reserved.
|
|
All rights reserved.
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
Redistribution and use of this software in source and binary forms,
|
|
@@ -40,9 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
----------------------------------------------------------------------
|
|
----------------------------------------------------------------------
|
|
*/
|
|
*/
|
|
|
|
|
|
-/** @file IFCUtil.cpp
|
|
|
|
- * @brief Implementation of conversion routines for some common Ifc helper entities.
|
|
|
|
- */
|
|
|
|
|
|
+/// @file IFCUtil.cpp
|
|
|
|
+/// @brief Implementation of conversion routines for some common Ifc helper entities.
|
|
|
|
|
|
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
|
|
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
|
|
|
|
|
|
@@ -66,8 +64,7 @@ void TempOpening::Transform(const IfcMatrix4& mat) {
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-aiMesh* TempMesh::ToMesh()
|
|
|
|
-{
|
|
|
|
|
|
+aiMesh* TempMesh::ToMesh() {
|
|
ai_assert(mVerts.size() == std::accumulate(mVertcnt.begin(),mVertcnt.end(),size_t(0)));
|
|
ai_assert(mVerts.size() == std::accumulate(mVertcnt.begin(),mVertcnt.end(),size_t(0)));
|
|
|
|
|
|
if (mVerts.empty()) {
|
|
if (mVerts.empty()) {
|
|
@@ -105,36 +102,31 @@ aiMesh* TempMesh::ToMesh()
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void TempMesh::Clear()
|
|
|
|
-{
|
|
|
|
|
|
+void TempMesh::Clear() {
|
|
mVerts.clear();
|
|
mVerts.clear();
|
|
mVertcnt.clear();
|
|
mVertcnt.clear();
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void TempMesh::Transform(const IfcMatrix4& mat)
|
|
|
|
-{
|
|
|
|
|
|
+void TempMesh::Transform(const IfcMatrix4& mat) {
|
|
for(IfcVector3& v : mVerts) {
|
|
for(IfcVector3& v : mVerts) {
|
|
v *= mat;
|
|
v *= mat;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------
|
|
-IfcVector3 TempMesh::Center() const
|
|
|
|
-{
|
|
|
|
- return (mVerts.size() == 0) ? IfcVector3(0.0f, 0.0f, 0.0f) : (std::accumulate(mVerts.begin(),mVerts.end(),IfcVector3()) / static_cast<IfcFloat>(mVerts.size()));
|
|
|
|
|
|
+IfcVector3 TempMesh::Center() const {
|
|
|
|
+ return mVerts.empty() ? IfcVector3(0.0f, 0.0f, 0.0f) : (std::accumulate(mVerts.begin(),mVerts.end(),IfcVector3()) / static_cast<IfcFloat>(mVerts.size()));
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void TempMesh::Append(const TempMesh& other)
|
|
|
|
-{
|
|
|
|
|
|
+void TempMesh::Append(const TempMesh& other) {
|
|
mVerts.insert(mVerts.end(),other.mVerts.begin(),other.mVerts.end());
|
|
mVerts.insert(mVerts.end(),other.mVerts.begin(),other.mVerts.end());
|
|
mVertcnt.insert(mVertcnt.end(),other.mVertcnt.begin(),other.mVertcnt.end());
|
|
mVertcnt.insert(mVertcnt.end(),other.mVertcnt.begin(),other.mVertcnt.end());
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void TempMesh::RemoveDegenerates()
|
|
|
|
-{
|
|
|
|
|
|
+void TempMesh::RemoveDegenerates() {
|
|
// The strategy is simple: walk the mesh and compute normals using
|
|
// The strategy is simple: walk the mesh and compute normals using
|
|
// Newell's algorithm. The length of the normals gives the area
|
|
// Newell's algorithm. The length of the normals gives the area
|
|
// of the polygons, which is close to zero for lines.
|
|
// of the polygons, which is close to zero for lines.
|
|
@@ -167,11 +159,9 @@ void TempMesh::RemoveDegenerates()
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-IfcVector3 TempMesh::ComputePolygonNormal(const IfcVector3* vtcs, size_t cnt, bool normalize)
|
|
|
|
-{
|
|
|
|
|
|
+IfcVector3 TempMesh::ComputePolygonNormal(const IfcVector3* vtcs, size_t cnt, bool normalize) {
|
|
std::vector<IfcFloat> temp((cnt+2)*3);
|
|
std::vector<IfcFloat> temp((cnt+2)*3);
|
|
- for( size_t vofs = 0, i = 0; vofs < cnt; ++vofs )
|
|
|
|
- {
|
|
|
|
|
|
+ for( size_t vofs = 0, i = 0; vofs < cnt; ++vofs ) {
|
|
const IfcVector3& v = vtcs[vofs];
|
|
const IfcVector3& v = vtcs[vofs];
|
|
temp[i++] = v.x;
|
|
temp[i++] = v.x;
|
|
temp[i++] = v.y;
|
|
temp[i++] = v.y;
|
|
@@ -185,9 +175,8 @@ IfcVector3 TempMesh::ComputePolygonNormal(const IfcVector3* vtcs, size_t cnt, bo
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
void TempMesh::ComputePolygonNormals(std::vector<IfcVector3>& normals,
|
|
void TempMesh::ComputePolygonNormals(std::vector<IfcVector3>& normals,
|
|
- bool normalize,
|
|
|
|
- size_t ofs) const
|
|
|
|
-{
|
|
|
|
|
|
+ bool normalize,
|
|
|
|
+ size_t ofs) const {
|
|
size_t max_vcount = 0;
|
|
size_t max_vcount = 0;
|
|
std::vector<unsigned int>::const_iterator begin = mVertcnt.begin()+ofs, end = mVertcnt.end(), iit;
|
|
std::vector<unsigned int>::const_iterator begin = mVertcnt.begin()+ofs, end = mVertcnt.end(), iit;
|
|
for(iit = begin; iit != end; ++iit) {
|
|
for(iit = begin; iit != end; ++iit) {
|
|
@@ -250,29 +239,27 @@ struct FindVector {
|
|
};
|
|
};
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void TempMesh::FixupFaceOrientation()
|
|
|
|
-{
|
|
|
|
|
|
+void TempMesh::FixupFaceOrientation() {
|
|
const IfcVector3 vavg = Center();
|
|
const IfcVector3 vavg = Center();
|
|
|
|
|
|
// create a list of start indices for all faces to allow random access to faces
|
|
// create a list of start indices for all faces to allow random access to faces
|
|
std::vector<size_t> faceStartIndices(mVertcnt.size());
|
|
std::vector<size_t> faceStartIndices(mVertcnt.size());
|
|
- for( size_t i = 0, a = 0; a < mVertcnt.size(); i += mVertcnt[a], ++a )
|
|
|
|
|
|
+ for( size_t i = 0, a = 0; a < mVertcnt.size(); i += mVertcnt[a], ++a ) {
|
|
faceStartIndices[a] = i;
|
|
faceStartIndices[a] = i;
|
|
|
|
+ }
|
|
|
|
|
|
// list all faces on a vertex
|
|
// list all faces on a vertex
|
|
std::map<IfcVector3, std::vector<size_t>, CompareVector> facesByVertex;
|
|
std::map<IfcVector3, std::vector<size_t>, CompareVector> facesByVertex;
|
|
- for( size_t a = 0; a < mVertcnt.size(); ++a )
|
|
|
|
- {
|
|
|
|
- for( size_t b = 0; b < mVertcnt[a]; ++b )
|
|
|
|
|
|
+ for( size_t a = 0; a < mVertcnt.size(); ++a ) {
|
|
|
|
+ for( size_t b = 0; b < mVertcnt[a]; ++b ) {
|
|
facesByVertex[mVerts[faceStartIndices[a] + b]].push_back(a);
|
|
facesByVertex[mVerts[faceStartIndices[a] + b]].push_back(a);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// determine neighbourhood for all polys
|
|
// determine neighbourhood for all polys
|
|
std::vector<size_t> neighbour(mVerts.size(), SIZE_MAX);
|
|
std::vector<size_t> neighbour(mVerts.size(), SIZE_MAX);
|
|
std::vector<size_t> tempIntersect(10);
|
|
std::vector<size_t> tempIntersect(10);
|
|
- for( size_t a = 0; a < mVertcnt.size(); ++a )
|
|
|
|
- {
|
|
|
|
- for( size_t b = 0; b < mVertcnt[a]; ++b )
|
|
|
|
- {
|
|
|
|
|
|
+ for( size_t a = 0; a < mVertcnt.size(); ++a ) {
|
|
|
|
+ for( size_t b = 0; b < mVertcnt[a]; ++b ) {
|
|
size_t ib = faceStartIndices[a] + b, nib = faceStartIndices[a] + (b + 1) % mVertcnt[a];
|
|
size_t ib = faceStartIndices[a] + b, nib = faceStartIndices[a] + (b + 1) % mVertcnt[a];
|
|
const std::vector<size_t>& facesOnB = facesByVertex[mVerts[ib]];
|
|
const std::vector<size_t>& facesOnB = facesByVertex[mVerts[ib]];
|
|
const std::vector<size_t>& facesOnNB = facesByVertex[mVerts[nib]];
|
|
const std::vector<size_t>& facesOnNB = facesByVertex[mVerts[nib]];
|
|
@@ -281,10 +268,12 @@ void TempMesh::FixupFaceOrientation()
|
|
std::vector<size_t>::iterator sectend = std::set_intersection(
|
|
std::vector<size_t>::iterator sectend = std::set_intersection(
|
|
facesOnB.begin(), facesOnB.end(), facesOnNB.begin(), facesOnNB.end(), sectstart);
|
|
facesOnB.begin(), facesOnB.end(), facesOnNB.begin(), facesOnNB.end(), sectstart);
|
|
|
|
|
|
- if( std::distance(sectstart, sectend) != 2 )
|
|
|
|
|
|
+ if( std::distance(sectstart, sectend) != 2 ) {
|
|
continue;
|
|
continue;
|
|
- if( *sectstart == a )
|
|
|
|
|
|
+ }
|
|
|
|
+ if( *sectstart == a ) {
|
|
++sectstart;
|
|
++sectstart;
|
|
|
|
+ }
|
|
neighbour[ib] = *sectstart;
|
|
neighbour[ib] = *sectstart;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -293,15 +282,14 @@ void TempMesh::FixupFaceOrientation()
|
|
// facing outwards. So we reverse this face to point outwards in relation to the center. Then we adapt neighbouring
|
|
// facing outwards. So we reverse this face to point outwards in relation to the center. Then we adapt neighbouring
|
|
// faces to have the same winding until all faces have been tested.
|
|
// faces to have the same winding until all faces have been tested.
|
|
std::vector<bool> faceDone(mVertcnt.size(), false);
|
|
std::vector<bool> faceDone(mVertcnt.size(), false);
|
|
- while( std::count(faceDone.begin(), faceDone.end(), false) != 0 )
|
|
|
|
- {
|
|
|
|
|
|
+ while( std::count(faceDone.begin(), faceDone.end(), false) != 0 ) {
|
|
// find the farthest of the remaining faces
|
|
// find the farthest of the remaining faces
|
|
size_t farthestIndex = SIZE_MAX;
|
|
size_t farthestIndex = SIZE_MAX;
|
|
IfcFloat farthestDistance = -1.0;
|
|
IfcFloat farthestDistance = -1.0;
|
|
- for( size_t a = 0; a < mVertcnt.size(); ++a )
|
|
|
|
- {
|
|
|
|
- if( faceDone[a] )
|
|
|
|
|
|
+ for( size_t a = 0; a < mVertcnt.size(); ++a ) {
|
|
|
|
+ if( faceDone[a] ) {
|
|
continue;
|
|
continue;
|
|
|
|
+ }
|
|
IfcVector3 faceCenter = std::accumulate(mVerts.begin() + faceStartIndices[a],
|
|
IfcVector3 faceCenter = std::accumulate(mVerts.begin() + faceStartIndices[a],
|
|
mVerts.begin() + faceStartIndices[a] + mVertcnt[a], IfcVector3(0.0)) / IfcFloat(mVertcnt[a]);
|
|
mVerts.begin() + faceStartIndices[a] + mVertcnt[a], IfcVector3(0.0)) / IfcFloat(mVertcnt[a]);
|
|
IfcFloat dst = (faceCenter - vavg).SquareLength();
|
|
IfcFloat dst = (faceCenter - vavg).SquareLength();
|
|
@@ -315,8 +303,7 @@ void TempMesh::FixupFaceOrientation()
|
|
/ IfcFloat(mVertcnt[farthestIndex]);
|
|
/ IfcFloat(mVertcnt[farthestIndex]);
|
|
// We accept a bit of negative orientation without reversing. In case of doubt, prefer the orientation given in
|
|
// We accept a bit of negative orientation without reversing. In case of doubt, prefer the orientation given in
|
|
// the file.
|
|
// the file.
|
|
- if( (farthestNormal * (farthestCenter - vavg).Normalize()) < -0.4 )
|
|
|
|
- {
|
|
|
|
|
|
+ if( (farthestNormal * (farthestCenter - vavg).Normalize()) < -0.4 ) {
|
|
size_t fsi = faceStartIndices[farthestIndex], fvc = mVertcnt[farthestIndex];
|
|
size_t fsi = faceStartIndices[farthestIndex], fvc = mVertcnt[farthestIndex];
|
|
std::reverse(mVerts.begin() + fsi, mVerts.begin() + fsi + fvc);
|
|
std::reverse(mVerts.begin() + fsi, mVerts.begin() + fsi + fvc);
|
|
std::reverse(neighbour.begin() + fsi, neighbour.begin() + fsi + fvc);
|
|
std::reverse(neighbour.begin() + fsi, neighbour.begin() + fsi + fvc);
|
|
@@ -333,19 +320,18 @@ void TempMesh::FixupFaceOrientation()
|
|
todo.push_back(farthestIndex);
|
|
todo.push_back(farthestIndex);
|
|
|
|
|
|
// go over its neighbour faces recursively and adapt their winding order to match the farthest face
|
|
// go over its neighbour faces recursively and adapt their winding order to match the farthest face
|
|
- while( !todo.empty() )
|
|
|
|
- {
|
|
|
|
|
|
+ while( !todo.empty() ) {
|
|
size_t tdf = todo.back();
|
|
size_t tdf = todo.back();
|
|
size_t vsi = faceStartIndices[tdf], vc = mVertcnt[tdf];
|
|
size_t vsi = faceStartIndices[tdf], vc = mVertcnt[tdf];
|
|
todo.pop_back();
|
|
todo.pop_back();
|
|
|
|
|
|
// check its neighbours
|
|
// check its neighbours
|
|
- for( size_t a = 0; a < vc; ++a )
|
|
|
|
- {
|
|
|
|
|
|
+ for( size_t a = 0; a < vc; ++a ) {
|
|
// ignore neighbours if we already checked them
|
|
// ignore neighbours if we already checked them
|
|
size_t nbi = neighbour[vsi + a];
|
|
size_t nbi = neighbour[vsi + a];
|
|
- if( nbi == SIZE_MAX || faceDone[nbi] )
|
|
|
|
|
|
+ if( nbi == SIZE_MAX || faceDone[nbi] ) {
|
|
continue;
|
|
continue;
|
|
|
|
+ }
|
|
|
|
|
|
const IfcVector3& vp = mVerts[vsi + a];
|
|
const IfcVector3& vp = mVerts[vsi + a];
|
|
size_t nbvsi = faceStartIndices[nbi], nbvc = mVertcnt[nbi];
|
|
size_t nbvsi = faceStartIndices[nbi], nbvc = mVertcnt[nbi];
|
|
@@ -388,32 +374,8 @@ void TempMesh::RemoveAdjacentDuplicates() {
|
|
IfcVector3 vmin,vmax;
|
|
IfcVector3 vmin,vmax;
|
|
ArrayBounds(&*base, cnt ,vmin,vmax);
|
|
ArrayBounds(&*base, cnt ,vmin,vmax);
|
|
|
|
|
|
-
|
|
|
|
const IfcFloat epsilon = (vmax-vmin).SquareLength() / static_cast<IfcFloat>(1e9);
|
|
const IfcFloat epsilon = (vmax-vmin).SquareLength() / static_cast<IfcFloat>(1e9);
|
|
- //const IfcFloat dotepsilon = 1e-9;
|
|
|
|
-
|
|
|
|
- //// look for vertices that lie directly on the line between their predecessor and their
|
|
|
|
- //// successor and replace them with either of them.
|
|
|
|
-
|
|
|
|
- //for(size_t i = 0; i < cnt; ++i) {
|
|
|
|
- // IfcVector3& v1 = *(base+i), &v0 = *(base+(i?i-1:cnt-1)), &v2 = *(base+(i+1)%cnt);
|
|
|
|
- // const IfcVector3& d0 = (v1-v0), &d1 = (v2-v1);
|
|
|
|
- // const IfcFloat l0 = d0.SquareLength(), l1 = d1.SquareLength();
|
|
|
|
- // if (!l0 || !l1) {
|
|
|
|
- // continue;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // const IfcFloat d = (d0/std::sqrt(l0))*(d1/std::sqrt(l1));
|
|
|
|
-
|
|
|
|
- // if ( d >= 1.f-dotepsilon ) {
|
|
|
|
- // v1 = v0;
|
|
|
|
- // }
|
|
|
|
- // else if ( d < -1.f+dotepsilon ) {
|
|
|
|
- // v2 = v1;
|
|
|
|
- // continue;
|
|
|
|
- // }
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
|
|
+
|
|
// drop any identical, adjacent vertices. this pass will collect the dropouts
|
|
// drop any identical, adjacent vertices. this pass will collect the dropouts
|
|
// of the previous pass as a side-effect.
|
|
// of the previous pass as a side-effect.
|
|
FuzzyVectorCompare fz(epsilon);
|
|
FuzzyVectorCompare fz(epsilon);
|
|
@@ -440,78 +402,58 @@ void TempMesh::RemoveAdjacentDuplicates() {
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void TempMesh::Swap(TempMesh& other)
|
|
|
|
-{
|
|
|
|
|
|
+void TempMesh::Swap(TempMesh& other) {
|
|
mVertcnt.swap(other.mVertcnt);
|
|
mVertcnt.swap(other.mVertcnt);
|
|
mVerts.swap(other.mVerts);
|
|
mVerts.swap(other.mVerts);
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-bool IsTrue(const ::Assimp::STEP::EXPRESS::BOOLEAN& in)
|
|
|
|
-{
|
|
|
|
|
|
+bool IsTrue(const ::Assimp::STEP::EXPRESS::BOOLEAN& in) {
|
|
return (std::string)in == "TRUE" || (std::string)in == "T";
|
|
return (std::string)in == "TRUE" || (std::string)in == "T";
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-IfcFloat ConvertSIPrefix(const std::string& prefix)
|
|
|
|
-{
|
|
|
|
|
|
+IfcFloat ConvertSIPrefix(const std::string& prefix) {
|
|
if (prefix == "EXA") {
|
|
if (prefix == "EXA") {
|
|
return 1e18f;
|
|
return 1e18f;
|
|
- }
|
|
|
|
- else if (prefix == "PETA") {
|
|
|
|
|
|
+ } else if (prefix == "PETA") {
|
|
return 1e15f;
|
|
return 1e15f;
|
|
- }
|
|
|
|
- else if (prefix == "TERA") {
|
|
|
|
|
|
+ } else if (prefix == "TERA") {
|
|
return 1e12f;
|
|
return 1e12f;
|
|
- }
|
|
|
|
- else if (prefix == "GIGA") {
|
|
|
|
|
|
+ } else if (prefix == "GIGA") {
|
|
return 1e9f;
|
|
return 1e9f;
|
|
- }
|
|
|
|
- else if (prefix == "MEGA") {
|
|
|
|
|
|
+ } else if (prefix == "MEGA") {
|
|
return 1e6f;
|
|
return 1e6f;
|
|
- }
|
|
|
|
- else if (prefix == "KILO") {
|
|
|
|
|
|
+ } else if (prefix == "KILO") {
|
|
return 1e3f;
|
|
return 1e3f;
|
|
- }
|
|
|
|
- else if (prefix == "HECTO") {
|
|
|
|
|
|
+ } else if (prefix == "HECTO") {
|
|
return 1e2f;
|
|
return 1e2f;
|
|
- }
|
|
|
|
- else if (prefix == "DECA") {
|
|
|
|
|
|
+ } else if (prefix == "DECA") {
|
|
return 1e-0f;
|
|
return 1e-0f;
|
|
- }
|
|
|
|
- else if (prefix == "DECI") {
|
|
|
|
|
|
+ } else if (prefix == "DECI") {
|
|
return 1e-1f;
|
|
return 1e-1f;
|
|
- }
|
|
|
|
- else if (prefix == "CENTI") {
|
|
|
|
|
|
+ } else if (prefix == "CENTI") {
|
|
return 1e-2f;
|
|
return 1e-2f;
|
|
- }
|
|
|
|
- else if (prefix == "MILLI") {
|
|
|
|
|
|
+ } else if (prefix == "MILLI") {
|
|
return 1e-3f;
|
|
return 1e-3f;
|
|
- }
|
|
|
|
- else if (prefix == "MICRO") {
|
|
|
|
|
|
+ } else if (prefix == "MICRO") {
|
|
return 1e-6f;
|
|
return 1e-6f;
|
|
- }
|
|
|
|
- else if (prefix == "NANO") {
|
|
|
|
|
|
+ } else if (prefix == "NANO") {
|
|
return 1e-9f;
|
|
return 1e-9f;
|
|
- }
|
|
|
|
- else if (prefix == "PICO") {
|
|
|
|
|
|
+ } else if (prefix == "PICO") {
|
|
return 1e-12f;
|
|
return 1e-12f;
|
|
- }
|
|
|
|
- else if (prefix == "FEMTO") {
|
|
|
|
|
|
+ } else if (prefix == "FEMTO") {
|
|
return 1e-15f;
|
|
return 1e-15f;
|
|
- }
|
|
|
|
- else if (prefix == "ATTO") {
|
|
|
|
|
|
+ } else if (prefix == "ATTO") {
|
|
return 1e-18f;
|
|
return 1e-18f;
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
IFCImporter::LogError("Unrecognized SI prefix: ", prefix);
|
|
IFCImporter::LogError("Unrecognized SI prefix: ", prefix);
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourRgb& in)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourRgb& in) {
|
|
out.r = static_cast<float>( in.Red );
|
|
out.r = static_cast<float>( in.Red );
|
|
out.g = static_cast<float>( in.Green );
|
|
out.g = static_cast<float>( in.Green );
|
|
out.b = static_cast<float>( in.Blue );
|
|
out.b = static_cast<float>( in.Blue );
|
|
@@ -519,8 +461,10 @@ void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourRgb& in)
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourOrFactor& in,ConversionData& conv,const aiColor4D* base)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertColor(aiColor4D& out,
|
|
|
|
+ const Schema_2x3::IfcColourOrFactor& in,
|
|
|
|
+ ConversionData& conv,
|
|
|
|
+ const aiColor4D* base) {
|
|
if (const ::Assimp::STEP::EXPRESS::REAL* const r = in.ToPtr<::Assimp::STEP::EXPRESS::REAL>()) {
|
|
if (const ::Assimp::STEP::EXPRESS::REAL* const r = in.ToPtr<::Assimp::STEP::EXPRESS::REAL>()) {
|
|
out.r = out.g = out.b = static_cast<float>(*r);
|
|
out.r = out.g = out.b = static_cast<float>(*r);
|
|
if(base) {
|
|
if(base) {
|
|
@@ -528,20 +472,18 @@ void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourOrFactor& in,Conver
|
|
out.g *= static_cast<float>( base->g );
|
|
out.g *= static_cast<float>( base->g );
|
|
out.b *= static_cast<float>( base->b );
|
|
out.b *= static_cast<float>( base->b );
|
|
out.a = static_cast<float>( base->a );
|
|
out.a = static_cast<float>( base->a );
|
|
|
|
+ } else {
|
|
|
|
+ out.a = 1.0;
|
|
}
|
|
}
|
|
- else out.a = 1.0;
|
|
|
|
- }
|
|
|
|
- else if (const Schema_2x3::IfcColourRgb* const rgb = in.ResolveSelectPtr<Schema_2x3::IfcColourRgb>(conv.db)) {
|
|
|
|
|
|
+ } else if (const Schema_2x3::IfcColourRgb* const rgb = in.ResolveSelectPtr<Schema_2x3::IfcColourRgb>(conv.db)) {
|
|
ConvertColor(out,*rgb);
|
|
ConvertColor(out,*rgb);
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
IFCImporter::LogWarn("skipping unknown IfcColourOrFactor entity");
|
|
IFCImporter::LogWarn("skipping unknown IfcColourOrFactor entity");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertCartesianPoint(IfcVector3& out, const Schema_2x3::IfcCartesianPoint& in)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertCartesianPoint(IfcVector3& out, const Schema_2x3::IfcCartesianPoint& in) {
|
|
out = IfcVector3();
|
|
out = IfcVector3();
|
|
for(size_t i = 0; i < in.Coordinates.size(); ++i) {
|
|
for(size_t i = 0; i < in.Coordinates.size(); ++i) {
|
|
out[static_cast<unsigned int>(i)] = in.Coordinates[i];
|
|
out[static_cast<unsigned int>(i)] = in.Coordinates[i];
|
|
@@ -549,15 +491,13 @@ void ConvertCartesianPoint(IfcVector3& out, const Schema_2x3::IfcCartesianPoint&
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertVector(IfcVector3& out, const Schema_2x3::IfcVector& in)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertVector(IfcVector3& out, const Schema_2x3::IfcVector& in) {
|
|
ConvertDirection(out,in.Orientation);
|
|
ConvertDirection(out,in.Orientation);
|
|
out *= in.Magnitude;
|
|
out *= in.Magnitude;
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertDirection(IfcVector3& out, const Schema_2x3::IfcDirection& in)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertDirection(IfcVector3& out, const Schema_2x3::IfcDirection& in) {
|
|
out = IfcVector3();
|
|
out = IfcVector3();
|
|
for(size_t i = 0; i < in.DirectionRatios.size(); ++i) {
|
|
for(size_t i = 0; i < in.DirectionRatios.size(); ++i) {
|
|
out[static_cast<unsigned int>(i)] = in.DirectionRatios[i];
|
|
out[static_cast<unsigned int>(i)] = in.DirectionRatios[i];
|
|
@@ -571,8 +511,7 @@ void ConvertDirection(IfcVector3& out, const Schema_2x3::IfcDirection& in)
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void AssignMatrixAxes(IfcMatrix4& out, const IfcVector3& x, const IfcVector3& y, const IfcVector3& z)
|
|
|
|
-{
|
|
|
|
|
|
+void AssignMatrixAxes(IfcMatrix4& out, const IfcVector3& x, const IfcVector3& y, const IfcVector3& z) {
|
|
out.a1 = x.x;
|
|
out.a1 = x.x;
|
|
out.b1 = x.y;
|
|
out.b1 = x.y;
|
|
out.c1 = x.z;
|
|
out.c1 = x.z;
|
|
@@ -587,8 +526,7 @@ void AssignMatrixAxes(IfcMatrix4& out, const IfcVector3& x, const IfcVector3& y,
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement3D& in)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement3D& in) {
|
|
IfcVector3 loc;
|
|
IfcVector3 loc;
|
|
ConvertCartesianPoint(loc,in.Location);
|
|
ConvertCartesianPoint(loc,in.Location);
|
|
|
|
|
|
@@ -612,8 +550,7 @@ void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement3D
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement2D& in)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement2D& in) {
|
|
IfcVector3 loc;
|
|
IfcVector3 loc;
|
|
ConvertCartesianPoint(loc,in.Location);
|
|
ConvertCartesianPoint(loc,in.Location);
|
|
|
|
|
|
@@ -629,34 +566,28 @@ void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement2D
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertAxisPlacement(IfcVector3& axis, IfcVector3& pos, const Schema_2x3::IfcAxis1Placement& in)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertAxisPlacement(IfcVector3& axis, IfcVector3& pos, const Schema_2x3::IfcAxis1Placement& in) {
|
|
ConvertCartesianPoint(pos,in.Location);
|
|
ConvertCartesianPoint(pos,in.Location);
|
|
if (in.Axis) {
|
|
if (in.Axis) {
|
|
ConvertDirection(axis,in.Axis.Get());
|
|
ConvertDirection(axis,in.Axis.Get());
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
axis = IfcVector3(0.f,0.f,1.f);
|
|
axis = IfcVector3(0.f,0.f,1.f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement& in, ConversionData& conv)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement& in, ConversionData& conv) {
|
|
if(const Schema_2x3::IfcAxis2Placement3D* pl3 = in.ResolveSelectPtr<Schema_2x3::IfcAxis2Placement3D>(conv.db)) {
|
|
if(const Schema_2x3::IfcAxis2Placement3D* pl3 = in.ResolveSelectPtr<Schema_2x3::IfcAxis2Placement3D>(conv.db)) {
|
|
ConvertAxisPlacement(out,*pl3);
|
|
ConvertAxisPlacement(out,*pl3);
|
|
- }
|
|
|
|
- else if(const Schema_2x3::IfcAxis2Placement2D* pl2 = in.ResolveSelectPtr<Schema_2x3::IfcAxis2Placement2D>(conv.db)) {
|
|
|
|
|
|
+ } else if(const Schema_2x3::IfcAxis2Placement2D* pl2 = in.ResolveSelectPtr<Schema_2x3::IfcAxis2Placement2D>(conv.db)) {
|
|
ConvertAxisPlacement(out,*pl2);
|
|
ConvertAxisPlacement(out,*pl2);
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
IFCImporter::LogWarn("skipping unknown IfcAxis2Placement entity");
|
|
IFCImporter::LogWarn("skipping unknown IfcAxis2Placement entity");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-void ConvertTransformOperator(IfcMatrix4& out, const Schema_2x3::IfcCartesianTransformationOperator& op)
|
|
|
|
-{
|
|
|
|
|
|
+void ConvertTransformOperator(IfcMatrix4& out, const Schema_2x3::IfcCartesianTransformationOperator& op) {
|
|
IfcVector3 loc;
|
|
IfcVector3 loc;
|
|
ConvertCartesianPoint(loc,op.LocalOrigin);
|
|
ConvertCartesianPoint(loc,op.LocalOrigin);
|
|
|
|
|
|
@@ -677,14 +608,12 @@ void ConvertTransformOperator(IfcMatrix4& out, const Schema_2x3::IfcCartesianTra
|
|
IfcMatrix4::Translation(loc,locm);
|
|
IfcMatrix4::Translation(loc,locm);
|
|
AssignMatrixAxes(out,x,y,z);
|
|
AssignMatrixAxes(out,x,y,z);
|
|
|
|
|
|
-
|
|
|
|
IfcVector3 vscale;
|
|
IfcVector3 vscale;
|
|
if (const Schema_2x3::IfcCartesianTransformationOperator3DnonUniform* nuni = op.ToPtr<Schema_2x3::IfcCartesianTransformationOperator3DnonUniform>()) {
|
|
if (const Schema_2x3::IfcCartesianTransformationOperator3DnonUniform* nuni = op.ToPtr<Schema_2x3::IfcCartesianTransformationOperator3DnonUniform>()) {
|
|
vscale.x = nuni->Scale?op.Scale.Get():1.f;
|
|
vscale.x = nuni->Scale?op.Scale.Get():1.f;
|
|
vscale.y = nuni->Scale2?nuni->Scale2.Get():1.f;
|
|
vscale.y = nuni->Scale2?nuni->Scale2.Get():1.f;
|
|
vscale.z = nuni->Scale3?nuni->Scale3.Get():1.f;
|
|
vscale.z = nuni->Scale3?nuni->Scale3.Get():1.f;
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
const IfcFloat sc = op.Scale?op.Scale.Get():1.f;
|
|
const IfcFloat sc = op.Scale?op.Scale.Get():1.f;
|
|
vscale = IfcVector3(sc,sc,sc);
|
|
vscale = IfcVector3(sc,sc,sc);
|
|
}
|
|
}
|
|
@@ -695,8 +624,7 @@ void ConvertTransformOperator(IfcMatrix4& out, const Schema_2x3::IfcCartesianTra
|
|
out = locm * out * s;
|
|
out = locm * out * s;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
} // ! IFC
|
|
} // ! IFC
|
|
} // ! Assimp
|
|
} // ! Assimp
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
+#endif // ASSIMP_BUILD_NO_IFC_IMPORTER
|