mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Don't compare smart pointers to zero, but convert to bool
This commit is contained in:
+22
-15
@@ -807,40 +807,45 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* f) {
|
||||
Logger::Message(Logger::LOG_ERROR,ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
IfcSchema::Type::Enum ty = entity->type();
|
||||
do {
|
||||
IfcEntityList::ptr L = EntitiesByType(ty);
|
||||
if ( L == 0 ) {
|
||||
L = IfcEntityList::ptr(new IfcEntityList());
|
||||
bytype[ty] = L;
|
||||
IfcEntityList::ptr instances_by_type = EntitiesByType(ty);
|
||||
if (!instances_by_type) {
|
||||
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
|
||||
bytype[ty] = instances_by_type;
|
||||
}
|
||||
L->push(entity);
|
||||
instances_by_type->push(entity);
|
||||
ty = IfcSchema::Type::Parent(ty);
|
||||
} while ( ty > -1 );
|
||||
|
||||
if ( byid.find(currentId) != byid.end() ) {
|
||||
std::stringstream ss;
|
||||
ss << "Overwriting entity with id " << currentId;
|
||||
Logger::Message(Logger::LOG_WARNING,ss.str());
|
||||
}
|
||||
byid[currentId] = entity;
|
||||
|
||||
MaxId = (std::max)(MaxId,currentId);
|
||||
currentId = 0;
|
||||
} else {
|
||||
try { token = tokens->Next(); }
|
||||
catch (... ) { token = TokenPtr(); }
|
||||
}
|
||||
|
||||
if ( ! (token.second || token.first) ) break;
|
||||
|
||||
if ( (previous.second || previous.first) && TokenFunc::isIdentifier(previous) ) {
|
||||
int id = TokenFunc::asInt(previous);
|
||||
if ( TokenFunc::isOperator(token,'=') ) {
|
||||
currentId = id;
|
||||
} else if (entity) {
|
||||
IfcEntityList::ptr L = EntitiesByReference(id);
|
||||
if ( L == 0 ) {
|
||||
L = IfcEntityList::ptr(new IfcEntityList());
|
||||
byref[id] = L;
|
||||
IfcEntityList::ptr instances_by_ref = EntitiesByReference(id);
|
||||
if (!instances_by_ref) {
|
||||
instances_by_ref = IfcEntityList::ptr(new IfcEntityList());
|
||||
byref[id] = instances_by_ref;
|
||||
}
|
||||
L->push(entity);
|
||||
instances_by_ref->push(entity);
|
||||
}
|
||||
}
|
||||
previous = token;
|
||||
@@ -868,16 +873,18 @@ void IfcFile::AddEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
Logger::Message(Logger::LOG_ERROR,ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
IfcSchema::Type::Enum ty = entity->type();
|
||||
do {
|
||||
IfcEntityList::ptr L = EntitiesByType(ty);
|
||||
if ( L == 0 ) {
|
||||
L = IfcEntityList::ptr(new IfcEntityList());
|
||||
bytype[ty] = L;
|
||||
IfcEntityList::ptr instances_by_type = EntitiesByType(ty);
|
||||
if (!instances_by_type) {
|
||||
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
|
||||
bytype[ty] = instances_by_type;
|
||||
}
|
||||
L->push(entity);
|
||||
instances_by_type->push(entity);
|
||||
ty = IfcSchema::Type::Parent(ty);
|
||||
} while ( ty > -1 );
|
||||
|
||||
int new_id = -1;
|
||||
// For newly created entities ensure a valid ENTITY_INSTANCE_NAME is set
|
||||
if ( entity->entity->isWritable() ) {
|
||||
|
||||
Reference in New Issue
Block a user