/bunny_mesh_normals

C++ challenge to compute normalised normals and normalised vertex of a triangular mesh. Data is read in the Numpy format and converted to Eigen matrixes.

Primary LanguageC++MIT LicenseMIT

Bunny Mesh Normals

Ladies and gentlemen, I would like to introduce you the famous Stanford Bunny Triangle Mesh. If you would like to get to know him better, Georgia Tech provides an overview of his history and Stanford shares his data source and many other 3D models.

The Challenge

Given the mesh data of the Stanford bunny, saved in the numpy format, the challenge is to develop a C++ program that computes:

1 - Normalized normals at each face of the object;

2 - Normalized normals at each vertex of the object.

Dependencies

External Libraries

  • CNPY: IO operations between numpy files and C/C++ data structures.

  • Google Tests (Gtest): Basic testing functionalities. The CMake and Gtest integration was based on the gtest-demo repository.

Usage

In order to perform the basic interface with the bunny-mesh project, you may use the helping bash scripts of the folder scripts. Their names are mostly self explanatory.

In order to generate the CMake files:

bash scripts/cmake.sh

In order to build and compile:

bash scripts/build.sh

Finally you may run the project:

bash scripts/run_bunny_mesh_normals.sh
  • Other commands:

To remove the build folder:

bash scripts/clean.sh

To run unit tests:

bash scripts/run_tests.sh

References

Information sources that were quite useful to understand and perform the triagular mesh operations:

Project Structure

The project structure is based on An Introduction to Modern CMake. Some adjustments would also be interesting, such as downloading the external dependency CNPY from a CMake file.

.
├── CMakeLists.txt
├── LICENSE
├── README.md
├── app
│   ├── CMakeLists.txt
│   └── main.cc
├── cmake
│   ├── googletest-download.cmake
│   └── googletest.cmake
├── data
│   ├── bunny_faces.npy
│   ├── bunny_vertices.npy
│   ├── face_normals.npy
│   └── vertex_normals.npy
├── extern
│   └── cnpy
│       ├── CMakeLists.txt
│       ├── LICENSE
│       ├── README.md
│       ├── cnpy.cpp
│       ├── cnpy.h
│       ├── example1.cpp
│       ├── mat2npz
│       ├── npy2mat
│       └── npz2mat
├── include
│   └── bunny_mesh
│       ├── Mesh.h
│       └── data_io.h
├── python
│   └── visualize_mesh.py
├── scripts
│   ├── build.sh
│   ├── clean.sh
│   ├── cmake.sh
│   ├── run_bunny_mesh_normals.sh
│   └── run_tests.sh
├── src
│   ├── CMakeLists.txt
│   └── Mesh.cc
└── test
    ├── CMakeLists.txt
    ├── data
    │   ├── sequential_double.npy
    │   └── sequential_int.npy
    ├── test_IO.cc
    └── test_Mesh.cc