本文整理汇总了C++中int32arraytype::Pointer::getPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::getPointer方法的具体用法?C++ Pointer::getPointer怎么用?C++ Pointer::getPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类int32arraytype::Pointer
的用法示例。
在下文中一共展示了Pointer::getPointer方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assign_points
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void RegularGridSampleSurfaceMesh::assign_points(Int32ArrayType::Pointer iArray)
{
int32_t* ids = iArray->getPointer(0);
for (int64_t i = 0; i < (m_XPoints * m_YPoints * m_ZPoints); i++)
{
m_FeatureIds[i] = ids[i];
}
}
示例2: assign_badpoints
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void RemoveFlaggedFeatures::assign_badpoints()
{
DataContainer::Pointer m = getDataContainerArray()->getDataContainer(m_FeatureIdsArrayPath.getDataContainerName());
size_t totalPoints = m_FeatureIdsPtr.lock()->getNumberOfTuples();
size_t udims[3] = {0, 0, 0};
m->getGeometryAs<ImageGeom>()->getDimensions(udims);
#if (CMP_SIZEOF_SIZE_T == 4)
typedef int32_t DimType;
#else
typedef int64_t DimType;
#endif
DimType dims[3] =
{
static_cast<DimType>(udims[0]),
static_cast<DimType>(udims[1]),
static_cast<DimType>(udims[2]),
};
Int32ArrayType::Pointer neighborsPtr = Int32ArrayType::CreateArray(totalPoints, "_INTERNAL_USE_ONLY_Neighbors");
m_Neighbors = neighborsPtr->getPointer(0);
neighborsPtr->initializeWithValue(-1);
int32_t good = 1;
int32_t current = 0;
int32_t most = 0;
int64_t neighpoint = 0;
DimType neighpoints[6];
neighpoints[0] = -dims[0] * dims[1];
neighpoints[1] = -dims[0];
neighpoints[2] = -1;
neighpoints[3] = 1;
neighpoints[4] = dims[0];
neighpoints[5] = dims[0] * dims[1];
size_t counter = 1;
int64_t count = 0;
int64_t kstride = 0, jstride = 0;
int32_t featurename, feature;
int32_t neighbor;
QVector<int32_t> n(m_FlaggedFeaturesPtr.lock()->getNumberOfTuples(), 0);
while (counter != 0)
{
counter = 0;
for (DimType k = 0; k < dims[2]; k++)
{
kstride = dims[0] * dims[1] * k;
for (DimType j = 0; j < dims[1]; j++)
{
jstride = dims[0] * j;
for (DimType i = 0; i < dims[0]; i++)
{
count = kstride + jstride + i;
featurename = m_FeatureIds[count];
if (featurename < 0)
{
counter++;
current = 0;
most = 0;
for (int32_t l = 0; l < 6; l++)
{
good = 1;
neighpoint = count + neighpoints[l];
if (l == 0 && k == 0) { good = 0; }
if (l == 5 && k == (dims[2] - 1)) { good = 0; }
if (l == 1 && j == 0) { good = 0; }
if (l == 4 && j == (dims[1] - 1)) { good = 0; }
if (l == 2 && i == 0) { good = 0; }
if (l == 3 && i == (dims[0] - 1)) { good = 0; }
if (good == 1)
{
feature = m_FeatureIds[neighpoint];
if (feature >= 0)
{
n[feature]++;
current = n[feature];
if (current > most)
{
most = current;
m_Neighbors[count] = neighpoint;
}
}
}
}
for (int32_t l = 0; l < 6; l++)
{
good = 1;
neighpoint = count + neighpoints[l];
if (l == 0 && k == 0) { good = 0; }
if (l == 5 && k == (dims[2] - 1)) { good = 0; }
if (l == 1 && j == 0) { good = 0; }
if (l == 4 && j == (dims[1] - 1)) { good = 0; }
if (l == 2 && i == 0) { good = 0; }
if (l == 3 && i == (dims[0] - 1)) { good = 0; }
if (good == 1)
{
//.........这里部分代码省略.........
示例3: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ErodeDilateBadData::execute()
{
setErrorCondition(0);
dataCheck();
if(getErrorCondition() < 0) { return; }
DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getFeatureIdsArrayPath().getDataContainerName());
size_t totalPoints = m_FeatureIdsPtr.lock()->getNumberOfTuples();
Int32ArrayType::Pointer neighborsPtr = Int32ArrayType::CreateArray(totalPoints, "_INTERNAL_USE_ONLY_Neighbors");
m_Neighbors = neighborsPtr->getPointer(0);
neighborsPtr->initializeWithValue(-1);
size_t udims[3] = {0, 0, 0};
m->getGeometryAs<ImageGeom>()->getDimensions(udims);
#if (CMP_SIZEOF_SIZE_T == 4)
typedef int32_t DimType;
#else
typedef int64_t DimType;
#endif
DimType dims[3] =
{
static_cast<DimType>(udims[0]),
static_cast<DimType>(udims[1]),
static_cast<DimType>(udims[2]),
};
int32_t good = 1;
int64_t count = 0;
int64_t kstride = 0, jstride = 0;
int32_t featurename = 0, feature = 0;
int32_t current = 0;
int32_t most = 0;
int64_t neighpoint = 0;
size_t numfeatures = 0;
for (size_t i = 0; i < totalPoints; i++)
{
featurename = m_FeatureIds[i];
if (featurename > numfeatures) { numfeatures = featurename; }
}
DimType neighpoints[6] = { 0, 0, 0, 0, 0, 0 };
neighpoints[0] = -dims[0] * dims[1];
neighpoints[1] = -dims[0];
neighpoints[2] = -1;
neighpoints[3] = 1;
neighpoints[4] = dims[0];
neighpoints[5] = dims[0] * dims[1];
QVector<int32_t> n(numfeatures + 1, 0);
for (int32_t iteration = 0; iteration < m_NumIterations; iteration++)
{
for (DimType k = 0; k < dims[2]; k++)
{
kstride = dims[0] * dims[1] * k;
for (DimType j = 0; j < dims[1]; j++)
{
jstride = dims[0] * j;
for (DimType i = 0; i < dims[0]; i++)
{
count = kstride + jstride + i;
featurename = m_FeatureIds[count];
if (featurename == 0)
{
current = 0;
most = 0;
for (int32_t l = 0; l < 6; l++)
{
good = 1;
neighpoint = count + neighpoints[l];
if (l == 0 && (k == 0 || m_ZDirOn == false)) { good = 0; }
else if (l == 5 && (k == (dims[2] - 1) || m_ZDirOn == false)) { good = 0; }
else if (l == 1 && (j == 0 || m_YDirOn == false)) { good = 0; }
else if (l == 4 && (j == (dims[1] - 1) || m_YDirOn == false)) { good = 0; }
else if (l == 2 && (i == 0 || m_XDirOn == false)) { good = 0; }
else if (l == 3 && (i == (dims[0] - 1) || m_XDirOn == false)) { good = 0; }
if (good == 1)
{
feature = m_FeatureIds[neighpoint];
if (m_Direction == 0 && feature > 0)
{
m_Neighbors[neighpoint] = count;
}
if (feature > 0 && m_Direction == 1)
{
n[feature]++;
current = n[feature];
if (current > most)
{
most = current;
m_Neighbors[count] = neighpoint;
}
}
}
}
//.........这里部分代码省略.........
示例4: find_shifts
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void AlignSectionsMutualInformation::find_shifts(std::vector<int64_t>& xshifts, std::vector<int64_t>& yshifts)
{
DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName());
int64_t totalPoints = m->getAttributeMatrix(getCellAttributeMatrixName())->getNumTuples();
Int32ArrayType::Pointer p = Int32ArrayType::CreateArray((totalPoints * 1), "_INTERNAL_USE_ONLY_MIFeatureIds");
m_FeatureIds = p->getPointer(0);
std::ofstream outFile;
if (getWriteAlignmentShifts() == true)
{
outFile.open(getAlignmentShiftFileName().toLatin1().data());
}
size_t udims[3] = { 0, 0, 0 };
m->getGeometryAs<ImageGeom>()->getDimensions(udims);
#if (CMP_SIZEOF_SIZE_T == 4)
typedef int32_t DimType;
#else
typedef int64_t DimType;
#endif
DimType dims[3] =
{
static_cast<DimType>(udims[0]),
static_cast<DimType>(udims[1]),
static_cast<DimType>(udims[2]),
};
float disorientation = 0.0f;
float mindisorientation = std::numeric_limits<float>::max();
float** mutualinfo12 = NULL;
float* mutualinfo1 = NULL;
float* mutualinfo2 = NULL;
int32_t featurecount1 = 0, featurecount2 = 0;
int64_t newxshift = 0;
int64_t newyshift = 0;
int64_t oldxshift = 0;
int64_t oldyshift = 0;
float count = 0.0f;
DimType slice = 0;
int32_t refgnum = 0, curgnum = 0;
DimType refposition = 0;
DimType curposition = 0;
form_features_sections();
std::vector<std::vector<float> > misorients;
misorients.resize(dims[0]);
for (DimType a = 0; a < dims[0]; a++)
{
misorients[a].assign(dims[1], 0.0f);
}
for (DimType iter = 1; iter < dims[2]; iter++)
{
QString ss = QObject::tr("Aligning Sections || Determining Shifts || %1% Complete").arg(((float)iter / dims[2]) * 100);
notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss);
mindisorientation = std::numeric_limits<float>::max();
slice = (dims[2] - 1) - iter;
featurecount1 = featurecounts[slice];
featurecount2 = featurecounts[slice + 1];
mutualinfo12 = new float *[featurecount1];
mutualinfo1 = new float[featurecount1];
mutualinfo2 = new float[featurecount2];
for (int32_t a = 0; a < featurecount1; a++)
{
mutualinfo1[a] = 0.0f;
mutualinfo12[a] = new float[featurecount2];
for (int32_t b = 0; b < featurecount2; b++)
{
mutualinfo12[a][b] = 0.0f;
mutualinfo2[b] = 0.0f;
}
}
oldxshift = -1;
oldyshift = -1;
newxshift = 0;
newyshift = 0;
for (DimType a = 0; a < dims[0]; a++)
{
for (DimType b = 0; b < dims[1]; b++)
{
misorients[a][b] = 0;
}
}
while (newxshift != oldxshift || newyshift != oldyshift)
{
oldxshift = newxshift;
oldyshift = newyshift;
for (int32_t j = -3; j < 4; j++)
{
for (int32_t k = -3; k < 4; k++)
{
disorientation = 0;
count = 0;
//.........这里部分代码省略.........
示例5: 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 };
//.........这里部分代码省略.........
示例6: removeInactiveObjects
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool AttributeMatrix::removeInactiveObjects(QVector<bool> activeObjects, Int32ArrayType::Pointer Ids)
{
bool acceptableMatrix = false;
//Only valid for feature or ensemble type matrices
if(m_Type == DREAM3D::AttributeMatrixType::VertexFeature || m_Type == DREAM3D::AttributeMatrixType::VertexEnsemble ||
m_Type == DREAM3D::AttributeMatrixType::EdgeFeature || m_Type == DREAM3D::AttributeMatrixType::EdgeEnsemble ||
m_Type == DREAM3D::AttributeMatrixType::FaceFeature || m_Type == DREAM3D::AttributeMatrixType::FaceEnsemble ||
m_Type == DREAM3D::AttributeMatrixType::CellFeature || m_Type == DREAM3D::AttributeMatrixType::CellEnsemble)
{
acceptableMatrix = true;
}
size_t totalTuples = getNumTuples();
if( static_cast<size_t>(activeObjects.size()) == totalTuples && acceptableMatrix == true)
{
size_t goodcount = 1;
QVector<size_t> NewNames(totalTuples, 0);
QVector<size_t> RemoveList;
for(qint32 i = 1; i < activeObjects.size(); i++)
{
if(activeObjects[i] == false)
{
RemoveList.push_back(i);
NewNames[i] = 0;
}
else
{
NewNames[i] = goodcount;
goodcount++;
}
}
if(RemoveList.size() > 0)
{
QList<QString> headers = getAttributeArrayNames();
for (QList<QString>::iterator iter = headers.begin(); iter != headers.end(); ++iter)
{
IDataArray::Pointer p = getAttributeArray(*iter);
QString type = p->getTypeAsString();
if(type.compare("NeighborList<T>") == 0)
{
removeAttributeArray(*iter);
}
else
{
p->eraseTuples(RemoveList);
}
}
QVector<size_t> tDims(1, (totalTuples - RemoveList.size()));
setTupleDimensions(tDims);
// Loop over all the points and correct all the feature names
size_t totalPoints = Ids->getNumberOfTuples();
int32_t* id = Ids->getPointer(0);
for (size_t i = 0; i < totalPoints; i++)
{
if(id[i] >= 0 && id[i] < NewNames.size())
{
id[i] = static_cast<int32_t>( NewNames[id[i]] );
}
}
}
}
else
{
return false;
}
return true;
}
示例7: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ErodeDilateCoordinationNumber::execute()
{
setErrorCondition(0);
dataCheck();
if(getErrorCondition() < 0) { return; }
DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getFeatureIdsArrayPath().getDataContainerName());
size_t totalPoints = m_FeatureIdsPtr.lock()->getNumberOfTuples();
Int32ArrayType::Pointer neighborsPtr = Int32ArrayType::CreateArray(totalPoints, "Neighbors");
m_Neighbors = neighborsPtr->getPointer(0);
neighborsPtr->initializeWithValue(-1);
size_t udims[3] = {0, 0, 0};
m->getGeometryAs<ImageGeom>()->getDimensions(udims);
int64_t dims[3] =
{
static_cast<int64_t>(udims[0]),
static_cast<int64_t>(udims[1]),
static_cast<int64_t>(udims[2]),
};
int32_t good = 1;
int64_t point = 0;
int64_t kstride = 0, jstride = 0;
int32_t featurename = 0, feature = 0;
int32_t coordination = 0;
int32_t current = 0;
int32_t most = 0;
int64_t neighpoint = 0;
size_t numfeatures = 0;
for(size_t i = 0; i < totalPoints; i++)
{
featurename = m_FeatureIds[i];
if (featurename > numfeatures) { numfeatures = featurename; }
}
int64_t neighpoints[6] = { 0, 0, 0, 0, 0, 0 };
neighpoints[0] = -dims[0] * dims[1];
neighpoints[1] = -dims[0];
neighpoints[2] = -1;
neighpoints[3] = 1;
neighpoints[4] = dims[0];
neighpoints[5] = dims[0] * dims[1];
QString attrMatName = m_FeatureIdsArrayPath.getAttributeMatrixName();
QList<QString> voxelArrayNames = m->getAttributeMatrix(attrMatName)->getAttributeArrayNames();
QVector<int32_t> n(numfeatures + 1, 0);
QVector<int32_t> coordinationNumber(totalPoints, 0);
bool keepgoing = true;
int32_t counter = 1;
while (counter > 0 && keepgoing == true)
{
counter = 0;
if (m_Loop == false) { keepgoing = false; }
for (int64_t k = 0; k < dims[2]; k++)
{
kstride = dims[0] * dims[1] * k;
for (int64_t j = 0; j < dims[1]; j++)
{
jstride = dims[0] * j;
for (int64_t i = 0; i < dims[0]; i++)
{
point = kstride + jstride + i;
featurename = m_FeatureIds[point];
coordination = 0;
current = 0;
most = 0;
for (int32_t l = 0; l < 6; l++)
{
good = 1;
neighpoint = point + neighpoints[l];
if (l == 0 && k == 0) { good = 0; }
if (l == 5 && k == (dims[2] - 1)) { good = 0; }
if (l == 1 && j == 0) { good = 0; }
if (l == 4 && j == (dims[1] - 1)) { good = 0; }
if (l == 2 && i == 0) { good = 0; }
if (l == 3 && i == (dims[0] - 1)) { good = 0; }
if (good == 1)
{
feature = m_FeatureIds[neighpoint];
if ((featurename > 0 && feature == 0) || (featurename == 0 && feature > 0))
{
coordination = coordination + 1;
n[feature]++;
current = n[feature];
if (current > most)
{
most = current;
m_Neighbors[point] = neighpoint;
}
}
//.........这里部分代码省略.........
示例8: TestDataArray
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void TestDataArray()
{
int32_t* ptr = NULL;
{
Int32ArrayType::Pointer d = Int32ArrayType::CreateArray(0, "Test7");
DREAM3D_REQUIRE_EQUAL(0, d->getSize());
DREAM3D_REQUIRE_EQUAL(0, d->getNumberOfTuples());
ptr = d->getPointer(0);
DREAM3D_REQUIRE_EQUAL(ptr, 0);
DREAM3D_REQUIRE_EQUAL(d->isAllocated(), false);
}
{
QVector<size_t> dims(1, NUM_COMPONENTS);
Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray(NUM_ELEMENTS, dims, "Test8");
ptr = int32Array->getPointer(0);
DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true);
DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS, int32Array->getNumberOfTuples());
DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS * NUM_COMPONENTS, int32Array->getSize());
for (int i = 0; i < NUM_TUPLES; ++i)
{
for (int c = 0; c < NUM_COMPONENTS; ++c)
{
int32Array->setComponent(i, c, i + c);
}
}
// Resize Larger
int32Array->resize(NUM_TUPLES_2);
DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_2, int32Array->getNumberOfTuples());
DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_2, int32Array->getSize());
DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true);
// This should have saved our data so lets look at the data and compare it
for (int i = 0; i < NUM_TUPLES; ++i)
{
for (int c = 0; c < NUM_COMPONENTS; ++c)
{
DREAM3D_REQUIRE_EQUAL( (int32Array->getComponent(i, c)), (i + c))
}
}
// Resize Smaller - Which should have still saved some of our data
int32Array->resize(NUM_TUPLES_3);
DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_3, int32Array->getNumberOfTuples());
DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_3, int32Array->getSize());
DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true);
// This should have saved our data so lets look at the data and compare it
for (int i = 0; i < NUM_TUPLES; ++i)
{
for (int c = 0; c < NUM_COMPONENTS; ++c)
{
DREAM3D_REQUIRE_EQUAL( (int32Array->getComponent(i, c)), (i + c))
}
}
// Change number of components
// dims[0] = NUM_COMPONENTS_4;
// int32Array->setDims(dims);
// DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_4, int32Array->getNumberOfTuples());
// DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_4, int32Array->getSize());
double temp = 9999;
int32Array->initializeTuple(0, temp );
for (int c = 0; c < NUM_COMPONENTS; ++c)
{
DREAM3D_REQUIRE_EQUAL( (int32Array->getComponent(0, c)), (9999))
}
ptr = int32Array->getPointer(0);
}
}
示例9: 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 } };
//.........这里部分代码省略.........
示例10: generate
void generate(size_t start, size_t end) const
{
// We want to work with the raw pointers for speed so get those pointers.
float* m_GBCDdeltas = m_GbcdDeltasArray->getPointer(0);
float* m_GBCDlimits = m_GbcdLimitsArray->getPointer(0);
int* m_GBCDsizes = m_GbcdSizesArray->getPointer(0);
int32_t* m_Bins = m_GbcdBinsArray->getPointer(0);
bool* m_HemiCheck = m_GbcdHemiCheckArray->getPointer(0);
int32_t* m_Labels = m_LabelsArray->getPointer(0);
double* m_Normals = m_NormalsArray->getPointer(0);
int32_t* m_Phases = m_PhasesArray->getPointer(0);
float* m_Eulers = m_EulersArray->getPointer(0);
uint32_t* m_CrystalStructures = m_CrystalStructuresArray->getPointer(0);
int32_t j = 0;//, j4;
int32_t k = 0;//, k4;
int32_t m = 0;
int32_t temp = 0;
//bool gbcd_indices_good;
int32_t feature1 = 0, feature2 = 0;
int32_t inversion = 1;
float g1ea[3] = { 0.0f, 0.0f, 0.0f }, g2ea[3] = { 0.0f, 0.0f, 0.0f };
float g1[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, g2[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float g1s[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, g2s[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 } }, sym2[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float g2t[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, dg[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
float euler_mis[3] = { 0.0f, 0.0f, 0.0f };
float normal[3] = { 0.0f, 0.0f, 0.0f };
float xstl1_norm1[3] = { 0.0f, 0.0f, 0.0f };
int32_t gbcd_index = 0;
float sqCoord[2] = { 0.0f, 0.0f }, sqCoordInv[2] = { 0.0f, 0.0f };
bool nhCheck = false, nhCheckInv = true;
int32_t SYMcounter = 0;
int64_t TRIcounter = static_cast<int64_t>(start - startOffset);
int64_t TRIcounterShift = 0;
for (size_t i = start; i < end; i++)
{
SYMcounter = 0;
feature1 = m_Labels[2 * i];
feature2 = m_Labels[2 * i + 1];
normal[0] = m_Normals[3 * i];
normal[1] = m_Normals[3 * i + 1];
normal[2] = m_Normals[3 * i + 2];
if (feature1 < 0 || feature2 < 0) { continue; }
if (m_Phases[feature1] == m_Phases[feature2] && m_Phases[feature1] > 0)
{
TRIcounterShift = (TRIcounter * numEntriesPerTri);
uint32_t cryst = m_CrystalStructures[m_Phases[feature1]];
for (int32_t q = 0; q < 2; q++)
{
if (q == 1)
{
temp = feature1;
feature1 = feature2;
feature2 = temp;
normal[0] = -normal[0];
normal[1] = -normal[1];
normal[2] = -normal[2];
}
for (m = 0; m < 3; m++)
{
g1ea[m] = m_Eulers[3 * feature1 + m];
g2ea[m] = m_Eulers[3 * feature2 + m];
}
FOrientArrayType om(9, 0.0f);
FOrientTransformsType::eu2om(FOrientArrayType(g1ea, 3), om);
om.toGMatrix(g1);
FOrientTransformsType::eu2om(FOrientArrayType(g2ea, 3), om);
om.toGMatrix(g2);
int32_t nsym = m_OrientationOps[cryst]->getNumSymOps();
for (j = 0; j < nsym; j++)
{
// rotate g1 by symOp
m_OrientationOps[cryst]->getMatSymOp(j, sym1);
MatrixMath::Multiply3x3with3x3(sym1, g1, g1s);
// get the crystal directions along the triangle normals
MatrixMath::Multiply3x3with3x1(g1s, normal, xstl1_norm1);
// get coordinates in square projection of crystal normal parallel to boundary normal
nhCheck = getSquareCoord(xstl1_norm1, sqCoord);
if (inversion == 1)
{
sqCoordInv[0] = -sqCoord[0];
sqCoordInv[1] = -sqCoord[1];
if (nhCheck == false) { nhCheckInv = true; }
else { nhCheckInv = false; }
}
for (k = 0; k < nsym; k++)
{
// calculate the symmetric misorienation
m_OrientationOps[cryst]->getMatSymOp(k, sym2);
//.........这里部分代码省略.........
示例11: CalculateCubicODFData
static void CalculateCubicODFData(T* e1s, T* e2s, T* e3s,
T* weights, T* sigmas,
bool normalize, T* odf, size_t numEntries)
{
SIMPL_RANDOMNG_NEW()
CubicOps ops;
Int32ArrayType::Pointer textureBins = Int32ArrayType::CreateArray(numEntries, "TextureBins");
int32_t* TextureBins = textureBins->getPointer(0);
float addweight = 0;
float totaladdweight = 0;
float totalweight = float(ops.getODFSize());
int bin, addbin;
int bin1, bin2, bin3;
int addbin1, addbin2, addbin3;
float dist, fraction;
for (size_t i = 0; i < numEntries; i++)
{
FOrientArrayType eu(e1s[i], e2s[i], e3s[i]);
FOrientArrayType rod(4);
OrientationTransforms<FOrientArrayType, float>::eu2ro(eu, rod);
rod = ops.getODFFZRod(rod);
bin = ops.getOdfBin(rod);
TextureBins[i] = static_cast<int>(bin);
}
for (int i = 0; i < ops.getODFSize(); i++)
{
odf[i] = 0;
}
for (size_t i = 0; i < numEntries; i++)
{
bin = TextureBins[i];
bin1 = bin % 18;
bin2 = (bin / 18) % 18;
bin3 = bin / (18 * 18);
for (int j = -sigmas[i]; j <= sigmas[i]; j++)
{
int jsqrd = j * j;
for (int k = -sigmas[i]; k <= sigmas[i]; k++)
{
int ksqrd = k * k;
for (int l = -sigmas[i]; l <= sigmas[i]; l++)
{
int lsqrd = l * l;
addbin1 = bin1 + int(j);
addbin2 = bin2 + int(k);
addbin3 = bin3 + int(l);
//if(addbin1 < 0) addbin1 = addbin1 + 18;
//if(addbin1 >= 18) addbin1 = addbin1 - 18;
//if(addbin2 < 0) addbin2 = addbin2 + 18;
//if(addbin2 >= 18) addbin2 = addbin2 - 18;
//if(addbin3 < 0) addbin3 = addbin3 + 18;
//if(addbin3 >= 18) addbin3 = addbin3 - 18;
int good = 1;
if(addbin1 < 0) { good = 0; }
if(addbin1 >= 18) { good = 0; }
if(addbin2 < 0) { good = 0; }
if(addbin2 >= 18) { good = 0; }
if(addbin3 < 0) { good = 0; }
if(addbin3 >= 18) { good = 0; }
addbin = (addbin3 * 18 * 18) + (addbin2 * 18) + (addbin1);
dist = powf((jsqrd + ksqrd + lsqrd), 0.5);
fraction = 1.0 - (double(dist / int(sigmas[i])) * double(dist / int(sigmas[i])));
if(dist <= int(sigmas[i]) && good == 1)
{
addweight = (weights[i] * fraction);
if(sigmas[i] == 0.0) { addweight = weights[i]; }
odf[addbin] = odf[addbin] + addweight;
totaladdweight = totaladdweight + addweight;
}
}
}
}
}
if(totaladdweight > totalweight)
{
float scale = (totaladdweight / totalweight);
for (int i = 0; i < ops.getODFSize(); i++)
{
odf[i] = odf[i] / scale;
}
}
else
{
float remainingweight = totalweight - totaladdweight;
float background = remainingweight / static_cast<float>(ops.getODFSize());
for (int i = 0; i < ops.getODFSize(); i++)
{
odf[i] += background;
}
}
if (normalize == true)
{
// Normalize the odf
for (int i = 0; i < ops.getODFSize(); i++)
{
odf[i] = odf[i] / totalweight;
//.........这里部分代码省略.........
示例12: 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);
//.........这里部分代码省略.........