Skip to content
Snippets Groups Projects
Commit 88d225e4 authored by Astrid Beyer's avatar Astrid Beyer
Browse files

readme: fichier pour la librairie

parent 4941356e
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,9 @@ $ sudo apt install ./ttk-1.1.0-ubuntu-22.04.deb ...@@ -28,6 +28,9 @@ $ sudo apt install ./ttk-1.1.0-ubuntu-22.04.deb
## Modifications à apporter à la librairie ## Modifications à apporter à la librairie
Ces modifications doivent être faites sur les fichiers situés dans `usr/include/ttk/vtk/`. Ces modifications doivent être faites sur les fichiers situés dans `usr/include/ttk/vtk/`.
### Modifications d'en-têtes
Dans le fichier d'en-tête **ttkContourForests.h**, modifier les lignes 54 à 56 pour remplacer les guillemets par des chevrons : Dans le fichier d'en-tête **ttkContourForests.h**, modifier les lignes 54 à 56 pour remplacer les guillemets par des chevrons :
``` ```
...@@ -46,10 +49,189 @@ Se rendre ensuite dans le fichier d'en-tête **ttkFTRGraph.h** et modifier les l ...@@ -46,10 +49,189 @@ Se rendre ensuite dans le fichier d'en-tête **ttkFTRGraph.h** et modifier les l
#include <ttkFTRGraphStructures.h> #include <ttkFTRGraphStructures.h>
``` ```
### Fichiers à ajouter
<details> <details>
<summary markdown="span">Enfin, créer le fichier **ttkFTRGraph.h** :</summary> <summary markdown="span">Créer le fichier <b>ttkFTRGraphStructures.h</b> :</summary>
```c++
#pragma once
#include <vtkCellData.h>
#include <vtkCharArray.h>
#include <vtkDataSet.h>
#include <vtkDoubleArray.h>
#include <vtkIntArray.h>
#include <vtkNew.h>
#include <vtkPointData.h>
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
#include <FTRCommon.h>
#include <FTRDataTypes.h>
#include <Graph.h>
namespace ttk {
namespace ftr {
/// Vertex / Node / Arc data inherit from this
/// master structure.
struct ObjectData {
inline void allocArray(vtkDataArray *const arr,
const char *fieldName,
size_t nbElmnt) {
arr->SetName(fieldName);
arr->SetNumberOfComponents(1);
arr->SetNumberOfTuples(nbElmnt);
#ifndef TTK_ENABLE_KAMIKAZE
if(!arr) {
Debug dbg{};
dbg.setDebugMsgPrefix("FTRGraph");
dbg.printErr("unable to allocate " + std::string{fieldName}
+ " the program will likely crash");
}
#endif
}
};
struct NodeData : public ObjectData {
vtkNew<vtkIntArray> ids{};
vtkNew<vtkIntArray> types{};
vtkNew<vtkDoubleArray> scalars{};
explicit NodeData(const ttk::ftr::idVertex nbNodes) {
allocArray(ids, "VertexId", nbNodes);
allocArray(types, "CriticalType", nbNodes);
allocArray(scalars, "Scalar", nbNodes);
}
void addNode(const ttk::ftr::Graph &graph,
const ttk::ftr::idNode n,
const double scalar) {
ids->SetTuple1(n, graph.getNode(n).getVertexIdentifier());
types->SetTuple1(n, (double)graph.getNode(n).getType());
scalars->SetTuple1(n, scalar);
}
void addArrays(vtkPointData *pointData,
ttk::ftr::Params ttkNotUsed(params)) {
pointData->AddArray(ids);
pointData->SetScalars(types);
pointData->AddArray(scalars);
}
};
struct ArcData : public ObjectData {
vtkNew<vtkIntArray> ids{};
vtkNew<vtkCharArray> reg{};
#ifndef NDEBUG
vtkNew<vtkUnsignedCharArray> fromUp{};
#endif
std::map<ttk::ftr::idVertex, vtkIdType> points;
ArcData(const ttk::ftr::idSuperArc nbArcs) {
allocArray(ids, "ArcId", nbArcs);
allocArray(reg, ttk::MaskScalarFieldName, nbArcs * 2);
#ifndef NDEBUG
allocArray(fromUp, "growUp", nbArcs);
#endif
}
void setPointInfo(const ttk::ftr::Graph &ttkNotUsed(graph),
const ttk::ftr::idSuperArc ttkNotUsed(a),
const vtkIdType skeletonVert,
bool r = false) {
reg->SetTuple1(skeletonVert, r);
}
void setArcInfo(const ttk::ftr::Graph &graph,
const ttk::ftr::idSuperArc a,
const vtkIdType skeletonCell) {
ids->SetTuple1(skeletonCell, a);
#ifndef NDEBUG
fromUp->SetTuple1(skeletonCell, graph.getArc(a).getFromUp());
#else
TTK_FORCE_USE(graph);
#endif
}
void addArrays(vtkUnstructuredGrid *arcs,
ttk::ftr::Params ttkNotUsed(params)) {
// original size may be too large
ids->SetNumberOfTuples(arcs->GetNumberOfCells());
arcs->GetCellData()->SetScalars(ids);
reg->SetNumberOfTuples(arcs->GetNumberOfPoints());
arcs->GetPointData()->AddArray(reg);
#ifndef NDEBUG
fromUp->SetNumberOfTuples(arcs->GetNumberOfCells());
arcs->GetCellData()->AddArray(fromUp);
#endif
}
};
struct VertData : public ObjectData {
vtkNew<vtkIntArray> ids{};
vtkNew<vtkIntArray> regionType{};
#ifdef TTK_ENABLE_FTR_VERT_STATS
vtkNew<vtkIntArray> touch{};
vtkNew<vtkIntArray> arcActif{};
vtkNew<vtkIntArray> taskActif{};
#endif
explicit VertData(const ttk::ftr::idVertex nbVertices) {
allocArray(ids, "ArcId", nbVertices);
allocArray(regionType, "RegionType", nbVertices);
#ifdef TTK_ENABLE_FTR_VERT_STATS
allocArray(touch, "Visit", nbVertices);
allocArray(arcActif, "Arc active", nbVertices);
#endif
}
void setVertexInfo(const ttk::ftr::Graph &graph,
const ttk::ftr::idVertex v) {
if(!graph.isVisited(v)) {
// Problem, we should have visited all vertices
// return to avoid crash
return;
}
const ttk::ftr::idSuperArc curArcId = graph.getArcId(v);
ids->SetTuple1(v, curArcId);
int downNodeType
= (int)graph.getNode(graph.getArc(curArcId).getDownNodeId())
.getType();
regionType->SetTuple1(v, downNodeType);
#ifdef TTK_ENABLE_FTR_VERT_STATS
touch->SetTuple1(v, graph.getNbTouch(v));
arcActif->SetTuple1(v, graph.getNbArcActive(v));
#endif
}
void addArrays(vtkDataSet *segmentation,
ttk::ftr::Params ttkNotUsed(params)) {
segmentation->GetPointData()->AddArray(ids);
segmentation->GetPointData()->SetActiveScalars(ids->GetName());
segmentation->GetPointData()->AddArray(regionType);
#ifdef TTK_ENABLE_FTR_VERT_STATS
segmentation->GetPointData()->AddArray(touch);
segmentation->GetPointData()->AddArray(arcActif);
#endif
}
};
}; // namespace ftr
}; // namespace ttk
``` ```
</details>
<details>
<summary markdown="span">Enfin, créer le fichier <b>ttkFTRGraph.h</b> :</summary>
```c++
/// \ingroup vtk /// \ingroup vtk
/// \class ttkFTRGraph /// \class ttkFTRGraph
/// \author Charles Gueunet <charles.gueunet@kitware.com> /// \author Charles Gueunet <charles.gueunet@kitware.com>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment