Difference between revisions of "Realistic 3D models"

From Medusa: Coordinate Free Mehless Method implementation
Jump to: navigation, search
Line 1: Line 1:
 
Medusa is not meant to deal with complex 3D geometry - we support balls, cuboids, and their differences, unions, translations and rotations. More general 2D shapes can be described by polygons, which are also included in Medusa. For more general 3D objects, the geometric algorithms become more complex and it makes sense to leverage third-party libraries. A good library in c++ is CGAL ([https://www.cgal.org/]), that we can use to work with polyhedrons: [https://doc.cgal.org/latest/Polyhedron/index.html https://doc.cgal.org/latest/Polyhedron/index.html]
 
Medusa is not meant to deal with complex 3D geometry - we support balls, cuboids, and their differences, unions, translations and rotations. More general 2D shapes can be described by polygons, which are also included in Medusa. For more general 3D objects, the geometric algorithms become more complex and it makes sense to leverage third-party libraries. A good library in c++ is CGAL ([https://www.cgal.org/]), that we can use to work with polyhedrons: [https://doc.cgal.org/latest/Polyhedron/index.html https://doc.cgal.org/latest/Polyhedron/index.html]
 +
CGAL can usually be installed with <code>apt-get install libcgal-dev</code> or similar. The Qt dependency is not necessary, but can be useful for easier visualization without exporting to an external program.
  
Polyhedrons are solid bodies with polygonal faces, and their surface forms a closed mesh. CGAL can work also with surfaces meshes that are not closed, but for PDE solving in 3D bodies, we assume them to be closed (or watertight). Polyhedron data is usually stored in a separate file with many different formats available. Some of the formats actually store the polyhedron data (including how faces are connected) and some only store the faces. By default, CGAL reads .off [https://en.wikipedia.org/wiki/OFF_(file_format)] files.
+
Polyhedrons are solid bodies with polygonal faces, and their surface forms a closed mesh. CGAL can work also with surfaces meshes that are not closed, but for PDE solving in 3D bodies, we assume them to be closed (or watertight). Polyhedron data is usually stored in a separate file with many different formats available. Some of the formats actually store the polyhedron data (including how faces are connected) and some only store the faces. By default, CGAL reads OFF files. [https://en.wikipedia.org/wiki/OFF_(file_format)]  
 +
 
 +
Other formats include STL, PLY and OBJ. Some of these formats are more appropriate than others. Notably STL, while very common, can be problematic, as it does not include connections between faces, bit only a list of triangles, from which the polyhedron must first be reconstructed. This can be done directly in CGAL by using <code>CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh</code>, through an intermediate program, like Meshlab https://www.meshlab.net/, or through an online converter, such as https://cadcook.com/ply-off/. Note that it is not necessary that any of these conversions work, since STL file can represent an object with holes in the surface mesh or other degenerated objects.
 +
PLY files on the other hand do represent surface meshes, and can be read in CGAL (or easily converted to OFF) [https://cadcook.com/ply-off]. CGAL includes readers and writers for OFF, PLY and STL formats [https://github.com/CGAL/cgal/tree/master/Polyhedron_IO/include/CGAL/IO], and the default <code>cin >> </code> operator expects an OFF file.
 +
 
 +
PLY, OFF and STL files can also be read with Matlab, but require (short) external functions, available at [https://www.mathworks.com/matlabcentral/fileexchange/46540-geometry-processing-package], see Funciton/IO. These return a list of vertices and faces, that can be plotted with <code>patch</code> or <code>trisurf</code> after constructing the triangulation.

Revision as of 16:41, 9 November 2020

Medusa is not meant to deal with complex 3D geometry - we support balls, cuboids, and their differences, unions, translations and rotations. More general 2D shapes can be described by polygons, which are also included in Medusa. For more general 3D objects, the geometric algorithms become more complex and it makes sense to leverage third-party libraries. A good library in c++ is CGAL ([1]), that we can use to work with polyhedrons: https://doc.cgal.org/latest/Polyhedron/index.html CGAL can usually be installed with apt-get install libcgal-dev or similar. The Qt dependency is not necessary, but can be useful for easier visualization without exporting to an external program.

Polyhedrons are solid bodies with polygonal faces, and their surface forms a closed mesh. CGAL can work also with surfaces meshes that are not closed, but for PDE solving in 3D bodies, we assume them to be closed (or watertight). Polyhedron data is usually stored in a separate file with many different formats available. Some of the formats actually store the polyhedron data (including how faces are connected) and some only store the faces. By default, CGAL reads OFF files. [2]

Other formats include STL, PLY and OBJ. Some of these formats are more appropriate than others. Notably STL, while very common, can be problematic, as it does not include connections between faces, bit only a list of triangles, from which the polyhedron must first be reconstructed. This can be done directly in CGAL by using CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh, through an intermediate program, like Meshlab https://www.meshlab.net/, or through an online converter, such as https://cadcook.com/ply-off/. Note that it is not necessary that any of these conversions work, since STL file can represent an object with holes in the surface mesh or other degenerated objects. PLY files on the other hand do represent surface meshes, and can be read in CGAL (or easily converted to OFF) [3]. CGAL includes readers and writers for OFF, PLY and STL formats [4], and the default cin >> operator expects an OFF file.

PLY, OFF and STL files can also be read with Matlab, but require (short) external functions, available at [5], see Funciton/IO. These return a list of vertices and faces, that can be plotted with patch or trisurf after constructing the triangulation.