diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/freestyle/intern/image/GaussianFilter.cpp | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/freestyle/intern/image/GaussianFilter.cpp')
-rw-r--r-- | source/blender/freestyle/intern/image/GaussianFilter.cpp | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/source/blender/freestyle/intern/image/GaussianFilter.cpp b/source/blender/freestyle/intern/image/GaussianFilter.cpp index 540c3392aa3..8a14fe4e6dd 100644 --- a/source/blender/freestyle/intern/image/GaussianFilter.cpp +++ b/source/blender/freestyle/intern/image/GaussianFilter.cpp @@ -27,77 +27,76 @@ namespace Freestyle { GaussianFilter::GaussianFilter(float iSigma) { - _sigma = iSigma; - _mask = 0; - computeMask(); + _sigma = iSigma; + _mask = 0; + computeMask(); } -GaussianFilter::GaussianFilter(const GaussianFilter& iBrother) +GaussianFilter::GaussianFilter(const GaussianFilter &iBrother) { - _sigma = iBrother._sigma; - _maskSize = iBrother._maskSize; - _bound = iBrother._bound; - _storedMaskSize = iBrother._storedMaskSize; - _mask = new float[_maskSize * _maskSize]; - memcpy(_mask, iBrother._mask, _maskSize * _maskSize * sizeof(float)); + _sigma = iBrother._sigma; + _maskSize = iBrother._maskSize; + _bound = iBrother._bound; + _storedMaskSize = iBrother._storedMaskSize; + _mask = new float[_maskSize * _maskSize]; + memcpy(_mask, iBrother._mask, _maskSize * _maskSize * sizeof(float)); } -GaussianFilter& GaussianFilter::operator=(const GaussianFilter& iBrother) +GaussianFilter &GaussianFilter::operator=(const GaussianFilter &iBrother) { - _sigma = iBrother._sigma; - _maskSize = iBrother._maskSize; - _bound = iBrother._bound; - _storedMaskSize = iBrother._storedMaskSize; - _mask = new float[_storedMaskSize * _storedMaskSize]; - memcpy(_mask, iBrother._mask, _storedMaskSize * _storedMaskSize * sizeof(float)); - return *this; + _sigma = iBrother._sigma; + _maskSize = iBrother._maskSize; + _bound = iBrother._bound; + _storedMaskSize = iBrother._storedMaskSize; + _mask = new float[_storedMaskSize * _storedMaskSize]; + memcpy(_mask, iBrother._mask, _storedMaskSize * _storedMaskSize * sizeof(float)); + return *this; } - GaussianFilter::~GaussianFilter() { - if (0 != _mask) { - delete[] _mask; - } + if (0 != _mask) { + delete[] _mask; + } } int GaussianFilter::computeMaskSize(float sigma) { - int maskSize = (int)floor(4 * sigma) + 1; - if (0 == (maskSize % 2)) - ++maskSize; + int maskSize = (int)floor(4 * sigma) + 1; + if (0 == (maskSize % 2)) + ++maskSize; - return maskSize; + return maskSize; } void GaussianFilter::setSigma(float sigma) { - _sigma = sigma; - computeMask(); + _sigma = sigma; + computeMask(); } void GaussianFilter::computeMask() { - if (0 != _mask) { - delete[] _mask; - } - - _maskSize = computeMaskSize(_sigma); - _storedMaskSize = (_maskSize + 1) >> 1; - _bound = _storedMaskSize - 1; - - float norm = _sigma * _sigma * 2.0f * M_PI; - float invNorm = 1.0f / norm; - _mask = new float[_storedMaskSize * _storedMaskSize * sizeof(float)]; - for (int i = 0; i < _storedMaskSize; ++i) { - for (int j = 0; j < _storedMaskSize; ++j) { + if (0 != _mask) { + delete[] _mask; + } + + _maskSize = computeMaskSize(_sigma); + _storedMaskSize = (_maskSize + 1) >> 1; + _bound = _storedMaskSize - 1; + + float norm = _sigma * _sigma * 2.0f * M_PI; + float invNorm = 1.0f / norm; + _mask = new float[_storedMaskSize * _storedMaskSize * sizeof(float)]; + for (int i = 0; i < _storedMaskSize; ++i) { + for (int j = 0; j < _storedMaskSize; ++j) { #if 0 - _mask[i * _storedMaskSize + j] = exp(-(i * i + j * j) / (2.0 * _sigma * _sigma)); + _mask[i * _storedMaskSize + j] = exp(-(i * i + j * j) / (2.0 * _sigma * _sigma)); #else - _mask[i * _storedMaskSize + j] = invNorm * exp(-(i * i + j * j) / (2.0 * _sigma * _sigma)); + _mask[i * _storedMaskSize + j] = invNorm * exp(-(i * i + j * j) / (2.0 * _sigma * _sigma)); #endif - } - } + } + } } } /* namespace Freestyle */ |