Changeset 13041 for OpenSceneGraph/trunk/src/osgPlugins/ply/plyfile.cpp
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/ply/plyfile.cpp
r12577 r13041 1 /* Copyright (c) 2005-2007, Stefan Eilemann <eile@equalizergraphics.com> 1 /* Copyright (c) 2005-2007, Stefan Eilemann <eile@equalizergraphics.com> 2 2 All rights reserved. 3 3 - Cleaned up code for 64 bit, little and big endian support … … 26 26 27 27 Copyright (c) 1994 The Board of Trustees of The Leland Stanford 28 Junior University. All rights reserved. 29 30 Permission to use, copy, modify and distribute this software and its 31 documentation for any purpose is hereby granted without fee, provided 32 that the above copyright notice and this permission notice appear in 33 all copies of this software and that you do not sell the software. 34 35 THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, 36 EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 37 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 28 Junior University. All rights reserved. 29 30 Permission to use, copy, modify and distribute this software and its 31 documentation for any purpose is hereby granted without fee, provided 32 that the above copyright notice and this permission notice appear in 33 all copies of this software and that you do not sell the software. 34 35 THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, 36 EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 37 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 38 38 39 39 */ … … 136 136 unsigned char* bytes = (unsigned char*)ptr; 137 137 unsigned short* result = (unsigned short*)ptr; 138 138 139 139 *result = (bytes[0]<<8) | bytes[1]; 140 140 } … … 146 146 147 147 *result = (bytes[0]<<24) | (bytes[1]<<16) | (bytes[2]<<8) | bytes[3]; 148 } 148 } 149 149 150 150 void swap8Bytes( void* ptr ) … … 152 152 unsigned char* bytes = (unsigned char*)ptr; 153 153 unsigned long long* result = (unsigned long long*)ptr; 154 154 155 155 *result = ((unsigned long long)(bytes[0])) << 56 | 156 156 ((unsigned long long)(bytes[1])) << 48 | … … 307 307 308 308 /* tack on the extension .ply, if necessary */ 309 name = (char *) myalloc (sizeof (char) * 309 name = (char *) myalloc (sizeof (char) * 310 310 (static_cast<int>(strlen (filename)) + 5)); 311 311 strcpy (name, filename); … … 754 754 sizeof (char *) * (plyfile->num_comments + 1)); 755 755 } 756 756 757 757 /* add comment to list */ 758 758 plyfile->comments[plyfile->num_comments] = strdup (comment); … … 782 782 sizeof (char *) * (plyfile->num_obj_info + 1)); 783 783 } 784 784 785 785 /* add info to list */ 786 786 plyfile->obj_info[plyfile->num_obj_info] = strdup (obj_info); … … 830 830 plyfile = (PlyFile *) myalloc (sizeof (PlyFile)); 831 831 if (!plyfile) return (NULL); 832 832 833 833 plyfile->nelems = 0; 834 834 plyfile->comments = NULL; … … 895 895 words = get_words (plyfile->fp, &nwords, &orig_line); 896 896 } 897 897 898 898 899 899 /* create tags for each property of each element, to be used */ … … 951 951 /* tack on the extension .ply, if necessary */ 952 952 953 name = (char *) myalloc (sizeof (char) * 953 name = (char *) myalloc (sizeof (char) * 954 954 (static_cast<int>(strlen (filename) + 5))); 955 955 strcpy (name, filename); … … 1056 1056 1057 1057 /* deposit the property information into the element's description */ 1058 for (i = 0; i < nprops; i++) 1058 for (i = 0; i < nprops; i++) 1059 1059 { 1060 1060 /* look for actual property */ 1061 1061 prop = find_property (elem, prop_list[i].name, &index); 1062 if (prop == NULL) 1062 if (prop == NULL) 1063 1063 { 1064 fprintf ( stderr, 1064 fprintf ( stderr, 1065 1065 "Warning: Can't find property '%s' in element '%s'\n", 1066 1066 prop_list[i].name, elem_name ); … … 1304 1304 other->size = elem->other_size; 1305 1305 other->props = (PlyProperty **) myalloc (sizeof(PlyProperty*) * elem->nprops); 1306 1306 1307 1307 /* save descriptions of each "other" property */ 1308 1308 nprops = 0; … … 1323 1323 } 1324 1324 #endif 1325 1325 1326 1326 /* return structure */ 1327 1327 return (other); … … 1535 1535 } 1536 1536 free (plyfile->comments); 1537 1537 1538 1538 for (i=0; i<plyfile->num_obj_info; i++) 1539 1539 { … … 1541 1541 } 1542 1542 free (plyfile->obj_info); 1543 1543 1544 1544 free (plyfile); 1545 1545 } … … 1602 1602 if (equal_strings (element, plyfile->elems[i]->name)) 1603 1603 return (plyfile->elems[i]); 1604 1604 1605 1605 return (NULL); 1606 1606 } … … 1622 1622 { 1623 1623 int i; 1624 1624 1625 1625 for( i = 0; i < elem->nprops; i++) 1626 1626 if (equal_strings (prop_name, elem->props[i]->name)) … … 1629 1629 return (elem->props[i]); 1630 1630 } 1631 1631 1632 1632 *index = -1; 1633 1633 return (NULL); … … 1828 1828 * so that zipper won't crash reading plies that have additional 1829 1829 * properties. 1830 */ 1830 */ 1831 1831 if (store_it) { 1832 1832 item_size = ply_type_size[prop->internal_type]; … … 2761 2761 ptr = (char *) malloc (size); 2762 2762 2763 if (ptr == 0) 2764 fprintf( stderr, "Memory allocation bombed on line %d in %s\n", 2763 if (ptr == 0) 2764 fprintf( stderr, "Memory allocation bombed on line %d in %s\n", 2765 2765 lnum, fname); 2766 2766
