- Ifc: more sanity clamping, improve error messages for degenerate windows.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1310 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/6/merge
aramis_acg 2012-10-17 00:37:52 +00:00
parent f8974b7209
commit 8a77193a33
1 changed files with 7 additions and 4 deletions

View File

@ -64,6 +64,7 @@ namespace Assimp {
//#define to_int64(p) (static_cast<ulong64>( std::max( 0., std::min( static_cast<IfcFloat>((p)), 1.) ) * max_ulong64 )) //#define to_int64(p) (static_cast<ulong64>( std::max( 0., std::min( static_cast<IfcFloat>((p)), 1.) ) * max_ulong64 ))
#define to_int64(p) (static_cast<ulong64>(static_cast<IfcFloat>((p) ) * max_ulong64 )) #define to_int64(p) (static_cast<ulong64>(static_cast<IfcFloat>((p) ) * max_ulong64 ))
#define from_int64(p) (static_cast<IfcFloat>((p)) / max_ulong64) #define from_int64(p) (static_cast<IfcFloat>((p)) / max_ulong64)
#define one_vec (IfcVector2(static_cast<IfcFloat>(1.0),static_cast<IfcFloat>(1.0)))
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool ProcessPolyloop(const IfcPolyLoop& loop, TempMesh& meshout, ConversionData& /*conv*/) bool ProcessPolyloop(const IfcPolyLoop& loop, TempMesh& meshout, ConversionData& /*conv*/)
@ -1326,6 +1327,7 @@ void CleanupWindowContours(std::vector< std::vector<IfcVector2> >& contours)
// empty polygon? drop the contour altogether // empty polygon? drop the contour altogether
if(clipped.empty()) { if(clipped.empty()) {
IFCImporter::LogError("error during polygon clipping, window contour is degenerate");
contour.clear(); contour.clear();
continue; continue;
} }
@ -1336,7 +1338,10 @@ void CleanupWindowContours(std::vector< std::vector<IfcVector2> >& contours)
scratch.clear(); scratch.clear();
BOOST_FOREACH(const ClipperLib::IntPoint& point, clipped[0].outer) { BOOST_FOREACH(const ClipperLib::IntPoint& point, clipped[0].outer) {
scratch.push_back( IfcVector2(from_int64(point.X), from_int64(point.Y))); IfcVector2 vv = IfcVector2(from_int64(point.X), from_int64(point.Y));
vv = std::max(vv,IfcVector2());
vv = std::min(vv,one_vec);
scratch.push_back( vv );
} }
contour.swap(scratch); contour.swap(scratch);
} }
@ -1437,8 +1442,6 @@ bool TryAddOpenings_Quadrulate(const std::vector<TempOpening>& openings,
{ {
std::vector<IfcVector3>& out = curmesh.verts; std::vector<IfcVector3>& out = curmesh.verts;
const IfcVector2 one_vec = IfcVector2(static_cast<IfcFloat>(1.0),static_cast<IfcFloat>(1.0));
// Try to derive a solid base plane within the current surface for use as // Try to derive a solid base plane within the current surface for use as
// working coordinate system. // working coordinate system.
const IfcMatrix3& m = DerivePlaneCoordinateSpace(curmesh); const IfcMatrix3& m = DerivePlaneCoordinateSpace(curmesh);
@ -2059,7 +2062,7 @@ bool ProcessRepresentationItem(const IfcRepresentationItem& item,
#undef to_int64 #undef to_int64
#undef from_int64 #undef from_int64
#undef from_int64_f #undef one_vec
} // ! IFC } // ! IFC
} // ! Assimp } // ! Assimp