Merge remote-tracking branch 'origin/master' into hdf5

Conflicts:
	src/ifcexpressparser/bootstrap.py
	src/ifcexpressparser/templates.py
	src/ifcgeom/IfcGeomFaces.cpp
	src/ifcgeom/IfcGeomFunctions.cpp
	src/ifcgeom/IfcGeomIterator.h
	src/ifcgeom/IfcGeomWires.cpp
	src/ifcparse/Ifc2x3.h
	src/ifcparse/Ifc4.h
	src/ifcparse/IfcLateBoundEntity.cpp
	src/ifcparse/IfcParse.cpp
	src/ifcparse/IfcUtil.h
This commit is contained in:
aothms
2016-02-19 14:19:57 +01:00
100 changed files with 3560 additions and 1002 deletions
+37 -30
View File
@@ -28,6 +28,8 @@
#include <Windows.h>
#endif
#include <boost/algorithm/string.hpp>
#include "../ifcparse/IfcCharacterDecoder.h"
#include "../ifcparse/IfcParse.h"
#include "../ifcparse/IfcException.h"
@@ -127,6 +129,11 @@ IfcSpfStream::IfcSpfStream(void* data, int l) {
len = l;
}
IfcSpfStream::~IfcSpfStream()
{
Close();
}
void IfcSpfStream::Close() {
#ifdef BUF_SIZE
if ( paging ) fclose(stream);
@@ -143,6 +150,8 @@ void IfcSpfStream::ReadBuffer(bool inc) {
offset += len;
fseek(stream, offset, SEEK_SET);
}
#else
(void)inc;
#endif
eof = feof(stream) != 0;
if ( eof ) return;
@@ -308,7 +317,7 @@ Token IfcSpfLexer::Next() {
while ( ! stream->eof ) {
// Read character and increment pointer if not starting a new token
char c = stream->Peek();
c = stream->Peek();
if ( len && (c == '(' || c == ')' || c == '=' || c == ',' || c == ';' || c == '/') ) break;
stream->Inc();
len ++;
@@ -363,7 +372,7 @@ bool TokenFunc::startsWith(const Token& t, char c) {
}
bool TokenFunc::isOperator(const Token& t, char op) {
return (!t.first) && (!op || op == t.second);
return (!t.first) && (!op || (unsigned)op == t.second);
}
bool TokenFunc::isIdentifier(const Token& t) {
@@ -394,8 +403,8 @@ bool TokenFunc::isInt(const Token& t) {
const std::string str = asString(t);
const char* start = str.c_str();
char* end;
long result = strtol(start,&end,10);
return ((end - start) == str.length());
/*long result =*/ strtol(start,&end,10);
return ((end - start) == (ptrdiff_t)str.length());
}
bool TokenFunc::isBool(const Token& t) {
@@ -412,11 +421,11 @@ bool TokenFunc::isFloat(const Token& t) {
const char* start = str.c_str();
char* end;
#ifdef _MSC_VER
double result = _strtod_l(start,&end,locale);
/*double result =*/ _strtod_l(start,&end,locale);
#else
double result = strtod_l(start,&end,locale);
#endif
return ((end - start) == str.length());
return ((end - start) == (ptrdiff_t)str.length());
}
int TokenFunc::asInt(const Token& t) {
@@ -467,7 +476,7 @@ boost::dynamic_bitset<> TokenFunc::asBinary(const Token& t) {
}
++it;
unsigned i = (str.size()-1) * 4 - n;
unsigned i = ((unsigned)str.size()-1) * 4 - n;
boost::dynamic_bitset<> bitset(i);
for(; it != str.end(); ++it) {
@@ -508,8 +517,7 @@ EntityArgument::EntityArgument(const Token& t) {
// Aditionally, stores the ids (i.e. #[\d]+) in a vector
//
void ArgumentList::read(IfcSpfLexer* t, std::vector<unsigned int>& ids) {
IfcParse::IfcFile* file = t->file;
//IfcParse::IfcFile* file = t->file;
Token next = t->Next();
while( next.second || next.first ) {
if ( TokenFunc::isOperator(next,',') ) {
@@ -517,9 +525,9 @@ void ArgumentList::read(IfcSpfLexer* t, std::vector<unsigned int>& ids) {
} else if ( TokenFunc::isOperator(next,')') ) {
break;
} else if ( TokenFunc::isOperator(next,'(') ) {
ArgumentList* list = new ArgumentList();
list->read(t, ids);
push(list);
ArgumentList* alist = new ArgumentList();
alist->read(t, ids);
push(alist);
} else {
if ( TokenFunc::isIdentifier(next) ) {
ids.push_back(TokenFunc::asInt(next));
@@ -640,7 +648,7 @@ ArgumentList::operator IfcEntityListList::ptr() const {
for ( it = list.begin(); it != list.end(); ++ it ) {
const Argument* arg = *it;
const ArgumentList* arg_list;
if ((arg_list = dynamic_cast<const ArgumentList*>(arg))) {
if ((arg_list = dynamic_cast<const ArgumentList*>(arg)) != 0) {
IfcEntityList::ptr e = *arg_list;
l->push(e);
}
@@ -732,7 +740,7 @@ TokenArgument::operator std::vector< std::vector<int> >() const { throw IfcExcep
TokenArgument::operator std::vector< std::vector<double> >() const { throw IfcException("Argument is not a list of list of floats"); }
TokenArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of list of entity instances"); }
unsigned int TokenArgument::size() const { return 1; }
Argument* TokenArgument::operator [] (unsigned int i) const { throw IfcException("Argument is not a list of attributes"); }
Argument* TokenArgument::operator [] (unsigned int /*i*/) const { throw IfcException("Argument is not a list of attributes"); }
std::string TokenArgument::toString(bool upper) const {
if ( upper && TokenFunc::isString(token) ) {
return IfcWrite::IfcCharacterEncoder(TokenFunc::asString(token));
@@ -764,7 +772,7 @@ EntityArgument::operator std::vector< std::vector<int> >() const { throw IfcExce
EntityArgument::operator std::vector< std::vector<double> >() const { throw IfcException("Argument is not a list of list of floats"); }
EntityArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of list of entity instances"); }
unsigned int EntityArgument::size() const { return 1; }
Argument* EntityArgument::operator [] (unsigned int i) const { throw IfcException("Argument is not a list of arguments"); }
Argument* EntityArgument::operator [] (unsigned int /*i*/) const { throw IfcException("Argument is not a list of arguments"); }
std::string EntityArgument::toString(bool upper) const {
return entity->data().toString(upper);
}
@@ -862,7 +870,7 @@ std::string Entity::toString(bool upper) const {
std::string dt = datatype();
if (upper) {
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
boost::to_upper(dt);
}
if (!IfcSchema::Type::IsSimple(type()) || _id != 0) {
@@ -1065,9 +1073,9 @@ void IfcFile::addEntities(IfcEntityList::ptr es) {
IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* instance) {
// If this instance has been inserted before, return
// a reference to the copy that was created from it.
entity_entity_map_t::iterator it = entity_file_map.find(instance);
if (it != entity_file_map.end()) {
return it->second;
entity_entity_map_t::iterator mit = entity_file_map.find(instance);
if (mit != entity_file_map.end()) {
return mit->second;
}
// Obtain all forward references by a depth-first
@@ -1281,11 +1289,12 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* instance) {
// moment, inversely related instances affected by the removal of the
// instance being deleted are not deleted themselves.
if (references) {
for (IfcEntityList::it it = references->begin(); it != references->end(); ++it) {
IfcUtil::IfcBaseEntity* related_instance = (IfcUtil::IfcBaseEntity*) *it;
for (IfcEntityList::it iit = references->begin(); iit != references->end(); ++iit) {
IfcUtil::IfcBaseEntity* related_instance = (IfcUtil::IfcBaseEntity*) *iit;
for (unsigned i = 0; i < related_instance->data().getArgumentCount(); ++i) {
Argument* attr = related_instance->data().getArgument(i);
if (attr->isNull()) continue;
IfcUtil::ArgumentType attr_type = attr->type();
@@ -1368,9 +1377,7 @@ IfcEntityList::ptr IfcFile::entitiesByType(IfcSchema::Type::Enum t) {
}
IfcEntityList::ptr IfcFile::entitiesByType(const std::string& t) {
std::string ty = t;
for (std::string::iterator p = ty.begin(); p != ty.end(); ++p ) *p = toupper(*p);
return entitiesByType(IfcSchema::Type::FromString(ty));
return entitiesByType(IfcSchema::Type::FromString(boost::to_upper_copy(t)));
}
IfcEntityList::ptr IfcFile::entitiesByReference(int t) {
@@ -1507,21 +1514,21 @@ std::pair<IfcSchema::IfcNamedUnit*, double> IfcFile::getUnit(IfcSchema::IfcUnitE
if (named_unit->UnitType() != type) {
continue;
}
IfcSchema::IfcSIUnit* unit = 0;
IfcSchema::IfcSIUnit* siunit = 0;
if (named_unit->declaration().is(IfcSchema::Type::IfcConversionBasedUnit)) {
IfcSchema::IfcConversionBasedUnit* u = (IfcSchema::IfcConversionBasedUnit*)named_unit;
IfcSchema::IfcMeasureWithUnit* mu = u->ConversionFactor();
return_value.second *= static_cast<double>(*mu->ValueComponent()->data().getArgument(0));
return_value.first = named_unit;
if (mu->UnitComponent()->declaration().is(IfcSchema::Type::IfcSIUnit)) {
unit = (IfcSchema::IfcSIUnit*) mu->UnitComponent();
siunit = (IfcSchema::IfcSIUnit*) mu->UnitComponent();
}
} else if (named_unit->declaration().is(IfcSchema::Type::IfcSIUnit)) {
return_value.first = unit = (IfcSchema::IfcSIUnit*) named_unit;
return_value.first = siunit = (IfcSchema::IfcSIUnit*) named_unit;
}
if (unit) {
if (unit->hasPrefix()) {
return_value.second *= IfcSIPrefixToValue(unit->Prefix());
if (siunit) {
if (siunit->hasPrefix()) {
return_value.second *= IfcSIPrefixToValue(siunit->Prefix());
}
}
}