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]) {
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 nextCellId = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
113 vtkUnstructuredGrid *skeletonArcs,
119#ifndef TTK_ENABLE_KAMIKAZE
120 if(upNodeId == nullNode || downNodeId == nullNode) {
130 vtkIdType pointIds[2];
131 if(arcData.
points.count(downVertId)) {
132 pointIds[0] = arcData.
points[downVertId];
135 downVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
136 pointIds[0] = points->InsertNextPoint(pointCoord);
137 arcData.
points.emplace(downVertId, pointIds[0]);
140 if(arcData.
points.count(upVertId)) {
141 pointIds[1] = arcData.
points[upVertId];
144 upVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
145 pointIds[1] = points->InsertNextPoint(pointCoord);
146 arcData.
points.emplace(upVertId, pointIds[1]);
149 vtkIdType nextCellId = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
159 vtkUnstructuredGrid *skeletonArcs,
166 const double scalarMin
168 const double scalarMax
170 const double delta = (scalarMax - scalarMin) / (params_.
samplingLvl + 1);
172#ifndef TTK_ENABLE_KAMIKAZE
173 if(upNodeId == nullNode || downNodeId == nullNode) {
182 vtkIdType pointIds[2];
183 if(arcData.
points.count(downVertId)) {
184 pointIds[0] = arcData.
points[downVertId];
187 downVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
188 pointIds[0] = points->InsertNextPoint(pointCoord);
189 arcData.
points.emplace(downVertId, pointIds[0]);
195 double scalarLimit = scalarMin + delta;
200 if(regV == downVertId || regV == upVertId)
204 regV, pointCoord[0], pointCoord[1], pointCoord[2]);
205 const double scalar = inputScalars_->GetTuple1(regV);
206 if(scalar < scalarLimit) {
207 sum[0] += pointCoord[0];
208 sum[1] += pointCoord[1];
209 sum[2] += pointCoord[2];
219 pointIds[1] = points->InsertNextPoint(sum);
220 arcData.
points.emplace(regV, pointIds[1]);
223 if(pointIds[0] != pointIds[1]) {
225 = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
229 pointIds[0] = pointIds[1];
233 scalarLimit += delta;
241 if(arcData.
points.count(upVertId)) {
242 pointIds[1] = arcData.
points[upVertId];
245 upVertId, pointCoord[0], pointCoord[1], pointCoord[2]);
246 pointIds[1] = points->InsertNextPoint(pointCoord);
247 arcData.
points.emplace(upVertId, pointIds[1]);
250 if(pointIds[0] != pointIds[1]) {
251 vtkIdType nextCellId = skeletonArcs->InsertNextCell(VTK_LINE, 2, pointIds);
258template <
typename VTK_TT,
typename TTK_TT>
261 static_cast<TTK_TT *
>(triangulation_->
getData()));
272 this->
printMsg(
"Starting computation on field: "
273 + std::string{inputScalars_->GetName()});
282 vtkInformationVector **inputVector,
283 vtkInformationVector *outputVector) {
286 mesh_ = vtkDataSet::GetData(inputVector[0]);
289 auto outputSkeletonNodes = vtkUnstructuredGrid::GetData(outputVector, 0);
290 auto outputSkeletonArcs = vtkUnstructuredGrid::GetData(outputVector, 1);
291 auto outputSegmentation = vtkDataSet::GetData(outputVector, 2);
297#ifndef TTK_ENABLE_KAMIKAZE
298 if(!triangulation_) {
299 this->
printErr(
"ttkTriangulation::getTriangulation() is null.");
302 if(triangulation_->
isEmpty()) {
304 "ttkTriangulation on connected component allocation problem.");
314 inputScalars_ = this->GetInputArrayToProcess(0, inputVector);
315 if(inputScalars_ ==
nullptr) {
316 this->
printErr(
"input scalar field pointer is null.");
320 offsets_ = this->
GetOrderArray(mesh_, 0, 1, ForceInputOffsetScalarField);
324 (dispatch<VTK_TT, TTK_TT>(graph)));
326 UpdateProgress(0.50);
330#ifndef TTK_ENABLE_KAMIKAZE
331 this->
printErr(
"wrong properties on skeleton nodes.");
337#ifndef TTK_ENABLE_KAMIKAZE
338 this->
printErr(
"wrong properties on skeleton arcs.");
344#ifndef TTK_ENABLE_KAMIKAZE
345 this->
printErr(
"wrong properties on segmentation.");
356 vtkDataSet *outputSegmentation) {
357 outputSegmentation->ShallowCopy(mesh_);
359 const idVertex numberOfVertices = mesh_->GetNumberOfPoints();
363 for(
idVertex v = 0; v < numberOfVertices; ++v) {
367 vertData.
addArrays(outputSegmentation, params_);
373 vtkUnstructuredGrid *outputSkeletonArcs) {
391 vtkNew<vtkUnstructuredGrid> arcs{};
392 vtkNew<vtkPoints> points{};
394 for(
idSuperArc arcId = 0; arcId < nbArcs; ++arcId) {
411 arcs->SetPoints(points);
413 outputSkeletonArcs->ShallowCopy(arcs);
419 vtkUnstructuredGrid *outputSkeletonNodes) {
423 vtkNew<vtkUnstructuredGrid> nodes{};
424 vtkNew<vtkPoints> points{};
426 for(
idNode nodeId = 0; nodeId < nbNodes; nodeId++) {
430 triangulation_->
getVertexPoint(vertId, point[0], point[1], point[2]);
431 points->InsertNextPoint(point);
433 double scalar = inputScalars_->GetTuple1(vertId);
434 nodeData.
addNode(graph, nodeId, scalar);
438 nodeData.
addArrays(nodes->GetPointData(), params_);
440 outputSkeletonNodes->ShallowCopy(nodes);
448 vtkNew<vtkIntArray> identifiers{};
449 const vtkIdType nbPoints = ds->GetNumberOfPoints();
450 identifiers->SetName(
"VertexIdentifier");
451 identifiers->SetNumberOfComponents(1);
452 identifiers->SetNumberOfTuples(nbPoints);
454 for(
int i = 0; i < nbPoints; i++) {
455 identifiers->SetTuple1(i, i);
458 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()
vtkDataArray * GetOrderArray(vtkDataSet *const inputData, const int scalarArrayIdx, const int orderArrayIdx=0, const bool enforceOrderArrayIdx=false)
ttk::Triangulation * GetTriangulation(vtkDataSet *dataSet)
TTK VTK-filter for the computation of Reeb Graphs.
int FillInputPortInformation(int port, vtkInformation *info) override
int addDirectSkeletonArc(const ttk::ftr::Graph &graph, const ttk::ftr::idSuperArc arcId, vtkPoints *points, vtkUnstructuredGrid *skeletonArcs, ttk::ftr::ArcData &arcData)
int FillOutputPortInformation(int port, vtkInformation *info) override
int getSkeletonNodes(const ttk::ftr::Graph &graph, vtkUnstructuredGrid *outputSkeletonNodes)
bool GetWithSegmentation() const
void identify(vtkDataSet *ds) const
int getSegmentation(const ttk::ftr::Graph &graph, vtkDataSet *outputSegmentation)
int getSkeletonArcs(const ttk::ftr::Graph &graph, vtkUnstructuredGrid *outputSkeletonArcs)
int addSampledSkeletonArc(const ttk::ftr::Graph &graph, const ttk::ftr::idSuperArc arcId, vtkPoints *points, vtkUnstructuredGrid *skeletonArcs, ttk::ftr::ArcData &arcData)
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
int dispatch(ttk::ftr::Graph &graph)
int addCompleteSkeletonArc(const ttk::ftr::Graph &graph, const ttk::ftr::idSuperArc arcId, vtkPoints *points, vtkUnstructuredGrid *skeletonArcs, ttk::ftr::ArcData &arcData)
static void * GetVoidPointer(vtkDataArray *array, vtkIdType start=0)
static int CellVertexFromPoints(vtkDataSet *const dataSet, vtkPoints *const points)
void setDebugMsgPrefix(const std::string &prefix)
int printMsg(const std::string &msg, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
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))
vtkStandardNewMacro(ttkFTRGraph)
#define ttkVtkTemplateMacro(dataType, triangulationType, call)