示例#1
0
void SketchSample::compute_mesh_position() {
    typedef CGAL::Cartesian<double> Kernel;
    Kernel::Iso_cuboid_3  box = CGAL::bounding_box(p_mesh->points_begin(),
                                p_mesh->points_end());
    Kernel::Point_3 center = CGAL::midpoint(box.min(), box.max());
    Kernel::Vector_3 diameter = box.min() - box.max();
    mesh_center_x = center.x();
    mesh_center_y = center.y();
    mesh_center_z = center.z();
    mesh_radius = CGAL::sqrt( diameter * diameter )/2;
}
示例#2
0
std::pair<PointCGAL,PointCGAL> getMeshBoundingBox(MeshData &meshData)
{
	std::list<Triangle> meshTriangles = meshData.first;
	std::list<PointCGAL> pointsInMesh;
	std::list<Triangle>::iterator triangleIter;
	for(triangleIter = meshTriangles.begin(); triangleIter != meshTriangles.end(); ++triangleIter)
	{
		Triangle t = *triangleIter;
		pointsInMesh.push_back(t.vertex(0));
		pointsInMesh.push_back(t.vertex(1));
		pointsInMesh.push_back(t.vertex(2));
	}

	Kernel::Iso_cuboid_3 isoCuboid = CGAL::bounding_box(pointsInMesh.begin(), pointsInMesh.end());

	return std::pair<PointCGAL,PointCGAL>(isoCuboid.min(), isoCuboid.max());
}