From b9895df36f782b362180efe520adcfa8a4b4e35e Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sat, 27 Jun 2015 22:07:51 +0900 Subject: Freestyle: internal switch from double to float in mesh loading and construction of winged edges. --- .../freestyle/intern/geometry/GeomCleaner.cpp | 48 +++++++++++----------- .../freestyle/intern/geometry/GeomCleaner.h | 26 ++++++------ 2 files changed, 37 insertions(+), 37 deletions(-) (limited to 'source/blender/freestyle/intern/geometry') diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp index acbc668118e..c5d1c8df17b 100644 --- a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp +++ b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp @@ -50,13 +50,13 @@ using namespace std; namespace Freestyle { void GeomCleaner::SortIndexedVertexArray(const float *iVertices, unsigned iVSize, const unsigned *iIndices, - unsigned iISize, real **oVertices, unsigned **oIndices) + unsigned iISize, float **oVertices, unsigned **oIndices) { // First, we build a list of IndexVertex: list indexedVertices; unsigned i; for (i = 0; i < iVSize; i += 3) { - indexedVertices.push_back(IndexedVertex(Vec3r(iVertices[i], iVertices[i + 1], iVertices[i + 2]), i / 3)); + indexedVertices.push_back(IndexedVertex(Vec3f(iVertices[i], iVertices[i + 1], iVertices[i + 2]), i / 3)); } // q-sort @@ -64,7 +64,7 @@ void GeomCleaner::SortIndexedVertexArray(const float *iVertices, unsigned iVSize // build the indices mapping array: unsigned *mapIndices = new unsigned[iVSize / 3]; - *oVertices = new real[iVSize]; + *oVertices = new float[iVSize]; list::iterator iv; unsigned newIndex = 0; unsigned vIndex = 0; @@ -88,26 +88,26 @@ void GeomCleaner::SortIndexedVertexArray(const float *iVertices, unsigned iVSize delete [] mapIndices; } -void GeomCleaner::CompressIndexedVertexArray(const real *iVertices, unsigned iVSize, const unsigned *iIndices, - unsigned iISize, real **oVertices, unsigned *oVSize, unsigned **oIndices) +void GeomCleaner::CompressIndexedVertexArray(const float *iVertices, unsigned iVSize, const unsigned *iIndices, + unsigned iISize, float **oVertices, unsigned *oVSize, unsigned **oIndices) { // First, we build a list of IndexVertex: - vector vertices; + vector vertices; unsigned i; for (i = 0; i < iVSize; i += 3) { - vertices.push_back(Vec3r(iVertices[i], iVertices[i + 1], iVertices[i + 2])); + vertices.push_back(Vec3f(iVertices[i], iVertices[i + 1], iVertices[i + 2])); } unsigned *mapVertex = new unsigned[iVSize]; - vector::iterator v = vertices.begin(); + vector::iterator v = vertices.begin(); - vector compressedVertices; - Vec3r previous = *v; + vector compressedVertices; + Vec3f previous = *v; mapVertex[0] = 0; compressedVertices.push_back(vertices.front()); v++; - Vec3r current; + Vec3f current; i = 1; for (; v != vertices.end(); v++) { current = *v; @@ -123,7 +123,7 @@ void GeomCleaner::CompressIndexedVertexArray(const real *iVertices, unsigned iVS // Builds the resulting vertex array: *oVSize = 3 * compressedVertices.size(); - *oVertices = new real[*oVSize]; + *oVertices = new float[*oVSize]; i = 0; for (v = compressedVertices.begin(); v != compressedVertices.end(); v++) { (*oVertices)[i] = (*v)[0]; @@ -142,11 +142,11 @@ void GeomCleaner::CompressIndexedVertexArray(const real *iVertices, unsigned iVS } void GeomCleaner::SortAndCompressIndexedVertexArray(const float *iVertices, unsigned iVSize, const unsigned *iIndices, - unsigned iISize, real **oVertices, unsigned *oVSize, + unsigned iISize, float **oVertices, unsigned *oVSize, unsigned **oIndices) { // tmp arrays used to store the sorted data: - real *tmpVertices; + float *tmpVertices; unsigned *tmpIndices; Chronometer chrono; @@ -154,7 +154,7 @@ void GeomCleaner::SortAndCompressIndexedVertexArray(const float *iVertices, unsi chrono.start(); GeomCleaner::SortIndexedVertexArray(iVertices, iVSize, iIndices, iISize, &tmpVertices, &tmpIndices); if (G.debug & G_DEBUG_FREESTYLE) { - printf("Sorting: %lf\n", chrono.stop()); + printf("Sorting: %lf sec.\n", chrono.stop()); } // compress data @@ -162,7 +162,7 @@ void GeomCleaner::SortAndCompressIndexedVertexArray(const float *iVertices, unsi GeomCleaner::CompressIndexedVertexArray(tmpVertices, iVSize, tmpIndices, iISize, oVertices, oVSize, oIndices); real duration = chrono.stop(); if (G.debug & G_DEBUG_FREESTYLE) { - printf("Merging: %lf\n", duration); + printf("Merging: %lf sec.\n", duration); } // deallocates memory: @@ -185,22 +185,22 @@ struct GeomCleanerHasher { }; void GeomCleaner::CleanIndexedVertexArray(const float *iVertices, unsigned iVSize, const unsigned *iIndices, - unsigned iISize, real **oVertices, unsigned *oVSize, unsigned **oIndices) + unsigned iISize, float **oVertices, unsigned *oVSize, unsigned **oIndices) { - typedef map cleanHashTable; - vector vertices; + typedef map cleanHashTable; + vector vertices; unsigned i; for (i = 0; i < iVSize; i += 3) - vertices.push_back(Vec3r(iVertices[i], iVertices[i + 1], iVertices[i + 2])); + vertices.push_back(Vec3f(iVertices[i], iVertices[i + 1], iVertices[i + 2])); cleanHashTable ht; vector newIndices; - vector newVertices; + vector newVertices; // elimination of needless points unsigned currentIndex = 0; - vector::const_iterator v = vertices.begin(); - vector::const_iterator end = vertices.end(); + vector::const_iterator v = vertices.begin(); + vector::const_iterator end = vertices.end(); cleanHashTable::const_iterator found; for (; v != end; v++) { found = ht.find(*v); @@ -218,7 +218,7 @@ void GeomCleaner::CleanIndexedVertexArray(const float *iVertices, unsigned iVSiz // creation of oVertices array: *oVSize = 3 * newVertices.size(); - *oVertices = new real[*oVSize]; + *oVertices = new float[*oVSize]; currentIndex = 0; end = newVertices.end(); for (v = newVertices.begin(); v != end ; v++) { diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.h b/source/blender/freestyle/intern/geometry/GeomCleaner.h index d516c5623b9..aeca592a8c4 100644 --- a/source/blender/freestyle/intern/geometry/GeomCleaner.h +++ b/source/blender/freestyle/intern/geometry/GeomCleaner.h @@ -64,7 +64,7 @@ public: * Output corresponding to the iIndices array but reorganized in order to match the sorted vertex array. */ static void SortIndexedVertexArray(const float *iVertices, unsigned iVSize, const unsigned *iIndices, - unsigned iISize, real **oVertices, unsigned **oIndices); + unsigned iISize, float **oVertices, unsigned **oIndices); /*! Compress a SORTED indexed vertex array by eliminating multiple appearing occurences of a single vertex. * iVertices @@ -84,8 +84,8 @@ public: * oIndices * The indices array, reorganized to match the compressed oVertices array. */ - static void CompressIndexedVertexArray(const real *iVertices, unsigned iVSize, const unsigned *iIndices, - unsigned iISize, real **oVertices, unsigned *oVSize, unsigned **oIndices); + static void CompressIndexedVertexArray(const float *iVertices, unsigned iVSize, const unsigned *iIndices, + unsigned iISize, float **oVertices, unsigned *oVSize, unsigned **oIndices); /*! Sorts and compress an array of indexed vertices. * iVertices @@ -107,7 +107,7 @@ public: * The indices array, reorganized to match the sorted and compressed oVertices array. */ static void SortAndCompressIndexedVertexArray(const float *iVertices, unsigned iVSize, const unsigned *iIndices, - unsigned iISize, real **oVertices, unsigned *oVSize, + unsigned iISize, float **oVertices, unsigned *oVSize, unsigned **oIndices); /*! Cleans an indexed vertex array. (Identical to SortAndCompress except that we use here a hash table @@ -131,7 +131,7 @@ public: * The indices array, reorganized to match the sorted and compressed oVertices array. */ static void CleanIndexedVertexArray(const float *iVertices, unsigned iVSize, const unsigned *iIndices, - unsigned iISize, real **oVertices, unsigned *oVSize, unsigned **oIndices); + unsigned iISize, float **oVertices, unsigned *oVSize, unsigned **oIndices); #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:GeomCleaner") @@ -146,20 +146,20 @@ public: class IndexedVertex { private: - Vec3r _Vector; + Vec3f _Vector; unsigned _index; public: inline IndexedVertex() {} - inline IndexedVertex(Vec3r iVector, unsigned iIndex) + inline IndexedVertex(Vec3f iVector, unsigned iIndex) { _Vector = iVector; _index = iIndex; } /*! accessors */ - inline const Vec3r& vector() const + inline const Vec3f& vector() const { return _Vector; } @@ -169,23 +169,23 @@ public: return _index; } - inline real x() + inline float x() { return _Vector[0]; } - inline real y() + inline float y() { return _Vector[1]; } - inline real z() + inline float z() { return _Vector[2]; } /*! modifiers */ - inline void setVector(const Vec3r& iVector) + inline void setVector(const Vec3f& iVector) { _Vector = iVector; } @@ -203,7 +203,7 @@ public: return *this; } - inline real operator[](const unsigned i) + inline float operator[](const unsigned i) { return _Vector[i]; } -- cgit v1.2.3