Revision: 75363
http://sourceforge.net/p/brlcad/code/75363
Author: starseeker
Date: 2020-04-11 02:05:18 +0000 (Sat, 11 Apr 2020)
Log Message:
-----------
Update rply to 1.1.4, add embedded license info
Modified Paths:
--------------
brlcad/trunk/doc/legal/embedded/CMakeLists.txt
brlcad/trunk/doc/legal/other/CMakeLists.txt
brlcad/trunk/src/conv/ply/CMakeLists.txt
brlcad/trunk/src/conv/ply/rply.c
brlcad/trunk/src/conv/ply/rply.h
brlcad/trunk/src/conv/ply/rply_license.txt
Added Paths:
-----------
brlcad/trunk/doc/legal/embedded/rply.txt
brlcad/trunk/src/conv/ply/rplyfile.h
Removed Paths:
-------------
brlcad/trunk/doc/legal/other/rply.txt
Modified: brlcad/trunk/doc/legal/embedded/CMakeLists.txt
===================================================================
--- brlcad/trunk/doc/legal/embedded/CMakeLists.txt 2020-04-11 01:48:13 UTC
(rev 75362)
+++ brlcad/trunk/doc/legal/embedded/CMakeLists.txt 2020-04-11 02:05:18 UTC
(rev 75363)
@@ -41,6 +41,7 @@
qsort.txt
QuickHull.txt
realpath.txt
+ rply.txt
RTree.txt
search.txt
sha1.txt
Added: brlcad/trunk/doc/legal/embedded/rply.txt
===================================================================
--- brlcad/trunk/doc/legal/embedded/rply.txt (rev 0)
+++ brlcad/trunk/doc/legal/embedded/rply.txt 2020-04-11 02:05:18 UTC (rev
75363)
@@ -0,0 +1,24 @@
+RPly 1.1.4 license
+Copyright \xA9 2003-2015 Diego Nehab.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+file:src/conv/ply/rply.c
+file:src/conv/ply/rply.h
+file:src/conv/ply/rplyfile.h
Property changes on: brlcad/trunk/doc/legal/embedded/rply.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: brlcad/trunk/doc/legal/other/CMakeLists.txt
===================================================================
--- brlcad/trunk/doc/legal/other/CMakeLists.txt 2020-04-11 01:48:13 UTC (rev
75362)
+++ brlcad/trunk/doc/legal/other/CMakeLists.txt 2020-04-11 02:05:18 UTC (rev
75363)
@@ -17,7 +17,6 @@
openscenegraph.txt
poly2tri.txt
proj-4.txt
- rply.txt
SPSR.txt
stepcode.txt
tcl.txt
Deleted: brlcad/trunk/doc/legal/other/rply.txt
===================================================================
--- brlcad/trunk/doc/legal/other/rply.txt 2020-04-11 01:48:13 UTC (rev
75362)
+++ brlcad/trunk/doc/legal/other/rply.txt 2020-04-11 02:05:18 UTC (rev
75363)
@@ -1,20 +0,0 @@
-RPly 1.1.3 license
-Copyright \xA9 2003-2013 Diego Nehab.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
Modified: brlcad/trunk/src/conv/ply/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/conv/ply/CMakeLists.txt 2020-04-11 01:48:13 UTC (rev
75362)
+++ brlcad/trunk/src/conv/ply/CMakeLists.txt 2020-04-11 02:05:18 UTC (rev
75363)
@@ -16,6 +16,7 @@
CMAKEFILES(
CMakeLists.txt
rply.h
+ rplyfile.h
rply_license.txt
)
Modified: brlcad/trunk/src/conv/ply/rply.c
===================================================================
--- brlcad/trunk/src/conv/ply/rply.c 2020-04-11 01:48:13 UTC (rev 75362)
+++ brlcad/trunk/src/conv/ply/rply.c 2020-04-11 02:05:18 UTC (rev 75363)
@@ -3,8 +3,27 @@
* Diego Nehab, IMPA
* http://www.impa.br/~diego/software/rply
*
- * This library is distributed under the MIT License. See notice
- * at the end of this file.
+ * This library is distributed under the MIT License.
+ * Copyright (C) 2003-2015 Diego Nehab. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ---------------------------------------------------------------------- */
#include "common.h"
@@ -20,6 +39,7 @@
#include <stddef.h>
#include "rply.h"
+#include "rplyfile.h"
/* pointers to tokenized word and line in buffer */
#define BWORD(p) (p->buffer + p->buffer_token)
@@ -74,7 +94,7 @@
#endif
/* ----------------------------------------------------------------------
- * Constants
+ * Constants
* ---------------------------------------------------------------------- */
#define WORDSIZE 256
#define LINESIZE 1024
@@ -81,7 +101,7 @@
#define BUFFERSIZE (8*1024)
typedef enum e_ply_io_mode_ {
- PLY_READ,
+ PLY_READ,
PLY_WRITE
} e_ply_io_mode;
@@ -138,7 +158,7 @@
p_ply_read_cb read_cb;
void *pdata;
long idata;
-} t_ply_property;
+} t_ply_property;
/* ----------------------------------------------------------------------
* Element information
@@ -160,8 +180,8 @@
/* ----------------------------------------------------------------------
* Input/output driver
*
- * Depending on file mode, different functions are used to read/write
- * property fields. The drivers make it transparent to read/write in ascii,
+ * Depending on file mode, different functions are used to read/write
+ * property fields. The drivers make it transparent to read/write in ascii,
* big endian or little endian cases.
* ---------------------------------------------------------------------- */
typedef int (*p_ply_ihandler)(p_ply ply, double *value);
@@ -183,7 +203,7 @@
typedef t_ply_odriver *p_ply_odriver;
/* ----------------------------------------------------------------------
- * Ply file handle.
+ * Ply file handle.
*
* io_mode: read or write (from e_ply_io_mode)
* storage_mode: mode of file associated with handle (from e_ply_storage_mode)
@@ -194,15 +214,15 @@
* obj_info: obj_info items for this file
* nobj_infos: number of obj_info items in file
* fp: file pointer associated with ply file
- * rn: skip extra char after end_header?
+ * rn: skip extra char after end_header?
* buffer: last word/chunck of data read from ply file
* buffer_first, buffer_last: interval of untouched good data in buffer
* buffer_token: start of parsed token (line or word) in buffer
- * idriver, odriver: input driver used to get property fields from file
+ * idriver, odriver: input driver used to get property fields from file
* argument: storage space for callback arguments
* welement, wproperty: element/property type being written
* winstance_index: index of instance of current element being written
- * wvalue_index: index of list property value being written
+ * wvalue_index: index of list property value being written
* wlength: number of values in list property being written
* error_cb: error callback
* pdata/idata: user data defined with ply_open/ply_create
@@ -217,6 +237,7 @@
char *obj_info;
long nobj_infos;
FILE *fp;
+ int own_fp;
int rn;
char buffer[BUFFERSIZE];
size_t buffer_first, buffer_token, buffer_last;
@@ -556,18 +577,18 @@
* Special functions
* ---------------------------------------------------------------------- */
static e_ply_storage_mode ply_arch_endian(void);
-static int ply_type_check(void);
+static int ply_type_check(void);
/* ----------------------------------------------------------------------
* Auxiliary read functions
* ---------------------------------------------------------------------- */
-static int ply_read_element(p_ply ply, p_ply_element element,
+static int ply_read_element(p_ply ply, p_ply_element element,
p_ply_argument argument);
-static int ply_read_property(p_ply ply, p_ply_element element,
+static int ply_read_property(p_ply ply, p_ply_element element,
p_ply_property property, p_ply_argument argument);
-static int ply_read_list_property(p_ply ply, p_ply_element element,
+static int ply_read_list_property(p_ply ply, p_ply_element element,
p_ply_property property, p_ply_argument argument);
-static int ply_read_scalar_property(p_ply ply, p_ply_element element,
+static int ply_read_scalar_property(p_ply ply, p_ply_element element,
p_ply_property property, p_ply_argument argument);
/* ----------------------------------------------------------------------
@@ -583,18 +604,17 @@
ply->buffer_first = ply->buffer_token = 0;
/* fill remaining with new data */
size = fread(ply->buffer+size, 1, BUFFERSIZE-size-1, ply->fp);
+ /* increase size to account for new data */
+ ply->buffer_last += size;
/* place sentinel so we can use str* functions with buffer */
- ply->buffer[BUFFERSIZE-1] = '\0';
+ ply->buffer[ply->buffer_last] = '\0';
/* check if read failed */
- if (size <= 0) return 0;
- /* increase size to account for new data */
- ply->buffer_last += size;
- return 1;
+ return size > 0;
}
/* We don't care about end-of-line, generally, because we
* separate words by any white-space character.
- * Unfortunately, in binary mode, right after 'end_header',
+ * Unfortunately, in binary mode, right after 'end_header',
* we have to know *exactly* how many characters to skip */
/* We use the end-of-line marker after the 'ply' magic
* number to figure out what to do */
@@ -605,7 +625,7 @@
return 0;
}
/* check if it is ply */
- if (magic[0] != 'p' || magic[1] != 'l' || magic[2] != 'y'
+ if (magic[0] != 'p' || magic[1] != 'l' || magic[2] != 'y'
|| !isspace(magic[3])) {
ply->error_cb(ply, "Wrong magic number. Expected 'ply'");
return 0;
@@ -623,11 +643,33 @@
/* ----------------------------------------------------------------------
* Read support functions
* ---------------------------------------------------------------------- */
-p_ply ply_open(const char *name, p_ply_error_cb error_cb,
+p_ply ply_open(const char *name, p_ply_error_cb error_cb,
long idata, void *pdata) {
- FILE *fp = NULL;
- p_ply ply = ply_alloc();
+ FILE *fp;
+ p_ply ply;
if (error_cb == NULL) error_cb = ply_error_cb;
+ assert(name);
+ fp = fopen(name, "rb");
+ if (!fp) {
+ error_cb(NULL, "Unable to open file");
+ return NULL;
+ }
+ ply = ply_open_from_file(fp, error_cb, idata, pdata);
+ if (ply) ply->own_fp = 1;
+ else fclose(fp);
+ return ply;
+}
+
+p_ply ply_open_from_file(FILE *fp, p_ply_error_cb error_cb,
+ long idata, void *pdata) {
+ p_ply ply = NULL;
+ if (error_cb == NULL) error_cb = ply_error_cb;
+ assert(fp);
+ if (!ply_type_check()) {
+ error_cb(ply, "Incompatible type system");
+ return NULL;
+ }
+ ply = ply_alloc();
if (!ply) {
error_cb(NULL, "Out of memory");
return NULL;
@@ -636,19 +678,8 @@
ply->pdata = pdata;
ply->io_mode = PLY_READ;
ply->error_cb = error_cb;
- if (!ply_type_check()) {
- error_cb(ply, "Incompatible type system");
- free(ply);
- return NULL;
- }
- assert(name);
- fp = fopen(name, "rb");
- if (!fp) {
- error_cb(ply, "Unable to open file");
- free(ply);
- return NULL;
- }
ply->fp = fp;
+ ply->own_fp = 0;
return ply;
}
@@ -663,8 +694,8 @@
}
/* parse elements, comments or obj_infos until the end of header */
while (strcmp(BWORD(ply), "end_header")) {
- if (!ply_read_header_comment(ply) &&
- !ply_read_header_element(ply) &&
+ if (!ply_read_header_comment(ply) &&
+ !ply_read_header_element(ply) &&
!ply_read_header_obj_info(ply)) {
ply_ferror(ply, "Unexpected token '%s'", BWORD(ply));
return 0;
@@ -681,10 +712,10 @@
return 1;
}
-long ply_set_read_cb(p_ply ply, const char *element_name,
- const char* property_name, p_ply_read_cb read_cb,
+long ply_set_read_cb(p_ply ply, const char *element_name,
+ const char* property_name, p_ply_read_cb read_cb,
void *pdata, long idata) {
- p_ply_element element = NULL;
+ p_ply_element element = NULL;
p_ply_property property = NULL;
assert(ply && element_name && property_name);
element = ply_find_element(ply, element_name);
@@ -715,25 +746,34 @@
/* ----------------------------------------------------------------------
* Write support functions
* ---------------------------------------------------------------------- */
-p_ply ply_create(const char *name, e_ply_storage_mode storage_mode,
+p_ply ply_create(const char *name, e_ply_storage_mode storage_mode,
p_ply_error_cb error_cb, long idata, void *pdata) {
+ p_ply ply = NULL;
FILE *fp = NULL;
- p_ply ply = ply_alloc();
+ assert(name && storage_mode <= PLY_DEFAULT);
if (error_cb == NULL) error_cb = ply_error_cb;
- if (!ply) {
- error_cb(NULL, "Out of memory");
+ fp = fopen(name, "wb");
+ if (!fp) {
+ error_cb(ply, "Unable to create file");
return NULL;
}
+ ply = ply_create_to_file(fp, storage_mode, error_cb, idata, pdata);
+ if (ply) ply->own_fp = 1;
+ else fclose(fp);
+ return ply;
+}
+
+p_ply ply_create_to_file(FILE *fp, e_ply_storage_mode storage_mode,
+ p_ply_error_cb error_cb, long idata, void *pdata) {
+ p_ply ply = NULL;
+ assert(fp && storage_mode <= PLY_DEFAULT);
if (!ply_type_check()) {
error_cb(ply, "Incompatible type system");
- free(ply);
return NULL;
}
- assert(name && storage_mode <= PLY_DEFAULT);
- fp = fopen(name, "wb");
- if (!fp) {
- error_cb(ply, "Unable to create file");
- free(ply);
+ ply = ply_alloc();
+ if (!ply) {
+ error_cb(NULL, "Out of memory");
return NULL;
}
ply->idata = idata;
@@ -741,15 +781,17 @@
ply->io_mode = PLY_WRITE;
if (storage_mode == PLY_DEFAULT) storage_mode = ply_arch_endian();
if (storage_mode == PLY_ASCII) ply->odriver = &ply_odriver_ascii;
- else if (storage_mode == ply_arch_endian())
+ else if (storage_mode == ply_arch_endian())
ply->odriver = &ply_odriver_binary;
else ply->odriver = &ply_odriver_binary_reverse;
ply->storage_mode = storage_mode;
ply->fp = fp;
+ ply->own_fp = 0;
ply->error_cb = error_cb;
return ply;
}
+
int ply_add_element(p_ply ply, const char *name, long ninstances) {
p_ply_element element = NULL;
assert(ply && ply->fp && ply->io_mode == PLY_WRITE);
@@ -783,7 +825,7 @@
return 1;
}
-int ply_add_list_property(p_ply ply, const char *name,
+int ply_add_list_property(p_ply ply, const char *name,
e_ply_type length_type, e_ply_type value_type) {
p_ply_element element = NULL;
p_ply_property property = NULL;
@@ -811,9 +853,9 @@
int ply_add_property(p_ply ply, const char *name, e_ply_type type,
e_ply_type length_type, e_ply_type value_type) {
- if (type == PLY_LIST)
+ if (type == PLY_LIST)
return ply_add_list_property(ply, name, length_type, value_type);
- else
+ else
return ply_add_scalar_property(ply, name, type);
}
@@ -848,9 +890,9 @@
int ply_write_header(p_ply ply) {
long i, j;
assert(ply && ply->fp && ply->io_mode == PLY_WRITE);
- assert(ply->element || ply->nelements == 0);
- assert(!ply->element || ply->nelements > 0);
- if (fprintf(ply->fp, "ply\nformat %s 1.0\n",
+ assert(ply->element || ply->nelements == 0);
+ assert(!ply->element || ply->nelements > 0);
+ if (fprintf(ply->fp, "ply\nformat %s 1.0\n",
ply_storage_mode_list[ply->storage_mode]) <= 0) goto error;
for (i = 0; i < ply->ncomments; i++)
if (fprintf(ply->fp, "comment %s\n", ply->comment + LINESIZE*i) <= 0)
@@ -860,19 +902,19 @@
goto error;
for (i = 0; i < ply->nelements; i++) {
p_ply_element element = &ply->element[i];
- assert(element->property || element->nproperties == 0);
- assert(!element->property || element->nproperties > 0);
- if (fprintf(ply->fp, "element %s %ld\n", element->name,
+ assert(element->property || element->nproperties == 0);
+ assert(!element->property || element->nproperties > 0);
+ if (fprintf(ply->fp, "element %s %ld\n", element->name,
element->ninstances) <= 0) goto error;
for (j = 0; j < element->nproperties; j++) {
p_ply_property property = &element->property[j];
if (property->type == PLY_LIST) {
- if (fprintf(ply->fp, "property list %s %s %s\n",
+ if (fprintf(ply->fp, "property list %s %s %s\n",
ply_type_list[property->length_type],
ply_type_list[property->value_type],
property->name) <= 0) goto error;
} else {
- if (fprintf(ply->fp, "property %s %s\n",
+ if (fprintf(ply->fp, "property %s %s\n",
ply_type_list[property->type],
property->name) <= 0) goto error;
}
@@ -904,9 +946,9 @@
ply->wlength = 0;
}
if (!ply->odriver->ohandler[type](ply, value)) {
- ply_ferror(ply, "Failed writing %s of %s %d (%s: %s)",
- property->name, element->name,
- ply->winstance_index,
+ ply_ferror(ply, "Failed writing %s of %s %d (%s: %s)",
+ property->name, element->name,
+ ply->winstance_index,
ply->odriver->name, ply_type_list[type]);
return 0;
}
@@ -929,9 +971,9 @@
} while (ply->welement < ply->nelements && !element->ninstances);
}
if (ply->storage_mode == PLY_ASCII) {
- return (!spaceafter || putc(' ', ply->fp) > 0) &&
+ return (!spaceafter || putc(' ', ply->fp) > 0) &&
(!breakafter || putc('\n', ply->fp) > 0);
- } else {
+ } else {
return 1;
}
}
@@ -942,12 +984,12 @@
assert(ply->element || ply->nelements == 0);
assert(!ply->element || ply->nelements > 0);
/* write last chunk to file */
- if (ply->io_mode == PLY_WRITE &&
+ if (ply->io_mode == PLY_WRITE &&
fwrite(ply->buffer, 1, ply->buffer_last, ply->fp) < ply->buffer_last) {
ply_ferror(ply, "Error closing up");
return 0;
}
- fclose(ply->fp);
+ if (ply->own_fp) fclose(ply->fp);
/* free all memory used by handle */
if (ply->element) {
for (i = 0; i < ply->nelements; i++) {
@@ -965,7 +1007,7 @@
/* ----------------------------------------------------------------------
* Query support functions
* ---------------------------------------------------------------------- */
-p_ply_element ply_get_next_element(p_ply ply,
+p_ply_element ply_get_next_element(p_ply ply,
p_ply_element last) {
assert(ply);
if (!last) return ply->element;
@@ -982,7 +1024,7 @@
return 1;
}
-p_ply_property ply_get_next_property(p_ply_element element,
+p_ply_property ply_get_next_property(p_ply_element element,
p_ply_property last) {
assert(element);
if (!last) return element->property;
@@ -1004,7 +1046,7 @@
const char *ply_get_next_comment(p_ply ply, const char *last) {
assert(ply);
- if (!last) return ply->comment;
+ if (!last) return ply->comment;
last += LINESIZE;
if (last < ply->comment + LINESIZE*ply->ncomments) return last;
else return NULL;
@@ -1012,7 +1054,7 @@
const char *ply_get_next_obj_info(p_ply ply, const char *last) {
assert(ply);
- if (!last) return ply->obj_info;
+ if (!last) return ply->obj_info;
last += LINESIZE;
if (last < ply->obj_info + LINESIZE*ply->nobj_infos) return last;
else return NULL;
@@ -1019,9 +1061,9 @@
}
/* ----------------------------------------------------------------------
- * Callback argument support functions
+ * Callback argument support functions
* ---------------------------------------------------------------------- */
-int ply_get_argument_element(p_ply_argument argument,
+int ply_get_argument_element(p_ply_argument argument,
p_ply_element *element, long *instance_index) {
assert(argument);
if (!argument) return 0;
@@ -1030,7 +1072,7 @@
return 1;
}
-int ply_get_argument_property(p_ply_argument argument,
+int ply_get_argument_property(p_ply_argument argument,
p_ply_property *property, long *length, long *value_index) {
assert(argument);
if (!argument) return 0;
@@ -1040,7 +1082,7 @@
return 1;
}
-int ply_get_argument_user_data(p_ply_argument argument, void **pdata,
+int ply_get_argument_user_data(p_ply_argument argument, void **pdata,
long *idata) {
assert(argument);
if (!argument) return 0;
@@ -1066,11 +1108,11 @@
/* ----------------------------------------------------------------------
* Internal functions
* ---------------------------------------------------------------------- */
-static int ply_read_list_property(p_ply ply, p_ply_element element,
+static int ply_read_list_property(p_ply ply, p_ply_element element,
p_ply_property property, p_ply_argument argument) {
int l;
p_ply_read_cb read_cb = property->read_cb;
- p_ply_ihandler *driver = ply->idriver->ihandler;
+ p_ply_ihandler *driver = ply->idriver->ihandler;
/* get list length */
p_ply_ihandler handler = driver[property->length_type];
double length;
@@ -1095,7 +1137,7 @@
argument->value_index = l;
if (!handler(ply, &argument->value)) {
ply_ferror(ply, "Error reading value number %d of '%s' of "
- "'%s' number %d", l+1, property->name,
+ "'%s' number %d", l+1, property->name,
element->name, argument->instance_index);
return 0;
}
@@ -1108,10 +1150,10 @@
return 1;
}
-static int ply_read_scalar_property(p_ply ply, p_ply_element element,
+static int ply_read_scalar_property(p_ply ply, p_ply_element element,
p_ply_property property, p_ply_argument argument) {
p_ply_read_cb read_cb = property->read_cb;
- p_ply_ihandler *driver = ply->idriver->ihandler;
+ p_ply_ihandler *driver = ply->idriver->ihandler;
p_ply_ihandler handler = driver[property->type];
argument->length = 1;
argument->value_index = 0;
@@ -1127,15 +1169,15 @@
return 1;
}
-static int ply_read_property(p_ply ply, p_ply_element element,
+static int ply_read_property(p_ply ply, p_ply_element element,
p_ply_property property, p_ply_argument argument) {
- if (property->type == PLY_LIST)
+ if (property->type == PLY_LIST)
return ply_read_list_property(ply, element, property, argument);
- else
+ else
return ply_read_scalar_property(ply, element, property, argument);
}
-static int ply_read_element(p_ply ply, p_ply_element element,
+static int ply_read_element(p_ply ply, p_ply_element element,
p_ply_argument argument) {
long j, k;
/* for each element of this type */
@@ -1227,26 +1269,26 @@
static p_ply_element ply_find_element(p_ply ply, const char *name) {
p_ply_element element;
int i, nelements;
- assert(ply && name);
+ assert(ply && name);
element = ply->element;
nelements = ply->nelements;
- assert(element || nelements == 0);
- assert(!element || nelements > 0);
- for (i = 0; i < nelements; i++)
+ assert(element || nelements == 0);
+ assert(!element || nelements > 0);
+ for (i = 0; i < nelements; i++)
if (!strcmp(element[i].name, name)) return &element[i];
return NULL;
}
-static p_ply_property ply_find_property(p_ply_element element,
+static p_ply_property ply_find_property(p_ply_element element,
const char *name) {
p_ply_property property;
int i, nproperties;
- assert(element && name);
+ assert(element && name);
property = element->property;
nproperties = element->nproperties;
- assert(property || nproperties == 0);
- assert(!property || nproperties > 0);
- for (i = 0; i < nproperties; i++)
+ assert(property || nproperties == 0);
+ assert(!property || nproperties > 0);
+ for (i = 0; i < nproperties; i++)
if (!strcmp(property[i].name, name)) return &property[i];
return NULL;
}
@@ -1275,9 +1317,9 @@
ply_ferror(ply, "Unexpected end of file");
return 0;
}
- } else break;
- }
- BSKIP(ply, t);
+ } else break;
+ }
+ BSKIP(ply, t);
/* look for a space after the current word */
t = strcspn(BFIRST(ply), " \n\r\t");
/* if we didn't reach the end of the buffer, we are done */
@@ -1333,7 +1375,7 @@
BSKIP(ply, 1);
return ply_check_line(ply);
} else {
- end = ply->buffer + BSIZE(ply);
+ end = ply->buffer + BSIZE(ply);
/* otherwise, try to refill buffer */
if (!BREFILL(ply)) {
ply_ferror(ply, "Unexpected end of file");
@@ -1477,14 +1519,14 @@
static p_ply_element ply_grow_element(p_ply ply) {
p_ply_element element = NULL;
- assert(ply);
- assert(ply->element || ply->nelements == 0);
- assert(!ply->element || ply->nelements > 0);
- element = (p_ply_element) ply_grow_array(ply, (void **) &ply->element,
+ assert(ply);
+ assert(ply->element || ply->nelements == 0);
+ assert(!ply->element || ply->nelements > 0);
+ element = (p_ply_element) ply_grow_array(ply, (void **) &ply->element,
&ply->nelements, sizeof(t_ply_element));
if (!element) return NULL;
ply_element_init(element);
- return element;
+ return element;
}
static p_ply_property ply_grow_property(p_ply ply, p_ply_element element) {
@@ -1493,8 +1535,8 @@
assert(element);
assert(element->property || element->nproperties == 0);
assert(!element->property || element->nproperties > 0);
- property = (p_ply_property) ply_grow_array(ply,
- (void **) &element->property,
+ property = (p_ply_property) ply_grow_array(ply,
+ (void **) &element->property,
&element->nproperties, sizeof(t_ply_property));
if (!property) return NULL;
ply_property_init(property);
@@ -1583,7 +1625,7 @@
element->ninstances = dummy;
/* get all properties for this element */
if (!ply_read_word(ply)) return 0;
- while (ply_read_header_property(ply) ||
+ while (ply_read_header_property(ply) ||
ply_read_header_comment(ply) || ply_read_header_obj_info(ply))
/* do nothing */;
return 1;
@@ -1630,29 +1672,6 @@
return 1;
}
-/* ----------------------------------------------------------------------
- * Copyright (C) 2003-2011 Diego Nehab. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * ---------------------------------------------------------------------- */
-
/*
* Local Variables:
* tab-width: 8
Modified: brlcad/trunk/src/conv/ply/rply.h
===================================================================
--- brlcad/trunk/src/conv/ply/rply.h 2020-04-11 01:48:13 UTC (rev 75362)
+++ brlcad/trunk/src/conv/ply/rply.h 2020-04-11 02:05:18 UTC (rev 75363)
@@ -27,8 +27,8 @@
extern "C" {
#endif
-#define RPLY_VERSION "RPly 1.1.3"
-#define RPLY_COPYRIGHT "Copyright (C) 2003-2013 Diego Nehab"
+#define RPLY_VERSION "RPly 1.1.4"
+#define RPLY_COPYRIGHT "Copyright (C) 2003-2015 Diego Nehab"
#define RPLY_AUTHORS "Diego Nehab"
/* ----------------------------------------------------------------------
@@ -45,7 +45,7 @@
PLY_INVALID_STORAGE,
PLY_BIG_ENDIAN,
PLY_LITTLE_ENDIAN,
- PLY_ASCII,
+ PLY_ASCII,
PLY_DEFAULT /* has to be the last in enum */
} e_ply_storage_mode; /* order matches ply_storage_mode_list */
@@ -52,7 +52,7 @@
/* ply data type */
typedef enum e_ply_type {
PLY_INVALID_TYPE,
- PLY_INT8, PLY_UINT8, PLY_INT16, PLY_UINT16,
+ PLY_INT8, PLY_UINT8, PLY_INT16, PLY_UINT16,
PLY_INT32, PLY_UIN32, PLY_FLOAT32, PLY_FLOAT64,
PLY_CHAR, PLY_UCHAR, PLY_SHORT, PLY_USHORT,
PLY_INT, PLY_UINT, PLY_FLOAT, PLY_DOUBLE,
@@ -68,7 +68,7 @@
typedef void (*p_ply_error_cb)(p_ply ply, const char *message);
/* ----------------------------------------------------------------------
- * Gets user data from within an error callback
+ * Gets user data from within an error callback
*
* ply: handle returned by ply_open or ply_create
* idata,pdata: contextual information set in ply_open or ply_create
@@ -115,18 +115,18 @@
* pdata/idata: user data that will be passed to callback
*
* Returns 0 if no element or no property in element, returns the
- * number of element instances otherwise.
+ * number of element instances otherwise.
* ---------------------------------------------------------------------- */
RPLY_EXPORT long ply_set_read_cb(p_ply ply, const char *element_name,
- const char *property_name, p_ply_read_cb read_cb,
+ const char *property_name, p_ply_read_cb read_cb,
void *pdata, long idata);
/* ----------------------------------------------------------------------
* Returns information about the element originating a callback
*
- * argument: handle to argument
+ * argument: handle to argument
* element: receives a the element handle (if non-null)
- * instance_index: receives the index of the current element instance
+ * instance_index: receives the index of the current element instance
* (if non-null)
*
* Returns 1 if successfull, 0 otherwise
@@ -137,7 +137,7 @@
/* ----------------------------------------------------------------------
* Returns information about the property originating a callback
*
- * argument: handle to argument
+ * argument: handle to argument
* property: receives the property handle (if non-null)
* length: receives the number of values in this property (if non-null)
* value_index: receives the index of current property value (if non-null)
@@ -148,7 +148,7 @@
p_ply_property *property, long *length, long *value_index);
/* ----------------------------------------------------------------------
- * Returns user data associated with callback
+ * Returns user data associated with callback
*
* pdata: receives a copy of user custom data pointer (if non-null)
* idata: receives a copy of user custom data integer (if non-null)
@@ -161,7 +161,7 @@
/* ----------------------------------------------------------------------
* Returns the value associated with a callback
*
- * argument: handle to argument
+ * argument: handle to argument
*
* Returns the current data item
* ---------------------------------------------------------------------- */
@@ -242,7 +242,7 @@
* type: receives the property type (if non-null)
* length_type: for list properties, receives the scalar type of
* the length field (if non-null)
- * value_type: for list properties, receives the scalar type of the value
+ * value_type: for list properties, receives the scalar type of the value
* fields (if non-null)
*
* Returns 1 if successfull or 0 otherwise
@@ -255,6 +255,8 @@
*
* name: file name
* storage_mode: file format mode
+ * error_cb: error callback function
+ * idata,pdata: contextual information available to users
*
* Returns handle to PLY file if successfull, NULL otherwise
* ---------------------------------------------------------------------- */
@@ -278,7 +280,7 @@
* ply: handle returned by ply_create
* name: name of new property
* type: property type
- * length_type: scalar type of length field of a list property
+ * length_type: scalar type of length field of a list property
* value_type: scalar type of value fields of a list property
*
* Returns 1 if successfull, 0 otherwise
@@ -291,7 +293,7 @@
*
* ply: handle returned by ply_create
* name: name of new property
- * length_type: scalar type of length field of a list property
+ * length_type: scalar type of length field of a list property
* value_type: scalar type of value fields of a list property
*
* Returns 1 if successfull, 0 otherwise
@@ -311,7 +313,7 @@
RPLY_EXPORT int ply_add_scalar_property(p_ply ply, const char *name,
e_ply_type type);
/* ----------------------------------------------------------------------
- * Adds a new comment item
+ * Adds a new comment item
*
* ply: handle returned by ply_create
* comment: pointer to string with comment text
@@ -321,7 +323,7 @@
RPLY_EXPORT int ply_add_comment(p_ply ply, const char *comment);
/* ----------------------------------------------------------------------
- * Adds a new obj_info item
+ * Adds a new obj_info item
*
* ply: handle returned by ply_create
* comment: pointer to string with obj_info data
@@ -344,7 +346,7 @@
* Writes one property value, in the order they should be written to the
* file. For each element type, write all elements of that type in order.
* For each element, write all its properties in order. For scalar
- * properties, just write the value. For list properties, write the length
+ * properties, just write the value. For list properties, write the length
* and then each of the values.
*
* ply: handle returned by ply_create
@@ -356,7 +358,7 @@
/* ----------------------------------------------------------------------
* Closes a PLY file handle. Releases all memory used by handle
*
- * ply: handle to be closed.
+ * ply: handle to be closed.
*
* Returns 1 if successfull, 0 otherwise
* ---------------------------------------------------------------------- */
Modified: brlcad/trunk/src/conv/ply/rply_license.txt
===================================================================
--- brlcad/trunk/src/conv/ply/rply_license.txt 2020-04-11 01:48:13 UTC (rev
75362)
+++ brlcad/trunk/src/conv/ply/rply_license.txt 2020-04-11 02:05:18 UTC (rev
75363)
@@ -1,5 +1,5 @@
-RPly 1.1.3 license
-Copyright \xA9 2003-2013 Diego Nehab.
+RPly 1.1.4 license
+Copyright \xA9 2003-2015 Diego Nehab.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Added: brlcad/trunk/src/conv/ply/rplyfile.h
===================================================================
--- brlcad/trunk/src/conv/ply/rplyfile.h (rev 0)
+++ brlcad/trunk/src/conv/ply/rplyfile.h 2020-04-11 02:05:18 UTC (rev
75363)
@@ -0,0 +1,69 @@
+/* ----------------------------------------------------------------------
+ * Copyright (C) 2003-2015 Diego Nehab. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * ---------------------------------------------------------------------- */
+
+#ifndef RPLY_FILE_H
+#define RPLY_FILE_H
+/* ----------------------------------------------------------------------
+ * RPly library, read/write PLY files
+ * Diego Nehab, IMPA
+ * http://www.impa.br/~diego/software/rply
+ *
+ * This library is distributed under the MIT License. See notice
+ * at the end of this file.
+ * ---------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----------------------------------------------------------------------
+ * Opens a PLY file for reading (fails if file is not a PLY file)
+ *
+ * file_pointer: FILE * to file open for reading
+ * error_cb: error callback function
+ * idata,pdata: contextual information available to users
+ *
+ * Returns 1 if successful, 0 otherwise
+ * ---------------------------------------------------------------------- */
+p_ply ply_open_from_file(FILE *file_pointer, p_ply_error_cb error_cb,
+ long idata, void *pdata);
+
+/* ----------------------------------------------------------------------
+ * Creates new PLY file
+ *
+ * file_pointer: FILE * to a file open for writing
+ * storage_mode: file format mode
+ * error_cb: error callback function
+ * idata,pdata: contextual information available to users
+ *
+ * Returns handle to PLY file if successfull, NULL otherwise
+ * ---------------------------------------------------------------------- */
+p_ply ply_create_to_file(FILE *file_pointer, e_ply_storage_mode storage_mode,
+ p_ply_error_cb error_cb, long idata, void *pdata);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RPLY_FILE_H */
+
Property changes on: brlcad/trunk/src/conv/ply/rplyfile.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits