Ich lerne gerade, 3D-Triangulation mit CGAL durchzuführen, und bisher habe ich es geschafft, ein regelmäßiges Tetraeder durch Einfügen und Triangulieren von 4 Vertices zu erstellen. Aber wenn ich versuche, über die Kanten des Tetraeders zu schleifen und die Scheitelpunkte zu erhalten, die dieser Kante entsprechen, bekomme ich den Ursprung als Scheitelpunkt oder Duplikate der vorherigen Kanten. In 2D funktioniert alles gut, aber in 3D läuft alles schief. Ich denke, das hängt damit zusammen, dass ein unendlicher/undefinierter Knoten enthalten ist, aber ich weiß nicht, wie ich damit umgehen soll. Jede Hilfe wäre willkommen.CGAL Triangulation Edge Iterator enthält Ursprung
Mein Code (von this question modifizierte):
#include <vector>
#include <iostream>
#include <cmath>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_3<K> Delaunay;
typedef K::Point_3 Point;
void load_points(std::vector<Point>& rPoints)
{
rPoints.push_back(Point(1.0, 0.0, -1.0/sqrt(2))); // first point
rPoints.push_back(Point(-1.0, 0.0, -1.0/sqrt(2))); // second point
rPoints.push_back(Point(0.0, 1.0, 1.0/sqrt(2))); // third point
rPoints.push_back(Point(0.0, -1.0, 1.0/sqrt(2))); // fourth point
}
int main()
{
std::vector<Point> points;
load_points(points);
Delaunay dt;
dt.insert(points.begin(),points.end());
for(Delaunay::Finite_edges_iterator it = dt.finite_edges_begin(); it != dt.finite_edges_end(); ++it)
{
Point i1= it->first->vertex((it->second+1)%3)->point();
Point i2= it->first->vertex((it->second+2)%3)->point();
std::cout << "i1: " << i1 << "\t i2: " << i2 << "\n";
}
return 0;
}