Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Infinite vertex in Triangulations

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Infinite vertex in Triangulations


Chronological Thread 
  • From: "Daniel Weber" <>
  • To:
  • Subject: Re: [cgal-discuss] Infinite vertex in Triangulations
  • Date: Thu, 21 Jan 2010 16:50:02 +0100

Hi Nico,

please find attached the code for the construction of the triangulation and
the example file "examples.tet". Unfortunately, i am not familiar with with
topological properties of meshes. That is why i asked, if the tds can
represent every triangulation of a domain. The ".tet"-file is an indirect
output of the 3D-Mesh Generation package. Maybe you can tell me, if the
attached mesh can not be used for the CGAL-tds.

Thank you!
Daniel


-------- Original-Nachricht --------
> Datum: Tue, 19 Jan 2010 20:02:39 +0100
> Von: Nico Kruithof
> <>
> An:
>
> Betreff: Re: [cgal-discuss] Infinite vertex in Triangulations

> Hi Daniel,
>
> I wrote the incremental builder for the skin surface package where I had
> to
> construct a triangulation from cells and incidence relations. In that
> setting the triangulation is always topologically a sphere. I can have a
> look if you present a small example.
>
> Bests,
> Nico
>
> On Tue, Jan 19, 2010 at 6:26 PM, Daniel Weber
> <>
> wrote:
>
> > Hi,
> >
> > i use the incremental builder
> (CGAL/Triangulation_incremental_builder_3.h)
> > to reconstruct the adjacency information. This algorithm crashes during
> the
> > reconstruction of inifite cell adjacency. Now, I want to find out why
> > "Triangulation_incremental_builder_3" crashes. Maybe I should post a
> minimal
> > code snipplet, which causes this crash.
> >
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>

--
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_3.h>
#include <CGAL/Triangulation_cell_base_with_info_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <CGAL/Triangulation_incremental_builder_3.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

typedef
CGAL::Triangulation_data_structure_3<CGAL::Triangulation_vertex_base_with_info_3<int,K>,

CGAL::Triangulation_cell_base_with_info_3<int, K> >
Triangulation_data_structure;

typedef CGAL::Triangulation_3<K, Triangulation_data_structure > Triangulation;


typedef Triangulation::Cell_handle Cell_handle;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Point Point;
typedef Triangulation::Facet Facet;
typedef Triangulation::Cell_circulator Cell_circulator;

using namespace std;

#include <iostream>
#include <string>
#include <fstream>

bool load(const std::string& fileName, std::vector<int>& tets,
std::vector<Point>& points)
{
// variables
size_t i, num_materials, num_vertices, num_tetras, num_triangles;
float value;
string line, label;
stringstream sStream;
// try to open the file
ifstream fin(fileName.c_str());
if(!fin)
return false;
// load tet version 1.2
getline(fin, line);
sStream << line;
sStream >> label; // tet
sStream >> label; // version
sStream >> value;
sStream.clear();
// load number of materials
getline(fin, line); // num_materials x
sStream << line;
sStream >> label;
sStream >> num_materials;
sStream.clear();
// load number of vertices
getline(fin, line); // num_vertices x
sStream << line;
sStream >> label;
sStream >> num_vertices;
sStream.clear();
// reverse the order of the vertices
points.reserve(num_vertices);
// read number of tetraeders
getline(fin, line); // num_tetras x
sStream << line;
sStream >> label;
sStream >> num_tetras;
sStream.clear();
// read number of triangles
getline(fin, line); // num_triangles x
sStream << line;
sStream >> label;
sStream >> num_triangles;
sStream.clear();
// reverse the order of the tetraeders
tets.reserve(num_tetras);
// skip materials
getline(fin, line);
for(i = 0; i < num_materials; ++i)
getline(fin, line);
// skip the VERTICES label
getline(fin, line);
// read the vertices

for(i = 0; i < num_vertices; ++i)
{
float x, y, z;
getline(fin, line);
sStream << line;
sStream >> x >> y >> z;
getline(sStream, line);
sStream.clear();

points.push_back(Point(x,y,z));
}
// skip TETRAS label
getline(fin, line);
// read tets

for(i = 0; i < num_tetras; ++i)
{
int v0,v1,v2,v3;
int m;
getline(fin, line);
sStream << line;
sStream >> v0 >> v1 >> v2 >> v3 >> m;
getline(sStream, line);
sStream.clear();

tets.push_back(v0);
tets.push_back(v1);
tets.push_back(v2);
tets.push_back(v3);
}
// close file
fin.close();
// finished
return true;
}

void createCGALTriangulation(const std::vector<Point> & points,const
std::vector<int> tets,Triangulation& T)
{
// variables
//size_t i = 0;
// perform orientation check
//bool ccw0 = computeOrientation(points[4 * tets[i] + 0],points[4 *
tets[i] + 1],points[4 * tets[i] + 2],points[4 * tets[i] + 3]);

//for(size_t i = 1; i < tets.size() / 4; ++i)
//{
// if(computeOrientation(points[4 * tets[i] + 0]],points[4 *
tets[i] + 1],points[[4 * tets[i] + 2]],points[4 * tets[i] + 3])
// {
// throw MeshLoaderException("Tets orientation test
failed!!!");
// }
//}

// create incremental builder
CGAL::Triangulation_incremental_builder_3<Triangulation> builder(T,
true);
builder.begin_triangulation(3);
// add the vertices to the incremental builder object and store the
vertex handles
vector<Vertex_handle> vertex_handles(points.size());

for(size_t i = 0; i < points.size(); ++i)
{
vertex_handles[i] = builder.add_vertex();
vertex_handles[i]->set_point(points[i]);
}
// now add the tets
for(size_t i = 0; i < tets.size() / 4; ++i)
{
Cell_handle c;
//if(ccw0)
{
c = builder.add_cell(vertex_handles[tets[4*i+0]],
vertex_handles[tets[4*i+1]],
vertex_handles[tets[4*i+2]],
vertex_handles[tets[4*i+3]]);
}
//else
//{
// c = builder.add_cell(vertex_handles[tets[4*i+1]],
// vertex_handles[tets[4*i+0]],
// vertex_handles[tets[4*i+2]],
// vertex_handles[tets[4*i+3]]);
//}
}
// finished
builder.end_triangulation();
}


int main()
{
std::string filename = "example.tet";
std::vector<int> tets;
std::vector<Point> points;
load(filename, tets, points);

Triangulation T;
createCGALTriangulation(points, tets, T);

T.is_valid();

return 0;
}

Attachment: example.tet
Description: Binary data




Archive powered by MHonArc 2.6.16.

Top of Page