//---------------------------------------------------------------------------- void Boolean2D::DrawPolySolid (BspPolygon2& polygon, ColorRGB color) { Vector2d v0, v1; Edge2 edge; int i, x0, y0, x1, y1; // Draw the edges. for (i = 0; i < polygon.GetNumEdges(); ++i) { polygon.GetEdge(i, edge); polygon.GetVertex(edge.I0, v0); polygon.GetVertex(edge.I1, v1); x0 = (int)(v0.X() + 0.5f); y0 = GetWidth() - 1 - (int)(v0.Y() + 0.5f); x1 = (int)(v1.X() + 0.5f); y1 = GetWidth() - 1 - (int)(v1.Y() + 0.5f); DrawLine(x0, y0, x1, y1, color); } // Draw the vertices. ColorRGB black(0, 0, 0); for (i = 0; i < polygon.GetNumVertices(); ++i) { polygon.GetVertex(i, v0); x0 = (int)(v0.X() + 0.5f); y0 = GetWidth() - 1 - (int)(v0.Y() + 0.5f); SetThickPixel(x0, y0, 1, black); } }
//---------------------------------------------------------------------------- void BspPolygon2::GetInsideEdgesFrom (const BspPolygon2& polygon, BspPolygon2& inside) const { assertion(mTree != 0, "Tree must exist.\n"); BspPolygon2 ignore; const int numEdges = polygon.GetNumEdges(); for (int i = 0; i < numEdges; ++i) { int v0 = polygon.mEArray[i].I0; int v1 = polygon.mEArray[i].I1; Vector2d vertex0 = polygon.mVArray[v0]; Vector2d vertex1 = polygon.mVArray[v1]; mTree->GetPartition(*this, vertex0, vertex1, ignore, inside, inside, ignore); } }