Manually merging citygml test and model with culling algorithm

parent b64cd3f2
......@@ -31,16 +31,6 @@
#include <string>
#include <vector>
// OpenMesh includes
#pragma warning( disable : 4512 4127 )
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/IO/IOManager.hh>
#include <OpenMesh/Core/IO/importer/ImporterT.hh>
#pragma warning( default : 4512 4127 )
struct CITACityGMLPtr;
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
namespace ITAGeo
{
......@@ -57,11 +47,11 @@ namespace ITAGeo
public:
struct CCityBuilding
{
int num;
std::string id;
std::string type;
int iNum;
std::string sID;
std::string sType;
VistaVector3D v3CenterPos;
float fBoundingSphereRad;
float fBoundingSphereRadius;
bool CenterInsideEllipse( const float coordinates[ 4 ], const float SemiMajorAxis, const float SemiMinorAxis ) const;
......@@ -87,8 +77,9 @@ namespace ITAGeo
bool Store( const std::string& sGMLFilePath, bool bOverwrite = true ) const;
void GetBuildingMesh( const CCityBuilding* pBuilding, ITAGeo::CHalfedgeMeshModel* pBuildingMesh );
std::vector< const ITAGeo::CCityGMLModel::CCityBuilding* > GetBuildings() const;
void DistanceCulling( const double dDetourDistance, const ITAGeo::CEmitter& v3Source, const ITAGeo::CSensor& v3Receiver, std::vector< const CCityBuilding* >& vpResidualBuildings );
void DistanceCulling( const double dDetourDistance, const ITAGeo::CPropagationAnchor& v3Source, const ITAGeo::CPropagationAnchor& v3Target, std::vector< const ITAGeo::CCityGMLModel::CCityBuilding* >& vpResidualBuildings );
void CalculateObjectCentroids();
......
This diff is collapsed.
......@@ -384,14 +384,14 @@ bool ITAGeo::CSketchUpModel::Store( const std::string& sSKPFilePath, bool bOverw
const std::string& sVisLayerName( key.first );
std::vector< const CHalfedgeMeshModel* > vpHMM( key.second );
SULayerRef rVisLayer = SU_INVALID;
SU_EXC( SULayerCreate( &rVisLayer ) );
SU_EXC( SULayerSetName( rVisLayer, sVisLayerName.c_str() ) );
SU_EXC( SUModelAddLayers( rModel, 1, &rVisLayer ) );
for( size_t n = 0; n < vpHMM.size(); n++ )
{
const CHalfedgeMeshModel* pHMM( vpHMM[ n ] );
SULayerRef rVisLayer = SU_INVALID;
SU_EXC( SULayerCreate( &rVisLayer ) );
SU_EXC( SULayerSetName( rVisLayer, sVisLayerName.c_str() ) );
SU_EXC( SUModelAddLayers( rModel, 1, &rVisLayer ) );
CITAMesh* pVisMesh = pHMM->GetMesh()->pTopLevelMesh;
SU_EXC( ITAMeshToSUEntities( pVisMesh, &rEntities, &rVisLayer ) );
......
......@@ -72,14 +72,23 @@ int main( int, char** )
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...." << 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;
......@@ -90,63 +99,29 @@ int main( int, char** )
std::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 " << endl;
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;
cout << RemainingObjects.size() << " Objects Remaining" << endl;
for( unsigned int i = 0; i < RemainingObjects.size(); i++ )
{
cout << RemainingObjects[ i ]->id << " " << RemainingObjects[ i ]->v3CenterPos << endl;
cout << RemainingObjects[ i ]->sID << " " << RemainingObjects[ i ]->v3CenterPos << endl;
}
cout << "Testing Mesh Conversion....";
cout << "Exporting remaining meshes ... ";
std::vector< ITAGeo::CHalfedgeMeshModel > CityMesh( RemainingObjects.size() );
ITAGeo::CSketchUpModel voSketchUpCity;
cout << ITAGeo::CHalfedgeMeshModel::GetSupportedOutputFormats() << endl;
for( unsigned int i = 0; i < RemainingObjects.size(); i++ )
{
cout << "Fetching building " << i << endl;
oModel.GetBuildingMesh( RemainingObjects[ i ], &CityMesh[ i ] );
cout << "Barycenter: " << CityMesh[ i ].GetBarycenter() << endl;
auto s = std::to_string( i );
cout << "Exporting " << s << endl;
voSketchUpCity.AddVisualizationMesh( &CityMesh[ i ] );
cout << "Stored " << s << endl;
if( i == 66 )
break;
voSketchUpCity.AddVisualizationMesh( &CityMesh[ i ], "CullingAlgo" );
}
cout << "done." << endl;
voSketchUpCity.Store( "LoD2_288_5631_1_NW.skp" );
/* cout << "Creating PointCloud Visualisation...";
std::vector<VistaVector3D> vvPointCloud;
for (unsigned int j = 0; j < RemainingObjects.size(); j++)
{
vvPointCloud.push_back(RemainingObjects[j]->v3CenterPos);
}
CITAGeoPropagationPath oDummyPath;
for (int n = 0; n<vvPointCloud.size(); n++)
{
CITAGeoPropagationAnchor* pAnchor = new CITAGeoPropagationAnchor(vvPointCloud[n]);
oDummyPath.push_back(pAnchor);
}
CITAGeoSketchUpModel CulledModel;
CulledModel.AddPropagationPathVisualization(oDummyPath, "PointCloudPolyLine");
CulledModel.Store("CulledModel.skp"); */
//cout << "\tIdentifier: " << pCityModel->getId() << endl;
//cout << "\tNum root objects: " << pCityModel->getNumRootCityObjects() << endl;
string sExportFileName = "LoD2_288_5631_1_NW.skp";
cout << "Storing city as SketchUp file to " << sExportFileName << " ... ";
voSketchUpCity.Store( sExportFileName );
cout << "done." << endl;
}
catch( ITAException e )
{
......
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