# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Classes | Public Member Functions | Protected Member Functions | Protected Attributes

# vl::PolygonSimplifier Class Reference

The PolygonSimplifier class reduces the amount of polygons present in a Geometry using a quadric error metric. More...

`#include <PolygonSimplifier.hpp>`

Inheritance diagram for vl::PolygonSimplifier:

List of all members.

## Classes

class | QErr
| The quadric error metric as defined by PolygonSimplifier. More...
class | Triangle
| A Triangle as defined by PolygonSimplifier. More...
class | Vertex
| A Vertex as defined by PolygonSimplifier. More...

## Public Member Functions

| PolygonSimplifier ()
virtual const char * | className ()
| Returns the name of the class.
void | simplify (float simplification_ratio, Geometry *geom)
void | simplify (int target_vertex_count, Geometry *geom)
void | simplify (int target_vertex_count, std::vector< fvec3 > &in_out_verts, std::vector< int > &in_out_tris)
void | setProtectedVertices (const std::vector< int > &protected_verts)
int | simplifiedVerticesCount () const
Vertex * | simplifiedVertices (int index) const
int | simplifiedTrianglesCount () const
Triangle * | simplifiedTriangles (int index) const
void | clearTrianglesAndVertices ()
bool | removeDoubles () const
void | setRemoveDoubles (bool remove_doubles)
bool | verbose () const
void | setVerbose (bool verbose)
bool | quick () const
void | setQuick (bool quick)

## Protected Member Functions

void | collapse (Vertex *v)
void | computeCollapseInfo (Vertex *v)

## Protected Attributes

std::vector< Vertex * > | mSimplifiedVertices
std::vector< Triangle * > | mSimplifiedTriangles
std::vector< int > | mProtectedVerts
bool | mRemoveDoubles
bool | mVerbose
bool | mQuick

## Detailed Description

The PolygonSimplifier class reduces the amount of polygons present in a Geometry using a quadric error metric.

The algorithm simplifies only the position array of the Geometry all the other vertex attributes will be discarded.

Definition at line 52 of file PolygonSimplifier.hpp.

## Constructor & Destructor Documentation

vl::PolygonSimplifier::PolygonSimplifier | ( | ) | `[inline]`

Definition at line 319 of file PolygonSimplifier.hpp.

## Member Function Documentation

virtual const char* vl::PolygonSimplifier::className | ( | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::Object.

Definition at line 321 of file PolygonSimplifier.hpp.

void PolygonSimplifier::simplify | ( | float | simplification_ratio,
|  | Geometry * | geom
| ) |  |

Definition at line 70 of file PolygonSimplifier.cpp.

References vl::Log::error(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::size(), and vl::Geometry::vertexArray().

Referenced by simplify().

void PolygonSimplifier::simplify | ( | int | target_vertex_count,
|  | Geometry * | geom
| ) |  |

Definition at line 87 of file PolygonSimplifier.cpp.

References vl::Collection< T >::at(), vl::Collection< T >::clear(), vl::Geometry::colorArray(), vl::Geometry::drawCalls(), vl::Time::elapsed(), vl::Log::error(), vl::Geometry::fogCoordArray(), vl::ref< T >::get(), vl::TriangleIterator::isEnd(), vl::Geometry::normalArray(), vl::Log::print(), vl::PT_TRIANGLES, vl::Collection< T >::push_back(), vl::DoubleVertexRemover::removeDoubles(), removeDoubles(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::resize(), vl::Geometry::secondaryColorArray(), vl::Geometry::setColorArray(), vl::Geometry::setFogCoordArray(), vl::Geometry::setNormalArray(), vl::Geometry::setSecondaryColorArray(), vl::Geometry::setTexCoordArray(), simplify(), vl::Collection< T >::size(), vl::Time::start(), vl::Geometry::texCoordArray(), vl::DrawCall::triangleIterator(), verbose(), vl::Geometry::vertexArray(), vl::Geometry::vertexAttribArrays(), VL_MAX_TEXTURE_UNITS, and vl::Log::warning().

void PolygonSimplifier::simplify | ( | int | target_vertex_count,
|  | std::vector< fvec3 > & | in_out_verts,
|  | std::vector< int > & | in_out_tris
| ) |  |

Definition at line 165 of file PolygonSimplifier.cpp.

References vl::PolygonSimplifier::Vertex::adjacentVertex(), vl::PolygonSimplifier::Vertex::adjacentVerticesCount(), collapse(), vl::PolygonSimplifier::Vertex::collapseVertex(), computeCollapseInfo(), vl::Time::elapsed(), vl::PolygonSimplifier::Vertex::mAlreadyProcessed, mProtectedVerts, vl::PolygonSimplifier::Vertex::mRemoveOrder, mSimplifiedTriangles, mSimplifiedVertices, vl::Log::print(), vl::PolygonSimplifier::Vertex::removed(), vl::Time::start(), verbose(), and VL_CHECK.

void vl::PolygonSimplifier::setProtectedVertices | ( | const std::vector< int > & | protected_verts ) | `[inline]`

Definition at line 327 of file PolygonSimplifier.hpp.

int vl::PolygonSimplifier::simplifiedVerticesCount | ( | ) | const`[inline]`

Definition at line 329 of file PolygonSimplifier.hpp.

Vertex* vl::PolygonSimplifier::simplifiedVertices | ( | int | index ) | const`[inline]`

Definition at line 330 of file PolygonSimplifier.hpp.

int vl::PolygonSimplifier::simplifiedTrianglesCount | ( | ) | const`[inline]`

Definition at line 332 of file PolygonSimplifier.hpp.

Triangle* vl::PolygonSimplifier::simplifiedTriangles | ( | int | index ) | const`[inline]`

Definition at line 333 of file PolygonSimplifier.hpp.

void PolygonSimplifier::clearTrianglesAndVertices | ( | ) |

Definition at line 393 of file PolygonSimplifier.cpp.

References mProtectedVerts, mSimplifiedTriangles, and mSimplifiedVertices.

bool vl::PolygonSimplifier::removeDoubles | ( | ) | const`[inline]`

Definition at line 337 of file PolygonSimplifier.hpp.

Referenced by simplify().

void vl::PolygonSimplifier::setRemoveDoubles | ( | bool | remove_doubles ) | `[inline]`

Definition at line 338 of file PolygonSimplifier.hpp.

bool vl::PolygonSimplifier::verbose | ( | ) | const`[inline]`

Definition at line 340 of file PolygonSimplifier.hpp.

Referenced by simplify().

void vl::PolygonSimplifier::setVerbose | ( | bool | verbose ) | `[inline]`

Definition at line 341 of file PolygonSimplifier.hpp.

bool vl::PolygonSimplifier::quick | ( | ) | const`[inline]`

Definition at line 343 of file PolygonSimplifier.hpp.

Referenced by collapse(), and computeCollapseInfo().

void vl::PolygonSimplifier::setQuick | ( | bool | quick ) | `[inline]`

Definition at line 344 of file PolygonSimplifier.hpp.

void vl::PolygonSimplifier::collapse | ( | Vertex * | v ) | `[inline, protected]`

Definition at line 594 of file PolygonSimplifier.hpp.

References vl::PolygonSimplifier::Vertex::adjacentVertex(), vl::PolygonSimplifier::Vertex::adjacentVerticesCount(), vl::Object::as(), vl::PolygonSimplifier::Vertex::checkConnectivity(), vl::PolygonSimplifier::Vertex::checkTriangles(), vl::PolygonSimplifier::Vertex::incidentTrianglesCount(), vl::PolygonSimplifier::Vertex::isAdjacentVertex(), vl::PolygonSimplifier::Vertex::isIncidentTriangle(), vl::PolygonSimplifier::Vertex::mAdjacentVerts, vl::PolygonSimplifier::Vertex::mCollapsePosition, vl::PolygonSimplifier::Vertex::mCollapseVertex, vl::PolygonSimplifier::Vertex::mIncidentTriangles, vl::PolygonSimplifier::Vertex::mPosition, vl::PolygonSimplifier::Vertex::mQErr, vl::PolygonSimplifier::Vertex::mRemoved, quick(), vl::PolygonSimplifier::Vertex::removed(), and VL_CHECK.

Referenced by simplify().

void vl::PolygonSimplifier::computeCollapseInfo | ( | Vertex * | v ) | `[inline, protected]`

Definition at line 683 of file PolygonSimplifier.hpp.

References vl::PolygonSimplifier::Vertex::adjacentVerticesCount(), vl::PolygonSimplifier::QErr::analyticSolution(), vl::cross(), vl::dot(), vl::PolygonSimplifier::QErr::evaluate(), vl::PolygonSimplifier::Triangle::hasVertex(), vl::PolygonSimplifier::Vertex::incidentTriangle(), vl::PolygonSimplifier::Vertex::incidentTrianglesCount(), vl::length(), vl::PolygonSimplifier::Vertex::mAdjacentVerts, vl::PolygonSimplifier::Vertex::mCollapseCost, vl::PolygonSimplifier::Vertex::mCollapsePosition, vl::PolygonSimplifier::Vertex::mCollapseVertex, vl::PolygonSimplifier::Vertex::mRemoved, vl::PolygonSimplifier::Triangle::normal(), vl::Vector3< T_Scalar >::normalize(), vl::PolygonSimplifier::Vertex::position(), vl::PolygonSimplifier::Vertex::qerr(), quick(), vl::PolygonSimplifier::Triangle::vertex(), and VL_CHECK.

Referenced by simplify().

## Member Data Documentation

std::vector<Vertex*> vl::PolygonSimplifier::mSimplifiedVertices`[protected]`

Definition at line 351 of file PolygonSimplifier.hpp.

Referenced by clearTrianglesAndVertices(), and simplify().

std::vector<Triangle*> vl::PolygonSimplifier::mSimplifiedTriangles`[protected]`

Definition at line 352 of file PolygonSimplifier.hpp.

Referenced by clearTrianglesAndVertices(), and simplify().

std::vector<int> vl::PolygonSimplifier::mProtectedVerts`[protected]`

Definition at line 353 of file PolygonSimplifier.hpp.

Referenced by clearTrianglesAndVertices(), and simplify().

bool vl::PolygonSimplifier::mRemoveDoubles`[protected]`

Definition at line 354 of file PolygonSimplifier.hpp.

bool vl::PolygonSimplifier::mVerbose`[protected]`

Definition at line 355 of file PolygonSimplifier.hpp.

bool vl::PolygonSimplifier::mQuick`[protected]`

Definition at line 356 of file PolygonSimplifier.hpp.

The documentation for this class was generated from the following files:

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/PolygonSimplifier.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/PolygonSimplifier.cpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:43.
Permission is granted to use this page to write and publish articles regarding Visualization Library.