PDA

View Full Version : Algorithm that finds the amount of vertices in an object


Garma
06-09-2006, 06:14 PM
folks,

I need an algorithm that, given a certain polygonal object, can find out how many vertices the polygon has. The object consists of faces, edges and vertices. An edge has 2 vertices but a vertice kan have an unknown amount of edges. The data model I am using is hierarchical:

Bodies contain Faces, which contain Loops (linked lists of Edges that define the edge of a Face). Those edges exist of 2 vertices. This means that vertices can be the same, but be defined multiple times (for every edge). I can compare them to find matching locations but that is going to be pretty exhausting.

This is for an assignment, so I cannot change the dataa model. I need a way that traverses the model. Oh and please don't give me Euler, the assignment is to prove the correctness of Euler :)

Any pointers are most welcome.

noon
06-09-2006, 11:21 PM
Not asking you to change the data model, but just I try to understand :
Are edges pointing to a vertex or do they directly contains vertex coord ?

struct Edge
{
Vertex* v1;
Vertex* v2;
};

OR

struct Edge
{
Vertex v1;
Vertex v2;
};

OR

struct Edge
{
int v1; // vertex 1 index in a table
int v2; // vertex 2 index in a table
};

- Can you explain what is the Euler method ?

Thanks

bdx
06-10-2006, 07:28 AM
noon, see this:
http://en.wikipedia.org/wiki/Euler-Poincaré_characteristic

I'd just put all those vertices in a hash table.

CGTalk Moderation
06-10-2006, 07:28 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.