// // Look at the sloped edges to see if they meet at a particular point; // if so, set that as the Level's story height. Return true on success. // bool vtLevel::DetermineHeightFromSlopes() { // In order to find a roof point, we need 3 adjacent edges whose // edges intersect. int i, edges = NumEdges(); bool bFoundASolution = false; FPlane *planes = new FPlane[edges]; float fMinHeight = 1E10; for (i = 0; i < edges; i++) { GetEdgePlane(i, planes[i]); } for (i = 0; i < edges; i++) { int i0 = i; int i1 = (i+1)%edges; int i2 = (i+2)%edges; vtEdge *edge0 = m_Edges[i0]; vtEdge *edge1 = m_Edges[i1]; vtEdge *edge2 = m_Edges[i2]; if (edge0->m_iSlope == 90 && edge1->m_iSlope == 90 && edge2->m_iSlope == 90) { // skip this one; 3 vertical edges aren't useful continue; } FPoint3 point; bool valid = PlaneIntersection(planes[i0], planes[i1], planes[i2], point); if (valid) { // take this point as the height of the roof float fHeight = (point.y - m_LocalFootprint[0][0].y); if (fHeight < 0) // shouldn't happen, but just a safety check continue; if (fHeight < fMinHeight) fMinHeight = fHeight; bFoundASolution = true; } } if (bFoundASolution) m_fStoryHeight = fMinHeight; delete [] planes; return bFoundASolution; }
template<class T> bool Polygon3T<T>::Encloses(const Polygon3T<T>& OtherPoly, bool MayTouchEdges, const T EdgeThickness) const { // See if this polygon and OtherPoly are in the same or mirrored plane. SideT Side=OtherPoly.WhatSide(Plane, EdgeThickness); if (Side!=InIdentical && Side!=InMirrored) return false; for (unsigned long VertexNr=0; VertexNr<Vertices.Size(); VertexNr++) switch (OtherPoly.WhatSide(GetEdgePlane(VertexNr, EdgeThickness), EdgeThickness)) { case Front: break; case FrontAndOn: if (!MayTouchEdges) return false; break; default: return false; } return true; }