mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-19 19:14:42 +00:00
Poisson 6.12 Merging:
- Minor Improvements to the Plyclass (const stuff...)
This commit is contained in:
parent
5f3e4a0422
commit
07cbb405ba
@ -79,6 +79,7 @@ extern "C" {
|
||||
#define PLY_SCALAR 0
|
||||
#define PLY_LIST 1
|
||||
|
||||
#define PLY_STRIP_COMMENT_HEADER 0
|
||||
|
||||
typedef struct PlyProperty { /* description of a property */
|
||||
|
||||
@ -187,10 +188,10 @@ extern char *my_alloc();
|
||||
extern PlyFile *ply_write(FILE *, int, const char **, int);
|
||||
extern PlyFile *ply_open_for_writing(char *, int, const char **, int, float *);
|
||||
extern void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *);
|
||||
extern void ply_describe_property(PlyFile *, char *, PlyProperty *);
|
||||
extern void ply_element_count(PlyFile *, char *, int);
|
||||
extern void ply_describe_property(PlyFile *, const char *, PlyProperty *);
|
||||
extern void ply_element_count(PlyFile *, const char *, int);
|
||||
extern void ply_header_complete(PlyFile *);
|
||||
extern void ply_put_element_setup(PlyFile *, char *);
|
||||
extern void ply_put_element_setup(PlyFile *, const char *);
|
||||
extern void ply_put_element(PlyFile *, void *);
|
||||
extern void ply_put_comment(PlyFile *, char *);
|
||||
extern void ply_put_obj_info(PlyFile *, char *);
|
||||
@ -219,6 +220,14 @@ extern int equal_strings(const char *, const char *);
|
||||
#include "Geometry.h"
|
||||
#include <vector>
|
||||
|
||||
template< class Real > int PLYType( void );
|
||||
template<> inline int PLYType< int >( void ){ return PLY_INT ; }
|
||||
template<> inline int PLYType< char >( void ){ return PLY_CHAR ; }
|
||||
template<> inline int PLYType< unsigned char >( void ){ return PLY_UCHAR ; }
|
||||
template<> inline int PLYType< float >( void ){ return PLY_FLOAT ; }
|
||||
template<> inline int PLYType< double >( void ){ return PLY_DOUBLE; }
|
||||
template< class Real > inline int PLYType( void ){ fprintf( stderr , "[ERROR] Unrecognized type\n" ) , exit( 0 ); }
|
||||
|
||||
typedef struct PlyFace
|
||||
{
|
||||
unsigned char nr_vertices;
|
||||
@ -227,7 +236,7 @@ typedef struct PlyFace
|
||||
} PlyFace;
|
||||
static PlyProperty face_props[] =
|
||||
{
|
||||
{ "vertex_indices" , PLY_INT , PLY_INT , offsetof(PlyFace,vertices) , 1 , PLY_UCHAR, PLY_UCHAR , offsetof(PlyFace,nr_vertices) },
|
||||
{ _strdup( "vertex_indices" ) , PLY_INT , PLY_INT , offsetof( PlyFace , vertices ) , 1 , PLY_UCHAR, PLY_UCHAR , offsetof(PlyFace,nr_vertices) },
|
||||
};
|
||||
|
||||
template< class Real >
|
||||
@ -251,19 +260,11 @@ public:
|
||||
template< class _Real > PlyVertex& operator /= ( _Real s ) { point /= s ; return *this; }
|
||||
};
|
||||
template< class Real , class _Real > PlyVertex< Real > operator * ( XForm4x4< _Real > xForm , PlyVertex< Real > v ) { return PlyVertex< Real >( xForm * v.point ); }
|
||||
template<>
|
||||
PlyProperty PlyVertex< float >::Properties[]=
|
||||
template< class Real > PlyProperty PlyVertex< Real >::Properties[]=
|
||||
{
|
||||
{"x", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyVertex,point.coords[0])), 0, 0, 0, 0},
|
||||
{"y", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyVertex,point.coords[1])), 0, 0, 0, 0},
|
||||
{"z", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyVertex,point.coords[2])), 0, 0, 0, 0}
|
||||
};
|
||||
template<>
|
||||
PlyProperty PlyVertex< double >::Properties[]=
|
||||
{
|
||||
{"x", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyVertex,point.coords[0])), 0, 0, 0, 0},
|
||||
{"y", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyVertex,point.coords[1])), 0, 0, 0, 0},
|
||||
{"z", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyVertex,point.coords[2])), 0, 0, 0, 0}
|
||||
{ _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 }
|
||||
};
|
||||
template< class Real >
|
||||
class PlyValueVertex
|
||||
@ -287,21 +288,13 @@ public:
|
||||
template< class _Real > PlyValueVertex& operator /= ( _Real s ) { point /= s , value /= Real(s) ; return *this; }
|
||||
};
|
||||
template< class Real , class _Real > PlyValueVertex< Real > operator * ( XForm4x4< _Real > xForm , PlyValueVertex< Real > v ) { return PlyValueVertex< Real >( xForm * v.point , v.value ); }
|
||||
template< >
|
||||
PlyProperty PlyValueVertex< float >::Properties[]=
|
||||
template< class Real >
|
||||
PlyProperty PlyValueVertex< Real >::Properties[]=
|
||||
{
|
||||
{"x", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyValueVertex,point.coords[0])), 0, 0, 0, 0},
|
||||
{"y", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyValueVertex,point.coords[1])), 0, 0, 0, 0},
|
||||
{"z", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyValueVertex,point.coords[2])), 0, 0, 0, 0},
|
||||
{"value", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyValueVertex,value)), 0, 0, 0, 0}
|
||||
};
|
||||
template< >
|
||||
PlyProperty PlyValueVertex< double >::Properties[]=
|
||||
{
|
||||
{"x", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyValueVertex,point.coords[0])), 0, 0, 0, 0},
|
||||
{"y", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyValueVertex,point.coords[1])), 0, 0, 0, 0},
|
||||
{"z", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyValueVertex,point.coords[2])), 0, 0, 0, 0},
|
||||
{"value", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyValueVertex,value)), 0, 0, 0, 0}
|
||||
{ _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "value" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , value ) ) , 0 , 0 , 0 , 0 }
|
||||
};
|
||||
template< class Real >
|
||||
class PlyOrientedVertex
|
||||
@ -324,25 +317,15 @@ public:
|
||||
template< class _Real > PlyOrientedVertex& operator /= ( _Real s ) { point /= s , normal /= s ; return *this; }
|
||||
};
|
||||
template< class Real , class _Real > PlyOrientedVertex< Real > operator * ( XForm4x4< _Real > xForm , PlyOrientedVertex< Real > v ) { return PlyOrientedVertex< Real >( xForm * v.point , xForm.inverse().transpose() * v.normal ); }
|
||||
template<>
|
||||
PlyProperty PlyOrientedVertex< float >::Properties[]=
|
||||
template< class Real >
|
||||
PlyProperty PlyOrientedVertex< Real >::Properties[]=
|
||||
{
|
||||
{"x", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyOrientedVertex,point.coords[0])), 0, 0, 0, 0},
|
||||
{"y", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyOrientedVertex,point.coords[1])), 0, 0, 0, 0},
|
||||
{"z", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyOrientedVertex,point.coords[2])), 0, 0, 0, 0},
|
||||
{"nx", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyOrientedVertex,normal.coords[0])), 0, 0, 0, 0},
|
||||
{"ny", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyOrientedVertex,normal.coords[1])), 0, 0, 0, 0},
|
||||
{"nz", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyOrientedVertex,normal.coords[2])), 0, 0, 0, 0}
|
||||
};
|
||||
template<>
|
||||
PlyProperty PlyOrientedVertex< double >::Properties[]=
|
||||
{
|
||||
{"x", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyOrientedVertex,point.coords[0])), 0, 0, 0, 0},
|
||||
{"y", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyOrientedVertex,point.coords[1])), 0, 0, 0, 0},
|
||||
{"z", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyOrientedVertex,point.coords[2])), 0, 0, 0, 0},
|
||||
{"nx", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyOrientedVertex,normal.coords[0])), 0, 0, 0, 0},
|
||||
{"ny", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyOrientedVertex,normal.coords[1])), 0, 0, 0, 0},
|
||||
{"nz", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyOrientedVertex,normal.coords[2])), 0, 0, 0, 0}
|
||||
{ _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "nx" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , normal.coords[0] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "ny" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , normal.coords[1] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "nz" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , normal.coords[2] ) ) , 0 , 0 , 0 , 0 }
|
||||
};
|
||||
template< class Real >
|
||||
class PlyColorVertex
|
||||
@ -359,25 +342,15 @@ public:
|
||||
PlyColorVertex(void) {point.coords[0]=point.coords[1]=point.coords[2]=0,color[0]=color[1]=color[2]=0;}
|
||||
PlyColorVertex(const Point3D<Real>& p) {point=p;}
|
||||
};
|
||||
template<>
|
||||
PlyProperty PlyColorVertex< float >::Properties[]=
|
||||
template< class Real >
|
||||
PlyProperty PlyColorVertex< Real >::Properties[]=
|
||||
{
|
||||
{"x", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyColorVertex,point.coords[0])), 0, 0, 0, 0},
|
||||
{"y", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyColorVertex,point.coords[1])), 0, 0, 0, 0},
|
||||
{"z", PLY_FLOAT, PLY_FLOAT, int(offsetof(PlyColorVertex,point.coords[2])), 0, 0, 0, 0},
|
||||
{"red", PLY_UCHAR, PLY_UCHAR, int(offsetof(PlyColorVertex,color[0])), 0, 0, 0, 0},
|
||||
{"green", PLY_UCHAR, PLY_UCHAR, int(offsetof(PlyColorVertex,color[1])), 0, 0, 0, 0},
|
||||
{"blue", PLY_UCHAR, PLY_UCHAR, int(offsetof(PlyColorVertex,color[2])), 0, 0, 0, 0}
|
||||
};
|
||||
template<>
|
||||
PlyProperty PlyColorVertex< double >::Properties[]=
|
||||
{
|
||||
{"x", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyColorVertex,point.coords[0])), 0, 0, 0, 0},
|
||||
{"y", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyColorVertex,point.coords[1])), 0, 0, 0, 0},
|
||||
{"z", PLY_DOUBLE, PLY_DOUBLE, int(offsetof(PlyColorVertex,point.coords[2])), 0, 0, 0, 0},
|
||||
{"red", PLY_UCHAR, PLY_UCHAR, int(offsetof(PlyColorVertex,color[0])), 0, 0, 0, 0},
|
||||
{"green", PLY_UCHAR, PLY_UCHAR, int(offsetof(PlyColorVertex,color[1])), 0, 0, 0, 0},
|
||||
{"blue", PLY_UCHAR, PLY_UCHAR, int(offsetof(PlyColorVertex,color[2])), 0, 0, 0, 0}
|
||||
{ _strdup( "x" ) , PLYType< Real >() , PLYType< Real >(), int( offsetof( PlyColorVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "y" ) , PLYType< Real >() , PLYType< Real >(), int( offsetof( PlyColorVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "z" ) , PLYType< Real >() , PLYType< Real >(), int( offsetof( PlyColorVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "red" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[0] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "green" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[1] ) ) , 0 , 0 , 0 , 0 },
|
||||
{ _strdup( "blue" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[2] ) ) , 0 , 0 , 0 , 0 }
|
||||
};
|
||||
|
||||
template< class Vertex , class Real >
|
||||
|
||||
@ -36,9 +36,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "PlyFile.h"
|
||||
#include "Ply.h"
|
||||
|
||||
char *type_names[] = {
|
||||
const char *type_names[] = {
|
||||
"invalid",
|
||||
"char",
|
||||
"short",
|
||||
@ -102,10 +102,10 @@ static int types_checked = 0;
|
||||
int equal_strings(const char *, const char *);
|
||||
|
||||
/* find an element in a plyfile's list */
|
||||
PlyElement *find_element(PlyFile *, char *);
|
||||
PlyElement *find_element(PlyFile *, const char *);
|
||||
|
||||
/* find a property in an element's list */
|
||||
PlyProperty *find_property(PlyElement *, char *, int *);
|
||||
PlyProperty *find_property(PlyElement *, const char *, int *);
|
||||
|
||||
/* write to a file the word describing a PLY file data type */
|
||||
void write_scalar_type (FILE *, int);
|
||||
@ -146,7 +146,7 @@ void ascii_get_element(PlyFile *, char *);
|
||||
void binary_get_element(PlyFile *, char *);
|
||||
|
||||
/* memory allocation */
|
||||
char *my_alloc(int, int, char *);
|
||||
char *my_alloc(int, int, const char *);
|
||||
|
||||
/* byte ordering */
|
||||
void get_native_binary_type();
|
||||
@ -336,7 +336,7 @@ Describe a property of an element.
|
||||
|
||||
void ply_describe_property(
|
||||
PlyFile *plyfile,
|
||||
char *elem_name,
|
||||
const char *elem_name,
|
||||
PlyProperty *prop
|
||||
)
|
||||
{
|
||||
@ -442,7 +442,7 @@ State how many of a given element will be written.
|
||||
|
||||
void ply_element_count(
|
||||
PlyFile *plyfile,
|
||||
char *elem_name,
|
||||
const char *elem_name,
|
||||
int nelems
|
||||
)
|
||||
{
|
||||
@ -540,7 +540,7 @@ before a call to the routine ply_put_element().
|
||||
elem_name - name of element we're talking about
|
||||
******************************************************************************/
|
||||
|
||||
void ply_put_element_setup(PlyFile *plyfile, char *elem_name)
|
||||
void ply_put_element_setup(PlyFile *plyfile, const char *elem_name)
|
||||
{
|
||||
PlyElement *elem;
|
||||
|
||||
@ -1479,7 +1479,7 @@ Open a polygon file for reading.
|
||||
returns the element, or NULL if not found
|
||||
******************************************************************************/
|
||||
|
||||
PlyElement *find_element(PlyFile *plyfile, char *element)
|
||||
PlyElement *find_element(PlyFile *plyfile, const char *element)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -1503,7 +1503,7 @@ Open a polygon file for reading.
|
||||
returns a pointer to the property, or NULL if not found
|
||||
******************************************************************************/
|
||||
|
||||
PlyProperty *find_property(PlyElement *elem, char *prop_name, int *index)
|
||||
PlyProperty *find_property(PlyElement *elem, const char *prop_name, int *index)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -2712,7 +2712,7 @@ Read an element from a binary file.
|
||||
fname - file name from which memory was requested
|
||||
******************************************************************************/
|
||||
|
||||
char *my_alloc(int size, int lnum, char *fname)
|
||||
char *my_alloc(int size, int lnum, const char *fname)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user