assert: remove assert with more than one statement and use only ai_assert.

pull/1385/head
Kim Kulling 2017-08-14 22:20:26 +02:00
parent 974eb669c8
commit dab0985994
13 changed files with 30 additions and 31 deletions

View File

@ -128,7 +128,10 @@ protected:
/// Enters a new xml element, which increases the indentation /// Enters a new xml element, which increases the indentation
void PushTag() { startstr.append( " "); } void PushTag() { startstr.append( " "); }
/// Leaves an element, decreasing the indentation /// Leaves an element, decreasing the indentation
void PopTag() { ai_assert( startstr.length() > 1); startstr.erase( startstr.length() - 2); } void PopTag() {
ai_assert( startstr.length() > 1);
startstr.erase( startstr.length() - 2);
}
/// Creates a mesh ID for the given mesh /// Creates a mesh ID for the given mesh
std::string GetMeshId( size_t pIndex) const { std::string GetMeshId( size_t pIndex) const {

View File

@ -229,7 +229,7 @@ ZipFile::~ZipFile() {
size_t ZipFile::Read(void* pvBuffer, size_t pSize, size_t pCount) { size_t ZipFile::Read(void* pvBuffer, size_t pSize, size_t pCount) {
const size_t size = pSize * pCount; const size_t size = pSize * pCount;
assert(size <= m_Size); ai_assert(size <= m_Size);
std::memcpy(pvBuffer, m_Buffer, size); std::memcpy(pvBuffer, m_Buffer, size);

View File

@ -243,7 +243,6 @@ const unsigned int* MeshGeometry::ToOutputVertexIndex( unsigned int in_index, un
ai_assert( m_mapping_counts.size() == m_mapping_offsets.size() ); ai_assert( m_mapping_counts.size() == m_mapping_offsets.size() );
count = m_mapping_counts[ in_index ]; count = m_mapping_counts[ in_index ];
// ai_assert( count != 0 );
ai_assert( m_mapping_offsets[ in_index ] + count <= m_mappings.size() ); ai_assert( m_mapping_offsets[ in_index ] + count <= m_mappings.size() );
return &m_mappings[ m_mapping_offsets[ in_index ] ]; return &m_mappings[ m_mapping_offsets[ in_index ] ];

View File

@ -55,14 +55,12 @@ namespace FBX {
// Forward declarations // Forward declarations
class Element; class Element;
/** Represents a dynamic property. Type info added by deriving classes, /** Represents a dynamic property. Type info added by deriving classes,
* see #TypedProperty. * see #TypedProperty.
Example: Example:
@verbatim @verbatim
P: "ShininessExponent", "double", "Number", "",0.5 P: "ShininessExponent", "double", "Number", "",0.5
@endvebatim @endvebatim
*/ */
class Property class Property
{ {
@ -79,7 +77,6 @@ public:
} }
}; };
template<typename T> template<typename T>
class TypedProperty : public Property class TypedProperty : public Property
{ {
@ -138,38 +135,35 @@ private:
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename T> template <typename T>
inline T PropertyGet(const PropertyTable& in, const std::string& name, inline
const T& defaultValue) T PropertyGet(const PropertyTable& in, const std::string& name, const T& defaultValue) {
{
const Property* const prop = in.Get(name); const Property* const prop = in.Get(name);
if(!prop) { if( nullptr == prop) {
return defaultValue; return defaultValue;
} }
// strong typing, no need to be lenient // strong typing, no need to be lenient
const TypedProperty<T>* const tprop = prop->As< TypedProperty<T> >(); const TypedProperty<T>* const tprop = prop->As< TypedProperty<T> >();
if(!tprop) { if( nullptr == tprop) {
return defaultValue; return defaultValue;
} }
return tprop->Value(); return tprop->Value();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename T> template <typename T>
inline T PropertyGet(const PropertyTable& in, const std::string& name, inline
bool& result) T PropertyGet(const PropertyTable& in, const std::string& name, bool& result) {
{
const Property* const prop = in.Get(name); const Property* const prop = in.Get(name);
if(!prop) { if( nullptr == prop) {
result = false; result = false;
return T(); return T();
} }
// strong typing, no need to be lenient // strong typing, no need to be lenient
const TypedProperty<T>* const tprop = prop->As< TypedProperty<T> >(); const TypedProperty<T>* const tprop = prop->As< TypedProperty<T> >();
if(!tprop) { if( nullptr == tprop) {
result = false; result = false;
return T(); return T();
} }
@ -178,7 +172,6 @@ inline T PropertyGet(const PropertyTable& in, const std::string& name,
return tprop->Value(); return tprop->Value();
} }
} //! FBX } //! FBX
} //! Assimp } //! Assimp

View File

@ -101,7 +101,6 @@ public:
return std::string(begin(),end()); return std::string(begin(),end());
} }
public:
bool IsBinary() const { bool IsBinary() const {
return column == BINARY_MARKER; return column == BINARY_MARKER;
} }

View File

@ -448,7 +448,8 @@ void HMPImporter::CreateOutputFaceList(unsigned int width,unsigned int height)
void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char* szCursor, void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char* szCursor,
const unsigned char** szCursorOut) const unsigned char** szCursorOut)
{ {
ai_assert(0 != iNumSkins && NULL != szCursor); ai_assert( 0 != iNumSkins );
ai_assert( nullptr != szCursor);
// read the type of the skin ... // read the type of the skin ...
// sometimes we need to skip 12 bytes here, I don't know why ... // sometimes we need to skip 12 bytes here, I don't know why ...

View File

@ -381,7 +381,6 @@ bool PointInPoly(const IfcVector3& p, const std::vector<IfcVector3>& boundary)
IntersectsBoundaryProfile(p, p + IfcVector3(0.6, -0.6, 0.0), boundary, true, intersected_boundary, true); IntersectsBoundaryProfile(p, p + IfcVector3(0.6, -0.6, 0.0), boundary, true, intersected_boundary, true);
votes += intersected_boundary.size() % 2; votes += intersected_boundary.size() % 2;
// ai_assert(votes == 3 || votes == 0);
return votes > 1; return votes > 1;
} }

View File

@ -548,8 +548,6 @@ bool Curve :: InRange(IfcFloat u) const
const ParamRange range = GetParametricRange(); const ParamRange range = GetParametricRange();
if (IsClosed()) { if (IsClosed()) {
return true; return true;
//ai_assert(range.first != std::numeric_limits<IfcFloat>::infinity() && range.second != std::numeric_limits<IfcFloat>::infinity());
//u = range.first + std::fmod(u-range.first,range.second-range.first);
} }
const IfcFloat epsilon = 1e-5; const IfcFloat epsilon = 1e-5;
return u - range.first > -epsilon && range.second - u > -epsilon; return u - range.first > -epsilon && range.second - u > -epsilon;

View File

@ -1492,7 +1492,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector<TempOpening>& openings,const std:
vmax -= vmin; vmax -= vmin;
// If this happens then the projection must have been wrong. // If this happens then the projection must have been wrong.
assert(vmax.Length()); ai_assert(vmax.Length());
ClipperLib::ExPolygons clipped; ClipperLib::ExPolygons clipped;
ClipperLib::Polygons holes_union; ClipperLib::Polygons holes_union;
@ -1616,7 +1616,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector<TempOpening>& openings,const std:
std::vector<IfcVector3> tmpvec; std::vector<IfcVector3> tmpvec;
for(ClipperLib::Polygon& opening : holes_union) { for(ClipperLib::Polygon& opening : holes_union) {
assert(ClipperLib::Orientation(opening)); ai_assert(ClipperLib::Orientation(opening));
tmpvec.clear(); tmpvec.clear();
@ -1705,7 +1705,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector<TempOpening>& openings,const std:
static_cast<IfcFloat>( tri->GetPoint(i)->y ) static_cast<IfcFloat>( tri->GetPoint(i)->y )
); );
assert(v.x <= 1.0 && v.x >= 0.0 && v.y <= 1.0 && v.y >= 0.0); ai_assert(v.x <= 1.0 && v.x >= 0.0 && v.y <= 1.0 && v.y >= 0.0);
const IfcVector3 v3 = minv * IfcVector3(vmin.x + v.x * vmax.x, vmin.y + v.y * vmax.y,coord) ; const IfcVector3 v3 = minv * IfcVector3(vmin.x + v.x * vmax.x, vmin.y + v.y * vmax.y,coord) ;
curmesh.verts.push_back(v3); curmesh.verts.push_back(v3);

View File

@ -1132,7 +1132,9 @@ bool MDLImporter::ProcessFrames_3DGS_MDL7(const MDL::IntGroupInfo_MDL7& groupInf
const unsigned char* szCurrent, const unsigned char* szCurrent,
const unsigned char** szCurrentOut) const unsigned char** szCurrentOut)
{ {
ai_assert(NULL != szCurrent && NULL != szCurrentOut); ai_assert( nullptr != szCurrent );
ai_assert( nullptr != szCurrentOut);
const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7*)mBuffer; const MDL::Header_MDL7 *pcHeader = (const MDL::Header_MDL7*)mBuffer;
// if we have no bones we can simply skip all frames, // if we have no bones we can simply skip all frames,

View File

@ -450,7 +450,9 @@ void SMDImporter::CreateOutputMeshes()
// add bone child nodes // add bone child nodes
void SMDImporter::AddBoneChildren(aiNode* pcNode, uint32_t iParent) void SMDImporter::AddBoneChildren(aiNode* pcNode, uint32_t iParent)
{ {
ai_assert(NULL != pcNode && 0 == pcNode->mNumChildren && NULL == pcNode->mChildren); ai_assert( NULL != pcNode );
ai_assert( 0 == pcNode->mNumChildren );
ai_assert( NULL == pcNode->mChildren);
// first count ... // first count ...
for (unsigned int i = 0; i < asBones.size();++i) for (unsigned int i = 0; i < asBones.size();++i)

View File

@ -93,7 +93,10 @@ protected:
void PushTag() { startstr.append( " "); } void PushTag() { startstr.append( " "); }
/// Leaves an element, decreasing the indentation /// Leaves an element, decreasing the indentation
void PopTag() { ai_assert( startstr.length() > 1); startstr.erase( startstr.length() - 2); } void PopTag() {
ai_assert( startstr.length() > 1);
startstr.erase( startstr.length() - 2);
}
public: public:
/// Stringstream to write all output into /// Stringstream to write all output into

View File

@ -142,8 +142,8 @@ void CGLView::Material_Apply(const aiMaterial* pMaterial)
void CGLView::Matrix_NodeToRoot(const aiNode* pNode, aiMatrix4x4& pOutMatrix) void CGLView::Matrix_NodeToRoot(const aiNode* pNode, aiMatrix4x4& pOutMatrix)
{ {
const aiNode* node_cur; const aiNode* node_cur;
std::list<aiMatrix4x4> mat_list; std::list<aiMatrix4x4> mat_list;
pOutMatrix = aiMatrix4x4(); pOutMatrix = aiMatrix4x4();
// starting walk from current element to root // starting walk from current element to root