浏览代码

- Ifc: skip lines during boolean differentiation between two solids.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1316 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
aramis_acg 13 年之前
父节点
当前提交
f6f2c087db
共有 1 个文件被更改,包括 17 次插入2 次删除
  1. 17 2
      code/IFCGeometry.cpp

+ 17 - 2
code/IFCGeometry.cpp

@@ -282,10 +282,12 @@ void ProcessConnectedFaceSet(const IfcConnectedFaceSet& fset, TempMesh& result,
 		TempMesh meshout;
 		BOOST_FOREACH(const IfcFaceBound& bound, face.Bounds) {
 			
-			// XXX implement proper merging for polygonal loops
 			if(const IfcPolyLoop* const polyloop = bound.Bound->ToPtr<IfcPolyLoop>()) {
 				if(ProcessPolyloop(*polyloop, meshout,conv)) {
 
+					// The outer boundary is better determined by checking which
+					// polygon covers the largest area.
+
 					//if(bound.ToPtr<IfcFaceOuterBound>()) {
 					//	ob = cnt;
 					//}
@@ -298,6 +300,9 @@ void ProcessConnectedFaceSet(const IfcConnectedFaceSet& fset, TempMesh& result,
 				continue;
 			}
 
+			// And this, even though it is sometimes TRUE and sometimes FALSE,
+			// does not really improve results.
+
 			/*if(!IsTrue(bound.Orientation)) {
 				size_t c = 0;
 				BOOST_FOREACH(unsigned int& c, meshout.vertcnt) {
@@ -305,7 +310,6 @@ void ProcessConnectedFaceSet(const IfcConnectedFaceSet& fset, TempMesh& result,
 					cnt += c;
 				}
 			}*/
-
 		}
 		ProcessPolygonBoundaries(result, meshout);
 	}
@@ -1903,6 +1907,17 @@ void ProcessBooleanExtrudedAreaSolidDifference(const IfcExtrudedAreaSolid* as, T
 		temp.verts.insert(temp.verts.end(), vit, vit + pcount);
 		temp.vertcnt.push_back(pcount);
 
+		// The algorithms used to generate mesh geometry sometimes
+		// spit out lines or other degenerates which must be
+		// filtered to avoid running into assertions later on.
+
+		// ComputePolygonNormal returns the Newell normal, so the
+		// length of the normal is the area of the polygon.
+		const IfcVector3& normal = ComputePolygonNormal(temp, false);
+		if (normal.SquareLength() < static_cast<IfcFloat>(1e-5)) {
+			continue;
+		}
+
 		TryAddOpenings_Quadrulate(openings, std::vector<IfcVector3>(1,IfcVector3(1,0,0)), temp);
 		result.Append(temp);