Commit 2b6ef96d authored by Matthias Möller's avatar Matthias Möller

fixes some cpp check warnings

refs #1403

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free-Staging@16367 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a16779e6
......@@ -90,9 +90,9 @@ template< class C > ConstArray< C > GetPointer( const std::vector< C >& v ){ ret
#define DeletePointer( ... ) { if( __VA_ARGS__ ) delete[] __VA_ARGS__ , __VA_ARGS__ = NULL; }
template< class C > C* NewPointer( size_t size , const char* name=NULL ){ return new C[size]; }
template< class C > C* AllocPointer( size_t size , const char* name=NULL ){ return (C*) malloc( sizeof(C) * size ); }
template< class C > C* AlignedAllocPointer( size_t size , size_t alignment , const char* name=NULL ){ return (C*)aligned_malloc( sizeof(C) * size , alignment ); }
template< class C > C* ReAllocPointer( C* c , size_t size , const char* name=NULL ){ return (C*) realloc( c , sizeof(C) * size ); }
template< class C > C* AllocPointer( size_t size , const char* name=NULL ){ return static_cast<C*> (malloc( sizeof(C) * size )); }
template< class C > C* AlignedAllocPointer( size_t size , size_t alignment , const char* name=NULL ){ return static_cast<C*>(aligned_malloc( sizeof(C) * size , alignment )); }
template< class C > C* ReAllocPointer( C* c , size_t size , const char* name=NULL ){ return static_cast<C*> (realloc( c , sizeof(C) * size )); }
template< class C > C* NullPointer( void ){ return NULL; }
......
......@@ -33,106 +33,106 @@ DAMAGE.
#include "PPolynomial.h"
#include "Array.h"
template< unsigned int Degree >
template< int Degree >
struct BSplineElementCoefficients
{
int coeffs[Degree+1];
BSplineElementCoefficients( void ) { memset( coeffs , 0 , sizeof( int ) * ( Degree+1 ) ); }
int& operator[]( int idx ){ return coeffs[idx]; }
const int& operator[]( int idx ) const { return coeffs[idx]; }
int coeffs[Degree+1];
BSplineElementCoefficients( void ) { memset( coeffs , 0 , sizeof( int ) * ( Degree+1 ) ); }
int& operator[]( unsigned int idx ){ if (idx <= Degree) return coeffs[idx]; return coeffs[0];}
const int& operator[]( unsigned int idx ) const {if (idx <= Degree) return coeffs[idx]; return coeffs[0];}
};
template< int Degree >
struct BSplineElements : public std::vector< BSplineElementCoefficients< Degree > >
{
static const int _off = (Degree+1)/2;
void _addLeft ( int offset , int boundary );
void _addRight( int offset , int boundary );
static const int _off = (Degree+1)/2;
void _addLeft ( int offset , int boundary );
void _addRight( int offset , int boundary );
public:
enum
{
NONE = 0,
DIRICHLET = -1,
NEUMANN = 1
};
// Coefficients are ordered as "/" "-" "\"
int denominator;
BSplineElements( void ) { denominator = 1; }
BSplineElements( int res , int offset , int boundary=NONE , int inset=0 );
void upSample( BSplineElements& high ) const;
void differentiate( BSplineElements< Degree-1 >& d ) const;
void print( FILE* fp=stdout ) const
{
enum
{
NONE = 0,
DIRICHLET = -1,
NEUMANN = 1
};
// Coefficients are ordered as "/" "-" "\"
int denominator;
BSplineElements( void ) { denominator = 1; }
BSplineElements( int res , int offset , int boundary=NONE , int inset=0 );
void upSample( BSplineElements& high ) const;
void differentiate( BSplineElements< Degree-1 >& d ) const;
void print( FILE* fp=stdout ) const
{
for( int i=0 ; i< this->size() ; i++ )
{
printf( "%d]" , i );
for( int j=0 ; j<=Degree ; j++ ) printf( " %d" , (*this)[i][j] );
printf( " (%d)\n" , denominator );
}
}
{
printf( "%d]" , i );
for( int j=0 ; j<=Degree ; j++ ) printf( " %d" , (*this)[i][j] );
printf( " (%d)\n" , denominator );
}
}
};
template< int Degree , class Real >
class BSplineData
{
bool useDotRatios;
int boundaryType;
bool useDotRatios;
int boundaryType;
public:
struct BSplineComponents
{
Polynomial< Degree > polys[Degree+1];
Polynomial< Degree >& operator[] ( int idx ) { return polys[idx]; }
const Polynomial< Degree >& operator[] ( int idx ) const { return polys[idx]; }
void printnl( void ) const { for( int d=0 ; d<=Degree ; d++ ) polys[d].printnl(); }
BSplineComponents scale( double s ) const { BSplineComponents b ; for( int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].scale(s) ; return b; }
BSplineComponents shift( double s ) const { BSplineComponents b ; for( int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].shift(s) ; return b; }
};
const static int VV_DOT_FLAG = 1;
const static int DV_DOT_FLAG = 2;
const static int DD_DOT_FLAG = 4;
const static int VALUE_FLAG = 1;
const static int D_VALUE_FLAG = 2;
int depth , functionCount , sampleCount;
Pointer( Real ) vvDotTable;
Pointer( Real ) dvDotTable;
Pointer( Real ) ddDotTable;
Pointer( Real ) valueTables;
Pointer( Real ) dValueTables;
PPolynomial< Degree > baseFunction , leftBaseFunction , rightBaseFunction , leftRightBaseFunction;
PPolynomial< Degree-1 > dBaseFunction , dLeftBaseFunction , dRightBaseFunction , dLeftRightBaseFunction;
BSplineComponents baseBSpline , leftBSpline , rightBSpline , leftRightBSpline;
Pointer( PPolynomial< Degree > ) baseFunctions;
Pointer( BSplineComponents ) baseBSplines;
BSplineData(void);
~BSplineData(void);
virtual void setDotTables( int flags , bool inset=false );
virtual void clearDotTables( int flags );
virtual void setValueTables( int flags , double smooth=0 );
virtual void setValueTables( int flags , double valueSmooth , double normalSmooth );
virtual void clearValueTables( void );
void setSampleSpan( int idx , int& start , int& end , double smooth=0 ) const;
/********************************************************
* Sets the translates and scales of the basis function
* up to the prescribed depth
* <maxDepth> the maximum depth
* <useDotRatios> specifies if dot-products of derivatives
* should be pre-divided by function integrals
* <reflectBoundary> spcifies if function space should be
* forced to be reflectively symmetric across the boundary
********************************************************/
void set( int maxDepth , bool useDotRatios=true , int boundaryType=BSplineElements< Degree >::NONE );
inline int Index( int i1 , int i2 ) const;
static inline int SymmetricIndex( int i1 , int i2 );
static inline int SymmetricIndex( int i1 , int i2 , int& index );
struct BSplineComponents
{
Polynomial< Degree > polys[Degree+1];
Polynomial< Degree >& operator[] ( unsigned int idx ) { return polys[idx]; }
const Polynomial< Degree >& operator[] ( unsigned int idx ) const { return polys[idx]; }
void printnl( void ) const { for( int d=0 ; d<=Degree ; d++ ) polys[d].printnl(); }
BSplineComponents scale( double s ) const { BSplineComponents b ; for( unsigned int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].scale(s) ; return b; }
BSplineComponents shift( double s ) const { BSplineComponents b ; for( unsigned int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].shift(s) ; return b; }
};
const static int VV_DOT_FLAG = 1;
const static int DV_DOT_FLAG = 2;
const static int DD_DOT_FLAG = 4;
const static int VALUE_FLAG = 1;
const static int D_VALUE_FLAG = 2;
int depth , functionCount , sampleCount;
Pointer( Real ) vvDotTable;
Pointer( Real ) dvDotTable;
Pointer( Real ) ddDotTable;
Pointer( Real ) valueTables;
Pointer( Real ) dValueTables;
PPolynomial< Degree > baseFunction , leftBaseFunction , rightBaseFunction , leftRightBaseFunction;
PPolynomial< Degree-1 > dBaseFunction , dLeftBaseFunction , dRightBaseFunction , dLeftRightBaseFunction;
BSplineComponents baseBSpline , leftBSpline , rightBSpline , leftRightBSpline;
Pointer( PPolynomial< Degree > ) baseFunctions;
Pointer( BSplineComponents ) baseBSplines;
BSplineData(void);
~BSplineData(void);
virtual void setDotTables( int flags , bool inset=false );
virtual void clearDotTables( int flags );
virtual void setValueTables( int flags , double smooth=0 );
virtual void setValueTables( int flags , double valueSmooth , double normalSmooth );
virtual void clearValueTables( void );
void setSampleSpan( int idx , int& start , int& end , double smooth=0 ) const;
/********************************************************
* Sets the translates and scales of the basis function
* up to the prescribed depth
* <maxDepth> the maximum depth
* <useDotRatios> specifies if dot-products of derivatives
* should be pre-divided by function integrals
* <reflectBoundary> spcifies if function space should be
* forced to be reflectively symmetric across the boundary
********************************************************/
void set( int maxDepth , bool useDotRatios=true , int boundaryType=BSplineElements< Degree >::NONE );
inline int Index( int i1 , int i2 ) const;
static inline int SymmetricIndex( int i1 , int i2 );
static inline int SymmetricIndex( int i1 , int i2 , int& index );
};
template< int Degree1 , int Degree2 > void SetBSplineElementIntegrals( double integrals[Degree1+1][Degree2+1] );
......
......@@ -164,6 +164,9 @@ CoredFileMeshData::CoredFileMeshData( void )
oocPointFile = new BufferedReadWriteFile();
polygonFile = new BufferedReadWriteFile();
memset(pointFileName,0,sizeof(char)*1024);
memset(polygonFileName,0,sizeof(char)*1024);
}
CoredFileMeshData::~CoredFileMeshData( void )
{
......
......@@ -29,8 +29,10 @@ DAMAGE.
#ifndef GEOMETRY_INCLUDED
#define GEOMETRY_INCLUDED
#include <math.h>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include "Hash.h"
template<class Real>
......@@ -308,11 +310,11 @@ public:
{
Point3D< float > start , end;
float value;
Vertex( void ) { ; }
Vertex( Point3D< float > s , Point3D< float > e , float v ) { start = s , end = e , value = v; }
Vertex( Point3D< float > s , Point3D< float > e , Point3D< float > p )
Vertex( void ):value(0.f) { ; }
Vertex( Point3D< float > s , Point3D< float > e , float v ):start(s),end(e),value(v) { }
Vertex( Point3D< float > s , Point3D< float > e , Point3D< float > p ):
start(s),end(e)
{
start = s , end = e;
// < p , e-s > = < s + v*(e-s) , e-s >
// < p , e-s > - < s , e-s > = v || e-s || ^2
// v = < p-s , e-s > / || e-s ||^2
......
......@@ -4,6 +4,12 @@
#include <hash_map>
using stdext::hash_map;
#else // !WIN32
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)>= 40300 //gcc >= 4.3
#include <tr1/unordered_map>
#define hash_map std::tr1::unordered_map
#else //GCC_VERSION < 40300
#include <ext/hash_map>
using namespace __gnu_cxx;
......@@ -24,6 +30,7 @@ namespace __gnu_cxx
size_t operator()(const unsigned long long __x) const { return __x; }
};
}
#endif // gcc >= 4.3
#endif // WIN32
#endif // HASH_INCLUDED
......@@ -34,46 +34,46 @@ DAMAGE.
#include <Windows.h>
class MemoryInfo{
public:
size_t TotalPhysicalMemory;
size_t FreePhysicalMemory;
size_t TotalSwapSpace;
size_t FreeSwapSpace;
size_t TotalVirtualAddressSpace;
size_t FreeVirtualAddressSpace;
size_t PageSize;
void set(void){
MEMORYSTATUSEX Mem;
SYSTEM_INFO Info;
ZeroMemory( &Mem, sizeof(Mem));
ZeroMemory( &Info, sizeof(Info));
Mem.dwLength = sizeof(Mem);
::GlobalMemoryStatusEx( &Mem );
::GetSystemInfo( &Info );
TotalPhysicalMemory = (size_t)Mem.ullTotalPhys;
FreePhysicalMemory = (size_t)Mem.ullAvailPhys;
TotalSwapSpace = (size_t)Mem.ullTotalPageFile;
FreeSwapSpace = (size_t)Mem.ullAvailPageFile;
TotalVirtualAddressSpace = (size_t)Mem.ullTotalVirtual;
FreeVirtualAddressSpace = (size_t)Mem.ullAvailVirtual;
PageSize = (size_t)Info.dwPageSize;
}
size_t usage(void) const {return TotalVirtualAddressSpace-FreeVirtualAddressSpace;}
static size_t Usage(void){
MEMORY_BASIC_INFORMATION mbi;
size_t dwMemUsed = 0;
PVOID pvAddress = 0;
memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION));
while(VirtualQuery(pvAddress, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) == sizeof(MEMORY_BASIC_INFORMATION)){
if(mbi.State == MEM_COMMIT && mbi.Type == MEM_PRIVATE){dwMemUsed += mbi.RegionSize;}
pvAddress = ((BYTE*)mbi.BaseAddress) + mbi.RegionSize;
}
return dwMemUsed;
}
size_t TotalPhysicalMemory;
size_t FreePhysicalMemory;
size_t TotalSwapSpace;
size_t FreeSwapSpace;
size_t TotalVirtualAddressSpace;
size_t FreeVirtualAddressSpace;
size_t PageSize;
void set(void){
MEMORYSTATUSEX Mem;
SYSTEM_INFO Info;
ZeroMemory( &Mem, sizeof(Mem));
ZeroMemory( &Info, sizeof(Info));
Mem.dwLength = sizeof(Mem);
::GlobalMemoryStatusEx( &Mem );
::GetSystemInfo( &Info );
TotalPhysicalMemory = (size_t)Mem.ullTotalPhys;
FreePhysicalMemory = (size_t)Mem.ullAvailPhys;
TotalSwapSpace = (size_t)Mem.ullTotalPageFile;
FreeSwapSpace = (size_t)Mem.ullAvailPageFile;
TotalVirtualAddressSpace = (size_t)Mem.ullTotalVirtual;
FreeVirtualAddressSpace = (size_t)Mem.ullAvailVirtual;
PageSize = (size_t)Info.dwPageSize;
}
size_t usage(void) const {return TotalVirtualAddressSpace-FreeVirtualAddressSpace;}
static size_t Usage(void){
MEMORY_BASIC_INFORMATION mbi;
size_t dwMemUsed = 0;
PVOID pvAddress = 0;
memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION));
while(VirtualQuery(pvAddress, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) == sizeof(MEMORY_BASIC_INFORMATION)){
if(mbi.State == MEM_COMMIT && mbi.Type == MEM_PRIVATE){dwMemUsed += mbi.RegionSize;}
pvAddress = ((BYTE*)mbi.BaseAddress) + mbi.RegionSize;
}
return dwMemUsed;
}
};
#else // !WIN32
......@@ -88,23 +88,23 @@ class MemoryInfo
public:
static size_t Usage(void)
{
FILE* f = fopen("/proc/self/stat","rb");
int d;
long ld;
unsigned long lu;
unsigned long long llu;
char tmp[256];
char* s = &tmp[0];
char c;
int pid;
unsigned long vm;
int n = fscanf(f, "%d %s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %d %ld %llu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu"
,&pid ,s ,&c ,&d ,&d ,&d ,&d ,&d ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&ld ,&ld ,&ld ,&ld ,&d ,&ld ,&llu ,&vm ,&ld ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&d ,&d ,&lu ,&lu );
fclose(f);
FILE* f = fopen("/proc/self/stat","rb");
int d;
long ld;
unsigned long lu;
unsigned long long llu;
char tmp[256];
char* s = &tmp[0];
char c;
int pid;
unsigned long vm;
fscanf(f, "%d %255s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %d %ld %llu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu"
,&pid ,s ,&c ,&d ,&d ,&d ,&d ,&d ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&ld ,&ld ,&ld ,&ld ,&d ,&ld ,&llu ,&vm ,&ld ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&d ,&d ,&lu ,&lu );
fclose(f);
/*
pid %d
comm %s
......@@ -148,8 +148,8 @@ processor %d
rt_priority %lu (since kernel 2.5.19)
policy %lu (since kernel 2.5.19)
*/
return vm;
}
return vm;
}
};
#else // __APPLE__: has no "/proc" pseudo-file system
......@@ -182,7 +182,7 @@ class MemoryInfo
public:
static size_t Usage(void)
{
unsigned long rss, vs, psize;
unsigned long rss, vs;
task_t task = MACH_PORT_NULL;
if (task_for_pid(current_task(), getpid(), &task) != KERN_SUCCESS)
......
......@@ -245,7 +245,7 @@ class Octree
Point3D< Real > position;
Real coarserValue;
Real weight;
PointData( Point3D< Real > p=Point3D< Real >() , Real w=0 ) { position = p , weight = w , coarserValue = Real(0); }
PointData( Point3D< Real > p=Point3D< Real >() , Real w=0 ):position(p),coarserValue(Real(0)),weight(w){}
};
std::vector< PointData > _points;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -34,80 +34,80 @@ DAMAGE.
template<int Degree>
class StartingPolynomial{
public:
Polynomial<Degree> p;
double start;
template<int Degree2>
StartingPolynomial<Degree+Degree2> operator * (const StartingPolynomial<Degree2>& p) const;
StartingPolynomial scale(double s) const;
StartingPolynomial shift(double t) const;
int operator < (const StartingPolynomial& sp) const;
static int Compare(const void* v1,const void* v2);
Polynomial<Degree> p;
double start;
template<int Degree2>
StartingPolynomial<Degree+Degree2> operator * (const StartingPolynomial<Degree2>& p) const;
StartingPolynomial scale(double s) const;
StartingPolynomial shift(double t) const;
int operator < (const StartingPolynomial& sp) const;
static int Compare(const void* v1,const void* v2);
};
template<int Degree>
class PPolynomial
{
public:
size_t polyCount;
StartingPolynomial<Degree>* polys;
size_t polyCount;
StartingPolynomial<Degree>* polys;
PPolynomial(void);
PPolynomial(const PPolynomial<Degree>& p);
~PPolynomial(void);
PPolynomial(void);
PPolynomial(const PPolynomial<Degree>& p);
~PPolynomial(void);
PPolynomial& operator = (const PPolynomial& p);
PPolynomial& operator = (const PPolynomial& p);
int size(void) const;
int size(void) const;
void set( size_t size );
// Note: this method will sort the elements in sps
void set( StartingPolynomial<Degree>* sps , int count );
void reset( size_t newSize );
void set( size_t size );
// Note: this method will sort the elements in sps
void set( StartingPolynomial<Degree>* sps , int count );
void reset( size_t newSize );
double operator()( double t ) const;
double integral( double tMin , double tMax ) const;
double Integral( void ) const;
double operator()( double t ) const;
double integral( double tMin , double tMax ) const;
double Integral( void ) const;
template<int Degree2>
PPolynomial<Degree>& operator = (const PPolynomial<Degree2>& p);
template<int Degree2>
PPolynomial<Degree>& operator = (const PPolynomial<Degree2>& p);
PPolynomial operator + (const PPolynomial& p) const;
PPolynomial operator - (const PPolynomial& p) const;
PPolynomial operator + (const PPolynomial& p) const;
PPolynomial operator - (const PPolynomial& p) const;
template<int Degree2>
PPolynomial<Degree+Degree2> operator * (const Polynomial<Degree2>& p) const;
template<int Degree2>
PPolynomial<Degree+Degree2> operator * (const Polynomial<Degree2>& p) const;
template<int Degree2>
PPolynomial<Degree+Degree2> operator * (const PPolynomial<Degree2>& p) const;
template<int Degree2>
PPolynomial<Degree+Degree2> operator * (const PPolynomial<Degree2>& p) const;
PPolynomial& operator += ( double s );
PPolynomial& operator -= ( double s );
PPolynomial& operator *= ( double s );
PPolynomial& operator /= ( double s );
PPolynomial operator + ( double s ) const;
PPolynomial operator - ( double s ) const;
PPolynomial operator * ( double s ) const;
PPolynomial operator / ( double s ) const;
PPolynomial& operator += ( double s );
PPolynomial& operator -= ( double s );
PPolynomial& operator *= ( double s );
PPolynomial& operator /= ( double s );
PPolynomial operator + ( double s ) const;
PPolynomial operator - ( double s ) const;
PPolynomial operator * ( double s ) const;
PPolynomial operator / ( double s ) const;
PPolynomial& addScaled(const PPolynomial& poly,double scale);
PPolynomial& addScaled(const PPolynomial& poly,double scale);
PPolynomial scale( double s ) const;
PPolynomial shift( double t ) const;
PPolynomial scale( double s ) const;
PPolynomial shift( double t ) const;
PPolynomial< Degree-1 > derivative(void) const;
PPolynomial< Degree+1 > integral(void) const;
PPolynomial< Degree-1 > derivative(void) const;
PPolynomial< Degree+1 > integral(void) const;
void getSolutions(double c,std::vector<double>& roots,double EPS,double min=-DBL_MAX,double max=DBL_MAX) const;
void getSolutions(double c,std::vector<double>& roots,double EPS,double min=-DBL_MAX,double max=DBL_MAX) const;
void printnl( void ) const;
void printnl( void ) const;
PPolynomial< Degree+1 > MovingAverage( double radius );
static PPolynomial BSpline( double radius=0.5 );
PPolynomial< Degree+1 > MovingAverage( double radius );
static PPolynomial BSpline( double radius=0.5 );
void write( FILE* fp , int samples , double min , double max ) const;
void write( FILE* fp , int samples , double min , double max ) const;
};
#include "PPolynomial.inl"
#endif // P_POLYNOMIAL_INCLUDED
......@@ -29,64 +29,64 @@ DAMAGE.
template< class Real >
ASCIIPointStream< Real >::ASCIIPointStream( const char* fileName )
{
_fp = fopen( fileName , "r" );
if( !_fp ) fprintf( stderr , "Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
_fp = fopen( fileName , "r" );
if( !_fp ) fprintf( stderr , "Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
}
template< class Real >
ASCIIPointStream< Real >::~ASCIIPointStream( void )
{
fclose( _fp );
_fp = NULL;
fclose( _fp );
_fp = NULL;
}
template< class Real >
void ASCIIPointStream< Real >::reset( void ) { fseek( _fp , SEEK_SET , 0 ); }
template< class Real >
bool ASCIIPointStream< Real >::nextPoint( Point3D< Real >& p , Point3D< Real >& n )
{
float c[2*DIMENSION];
if( fscanf( _fp , " %f %f %f %f %f %f " , &c[0] , &c[1] , &c[2] , &c[3] , &c[4] , &c[5] )!=2*DIMENSION ) return false;
p[0] = c[0] , p[1] = c[1] , p[2] = c[2];
n[0] = c[3] , n[1] = c[4] , n[2] = c[5];
return true;
float c[2*DIMENSION];
if( fscanf( _fp , " %8f %8f %8f %8f %8f %8f " , &c[0] , &c[1] , &c[2] , &c[3] , &c[4] , &c[5] )!=2*DIMENSION ) return false;
p[0] = c[0] , p[1] = c[1] , p[2] = c[2];
n[0] = c[3] , n[1] = c[4] , n[2] = c[5];
return true;
}
template< class Real >
BinaryPointStream< Real >::BinaryPointStream( const char* fileName )
{
_pointsInBuffer = _currentPointIndex = 0;
_fp = fopen( fileName , "rb" );
if( !_fp ) fprintf( stderr , "Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
_pointsInBuffer = _currentPointIndex = 0;
_fp = fopen( fileName , "rb" );
if( !_fp ) fprintf( stderr , "Failed to open file for reading: %s\n" , fileName ) , exit( 0 );
}
template< class Real >
BinaryPointStream< Real >::~BinaryPointStream( void )
{
fclose( _fp );
_fp = NULL;
fclose( _fp );
_fp = NULL;
}
template< class Real >
void BinaryPointStream< Real >::reset( void )
{
fseek( _fp , SEEK_SET , 0 );
_pointsInBuffer = _currentPointIndex = 0;
fseek( _fp , SEEK_SET , 0 );
_pointsInBuffer = _currentPointIndex = 0;
}
template< class Real >
bool BinaryPointStream< Real >::nextPoint( Point3D< Real >& p , Point3D< Real >& n )
{
if( _currentPointIndex<_pointsInBuffer )
{
p[0] = _pointBuffer[ _currentPointIndex*6+0 ];
p[1] = _pointBuffer[ _currentPointIndex*6+1 ];
p[2] = _pointBuffer[ _currentPointIndex*6+2 ];
n[0] = _pointBuffer[ _currentPointIndex*6+3 ];
n[1] = _pointBuffer[ _currentPointIndex*6+4 ];
n[2] = _pointBuffer[ _currentPointIndex*6+5 ];
_currentPointIndex++;
return true;
}
else
{
_currentPointIndex = 0;
_pointsInBuffer = int( fread( _pointBuffer , sizeof( Real ) * 6 , POINT_BUFFER_SIZE , _fp ) );
if( !_pointsInBuffer ) return false;
else return nextPoint( p , n );
}
if( _currentPointIndex<_pointsInBuffer )
{
p[0] = _pointBuffer[ _currentPointIndex*6+0 ];
p[1] = _pointBuffer[ _currentPointIndex*6+1 ];