diff --git a/ext/ghoul b/ext/ghoul index 79a336b773..6944475ee6 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 79a336b7731ca64e00ab82769c93bc799d041ed5 +Subproject commit 6944475ee6293e4dd6671800cb28953e877e1cb7 diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index cbd4fd1e67..253870f426 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -184,12 +184,12 @@ bool KameleonWrapper::open(const std::string& filename) { } void KameleonWrapper::close() { - if (_kameleon) + if (_kameleon) { _kameleon->close(); - if (_interpolator) - delete _interpolator; - if (_kameleon) - delete _kameleon; + } + + delete _interpolator; + delete _kameleon; _kameleon = nullptr; _interpolator = nullptr; @@ -202,8 +202,7 @@ float* KameleonWrapper::getUniformSampledValues( const std::string& var, const glm::size3_t& outDimensions) { - assert(_model && _interpolator); - assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO("Loading variable " << var << " from CDF data with a uniform sampling"); unsigned int size = static_cast( @@ -384,8 +383,7 @@ float* KameleonWrapper::getUniformSliceValues(const std::string& var, const glm::size3_t& outDimensions, const float& slice) { - assert(_model && _interpolator); - assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO("Loading variable " << var << " from CDF data with a uniform sampling"); unsigned int size = static_cast( @@ -517,8 +515,7 @@ float* KameleonWrapper::getUniformSampledVectorValues(const std::string& xVar, const std::string& zVar, const glm::size3_t& outDimensions) { - assert(_model && _interpolator); - assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO( "Loading variables " << xVar << " " << yVar << " " << zVar << " from CDF data with a uniform sampling" @@ -597,7 +594,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getClassifiedFieldLines( const std::vector& seedPoints, float stepSize ) { - assert(_model && _interpolator); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO( "Creating " << seedPoints.size() << " fieldlines from variables " << xVar << " " << yVar << " " << zVar @@ -654,7 +651,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getFieldLines(const std::string& xV const std::string& yVar, const std::string& zVar, const std::vector& seedPoints, float stepSize, const glm::vec4& color) { - assert(_model && _interpolator); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO( "Creating " << seedPoints.size() << " fieldlines from variables " << xVar << " " << yVar << " " << zVar @@ -744,7 +741,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getLorentzTrajectories( glm::vec3 KameleonWrapper::getModelBarycenterOffset() { // ENLIL is centered, no need for offset if (_type == Model::ENLIL) { - return glm::vec3(0,0,0); + return glm::vec3(0.f); } glm::vec3 offset; @@ -770,8 +767,9 @@ glm::vec4 KameleonWrapper::getModelBarycenterOffsetScaled() { } glm::vec3 KameleonWrapper::getModelScale() { - if (_type == Model::ENLIL) - return glm::vec3(1.0f, 1.0f, 1.0f); + if (_type == Model::ENLIL) { + return glm::vec3(1.f); + } glm::vec3 scale; scale.x = _xMax - _xMin; diff --git a/modules/multiresvolume/rendering/atlasmanager.cpp b/modules/multiresvolume/rendering/atlasmanager.cpp index 83fa9646e5..389951a69b 100644 --- a/modules/multiresvolume/rendering/atlasmanager.cpp +++ b/modules/multiresvolume/rendering/atlasmanager.cpp @@ -170,7 +170,7 @@ void AtlasManager::addToAtlas(int firstBrickIndex, int lastBrickIndex, float* ma unsigned int atlasCoords = _freeAtlasCoords.back(); _freeAtlasCoords.pop_back(); int level = _nOtLevels - floor(log((7.0 * (float(brickIndex % _nOtNodes)) + 1.0))/log(8)) - 1; - assert(atlasCoords <= 0x0FFFFFFF); + ghoul_assert(atlasCoords <= 0x0FFFFFFF, "@MISSING"); unsigned int atlasData = (level << 28) + atlasCoords; _brickMap.insert(std::pair(brickIndex, atlasData)); _nStreamedBricks++; diff --git a/modules/multiresvolume/rendering/localtfbrickselector.cpp b/modules/multiresvolume/rendering/localtfbrickselector.cpp index 39f3abe12e..c5426f95a5 100644 --- a/modules/multiresvolume/rendering/localtfbrickselector.cpp +++ b/modules/multiresvolume/rendering/localtfbrickselector.cpp @@ -358,8 +358,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() { for (int i = 0; i < gradients.size(); i++) { float x = (i + 0.5f) / tfWidth; float sample = histogram->interpolate(x); - assert(sample >= 0); - assert(gradients[i] >= 0); + ghoul_assert(sample >= 0, "@MISSING"); + ghoul_assert(gradients[i] >= 0, "@MISSING"); error += sample * gradients[i]; } _brickErrors[brickIndex].spatial = error; @@ -375,8 +375,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() { for (int i = 0; i < gradients.size(); i++) { float x = (i + 0.5f) / tfWidth; float sample = histogram->interpolate(x); - assert(sample >= 0); - assert(gradients[i] >= 0); + ghoul_assert(sample >= 0, "@MISSING"); + ghoul_assert(gradients[i] >= 0, "@MISSING"); error += sample * gradients[i]; } _brickErrors[brickIndex].temporal = error; diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp index f563ee5485..a524ac362c 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp @@ -187,8 +187,6 @@ RenderableMultiresVolume::RenderableMultiresVolume (const ghoul::Dictionary& dic , _rotation(RotationInfo, glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(6.28f)) { std::string name; - //bool success = dictionary.getValue(constants::scenegraphnode::keyName, name); - //assert(success); _filename = ""; bool success = dictionary.getValue(KeyDataSource, _filename); diff --git a/modules/multiresvolume/rendering/simpletfbrickselector.cpp b/modules/multiresvolume/rendering/simpletfbrickselector.cpp index 9c797fc50a..6e20188591 100644 --- a/modules/multiresvolume/rendering/simpletfbrickselector.cpp +++ b/modules/multiresvolume/rendering/simpletfbrickselector.cpp @@ -311,7 +311,7 @@ bool SimpleTfBrickSelector::calculateBrickImportances() { float x = static_cast(i) / static_cast(tfWidth); float sample = histogram->interpolate(x); - assert(sample >= 0); + ghoul_assert(sample >= 0, "@MISSING"); dotProduct += sample * tf->sample(i).w; } _brickImportances[brickIndex] = dotProduct; diff --git a/modules/multiresvolume/rendering/tfbrickselector.cpp b/modules/multiresvolume/rendering/tfbrickselector.cpp index 3ee23994a9..4406e88f17 100644 --- a/modules/multiresvolume/rendering/tfbrickselector.cpp +++ b/modules/multiresvolume/rendering/tfbrickselector.cpp @@ -367,8 +367,8 @@ bool TfBrickSelector::calculateBrickErrors() { for (int i = 0; i < gradients.size(); i++) { float x = (i + 0.5f) / tfWidth; float sample = histogram->interpolate(x); - assert(sample >= 0); - assert(gradients[i] >= 0); + ghoul_assert(sample >= 0, "@MISSING"); + ghoul_assert(gradients[i] >= 0, "@MISSING"); error += sample * gradients[i]; } _brickErrors[brickIndex] = error; diff --git a/modules/volume/rendering/renderabletimevaryingvolume.h b/modules/volume/rendering/renderabletimevaryingvolume.h index 30fd980c78..67f2b44269 100644 --- a/modules/volume/rendering/renderabletimevaryingvolume.h +++ b/modules/volume/rendering/renderabletimevaryingvolume.h @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_VOLUME___RENDERABLEKAMELEONVOLUME___H__ -#define __OPENSPACE_MODULE_VOLUME___RENDERABLEKAMELEONVOLUME___H__ +#ifndef __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__ +#define __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__ #include @@ -106,4 +106,4 @@ private: } // namespace volume } // namespace openspace -#endif // __OPENSPACE_MODULE_KAMELEONVOLUME___RENDERABLEKAMELEONVOLUME___H__ +#endif // __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__ diff --git a/src/util/histogram.cpp b/src/util/histogram.cpp index ca3410c070..ea98fc0b3b 100644 --- a/src/util/histogram.cpp +++ b/src/util/histogram.cpp @@ -223,7 +223,7 @@ float Histogram::interpolate(float bin) const { } float Histogram::sample(int binIndex) const { - assert(binIndex >= 0 && binIndex < _numBins); + ghoul_assert(binIndex >= 0 && binIndex < _numBins, "@MISSING"); return _data[binIndex]; } diff --git a/support/coding/check_style_guide.py b/support/coding/check_style_guide.py index c91bc80d6e..a2c73df3b7 100644 --- a/support/coding/check_style_guide.py +++ b/support/coding/check_style_guide.py @@ -42,6 +42,8 @@ guards for correctness. At the moment this includes: * Checking that no file includes glm header directly * Checking whether any files starts with the UTF-8 Byte-order mark * Checking whether a file as empty-only lines + * Checking whether the default assert macros are used anywhere instead of the + ghoul_assert macro If this script is executed from the base directory of OpenSpace, no arguments need to be passed, otherwise the first and only argument has to point to the base directory. @@ -308,6 +310,16 @@ def check_line_length(lines): +def check_assert_usage(lines): + # _assert checks for both ghoul_assert and static_assert, which are both reasonable + index = [i + 1 for i,s in enumerate(lines) if ('assert(' in s and not '_assert(' in s) and s.strip()[0:2] != '//'] + if len(index) > 0: + return index + else: + return ''; + + + def check_line_length(lines): # Disable this check in non-strict mode if not is_strict_mode: @@ -422,6 +434,11 @@ def check_header_file(file, component): if empty_character_at_end: print(file, '\t', 'Empty character at end: ', empty_character_at_end) + assert_usage = check_assert_usage(lines) + if assert_usage: + print(file, '\t', 'Wrong assert usage: ', assert_usage) + + def check_inline_file(file, component): with open(file, 'r+', encoding="utf8") as f: @@ -471,6 +488,10 @@ def check_inline_file(file, component): if empty_character_at_end: print(file, '\t', 'Empty character at end: ', empty_character_at_end) + assert_usage = check_assert_usage(lines) + if assert_usage: + print(file, '\t', 'Wrong assert usage: ', assert_usage) + def check_source_file(file, component): @@ -510,6 +531,10 @@ def check_source_file(file, component): if empty_character_at_end: print(file, '\t', 'Empty character at end: ', empty_character_at_end) + assert_usage = check_assert_usage(lines) + if assert_usage: + print(file, '\t', 'Wrong assert usage: ', assert_usage) + def check_files(positiveList, negativeList, component, check_function):