本文整理汇总了C++中VoxelDataContainer::setOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ VoxelDataContainer::setOrigin方法的具体用法?C++ VoxelDataContainer::setOrigin怎么用?C++ VoxelDataContainer::setOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VoxelDataContainer
的用法示例。
在下文中一共展示了VoxelDataContainer::setOrigin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void AdjustVolumeOrigin::execute()
{
VoxelDataContainer* m = getVoxelDataContainer();
if(NULL == m)
{
setErrorCondition(-999);
notifyErrorMessage("The DataContainer Object was NULL", -999);
return;
}
setErrorCondition(0);
std::stringstream ss;
// Set the Voxel Volume First, since this is easy
if (m_ApplyToVoxelVolume ==true)
{
m->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z);
}
if (m_ApplyToSurfaceMesh == true)
{
updateSurfaceMesh();
}
if (m_ApplyToSolidMesh == true)
{
updatesSolidMesh();
}
notifyStatusMessage("Complete");
}
示例2: dataCheck
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void DxReader::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles)
{
setErrorCondition(0);
std::stringstream ss;
VoxelDataContainer* m = getVoxelDataContainer();
if (getInputFile().empty() == true)
{
ss << ClassName() << " needs the Input File Set and it was not.";
setErrorCondition(-387);
addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition());
}
else if (MXAFileInfo::exists(getInputFile()) == false)
{
ss << "The input file does not exist.";
setErrorCondition(-388);
addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition());
}
CREATE_NON_PREREQ_DATA(m, DREAM3D, CellData, GrainIds, ss, int32_t, Int32ArrayType, 0, voxels, 1)
m->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z);
m->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z);
if (m_InStream.is_open() == true)
{
m_InStream.close();
}
// We need to read the header of the input file to get the dimensions
m_InStream.open(getInputFile().c_str(), std::ios_base::binary);
if(!m_InStream)
{
ss.clear();
ss << " Runtime Error. The input file '" << getInputFile() << "' could not be"
<< " opened for reading. Do you have access to this file?";
setErrorCondition(-49800);
addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition());
return;
}
int error = readHeader();
m_InStream.close();
if (error < 0)
{
setErrorCondition(error);
ss.clear();
ss << "Error occurred trying to parse the dimensions from the input file. Is the input file a Dx file?";
addErrorMessage(getHumanLabel(), ss.str(), -11000);
}
}
示例3: dataCheck
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void YSChoiAbaqusReader::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles)
{
setErrorCondition(0);
std::stringstream ss;
VoxelDataContainer* m = getVoxelDataContainer();
if (getInputFile().empty() == true)
{
ss << ClassName() << " needs the Input File Set and it was not.";
setErrorCondition(-387);
addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition());
}
else if (MXAFileInfo::exists(getInputFile()) == false)
{
ss << "The input file does not exist.";
setErrorCondition(-388);
addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition());
}
else
{
const unsigned int size(1024);
char buf[size];
// Read header from data file to figure out how many points there are
std::ifstream in(getInputFile().c_str());
std::string word;
bool headerdone = false;
int xpoints, ypoints, zpoints;
float resx, resy, resz;
while (headerdone == false)
{
in.getline(buf, size);
std::string line = buf;
in >> word;
if (DIMS == word)
{
in >> xpoints >> ypoints >> zpoints;
size_t dims[3] = {xpoints, ypoints, zpoints};
m->setDimensions(dims);
m->setOrigin(0,0,0);
}
if (RES == word)
{
in >> resx >> resy >> resz;
float res[3] = {resx, resy, resz};
m->setResolution(res);
}
}
示例4: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void RawBinaryReader::execute()
{
int err = 0;
std::stringstream ss;
setErrorCondition(err);
VoxelDataContainer* m = getVoxelDataContainer();
if(NULL == m)
{
setErrorCondition(-999);
notifyErrorMessage("The Voxel DataContainer Object was NULL", -999);
return;
}
setErrorCondition(0);
// Get the total size of the array from the options
size_t voxels = m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
if (m_OverRideOriginResolution == true)
{
m->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z);
m->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z);
}
m->setDimensions(m_Dimensions.x, m_Dimensions.y, m_Dimensions.z);
array = IDataArray::NullPointer();
if (m_ScalarType == Detail::Int8)
{
Int8ArrayType::Pointer p = Int8ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<int8_t>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
else if (m_ScalarType == Detail::UInt8)
{
UInt8ArrayType::Pointer p = UInt8ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<uint8_t>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
else if (m_ScalarType == Detail::Int16)
{
Int16ArrayType::Pointer p = Int16ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<int16_t>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
else if (m_ScalarType == Detail::UInt16)
{
UInt16ArrayType::Pointer p = UInt16ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<uint16_t>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
else if (m_ScalarType == Detail::Int32)
{
Int32ArrayType::Pointer p = Int32ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<int32_t>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
else if (m_ScalarType == Detail::UInt32)
{
UInt32ArrayType::Pointer p = UInt32ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<uint32_t>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
else if (m_ScalarType == Detail::Int64)
{
Int64ArrayType::Pointer p = Int64ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<int64_t>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
else if (m_ScalarType == Detail::UInt64)
{
UInt64ArrayType::Pointer p = UInt64ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<uint64_t>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
else if (m_ScalarType == Detail::Float)
{
FloatArrayType::Pointer p = FloatArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<float>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
else if (m_ScalarType == Detail::Double)
{
DoubleArrayType::Pointer p = DoubleArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
err = ReadBinaryFile<double>(p, m_InputFile, m_SkipHeaderBytes);
if (err >= 0 ) { SWAP_ARRAY(p)
array = p;}
}
//.........这里部分代码省略.........
示例5: dataCheck
//.........这里部分代码省略.........
addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition());
}
if (m_Dimensionality < 1)
{
ss.str("");
ss << "The dimensionality must be larger than Zero";
setErrorCondition(-389);
addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition());
}
if ( m_Dimensions.x == 0 || m_Dimensions.y == 0 || m_Dimensions.z == 0)
{
ss.str("");
ss << "One of the dimensions has a size less than or Equal to Zero (0). The minimum size must be greater than One (1).";
setErrorCondition(-390);
addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition());
}
if (true == preflight)
{
size_t allocatedBytes = 0;
IDataArray::Pointer p = IDataArray::NullPointer();
if (m_ScalarType == Detail::Int8)
{
p = Int8ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(int8_t) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
else if (m_ScalarType == Detail::UInt8)
{
p = UInt8ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(uint8_t) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
else if (m_ScalarType == Detail::Int16)
{
p = Int16ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(int16_t) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
else if (m_ScalarType == Detail::UInt16)
{
p = UInt16ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(uint16_t) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
else if (m_ScalarType == Detail::Int32)
{
p = Int32ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(int32_t) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
else if (m_ScalarType == Detail::UInt32)
{
p = UInt32ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(uint32_t) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
else if (m_ScalarType == Detail::Int64)
{
p = Int64ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(int64_t) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
else if (m_ScalarType == Detail::UInt64)
{
p = UInt64ArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(uint64_t) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
else if (m_ScalarType == Detail::Float)
{
p = FloatArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(float) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
else if (m_ScalarType == Detail::Double)
{
p = DoubleArrayType::CreateArray(voxels, m_NumberOfComponents, m_OutputArrayName);
allocatedBytes = sizeof(double) * m_NumberOfComponents * m_Dimensions.x * m_Dimensions.y * m_Dimensions.z;
}
// Sanity Check Allocated Bytes versus size of file
uint64_t fileSize = MXAFileInfo::fileSize(m_InputFile);
int check = SanityCheckFileSizeVersusAllocatedSize(allocatedBytes, fileSize, m_SkipHeaderBytes);
if (check == -1)
{
ss.str("");
ss << "The file size is " << fileSize << " but the number of bytes needed to fill the array is " << allocatedBytes << ". This condition would cause an error reading the input file.";
ss << " Please adjust the input parameters to match the size of the file or select a different data file.";
setErrorCondition(RBR_FILE_TOO_SMALL);
addErrorMessage(getHumanLabel(), ss.str(), getErrorCondition());
}
else if (check == 1)
{
ss.str("");
ss << "The file size is " << fileSize << " but the number of bytes needed to fill the array is " << allocatedBytes << " which is less than the size of the file.";
ss << " DREAM3D will read only the first part of the file into the array.";
addWarningMessage(getHumanLabel(), ss.str(), RBR_FILE_TOO_BIG);
}
m->addCellData(p->GetName(), p);
m->setDimensions(m_Dimensions.x, m_Dimensions.y, m_Dimensions.z);
m->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z);
m->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z);
}
}
示例6: if
//.........这里部分代码省略.........
addErrorMessage(getHumanLabel(), ss.str(), -1);
return;
}
int64_t dims[3];
float res[3];
reader->getDimsAndResolution(dims[0], dims[1], dims[2], res[0], res[1], res[2]);
/* Sanity check what we are trying to load to make sure it can fit in our address space.
* Note that this does not guarantee the user has enough left, just that the
* size of the volume can fit in the address space of the program
*/
#if (CMP_SIZEOF_SSIZE_T==4)
int64_t max = std::numeric_limits<size_t>::max();
#else
int64_t max = std::numeric_limits<int64_t>::max();
#endif
if(dims[0] * dims[1] * dims[2] > max)
{
err = -1;
std::stringstream s;
s << "The total number of elements '" << (dims[0] * dims[1] * dims[2]) << "' is greater than this program can hold. Try the 64 bit version.";
setErrorCondition(err);
addErrorMessage(getHumanLabel(), s.str(), -1);
return;
}
if(dims[0] > max || dims[1] > max || dims[2] > max)
{
err = -1;
std::stringstream s;
s << "One of the dimensions is greater than the max index for this sysem. Try the 64 bit version.";
s << " dim[0]=" << dims[0] << " dim[1]=" << dims[1] << " dim[2]=" << dims[2];
setErrorCondition(err);
addErrorMessage(getHumanLabel(), s.str(), -1);
return;
}
/* ************ End Sanity Check *************************** */
size_t dcDims[3] =
{ dims[0], dims[1], dims[2] };
m->setDimensions(dcDims);
m->setResolution(res);
m->setOrigin(0.0f, 0.0f, 0.0f);
}
H5EbsdVolumeReader::Pointer reader;
std::vector<std::string> names;
if (m_Manufacturer == Ebsd::TSL)
{
AngFields fields;
reader = H5AngVolumeReader::New();
names = fields.getFilterFields<std::vector<std::string> > ();
}
else if (m_Manufacturer == Ebsd::HKL)
{
CtfFields fields;
reader = H5CtfVolumeReader::New();
names = fields.getFilterFields<std::vector<std::string> > ();
}
else if (m_Manufacturer == Ebsd::HEDM)
{
MicFields fields;
reader = H5MicVolumeReader::New();
names = fields.getFilterFields<std::vector<std::string> > ();
}
else
{
ss << getHumanLabel() << ": Original Data source could not be determined. It should be TSL or HKL";
setErrorCondition(-1);
addErrorMessage(getHumanLabel(), ss.str(), -1);
return;
}
for (size_t i = 0; i < names.size(); ++i)
{
if (reader->getPointerType(names[i]) == Ebsd::Int32)
{
Int32ArrayType::Pointer array = Int32ArrayType::CreateArray(voxels, names[i]);
m->addCellData(names[i], array);
}
else if (reader->getPointerType(names[i]) == Ebsd::Float)
{
FloatArrayType::Pointer array = FloatArrayType::CreateArray(voxels, names[i]);
m->addCellData(names[i], array);
}
}
CREATE_NON_PREREQ_DATA(m, DREAM3D, CellData, CellEulerAngles, ss, float, FloatArrayType, 0, voxels, 3)
CREATE_NON_PREREQ_DATA(m, DREAM3D, CellData, CellPhases, ss, int32_t, Int32ArrayType, 0, voxels, 1)
typedef DataArray<unsigned int> XTalStructArrayType;
CREATE_NON_PREREQ_DATA(m, DREAM3D, EnsembleData, CrystalStructures, ss, unsigned int, XTalStructArrayType, Ebsd::CrystalStructure::UnknownCrystalStructure, ensembles, 1)
CREATE_NON_PREREQ_DATA(m, DREAM3D, EnsembleData, LatticeConstants, ss, float, FloatArrayType, 0.0, ensembles, 6)
StringDataArray::Pointer materialNames = StringDataArray::CreateArray(1, DREAM3D::EnsembleData::MaterialName);
m->addEnsembleData( DREAM3D::EnsembleData::MaterialName, materialNames);
ADD_HELP_INDEX_ENTRY(EnsembleData, MaterialName, XTalStructArrayType, 1);
}
示例7: in
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ImportR3DStack::execute()
{
int err = 0;
setErrorCondition(err);
dataCheck(false,1,1,1);
if (getErrorCondition() < 0) { notifyErrorMessage("There is a problem with the data check", getErrorCondition()); }
VoxelDataContainer* m = getVoxelDataContainer();
if(NULL == m)
{
setErrorCondition(-999);
notifyErrorMessage("The DataContainer Object was NULL", -999);
return;
}
setErrorCondition(0);
std::stringstream ss;
m->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z);
m->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z);
int x = 0;
int y = 0;
readXYSize(x, y);
if (x < 1 || y < 1)
{
setErrorCondition(-1000);
notifyErrorMessage("At least one dimension is less than 1", getErrorCondition());
}
size_t numSlices = m_ZEndIndex - m_ZStartIndex + 1;
size_t totalVoxels = numSlices * x * y;
// Create a new array, eventually substituting this into the DataContainer later on.
Int32ArrayType::Pointer grainIdsPtr = Int32ArrayType::CreateArray(totalVoxels, 1, DREAM3D::CellData::GrainIds);
grainIdsPtr->initializeWithZeros();
m_GrainIds = grainIdsPtr->GetPointer(0); // Get the pointer to the front of the array
int32_t* currentPositionPtr = m_GrainIds;
bool ok = false;
int pixelBytes = 0;
int totalPixels = 0;
int height = 0;
int width = 0;
size_t index = 0;
int64_t z = m_ZStartIndex;
m->setDimensions(x,y,numSlices);
for (std::vector<std::string>::iterator filepath = m_R3DFileList.begin(); filepath != m_R3DFileList.end(); ++filepath)
{
QString R3DFName = QString::fromStdString(*filepath);
ss.str("");
ss << "Importing file " << R3DFName.toStdString();
notifyStatusMessage(ss.str());
QByteArray buf;
QFile in(R3DFName);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
{
QString msg = QString("R3D file could not be opened: ") + R3DFName;
setErrorCondition(-14000);
notifyErrorMessage(msg.toStdString(), getErrorCondition());
}
buf = in.readLine(); // Read first line which is the x and y sizes
QList<QByteArray> tokens = buf.split(',');
width = tokens.at(0).toInt();
height = tokens.at(1).toInt();
int32_t value = 0;
for(qint32 i = 0; i < height; ++i)
{
buf = in.readLine();
tokens = buf.split(',');
if (tokens.size() != width+2)
{
notifyStatusMessage("A file did not have the correct width partilcuar line");
break;
}
for(int j = 1; j < width+1; j++)
{
currentPositionPtr[index] = tokens[j].toInt(&ok, 10);
++index;
if (!ok)
{
setErrorCondition(-2004);
notifyErrorMessage("Width dimension entry was not an integer", getErrorCondition());
break;
}
}
if (in.atEnd() == true && i < height - 2)
//.........这里部分代码省略.........