Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 1 addition & 101 deletions inc/cvc/hdf5_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1334,107 +1334,7 @@ inline void setAttribute(app &ctx, const std::string &hdf5_filename,
setAttribute(ctx, hdf5_filename, hdf5_objname, attribname, std::string(value));
}

// ============================================================
// Context-less convenience overloads (inject cvc::app::instance())
// ============================================================
inline bool isGroup(const std::string &hdf5_filename, const std::string &hdf5_objname) {
return isGroup(app::instance(), hdf5_filename, hdf5_objname);
}

inline bool isDataSet(const std::string &hdf5_filename, const std::string &hdf5_objname) {
return isDataSet(app::instance(), hdf5_filename, hdf5_objname);
}

inline bool objectExists(const std::string &hdf5_filename, const std::string &hdf5_objname) {
return objectExists(app::instance(), hdf5_filename, hdf5_objname);
}

inline void removeObject(const std::string &hdf5_filename, const std::string &hdf5_objname) {
removeObject(app::instance(), hdf5_filename, hdf5_objname);
}

inline void createHDF5File(const std::string &hdf5_filename) {
createHDF5File(app::instance(), hdf5_filename);
}

inline void createGroup(const std::string &hdf5_filename, const std::string &hdf5_objname,
bool replace = false) {
createGroup(app::instance(), hdf5_filename, hdf5_objname, replace);
}

inline void createDataSet(const std::string &hdf5_filename, const std::string &hdf5_objname,
const bounding_box &boundingBox, const dimension &dimension,
data_type dataType, const bool replace = false,
const bool createGroups = true) {
createDataSet(app::instance(), hdf5_filename, hdf5_objname, boundingBox, dimension, dataType,
replace, createGroups);
}

inline void createDataSet(const std::string &hdf5_filename, const std::string &hdf5_objname,
const dimension &dimension, data_type dataType,
const bool createGroups = true) {
createDataSet(app::instance(), hdf5_filename, hdf5_objname, dimension, dataType, createGroups);
}

inline void createDataSet(const std::string &hdf5_filename, const std::string &hdf5_objname,
const std::string &value, bool createGroups = true) {
createDataSet(app::instance(), hdf5_filename, hdf5_objname, value, createGroups);
}

inline dimension getObjectDimension(const std::string &hdf5_filename,
const std::string &hdf5_objname) {
return getObjectDimension(app::instance(), hdf5_filename, hdf5_objname);
}

inline void setObjectDimension(const std::string &hdf5_filename, const std::string &hdf5_objname,
const dimension &dim) {
setObjectDimension(app::instance(), hdf5_filename, hdf5_objname, dim);
}

inline dimension getDataSetDimensionForBoundingBox(const std::string &hdf5_filename,
const std::string &hdf5_objname,
const bounding_box &subvolbox) {
return getDataSetDimensionForBoundingBox(app::instance(), hdf5_filename, hdf5_objname, subvolbox);
}

inline dimension getDataSetDimension(const std::string &hdf5_filename,
const std::string &hdf5_objname, const bounding_box &subvolbox,
const dimension &maxdim = dimension(256, 256, 256)) {
return getDataSetDimension(app::instance(), hdf5_filename, hdf5_objname, subvolbox, maxdim);
}

inline bounding_box getObjectBoundingBox(const std::string &hdf5_filename,
const std::string &hdf5_objname) {
return getObjectBoundingBox(app::instance(), hdf5_filename, hdf5_objname);
}

inline void setObjectBoundingBox(const std::string &hdf5_filename, const std::string &hdf5_objname,
const bounding_box &boundingBox) {
setObjectBoundingBox(app::instance(), hdf5_filename, hdf5_objname, boundingBox);
}

inline double getDataSetMinimum(const std::string &hdf5_filename, const std::string &hdf5_objname) {
return getDataSetMinimum(app::instance(), hdf5_filename, hdf5_objname);
}

inline double getDataSetMaximum(const std::string &hdf5_filename, const std::string &hdf5_objname) {
return getDataSetMaximum(app::instance(), hdf5_filename, hdf5_objname);
}

inline std::string getDataSetInfo(const std::string &hdf5_filename,
const std::string &hdf5_objname) {
return getDataSetInfo(app::instance(), hdf5_filename, hdf5_objname);
}

inline data_type getDataSetType(const std::string &hdf5_filename, const std::string &hdf5_objname) {
return getDataSetType(app::instance(), hdf5_filename, hdf5_objname);
}

inline std::vector<std::string> getChildObjects(const std::string &hdf5_filename,
const std::string &hdf5_objname = "/",
const std::string &filter = std::string()) {
return getChildObjects(app::instance(), hdf5_filename, hdf5_objname, filter);
}
// All hdf5_utils free functions require an explicit cvc::app context.
} // namespace hdf5_utils
} // namespace CVC_NAMESPACE

Expand Down
30 changes: 3 additions & 27 deletions inc/cvc/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,9 @@ static inline double getTriVal(double val[8], double x, double y, double z, doub
}

/*
Shortcut for creating a volume file based on a volume file info object
Shortcut for creating a volume file based on a volume file info object.
All overloads require an explicit cvc::app context.
*/
static inline void createVolumeFile(const std::string &filename, const volume_file_info &volinfo) {
createVolumeFile(filename, volinfo.boundingBox(), volinfo.voxel_dimensions(),
volinfo.voxelTypes(), volinfo.numVariables(), volinfo.numTimesteps(),
volinfo.TMin(), volinfo.TMax());
}

static inline void createVolumeFile(app &ctx, const std::string &filename,
const volume_file_info &volinfo) {
createVolumeFile(ctx, filename, volinfo.boundingBox(), volinfo.voxel_dimensions(),
Expand All @@ -126,12 +121,6 @@ static inline void createVolumeFile(app &ctx, const std::string &filename,
// writes the volume data in the object to the specified file.
// ---- Change History ----
// 01/04/2010 -- Joe R. -- Creation.
static inline void createVolumeFile(const volume &vol, const std::string &filename) {
createVolumeFile(filename, vol.boundingBox(), vol.voxel_dimensions(),
std::vector<data_type>(1, vol.voxelType()));
writeVolumeFile(vol, filename);
}

static inline void createVolumeFile(app &ctx, const volume &vol, const std::string &filename) {
createVolumeFile(ctx, filename, vol.boundingBox(), vol.voxel_dimensions(),
std::vector<data_type>(1, vol.voxelType()));
Expand All @@ -146,10 +135,6 @@ static inline void createVolumeFile(app &ctx, const volume &vol, const std::stri
// createVolumeFile call
// ---- Change History ----
// 01/04/2010 -- Joe R. -- Creation.
static inline void createVolumeFile(const std::string &filename, const volume &vol) {
createVolumeFile(vol, filename);
}

static inline void createVolumeFile(app &ctx, const std::string &filename, const volume &vol) {
createVolumeFile(ctx, vol, filename);
}
Expand All @@ -160,14 +145,7 @@ static inline void createVolumeFile(app &ctx, const std::string &filename, const
(UChar, UShort, UInt), the first half of the set of integers maps to [-1.0,0) and the last half
maps to (0,1.0].
*/
void calcGradient(std::vector<volume> &grad, const volume &vol, data_type vt = Float);

void sub(volume &dest, const volume &vol, uint64 off_x, uint64 off_y, uint64 off_z,
const dimension &subvoldim);

void volconvert(const std::string &input_volume_file, const std::string &output_volume_file);

// ---- Overloads accepting explicit app& context ----
// ---- All free functions take an explicit cvc::app context. ----
void calcGradient(app &ctx, std::vector<volume> &grad, const volume &vol, data_type vt = Float);

void sub(app &ctx, volume &dest, const volume &vol, uint64 off_x, uint64 off_y, uint64 off_z,
Expand Down Expand Up @@ -241,7 +219,5 @@ bool is_volume(const boost::any &data);
bool is_volume_file_info(const boost::any &data);
bool is_geometry_filename(const std::string &filename);
bool is_volume_filename(const std::string &filename);
boost::any load(const std::string &filename);
void save(const boost::any &data, const std::string &filename);
} // namespace CVC_NAMESPACE
#endif
65 changes: 5 additions & 60 deletions inc/cvc/volume_file_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,66 +244,11 @@ struct volume_file_io {
};

// ------------------------- Volume I/O API

/*
read the specified subvolume from the specified file and copy it to the object
vol.
*/
void readVolumeFile(volume &vol, const std::string &filename, unsigned int var, unsigned int time,
uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim);

/*
read the specified subvolume from the specified file and copy it to the object
vol.
*/
void readVolumeFile(volume &vol, const std::string &filename, unsigned int var, unsigned int time,
const bounding_box &subvolbox);

/*
read the entire volume from the specified file and copy it to the object vol.
*/
void readVolumeFile(volume &vol, const std::string &filename, unsigned int var = 0,
unsigned int time = 0);

/*
Read multi-volume file and add each volume to the vector vols.
*/
void readVolumeFile(std::vector<volume> &vols, const std::string &filename);

/*
write the specified volume to the specified offset in file 'filename'
*/
void writeVolumeFile(const volume &vol, const std::string &filename, unsigned int var = 0,
unsigned int time = 0, uint64 off_x = 0, uint64 off_y = 0, uint64 off_z = 0);

/*
write the specified volume to the specified subvolume bounding box in file 'filename'
*/
void writeVolumeFile(const volume &vol, const std::string &filename, unsigned int var,
unsigned int time, const bounding_box &subvolbox);

/*
Writes the vector 'vols' to the specified file. Make sure that the file extension
specified is for a volume file type that supports multi-volumes. Assumes 1 timestep.
*/
void writeVolumeFile(const std::vector<volume> &vols, const std::string &filename);

/*
Creates a volume file using the specified information.
*/
void createVolumeFile(const std::string &filename, const bounding_box &boundingBox,
const dimension &dimension,
const std::vector<data_type> &voxelTypes = std::vector<data_type>(1, UChar),
unsigned int numVariables = 1, unsigned int numTimesteps = 1,
double min_time = 0.0, double max_time = 0.0);

// Functions for reading and writing volume bounding boxes
bounding_box readBoundingBox(const std::string &filename);
void writeBoundingBox(const bounding_box &bbox, const std::string &filename);

// ---- Overloads accepting explicit app& context ----
// These avoid the app::instance() singleton. Legacy overloads above
// delegate to app::instance() internally.
//
// All free-function I/O takes an explicit cvc::app context so each
// caller controls thread/property/data scoping. (The earlier
// parameterless overloads that delegated to app::instance() have been
// removed.)

void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var = 0,
unsigned int time = 0);
Expand Down
4 changes: 3 additions & 1 deletion src/cvc/cvc-mesher/Mesher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#include <string>
#include <cstdlib>
#include <VolMagickCompat.h>
#include <cvc/app.h>
#include <mesher.h>
#include <boost/program_options.hpp>
#include <stdexcept>

int main(int argc, char **argv)
{
CVC_NAMESPACE::app cvc_ctx;
using namespace std;
namespace po = boost::program_options;

Expand Down Expand Up @@ -79,7 +81,7 @@ int main(int argc, char **argv)
if(operation == "mesh")
{
VolMagick::Volume vol;
VolMagick::readVolumeFile(vol,input_file);
CVC_NAMESPACE::readVolumeFile(cvc_ctx, vol, input_file);

// Convert string arguments to enums
LBIE::Mesher::ExtractionMethod extraction_method_enum;
Expand Down
31 changes: 15 additions & 16 deletions src/cvc/hdf5_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ struct hdf5_io : public volume_file_io {
// 09/02/2011 -- Joe R. -- Forgot to copy filename to data.
// 09/09/2011 -- Joe R. -- Adding support for ungrouped, lone datasets to make
// multi-res hierarchy thread code simpler.
virtual void getVolumeFileInfo(app & /*ctx*/, volume_file_info::data &d,
virtual void getVolumeFileInfo(app &ctx, volume_file_info::data &d,
const std::string &filename) const {
using namespace hdf5_utils;
using namespace boost;

thread_info ti(BOOST_CURRENT_FUNCTION);
thread_info ti(ctx, BOOST_CURRENT_FUNCTION);

std::string actualFileName;
std::string objectName;
Expand Down Expand Up @@ -456,14 +456,14 @@ struct hdf5_io : public volume_file_io {
// 08/05/2011 -- Joe R. -- Using HDF5 Utilities now.
// 09/09/2011 -- Joe R. -- Adding support for ungrouped, lone datasets to make
// multi-res hierarchy thread code simpler.
virtual void readVolumeFile(app & /*ctx*/, volume &vol, const std::string &filename,
unsigned int var, unsigned int time, uint64 off_x, uint64 off_y,
uint64 off_z, const dimension &subvoldim) const {
virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var,
unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z,
const dimension &subvoldim) const {
using namespace H5;
using namespace hdf5_utils;
using namespace boost;

thread_info ti(BOOST_CURRENT_FUNCTION);
thread_info ti(ctx, BOOST_CURRENT_FUNCTION);

std::string actualFileName;
std::string objectName;
Expand Down Expand Up @@ -542,13 +542,12 @@ struct hdf5_io : public volume_file_io {
// multi-res hierarchy thread code simpler.
// 09/17/2011 -- Joe R. -- Picking out the closest dimension to the maxdim in
// the hierarchy.
virtual void readVolumeFile(app & /*ctx*/, volume &vol, const std::string &filename,
unsigned int var, unsigned int time,
const bounding_box &subvolbox) const {
virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var,
unsigned int time, const bounding_box &subvolbox) const {
using namespace hdf5_utils;
using namespace boost;

thread_info ti(BOOST_CURRENT_FUNCTION);
thread_info ti(ctx, BOOST_CURRENT_FUNCTION);

std::string actualFileName;
std::string objectName;
Expand Down Expand Up @@ -666,15 +665,15 @@ struct hdf5_io : public volume_file_io {
// 09/02/2011 -- Joe R. -- Calling new createHDF5File function.
// 09/08/2011 -- Joe R. -- Only creating a file if none exists, else just re-using it.
// 09/30/2011 -- Joe R. -- Added objectType attribute.
virtual void createVolumeFile(app & /*ctx*/, const std::string &filename,
virtual void createVolumeFile(app &ctx, const std::string &filename,
const bounding_box &boundingBox, const dimension &dimension,
const std::vector<data_type> &voxelTypes, unsigned int numVariables,
unsigned int numTimesteps, double min_time, double max_time) const {
using namespace hdf5_utils;
namespace fs = boost::filesystem;
using boost::filesystem::path;

thread_info ti(BOOST_CURRENT_FUNCTION);
thread_info ti(ctx, BOOST_CURRENT_FUNCTION);

std::string actualFileName;
std::string objectName;
Expand Down Expand Up @@ -738,13 +737,13 @@ struct hdf5_io : public volume_file_io {
// 08/28/2011 -- Joe R. -- Using HDF5 Utilities now.
// 09/09/2011 -- Joe R. -- Adding support for ungrouped, lone datasets to make
// multi-res hierarchy thread code simpler.
virtual void writeVolumeFile(app & /*ctx*/, const volume &wvol, const std::string &filename,
virtual void writeVolumeFile(app &ctx, const volume &wvol, const std::string &filename,
unsigned int var, unsigned int time, uint64 off_x, uint64 off_y,
uint64 off_z) const {
using namespace hdf5_utils;
using namespace boost;

thread_info ti(BOOST_CURRENT_FUNCTION);
thread_info ti(ctx, BOOST_CURRENT_FUNCTION);

std::string actualFileName;
std::string objectName;
Expand Down Expand Up @@ -825,12 +824,12 @@ struct hdf5_io : public volume_file_io {
// Writes the specified bounding box to the file.
// ---- Change History ----
// 04/06/2012 -- Joe R. -- Creation.
virtual void writeBoundingBox(app & /*ctx*/, const bounding_box &bbox,
virtual void writeBoundingBox(app &ctx, const bounding_box &bbox,
const std::string &filename) const {
using namespace hdf5_utils;
using namespace boost;

thread_info ti(BOOST_CURRENT_FUNCTION);
thread_info ti(ctx, BOOST_CURRENT_FUNCTION);

std::string actualFileName;
std::string objectName;
Expand Down
Loading
Loading