Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation
Chronological Thread
- From: Pol Monsó Purtí <>
- To:
- Subject: Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation
- Date: Wed, 29 Jun 2016 16:34:33 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-phdr: 9a23:7dsI0hKesk64MKzODNmcpTZWNBhigK39O0sv0rFitYgUI/zxwZ3uMQTl6Ol3ixeRBMOAuqoC0red7PmocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIsYL+kQsiL0o/ojqibwN76W01wnj2zYLd/fl2djD76kY0ou7ZkMbs70RDTo3FFKKx8zGJsIk+PzV6nvp/jtM0rziJLpvh099JcSb6oOOMjXLlABXInNXo07Yvlr17YXA6X7zwdVGsR1RFHCgyA4BDhVYrqqXjGsb921yCeeMH3VrspQi+K7qFxSRauhj1UGSQ+9TTvjcg4qaVdu4npnwFl3wucNIWRKfx3OKXaY9oySm9IX8IXXCtEVNDvJ7ATBvYMaL4L57L2oEED+EOz
Hello Laurent,
Sorry for the late reply, I've quickly tried what you've suggested right now, to no avail. I've added 4 vertices that contain the others and then called refine. The number of faces and vertices is the same and all faces are outside the domain.typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Projection_traits_xy_3<K> Gt;
typedef K::Point_3 Point3;
typedef CGAL::Triangulation_vertex_base_2<Gt> Vb;
typedef CGAL::Delaunay_mesh_face_base_2<Gt> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
//TODO check wether Exact_intersections_tag is more appropriate
typedef CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, CGAL::Exact_predicates_tag> CDTb;
typedef CGAL::Constrained_triangulation_plus_2<CDTb> CDT; //handles breaklines intersections
typedef CGAL::Delaunay_mesh_size_criteria_2<CDT> Criteria;
typedef CDT::Vertex_handle Vertex_handle;
typedef CDT::Point Point;
[...]
int QD::triangulate(const std::vector<cgal_utils::Point>& points,
const std::vector<std::vector<cgal_utils::Point>>& breaklines,
cgal_utils::CDT& cdt,
const bool& saveTriangulation,
const fs::path& outdir,
const fs::path& outfname)
{
std::cout << "Start triangulation" << std::endl;
//constraints
for( std::vector<Point> breakline : breaklines)
{
for(unsigned int i=0; i < breakline.size()-1; i++)
{
cdt.insert_constraint(breakline[i], breakline[i+1]);
}
}
cdt.insert(points.begin(), points.end());
double margin = 50;
cgal_utils::Point bbul(727250.0 - margin, 6880620.0 + margin, 0.0);
cgal_utils::Point bbbl(bbul.x(), bbul.y() - 20000.0 - margin, 0.0);
cgal_utils::Point bbur(bbul.x() + 17000.0 + margin, bbul.y(), bbul.z() + 200.0 + margin);
cgal_utils::Point bbbr(bbul.x() + 17000.0 + margin, bbul.y() - 20000.0 - margin, bbul.z() + 200.0 + margin);
cdt.insert(bbul);
cdt.insert(bbbl);
cdt.insert(bbur);
cdt.insert(bbbr);
std::cout << "Bounding box: " << bbul << " " << bbbr << std::endl;
std::cout << "Refining the " << cdt.number_of_vertices() << " vertices." << std::endl;
std::cout << "Number of points and faces of CDT: "
<< cdt.number_of_vertices() << " " << cdt.number_of_faces() << std::endl;
CGAL::refine_Delaunay_mesh_2(cdt, Criteria(0.1, 0.1));
std::cout << "Number of points and faces of CDT: "
<< cdt.number_of_vertices() << " " << cdt.number_of_faces() << std::endl;
if(saveTriangulation)
{
fs::path outoff(outdir);
outoff /= outfname;
outoff.replace_extension(".off");
std::ofstream outstream1(outoff);
if(!outstream1)
{
std::cerr << "error writing to " << outoff << std::endl;
return EXIT_FAILURE;
}
outstream1 << std::fixed << std::setprecision(4) ;
outstream1 << "OFF\n" << cdt.number_of_vertices()
<< " " << cdt.number_of_faces() << " 0" << std::endl;
std::map<CDT::Vertex_handle,int> indices;
int counter = 0;
for(CDT::Finite_vertices_iterator it = cdt.finite_vertices_begin();
it != cdt.finite_vertices_end(); ++it)
{
//K::Point_3 p = it->point();
//outstream1 << p.x() << " " << p.y() << " " << p.z() << std::endl;
outstream1 << it->point() << std::endl;
indices.insert(std::pair<CDT::Vertex_handle,int>(it, counter++));
}
for(CDT::Finite_faces_iterator it = cdt.finite_faces_begin(); it != cdt.finite_faces_end(); ++it)
{
bool indomain = it->is_in_domain();
if(!indomain)
{
outstream1 << "3 " << indices[it->vertex(0)]
<< " " << indices[it->vertex(1)]
<< " " << indices[it->vertex(2)] << std::endl;
}
}
std::cout << "Saved triangulation at " << outoff << std::endl;
}
return 0;
}
On Fri, Jun 10, 2016 at 6:00 PM, Laurent Rineau (CGAL/GeometryFactory) <> wrote:
Le Friday 10 June 2016 17:28:46 Pol Monsó Purtí a écrit :
> Hello Laurent, thank you for your interest,
>
> *All* the faces are said to be outside the domain, not only those long
> faces. Otherwise I'd be done by checking wether it is in or out. Should I
> check that my cdt constitutes indeed a *planar straight line graph *? Is it
> possible it doesn't at all?
I suggest you insert in the CDT a closed polygon with four vertices, a "box",
that contains all the other ones. That way, you will be sure that everything
is inside the domain bounded by that box.
--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory http://www.geometryfactory.com/
Release Manager of the CGAL Project http://www.cgal.org/
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
Attachment:
edges_cgal.PNG
Description: PNG image
- Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation, Laurent Rineau (CGAL/GeometryFactory), 06/10/2016
- Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation, Pol Monsó Purtí, 06/10/2016
- Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation, Laurent Rineau (CGAL/GeometryFactory), 06/10/2016
- Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation, Pol Monsó Purtí, 06/29/2016
- Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation, Pol Monsó Purtí, 06/29/2016
- Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation, Laurent Rineau (CGAL/GeometryFactory), 06/29/2016
- Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation, Pol Monsó Purtí, 06/29/2016
- Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation, Laurent Rineau (CGAL/GeometryFactory), 06/10/2016
- Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation, Pol Monsó Purtí, 06/10/2016
Archive powered by MHonArc 2.6.18.