本文整理汇总了C++中idataarray::Pointer::GetVoidPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetVoidPointer方法的具体用法?C++ Pointer::GetVoidPointer怎么用?C++ Pointer::GetVoidPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idataarray::Pointer
的用法示例。
在下文中一共展示了Pointer::GetVoidPointer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
IDataArray::Pointer readH5Dataset(hid_t locId,
const std::string &datasetPath,
const std::vector<hsize_t> &dims)
{
herr_t err = -1;
IDataArray::Pointer ptr;
size_t numElements = 1;
for (size_t i = 0; i < dims.size(); ++i)
{
numElements *= dims[i];
}
ptr = DataArray<T>::CreateArray(numElements, datasetPath);
if(dims.size() > 1)
{
ptr->SetNumberOfComponents(static_cast<int>(dims[1]));
}
T* data = (T*)(ptr->GetVoidPointer(0));
err = H5Lite::readPointerDataset(locId, datasetPath, data);
if(err < 0)
{
std::cout << "readH5Data read error: " << __FILE__ << "(" << __LINE__ << ")" << std::endl;
ptr = IDataArray::NullPointer();
}
return ptr;
}
示例2: GetName
/**
* @brief
* @param parentId
* @return
*/
virtual int readH5Data(hid_t parentId)
{
int err = 0;
this->Resize(0);
IDataArray::Pointer p = H5DataArrayReader::readIDataArray(parentId, GetName());
if (p.get() == NULL)
{
return -1;
}
this->NumberOfComponents = p->GetNumberOfComponents();
this->Size = p->GetSize();
this->MaxId = (Size == 0) ? 0 : Size -1;
this->Array = reinterpret_cast<T*>(p->GetVoidPointer(0));
p->releaseOwnership();
return err;
}
示例3: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ChangeResolution::execute()
{
int err = 0;
setErrorCondition(err);
DREAM3D_RANDOMNG_NEW()
VoxelDataContainer* m = getVoxelDataContainer();
if(NULL == m)
{
setErrorCondition(-999);
notifyErrorMessage("The DataContainer Object was NULL", -999);
return;
}
setErrorCondition(0);
if (getErrorCondition() < 0)
{
return;
}
if(m->getXRes() == m_Resolution.x
&& m->getYRes() == m_Resolution.y
&& m->getZRes() == m_Resolution.z)
{
return;
}
size_t dims[3];
m->getDimensions(dims);
float sizex = (dims[0])*m->getXRes();
float sizey = (dims[1])*m->getYRes();
float sizez = (dims[2])*m->getZRes();
int m_XP = int(sizex / m_Resolution.x);
int m_YP = int(sizey / m_Resolution.y);
int m_ZP = int(sizez / m_Resolution.z);
int64_t totalPoints = m_XP*m_YP*m_ZP;
float x, y, z;
int col, row, plane;
int index;
int index_old;
std::vector<size_t> newindicies;
newindicies.resize(totalPoints);
for (int i = 0; i < m_ZP; i++)
{
std::stringstream ss;
ss << "Changing Resolution - " << ((float)i/m->getZPoints())*100 << " Percent Complete";
notifyStatusMessage(ss.str());
for (int j = 0; j < m_YP; j++)
{
for (int k = 0; k < m_XP; k++)
{
x = (k * m_Resolution.x);
y = (j * m_Resolution.y);
z = (i * m_Resolution.z);
col = int(x / m->getXRes());
row = int(y / m->getYRes());
plane = int(z / m->getZRes());
index_old = (plane * m->getXPoints() * m->getYPoints()) + (row * m->getXPoints()) + col;
index = (i * m_XP * m_YP) + (j * m_XP) + k;
newindicies[index] = index_old;
}
}
}
std::list<std::string> voxelArrayNames = m->getCellArrayNameList();
for (std::list<std::string>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
{
std::string name = *iter;
IDataArray::Pointer p = m->getCellData(*iter);
// Make a copy of the 'p' array that has the same name. When placed into
// the data container this will over write the current array with
// the same name. At least in theory
IDataArray::Pointer data = p->createNewArray(p->GetNumberOfTuples(), p->GetNumberOfComponents(), p->GetName());
data->Resize(totalPoints);
void* source = NULL;
void* destination = NULL;
size_t newIndicies_I = 0;
int nComp = data->GetNumberOfComponents();
for (size_t i = 0; i < static_cast<size_t>(totalPoints); i++)
{
newIndicies_I = newindicies[i];
source = p->GetVoidPointer((nComp * newIndicies_I));
destination = data->GetVoidPointer((data->GetNumberOfComponents() * i));
::memcpy(destination, source, p->GetTypeSize() * data->GetNumberOfComponents());
}
m->addCellData(*iter, data);
}
m->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z);
m->setDimensions(m_XP, m_YP, m_ZP);
notifyStatusMessage("Complete");
}
示例4: str
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
IDataArray::Pointer H5DataArrayReader::readStringDataArray(hid_t gid, const std::string &name, bool preflightOnly)
{
herr_t err = -1;
herr_t retErr = 1;
hid_t typeId = -1;
H5T_class_t attr_type;
size_t attr_size;
std::string res;
std::vector<hsize_t> dims; //Reusable for the loop
IDataArray::Pointer ptr = IDataArray::NullPointer();
//std::cout << "Reading Attribute " << *iter << std::endl;
typeId = H5Lite::getDatasetType(gid, name);
if (typeId < 0)
{
return ptr;
}
err = H5Lite::getDatasetInfo(gid, name, dims, attr_type, attr_size);
if(err < 0)
{
std::cout << "Error in getAttributeInfo method in readUserMetaData." << std::endl;
}
else
{
std::string classType;
err = H5Lite::readStringAttribute(gid, name, DREAM3D::HDF5::ObjectType, classType);
if (err < 0)
{
return ptr;
}
int numComp = 1;
err = H5Lite::readScalarAttribute(gid, name, DREAM3D::HDF5::NumComponents, numComp);
if (err < 0)
{
numComp = 1;
}
if(H5Tequal(typeId, H5T_STD_U8BE) || H5Tequal(typeId, H5T_STD_U8LE)
|| H5Tequal(typeId, H5T_STD_I8BE) || H5Tequal(typeId, H5T_STD_I8LE) )
{
if (preflightOnly == false) {
IDataArray::Pointer bufferPtr = Detail::readH5Dataset<char>(gid, name, dims);
const char* buf = reinterpret_cast<char*>(bufferPtr->GetVoidPointer(0));
// count the number of 0x00 characters which are the 'null termination' of each string
size_t size = bufferPtr->GetNumberOfTuples();
size_t count = 0;
for(size_t i = 0; i < size; ++i)
{
if(buf[i] == 0)
{
++count;
}
}
ptr = StringDataArray::CreateArray(count, name);
StringDataArray* strArray = StringDataArray::SafePointerDownCast(ptr.get());
size_t start = 0;
size_t index = 0;
for(size_t i = 0; i < size; ++i)
{
if(buf[i] == 0)
{
std::string str( &(buf[start]) );
strArray->SetValue(index, str);
++index;
start = i + 1;
}
}
}
else // We are preflighting only so just create a StringDataArray of lenght 1
{
ptr = StringDataArray::CreateArray(1, name);
}
}
}
CloseH5T(typeId, err, retErr);
return ptr;
}