Commit 60acfb6c authored by Cyril Poupon's avatar Cyril Poupon
Browse files

added the possibility to create the distance field in addition to the vector field

parent 5793593f
......@@ -42,6 +42,7 @@ gkg::BrainVISAVectorFieldConverterCommand::BrainVISAVectorFieldConverterCommand(
const std::string& fileNameInputDirectVectorField,
const std::string& fileNameInputInverseVectorField,
const std::string& fileNameOutputVectorField,
const std::string& fileNameOutputDistanceField,
bool ascii,
const std::string& format,
bool verbose )
......@@ -53,6 +54,7 @@ gkg::BrainVISAVectorFieldConverterCommand::BrainVISAVectorFieldConverterCommand(
execute( fileNameInputDirectVectorField,
fileNameInputInverseVectorField,
fileNameOutputVectorField,
fileNameOutputDistanceField,
ascii,
format,
verbose );
......@@ -63,6 +65,7 @@ gkg::BrainVISAVectorFieldConverterCommand::BrainVISAVectorFieldConverterCommand(
"const std::string& fileNameInputDirectVectorField, "
"const std::string& fileNameInputInverseVectorField, "
"const std::string& fileNameOutputVectorField, "
"const std::string& fileNameOutputDistanceField, "
"bool ascii, "
"const std::string& format, "
"bool verbose )" );
......@@ -84,6 +87,8 @@ gkg::BrainVISAVectorFieldConverterCommand::BrainVISAVectorFieldConverterCommand(
fileNameInputInverseVectorField );
DECLARE_STRING_PARAMETER( parameters, std::string,
fileNameOutputVectorField );
DECLARE_STRING_PARAMETER( parameters, std::string,
fileNameOutputDistanceField );
DECLARE_BOOLEAN_PARAMETER( parameters, bool, ascii );
DECLARE_STRING_PARAMETER( parameters, std::string, format );
DECLARE_BOOLEAN_PARAMETER( parameters, bool, verbose );
......@@ -91,6 +96,7 @@ gkg::BrainVISAVectorFieldConverterCommand::BrainVISAVectorFieldConverterCommand(
execute( fileNameInputDirectVectorField,
fileNameInputInverseVectorField,
fileNameOutputVectorField,
fileNameOutputDistanceField,
ascii,
format,
verbose );
......@@ -133,6 +139,7 @@ void gkg::BrainVISAVectorFieldConverterCommand::parse()
std::string fileNameInputDirectVectorField;
std::string fileNameInputInverseVectorField;
std::string fileNameOutputVectorField;
std::string fileNameOutputDistanceField;
bool ascii = false;
std::string format = "";
bool verbose = false;
......@@ -151,6 +158,9 @@ void gkg::BrainVISAVectorFieldConverterCommand::parse()
application.addSingleOption( "-o",
"Output GKG direct and inverse vector field",
fileNameOutputVectorField );
application.addSingleOption( "-d",
"Output GKG direct and inverse distance field",
fileNameOutputDistanceField );
application.addSingleOption( "-ascii",
"Save ouput volume in ASCII mode",
ascii,
......@@ -168,6 +178,7 @@ void gkg::BrainVISAVectorFieldConverterCommand::parse()
execute( fileNameInputDirectVectorField,
fileNameInputInverseVectorField,
fileNameOutputVectorField,
fileNameOutputDistanceField,
ascii,
format,
verbose );
......@@ -183,6 +194,7 @@ void gkg::BrainVISAVectorFieldConverterCommand::execute(
const std::string& fileNameInputDirectVectorField,
const std::string& fileNameInputInverseVectorField,
const std::string& fileNameOutputVectorField,
const std::string& fileNameOutputDistanceField,
bool ascii,
const std::string& format,
bool verbose )
......@@ -301,6 +313,7 @@ void gkg::BrainVISAVectorFieldConverterCommand::execute(
directAndInverseVectorFieldVolume( voxel, 5 ) =
inverseVectorFieldVolume( voxel ).z;
}
}
......@@ -338,11 +351,94 @@ void gkg::BrainVISAVectorFieldConverterCommand::execute(
}
////////////////////////////////////////////////////////////////////////////
// computing and saving output GKG direct/inverse distance field volume
////////////////////////////////////////////////////////////////////////////
if ( !fileNameOutputDistanceField.empty() )
{
// computing output GKG direct/inverse distance field volume
if ( verbose )
{
std::cout << "computing GKG direct/inverse distance field : "
<< std::flush;
}
gkg::Volume< float >
directAndInverseDistanceFieldVolume( size, 2 );
directAndInverseDistanceFieldVolume.setResolution( resolution );
for ( voxel.z = 0; voxel.z < size.z; voxel.z++ )
{
for ( voxel.y = 0; voxel.y < size.y; voxel.y++ )
{
for ( voxel.x = 0; voxel.x < size.x; voxel.x++ )
{
directAndInverseDistanceFieldVolume( voxel, 0 ) =
std::sqrt( directAndInverseVectorFieldVolume( voxel, 0 ) *
directAndInverseVectorFieldVolume( voxel, 0 ) +
directAndInverseVectorFieldVolume( voxel, 1 ) *
directAndInverseVectorFieldVolume( voxel, 1 ) +
directAndInverseVectorFieldVolume( voxel, 2 ) *
directAndInverseVectorFieldVolume( voxel, 2 ) );
directAndInverseDistanceFieldVolume( voxel, 1 ) =
std::sqrt( directAndInverseVectorFieldVolume( voxel, 3 ) *
directAndInverseVectorFieldVolume( voxel, 3 ) +
directAndInverseVectorFieldVolume( voxel, 4 ) *
directAndInverseVectorFieldVolume( voxel, 4 ) +
directAndInverseVectorFieldVolume( voxel, 5 ) *
directAndInverseVectorFieldVolume( voxel, 5 ) );
}
}
}
if ( verbose )
{
std::cout << "done" << std::endl;
}
// writing output GKG direct/inverse distance field volume
if ( verbose )
{
std::cout << "writing '" << fileNameOutputDistanceField
<< "' : " << std::flush;
}
gkg::Writer::getInstance().write( fileNameOutputDistanceField,
directAndInverseDistanceFieldVolume,
ascii,
format );
if ( verbose )
{
std::cout << "done" << std::endl;
}
}
}
GKG_CATCH( "void gkg::BrainVISAVectorFieldConverterCommand::execute( "
"const std::string& fileNameInputDirectVectorField, "
"const std::string& fileNameInputInverseVectorField, "
"const std::string& fileNameOutputVectorField, "
"const std::string& fileNameOutputDistanceField, "
"bool ascii, "
"const std::string& format, "
"bool verbose )" );
......@@ -357,6 +453,8 @@ RegisterCommandCreator( BrainVISAVectorFieldConverterCommand,
fileNameInputInverseVectorField ) +
DECLARE_STRING_PARAMETER_HELP(
fileNameOutputVectorField ) +
DECLARE_STRING_PARAMETER_HELP(
fileNameOutputDistanceField ) +
DECLARE_BOOLEAN_PARAMETER_HELP( ascii ) +
DECLARE_STRING_PARAMETER_HELP( format ) +
DECLARE_BOOLEAN_PARAMETER_HELP( verbose ) );
......@@ -32,6 +32,7 @@ class BrainVISAVectorFieldConverterCommand : public Command,
const std::string& fileNameInputDirectVectorField,
const std::string& fileNameInputInverseVectorField,
const std::string& fileNameOutputVectorField,
const std::string& fileNameOutputDistanceField,
bool ascii,
const std::string& format,
bool verbose );
......@@ -51,6 +52,7 @@ class BrainVISAVectorFieldConverterCommand : public Command,
void execute( const std::string& fileNameInputDirectVectorField,
const std::string& fileNameInputInverseVectorField,
const std::string& fileNameOutputVectorField,
const std::string& fileNameOutputDistanceField,
bool ascii,
const std::string& format,
bool verbose );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment