11 vtkUnstructuredGrid *skeletonArcs,
16 auto arc = tree->getSuperArc(arcId);
18 vtkIdType pointIds[2];
21 const SimplexId downNodeId = tree->getLowerNodeId(arc);
22 const SimplexId l_downVertexId = tree->getNode(downNodeId)->getVertexId();
23 const SimplexId g_downVertexId = idMapper->GetTuple1(l_downVertexId);
25 l_downVertexId, point[0], point[1], point[2]);
26 const double scalarMin =
inputScalars_[cc]->GetTuple1(l_downVertexId);
29 SimplexId nextPointId;
30 if(!arcData.
hasPoint(g_downVertexId)) {
31 nextPointId = points->InsertNextPoint(point);
32 arcData.
addPoint(g_downVertexId, nextPointId, scalarMin,
false);
34 nextPointId = arcData.
point_ids[g_downVertexId];
37 pointIds[0] = nextPointId;
39 for(
const SimplexId vertexId : *arc) {
40 triangulation_[cc]->getVertexPoint(vertexId, point[0], point[1], point[2]);
41 pointIds[1] = points->InsertNextPoint(point);
43 arcData.
setPoint(pointIds[1], scalar,
true);
45 const SimplexId nextCell
46 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
50 pointIds[0] = pointIds[1];
53 const SimplexId upNodeId = tree->getUpperNodeId(arc);
54 const SimplexId l_upVertexId = tree->getNode(upNodeId)->getVertexId();
55 const SimplexId g_upVertexId = idMapper->GetTuple1(l_upVertexId);
57 l_upVertexId, point[0], point[1], point[2]);
58 const double scalarMax =
inputScalars_[cc]->GetTuple1(l_upVertexId);
61 if(!arcData.
hasPoint(g_upVertexId)) {
62 nextPointId = points->InsertNextPoint(point);
63 arcData.
addPoint(g_upVertexId, nextPointId, scalarMax,
false);
65 nextPointId = arcData.
point_ids[g_upVertexId];
68 pointIds[1] = nextPointId;
70 const SimplexId nextCell
71 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
81 vtkUnstructuredGrid *skeletonArcs,
86 auto arc = tree->getSuperArc(arcId);
88 vtkIdType pointIds[2];
91 const SimplexId downNodeId = tree->getLowerNodeId(arc);
92 const SimplexId l_downVertexId = tree->getNode(downNodeId)->getVertexId();
93 const SimplexId g_downVertexId = idMapper->GetTuple1(l_downVertexId);
95 l_downVertexId, point[0], point[1], point[2]);
96 const double scalarMin =
inputScalars_[cc]->GetTuple1(l_downVertexId);
98 if(!arcData.
hasPoint(g_downVertexId)) {
99 const SimplexId nextPointId = points->InsertNextPoint(point);
100 pointIds[0] = nextPointId;
101 arcData.
addPoint(g_downVertexId, nextPointId, scalarMin,
false);
103 pointIds[0] = arcData.
point_ids[g_downVertexId];
106 const SimplexId upNodeId = tree->getUpperNodeId(arc);
107 const SimplexId l_upVertexId = tree->getNode(upNodeId)->getVertexId();
108 const SimplexId g_upVertexId = idMapper->GetTuple1(l_upVertexId);
110 l_upVertexId, point[0], point[1], point[2]);
111 const double scalarMax =
inputScalars_[cc]->GetTuple1(l_upVertexId);
113 if(!arcData.
hasPoint(g_upVertexId)) {
114 const SimplexId nextPointId = points->InsertNextPoint(point);
115 pointIds[1] = nextPointId;
116 arcData.
addPoint(g_upVertexId, nextPointId, scalarMax,
false);
118 pointIds[1] = arcData.
point_ids[g_upVertexId];
121 const SimplexId nextCell
122 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
132 vtkUnstructuredGrid *skeletonArcs,
137 auto arc = tree->getSuperArc(arcId);
139 vtkIdType pointIds[2];
142 const SimplexId downNodeId = tree->getLowerNodeId(arc);
143 const SimplexId l_downVertexId = tree->getNode(downNodeId)->getVertexId();
144 const SimplexId g_downVertexId = idMapper->GetTuple1(l_downVertexId);
146 l_downVertexId, point[0], point[1], point[2]);
147 const double scalarMin =
inputScalars_[cc]->GetTuple1(l_downVertexId);
150 SimplexId nextPointId;
151 if(!arcData.
hasPoint(g_downVertexId)) {
152 nextPointId = points->InsertNextPoint(point);
153 arcData.
addPoint(g_downVertexId, nextPointId, scalarMin,
false);
155 nextPointId = arcData.
point_ids[g_downVertexId];
158 pointIds[0] = nextPointId;
160 const SimplexId upNodeId = tree->getUpperNodeId(arc);
161 const SimplexId l_upVertexId = tree->getNode(upNodeId)->getVertexId();
162 const SimplexId g_upVertexId = idMapper->GetTuple1(l_upVertexId);
164 l_upVertexId, point[0], point[1], point[2]);
165 const double scalarMax =
inputScalars_[cc]->GetTuple1(l_upVertexId);
168 double scalarLimit = scalarMin + delta;
169 double scalarAvg = 0;
172 if(!arcData.
hasPoint(g_upVertexId)) {
173 nextPointId = points->InsertNextPoint(point);
174 arcData.
addPoint(g_upVertexId, nextPointId, scalarMax,
false);
176 nextPointId = arcData.
point_ids[g_upVertexId];
180 float sum[3]{0, 0, 0};
181 for(
const SimplexId vertexId : *arc) {
182 triangulation_[cc]->getVertexPoint(vertexId, point[0], point[1], point[2]);
183 const double scalarVertex =
inputScalars_[cc]->GetTuple1(vertexId);
185 if(scalarVertex < scalarLimit) {
189 scalarAvg += scalarVertex;
198 pointIds[1] = points->InsertNextPoint(sum);
199 arcData.
setPoint(pointIds[1], scalarAvg,
true);
200 const SimplexId nextCell
201 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
205 pointIds[0] = pointIds[1];
208 scalarLimit += delta;
218 pointIds[1] = nextPointId;
220 const SimplexId nextCell
221 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
232 for(
int cc = 0; cc <
nbCC_; cc++) {
234 vtkDataArray *idMapper
237 const auto numberOfSuperArcs = tree->getNumberOfSuperArcs();
245 vtkPointData *pointData = outputSegmentation->GetPointData();
255 vtkNew<vtkUnstructuredGrid> skeletonArcs{};
256 vtkNew<vtkPoints>
const points{};
262 for(
int cc = 0; cc <
nbCC_; cc++) {
266 const SimplexId numberOfSuperArcs = tree->getNumberOfSuperArcs();
267#ifndef TTK_ENABLE_KAMIKAZE
268 if(!numberOfSuperArcs) {
269 this->
printErr(
"Error : tree has no super arcs.");
274 for(SimplexId arcId = 0; arcId < numberOfSuperArcs; ++arcId) {
275 const SimplexId numberOfRegularNodes = tree->getArcSize(arcId);
276 if(numberOfRegularNodes > 0 and samplingLevel > 0) {
278 }
else if(samplingLevel == -1) {
286 skeletonArcs->SetPoints(points);
288 outputSkeletonArcs->ShallowCopy(skeletonArcs);
303 vtkUnstructuredGrid *outputSkeletonNodes) {
304 vtkNew<vtkUnstructuredGrid> skeletonNodes{};
305 vtkNew<vtkPoints> points{};
311 for(
int cc = 0; cc <
nbCC_; cc++) {
313 vtkDataArray *idMapper
317 const auto numberOfNodes = tree->getNumberOfNodes();
318#ifndef TTK_ENABLE_KAMIKAZE
320 this->
printErr(
"Error : tree has no nodes.");
326 const auto node = tree->getNode(nodeId);
327#ifndef TTK_ENABLE_KAMIKAZE
329 this->
printMsg({
"Error : node ", std::to_string(nodeId),
" is null."},
334 const auto local_vertId = node->getVertexId();
337 local_vertId, point[0], point[1], point[2]);
338 const auto nextPoint = points->InsertNextPoint(point);
346 vtkPointData *pointData = skeletonNodes->GetPointData();
349 outputSkeletonNodes->ShallowCopy(skeletonNodes);
354#ifdef TTK_ENABLE_FTM_TREE_STATS_TIME
355void ttkMergeTreeBase::printCSVStats() {
360 case ftm::TreeType::Join:
361 cout <<
"JT" << endl;
362 printCSVTree(t.tree.getTree(ftm::TreeType::Join));
364 case ftm::TreeType::Split:
365 cout <<
"ST" << endl;
366 printCSVTree(t.tree.getTree(ftm::TreeType::Split));
369 cout <<
"JT" << endl;
370 printCSVTree(t.tree.getTree(ftm::TreeType::Join));
371 cout <<
"ST" << endl;
372 printCSVTree(t.tree.getTree(ftm::TreeType::Split));
378void ttkMergeTreeBase::printCSVTree(
385 cout << tree->getActiveTasks(a).begin <<
"; ";
387 cout << endl <<
"end; ";
389 cout << tree->getActiveTasks(a).end <<
"; ";
391 cout << endl <<
"origing; ";
393 cout << tree->getActiveTasks(a).origin <<
"; ";
402 vtkNew<ttkSimplexIdTypeArray> identifiers{};
403 const auto nbPoints = ds->GetNumberOfPoints();
405 identifiers->SetNumberOfComponents(1);
406 identifiers->SetNumberOfTuples(nbPoints);
408 for(
int i = 0; i < nbPoints; i++) {
409 identifiers->SetTuple1(i, i);
412 ds->GetPointData()->AddArray(identifiers);
ttk::ftm::TreeType GetTreeType() const
std::vector< ttk::Triangulation * > triangulation_
int addCompleteSkeletonArc(const ttk::ftm::idSuperArc arcId, const int cc, vtkPoints *points, vtkUnstructuredGrid *skeletonArcs, ttk::ftm::ArcData &arcData)
int addSampledSkeletonArc(const ttk::ftm::idSuperArc arcId, const int cc, vtkPoints *points, vtkUnstructuredGrid *skeletonArcs, ttk::ftm::ArcData &arcData)
std::vector< vtkDataArray * > inputScalars_
int getSegmentation(vtkDataSet *outputSegmentation)
int getSkeletonNodes(vtkUnstructuredGrid *outputSkeletonNodes)
int addDirectSkeletonArc(const ttk::ftm::idSuperArc arcId, const int cc, vtkPoints *points, vtkUnstructuredGrid *skeletonArcs, ttk::ftm::ArcData &arcData)
int getSkeletonArcs(vtkUnstructuredGrid *outputSkeletonArcs)
void identify(vtkDataSet *ds) const
std::vector< vtkSmartPointer< vtkDataSet > > connected_components_
std::vector< ttk::ftm::LocalFTM > ftmTree_
static int CellVertexFromPoints(vtkDataSet *const dataSet, vtkPoints *const points)
void setDebugMsgPrefix(const std::string &prefix)
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
idNode getNumberOfLeaves() const
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
unsigned int idNode
Node index in vect_nodes_.
const char VertexScalarFieldName[]
default name for vertex 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)
bool hasPoint(const SimplexId vertId)
std::vector< SimplexId > point_ids
void addArray(vtkUnstructuredGrid *skeletonArcs, Params params)
void setPoint(const SimplexId id, const float scalar, const bool reg)
int init(std::vector< LocalFTM > &ftmTree, Params params)
void fillArrayPoint(SimplexId arrIdx, const idNode nodeId, LocalFTM &ftmTree, vtkDataArray *idMapper, Triangulation *triangulation, Params params)
void addArray(vtkPointData *pointData, Params params)
void setScalarType(const int s)
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)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)