nuclear@0: /* nuclear@0: Open Asset Import Library (assimp) nuclear@0: ---------------------------------------------------------------------- nuclear@0: nuclear@0: Copyright (c) 2006-2012, assimp team nuclear@0: All rights reserved. nuclear@0: nuclear@0: Redistribution and use of this software in source and binary forms, nuclear@0: with or without modification, are permitted provided that the nuclear@0: following conditions are met: nuclear@0: nuclear@0: * Redistributions of source code must retain the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer. nuclear@0: nuclear@0: * Redistributions in binary form must reproduce the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer in the documentation and/or other nuclear@0: materials provided with the distribution. nuclear@0: nuclear@0: * Neither the name of the assimp team, nor the names of its nuclear@0: contributors may be used to endorse or promote products nuclear@0: derived from this software without specific prior nuclear@0: written permission of the assimp team. nuclear@0: nuclear@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS nuclear@0: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT nuclear@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR nuclear@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT nuclear@0: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, nuclear@0: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT nuclear@0: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, nuclear@0: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY nuclear@0: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT nuclear@0: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE nuclear@0: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. nuclear@0: nuclear@0: ---------------------------------------------------------------------- nuclear@0: */ nuclear@0: nuclear@0: /** @file IFCUtil.cpp nuclear@0: * @brief Implementation of conversion routines for some common Ifc helper entities. nuclear@0: */ nuclear@0: nuclear@0: #include "AssimpPCH.h" nuclear@0: nuclear@0: #ifndef ASSIMP_BUILD_NO_IFC_IMPORTER nuclear@0: nuclear@0: #include "IFCUtil.h" nuclear@0: #include "PolyTools.h" nuclear@0: #include "ProcessHelper.h" nuclear@0: nuclear@0: namespace Assimp { nuclear@0: namespace IFC { nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void TempOpening::Transform(const IfcMatrix4& mat) nuclear@0: { nuclear@0: if(profileMesh) { nuclear@0: profileMesh->Transform(mat); nuclear@0: } nuclear@0: if(profileMesh2D) { nuclear@0: profileMesh2D->Transform(mat); nuclear@0: } nuclear@0: extrusionDir *= IfcMatrix3(mat); nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: aiMesh* TempMesh::ToMesh() nuclear@0: { nuclear@0: ai_assert(verts.size() == std::accumulate(vertcnt.begin(),vertcnt.end(),size_t(0))); nuclear@0: nuclear@0: if (verts.empty()) { nuclear@0: return NULL; nuclear@0: } nuclear@0: nuclear@0: std::auto_ptr mesh(new aiMesh()); nuclear@0: nuclear@0: // copy vertices nuclear@0: mesh->mNumVertices = static_cast(verts.size()); nuclear@0: mesh->mVertices = new aiVector3D[mesh->mNumVertices]; nuclear@0: std::copy(verts.begin(),verts.end(),mesh->mVertices); nuclear@0: nuclear@0: // and build up faces nuclear@0: mesh->mNumFaces = static_cast(vertcnt.size()); nuclear@0: mesh->mFaces = new aiFace[mesh->mNumFaces]; nuclear@0: nuclear@0: for(unsigned int i = 0,n=0, acc = 0; i < mesh->mNumFaces; ++n) { nuclear@0: aiFace& f = mesh->mFaces[i]; nuclear@0: if (!vertcnt[n]) { nuclear@0: --mesh->mNumFaces; nuclear@0: continue; nuclear@0: } nuclear@0: nuclear@0: f.mNumIndices = vertcnt[n]; nuclear@0: f.mIndices = new unsigned int[f.mNumIndices]; nuclear@0: for(unsigned int a = 0; a < f.mNumIndices; ++a) { nuclear@0: f.mIndices[a] = acc++; nuclear@0: } nuclear@0: nuclear@0: ++i; nuclear@0: } nuclear@0: nuclear@0: return mesh.release(); nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void TempMesh::Clear() nuclear@0: { nuclear@0: verts.clear(); nuclear@0: vertcnt.clear(); nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void TempMesh::Transform(const IfcMatrix4& mat) nuclear@0: { nuclear@0: BOOST_FOREACH(IfcVector3& v, verts) { nuclear@0: v *= mat; nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------ nuclear@0: IfcVector3 TempMesh::Center() const nuclear@0: { nuclear@0: return std::accumulate(verts.begin(),verts.end(),IfcVector3()) / static_cast(verts.size()); nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void TempMesh::Append(const TempMesh& other) nuclear@0: { nuclear@0: verts.insert(verts.end(),other.verts.begin(),other.verts.end()); nuclear@0: vertcnt.insert(vertcnt.end(),other.vertcnt.begin(),other.vertcnt.end()); nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void TempMesh::RemoveDegenerates() nuclear@0: { nuclear@0: // The strategy is simple: walk the mesh and compute normals using nuclear@0: // Newell's algorithm. The length of the normals gives the area nuclear@0: // of the polygons, which is close to zero for lines. nuclear@0: nuclear@0: std::vector normals; nuclear@0: ComputePolygonNormals(normals, false); nuclear@0: nuclear@0: bool drop = false; nuclear@0: size_t inor = 0; nuclear@0: nuclear@0: std::vector::iterator vit = verts.begin(); nuclear@0: for (std::vector::iterator it = vertcnt.begin(); it != vertcnt.end(); ++inor) { nuclear@0: const unsigned int pcount = *it; nuclear@0: nuclear@0: if (normals[inor].SquareLength() < 1e-5f) { nuclear@0: it = vertcnt.erase(it); nuclear@0: vit = verts.erase(vit, vit + pcount); nuclear@0: nuclear@0: drop = true; nuclear@0: continue; nuclear@0: } nuclear@0: nuclear@0: vit += pcount; nuclear@0: ++it; nuclear@0: } nuclear@0: nuclear@0: if(drop) { nuclear@0: IFCImporter::LogDebug("removing degenerate faces"); nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void TempMesh::ComputePolygonNormals(std::vector& normals, nuclear@0: bool normalize, nuclear@0: size_t ofs) const nuclear@0: { nuclear@0: size_t max_vcount = 0; nuclear@0: std::vector::const_iterator begin = vertcnt.begin()+ofs, end = vertcnt.end(), iit; nuclear@0: for(iit = begin; iit != end; ++iit) { nuclear@0: max_vcount = std::max(max_vcount,static_cast(*iit)); nuclear@0: } nuclear@0: nuclear@0: std::vector temp((max_vcount+2)*4); nuclear@0: normals.reserve( normals.size() + vertcnt.size()-ofs ); nuclear@0: nuclear@0: // `NewellNormal()` currently has a relatively strange interface and need to nuclear@0: // re-structure things a bit to meet them. nuclear@0: size_t vidx = std::accumulate(vertcnt.begin(),begin,0); nuclear@0: for(iit = begin; iit != end; vidx += *iit++) { nuclear@0: if (!*iit) { nuclear@0: normals.push_back(IfcVector3()); nuclear@0: continue; nuclear@0: } nuclear@0: for(size_t vofs = 0, cnt = 0; vofs < *iit; ++vofs) { nuclear@0: const IfcVector3& v = verts[vidx+vofs]; nuclear@0: temp[cnt++] = v.x; nuclear@0: temp[cnt++] = v.y; nuclear@0: temp[cnt++] = v.z; nuclear@0: #ifdef _DEBUG nuclear@0: temp[cnt] = std::numeric_limits::quiet_NaN(); nuclear@0: #endif nuclear@0: ++cnt; nuclear@0: } nuclear@0: nuclear@0: normals.push_back(IfcVector3()); nuclear@0: NewellNormal<4,4,4>(normals.back(),*iit,&temp[0],&temp[1],&temp[2]); nuclear@0: } nuclear@0: nuclear@0: if(normalize) { nuclear@0: BOOST_FOREACH(IfcVector3& n, normals) { nuclear@0: n.Normalize(); nuclear@0: } nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: // Compute the normal of the last polygon in the given mesh nuclear@0: IfcVector3 TempMesh::ComputeLastPolygonNormal(bool normalize) const nuclear@0: { nuclear@0: size_t total = vertcnt.back(), vidx = verts.size() - total; nuclear@0: std::vector temp((total+2)*3); nuclear@0: for(size_t vofs = 0, cnt = 0; vofs < total; ++vofs) { nuclear@0: const IfcVector3& v = verts[vidx+vofs]; nuclear@0: temp[cnt++] = v.x; nuclear@0: temp[cnt++] = v.y; nuclear@0: temp[cnt++] = v.z; nuclear@0: } nuclear@0: IfcVector3 nor; nuclear@0: NewellNormal<3,3,3>(nor,total,&temp[0],&temp[1],&temp[2]); nuclear@0: return normalize ? nor.Normalize() : nor; nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void TempMesh::FixupFaceOrientation() nuclear@0: { nuclear@0: const IfcVector3 vavg = Center(); nuclear@0: nuclear@0: std::vector normals; nuclear@0: ComputePolygonNormals(normals); nuclear@0: nuclear@0: size_t c = 0, ofs = 0; nuclear@0: BOOST_FOREACH(unsigned int cnt, vertcnt) { nuclear@0: if (cnt>2){ nuclear@0: const IfcVector3& thisvert = verts[c]; nuclear@0: if (normals[ofs]*(thisvert-vavg) < 0) { nuclear@0: std::reverse(verts.begin()+c,verts.begin()+cnt+c); nuclear@0: } nuclear@0: } nuclear@0: c += cnt; nuclear@0: ++ofs; nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void TempMesh::RemoveAdjacentDuplicates() nuclear@0: { nuclear@0: nuclear@0: bool drop = false; nuclear@0: std::vector::iterator base = verts.begin(); nuclear@0: BOOST_FOREACH(unsigned int& cnt, vertcnt) { nuclear@0: if (cnt < 2){ nuclear@0: base += cnt; nuclear@0: continue; nuclear@0: } nuclear@0: nuclear@0: IfcVector3 vmin,vmax; nuclear@0: ArrayBounds(&*base, cnt ,vmin,vmax); nuclear@0: nuclear@0: nuclear@0: const IfcFloat epsilon = (vmax-vmin).SquareLength() / static_cast(1e9); nuclear@0: //const IfcFloat dotepsilon = 1e-9; nuclear@0: nuclear@0: //// look for vertices that lie directly on the line between their predecessor and their nuclear@0: //// successor and replace them with either of them. nuclear@0: nuclear@0: //for(size_t i = 0; i < cnt; ++i) { nuclear@0: // IfcVector3& v1 = *(base+i), &v0 = *(base+(i?i-1:cnt-1)), &v2 = *(base+(i+1)%cnt); nuclear@0: // const IfcVector3& d0 = (v1-v0), &d1 = (v2-v1); nuclear@0: // const IfcFloat l0 = d0.SquareLength(), l1 = d1.SquareLength(); nuclear@0: // if (!l0 || !l1) { nuclear@0: // continue; nuclear@0: // } nuclear@0: nuclear@0: // const IfcFloat d = (d0/sqrt(l0))*(d1/sqrt(l1)); nuclear@0: nuclear@0: // if ( d >= 1.f-dotepsilon ) { nuclear@0: // v1 = v0; nuclear@0: // } nuclear@0: // else if ( d < -1.f+dotepsilon ) { nuclear@0: // v2 = v1; nuclear@0: // continue; nuclear@0: // } nuclear@0: //} nuclear@0: nuclear@0: // drop any identical, adjacent vertices. this pass will collect the dropouts nuclear@0: // of the previous pass as a side-effect. nuclear@0: FuzzyVectorCompare fz(epsilon); nuclear@0: std::vector::iterator end = base+cnt, e = std::unique( base, end, fz ); nuclear@0: if (e != end) { nuclear@0: cnt -= static_cast(std::distance(e, end)); nuclear@0: verts.erase(e,end); nuclear@0: drop = true; nuclear@0: } nuclear@0: nuclear@0: // check front and back vertices for this polygon nuclear@0: if (cnt > 1 && fz(*base,*(base+cnt-1))) { nuclear@0: verts.erase(base+ --cnt); nuclear@0: drop = true; nuclear@0: } nuclear@0: nuclear@0: // removing adjacent duplicates shouldn't erase everything :-) nuclear@0: ai_assert(cnt>0); nuclear@0: base += cnt; nuclear@0: } nuclear@0: if(drop) { nuclear@0: IFCImporter::LogDebug("removing duplicate vertices"); nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void TempMesh::Swap(TempMesh& other) nuclear@0: { nuclear@0: vertcnt.swap(other.vertcnt); nuclear@0: verts.swap(other.verts); nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: bool IsTrue(const EXPRESS::BOOLEAN& in) nuclear@0: { nuclear@0: return (std::string)in == "TRUE" || (std::string)in == "T"; nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: IfcFloat ConvertSIPrefix(const std::string& prefix) nuclear@0: { nuclear@0: if (prefix == "EXA") { nuclear@0: return 1e18f; nuclear@0: } nuclear@0: else if (prefix == "PETA") { nuclear@0: return 1e15f; nuclear@0: } nuclear@0: else if (prefix == "TERA") { nuclear@0: return 1e12f; nuclear@0: } nuclear@0: else if (prefix == "GIGA") { nuclear@0: return 1e9f; nuclear@0: } nuclear@0: else if (prefix == "MEGA") { nuclear@0: return 1e6f; nuclear@0: } nuclear@0: else if (prefix == "KILO") { nuclear@0: return 1e3f; nuclear@0: } nuclear@0: else if (prefix == "HECTO") { nuclear@0: return 1e2f; nuclear@0: } nuclear@0: else if (prefix == "DECA") { nuclear@0: return 1e-0f; nuclear@0: } nuclear@0: else if (prefix == "DECI") { nuclear@0: return 1e-1f; nuclear@0: } nuclear@0: else if (prefix == "CENTI") { nuclear@0: return 1e-2f; nuclear@0: } nuclear@0: else if (prefix == "MILLI") { nuclear@0: return 1e-3f; nuclear@0: } nuclear@0: else if (prefix == "MICRO") { nuclear@0: return 1e-6f; nuclear@0: } nuclear@0: else if (prefix == "NANO") { nuclear@0: return 1e-9f; nuclear@0: } nuclear@0: else if (prefix == "PICO") { nuclear@0: return 1e-12f; nuclear@0: } nuclear@0: else if (prefix == "FEMTO") { nuclear@0: return 1e-15f; nuclear@0: } nuclear@0: else if (prefix == "ATTO") { nuclear@0: return 1e-18f; nuclear@0: } nuclear@0: else { nuclear@0: IFCImporter::LogError("Unrecognized SI prefix: " + prefix); nuclear@0: return 1; nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertColor(aiColor4D& out, const IfcColourRgb& in) nuclear@0: { nuclear@0: out.r = static_cast( in.Red ); nuclear@0: out.g = static_cast( in.Green ); nuclear@0: out.b = static_cast( in.Blue ); nuclear@0: out.a = static_cast( 1.f ); nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertColor(aiColor4D& out, const IfcColourOrFactor& in,ConversionData& conv,const aiColor4D* base) nuclear@0: { nuclear@0: if (const EXPRESS::REAL* const r = in.ToPtr()) { nuclear@0: out.r = out.g = out.b = static_cast(*r); nuclear@0: if(base) { nuclear@0: out.r *= static_cast( base->r ); nuclear@0: out.g *= static_cast( base->g ); nuclear@0: out.b *= static_cast( base->b ); nuclear@0: out.a = static_cast( base->a ); nuclear@0: } nuclear@0: else out.a = 1.0; nuclear@0: } nuclear@0: else if (const IfcColourRgb* const rgb = in.ResolveSelectPtr(conv.db)) { nuclear@0: ConvertColor(out,*rgb); nuclear@0: } nuclear@0: else { nuclear@0: IFCImporter::LogWarn("skipping unknown IfcColourOrFactor entity"); nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertCartesianPoint(IfcVector3& out, const IfcCartesianPoint& in) nuclear@0: { nuclear@0: out = IfcVector3(); nuclear@0: for(size_t i = 0; i < in.Coordinates.size(); ++i) { nuclear@0: out[i] = in.Coordinates[i]; nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertVector(IfcVector3& out, const IfcVector& in) nuclear@0: { nuclear@0: ConvertDirection(out,in.Orientation); nuclear@0: out *= in.Magnitude; nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertDirection(IfcVector3& out, const IfcDirection& in) nuclear@0: { nuclear@0: out = IfcVector3(); nuclear@0: for(size_t i = 0; i < in.DirectionRatios.size(); ++i) { nuclear@0: out[i] = in.DirectionRatios[i]; nuclear@0: } nuclear@0: const IfcFloat len = out.Length(); nuclear@0: if (len<1e-6) { nuclear@0: IFCImporter::LogWarn("direction vector magnitude too small, normalization would result in a division by zero"); nuclear@0: return; nuclear@0: } nuclear@0: out /= len; nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void AssignMatrixAxes(IfcMatrix4& out, const IfcVector3& x, const IfcVector3& y, const IfcVector3& z) nuclear@0: { nuclear@0: out.a1 = x.x; nuclear@0: out.b1 = x.y; nuclear@0: out.c1 = x.z; nuclear@0: nuclear@0: out.a2 = y.x; nuclear@0: out.b2 = y.y; nuclear@0: out.c2 = y.z; nuclear@0: nuclear@0: out.a3 = z.x; nuclear@0: out.b3 = z.y; nuclear@0: out.c3 = z.z; nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertAxisPlacement(IfcMatrix4& out, const IfcAxis2Placement3D& in) nuclear@0: { nuclear@0: IfcVector3 loc; nuclear@0: ConvertCartesianPoint(loc,in.Location); nuclear@0: nuclear@0: IfcVector3 z(0.f,0.f,1.f),r(1.f,0.f,0.f),x; nuclear@0: nuclear@0: if (in.Axis) { nuclear@0: ConvertDirection(z,*in.Axis.Get()); nuclear@0: } nuclear@0: if (in.RefDirection) { nuclear@0: ConvertDirection(r,*in.RefDirection.Get()); nuclear@0: } nuclear@0: nuclear@0: IfcVector3 v = r.Normalize(); nuclear@0: IfcVector3 tmpx = z * (v*z); nuclear@0: nuclear@0: x = (v-tmpx).Normalize(); nuclear@0: IfcVector3 y = (z^x); nuclear@0: nuclear@0: IfcMatrix4::Translation(loc,out); nuclear@0: AssignMatrixAxes(out,x,y,z); nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertAxisPlacement(IfcMatrix4& out, const IfcAxis2Placement2D& in) nuclear@0: { nuclear@0: IfcVector3 loc; nuclear@0: ConvertCartesianPoint(loc,in.Location); nuclear@0: nuclear@0: IfcVector3 x(1.f,0.f,0.f); nuclear@0: if (in.RefDirection) { nuclear@0: ConvertDirection(x,*in.RefDirection.Get()); nuclear@0: } nuclear@0: nuclear@0: const IfcVector3 y = IfcVector3(x.y,-x.x,0.f); nuclear@0: nuclear@0: IfcMatrix4::Translation(loc,out); nuclear@0: AssignMatrixAxes(out,x,y,IfcVector3(0.f,0.f,1.f)); nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertAxisPlacement(IfcVector3& axis, IfcVector3& pos, const IfcAxis1Placement& in) nuclear@0: { nuclear@0: ConvertCartesianPoint(pos,in.Location); nuclear@0: if (in.Axis) { nuclear@0: ConvertDirection(axis,in.Axis.Get()); nuclear@0: } nuclear@0: else { nuclear@0: axis = IfcVector3(0.f,0.f,1.f); nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertAxisPlacement(IfcMatrix4& out, const IfcAxis2Placement& in, ConversionData& conv) nuclear@0: { nuclear@0: if(const IfcAxis2Placement3D* pl3 = in.ResolveSelectPtr(conv.db)) { nuclear@0: ConvertAxisPlacement(out,*pl3); nuclear@0: } nuclear@0: else if(const IfcAxis2Placement2D* pl2 = in.ResolveSelectPtr(conv.db)) { nuclear@0: ConvertAxisPlacement(out,*pl2); nuclear@0: } nuclear@0: else { nuclear@0: IFCImporter::LogWarn("skipping unknown IfcAxis2Placement entity"); nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------------------ nuclear@0: void ConvertTransformOperator(IfcMatrix4& out, const IfcCartesianTransformationOperator& op) nuclear@0: { nuclear@0: IfcVector3 loc; nuclear@0: ConvertCartesianPoint(loc,op.LocalOrigin); nuclear@0: nuclear@0: IfcVector3 x(1.f,0.f,0.f),y(0.f,1.f,0.f),z(0.f,0.f,1.f); nuclear@0: if (op.Axis1) { nuclear@0: ConvertDirection(x,*op.Axis1.Get()); nuclear@0: } nuclear@0: if (op.Axis2) { nuclear@0: ConvertDirection(y,*op.Axis2.Get()); nuclear@0: } nuclear@0: if (const IfcCartesianTransformationOperator3D* op2 = op.ToPtr()) { nuclear@0: if(op2->Axis3) { nuclear@0: ConvertDirection(z,*op2->Axis3.Get()); nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: IfcMatrix4 locm; nuclear@0: IfcMatrix4::Translation(loc,locm); nuclear@0: AssignMatrixAxes(out,x,y,z); nuclear@0: nuclear@0: nuclear@0: IfcVector3 vscale; nuclear@0: if (const IfcCartesianTransformationOperator3DnonUniform* nuni = op.ToPtr()) { nuclear@0: vscale.x = nuni->Scale?op.Scale.Get():1.f; nuclear@0: vscale.y = nuni->Scale2?nuni->Scale2.Get():1.f; nuclear@0: vscale.z = nuni->Scale3?nuni->Scale3.Get():1.f; nuclear@0: } nuclear@0: else { nuclear@0: const IfcFloat sc = op.Scale?op.Scale.Get():1.f; nuclear@0: vscale = IfcVector3(sc,sc,sc); nuclear@0: } nuclear@0: nuclear@0: IfcMatrix4 s; nuclear@0: IfcMatrix4::Scaling(vscale,s); nuclear@0: nuclear@0: out = locm * out * s; nuclear@0: } nuclear@0: nuclear@0: nuclear@0: } // ! IFC nuclear@0: } // ! Assimp nuclear@0: nuclear@0: #endif