View Full Version : Triangulating a surface constructed by 3D curves

esapir

02-27-2014, 05:57 AM

I have a 3D polygon (i wonder if polygon is the correct term here) that is constructed from 3D curves. These curves are basically lists of 3D points.

I would like to triangulate this surface so i could draw it using OpenGL.

Are there any recommended algorithms and/or code libraries (preferably in c++) that i could use?

wmelgaard

02-27-2014, 11:36 AM

The example that I provided (creating a sphere from a single triangle strip) in this forum sounds close to what you are trying to do.

assume:

float curve[n][npoints][3]; // this assumes that all curves have the same number of points

int i, j;

curve[i][j][0] = x;

curve[i][j][1] = y;

curve[i][j][2] = z

for(i=0; i , (n-1); i++){

glBegin(GL_TRIANGLE_STRIP);

for(j=0; j < npoints; j++){

glVertex3fv(curve[i]j]);

glVertex(3v([i+1][j]);

}

glEnd();

}

This is just the code fragment that draws the triangles.

If curves intersect (share common vertices) you could have problems. One simple way to avoid that is to move one of those common vertices just a bit.

I have a 3D polygon (i wonder if polygon is the correct term here) that is constructed from 3D curves. These curves are basically lists of 3D points.

I would like to triangulate this surface so i could draw it using OpenGL.

Are there any recommended algorithms and/or code libraries (preferably in c++) that i could use?

esapir

02-27-2014, 03:17 PM

The example that I provided (creating a sphere from a single triangle strip) in this forum sounds close to what you are trying to do.

assume:

float curve[n][npoints][3]; // this assumes that all curves have the same number of points

int i, j;

curve[i][j][0] = x;

curve[i][j][1] = y;

curve[i][j][2] = z

for(i=0; i , (n-1); i++){

glBegin(GL_TRIANGLE_STRIP);

for(j=0; j < npoints; j++){

glVertex3fv(curve[i]j]);

glVertex(3v([i+1][j]);

}

glEnd();

}

This is just the code fragment that draws the triangles.

If curves intersect (share common vertices) you could have problems. One simple way to avoid that is to move one of those common vertices just a bit.

I think this kind of solution will work only for planar polygons. I don't think it will work for real 3D polygons

tonyo_au

02-27-2014, 03:55 PM

I doubt if you will find source code for this. My son was working on a similar project recently for his company. He found quite a few papers on algorithms but had to implement it himself. The basic idea is to expand each edge line into a quad but avoid overlapping quads. For optimum performance and shape definition the quads should be approximately the same area.

esapir

02-27-2014, 04:01 PM

It was also my intuition - that i need to construct quads. However, there are several problems that i am not sure how to solve:

1. Number of points on the curves is not equal and more than that - the distance between every two samples is not the same.

2. I am not sure how this algorithm should work. At first my idea was to start on one of the polygon edges (i cam assume for simplicity that the polygon always has exactly 4 curves) and iteratively build the grid. However, i think that the grid will look different if i will start for different edges. Am i correct? How i should approach to this problem?

wmelgaard

02-27-2014, 08:32 PM

Again without having seen your data, it sounds like the same problem as meshing a Finite Element Analysis (FEA) model. The Finite Element Method Its Basis And Fundamentals , by Ziendiewicz, Taylor & Zhu has an entire chapter on that subject.

It was also my intuition - that i need to construct quads. However, there are several problems that i am not sure how to solve:

1. Number of points on the curves is not equal and more than that - the distance between every two samples is not the same.

2. I am not sure how this algorithm should work. At first my idea was to start on one of the polygon edges (i cam assume for simplicity that the polygon always has exactly 4 curves) and iteratively build the grid. However, i think that the grid will look different if i will start for different edges. Am i correct? How i should approach to this problem?

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.