mirror of https://github.com/CGAL/cgal
Merge remote-tracking branch 'soesau/Kinetic_shape_reconstruction-new_package-soesau' into HEAD
originally: Author: Sébastien Loriot <sebastien.loriot@cgal.org> Date: Mon Apr 29 10:08:21 2024 +0200
This commit is contained in:
commit
5a9321d779
|
|
@ -15,7 +15,8 @@ using Surface_mesh = CGAL::Surface_mesh<Point_3>;
|
|||
using KSP = CGAL::Kinetic_space_partition_3<EPICK>;
|
||||
using Timer = CGAL::Real_timer;
|
||||
|
||||
int main(const int argc, const char** argv) {
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// Reading polygons from file
|
||||
std::string input_filename = (argc > 1 ? argv[1] : "data/test-4-rnd-polygons-4-6.off");
|
||||
std::ifstream input_file(input_filename);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ private:
|
|||
using Tetrahedron_3 = typename Kernel::Tetrahedron_3;
|
||||
|
||||
using From_exact = CGAL::Cartesian_converter<IntersectionKernel, Kernel>;
|
||||
using To_exact = CGAL::Cartesian_converter<Kernel, IntersectionKernel>;
|
||||
|
||||
using Data_structure = CGAL::KSP_3::internal::Data_structure<Kernel, IntersectionKernel>;
|
||||
|
||||
|
|
@ -422,16 +423,23 @@ private:
|
|||
// take 2d directions orthogonal to edge
|
||||
// sort and take neighbors to current face
|
||||
|
||||
const Segment_3 segment = m_data.segment_3(pedge);
|
||||
Vector_3 norm(segment.source(), segment.target());
|
||||
norm = KSP::internal::normalize(norm);
|
||||
const Plane_3 plane(segment.source(), norm);
|
||||
Point_2 source2d = plane.to_2d(segment.source());
|
||||
To_exact to_exact;
|
||||
|
||||
// const Segment_3 segment = m_data.segment_3(pedge);
|
||||
IEdge ie = m_data.iedge(pedge);
|
||||
typename Intersection_kernel::Point_3 source = m_data.point_3(m_data.igraph().source(ie));
|
||||
typename Intersection_kernel::Vector_3 norm(source, m_data.point_3(m_data.igraph().target(ie)));
|
||||
|
||||
norm = KSP::internal::normalize(norm);
|
||||
|
||||
const typename Intersection_kernel::Plane_3 plane(source, norm);
|
||||
typename Intersection_kernel::Point_2 source2d = plane.to_2d(source);
|
||||
|
||||
std::vector< std::pair<typename Intersection_kernel::Direction_2, PFace> > dir_edges;
|
||||
|
||||
std::vector< std::pair<Direction_2, PFace> > dir_edges;
|
||||
// Get orientation towards edge of current face
|
||||
Point_2 v2d = plane.to_2d(m_data.centroid_of_pface(pface));
|
||||
dir_edges.push_back(std::make_pair(Direction_2(source2d - v2d), pface));
|
||||
typename Intersection_kernel::Point_2 v2d = plane.to_2d(to_exact(m_data.centroid_of_pface(pface)));
|
||||
dir_edges.push_back(std::make_pair(typename Intersection_kernel::Direction_2(source2d - v2d), pface));
|
||||
|
||||
// Get orientation towards edge of other faces
|
||||
for (const PFace& face : neighbor_faces) {
|
||||
|
|
@ -444,13 +452,14 @@ private:
|
|||
auto h = mesh.halfedge(face.second);
|
||||
auto first = h;
|
||||
|
||||
Point_3 point;
|
||||
FT dist = 0;
|
||||
typename Intersection_kernel::Point_3 point;
|
||||
typename Intersection_kernel::FT dist = 0;
|
||||
do {
|
||||
Point_3 p = sp.to_3d(mesh.point(mesh.target(h)));
|
||||
Vector_3 dist_in_plane = (p - segment.source());
|
||||
typename Intersection_kernel::Point_3 p = m_data.point_3(m_data.ivertex(PVertex(face.first, mesh.target(h))));
|
||||
typename Intersection_kernel::Vector_3 dist_in_plane = (p - source);
|
||||
dist_in_plane -= norm * (dist_in_plane * norm);
|
||||
FT d = dist_in_plane.squared_length();
|
||||
typename Intersection_kernel::FT d = dist_in_plane.squared_length();
|
||||
|
||||
if (d > dist) {
|
||||
dist = d;
|
||||
point = p;
|
||||
|
|
@ -458,17 +467,15 @@ private:
|
|||
h = mesh.next(h);
|
||||
} while (first != h);
|
||||
|
||||
Point_2 p = plane.to_2d(point);
|
||||
|
||||
dir_edges.push_back(std::make_pair(Direction_2(source2d - p), face));
|
||||
dir_edges.push_back(std::make_pair(typename Intersection_kernel::Direction_2(source2d - plane.to_2d(point)), face));
|
||||
}
|
||||
|
||||
CGAL_assertion(dir_edges.size() == neighbor_faces.size());
|
||||
|
||||
// Sort directions
|
||||
std::sort(dir_edges.begin(), dir_edges.end(), [&](
|
||||
const std::pair<Direction_2, PFace>& p,
|
||||
const std::pair<Direction_2, PFace>& q) -> bool {
|
||||
const std::pair<typename Intersection_kernel::Direction_2, PFace>& p,
|
||||
const std::pair<typename Intersection_kernel::Direction_2, PFace>& q) -> bool {
|
||||
return p.first < q.first;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -984,10 +984,12 @@ public:
|
|||
if (!added_volumes[i])
|
||||
std::cout << "volume " << i << " has not been added" << std::endl;
|
||||
|
||||
std::cout << "lcc #volumes: " << lcc.template one_dart_per_cell<3>().size() << " ksp #volumes: " << number_of_volumes() << std::endl;
|
||||
std::cout << "lcc #faces: " << lcc.template one_dart_per_cell<2>().size() << " ksp #faces: " << num_faces << std::endl;
|
||||
std::cout << "lcc #n-edges: " << lcc.template one_dart_per_cell<1>().size() << std::endl;
|
||||
std::cout << "lcc #vtx: " << lcc.template one_dart_per_cell<0>().size() << " ksp #vtx: " << vtx.size() << std::endl;
|
||||
if (m_parameters.verbose) {
|
||||
std::cout << "lcc #volumes: " << lcc.template one_dart_per_cell<3>().size() << " ksp #volumes: " << number_of_volumes() << std::endl;
|
||||
std::cout << "lcc #faces: " << lcc.template one_dart_per_cell<2>().size() << " ksp #faces: " << num_faces << std::endl;
|
||||
std::cout << "lcc #n-edges: " << lcc.template one_dart_per_cell<1>().size() << std::endl;
|
||||
std::cout << "lcc #vtx: " << lcc.template one_dart_per_cell<0>().size() << " ksp #vtx: " << vtx.size() << std::endl;
|
||||
}
|
||||
|
||||
// Verification
|
||||
// Check attributes in each dart
|
||||
|
|
@ -1012,7 +1014,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
lcc.display_characteristics(std::cout) << std::endl;
|
||||
if (m_parameters.verbose)
|
||||
lcc.display_characteristics(std::cout) << std::endl;
|
||||
|
||||
if (!lcc.is_valid())
|
||||
std::cout << "LCC is not valid" << std::endl;
|
||||
|
|
@ -2391,7 +2394,8 @@ private:
|
|||
idx++;
|
||||
}
|
||||
|
||||
std::cout << "input split into " << m_partition_nodes.size() << " partitions" << std::endl;
|
||||
if (m_parameters.verbose)
|
||||
std::cout << "input split into " << m_partition_nodes.size() << " partitions" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue