ovmb.ksy 4.32 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
meta:
  id: ovmb
  title: OVMB (OpenVolumeMesh binary file format)
  file-extension:
    - ovmb
  license: CC0-1.0
  encoding: ASCII
  endian: le
doc:
  OVMB files describe volumetric meshes and associated properties.
doc-ref: http://openvolumemesh.org
seq:

  - id: file_header
    type: file_header
  - id: chunks
    type: chunk
    repeat: eos

enums:
    int_encoding:
        0: none
        1: u8
        2: u16
        4: u32
    vertex_encoding:
        0: none
        1: float
        2: double
    property_entity:
        0: vertex
        1: edge
        2: face
        3: cell
        4: halfedge
        5: halfface
        6: mesh
    topo_type:
        0: polyhedral
        1: tetrahedral
        2: hexahedral
    topo_entity:
        1: edge
        2: face
        3: cell
types:
  file_header:
    seq:
      - id: magic
        contents: ['O', 'V', 'M', 'B', 0xa, 0xd, 0xa, 0xff]
      - id: file_version
        type: u1
      - id: header_version
        type: u1
      - id: vertex_dim
        type: u1
      - id: topo_type
        type: u1
        enum: topo_type
      - id: reserved
        contents: [0, 0, 0, 0]
      - id: n_vertices
        type: u8
      - id: n_edges
        type: u8
      - id: n_faces
        type: u8
      - id: n_cells
        type: u8
  chunk:
    seq:
      - id: type
        type: str
        size: 4
      - id: version
        type: u1
      - id: padding_bytes
        type: u1
      - id: compression
        type: u1
      - id: flags
        type: u1
      - id: file_length
        type: u8
      - id: body
        size: file_length - padding_bytes
        type:
            switch-on: type
            cases:
                '"VERT"': vert_chunk
                '"PROP"': prop_chunk
                '"TOPO"': topo_chunk
                '"DIRP"': propdir_chunk
      - id: padding
        size: padding_bytes
  array_span:
    seq:
      - id: base
        type: u8
      - id: count
        type: u4

  vert_chunk:
    seq:
      - id: span
        type: array_span
      - id: vertex_encoding
        type: u1
        enum: vertex_encoding
      - id: reserved
        contents: [0, 0, 0]
      - id: coordinates
        repeat: expr
        repeat-expr: span.count * _root.file_header.vertex_dim
        type:
          switch-on: vertex_encoding
          cases:
            'vertex_encoding::float': f4
            'vertex_encoding::double': f8

  topo_chunk:
    seq:
      - id: span
        type: array_span

      - id: entity
        type: u1
        enum: topo_entity

      - id: valence
        type: u1
        doc: 0 for variable valence

      - id: valence_encoding
        type: u1
        enum: int_encoding

      - id: handle_encoding
        type: u1
        enum: int_encoding

      - id: handle_offset
        type: u8

      - id: data
        type:
          switch-on: valence
          cases:
            0: topo_data_variable
            _: topo_data_fixed

  topo_data_fixed:
    seq:
      - id: handles
        repeat: expr
        repeat-expr: _parent.span.count * _parent.valence
        type:
          switch-on: _parent.handle_encoding
          cases:
            'int_encoding::u8': u1
            'int_encoding::u16': u2
            'int_encoding::u32': u4


  topo_data_variable:
    seq:
      - id: valences
        repeat: expr
        repeat-expr: _parent.span.count
        type:
          switch-on: _parent.valence_encoding
          cases:
            'int_encoding::u8': u1
            'int_encoding::u16': u2
            'int_encoding::u32': u4
      - id: handles
        type:
          switch-on: _parent.handle_encoding
          cases:
            'int_encoding::u8': u1
            'int_encoding::u16': u2
            'int_encoding::u32': u4



  prop_chunk:
    seq:
      - id: span
        type: array_span
      - id: prop_idx
        type: u4

  propdir_chunk:
    seq:
      - id: entry
        type: propdir_entry
        repeat: eos

  string4:
    seq:
      - id: len
        type: u4
      - id: data
        type: str
        encoding: UTF-8
        size: len

  bytes4:
    seq:
      - id: len
        type: u4
      - id: data
        size: len



  propdir_entry:
    seq:
      - id: entity
        type: u1
        enum: property_entity
      - id: name
        type: string4
      - id: data_type_name
        type: string4
      - id: serialized_default
        type: bytes4