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

2.1. loadFromJsonGis

void loadFromJsonGis(const std::string& filename);

Load building data from a JSON file in GIS format.

  • filename - Path to the JSON file containing building data.

2.2. loadFromJsonDat

void loadFromJsonDat(std::string Json);

Load building data from a JSON file in DAT format.

  • Json - Path to the JSON file containing building data.

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:

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.

triangulateBasePolygon before

triangulateBasePolygon after

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.

triangulateBasePolygon after

extrudeBasePolygon after

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:

  1. Mesh Conversion: Converts the input baseMesh to the CGAL Surface_mesh format.

  2. Normal Computation: Computes vertex normals for the mesh using CGAL’s compute_vertex_normals function to ensure accurate extrusion along the correct direction.

  3. Extrusion: Applies extrusion using the extrude_mesh function from CGAL’s Polygon Mesh Processing module. The extrusion is controlled by the wall_thickness parameter, which determines the thickness of the walls. This parameter defaults to 0.1 if not specified.

  4. 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.

  5. 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.

extrudeWalls before

extrudeWalls after

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.

extrudeWalls after

addFloors after

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.

triangulateBasePolygon before

generateRoof after

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.

transformRoof before

transformRoof after

transformRoof after2

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.

extrudeRoofWalls before

extrudeRoofWalls after

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.

addFloors after

extrudeRoofWalls after

mergeWallRoof after

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.

mergeAllMeshes building1

mergeAllMeshes building2

mergeAllMeshes after

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.

mergeWallRoof after

meshing3D after

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.6. getBuildingId

const std::vector<int>& getBuildingId() const;

Get the building IDs.

4.7. getHeight

const std::vector<double>& getHeight() const;

Get the heights of the buildings.

4.8. getPolygons

const std::vector<PolygonWithHoles>& getPolygons() const;

Get the polygons representing the buildings.

4.9. checkMesh

void checkMesh(const Mesh& mesh, const std::string& nameMesh) const;

Check the integrity of the mesh and log the results.

  • mesh - The mesh to be checked.

  • nameMesh - A name or description for the mesh being checked.

4.10. getIndexById

int getIndexById( int Id)

Return index from the building Id

Important Note: The program will abort if Id is not found.

  • Id - The id of the building index wanted

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.