开发者

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.50开发者_高级运维0000 -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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜