// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FindNeighbors::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setCellFeatureAttributeMatrixPath(reader->readDataArrayPath("CellFeatureAttributeMatrixPath", getCellFeatureAttributeMatrixPath() ) ); setFeatureIdsArrayPath(reader->readDataArrayPath("FeatureIdsArrayPath", getFeatureIdsArrayPath() ) ); setBoundaryCellsArrayName(reader->readString("BoundaryCellsArrayName", getBoundaryCellsArrayName() ) ); setSurfaceFeaturesArrayName(reader->readString("SurfaceFeaturesArrayName", getSurfaceFeaturesArrayName() ) ); setStoreBoundaryCells(reader->readValue("StoreBoundaryCells", getStoreBoundaryCells() ) ); setStoreSurfaceFeatures(reader->readValue("StoreSurfaceFeatures", getStoreSurfaceFeatures() ) ); setNumNeighborsArrayName(reader->readString("NumNeighborsArrayName", getNumNeighborsArrayName() ) ); setNeighborListArrayName(reader->readString("NeighborListArrayName", getNeighborListArrayName() ) ); setSharedSurfaceAreaListArrayName(reader->readString("SharedSurfaceAreaListArrayName", getSharedSurfaceAreaListArrayName() ) ); reader->closeFilterGroup(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FindNeighbors::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); // Cell Data GET_PREREQ_DATA( m, DREAM3D, CellData, GrainIds, ss, -300, int32_t, Int32ArrayType, voxels, 1) CREATE_NON_PREREQ_DATA(m, DREAM3D, CellData, SurfaceVoxels, ss, int8_t, Int8ArrayType, 0, voxels, 1) // Field Data // Do this whole block FIRST otherwise the side effect is that a call to m->getNumFieldTuples will = 0 // because we are just creating an empty NeighborList object. // Now we are going to get a "Pointer" to the NeighborList object out of the DataContainer m_NeighborList = NeighborList<int>::SafeObjectDownCast<IDataArray*, NeighborList<int>* > (m->getFieldData(m_NeighborListArrayName).get()); if(m_NeighborList == NULL) { NeighborList<int>::Pointer neighborlistPtr = NeighborList<int>::New(); neighborlistPtr->SetName(m_NeighborListArrayName); neighborlistPtr->Resize(fields); neighborlistPtr->setNumNeighborsArrayName(getNumNeighborsArrayName()); m->addFieldData(m_NeighborListArrayName, neighborlistPtr); if (neighborlistPtr.get() == NULL) { ss << "NeighborLists Array Not Initialized at Beginning of FindNeighbors Filter" << std::endl; setErrorCondition(-308); } m_NeighborList = NeighborList<int>::SafeObjectDownCast<IDataArray*, NeighborList<int>* > (m->getFieldData(m_NeighborListArrayName).get()); CreatedArrayHelpIndexEntry::Pointer e = CreatedArrayHelpIndexEntry::New(); e->setFilterName(this->getNameOfClass()); e->setFilterHumanLabel(this->getHumanLabel()); e->setFilterGroup(this->getGroupName()); e->setFilterSubGroup(this->getSubGroupName()); e->setArrayDefaultName(m_NeighborListArrayName); e->setArrayGroup("Field"); e->setArrayNumComponents(0); e->setArrayType("NeighborList"); addCreatedArrayHelpIndexEntry(e); } // And we do the same for the SharedSurfaceArea list m_SharedSurfaceAreaList = NeighborList<float>::SafeObjectDownCast<IDataArray*, NeighborList<float>*> (m->getFieldData(m_SharedSurfaceAreaListArrayName).get()); if(m_SharedSurfaceAreaList == NULL) { NeighborList<float>::Pointer sharedSurfaceAreaListPtr = NeighborList<float>::New(); sharedSurfaceAreaListPtr->SetName(m_SharedSurfaceAreaListArrayName); sharedSurfaceAreaListPtr->Resize(fields); sharedSurfaceAreaListPtr->setNumNeighborsArrayName(getNumNeighborsArrayName()); m->addFieldData(m_SharedSurfaceAreaListArrayName, sharedSurfaceAreaListPtr); if (sharedSurfaceAreaListPtr.get() == NULL) { ss.str(""); ss << "SurfaceAreaLists Array Not Initialized correctly at Beginning of FindNeighbors Filter" << std::endl; setErrorCondition(-308); addErrorMessage(getHumanLabel(), ss.str(), -308); } m_SharedSurfaceAreaList = NeighborList<float>::SafeObjectDownCast<IDataArray*, NeighborList<float>*> (m->getFieldData(m_SharedSurfaceAreaListArrayName).get()); CreatedArrayHelpIndexEntry::Pointer e = CreatedArrayHelpIndexEntry::New(); e->setFilterName(this->getNameOfClass()); e->setFilterHumanLabel(this->getHumanLabel()); e->setFilterGroup(this->getGroupName()); e->setFilterSubGroup(this->getSubGroupName()); e->setArrayDefaultName(m_SharedSurfaceAreaListArrayName); e->setArrayGroup("Field"); e->setArrayNumComponents(0); e->setArrayType("SurfaceAreaLists"); addCreatedArrayHelpIndexEntry(e); } CREATE_NON_PREREQ_DATA(m, DREAM3D, FieldData, SurfaceFields, ss, bool, BoolArrayType, false, fields, 1) CREATE_NON_PREREQ_DATA(m, DREAM3D, FieldData, NumNeighbors, ss, int32_t, Int32ArrayType, 0, fields, 1) }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FindNeighbors::setupFilterParameters() { FilterParameterVector parameters; QStringList linkedProps("BoundaryCellsArrayName"); parameters.push_back(LinkedBooleanFilterParameter::New("Store Boundary Cells Array", "StoreBoundaryCells", getStoreBoundaryCells(), linkedProps, FilterParameter::Parameter)); linkedProps.clear(); linkedProps << "SurfaceFeaturesArrayName"; parameters.push_back(LinkedBooleanFilterParameter::New("Store Surface Features Array", "StoreSurfaceFeatures", getStoreSurfaceFeatures(), linkedProps, FilterParameter::Parameter)); parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(DREAM3D::TypeNames::Int32, 1, DREAM3D::AttributeMatrixType::Cell, DREAM3D::GeometryType::ImageGeometry); parameters.push_back(DataArraySelectionFilterParameter::New("Feature Ids", "FeatureIdsArrayPath", getFeatureIdsArrayPath(), FilterParameter::RequiredArray, req)); } parameters.push_back(SeparatorFilterParameter::New("Cell Feature Data", FilterParameter::RequiredArray)); { AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(DREAM3D::AttributeMatrixType::CellFeature, DREAM3D::GeometryType::ImageGeometry); parameters.push_back(AttributeMatrixSelectionFilterParameter::New("Cell Feature Attribute Matrix", "CellFeatureAttributeMatrixPath", getCellFeatureAttributeMatrixPath(), FilterParameter::RequiredArray, req)); } parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::CreatedArray)); parameters.push_back(StringFilterParameter::New("Boundary Cells", "BoundaryCellsArrayName", getBoundaryCellsArrayName(), FilterParameter::CreatedArray)); parameters.push_back(SeparatorFilterParameter::New("Cell Feature Data", FilterParameter::CreatedArray)); parameters.push_back(StringFilterParameter::New("Number of Neighbors", "NumNeighborsArrayName", getNumNeighborsArrayName(), FilterParameter::CreatedArray)); parameters.push_back(StringFilterParameter::New("Neighbor List", "NeighborListArrayName", getNeighborListArrayName(), FilterParameter::CreatedArray)); parameters.push_back(StringFilterParameter::New("Shared Surface Area List", "SharedSurfaceAreaListArrayName", getSharedSurfaceAreaListArrayName(), FilterParameter::CreatedArray)); parameters.push_back(StringFilterParameter::New("Surface Features", "SurfaceFeaturesArrayName", getSurfaceFeaturesArrayName(), FilterParameter::CreatedArray)); setFilterParameters(parameters); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FindNeighbors::dataCheck() { setErrorCondition(0); DataArrayPath tempPath; getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getFeatureIdsArrayPath().getDataContainerName()); QVector<size_t> cDims(1, 1); 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(), getBoundaryCellsArrayName() ); if (m_StoreBoundaryCells == true) { m_BoundaryCellsPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<int8_t>, AbstractFilter, int8_t>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_BoundaryCellsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_BoundaryCells = m_BoundaryCellsPtr.lock()->getPointer(0); /* Now assign the raw pointer to data from the DataArray<T> object */ } } getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getCellFeatureAttributeMatrixPath(), -301); tempPath.update(getCellFeatureAttributeMatrixPath().getDataContainerName(), getCellFeatureAttributeMatrixPath().getAttributeMatrixName(), getNumNeighborsArrayName() ); m_NumNeighborsPtr = 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_NumNeighborsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_NumNeighbors = m_NumNeighborsPtr.lock()->getPointer(0); /* Now assign the raw pointer to data from the DataArray<T> object */ } tempPath.update(getCellFeatureAttributeMatrixPath().getDataContainerName(), getCellFeatureAttributeMatrixPath().getAttributeMatrixName(), getSurfaceFeaturesArrayName() ); if (m_StoreSurfaceFeatures == true) { m_SurfaceFeaturesPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<bool>, AbstractFilter, bool>(this, tempPath, false, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_SurfaceFeaturesPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_SurfaceFeatures = m_SurfaceFeaturesPtr.lock()->getPointer(0); /* Now assign the raw pointer to data from the DataArray<T> object */ } } // Feature Data // Do this whole block FIRST otherwise the side effect is that a call to m->getNumCellFeatureTuples will = 0 // because we are just creating an empty NeighborList object. // Now we are going to get a "Pointer" to the NeighborList object out of the DataContainer tempPath.update(getCellFeatureAttributeMatrixPath().getDataContainerName(), getCellFeatureAttributeMatrixPath().getAttributeMatrixName(), getNeighborListArrayName() ); m_NeighborList = getDataContainerArray()->createNonPrereqArrayFromPath<NeighborList<int32_t>, AbstractFilter, int32_t>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ // And we do the same for the SharedSurfaceArea list tempPath.update(getCellFeatureAttributeMatrixPath().getDataContainerName(), getCellFeatureAttributeMatrixPath().getAttributeMatrixName(), getSharedSurfaceAreaListArrayName() ); m_SharedSurfaceAreaList = getDataContainerArray()->createNonPrereqArrayFromPath<NeighborList<float>, AbstractFilter, float>(this, tempPath, 0, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ }