Skip to content

Commit

Permalink
fix morse smale complex for multiblock input
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-dani committed Dec 12, 2024
1 parent fac0085 commit 0eeb872
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
25 changes: 20 additions & 5 deletions core/vtk/ttkMorseSmaleComplex/ttkMorseSmaleComplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ int ttkMorseSmaleComplex::FillOutputPortInformation(int port,

template <typename vtkArrayType, typename vectorType>
void setArray(vtkArrayType &vtkArray, vectorType &vector) {
ttkUtils::SetVoidArray(vtkArray, vector.data(), vector.size(), 1);
vtkArray->SetNumberOfTuples(vector.size());
for(unsigned int i = 0; i < vector.size(); i++) {
vtkArray->SetValue(i, vector[i]);
}
}

template <typename scalarType, typename triangulationType>
Expand All @@ -61,6 +64,9 @@ int ttkMorseSmaleComplex::dispatch(vtkDataArray *const inputScalars,
const int dimensionality = triangulation.getDimensionality();
const auto scalars = ttkUtils::GetPointer<scalarType>(inputScalars);

OutputCriticalPoints criticalPoints_{};
Output1Separatrices separatrices1_{};
Output2Separatrices separatrices2_{};
const int ret = this->execute(
criticalPoints_, separatrices1_, separatrices2_, segmentations_, scalars,
inputScalars->GetMTime(), inputOffsets, triangulation);
Expand Down Expand Up @@ -148,7 +154,6 @@ int ttkMorseSmaleComplex::dispatch(vtkDataArray *const inputScalars,
pointData->AddArray(PLVertexIdentifiers);
pointData->AddArray(manifoldSizeScalars);
}

// 1-separatrices
if(ComputeAscendingSeparatrices1 or ComputeDescendingSeparatrices1
or ComputeSaddleConnectors) {
Expand Down Expand Up @@ -177,7 +182,12 @@ int ttkMorseSmaleComplex::dispatch(vtkDataArray *const inputScalars,
#endif

pointsCoords->SetNumberOfComponents(3);
setArray(pointsCoords, separatrices1_.pt.points_);
pointsCoords->SetNumberOfTuples(separatrices1_.pt.numberOfPoints_);
for(int i = 0; i < separatrices1_.pt.numberOfPoints_; i++) {
pointsCoords->SetTuple3(i, separatrices1_.pt.points_[3 * i],
separatrices1_.pt.points_[3 * i + 1],
separatrices1_.pt.points_[3 * i + 2]);
}

smoothingMask->SetNumberOfComponents(1);
smoothingMask->SetName(ttk::MaskScalarFieldName);
Expand Down Expand Up @@ -309,7 +319,12 @@ int ttkMorseSmaleComplex::dispatch(vtkDataArray *const inputScalars,
#endif

pointsCoords->SetNumberOfComponents(3);
setArray(pointsCoords, separatrices2_.pt.points_);
pointsCoords->SetNumberOfTuples(separatrices2_.pt.points_.size());
for(int i = 0; i < separatrices2_.pt.numberOfPoints_; i++) {
pointsCoords->SetTuple3(i, separatrices2_.pt.points_[3 * i],
separatrices2_.pt.points_[3 * i + 1],
separatrices2_.pt.points_[3 * i + 2]);
}

sourceIds->SetNumberOfComponents(1);
sourceIds->SetName(ttk::MorseSmaleSourceIdName);
Expand Down Expand Up @@ -387,7 +402,6 @@ int ttkMorseSmaleComplex::dispatch(vtkDataArray *const inputScalars,
cellData->AddArray(separatrixFunctionDiffs);
cellData->AddArray(isOnBoundary);
}

return ret;
}

Expand Down Expand Up @@ -469,6 +483,7 @@ int ttkMorseSmaleComplex::RequestData(vtkInformation *ttkNotUsed(request),
return -1;
}
#endif

ascendingManifold->SetNumberOfComponents(1);
ascendingManifold->SetNumberOfTuples(numberOfVertices);
ascendingManifold->SetName(ttk::MorseSmaleAscendingName);
Expand Down
3 changes: 0 additions & 3 deletions core/vtk/ttkMorseSmaleComplex/ttkMorseSmaleComplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,5 @@ class TTKMORSESMALECOMPLEX_EXPORT ttkMorseSmaleComplex
private:
bool ForceInputOffsetScalarField{};
int IterationThreshold{-1};
OutputCriticalPoints criticalPoints_{};
Output1Separatrices separatrices1_{};
Output2Separatrices separatrices2_{};
OutputManifold segmentations_{};
};

0 comments on commit 0eeb872

Please sign in to comment.