1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
void Geometry::generatePointsInBoundingBox() {
if (myrank == 0) {
Point minPoint = { std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity() };
Point maxPoint = { -std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity() };
for (int t = 0; t < triangles.size(); ++t) {
const auto& triangle = triangles[t];
minPoint.x = std::min(minPoint.x, std::min(triangle.x1, std::min(triangle.x2, triangle.x3)));
minPoint.y = std::min(minPoint.y, std::min(triangle.y1, std::min(triangle.y2, triangle.y3)));
minPoint.z = std::min(minPoint.z, std::min(triangle.z1, std::min(triangle.z2, triangle.z3)));
maxPoint.x = std::max(maxPoint.x, std::max(triangle.x1, std::max(triangle.x2, triangle.x3)));
maxPoint.y = std::max(maxPoint.y, std::max(triangle.y1, std::max(triangle.y2, triangle.y3)));
maxPoint.z = std::max(maxPoint.z, std::max(triangle.z1, std::max(triangle.z2, triangle.z3)));
}
boundingbox = { minPoint.x, minPoint.y, minPoint.z, maxPoint.x, maxPoint.y, maxPoint.z };
}
MPI_Datatype mpiBoundingBoxType = mpi_caller.createBoundingBoxMPIType();
MPI_Bcast(&boundingbox, 1, mpiBoundingBoxType, 0, MPI_COMM_WORLD);
std::cout << "Processor " << myrank << ": BoundingBox: "
<< "Min(" << boundingbox.min_x << ", " << boundingbox.min_y << ", " << boundingbox.min_z << ") "
<< "Max(" << boundingbox.max_x << ", " << boundingbox.max_y << ", " << boundingbox.max_z << ")"
<< std::endl;
MPI_Type_free(&mpiBoundingBoxType);
}
| |