8000 GitHub - PeterZs/CDT: C++ library for constrained Delaunay triangulation (CDT)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PeterZs/CDT

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CDT: Constrained Delaunay Triangulation

Please ★ this repository if it helped. This means a lot to the authors :)

C++ implementation of constrained Delaunay triangulation (CDT)

  • numerically robust (uses robust geometric predicates)
  • header-only (default)
  • using as compiled library is possible by defining CDT_USE_AS_COMPILED_LIBRARY
  • permissively-licensed (MPL-2.0)
  • compatible with C++03
  • cross-platform: tested on Windows and Linux

Table of Contents

Description

  • Uses William C. Lenthe's implementation of robust orientation and in-circle geometric predicates: https://github.com/wlenthe/GeometricPredicates.

  • Optionally depends on Boost for rtree implementation (finding closest point) and fall back for some std types on pre-C++11 compilers. Boost dependency can be easily be removed via defining CDT_DONT_USE_BOOST_RTREE. This replaces nearestVertexRtree with slower nearestVertexRand.

  • A demonstrator tool is included: requires Qt for GUI. When running demo-tool make sure that working directory contains folder test files.

Algorithm

Implementation closely follows incremental construction algorithm by Anglada [1]. During the legalization, the cases when at least one vertex belongs to super-triangle are resolved using an approach as described in Žalik et. al [2]. For efficient search of a triangle that contains inserted point randomized walking search is applied [3]. To find the starting triangle we first find the nearest point using boost::rtree or using a closest random point.

Input pre-conditions:

  • No duplicated points
  • No two constraint edges intersect each other

Installing

As header-only

No installation is needed. For the demonstrator tool qmake project file is used. It could either be opened in QtCreator directly, or qmake can be used to generate project files (e.g., makefiles or MSVC-project)

As compiled library

Define CDT_USE_AS_COMPILED_LIBRARY and compile CDT.cpp

Using

Synopsis

namespace CDT
{

struct FindingClosestPoint
{
    enum Enum
    {
#ifndef CDT_DONT_USE_BOOST_RTREE
        BoostRTree,
#endif
        ClosestRandom,
    };
};

template <typename T>
class Triangulation
{
public:
    /*____ Data ____*/
    std::vector<Vertex<T> > vertices;
    std::vector<Triangle> triangles;
    EdgeUSet fixedEdges;
    /*____ API _____*/
    Triangulation(
        const FindingClosestPoint::Enum closestPtMode,
        const size_t nRandSamples = 10);
    void insertVertices(const std::vector<V2d<T> >& vertices);
    void insertEdges(const std::vector<Edge>& edges);
    void eraseSuperTriangle();
    void eraseOuterTriangles();
    // ...
}

} // namespace CDT

Triangulated convex-hull example

#include "CDT.h"
using Triangulation = CDT::Triangulation<float>;

Triangulation cdt = 
    Triangulation(CDT::FindingClosestPoint::BoostRTree);
/* 
  // Without boost::rtree:
  Triangulation(CDT::FindingClosestPoint::ClosestRandom, 10);
*/
cdt.insertVertices(/* points */);
cdt.eraseSuperTriangle();
/* ... */ = cdt.vertices;
/* ... */ = cdt.edges;

Triangulated region constrained by boundary example

// ... same as above
cdt.insertVertices(/* points */);
cdt.insertEdges(/* boundary edges */);
cdt.eraseOuterTriangles();
/* ... */ = cdt.vertices;
/* ... */ = cdt.edges;

Contributors

Karl Åkerblom: algorithm implementation, triangle walking

Contributing

Any feedback and contributions are welcome.

License

Mozilla Public License, v. 2.0

Examples

A Bean Guitar Lake Superior Sweden

Bibliography

[1] Marc Vigo Anglada, An improved incremental algorithm for constructing restricted Delaunay triangulations, Computers & Graphics, Volume 21, Issue 2, 1997, Pages 215-223, ISSN 0097-8493.

[2] Borut Žalik and Ivana Kolingerová, An incremental construction algorithm for Delaunay triangulation using the nearest-point paradigm, International Journal of Geographical Information Science, Volume 17, Issue 2, Pages 119-138, 2003, DOI 10.1080/713811749.

[3] Olivier Devillers, Sylvvain Pion, Monique Tellaud, Walking in a triangulation, International Journal of Foundations of Computer Science, Volume 13, Issue 2, Pages 181-199, 2002

About

C++ library for constrained Delaunay triangulation (CDT)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.6%
  • QMake 0.4%
0