Merge branch 'master' of github.com:libigl/libigl into alecjacobson
This commit is contained in:
+108
-40
@@ -220,7 +220,7 @@ inline void ply_describe_property(PlyFile *, const char *, PlyProperty *);
|
||||
inline void ply_element_count(PlyFile *, const char *, int);
|
||||
inline void ply_header_complete(PlyFile *);
|
||||
inline void ply_put_element_setup(PlyFile *, const char *);
|
||||
inline void ply_put_element(PlyFile *, void *);
|
||||
inline void ply_put_element(PlyFile *, void *, int*);
|
||||
inline void ply_put_comment(PlyFile *, char *);
|
||||
inline void ply_put_obj_info(PlyFile *, char *);
|
||||
inline PlyFile *ply_read(FILE *, int *, char ***);
|
||||
@@ -324,6 +324,7 @@ properly to target OSs with binary files.
|
||||
//#include "ply.h"
|
||||
|
||||
// Use unnamed namespace to avoid duplicate symbols
|
||||
/*
|
||||
namespace
|
||||
{
|
||||
const char *type_names[] = {
|
||||
@@ -333,7 +334,8 @@ const char *type_names[] = {
|
||||
"float", "double",
|
||||
};
|
||||
|
||||
const char *alt_type_names[] = { /* names of scalar types */
|
||||
// names of scalar types
|
||||
const char *alt_type_names[] = {
|
||||
"invalid",
|
||||
"int8", "int16", "int32", "uint8", "uint16", "uint32", "float32", "float64",
|
||||
};
|
||||
@@ -355,6 +357,7 @@ namespace
|
||||
static int native_binary_type = -1;
|
||||
static int types_checked = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
#define NO_OTHER_PROPS -1
|
||||
|
||||
@@ -381,7 +384,7 @@ inline char **get_words(FILE *, int *, char **);
|
||||
inline char **old_get_words(FILE *, int *);
|
||||
|
||||
/* write an item to a file */
|
||||
inline void write_binary_item(FILE *, int, int, unsigned int, double, int);
|
||||
inline void write_binary_item(FILE *, int, int, unsigned int, double, int, int*);
|
||||
inline void write_ascii_item(FILE *, int, unsigned int, double, int);
|
||||
inline double old_write_ascii_item(FILE *, char *, int);
|
||||
|
||||
@@ -405,20 +408,20 @@ inline double get_item_value(char *, int);
|
||||
|
||||
/* get binary or ascii item and store it according to ptr and type */
|
||||
inline void get_ascii_item(char *, int, int *, unsigned int *, double *);
|
||||
inline void get_binary_item(FILE *, int, int, int *, unsigned int *, double *);
|
||||
inline void get_binary_item(FILE *, int, int, int *, unsigned int *, double *, int*);
|
||||
|
||||
/* get a bunch of elements from a file */
|
||||
inline void ascii_get_element(PlyFile *, char *);
|
||||
inline void binary_get_element(PlyFile *, char *);
|
||||
inline void binary_get_element(PlyFile *, char *, int*);
|
||||
|
||||
/* memory allocation */
|
||||
inline char *my_alloc(int, int, const char *);
|
||||
|
||||
/* byte ordering */
|
||||
inline void get_native_binary_type();
|
||||
inline void get_native_binary_type(int*);
|
||||
inline void swap_bytes(char *, int);
|
||||
|
||||
inline void check_types();
|
||||
inline int check_types();
|
||||
|
||||
|
||||
/*************/
|
||||
@@ -453,11 +456,13 @@ inline PlyFile *ply_write(
|
||||
/* check for NULL file pointer */
|
||||
if (fp == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
||||
int native_binary_type = -1;
|
||||
int types_checked = 0;
|
||||
if (native_binary_type == -1)
|
||||
get_native_binary_type();
|
||||
native_binary_type = get_native_binary_type2();
|
||||
if (!types_checked)
|
||||
check_types();
|
||||
types_checked = check_types();
|
||||
|
||||
/* create a record for this object */
|
||||
|
||||
@@ -816,7 +821,7 @@ inline void ply_put_element_setup(PlyFile *plyfile, const char *elem_name)
|
||||
fprintf(stderr, "ply_elements_setup: can't find element '%s'\n", elem_name);
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
|
||||
plyfile->which_elem = elem;
|
||||
}
|
||||
|
||||
@@ -831,7 +836,7 @@ Entry:
|
||||
elem_ptr - pointer to the element
|
||||
******************************************************************************/
|
||||
|
||||
inline void ply_put_element(PlyFile *plyfile, void *elem_ptr)
|
||||
inline void ply_put_element(PlyFile *plyfile, void *elem_ptr, int *native_binary_type)
|
||||
{
|
||||
int j,k;
|
||||
FILE *fp = plyfile->fp;
|
||||
@@ -851,6 +856,9 @@ inline void ply_put_element(PlyFile *plyfile, void *elem_ptr)
|
||||
other_ptr = (char **) (((char *) elem_ptr) + elem->other_offset);
|
||||
|
||||
/* write out either to an ascii or binary file */
|
||||
int ply_type_size[] = {
|
||||
0, 1, 2, 4, 1, 2, 4, 4, 8
|
||||
};
|
||||
|
||||
if (plyfile->file_type == PLY_ASCII) {
|
||||
|
||||
@@ -909,7 +917,7 @@ inline void ply_put_element(PlyFile *plyfile, void *elem_ptr)
|
||||
get_stored_item ((void *) item, prop->count_internal,
|
||||
&int_val, &uint_val, &double_val);
|
||||
write_binary_item (fp, plyfile->file_type, int_val, uint_val,
|
||||
double_val, prop->count_external);
|
||||
double_val, prop->count_external, native_binary_type);
|
||||
list_count = uint_val;
|
||||
item_ptr = (char **) (elem_data + prop->offset);
|
||||
item = item_ptr[0];
|
||||
@@ -918,7 +926,7 @@ inline void ply_put_element(PlyFile *plyfile, void *elem_ptr)
|
||||
get_stored_item ((void *) item, prop->internal_type,
|
||||
&int_val, &uint_val, &double_val);
|
||||
write_binary_item (fp, plyfile->file_type, int_val, uint_val,
|
||||
double_val, prop->external_type);
|
||||
double_val, prop->external_type, native_binary_type);
|
||||
item += item_size;
|
||||
}
|
||||
}
|
||||
@@ -928,7 +936,7 @@ inline void ply_put_element(PlyFile *plyfile, void *elem_ptr)
|
||||
get_stored_item ((void *) item, prop->internal_type,
|
||||
&int_val, &uint_val, &double_val);
|
||||
write_binary_item (fp, plyfile->file_type, int_val, uint_val,
|
||||
double_val, prop->external_type);
|
||||
double_val, prop->external_type, native_binary_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1019,11 +1027,14 @@ inline PlyFile *ply_read(FILE *fp, int *nelems, char ***elem_names)
|
||||
/* check for NULL file pointer */
|
||||
if (fp == NULL)
|
||||
return (NULL);
|
||||
|
||||
|
||||
int native_binary_type = -1;
|
||||
int types_checked = 0;
|
||||
|
||||
if (native_binary_type == -1)
|
||||
get_native_binary_type();
|
||||
native_binary_type = get_native_binary_type2();
|
||||
if (!types_checked)
|
||||
check_types();
|
||||
types_checked = check_types();
|
||||
|
||||
/* create record for this object */
|
||||
|
||||
@@ -1326,12 +1337,12 @@ Entry:
|
||||
elem_ptr - pointer to location where the element information should be put
|
||||
******************************************************************************/
|
||||
|
||||
inline void ply_get_element(PlyFile *plyfile, void *elem_ptr)
|
||||
inline void ply_get_element(PlyFile *plyfile, void *elem_ptr, int *native_binary_type)
|
||||
{
|
||||
if (plyfile->file_type == PLY_ASCII)
|
||||
ascii_get_element (plyfile, (char *) elem_ptr);
|
||||
else
|
||||
binary_get_element (plyfile, (char *) elem_ptr);
|
||||
binary_get_element (plyfile, (char *) elem_ptr, native_binary_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -1393,6 +1404,9 @@ inline void setup_other_props(PlyElement *elem)
|
||||
/* Examine each property in decreasing order of size. */
|
||||
/* We do this so that all data types will be aligned by */
|
||||
/* word, half-word, or whatever within the structure. */
|
||||
int ply_type_size[] = {
|
||||
0, 1, 2, 4, 1, 2, 4, 4, 8
|
||||
};
|
||||
|
||||
for (type_size = 8; type_size > 0; type_size /= 2) {
|
||||
|
||||
@@ -1657,7 +1671,7 @@ Entry:
|
||||
plyfile - pointer to PLY file to write out other elements for
|
||||
******************************************************************************/
|
||||
|
||||
inline void ply_put_other_elements (PlyFile *plyfile)
|
||||
inline void ply_put_other_elements (PlyFile *plyfile, int *native_binary_type)
|
||||
{
|
||||
int i,j;
|
||||
OtherElem *other;
|
||||
@@ -1675,7 +1689,7 @@ inline void ply_put_other_elements (PlyFile *plyfile)
|
||||
|
||||
/* write out each instance of the current element */
|
||||
for (j = 0; j < other->elem_count; j++)
|
||||
ply_put_element (plyfile, (void *) other->other_data[j]);
|
||||
ply_put_element (plyfile, (void *) other->other_data[j], native_binary_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1819,6 +1833,10 @@ Entry:
|
||||
|
||||
inline void ascii_get_element(PlyFile *plyfile, char *elem_ptr)
|
||||
{
|
||||
int ply_type_size[] = {
|
||||
0, 1, 2, 4, 1, 2, 4, 4, 8
|
||||
};
|
||||
|
||||
int j,k;
|
||||
PlyElement *elem;
|
||||
PlyProperty *prop;
|
||||
@@ -1939,7 +1957,7 @@ Entry:
|
||||
elem_ptr - pointer to an element
|
||||
******************************************************************************/
|
||||
|
||||
inline void binary_get_element(PlyFile *plyfile, char *elem_ptr)
|
||||
inline void binary_get_element(PlyFile *plyfile, char *elem_ptr, int *native_binary_type)
|
||||
{
|
||||
int j,k;
|
||||
PlyElement *elem;
|
||||
@@ -1956,6 +1974,11 @@ inline void binary_get_element(PlyFile *plyfile, char *elem_ptr)
|
||||
char **store_array;
|
||||
char *other_data=NULL;
|
||||
int other_flag;
|
||||
|
||||
int ply_type_size[] = {
|
||||
0, 1, 2, 4, 1, 2, 4, 4, 8
|
||||
};
|
||||
|
||||
|
||||
/* the kind of element we're reading currently */
|
||||
elem = plyfile->which_elem;
|
||||
@@ -1991,7 +2014,7 @@ inline void binary_get_element(PlyFile *plyfile, char *elem_ptr)
|
||||
|
||||
/* get and store the number of items in the list */
|
||||
get_binary_item (fp, plyfile->file_type, prop->count_external,
|
||||
&int_val, &uint_val, &double_val);
|
||||
&int_val, &uint_val, &double_val, native_binary_type);
|
||||
if (store_it) {
|
||||
item = elem_data + prop->count_offset;
|
||||
store_item(item, prop->count_internal, int_val, uint_val, double_val);
|
||||
@@ -2017,7 +2040,7 @@ inline void binary_get_element(PlyFile *plyfile, char *elem_ptr)
|
||||
// read items and store them into the array
|
||||
for (k = 0; k < list_count; k++) {
|
||||
get_binary_item (fp, plyfile->file_type, prop->external_type,
|
||||
&int_val, &uint_val, &double_val);
|
||||
&int_val, &uint_val, &double_val, native_binary_type);
|
||||
if (store_it) {
|
||||
store_item (item, prop->internal_type,
|
||||
int_val, uint_val, double_val);
|
||||
@@ -2032,7 +2055,7 @@ inline void binary_get_element(PlyFile *plyfile, char *elem_ptr)
|
||||
}
|
||||
else { /* not a list */
|
||||
get_binary_item (fp, plyfile->file_type, prop->external_type,
|
||||
&int_val, &uint_val, &double_val);
|
||||
&int_val, &uint_val, &double_val, native_binary_type);
|
||||
if (store_it) {
|
||||
item = elem_data + prop->offset;
|
||||
store_item (item, prop->internal_type, int_val, uint_val, double_val);
|
||||
@@ -2061,6 +2084,13 @@ inline void write_scalar_type (FILE *fp, int code)
|
||||
}
|
||||
|
||||
/* write the code to a file */
|
||||
const char *type_names[] = {
|
||||
"invalid",
|
||||
"char", "short", "int",
|
||||
"uchar", "ushort", "uint",
|
||||
"float", "double",
|
||||
};
|
||||
|
||||
|
||||
fprintf (fp, "%s", type_names[code]);
|
||||
}
|
||||
@@ -2096,16 +2126,23 @@ inline void swap_bytes(char *bytes, int num_bytes)
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
inline void get_native_binary_type()
|
||||
inline void get_native_binary_type(int *native_binary_type)
|
||||
{
|
||||
endian_test_type test;
|
||||
typedef union
|
||||
{
|
||||
int int_value;
|
||||
char byte_values[sizeof(int)];
|
||||
} endian_test_type;
|
||||
|
||||
test.int_value = 0;
|
||||
|
||||
endian_test_type test;
|
||||
|
||||
test.int_value = 0;
|
||||
test.int_value = 1;
|
||||
if (test.byte_values[0] == 1)
|
||||
native_binary_type = PLY_BINARY_LE;
|
||||
*native_binary_type = PLY_BINARY_LE;
|
||||
else if (test.byte_values[sizeof(int)-1] == 1)
|
||||
native_binary_type = PLY_BINARY_BE;
|
||||
*native_binary_type = PLY_BINARY_BE;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ply: Couldn't determine machine endianness.\n");
|
||||
@@ -2116,6 +2153,13 @@ inline void get_native_binary_type()
|
||||
|
||||
inline int get_native_binary_type2()
|
||||
{
|
||||
typedef union
|
||||
{
|
||||
int int_value;
|
||||
char byte_values[sizeof(int)];
|
||||
} endian_test_type;
|
||||
|
||||
|
||||
endian_test_type test;
|
||||
|
||||
test.int_value = 0;
|
||||
@@ -2138,8 +2182,12 @@ inline int get_native_binary_type2()
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
inline void check_types()
|
||||
inline int check_types()
|
||||
{
|
||||
int ply_type_size[] = {
|
||||
0, 1, 2, 4, 1, 2, 4, 4, 8
|
||||
};
|
||||
|
||||
if ((ply_type_size[PLY_CHAR] != sizeof(char)) ||
|
||||
(ply_type_size[PLY_SHORT] != sizeof(short)) ||
|
||||
(ply_type_size[PLY_INT] != sizeof(int)) ||
|
||||
@@ -2153,8 +2201,8 @@ inline void check_types()
|
||||
fprintf(stderr, "ply: Exiting...\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
types_checked = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -2175,8 +2223,8 @@ Exit:
|
||||
inline char **get_words(FILE *fp, int *nwords, char **orig_line)
|
||||
{
|
||||
#define BIG_STRING 4096
|
||||
static char str[BIG_STRING];
|
||||
static char str_copy[BIG_STRING];
|
||||
char str[BIG_STRING];
|
||||
char str_copy[BIG_STRING];
|
||||
char **words;
|
||||
int max_words = 10;
|
||||
int num_words = 0;
|
||||
@@ -2440,7 +2488,8 @@ inline void write_binary_item(
|
||||
int int_val,
|
||||
unsigned int uint_val,
|
||||
double double_val,
|
||||
int type
|
||||
int type,
|
||||
int *native_binary_type
|
||||
)
|
||||
{
|
||||
unsigned char uchar_val;
|
||||
@@ -2484,8 +2533,11 @@ inline void write_binary_item(
|
||||
fprintf (stderr, "write_binary_item: bad type = %d\n", type);
|
||||
exit (-1);
|
||||
}
|
||||
int ply_type_size[] = {
|
||||
0, 1, 2, 4, 1, 2, 4, 4, 8
|
||||
};
|
||||
|
||||
if ((file_type != native_binary_type) && (ply_type_size[type] > 1))
|
||||
if ((file_type != *native_binary_type) && (ply_type_size[type] > 1))
|
||||
swap_bytes((char *)value, ply_type_size[type]);
|
||||
|
||||
if (fwrite (value, ply_type_size[type], 1, fp) != 1)
|
||||
@@ -2713,13 +2765,17 @@ inline void get_binary_item(
|
||||
int type,
|
||||
int *int_val,
|
||||
unsigned int *uint_val,
|
||||
double *double_val
|
||||
double *double_val,
|
||||
int *native_binary_type
|
||||
)
|
||||
{
|
||||
char c[8];
|
||||
void *ptr;
|
||||
|
||||
ptr = (void *) c;
|
||||
int ply_type_size[] = {
|
||||
0, 1, 2, 4, 1, 2, 4, 4, 8
|
||||
};
|
||||
|
||||
if (fread (ptr, ply_type_size[type], 1, fp) != 1)
|
||||
{
|
||||
@@ -2728,7 +2784,7 @@ inline void get_binary_item(
|
||||
}
|
||||
|
||||
|
||||
if ((file_type != native_binary_type) && (ply_type_size[type] > 1))
|
||||
if ((file_type != *native_binary_type) && (ply_type_size[type] > 1))
|
||||
swap_bytes((char *)ptr, ply_type_size[type]);
|
||||
|
||||
switch (type) {
|
||||
@@ -2946,6 +3002,18 @@ Exit:
|
||||
inline int get_prop_type(char *type_name)
|
||||
{
|
||||
int i;
|
||||
const char *type_names[] = {
|
||||
"invalid",
|
||||
"char", "short", "int",
|
||||
"uchar", "ushort", "uint",
|
||||
"float", "double",
|
||||
};
|
||||
|
||||
const char *alt_type_names[] = {
|
||||
"invalid",
|
||||
"int8", "int16", "int32", "uint8", "uint16", "uint32", "float32", "float64",
|
||||
};
|
||||
|
||||
|
||||
for (i = PLY_START_TYPE + 1; i < PLY_END_TYPE; i++)
|
||||
if (equal_strings (type_name, type_names[i]))
|
||||
|
||||
+11
-9
@@ -16,7 +16,7 @@ template <
|
||||
typename Ntype,
|
||||
typename UVtype>
|
||||
IGL_INLINE bool igl::readPLY(
|
||||
const std::string & filename,
|
||||
const std::string filename,
|
||||
std::vector<std::vector<Vtype> > & V,
|
||||
std::vector<std::vector<Ftype> > & F,
|
||||
std::vector<std::vector<Ntype> > & N,
|
||||
@@ -88,6 +88,7 @@ IGL_INLINE bool igl::readPLY(
|
||||
int nprops;
|
||||
int elem_count;
|
||||
plist = ply_get_element_description (in_ply,"vertex", &elem_count, &nprops);
|
||||
int native_binary_type = get_native_binary_type2();
|
||||
if (plist != NULL)
|
||||
{
|
||||
/* set up for getting vertex elements */
|
||||
@@ -132,11 +133,12 @@ IGL_INLINE bool igl::readPLY(
|
||||
{
|
||||
UV.resize(0);
|
||||
}
|
||||
for(int j = 0;j<elem_count;j++)
|
||||
|
||||
for(int j = 0;j<elem_count;j++)
|
||||
{
|
||||
Vertex v;
|
||||
ply_get_element_setup(in_ply,"vertex",3,vert_props);
|
||||
ply_get_element(in_ply,(void*)&v);
|
||||
ply_get_element(in_ply,(void*)&v, &native_binary_type);
|
||||
V[j][0] = v.x;
|
||||
V[j][1] = v.y;
|
||||
V[j][2] = v.z;
|
||||
@@ -161,7 +163,7 @@ IGL_INLINE bool igl::readPLY(
|
||||
for (int j = 0; j < elem_count; j++)
|
||||
{
|
||||
Face f;
|
||||
ply_get_element(in_ply, (void *) &f);
|
||||
ply_get_element(in_ply, (void *) &f, &native_binary_type);
|
||||
for(size_t c = 0;c<f.nverts;c++)
|
||||
{
|
||||
F[j].push_back(f.verts[c]);
|
||||
@@ -178,7 +180,7 @@ template <
|
||||
typename DerivedN,
|
||||
typename DerivedUV>
|
||||
IGL_INLINE bool igl::readPLY(
|
||||
const std::string & filename,
|
||||
const std::string filename,
|
||||
Eigen::PlainObjectBase<DerivedV> & V,
|
||||
Eigen::PlainObjectBase<DerivedF> & F,
|
||||
Eigen::PlainObjectBase<DerivedN> & N,
|
||||
@@ -203,7 +205,7 @@ template <
|
||||
typename DerivedV,
|
||||
typename DerivedF>
|
||||
IGL_INLINE bool igl::readPLY(
|
||||
const std::string & filename,
|
||||
const std::string filename,
|
||||
Eigen::PlainObjectBase<DerivedV> & V,
|
||||
Eigen::PlainObjectBase<DerivedF> & F)
|
||||
{
|
||||
@@ -213,9 +215,9 @@ IGL_INLINE bool igl::readPLY(
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template bool igl::readPLY<double, int, double, double>(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&);
|
||||
template bool igl::readPLY<double, int, double, double>(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&);
|
||||
|
||||
template bool igl::readPLY<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &);
|
||||
template bool igl::readPLY<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &);
|
||||
|
||||
template bool igl::readPLY<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> > &);
|
||||
template bool igl::readPLY<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>, Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, Eigen::PlainObjectBase<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > &, Eigen::PlainObjectBase<Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic> > &);
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace igl
|
||||
typename Ntype,
|
||||
typename UVtype>
|
||||
IGL_INLINE bool readPLY(
|
||||
const std::string & filename,
|
||||
const std::string filename,
|
||||
std::vector<std::vector<Vtype> > & V,
|
||||
std::vector<std::vector<Ftype> > & F,
|
||||
std::vector<std::vector<Ntype> > & N,
|
||||
@@ -57,7 +57,7 @@ namespace igl
|
||||
typename DerivedN,
|
||||
typename DerivedUV>
|
||||
IGL_INLINE bool readPLY(
|
||||
const std::string & filename,
|
||||
const std::string filename,
|
||||
Eigen::PlainObjectBase<DerivedV> & V,
|
||||
Eigen::PlainObjectBase<DerivedF> & F,
|
||||
Eigen::PlainObjectBase<DerivedN> & N,
|
||||
@@ -66,7 +66,7 @@ namespace igl
|
||||
typename DerivedV,
|
||||
typename DerivedF>
|
||||
IGL_INLINE bool readPLY(
|
||||
const std::string & filename,
|
||||
const std::string filename,
|
||||
Eigen::PlainObjectBase<DerivedV> & V,
|
||||
Eigen::PlainObjectBase<DerivedF> & F);
|
||||
}
|
||||
|
||||
@@ -120,15 +120,16 @@ IGL_INLINE bool igl::writePLY(
|
||||
|
||||
ply_describe_element(ply, "face", F.rows(),1,&face_props[0]);
|
||||
ply_header_complete(ply);
|
||||
int native_binary_type = get_native_binary_type2();
|
||||
ply_put_element_setup(ply, "vertex");
|
||||
for(const auto v : vlist)
|
||||
{
|
||||
ply_put_element(ply, (void *) &v);
|
||||
ply_put_element(ply, (void *) &v, &native_binary_type);
|
||||
}
|
||||
ply_put_element_setup(ply, "face");
|
||||
for(const auto f : flist)
|
||||
{
|
||||
ply_put_element(ply, (void *) &f);
|
||||
ply_put_element(ply, (void *) &f, &native_binary_type);
|
||||
}
|
||||
|
||||
ply_close(ply);
|
||||
|
||||
@@ -1436,3 +1436,13 @@ const char *__doc_igl_writePLY = R"igl_Qu8mg5v7(// Write a mesh in an ascii ply
|
||||
// N #V by 3 normal vectors
|
||||
// UV #V by 2 texture coordinates
|
||||
// Returns true on success, false on error)igl_Qu8mg5v7";
|
||||
const char *__doc_igl_readPLY= R"igl_Qu8mg5v7(// Read a mesh from an ascii ply file, filling in vertex positions,
|
||||
// mesh indices, normals and texture coordinates
|
||||
// Inputs:
|
||||
// str path to .obj file
|
||||
// Outputs:
|
||||
// V double matrix of vertex positions #V by 3
|
||||
// F #F list of face indices into vertex positions
|
||||
// N double matrix of corner normals #N by 3
|
||||
// UV #V by 2 texture coordinates
|
||||
// Returns true on success, false on errors)igl_Qu8mg5v7";
|
||||
|
||||
@@ -118,3 +118,4 @@ extern const char *__doc_igl_winding_number_2;
|
||||
extern const char *__doc_igl_writeMESH;
|
||||
extern const char *__doc_igl_writeOBJ;
|
||||
extern const char *__doc_igl_writePLY;
|
||||
extern const char *__doc_igl_readPLY;
|
||||
|
||||
+2
-2
@@ -94,7 +94,7 @@
|
||||
#include <igl/writeMESH.h>
|
||||
#include <igl/writeOBJ.h>
|
||||
#include <igl/writePLY.h>
|
||||
|
||||
#include <igl/readPLY.h>
|
||||
|
||||
void python_export_igl(py::module &m)
|
||||
{
|
||||
@@ -191,5 +191,5 @@ void python_export_igl(py::module &m)
|
||||
#include "py_igl/py_writeMESH.cpp"
|
||||
#include "py_igl/py_writeOBJ.cpp"
|
||||
#include "py_igl/py_writePLY.cpp"
|
||||
|
||||
#include "py_igl/py_readPLY.cpp"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
m.def("readPLY", []
|
||||
(
|
||||
const std::string str,
|
||||
Eigen::MatrixXd& V,
|
||||
Eigen::MatrixXi& F,
|
||||
Eigen::MatrixXd& N,
|
||||
Eigen::MatrixXd& UV
|
||||
)
|
||||
{
|
||||
return igl::readPLY(str,V,F,N,UV);
|
||||
}, __doc_igl_readPLY,
|
||||
py::arg("str"), py::arg("V"), py::arg("F"), py::arg("N"), py::arg("UV"));
|
||||
@@ -153,6 +153,7 @@ PYBIND11_PLUGIN(pyigl) {
|
||||
writeMESH
|
||||
writeOBJ
|
||||
writePLY
|
||||
readPLY
|
||||
|
||||
)pyigldoc");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user