6#include <vtkConnectivityFilter.h>
7#include <vtkDataObject.h>
8#include <vtkInformation.h>
16 this->SetNumberOfInputPorts(1);
17 this->SetNumberOfOutputPorts(3);
22 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkDataSet");
29 if(port == 0 || port == 1) {
30 info->Set(vtkDataObject::DATA_TYPE_NAME(),
"vtkUnstructuredGrid");
32 }
else if(port == 2) {
42 vtkUnstructuredGrid *skeletonArcs,
49#ifndef TTK_ENABLE_KAMIKAZE
50 if(upNodeId == nullNode || downNodeId == nullNode) {
59 vtkIdType pointIds[2];
60 if(arcData.
points.count(downVertId)) {
61 pointIds[0] = arcData.
points[downVertId];
64 downVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
65 pointIds[0] = points->InsertNextPoint(pointCoord);
66 arcData.
points.emplace(downVertId, pointIds[0]);
73 if(regV == downVertId || regV == upVertId)
76 if(arcData.
points.count(regV)) {
77 pointIds[1] = arcData.
points[regV];
80 regV, pointCoord[0], pointCoord[1], pointCoord[2]);
81 pointIds[1] = points->InsertNextPoint(pointCoord);
82 arcData.
points.emplace(regV, pointIds[1]);
85 if(pointIds[0] != pointIds[1]) {
86 vtkIdType
const nextCellId
87 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
90 pointIds[0] = pointIds[1];
93 if(arcData.
points.count(upVertId)) {
94 pointIds[1] = arcData.
points[upVertId];
97 upVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
98 pointIds[1] = points->InsertNextPoint(pointCoord);
99 arcData.
points.emplace(upVertId, pointIds[1]);
102 if(pointIds[0] != pointIds[1]) {
103 vtkIdType
const nextCellId
104 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
114 vtkUnstructuredGrid *skeletonArcs,
120#ifndef TTK_ENABLE_KAMIKAZE
121 if(upNodeId == nullNode || downNodeId == nullNode) {
131 vtkIdType pointIds[2];
132 if(arcData.
points.count(downVertId)) {
133 pointIds[0] = arcData.
points[downVertId];
136 downVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
137 pointIds[0] = points->InsertNextPoint(pointCoord);
138 arcData.
points.emplace(downVertId, pointIds[0]);
141 if(arcData.
points.count(upVertId)) {
142 pointIds[1] = arcData.
points[upVertId];
145 upVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
146 pointIds[1] = points->InsertNextPoint(pointCoord);
147 arcData.
points.emplace(upVertId, pointIds[1]);
150 vtkIdType
const nextCellId
151 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
161 vtkUnstructuredGrid *skeletonArcs,
168 const double scalarMin
170 const double scalarMax
172 const double delta = (scalarMax - scalarMin) / (params_.
samplingLvl + 1);
174#ifndef TTK_ENABLE_KAMIKAZE
175 if(upNodeId == nullNode || downNodeId == nullNode) {
184 vtkIdType pointIds[2];
185 if(arcData.
points.count(downVertId)) {
186 pointIds[0] = arcData.
points[downVertId];
189 downVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
190 pointIds[0] = points->InsertNextPoint(pointCoord);
191 arcData.
points.emplace(downVertId, pointIds[0]);
197 double scalarLimit = scalarMin + delta;
202 if(regV == downVertId || regV == upVertId)
206 regV, pointCoord[0], pointCoord[1], pointCoord[2]);
207 const double scalar = inputScalars_->GetTuple1(regV);
208 if(scalar < scalarLimit) {
209 sum[0] += pointCoord[0];
210 sum[1] += pointCoord[1];
211 sum[2] += pointCoord[2];
221 pointIds[1] = points->InsertNextPoint(sum);
222 arcData.
points.emplace(regV, pointIds[1]);
225 if(pointIds[0] != pointIds[1]) {
226 vtkIdType
const nextCellId
227 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
231 pointIds[0] = pointIds[1];
235 scalarLimit += delta;
243 if(arcData.
points.count(upVertId)) {
244 pointIds[1] = arcData.
points[upVertId];
247 upVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
248 pointIds[1] = points->InsertNextPoint(pointCoord);
249 arcData.
points.emplace(upVertId, pointIds[1]);
252 if(pointIds[0] != pointIds[1]) {
253 vtkIdType
const nextCellId
254 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
261template <
typename VTK_TT,
typename TTK_TT>
264 static_cast<TTK_TT *
>(triangulation_->
getData()));
275 this->
printMsg(
"Starting computation on field: "
276 + std::string{inputScalars_->GetName()});
285 vtkInformationVector **inputVector,
286 vtkInformationVector *outputVector) {
289 mesh_ = vtkDataSet::GetData(inputVector[0]);
292 auto outputSkeletonNodes = vtkUnstructuredGrid::GetData(outputVector, 0);
293 auto outputSkeletonArcs = vtkUnstructuredGrid::GetData(outputVector, 1);
294 auto outputSegmentation = vtkDataSet::GetData(outputVector, 2);
300#ifndef TTK_ENABLE_KAMIKAZE
301 if(!triangulation_) {
302 this->
printErr(
"ttkTriangulation::getTriangulation() is null.");
305 if(triangulation_->
isEmpty()) {
307 "ttkTriangulation on connected component allocation problem.");
317 inputScalars_ = this->GetInputArrayToProcess(0, inputVector);
318 if(inputScalars_ ==
nullptr) {
319 this->
printErr(
"input scalar field pointer is null.");
324 mesh_, 0, triangulation_,
false, 1, ForceInputOffsetScalarField);
328 (dispatch<VTK_TT, TTK_TT>(graph)));
330 UpdateProgress(0.50);
334#ifndef TTK_ENABLE_KAMIKAZE
335 this->
printErr(
"wrong properties on skeleton nodes.");
341#ifndef TTK_ENABLE_KAMIKAZE
342 this->
printErr(
"wrong properties on skeleton arcs.");
348#ifndef TTK_ENABLE_KAMIKAZE
349 this->
printErr(
"wrong properties on segmentation.");
360 vtkDataSet *outputSegmentation) {
361 outputSegmentation->ShallowCopy(mesh_);
363 const idVertex numberOfVertices = mesh_->GetNumberOfPoints();
367 for(
idVertex v = 0; v < numberOfVertices; ++v) {
371 vertData.
addArrays(outputSegmentation, params_);
377 vtkUnstructuredGrid *outputSkeletonArcs) {
395 vtkNew<vtkUnstructuredGrid> arcs{};
396 vtkNew<vtkPoints>
const points{};
398 for(
idSuperArc arcId = 0; arcId < nbArcs; ++arcId) {
415 arcs->SetPoints(points);
417 outputSkeletonArcs->ShallowCopy(arcs);
423 vtkUnstructuredGrid *outputSkeletonNodes) {
427 vtkNew<vtkUnstructuredGrid> nodes{};
428 vtkNew<vtkPoints> points{};
430 for(
idNode nodeId = 0; nodeId < nbNodes; nodeId++) {
434 triangulation_->
getVertexPoint(vertId, point[0], point[1], point[2]);
435 points->InsertNextPoint(point);
437 double const scalar = inputScalars_->GetTuple1(vertId);
438 nodeData.
addNode(graph, nodeId, scalar);
442 nodeData.
addArrays(nodes->GetPointData(), params_);
444 outputSkeletonNodes->ShallowCopy(nodes);
452 vtkNew<vtkIntArray> identifiers{};
453 const vtkIdType nbPoints = ds->GetNumberOfPoints();
454 identifiers->SetName(
"VertexIdentifier");
455 identifiers->SetNumberOfComponents(1);
456 identifiers->SetNumberOfTuples(nbPoints);
458 for(
int i = 0; i < nbPoints; i++) {
459 identifiers->SetTuple1(i, i);
462 ds->GetPointData()->AddArray(identifiers);
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
static vtkInformationIntegerKey * SAME_DATA_TYPE_AS_INPUT_PORT()
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
vtkDataArray * GetOrderArray(vtkDataSet *const inputData, const int scalarArrayIdx, ttk::Triangulation *triangulation, const bool getGlobalOrder=false, const int orderArrayIdx=0, const bool enforceOrderArrayIdx=false)
TTK VTK-filter for the computation of Reeb Graphs.
int getSkeletonNodes(const ttk::ftr::Graph &graph, vtkUnstructuredGrid *outputSkeletonNodes)
void identify(vtkDataSet *ds) const
int addCompleteSkeletonArc(const ttk::ftr::Graph &graph, const ttk::ftr::idSuperArc arcId, vtkPoints *points, vtkUnstructuredGrid *skeletonArcs, ttk::ftr::ArcData &arcData)
int getSegmentation(const ttk::ftr::Graph &graph, vtkDataSet *outputSegmentation)
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int FillInputPortInformation(int port, vtkInformation *info) override
int addSampledSkeletonArc(const ttk::ftr::Graph &graph, const ttk::ftr::idSuperArc arcId, vtkPoints *points, vtkUnstructuredGrid *skeletonArcs, ttk::ftr::ArcData &arcData)
int addDirectSkeletonArc(const ttk::ftr::Graph &graph, const ttk::ftr::idSuperArc arcId, vtkPoints *points, vtkUnstructuredGrid *skeletonArcs, ttk::ftr::ArcData &arcData)
int dispatch(ttk::ftr::Graph &graph)
int getSkeletonArcs(const ttk::ftr::Graph &graph, vtkUnstructuredGrid *outputSkeletonArcs)
int FillOutputPortInformation(int port, vtkInformation *info) override
bool GetWithSegmentation() const
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
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
AbstractTriangulation * getData()
Triangulation::Type getType() const
int getVertexPoint(const SimplexId &vertexId, float &x, float &y, float &z) const override
bool isEmpty() const override
SimplexId getNumberOfVertices() const override
TTK FTRGraph processing package.
void setVertexSoSoffsets(SimplexId *sos)
void setScalars(const void *scalars)
Scalar field used to compute the Reeb Graph.
int setDebugLevel(const int &lvl) override
Control the verbosity of the base code.
Graph && extractOutputGraph()
void setParams(const Params &p)
TTK FTRGraph graph skeleton.
idNode getNumberOfNodes() const
idSuperArc getNumberOfArcs() const
std::string printArc(const idSuperArc arcId) const
const SuperArc & getArc(const idSuperArc id) const
const Node & getNode(const idNode id) const
idSuperArc getNumberOfVisibleArcs() const
idVertex getVertexIdentifier() const
idNode getUpNodeId() const
idNode getDownNodeId() const
const decltype(segmentation_) & segmentation() const
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
SimplexId idVertex
Vertex index in scalars_.
unsigned int idNode
Node index in vect_nodes_.
int SimplexId
Identifier type for simplices of any dimension.
std::map< ttk::ftr::idVertex, vtkIdType > points
void setPointInfo(const ttk::ftr::Graph &ttkNotUsed(graph), const ttk::ftr::idSuperArc ttkNotUsed(a), const vtkIdType skeletonVert, bool r=false)
void addArrays(vtkUnstructuredGrid *arcs, ttk::ftr::Params ttkNotUsed(params))
void setArcInfo(const ttk::ftr::Graph &graph, const ttk::ftr::idSuperArc a, const vtkIdType skeletonCell)
void addNode(const ttk::ftr::Graph &graph, const ttk::ftr::idNode n, const double scalar)
void addArrays(vtkPointData *pointData, ttk::ftr::Params ttkNotUsed(params))
void setVertexInfo(const ttk::ftr::Graph &graph, const ttk::ftr::idVertex v)
void addArrays(vtkDataSet *segmentation, ttk::ftr::Params ttkNotUsed(params))
#define ttkVtkTemplateMacro(dataType, triangulationType, call)
vtkStandardNewMacro(ttkReebGraph)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)