Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] How to access points' corrdinate of the edge

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] How to access points' corrdinate of the edge


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] How to access points' corrdinate of the edge
  • Date: Thu, 25 May 2017 08:47:24 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:hZ6y9BFruFiObBcCQApExZ1GYnF86YWxBRYc798ds5kLTJ7zoM2wAkXT6L1XgUPTWs2DsrQf2rSQ7v+oGTRZp83Q7zZaKN0EfiRGoPtVtjRjOvLNMVf8Iv/uYn5yN+V5f3ghwUuGN1NIEt31fVzYry76xzcTHhLiKVg9fbytScbdgMutyu+95YDYbRlWizqhe7NyKwi9oRnMusUMj4ZvLqc8xgHJr3ZKZu9awX9kKU+Jkxvy4sq9/oRv/zhMt/4k6sVNTbj0c6MkQLNXCzgrL3o76Mr3uxfdUACB/GEcUmIYkhpJBwjK8hT3VYrvvyX5q+RwxjCUMdX5Qr4oVzui6bxrSALzhyccKzE56mDXhddug69dvRmsugZww4/QYIGSKfp+YqbQds4USGZdQspcUTFKD4WhZIUNEuUBJ/5VoZTjqVsArRW+AgqiCu3hxTBHhHD5waI03v89EQzExgEsA84CvXrWodjzKawcUfq1zK7NzTjbYf9YxCny55PSfRA6vfGMXKx/cczMwkcpEAPFlFSQqYv5PziI0ugDsnaU7+1lVe2xl24nsQFwrDi1ycgwlonJgZgVy1DB+Sl33Y04Isa4SEp8Yd6+EZtQsD2aO5FzQsMmWGxotyM6xacHuZ6/ZiQF1JMnxxvGZvGBboOG4QrjWf6PLTtkgH9pYrGyihao/US91OHxVdO43EtOoydFitXBtHIA2wbO5sSZS/Zx5Fqt1DiL2gzJ9O1JIEY5nrfBJZE72L4/jJ8TvFzDHiDonEX2i7ebdkA+9eip7+Tre7vnpoWAO4NthAHyL6Ajl8ylDeQ3NQgOWGeb+eCi27H54UL5R7BKguU3kqnfrp/aOdwWqrClDwJRyIou6BayAy273NgGnnQLNk9JdRaHgoTxPlHBOvH4DfOxg1S2lzdrwujLPqblApXKNHjDkbDhfapn505ZzAo+1t9f55dOBbEAJPL/QFP+tNvdDhMhKQy73/7nCMlh1oMZQW+AHqCZP7nWsVOR++0vIvKMa5MIuDbmMPgo/OXujH88mV8FZ6alx5oXaHaiHvRnOUqVe3Tsgs1SWVsN6wExReivhFyZWiNIfF6zWbg973c1EtGIF4DGE8qWjbaIxzu6E5seQmdcC1eQWTfHeoKBVusWeQybKdNmiC1FH/D1UIsmzxCpqEn/z5JoK+PV/msTspe1h4s93PHaiRxnrW88NM+ayWzYF2w=
  • Organization: GeometryFactory

IIRC, the constrained edge map is updated. Meaning that if an edge was split and that edge was contrained, sub-edges are then constrained.

Did you observe a different behavior?

Sebastien.

On 04/13/2017 09:20 PM, Yongzhou Gu wrote:
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;
}






  • Re: [cgal-discuss] How to access points' corrdinate of the edge, Sebastien Loriot (GeometryFactory), 05/25/2017

Archive powered by MHonArc 2.6.18.

Top of Page