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
+25 -25
View File
@@ -4247,48 +4247,48 @@ std::pair<const char*, int> Type::GetEnumerationIndex(Enum t, const std::string&
}
std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) {
if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt;
while (true) {
if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt;
for(;;) {
it = inverse_map.find(t);
if (it != inverse_map.end()) {
jt = it->second.find(a);
if (jt != it->second.end()) {
return jt->second;
}
}
jt = it->second.find(a);
if (jt != it->second.end()) {
return jt->second;
}
}
if ((t = Parent(t)) == -1) break;
}
throw IfcException("Attribute not found");
}
std::set<std::string> Type::GetInverseAttributeNames(Enum t) {
if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt;
if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt;
std::set<std::string> return_value;
std::set<std::string> return_value;
while (true) {
for (;;) {
it = inverse_map.find(t);
if (it != inverse_map.end()) {
for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
return_value.insert(jt->first);
}
}
for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
return_value.insert(jt->first);
}
}
if ((t = Parent(t)) == -1) break;
}
return return_value;
return return_value;
}
void Type::PopulateDerivedFields(IfcWrite::IfcWritableEntity* e) {
std::map<Type::Enum, std::set<int> >::const_iterator i = derived_map.find(e->type());
if (i != derived_map.end()) {
for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) {
e->setArgumentDerived(*it);
}
}
if (i != derived_map.end()) {
for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) {
e->setArgumentDerived(*it);
}
}
}
#endif
+2
View File
@@ -32,6 +32,8 @@
#include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcWritableEntity.h"
#include <map>
using namespace Ifc2x3;
using namespace IfcParse;
using namespace IfcWrite;
+9 -1
View File
@@ -29,7 +29,6 @@
#include <string>
#include <vector>
#include <map>
#include <boost/optional.hpp>
@@ -40,6 +39,11 @@
const IfcParse::schema_definition& get_schema();
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4100)
#endif
#define IfcSchema Ifc2x3
namespace Ifc2x3 {
@@ -37317,4 +37321,8 @@ void InitStringMap();
IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0);
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif
+25 -25
View File
@@ -4941,48 +4941,48 @@ std::pair<const char*, int> Type::GetEnumerationIndex(Enum t, const std::string&
}
std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) {
if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt;
while (true) {
if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt;
for(;;) {
it = inverse_map.find(t);
if (it != inverse_map.end()) {
jt = it->second.find(a);
if (jt != it->second.end()) {
return jt->second;
}
}
jt = it->second.find(a);
if (jt != it->second.end()) {
return jt->second;
}
}
if ((t = Parent(t)) == -1) break;
}
throw IfcException("Attribute not found");
}
std::set<std::string> Type::GetInverseAttributeNames(Enum t) {
if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt;
if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt;
std::set<std::string> return_value;
std::set<std::string> return_value;
while (true) {
for (;;) {
it = inverse_map.find(t);
if (it != inverse_map.end()) {
for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
return_value.insert(jt->first);
}
}
for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
return_value.insert(jt->first);
}
}
if ((t = Parent(t)) == -1) break;
}
return return_value;
return return_value;
}
void Type::PopulateDerivedFields(IfcWrite::IfcWritableEntity* e) {
std::map<Type::Enum, std::set<int> >::const_iterator i = derived_map.find(e->type());
if (i != derived_map.end()) {
for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) {
e->setArgumentDerived(*it);
}
}
if (i != derived_map.end()) {
for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) {
e->setArgumentDerived(*it);
}
}
}
#endif
+2
View File
@@ -32,6 +32,8 @@
#include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcWritableEntity.h"
#include <map>
using namespace Ifc4;
using namespace IfcParse;
using namespace IfcWrite;
+9 -1
View File
@@ -29,7 +29,6 @@
#include <string>
#include <vector>
#include <map>
#include <boost/optional.hpp>
@@ -40,6 +39,11 @@
const IfcParse::schema_definition& get_schema();
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4100)
#endif
#define IfcSchema Ifc4
namespace Ifc4 {
@@ -50176,4 +50180,8 @@ void InitStringMap();
IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0);
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif
+35 -14
View File
@@ -47,6 +47,7 @@
#define ENDEXTENDED_0 (1 << 20)
#define FOURTH_SOLIDUS (1 << 21)
#define IGNORED_DIRECTIVE (1 << 22)
#define ENCOUNTERED_HEX (1 << 23)
// FIXME: These probably need to be less forgiving in terms of wrongly defined sequences
#define EXPECTS_ALPHABET(S) (S & FIRST_SOLIDUS)
@@ -64,7 +65,7 @@
#define IS_VALID_ALPHABET_DEFINITION(C) (C >= 0x40 && C <= 0x4A)
#define IS_HEXADECIMAL(C) ((C >= 0x30 && C <= 0x39 ) || (C >= 0x41 && C <= 0x46 ))
#define HEX_TO_INT(C) ((C >= 0x30 && C <= 0x39 ) ? C - 0x30 : (C+10) - 0x41)
#define CLEAR_HEX(C) (C &= ~(HEX(1)&HEX(2)&HEX(3)&HEX(4)&HEX(5)&HEX(6)&HEX(7)&HEX(8)))
#define CLEAR_HEX(C) (C &= ~(HEX(1)|HEX(2)|HEX(3)|HEX(4)|HEX(5)|HEX(6)|HEX(7)|HEX(8)))
using namespace IfcParse;
using namespace IfcWrite;
@@ -117,6 +118,7 @@ IfcCharacterDecoder::~IfcCharacterDecoder() {
destination = 0;
converter = 0;
compatibility_converter = 0;
ucnv_flushCache();
#endif
}
IfcCharacterDecoder::operator std::string() {
@@ -130,12 +132,12 @@ IfcCharacterDecoder::operator std::string() {
#ifdef HAVE_ICU
unsigned int old_hex = 0; // for compatibility_mode
#endif
while ( current_char = file->Peek() ) {
while ( (current_char = file->Peek()) != 0 ) {
if ( EXPECTS_CHARACTER(parse_state) ) {
#ifdef HAVE_ICU
if ( previous_codepage != codepage ) {
if ( converter ) ucnv_close(converter);
char encoder[11] = {'i','s','o','-','8','8','5','9','-',codepage + 0x30};
char encoder[11] = {'i','s','o','-','8','8','5','9','-', (char)codepage + 0x30};
converter = ucnv_open(encoder, &status);
}
const char characters[2] = { current_char + 0x80 };
@@ -155,7 +157,10 @@ IfcCharacterDecoder::operator std::string() {
if ( parse_state & ALPHABET_DEFINITION ||
parse_state & IGNORED_DIRECTIVE ||
parse_state & ENDEXTENDED_0 ) parse_state = hex = hex_count = 0;
else if ( parse_state & HEX(3) ) parse_state += THIRD_SOLIDUS;
else if ( parse_state & ENCOUNTERED_HEX ) {
parse_state += THIRD_SOLIDUS;
parse_state -= ENCOUNTERED_HEX;
}
else parse_state += SECOND_SOLIDUS;
} else if ( current_char == 'X' && EXPECTS_ENDEXTENDED_X(parse_state) ) {
parse_state += ENDEXTENDED_X;
@@ -188,7 +193,7 @@ IfcCharacterDecoder::operator std::string() {
if (old_hex == 0) {
old_hex = hex;
} else {
char characters[3] = { old_hex, hex };
char characters[3] = { (char)old_hex, (char)hex };
const char* char_array = &characters[0];
UChar32 ch = ucnv_getNextUChar(compatibility_converter,&char_array,char_array+2,&status);
addChar(s,ch);
@@ -202,7 +207,10 @@ IfcCharacterDecoder::operator std::string() {
}
#endif
if ( hex_count == 2 ) parse_state = 0;
else CLEAR_HEX(parse_state);
else {
CLEAR_HEX(parse_state);
parse_state |= ENCOUNTERED_HEX;
}
hex = hex_count = 0;
}
} else if ( parse_state && !(
@@ -227,7 +235,7 @@ void IfcCharacterDecoder::dryRun() {
unsigned int parse_state = 0;
char current_char;
unsigned int hex_count = 0;
while ( current_char = file->Peek() ) {
while ((current_char = file->Peek()) != 0) {
if ( EXPECTS_CHARACTER(parse_state) ) {
parse_state = 0;
} else if ( current_char == '\'' && ! parse_state ) {
@@ -238,7 +246,10 @@ void IfcCharacterDecoder::dryRun() {
if ( parse_state & ALPHABET_DEFINITION ||
parse_state & IGNORED_DIRECTIVE ||
parse_state & ENDEXTENDED_0 ) parse_state = hex_count = 0;
else if ( parse_state & HEX(3) ) parse_state += THIRD_SOLIDUS;
else if ( parse_state & ENCOUNTERED_HEX ) {
parse_state += THIRD_SOLIDUS;
parse_state -= ENCOUNTERED_HEX;
}
else parse_state += SECOND_SOLIDUS;
} else if ( current_char == 'X' && EXPECTS_ENDEXTENDED_X(parse_state) ) {
parse_state += ENDEXTENDED_X;
@@ -264,7 +275,10 @@ void IfcCharacterDecoder::dryRun() {
(hex_count == 4 && !(parse_state & EXTENDED4)) ||
(hex_count == 8) ) {
if ( hex_count == 2 ) parse_state = 0;
else CLEAR_HEX(parse_state);
else {
CLEAR_HEX(parse_state);
parse_state |= ENCOUNTERED_HEX;
}
hex_count = 0;
}
} else if ( parse_state && !(
@@ -288,7 +302,7 @@ UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR;
#endif
#ifdef HAVE_ICU
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON;
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::UTF8;
// Many BIM software (eg. Revit, ArchiCAD, ...) has wrong behavior
bool IfcCharacterDecoder::compatibility_mode = false;
@@ -340,8 +354,8 @@ IfcCharacterEncoder::operator std::string() {
oss << "\\X" << num_bytes_str << "\\";
}
if ( within_spf_range ) {
oss.put(ch);
if ( ch == '\\' || ch == '\'' ) oss.put(ch);
oss.put((char)ch);
if ( ch == '\\' || ch == '\'' ) oss.put((char)ch);
} else {
oss << std::hex << std::setw(num_bytes*2) << std::uppercase << std::setfill('0') << (int) ch;
}
@@ -352,8 +366,15 @@ IfcCharacterEncoder::operator std::string() {
#else
for (std::string::const_iterator i = str.begin(); i != str.end(); ++i) {
char ch = *i;
if ( ch == '\\' || ch == '\'' ) oss.put(ch);
oss.put(ch);
const bool within_spf_range = ch >= 0x20 && ch <= 0x7e;
if (within_spf_range) {
if ( ch == '\\' || ch == '\'' ) {
oss.put(ch);
}
oss.put(ch);
} else {
oss.put('_');
}
}
#endif
oss.put('\'');
+4 -3
View File
@@ -26,7 +26,8 @@
#include <iostream>
#include <algorithm>
#include "../ifcparse/SharedPointer.h"
#include <boost/shared_ptr.hpp>
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcException.h"
@@ -48,7 +49,7 @@ namespace IfcUtil {
std::pair<const char*, int> getIndex(const std::string& value) const {
std::vector<std::string>::const_iterator it = std::find(values.begin(), values.end(), value);
if (it != values.end()) {
return std::make_pair(it->c_str(), std::distance(it, values.begin()));
return std::make_pair(it->c_str(), (int)std::distance(it, values.begin()));
} else {
throw IfcParse::IfcException("Invalid enumeration value");
}
@@ -91,7 +92,7 @@ namespace IfcUtil {
arguments.push_back(IfcArgumentDescriptor(name, optional, argument_type, data_type));
}
unsigned getArgumentCount() const {
return (parent ? parent->getArgumentCount() : 0) + arguments.size();
return (parent ? parent->getArgumentCount() : 0) + (unsigned)arguments.size();
}
const std::string& getArgumentName(unsigned i) const {
const unsigned a = argument_start();
+13 -3
View File
@@ -23,6 +23,8 @@
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/version.hpp>
#include <boost/lexical_cast.hpp>
#include "../ifcparse/IfcGlobalId.h"
#include "../ifcparse/IfcException.h"
@@ -38,7 +40,7 @@ std::string base64(unsigned v, int l) {
r.push_back(chars[v%64]);
v /= 64;
}
while ( r.size() != l ) r.push_back('0');
while ( (int)r.size() != l ) r.push_back('0');
std::reverse(r.begin(),r.end());
return r;
}
@@ -52,7 +54,7 @@ unsigned from_base64(const std::string& s) {
r *= 64;
const char* c = strchr(chars,*i);
if ( !c ) throw IfcParse::IfcException("Failed to decode GlobalId");
r += (c-chars);
r += (unsigned)(c-chars);
}
return r;
}
@@ -70,7 +72,7 @@ std::string compress(unsigned char* v) {
// Expands the base64 representation into a UUID byte array
void expand(const std::string& s, std::vector<unsigned char>& v) {
v.push_back(from_base64(s.substr(0,2)));
v.push_back((unsigned char)from_base64(s.substr(0,2)));
for( unsigned i = 0; i < 5; ++i ) {
unsigned d = from_base64(s.substr(2+4*i,4));
for ( unsigned j = 0; j < 3; ++ j ) {
@@ -87,7 +89,11 @@ IfcParse::IfcGlobalId::IfcGlobalId() {
std::vector<unsigned char> v(uuid_data.size());
std::copy(uuid_data.begin(), uuid_data.end(), v.begin());
string_data = compress(&v[0]);
#if BOOST_VERSION < 104400
formatted_string = boost::lexical_cast<std::string>(uuid_data);
#else
formatted_string = boost::uuids::to_string(uuid_data);
#endif
#ifndef NDEBUG
std::vector<unsigned char> test_vector;
@@ -106,7 +112,11 @@ IfcParse::IfcGlobalId::IfcGlobalId(const std::string& s)
std::vector<unsigned char> v;
expand(string_data, v);
std::copy(v.begin(), v.end(), uuid_data.begin());
#if BOOST_VERSION < 104400
formatted_string = boost::lexical_cast<std::string>(uuid_data);
#else
formatted_string = boost::uuids::to_string(uuid_data);
#endif
#ifndef NDEBUG
const std::string test_string = compress(&uuid_data.data[0]);
+5 -5
View File
@@ -290,7 +290,7 @@ void IfcHierarchyHelper::addBox(IfcSchema::IfcShapeRepresentation* rep, double w
IfcSchema::IfcAxis2Placement2D* place, IfcSchema::IfcAxis2Placement3D* place2,
IfcSchema::IfcDirection* dir, IfcSchema::IfcRepresentationContext* context)
{
if (false) {
if (false) { // TODO What's this?
IfcSchema::IfcRectangleProfileDef* profile = new IfcSchema::IfcRectangleProfileDef(
IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, boost::none, place ? place : addPlacement2d(), w, d);
IfcSchema::IfcExtrudedAreaSolid* solid = new IfcSchema::IfcExtrudedAreaSolid(profile,
@@ -303,10 +303,10 @@ void IfcHierarchyHelper::addBox(IfcSchema::IfcShapeRepresentation* rep, double w
rep->setItems(items);
} else {
std::vector<std::pair<double, double> > points;
points.push_back(std::pair<double, double>(-w/2, -d/2));
points.push_back(std::pair<double, double>(w/2, -d/2));
points.push_back(std::pair<double, double>(w/2, d/2));
points.push_back(std::pair<double, double>(-w/2, d/2));
points.push_back(std::make_pair(-w/2, -d/2));
points.push_back(std::make_pair(w/2, -d/2));
points.push_back(std::make_pair(w/2, d/2));
points.push_back(std::make_pair(-w/2, d/2));
// The call to addExtrudedPolyline() closes the polyline
addExtrudedPolyline(rep, points, h, place, place2, dir, context);
}
+43 -11
View File
@@ -78,8 +78,8 @@ public:
double xx=1.0, double xy=0.0, double xz=0.0);
template <class T>
void addRelatedObject(IfcSchema::IfcObjectDefinition* related_object,
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist = 0)
void addRelatedObject(IfcSchema::IfcObjectDefinition* relating_object,
IfcSchema::IfcObjectDefinition* related_object, IfcSchema::IfcOwnerHistory* owner_hist = 0)
{
typename T::list::ptr li = entitiesByType<T>();
bool found = false;
@@ -100,9 +100,9 @@ public:
if (! owner_hist) {
owner_hist = addOwnerHistory();
}
IfcSchema::IfcObjectDefinition::list::ptr relating_objects (new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
relating_objects->push(relating_object);
T* t = new T(IfcParse::IfcGlobalId(), owner_hist, boost::none, boost::none, related_object, relating_objects);
IfcSchema::IfcObjectDefinition::list::ptr related_objects (new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
related_objects->push(related_object);
T* t = new T(IfcParse::IfcGlobalId(), owner_hist, boost::none, boost::none, relating_object, related_objects);
addEntity(t);
}
}
@@ -174,14 +174,14 @@ private:
};
template <>
inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSpatialStructure> (IfcSchema::IfcObjectDefinition* related_object,
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist)
inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSpatialStructure> (IfcSchema::IfcObjectDefinition* relating_structure,
IfcSchema::IfcObjectDefinition* related_object, IfcSchema::IfcOwnerHistory* owner_hist)
{
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr li = entitiesByType<IfcSchema::IfcRelContainedInSpatialStructure>();
bool found = false;
for (IfcSchema::IfcRelContainedInSpatialStructure::list::it i = li->begin(); i != li->end(); ++i) {
IfcSchema::IfcRelContainedInSpatialStructure* rel = *i;
if (rel->RelatingStructure() == relating_object) {
if (rel->RelatingStructure() == relating_structure) {
IfcSchema::IfcProduct::list::ptr products = rel->RelatedElements();
products->push((IfcSchema::IfcProduct*)related_object);
rel->setRelatedElements(products);
@@ -196,10 +196,42 @@ inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSp
if (! owner_hist) {
owner_hist = addOwnerHistory();
}
IfcSchema::IfcProduct::list::ptr relating_objects (new IfcTemplatedEntityList<IfcSchema::IfcProduct>());
relating_objects->push((IfcSchema::IfcProduct*)relating_object);
IfcSchema::IfcProduct::list::ptr related_objects (new IfcTemplatedEntityList<IfcSchema::IfcProduct>());
related_objects->push((IfcSchema::IfcProduct*)related_object);
IfcSchema::IfcRelContainedInSpatialStructure* t = new IfcSchema::IfcRelContainedInSpatialStructure(IfcParse::IfcGlobalId(), owner_hist,
boost::none, boost::none, relating_objects, (IfcSchema::IfcSpatialStructureElement*)related_object);
boost::none, boost::none, related_objects, (IfcSchema::IfcSpatialStructureElement*)relating_structure);
addEntity(t);
}
}
template <>
inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelDefinesByType> (IfcSchema::IfcObjectDefinition* relating_type,
IfcSchema::IfcObjectDefinition* related_object, IfcSchema::IfcOwnerHistory* owner_hist)
{
IfcSchema::IfcRelDefinesByType::list::ptr li = entitiesByType<IfcSchema::IfcRelDefinesByType>();
bool found = false;
for (IfcSchema::IfcRelDefinesByType::list::it i = li->begin(); i != li->end(); ++i) {
IfcSchema::IfcRelDefinesByType* rel = *i;
if (rel->RelatingType() == relating_type) {
IfcSchema::IfcObject::list::ptr objects = rel->RelatedObjects();
objects->push((IfcSchema::IfcObject*)related_object);
rel->setRelatedObjects(objects);
found = true;
break;
}
}
if (! found) {
if (! owner_hist) {
owner_hist = getSingle<IfcSchema::IfcOwnerHistory>();
}
if (! owner_hist) {
owner_hist = addOwnerHistory();
}
IfcSchema::IfcObject::list::ptr related_objects (new IfcTemplatedEntityList<IfcSchema::IfcObject>());
related_objects->push((IfcSchema::IfcObject*)related_object);
IfcSchema::IfcRelDefinesByType* t = new IfcSchema::IfcRelDefinesByType(IfcParse::IfcGlobalId(), owner_hist,
boost::none, boost::none, related_objects, (IfcSchema::IfcTypeObject*)relating_type);
addEntity(t);
}
+27 -27
View File
@@ -19,6 +19,8 @@
#include <sstream>
#include <boost/algorithm/string.hpp>
#include "../ifcparse/IfcWritableEntity.h"
#include "../ifcparse/IfcUtil.h"
@@ -44,14 +46,14 @@ IfcWrite::IfcWritableEntity* IfcParse::IfcLateBoundEntity::writable_entity() {
return e;
}
IfcParse::IfcLateBoundEntity::IfcLateBoundEntity(const std::string& s) {
std::string S = s;
for (std::string::iterator i = S.begin(); i != S.end(); ++i ) *i = toupper(*i);
_type = IfcSchema::Type::FromString(S);
_type = IfcSchema::Type::FromString(boost::to_upper_copy(s));
data_ = new IfcWrite::IfcWritableEntity(_type);
for (unsigned i = 0; i < getArgumentCount(); ++i) {
// Side effect of this is that a NULL attribute is created.
data_->getArgument(i);
}
IfcSchema::Type::PopulateDerivedFields(writable_entity());
}
IfcParse::IfcLateBoundEntity::IfcLateBoundEntity(IfcAbstractEntity* e) {
@@ -83,9 +85,7 @@ std::string IfcParse::IfcLateBoundEntity::is_a() const {
return IfcSchema::Type::ToString(_type);
}
bool IfcParse::IfcLateBoundEntity::is_a(const std::string& s) const {
std::string S = s;
for (std::string::iterator i = S.begin(); i != S.end(); ++i ) *i = toupper(*i);
return is(IfcSchema::Type::FromString(S));
return is(IfcSchema::Type::FromString(boost::to_upper_copy(s)));
}
IfcSchema::Type::Enum IfcParse::IfcLateBoundEntity::type() const {
return _type;
@@ -94,35 +94,35 @@ unsigned int IfcParse::IfcLateBoundEntity::getArgumentCount() const {
return IfcSchema::Type::GetAttributeCount(_type);
}
IfcUtil::ArgumentType IfcParse::IfcLateBoundEntity::getArgumentType(unsigned int i) const {
return IfcSchema::Type::GetAttributeDerived(_type, i)
return IfcSchema::Type::GetAttributeDerived(_type, (unsigned char)i)
? IfcUtil::Argument_DERIVED
: IfcSchema::Type::GetAttributeType(_type,i);
: IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
}
IfcSchema::Type::Enum IfcParse::IfcLateBoundEntity::getArgumentEntity(unsigned int i) const {
return IfcSchema::Type::GetAttributeEntity(_type, i);
return IfcSchema::Type::GetAttributeEntity(_type, (unsigned char)i);
}
Argument* IfcParse::IfcLateBoundEntity::getArgument(unsigned int i) const {
return data_->getArgument(i);
}
const char* IfcParse::IfcLateBoundEntity::getArgumentName(unsigned int i) const {
return IfcSchema::Type::GetAttributeName(_type,i).c_str();
return IfcSchema::Type::GetAttributeName(_type, (unsigned char)i).c_str();
}
bool IfcParse::IfcLateBoundEntity::getArgumentOptionality(unsigned int i) const {
return IfcSchema::Type::GetAttributeOptional(_type, i);
return IfcSchema::Type::GetAttributeOptional(_type, (unsigned char)i);
}
void IfcParse::IfcLateBoundEntity::invalid_argument(unsigned int i, const std::string& t) {
const std::string arg_name = IfcSchema::Type::GetAttributeName(_type,i);
const std::string arg_name = IfcSchema::Type::GetAttributeName(_type, (unsigned char)i);
throw IfcException(t + " is not a valid type for '" + arg_name + "'");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsNull(unsigned int i) {
bool is_optional = IfcSchema::Type::GetAttributeOptional(_type, i);
bool is_optional = IfcSchema::Type::GetAttributeOptional(_type, (unsigned char)i);
if (is_optional) {
writable_entity()->setArgument(i);
} else invalid_argument(i,"NULL");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsInt(unsigned int i, int v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_INT) {
writable_entity()->setArgument(i,v);
} else if ( (arg_type == Argument_BOOL) && ( (v == 0) || (v == 1) ) ) {
@@ -130,23 +130,23 @@ void IfcParse::IfcLateBoundEntity::setArgumentAsInt(unsigned int i, int v) {
} else invalid_argument(i,"INTEGER");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsBool(unsigned int i, bool v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_BOOL) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"BOOLEAN");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsDouble(unsigned int i, double v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_DOUBLE) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"REAL");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsString(unsigned int i, const std::string& a) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_STRING) {
writable_entity()->setArgument(i,a);
} else if (arg_type == Argument_ENUMERATION) {
std::pair<const char*, int> enum_data = IfcSchema::Type::GetEnumerationIndex(IfcSchema::Type::GetAttributeEntity(_type, i), a);
std::pair<const char*, int> enum_data = IfcSchema::Type::GetEnumerationIndex(IfcSchema::Type::GetAttributeEntity(_type, (unsigned char)i), a);
writable_entity()->setArgument(i, enum_data.second, enum_data.first);
} else if (arg_type == Argument_BINARY) {
if (valid_binary_string(a)) {
@@ -158,19 +158,19 @@ void IfcParse::IfcLateBoundEntity::setArgumentAsString(unsigned int i, const std
} else invalid_argument(i,"STRING");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfInt(unsigned int i, const std::vector<int>& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_INT) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF INT");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfDouble(unsigned int i, const std::vector<double>& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_DOUBLE) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF DOUBLE");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfString(unsigned int i, const std::vector<std::string>& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_STRING) {
writable_entity()->setArgument(i,v);
} else if (arg_type == Argument_AGGREGATE_OF_BINARY) {
@@ -187,31 +187,31 @@ void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfString(unsigned int i
} else invalid_argument(i,"AGGREGATE OF STRING");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsEntityInstance(unsigned int i, IfcParse::IfcLateBoundEntity* v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_ENTITY_INSTANCE) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"ENTITY INSTANCE");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfEntityInstance(unsigned int i, IfcEntityList::ptr v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF ENTITY INSTANCE");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfAggregateOfInt(unsigned int i, const std::vector< std::vector<int> >& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_AGGREGATE_OF_INT) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF AGGREGATE OF INT");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfAggregateOfDouble(unsigned int i, const std::vector< std::vector<double> >& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF AGGREGATE OF DOUBLE");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfAggregateOfEntityInstance(unsigned int i, IfcEntityListList::ptr v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type,i);
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF AGGREGATE OF ENTITY INSTANCE");
@@ -237,7 +237,7 @@ bool IfcParse::IfcLateBoundEntity::is_valid() {
const Argument& arg = *getArgument(i);
is_null = arg.isNull();
} catch(IfcException) {}
if (!IfcSchema::Type::GetAttributeOptional(_type,i) && is_null) {
if (!IfcSchema::Type::GetAttributeOptional(_type, (unsigned char)i) && is_null) {
if (!valid) {
oss << ", ";
}
+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());
}
}
}
+2 -2
View File
@@ -37,9 +37,9 @@
#include <cstring>
#include <map>
#include <boost/shared_ptr.hpp>
#include <boost/dynamic_bitset.hpp>
#include "../ifcparse/SharedPointer.h"
#include "../ifcparse/IfcCharacterDecoder.h"
#include "../ifcparse/IfcUtil.h"
@@ -248,7 +248,7 @@ namespace IfcParse {
unsigned int offset;
Entity(unsigned int i, IfcFile* t);
Entity(unsigned int i, IfcFile* t, unsigned int o);
~Entity();
virtual ~Entity();
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum type, int attribute_index);
void Load(std::vector<unsigned int>& ids, bool seek=false) const;
void Unload();
+14 -4
View File
@@ -29,6 +29,9 @@ class HeaderEntity : public IfcAbstractEntity {
private:
ArgumentList* _list;
const char * const _datatype;
HeaderEntity(const HeaderEntity&); //N/A
HeaderEntity& operator =(const HeaderEntity&); //N/A
protected:
HeaderEntity(const char * const datatype, IfcSpfLexer* lexer)
: _datatype(datatype), _list(0)
@@ -40,7 +43,7 @@ protected:
}
}
~HeaderEntity() {
virtual ~HeaderEntity() {
delete _list;
}
@@ -65,7 +68,7 @@ public:
return (*_list)[i];
}
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum type, int attribute_index) {
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum /*type*/, int /*attribute_index*/) {
return IfcEntityList::ptr(new IfcEntityList);
}
@@ -81,7 +84,7 @@ public:
return (IfcSchema::Type::Enum) -1;
}
bool is(IfcSchema::Type::Enum v) const {
bool is(IfcSchema::Type::Enum /*v*/) const {
return false;
}
@@ -167,7 +170,14 @@ public:
_file_name = new FileName();
_file_schema = new FileSchema();
}
~IfcSpfHeader()
{
delete _file_schema;
delete _file_name;
delete _file_description;
}
IfcSpfLexer* lexer() { return _lexer; }
void lexer(IfcSpfLexer* l) { _lexer = l; }
+1
View File
@@ -64,6 +64,7 @@ namespace IfcParse {
IfcSpfStream(const std::string& fn);
IfcSpfStream(std::istream& f, int len);
IfcSpfStream(void* data, int len);
~IfcSpfStream();
/// Returns the character at the cursor
char Peek();
/// Returns the character at specified offset
+8 -8
View File
@@ -26,10 +26,10 @@
#include <sstream>
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <boost/dynamic_bitset.hpp>
#include "../ifcparse/IfcSchema.h"
#include "../ifcparse/SharedPointer.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4enum.h"
@@ -155,7 +155,7 @@ class IfcTemplatedEntityList;
class IfcEntityList {
std::vector<IfcUtil::IfcBaseClass*> ls;
public:
typedef SHARED_PTR<IfcEntityList> ptr;
typedef boost::shared_ptr<IfcEntityList> ptr;
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator it;
void push(IfcUtil::IfcBaseClass* l);
void push(const ptr& l);
@@ -179,7 +179,7 @@ template <class T>
class IfcTemplatedEntityList {
std::vector<T*> ls;
public:
typedef SHARED_PTR< IfcTemplatedEntityList<T> > ptr;
typedef boost::shared_ptr< IfcTemplatedEntityList<T> > ptr;
typedef typename std::vector<T*>::const_iterator it;
void push(T* t) { if (t) { ls.push_back(t); } }
void push(ptr t) { if (t) { for ( typename T::list::it it = t->begin(); it != t->end(); ++it ) push(*it); } }
@@ -213,7 +213,7 @@ class IfcTemplatedEntityListList;
class IfcEntityListList {
std::vector< std::vector<IfcUtil::IfcBaseClass*> > ls;
public:
typedef SHARED_PTR< IfcEntityListList > ptr;
typedef boost::shared_ptr< IfcEntityListList > ptr;
typedef std::vector< std::vector<IfcUtil::IfcBaseClass*> >::const_iterator outer_it;
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator inner_it;
void push(const std::vector<IfcUtil::IfcBaseClass*>& l) {
@@ -230,11 +230,11 @@ public:
}
outer_it begin() const { return ls.begin(); }
outer_it end() const { return ls.end(); }
int size() const { return ls.size(); }
int size() const { return (int)ls.size(); }
int totalSize() const {
int accum = 0;
for (outer_it it = begin(); it != end(); ++it) {
accum += it->size();
accum += (int)it->size();
}
return accum;
}
@@ -267,13 +267,13 @@ template <class T>
class IfcTemplatedEntityListList {
std::vector< std::vector<T*> > ls;
public:
typedef typename SHARED_PTR< IfcTemplatedEntityListList<T> > ptr;
typedef typename boost::shared_ptr< IfcTemplatedEntityListList<T> > ptr;
typedef typename std::vector< std::vector<T*> >::const_iterator outer_it;
typedef typename std::vector<T*>::const_iterator inner_it;
void push(const std::vector<T*>& t) {ls.push_back(t);}
outer_it begin() { return ls.begin(); }
outer_it end() { return ls.end(); }
int size() const { return ls.size(); }
int size() const { return (int)ls.size(); }
int totalSize() const {
int accum = 0;
for (outer_it it = begin(); it != end(); ++it) {
+29 -25
View File
@@ -19,6 +19,9 @@
#include <iomanip>
#include <locale>
#include <limits>
#include <boost/algorithm/string.hpp>
#include "../ifcparse/IfcParse.h"
#include "../ifcparse/IfcWrite.h"
@@ -82,7 +85,7 @@ Argument* IfcWritableEntity::getArgument (unsigned int i) {
}
return args[i];
}
unsigned int IfcWritableEntity::getArgumentCount() const {return args.size(); }
unsigned int IfcWritableEntity::getArgumentCount() const { return (unsigned)args.size(); }
IfcSchema::Type::Enum IfcWritableEntity::type() const { return _type; }
bool IfcWritableEntity::is(IfcSchema::Type::Enum v) const { return _type == v; }
std::string IfcWritableEntity::toString(bool upper) const {
@@ -91,7 +94,7 @@ std::string IfcWritableEntity::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 (_id && !IfcSchema::Type::IsSimple(type())) {
@@ -102,7 +105,6 @@ std::string IfcWritableEntity::toString(bool upper) const {
ss << dt << "(";
for (std::map<int,Argument*>::const_iterator it = args.begin(); it != args.end(); ++ it) {
if ( it != args.begin() ) ss << ",";
const Argument* a = it->second;
ss << it->second->toString(upper);
}
ss << ")";
@@ -139,7 +141,6 @@ void IfcWritableEntity::setArgument(int i) {
}
void IfcWritableEntity::setArgument(int i, Argument* a) {
IfcWrite::IfcWriteArgument* wa = new IfcWrite::IfcWriteArgument(this);
IfcUtil::ArgumentType attr_type = a->type();
switch(attr_type) {
case IfcUtil::Argument_NULL:
@@ -181,7 +182,7 @@ void IfcWritableEntity::setArgument(int i, Argument* a) {
this->setArgument(i, attr_value); }
break;
case IfcUtil::Argument_ENUMERATION: {
IfcSchema::Type::Enum ty = IfcSchema::Type::GetAttributeEntity(_type, i);
IfcSchema::Type::Enum ty = IfcSchema::Type::GetAttributeEntity(_type, (unsigned char)i);
std::string enum_literal = a->toString();
// Remove leading and trailing '.'
enum_literal = enum_literal.substr(1, enum_literal.size() - 2);
@@ -290,27 +291,30 @@ void IfcWritableEntity::setArgument(int i,const std::vector< boost::dynamic_bits
class SizeVisitor : public boost::static_visitor<int> {
public:
int operator()(const boost::none_t& i) const { return -1; }
int operator()(const IfcWriteArgument::Derived& i) const { return -1; }
int operator()(const int& i) const { return -1; }
int operator()(const bool& i) const { return -1; }
int operator()(const double& i) const { return -1; }
int operator()(const std::string& i) const { return -1; }
int operator()(const boost::dynamic_bitset<>& i) const { return -1; }
int operator()(const std::vector<int>& i) const { return i.size(); }
int operator()(const std::vector<double>& i) const { return i.size(); }
int operator()(const std::vector< std::vector<int> >& i) const { return i.size(); }
int operator()(const std::vector< std::vector<double> >& i) const { return i.size(); }
int operator()(const std::vector<std::string>& i) const { return i.size(); }
int operator()(const std::vector< boost::dynamic_bitset<> >& i) const { return i.size(); }
int operator()(const IfcWriteArgument::EnumerationReference& i) const { return -1; }
int operator()(const IfcUtil::IfcBaseClass* const& i) const { return -1; }
int operator()(const boost::none_t& /*i*/) const { return -1; }
int operator()(const IfcWriteArgument::Derived& /*i*/) const { return -1; }
int operator()(const int& /*i*/) const { return -1; }
int operator()(const bool& /*i*/) const { return -1; }
int operator()(const double& /*i*/) const { return -1; }
int operator()(const std::string& /*i*/) const { return -1; }
int operator()(const boost::dynamic_bitset<>& /*i*/) const { return -1; }
int operator()(const std::vector<int>& i) const { return (int)i.size(); }
int operator()(const std::vector<double>& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<int> >& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<double> >& i) const { return (int)i.size(); }
int operator()(const std::vector<std::string>& i) const { return (int)i.size(); }
int operator()(const std::vector< boost::dynamic_bitset<> >& i) const { return (int)i.size(); }
int operator()(const IfcWriteArgument::EnumerationReference& /*i*/) const { return -1; }
int operator()(const IfcUtil::IfcBaseClass* const& /*i*/) const { return -1; }
int operator()(const IfcEntityList::ptr& i) const { return i->size(); }
int operator()(const IfcEntityListList::ptr& i) const { return i->size(); }
};
class StringBuilderVisitor : public boost::static_visitor<void> {
private:
StringBuilderVisitor(const StringBuilderVisitor&); //N/A
StringBuilderVisitor& operator =(const StringBuilderVisitor&); //N/A
std::ostringstream& data;
template <typename T> void serialize(const std::vector<T>& i) {
data << "(";
@@ -326,7 +330,7 @@ private:
std::string format_double(const double& d) {
std::ostringstream oss;
oss.imbue(std::locale::classic());
oss << std::setprecision(15) << d;
oss << std::setprecision(std::numeric_limits<double>::digits10) << d;
const std::string str = oss.str();
oss.str("");
std::string::size_type e = str.find('e');
@@ -350,7 +354,7 @@ private:
oss.imbue(std::locale::classic());
oss.put('"');
oss << std::hex << std::setw(1);
unsigned c = b.size();
unsigned c = (unsigned)b.size();
unsigned n = (4 - (c % 4)) & 3;
oss << n;
for (unsigned i = 0; i < c + n;) {
@@ -369,8 +373,8 @@ private:
public:
StringBuilderVisitor(std::ostringstream& stream, bool upper = false)
: data(stream), upper(upper) {}
void operator()(const boost::none_t& i) { data << "$"; }
void operator()(const IfcWriteArgument::Derived& i) { data << "*"; }
void operator()(const boost::none_t& /*i*/) { data << "$"; }
void operator()(const IfcWriteArgument::Derived& /*i*/) { data << "*"; }
void operator()(const int& i) { data << i; }
void operator()(const bool& i) { data << (i ? ".T." : ".F."); }
void operator()(const double& i) { data << format_double(i); }
@@ -500,7 +504,7 @@ IfcWriteArgument::operator std::vector< std::vector<int> >() const { return as<s
IfcWriteArgument::operator std::vector< std::vector<double> >() const { return as<std::vector< std::vector<double> > >(); }
IfcWriteArgument::operator IfcEntityListList::ptr() const { throw; }
bool IfcWriteArgument::isNull() const { return type() == IfcUtil::Argument_NULL; }
Argument* IfcWriteArgument::operator [] (unsigned int i) const { throw IfcParse::IfcException("Invalid cast"); }
Argument* IfcWriteArgument::operator [] (unsigned int /*i*/) const { throw IfcParse::IfcException("Invalid cast"); }
std::string IfcWriteArgument::toString(bool upper) const {
std::ostringstream str;
str.imbue(std::locale::classic());
-41
View File
@@ -1,41 +0,0 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
/********************************************************************************
* *
* This file defines the shared pointer implementation to use, shared pointers *
* are used extensively in IfcOpenShell *
* *
********************************************************************************/
#ifdef __GNUC__
#include <tr1/memory>
#define SHARED_PTR std::tr1::shared_ptr
#else
#if _MSC_VER >= 1600
// MSVC 2008 does not have shared_ptr by default, but it comes
// in a feature pack. Therefore for IDEs prior to MSVC 2010 the
// shared_ptr that ships with boost is used.
#include <memory>
#define SHARED_PTR std::tr1::shared_ptr
#else
#include <boost/shared_ptr.hpp>
#define SHARED_PTR boost::shared_ptr
#endif
#endif