Commit 25d4a3ba authored by Julian Jansen's avatar Julian Jansen

CityGML Mesh Conversion

parent 39763fb6
......@@ -29,7 +29,13 @@
// STL includes
#include <string>
// OpenMesh includes
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/IO/IOManager.hh>
#include <OpenMesh/Core/IO/importer/ImporterT.hh>
struct CITACityGMLPtr;
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
//! CityGML input and output class
/**
......@@ -39,11 +45,18 @@ struct CITACityGMLPtr;
class ITA_GEO_API CITAGeoCityGMLModel : public CITAGeoModelBase
{
public:
struct CCityBuilding
class CCityObject
{
public:
int num;
std::string id;
std::string type;
VistaVector3D v3CenterPos;
float fBoundingSphereRad;
bool CenterInsideEllipse(const float coordinates[4], const float SemiMajorAxis, const float SemiMinorAxis);
bool BoundingSphereInsideEllipse(const VistaVector3D v3centerpos, const float fBSradius, const float SemiMajorAxis, const float SemiMinorAxis);
};
CITAGeoCityGMLModel();
......@@ -64,20 +77,19 @@ public:
*/
bool Store( const std::string& sGMLFilePath, bool bOverwrite = true ) const;
void GetBuildingMesh(const CCityBuilding* pBuilding, CITAGeoHalfedgeMeshModel* pBuildingMesh);
void CalculateObjectCentroids();
void DistanceCulling(const double dDetourDistance, const CITASource& v3Source, const CITAReceiver& v3Receiver, std::vector< const CCityBuilding* >& vpResidualBuildings);
void GetObjectMesh(const CCityObject* pObject, CITAMesh& oObjectMesh);
void DistanceCulling(const double dDetourDistance, const CITASource& v3Source, const CITAReceiver& v3Receiver, std::vector< const CCityObject* >& vpResidualObjects);
protected:
CITACityGMLPtr* m_pCityModel; //!< Encapsuled pointer to the city GML instance
std::vector< CITAGeoHalfedgeMeshModel* > m_pBuildings;
std::vector< CCityBuilding> m_vOBuildings;
bool CenterInsideEllipse(const float coordinates[4], const float SemiMajorAxis, const float SemiMinorAxis);
std::vector< CITAGeoHalfedgeMeshModel* > m_pObjects;
std::vector< CCityObject> m_vOObjects;
bool BoundingSphereInsideEllipse(const VistaVector3D v3centerpos, const float fBSradius, const float SemiMajorAxis, const float SemiMinorAxis);
};
#endif // INCLUDE_WATCHER_ITA_GEO_CITYGML_MODEL
......@@ -33,6 +33,7 @@
#include <vector>
class CITAGeoHalfedgeMeshModel;
class CITAMaterialManager;
//! Geometric model for acoustics
......
......@@ -4,7 +4,7 @@
#include <ITAException.h>
CITAMesh::Point CityGMLPoint3DToITAMeshPoint( const TVec3d& vCityGMLPoint )
CITAMesh::Point CityGMLPoint3DToITAMeshPoint( TVec3d& vCityGMLPoint )
{
return CITAMesh::Point( float( vCityGMLPoint.x ), float( vCityGMLPoint.y ), float( vCityGMLPoint.z ) );
}
......@@ -37,6 +37,6 @@
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
//! Creates CITAMesh point from CityGML point (double precision)
CITAMesh::Point CityGMLPoint3DToITAMeshPoint( const TVec3d& vCityGMLPoint );
CITAMesh::Point CityGMLPoint3DToITAMeshPoint( TVec3d& vCityGMLPoint );
#endif // INCLUDE_WATCHER_ITA_GEO_CITYGML_CONVERSIONS
This diff is collapsed.
......@@ -38,7 +38,7 @@ CITAGeoHalfedgeCityGMLReader::~CITAGeoHalfedgeCityGMLReader()
}
bool CITAGeoHalfedgeCityGMLReader::read( const std::string& sCityGMLFilePath, OpenMesh::IO::BaseImporter& oBaseImporter, OpenMesh::IO::Options& )
{
{ /*
try
{
citygml::ParserParams oParserParams;
......@@ -80,7 +80,7 @@ bool CITAGeoHalfedgeCityGMLReader::read( const std::string& sCityGMLFilePath, Op
}
}
return true;
return true;
}
#ifdef ITA_GEO_WITH_XERCES_SUPPORT
......@@ -94,7 +94,8 @@ bool CITAGeoHalfedgeCityGMLReader::read( const std::string& sCityGMLFilePath, Op
ITA_EXCEPT_INVALID_PARAMETER( "Could not parse CityGML file " + sCityGMLFilePath );
}
return false;
return false; */
return true;
};
bool CITAGeoHalfedgeCityGMLReader::read( std::istream&, OpenMesh::IO::BaseImporter&, OpenMesh::IO::Options& )
......
......@@ -20,7 +20,8 @@
#include <ITAException.h>
#include <ITAStopWatch.h>
#include <ITAGeoCityGMLModel.h>
#include <ITAGeoSketchUpModel.h>
#include <VistaBase/VistaVector3D.h>
#include <VistaMath/VistaGeometries.h>
#include <VistaTools/VistaFileSystemFile.h>
......@@ -28,7 +29,12 @@
#include <citygml/citygml.h>
#include <citygml/citymodel.h>
#include <xercesc/sax/SAXParseException.hpp>
// OpenMesh includes
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/IO/IOManager.hh>
#include <OpenMesh/Core/IO/MeshIO.hh>
//#include <xercesc/sax/SAXParseException.hpp>
#include <cassert>
#include <iostream>
......@@ -36,23 +42,91 @@
#include <string>
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 = "3d-gm_lod2_05334002_Aachen_EPSG25832_CityGML/LoD2_293_5624_1_NW.gml";
static string sCityGMLFilePath = "LOD2_0_F0.gml";
int main( int, char** )
{
citygml::ParserParams oParserParams;
shared_ptr< const citygml::CityModel > pCityModel;
shared_ptr< citygml::CityGMLLogger > pLogger = nullptr;
CITAGeoCityGMLModel oModel;
//shared_ptr< const citygml::CityModel > pCityModel;
//shared_ptr< citygml::CityGMLLogger > pLogger = nullptr;
try
{
cout << "Loading CityGML file path '" << sCityGMLFilePath << "'" << endl;
pCityModel = citygml::load( sCityGMLFilePath, oParserParams, pLogger );
cout << "\tIdentifier: " << pCityModel->getId() << endl;
cout << "\tNum root objects: " << pCityModel->getNumRootCityObjects() << endl;
oModel.Load(sCityGMLFilePath);
cout << "Loading successful! " << endl;
cout << "Continuing with centroid calculation of cityobjects...." << endl;
oModel.CalculateObjectCentroids();
float fDistance = 1000;
CITAReceiver oReceiver;
oReceiver.vPos.SetValues(300.0f, 300.0f, 0.0f);
CITASource oSource;
oSource.vPos.SetValues(100.0f, 100.0f, 10.0f);
std::vector< const CITAGeoCityGMLModel::CCityObject* > RemainingObjects;
cout << "Executing Culling Test with Distance of 1000m, Source Position at 100/100/10, Receiver Position at 300/300/0 " << endl;
oModel.DistanceCulling(fDistance, oSource, oReceiver, RemainingObjects);
cout << RemainingObjects.size() << " Objects Remaining" << endl;
for (unsigned int i = 0; i < RemainingObjects.size(); i++)
{
cout << RemainingObjects[i]->id << " " << RemainingObjects[i]->v3CenterPos << endl;
}
cout << "Testing Mesh Conversion....";
std::vector<CITAMesh> CityMesh;
for (unsigned int i = 0; i < RemainingObjects.size(); i++)
{
CITAMesh ObjectMesh;
oModel.GetObjectMesh(RemainingObjects[i], ObjectMesh);
CityMesh.push_back(ObjectMesh);
}
/*
for (unsigned int i = 0; i < CityMesh.size(); i++)
{
auto s = std::to_string(i+1);
OpenMesh::IO::write_mesh(CityMesh[i], s + ". ObjectMesh.obj");
} */
/* 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;
}
catch( ... )
{
......
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