Missing face in imported ply model file.

The ply model file below illustrates a problem which I think may be an issue for ModelIO.

If you save to a file and then add the file to a new xcode project (10.0 beta 6 or 9.4.1 show same issue)

you will see a simple figure. BUT, note that the number of faces is shown as 25 (the line: element face 25). The 25th face actually has 0 vertices.

That is the last line of the file with just one number: 0.


This 25 count is a hack to the original file and a workaround. If you change the face count to the number of real faces (24) you

will see that the 24th face is missing from the figure. You don't need an app to see this issue because it shows up in xcode.

But I have a Metal/ModelIO app that displays this figure and that app shows the same problem. The last face is always missing.


Any ideas what is going on?


-------------- data file starts on next line (save it to test.ply)

ply

format ascii 1.0

comment Created by

element vertex 72

property float x

property float y

property float z

property float nx

property float ny

property float nz

property uchar red

property uchar green

property uchar blue

element face 25

property list uchar uint vertex_indices

end_header

-5.0 0.0 0.0 0.0 -1.0 0.0 255 0 0 comment 0 back t0

5.0 0.0 0.0 0.0 -1.0 0.0 255 0 0 comment 1 back t0

5.0 0.0 2.0 0.0 -1.0 0.0 255 0 0 comment 2 back t0

5.0 0.0 2.0 -0.0 -1.0 0.0 255 0 0 comment 3 back t1

-5.0 0.0 2.0 -0.0 -1.0 0.0 255 0 0 comment 4 back t1

-5.0 0.0 0.0 -0.0 -1.0 0.0 255 0 0 comment 5 back t1

5.0 0.0 0.0 0.89442724 -0.44721362 0.0 63 8 32 comment 6 right side t0

7.0 4.0 2.0 0.89442724 -0.44721362 0.0 63 8 32 comment 7 right side t0

5.0 0.0 2.0 0.89442724 -0.44721362 0.0 63 8 32 comment 8 right side t0

7.0 4.0 2.0 0.89442724 -0.44721362 0.0 63 8 32 comment 9 right side t1

5.0 0.0 0.0 0.89442724 -0.44721362 0.0 63 8 32 comment 10 right side t1

7.0 4.0 0.0 0.89442724 -0.44721362 0.0 63 8 32 comment 11 right side t1

7.0 4.0 0.0 0.0 1.0 0.0 127 16 64 comment 12 right-most front t0

4.5 4.0 0.0 0.0 1.0 0.0 127 16 64 comment 13 right-most front t0

4.5 4.0 2.0 0.0 1.0 0.0 127 16 64 comment 14 right-most front t0

4.5 4.0 2.0 -0.0 1.0 0.0 127 16 64 comment 15 right-most front t1

7.0 4.0 2.0 -0.0 1.0 0.0 127 16 64 comment 16 right-most front t1

7.0 4.0 0.0 -0.0 1.0 0.0 127 16 64 comment 17 right-most front t1

4.5 4.0 0.0 0.70710677 0.70710677 0.0 191 24 96 comment 18 right front diagonal t0

2.5 6.0 0.0 0.70710677 0.70710677 0.0 191 24 96 comment 19 right front diagonal t0

2.5 6.0 2.0 0.70710677 0.70710677 0.0 191 24 96 comment 20 right front diagonal t0

2.5 6.0 2.0 0.70710677 0.70710677 0.0 191 24 96 comment 21 right front diagonal t1

4.5 4.0 2.0 0.70710677 0.70710677 0.0 191 24 96 comment 22 right front diagonal t1

4.5 4.0 0.0 0.70710677 0.70710677 0.0 191 24 96 comment 23 right front diagonal t1

2.5 6.0 0.0 0.0 1.0 0.0 255 32 128 comment 24 front t0

-2.5 6.0 0.0 0.0 1.0 0.0 255 32 128 comment 25 front t0

-2.5 6.0 2.0 0.0 1.0 0.0 255 32 128 comment 26 front t0

-2.5 6.0 2.0 -0.0 1.0 0.0 255 32 128 comment 27 front t1

2.5 6.0 2.0 -0.0 1.0 0.0 255 32 128 comment 28 front t1

2.5 6.0 0.0 -0.0 1.0 0.0 255 32 128 comment 29 front t1

-2.5 6.0 0.0 -0.70710677 0.70710677 0.0 63 40 160 comment 30 left front diagonal t0

-4.5 4.0 0.0 -0.70710677 0.70710677 0.0 63 40 160 comment 31 left front diagonal t0

-4.5 4.0 2.0 -0.70710677 0.70710677 0.0 63 40 160 comment 32 left front diagonal t0

-4.5 4.0 2.0 -0.70710677 0.70710677 0.0 63 40 160 comment 33 left front diagonal t1

-2.5 6.0 2.0 -0.70710677 0.70710677 0.0 63 40 160 comment 34 left front diagonal t1

-2.5 6.0 0.0 -0.70710677 0.70710677 0.0 63 40 160 comment 35 left front diagonal t1

-4.5 4.0 0.0 0.0 1.0 0.0 127 48 192 comment 36 left-most front t0

-7.0 4.0 0.0 0.0 1.0 0.0 127 48 192 comment 37 left-most front t0

-7.0 4.0 2.0 0.0 1.0 0.0 127 48 192 comment 38 left-most front t0

-7.0 4.0 2.0 -0.0 1.0 0.0 127 48 192 comment 39 left-most front t1

-4.5 4.0 2.0 -0.0 1.0 0.0 127 48 192 comment 40 left-most front t1

-4.5 4.0 0.0 -0.0 1.0 0.0 127 48 192 comment 41 left-most front t1

-5.0 0.0 0.0 -0.8944271 -0.44721356 0.0 191 56 224 comment 42 left side t0

-7.0 4.0 2.0 -0.8944271 -0.44721356 0.0 191 56 224 comment 43 left side t0

-7.0 4.0 0.0 -0.8944271 -0.44721356 0.0 191 56 224 comment 44 left side t0

-7.0 4.0 2.0 -0.8944271 -0.44721356 0.0 191 56 224 comment 45 left side t1

-5.0 0.0 0.0 -0.8944271 -0.44721356 0.0 191 56 224 comment 46 left side t1

-5.0 0.0 2.0 -0.8944271 -0.44721356 0.0 191 56 224 comment 47 left side t1

-5.0 0.0 0.0 0.0 0.0 -1.0 255 64 0 comment 48 bottom center t0

-7.0 4.0 0.0 0.0 0.0 -1.0 255 64 0 comment 49 bottom center t0

7.0 4.0 0.0 0.0 0.0 -1.0 255 64 0 comment 50 bottom center t0

7.0 4.0 0.0 0.0 0.0 -0.99999994 255 64 0 comment 51 bottom center t1

5.0 0.0 0.0 0.0 0.0 -0.99999994 255 64 0 comment 52 bottom center t1

-5.0 0.0 0.0 0.0 0.0 -0.99999994 255 64 0 comment 53 bottom center t1

4.5 4.0 0.0 0.0 0.0 -1.0 63 72 32 comment 54 bottom front stage t0

-2.5 6.0 0.0 0.0 0.0 -1.0 63 72 32 comment 55 bottom front stage t0

2.5 6.0 0.0 0.0 0.0 -1.0 63 72 32 comment 56 bottom front stage t0

-2.5 6.0 0.0 0.0 0.0 -1.0 63 72 32 comment 57 bottom front stage t1

4.5 4.0 0.0 0.0 0.0 -1.0 63 72 32 comment 58 bottom front stage t1

-4.5 4.0 0.0 0.0 0.0 -1.0 63 72 32 comment 59 bottom front stage t1

-5.0 0.0 2.0 0.0 0.0 0.99999994 127 80 64 comment 60 top center t0

5.0 0.0 2.0 0.0 0.0 0.99999994 127 80 64 comment 61 top center t0

7.0 4.0 2.0 0.0 0.0 0.99999994 127 80 64 comment 62 top center t0

7.0 4.0 2.0 0.0 0.0 1.0 127 80 64 comment 63 top center t1

-7.0 4.0 2.0 0.0 0.0 1.0 127 80 64 comment 64 top center t1

-5.0 0.0 2.0 0.0 0.0 1.0 127 80 64 comment 65 top center t1

4.5 4.0 2.0 0.0 0.0 1.0 191 88 96 comment 66 top front stage t0

-2.5 6.0 2.0 0.0 0.0 1.0 191 88 96 comment 67 top front stage t0

-4.5 4.0 2.0 0.0 0.0 1.0 191 88 96 comment 68 top front stage t0

-2.5 6.0 2.0 0.0 0.0 1.0 191 88 96 comment 69 top front stage t1

4.5 4.0 2.0 0.0 0.0 1.0 191 88 96 comment 70 top front stage t1

2.5 6.0 2.0 0.0 0.0 1.0 191 88 96 comment 71 top front stage t1

3 0 1 2

3 3 4 5

3 6 7 8

3 9 10 11

3 12 13 14

3 15 16 17

3 18 19 20

3 21 22 23

3 24 25 26

3 27 28 29

3 30 31 32

3 33 34 35

3 36 37 38

3 39 40 41

3 42 43 44

3 45 46 47

3 48 49 50

3 51 52 53

3 54 55 56

3 57 58 59

3 60 61 62

3 63 64 65

3 66 67 68

3 69 70 71

0

--------- The line above is the last line of the file.