public static bool CheckIfTwoSolidsShareAnySpace(Solid s1, Solid s2) { BoundingBox3d bb1 = s1.GetBoundingBox(); BoundingBox3d bb2 = s2.GetBoundingBox(); if (!BoundingBox3d.intersect(bb1, bb2)) { return(false); } BoundingBox3d bb3 = BoundingBox3d.CalcIntersection(bb1, bb2); if (fp.eq_tol(bb3.volume, 0, 0.0001)) { return(false); } bsp3d bsp1 = new bsp3d(s1); bsp3d bsp2 = new bsp3d(s2); xyz c1 = s1.GetCenter(); if ( (bsp1.PointInPolyhedron(c1) == PointInPoly.Inside) && (bsp2.PointInPolyhedron(c1) == PointInPoly.Inside) ) { return(true); } xyz c2 = s2.GetCenter(); if ( (bsp2.PointInPolyhedron(c2) == PointInPoly.Inside) && (bsp1.PointInPolyhedron(c2) == PointInPoly.Inside) ) { return(true); } foreach (Face f1 in s1.Faces) { xyz p = f1.GetCenter() - f1.UnitNormal() * 0.01; if ( (bsp2.PointInPolyhedron(p) == PointInPoly.Inside) && (bsp1.PointInPolyhedron(p) == PointInPoly.Inside) ) { return(true); } } foreach (Face f2 in s2.Faces) { xyz p = f2.GetCenter() - f2.UnitNormal() * 0.01; if ( (bsp1.PointInPolyhedron(p) == PointInPoly.Inside) && (bsp2.PointInPolyhedron(p) == PointInPoly.Inside) ) { return(true); } } if (s1.AnyEdgePiercesAnyFace(s2)) { return(true); } if (s2.AnyEdgePiercesAnyFace(s1)) { return(true); } // TODO we apparently need another testhere return(false); }