7#include <vtkCellData.h>
8#include <vtkDataArray.h>
9#include <vtkPointData.h>
10#include <vtkSmartPointer.h>
12#include <vtkUnstructuredGrid.h>
14#include <vtkCharArray.h>
15#include <vtkDoubleArray.h>
16#include <vtkFloatArray.h>
17#include <vtkIntArray.h>
30 template <
typename vtkArrayType>
35 arr->SetName(fieldName);
36 arr->SetNumberOfComponents(1);
37 arr->SetNumberOfTuples(nbElmnt);
39#ifndef TTK_ENABLE_KAMIKAZE
41 std::cerr <<
"[ttkMergeTree] Error, unable to allocate " << fieldName
42 <<
" the program will likely crash" << std::endl;
61 int const degree = upDegree + downDegree;
65 if(upDegree == 2 and downDegree == 1)
67 else if(upDegree == 1 and downDegree == 2)
69 else if(upDegree == 1 and downDegree == 1)
94 inline int init(std::vector<LocalFTM> &ftmTree,
Params params) {
99 for(
auto &t : ftmTree) {
111 = initArray<ttkSimplexIdTypeArray>(
"SegmentationId", samplePoints);
113 = initArray<ttkSimplexIdTypeArray>(
"upNodeId", samplePoints);
115 = initArray<ttkSimplexIdTypeArray>(
"downNodeId", samplePoints);
118 point_scalar = initArray<vtkFloatArray>(
"Scalar", samplePoints);
123 = initArray<ttkSimplexIdTypeArray>(
"RegionSize", samplePoints);
125 cell_spanArcs = initArray<vtkDoubleArray>(
"RegionSpan", samplePoints);
161 cell_ids->SetTuple1(pos, idOffset + arcId);
177 downVertexId, downPoints[0], downPoints[1], downPoints[2]);
183 upVertexId, upPoints[0], upPoints[1], upPoints[2]);
194 const size_t nbPoints = skeletonArcs->GetNumberOfPoints();
195 const size_t nbCells = skeletonArcs->GetNumberOfCells();
197 cell_ids->SetNumberOfTuples(nbCells);
198 skeletonArcs->GetCellData()->SetScalars(
cell_ids);
202 skeletonArcs->GetCellData()->AddArray(
cell_upNode);
232 inline int init(std::vector<LocalFTM> &ftmTree,
Params params) {
234 for(
auto &t : ftmTree) {
239 ids = initArray<ttkSimplexIdTypeArray>(
"NodeId", numberOfNodes);
240 vertIds = initArray<ttkSimplexIdTypeArray>(
"VertexId", numberOfNodes);
241 type = initArray<vtkIntArray>(
"CriticalType", numberOfNodes);
242 scalars = initArray<vtkFloatArray>(
"Scalar", numberOfNodes);
247 = initArray<ttkSimplexIdTypeArray>(
"RegionSize", numberOfNodes);
250 = initArray<ttkSimplexIdTypeArray>(
"RegionSpan", numberOfNodes);
263 vtkDataArray *idMapper,
272 const SimplexId g_vertexId = idMapper->GetTuple1(l_vertexId);
273 float cellScalar = 0;
275 vtkTemplateMacro(cellScalar
276 = (
float)tree->
getValue<VTK_TT>(l_vertexId));
279 ids->SetTuple1(arrIdx, idOffset + nodeId);
280 scalars->SetTuple1(arrIdx, cellScalar);
281 vertIds->SetTuple1(arrIdx, g_vertexId);
283 arrIdx,
static_cast<int>(
getNodeType(*tree, nodeId, params)));
298 downVertexId, downPoints[0], downPoints[1], downPoints[2]);
304 upVertexId, upPoints[0], upPoints[1], upPoints[2]);
312 pointData->AddArray(
ids);
315 pointData->SetScalars(
type);
344#ifndef TTK_ENABLE_KAMIKAZE
345 std::cerr <<
"[ttkMergeTree]: node without arcs:" << node->
getVertexId()
358 inline int init(std::vector<LocalFTM> &ftmTrees,
Params params) {
364 for(
auto &t : ftmTrees) {
369 ids = initArray<ttkSimplexIdTypeArray>(
370 "SegmentationId", numberOfVertices);
371 typeRegion = initArray<vtkCharArray>(
"RegionType", numberOfVertices);
375 = initArray<ttkSimplexIdTypeArray>(
"RegionSize", numberOfVertices);
377 = initArray<vtkDoubleArray>(
"RegionSpan", numberOfVertices);
386 vtkDataArray *idMapper,
398 const SimplexId g_upVertexId = idMapper->GetTuple1(l_upVertexId);
402 l_upVertexId, coordUp[0], coordUp[1], coordUp[2]);
407 const SimplexId g_downVertexId = idMapper->GetTuple1(l_downVertexId);
412 l_downVertexId, coordDown[0], coordDown[1], coordDown[2]);
444 ids->SetTuple1(g_upVertexId, idOffset + nid);
445 ids->SetTuple1(g_downVertexId, idOffset + nid);
447 ids->SetTuple1(g_upVertexId, idOffset + arcId);
448 ids->SetTuple1(g_downVertexId, idOffset + arcId);
452 sizeRegion->SetTuple1(g_upVertexId, regionSize);
453 sizeRegion->SetTuple1(g_downVertexId, regionSize);
454 spanRegion->SetTuple1(g_upVertexId, regionSpan);
455 spanRegion->SetTuple1(g_downVertexId, regionSpan);
457 typeRegion->SetTuple1(g_upVertexId,
static_cast<char>(regionType));
458 typeRegion->SetTuple1(g_downVertexId,
static_cast<char>(regionType));
462 const SimplexId g_vertexId = idMapper->GetTuple1(l_vertexId);
464 ids->SetTuple1(g_vertexId, idOffset + nid);
466 ids->SetTuple1(g_vertexId, idOffset + arcId);
469 sizeRegion->SetTuple1(g_vertexId, regionSize);
470 spanRegion->SetTuple1(g_vertexId, regionSpan);
472 typeRegion->SetTuple1(g_vertexId,
static_cast<char>(regionType));
480 pointData->AddArray(
ids);
481 pointData->SetActiveScalars(
ids->GetName());
Triangulation is a class that provides time and memory efficient traversal methods on triangulations ...
int getVertexPoint(const SimplexId &vertexId, float &x, float &y, float &z) const override
FTMTree_MT * getTree(const TreeType tt)
const scalarType & getValue(SimplexId nodeId) const
SuperArc * getSuperArc(idSuperArc i)
idNode getNumberOfNodes() const
idNode getLowerNodeId(const SuperArc *a)
SimplexId getNumberOfVertices() const
idSuperArc getNumberOfSuperArcs() const
idNode getUpperNodeId(const SuperArc *a)
Node * getNode(idNode nodeId)
SimplexId getArcSize(const idSuperArc arcId)
TTK processing package that efficiently computes the contour tree of scalar data and more (data segme...
idSuperArc getUpSuperArcId(idSuperArc neighborId) const
idSuperArc getNumberOfDownSuperArcs() const
idSuperArc getDownSuperArcId(idSuperArc neighborId) const
SimplexId getVertexId() const
idSuperArc getNumberOfUpSuperArcs() const
SimplexId getNumberOfRegularNodes() const
idNode getUpNodeId() const
idNode getDownNodeId() const
idSuperArc getNormalizedId() const
T distance(const T *p0, const T *p1, const int &dimension=3)
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
unsigned int idNode
Node index in vect_nodes_.
CriticalType
default value for critical index
const char MaskScalarFieldName[]
default name for mask scalar field
int SimplexId
Identifier type for simplices of any dimension.
void fillArrayCell(const SimplexId pos, const idSuperArc arcId, LocalFTM &ftmTree, Triangulation *triangulation, Params params)
void addPoint(const SimplexId globalId, const SimplexId id, const float scalar, const bool reg)
int init(std::vector< LocalFTM > &ftmTree, Params params)
vtkSmartPointer< vtkFloatArray > point_scalar
vtkSmartPointer< vtkDoubleArray > cell_spanArcs
bool hasPoint(const SimplexId vertId)
vtkSmartPointer< ttkSimplexIdTypeArray > cell_downNode
vtkSmartPointer< ttkSimplexIdTypeArray > cell_sizeArcs
std::vector< SimplexId > point_ids
vtkSmartPointer< ttkSimplexIdTypeArray > cell_upNode
void addArray(vtkUnstructuredGrid *skeletonArcs, Params params)
vtkSmartPointer< ttkSimplexIdTypeArray > cell_ids
void setPoint(const SimplexId id, const float scalar, const bool reg)
vtkSmartPointer< vtkCharArray > point_regularMask
vtkSmartPointer< ttkSimplexIdTypeArray > regionSize
vtkSmartPointer< ttkSimplexIdTypeArray > regionSpan
int init(std::vector< LocalFTM > &ftmTree, Params params)
void fillArrayPoint(SimplexId arrIdx, const idNode nodeId, LocalFTM &ftmTree, vtkDataArray *idMapper, Triangulation *triangulation, Params params)
vtkSmartPointer< ttkSimplexIdTypeArray > ids
void addArray(vtkPointData *pointData, Params params)
vtkSmartPointer< vtkIntArray > type
vtkSmartPointer< vtkFloatArray > scalars
void setScalarType(const int s)
vtkSmartPointer< ttkSimplexIdTypeArray > vertIds
void addArray(vtkPointData *pointData, Params params)
void fillArrayPoint(const idSuperArc arcId, LocalFTM &l_tree, Triangulation *triangulation, vtkDataArray *idMapper, Params params)
int init(std::vector< LocalFTM > &ftmTrees, Params params)
vtkSmartPointer< vtkCharArray > typeRegion
vtkSmartPointer< ttkSimplexIdTypeArray > ids
vtkSmartPointer< vtkDoubleArray > spanRegion
vtkSmartPointer< ttkSimplexIdTypeArray > sizeRegion
vtkSmartPointer< vtkArrayType > initArray(const char *fieldName, size_t nbElmnt)
static CriticalType getNodeType(FTMTree_MT &tree, const idNode nodeId, Params params)