CGAL error: assertion violation! When using "CGAL::Polygon_mesh_processing::extrude_mesh()"
Issue Details
loaded my own mesh file (.obj) which is creadted by using example from "Digital Surface Model (DSM)", many more then the example provided. Then I want to use the"Extrude_mesh()" to get an extrusion model, and the direction of extrusion is only negative to the z-axis. The code compiles fine, but when I run it after a few minutes I get an error like this:
CGAL error: assertion violation! Expression : !CGAL::is_closed(input) File : D:\Programs\dev\CGAL-5.5.1\include\CGAL\Polygon_mesh_processing\extrude.h Line : 177 Explanation: Refer to the bug-reporting instructions at https://www.cgal.org/bug_report.html
Source Code
My source code is divided into two parts: the DSM part and the extrude part. the DSM part: headfile:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/read_las_points.h>
#include <CGAL/property_map.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Point_set_3/IO.h>
#include <CGAL/Point_set_3/IO/LAS.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Projection_traits_xy_3.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>
#include <CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h>
#include <CGAL/boost/graph/copy_face_graph.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/locate.h>
#include <CGAL/Polygon_mesh_processing/triangulate_hole.h>
#include <CGAL/Polygon_mesh_processing/border.h>
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <boost/graph/adjacency_list.hpp>
#include <CGAL/boost/graph/split_graph_into_polylines.h>
#include <CGAL/IO/WKT.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Constrained_triangulation_plus_2.h>
#include <CGAL/Polyline_simplification_2/simplify.h>
#include <CGAL/Polyline_simplification_2/Squared_distance_cost.h>
#include <CGAL/Classification.h>
#include <CGAL/Random.h>
#include <fstream>
#include <queue>
#include <cstdlib>
code:
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using Projection_traits = CGAL::Projection_traits_xy_3<Kernel>;
using Point_2 = Kernel::Point_2;
using Point_3 = Kernel::Point_3;
using Segment_3 = Kernel::Segment_3;
// Triangulated Irregular Network
using TIN = CGAL::Delaunay_triangulation_2<Projection_traits>;
int main(int argc, char** argv)
{
clock_t startTime, endTime;
startTime = clock();
// Read points
char v2[] = "E:/zlx/result/0_1.xyz";
std::ifstream ifile(v2, std::ios_base::binary);
CGAL::Point_set_3<Point_3> points;
ifile >> points;
std::cerr << points.size() << " point(s) read" << std::endl;
// Create DSM
TIN dsm(points.points().begin(), points.points().end());
using Mesh = CGAL::Surface_mesh<Point_3>;
Mesh dsm_mesh;
CGAL::copy_face_graph(dsm, dsm_mesh);
std::ofstream dsm_ofile("E:/zlx/result/0_1.obj", std::ios_base::binary);
CGAL::IO::set_binary_mode(dsm_ofile);
CGAL::IO::write_OBJ(dsm_ofile, dsm_mesh);
dsm_ofile.close();
endTime = clock();
std::cout << "时间是(ms):" << endTime - startTime;
return EXIT_FAILURE;
}
the extrude part headfile:
#include<ctime>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/extrude.h>
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing.h>
#include <CGAL/IO/OBJ.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include<CGAL/Polygon_mesh_processing/border.h>
typedef:
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> SM;
typedef Kernel::Vector_3 Vector;
code:
auto start = std::clock();
double extrudeVector[3] = { 0, 0, -500 };
SM mesh;
SM outMesh;
CGAL::IO::read_polygon_mesh(v2, mesh);
CGAL::Polygon_mesh_processing::extrude_mesh(mesh, outMesh, *new Vector(extrudeVector[0], extrudeVector[1], extrudeVector[2]));
mesh.clear();
CGAL::IO::write_polygon_mesh(v82, outMesh, CGAL::parameters::stream_precision(17));
endTime = clock();
std::cout << "时间是(ms):" << endTime - startTime;
return EXIT_FAILURE;
Environment
- Operating system (Windows/Mac/Linux, 32/64 bits): Windows 64 bits
- Compiler: Visual Studio 2019
- Release or debug mode: debug
- Specific flags used (if any):
- CGAL version: 5.5.1
- Boost version: 1.71.0
- Other libraries versions if used (Eigen, TBB, etc.): Eigen 3