// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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 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 GroupMicroTextureRegions::randomizeFeatureIds(int64_t totalPoints, int64_t totalFeatures) { notifyStatusMessage(getHumanLabel(), "Randomizing Parent Ids"); // Generate an even distribution of numbers between the min and max range const int32_t rangeMin = 0; const int32_t rangeMax = totalFeatures - 1; initializeVoxelSeedGenerator(rangeMin, rangeMax); // Get a reference variable to the Generator object Generator& numberGenerator = *m_NumberGenerator; DataArray<int32_t>::Pointer rndNumbers = DataArray<int32_t>::CreateArray(totalFeatures, "_INTERNAL_USE_ONLY_NewFeatureIds"); int32_t* gid = rndNumbers->getPointer(0); gid[0] = 0; for (int64_t i = 1; i < totalFeatures; ++i) { gid[i] = i; } int32_t r = 0; int32_t temp; //--- Shuffle elements by randomly exchanging each with one other. for (int64_t i = 1; i < totalFeatures; i++) { r = numberGenerator(); // Random remaining position. if (r >= totalFeatures) { continue; } temp = gid[i]; gid[i] = gid[r]; gid[r] = temp; } // Now adjust all the Grain Id values for each Voxel for (int64_t i = 0; i < totalPoints; ++i) { m_CellParentIds[i] = gid[m_CellParentIds[i]]; m_FeatureParentIds[m_FeatureIds[i]] = m_CellParentIds[i]; } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- 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"); }