-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing element in triangulation of point cloud due to small super-triangle #37
Comments
Hello, @AndreFecteau Thank you very much for the issue and a detailed description with an example! :) If any vertex belongs to the super-triangle during edge-flip test: algorithm should treat this as a special case and handle it appropriately. So the size of the super-triangle should not matter. I will check if there is a bug in that special-case handling. |
Previously flip was rejected only if both vertices of flip-candidate belong to the super-tri. The change rejects the flip if at least one vertex belongs to super-tri and original edge does not touch super-tri. If both original edge and flipped edge touch super-tri: use normal circumference test as a tie-breaker.
The bug was there indeed, thank you again :) Please check this PR: #38 |
Thanks for the quick fix, I will try this in the next few days. |
I ran it through all the benchmarks and the fix seemed to have worked. Thanks a lot!! |
@AndreFecteau May I ask what did you compare CDT with and how did it compare? This is very interesting :) |
Previously flip was rejected only if both vertices of flip-candidate belong to the super-tri. The change rejects the flip if at least one vertex belongs to super-tri and original edge does not touch super-tri. If both original edge and flipped edge touch super-tri: use normal circumcircle test as a tie-breaker. Add two test files for regression testing.
Previously flip was rejected only if both vertices of flip-candidate belong to the super-tri. The change rejects the flip if at least one vertex belongs to super-tri and original edge does not touch super-tri. If both original edge and flipped edge touch super-tri: use normal circumcircle test as a tie-breaker. Add two test files for regression testing.
@artem-ogre These numbers are only meant to be a rough measurement. Note that not all these libraries are reliable or support general constrained Delaunay triangulation.
10x10
20x20 100x100 100x1000
1000x1000
10x10
100x100 100x1000
500x500 |
@AndreFecteau Is CDT using boost with |
And if yes, does it use |
Yes CDT_USE_BOOST is enabled, I attached a flame graph of the benchmark 500x500. While I don't have experience with nearest neighbour search in point tree, I've always found that Boost::RTree access iterators are quite expensive for simple shapes. Have you tried using a Oct Tree or kd-Tree for this section of the code? |
Really appreciate the input, thank you! I will look into it as soon as I get some free time. I will open a new issue for this. |
@AndreFecteau Flame GraphBenchmarked code#include "CDT.h"
typedef double CoordType;
typedef CDT::Triangulation<CoordType> Triangulation;
typedef CDT::V2d<CoordType> V2d;
typedef CDT::Vertex<CoordType> Vertex;
typedef CDT::Triangle Triangle;
typedef CDT::Box2d<CoordType> Box2d;
typedef CDT::Edge Edge;
#include <chrono>
#include <iostream>
int main(int argc, char* argv[])
{
const size_t N = 1000;
std::vector<V2d> vertices;
vertices.reserve(N * N);
for(size_t i = 0; i < N; ++i)
{
for(size_t j = 0; j < N; ++j)
{
vertices.push_back(V2d::make(i * 1e-5, j * 1e-5));
}
}
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::high_resolution_clock;
using std::chrono::milliseconds;
auto t1 = high_resolution_clock::now();
Triangulation triangulation(CDT::FindingClosestPoint::BoostRTree);
triangulation.insertVertices(vertices);
auto t2 = high_resolution_clock::now();
/* Getting number of milliseconds as an integer. */
auto ms_int = duration_cast<milliseconds>(t2 - t1);
std::cout << ms_int.count() << "ms\n";
return 0;
} |
Recently I have been evaluating constrained Delaunay triangulation libraries and have stumbled onto this gem. During my testing of this tool I have encountered one triangulation where I believe is not the desired output but due to having the super-triangle being too small for the point cloud. Here is the point cloud that causes the issue also attached you can find the visualization of the triangulation including the super-triangle and missing edge in red.
PointCloudTriangulation.pdf
The text was updated successfully, but these errors were encountered: