Polygon Mesh Processing
1. Polygon Mesh Processing overview
The Polygon Mesh Processing [PMP] module offers a variety of tools for manipulating and analyzing polygonal meshes.
-
Key functionalities include:
-
Boolean Operations: Perform operations like union, intersection, and difference on meshes.
-
Mesh Smoothing: Techniques to smooth the surface of meshes.
-
Mesh Simplification: Reduce the complexity of meshes while preserving their essential shape and features.
-
Mesh Repair: Tools to detect and fix defects in meshes, such as holes or self-intersections.
-
Feature Detection: Identify and process features like edges and corners.
-
Subdivision Methods: Refine meshes by subdividing their faces.
-
-
Application:
-
Extrusion: Create base and interior walls
-
Union: Merge without break between floors and walls
-
Quality Check: triangulated faces, closed mesh, outward oriented mesh, self_intersection check
-
2. extrude_mesh Function in CGAL
The extrude_mesh
function is used to create a 3D extrusion from a 2D polygonal mesh.
This process extends the input mesh along its normal vectors to generate walls or other 3D structures.
Below is an overview of its functionality and parameters:
2.1. Function Overview
The extrude_mesh
function transforms a 2D polygonal mesh into a 3D mesh by extruding it along specified directions. This is commonly used to create volumetric elements from 2D shapes, such as converting floor plans into walls.
2.2. Key Parameters
-
Input Mesh: The 2D mesh that will be extruded.
-
Output Mesh: The resulting 3D mesh after extrusion.
-
Bottom Function Object: A callable object or lambda function that specifies how to position the vertices of the bottom face of the extrusion. This function typically moves the vertices along their normal vectors by a given distance.
-
Top Function Object: A callable object or lambda function that specifies how to position the vertices of the top face of the extrusion. This usually involves translating the vertices in a direction defined by the
Top
function object.
2.3. Function Behavior
-
Vertex Normal Calculation: Computes the normal vectors for each vertex in the mesh. These normals are used to determine the direction and magnitude of the extrusion.
-
Vertex Positioning:
-
Bottom Face: Moves the vertices of the bottom face of the input mesh according to the
Bottom
function object, typically by translating them along their normal vectors. -
Top Face: Moves the vertices of the top face based on the
Top
function object, often by applying a transformation defined by theTop
function object.
-
-
Mesh Construction: Constructs the extruded mesh by connecting corresponding vertices of the bottom and top faces, resulting in a 3D representation of the original 2D mesh.
2.4. Usage Example
Here is a basic example of using the extrude_mesh
function:
#include <CGAL/Surface_mesh.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/extrude.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef K::Vector_3 Vector;
Mesh input_mesh; // Initialize with your 2D mesh
Mesh output_mesh; // Mesh to store the extruded result
auto bottom_func = [](const auto& vin, const auto& vout) {
// Define how to move the bottom vertices
};
auto top_func = [](const auto& vin, const auto& vout) {
// Define how to move the top vertices
};
CGAL::Polygon_mesh_processing::extrude_mesh(input_mesh, output_mesh, bottom_func, top_func);
Important Considerations:
-
Ensure that the input mesh is well-defined and free of intersecting faces or other issues that might affect the extrusion process.
-
Customize the
Bottom
andTop
function objects to meet the specific requirements of your application and desired extrusion parameters.