mirror of
https://github.com/CloudCompare/PoissonRecon.git
synced 2026-08-29 08:34:27 +08:00
Resolved bug that would cause a bad memory access when the octree had empty slices.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<center><h2>Adaptive Multigrid Solvers (Version 10.06)</h2></center>
|
||||
<center><h2>Adaptive Multigrid Solvers (Version 10.07)</h2></center>
|
||||
<center>
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.05/index.html#LINKS">links</a>
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.05/index.html#EXECUTABLES">executables</a>
|
||||
@@ -27,10 +27,11 @@ This code-base was born from the Poisson Surface Reconstruction code. It has evo
|
||||
<a href="http://www.cs.jhu.edu/~misha/MyPapers/ToG13.pdf">[Kazhdan and Hoppe, 2013]</a>
|
||||
<br>
|
||||
<b>Executables: </b>
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.06/AdaptiveSolvers.x64.zip">Win64</a><br>
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.07/AdaptiveSolvers.x64.zip">Win64</a><br>
|
||||
<b>Source Code:</b>
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.06/AdaptiveSolvers.zip">ZIP</a> <a href="https://github.com/mkazhdan/PoissonRecon">GitHub</a><br>
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.07/AdaptiveSolvers.zip">ZIP</a> <a href="https://github.com/mkazhdan/PoissonRecon">GitHub</a><br>
|
||||
<b>Older Versions:</b>
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.06/">V10.06</a>,
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.05/">V10.05</a>,
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.04/">V10.04</a>,
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.03/">V10.03</a>,
|
||||
@@ -805,6 +806,12 @@ Similarly, to reduce compilation times, support for specific degrees can be remo
|
||||
<LI> Modified the 2D implementations of <CODE>PoissonRecon</CODE>, <CODE>SSDRecon</CODE>, and <CODE>AdaptiveTreeVisualization</CODE> to support ouput to <CODE>.jpg</CODE> and <CODE>.png</CODE> image files.
|
||||
</ol>
|
||||
|
||||
<a href="http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version10.06/">Version 10.06</a>:
|
||||
<ol>
|
||||
<LI> Removed a bug that would cause memory access errors when some slices were empty.
|
||||
g</CODE> image files.
|
||||
</ol>
|
||||
|
||||
</DETAILS>
|
||||
|
||||
|
||||
|
||||
@@ -91,61 +91,59 @@ void ShowUsage( char* ex )
|
||||
}
|
||||
|
||||
template< typename Real , unsigned int Dim >
|
||||
bool WriteImage( const Real *values , int res , const char *fileName , bool verbose )
|
||||
void WriteGrid( ConstPointer( Real ) values , int res , const char *fileName )
|
||||
{
|
||||
if( Dim!=2 ) return false;
|
||||
int resolution = 1;
|
||||
for( int d=0 ; d<Dim ; d++ ) resolution *= res;
|
||||
|
||||
Real avg = 0;
|
||||
#pragma omp parallel for reduction( + : avg )
|
||||
for( int i=0 ; i<resolution ; i++ ) avg += values[i];
|
||||
avg /= (Real)resolution;
|
||||
char *ext = GetFileExtension( fileName );
|
||||
|
||||
Real std = 0;
|
||||
#pragma omp parallel for reduction( + : std )
|
||||
for( int i=0 ; i<resolution ; i++ ) std += ( values[i] - avg ) * ( values[i] - avg );
|
||||
std = (Real)sqrt( std / resolution );
|
||||
|
||||
if( verbose ) printf( "Grid to image: [%.2f,%.2f] -> [0,255]\n" , avg - 2*std , avg + 2*std );
|
||||
|
||||
unsigned char *pixels = new unsigned char[ resolution*3 ];
|
||||
#pragma omp parallel for
|
||||
for( int i=0 ; i<resolution ; i++ )
|
||||
if( Dim==2 && ImageWriter::ValidExtension( ext ) )
|
||||
{
|
||||
Real v = (Real)std::min< Real >( (Real)1. , std::max< Real >( (Real)-1. , ( values[i] - avg ) / (2*std ) ) );
|
||||
v = (Real)( ( v + 1. ) / 2. * 256. );
|
||||
unsigned char color = (unsigned char )std::min< Real >( (Real)255. , std::max< Real >( (Real)0. , v ) );
|
||||
for( int c=0 ; c<3 ; c++ ) pixels[i*3+c ] = color;
|
||||
Real avg = 0;
|
||||
#pragma omp parallel for reduction( + : avg )
|
||||
for( int i=0 ; i<resolution ; i++ ) avg += values[i];
|
||||
avg /= (Real)resolution;
|
||||
|
||||
Real std = 0;
|
||||
#pragma omp parallel for reduction( + : std )
|
||||
for( int i=0 ; i<resolution ; i++ ) std += ( values[i] - avg ) * ( values[i] - avg );
|
||||
std = (Real)sqrt( std / resolution );
|
||||
|
||||
if( Verbose.set ) printf( "Grid to image: [%.2f,%.2f] -> [0,255]\n" , avg - 2*std , avg + 2*std );
|
||||
|
||||
unsigned char *pixels = new unsigned char[ resolution*3 ];
|
||||
#pragma omp parallel for
|
||||
for( int i=0 ; i<resolution ; i++ )
|
||||
{
|
||||
Real v = (Real)std::min< Real >( (Real)1. , std::max< Real >( (Real)-1. , ( values[i] - avg ) / (2*std ) ) );
|
||||
v = (Real)( ( v + 1. ) / 2. * 256. );
|
||||
unsigned char color = (unsigned char )std::min< Real >( (Real)255. , std::max< Real >( (Real)0. , v ) );
|
||||
for( int c=0 ; c<3 ; c++ ) pixels[i*3+c ] = color;
|
||||
}
|
||||
ImageWriter::Write( fileName , pixels , res , res , 3 );
|
||||
delete[] pixels;
|
||||
}
|
||||
bool success = true;
|
||||
try{ ImageWriter::Write( fileName , pixels , res , res , 3 ); }
|
||||
catch( MKExceptions::Exception & ){ success = false; }
|
||||
delete[] pixels;
|
||||
return success;
|
||||
}
|
||||
|
||||
template< typename Real , unsigned int Dim >
|
||||
void WriteGrid( const Real *values , int res , const char *fileName )
|
||||
{
|
||||
int resolution = 1;
|
||||
for( int d=0 ; d<Dim ; d++ ) resolution *= res;
|
||||
|
||||
FILE *fp = fopen( fileName , "wb" );
|
||||
if( !fp ) ERROR_OUT( "Failed to open grid file for writing: %s" , fileName );
|
||||
else
|
||||
{
|
||||
fwrite( &res , sizeof(int) , 1 , fp );
|
||||
if( typeid(Real)==typeid(float) ) fwrite( values , sizeof(float) , resolution , fp );
|
||||
|
||||
FILE *fp = fopen( fileName , "wb" );
|
||||
if( !fp ) ERROR_OUT( "Failed to open grid file for writing: %s" , fileName );
|
||||
else
|
||||
{
|
||||
float *fValues = new float[resolution];
|
||||
for( int i=0 ; i<resolution ; i++ ) fValues[i] = float( values[i] );
|
||||
fwrite( fValues , sizeof(float) , resolution , fp );
|
||||
delete[] fValues;
|
||||
fwrite( &res , sizeof(int) , 1 , fp );
|
||||
if( typeid(Real)==typeid(float) ) fwrite( values , sizeof(float) , resolution , fp );
|
||||
else
|
||||
{
|
||||
float *fValues = new float[resolution];
|
||||
for( int i=0 ; i<resolution ; i++ ) fValues[i] = float( values[i] );
|
||||
fwrite( fValues , sizeof(float) , resolution , fp );
|
||||
delete[] fValues;
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
||||
delete[] ext;
|
||||
}
|
||||
|
||||
template< unsigned int Dim , class Real , unsigned int FEMSig >
|
||||
@@ -163,7 +161,7 @@ void _Execute( const FEMTree< Dim , Real >* tree , FILE* fp )
|
||||
double t = Time();
|
||||
Pointer( Real ) values = tree->template regularGridEvaluate< true >( coefficients , res , -1 , PrimalGrid.set );
|
||||
if( Verbose.set ) printf( "Got grid: %.2f(s)\n" , Time()-t );
|
||||
if( !WriteImage< Real , Dim >( values , res , OutGrid.value , Verbose.set ) ) WriteGrid< Real , Dim >( values , res , OutGrid.value );
|
||||
WriteGrid< Real , Dim >( values , res , OutGrid.value );
|
||||
DeletePointer( values );
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ DAMAGE.
|
||||
#ifndef FEM_TREE_INCLUDED
|
||||
#define FEM_TREE_INCLUDED
|
||||
|
||||
#define VERSION "10.06"
|
||||
#define VERSION "10.07"
|
||||
#define MEMORY_ALLOCATOR_BLOCK_SIZE 1<<12
|
||||
|
||||
#define NEW_CODE
|
||||
|
||||
+36
@@ -37,6 +37,7 @@ struct ImageReader
|
||||
return pixels;
|
||||
}
|
||||
|
||||
static bool ValidExtension( const char *ext );
|
||||
static ImageReader* Get( const char* fileName );
|
||||
static void GetInfo( const char* fileName , unsigned int& width , unsigned int& height , unsigned int& channels );
|
||||
virtual ~ImageReader( void ){ }
|
||||
@@ -70,6 +71,8 @@ struct ImageWriter
|
||||
for( unsigned int j=0 ; j<height ; j++ ) writer->nextRow( pixels + j*width*channels );
|
||||
delete writer;
|
||||
}
|
||||
|
||||
static bool ValidExtension( const char *ext );
|
||||
static ImageWriter* Get( const char* fileName , unsigned int width , unsigned int height , unsigned int channels , ImageWriterParams params=ImageWriterParams() );
|
||||
virtual ~ImageWriter( void ){ }
|
||||
unsigned int width( void ) const { return _width; }
|
||||
@@ -160,6 +163,20 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
inline bool ImageReader::ValidExtension( const char *ext )
|
||||
{
|
||||
#ifdef WIN32
|
||||
if ( !_stricmp( ext , "jpeg" ) || !_stricmp( ext , "jpg" ) ) return true;
|
||||
else if( !_stricmp( ext , "png" ) ) return true;
|
||||
else if( !_stricmp( ext , "iGrid" ) ) return true;
|
||||
#else // !WIN32
|
||||
if( !strcasecmp( ext , "jpeg" ) || !strcasecmp( ext , "jpg" ) ) return true;
|
||||
else if( !strcasecmp( ext , "png" ) ) return true;
|
||||
else if( !strcasecmp( ext , "iGrid" ) ) return true;
|
||||
#endif // WIN32
|
||||
return false;
|
||||
}
|
||||
|
||||
inline ImageReader* ImageReader::Get( const char* fileName )
|
||||
{
|
||||
unsigned int width , height , channels;
|
||||
@@ -200,6 +217,25 @@ inline void ImageReader::GetInfo( const char* fileName , unsigned int& width , u
|
||||
#endif // WIN32
|
||||
delete[] ext;
|
||||
}
|
||||
|
||||
inline bool ImageWriter::ValidExtension( const char *ext )
|
||||
{
|
||||
#ifdef WIN32
|
||||
if( !_stricmp( ext , "jpeg" ) || !_stricmp( ext , "jpg" ) ) return true;
|
||||
else if( !_stricmp( ext , "png" ) ) return true;
|
||||
#ifdef SUPPORT_TILES
|
||||
else if( !_stricmp( ext , "iGrid" ) ) return true;
|
||||
#endif // SUPPORT_TILES
|
||||
#else // !WIN32
|
||||
if( !strcasecmp( ext , "jpeg" ) || !strcasecmp( ext , "jpg" ) ) return true;
|
||||
else if( !strcasecmp( ext , "png" ) ) return true;
|
||||
#ifdef SUPPORT_TILES
|
||||
else if( !strcasecmp( ext , "iGrid" ) ) return true;
|
||||
#endif // SUPPORT_TILES
|
||||
#endif // WIN32
|
||||
return false;
|
||||
}
|
||||
|
||||
inline ImageWriter* ImageWriter::Get( const char* fileName , unsigned int width , unsigned int height , unsigned int channels , ImageWriterParams params )
|
||||
{
|
||||
ImageWriter* writer = NULL;
|
||||
|
||||
+42
-43
@@ -353,63 +353,62 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr
|
||||
}
|
||||
|
||||
template< typename Real , unsigned int Dim >
|
||||
bool WriteImage( const Real *values , int res , const char *fileName , bool verbose )
|
||||
void WriteGrid( ConstPointer( Real ) values , int res , const char *fileName )
|
||||
{
|
||||
if( Dim!=2 ) return false;
|
||||
int resolution = 1;
|
||||
for( int d=0 ; d<Dim ; d++ ) resolution *= res;
|
||||
|
||||
Real avg = 0;
|
||||
#pragma omp parallel for reduction( + : avg )
|
||||
for( int i=0 ; i<resolution ; i++ ) avg += values[i];
|
||||
avg /= (Real)resolution;
|
||||
char *ext = GetFileExtension( fileName );
|
||||
|
||||
Real std = 0;
|
||||
#pragma omp parallel for reduction( + : std )
|
||||
for( int i=0 ; i<resolution ; i++ ) std += ( values[i] - avg ) * ( values[i] - avg );
|
||||
std = (Real)sqrt( std / resolution );
|
||||
|
||||
if( verbose ) printf( "Grid to image: [%.2f,%.2f] -> [0,255]\n" , avg - 2*std , avg + 2*std );
|
||||
|
||||
unsigned char *pixels = new unsigned char[ resolution*3 ];
|
||||
#pragma omp parallel for
|
||||
for( int i=0 ; i<resolution ; i++ )
|
||||
if( Dim==2 && ImageWriter::ValidExtension( ext ) )
|
||||
{
|
||||
Real v = (Real)std::min< Real >( (Real)1. , std::max< Real >( (Real)-1. , ( values[i] - avg ) / (2*std ) ) );
|
||||
v = (Real)( ( v + 1. ) / 2. * 256. );
|
||||
unsigned char color = (unsigned char )std::min< Real >( (Real)255. , std::max< Real >( (Real)0. , v ) );
|
||||
for( int c=0 ; c<3 ; c++ ) pixels[i*3+c ] = color;
|
||||
Real avg = 0;
|
||||
#pragma omp parallel for reduction( + : avg )
|
||||
for( int i=0 ; i<resolution ; i++ ) avg += values[i];
|
||||
avg /= (Real)resolution;
|
||||
|
||||
Real std = 0;
|
||||
#pragma omp parallel for reduction( + : std )
|
||||
for( int i=0 ; i<resolution ; i++ ) std += ( values[i] - avg ) * ( values[i] - avg );
|
||||
std = (Real)sqrt( std / resolution );
|
||||
|
||||
if( Verbose.set ) printf( "Grid to image: [%.2f,%.2f] -> [0,255]\n" , avg - 2*std , avg + 2*std );
|
||||
|
||||
unsigned char *pixels = new unsigned char[ resolution*3 ];
|
||||
#pragma omp parallel for
|
||||
for( int i=0 ; i<resolution ; i++ )
|
||||
{
|
||||
Real v = (Real)std::min< Real >( (Real)1. , std::max< Real >( (Real)-1. , ( values[i] - avg ) / (2*std ) ) );
|
||||
v = (Real)( ( v + 1. ) / 2. * 256. );
|
||||
unsigned char color = (unsigned char )std::min< Real >( (Real)255. , std::max< Real >( (Real)0. , v ) );
|
||||
for( int c=0 ; c<3 ; c++ ) pixels[i*3+c ] = color;
|
||||
}
|
||||
ImageWriter::Write( fileName , pixels , res , res , 3 );
|
||||
delete[] pixels;
|
||||
}
|
||||
bool success = true;
|
||||
try{ ImageWriter::Write( fileName , pixels , res , res , 3 ); }
|
||||
catch( MKExceptions::Exception & ){ success = false; }
|
||||
delete[] pixels;
|
||||
return success;
|
||||
}
|
||||
|
||||
template< typename Real , unsigned int Dim >
|
||||
void WriteGrid( const Real *values , int res , const char *fileName )
|
||||
{
|
||||
int resolution = 1;
|
||||
for( int d=0 ; d<Dim ; d++ ) resolution *= res;
|
||||
|
||||
FILE *fp = fopen( fileName , "wb" );
|
||||
if( !fp ) ERROR_OUT( "Failed to open grid file for writing: %s" , fileName );
|
||||
else
|
||||
{
|
||||
fwrite( &res , sizeof(int) , 1 , fp );
|
||||
if( typeid(Real)==typeid(float) ) fwrite( values , sizeof(float) , resolution , fp );
|
||||
|
||||
FILE *fp = fopen( fileName , "wb" );
|
||||
if( !fp ) ERROR_OUT( "Failed to open grid file for writing: %s" , fileName );
|
||||
else
|
||||
{
|
||||
float *fValues = new float[resolution];
|
||||
for( int i=0 ; i<resolution ; i++ ) fValues[i] = float( values[i] );
|
||||
fwrite( fValues , sizeof(float) , resolution , fp );
|
||||
delete[] fValues;
|
||||
fwrite( &res , sizeof(int) , 1 , fp );
|
||||
if( typeid(Real)==typeid(float) ) fwrite( values , sizeof(float) , resolution , fp );
|
||||
else
|
||||
{
|
||||
float *fValues = new float[resolution];
|
||||
for( int i=0 ; i<resolution ; i++ ) fValues[i] = float( values[i] );
|
||||
fwrite( fValues , sizeof(float) , resolution , fp );
|
||||
delete[] fValues;
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
||||
delete[] ext;
|
||||
}
|
||||
|
||||
|
||||
template< class Real , typename ... SampleData , unsigned int ... FEMSigs >
|
||||
void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
|
||||
{
|
||||
@@ -669,7 +668,7 @@ void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
|
||||
#pragma omp parallel for
|
||||
for( int i=0 ; i<resolution ; i++ ) values[i] -= isoValue;
|
||||
profiler.dumpOutput( "Got grid:" );
|
||||
if( !WriteImage< Real , DIMENSION >( values , res , Grid.value , Verbose.set ) ) WriteGrid< Real , DIMENSION >( values , res , Grid.value );
|
||||
WriteGrid< Real , DIMENSION >( values , res , Grid.value );
|
||||
DeletePointer( values );
|
||||
if( Verbose.set )
|
||||
{
|
||||
|
||||
+42
-43
@@ -377,63 +377,62 @@ void ExtractMesh( UIntPack< FEMSigs ... > , std::tuple< SampleData ... > , FEMTr
|
||||
}
|
||||
|
||||
template< typename Real , unsigned int Dim >
|
||||
bool WriteImage( const Real *values , int res , const char *fileName , bool verbose )
|
||||
void WriteGrid( ConstPointer( Real ) values , int res , const char *fileName )
|
||||
{
|
||||
if( Dim!=2 ) return false;
|
||||
int resolution = 1;
|
||||
for( int d=0 ; d<Dim ; d++ ) resolution *= res;
|
||||
|
||||
Real avg = 0;
|
||||
#pragma omp parallel for reduction( + : avg )
|
||||
for( int i=0 ; i<resolution ; i++ ) avg += values[i];
|
||||
avg /= (Real)resolution;
|
||||
char *ext = GetFileExtension( fileName );
|
||||
|
||||
Real std = 0;
|
||||
#pragma omp parallel for reduction( + : std )
|
||||
for( int i=0 ; i<resolution ; i++ ) std += ( values[i] - avg ) * ( values[i] - avg );
|
||||
std = (Real)sqrt( std / resolution );
|
||||
|
||||
if( verbose ) printf( "Grid to image: [%.2f,%.2f] -> [0,255]\n" , avg - 2*std , avg + 2*std );
|
||||
|
||||
unsigned char *pixels = new unsigned char[ resolution*3 ];
|
||||
#pragma omp parallel for
|
||||
for( int i=0 ; i<resolution ; i++ )
|
||||
if( Dim==2 && ImageWriter::ValidExtension( ext ) )
|
||||
{
|
||||
Real v = (Real)std::min< Real >( (Real)1. , std::max< Real >( (Real)-1. , ( values[i] - avg ) / (2*std ) ) );
|
||||
v = (Real)( ( v + 1. ) / 2. * 256. );
|
||||
unsigned char color = (unsigned char )std::min< Real >( (Real)255. , std::max< Real >( (Real)0. , v ) );
|
||||
for( int c=0 ; c<3 ; c++ ) pixels[i*3+c ] = color;
|
||||
Real avg = 0;
|
||||
#pragma omp parallel for reduction( + : avg )
|
||||
for( int i=0 ; i<resolution ; i++ ) avg += values[i];
|
||||
avg /= (Real)resolution;
|
||||
|
||||
Real std = 0;
|
||||
#pragma omp parallel for reduction( + : std )
|
||||
for( int i=0 ; i<resolution ; i++ ) std += ( values[i] - avg ) * ( values[i] - avg );
|
||||
std = (Real)sqrt( std / resolution );
|
||||
|
||||
if( Verbose.set ) printf( "Grid to image: [%.2f,%.2f] -> [0,255]\n" , avg - 2*std , avg + 2*std );
|
||||
|
||||
unsigned char *pixels = new unsigned char[ resolution*3 ];
|
||||
#pragma omp parallel for
|
||||
for( int i=0 ; i<resolution ; i++ )
|
||||
{
|
||||
Real v = (Real)std::min< Real >( (Real)1. , std::max< Real >( (Real)-1. , ( values[i] - avg ) / (2*std ) ) );
|
||||
v = (Real)( ( v + 1. ) / 2. * 256. );
|
||||
unsigned char color = (unsigned char )std::min< Real >( (Real)255. , std::max< Real >( (Real)0. , v ) );
|
||||
for( int c=0 ; c<3 ; c++ ) pixels[i*3+c ] = color;
|
||||
}
|
||||
ImageWriter::Write( fileName , pixels , res , res , 3 );
|
||||
delete[] pixels;
|
||||
}
|
||||
bool success = true;
|
||||
try{ ImageWriter::Write( fileName , pixels , res , res , 3 ); }
|
||||
catch( MKExceptions::Exception & ){ success = false; }
|
||||
delete[] pixels;
|
||||
return success;
|
||||
}
|
||||
|
||||
template< typename Real , unsigned int Dim >
|
||||
void WriteGrid( const Real *values , int res , const char *fileName )
|
||||
{
|
||||
int resolution = 1;
|
||||
for( int d=0 ; d<Dim ; d++ ) resolution *= res;
|
||||
|
||||
FILE *fp = fopen( fileName , "wb" );
|
||||
if( !fp ) ERROR_OUT( "Failed to open grid file for writing: %s" , fileName );
|
||||
else
|
||||
{
|
||||
fwrite( &res , sizeof(int) , 1 , fp );
|
||||
if( typeid(Real)==typeid(float) ) fwrite( values , sizeof(float) , resolution , fp );
|
||||
|
||||
FILE *fp = fopen( fileName , "wb" );
|
||||
if( !fp ) ERROR_OUT( "Failed to open grid file for writing: %s" , fileName );
|
||||
else
|
||||
{
|
||||
float *fValues = new float[resolution];
|
||||
for( int i=0 ; i<resolution ; i++ ) fValues[i] = float( values[i] );
|
||||
fwrite( fValues , sizeof(float) , resolution , fp );
|
||||
delete[] fValues;
|
||||
fwrite( &res , sizeof(int) , 1 , fp );
|
||||
if( typeid(Real)==typeid(float) ) fwrite( values , sizeof(float) , resolution , fp );
|
||||
else
|
||||
{
|
||||
float *fValues = new float[resolution];
|
||||
for( int i=0 ; i<resolution ; i++ ) fValues[i] = float( values[i] );
|
||||
fwrite( fValues , sizeof(float) , resolution , fp );
|
||||
delete[] fValues;
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
||||
delete[] ext;
|
||||
}
|
||||
|
||||
|
||||
template< class Real , typename ... SampleData , unsigned int ... FEMSigs >
|
||||
void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
|
||||
{
|
||||
@@ -674,7 +673,7 @@ void Execute( int argc , char* argv[] , UIntPack< FEMSigs ... > )
|
||||
#pragma omp parallel for
|
||||
for( int i=0 ; i<resolution ; i++ ) values[i] -= isoValue;
|
||||
profiler.dumpOutput( "Got grid:" );
|
||||
if( !WriteImage< Real , DIMENSION >( values , res , Grid.value , Verbose.set ) ) WriteGrid< Real , DIMENSION >( values , res , Grid.value );
|
||||
WriteGrid< Real , DIMENSION >( values , res , Grid.value );
|
||||
DeletePointer( values );
|
||||
if( Verbose.set )
|
||||
{
|
||||
|
||||
@@ -598,13 +598,18 @@ template< class T , class IndexType , size_t MaxRowSize >
|
||||
template< class T2 >
|
||||
void SparseMatrix< T , IndexType , MaxRowSize >::operator() ( const T2* in , T2* out ) const { Interface::multiply( in , out ); }
|
||||
|
||||
template< class T , class IndexType , size_t MaxRowSize > SparseMatrix< T , IndexType , MaxRowSize >::~SparseMatrix( void ) { resize( 0 ); }
|
||||
template< class T , class IndexType , size_t MaxRowSize >
|
||||
SparseMatrix< T , IndexType , MaxRowSize >::~SparseMatrix( void )
|
||||
{
|
||||
FreePointer( _rowSizes );
|
||||
FreePointer( _entries );
|
||||
}
|
||||
|
||||
template< class T , class IndexType , size_t MaxRowSize >
|
||||
void SparseMatrix< T , IndexType , MaxRowSize >::resize( size_t rowNum )
|
||||
{
|
||||
_rowNum = rowNum;
|
||||
if( !rowNum || rowNum>_maxRows )
|
||||
if( rowNum>_maxRows )
|
||||
{
|
||||
FreePointer( _rowSizes );
|
||||
FreePointer( _entries );
|
||||
|
||||
Reference in New Issue
Block a user