Improving test for processing and exporting more than one GML input file

parent fb469b22
......@@ -261,7 +261,6 @@ void ITAGeo::CCityGMLModel::CalculateObjectCentroids()
const TVec3d v3TObjectCentroid( fObjectCentroid_X / vPolygonCentroids.size(), fObjectCentroid_Y / vPolygonCentroids.size(), fObjectCentroid_Z / vPolygonCentroids.size() );
const VistaVector3D v3ObjectCentroid( v3TObjectCentroid.x, v3TObjectCentroid.y, v3TObjectCentroid.z );
std::cout << v3ObjectCentroid << std::endl;
//Defining Object Boundingsphere by finding Object Vertex that is the farthest from Centroid and using this distance as radius for the Boundingsphere
float fMaxDistance = 0;
......@@ -282,8 +281,6 @@ void ITAGeo::CCityGMLModel::CalculateObjectCentroids()
oCCityObject.fBoundingSphereRadius = fMaxDistance;
m_voBuildings.push_back( oCCityObject );
}
std::cout << "Preparation of " << m_voBuildings.size() << " Objects completed..." << std::endl;
}
/**
......
......@@ -54,7 +54,13 @@ using namespace std;
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
// Resource (CC BY-SA 4.0 Filip Biljecki): https://3d.bk.tudelft.nl/biljecki/Random3Dcity.html
static string sCityGMLFilePath = "LoD2_288_5631_1_NW.gml";
static vector< string > vsAachenCityFilePaths = {
"LoD2_293_5628_1_NW",
"LoD2_293_5629_1_NW",
"LoD2_294_5628_1_NW",
"LoD2_294_5629_1_NW",
"LoD2_295_5628_1_NW",
"LoD2_295_5629_1_NW" };
// Resource (Land NRW, 2017, https://www.govdata.de/dl-de/by-2-0): https://www.opengeodata.nrw.de/produkte/geobasis/3d-gm/3d-gm_lod2/
//static string sCityGMLFilePath = "Aachen/LoD2_287_5631_1_NW_no_terrain_intersection.gml";
......@@ -62,70 +68,87 @@ static string sCityGMLFilePath = "LoD2_288_5631_1_NW.gml";
int main( int, char** )
{
ITAGeo::CCityGMLModel oModel;
VistaFileSystemFile f( sCityGMLFilePath );
try
{
if( !f.Exists() )
ITA_EXCEPT_INVALID_PARAMETER( "File path " + f.GetName() + " does not exist." );
cout << "Loading CityGML file path '" << f.GetLocalName() << "'" << endl;
oModel.Load( f.GetName() );
cout << "Loading successful! " << endl;
cout << "Continuing with centroid calculation of cityobjects ...";
oModel.CalculateObjectCentroids();
cout << " done." << endl;
cout << "Converting all meshes for visualization export ...";
ITAGeo::CSketchUpModel voSketchUpCity;
auto vpCityBuildings = oModel.GetBuildings();
std::vector< ITAGeo::CHalfedgeMeshModel > voBuildingModels( vpCityBuildings.size() );
for( size_t n = 0; n < vpCityBuildings.size(); n++ )
{
oModel.GetBuildingMesh( vpCityBuildings[ n ], &voBuildingModels[ n ] );
voSketchUpCity.AddVisualizationMesh( &voBuildingModels[n], "CityBuildings" );
}
cout << " done." << endl;
float fDistance = 1000;
ITAGeo::CSensor oReceiver;
oReceiver.vPos.SetValues( 288153.0f, 5631691.0f, 190.0f );
double dDistance = 1000;
ITAGeo::CEmitter oSource;
oSource.vPos.SetValues( 288253.0f, 5631591.0f, 193.0f );
oSource.vPos.SetValues( 294005.0f, 5629168.0f, 178.0f );
std::vector< const ITAGeo::CCityGMLModel::CCityBuilding* > RemainingObjects;
ITAGeo::CSensor oReceiver;
oReceiver.vPos.SetValues( 294605.0f, 5628758.0f, 164.0f );
cout << "Executing Culling Test with Distance of 1000m, Source Position at 100/100/10, Receiver Position at 300/300/0 ...";
oModel.DistanceCulling( fDistance, oSource, oReceiver, RemainingObjects );
cout << "done." << endl;
vector< ITAGeo::CHalfedgeMeshModel* > vpRemainingBuildingModels;
vector< ITAGeo::CHalfedgeMeshModel* > vpAachenBuildingModels;
cout << RemainingObjects.size() << " Objects Remaining" << endl;
for( unsigned int i = 0; i < RemainingObjects.size(); i++ )
for( auto sCityGMLFileName : vsAachenCityFilePaths )
{
cout << RemainingObjects[ i ]->sID << " " << RemainingObjects[ i ]->v3CenterPos << endl;
ITAGeo::CCityGMLModel oModel;
VistaFileSystemFile f( sCityGMLFileName + ".gml" );
if( !f.Exists() )
ITA_EXCEPT_INVALID_PARAMETER( "File path " + f.GetName() + " does not exist." );
cout << "Loading CityGML file path '" << f.GetLocalName() << "' ... ";
oModel.Load( f.GetName() );
cout << "done." << endl;
cout << "Continuing with centroid calculation of cityobjects ... ";
oModel.CalculateObjectCentroids();
cout << "done." << endl;
cout << "Converting all meshes for visualization export ...";
auto vpCityBuildings = oModel.GetBuildings();
for( size_t n = 0; n < vpCityBuildings.size(); n++ )
{
auto pBuildingModel = new ITAGeo::CHalfedgeMeshModel();
oModel.GetBuildingMesh( vpCityBuildings[ n ], pBuildingModel );
voSketchUpCity.AddVisualizationMesh( pBuildingModel, "CityBuildings_" + sCityGMLFileName );
vpRemainingBuildingModels.push_back( pBuildingModel );
}
cout << " done." << endl;
vector< const ITAGeo::CCityGMLModel::CCityBuilding* > RemainingObjects;
cout << "Executing Culling Test with Distance of 1000m, Source Position at 100/100/10, Receiver Position at 300/300/0 ...";
oModel.DistanceCulling( dDistance, oSource, oReceiver, RemainingObjects );
cout << "done." << endl;
cout << RemainingObjects.size() << " Objects Remaining" << endl;
for( unsigned int i = 0; i < RemainingObjects.size(); i++ )
{
cout << RemainingObjects[ i ]->sID << " " << RemainingObjects[ i ]->v3CenterPos << endl;
}
cout << "Exporting remaining meshes ... ";
for( unsigned int i = 0; i < RemainingObjects.size(); i++ )
{
auto pBuildingModel = new ITAGeo::CHalfedgeMeshModel();
oModel.GetBuildingMesh( RemainingObjects[ i ], pBuildingModel );
voSketchUpCity.AddVisualizationMesh( pBuildingModel, "CullingAlgo_" + sCityGMLFileName );
vpAachenBuildingModels.push_back( pBuildingModel );
}
cout << "done." << endl;
}
cout << "Exporting remaining meshes ... ";
std::vector< ITAGeo::CHalfedgeMeshModel > CityMesh( RemainingObjects.size() );
for( unsigned int i = 0; i < RemainingObjects.size(); i++ )
{
oModel.GetBuildingMesh( RemainingObjects[ i ], &CityMesh[ i ] );
voSketchUpCity.AddVisualizationMesh( &CityMesh[ i ], "CullingAlgo" );
}
cout << "done." << endl;
string sExportFileName = "LoD2_288_5631_1_NW.skp";
string sExportFileName = "AachenCityCulling.skp";
cout << "Storing city as SketchUp file to " << sExportFileName << " ... ";
voSketchUpCity.Store( sExportFileName );
cout << "done." << endl;
// Release models after export / store
for( auto p : vpAachenBuildingModels )
delete p;
for( auto p : vpRemainingBuildingModels )
delete p;
}
catch( ITAException e )
{
cerr << e << endl;
return 255;
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment