Browse Source

Using operator() instead of run() in MeshTools.

In other words I finally discovered how to work around C++'s most vexing
parse.
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
f7ba048c06
  1. 6
      src/MeshTools/Clean.h
  2. 6
      src/MeshTools/Subdivide.h
  3. 2
      src/MeshTools/Tipsify.cpp
  4. 8
      src/MeshTools/Tipsify.h

6
src/MeshTools/Clean.h

@ -38,7 +38,7 @@ template<class Vertex, size_t vertexSize = Vertex::Size> class Clean: public Abs
*
* See clean() for full documentation.
*/
void run(typename Vertex::Type epsilon = TypeTraits<typename Vertex::Type>::epsilon()) {
void operator()(typename Vertex::Type epsilon = TypeTraits<typename Vertex::Type>::epsilon()) {
if(this->indices.empty()) return;
/* Get mesh bounds */
@ -136,7 +136,7 @@ This is convenience function supplementing direct usage of Clean class,
instead of
@code
MeshBuilder<T> builder;
MeshTools::Clean<T>(builder).run(epsilon);
MeshTools::Clean<T>{builder}(epsilon);
@endcode
you can just write
@code
@ -149,7 +149,7 @@ MeshTools::clean<T, 3>(builder, epsilon);
@endcode
*/
template<class Vertex, size_t vertexSize = Vertex::Size> inline void clean(MeshBuilder<Vertex>& builder, typename Vertex::Type epsilon = TypeTraits<typename Vertex::Type>::epsilon()) {
Clean<Vertex, vertexSize>(builder).run(epsilon);
Clean<Vertex, vertexSize>{builder}(epsilon);
}
}}

6
src/MeshTools/Subdivide.h

@ -38,7 +38,7 @@ template<class Vertex, class Interpolator> class Subdivide: public AbstractTool<
*
* See subdivide() for full documentation.
*/
void run(Interpolator interpolator) {
void operator()(Interpolator interpolator) {
size_t indexCount = this->indices.size();
this->indices.reserve(this->indices.size()*4);
@ -86,7 +86,7 @@ This is convenience function supplementing direct usage of Subdivide class,
instead of
@code
MeshBuilder<T> builder;
MeshTools::Subdivide<T, Interpolator>(builder).run(interpolator);
MeshTools::Subdivide<T, Interpolator>{builder}(interpolator);
@endcode
you can just write
@code
@ -94,7 +94,7 @@ MeshTools::subdivide(builder, interpolator);
@endcode
*/
template<class Vertex, class Interpolator> inline void subdivide(MeshBuilder<Vertex>& builder, Interpolator interpolator) {
Subdivide<Vertex, Interpolator>(builder).run(interpolator);
Subdivide<Vertex, Interpolator>{builder}(interpolator);
}
}}

2
src/MeshTools/Tipsify.cpp

@ -19,7 +19,7 @@
namespace Magnum { namespace MeshTools {
void Tipsify::run(size_t cacheSize) {
void Tipsify::operator()(size_t cacheSize) {
/* Neighboring triangles for each vertex, per-vertex live triangle count */
std::vector<unsigned int> liveTriangleCount, neighborPosition, neighbors;
buildAdjacency(liveTriangleCount, neighborPosition, neighbors);

8
src/MeshTools/Tipsify.h

@ -41,7 +41,7 @@ class MESHTOOLS_EXPORT Tipsify: public AbstractIndexTool {
*
* See tipsify() for full documentation.
*/
void run(size_t cacheSize);
void operator()(size_t cacheSize);
/**
* @brief Build vertex-triangle adjacency
@ -69,7 +69,7 @@ This is convenience function supplementing direct usage of Tipsify class,
instead of
@code
MeshBuilder<T> builder;
MeshTools::Tipsify(builder).run(cacheSize);
MeshTools::Tipsify{builder}(cacheSize);
@endcode
you can just write
@code
@ -77,7 +77,7 @@ MeshTools::tipsify(builder, cacheSize);
@endcode
*/
template<class Vertex> inline void tipsify(MeshBuilder<Vertex>& builder, size_t cacheSize) {
Tipsify(builder).run(cacheSize);
Tipsify{builder}(cacheSize);
}
/**
@ -89,7 +89,7 @@ template<class Vertex> inline void tipsify(MeshBuilder<Vertex>& builder, size_t
See tipsify(MeshBuilder<Vertex>&, size_t) for more information.
*/
inline void tipsify(std::vector<unsigned int>& indices, unsigned int vertexCount, size_t cacheSize) {
Tipsify(indices, vertexCount).run(cacheSize);
Tipsify(indices, vertexCount)(cacheSize);
}
}}

Loading…
Cancel
Save