Actionhank
January 18th, 2006, 07:17 AM
i need to extract edges out of a 3d model stored in a stl file. the stl format consists of triangles
(three points and the normal vector represent a triangle).
thus the whole object is stored in a set of triangles.
following tasks:
- dont get edges twice, e.g. two connected triangles have one line in common
-eliminate edges, that are not edges of the object, e.g. a square of a model is represented by two triangles. but the diagonal line is no edge of the object. this can be found by adding the normalvector of the corresponding triangle as parameter to every line that is constructed out of this triangle. if a line is found twice and both have the same normal vector, erase the lines.
i have a class for extracting edges out of a stl file, but i think its not very efficient. it consists of 3 lists (list of points, list of edges and list of normal vectors). for every new triangle the list of points is scanned for all three points. if one of the point is already in the list, the point is not added, otherwise its added. same with the normal vector list.
the edges consists only of 2 indices to list line and one to list normal vector (overall 3 indices in every element of list edge).
the three edges are created with the corresponding indices.
the edges are only added to list of edges if they are not already in the list, i.e. all 3 indices are equal ( thus both points are equal and the normal vector). if already in list, dont add edge AND erase the equal edge
(becaus its no edge of object)
after this the list of edges is scanned another time to remove duplicates
(lines that dont have the same normalvector but same points)
what bothers me is that no sorting is used at all.
what i have in mind is first to use two double linked lists of points and lines.
then sort the list of points and then travers the list, comparing the elements. if points are equal go to corresponding lines and check if lines have same normalvector and/or same corresponding point.
thx
Actionhank
(three points and the normal vector represent a triangle).
thus the whole object is stored in a set of triangles.
following tasks:
- dont get edges twice, e.g. two connected triangles have one line in common
-eliminate edges, that are not edges of the object, e.g. a square of a model is represented by two triangles. but the diagonal line is no edge of the object. this can be found by adding the normalvector of the corresponding triangle as parameter to every line that is constructed out of this triangle. if a line is found twice and both have the same normal vector, erase the lines.
i have a class for extracting edges out of a stl file, but i think its not very efficient. it consists of 3 lists (list of points, list of edges and list of normal vectors). for every new triangle the list of points is scanned for all three points. if one of the point is already in the list, the point is not added, otherwise its added. same with the normal vector list.
the edges consists only of 2 indices to list line and one to list normal vector (overall 3 indices in every element of list edge).
the three edges are created with the corresponding indices.
the edges are only added to list of edges if they are not already in the list, i.e. all 3 indices are equal ( thus both points are equal and the normal vector). if already in list, dont add edge AND erase the equal edge
(becaus its no edge of object)
after this the list of edges is scanned another time to remove duplicates
(lines that dont have the same normalvector but same points)
what bothers me is that no sorting is used at all.
what i have in mind is first to use two double linked lists of points and lines.
then sort the list of points and then travers the list, comparing the elements. if points are equal go to corresponding lines and check if lines have same normalvector and/or same corresponding point.
thx
Actionhank