English 中文(简体)
Reading in polygons from a Object File Format (.off) file
原标题:

I need to read in a list of polygons from a Object File Format (.off) file (in c++). The format of .off files is basically like this:

Header infomation
x y z //co-ords for each vertex
...
NVertices v1 v2 v3 ... vN //Number of vertices for each polygon,
                          //followed by each vertex s index
...

.off files allow any number of vertices per polygon, which brings me to my question. How do you know which vertices are connected to which? For eg, if the .off file read:

Header stuff
-0.500000 -0.500000 0.500000
0.500000 -0.500000 0.500000
-0.500000 0.500000 0.500000
0.500000 0.500000 0.500000
-0.500000 0.500000 -0.500000
0.500000 0.500000 -0.500000
-0.500000 -0.500000 -0.500000
0.500000 -0.500000 -0.500000
4 0 1 3 2
4 2 3 5 4
4 4 5 7 6
4 6 7 1 0
4 1 7 5 3
4 6 0 2 4

The polygons are four sided, but not all vertices are connected. If you simply connect each vertex to each other vertex, you end up with four three sided polygons instead of one four sided polygon. I was hoping vertices were listed in a way similar to cycle notation, but I can t seem to find any information on this, so I m guessing not.

So my question is:
Is there any format that .off files use to show this connection? If not, is there any other way to determine which vertices are connected in an .off file?

问题回答

In an .off file, each polygon s vertices are connected sequentially in their listed order, with the last one connecting back to the first. In your example, the first polygon has 4 vertices, listed as "0 1 3 2", which means there are connections (i.e. edges) from 0 to 1, from 1 to 3, from 3 to 2, and from 2 back to 0.





相关问题
point in a self-intersecting / complex polygon

I ve read How can I determine whether a 2D Point is within a Polygon? but I m not sure if the solution would apply to a polygon that is divided down the middle by an interior segment. Think of a ...

In PostGIS, how do I find all points within a polygon?

I am using PostgreSQL with the GIS extension to store map data, together with OpenLayers, GeoServer etc. Given a polygon, e.g. of a neighborhood, I need to find all LAT/LONG points stored in some ...

Algorithm for fitting 2D polygons in an area?

Is there a standard for this? Algorithm name? Say: I have 10 polygons of different sizes. I have an area of specific size. I want to know how to fill the most polygons in that area, and how they are ...

Draw a polygon in C

i need to draw a polygon of "n" sides given 2 points (the center and 1 of his vertex) just that i suck in math. I have been reading a lot and all this is what i have been able to figure it (i dont ...

Generate new polygons from a cut polygon (2D)

I m stuck with this little problem and my algorithm to solve this doesn t hold for all cases. Does anybody has an idea how to solve this? Here s an example polygon: example http://img148.imageshack....

Any free polygon library for the iPhone?

I need a library that can manage polygon modeling and basic transformation like rotating and translating. I d rather not redevelop everything from scratch Thanks

Delete holes in a Polygon

I have a polygon determined by an Array of Points. This polygon is crossing itself making some holes in the polygon itself. My questions is: How can I omit this holes and just get the exterior ...

热门标签