// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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; }
/** * * @param FileName * @param data * @param nx X Dimension * @param ny Y Dimension * @param nz Z Dimension */ int ReadPHFile(QString FileName, QVector<int>& data, int& nx, int& ny, int& nz) { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer m = DataContainer::New(); /* FIXME: What Geometry do we need? */ dca->pushBack(m); FilterManager::Pointer fm = FilterManager::Instance(); AbstractFilter::Pointer reader = fm->getFactoryForFilter("PhReader")->create(); reader->setDataContainerArray(dca); bool propWasSet = reader->setProperty("InputFile", FileName); if(propWasSet == false) { } reader->execute(); if (reader->getErrorCondition() < 0) { qDebug() << "Error Reading the Ph File '" << FileName << "' Error Code:" << reader->getErrorCondition(); return -1; } Int32ArrayType* featureIds = Int32ArrayType::SafePointerDownCast(m->getAttributeMatrix(DREAM3D::Defaults::CellAttributeMatrixName)->getAttributeArray(DREAM3D::CellData::FeatureIds).get()); size_t count = featureIds->getNumberOfTuples(); data.resize(count); for(size_t i = 0; i < count; ++i) { data[i] = featureIds->getValue(i); } return 0; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AvizoUniformCoordinateWriter::dataCheck() { setErrorCondition(0); DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getFeatureIdsArrayPath().getDataContainerName(), false); if (getErrorCondition() < 0 || NULL == dc.get()) { return; } ImageGeom::Pointer image = dc->getPrereqGeometry<ImageGeom, AbstractFilter>(this); if (getErrorCondition() < 0 || NULL == image.get()) { return; } if(m_OutputFile.isEmpty() == true) { QString ss = QObject::tr("The output file must be set before executing this filter."); setErrorCondition(-1); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if(m_WriteFeatureIds == true) { QVector<size_t> dims(1, 1); m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getFeatureIdsArrayPath(), 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 */ } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- IntVec3_t CropImageGeometry::getCurrentVolumeDataContainerDimensions() { DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName()); IntVec3_t data; if (NULL != m.get() ) { ImageGeom::Pointer image = m->getGeometryAs<ImageGeom>(); if (image.get() != NULL) { data.x = image->getXPoints(); data.y = image->getYPoints(); data.z = image->getZPoints(); } else { data.x = 0; data.y = 0; data.z = 0; } } else { data.x = 0; data.y = 0; data.z = 0; } return data; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ConvertData::execute() { setErrorCondition(0); dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(m_SelectedCellArrayPath.getDataContainerName()); IDataArray::Pointer iArray = m->getAttributeMatrix(m_SelectedCellArrayPath.getAttributeMatrixName())->getAttributeArray(m_SelectedCellArrayPath.getDataArrayName()); bool completed = false; CHECK_AND_CONVERT(UInt8ArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(Int8ArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(UInt16ArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(Int16ArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(UInt32ArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(Int32ArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(UInt64ArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(Int64ArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(FloatArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(DoubleArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) CHECK_AND_CONVERT(BoolArrayType, m, m_ScalarType, iArray, m_SelectedCellArrayPath.getAttributeMatrixName(), m_OutputArrayName) /* Let the GUI know we are done with this filter */ notifyStatusMessage(getHumanLabel(), "Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RenameAttributeMatrix::dataCheck() { setErrorCondition(0); if (m_NewAttributeMatrix.isEmpty() == true) { setErrorCondition(-11004); QString ss = QObject::tr("The new Attribute Matrix name must be set"); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } QString amName = getSelectedAttributeMatrixPath().getAttributeMatrixName(); DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getSelectedAttributeMatrixPath().getDataContainerName()); getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getSelectedAttributeMatrixPath(), -301); if(getErrorCondition() < 0) { return; } bool check = dc->renameAttributeMatrix(amName, getNewAttributeMatrix() ); if (check == false) { setErrorCondition(-11006); QString ss = QObject::tr("Attempt to rename Attribute Matrix '%1' to '%2' failed").arg(amName).arg(getNewAttributeMatrix()); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QVector<DataArrayPath> DataContainerBundle::findCommonDataArrayPaths(bool filterMetaData) { QVector<DataArrayPath> commonPaths; if(m_DataContainers.count() == 0) { return commonPaths; } // Get the first DataContainer DataContainer::Pointer dc0 = m_DataContainers[0]; if(NULL == dc0.get()) { return commonPaths; } QVector<DataArrayPath> dc0Paths = dc0->getAllDataArrayPaths(); if(m_DataContainers.count() == 1) { return commonPaths; } int count = m_DataContainers.count(); // We already have the first DataContainer, so start at the 2nd for (int dcIdx = 1; dcIdx < count; ++dcIdx) { DataContainer::Pointer dcX = m_DataContainers[dcIdx]; QVector<DataArrayPath> paths = dcX->getAllDataArrayPaths(); int numPaths = dc0Paths.count(); // Loop over the paths from the first data container from back to front, // removing the path if it does not exist. for(int i = numPaths - 1; i >= 0; i--) { DataArrayPath dc0Path = dc0Paths[i]; bool match = false; foreach(DataArrayPath path, paths) { //qDebug() << "Comparing " << dc0Path.serialize() << " TO " << path.serialize(); if(path.hasSameAttributeMatrix(dc0Path) && path.hasSameDataArray(dc0Path) ) { match = true; } if(filterMetaData == true && (path.getAttributeMatrixName() == DREAM3D::StringConstants::MetaData) ) { match = false; } } if(!match) { dc0Paths.remove(i); } } } commonPaths = dc0Paths; return commonPaths; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 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 CombineAttributeMatrices::execute() { setErrorCondition(0); dataCheck(); if (getErrorCondition() < 0) { return; } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getFirstAttributeMatrixPath().getDataContainerName()); AttributeMatrix::Pointer firstAttrMat = m->getAttributeMatrix(getFirstAttributeMatrixPath().getAttributeMatrixName()); AttributeMatrix::Pointer secondAttrMat = m->getAttributeMatrix(getSecondAttributeMatrixPath().getAttributeMatrixName()); AttributeMatrix::Pointer combinedAttrMat = m->getAttributeMatrix(getCombinedAttributeMatrixName()); size_t firstAttrMatNumTuples = firstAttrMat->getNumTuples(); size_t totalTuples1 = m_SecondIndexPtr.lock()->getNumberOfTuples(); size_t totalTuples2 = m_SecondIndexPtr.lock()->getNumberOfTuples(); for (size_t i = 0; i < totalTuples1; i++) { if (m_FirstIndex > 0) { m_NewIndex[i] = m_FirstIndex[i]; } } for (size_t i = 0; i < totalTuples2; i++) { //subtract 1 from the index plus numTuples because the second index should be shifted to account for the zeroth tuple (all AMs above element start at tuple 1) if (m_SecondIndex[i] > 0 && m_NewIndex[i] == 0) m_NewIndex[i] = m_SecondIndex[i] + firstAttrMatNumTuples - 1; else if (m_SecondIndex[i] > 0 && m_NewIndex[i] != 0) { QString ss = QObject::tr("When copying the indices, the indices of the two attribute matrices overlapped. The index of the first attribute matrix was kept."); notifyWarningMessage(getHumanLabel(), ss, -111); } } QList<QString> arrayNames = firstAttrMat->getAttributeArrayNames(); size_t location = 0; for (QList<QString>::iterator iter = arrayNames.begin(); iter != arrayNames.end(); ++iter) { IDataArray::Pointer fromDataArray = firstAttrMat->getAttributeArray(*iter); IDataArray::Pointer toDataArray = combinedAttrMat->getAttributeArray(*iter); EXECUTE_FUNCTION_TEMPLATE(this, copyData, fromDataArray, fromDataArray, toDataArray, location); } arrayNames.clear(); arrayNames = secondAttrMat->getAttributeArrayNames(); location = firstAttrMatNumTuples; for (QList<QString>::iterator iter = arrayNames.begin(); iter != arrayNames.end(); ++iter) { IDataArray::Pointer fromDataArray = secondAttrMat->getAttributeArray(*iter); IDataArray::Pointer toDataArray = combinedAttrMat->getAttributeArray(*iter); EXECUTE_FUNCTION_TEMPLATE(this, copyData, fromDataArray, fromDataArray, toDataArray, location); } notifyStatusMessage(getHumanLabel(), "Complete"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 writePointScalarData(DataContainer::Pointer dc, const QString& vertexAttributeMatrixName, const QString& dataName, const QString& dataType, bool writeBinaryData, FILE* vtkFile, int nT) { IDataArray::Pointer data = dc->getAttributeMatrix(vertexAttributeMatrixName)->getAttributeArray(dataName); QString ss; if (NULL != data.get()) { T* m = reinterpret_cast<T*>(data->getVoidPointer(0)); fprintf(vtkFile, "\n"); fprintf(vtkFile, "SCALARS %s %s\n", dataName.toLatin1().data(), dataType.toLatin1().data()); fprintf(vtkFile, "LOOKUP_TABLE default\n"); for(int i = 0; i < nT; ++i) { T swapped = 0x00; if(writeBinaryData == true) { swapped = static_cast<T>(m[i]); SIMPLib::Endian::FromSystemToBig::convert(swapped); fwrite(&swapped, sizeof(T), 1, vtkFile); } else { ss = QString::number(m[i]) + " "; fprintf(vtkFile, "%s ", ss.toLatin1().data()); //if (i%50 == 0) { fprintf(vtkFile, "\n"); } } } } }
void writeCellScalarData(DataContainer::Pointer dc, const QString& faceAttributeMatrixName, const QString& dataName, const QString& dataType, bool writeBinaryData, FILE* vtkFile, QMap<int32_t, int32_t>& featureIds, int32_t* m_SurfaceMeshFaceLabels) { TriangleGeom::Pointer triangleGeom = dc->getGeometryAs<TriangleGeom>(); int64_t numTriangles = triangleGeom->getNumberOfTris(); IDataArray::Pointer data = dc->getAttributeMatrix(faceAttributeMatrixName)->getAttributeArray(dataName); QString ss; if (NULL != data.get()) { int32_t totalCellsWritten = 0; T* m = reinterpret_cast<T*>(data->getVoidPointer(0)); fprintf(vtkFile, "\n"); fprintf(vtkFile, "SCALARS %s %s 1\n", dataName.toLatin1().data(), dataType.toLatin1().data()); fprintf(vtkFile, "LOOKUP_TABLE default\n"); // Loop over all the features for(QMap<int32_t, int32_t>::iterator featureIter = featureIds.begin(); featureIter != featureIds.end(); ++featureIter) { int32_t gid = featureIter.key(); // The current Feature Id size_t size = featureIter.value(); // The number of triangles for this feature id std::vector<T> buffer(size, 0); totalCellsWritten += size; size_t index = 0; for (int j = 0; j < numTriangles; j++) { if (m_SurfaceMeshFaceLabels[j * 2] != gid && m_SurfaceMeshFaceLabels[j * 2 + 1] != gid) { continue; } // Get the data T s0 = static_cast<T>(m[j]); if (m_SurfaceMeshFaceLabels[j * 2 + 1] == gid) { s0 = s0 * -1; } // Write the values to the buffer after an Endian swap. if(writeBinaryData == true) { SIMPLib::Endian::FromSystemToBig::convert(s0); buffer[index] = s0; ++index; } else { ss = QString::number(s0); fprintf(vtkFile, "%s\n", ss.toLatin1().data()); } } // Write the Buffer if(writeBinaryData == true) { fwrite(&(buffer.front()), sizeof(T), size, vtkFile); } } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 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 FindModulusMismatch::dataCheckSurfaceMesh() { DataArrayPath tempPath; setErrorCondition(0); DataContainer::Pointer sm = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath().getDataContainerName()); if(getErrorCondition() < 0 || NULL == sm.get()) { return; } QVector<size_t> dims(1, 2); m_SurfaceMeshFaceLabelsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getSurfaceMeshFaceLabelsArrayPath(), dims); /* 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 */ dims[0] = 1; tempPath.update(m_SurfaceMeshFaceLabelsArrayPath.getDataContainerName(), m_SurfaceMeshFaceLabelsArrayPath.getAttributeMatrixName(), getSurfaceMeshDeltaModulusArrayName() ); m_SurfaceMeshDeltaModulusPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<float>, AbstractFilter, float>(this, tempPath, 180.0, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceMeshDeltaModulusPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceMeshDeltaModulus = m_SurfaceMeshDeltaModulusPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MinNeighbors::execute() { setErrorCondition(0); dataCheck(); if(getErrorCondition() < 0) { return; } // If running on a single phase, validate that the user has not entered a phase number // that is not in the system ; the filter would not crash otherwise, but the user should // be notified of unanticipated behavior ; this cannot be done in the dataCheck since // we don't have acces to the data yet if (m_ApplyToSinglePhase == true) { AttributeMatrix::Pointer featAttrMat = getDataContainerArray()->getDataContainer(getFeaturePhasesArrayPath().getDataContainerName())->getAttributeMatrix(getFeaturePhasesArrayPath().getAttributeMatrixName()); size_t numFeatures = featAttrMat->getNumTuples(); bool unavailablePhase = true; for (size_t i = 0; i < numFeatures; i++) { if (m_FeaturePhases[i] == m_PhaseNumber) { unavailablePhase = false; break; } } if (unavailablePhase == true) { QString ss = QObject::tr("The phase number (%1) is not available in the supplied Feature phases array with path (%2)").arg(m_PhaseNumber).arg(m_FeaturePhasesArrayPath.serialize()); setErrorCondition(-5555); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } } QVector<bool> activeObjects = merge_containedfeatures(); if(getErrorCondition() < 0) { return; } assign_badpoints(); DataContainer::Pointer m = getDataContainerArray()->getDataContainer(m_NumNeighborsArrayPath.getDataContainerName()); AttributeMatrix::Pointer cellFeatureAttrMat = m->getAttributeMatrix(m_NumNeighborsArrayPath.getAttributeMatrixName()); cellFeatureAttrMat->removeInactiveObjects(activeObjects, m_FeatureIdsPtr.lock()); // If there is an error set this to something negative and also set a message notifyStatusMessage(getHumanLabel(), "Complete"); }
void writeCellNormalData(DataContainer::Pointer dc, const QString& faceAttributeMatrixName, const QString& dataName, const QString& dataType, bool writeBinaryData, bool writeConformalMesh, FILE* vtkFile, int nT) { IDataArray::Pointer data = dc->getAttributeMatrix(faceAttributeMatrixName)->getAttributeArray(dataName); QString buf; QTextStream ss(&buf); if (NULL != data.get()) { T* m = reinterpret_cast<T*>(data->getVoidPointer(0)); fprintf(vtkFile, "\n"); fprintf(vtkFile, "NORMALS %s %s\n", dataName.toLatin1().data(), dataType.toLatin1().data()); for(int i = 0; i < nT; ++i) { T s0 = 0x00; T s1 = 0x00; T s2 = 0x00; if(writeBinaryData == true) { s0 = static_cast<T>(m[i * 3 + 0]); s1 = static_cast<T>(m[i * 3 + 1]); s2 = static_cast<T>(m[i * 3 + 2]); SIMPLib::Endian::FromSystemToBig::convert(s0); SIMPLib::Endian::FromSystemToBig::convert(s1); SIMPLib::Endian::FromSystemToBig::convert(s2); fwrite(&s0, sizeof(T), 1, vtkFile); fwrite(&s1, sizeof(T), 1, vtkFile); fwrite(&s2, sizeof(T), 1, vtkFile); if(false == writeConformalMesh) { s0 = static_cast<T>(m[i * 3 + 0]) * -1.0; s1 = static_cast<T>(m[i * 3 + 1]) * -1.0; s2 = static_cast<T>(m[i * 3 + 2]) * -1.0; SIMPLib::Endian::FromSystemToBig::convert(s0); SIMPLib::Endian::FromSystemToBig::convert(s1); SIMPLib::Endian::FromSystemToBig::convert(s2); fwrite(&s0, sizeof(T), 1, vtkFile); fwrite(&s1, sizeof(T), 1, vtkFile); fwrite(&s2, sizeof(T), 1, vtkFile); } } else { ss << m[i * 3 + 0] << " " << m[i * 3 + 1] << " " << m[i * 3 + 2] << " "; if(false == writeConformalMesh) { ss << -1.0 * m[i * 3 + 0] << " " << -1.0 * m[i * 3 + 1] << " " << -1.0 * m[i * 3 + 2] << " "; } fprintf(vtkFile, "%s ", buf.toLatin1().data()); buf.clear(); if (i % 50 == 0) { fprintf(vtkFile, "\n"); } } } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 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"); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- DataContainer::Pointer DataContainer::deepCopy() { DataContainer::Pointer dcCopy = DataContainer::New(getName()); dcCopy->setName(getName()); if (m_Geometry.get() != NULL) { IGeometry::Pointer geomCopy = m_Geometry->deepCopy(); dcCopy->setGeometry(geomCopy); } for (AttributeMatrixMap_t::iterator iter = getAttributeMatrices().begin(); iter != getAttributeMatrices().end(); ++iter) { AttributeMatrix::Pointer attrMat = (*iter)->deepCopy(); dcCopy->addAttributeMatrix(attrMat->getName(), attrMat); } return dcCopy; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void DataContainerBundle::removeDataContainer(DataContainer::Pointer dc) { for(qint32 i = 0; i < m_DataContainers.size(); i++) { if(m_DataContainers[i].get() == dc.get()) { m_DataContainers.remove(i); return; } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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"); }