@@ -179,11 +179,7 @@ void InsertTransformationPhases::setupFilterParameters()
179179 }
180180
181181 parameters.push_back (SeparatorFilterParameter::Create (" Cell Ensemble Data" , FilterParameter::Category::RequiredArray));
182- {
183- AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement (AttributeMatrix::Type::CellEnsemble, IGeometry::Type::Any);
184- parameters.push_back (
185- SIMPL_NEW_AM_SELECTION_FP (" Cell Ensemble Attribute Matrix" , StatsGenCellEnsembleAttributeMatrixPath, FilterParameter::Category::RequiredArray, InsertTransformationPhases, req));
186- }
182+
187183 {
188184 DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement (SIMPL::Defaults::AnyPrimitive, 1 , AttributeMatrix::Category::Ensemble);
189185 parameters.push_back (SIMPL_NEW_DA_SELECTION_FP (" Crystal Structures" , CrystalStructuresArrayPath, FilterParameter::Category::RequiredArray, InsertTransformationPhases, req));
@@ -229,7 +225,6 @@ void InsertTransformationPhases::readFilterParameters(AbstractFilterParametersRe
229225 setNumTransformationPhasesPerFeature (reader->readValue (" NumTransformationPhasesPerFeature" , getNumTransformationPhasesPerFeature ()));
230226 setPeninsulaFrac (reader->readValue (" PeninsulaFrac" , getPeninsulaFrac ()));
231227
232- setStatsGenCellEnsembleAttributeMatrixPath (reader->readDataArrayPath (" StatsGenCellEnsembleAttributeMatrixPath" , getStatsGenCellEnsembleAttributeMatrixPath ()));
233228 setCellFeatureAttributeMatrixName (reader->readDataArrayPath (" CellFeatureAttributeMatrixName" , getCellFeatureAttributeMatrixName ()));
234229 setFeatureIdsArrayPath (reader->readDataArrayPath (" FeatureIdsArrayPath" , getFeatureIdsArrayPath ()));
235230 setCellEulerAnglesArrayPath (reader->readDataArrayPath (" CellEulerAnglesArrayPath" , getCellEulerAnglesArrayPath ()));
@@ -257,31 +252,31 @@ void InsertTransformationPhases::updateFeatureInstancePointers()
257252 if (nullptr != m_AvgQuatsPtr.lock ())
258253 {
259254 m_AvgQuats = m_AvgQuatsPtr.lock ()->getPointer (0 );
260- } /* Now assign the raw pointer to data from the DataArray<T> object */
255+ }
261256 if (nullptr != m_CentroidsPtr.lock ())
262257 {
263258 m_Centroids = m_CentroidsPtr.lock ()->getPointer (0 );
264- } /* Now assign the raw pointer to data from the DataArray<T> object */
259+ }
265260 if (nullptr != m_FeatureEulerAnglesPtr.lock ())
266261 {
267262 m_FeatureEulerAngles = m_FeatureEulerAnglesPtr.lock ()->getPointer (0 );
268- } /* Now assign the raw pointer to data from the DataArray<T> object */
263+ }
269264 if (nullptr != m_EquivalentDiametersPtr.lock ())
270265 {
271266 m_EquivalentDiameters = m_EquivalentDiametersPtr.lock ()->getPointer (0 );
272- } /* Now assign the raw pointer to data from the DataArray<T> object */
267+ }
273268 if (nullptr != m_FeaturePhasesPtr.lock ())
274269 {
275270 m_FeaturePhases = m_FeaturePhasesPtr.lock ()->getPointer (0 );
276- } /* Now assign the raw pointer to data from the DataArray<T> object */
271+ }
277272 if (nullptr != m_FeatureParentIdsPtr.lock ())
278273 {
279274 m_FeatureParentIds = m_FeatureParentIdsPtr.lock ()->getPointer (0 );
280- } /* Now assign the raw pointer to data from the DataArray<T> object */
275+ }
281276 if (nullptr != m_NumFeaturesPerParentPtr.lock ())
282277 {
283278 m_NumFeaturesPerParent = m_NumFeaturesPerParentPtr.lock ()->getPointer (0 );
284- } /* Now assign the raw pointer to data from the DataArray<T> object */
279+ }
285280}
286281
287282// -----------------------------------------------------------------------------
@@ -295,15 +290,15 @@ void InsertTransformationPhases::updateStatsGenEnsembleInstancePointers()
295290 if (nullptr != m_CrystalStructuresPtr.lock ())
296291 {
297292 m_CrystalStructures = m_CrystalStructuresPtr.lock ()->getPointer (0 );
298- } /* Now assign the raw pointer to data from the DataArray<T> object */
293+ }
299294 if (nullptr != m_PhaseTypesPtr.lock ())
300295 {
301296 m_PhaseTypes = m_PhaseTypesPtr.lock ()->getPointer (0 );
302- } /* Now assign the raw pointer to data from the DataArray<T> object */
297+ }
303298 if (nullptr != m_ShapeTypesPtr.lock ())
304299 {
305300 m_ShapeTypes = m_ShapeTypesPtr.lock ()->getPointer (0 );
306- } /* Now assign the raw pointer to data from the DataArray<T> object */
301+ }
307302}
308303
309304// -----------------------------------------------------------------------------
@@ -317,7 +312,7 @@ void InsertTransformationPhases::updateVolEnsembleInstancePointers()
317312 if (nullptr != m_NumFeaturesPtr.lock ())
318313 {
319314 m_NumFeatures = m_NumFeaturesPtr.lock ()->getPointer (0 );
320- } /* Now assign the raw pointer to data from the DataArray<T> object */
315+ }
321316}
322317
323318// -----------------------------------------------------------------------------
@@ -343,11 +338,6 @@ void InsertTransformationPhases::dataCheck()
343338 return ;
344339 }
345340
346- AttributeMatrix::Pointer statsGenAttrMat = m->getPrereqAttributeMatrix (this , getStatsGenCellEnsembleAttributeMatrixPath ().getAttributeMatrixName (), -301 );
347- if (getErrorCode () < 0 || statsGenAttrMat == nullptr )
348- {
349- return ;
350- }
351341 AttributeMatrix::Pointer volAttrMat = m->getPrereqAttributeMatrix (this , getNumFeaturesPerParentArrayPath ().getAttributeMatrixName (), -301 );
352342 if (getErrorCode () < 0 || volAttrMat == nullptr )
353343 {
@@ -362,101 +352,145 @@ void InsertTransformationPhases::dataCheck()
362352
363353 std::vector<size_t > dims (1 , 1 );
364354 // Cell Data
365- m_FeatureIdsPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray< int32_t > >(this , getFeatureIdsArrayPath (), dims);
355+ m_FeatureIdsPtr = getDataContainerArray ()->getPrereqArrayFromPath <Int32ArrayType >(this , getFeatureIdsArrayPath (), dims);
366356 if (nullptr != m_FeatureIdsPtr.lock ())
367357 {
368358 m_FeatureIds = m_FeatureIdsPtr.lock ()->getPointer (0 );
369- } /* Now assign the raw pointer to data from the DataArray<T> object */
359+ }
370360
371361 dims[0 ] = 3 ;
372362 m_CellEulerAnglesPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray<float >>(this , getCellEulerAnglesArrayPath (), dims);
373363 if (nullptr != m_CellEulerAnglesPtr.lock ())
374364 {
375365 m_CellEulerAngles = m_CellEulerAnglesPtr.lock ()->getPointer (0 );
376- } /* Now assign the raw pointer to data from the DataArray<T> object */
366+ }
377367
378368 dims[0 ] = 1 ;
379369 m_CellPhasesPtr = getDataContainerArray ()->getPrereqArrayFromPath <Int32ArrayType>(this , getCellPhasesArrayPath (), dims);
380370 if (nullptr != m_CellEulerAnglesPtr.lock ())
381371 {
382372 m_CellPhases = m_CellPhasesPtr.lock ()->getPointer (0 );
383- } /* Now assign the raw pointer to data from the DataArray<T> object */
373+ }
384374
385375 // Feature Data
386376 dims[0 ] = 4 ;
387377 m_AvgQuatsPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray<float >>(this , getAvgQuatsArrayPath (), dims);
388378 if (nullptr != m_AvgQuatsPtr.lock ())
389379 {
390380 m_AvgQuats = m_AvgQuatsPtr.lock ()->getPointer (0 );
391- } /* Now assign the raw pointer to data from the DataArray<T> object */
381+ }
392382
393383 dims[0 ] = 1 ;
394384 m_EquivalentDiametersPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray<float >>(this , getEquivalentDiametersArrayPath (), dims);
395385 if (nullptr != m_EquivalentDiametersPtr.lock ())
396386 {
397387 m_EquivalentDiameters = m_EquivalentDiametersPtr.lock ()->getPointer (0 );
398- } /* Now assign the raw pointer to data from the DataArray<T> object */
388+ }
399389
400390 dims[0 ] = 3 ;
401391 m_CentroidsPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray<float >>(this , getCentroidsArrayPath (), dims);
402392 if (nullptr != m_CentroidsPtr.lock ())
403393 {
404394 m_Centroids = m_CentroidsPtr.lock ()->getPointer (0 );
405- } /* Now assign the raw pointer to data from the DataArray<T> object */
395+ }
406396
407397 m_FeatureEulerAnglesPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray<float >>(this , getFeatureEulerAnglesArrayPath (), dims);
408398 if (nullptr != m_FeatureEulerAnglesPtr.lock ())
409399 {
410400 m_FeatureEulerAngles = m_FeatureEulerAnglesPtr.lock ()->getPointer (0 );
411- } /* Now assign the raw pointer to data from the DataArray<T> object */
401+ }
412402
413403 dims[0 ] = 1 ;
414- m_FeaturePhasesPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray< int32_t > >(this , getFeaturePhasesArrayPath (), dims);
404+ m_FeaturePhasesPtr = getDataContainerArray ()->getPrereqArrayFromPath <Int32ArrayType >(this , getFeaturePhasesArrayPath (), dims);
415405 if (nullptr != m_FeaturePhasesPtr.lock ())
416406 {
417407 m_FeaturePhases = m_FeaturePhasesPtr.lock ()->getPointer (0 );
418- } /* Now assign the raw pointer to data from the DataArray<T> object */
408+ }
419409
420410 // New Feature Data
421411
422412 tempPath.update (getCellFeatureAttributeMatrixName ().getDataContainerName (), getCellFeatureAttributeMatrixName ().getAttributeMatrixName (), getFeatureParentIdsArrayName ());
423- m_FeatureParentIdsPtr = getDataContainerArray ()->createNonPrereqArrayFromPath <DataArray< int32_t > >(this , tempPath, -1 , dims, " " , DataArrayID31);
413+ m_FeatureParentIdsPtr = getDataContainerArray ()->createNonPrereqArrayFromPath <Int32ArrayType >(this , tempPath, -1 , dims, " " , DataArrayID31);
424414 if (nullptr != m_FeatureParentIdsPtr.lock ())
425415 {
426416 m_FeatureParentIds = m_FeatureParentIdsPtr.lock ()->getPointer (0 );
427- } /* Now assign the raw pointer to data from the DataArray<T> object */
417+ }
428418
429419 tempPath.update (getCellFeatureAttributeMatrixName ().getDataContainerName (), getCellFeatureAttributeMatrixName ().getAttributeMatrixName (), getNumFeaturesPerParentArrayPath ().getDataArrayName ());
430- m_NumFeaturesPerParentPtr = getDataContainerArray ()->createNonPrereqArrayFromPath <DataArray< int32_t > >(this , tempPath, 0 , dims, " " , DataArrayID32);
420+ m_NumFeaturesPerParentPtr = getDataContainerArray ()->createNonPrereqArrayFromPath <Int32ArrayType >(this , tempPath, 0 , dims, " " , DataArrayID32);
431421 if (nullptr != m_NumFeaturesPerParentPtr.lock ())
432422 {
433423 m_NumFeaturesPerParent = m_NumFeaturesPerParentPtr.lock ()->getPointer (0 );
434- } /* Now assign the raw pointer to data from the DataArray<T> object */
424+ }
425+
426+ m_NumFeaturesPtr = getDataContainerArray ()->getPrereqArrayFromPath <Int32ArrayType>(this , getNumFeaturesArrayPath (), dims);
427+ if (nullptr != m_NumFeaturesPtr.lock ())
428+ {
429+ m_NumFeatures = m_NumFeaturesPtr.lock ()->getPointer (0 );
430+ }
431+ AttributeMatrix::Pointer outputAttributeMatrix = getDataContainerArray ()->getPrereqAttributeMatrixFromPath (this , getNumFeaturesArrayPath (), -10655 );
435432
436433 // Ensemble Data
437- m_CrystalStructuresPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray< unsigned int > >(this , getCrystalStructuresArrayPath (), dims);
434+ m_CrystalStructuresPtr = getDataContainerArray ()->getPrereqArrayFromPath <UInt32ArrayType >(this , getCrystalStructuresArrayPath (), dims);
438435 if (nullptr != m_CrystalStructuresPtr.lock ())
439436 {
440437 m_CrystalStructures = m_CrystalStructuresPtr.lock ()->getPointer (0 );
441- } /* Now assign the raw pointer to data from the DataArray<T> object */
438+ }
439+ UInt32ArrayType::Pointer xtals2 = outputAttributeMatrix->getPrereqArray <UInt32ArrayType>(this , getCrystalStructuresArrayPath ().getDataArrayName (), -41232 , {1 });
440+
441+ // Is it the same xtalStructures?
442+ if (xtals2 == nullptr ) // There is NOT a crystal structures in the output Ensemble AM,
443+ {
444+ m_CopyCrystalStructures = true ;
445+ outputAttributeMatrix->createNonPrereqArray <UInt32ArrayType>(this , getCrystalStructuresArrayPath ().getDataArrayName (), 999 , {1 });
446+ }
447+ else if (m_CrystalStructuresPtr.lock ().get () != xtals2.get ()) // is not the same, do the copy
448+ {
449+ AttributeMatrix::Pointer am = getDataContainerArray ()->getPrereqAttributeMatrixFromPath (this , getCrystalStructuresArrayPath (), -10656 );
450+ if (am.get () != outputAttributeMatrix.get () && outputAttributeMatrix->doesAttributeArrayExist (getCrystalStructuresArrayPath ().getDataArrayName ()))
451+ {
452+ QString ss;
453+ QTextStream out (&ss);
454+ out << " The selected CrystalStructures at " << getCrystalStructuresArrayPath ().serialize () << " is not within the output AttributeMatrix at "
455+ << outputAttributeMatrix->getDataArrayPath ().serialize ()
456+ << " but the output Attribute Matrix already contains a DataArray called "
457+ << getCrystalStructuresArrayPath ().getDataArrayName ()
458+ << " . Either select the "
459+ << getCrystalStructuresArrayPath ().getDataArrayName ()
460+ << " from the " << outputAttributeMatrix->getDataArrayPath ().serialize () << " AttributeMatrix or rename one of the DataArrays" ;
461+ setErrorCondition (-14345 , ss);
462+ }
463+ }
442464
443- m_PhaseTypesPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray< unsigned int > >(this , getPhaseTypesArrayPath (), dims);
465+ m_PhaseTypesPtr = getDataContainerArray ()->getPrereqArrayFromPath <UInt32ArrayType >(this , getPhaseTypesArrayPath (), dims);
444466 if (nullptr != m_PhaseTypesPtr.lock ())
445467 {
446468 m_PhaseTypes = m_PhaseTypesPtr.lock ()->getPointer (0 );
447- } /* Now assign the raw pointer to data from the DataArray<T> object */
469+ }
470+
471+ {
472+ AttributeMatrix::Pointer am = getDataContainerArray ()->getPrereqAttributeMatrixFromPath (this , getPhaseTypesArrayPath (), -10657 );
473+ if (am.get () != outputAttributeMatrix.get ())
474+ {
475+ m_CopyPhaseTypes = true ;
476+ outputAttributeMatrix->createNonPrereqArray <UInt32ArrayType>(this , getPhaseTypesArrayPath ().getDataArrayName (), 999 , {1 });
477+ }
478+ }
448479
449480 m_ShapeTypesPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray<ShapeType::EnumType>>(this , getShapeTypesArrayPath (), dims);
450481 if (nullptr != m_ShapeTypesPtr.lock ())
451482 {
452483 m_ShapeTypes = m_ShapeTypesPtr.lock ()->getPointer (0 );
453- } /* Now assign the raw pointer to data from the DataArray<T> object */
484+ }
454485
455- m_NumFeaturesPtr = getDataContainerArray ()->getPrereqArrayFromPath <DataArray<int32_t >>(this , getNumFeaturesArrayPath (), dims);
456- if (nullptr != m_NumFeaturesPtr.lock ())
457486 {
458- m_NumFeatures = m_NumFeaturesPtr.lock ()->getPointer (0 );
459- } /* Now assign the raw pointer to data from the DataArray<T> object */
487+ AttributeMatrix::Pointer am = getDataContainerArray ()->getPrereqAttributeMatrixFromPath (this , getShapeTypesArrayPath (), -10658 );
488+ if (am.get () != outputAttributeMatrix.get ())
489+ {
490+ m_CopyShapeTypes = true ;
491+ outputAttributeMatrix->createNonPrereqArray <UInt32ArrayType>(this , getShapeTypesArrayPath ().getDataArrayName (), 999 , {1 });
492+ }
493+ }
460494}
461495
462496// -----------------------------------------------------------------------------
@@ -488,15 +522,44 @@ void InsertTransformationPhases::execute()
488522 DataContainerArray::Pointer dca = getDataContainerArray ();
489523
490524 // defining separate ensemble attribute matrix for statsgen & vol
491- // AttributeMatrix::Pointer statsGenAttrMat = dca->getAttributeMatrix(getStatsGenCellEnsembleAttributeMatrixPath());
492525 AttributeMatrix::Pointer volAttrMat = dca->getAttributeMatrix (getNumFeaturesPerParentArrayPath ());
493526
494527 size_t totalFeatures = m_FeaturePhasesPtr.lock ()->getNumberOfTuples ();
495- size_t numensembles = m_PhaseTypesPtr. lock () ->getNumberOfTuples ();
528+ size_t numensembles = volAttrMat ->getNumberOfTuples ();
496529
497530 // resizing statsgen attribute matrix to add new phase info
498- // std::vector<size_t> tDims(1, numensembles + 1);
499- // statsGenAttrMat->resizeAttributeArrays(tDims);
531+ volAttrMat->resizeAttributeArrays ({numensembles + 1 });
532+
533+ if (m_CopyCrystalStructures)
534+ {
535+ DataContainer::Pointer m = dca->getDataContainer (getCrystalStructuresArrayPath ());
536+ AttributeMatrix::Pointer am = m->getAttributeMatrix (getCrystalStructuresArrayPath ());
537+ IDataArray::Pointer arrayPtr = am->getAttributeArrayAs <UInt32ArrayType>(getCrystalStructuresArrayPath ().getDataArrayName ())->deepCopy ();
538+ arrayPtr->resizeTuples (volAttrMat->getNumberOfTuples ());
539+ volAttrMat->insertOrAssign (arrayPtr);
540+ m_CrystalStructuresPtr = std::dynamic_pointer_cast<UInt32ArrayType>(arrayPtr);
541+ }
542+
543+ if (m_CopyPhaseTypes)
544+ {
545+ DataContainer::Pointer m = dca->getDataContainer (getPhaseTypesArrayPath ());
546+ AttributeMatrix::Pointer am = m->getAttributeMatrix (getPhaseTypesArrayPath ());
547+ IDataArray::Pointer arrayPtr = am->getAttributeArrayAs <UInt32ArrayType>(getPhaseTypesArrayPath ().getDataArrayName ())->deepCopy ();
548+ arrayPtr->resizeTuples (volAttrMat->getNumberOfTuples ());
549+ volAttrMat->insertOrAssign (arrayPtr);
550+ m_PhaseTypesPtr = std::dynamic_pointer_cast<UInt32ArrayType>(arrayPtr);
551+ }
552+
553+ if (m_CopyShapeTypes)
554+ {
555+ DataContainer::Pointer m = dca->getDataContainer (getShapeTypesArrayPath ());
556+ AttributeMatrix::Pointer am = m->getAttributeMatrix (getShapeTypesArrayPath ());
557+ IDataArray::Pointer arrayPtr = am->getAttributeArrayAs <DataArray<ShapeType::EnumType>>(getShapeTypesArrayPath ().getDataArrayName ())->deepCopy ();
558+ arrayPtr->resizeTuples (volAttrMat->getNumberOfTuples ());
559+ volAttrMat->insertOrAssign (arrayPtr);
560+ m_ShapeTypesPtr = std::dynamic_pointer_cast<UInt32ArrayType>(arrayPtr);
561+ }
562+
500563 updateStatsGenEnsembleInstancePointers ();
501564
502565 // hard-coded to the below stats for now
@@ -514,14 +577,9 @@ void InsertTransformationPhases::execute()
514577 numensembles = m_PhaseTypesPtr.lock ()->getNumberOfTuples ();
515578
516579 // resizing vol attribute matrix
517- volAttrMat->resizeAttributeArrays ({numensembles + 1 });
518580 updateVolEnsembleInstancePointers ();
519-
581+ m_NumFeaturesPtr. lock ()-> initializeWithZeros ();
520582 // finding ensemble level number of features per phase
521- for (size_t i = 1 ; i < numensembles; ++i)
522- {
523- m_NumFeatures[i] = 0 ;
524- }
525583 for (size_t i = 1 ; i < totalFeatures; ++i)
526584 {
527585 ++m_NumFeatures[m_FeaturePhases[i]];
@@ -1242,17 +1300,6 @@ float InsertTransformationPhases::getPeninsulaFrac() const
12421300 return m_PeninsulaFrac;
12431301}
12441302
1245- // -----------------------------------------------------------------------------
1246- void InsertTransformationPhases::setStatsGenCellEnsembleAttributeMatrixPath (const DataArrayPath& value)
1247- {
1248- m_StatsGenCellEnsembleAttributeMatrixPath = value;
1249- }
1250-
1251- // -----------------------------------------------------------------------------
1252- DataArrayPath InsertTransformationPhases::getStatsGenCellEnsembleAttributeMatrixPath () const
1253- {
1254- return m_StatsGenCellEnsembleAttributeMatrixPath;
1255- }
12561303
12571304// -----------------------------------------------------------------------------
12581305void InsertTransformationPhases::setCellFeatureAttributeMatrixName (const DataArrayPath& value)
0 commit comments