Changeset 87

Show
Ignore:
Timestamp:
10/16/07 00:00:19 (1 year ago)
Author:
baxissimo
Message:

Apparently some ply files use "int","float","uchar" etc as type descriptors.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/OpenMeshD/OpenMesh/Core/IO/reader/PLYReader.d

    r85 r87  
    532532                "uint32"     :  4, 
    533533                "float32"    :  4, 
     534                "float"      :  4, 
    534535                "float64"    :  8, 
     536                "double"     :  8, 
    535537             ]; 
    536538        if (type in prop_sizes) { 
    537539            return prop_sizes[type]; 
     540        } 
     541        else { 
     542            throw new InvalidFormatError("Unknown data type: "~type); 
     543        } 
     544    } 
     545 
     546    // Some ply files contain types like 'int' or 'uchar' instead 
     547    // of the specific in32, uint8 types. 
     548    static string ply_canonical_type(string type)  
     549    { 
     550        string[string] prop_names = 
     551            [ 
     552                "int8"[]     :  "int8"[], 
     553                "char"       :  "int8", 
     554                "byte"       :  "int8", 
     555                "uint8"      :  "uint8", 
     556                "uchar"      :  "uint8", 
     557                "ubyte"      :  "uint8", 
     558                "int16"      :  "int16", 
     559                "uint16"     :  "uint16", 
     560                "int32"      :  "int32", 
     561                "int"        :  "int32", 
     562                "uint32"     :  "uint32", 
     563                "float32"    :  "float32", 
     564                "float"      :  "float32", 
     565                "float64"    :  "float64", 
     566                "double"     :  "float64", 
     567             ]; 
     568        if (type in prop_names) { 
     569            return prop_names[type].dup; 
    538570        } 
    539571        else { 
     
    656688    } 
    657689    static class ScalarProp : Prop { 
    658         this(string name, string type) { 
    659             super(name, type); 
    660             size = ply_format_binary_size(type); 
     690        this(string _name, string _type) { 
     691            super(_name, ply_canonical_type(_type)); 
     692            size = ply_format_binary_size(this.type); 
    661693        } 
    662694        override boxer.Box read_prop_ascii(InputStream _in, BaseImporter _bi, ref Options _opt) 
     
    676708        this(string name, string idx_t, string elem_t) { 
    677709            super(name, "list"); 
    678             index_type = idx_t.dup; 
    679             elem_type = elem_t.dup; 
    680             elem_size = ply_format_binary_size(elem_t); 
     710            index_type = ply_canonical_type(idx_t); 
     711            elem_type = ply_canonical_type(elem_t); 
     712            index_size = ply_format_binary_size(index_type); 
     713            elem_size = ply_format_binary_size(elem_type); 
    681714        } 
    682715        override boxer.Box read_prop_ascii(InputStream _in, BaseImporter _bi, ref Options _opt) 
     
    703736        string index_type; 
    704737        string elem_type; 
     738        uint index_size; 
    705739        uint elem_size; 
    706740    }