Subject: CGAL users discussion list
List archive
- From: Yongzhou Gu <>
- To:
- Subject: [cgal-discuss] How to access points' corrdinate of the edge
- Date: Thu, 13 Apr 2017 14:20:29 -0500
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Neutral ; spf=None
- Ironport-phdr: 9a23:JaDNFxLu43Ab1sOG/tmcpTZWNBhigK39O0sv0rFitYgQLfrxwZ3uMQTl6Ol3ixeRBMOAuq4C07KempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9ZDeZwpFiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QLYpUjqg8qhrUgflhicJOTA67W/ZlNB/gblBrx69vRFy2ZLYbJ2XOfd4Y6jTfckaRW1EXstJVSNBBYW8b4QODuoBOuZYspT2qVoTrRCjAgStBOzvxz1Ti3/32a061+UhEQfB3AwhBNICqmrbo8joNKoLV+2+0arGzS3bYv9IxTvw7JLEfxMhrP2WQ758bMrcxVMvGg7KiFibtJbrMCmP1usXtmiW9+pgWvyri24gswxxpyKgxsYoioXQgoIVxEzI+Tx3wIs1KtC0UkF7YdmjEJtfsyGVKZF6Td8lQ2FtoCo6y7sGtoCnfCUS1pgr2xrSZ+aEfoWI+B7vSvudLDdiiH9ld7+znxOy/lKhyu34WMm0ylFKri9dn9jMuXAA1Qfe6smDSvt5/0eh3zGP1wHI6u1eP087iLfbJ4Y7wrEsjpoTrVjDHijulUrqg6+ZbEEk9vG15OTmebXpuoKcN5RvigzlKaQvmsm/AfwiPQQUXmib//681Lz58kHjTrVKlK5+rq6Mu5/TIYEXp7WyHhRO+ocl8Re2STm8g/oCmnxSHVVDdwCHiJWhFEyGdOH3Ut++h1CtljBq3LbLMqC3UcaFFWTKjLq0JeU10EVb0gdmld0=
Hi,
My final purpose is to constrain some edges during isotropic_remseshing with proper splits on these edges.
However, when I use split_long_edge, the original edges are replaced by the new shorter edges. Thus the original constrained edges are no longer exist.
So, I tried to reset the constrained_edge_map. This requires me to determine whether the edge lies on the original long edge which is split by the function before. Thus I need to get the coordinates of both end of an edge to compare the position with the original long edge.
I've got iterator of edge descriptor now and I want to get the points' coordinates of both ends. But I don't know how to get it from an edge descriptor. Follows is my code:
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Polygon_mesh_processing/border.h>
#include <boost/function_output_iterator.hpp>
#include <fstream>
#include <vector>
#include <map>
#include <string>
#include <stdio.h>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
struct halfedge2edge
{
halfedge2edge(const Mesh& m, std::vector<edge_descriptor>& edges)
: m_mesh(m), m_edges(edges)
{}
void operator()(const halfedge_descriptor& h) const
{
m_edges.push_back(edge(h, m_mesh));
}
const Mesh& m_mesh;
std::vector<edge_descriptor>& m_edges;
};
int main(int argc, char* argv[])
{
Mesh mesh;
vertex_descriptor vd[12];
vd[0] = mesh.add_vertex(K::Point_3(0,0,0)); // cons
vd[1] = mesh.add_vertex(K::Point_3(1,0,0));
vd[2] = mesh.add_vertex(K::Point_3(2,0,0));
vd[3] = mesh.add_vertex(K::Point_3(0,1,0));
vd[4] = mesh.add_vertex(K::Point_3(1,1,0)); // cons
vd[5] = mesh.add_vertex(K::Point_3(2,1,0));
vd[6] = mesh.add_vertex(K::Point_3(0,2,0));
vd[7] = mesh.add_vertex(K::Point_3(1,2,0)); // cons
vd[8] = mesh.add_vertex(K::Point_3(2,2,0));
vd[9] = mesh.add_vertex(K::Point_3(0,3,0));
vd[10] = mesh.add_vertex(K::Point_3(1,3,0));
vd[11] = mesh.add_vertex(K::Point_3(2,3,0)); // cons
mesh.add_face(vd[0], vd[1], vd[4]);
mesh.add_face(vd[1], vd[2], vd[5]);
mesh.add_face(vd[0], vd[4], vd[3]);
mesh.add_face(vd[1], vd[5], vd[4]);
mesh.add_face(vd[3], vd[4], vd[7]);
mesh.add_face(vd[4], vd[5], vd[8]);
mesh.add_face(vd[3], vd[7], vd[6]);
mesh.add_face(vd[4], vd[8], vd[7]);
mesh.add_face(vd[6], vd[7], vd[10]);
mesh.add_face(vd[7], vd[8], vd[11]);
mesh.add_face(vd[6], vd[10], vd[9]);
mesh.add_face(vd[7], vd[11], vd[10]);
double target_edge_length;
std::cout << "input tartget_edge_length: ";
std::cin >> target_edge_length;
unsigned int nb_iter = 3;
//std::cin >> nb_iter;
std::cout << "Split border...";
std::vector<edge_descriptor> border;
std::map<edge_descriptor, bool> edgeMap;
boost::associative_property_map< std::map<edge_descriptor, bool> >
edge_map(edgeMap);
std::map<vertex_descriptor, bool> vertexMap;
boost::associative_property_map< std::map<vertex_descriptor, bool> >
vertex_map(vertexMap);
Mesh::Edge_range::iterator eb, ee;
Mesh::Edge_range r = mesh.edges();
eb = r.begin();
ee = r.end();
auto it = eb;
// Let's split the outiside boundary
double outside_boundary_split_length = 0.1;
std::cin >> outside_boundary_split_length;
// split the selected border
for (; it != r.end(); it++){
border.push_back(*it);
edgeMap.insert(std::make_pair(*it,
true));
}
printf("boder size = %d\n", border.size());
PMP::split_long_edges(border, outside_boundary_split_length, mesh);
// Set my constrained edge ends
r = mesh.edges();
it = r.begin();
int cnt = 0;
for (; it != r.end(); it++){
/****************************** How do I get the coordinates of vertices here? ********************************************/
it->???
cnt ++;
}
printf("num of edges %d\n", cnt);
std::cout << "done." << std::endl;
std::cout << "Start remeshing of "
<< " (" << num_faces(mesh) << " faces)..." << std::endl;
PMP::isotropic_remeshing(
faces(mesh),
target_edge_length,
mesh,
PMP::parameters::number_of_iterations(nb_iter)
.edge_is_constrained_map(edge_map)
.protect_constraints(true)//i.e. protect border, here
);
//PMP::split_long_edges(border, target_edge_length, mesh);
std::ofstream iso_off("isotropic.off");
iso_off << mesh;
iso_off.close();
std::cout << "Remeshing done." << std::endl;
return 0;
}
- [cgal-discuss] How to access points' corrdinate of the edge, Yongzhou Gu, 04/13/2017
Archive powered by MHonArc 2.6.18.