| VRS - The Virtual Rendering System |
| version 3.3 |
#include <vrs/polygonsettool.h>
Public Types | |
| enum | ClipMethod { KEEP_INTERSECTING_TRIANGLES, REMOVE_INTERSECTING_TRIANGLES, CLIP_INTERSECTING_TRIANGLES } |
| enum | EdgeGroup { SoftEdge = 1<<0, HardEdge = 1<<1, BoundaryEdge = 1<<2, NonManifoldEdge = 1<<3 } |
Public Member Functions | |
| VRS_SERIALIZABLE_CLASS_ENUM (ClipMethod) | |
Static Public Member Functions | |
| static SO< Facet > | removeRedundantVertices (SO< Facet > soFacet, double toleranceDegrees=0.0) |
| Removes all redundant vertices - means the ones which don't really contribute to the shape of the facet. | |
| static SO< PolygonSet > | tesselateFacet (SO< Facet > facet, const Vector &forceNormal=Vector::origin) |
| Tesselates a facet in respect to an optional normal vector (assumes (0, 1, 0) if not explictely specified). | |
| static void | copy (const PolygonSet *source, PolygonSet *dest, bool deepCopy=true) |
| Creates an independent copy of the source PolygonSet, overwriting it into the dest PolygonSet. dest must be non-NULL. | |
| static PolygonSet * | copy (const PolygonSet *poly, bool deepCopy=true) |
| Creates an independent copy of a given PolygonSet, i.e. all data contained in poly is copied and assigned to the returned PolygonSet. | |
| static PolygonSet * | mergePolygonSets (Iterator< SO< PolygonSet > > *polys) |
| Merges a sequence of PolygonSets to a single output PolygonSet. | |
| static SO< Iterator< SO < PolygonSet > > > | forceMerge (SO< Iterator< SO< PolygonSet > > > meshes, bool indexed, int maxVertices=65535) |
| Merges all given PolygonSets into a minimum set of combined PolygonSets. | |
| static SO< PolygonSet > | forceTriangleMerge (SO< Iterator< SO< PolygonSet > > > polys, bool indexed) |
| Similar to forceMerge, but not lossless:. | |
| static bool | canBeMerged (PolygonSet *poly1, PolygonSet *poly2, bool considerEfficiency=true) |
| Checks for two PolygonSets, whether they can be merged using the mergePolygonSet() method. | |
| static SO< PolygonSet > | convertToIndexedForm (SO< PolygonSet > poly, bool packData=false) |
| Conversion between indexed and non-indexed form. | |
| static SO< PolygonSet > | convertToTrivialIndexedForm (SO< PolygonSet > poly) |
| Adds a trivial index iterator to the polygon set if no index iterator is set. | |
| *static SO< PolygonSet > | convertToNonIndexedForm (SO< PolygonSet > poly, bool packData=false) |
| Conversion to non-indexed form is quite simple (in O(indices) time),. | |
| static PolygonSet * | invertOrientation (const PolygonSet *poly) |
| Inverts each single triangle contained in a PolygonSet. | |
| static PolygonSet * | extractTriangleMesh (const PolygonSet *mesh, bool removeUnusedVertices=false) |
| Extracts all triangles contained in "mesh". | |
| static bool | isValid (const PolygonSet *poly) |
| Checks if the PolygonSet fulfills some conditions. | |
| static void | ValidatePolygonSet (SO< PolygonSet > poly) |
| Ensures that the PolygonSet passes the isValid() test. | |
| static bool | isSimpleTriangleMesh (const PolygonSet *mesh) |
| Some mesh operations require that a PolygonSet defines a triangle mesh in a simple form, i.e. | |
| *static void | computeFaceNormals (PolygonSet *mesh) |
| The current implementation has the same restrictions as mergePolygonSets() (see above). | |
| static void | invertNormals (PolygonSet *mesh) |
| Inverts current vertex normals. | |
| static void | computeVertexNormals (PolygonSet *mesh) |
| The method works only for indexed polygon sets. | |
| static void | computeSmoothingNormals (PolygonSet *mesh, double maxAngle=30.0) |
| This method calculates face or vertex normals depending on the angle between normals of corners sharing a vertex. | |
| static void | computeSphericalTexCoords (PolygonSet *mesh, const Vector ¢er) |
| Creates analytical texture coordinates based on two-part mapping with a sphere as intermediate object. | |
| static void | computeTangents (PolygonSet *mesh) |
| Computes tangents for PolygonSet. | |
| static Vector | getTriangleNormal (const Vector &a, const Vector &b, const Vector &c) |
| Returns the normal of the oriented triangle (a,b,c). | |
| static void | transformPolygonSet (PolygonSet *mesh, const Matrix &matrix) |
| Multiplies each vertex of mesh with matrix. | |
| static void | compress (SO< PolygonSet > poly) |
| Compresses the data of the polygon set by storing it inside of PackedVertexIterator (gain: 50%) and PackedColorIterator (gain: 87.5%) objects. | |
| static SO< PolygonSet > | clipMesh (SO< PolygonSet > mesh, Bounds clipBounds, ClipMethod method=PolygonSetTool::CLIP_INTERSECTING_TRIANGLES) |
| static SO< PolygonSet > | clipMesh (SO< PolygonSet > poly, const Vector &onPlane, const Vector &planeNormal, PolygonSetTool::ClipMethod method=PolygonSetTool::CLIP_INTERSECTING_TRIANGLES) |
| Works as clipMesh(...) above, but for an arbitrary plane instead of a bounding volume. | |
| static PolygonSet * | createSphere (Vector midpoint, double radius, UINT subdivisions=4) |
| Creates a tesselated sphere in the form of a non-indexed polygon set with vertex normals. | |
| static PolygonSet * | extrudeEdges (const Facet *polygon, double height, bool stripes=false, Vector direction=Vector(0.0, 0.0, 0.0)) |
| Extrudes the edges of the facet to create Quads. | |
| static PolygonSet * | splitTriangles (const PolygonSet *poly, double maxEdgeLength) |
| Splits triangles in poly until the length of the longest edge of each triangle is less or equal maxEdgeLength. | |
| *static SO< PolygonSet > | filterTriangles (SO< PolygonSet > poly, const Vector &normal, double maxAngle, bool complement=false) |
| Creates a reduced copy of 'poly' containing only those triangles whose normal forms an angle alpha<=maxAngle with 'normal'. | |
| static SO< PolygonSet > | extractEdges (const PolygonSet *poly, double angle, EdgeGroup group=PolygonSetTool::HardEdge) |
| 'poly' must not be NULL. | |
| static PolygonSet * | computeNormals (const PolygonSet *poly, double length, Color color) |
| Computes the normals for all triangle vertices that can be extracted from 'poly'. | |
| static void | unifySimilarVertices (SO< PolygonSet > poly, double minDistance) |
| Changes the vertex positions of 'poly' slightly so that approximately equal vertices get exactly equal vertex positions. | |
| static VRS::SO< VRS::Iterator < VRS::Vector > > | unifySimilarVertices (VRS::Iterator< VRS::Vector > *vertices, double minDistance) |
| Sets vertices with similar positions to the same position. | |
| static VRS::SO< VRS::Iterator < VRS::SO< VRS::Iterator < VRS::Vector > > > > | unifySimilarVerticesInMultipleItems (VRS::SO< VRS::Iterator< VRS::SO< VRS::Iterator< VRS::Vector > > > > items, double minDistance) |
| Sets vertices with similar positions to the same position and maintains structure. | |
| static SO< PolygonSet > | extrudeSurface (SO< PolygonSet > surface, const Vector &shift, bool createTopSurface=true, bool createBottomSurface=true) |
| Takes a surface description (in the form of triangles) and creates the boundary of the volume obtained by extruding the surface along to a give shift vector. | |
| static SO< Iterator< SO < PolygonSet > > > | splitPolygonSet (SO< PolygonSet > poly, unsigned int maxElements=10000, bool allowSplitX=true, bool allowSplitY=true, bool allowSplitZ=true) |
| Splits the given polygon set (may be NULL => returns NULL) in several polygon sets. | |
| static SO<Facet> VRS::PolygonSetTool::removeRedundantVertices | ( | SO< Facet > | soFacet, | |
| double | toleranceDegrees = 0.0 | |||
| ) | [static] |
Removes all redundant vertices - means the ones which don't really contribute to the shape of the facet.
A vertex is redundant, if it lies on the line between its predecessor and its successor.
| soFacet | is the Facet that should be simplified | |
| toleranceDegrees | specifies the epsilon in degrees that is respected. Must be >=0.0 |
| static SO<PolygonSet> VRS::PolygonSetTool::tesselateFacet | ( | SO< Facet > | facet, | |
| const Vector & | forceNormal = Vector::origin | |||
| ) | [static] |
Tesselates a facet in respect to an optional normal vector (assumes (0, 1, 0) if not explictely specified).
Note: can return NULL for facets with several loops and degerented cases! Use VRS::PolygonSetBuilderGL::create() then...
| static void VRS::PolygonSetTool::copy | ( | const PolygonSet * | source, | |
| PolygonSet * | dest, | |||
| bool | deepCopy = true | |||
| ) | [static] |
Creates an independent copy of the source PolygonSet, overwriting it into the dest PolygonSet. dest must be non-NULL.
| static PolygonSet* VRS::PolygonSetTool::copy | ( | const PolygonSet * | poly, | |
| bool | deepCopy = true | |||
| ) | [static] |
Creates an independent copy of a given PolygonSet, i.e. all data contained in poly is copied and assigned to the returned PolygonSet.
| static PolygonSet* VRS::PolygonSetTool::mergePolygonSets | ( | Iterator< SO< PolygonSet > > * | polys | ) | [static] |
Merges a sequence of PolygonSets to a single output PolygonSet.
The sequence must not contain null pointers. If the sum of all vertices/indices of all PolygonSets is 0, NULL is returned. NOTE: All PolygonSets must define the same attributes. Edgeflags are not supported yet.
| static SO<Iterator<SO<PolygonSet> > > VRS::PolygonSetTool::forceMerge | ( | SO< Iterator< SO< PolygonSet > > > | meshes, | |
| bool | indexed, | |||
| int | maxVertices = 65535 | |||
| ) | [static] |
Merges all given PolygonSets into a minimum set of combined PolygonSets.
The results contain exclusively triangles and are either all indexed or all non-indexed, dependent on the parameter. Points and Lines are discarded.
| static SO<PolygonSet> VRS::PolygonSetTool::forceTriangleMerge | ( | SO< Iterator< SO< PolygonSet > > > | polys, | |
| bool | indexed | |||
| ) | [static] |
Similar to forceMerge, but not lossless:.
Here, all polygonsets are guaranteed to be merged into a single one. This is, however, impossible for the general case, because polygonsets might define different vertex attributes. Therefore, this method combines ONLY THE TRIANGLES (i.e. their vertex positions) contained in the polygonset. ALL OTHER INFORMATION IS LOST, i.e. any vertex attributes or any edges or points are lost.
| static bool VRS::PolygonSetTool::canBeMerged | ( | PolygonSet * | poly1, | |
| PolygonSet * | poly2, | |||
| bool | considerEfficiency = true | |||
| ) | [static] |
Checks for two PolygonSets, whether they can be merged using the mergePolygonSet() method.
If 'considerEfficiency' is true, the method returns true even if it is theoretically possible to merge polygonsets, but it is no performance advantage. (E.g. if you merge triangles and quads).
| static SO<PolygonSet> VRS::PolygonSetTool::convertToIndexedForm | ( | SO< PolygonSet > | poly, | |
| bool | packData = false | |||
| ) | [static] |
Conversion between indexed and non-indexed form.
| static SO<PolygonSet> VRS::PolygonSetTool::convertToTrivialIndexedForm | ( | SO< PolygonSet > | poly | ) | [static] |
Adds a trivial index iterator to the polygon set if no index iterator is set.
The trivial index iterator enumerates from 0 to the number of vertices minus 1.
| * static SO<PolygonSet> VRS::PolygonSetTool::convertToNonIndexedForm | ( | SO< PolygonSet > | poly, | |
| bool | packData = false | |||
| ) | [static] |
Conversion to non-indexed form is quite simple (in O(indices) time),.
but the other way round requires O(n*log n), where n is the number of vertices.
| poly | If a PolygonSet already has the required form (indexed or non-indexed) the method simply returns the original pointer, otherwise, a copy of the mesh is created. | |
| packData | The flag "packData" indicates, if PackedVertexIterator and PackedColorIterator should be used for storing the resulting vertex data (reduces the memory footprint but may slow down the data access a little bit). |
| static PolygonSet* VRS::PolygonSetTool::invertOrientation | ( | const PolygonSet * | poly | ) | [static] |
Inverts each single triangle contained in a PolygonSet.
Note: The current implementation only supports PolygonSets containing a single range of type PolygonSet::Triangles
| static PolygonSet* VRS::PolygonSetTool::extractTriangleMesh | ( | const PolygonSet * | mesh, | |
| bool | removeUnusedVertices = false | |||
| ) | [static] |
Extracts all triangles contained in "mesh".
Single triangles in "mesh" are simply copied. points and lines are ignored. All other primtives are tesselated. If some vertices are only indexed by points or lines or not indexed at all, they can be removed. This is enabled by 'removeUnusedVertices'. If it is set to false, all vector and color iterators of 'mesh' are directly copied into the resulting triangle mesh. Note: The result is ALWAYS indexed!
| static bool VRS::PolygonSetTool::isValid | ( | const PolygonSet * | poly | ) | [static] |
Checks if the PolygonSet fulfills some conditions.
There are some possible properties of polygon sets that normally should not occur and that lead to problems in some operations. A polygon set P is considered valid if:
| static void VRS::PolygonSetTool::ValidatePolygonSet | ( | SO< PolygonSet > | poly | ) | [static] |
Ensures that the PolygonSet passes the isValid() test.
Note: The method avoids crashes, but cannot repair missing data, e.g., incomplete vertex attributes can only be completed with 0-values.
| static bool VRS::PolygonSetTool::isSimpleTriangleMesh | ( | const PolygonSet * | mesh | ) | [static] |
Some mesh operations require that a PolygonSet defines a triangle mesh in a simple form, i.e.
| * static void VRS::PolygonSetTool::computeFaceNormals | ( | PolygonSet * | mesh | ) | [static] |
The current implementation has the same restrictions as mergePolygonSets() (see above).
It assigns the CCW normal of a triangle to all its vertices.
| static void VRS::PolygonSetTool::invertNormals | ( | PolygonSet * | mesh | ) | [static] |
Inverts current vertex normals.
| static void VRS::PolygonSetTool::computeVertexNormals | ( | PolygonSet * | mesh | ) | [static] |
The method works only for indexed polygon sets.
| static void VRS::PolygonSetTool::computeSmoothingNormals | ( | PolygonSet * | mesh, | |
| double | maxAngle = 30.0 | |||
| ) | [static] |
This method calculates face or vertex normals depending on the angle between normals of corners sharing a vertex.
The expected mesh must consist of triangles and should not be indexed. Indexed meshes are automatically converted. For faces whose normals have an angle < maxAngle, vertex normals will be calculated. For faces whose normals have an angle > maxAngle, face normals will be calculated.
| static void VRS::PolygonSetTool::computeSphericalTexCoords | ( | PolygonSet * | mesh, | |
| const Vector & | center | |||
| ) | [static] |
Creates analytical texture coordinates based on two-part mapping with a sphere as intermediate object.
| static void VRS::PolygonSetTool::computeTangents | ( | PolygonSet * | mesh | ) | [static] |
Computes tangents for PolygonSet.
The method works for indexed or non-indexed polygon sets, which contain a single range of triangles. The input polygon set must already provide normals and texture coordinates. The implementation is based on a post on www.opengl.org by Eric Lengyel. http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/011349.html
| Vector VRS::PolygonSetTool::getTriangleNormal | ( | const Vector & | a, | |
| const Vector & | b, | |||
| const Vector & | c | |||
| ) | [inline, static] |
Returns the normal of the oriented triangle (a,b,c).
| static void VRS::PolygonSetTool::transformPolygonSet | ( | PolygonSet * | mesh, | |
| const Matrix & | matrix | |||
| ) | [static] |
Multiplies each vertex of mesh with matrix.
If the mesh contains normals, they are transformed accordingly with (matrix^{-1})^T. Note that special vertex data is not appropriately transformed, e.g. binormals etc.
| static void VRS::PolygonSetTool::compress | ( | SO< PolygonSet > | poly | ) | [static] |
Compresses the data of the polygon set by storing it inside of PackedVertexIterator (gain: 50%) and PackedColorIterator (gain: 87.5%) objects.
| VRS::PolygonSetTool::VRS_SERIALIZABLE_CLASS_ENUM | ( | ClipMethod | ) |
| static SO<PolygonSet> VRS::PolygonSetTool::clipMesh | ( | SO< PolygonSet > | mesh, | |
| Bounds | clipBounds, | |||
| ClipMethod | method = PolygonSetTool::CLIP_INTERSECTING_TRIANGLES | |||
| ) | [static] |
Clips a PolygonSet against a given bounding box. The third parameter specifies how to handle triangles that lies partially but not completely inside the clipBounds. They can be removed, kept or exactly clipped. Note: Internally, the method works only for triangles. So, points and lines are removed, triangle strips and fans are converted into triangles, and indexed shapes are converted to non-indexed form.
If the result is emtpy, the return value is NULL.
| static SO<PolygonSet> VRS::PolygonSetTool::clipMesh | ( | SO< PolygonSet > | poly, | |
| const Vector & | onPlane, | |||
| const Vector & | planeNormal, | |||
| PolygonSetTool::ClipMethod | method = PolygonSetTool::CLIP_INTERSECTING_TRIANGLES | |||
| ) | [static] |
Works as clipMesh(...) above, but for an arbitrary plane instead of a bounding volume.
| static PolygonSet* VRS::PolygonSetTool::createSphere | ( | Vector | midpoint, | |
| double | radius, | |||
| UINT | subdivisions = 4 | |||
| ) | [static] |
Creates a tesselated sphere in the form of a non-indexed polygon set with vertex normals.
| static PolygonSet* VRS::PolygonSetTool::extrudeEdges | ( | const Facet * | polygon, | |
| double | height, | |||
| bool | stripes = false, |
|||
| Vector | direction = Vector(0.0, 0.0, 0.0) | |||
| ) | [static] |
Extrudes the edges of the facet to create Quads.
For each edge of polygon the resulting polygon set contains a quad resulting from extruding the polygon edge into the direction of polygon->normal(). The orientation of the quads is chosen in a way that the ccw normals of the quads point outside the polygon. To force the planarity of the given polygon, the points are first projected onto the plane defined by polygon->normal() and the first vertex of the polygon.
| stripes | If strips is true, the resulting polygon set contains multiple ranges with quadstrips, otherwise a single range of quads. | |
| direction | If a direction is provided, the edges are extruded into this direction. If direction is (0.0, 0.0, 0.0), polygon->normal() is used as described above. |
| static PolygonSet* VRS::PolygonSetTool::splitTriangles | ( | const PolygonSet * | poly, | |
| double | maxEdgeLength | |||
| ) | [static] |
Splits triangles in poly until the length of the longest edge of each triangle is less or equal maxEdgeLength.
Note:
| * static SO<PolygonSet> VRS::PolygonSetTool::filterTriangles | ( | SO< PolygonSet > | poly, | |
| const Vector & | normal, | |||
| double | maxAngle, | |||
| bool | complement = false | |||
| ) | [static] |
Creates a reduced copy of 'poly' containing only those triangles whose normal forms an angle alpha<=maxAngle with 'normal'.
If complement is true, the returned PolygonSet contains all other triangles. 'maxAngle' is in degrees. Note:
| static SO<PolygonSet> VRS::PolygonSetTool::extractEdges | ( | const PolygonSet * | poly, | |
| double | angle, | |||
| EdgeGroup | group = PolygonSetTool::HardEdge | |||
| ) | [static] |
'poly' must not be NULL.
It must contain a single range of indexed triangles. The return value is a PolygonSet containing lines. Each edge of 'poly' that is belongs to the given edge group is extracted. 'angle' is specified in degrees.
| static PolygonSet* VRS::PolygonSetTool::computeNormals | ( | const PolygonSet * | poly, | |
| double | length, | |||
| Color | color | |||
| ) | [static] |
Computes the normals for all triangle vertices that can be extracted from 'poly'.
Therefore 'poly' must have a normal iterator. Normals are stored as Polygonset of type PolygonSet::Lines, lines have the specified 'length' and 'color'.
| static void VRS::PolygonSetTool::unifySimilarVertices | ( | SO< PolygonSet > | poly, | |
| double | minDistance | |||
| ) | [static] |
Changes the vertex positions of 'poly' slightly so that approximately equal vertices get exactly equal vertex positions.
'minDistance' must be chosen small enough to avoid unintended collapsing of edges or vertex pairs. This method is useful for non-indexed meshes. The unification of vertices allows a subsequent call of convertToIndexedForm() to connect the topology properly, which does not work if topological equal vertices are slightly different.
| static VRS::SO<VRS::Iterator<VRS::Vector> > VRS::PolygonSetTool::unifySimilarVertices | ( | VRS::Iterator< VRS::Vector > * | vertices, | |
| double | minDistance | |||
| ) | [static] |
Sets vertices with similar positions to the same position.
| vertices | must not be NULL | |
| minDistance |
| static VRS::SO<VRS::Iterator<VRS::SO<VRS::Iterator<VRS::Vector> > > > VRS::PolygonSetTool::unifySimilarVerticesInMultipleItems | ( | VRS::SO< VRS::Iterator< VRS::SO< VRS::Iterator< VRS::Vector > > > > | items, | |
| double | minDistance | |||
| ) | [static] |
Sets vertices with similar positions to the same position and maintains structure.
Convenience function to maintain relation of vertices belonging to different items, e.g., polygonsets
| items | must not be NULL | |
| minDistance |
| static SO<PolygonSet> VRS::PolygonSetTool::extrudeSurface | ( | SO< PolygonSet > | surface, | |
| const Vector & | shift, | |||
| bool | createTopSurface = true, |
|||
| bool | createBottomSurface = true | |||
| ) | [static] |
Takes a surface description (in the form of triangles) and creates the boundary of the volume obtained by extruding the surface along to a give shift vector.
The surface need not to be planar.
| static SO<Iterator<SO<PolygonSet> > > VRS::PolygonSetTool::splitPolygonSet | ( | SO< PolygonSet > | poly, | |
| unsigned int | maxElements = 10000, |
|||
| bool | allowSplitX = true, |
|||
| bool | allowSplitY = true, |
|||
| bool | allowSplitZ = true | |||
| ) | [static] |
Splits the given polygon set (may be NULL => returns NULL) in several polygon sets.
The resulting polygon sets have at most "maxElement" vertices. The "allowSplit*" parameters specify along which coordinate axis splits are allowed.