本文整理汇总了C++中int32arraytype::Pointer::initializeWithZeros方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::initializeWithZeros方法的具体用法?C++ Pointer::initializeWithZeros怎么用?C++ Pointer::initializeWithZeros使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类int32arraytype::Pointer
的用法示例。
在下文中一共展示了Pointer::initializeWithZeros方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void VisualizeGBCDGMT::execute()
{
setErrorCondition(0);
dataCheck();
if(getErrorCondition() < 0) { return; }
DataContainer::Pointer sm = getDataContainerArray()->getDataContainer(getGBCDArrayPath().getDataContainerName());
// Make sure any directory path is also available as the user may have just typed
// in a path without actually creating the full path
QFileInfo fi(getOutputFile());
QDir dir(fi.path());
if (!dir.mkpath("."))
{
QString ss;
ss = QObject::tr("Error creating parent path '%1'").arg(dir.path());
setErrorCondition(-1);
notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
QFile file(getOutputFile());
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QString ss = QObject::tr("Error opening output file '%1'").arg(getOutputFile());
setErrorCondition(-100);
notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
FloatArrayType::Pointer gbcdDeltasArray = FloatArrayType::CreateArray(5, "GBCDDeltas");
gbcdDeltasArray->initializeWithZeros();
FloatArrayType::Pointer gbcdLimitsArray = FloatArrayType::CreateArray(10, "GBCDLimits");
gbcdLimitsArray->initializeWithZeros();
Int32ArrayType::Pointer gbcdSizesArray = Int32ArrayType::CreateArray(5, "GBCDSizes");
gbcdSizesArray->initializeWithZeros();
float* gbcdDeltas = gbcdDeltasArray->getPointer(0);
int32_t* gbcdSizes = gbcdSizesArray->getPointer(0);
float* gbcdLimits = gbcdLimitsArray->getPointer(0);
// Original Ranges from Dave R.
//m_GBCDlimits[0] = 0.0f;
//m_GBCDlimits[1] = cosf(1.0f*m_pi);
//m_GBCDlimits[2] = 0.0f;
//m_GBCDlimits[3] = 0.0f;
//m_GBCDlimits[4] = cosf(1.0f*m_pi);
//m_GBCDlimits[5] = 2.0f*m_pi;
//m_GBCDlimits[6] = cosf(0.0f);
//m_GBCDlimits[7] = 2.0f*m_pi;
//m_GBCDlimits[8] = 2.0f*m_pi;
//m_GBCDlimits[9] = cosf(0.0f);
// Greg R. Ranges
gbcdLimits[0] = 0.0f;
gbcdLimits[1] = 0.0f;
gbcdLimits[2] = 0.0f;
gbcdLimits[3] = -sqrtf(SIMPLib::Constants::k_Pi / 2.0f);
gbcdLimits[4] = -sqrtf(SIMPLib::Constants::k_Pi / 2.0f);
gbcdLimits[5] = SIMPLib::Constants::k_Pi / 2.0f;
gbcdLimits[6] = 1.0f;
gbcdLimits[7] = SIMPLib::Constants::k_Pi / 2.0f;
gbcdLimits[8] = sqrtf(SIMPLib::Constants::k_Pi / 2.0f);
gbcdLimits[9] = sqrtf(SIMPLib::Constants::k_Pi / 2.0f);
// get num components of GBCD
QVector<size_t> cDims = m_GBCDPtr.lock()->getComponentDimensions();
gbcdSizes[0] = cDims[0];
gbcdSizes[1] = cDims[1];
gbcdSizes[2] = cDims[2];
gbcdSizes[3] = cDims[3];
gbcdSizes[4] = cDims[4];
gbcdDeltas[0] = (gbcdLimits[5] - gbcdLimits[0]) / float(gbcdSizes[0]);
gbcdDeltas[1] = (gbcdLimits[6] - gbcdLimits[1]) / float(gbcdSizes[1]);
gbcdDeltas[2] = (gbcdLimits[7] - gbcdLimits[2]) / float(gbcdSizes[2]);
gbcdDeltas[3] = (gbcdLimits[8] - gbcdLimits[3]) / float(gbcdSizes[3]);
gbcdDeltas[4] = (gbcdLimits[9] - gbcdLimits[4]) / float(gbcdSizes[4]);
float vec[3] = { 0.0f, 0.0f, 0.0f };
float vec2[3] = { 0.0f, 0.0f, 0.0f };
float rotNormal[3] = { 0.0f, 0.0f, 0.0f };
float rotNormal2[3] = { 0.0f, 0.0f, 0.0f };
float sqCoord[2] = { 0.0f, 0.0f };
float dg[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float dgt[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float dg1[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float dg2[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float sym1[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float sym2[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float sym2t[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float mis_euler1[3] = { 0.0f, 0.0f, 0.0f };
//.........这里部分代码省略.........
示例2: 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)
//.........这里部分代码省略.........
示例3: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void VisualizeGBCDPoleFigure::execute()
{
setErrorCondition(0);
dataCheck();
if(getErrorCondition() < 0) { return; }
// Make sure any directory path is also available as the user may have just typed
// in a path without actually creating the full path
QFileInfo fi(getOutputFile());
QDir dir(fi.path());
if(!dir.mkpath("."))
{
QString ss;
ss = QObject::tr("Error creating parent path '%1'").arg(dir.path());
setErrorCondition(-1);
notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
QFile file(getOutputFile());
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QString ss = QObject::tr("Error opening output file '%1'").arg(getOutputFile());
setErrorCondition(-100);
notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
FloatArrayType::Pointer gbcdDeltasArray = FloatArrayType::CreateArray(5, "GBCDDeltas");
gbcdDeltasArray->initializeWithZeros();
FloatArrayType::Pointer gbcdLimitsArray = FloatArrayType::CreateArray(10, "GBCDLimits");
gbcdLimitsArray->initializeWithZeros();
Int32ArrayType::Pointer gbcdSizesArray = Int32ArrayType::CreateArray(5, "GBCDSizes");
gbcdSizesArray->initializeWithZeros();
float* gbcdDeltas = gbcdDeltasArray->getPointer(0);
int* gbcdSizes = gbcdSizesArray->getPointer(0);
float* gbcdLimits = gbcdLimitsArray->getPointer(0);
// Original Ranges from Dave R.
//m_GBCDlimits[0] = 0.0f;
//m_GBCDlimits[1] = cosf(1.0f*m_pi);
//m_GBCDlimits[2] = 0.0f;
//m_GBCDlimits[3] = 0.0f;
//m_GBCDlimits[4] = cosf(1.0f*m_pi);
//m_GBCDlimits[5] = 2.0f*m_pi;
//m_GBCDlimits[6] = cosf(0.0f);
//m_GBCDlimits[7] = 2.0f*m_pi;
//m_GBCDlimits[8] = 2.0f*m_pi;
//m_GBCDlimits[9] = cosf(0.0f);
// Greg R. Ranges
gbcdLimits[0] = 0.0f;
gbcdLimits[1] = 0.0f;
gbcdLimits[2] = 0.0f;
gbcdLimits[3] = 0.0f;
gbcdLimits[4] = 0.0f;
gbcdLimits[5] = SIMPLib::Constants::k_PiOver2;
gbcdLimits[6] = 1.0f;
gbcdLimits[7] = SIMPLib::Constants::k_PiOver2;
gbcdLimits[8] = 1.0f;
gbcdLimits[9] = SIMPLib::Constants::k_2Pi;
// reset the 3rd and 4th dimensions using the square grid approach
gbcdLimits[3] = -sqrtf(SIMPLib::Constants::k_PiOver2);
gbcdLimits[4] = -sqrtf(SIMPLib::Constants::k_PiOver2);
gbcdLimits[8] = sqrtf(SIMPLib::Constants::k_PiOver2);
gbcdLimits[9] = sqrtf(SIMPLib::Constants::k_PiOver2);
// get num components of GBCD
QVector<size_t> cDims = m_GBCDPtr.lock()->getComponentDimensions();
gbcdSizes[0] = cDims[0];
gbcdSizes[1] = cDims[1];
gbcdSizes[2] = cDims[2];
gbcdSizes[3] = cDims[3];
gbcdSizes[4] = cDims[4];
gbcdDeltas[0] = (gbcdLimits[5] - gbcdLimits[0]) / float(gbcdSizes[0]);
gbcdDeltas[1] = (gbcdLimits[6] - gbcdLimits[1]) / float(gbcdSizes[1]);
gbcdDeltas[2] = (gbcdLimits[7] - gbcdLimits[2]) / float(gbcdSizes[2]);
gbcdDeltas[3] = (gbcdLimits[8] - gbcdLimits[3]) / float(gbcdSizes[3]);
gbcdDeltas[4] = (gbcdLimits[9] - gbcdLimits[4]) / float(gbcdSizes[4]);
float vec[3] = { 0.0f, 0.0f, 0.0f };
float vec2[3] = { 0.0f, 0.0f, 0.0f };
float rotNormal[3] = { 0.0f, 0.0f, 0.0f };
float rotNormal2[3] = { 0.0f, 0.0f, 0.0f };
float sqCoord[2] = { 0.0f, 0.0f };
float dg[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float dgt[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float dg1[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float dg2[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float sym1[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
//.........这里部分代码省略.........
示例4: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void SampleSurfaceMesh::execute()
{
setErrorCondition(0);
dataCheck();
if(getErrorCondition() < 0) { return; }
DataContainer::Pointer sm = getDataContainerArray()->getDataContainer(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName());
SIMPL_RANDOMNG_NEW()
#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
tbb::task_scheduler_init init;
bool doParallel = true;
#endif
TriangleGeom::Pointer triangleGeom = sm->getGeometryAs<TriangleGeom>();
// pull down faces
int64_t numFaces = m_SurfaceMeshFaceLabelsPtr.lock()->getNumberOfTuples();
// create array to hold bounding vertices for each face
FloatArrayType::Pointer llPtr = FloatArrayType::CreateArray(3, "_INTERNAL_USE_ONLY_Lower_Left");
FloatArrayType::Pointer urPtr = FloatArrayType::CreateArray(3, "_INTERNAL_USE_ONLY_Upper_Right");
float* ll = llPtr->getPointer(0);
float* ur = urPtr->getPointer(0);
VertexGeom::Pointer faceBBs = VertexGeom::CreateGeometry(2 * numFaces, "_INTERNAL_USE_ONLY_faceBBs");
// walk through faces to see how many features there are
int32_t g1 = 0, g2 = 0;
int32_t maxFeatureId = 0;
for (int64_t i = 0; i < numFaces; i++)
{
g1 = m_SurfaceMeshFaceLabels[2 * i];
g2 = m_SurfaceMeshFaceLabels[2 * i + 1];
if (g1 > maxFeatureId) { maxFeatureId = g1; }
if (g2 > maxFeatureId) { maxFeatureId = g2; }
}
// add one to account for feature 0
int32_t numFeatures = maxFeatureId + 1;
// create a dynamic list array to hold face lists
Int32Int32DynamicListArray::Pointer faceLists = Int32Int32DynamicListArray::New();
std::vector<int32_t> linkCount(numFeatures, 0);
// fill out lists with number of references to cells
typedef boost::shared_array<int32_t> SharedInt32Array_t;
SharedInt32Array_t linkLocPtr(new int32_t[numFaces]);
int32_t* linkLoc = linkLocPtr.get();
::memset(linkLoc, 0, numFaces * sizeof(int32_t));
// traverse data to determine number of faces belonging to each feature
for (int64_t i = 0; i < numFaces; i++)
{
g1 = m_SurfaceMeshFaceLabels[2 * i];
g2 = m_SurfaceMeshFaceLabels[2 * i + 1];
if (g1 > 0) { linkCount[g1]++; }
if (g2 > 0) { linkCount[g2]++; }
}
// now allocate storage for the faces
faceLists->allocateLists(linkCount);
// traverse data again to get the faces belonging to each feature
for (int64_t i = 0; i < numFaces; i++)
{
g1 = m_SurfaceMeshFaceLabels[2 * i];
g2 = m_SurfaceMeshFaceLabels[2 * i + 1];
if (g1 > 0) { faceLists->insertCellReference(g1, (linkLoc[g1])++, i); }
if (g2 > 0) { faceLists->insertCellReference(g2, (linkLoc[g2])++, i); }
// find bounding box for each face
GeometryMath::FindBoundingBoxOfFace(triangleGeom, i, ll, ur);
faceBBs->setCoords(2 * i, ll);
faceBBs->setCoords(2 * i + 1, ur);
}
// generate the list of sampling points from subclass
VertexGeom::Pointer points = generate_points();
if(getErrorCondition() < 0 || NULL == points.get()) { return; }
int64_t numPoints = points->getNumberOfVertices();
// create array to hold which polyhedron (feature) each point falls in
Int32ArrayType::Pointer iArray = Int32ArrayType::NullPointer();
iArray = Int32ArrayType::CreateArray(numPoints, "_INTERNAL_USE_ONLY_polyhedronIds");
iArray->initializeWithZeros();
int32_t* polyIds = iArray->getPointer(0);
#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
if (doParallel == true)
{
tbb::parallel_for(tbb::blocked_range<size_t>(0, numFeatures),
SampleSurfaceMeshImpl(triangleGeom, faceLists, faceBBs, points, polyIds), tbb::auto_partitioner());
}
else
#endif
{
SampleSurfaceMeshImpl serial(triangleGeom, faceLists, faceBBs, points, polyIds);
serial.checkPoints(0, numFeatures);
//.........这里部分代码省略.........