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

initial commit

parent a6506163
No related branches found
No related tags found
No related merge requests found
build/
cmake_minimum_required(VERSION 3.8)
# name of the project
project(projet-stage)
set(CMAKE_CXX_STANDARD 11)
find_package(TTKVTK REQUIRED)
add_executable(projet-stage main.cpp)
target_link_libraries(projet-stage
PUBLIC
ttk::vtk::ttkAll
PRIVATE ${VTK_LIBRARIES}
)
# vtk_module_autoinit is needed
vtk_module_autoinit(
TARGETS projet-stage
MODULES ${VTK_LIBRARIES}
)
# extraction_informations_forme_3D
# Extraction d’information dans les formes 3D à partir de graphes de Reeb et d’un indice de forme spécifique, avec la librairie TTK
## Sujet
TTK (Topological Toolkit) est une librairie très puissante en ce qui concerne l’analyse de données topologiques. Il est par exemple aisé de calculer des graphes de Reeb d’une forme, en utilisant tous types de fonctions scalaires qui va “traverser” l’objet.
Dans ce projet, il sera question de poursuivre des travaux élaborés dans l’équipe G-Mod concernant l’analyse d’objets 3D par graphes de Reeb. La librairie TTK sera utilisée pour le calcul des graphes de Reeb, et nous utiliserons la fonction Shape Index [Koenderink et al. 1992]. Cet indice de forme fournit une représentation intrinsèque des caractéristiques géométriques locales de la surface 3D (forme convexe, concave, ornière, crête, selle, etc.) à partir des courbures principales. De plus, il est invariant à l’échelle, à la rotation et aux translations. Ce descripteur propose un bon score pour retrouver des surfaces similaires.
Sur la base des graphes de Reeb produits, le projet pourra se poursuivre par :
- La détection de similarité et de symétries au sein d’un maillage ;
- La segmentation d’objets ;
- La classification d’objets ;
- La simplification de formes.
## Environnements
- TTK : Topological Toolkit https://topology-tool-kit.github.io/
- Paraview
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
## Installer la librairie TTK
Avec Ubuntu :
[https://topology-tool-kit.github.io/downloads.html](Récupérer ici) la librairie TTK. Ce projet est sous la version Ubuntu Linux 22.04.
```
cd existing_repo
git remote add origin https://gitlab.lis-lab.fr/astrid.beyer/extraction_informations_forme_3d.git
git branch -M main
git push -uf origin main
$ sudo apt install ./ttk-1.1.0-ubuntu-22.04.deb
$ sudo apt install ./ttk-paraview-v5.10.1-ubuntu-22.04.deb
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.lis-lab.fr/astrid.beyer/extraction_informations_forme_3d/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Comment tester le projet
### Création du répertoire build
```
mkdir build
cd build
cmake ../
make
```
### Lancement du projet avec un objet
```
./nom_projet ../obj/cowhead.obj
paraview ShapeIndexMap.vtp
```
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
Cette dernière commande va lancer le programme ParaView avec l'objet donné.
Une fois dans le logiciel, penser à check l'icône avec l'œil fermé à côté de ShapeIndexMap.vtp dans la fenêtre Pipeline Browser afin d'afficher le résultat.
Modifier dans la fenêtre Properties la valeur du menu déroulant sous Coloring par Shape_Index (indice de forme). Enfin, dans le menu Color Map Editor à droite, cliquer sous Mapping Data pour sélectionner la color map nommée Turbo.
## License
For open source projects, say how it is licensed.
## Références
- Florian Beguet. Modélisation et description par graphes pour des formes géométriques complexes. Thèse de doctorat, Aix-Marseille Université, 2021.
- Jan J. Koenderink et Andrea J. Van Doorn. « Surface shape and curvature scales ». Image and vision computing, 10.8, p. 557-564, 1992.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
### Auteurs
Un sujet proposé par Jean-Luc MARI
Lucie CLERAND et Eve REGA (PFE Master 2 Informatique)
Astrid BEYER (avril 2023 - juin 2023)
main.cpp 0 → 100644
#include <vtkNew.h>
#include <vtkSmartPointer.h>
#include <vtkOBJReader.h>
#include <ttkOFFReader.h>
#include <vtksys/SystemTools.hxx>
#include <vtkPolyData.h>
#include <vtkCurvatures.h>
#include <vtkPointData.h>
#include <vtkCleanPolyData.h>
#include <vtkDoubleArray.h>
#include <vtkIdFilter.h>
#include <ttkFTRGraph.h>
#include <vtkXMLPolyDataWriter.h>
#include <vtkXMLUnstructuredGridWriter.h>
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkNamedColors.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <cassert>
#include <iostream>
#include <cmath>
#include <ttkIcospheresFromPoints.h>
#include <vtkTubeFilter.h>
#include <vtkExtractSurface.h>
#include <ttkGeometrySmoother.h>
#include <vtkDataSetSurfaceFilter.h>
#include <ttkUtils.h>
#include <vtkThresholdPoints.h>
#include <vtkAppendPolyData.h>
#include <vtkSortDataArray.h>
int main(int argc, char* argv[]) {
if (argc != 2)
{
std::cout << "Required arguments: Filename(.obj)" << std::endl;
return EXIT_FAILURE;
}
// Read the input file
std::string filename = argv[1];
vtkSmartPointer<vtkPolyData> source;
std::string extension = vtksys::SystemTools::GetFilenameLastExtension(filename);
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
if(extension == ".obj")
{
vtkNew<vtkOBJReader> reader;
reader->SetFileName(filename.c_str());
reader->Update();
source = reader->GetOutput();
}
else
{
std::cout << "Required arguments: Filename(.obj)" << std::endl;
return EXIT_FAILURE;
}
// Compute Max and Min curvature
vtkSmartPointer<vtkCurvatures> maxCurvaturesFilter = vtkSmartPointer<vtkCurvatures>::New();
maxCurvaturesFilter->SetInputData(source);
maxCurvaturesFilter->SetCurvatureTypeToMaximum(); // Set curvature type to maximum (k1)
maxCurvaturesFilter->Update();
auto k1 = maxCurvaturesFilter->GetOutput();
vtkSmartPointer<vtkCurvatures> minCurvaturesFilter = vtkSmartPointer<vtkCurvatures>::New();
minCurvaturesFilter->SetInputData(source);
minCurvaturesFilter->SetCurvatureTypeToMinimum(); // Set curvature type to minimum (k2)
minCurvaturesFilter->Update();
auto k2 = minCurvaturesFilter->GetOutput();
// Shape Index computation
k1->GetPointData()->SetActiveScalars("Maximum_Curvature");
auto k1Array = k1->GetPointData()->GetAbstractArray("Maximum_Curvature");
k2->GetPointData()->SetActiveScalars("Minimum_Curvature");
auto k2Array = k2->GetPointData()->GetAbstractArray("Minimum_Curvature");
vtkNew<vtkDoubleArray> shapeIndex;
shapeIndex->SetName("Shape_Index");
for (vtkIdType i = 0; i < k1->GetNumberOfPoints(); ++i)
{
double kmax = k1Array->GetVariantValue(i).ToDouble();
double kmin = k2Array->GetVariantValue(i).ToDouble();
if( kmax == kmin)
{
shapeIndex->InsertNextTuple1(0.5);
}
else
{
//double si = (2/M_PI)*atan((kmin+kmax)/(kmin-kmax)); //KOENDERIK ET VAN DOORN [-1,1]
double si = 0.5 - (1/M_PI)*atan((kmax+kmin)/(kmin-kmax)); // [0, 1]
shapeIndex->InsertNextTuple1(si);
}
}
source->GetPointData()->AddArray(shapeIndex);
source->GetPointData()->SetActiveScalars("Shape_Index");
/*
double pourcent = 0.8;
// Create a vtkThresholdPoints filter for each threshold value
vtkNew<vtkThresholdPoints> threshold1;
threshold1->SetInputData(source);
threshold1->ThresholdBetween(0.0, 0.0 + pourcent*0.25); // Scalar values near 0
threshold1->Update();
vtkNew<vtkThresholdPoints> threshold2;
threshold2->SetInputData(source);
threshold2->ThresholdBetween(0.5 - pourcent*0.25, 0.5 + pourcent*0.25); // Scalar values near 1
threshold2->Update();
vtkNew<vtkThresholdPoints> threshold3;
threshold3->SetInputData(source);
threshold3->ThresholdBetween(1.0 - pourcent*0.25, 1.0); // Scalar values near 1
threshold3->Update();
// Create a vtkFTRGraph for each thresholded dataset
vtkNew<ttkFTRGraph> graph1;
graph1->SetInputData(threshold1->GetOutput());
graph1->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Shape_Index");
graph1->Update();
vtkNew<ttkFTRGraph> graph2;
graph2->SetInputData(threshold2->GetOutput());
graph2->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Shape_Index");
graph2->Update();
vtkNew<ttkFTRGraph> graph3;
graph3->SetInputData(threshold3->GetOutput());
graph3->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Shape_Index");
graph3->Update();
// Merge the thresholded datasets together into a single polydata
vtkNew<vtkAppendPolyData> appendFilter;
appendFilter->AddInputData(threshold1->GetOutput());
appendFilter->AddInputData(threshold2->GetOutput());
appendFilter->AddInputData(threshold3->GetOutput());
appendFilter->Update();
*/
// Compute the Reeb Graph of the input dataset
vtkNew<ttkFTRGraph> reebGraph;
//reebGraph->SetInputData(appendFilter->GetOutput()); // ttkFTRGraph for the merged polydata
reebGraph->SetInputData(source);
reebGraph->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Shape_Index");
reebGraph->Update();
// Create Icospheres to represent nodes in the Reeb Graph
vtkNew<ttkIcospheresFromPoints> ttkIcospheresFromPoints{};
ttkIcospheresFromPoints->SetInputData(0, reebGraph->GetOutput());
ttkIcospheresFromPoints->SetRadius(0.008);
ttkIcospheresFromPoints->SetNumberOfSubdivisions(1);
ttkIcospheresFromPoints->Update();
// Filters dependencies with Tubes : applies smooth to the geometry of the Reeb Graph
vtkNew<ttkGeometrySmoother> ttkGeometrySmoother{};
ttkGeometrySmoother->SetInputConnection(reebGraph->GetOutputPort(1));
ttkGeometrySmoother->Update();
vtkNew<vtkGeometryFilter> geometryFilter{};
geometryFilter->SetInputConnection(ttkGeometrySmoother->GetOutputPort());
geometryFilter->Update();
vtkNew<vtkPolyData> polyData{};
polyData->ShallowCopy(geometryFilter->GetOutput());
// Create Tubes to represent edges in the Reeb Graph
vtkNew<vtkTubeFilter> tube{};
tube->SetInputData(polyData); //smoothed geometry of the Reeb graph
tube->SetRadius(0.004);
//tube->SetNumberOfSides(1);
tube->Update();
// Save the graph nodes with IcospheresFromPoints
vtkNew<vtkXMLPolyDataWriter> writerNodes{};
writerNodes->SetFileName("ReebGraphNodes.vtp");
writerNodes->SetInputData(ttkIcospheresFromPoints->GetOutput());
writerNodes->Write();
// Save the graph edges with Tubes
vtkNew<vtkXMLPolyDataWriter> writerArcs{};
writerArcs->SetFileName("ReebGraphArcs.vtp");
writerArcs->SetInputData(tube->GetOutput());
writerArcs->Write();
// Save the graph coloration
vtkNew<vtkXMLPolyDataWriter> segWriter{};
segWriter->SetFileName("ShapeIndexMap.vtp");
segWriter->SetInputConnection(reebGraph->GetOutputPort(2));
segWriter->Write();
/*
// Save the graph nodes (simple graph)
vtkNew<vtkXMLUnstructuredGridWriter> sWriter{};
sWriter->SetInputConnection(reebGraph->GetOutputPort(0));
sWriter->SetFileName("outputNodes.vtp");
sWriter->Write();
// Save the graph edges
vtkNew<vtkXMLUnstructuredGridWriter> sepWriter{};
sepWriter->SetInputConnection(reebGraph->GetOutputPort(1));
sepWriter->SetFileName("outputEdges.vtp");
sepWriter->Write();
// Save the graph coloration
vtkNew<vtkXMLPolyDataWriter> segWriter{};
segWriter->SetInputConnection(reebGraph->GetOutputPort(2));
segWriter->SetFileName("outputColor.vtp");
segWriter->Write();*/
return EXIT_SUCCESS;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment