MultipleBuilding Class Presentation
This guide explains how to use the MultipleBuilding
class to create building models,
with a focus on the correct method order, optional method usage, and how to extract results at each stage.
1. Overview
The MultipleBuilding
class provides methods for creating and processing building models.
Proper sequencing of method calls is essential for accurate results.
Some methods are optional, depending on your needs, while others have specific prerequisites.
Every parameters that will be used is detailed in the Parameters Section.
2. Method Call Order
Follow this sequence to ensure proper functionality of the MultipleBuilding
class:
-
Load Building Data:
-
Call
loadFromJsonGis(json)
orloadFromJsonDat(json)
to load building data.
-
-
Triangulate Base Polygon:
-
Use
triangulateBasePolygon(index)
to prepare the base polygon. -
Extract Result: Use
getBaseMeshes()
to retrieve the base meshes.
-
-
Extrude Base Polygon:
-
Call
extrudeBasePolygon(index)
to create initial walls from the base polygon. -
Extract Result: Use
getBaseMeshes()
to retrieve the extruded base meshes.
-
-
Extrude Walls:
-
Use
extrudeWalls(index)
to prepare extrude internal wall. -
Extract Result: Use
getWallMeshes()
to retrieve the wall meshes.
-
-
Add Floors:
-
call
addFloors(index)
to add floors, number of floor is deduced from building height (always near 3 meters). -
Extract Result: Use
getWallMeshes()
to retrieve the floor meshes.
-
-
Generate and Process Roof (optional):
-
If the
roof
option is enabled, callgenerateRoof(index)
, followed bytransformRoof(index)
,extrudeRoofWalls(index)
, andmergeWallRoof(index)
. -
Extract Result: Use
getWallMeshes()
for the combined result.
-
-
Merge All Meshes (optional):
-
Use
mergeAllMeshes()
to combine all meshes into a final model. -
Extract Result: Use
getWallMeshes()[0]
to retrieve the final merged meshes. -
Result: Result is written in MSH format.
-
-
3D Meshing (optional):
-
If
Volume
is enabled, callmeshing3D(0)
to perform 3D meshing. -
Result: result is written in VTU format.
-
3. Important Notes
-
createBuildings() : This method creates and merges every surface mesh with roof if the roof option is activated.
-
Result : Every result are written in a result file created if needed.
-
Debug: Debug option will write a file at every step of the building creation in a result/intermediate folder created if needed.
4. Example main
Function
Here’s a streamlined example of how to use the MultipleBuilding
class, highlighting the importance of the order in which methods are called and how to extract results.
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> // Kernel is needed because of the CGAL function used
#include <ktirio/geom/buildinglod1/multiplebuilding.hpp>
namespace Feel::Ktirio::Geom {
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using namespace Buildinglod1;
}
int main() {
using namespace Feel::Ktirio::Geom;
bool debug=true;
bool roof=true;
bool Union=false; // Union will lose every marker else than buildindId
bool Volume=false;
MultipleBuilding<Kernel> building(debug, roof, Union,Volume);
std::string json = "../..data/buildinglod1/gis.json";
building.loadFromJsonGis(json); // or loadFromJsonDat(json); depending of the inputted data
for (size_t i = 0; i < building.getPolygons().size(); ++i)
{
// Correct method order
//building.getBaseMeshes(); // Extract base meshes
building.triangulateBasePolygon(i);
//building.getBaseMeshes(); // Extract extruded base meshes
building.extrudeBasePolygon(i);
// building.getWallMeshes(); // Extract wall meshes
building.extrudeWalls(i);
//Optionnal if roof isn't generated
//building.getWallMeshes(); // Extract floor meshes
building.addFloors(i);
if (roof) // Optional: Generate roof if needed
{
//building.getRoofMeshes(); // Extract roof meshes
building.generateRoof(i);
//building.getRoofMeshes(); // Extract transformed roof meshes
building.transformRoof(i);
//building.getRoofWallMeshes(); // Extract extruded roof meshes
building.extrudeRoofWalls(i);
//building.getWallMeshes(); // Exctract merged mesh
building.mergeWallRoof(i);
}
}
//Optional: Merge all building in one mesh and write result
//building.getWallMeshes()[0]; // Extract final merged meshes
building.mergeAllMeshes();
// Optional: Create Volume Mesh if asked of the building index ( 0 after mergeAllMeshes is all building ) and write result in vtu format
if(Volume)
building.meshing3D(0);
return 0;
}