MultipleBuilding Class Documentation
To create one or multiple buildings, you need to instantiate a MultipleBuilding
object.
This object is templated with a Kernel
and can be configured with three parameters: debug
, roof
, and Union
.After creating the MultipleBuilding
instance, you need to provide it with the data required for building creation.
For a GIS format json
file, use the loadFromJsonGis
method, and for a configuration json
file, use the loadFromJsonDat
method, more details about those file in the data section .
With the data in place, you can start the building creation process using the createBuilding
method to generate the surface mesh of each building and export it.
Once you have the surface mesh, call meshing3D
to create the volumetric mesh of the selected surface mesh.
1. Constructor
MultipleBuilding(bool M_debugMode = false, bool roofMode = true, bool unionMode = false);
Constructor for MultipleBuilding
class.
-
M_debugMode
- Enable debug mode if true. -
roofMode
- Enable roof generation if true. -
unionMode
- Enable union mode if true, this mode change the floor and roof merge by a CGAL union. ( Union will lose every Marker else than buildindId ) -
volumeMode
- Enable volume mode if true, this mode create volume mesh on every buiding if true.
2. data loading method
3. Building creation method
This section is about every method used to create the building. In this section every example executed with the following command
./src/applications/ktirio_geom_app_building_lod1 --si ../../data/buildinglod1/config_create_building.json --r --d
3.1. createBuilding
The createBuilding
method orchestrates the creation of a building by calling the following methods:
-
if roof option is used:
-
if volume option is used:
3.2. MultipleBuilding Methods
3.2.1. triangulateBasePolygon
void triangulateBasePolygon(size_t index)
This method uses polygonTriangulation
from algorithms.hpp
on the polygon
attribute and stores the result in baseMesh
.
-
index
- The index of the building in the polygons vector.
Base Polygon Before Triangulation |
Base Polygon After Triangulation |
3.2.2. extrudeBasePolygon
void extrudeBasePolygon(size_t index);
This method creates a TriangleRange
from each triangle of the baseMesh
and calls
the extrusion function from algorithms.hpp
with {0,0,building_height}
as the direction.
-
index
- The index of the building in the polygons vector.
Base Polygon Before Extrusion |
Base Polygon After Extrusion |
3.2.3. extrudeWalls
void extrudeWalls(size_t index);
This method uses the extrude_wall
function to convert a base mesh (baseMesh
) into an extruded wall mesh (wallMesh
) with a specified thickness.
The extrude_wall
function performs the following steps:
-
Mesh Conversion: Converts the input
baseMesh
to the CGALSurface_mesh
format. -
Normal Computation: Computes vertex normals for the mesh using CGAL’s
compute_vertex_normals
function to ensure accurate extrusion along the correct direction. -
Extrusion: Applies extrusion using the
extrude_mesh
function from CGAL’s Polygon Mesh Processing module. The extrusion is controlled by thewall_thickness
parameter, which determines the thickness of the walls. This parameter defaults to0.1
if not specified. -
Mesh Conversion Back: Converts the extruded CGAL mesh back to the mesh format and assigns markers to differentiate between exterior and interior walls. Markers are used for distinguishing wall types in the final mesh.
-
Marker Assignment: The function also ensures that markers from the original mesh (
baseMesh
) are copied to the new extruded mesh (wallMesh
). It checks for exact or approximate matches between triangles in the original and extruded meshes and assigns appropriate markers for external or internal walls.
Important Note: This function can create intersections between surfaces if the wall_thickness
is too high or if surfaces are too close to each other.
Adequate spacing between surfaces in the original mesh is essential to avoid unintended overlaps or errors in the final mesh.
-
index
- The index of the building in the polygons vector.
Walls Before Extrusion |
Walls After Extrusion |
3.2.4. addFloors
void addFloors(size_t index);
This method creates a copy of wallMesh
and merges the copy with wallMesh
, adding a translation to place the copy above the original wallMesh
.
-
index
- The index of the building in the polygons vector.
Floors Before Addition |
Floors After Addition |
3.2.5. generateRoof
void generateRoof(size_t index);
This method calls extrude_Straight_Skeleton
with polygon
as input,
roofMesh
as output, and optionally a weight file. It starts by converting polygonWithHoles
to a CGAL Polygon_with_holes_2
, then calls extrude_skeleton
from 2D Straight Skeleton and Polygon Offsetting
and places the result in the output mesh.
-
index
- The index of the building in the polygons vector.
Roof Before Generation |
Roof After Generation |
3.2.6. transformRoof
void transformRoof(size_t index);
This method adjusts close points that may be created by the straight skeleton extrusion and can modify the roof height.
-
index
- The index of the building in the polygons vector.
Roof Before Transformation |
Roof After Transformation (roof height = 1 ) |
Roof After Transformation (roof height = 5 ) |
3.3. extrudeRoofWalls
void extrudeRoofWalls(size_t index);
The extrudeRoofWalls
method calls the extrude_wall
function similarly to extrudeWalls
, but it operates on roofMesh
.
-
index
- The index of the building in the polygons vector.
Roof Walls Before Extrusion |
Roof Walls After Extrusion |
3.4. mergeWallRoof
void mergeWallRoof(size_t index);
The mergeWallRoof
method merges the wall mesh with the roof mesh using the Mesh merge method. If union
is true, it applies a union operation from Polygon Mesh Processing.
-
index
- The index of the building in the polygons vector.
Base |
Roof |
Wall and Roof After Merging |
3.5. mergeAllMeshes
void mergeAllMeshes();
The mergeAllMeshes
method combines all surface meshes into the first one and exports the result.
Building 1 |
Building 2 |
Merged Mesh |
3.6. exportSurfaceMesh
void exportSurfaceMesh(size_t index);
The exportSurfaceMesh
method exports the wallMesh
of the index specified by the user.
-
index
- The index of the building in the polygons vector.
3.7. meshing3D
void meshing3D(size_t index);
The meshing3D
method calls mesh_3d
for the index specified by the user. It takes a mesh and a std::string
to write the result. The mesh is converted into a Polyhedron and used with the CGAL make_mesh_3
function. More details about it in Volume Mesh Section
Important Note: This method can be really long to execute.
-
index
- The index of the building in the polygons vector.
Mesh Before 3D Meshing |
Mesh After 3D Meshing |
4. Information and exctration method
4.1. printBuildingsInfo
void printBuildingsInfo(int index=0) const;
Print information about the buildings, including vertices, height, floor number, wall thickness, and roof height.
4.2. getBaseMeshes
const std::vector<std::unique_ptr<Mesh>>& getBaseMeshes() const;
Get the base meshes for all buildings.
4.3. getWallMeshes
const std::vector<std::unique_ptr<Mesh>>& getWallMeshes() const;
Get the wall meshes for all buildings.
4.4. getRoofMeshes
const std::vector<std::unique_ptr<Mesh>>& getRoofMeshes() const;
Get the roof meshes for all buildings.
4.5. getRoofWallMeshes
const std::vector<std::unique_ptr<Mesh>>& getRoofWallMeshes() const;
Get the roof wall meshes for all buildings.
4.8. getPolygons
const std::vector<PolygonWithHoles>& getPolygons() const;
Get the polygons representing the buildings.
5. Private Members
-
M_polygons
- Vector of polygons representing building outlines. -
M_height
- Vector of heights for each building. -
M_floorNumber
- Vector of floor numbers for each building. -
M_wallThickness
- Vector of wall thicknesses for each building. -
M_buildingId
- Vector of building IDs. -
M_roofHeight
- Vector of roof heights for each building. -
M_union
- Flag indicating if union mode is enabled. -
M_baseMeshes
- Vector of base meshes for each building. -
M_wallMeshes
- Vector of wall meshes for each building. -
M_roofMeshes
- Vector of roof meshes for each building. -
M_roofwallMeshes
- Vector of roof wall meshes for each building. -
M_debug
- Flag indicating if debug mode is enabled. -
M_roof
- Flag indicating if roof generation is enabled. -
M_volume
- Flag indicating if volume generation is enabled. -
M_intermediate
- Directory path for intermediate results. -
M_surface
- Directory path for surface meshes. -
M_filename
- Base filename for results. -
M_mapEdgeToPolygonEdgeId
- Vector of maps associating edges with polygon edge IDs.