Skip to content

Structure of the Code

Thomas Fröch edited this page May 1, 2023 · 14 revisions

General Information

The project consists of the following 6 files.

CityGML2OBJs.py

polygon3dmodule.py

markup3dmodule.py

CityGMLTranslation.py

generateMTL.py

plotcolorbar.py

CityGML2OBJs.py

This is the main file of the functionality. It contains the main function and the following functionalities:

  • Evaluation of the Command Line Arguments / Environment Parameters (input- / output-directory, optional parameters)

  • Iterarting over and reading all the files in the input directory. The following file extensions are supported: *.gml, *.GML, *.xml, *.XML

  • Definition of the Namespaces. There are different definitions for CityGML 1.0 and CityGML 2.0. The version of the CityGML file is identified by the analysis of the root tag.

  • Iteration within the CityGML file. Detailed information about the iteration can be found here.

  • Writing of the OBJ file

polygon3dmodule.py

This file contains the following functions that are necessary for the polygon validity check:

  • isPolyValid(...) This function checks for the following properties:

    • The last point equals first point
    • The total number of points is larger then, or equal to 3
    • The polygon is planar. (The auxiliary function isPolyPlanar is used here )
    • No repetition of points
  • getAreaOfGML(...)

  • isPolySimple(...)

  • intersection(...)

The following functions are used in order to analyze lists of points:

  • GMLstring2points(...) a function that converts the points that arre contained in a string to a list of points (float numbers)
  • smallestPoint(...) a function that is used in order to find the smallest point in a list of points (not the index, but the point itself)
  • highestPoint(...) a function that is used in order to find the highest point in a list of points (not the index, but the point itself)
  • centroid(...) a function that is used in order to find the centroid of a collection of points, given in form of a list
  • point_inside(...)a function that returns a point inside a poygon that is described by a list of points (assusmes validity). this function makes use of the shapely library. (This function is currently not used in the default settings, as it has lead to problems with polygons that contain holes)

Some auxiliary mathematical functions are found here, too:

  • collinear(...) a check for collinearity
  • det(...) determinant of a 3 x 3 matrix
  • unit_normal calculation of the unit noremal vector of a plane defined by three points
  • dot(...) dot product
  • cross(...) calculation of the cross product of two 3 x 3 matrices
  • get3DArea(...) function which reads the list of coordinates and returns its area
  • get2DArea(...) reads the list of coordinates and returns its projected area (disregards z coords)
  • getNormal(..) get the normal of the first three points of a polygon (Assumes planarity)
  • getAngles(...) get the azimuth and altitude from the normal vector`

markup3dmodule.py

This file contains the following functionalities:

  • Polygon identificatuion:: This function returns all the polygons that are oart of an object. The idetification is done by analyzing the namespace.
  • Polygon decomposition: The outer and inner ring of a polygon are identified and sved as such.
  • Point extraction: This function is used in order to extract the opints from a given liear ring and returns them as a list of points. In this function, the conversion from text (XML) to float takes place.
Clone this wiki locally