mirror of https://github.com/CGAL/cgal
output support planes + better numbering
This commit is contained in:
parent
6b5cd22716
commit
75b2bccfb5
|
|
@ -61,25 +61,24 @@ int main(const int argc, const char** argv) {
|
|||
|
||||
std::cout << std::endl;
|
||||
std::cout << "--- INPUT STATS: " << std::endl;
|
||||
std::cout << "* used kernel: " << kernel_name << std::endl;
|
||||
std::cout << "* number of vertices: " << input_vertices.size() << std::endl;
|
||||
std::cout << "* number of faces: " << input_faces.size() << std::endl;
|
||||
std::cout << "* used kernel: " << kernel_name << std::endl;
|
||||
std::cout << "* number of polygons: " << input_faces.size() << std::endl;
|
||||
|
||||
// Algorithm.
|
||||
const bool debug = true;
|
||||
const bool verbose = true;
|
||||
KSR ksr(verbose, debug);
|
||||
const unsigned int k = (argc > 2 ? std::atoi(argv[2]) : 1);
|
||||
std::cout << "* input k: " << k << std::endl;
|
||||
std::cout << "* number of intersections k: " << k << std::endl;
|
||||
const unsigned int n = 0;
|
||||
const unsigned int num_blocks = std::pow(n + 1, 3);
|
||||
std::cout << "* input blocks: " << num_blocks << std::endl;
|
||||
std::cout << "* number of blocks: " << num_blocks << std::endl;
|
||||
const Polygon_map polygon_map(input_vertices);
|
||||
const bool is_success = ksr.partition(input_faces, polygon_map, k, n);
|
||||
assert(is_success);
|
||||
|
||||
// Output.
|
||||
const int support_plane_idx = - 1;
|
||||
const int support_plane_idx = -1;
|
||||
const int num_support_planes = ksr.number_of_support_planes();
|
||||
CGAL_assertion(num_support_planes > 6);
|
||||
|
||||
|
|
@ -99,14 +98,12 @@ int main(const int argc, const char** argv) {
|
|||
|
||||
// Faces.
|
||||
const std::size_t num_faces = ksr.number_of_faces(support_plane_idx);
|
||||
std::vector<Point_3> output_face_vertices;
|
||||
std::vector< std::vector<std::size_t> > output_faces;
|
||||
ksr.output_partition_faces(
|
||||
std::back_inserter(output_face_vertices),
|
||||
std::back_inserter(output_faces), support_plane_idx);
|
||||
assert(num_faces == output_faces.size());
|
||||
|
||||
int volume_level = - 1;
|
||||
int volume_level = -1;
|
||||
const int num_volume_levels = ksr.number_of_volume_levels();
|
||||
CGAL_assertion(num_volume_levels > 0);
|
||||
|
||||
|
|
@ -118,17 +115,17 @@ int main(const int argc, const char** argv) {
|
|||
assert(num_volumes == output_volumes.size());
|
||||
|
||||
// Support planes.
|
||||
// std::vector<Surface_mesh> support_planes;
|
||||
// support_planes.reserve(num_support_planes);
|
||||
// for (int i = 0; i < num_support_planes; ++i) {
|
||||
// Surface_mesh sp_mesh;
|
||||
// ksr.output_support_plane(i, sp_mesh);
|
||||
// CGAL_assertion(sp_mesh.number_of_vertices() == ksr.number_of_vertices(i));
|
||||
// CGAL_assertion(sp_mesh.number_of_edges() == ksr.number_of_edges(i));
|
||||
// CGAL_assertion(sp_mesh.number_of_faces() == ksr.number_of_faces(i));
|
||||
// support_planes.push_back(sp_mesh);
|
||||
// }
|
||||
// CGAL_assertion(support_planes.size() == num_support_planes);
|
||||
std::vector<Surface_mesh> support_planes;
|
||||
support_planes.reserve(num_support_planes);
|
||||
for (int i = 0; i < num_support_planes; ++i) {
|
||||
Surface_mesh sp_mesh;
|
||||
ksr.output_support_plane(sp_mesh, i);
|
||||
CGAL_assertion(sp_mesh.number_of_vertices() == ksr.number_of_vertices(i));
|
||||
CGAL_assertion(sp_mesh.number_of_edges() == ksr.number_of_edges(i));
|
||||
CGAL_assertion(sp_mesh.number_of_faces() == ksr.number_of_faces(i));
|
||||
support_planes.push_back(sp_mesh);
|
||||
}
|
||||
CGAL_assertion(support_planes.size() == num_support_planes);
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "--- OUTPUT STATS: " << std::endl;
|
||||
|
|
@ -143,56 +140,57 @@ int main(const int argc, const char** argv) {
|
|||
std::cout << "--- EXPORT: " << std::endl;
|
||||
|
||||
// Vertices.
|
||||
std::string output_filename = "partition-vertices.xyz";
|
||||
std::ofstream output_file_vertices(output_filename);
|
||||
output_file_vertices.precision(20);
|
||||
for (const auto& output_vertex : output_vertices)
|
||||
output_file_vertices << output_vertex << std::endl;
|
||||
output_file_vertices.close();
|
||||
std::cout << "* partition vertices exported successfully" << std::endl;
|
||||
// std::string output_filename = "partition-vertices.xyz";
|
||||
// std::ofstream output_file_vertices(output_filename);
|
||||
// output_file_vertices.precision(20);
|
||||
// for (const auto& output_vertex : output_vertices)
|
||||
// output_file_vertices << output_vertex << std::endl;
|
||||
// output_file_vertices.close();
|
||||
// std::cout << "* partition vertices exported successfully" << std::endl;
|
||||
|
||||
// Edges.
|
||||
output_filename = "partition-edges.polylines.txt";
|
||||
std::ofstream output_file_edges(output_filename);
|
||||
output_file_edges.precision(20);
|
||||
for (const auto& output_edge : output_edges)
|
||||
output_file_edges << "2 " << output_edge << std::endl;
|
||||
output_file_edges.close();
|
||||
std::cout << "* partition edges exported successfully" << std::endl;
|
||||
// output_filename = "partition-edges.polylines.txt";
|
||||
// std::ofstream output_file_edges(output_filename);
|
||||
// output_file_edges.precision(20);
|
||||
// for (const auto& output_edge : output_edges)
|
||||
// output_file_edges << "2 " << output_edge << std::endl;
|
||||
// output_file_edges.close();
|
||||
// std::cout << "* partition edges exported successfully" << std::endl;
|
||||
|
||||
// Faces.
|
||||
output_filename = "partition-faces.ply";
|
||||
std::ofstream output_file_faces(output_filename);
|
||||
output_file_faces.precision(20);
|
||||
if (!CGAL::write_PLY(output_file_faces, output_face_vertices, output_faces)) {
|
||||
std::cerr << "ERROR: can't write to the file " << output_filename << "!" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
output_file_faces.close();
|
||||
std::cout << "* partition faces exported successfully" << std::endl;
|
||||
// output_filename = "partition-faces.ply";
|
||||
// std::ofstream output_file_faces(output_filename);
|
||||
// output_file_faces.precision(20);
|
||||
// if (!CGAL::write_PLY(output_file_faces, output_vertices, output_faces)) {
|
||||
// std::cerr << "ERROR: can't write to the file " << output_filename << "!" << std::endl;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// output_file_faces.close();
|
||||
// std::cout << "* partition faces exported successfully" << std::endl;
|
||||
|
||||
// Volumes.
|
||||
output_filename = "partition-volume-";
|
||||
for (std::size_t i = 0; i < num_volumes; ++i) {
|
||||
const auto output_file = output_filename + std::to_string(i) + ".ply";
|
||||
std::ofstream output_file_volume(output_file);
|
||||
output_file_volume.precision(20);
|
||||
if (!CGAL::write_ply(output_file_volume, output_volumes[i])) {
|
||||
std::cerr << "ERROR: can't write to the file " << output_file << "!" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
output_file_volume.close();
|
||||
}
|
||||
std::cout << "* partition volumes exported successfully" << std::endl;
|
||||
// output_filename = "partition-volume-";
|
||||
// for (std::size_t i = 0; i < num_volumes; ++i) {
|
||||
// const auto output_file = output_filename + std::to_string(i) + ".ply";
|
||||
// std::ofstream output_file_volume(output_file);
|
||||
// output_file_volume.precision(20);
|
||||
// if (!CGAL::write_ply(output_file_volume, output_volumes[i])) {
|
||||
// std::cerr << "ERROR: can't write to the file " << output_file << "!" << std::endl;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// output_file_volume.close();
|
||||
// }
|
||||
// std::cout << "* partition volumes exported successfully" << std::endl;
|
||||
|
||||
// Support planes.
|
||||
// for (std::size_t i = 0; i < support_planes.size(); ++i) {
|
||||
// const std::string filename = "support_plane-" + std::to_string(i);
|
||||
// const std::string filename = "support_plane-" + std::to_string(i) + ".ply";
|
||||
// std::ofstream output_file_support_plane(filename);
|
||||
// output_file_support_plane.precision(20);
|
||||
// CGAL::write_ply(output_file_support_plane, support_planes[i]);
|
||||
// output_file_support_plane.close();
|
||||
// }
|
||||
// std::cout << "* partition support planes exported successfully" << std::endl;
|
||||
|
||||
std::cout << std::endl << "3D KINETIC DONE!" << std::endl << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -578,7 +578,7 @@ private:
|
|||
};
|
||||
|
||||
template<typename DS, typename PFace>
|
||||
void dump_polyhedron(
|
||||
void dump_volume(
|
||||
const DS& data,
|
||||
const std::vector<PFace>& pfaces,
|
||||
const std::string file_name) {
|
||||
|
|
@ -609,7 +609,7 @@ void dump_polyhedron(
|
|||
}
|
||||
|
||||
template<typename DS>
|
||||
void dump_polyhedrons(const DS& data, const std::string tag = std::string()) {
|
||||
void dump_volumes(const DS& data, const std::string tag = std::string()) {
|
||||
|
||||
using Point_3 = typename DS::Kernel::Point_3;
|
||||
std::vector<Point_3> polygon;
|
||||
|
|
@ -617,8 +617,8 @@ void dump_polyhedrons(const DS& data, const std::string tag = std::string()) {
|
|||
std::vector<Color> colors;
|
||||
|
||||
Saver<typename DS::Kernel> saver;
|
||||
for (std::size_t i = 0; i < data.polyhedrons().size(); ++i) {
|
||||
const auto& volume = data.polyhedrons()[i];
|
||||
for (std::size_t i = 0; i < data.volumes().size(); ++i) {
|
||||
const auto& volume = data.volumes()[i];
|
||||
const auto color = saver.get_idx_color(i);
|
||||
|
||||
colors.clear();
|
||||
|
|
@ -652,7 +652,7 @@ void dump_pface(
|
|||
}
|
||||
polygons.push_back(polygon);
|
||||
Saver<Kernel> saver;
|
||||
saver.export_polygon_soup_3(polygons, "polyhedrons/" + name);
|
||||
saver.export_polygon_soup_3(polygons, "volumes/" + name);
|
||||
}
|
||||
|
||||
template<typename DS, typename PEdge>
|
||||
|
|
@ -665,7 +665,7 @@ void dump_pedge(
|
|||
using Segment_3 = typename Kernel::Segment_3;
|
||||
const std::vector<Segment_3> segments = { data.segment_3(pedge) };
|
||||
Saver<Kernel> saver;
|
||||
saver.export_segments_3(segments, "polyhedrons/" + name);
|
||||
saver.export_segments_3(segments, "volumes/" + name);
|
||||
}
|
||||
|
||||
template<typename DS, typename PFace, typename PEdge>
|
||||
|
|
|
|||
|
|
@ -199,15 +199,13 @@ private:
|
|||
bool m_verbose;
|
||||
|
||||
std::vector<Volume_cell> m_volumes;
|
||||
std::size_t m_num_volume_levels;
|
||||
std::map<int, std::size_t> m_volume_level_map;
|
||||
|
||||
public:
|
||||
Data_structure(const bool verbose) :
|
||||
m_current_time(FT(0)),
|
||||
m_previous_time(FT(0)),
|
||||
m_verbose(verbose),
|
||||
m_num_volume_levels(0)
|
||||
m_verbose(verbose)
|
||||
{ }
|
||||
|
||||
void clear() {
|
||||
|
|
@ -220,19 +218,23 @@ public:
|
|||
m_previous_time = FT(0);
|
||||
|
||||
m_volumes.clear();
|
||||
m_num_volume_levels = 0;
|
||||
m_volume_level_map.clear();
|
||||
}
|
||||
|
||||
const std::size_t number_of_volume_levels() const {
|
||||
return m_num_volume_levels;
|
||||
const int number_of_volume_levels() const {
|
||||
return static_cast<int>(m_volume_level_map.size());
|
||||
}
|
||||
|
||||
const std::size_t number_of_volumes(const int volume_level) const {
|
||||
|
||||
CGAL_assertion(volume_level < number_of_volume_levels());
|
||||
if (volume_level >= number_of_volume_levels()) return std::size_t(-1);
|
||||
if (volume_level < 0) {
|
||||
return m_volumes.size();
|
||||
}
|
||||
|
||||
CGAL_assertion(volume_level >= 0);
|
||||
CGAL_assertion(m_volume_level_map.find(volume_level) != m_volume_level_map.end());
|
||||
return m_volume_level_map.at(volume_level);
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +287,7 @@ public:
|
|||
return support_plane(pvertex).last_event_time(pvertex.second);
|
||||
}
|
||||
|
||||
const std::vector<Volume_cell>& polyhedrons() const {
|
||||
const std::vector<Volume_cell>& volumes() const {
|
||||
return m_volumes;
|
||||
}
|
||||
|
||||
|
|
@ -3203,7 +3205,7 @@ public:
|
|||
|
||||
const bool is_broken_volume = is_volume_degenerate(pfaces);
|
||||
if (is_broken_volume) {
|
||||
dump_polyhedron(*this, pfaces, "polyhedrons/degenerate");
|
||||
dump_volume(*this, pfaces, "volumes/degenerate");
|
||||
}
|
||||
CGAL_assertion(!is_broken_volume);
|
||||
CGAL_assertion(pfaces.size() == volume_size);
|
||||
|
|
@ -3254,7 +3256,7 @@ public:
|
|||
** EXTRACTING VOLUMES **
|
||||
********************************/
|
||||
|
||||
void create_polyhedrons() {
|
||||
void create_polyhedra() {
|
||||
|
||||
std::cout.precision(20);
|
||||
// for (KSR::size_t i = 0; i < number_of_support_planes(); ++i)
|
||||
|
|
@ -3304,10 +3306,9 @@ public:
|
|||
std::cout << "* found boundary volumes: "<< volume_index << std::endl;
|
||||
}
|
||||
num_volumes = volume_index;
|
||||
m_volume_level_map[volume_level] =
|
||||
static_cast<std::size_t>(num_volumes);
|
||||
++volume_level;
|
||||
CGAL_assertion(num_volumes > 0);
|
||||
m_volume_level_map[volume_level] = static_cast<std::size_t>(num_volumes);
|
||||
++volume_level;
|
||||
|
||||
// Then traverse all other volumes if any.
|
||||
std::vector<PFace> other_pfaces;
|
||||
|
|
@ -3346,16 +3347,16 @@ public:
|
|||
if (m_verbose) {
|
||||
std::cout << "* found interior volumes: "<< after - before << std::endl;
|
||||
}
|
||||
CGAL_assertion(after >= before);
|
||||
num_volumes = volume_index;
|
||||
m_volume_level_map[volume_level] =
|
||||
static_cast<std::size_t>(num_volumes);
|
||||
++volume_level;
|
||||
CGAL_assertion(after >= before);
|
||||
if (after > before) {
|
||||
m_volume_level_map[volume_level] = static_cast<std::size_t>(after - before);
|
||||
++volume_level;
|
||||
}
|
||||
|
||||
} while (!quit);
|
||||
m_num_volume_levels = volume_level;
|
||||
|
||||
// Now, set final polyhedrons and their neighbors.
|
||||
// Now, set final volumes and their neighbors.
|
||||
for (const auto& item : map_volumes) {
|
||||
const auto& pface = item.first;
|
||||
const auto& pair = item.second;
|
||||
|
|
@ -3381,13 +3382,13 @@ public:
|
|||
create_cell_pvertices(volume);
|
||||
|
||||
if (m_verbose) {
|
||||
std::cout << "* created polyhedrons: " << m_volumes.size() << std::endl;
|
||||
dump_polyhedrons(*this, "polyhedrons/final");
|
||||
std::cout << "* created volumes: " << m_volumes.size() << std::endl;
|
||||
dump_volumes(*this, "volumes/final");
|
||||
for (std::size_t i = 0; i < m_volumes.size(); ++i) {
|
||||
const auto& volume = m_volumes[i];
|
||||
CGAL_assertion(volume.pfaces.size() > 3);
|
||||
std::cout <<
|
||||
" POLYHEDRON " << std::to_string(i) << ": "
|
||||
" VOLUME " << std::to_string(i) << ": "
|
||||
" pvertices: " << volume.pvertices.size() <<
|
||||
" pfaces: " << volume.pfaces.size() << std::endl;
|
||||
}
|
||||
|
|
@ -3819,7 +3820,7 @@ public:
|
|||
}
|
||||
|
||||
if (is_debug) {
|
||||
dump_frame(points, "polyhedrons/directions-init");
|
||||
dump_frame(points, "volumes/directions-init");
|
||||
}
|
||||
|
||||
const FT cx = volume_centroid.x();
|
||||
|
|
@ -3854,7 +3855,7 @@ public:
|
|||
if (is_debug) {
|
||||
auto extended = points;
|
||||
extended.push_back(volume_centroid);
|
||||
dump_frame(extended, "polyhedrons/directions");
|
||||
dump_frame(extended, "volumes/directions");
|
||||
}
|
||||
|
||||
std::vector< std::pair<Direction_2, PFace> > dir_edges;
|
||||
|
|
@ -3914,10 +3915,10 @@ public:
|
|||
} else {
|
||||
// return null_pface();
|
||||
dump_info(*this, pface, pedge, nfaces);
|
||||
dump_frame(points, "polyhedrons/directions-init");
|
||||
dump_frame(points, "volumes/directions-init");
|
||||
auto extended = points;
|
||||
extended.push_back(volume_centroid);
|
||||
dump_frame(extended, "polyhedrons/directions");
|
||||
dump_frame(extended, "volumes/directions");
|
||||
CGAL_assertion_msg(false, "ERROR: WRONG ORIENTATION!");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,10 +63,12 @@ private:
|
|||
using Event = KSR_3::Event<Data_structure>;
|
||||
using Event_queue = KSR_3::Event_queue<Data_structure>;
|
||||
|
||||
using EK = CGAL::Exact_predicates_exact_constructions_kernel;
|
||||
using Initializer = KSR_3::Initializer<EK>;
|
||||
using Bbox_2 = CGAL::Bbox_2;
|
||||
using EK = CGAL::Exact_predicates_exact_constructions_kernel;
|
||||
using Initializer = KSR_3::Initializer<EK>;
|
||||
using Bbox_2 = CGAL::Bbox_2;
|
||||
|
||||
using Polygon_mesh = CGAL::Surface_mesh<Point_3>;
|
||||
using Vertex_index = typename Polygon_mesh::Vertex_index;
|
||||
|
||||
private:
|
||||
const bool m_debug;
|
||||
|
|
@ -177,18 +179,18 @@ public:
|
|||
}
|
||||
|
||||
if (m_verbose) std::cout << std::endl << "--- FINALIZING KSR:" << std::endl;
|
||||
if (m_debug) dump(m_data, "iter-" + std::to_string(global_iteration) + "-pre-final-result");
|
||||
if (m_debug) dump(m_data, "jiter-final-a-result");
|
||||
m_data.finalize();
|
||||
if (m_verbose) std::cout << "* checking final mesh integrity ...";
|
||||
m_data.check_integrity();
|
||||
if (m_verbose) std::cout << " done" << std::endl;
|
||||
if (m_debug) dump(m_data, "iter-" + std::to_string(global_iteration + 1) + "-final-result");
|
||||
if (m_debug) dump(m_data, "jiter-final-b-result");
|
||||
|
||||
// std::cout << std::endl << "CLEANING SUCCESS!" << std::endl << std::endl;
|
||||
// exit(EXIT_SUCCESS);
|
||||
|
||||
if (m_verbose) std::cout << "* getting volumes:" << std::endl;
|
||||
m_data.create_polyhedrons();
|
||||
m_data.create_polyhedra();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -199,6 +201,7 @@ public:
|
|||
const std::size_t number_of_vertices(const int support_plane_idx = -1) const {
|
||||
|
||||
CGAL_assertion(support_plane_idx < number_of_support_planes());
|
||||
if (support_plane_idx >= number_of_support_planes()) return std::size_t(-1);
|
||||
if (support_plane_idx < 0) {
|
||||
return m_data.igraph().number_of_vertices();
|
||||
}
|
||||
|
|
@ -211,6 +214,7 @@ public:
|
|||
const std::size_t number_of_edges(const int support_plane_idx = -1) const {
|
||||
|
||||
CGAL_assertion(support_plane_idx < number_of_support_planes());
|
||||
if (support_plane_idx >= number_of_support_planes()) return std::size_t(-1);
|
||||
if (support_plane_idx < 0) {
|
||||
return m_data.igraph().number_of_edges();
|
||||
}
|
||||
|
|
@ -223,6 +227,7 @@ public:
|
|||
const std::size_t number_of_faces(const int support_plane_idx = -1) const {
|
||||
|
||||
CGAL_assertion(support_plane_idx < number_of_support_planes());
|
||||
if (support_plane_idx >= number_of_support_planes()) return std::size_t(-1);
|
||||
if (support_plane_idx < 0) {
|
||||
std::size_t num_all_faces = 0;
|
||||
for (int i = 0; i < number_of_support_planes(); ++i) {
|
||||
|
|
@ -260,9 +265,10 @@ public:
|
|||
VertexOutputIterator vertices, const int support_plane_idx = -1) const {
|
||||
|
||||
CGAL_assertion(support_plane_idx < number_of_support_planes());
|
||||
if (support_plane_idx >= number_of_support_planes()) return vertices;
|
||||
if (support_plane_idx < 0) {
|
||||
const auto ivertices = m_data.ivertices();
|
||||
for (const auto ivertex : ivertices) {
|
||||
const auto all_ivertices = m_data.ivertices();
|
||||
for (const auto ivertex : all_ivertices) {
|
||||
*(vertices++) = m_data.point_3(ivertex);
|
||||
}
|
||||
return vertices;
|
||||
|
|
@ -270,9 +276,11 @@ public:
|
|||
|
||||
CGAL_assertion(support_plane_idx >= 0);
|
||||
const KSR::size_t sp_idx = static_cast<KSR::size_t>(support_plane_idx);
|
||||
const auto pvertices = m_data.pvertices(sp_idx);
|
||||
for (const auto pvertex : pvertices) {
|
||||
*(vertices++) = m_data.point_3(pvertex);
|
||||
const auto all_pvertices = m_data.pvertices(sp_idx);
|
||||
for (const auto pvertex : all_pvertices) {
|
||||
CGAL_assertion(m_data.has_ivertex(pvertex));
|
||||
const auto ivertex = m_data.ivertex(pvertex);
|
||||
*(vertices++) = m_data.point_3(ivertex);
|
||||
}
|
||||
return vertices;
|
||||
}
|
||||
|
|
@ -282,9 +290,10 @@ public:
|
|||
EdgeOutputIterator edges, const int support_plane_idx = -1) const {
|
||||
|
||||
CGAL_assertion(support_plane_idx < number_of_support_planes());
|
||||
if (support_plane_idx >= number_of_support_planes()) return edges;
|
||||
if (support_plane_idx < 0) {
|
||||
const auto iedges = m_data.iedges();
|
||||
for (const auto iedge : iedges) {
|
||||
const auto all_iedges = m_data.iedges();
|
||||
for (const auto iedge : all_iedges) {
|
||||
*(edges++) = m_data.segment_3(iedge);
|
||||
}
|
||||
return edges;
|
||||
|
|
@ -292,48 +301,85 @@ public:
|
|||
|
||||
CGAL_assertion(support_plane_idx >= 0);
|
||||
const KSR::size_t sp_idx = static_cast<KSR::size_t>(support_plane_idx);
|
||||
const auto pedges = m_data.pedges(sp_idx);
|
||||
for (const auto pedge : pedges) {
|
||||
*(edges++) = m_data.segment_3(pedge);
|
||||
const auto all_pedges = m_data.pedges(sp_idx);
|
||||
for (const auto pedge : all_pedges) {
|
||||
CGAL_assertion(m_data.has_iedge(pedge));
|
||||
const auto iedge = m_data.iedge(pedge);
|
||||
*(edges++) = m_data.segment_3(iedge);
|
||||
}
|
||||
return edges;
|
||||
}
|
||||
|
||||
template<typename VertexOutputIterator, typename FaceOutputIterator>
|
||||
void output_partition_faces(
|
||||
VertexOutputIterator vertices, FaceOutputIterator faces,
|
||||
const int support_plane_idx = -1) const {
|
||||
template<typename FaceOutputIterator>
|
||||
FaceOutputIterator output_partition_faces(
|
||||
FaceOutputIterator faces, const int support_plane_idx = -1) const {
|
||||
|
||||
std::size_t num_vertices = 0;
|
||||
KSR::Indexer<IVertex> indexer;
|
||||
|
||||
CGAL_assertion(support_plane_idx < number_of_support_planes());
|
||||
if (support_plane_idx >= number_of_support_planes()) return faces;
|
||||
if (support_plane_idx < 0) {
|
||||
const auto all_ivertices = m_data.ivertices();
|
||||
for (const auto ivertex : all_ivertices) indexer(ivertex);
|
||||
for (int i = 0; i < number_of_support_planes(); ++i) {
|
||||
output_partition_faces(vertices, faces, indexer, num_vertices, i);
|
||||
const KSR::size_t sp_idx = static_cast<KSR::size_t>(i);
|
||||
output_partition_faces(faces, indexer, sp_idx);
|
||||
}
|
||||
return;
|
||||
return faces;
|
||||
}
|
||||
|
||||
CGAL_assertion(support_plane_idx >= 0);
|
||||
output_partition_faces(
|
||||
vertices, faces, indexer, num_vertices, support_plane_idx);
|
||||
const KSR::size_t sp_idx = static_cast<KSR::size_t>(support_plane_idx);
|
||||
const auto all_pvertices = m_data.pvertices(sp_idx);
|
||||
for (const auto pvertex : all_pvertices) {
|
||||
CGAL_assertion(m_data.has_ivertex(pvertex));
|
||||
const auto ivertex = m_data.ivertex(pvertex);
|
||||
indexer(ivertex);
|
||||
}
|
||||
return output_partition_faces(faces, indexer, sp_idx);
|
||||
}
|
||||
|
||||
template<typename FaceGraph>
|
||||
void output_support_plane(
|
||||
FaceGraph& face_graph, const int support_plane_idx) const {
|
||||
Polygon_mesh& polygon_mesh, const int support_plane_idx) const {
|
||||
|
||||
face_graph.clear();
|
||||
polygon_mesh.clear();
|
||||
CGAL_assertion(support_plane_idx >= 0);
|
||||
if (support_plane_idx < 0) return;
|
||||
CGAL_assertion(support_plane_idx < number_of_support_planes());
|
||||
CGAL_assertion_msg(false, "TODO: IMPLEMENT ORIENTED OUTPUT SUPPORT PLANE!");
|
||||
if (support_plane_idx >= number_of_support_planes()) return;
|
||||
const KSR::size_t sp_idx = static_cast<KSR::size_t>(support_plane_idx);
|
||||
|
||||
std::vector<Vertex_index> vertices;
|
||||
std::vector<Vertex_index> map_vertices;
|
||||
|
||||
map_vertices.clear();
|
||||
const auto all_pvertices = m_data.pvertices(sp_idx);
|
||||
for (const auto pvertex : all_pvertices) {
|
||||
CGAL_assertion(m_data.has_ivertex(pvertex));
|
||||
const auto ivertex = m_data.ivertex(pvertex);
|
||||
|
||||
if (map_vertices.size() <= pvertex.second)
|
||||
map_vertices.resize(pvertex.second + 1);
|
||||
map_vertices[pvertex.second] =
|
||||
polygon_mesh.add_vertex(m_data.point_3(ivertex));
|
||||
}
|
||||
|
||||
const auto all_pfaces = m_data.pfaces(sp_idx);
|
||||
for (const auto pface : all_pfaces) {
|
||||
vertices.clear();
|
||||
const auto pvertices = m_data.pvertices_of_pface(pface);
|
||||
for (const auto pvertex : pvertices) {
|
||||
vertices.push_back(map_vertices[pvertex.second]);
|
||||
}
|
||||
polygon_mesh.add_face(vertices);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename VolumeOutputIterator>
|
||||
VolumeOutputIterator output_partition_volumes(
|
||||
VolumeOutputIterator volumes, const int volume_level = -1) const {
|
||||
|
||||
CGAL_assertion(volume_level < number_of_volume_levels());
|
||||
if (volume_level >= number_of_volume_levels()) return volumes;
|
||||
if (volume_level < 0) {
|
||||
for (int i = 0; i < number_of_volume_levels(); ++i) {
|
||||
output_partition_volumes(volumes, i);
|
||||
|
|
@ -342,9 +388,13 @@ public:
|
|||
}
|
||||
|
||||
CGAL_assertion(volume_level >= 0);
|
||||
const std::size_t begin = (volume_level == 0) ? 0 : number_of_volumes(volume_level - 1);
|
||||
const std::size_t end = number_of_volumes(volume_level);
|
||||
|
||||
std::size_t begin = 0;
|
||||
if (volume_level > 0) {
|
||||
for (int i = 0; i < volume_level; ++i) {
|
||||
begin += number_of_volumes(i);
|
||||
}
|
||||
}
|
||||
const std::size_t end = begin + number_of_volumes(volume_level);
|
||||
for (std::size_t i = begin; i < end; ++i) {
|
||||
output_partition_volume(volumes, i);
|
||||
}
|
||||
|
|
@ -356,6 +406,7 @@ public:
|
|||
VolumeOutputIterator volumes, const std::size_t volume_index) const {
|
||||
|
||||
CGAL_assertion(volume_index < number_of_volumes(-1));
|
||||
if (volume_index >= number_of_volumes(-1)) return volumes;
|
||||
|
||||
std::vector<Point_3> vertices;
|
||||
std::vector< std::vector<std::size_t> > faces;
|
||||
|
|
@ -376,8 +427,9 @@ public:
|
|||
const std::size_t volume_index) const {
|
||||
|
||||
CGAL_assertion(volume_index < number_of_volumes(-1));
|
||||
CGAL_assertion(m_data.polyhedrons().size() == number_of_volumes(-1));
|
||||
const auto& volume = m_data.polyhedrons()[volume_index];
|
||||
if (volume_index >= number_of_volumes(-1)) return;
|
||||
CGAL_assertion(m_data.volumes().size() == number_of_volumes(-1));
|
||||
const auto& volume = m_data.volumes()[volume_index];
|
||||
|
||||
std::size_t num_vertices = 0;
|
||||
KSR::Indexer<IVertex> indexer;
|
||||
|
|
@ -408,11 +460,16 @@ public:
|
|||
CGAL_assertion_msg(false, "TODO: OUTPUT PARTITION LCC!");
|
||||
}
|
||||
|
||||
template<typename InputRange, typename PointMap, typename VectorMap>
|
||||
template<
|
||||
typename InputRange,
|
||||
typename PointMap,
|
||||
typename VectorMap,
|
||||
typename LabelMap>
|
||||
void reconstruct(
|
||||
const InputRange& input_range,
|
||||
const PointMap point_map,
|
||||
const VectorMap normal_map) {
|
||||
const VectorMap normal_map,
|
||||
const LabelMap label_map) {
|
||||
|
||||
CGAL_assertion_msg(false, "TODO: ADD RECONSTRUCTION!");
|
||||
}
|
||||
|
|
@ -427,34 +484,25 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
template<typename VertexOutputIterator, typename FaceOutputIterator>
|
||||
void output_partition_faces(
|
||||
VertexOutputIterator vertices, FaceOutputIterator faces,
|
||||
KSR::Indexer<IVertex>& indexer, std::size_t& num_vertices,
|
||||
const int support_plane_idx) const {
|
||||
template<typename FaceOutputIterator>
|
||||
FaceOutputIterator output_partition_faces(
|
||||
FaceOutputIterator faces, KSR::Indexer<IVertex>& indexer,
|
||||
const KSR::size_t sp_idx) const {
|
||||
|
||||
std::vector<std::size_t> face;
|
||||
CGAL_assertion(support_plane_idx >= 0);
|
||||
const KSR::size_t sp_idx = static_cast<KSR::size_t>(support_plane_idx);
|
||||
|
||||
const auto pfaces = m_data.pfaces(sp_idx);
|
||||
for (const auto pface : pfaces) {
|
||||
const auto all_pfaces = m_data.pfaces(sp_idx);
|
||||
for (const auto pface : all_pfaces) {
|
||||
face.clear();
|
||||
const auto pvertices = m_data.pvertices_of_pface(pface);
|
||||
for (const auto pvertex : pvertices) {
|
||||
|
||||
CGAL_assertion(m_data.has_ivertex(pvertex));
|
||||
const auto ivertex = m_data.ivertex(pvertex);
|
||||
const std::size_t idx = indexer(ivertex);
|
||||
|
||||
if (idx == num_vertices) {
|
||||
*(vertices++) = m_data.point_3(ivertex);
|
||||
++num_vertices;
|
||||
}
|
||||
face.push_back(idx);
|
||||
}
|
||||
*(faces++) = face;
|
||||
}
|
||||
return faces;
|
||||
}
|
||||
|
||||
const bool initialize_queue() {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ QUESTIONS:
|
|||
- Merge polygons, which are at the same cell.
|
||||
|
||||
3. Can we avoid kinetic completely?
|
||||
- Probably yes, but there is a problem of how to find the correct criteria that guarantees the polyhedron convexity. But we can use the trick with tagging pfaces at least for all initial polygons.
|
||||
- Probably yes, but there is a problem of how to find the correct criteria that guarantees the volume convexity. But we can use the trick with tagging pfaces at least for all initial polygons.
|
||||
|
||||
4. Do you have any guarantee on the number of final volumes? Is this number optimal for each k?
|
||||
- No, it is super difficult.
|
||||
|
|
|
|||
Loading…
Reference in New Issue