我正在使用CGAL 4.13 (Linux 29)从分段的无象图像生成三维网格。我想使用劳埃德优化,但我得到了一个可复制的运行时错误。
为了说明我的问题,我修改了示例mesh_3D_image.cpp,添加了劳埃德优化步骤,如下所示。程序编译时没有错误/警告信息。
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/Image_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Labeled_mesh_domain_3<K> Mesh_domain;
typedef CGAL::Sequential_tag Concurrency_tag;
typedef CGAL::Mesh_triangulation_3<Mesh_domain,CGAL::Default,Concurrency_tag>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
using namespace CGAL::parameters;
int main(int argc, char* argv[])
{
const char* fname = (argc>1)?argv[1]:"data/liver.inr.gz";
CGAL::Image_3 image;
if(!image.read(fname)){
std::cerr << "Error: Cannot read file " << fname << std::endl;
return EXIT_FAILURE;
}
Mesh_domain domain = Mesh_domain::create_labeled_image_mesh_domain(image);
Mesh_criteria criteria(facet_angle=30, facet_size=6, facet_distance=4,
cell_radius_edge_ratio=3, cell_size=8);
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
// !!! THE FOLLOWING LINE MAKES THE PROGRAM CRASH !!!
CGAL::lloyd_optimize_mesh_3(c3t3, domain, time_limit=30);
std::ofstream medit_file("out.mesh");
c3t3.output_to_medit(medit_file);
return 0;
}我使用以下CMakeLists.txt文件编译它:
# Created by the script cgal_create_CMakeLists
project( executables )
cmake_minimum_required(VERSION 2.8.11)
find_package( CGAL QUIET COMPONENTS )
# !!! I had to add manually the following line !!!
find_package(CGAL COMPONENTS ImageIO)
include( ${CGAL_USE_FILE} )
find_package( Boost REQUIRED )
add_executable( executables lloyd.cpp )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS executables )
target_link_libraries(executables ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )不生成网格。我收到以下信息:
$ ./build/mesh_3D_image在抛出'CGAL::Precondition_exception‘内容():CGAL错误:前提条件违反后终止调用!Expr: std::>= 3文件:/usr/include/CGAL_3/std_move.hline: 419中止(核心抛出)
在哪里我的代码是错误的,我如何能够触发对三维图像生成的网格的优化?
发布于 2019-06-06 15:55:31
实际上,当CGAL::make_mesh_3()像这样被调用时:
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);它内部启动CGAL::perturb_mesh_3()和CGAL::exude_mesh_3()。最近的变化是规则三角剖分中顶点的权重,应该总是被称为最后一个(参见3()中的警告)。
命令的唯一限制是exuder应该被最后调用。所以你要么打电话
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, lloyd(time_limit=30));或
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, no_exude());
CGAL::lloyd_optimize_mesh_3(c3t3, domain, time_limit = 30);
CGAL::exude_mesh_3(c3t3);发布于 2019-05-21 11:04:35
你把那部分去掉了:
if(!image.read(fname)){
std::cerr << "Error: Cannot read file " << fname << std::endl;
return EXIT_FAILURE;
}从示例中,这就是从文件中实际读取图像的内容。
https://stackoverflow.com/questions/56228753
复制相似问题