span8
span4
span8
span4
Hello,
I have CityGML files for buildings and I want to know and expose the number of vertex and triangles that will be exported by the OBJ writer.
I use the aggregator transformer to merge all the geometries and count the number of vertex,then remove all duplicated vertex (not immediate,but feasible),but I don't know how to find the number of triangles.
Is somebody having an idea ?
Maybe using the pythocaller,but I'm not a specialist !
Hi @lavairye
The CityGML surfaces will be converted to triangular meshes by the OBJ writer,but in order to count the resulting vertices,we can do the mesh conversion before writing,with the Triangulator transformer.
After the Triangulator,add a PythonCaller with the following code:
import fmeimport fmeobjectsdef meshStats(feature): # extract geometry from feature geom = feature.getGeometry() # get number of vertices in Mesh numVerts = geom.numVertices() # set number of vertices on feature as attribute feature.setAttribute("_numVertices",numVerts) # convert Mesh to MultiSurface msurf = geom.getAsMultiSurface() # get number of parts in MultiSurface numTriangles = msurf.numParts() # set number of parts on feature as attribute feature.setAttribute("_numTriangles",numTriangles)
This will create two new attributes on the feature:
Although the geometry in the Python is converted from a Mesh to a MultiSurface to get the number of triangles,that geometry is not written back to the feature,so the feature geometry will be unchanged.
def meshStats(feature): # extract geometry from feature geom = feature.getGeometry() # get number of vertices and parts in Mesh numVerts = geom.numVertices() numTriangles = geom.numParts() # set number of vertices and parts on feature as attributes feature.setAttribute("_numVertices",numVerts) feature.setAttribute("_numTriangles",numTriangles)
Thanks a lot.All my 亚搏在线workflow works fine now.I shall use more python in the future!
© 2019 亚搏在线Safe Software Inc |法律