# 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 ()
void | simplify ()
void | simplify (const std::vector< fvec3 > &in_verts, const std::vector< int > &in_tris)
void | setIntput (Geometry *geom)
Geometry * | input ()
const Geometry * | input () const
std::vector< u32 > & | targets ()
const std::vector< u32 > & | targets () const
std::vector< ref< Geometry > > & | output ()
const std::vector< ref < Geometry > > & | output () const
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 | outputSimplifiedGeometry ()
void | collapse (Vertex *v)
void | computeCollapseInfo (Vertex *v)

## Protected Attributes

ref< Geometry > | mInput
std::vector< ref< Geometry > > | mOutput
std::vector< u32 > | mTargets
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 321 of file PolygonSimplifier.hpp.

## Member Function Documentation

void PolygonSimplifier::simplify | ( | ) |

Definition at line 70 of file PolygonSimplifier.cpp.

References vl::Time::elapsed(), vl::Log::error(), vl::ref< T >::get(), vl::ArrayAbstract::getAsVec3(), vl::TriangleIterator::hasNext(), mInput, NULL, vl::Log::print(), vl::PT_TRIANGLES, vl::DoubleVertexRemover::removeDoubles(), removeDoubles(), vl::ArrayAbstract::size(), vl::Time::start(), vl::DrawCall::triangleIterator(), vl::VA_Position, verbose(), VL_MAX_TEXTURE_UNITS, and vl::Log::warning().

void PolygonSimplifier::simplify | ( | const std::vector< fvec3 > & | in_verts,
|  | const std::vector< int > & | in_tris
| ) |  |

Definition at line 145 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, mTargets, output(), outputSimplifiedGeometry(), vl::Log::print(), vl::PolygonSimplifier::Vertex::removed(), vl::Time::start(), vl::VA_Position, verbose(), and VL_CHECK.

void vl::PolygonSimplifier::setIntput | ( | Geometry * | geom ) | `[inline]`

Definition at line 326 of file PolygonSimplifier.hpp.

Geometry* vl::PolygonSimplifier::input | ( | ) | `[inline]`

Definition at line 327 of file PolygonSimplifier.hpp.

const Geometry* vl::PolygonSimplifier::input | ( | ) | const`[inline]`

Definition at line 328 of file PolygonSimplifier.hpp.

std::vector< u32 >& vl::PolygonSimplifier::targets | ( | ) | `[inline]`

Definition at line 330 of file PolygonSimplifier.hpp.

const std::vector< u32 >& vl::PolygonSimplifier::targets | ( | ) | const`[inline]`

Definition at line 331 of file PolygonSimplifier.hpp.

std::vector< ref<Geometry> >& vl::PolygonSimplifier::output | ( | ) | `[inline]`

Definition at line 333 of file PolygonSimplifier.hpp.

Referenced by simplify().

const std::vector< ref<Geometry> >& vl::PolygonSimplifier::output | ( | ) | const`[inline]`

Definition at line 334 of file PolygonSimplifier.hpp.

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

Definition at line 336 of file PolygonSimplifier.hpp.

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

Definition at line 338 of file PolygonSimplifier.hpp.

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

Definition at line 339 of file PolygonSimplifier.hpp.

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

Definition at line 341 of file PolygonSimplifier.hpp.

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

Definition at line 342 of file PolygonSimplifier.hpp.

void PolygonSimplifier::clearTrianglesAndVertices | ( | ) |

Definition at line 412 of file PolygonSimplifier.cpp.

References mProtectedVerts, mSimplifiedTriangles, and mSimplifiedVertices.

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

Definition at line 346 of file PolygonSimplifier.hpp.

Referenced by simplify().

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

Definition at line 347 of file PolygonSimplifier.hpp.

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

Definition at line 349 of file PolygonSimplifier.hpp.

Referenced by simplify().

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

Definition at line 350 of file PolygonSimplifier.hpp.

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

Definition at line 352 of file PolygonSimplifier.hpp.

Referenced by collapse(), and computeCollapseInfo().

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

Definition at line 353 of file PolygonSimplifier.hpp.

void PolygonSimplifier::outputSimplifiedGeometry | ( | ) | `[protected]`

Definition at line 359 of file PolygonSimplifier.cpp.

References vl::ref< T >::get(), mInput, mOutput, mSimplifiedTriangles, mSimplifiedVertices, vl::PT_TRIANGLES, vl::VA_Position, and VL_CHECK.

Referenced by simplify().

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

Definition at line 607 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 696 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(), NULL, vl::PolygonSimplifier::Vertex::position(), vl::PolygonSimplifier::Vertex::qerr(), quick(), vl::PolygonSimplifier::Triangle::vertex(), and VL_CHECK.

Referenced by simplify().

## Member Data Documentation

ref<Geometry> vl::PolygonSimplifier::mInput`[protected]`

Definition at line 361 of file PolygonSimplifier.hpp.

Referenced by outputSimplifiedGeometry(), and simplify().

std::vector< ref<Geometry> > vl::PolygonSimplifier::mOutput`[protected]`

Definition at line 362 of file PolygonSimplifier.hpp.

Referenced by outputSimplifiedGeometry().

std::vector< u32 > vl::PolygonSimplifier::mTargets`[protected]`

Definition at line 363 of file PolygonSimplifier.hpp.

Referenced by simplify().

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

Definition at line 364 of file PolygonSimplifier.hpp.

Referenced by clearTrianglesAndVertices(), outputSimplifiedGeometry(), and simplify().

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

Definition at line 365 of file PolygonSimplifier.hpp.

Referenced by clearTrianglesAndVertices(), outputSimplifiedGeometry(), and simplify().

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

Definition at line 366 of file PolygonSimplifier.hpp.

Referenced by clearTrianglesAndVertices(), and simplify().

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

Definition at line 367 of file PolygonSimplifier.hpp.

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

Definition at line 368 of file PolygonSimplifier.hpp.

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

Definition at line 369 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.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:44:43.
Permission is granted to use this page to write and publish articles regarding Visualization Library.