-
-
Save sloriot/b29acaa073765dde8d79e735893e74a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OFF | |
54 104 0 | |
2.91913 0.691848 50 | |
3 -7.34788e-16 50 | |
3 -7.34788e-16 0 | |
2.91913 0.691848 0 | |
2.6809 1.3464 50 | |
2.6809 1.3464 0 | |
2.29813 1.92836 50 | |
2.29813 1.92836 0 | |
1.79148 2.40637 50 | |
1.79148 2.40637 0 | |
1.18824 2.75465 50 | |
1.18824 2.75465 0 | |
0.520945 2.95442 0 | |
0.520945 2.95442 50 | |
-0.174434 2.99492 0 | |
-0.174434 2.99492 50 | |
-0.86041 2.87397 50 | |
-0.86041 2.87397 0 | |
-1.5 2.59808 50 | |
-1.5 2.59808 0 | |
-2.05872 2.18212 50 | |
-2.05872 2.18212 0 | |
-2.50646 1.64853 0 | |
-2.50646 1.64853 50 | |
-2.81908 1.02606 50 | |
-2.81908 1.02606 0 | |
-2.97972 0.348279 50 | |
-2.97972 0.348279 0 | |
-2.97972 -0.348279 50 | |
-2.97972 -0.348279 0 | |
-2.81908 -1.02606 50 | |
-2.81908 -1.02606 0 | |
-2.50646 -1.64853 50 | |
-2.50646 -1.64853 0 | |
-2.05872 -2.18212 50 | |
-2.05872 -2.18212 0 | |
-1.5 -2.59808 0 | |
-1.5 -2.59808 50 | |
-0.86041 -2.87397 50 | |
-0.86041 -2.87397 0 | |
-0.174434 -2.99492 50 | |
-0.174434 -2.99492 0 | |
0.520945 -2.95442 0 | |
0.520945 -2.95442 50 | |
1.18824 -2.75465 50 | |
1.18824 -2.75465 0 | |
1.79148 -2.40637 50 | |
1.79148 -2.40637 0 | |
2.29813 -1.92836 50 | |
2.29813 -1.92836 0 | |
2.6809 -1.3464 50 | |
2.6809 -1.3464 0 | |
2.91913 -0.691848 50 | |
2.91913 -0.691848 0 | |
3 0 1 2 | |
3 0 2 3 | |
3 4 3 5 | |
3 4 0 3 | |
3 6 5 7 | |
3 6 4 5 | |
3 8 7 9 | |
3 8 6 7 | |
3 10 9 11 | |
3 10 11 12 | |
3 10 8 9 | |
3 13 12 14 | |
3 13 10 12 | |
3 15 13 14 | |
3 16 14 17 | |
3 16 15 14 | |
3 18 17 19 | |
3 18 16 17 | |
3 20 19 21 | |
3 20 21 22 | |
3 20 18 19 | |
3 23 20 22 | |
3 24 23 22 | |
3 24 22 25 | |
3 26 24 25 | |
3 26 25 27 | |
3 28 26 27 | |
3 28 27 29 | |
3 30 28 29 | |
3 30 29 31 | |
3 32 30 31 | |
3 32 31 33 | |
3 34 32 33 | |
3 34 33 35 | |
3 34 35 36 | |
3 37 34 36 | |
3 38 37 36 | |
3 38 36 39 | |
3 40 38 39 | |
3 40 39 41 | |
3 40 41 42 | |
3 43 40 42 | |
3 44 43 42 | |
3 44 42 45 | |
3 46 44 45 | |
3 46 45 47 | |
3 48 47 49 | |
3 48 46 47 | |
3 50 49 51 | |
3 50 48 49 | |
3 52 51 53 | |
3 52 53 2 | |
3 52 50 51 | |
3 1 52 2 | |
3 24 26 28 | |
3 23 28 30 | |
3 23 30 32 | |
3 23 32 34 | |
3 23 24 28 | |
3 46 40 43 | |
3 46 43 44 | |
3 52 48 50 | |
3 15 16 18 | |
3 15 18 20 | |
3 15 20 23 | |
3 15 23 34 | |
3 1 46 48 | |
3 1 48 52 | |
3 0 34 37 | |
3 0 37 38 | |
3 0 38 40 | |
3 0 40 46 | |
3 0 46 1 | |
3 6 0 4 | |
3 6 8 10 | |
3 6 10 13 | |
3 6 13 15 | |
3 6 15 34 | |
3 6 34 0 | |
3 27 25 29 | |
3 29 22 31 | |
3 31 22 33 | |
3 33 22 35 | |
3 25 22 29 | |
3 41 47 42 | |
3 42 47 45 | |
3 49 53 51 | |
3 17 14 19 | |
3 19 14 21 | |
3 21 14 22 | |
3 22 14 35 | |
3 47 2 49 | |
3 49 2 53 | |
3 35 3 36 | |
3 36 3 39 | |
3 39 3 41 | |
3 41 3 47 | |
3 47 3 2 | |
3 3 7 5 | |
3 9 7 11 | |
3 11 7 12 | |
3 12 7 14 | |
3 14 7 35 | |
3 35 7 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | |
#include <CGAL/Exact_predicates_exact_constructions_kernel.h> | |
#include <CGAL/Aff_transformation_3.h> | |
#include <CGAL/Surface_mesh.h> | |
#include <CGAL/Polygon_mesh_processing/corefinement.h> | |
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h> | |
#include <CGAL/Polygon_mesh_processing/transform.h> | |
#include <fstream> | |
#include <iostream> | |
#include <boost/timer/progress_display.hpp> | |
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; | |
using EK = CGAL::Exact_predicates_exact_constructions_kernel; | |
using Vector_3 = typename Kernel::Vector_3; | |
using K = CGAL::Exact_predicates_inexact_constructions_kernel; | |
using Mesh = CGAL::Surface_mesh<K::Point_3>; | |
using Affine_transformation_3 = CGAL::Aff_transformation_3<Kernel>; | |
using Exact_point_map = Mesh::Property_map<Mesh::Vertex_index, EK::Point_3>; | |
namespace PMP = CGAL::Polygon_mesh_processing; | |
namespace params = CGAL::parameters; | |
struct Exact_vertex_point_map | |
{ | |
// typedef for the property map | |
typedef boost::property_traits<Exact_point_map>::value_type value_type; | |
typedef boost::property_traits<Exact_point_map>::reference reference; | |
typedef boost::property_traits<Exact_point_map>::key_type key_type; | |
typedef boost::read_write_property_map_tag category; | |
// exterior references | |
Exact_point_map exact_point_map; | |
Mesh* tm_ptr; | |
// Converters | |
CGAL::Cartesian_converter<K, EK> to_exact; | |
CGAL::Cartesian_converter<EK, K> to_input; | |
Exact_vertex_point_map() | |
: tm_ptr(nullptr) | |
{} | |
Exact_vertex_point_map(const Exact_point_map& ep, Mesh& tm, bool already_init=false) | |
: exact_point_map(ep) | |
, tm_ptr(&tm) | |
{ | |
if (!already_init) | |
for (Mesh::Vertex_index v : vertices(tm)) | |
exact_point_map[v] = to_exact(tm.point(v)); | |
} | |
friend | |
reference get(const Exact_vertex_point_map& map, key_type k) | |
{ | |
CGAL_precondition(map.tm_ptr != nullptr); | |
return map.exact_point_map[k]; | |
} | |
friend | |
void put(const Exact_vertex_point_map& map, key_type k, const EK::Point_3& p) | |
{ | |
CGAL_precondition(map.tm_ptr != nullptr); | |
map.exact_point_map[k] = p; | |
// create the input point from the exact one | |
map.tm_ptr->point(k) = map.to_input(p); | |
} | |
}; | |
int main(int argc, char* argv[]) | |
{ | |
const std::string Tool = (argc > 1) ? argv[1] : "Cylinder6.off"; | |
const std::string Workpiece = (argc > 2) ? argv[2] : "VB56.off"; | |
Mesh mesh_Tool, meshWorkpiece; | |
if (!PMP::IO::read_polygon_mesh(Tool, mesh_Tool) || !PMP::IO::read_polygon_mesh(Workpiece, meshWorkpiece)) | |
{ | |
std::cerr << "Invalid input." << std::endl; | |
return 1; | |
} | |
Exact_point_map meshWorkpiece_exact_points = | |
meshWorkpiece.add_property_map<Mesh::Vertex_index, EK::Point_3>("v:exact_point").first; | |
Exact_vertex_point_map meshWorkpiece_vpm(meshWorkpiece_exact_points, meshWorkpiece); | |
const int nb_steps = 31; | |
boost::timer::progress_display show_progress(nb_steps, std::cout); | |
for (int step = 0; step < nb_steps; ++step) { | |
Mesh tool = mesh_Tool; | |
PMP::transform(Affine_transformation_3(CGAL::Translation(), Vector_3(0, 0, -step)), tool); | |
Exact_point_map tool_exact_points = | |
tool.add_property_map<Mesh::Vertex_index, EK::Point_3>("v:exact_point").first; | |
Exact_vertex_point_map tool_vpm(tool_exact_points, tool); | |
bool OK = PMP::corefine_and_compute_difference( | |
meshWorkpiece, tool, meshWorkpiece, | |
params::vertex_point_map(meshWorkpiece_vpm), | |
params::vertex_point_map(tool_vpm), | |
params::vertex_point_map(meshWorkpiece_vpm)); | |
if (!OK) | |
{ | |
std::cout << "Non-manifold output, cannot compute difference\n"; | |
return 1; | |
} | |
++show_progress; | |
} | |
// output file | |
std::cout << "Difference was successfully computed\n"; | |
std::ofstream output("NewWorkpiece.off"); | |
output.precision(17); | |
output << meshWorkpiece; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OFF | |
64 128 0 | |
-5 -5 -30 | |
-5 -5 0 | |
-5 5 -30 | |
-5 5 0 | |
5 -5 -30 | |
5 -5 0 | |
-1.56366 -1.24698 0 | |
-1.24698 -1.56366 0 | |
-1.80194 -0.867767 0 | |
-0.867767 -1.80194 0 | |
-0.445042 -1.94986 0 | |
-1.94986 -0.445042 0 | |
-2 2.44929e-16 0 | |
-3.67394e-16 -2 0 | |
-1.80194 0.867767 0 | |
-1.56366 1.24698 0 | |
-1.94986 0.445042 0 | |
0.445042 -1.94986 0 | |
0.867767 -1.80194 0 | |
1.24698 -1.56366 0 | |
1.56366 -1.24698 0 | |
-1.24698 1.56366 0 | |
-0.867767 1.80194 0 | |
1.80194 -0.867767 0 | |
1.94986 -0.445042 0 | |
-0.445042 1.94986 0 | |
2 -4.89859e-16 0 | |
1.22465e-16 2 0 | |
5 5 0 | |
1.94986 0.445042 0 | |
1.80194 0.867767 0 | |
1.56366 1.24698 0 | |
1.24698 1.56366 0 | |
0.867767 1.80194 0 | |
0.445042 1.94986 0 | |
5 5 -30 | |
-1.56366 -1.24698 -30 | |
-1.24698 -1.56366 -30 | |
-1.80194 -0.867767 -30 | |
-0.867767 -1.80194 -30 | |
-0.445042 -1.94986 -30 | |
-1.94986 -0.445042 -30 | |
-2 2.44929e-16 -30 | |
-3.67394e-16 -2 -30 | |
-1.80194 0.867767 -30 | |
-1.56366 1.24698 -30 | |
-1.94986 0.445042 -30 | |
0.445042 -1.94986 -30 | |
0.867767 -1.80194 -30 | |
1.24698 -1.56366 -30 | |
1.56366 -1.24698 -30 | |
-1.24698 1.56366 -30 | |
-0.867767 1.80194 -30 | |
1.80194 -0.867767 -30 | |
1.94986 -0.445042 -30 | |
-0.445042 1.94986 -30 | |
2 -4.89859e-16 -30 | |
1.22465e-16 2 -30 | |
1.94986 0.445042 -30 | |
1.80194 0.867767 -30 | |
1.56366 1.24698 -30 | |
1.24698 1.56366 -30 | |
0.867767 1.80194 -30 | |
0.445042 1.94986 -30 | |
3 0 1 2 | |
3 2 1 3 | |
3 4 5 0 | |
3 0 5 1 | |
3 6 1 7 | |
3 8 1 6 | |
3 9 7 1 | |
3 10 9 1 | |
3 11 1 8 | |
3 12 1 11 | |
3 13 10 1 | |
3 3 14 15 | |
3 3 16 14 | |
3 3 12 16 | |
3 3 1 12 | |
3 5 17 13 | |
3 5 18 17 | |
3 5 19 18 | |
3 5 13 1 | |
3 20 19 5 | |
3 21 3 15 | |
3 22 3 21 | |
3 23 20 5 | |
3 24 23 5 | |
3 25 3 22 | |
3 26 24 5 | |
3 27 3 25 | |
3 28 29 26 | |
3 28 30 29 | |
3 28 31 30 | |
3 28 32 31 | |
3 28 33 32 | |
3 28 34 33 | |
3 28 27 34 | |
3 28 26 5 | |
3 28 3 27 | |
3 28 35 2 | |
3 28 2 3 | |
3 0 36 37 | |
3 0 38 36 | |
3 37 39 0 | |
3 39 40 0 | |
3 0 41 38 | |
3 0 42 41 | |
3 40 43 0 | |
3 44 2 45 | |
3 46 2 44 | |
3 42 2 46 | |
3 0 2 42 | |
3 47 4 43 | |
3 48 4 47 | |
3 49 4 48 | |
3 43 4 0 | |
3 49 50 4 | |
3 2 51 45 | |
3 2 52 51 | |
3 50 53 4 | |
3 53 54 4 | |
3 2 55 52 | |
3 54 56 4 | |
3 2 57 55 | |
3 58 35 56 | |
3 59 35 58 | |
3 60 35 59 | |
3 61 35 60 | |
3 62 35 61 | |
3 63 35 62 | |
3 57 35 63 | |
3 56 35 4 | |
3 2 35 57 | |
3 5 4 35 | |
3 5 35 28 | |
3 26 29 56 | |
3 56 29 58 | |
3 58 30 59 | |
3 59 30 60 | |
3 29 30 58 | |
3 30 31 60 | |
3 60 32 61 | |
3 61 32 62 | |
3 31 32 60 | |
3 32 33 62 | |
3 62 34 63 | |
3 33 34 62 | |
3 63 27 57 | |
3 34 27 63 | |
3 57 25 55 | |
3 55 25 52 | |
3 27 25 57 | |
3 52 22 51 | |
3 25 22 52 | |
3 22 21 51 | |
3 21 15 51 | |
3 51 15 45 | |
3 45 15 44 | |
3 15 14 44 | |
3 44 14 46 | |
3 14 16 46 | |
3 16 12 46 | |
3 46 12 42 | |
3 12 11 42 | |
3 42 11 41 | |
3 11 8 41 | |
3 41 8 38 | |
3 38 8 36 | |
3 8 6 36 | |
3 6 7 36 | |
3 36 7 37 | |
3 7 9 37 | |
3 37 9 39 | |
3 9 10 39 | |
3 39 10 40 | |
3 10 13 40 | |
3 40 13 43 | |
3 43 17 47 | |
3 13 17 43 | |
3 17 18 47 | |
3 47 18 48 | |
3 48 18 49 | |
3 18 19 49 | |
3 49 20 50 | |
3 50 20 53 | |
3 19 20 49 | |
3 53 23 54 | |
3 20 23 53 | |
3 23 24 54 | |
3 54 26 56 | |
3 24 26 54 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment