// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ModifiedLambertProjection::initializeSquares(int dims, float sphereRadius) { m_Dimension = dims; m_SphereRadius = sphereRadius; // We want half the sphere area for each square because each square represents a hemisphere. float halfSphereArea = 4 * M_PI * sphereRadius * sphereRadius / 2.0; // The length of a side of the square is the square root of the area float squareEdge = sqrt(halfSphereArea); m_StepSize = squareEdge / static_cast<float>(m_Dimension); m_MaxCoord = squareEdge / 2.0; m_MinCoord = -squareEdge / 2.0; m_HalfDimension = static_cast<float>(m_Dimension) / 2.0; m_HalfDimensionTimesStepSize = m_HalfDimension * m_StepSize; QVector<size_t> tDims(2, m_Dimension); QVector<size_t> cDims(1, 1); m_NorthSquare = DoubleArrayType::CreateArray(tDims, cDims, "ModifiedLambert_NorthSquare"); m_NorthSquare->initializeWithZeros(); m_SouthSquare = DoubleArrayType::CreateArray(tDims, cDims, "ModifiedLambert_SouthSquare"); m_SouthSquare->initializeWithZeros(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ReadStlFile::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; if (m_StlFilePath.isEmpty() == true) { setErrorCondition(-1003); notifyErrorMessage(getHumanLabel(), "The input file must be set", -1003); } // Create a SufaceMesh Data Container with Faces, Vertices, Feature Labels and optionally Phase labels DataContainer::Pointer sm = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getSurfaceMeshDataContainerName()); if(getErrorCondition() < 0) { return; } SharedVertexList::Pointer sharedVertList = TriangleGeom::CreateSharedVertexList(0); TriangleGeom::Pointer triangleGeom = TriangleGeom::CreateGeometry(0, sharedVertList, DREAM3D::Geometry::TriangleGeometry); sm->setGeometry(triangleGeom); QVector<size_t> tDims(1, 0); sm->createNonPrereqAttributeMatrix<AbstractFilter>(this, getFaceAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Face); QVector<size_t> cDims(1, 3); tempPath.update(getSurfaceMeshDataContainerName(), getFaceAttributeMatrixName(), getFaceNormalsArrayName() ); m_FaceNormalsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<double>, AbstractFilter, double>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FaceNormalsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FaceNormals = m_FaceNormalsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int H5PrimaryStatsDataDelegate::writeVectorOfArrays(hid_t pid, VectorOfFloatArray colData) { herr_t err = 0; herr_t retErr = 0; // Loop through all the column data and write each one to the HDF5 file size_t numColumns = colData.size(); for (size_t c = 0; c < numColumns; ++c) { //qDebug() << "Writing Dataset:" << hdf5GroupName << "/" << columnHeaders[c] ; err = -1; if(NULL != colData[c].get() && colData[c]->getSize() > 0) { QVector<size_t> tDims(1, colData[c]->getNumberOfTuples()); err = colData[c]->writeH5Data(pid, tDims); if(err < 0) { retErr = err; break; } } else { qDebug() << ":Null Data Column had no data. Did you create the data?" ; qDebug() << " File: " << __FILE__ ; qDebug() << " Line: " << __LINE__ ; break; } } return retErr; }
void _TestNeighborListDeepCopy() { QVector<size_t> tDims(10); AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, "AttributeMatrix", DREAM3D::AttributeMatrixType::Cell); typename NeighborList<T>::Pointer neiList = NeighborList<T>::CreateArray(10, "NeighborList"); for(int i = 0; i < 10; ++i) { for(T j = 0; j < (T)(i + 4); ++j) { neiList->addEntry(i, static_cast<T>(i + 3) ); } } typename NeighborList<T>::Pointer copy = std::dynamic_pointer_cast<NeighborList<T> >(neiList->deepCopy()); for(int i = 0; i < 10; ++i) { unsigned char value = 255; typename NeighborList<T>::SharedVectorType nEntry = neiList->getList(i); typename NeighborList<T>::SharedVectorType cEntry = copy->getList(i); DREAM3D_REQUIRED(nEntry.get(), !=, cEntry.get()); (*nEntry)[0] = static_cast<T>(value); DREAM3D_REQUIRED( (*cEntry)[0], !=, 10000000); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int32_t MergeColonies::getSeed(int32_t newFid) { setErrorCondition(0); int32_t numfeatures = static_cast<int32_t>(m_FeaturePhasesPtr.lock()->getNumberOfTuples()); SIMPL_RANDOMNG_NEW() int32_t seed = -1; int32_t randfeature = 0; // Precalculate some constants int32_t totalFMinus1 = numfeatures - 1; size_t counter = 0; randfeature = int32_t(float(rg.genrand_res53()) * float(totalFMinus1)); while (seed == -1 && counter < numfeatures) { if (randfeature > totalFMinus1) { randfeature = randfeature - numfeatures; } if (m_FeatureParentIds[randfeature] == -1) { seed = randfeature; } randfeature++; counter++; } if (seed >= 0) { m_FeatureParentIds[seed] = newFid; QVector<size_t> tDims(1, newFid + 1); getDataContainerArray()->getDataContainer(m_FeatureIdsArrayPath.getDataContainerName())->getAttributeMatrix(getNewCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims); updateFeatureInstancePointers(); } return seed; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int64_t EBSDSegmentFeatures::getSeed(int32_t gnum, int64_t nextSeed) { setErrorCondition(0); DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); size_t totalPoints = m_FeatureIdsPtr.lock()->getNumberOfTuples(); int64_t seed = -1; // start with the next voxel after the last seed size_t randpoint = static_cast<size_t>(nextSeed); while (seed == -1 && randpoint < totalPoints) { if (m_FeatureIds[randpoint] == 0) // If the GrainId of the voxel is ZERO then we can use this as a seed point { if ((m_UseGoodVoxels == false || m_GoodVoxels[randpoint] == true) && m_CellPhases[randpoint] > 0) { seed = randpoint; } else { randpoint += 1; } } else { randpoint += 1; } } if (seed >= 0) { m_FeatureIds[seed] = gnum; QVector<size_t> tDims(1, gnum + 1); m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims); updateFeatureInstancePointers(); } return seed; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RegularGridSampleSurfaceMesh::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; DataContainer::Pointer m = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getDataContainerName()); if (getErrorCondition() < 0) { return; } ImageGeom::Pointer image = ImageGeom::CreateGeometry(DREAM3D::Geometry::ImageGeometry); m->setGeometry(image); // Set the Dimensions, Resolution and Origin of the output data container m->getGeometryAs<ImageGeom>()->setDimensions(m_XPoints, m_YPoints, m_ZPoints); m->getGeometryAs<ImageGeom>()->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z); m->getGeometryAs<ImageGeom>()->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z); QVector<size_t> tDims(3, 0); tDims[0] = m_XPoints; tDims[1] = m_YPoints; tDims[2] = m_ZPoints; AttributeMatrix::Pointer cellAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Cell); if (getErrorCondition() < 0 || NULL == cellAttrMat.get()) { return; } QVector<size_t> cDims(1, 1); tempPath.update(getDataContainerName(), getCellAttributeMatrixName(), getFeatureIdsArrayName() ); m_FeatureIdsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FeatureIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int64_t EBSDSegmentFeatures::getSeed(int32_t gnum) { setErrorCondition(0); DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); size_t totalPoints = m_FeatureIdsPtr.lock()->getNumberOfTuples(); int64_t seed = -1; Generator& numberGenerator = *m_NumberGenerator; while (seed == -1 && m_TotalRandomNumbersGenerated < totalPoints) { // Get the next voxel index in the precomputed list of voxel seeds int64_t randpoint = numberGenerator(); m_TotalRandomNumbersGenerated++; // Increment this counter if (m_FeatureIds[randpoint] == 0) // If the GrainId of the voxel is ZERO then we can use this as a seed point { if ((m_UseGoodVoxels == false || m_GoodVoxels[randpoint] == true) && m_CellPhases[randpoint] > 0) { seed = randpoint; } } } if (seed >= 0) { m_FeatureIds[seed] = gnum; QVector<size_t> tDims(1, gnum + 1); m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims); updateFeatureInstancePointers(); } return seed; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int VertexGeom::writeGeometryToHDF5(hid_t parentId, bool writeXdmf) { herr_t err = 0; QVector<size_t> tDims(1, 0); if (m_VertexList.get() != NULL) { err = GeometryHelpers::GeomIO::WriteListToHDF5(parentId, m_VertexList); if (err < 0) { return err; } if(writeXdmf == true) { QVector<size_t> cDims(1, 1); DataArray<int64_t>::Pointer vertsPtr = DataArray<int64_t>::CreateArray(getNumberOfVertices(), cDims, DREAM3D::StringConstants::VertsName); int64_t* verts = vertsPtr->getPointer(0); for(size_t i = 0; i < vertsPtr->getNumberOfTuples(); i++) { verts[i] = i; } tDims[0] = vertsPtr->getNumberOfTuples(); err = vertsPtr->writeH5Data(parentId, tDims); } } return err; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::execute() { setErrorCondition(0); dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getSelectedCellArrayPath().getDataContainerName()); size_t totalPoints = m_SelectedCellDataPtr.lock()->getNumberOfTuples(); int32_t maxIndex = 0; std::vector<bool> active; for (size_t i = 0; i < totalPoints; i++) { int32_t index = m_SelectedCellData[i]; if ((index + 1) > maxIndex) { active.resize(index + 1); active[index] = true; maxIndex = index + 1; } } QVector<size_t> tDims(1, maxIndex); m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims); updateFeatureInstancePointers(); for (int32_t i = 0; i < maxIndex; i++) { m_Active[i] = active[i]; } notifyStatusMessage(getHumanLabel(), "Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MergeTwins::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; GroupFeatures::dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, m_FeatureIdsArrayPath.getDataContainerName(), false); if(getErrorCondition() < 0 || NULL == m.get()) { return; } QVector<size_t> tDims(1, 0); m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getNewCellFeatureAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::CellFeature); QVector<size_t> cDims(1, 1); QVector<DataArrayPath> dataArrayPaths; // Cell Data m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getFeatureIdsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FeatureIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ tempPath.update(m_FeatureIdsArrayPath.getDataContainerName(), m_FeatureIdsArrayPath.getAttributeMatrixName(), getCellParentIdsArrayName() ); m_CellParentIdsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, -1, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_CellParentIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_CellParentIds = m_CellParentIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ // Feature Data m_FeaturePhasesPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getFeaturePhasesArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FeaturePhasesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FeaturePhases = m_FeaturePhasesPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if(getErrorCondition() >= 0) { dataArrayPaths.push_back(getFeaturePhasesArrayPath()); } tempPath.update(m_FeaturePhasesArrayPath.getDataContainerName(), m_FeaturePhasesArrayPath.getAttributeMatrixName(), getFeatureParentIdsArrayName() ); m_FeatureParentIdsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, -1, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FeatureParentIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FeatureParentIds = m_FeatureParentIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 4; m_AvgQuatsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<float>, AbstractFilter>(this, getAvgQuatsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_AvgQuatsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_AvgQuats = m_AvgQuatsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if(getErrorCondition() >= 0) { dataArrayPaths.push_back(getAvgQuatsArrayPath()); } // New Feature Data cDims[0] = 1; tempPath.update(m_FeatureIdsArrayPath.getDataContainerName(), getNewCellFeatureAttributeMatrixName(), getActiveArrayName() ); m_ActivePtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<bool>, AbstractFilter, bool>(this, tempPath, true, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_ActivePtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_Active = m_ActivePtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ // Ensemble Data m_CrystalStructuresPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<unsigned int>, AbstractFilter>(this, getCrystalStructuresArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_CrystalStructuresPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_CrystalStructures = m_CrystalStructuresPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ getDataContainerArray()->validateNumberOfTuples<AbstractFilter>(this, dataArrayPaths); }
void __TestArrayCreation() { int err = 0; size_t numTuples = NUM_TUPLES; int rank = RANK; size_t dims[RANK] = { DIM0, DIM1, DIM2}; int numComp = 1; { typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(numTuples, "TEST"); err = __ValidateArray<T>(array, numTuples, numComp); DREAM3D_REQUIRED(err, >=, 0) } { numComp = DIM0 * DIM1 * DIM2; typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(numTuples, rank, dims, "TEST"); err = __ValidateArray<T>(array, numTuples, numComp); DREAM3D_REQUIRED(err, >=, 0) } { numComp = DIM0 * DIM1 * DIM2; std::vector<size_t> vDims(3, 0); vDims[0] = DIM0; vDims[1] = DIM1; vDims[2] = DIM2; typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(numTuples, vDims, "TEST"); err = __ValidateArray<T>(array, numTuples, numComp); DREAM3D_REQUIRED(err, >=, 0) } { numComp = DIM0 * DIM1 * DIM2; QVector<size_t> vDims(3, 0); vDims[0] = DIM0; vDims[1] = DIM1; vDims[2] = DIM2; typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(numTuples, vDims, "TEST"); err = __ValidateArray<T>(array, numTuples, numComp); DREAM3D_REQUIRED(err, >=, 0) } { QVector<size_t> tDims(2, 4); QVector<size_t> vDims(3, 0); vDims[0] = DIM0; vDims[1] = DIM1; vDims[2] = DIM2; typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(tDims, vDims, "TEST"); err = __ValidateArray<T>(array, tDims[0] * tDims[1], numComp); DREAM3D_REQUIRED(err, >=, 0) } ////FromQVector(QVector<T>& vec, const QString& name) ///FromStdVector(std::vector<T>& vec, const QString& name) /// FromPointer(T* data, size_t size, const QString& name) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int32_t GroupMicroTextureRegions::getSeed(int32_t newFid) { setErrorCondition(0); int32_t numfeatures = static_cast<int32_t>(m_FeaturePhasesPtr.lock()->getNumberOfTuples()); float c1[3] = { 0.0f, 0.0f, 0.0f }; uint32_t phase1 = 0; QuatF* avgQuats = reinterpret_cast<QuatF*>(m_AvgQuats); float caxis[3] = { 0.0f, 0.0f, 1.0f }; QuatF q1 = QuaternionMathF::New(); float g1[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }; float g1t[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }; SIMPL_RANDOMNG_NEW() int32_t seed = -1; int32_t randfeature = 0; // Precalculate some constants int32_t totalFMinus1 = numfeatures - 1; size_t counter = 0; randfeature = int32_t(float(rg.genrand_res53()) * float(totalFMinus1)); while (seed == -1 && counter < numfeatures) { if (randfeature > totalFMinus1) { randfeature = randfeature - numfeatures; } if (m_FeatureParentIds[randfeature] == -1) { seed = randfeature; } randfeature++; counter++; } if (seed >= 0) { m_FeatureParentIds[seed] = newFid; QVector<size_t> tDims(1, newFid + 1); getDataContainerArray()->getDataContainer(m_FeatureIdsArrayPath.getDataContainerName())->getAttributeMatrix(getNewCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims); updateFeatureInstancePointers(); if (m_UseRunningAverage == true) { QuaternionMathF::Copy(avgQuats[seed], q1); phase1 = m_CrystalStructures[m_FeaturePhases[seed]]; FOrientArrayType om(9); FOrientTransformsType::qu2om(FOrientArrayType(q1), om); om.toGMatrix(g1); // transpose the g matrix so when caxis is multiplied by it // it will give the sample direction that the caxis is along MatrixMath::Transpose3x3(g1, g1t); MatrixMath::Multiply3x3with3x1(g1t, caxis, c1); // normalize so that the dot product can be taken below without // dividing by the magnitudes (they would be 1) MatrixMath::Normalize3x1(c1); MatrixMath::Copy3x1(c1, avgCaxes); MatrixMath::Multiply3x1withConstant(avgCaxes, m_Volumes[seed]); } } return seed; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- DoubleArrayType::Pointer ModifiedLambertProjection::createStereographicProjection(int dim) { QVector<size_t> tDims(2, dim); QVector<size_t> cDims(1, 1); DoubleArrayType::Pointer stereoIntensity = DoubleArrayType::CreateArray(tDims, cDims, "ModifiedLambertProjection_StereographicProjection"); stereoIntensity->initializeWithZeros(); createStereographicProjection(dim, stereoIntensity.get()); return stereoIntensity; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int H5PrimaryStatsDataDelegate::writeBinNumbers(PrimaryStatsData* data, hid_t groupId) { // Ensure we have valid bin numbers if(NULL == data->getBinNumbers().get()) { data->generateBinNumbers(); } QVector<size_t> tDims(1, data->getBinNumbers()->getNumberOfTuples()); return data->getBinNumbers()->writeH5Data(groupId, tDims); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ChangeResolution::preflight() { setInPreflight(true); emit preflightAboutToExecute(); emit updateFilterParameters(this); dataCheck(); if (getErrorCondition() < 0) { emit preflightExecuted(); setInPreflight(false); return; } DataContainer::Pointer m; if (m_SaveAsNewDataContainer == false) { m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName()); } else { m = getDataContainerArray()->getDataContainer(getNewDataContainerName()); } size_t dims[3] = { 0, 0, 0 }; m->getGeometryAs<ImageGeom>()->getDimensions(dims); float sizex = (dims[0]) * m->getGeometryAs<ImageGeom>()->getXRes(); float sizey = (dims[1]) * m->getGeometryAs<ImageGeom>()->getYRes(); float sizez = (dims[2]) * m->getGeometryAs<ImageGeom>()->getZRes(); size_t m_XP = size_t(sizex / m_Resolution.x); size_t m_YP = size_t(sizey / m_Resolution.y); size_t m_ZP = size_t(sizez / m_Resolution.z); if (m_XP == 0) { m_XP = 1; } if (m_YP == 0) { m_YP = 1; } if (m_ZP == 0) { m_ZP = 1; } m->getGeometryAs<ImageGeom>()->setDimensions(m_XP, m_YP, m_ZP); m->getGeometryAs<ImageGeom>()->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z); QVector<size_t> tDims(3, 0); tDims[0] = m_XP; tDims[1] = m_YP; tDims[2] = m_ZP; m->getAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName())->setTupleDimensions(tDims); if (m_RenumberFeatures == true) { AttributeMatrix::Pointer cellFeatureAttrMat = m->getAttributeMatrix(getCellFeatureAttributeMatrixPath().getAttributeMatrixName()); QVector<bool> activeObjects(cellFeatureAttrMat->getNumTuples(), true); cellFeatureAttrMat->removeInactiveObjects(activeObjects, m_FeatureIdsPtr.lock()); } emit preflightExecuted(); setInPreflight(false); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void EBSDSegmentFeatures::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; SegmentFeatures::dataCheck(); if(getErrorCondition() < 0) { return; } // Set the DataContainerName for the Parent Class (SegmentFeatures) to Use setDataContainerName(m_QuatsArrayPath.getDataContainerName()); DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getDataContainerName(), false); if(getErrorCondition() < 0 || NULL == m.get()) { return; } QVector<size_t> tDims(1, 0); m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellFeatureAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::CellFeature); QVector<DataArrayPath> dataArrayPaths; QVector<size_t> cDims(1, 1); if(m_UseGoodVoxels == true) { m_GoodVoxelsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<bool>, AbstractFilter>(this, getGoodVoxelsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_GoodVoxelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_GoodVoxels = m_GoodVoxelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if(getErrorCondition() >= 0) { dataArrayPaths.push_back(getGoodVoxelsArrayPath()); } } m_CellPhasesPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getCellPhasesArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_CellPhasesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_CellPhases = m_CellPhasesPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if(getErrorCondition() >= 0) { dataArrayPaths.push_back(getCellPhasesArrayPath()); } tempPath.update(getDataContainerName(), m_QuatsArrayPath.getAttributeMatrixName(), getFeatureIdsArrayName() ); m_FeatureIdsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FeatureIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ tempPath.update(getDataContainerName(), getCellFeatureAttributeMatrixName(), getActiveArrayName() ); m_ActivePtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<bool>, AbstractFilter, bool>(this, tempPath, true, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_ActivePtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_Active = m_ActivePtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ m_CrystalStructuresPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<uint32_t>, AbstractFilter>(this, getCrystalStructuresArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_CrystalStructuresPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_CrystalStructures = m_CrystalStructuresPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 4; m_QuatsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<float>, AbstractFilter>(this, getQuatsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_QuatsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_Quats = m_QuatsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if(getErrorCondition() >= 0) { dataArrayPaths.push_back(getQuatsArrayPath()); } getDataContainerArray()->validateNumberOfTuples<AbstractFilter>(this, dataArrayPaths); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RegularizeZSpacing::dataCheck() { setErrorCondition(0); if (getNewZRes() <= 0) { QString ss = QObject::tr("The new Z resolution Y (%1) must be positive").arg(getNewZRes()); setErrorCondition(-5555); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } std::ifstream inFile; inFile.open(m_InputFile.toLatin1().data()); if (!inFile.good()) { QString ss = QObject::tr("Unable to open input file with name '%1'").arg(getInputFile()); setErrorCondition(-5556); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName()); AttributeMatrix::Pointer cellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getCellAttributeMatrixPath(), -301); if(getErrorCondition() < 0) { return; } float zval = 0.0f; for (size_t iter = 0; iter < image->getZPoints() + 1; iter++) { inFile >> zval; } size_t zP = static_cast<size_t>(zval / getNewZRes()); if(zP == 0) { zP = 1; } if (getInPreflight()) { image->setDimensions(image->getXPoints(), image->getYPoints(), zP); QVector<size_t> tDims(3, 0); tDims[0] = image->getXPoints(); tDims[1] = image->getYPoints(); tDims[2] = zP; cellAttrMat->resizeAttributeArrays(tDims); } inFile.close(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void SineParamsSegmentFeatures::execute() { setErrorCondition(0); dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); QVector<size_t> tDims(1, 1); m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims); // This runs a subfilter int64_t totalPoints = m_FeatureIdsPtr.lock()->getNumberOfTuples(); // Tell the user we are starting the filter notifyStatusMessage(getMessagePrefix(), getHumanLabel(), "Starting"); //Convert user defined tolerance to radians. //angleTolerance = m_AngleTolerance * SIMPLib::Constants::k_Pi / 180.0f; for(int64_t i = 0; i < totalPoints; i++) { m_FeatureIds[i] = 0; } // Generate the random voxel indices that will be used for the seed points to start a new grain growth/agglomeration const size_t rangeMin = 0; const size_t rangeMax = totalPoints - 1; initializeVoxelSeedGenerator(rangeMin, rangeMax); SegmentFeatures::execute(); size_t totalFeatures = m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->getNumTuples(); if (totalFeatures < 2) { setErrorCondition(-87000); notifyErrorMessage(getHumanLabel(), "The number of Features was 0 or 1 which means no features were detected. Is a threshold value set to high?", getErrorCondition()); return; } // By default we randomize grains if (true == m_RandomizeFeatureIds) { randomizeFeatureIds(totalPoints, totalFeatures); } // If there is an error set this to something negative and also set a message notifyStatusMessage(getHumanLabel(), "Completed"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MakeDataContainer::dataCheck() { DataArrayPath tempPath; setErrorCondition(0); DataContainer::Pointer m = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getDataContainerName()); if (getErrorCondition() < 0) { return; } QVector<size_t> tDims(3, 64); AttributeMatrix::Pointer cellAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Cell); if (getErrorCondition() < 0) { return; } // tDims.resize(1); // tDims[0] = 0; // AttributeMatrix::Pointer cellEnsembleAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellEnsembleAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::CellEnsemble); // if(getErrorCondition() < 0) // { // return; // } QVector<size_t> dims(1, 1); m_FeatureIdsPtr = cellAttrMat->createNonPrereqArray<DataArray<int32_t>, AbstractFilter, int32_t>(this, m_FeatureIdsArrayName, 0, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FeatureIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); /* Now assign the raw pointer to data from the DataArray<T> object */ } //ImageGeom::Pointer image = ImageGeom::CreateGeometry("TestImageGeom"); //image->setResolution(0.1f, 0.2f, 0.3f); //image->setOrigin(100.3f, 987.234f, 0.0f); //image->setDimensions(64, 64, 64); //m->setGeometry(image); VertexGeom::Pointer vertices = VertexGeom::CreateGeometry(100, "TestVertexGeom"); SharedVertexList::Pointer test = vertices->getVertices(); float* verts = test->getPointer(0); for (int64_t i = 0; i < vertices->getNumberOfVertices(); i++) { verts[3 * i] = float(0.1 + i); verts[3 * i + 1] = float(0.2 + i); verts[3 * i + 2] = float(0.3 + i); } m->setGeometry(vertices); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FindGBCD::dataCheckSurfaceMesh() { setErrorCondition(0); initialize(); DataArrayPath tempPath; getDataContainerArray()->getPrereqGeometryFromDataContainer<TriangleGeom, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath().getDataContainerName()); DataContainer::Pointer sm = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), false); if(getErrorCondition() < 0 || NULL == sm.get()) { return; } QVector<size_t> tDims(1, m_CrystalStructuresPtr.lock()->getNumberOfTuples()); sm->createNonPrereqAttributeMatrix<AbstractFilter>(this, getFaceEnsembleAttributeMatrixName(), tDims, SIMPL::AttributeMatrixType::FaceEnsemble); QVector<size_t> cDims(1, 2); m_SurfaceMeshFaceLabelsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFaceLabelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFaceLabels = m_SurfaceMeshFaceLabelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 3; m_SurfaceMeshFaceNormalsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<double>, AbstractFilter>(this, getSurfaceMeshFaceNormalsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFaceNormalsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFaceNormals = m_SurfaceMeshFaceNormalsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 1; m_SurfaceMeshFaceAreasPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<double>, AbstractFilter>(this, getSurfaceMeshFaceAreasArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFaceAreasPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFaceAreas = m_SurfaceMeshFaceAreasPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ // call the sizeGBCD function to get the GBCD ranges, dimensions, etc. Note that the input parameters do not affect the size and can be dummy values here; sizeGBCD(0, 0); cDims.resize(6); cDims[0] = m_GbcdSizes[0]; cDims[1] = m_GbcdSizes[1]; cDims[2] = m_GbcdSizes[2]; cDims[3] = m_GbcdSizes[3]; cDims[4] = m_GbcdSizes[4]; cDims[5] = 2; tempPath.update(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), getFaceEnsembleAttributeMatrixName(), getGBCDArrayName() ); m_GBCDPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<double>, AbstractFilter, double>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_GBCDPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_GBCD = m_GBCDPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeSyntheticVolume::dataCheck() { setErrorCondition(0); // Create the output Data Container DataContainer::Pointer m = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getDataContainerName()); if(getErrorCondition() < 0) { return; } ImageGeom::Pointer image = ImageGeom::CreateGeometry(DREAM3D::Geometry::ImageGeometry); m->setGeometry(image); // Sanity Check the Dimensions and Resolution INIT_SYNTH_VOLUME_CHECK(Dimensions.x, -5000); INIT_SYNTH_VOLUME_CHECK(Dimensions.y, -5001); INIT_SYNTH_VOLUME_CHECK(Dimensions.z, -5002); INIT_SYNTH_VOLUME_CHECK(Resolution.x, -5003); INIT_SYNTH_VOLUME_CHECK(Resolution.y, -5004); INIT_SYNTH_VOLUME_CHECK(Resolution.z, -5005); // Set the Dimensions, Resolution and Origin of the output data container m->getGeometryAs<ImageGeom>()->setDimensions(m_Dimensions.x, m_Dimensions.y, m_Dimensions.z); m->getGeometryAs<ImageGeom>()->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z); m->getGeometryAs<ImageGeom>()->setOrigin(m_Origin.x, m_Origin.y, m_Origin.z); // Create our output Cell and Ensemble Attribute Matrix objects QVector<size_t> tDims(3, 0); tDims[0] = m_Dimensions.x; tDims[1] = m_Dimensions.y; tDims[2] = m_Dimensions.z; AttributeMatrix::Pointer cellAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Cell); if(getErrorCondition() < 0 && cellAttrMat.get() == NULL) { return; } QVector<size_t> cDims(1, 1); // This states that we are looking for an array with a single component UInt32ArrayType::Pointer phaseType = getDataContainerArray()->getPrereqArrayFromPath<UInt32ArrayType, AbstractFilter>(this, getInputPhaseTypesArrayPath(), cDims); if(getErrorCondition() < 0 && phaseType.get() == NULL) { return; } QVector<size_t> statsDims(1, 1); StatsDataArray::Pointer statsPtr = getDataContainerArray()->getPrereqArrayFromPath<StatsDataArray, AbstractFilter>(this, getInputStatsArrayPath(), statsDims); if(getErrorCondition() < 0 && statsPtr.get() == NULL) { return; } if(m_EstimateNumberOfFeatures) { m_EstimatedPrimaryFeatures = estimateNumFeatures(m_Dimensions, m_Resolution); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void VectorSegmentFeatures::execute() { setErrorCondition(0); dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); QVector<size_t> tDims(1, 1); m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims); updateFeatureInstancePointers(); int64_t totalPoints = static_cast<int64_t>(m_FeatureIdsPtr.lock()->getNumberOfTuples()); m_BeenPickedPtr = BoolArrayType::CreateArray(totalPoints, "BeenPicked INTERNAL ARRAY ONLY"); m_BeenPickedPtr->initializeWithValue(0); m_BeenPicked = m_BeenPickedPtr->getPointer(0); // Convert user defined tolerance to radians. angleTolerance = m_AngleTolerance * SIMPLib::Constants::k_Pi / 180.0f; // Generate the random voxel indices that will be used for the seed points to start a new grain growth/agglomeration const int64_t rangeMin = 0; const int64_t rangeMax = totalPoints - 1; initializeVoxelSeedGenerator(rangeMin, rangeMax); SegmentFeatures::execute(); int32_t totalFeatures = static_cast<int32_t>(m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->getNumTuples()); if (totalFeatures < 2) { setErrorCondition(-87000); notifyErrorMessage(getHumanLabel(), "The number of Features was 0 or 1 which means no Features were detected. A threshold value may be set too high", getErrorCondition()); return; } // By default we randomize grains if (true == m_RandomizeFeatureIds) { randomizeFeatureIds(totalPoints, totalFeatures); } // If there is an error set this to something negative and also set a message notifyStatusMessage(getHumanLabel(), "Completed"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeSyntheticVolume::execute() { setErrorCondition(0); dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); AttributeMatrix::Pointer cellAttrMat = m->getAttributeMatrix(getCellAttributeMatrixName()); // Resize the Cell AttributeMatrix to have the correct Tuple Dimensions. QVector<size_t> tDims(3, 0); tDims[0] = m->getGeometryAs<ImageGeom>()->getXPoints(); tDims[1] = m->getGeometryAs<ImageGeom>()->getYPoints(); tDims[2] = m->getGeometryAs<ImageGeom>()->getZPoints(); cellAttrMat->resizeAttributeArrays(tDims); // If there is an error set this to something negative and also set a message notifyStatusMessage(getHumanLabel(), "Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InsertAtoms::assign_points(QVector<VertexGeom::Pointer> points, QVector<BoolArrayType::Pointer> inFeature) { size_t count = 0; int32_t numFeatures = points.size(); for (int32_t i = 0; i < numFeatures; i++) { int64_t numPoints = points[i]->getNumberOfVertices(); bool* inside = inFeature[i]->getPointer(0); for (int64_t j = 0; j < numPoints; j++) { if (inside[j] == true) { count++; } } } DataContainer::Pointer v = getDataContainerArray()->getDataContainer(getVertexDataContainerName()); VertexGeom::Pointer vertices = VertexGeom::CreateGeometry(count, DREAM3D::VertexData::SurfaceMeshNodes); AttributeMatrix::Pointer vertexAttrMat = v->getAttributeMatrix(getVertexAttributeMatrixName()); QVector<size_t> tDims(1, count); vertexAttrMat->resizeAttributeArrays(tDims); updateVertexInstancePointers(); count = 0; float coords[3] = { 0.0f, 0.0f, 0.0f }; for (int32_t i = 0; i < numFeatures; i++) { int64_t numPoints = points[i]->getNumberOfVertices(); bool* inside = inFeature[i]->getPointer(0); for (int64_t j = 0; j < numPoints; j++) { if (inside[j] == true) { coords[0] = points[i]->getVertexPointer(j)[0]; coords[1] = points[i]->getVertexPointer(j)[1]; coords[2] = points[i]->getVertexPointer(j)[2]; vertices->setCoords(count, coords); m_AtomFeatureLabels[count] = i; count++; } } } v->setGeometry(vertices); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void EBSDSegmentFeatures::execute() { setErrorCondition(0); dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); int64_t totalPoints = static_cast<int64_t>(m_FeatureIdsPtr.lock()->getNumberOfTuples()); QVector<size_t> tDims(1, 1); m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims); updateFeatureInstancePointers(); // Convert user defined tolerance to radians. misoTolerance = m_MisorientationTolerance * DREAM3D::Constants::k_Pi / 180.0f; // Generate the random voxel indices that will be used for the seed points to start a new grain growth/agglomeration const int64_t rangeMin = 0; const int64_t rangeMax = totalPoints - 1; initializeVoxelSeedGenerator(rangeMin, rangeMax); SegmentFeatures::execute(); int64_t totalFeatures = static_cast<int64_t>(m_ActivePtr.lock()->getNumberOfTuples()); if (totalFeatures < 2) { setErrorCondition(-87000); notifyErrorMessage(getHumanLabel(), "The number of Features was 0 or 1 which means no Features were detected. A threshold value may be set too high", getErrorCondition()); return; } // By default we randomize grains if (true == getRandomizeFeatureIds()) { totalPoints = static_cast<int64_t>(m->getGeometryAs<ImageGeom>()->getNumberOfElements()); randomizeFeatureIds(totalPoints, totalFeatures); } // If there is an error set this to something negative and also set a message notifyStatusMessage(getHumanLabel(), "Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void SineParamsSegmentFeatures::dataCheck() { DataArrayPath tempPath; setErrorCondition(0); //Set the DataContainerName for the Parent Class (SegmentFeatures) to Use setDataContainerName(m_SineParamsArrayPath.getDataContainerName()); SegmentFeatures::dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getDataContainerName(), false); if(getErrorCondition() < 0 || NULL == m) { return; } QVector<size_t> tDims(1, 0); AttributeMatrix::Pointer cellFeatureAttrMat = m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellFeatureAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::CellFeature); if(getErrorCondition() < 0 || NULL == cellFeatureAttrMat.get()) { return; } ImageGeom::Pointer image = m->getPrereqGeometry<ImageGeom, AbstractFilter>(this); if(getErrorCondition() < 0 || NULL == image.get()) { return; } QVector<size_t> dims(1, 3); m_SineParamsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<float>, AbstractFilter>(this, getSineParamsArrayPath(), dims); if( NULL != m_SineParamsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SineParams = m_SineParamsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ dims[0] = 1; tempPath.update(getDataContainerName(), m_SineParamsArrayPath.getAttributeMatrixName(), getFeatureIdsArrayName() ); m_FeatureIdsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FeatureIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if(m_UseGoodVoxels == true) { m_GoodVoxelsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<bool>, AbstractFilter>(this, getGoodVoxelsArrayPath(), dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_GoodVoxelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_GoodVoxels = m_GoodVoxelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ } tempPath.update(getDataContainerName(), getCellFeatureAttributeMatrixName(), getActiveArrayName() ); m_ActivePtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<bool>, AbstractFilter, bool>(this, tempPath, true, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_ActivePtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_Active = m_ActivePtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InsertAtoms::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; TriangleGeom::Pointer triangles = getDataContainerArray()->getPrereqGeometryFromDataContainer<TriangleGeom, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath().getDataContainerName()); QVector<IDataArray::Pointer> dataArrays; if(getErrorCondition() >= 0) { dataArrays.push_back(triangles->getTriangles()); } DataContainer::Pointer v = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getVertexDataContainerName()); if(getErrorCondition() < 0) { return; } VertexGeom::Pointer vertices = VertexGeom::CreateGeometry(0, DREAM3D::Geometry::VertexGeometry); v->setGeometry(vertices); QVector<size_t> tDims(1, 0); AttributeMatrix::Pointer vertexAttrMat = v->createNonPrereqAttributeMatrix<AbstractFilter>(this, getVertexAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::Vertex); if(getErrorCondition() < 0 || NULL == vertexAttrMat.get()) { return; } QVector<size_t> cDims(1, 2); m_SurfaceMeshFaceLabelsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFaceLabelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFaceLabels = m_SurfaceMeshFaceLabelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if(getErrorCondition() >= 0) { dataArrays.push_back(m_SurfaceMeshFaceLabelsPtr.lock()); } cDims[0] = 4; m_AvgQuatsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<float>, AbstractFilter>(this, getAvgQuatsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_AvgQuatsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_AvgQuats = m_AvgQuatsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 1; tempPath.update(getVertexDataContainerName(), getVertexAttributeMatrixName(), getAtomFeatureLabelsArrayName() ); m_AtomFeatureLabelsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, -301, cDims); /* Assigns the shared_ptr<>(this, tempPath, -301, dims); Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_AtomFeatureLabelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_AtomFeatureLabels = m_AtomFeatureLabelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ getDataContainerArray()->validateNumberOfTuples<AbstractFilter>(this, dataArrays); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getSelectedCellArrayPath().getDataContainerName(), false); if(getErrorCondition() < 0 || NULL == m.get()) { return; } QVector<size_t> tDims(1, 0); m->createNonPrereqAttributeMatrix<AbstractFilter>(this, getCellFeatureAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::CellFeature); QVector<size_t> cDims(1, 1); m_SelectedCellDataPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getSelectedCellArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SelectedCellDataPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SelectedCellData = m_SelectedCellDataPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ if(getErrorCondition() < 0) { return; } tempPath.update(getSelectedCellArrayPath().getDataContainerName(), getCellFeatureAttributeMatrixName(), getActiveArrayName() ); m_ActivePtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<bool>, AbstractFilter, bool>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_ActivePtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_Active = m_ActivePtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void SharedFeatureFaceFilter::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; getDataContainerArray()->getPrereqGeometryFromDataContainer<TriangleGeom, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath().getDataContainerName()); DataContainer::Pointer sm = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), false); if(getErrorCondition() < 0) { return; } QVector<size_t> tDims(1, 0); AttributeMatrix::Pointer facefeatureAttrMat = sm->createNonPrereqAttributeMatrix<AbstractFilter>(this, getFaceFeatureAttributeMatrixName(), tDims, DREAM3D::AttributeMatrixType::FaceFeature); if(getErrorCondition() < 0 || NULL == facefeatureAttrMat.get()) { return; } QVector<size_t> cDims(1, 2); m_SurfaceMeshFaceLabelsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFaceLabelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFaceLabels = m_SurfaceMeshFaceLabelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 1; tempPath.update(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), m_SurfaceMeshFaceLabelsArrayPath.getAttributeMatrixName(), getSurfaceMeshFeatureFaceIdsArrayName() ); m_SurfaceMeshFeatureFaceIdsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFeatureFaceIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFeatureFaceIds = m_SurfaceMeshFeatureFaceIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ tempPath.update(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), getFaceFeatureAttributeMatrixName(), getSurfaceMeshFeatureFaceNumTrianglesArrayName() ); m_SurfaceMeshFeatureFaceNumTrianglesPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFeatureFaceNumTrianglesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFeatureFaceNumTriangles = m_SurfaceMeshFeatureFaceNumTrianglesPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ cDims[0] = 2; tempPath.update(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), getFaceFeatureAttributeMatrixName(), getSurfaceMeshFeatureFaceLabelsArrayName() ); m_SurfaceMeshFeatureFaceLabelsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshFeatureFaceLabelsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshFeatureFaceLabels = m_SurfaceMeshFeatureFaceLabelsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }