ply檔案格式詳細說明

2021-07-10 09:30:19 字數 4147 閱讀 9734

典型的   ply   檔案結構:

頭部頂點列表

麵片列表

(其他元素列表)

頭部是一系列以回車結尾的文字行,用來描述檔案的剩餘部分。頭部包含乙個對每個元素型別的描述,包括元素名(如「邊」),這個元素在工程裡有多少,以及一 個與這個元素關聯的不同屬性的列表。頭部還說明這個檔案是二進位制的或者是ascii的。頭部後面的是乙個每個元素型別的元素列表,按照在頭部中描述的順序 出現。

plyformat   ascii   1.0  

comment   this   file   is   a   cube

element   vertex   8  

property   float32   x  

property   float32   y  

property   float32   z  

element   face   6  

property   list   uint8   int32   vertex_index  

end_header  

0   0   0  

0   0   1

0   1   1

0   1   0

1   0   0

1   0   1

1   1   1

1   1   0

4   0   1   2   3  

4   7   6   5   4

4   0   4   5   1

4   1   5   6   2

4   2   6   7   3

4   3   7   4   0

element   《元素名》   《在檔案中的個數》

property   《資料型別》   《屬性名-1>

property   《資料型別》   《屬性名-2>

property   《資料型別》   《屬性名-3>

...屬性羅列在「element」(元素)行後面定義,既包含屬性的資料型別也包含屬性在每個元素中出現的次序。乙個屬性可以有三種資料型別:標量,字串和列表。屬性可能具有的標量資料型別列表如下:

名稱   型別   位元組數

-------------------------------

int8   字元   1

uint8   非負字元   1

int16   短整型   2

uint16   非負短整型   2

int32   整型   4

uint32   非負整型   4

float32   單精度浮點數   4

float64   雙精度浮點數   8

這些位元組計數很重要,而且在實現過程中不能修改以使這些檔案可移植。使用列表資料型別的屬性定義有一種特殊的格式:

property   list   《數值型別》   《數值型別》   《屬性名》

這種格式的一類例子是上面的立方體檔案中的:

property   list   uint8   int32   vertex_index

這表示屬性「vertex_index」首先包含乙個非負字元報蘇在屬性裡包含多少索引,接下來是乙個列表包含許多整數。在這個邊長列表裡的每個整數都是乙個頂點的索引。

另外乙個例子

------------

另外乙個立方體定義:

plyformat   ascii   1.0

comment   author:   anonymous

comment   object:   another   cube

element   vertex   8

property   float32   x

property   float32   y

property   float32   z

property   red   uint8  

property   green   uint8

property   blue   uint8

element   face   7

property   list   uint8   int32   vertex_index  

element   edge   5  

property   int32   vertex1  

property   int32   vertex2  

property   uint8   red  

property   uint8   green

property   uint8   blue

end_header

0   0   0   255   0   0  

0   0   1   255   0   0

0   1   1   255   0   0

0   1   0   255   0   0

1   0   0   0   0   255

1   0   1   0   0   255

1   1   1   0   0   255

1   1   0   0   0   255

3   0   1   2  

3   0   2   3  

4   7   6   5   4  

4   0   4   5   1

4   1   5   6   2

4   2   6   7   3

4   3   7   4   0

0   1   255   255   255  

1   2   255   255   255

2   3   255   255   255

3   0   255   255   255

2   0   0   0   0  

這個檔案為每個頂點指定乙個紅、綠、藍值。為了說明變長vertex_index(頂點索引)的能力,物體的頭兩個麵片是兩個三角形而不是乙個四邊形。這 意味著物體的麵片數是7。這個物體還包括乙個邊列表。每條邊包括兩個指向說明邊的頂點的指標。每條邊也有一種顏色。上面定義的五條邊指定了顏色,使檔案裡 的兩個三角形高亮。前四條邊白色,它們包圍兩個三角形。最後一條邊是黑的,他是分割三角形的邊。

使用者定義元素

------------

上面的例子顯示了頂點、麵片和邊三種元素的用法。ply   格式同樣允許使用者定義它們自己的元素。定義新元素的格式於頂點、麵片和邊相同。這是頭部定義材料屬性的部分:

element   material   6

property   ambient_red   uint8  

property   ambient_green   uint8

property   ambient_blue   uint8

property   ambient_coeff   float32

property   diffuse_red   uint8  

property   diffuse_green   uint8

property   diffuse_blue   uint8

property   diffuse_coeff   float32

property   specular_red   uint8  

property   specular_green   uint8

property   specular_blue   uint8

property   specular_coeff   float32

property   specular_power   float32  

這些行應該在頭部頂點、麵片和邊的說明後直接出現。如果我們希望每個頂點有乙個材質說明,我們可以將這行加在頂點屬性末尾:

property   material_index   int32

這個整數現在是乙個到檔案內包含的材質列表的索引。這可能誘使乙個新應用的作者編制一些信的元素儲存在   ply   檔案中。這個練習應該保持在最小。試著將普通元素(頂點、麵片、邊、材質)改編用於新用途更好,使得其他能夠讀懂這些元素的程式在操作這些改編過的元素時 更有用。比如,乙個將分子描述成球體和圓柱體集合的應用。這將需要在包含分子的   ply   檔案裡定義球體和圓柱體元素。然而,如果我們為了這個目的使用頂點和邊元素(為每個新增半徑屬性),我們可以利用操作和顯示頂點和邊的程式。無疑不應該為 三角形和四邊形建立特殊元素,而應該使用麵片元素。

ply檔案格式詳細說明

典型的 ply 檔案結構 頭部 頂點列表 麵片列表 其他元素列表 頭部是一系列以回車結尾的文字行,用來描述檔案的剩餘部分。頭部包含乙個對每個元素型別的描述,包括元素名 如 邊 這個元素在工程裡有多少,以及一 個與這個元素關聯的不同屬性的列表。頭部還說明這個檔案是二進位制的或者是ascii的。頭部後面...

scandef格式詳細說明

1 scan chain number 例子 scanchains 8 表示stub chain的個數,與設計中的實際scan chain個數不一定相同。例如,因retiming dff的插入,一條實際的scan chain在scandef中可能被拆分成兩條stub chain。該類stub cha...

Format格式詳細說明

rust中一系列的巨集,如 println format write writeln 等,都是用的同樣的格式控制規則 fn main 1 預設用法,列印display println 9 八進位制 println 255 十六進製制 小寫 println 255 十六進製制 大寫 println 0...