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

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,13 +33,13 @@ 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& 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 > >
......@@ -83,11 +83,11 @@ 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]; }
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( 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; }
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;
......
......@@ -73,16 +73,21 @@ template< int Degree > inline int ReflectRight( unsigned int depth , int offset
else return r-1-offset;
}
template< int Degree , class Real >
template<int Degree,class Real>
BSplineData<Degree,Real>::BSplineData( void ) :
depth(0)
useDotRatios(false),
boundaryType(0),
depth(0),
functionCount(0),
sampleCount(0),
baseFunctions(NULL),
baseBSplines(NULL)
{
vvDotTable = dvDotTable = ddDotTable = NullPointer< Real >();
valueTables = dValueTables = NullPointer< Real >();
functionCount = sampleCount = 0;
}
template< int Degree , class Real >
template<int Degree,class Real>
BSplineData< Degree , Real >::~BSplineData(void)
{
if( functionCount )
......@@ -96,7 +101,7 @@ BSplineData< Degree , Real >::~BSplineData(void)
functionCount = 0;
}
template< int Degree , class Real >
template<int Degree,class Real>
void BSplineData<Degree,Real>::set( int maxDepth , bool useDotRatios , int boundaryType )
{
this->useDotRatios = useDotRatios;
......@@ -290,7 +295,7 @@ void BSplineData<Degree,Real>::setDotTables( int flags , bool inset )
}
}
}
template<int Degree,class Real>
template< int Degree,class Real>
void BSplineData<Degree,Real>::clearDotTables( int flags )
{
if( (flags & VV_DOT_FLAG) && vvDotTable ) DeletePointer( vvDotTable );
......@@ -316,7 +321,7 @@ void BSplineData< Degree , Real >::setSampleSpan( int idx , int& start , int& en
end = int( ceil( _end * (sampleCount-1) - 1 ) );
if( end>=sampleCount ) end = sampleCount-1;
}
template<int Degree,class Real>
template< int Degree,class Real>
void BSplineData<Degree,Real>::setValueTables( int flags , double smooth )
{
clearValueTables();
......@@ -344,7 +349,7 @@ void BSplineData<Degree,Real>::setValueTables( int flags , double smooth )
}
}
}
template<int Degree,class Real>
template< int Degree,class Real>
void BSplineData<Degree,Real>::setValueTables( int flags , double valueSmooth , double derivativeSmooth )
{
clearValueTables();
......@@ -369,21 +374,21 @@ void BSplineData<Degree,Real>::setValueTables( int flags , double valueSmooth ,
}
template<int Degree,class Real>
template< int Degree,class Real>
void BSplineData<Degree,Real>::clearValueTables(void){
if( valueTables ) DeletePointer( valueTables );
if( dValueTables ) DeletePointer( dValueTables );
}
template<int Degree,class Real>
template< int Degree,class Real>
inline int BSplineData<Degree,Real>::Index( int i1 , int i2 ) const { return i1*functionCount+i2; }
template<int Degree,class Real>
template< int Degree,class Real>
inline int BSplineData<Degree,Real>::SymmetricIndex( int i1 , int i2 )
{
if( i1>i2 ) return ((i1*i1+i1)>>1)+i2;
else return ((i2*i2+i2)>>1)+i1;
}
template<int Degree,class Real>
template< int Degree,class Real>
inline int BSplineData<Degree,Real>::SymmetricIndex( int i1 , int i2 , int& index )
{
if( i1<i2 )
......@@ -513,9 +518,9 @@ void BSplineElements< Degree >::differentiate( BSplineElements< Degree-1 >& d )
{
d.resize( this->size() );
d.assign( d.size() , BSplineElementCoefficients< Degree-1 >() );
for( int i=0 ; i<int(this->size()) ; i++ ) for( int j=0 ; j<=Degree ; j++ )
for(int i=0 ; i<int(this->size()) ; i++ ) for(int j=0 ; j<=Degree ; j++ )
{
if( j-1>=0 ) d[i][j-1] -= (*this)[i][j];
if( j>0 ) d[i][j-1] -= (*this)[i][j];
if( j<Degree ) d[i][j ] += (*this)[i][j];
}
d.denominator = denominator;
......@@ -525,10 +530,10 @@ void BSplineElements< Degree >::differentiate( BSplineElements< Degree-1 >& d )
template< int Degree1 , int Degree2 >
void SetBSplineElementIntegrals( double integrals[Degree1+1][Degree2+1] )
{
for( int i=0 ; i<=Degree1 ; i++ )
for(int i=0 ; i<=Degree1 ; i++ )
{
Polynomial< Degree1 > p1 = Polynomial< Degree1 >::BSplineComponent( i );
for( int j=0 ; j<=Degree2 ; j++ )
for(int j=0 ; j<=Degree2 ; j++ )
{
Polynomial< Degree2 > p2 = Polynomial< Degree2 >::BSplineComponent( j );
integrals[i][j] = ( p1 * p2 ).integral( 0 , 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
......@@ -101,7 +101,7 @@ class MemoryInfo
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"
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);
......@@ -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;
......
......@@ -29,7 +29,7 @@ DAMAGE.
#ifndef DOXY_IGNORE_THIS
#include "Octree.h"
#include "time.h"
#include "Time.h"
#include "MemoryUsage.h"
#include "PointStream.h"
#include "MAT.h"
......@@ -211,7 +211,7 @@ void SortedTreeNodes::setCornerTable( CornerTableData& cData , const TreeOctNode
int& idx = cData[ treeNodes[i] ][c];
if( idx<0 )
{
fprintf( stderr , "[ERROR] Found unindexed corner nodes[%d][%d] = %d (%d,%d)\n" , treeNodes[i]->nodeData.nodeIndex , c , idx , minDepth , maxDepth );
fprintf( stderr , "[ERROR] Found unindexed corner nodes[%d][%u] = %d (%d,%d)\n" , treeNodes[i]->nodeData.nodeIndex , c , idx , minDepth , maxDepth );
int _d , _off[3];
treeNodes[i]->depthAndOffset( _d , _off );
if( rootNode )
......@@ -521,7 +521,11 @@ Octree<Degree>::Octree(void)
radius = 0;
width = 0;
postDerivativeSmooth = 0;
_minDepth = 0;
_constrainValues = false;
_boundaryType = 0;
_scale = Real(0);
normals = NULL;
}
template< int Degree >
......@@ -2303,10 +2307,10 @@ int Octree< Degree >::GetFixedDepthLaplacian( SparseSymmetricMatrix< Real >& mat
}
// Offset the constraints using the solution from lower resolutions.
int x , y , z , c;
int x , y , z;
if( node->parent )
{
c = int( node - node->parent->children );
int c = int( node - node->parent->children );
Cube::FactorCornerIndex( c , x , y , z );
}
else x = y = z = 0;
......@@ -2369,10 +2373,10 @@ int Octree<Degree>::GetRestrictedFixedDepthLaplacian( SparseSymmetricMatrix< Rea
}
// Adjust the system constraints
int x , y , z , c;
int x , y , z ;
if( node->parent )
{
c = int( node - node->parent->children );
int c = int( node - node->parent->children );
Cube::FactorCornerIndex( c , x , y , z );
}
else x = y = z = 0;
......@@ -2488,7 +2492,7 @@ int Octree<Degree>::_SolveFixedDepthMatrix( int depth , const SortedTreeNodes& s
AdjacencySetFunction asf;
AdjacencyCountFunction acf;
double systemTime = 0 , solveTime = 0 , memUsage = 0 , evaluateTime = 0 , gTime , sTime;
Real myRadius, myRadius2;
Real myRadius;
if( depth>_minDepth )
{
......@@ -2520,7 +2524,6 @@ int Octree<Degree>::_SolveFixedDepthMatrix( int depth , const SortedTreeNodes& s
myRadius = 2*radius-Real(0.5);
myRadius = int(myRadius-ROUND_EPS)+ROUND_EPS;
// myRadius2 = Real(radius+ROUND_EPS-0.5);
d = depth-startingDepth;
if( _boundaryType==0 ) d++;
std::vector< int > subDimension( sNodes.nodeCount[d+1]-sNodes.nodeCount[d] );
......@@ -3113,7 +3116,7 @@ void Octree<Degree>::GetMCIsoTriangles( Real isoValue , int subdivideDepth , Cor
#ifdef USE_OPENMP
#pragma omp parallel for num_threads( threads )
#endif
for( int t=0 ; t<threads ; t++ ) for( int i=(leafNodeCount*t)/threads ; i<(leafNodeCount*(t+1))/threads ; i++ )
for( int t=0 ; t<threads ; t++ ) for( int i=(leafNodeCount*t)/threads ; i<(leafNodeCount*(t+1))/threads ; ++i )
{
TreeOctNode* leaf = leafNodes[i];
if( _boundaryType!=0 || _IsInset( leaf ) ) GetMCIsoTriangles( leaf , mesh , rootData , interiorPoints , offSet , sDepth , polygonMesh , barycenterPtr );
......@@ -3131,7 +3134,7 @@ void Octree<Degree>::GetMCIsoTriangles( Real isoValue , int subdivideDepth , Cor
DeletePointer( rootData.edgesSet );
coarseRootData.interiorRoots = NullPointer< int >();
coarseRootData.boundaryValues = rootData.boundaryValues;
for( hash_map< long long , int >::iterator iter=rootData.boundaryRoots.begin() ; iter!=rootData.boundaryRoots.end() ; iter++ )
for( hash_map< long long , int >::iterator iter=rootData.boundaryRoots.begin() ; iter!=rootData.boundaryRoots.end() ; ++iter )
coarseRootData.boundaryRoots[iter->first] = iter->second;
for( int d=sDepth ; d>=0 ; d-- )
......@@ -4046,11 +4049,10 @@ int Octree< Degree >::SetBoundaryMCRootPositions( int sDepth , Real isoValue , R
if( IsBoundaryEdge( node , i , j , k , sDepth ) )
{
hits++;
long long key;
eIndex = Cube::EdgeIndex( i , j , k );
if( GetRootIndex( node , eIndex , fData.depth , ri ) )
{
key = ri.key;
long long key = ri.key;
if( rootData.boundaryRoots.find(key)==rootData.boundaryRoots.end() )
{
GetRoot( ri , isoValue , position , rootData , sDepth , nonLinearFit );
......
......@@ -28,8 +28,9 @@ DAMAGE.
#ifndef DOXY_IGNORE_THIS
#include <stdlib.h>
#include <math.h>
#include <cstdlib>
#include <cmath>
#include <cstddef>
#include <algorithm>
/////////////
......@@ -288,7 +289,7 @@ void OctNode<NodeData,Real>::printRange(void) const{
Real width;
centerAndWidth(center,width);
for(int dim=0;dim<DIMENSION;dim++){
printf("%[%f,%f]",center.coords[dim]-width/2,center.coords[dim]+width/2);
printf("[%f,%f]",center.coords[dim]-width/2,center.coords[dim]+width/2);
if(dim<DIMENSION-1){printf("x");}
else printf("\n");
}
......@@ -772,7 +773,7 @@ OctNode<NodeData,Real>& OctNode<NodeData,Real>::operator = (const OctNode<NodeDa
}
template <class NodeData,class Real>
int OctNode<NodeData,Real>::CompareForwardDepths(const void* v1,const void* v2){
return ((const OctNode<NodeData,Real>*)v1)->depth-((const OctNode<NodeData,Real>*)v2)->depth;
return static_cast<const OctNode<NodeData,Real>*>(v1)->depth-static_cast<const OctNode<NodeData,Real>*>(v2)->depth;
}
template< class NodeData , class Real >
int OctNode< NodeData , Real >::CompareByDepthAndXYZ( const void* v1 , const void* v2 )
......@@ -825,11 +826,11 @@ int OctNode<NodeData,Real>::CompareForwardPointerDepths( const void* v1 , const
}
template <class NodeData,class Real>
int OctNode<NodeData,Real>::CompareBackwardDepths(const void* v1,const void* v2){
return ((const OctNode<NodeData,Real>*)v2)->depth-((const OctNode<NodeData,Real>*)v1)->depth;
return static_cast<const OctNode<NodeData,Real>*>(v2)->depth-static_cast<const OctNode<NodeData,Real>*>(v1)->depth;
}
template <class NodeData,class Real>
int OctNode<NodeData,Real>::CompareBackwardPointerDepths(const void* v1,const void* v2){
return (*(const OctNode<NodeData,Real>**)v2)->depth()-(*(const OctNode<NodeData,Real>**)v1)->depth();
return (*static_cast<const OctNode<NodeData,Real>**>(v2))->depth()-(*static_cast<const OctNode<NodeData,Real>**>(v1))->depth();
}
template <class NodeData,class Real>
inline int OctNode<NodeData,Real>::Overlap2(const int &depth1,const int offSet1[DIMENSION],const Real& multiplier1,const int &depth2,const int offSet2[DIMENSION],const Real& multiplier2){
......@@ -855,7 +856,7 @@ const OctNode<NodeData,Real>* OctNode<NodeData,Real>::faceNeighbor(int faceIndex
template <class NodeData,class Real>
OctNode<NodeData,Real>* OctNode<NodeData,Real>::__faceNeighbor(int dir,int off,int forceChildren){
if(!parent){return NULL;}
int pIndex=int(this-parent->children);
ptrdiff_t pIndex= ptrdiff_t(-(this->parent->children - this));
pIndex^=(1<<dir);
if((pIndex & (1<<dir))==(off<<dir)){return &parent->children[pIndex];}
else{
......@@ -871,7 +872,7 @@ OctNode<NodeData,Real>* OctNode<NodeData,Real>::__faceNeighbor(int dir,int off,i
template <class NodeData,class Real>
const OctNode<NodeData,Real>* OctNode<NodeData,Real>::__faceNeighbor(int dir,int off) const {
if(!parent){return NULL;}
int pIndex=int(this-parent->children);
ptrdiff_t pIndex= ptrdiff_t(-(this->parent->children - this));
pIndex^=(1<<dir);
if((pIndex & (1<<dir))==(off<<dir)){return &parent->children[pIndex];}
else{
......@@ -906,7 +907,7 @@ const OctNode<NodeData,Real>* OctNode<NodeData,Real>::edgeNeighbor(int edgeIndex
template <class NodeData,class Real>
const OctNode<NodeData,Real>* OctNode<NodeData,Real>::__edgeNeighbor(int o,const int i[2],const int idx[2]) const{
if(!parent){return NULL;}
int pIndex=int(this-parent->children);
ptrdiff_t pIndex= ptrdiff_t(-(this->parent->children - this));
int aIndex,x[DIMENSION];
Cube::FactorCornerIndex(pIndex,x[0],x[1],x[2]);
......@@ -935,7 +936,7 @@ const OctNode<NodeData,Real>* OctNode<NodeData,Real>::__edgeNeighbor(int o,const
template <class NodeData,class Real>
OctNode<NodeData,Real>* OctNode<NodeData,Real>::__edgeNeighbor(int o,const int i[2],const int idx[2],int forceChildren){
if(!parent){return NULL;}
int pIndex=int(this-parent->children);
ptrdiff_t pIndex= ptrdiff_t(-(this->parent->children - this));
int aIndex,x[DIMENSION];
Cube::FactorCornerIndex(pIndex,x[0],x[1],x[2]);
......@@ -968,47 +969,47 @@ OctNode<NodeData,Real>* OctNode<NodeData,Real>::__edgeNeighbor(int o,const int i
template <class NodeData,class Real>
const OctNode<NodeData,Real>* OctNode<NodeData,Real>::cornerNeighbor(int cornerIndex) const {
int pIndex,aIndex=0;
int aIndex=0;
if(!parent){return NULL;}
pIndex=int(this-parent->children);
ptrdiff_t pIndex= ptrdiff_t(-(this->parent->children - this));
aIndex=(cornerIndex ^ pIndex); // The disagreement bits
pIndex=(~pIndex)&7; // The antipodal point
if(aIndex==7){ // Agree on no bits
return &parent->children[pIndex];
}
else if(aIndex==0){ // Agree on all bits
const OctNode* temp=((const OctNode*)parent)->cornerNeighbor(cornerIndex);
const OctNode* temp=static_cast<const OctNode*>(parent)->cornerNeighbor(cornerIndex);
if(!temp || !temp->children){return temp;}
else{return &temp->children[pIndex];}
}
else if(aIndex==6){ // Agree on face 0
const OctNode* temp=((const OctNode*)parent)->__faceNeighbor(0,cornerIndex & 1);
const OctNode* temp=static_cast<const OctNode*>(parent)->__faceNeighbor(0,cornerIndex & 1);
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==5){ // Agree on face 1
const OctNode* temp=((const OctNode*)parent)->__faceNeighbor(1,(cornerIndex & 2)>>1);
const OctNode* temp=static_cast<const OctNode*>(parent)->__faceNeighbor(1,(cornerIndex & 2)>>1);
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==3){ // Agree on face 2
const OctNode* temp=((const OctNode*)parent)->__faceNeighbor(2,(cornerIndex & 4)>>2);
const OctNode* temp=static_cast<const OctNode*>(parent)->__faceNeighbor(2,(cornerIndex & 4)>>2);
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==4){ // Agree on edge 2
const OctNode* temp=((const OctNode*)parent)->edgeNeighbor(8 | (cornerIndex & 1) | (cornerIndex & 2) );
const OctNode* temp=static_cast<const OctNode*>(parent)->edgeNeighbor(8 | (cornerIndex & 1) | (cornerIndex & 2) );
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==2){ // Agree on edge 1
const OctNode* temp=((const OctNode*)parent)->edgeNeighbor(4 | (cornerIndex & 1) | ((cornerIndex & 4)>>1) );
const OctNode* temp=static_cast<const OctNode*>(parent)->edgeNeighbor(4 | (cornerIndex & 1) | ((cornerIndex & 4)>>1) );
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==1){ // Agree on edge 0
const OctNode* temp=((const OctNode*)parent)->edgeNeighbor(((cornerIndex & 2) | (cornerIndex & 4))>>1 );
const OctNode* temp=static_cast<const OctNode*>(parent)->edgeNeighbor(((cornerIndex & 2) | (cornerIndex & 4))>>1 );
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
......@@ -1016,17 +1017,17 @@ const OctNode<NodeData,Real>* OctNode<NodeData,Real>::cornerNeighbor(int cornerI
}
template <class NodeData,class Real>
OctNode<NodeData,Real>* OctNode<NodeData,Real>::cornerNeighbor(int cornerIndex,int forceChildren){
int pIndex,aIndex=0;
int aIndex=0;
if(!parent){return NULL;}
pIndex=int(this-parent->children);
ptrdiff_t pIndex= ptrdiff_t(-(this->parent->children - this));
aIndex=(cornerIndex ^ pIndex); // The disagreement bits
pIndex=(~pIndex)&7; // The antipodal point
if(aIndex==7){ // Agree on no bits
return &parent->children[pIndex];
}
else if(aIndex==0){ // Agree on all bits
OctNode* temp=((OctNode*)parent)->cornerNeighbor(cornerIndex,forceChildren);
OctNode* temp=static_cast<OctNode*>(parent)->cornerNeighbor(cornerIndex,forceChildren);
if(!temp){return NULL;}
if(!temp->children){
if(forceChildren){temp->initChildren();}
......@@ -1035,32 +1036,32 @@ OctNode<NodeData,Real>* OctNode<NodeData,Real>::cornerNeighbor(int cornerIndex,i
return &temp->children[pIndex];
}
else if(aIndex==6){ // Agree on face 0
OctNode* temp=((OctNode*)parent)->__faceNeighbor(0,cornerIndex & 1,0);
OctNode* temp=static_cast<OctNode*>(parent)->__faceNeighbor(0,cornerIndex & 1,0);
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==5){ // Agree on face 1
OctNode* temp=((OctNode*)parent)->__faceNeighbor(1,(cornerIndex & 2)>>1,0);
OctNode* temp=static_cast<OctNode*>(parent)->__faceNeighbor(1,(cornerIndex & 2)>>1,0);
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==3){ // Agree on face 2
OctNode* temp=((OctNode*)parent)->__faceNeighbor(2,(cornerIndex & 4)>>2,0);
OctNode* temp=static_cast<OctNode*>(parent)->__faceNeighbor(2,(cornerIndex & 4)>>2,0);
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==4){ // Agree on edge 2
OctNode* temp=((OctNode*)parent)->edgeNeighbor(8 | (cornerIndex & 1) | (cornerIndex & 2) );
OctNode* temp=static_cast<OctNode*>(parent)->edgeNeighbor(8 | (cornerIndex & 1) | (cornerIndex & 2) );
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==2){ // Agree on edge 1
OctNode* temp=((OctNode*)parent)->edgeNeighbor(4 | (cornerIndex & 1) | ((cornerIndex & 4)>>1) );
OctNode* temp=static_cast<OctNode*>(parent)->edgeNeighbor(4 | (cornerIndex & 1) | ((cornerIndex & 4)>>1) );
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
else if(aIndex==1){ // Agree on edge 0
OctNode* temp=((OctNode*)parent)->edgeNeighbor(((cornerIndex & 2) | (cornerIndex & 4))>>1 );
OctNode* temp=static_cast<OctNode*>(parent)->edgeNeighbor(((cornerIndex & 2) | (cornerIndex & 4))>>1 );
if(!temp || !temp->children){return NULL;}
else{return & temp->children[pIndex];}
}
......
......@@ -63,7 +63,7 @@ int StartingPolynomial<Degree>::operator < (const StartingPolynomial<Degree>& sp
}
template<int Degree>
int StartingPolynomial<Degree>::Compare(const void* v1,const void* v2){
double d=((StartingPolynomial*)(v1))->start-((StartingPolynomial*)(v2))->start;
double d=(static_cast<const StartingPolynomial*>(v1))->start-(static_cast<const StartingPolynomial*>(v2))->start;
if (d<0) {return -1;}
else if (d>0) {return 1;}
else {return 0;}
......@@ -82,7 +82,7 @@ PPolynomial<Degree>::PPolynomial(const PPolynomial<Degree>& p){
polyCount=0;
polys=NULL;
set(p.polyCount);
memcpy(polys,p.polys,sizeof(StartingPolynomial<Degree>)*p.polyCount);
memcpy(polys,p.polys,sizeof( StartingPolynomial<Degree> )*p.polyCount);
}
template<int Degree>
......@@ -114,7 +114,7 @@ void PPolynomial<Degree>::set( size_t size )
polys=NULL;
polyCount=size;
if(size){
polys=(StartingPolynomial<Degree>*)malloc(sizeof(StartingPolynomial<Degree>)*size);
polys=static_cast<StartingPolynomial<Degree>*>(malloc(sizeof(StartingPolynomial<Degree>)*size));
memset(polys,0,sizeof(StartingPolynomial<Degree>)*size);
}
}
......@@ -122,7 +122,10 @@ template<int Degree>
void PPolynomial<Degree>::reset( size_t newSize )
{
polyCount=newSize;
polys=(StartingPolynomial<Degree>*)realloc(polys,sizeof(StartingPolynomial<Degree>)*newSize);
StartingPolynomial<Degree>* tmp = static_cast<StartingPolynomial<Degree>*>(realloc(polys,sizeof(StartingPolynomial<Degree>)*newSize));
if (!tmp)
free(polys);
polys=tmp;
}
template<int Degree>
......@@ -376,7 +379,7 @@ PPolynomial< 0 > PPolynomial< 0 >::BSpline( double radius )
q.polys[1].p.coefficients[0]=-1.0;
return q;
}
template< int Degree >
template<int Degree >
PPolynomial< Degree > PPolynomial<Degree>::BSpline( double radius )
{
return PPolynomial< Degree-1 >::BSpline().MovingAverage( radius );
......@@ -388,7 +391,7 @@ PPolynomial<Degree+1> PPolynomial<Degree>::MovingAverage( double radius )
Polynomial<Degree+1> p;
StartingPolynomial<Degree+1>* sps;
sps=(StartingPolynomial<Degree+1>*)malloc(sizeof(StartingPolynomial<Degree+1>)*polyCount*2);