TopoDS_Shape Plane::createShape() { // Get Plane normal and distance. V3D normal = this->getNormal(); double norm2 = normal.norm2(); if (norm2 == 0.0) { throw std::runtime_error("Cannot create a plane with zero normal"); } double distance = this->getDistance(); // Find point closest to origin double t = distance / norm2; // Create Half Space TopoDS_Face P = BRepBuilderAPI_MakeFace( gp_Pln(normal[0], normal[1], normal[2], -distance)) .Face(); TopoDS_Shape Result = BRepPrimAPI_MakeHalfSpace( P, gp_Pnt(normal[0] * (1 + t), normal[1] * (1 + t), normal[2] * (1 + t))) .Solid(); return Result.Complemented(); }