Skip to content

Commit

Permalink
Merge pull request #62 from HarutakaMatsumoto/develop
Browse files Browse the repository at this point in the history
Implemented some CityObjectElements and enabled tesselate
@HarutakaMatsumoto  Thank you for your efforts.
  • Loading branch information
jklimke authored Feb 7, 2022
2 parents d10ec50 + af36530 commit 0819937
Show file tree
Hide file tree
Showing 22 changed files with 382 additions and 30 deletions.
8 changes: 8 additions & 0 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ SET(SOURCES
src/citygml/geometrymanager.cpp
src/citygml/linestring.cpp
src/citygml/address.cpp
src/citygml/rectifiedgridcoverage.cpp
src/citygml/externalreference.cpp

src/parser/nodetypes.cpp
src/parser/attributes.cpp
Expand All @@ -98,11 +100,13 @@ SET(SOURCES
src/parser/citymodelelementparser.cpp
src/parser/cityobjectelementparser.cpp
src/parser/appearanceelementparser.cpp
src/parser/externalreferenceparser.cpp
src/parser/materialelementparser.cpp
src/parser/textureelementparser.cpp
src/parser/georeferencedtextureelementparser.cpp
src/parser/geometryelementparser.cpp
src/parser/polygonelementparser.cpp
src/parser/rectifiedgridcoverageparser.cpp
src/parser/linestringelementparser.cpp
src/parser/linearringelementparser.cpp
src/parser/implicitgeometryelementparser.cpp
Expand Down Expand Up @@ -145,6 +149,8 @@ SET(PUBLIC_HEADER
include/citygml/citygmlfactory.h
include/citygml/linestring.h
include/citygml/address.h
include/citygml/rectifiedgridcoverage.h
include/citygml/externalreference.h
)

SET(HEADERS
Expand Down Expand Up @@ -179,11 +185,13 @@ SET(HEADERS
include/parser/citymodelelementparser.h
include/parser/cityobjectelementparser.h
include/parser/appearanceelementparser.h
include/parser/externalreferenceparser.h
include/parser/materialelementparser.h
include/parser/textureelementparser.h
include/parser/georeferencedtextureelementparser.h
include/parser/geometryelementparser.h
include/parser/polygonelementparser.h
include/parser/rectifiedgridcoverageparser.h
include/parser/linestringelementparser.h
include/parser/linearringelementparser.h
include/parser/implicitgeometryelementparser.h
Expand Down
1 change: 1 addition & 0 deletions sources/include/citygml/citygml.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace citygml
, minLOD( 0 )
, maxLOD( 4 )
, optimize( false )
, tesselate( true )
, pruneEmptyObjects( false )
, destSRS( "" )
, srcSRS( "" )
Expand Down
4 changes: 4 additions & 0 deletions sources/include/citygml/citygmlfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <citygml/geometry.h>
#include <citygml/cityobject.h>
#include <citygml/externalreference.h>

#include <memory>

Expand All @@ -19,6 +20,7 @@ namespace citygml {
class ImplicitGeometry;
class Polygon;
class LineString;
class RectifiedGridCoverage;

class Appearance;
class Texture;
Expand All @@ -35,9 +37,11 @@ namespace citygml {
CityModel* createCityModel(const std::string& id);
CityObject* createCityObject(const std::string& id, CityObject::CityObjectsType type);
Geometry* createGeometry(const std::string& id, const CityObject::CityObjectsType& cityObjType = CityObject::CityObjectsType::COT_All, unsigned int lod = 0, std::string srsName = "");
RectifiedGridCoverage* createRectifiedGridCoverage(std::string const& id);

std::shared_ptr<Polygon> createPolygon(const std::string& id);
std::shared_ptr<LineString> createLineString(const std::string& id);
std::shared_ptr<ExternalReference> createExternalReference(const std::string& id);

/**
* @brief requests a polygon for a Geometry object that will be added later
Expand Down
2 changes: 1 addition & 1 deletion sources/include/citygml/citymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace citygml {

const std::string& getSRSName() const;

void finish(Tesselator& tesselator, bool optimize, std::shared_ptr<CityGMLLogger> logger);
void finish(Tesselator& tesselator, bool optimize, bool tesselate, std::shared_ptr<CityGMLLogger> logger);

std::vector<std::string> themes() const;
void setThemes(std::vector<std::string> themes);
Expand Down
14 changes: 13 additions & 1 deletion sources/include/citygml/cityobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <citygml/featureobject.h>
#include <citygml/citygml_api.h>
#include <citygml/enum_type_bitmask.h>
#include <citygml/rectifiedgridcoverage.h>
#include <citygml/externalreference.h>
class Tesselator;

namespace citygml {
Expand Down Expand Up @@ -108,8 +110,16 @@ namespace citygml {
// Access address
const Address* address() const;
void setAddress(std::unique_ptr<Address>&& address);

// Access rectifiedGridCoverage
RectifiedGridCoverage const* rectifiedGridCoverage() const;
void setRectifiedGridCoverage(RectifiedGridCoverage * rectifiedGridCoverage);

// Access externalReference
ExternalReference const* externalReference() const;
void setExternalReference(ExternalReference * externalReference);

void finish(Tesselator& tesselator, bool optimize, std::shared_ptr<citygml::CityGMLLogger> logger);
void finish(Tesselator& tesselator, bool optimize, bool tesselate, std::shared_ptr<citygml::CityGMLLogger> logger);

virtual ~CityObject();

Expand All @@ -120,6 +130,8 @@ namespace citygml {
std::vector<std::unique_ptr<ImplicitGeometry> > m_implicitGeometries;
std::vector<std::unique_ptr<CityObject> > m_children;
std::unique_ptr<Address> m_address;
std::unique_ptr<RectifiedGridCoverage> m_rectifiedGridCoverage;
std::unique_ptr<ExternalReference> m_externalReference;
};

LIBCITYGML_EXPORT std::ostream& operator<<( std::ostream& os, const CityObject& o );
Expand Down
25 changes: 25 additions & 0 deletions sources/include/citygml/externalreference.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include <citygml/object.h>


namespace citygml {
union LIBCITYGML_EXPORT ExternalObjectReference {
std::string name;
std::string uri;

ExternalObjectReference();
~ExternalObjectReference();
};

class LIBCITYGML_EXPORT ExternalReference: public Object {
friend class CityGMLFactory;

protected:
ExternalReference(std::string const& id);
// ~ExternalReference() noexcept override; // Destructor
public:
std::string informationSystem;
ExternalObjectReference externalObject;
};
}
2 changes: 1 addition & 1 deletion sources/include/citygml/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace citygml {
* @param tesselator the tesselator to be used for tesselation
* @param mergePolygons determines wether all polygons are merged into one
*/
void finish(Tesselator& tesselator, bool optimize, std::shared_ptr<CityGMLLogger> logger);
void finish(Tesselator& tesselator, bool optimize, bool tesselate, std::shared_ptr<CityGMLLogger> logger);

~Geometry();

Expand Down
2 changes: 1 addition & 1 deletion sources/include/citygml/polygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace citygml {

void addRing( LinearRing* );

void finish(Tesselator& tesselator , bool optimize, std::shared_ptr<CityGMLLogger> logger);
void finish(Tesselator& tesselator , bool optimize, bool tesselate, std::shared_ptr<CityGMLLogger> logger);

std::shared_ptr<LinearRing> exteriorRing(){
return m_exteriorRing;
Expand Down
18 changes: 18 additions & 0 deletions sources/include/citygml/rectifiedgridcoverage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <citygml/featureobject.h>

namespace citygml {

class LIBCITYGML_EXPORT RectifiedGridCoverage : public FeatureObject
{
friend class CityGMLFactory;

protected:
RectifiedGridCoverage(std::string const& id = "RectifiedGridCoverage");
};

LIBCITYGML_EXPORT std::ostream& operator<<( std::ostream& os, const RectifiedGridCoverage& o );

}

30 changes: 30 additions & 0 deletions sources/include/parser/externalreferenceparser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include "parser/gmlobjectparser.h"
#include <citygml/externalreference.h>


namespace citygml {
class ExternalReferenceParser: public GMLObjectElementParser {
public:
ExternalReferenceParser(CityGMLDocumentParser& documentParser, CityGMLFactory& factory, std::shared_ptr<CityGMLLogger> logger, std::function<void(ExternalReference *)> callback);

// ElementParser interface
virtual std::string elementParserName() const override;
virtual bool handlesElement(NodeType::XMLNode const& node) const override;

protected:
// CityGMLElementParser interaface
virtual bool parseElementStartTag(NodeType::XMLNode const& node, Attributes & attribute) override;
virtual bool parseElementEndTag(NodeType::XMLNode const& node, std::string const& characters) override;
virtual bool parseChildElementStartTag(NodeType::XMLNode const& node, Attributes & attributes) override;
virtual bool parseChildElementEndTag(NodeType::XMLNode const& node, std::string const& characters) override;

// GMLObjectElementParser interface
virtual Object* getObject() override;

private:
std::shared_ptr<ExternalReference> model;
std::function<void(ExternalReference *)> callback;
};
}
34 changes: 34 additions & 0 deletions sources/include/parser/rectifiedgridcoverageparser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include "parser/gmlfeaturecollectionparser.h"

#include <citygml/rectifiedgridcoverage.h>


namespace citygml {

class RectifiedGridCoverageParser : public GMLFeatureCollectionElementParser {
public:
RectifiedGridCoverageParser(CityGMLDocumentParser& documentParser, CityGMLFactory& factory, std::shared_ptr<CityGMLLogger> logger, std::function<void(RectifiedGridCoverage *)> callback);

// ElementParser interface
virtual std::string elementParserName() const override;
virtual bool handlesElement(const NodeType::XMLNode &node) const override;
protected:

// CityGMLElementParser interface
virtual bool parseElementStartTag(const NodeType::XMLNode& node, Attributes& attributes) override;
virtual bool parseElementEndTag(const NodeType::XMLNode& node, const std::string& characters) override;
virtual bool parseChildElementStartTag(const NodeType::XMLNode& node, Attributes& attributes) override;
virtual bool parseChildElementEndTag(const NodeType::XMLNode& node, const std::string& characters) override;

// GMLFeatureCollectionElementParser interface
virtual FeatureObject* getFeatureObject() override;

private:
std::function<void(RectifiedGridCoverage*)> m_callback;
RectifiedGridCoverage * m_model;
};
}


10 changes: 10 additions & 0 deletions sources/src/citygml/citygmlfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <citygml/citymodel.h>
#include <citygml/implictgeometry.h>
#include <citygml/citygmllogger.h>
#include <citygml/rectifiedgridcoverage.h>

namespace citygml {

Expand All @@ -26,6 +27,10 @@ namespace citygml {
m_logger = logger;
}

RectifiedGridCoverage* CityGMLFactory::createRectifiedGridCoverage(std::string const& id) {
return new RectifiedGridCoverage(id);
}

CityModel* CityGMLFactory::createCityModel(const std::string& id)
{
return new CityModel(id);
Expand Down Expand Up @@ -88,7 +93,12 @@ namespace citygml {
{
LineString* lineString = new LineString(id);
return std::shared_ptr<LineString>(lineString);
}

std::shared_ptr<ExternalReference> CityGMLFactory::createExternalReference(const std::string& id)
{
ExternalReference * externalReference = new ExternalReference(id);
return std::shared_ptr<ExternalReference>(externalReference);
}

void CityGMLFactory::requestSharedPolygonForGeometry(Geometry* geom, const std::string& polygonId)
Expand Down
4 changes: 2 additions & 2 deletions sources/src/citygml/citymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ namespace citygml
}


void CityModel::finish(Tesselator& tesselator, bool optimize, std::shared_ptr<CityGMLLogger> logger)
void CityModel::finish(Tesselator& tesselator, bool optimize, bool tesselate, std::shared_ptr<CityGMLLogger> logger)
{
// Finish all cityobjcts
for (auto& cityObj : m_roots) {
cityObj->finish(tesselator, optimize, logger);
cityObj->finish(tesselator, optimize, tesselate, logger);
}

// Build city objects map
Expand Down
24 changes: 20 additions & 4 deletions sources/src/citygml/cityobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,36 @@ namespace citygml {
m_address = std::move(address);
}

void CityObject::finish(Tesselator& tesselator, bool optimize, std::shared_ptr<CityGMLLogger> logger)
RectifiedGridCoverage const* CityObject::rectifiedGridCoverage() const {
return m_rectifiedGridCoverage.get();
}

void CityObject::setRectifiedGridCoverage(RectifiedGridCoverage * rectifiedGridCoverage) {
m_rectifiedGridCoverage = std::unique_ptr<RectifiedGridCoverage>(rectifiedGridCoverage);
}

ExternalReference const* CityObject::externalReference() const {
return m_externalReference.get();
}

void CityObject::setExternalReference(ExternalReference * externalReference) {
m_externalReference = std::unique_ptr<ExternalReference>(externalReference);
}

void CityObject::finish(Tesselator& tesselator, bool optimize, bool tesselate, std::shared_ptr<CityGMLLogger> logger)
{
for (std::unique_ptr<Geometry>& geom : m_geometries) {
geom->finish(tesselator, optimize, logger);
geom->finish(tesselator, optimize, tesselate, logger);
}

for (std::unique_ptr<ImplicitGeometry>& implictGeom : m_implicitGeometries) {
for (int i = 0; i < implictGeom->getGeometriesCount(); i++) {
implictGeom->getGeometry(i).finish(tesselator, optimize, logger);
implictGeom->getGeometry(i).finish(tesselator, optimize, tesselate, logger);
}
}

for (std::unique_ptr<CityObject>& child : m_children) {
child->finish(tesselator, optimize, logger);
child->finish(tesselator, optimize, tesselate, logger);
}
}

Expand Down
12 changes: 12 additions & 0 deletions sources/src/citygml/externalreference.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <citygml/externalreference.h>

namespace citygml {
ExternalObjectReference::ExternalObjectReference() {
}

ExternalObjectReference::~ExternalObjectReference() {
}

ExternalReference::ExternalReference(std::string const& id) : Object(id) {
}
}
6 changes: 3 additions & 3 deletions sources/src/citygml/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace citygml {
m_lineStrings.push_back(l);
}

void Geometry::finish(Tesselator& tesselator, bool optimize, std::shared_ptr<CityGMLLogger> logger)
void Geometry::finish(Tesselator& tesselator, bool optimize, bool tesselate, std::shared_ptr<CityGMLLogger> logger)
{
// only need to finish geometry once
if (m_finished) {
Expand All @@ -148,12 +148,12 @@ namespace citygml {

for (std::shared_ptr<Geometry>& child : m_childGeometries) {
child->addTargetDefinitionsOf(*this);
child->finish(tesselator, optimize, logger);
child->finish(tesselator, optimize, tesselate, logger);
}

for (std::shared_ptr<Polygon>& polygon : m_polygons) {
polygon->addTargetDefinitionsOf(*this);
polygon->finish(tesselator, optimize, logger);
polygon->finish(tesselator, optimize, tesselate, logger);
}

}
Expand Down
Loading

0 comments on commit 0819937

Please sign in to comment.