Assignment 1-resit

Triangulating the faces of a polyhedron (with semantics)

Deadline is 21 June 2024 at 09:00 am

Late submission? 10% will be removed for each day that you are late.

This is an individual assignment.

The assignment is worth 10% of your final mark.

cover



Overview

For this assignment you will implement a method to triangulate the faces of a polyhedron by performing a constrained triangulation in CGAL. This method should support faces with holes (also known as inner rings) and should export semantics through materials. It will involve the following steps:

  1. read the input polyhedron from a CityJSON file and load it into an appropriate data structure;
  2. for each face of the polyhedron, compute its best-fitting plane;
  3. for each face of the polyhedron, create a constrained triangulation containing all of its the edges as constraints projected to 2D using the best-fitting plane;
  4. for each face of the polyhedron, label its triangulation using the odd-even rule;
  5. for each face of the polyhedron, extract its triangulated interior back in 3D using the best-fitting plane;
  6. output all the faces of the triangulation to an OBJ file with materials in an MTL file.

You will hand in the program and the output triangulated OBJ file. You should also write a simple report.

What you are given

The file that you have to triangulate is the station building in the LoD3_Railway.city.json file from the CityJSON datasets website. The building has the ID GMLID_BUI184698_512_898. In that same file, you can see a couple more buildings that you can use to test your code. You can use the sample code that was provided for Homeworks 1 and 2, and you can use the image at the top of this page as an idea for how your output (with materials) should look.

This assignment needs to be implemented in C++. You can use any functions in the C++ standard library. From CGAL, you are only allowed to use functions in the packages 2D/3D Kernel, 2D Triangulations and Principal Component Analysis. In order to read the CityJSON file, you are allowed to use Niels Lohmann’s JSON for Modern C++ library.

The OBJ file format

If you’re not familiar with it, see this Wikipedia article. You can use MeshLab or Blender to visualise OBJ files. Some Windows versions and all recent macOS versions come with OBJ viewers, but these aren’t as good as MeshLab.

Some tips

Test your code with different OBJ files. Develop it using a simple example and move on to increasingly complex ones.

How do I compute a best fitting plane? See this.

How to I project to 2D using this plane? See the to_2d function of CGAL’s Plane_3 here. For the opposite operation, check to_3d too.

How to I insert constraints in the triangulation? See the Constrained_triangulation_2 documentation.

How do I label the triangulation? Starting from a Face_handle f, you can label it with something like f->info().processed = true. For labelling the whole triangulation of a face, see this from CGAL’s Triangulation_2 examples or this function from my code.

Odd-even rule?

Once you have triangulated a polygon, start from a triangle known to be outside the polygon and label it as part of the exterior. For this, you can use the triangulation’s infinite face. Starting from that triangle, the triangles that you can reach by passing through an odd number of constraints are part of the interior and those you can reach by passing through an even number of constraints are part of the exterior.

Marking

In order to mark your assignment, I will run your code to ensure that is capable of producing the same station.obj output that you submitted and will then evaluate your results by viewing your submitted station.obj file.

Criterion Points
code runs without modifications 2
quality of the station.obj file 4
report 4

Here, quality defined as the geometry and semantics being correctly generated: no arfefacts, no weird/sliver/intersecting triangles, windows/doors visible in the triangulation, etc.

What to submit and how to submit it

You have to submit a ZIP file (or another compressed format) with the following files:

  1. your code (everything that is needed to run/compile it).
  2. a README that very briefly explains how to run/use your program, including what I need to do in order to set the path to the CityJSON file in my computer.
  3. station.obj with your triangulated output.
  4. the .mtl file with the material definitions used in your OBJ file.
  5. a very short (maximum 3 page) report in PDF that briefly explains what you did, how to run/use your program (including what I need to do in order to set the paths to the input and output OBJ files in my computer), and a few screenshots of your OBJ files.

Do not submit your assignment by email, but use this Dropbox link.

[last updated: 2024-04-16 16:32]