mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Fix wrapper code
This commit is contained in:
@@ -133,9 +133,9 @@ public:
|
|||||||
|
|
||||||
std::pair<IfcSchema::IfcNamedUnit*, double> getUnit(IfcSchema::IfcUnitEnum::IfcUnitEnum);
|
std::pair<IfcSchema::IfcNamedUnit*, double> getUnit(IfcSchema::IfcUnitEnum::IfcUnitEnum);
|
||||||
|
|
||||||
const schema_definition* schema() const { return schema_; }
|
const IfcParse::schema_definition* schema() const { return schema_; }
|
||||||
|
|
||||||
void write_hdf5(const std::string&, const Hdf5Settings&);
|
void write_hdf5(const std::string&, const IfcParse::Hdf5Settings&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,3 +280,8 @@ std::vector<std::string> IfcParse::IfcLateBoundEntity::getInverseAttributeNames(
|
|||||||
std::copy(values.begin(), values.end(), std::back_inserter(return_value));
|
std::copy(values.begin(), values.end(), std::back_inserter(return_value));
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const IfcParse::declaration& IfcParse::IfcLateBoundEntity::declaration() const {
|
||||||
|
// TODO: Bound instances to a file and use according schema
|
||||||
|
return *get_schema().declaration_by_name(_type);
|
||||||
|
}
|
||||||
@@ -87,14 +87,7 @@ namespace IfcParse {
|
|||||||
const IfcAbstractEntity& data() const { return *data_; }
|
const IfcAbstractEntity& data() const { return *data_; }
|
||||||
IfcAbstractEntity& data() { return *data_; }
|
IfcAbstractEntity& data() { return *data_; }
|
||||||
|
|
||||||
virtual const IfcParse::declaration& declaration() const {
|
const IfcParse::declaration& IfcParse::IfcLateBoundEntity::declaration() const;
|
||||||
if (data().file) {
|
|
||||||
throw;
|
|
||||||
// data().file->
|
|
||||||
} else {
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -922,9 +922,7 @@ IfcFile::IfcFile(bool create_latebound_entities)
|
|||||||
, tokens(0)
|
, tokens(0)
|
||||||
, MaxId(0)
|
, MaxId(0)
|
||||||
{
|
{
|
||||||
if (!create_latebound_entities) {
|
schema_ = &get_schema();
|
||||||
schema_ = &get_schema();
|
|
||||||
}
|
|
||||||
setDefaultHeaderValues();
|
setDefaultHeaderValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
#include "../ifcparse/IfcException.h"
|
||||||
|
|
||||||
#ifdef USE_IFC4
|
#ifdef USE_IFC4
|
||||||
#include "../ifcparse/Ifc4enum.h"
|
#include "../ifcparse/Ifc4enum.h"
|
||||||
#else
|
#else
|
||||||
@@ -360,7 +364,22 @@ namespace IfcParse {
|
|||||||
class declaration_by_name_cmp : public std::binary_function<const declaration*, const std::string&, bool> {
|
class declaration_by_name_cmp : public std::binary_function<const declaration*, const std::string&, bool> {
|
||||||
public:
|
public:
|
||||||
bool operator()(const declaration* decl, const std::string& name) {
|
bool operator()(const declaration* decl, const std::string& name) {
|
||||||
return decl->name() < name;
|
// TODO: Efficiency?
|
||||||
|
return boost::to_lower_copy(decl->name()) < boost::to_lower_copy(name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class declaration_by_enum_cmp : public std::binary_function<const declaration*, IfcSchema::Type::Enum, bool> {
|
||||||
|
public:
|
||||||
|
bool operator()(const declaration* decl, IfcSchema::Type::Enum name) {
|
||||||
|
return decl->type() < name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class declaration_by_enum_sort : public std::binary_function<const declaration*, const declaration*, bool> {
|
||||||
|
public:
|
||||||
|
bool operator()(const declaration* a, const declaration* b) {
|
||||||
|
return a->type() < b->type();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -370,6 +389,7 @@ namespace IfcParse {
|
|||||||
, declarations_(declarations)
|
, declarations_(declarations)
|
||||||
, built_in_(built_in)
|
, built_in_(built_in)
|
||||||
{
|
{
|
||||||
|
std::sort(declarations_.begin(), declarations_.end(), declaration_by_enum_sort());
|
||||||
for (std::vector<const declaration*>::const_iterator it = declarations_.begin(); it != declarations_.end(); ++it) {
|
for (std::vector<const declaration*>::const_iterator it = declarations_.begin(); it != declarations_.end(); ++it) {
|
||||||
if ((**it).as_type_declaration()) type_declarations_.push_back((**it).as_type_declaration());
|
if ((**it).as_type_declaration()) type_declarations_.push_back((**it).as_type_declaration());
|
||||||
if ((**it).as_select_type()) select_types_.push_back((**it).as_select_type());
|
if ((**it).as_select_type()) select_types_.push_back((**it).as_select_type());
|
||||||
@@ -386,8 +406,8 @@ namespace IfcParse {
|
|||||||
|
|
||||||
const declaration* declaration_by_name(const std::string& name) const {
|
const declaration* declaration_by_name(const std::string& name) const {
|
||||||
std::vector<const declaration*>::const_iterator it = std::lower_bound(declarations_.begin(), declarations_.end(), name, declaration_by_name_cmp());
|
std::vector<const declaration*>::const_iterator it = std::lower_bound(declarations_.begin(), declarations_.end(), name, declaration_by_name_cmp());
|
||||||
if (it == declarations_.end() || (**it).name() != name) {
|
if (it == declarations_.end() || boost::to_lower_copy((**it).name()) != boost::to_lower_copy(name)) {
|
||||||
throw;
|
throw IfcParse::IfcException("Entity with '" + name + "' not found");
|
||||||
} else {
|
} else {
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
@@ -395,7 +415,7 @@ namespace IfcParse {
|
|||||||
|
|
||||||
const declaration* declaration_by_name(IfcSchema::Type::Enum name) const {
|
const declaration* declaration_by_name(IfcSchema::Type::Enum name) const {
|
||||||
if (!built_in_) throw;
|
if (!built_in_) throw;
|
||||||
return declaration_by_name(IfcSchema::Type::ToString(name));
|
return declarations_[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<const declaration*>& declarations() const { return declarations_; }
|
const std::vector<const declaration*>& declarations() const { return declarations_; }
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
boost::variant<IfcGeom::Element<double>*, IfcGeom::Representation::Representation*> create_shape(IfcGeom::IteratorSettings& settings, IfcParse::IfcLateBoundEntity* instance, IfcParse::IfcLateBoundEntity* representation = 0) {
|
boost::variant<IfcGeom::Element<double>*, IfcGeom::Representation::Representation*> create_shape(IfcGeom::IteratorSettings& settings, IfcParse::IfcLateBoundEntity* instance, IfcParse::IfcLateBoundEntity* representation = 0) {
|
||||||
IfcParse::IfcFile* file = instance->entity->file;
|
IfcParse::IfcFile* file = instance->data().file;
|
||||||
IfcSchema::IfcProject::list::ptr projects = file->entitiesByType<IfcSchema::IfcProject>();
|
IfcSchema::IfcProject::list::ptr projects = file->entitiesByType<IfcSchema::IfcProject>();
|
||||||
if (projects->size() != 1) {
|
if (projects->size() != 1) {
|
||||||
throw IfcParse::IfcException("Not a single IfcProject instance");
|
throw IfcParse::IfcException("Not a single IfcProject instance");
|
||||||
@@ -248,9 +248,9 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.include_curves() ? (settings.exclude_solids_and_surfaces() ? -1. : 0.) : +1.));
|
kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.include_curves() ? (settings.exclude_solids_and_surfaces() ? -1. : 0.) : +1.));
|
||||||
std::pair<std::string, double> length_unit = kernel.initializeUnits(project->UnitsInContext());
|
std::pair<std::string, double> length_unit = kernel.initializeUnits(project->UnitsInContext());
|
||||||
|
|
||||||
if (instance->is(IfcSchema::Type::IfcProduct)) {
|
if (instance->declaration().is(IfcSchema::Type::IfcProduct)) {
|
||||||
if (representation) {
|
if (representation) {
|
||||||
if (!representation->is(IfcSchema::Type::IfcRepresentation)) {
|
if (!representation->declaration().is(IfcSchema::Type::IfcRepresentation)) {
|
||||||
throw IfcParse::IfcException("Supplied representation not of type IfcRepresentation");
|
throw IfcParse::IfcException("Supplied representation not of type IfcRepresentation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,11 +323,11 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
}
|
}
|
||||||
|
|
||||||
IfcSchema::IfcRepresentationContext* ctx = ifc_representation->ContextOfItems();
|
IfcSchema::IfcRepresentationContext* ctx = ifc_representation->ContextOfItems();
|
||||||
if (!ctx->is(IfcSchema::Type::IfcGeometricRepresentationContext)) {
|
if (!ctx->declaration().is(IfcSchema::Type::IfcGeometricRepresentationContext)) {
|
||||||
throw IfcParse::IfcException("Context not of type IfcGeometricRepresentationContext");
|
throw IfcParse::IfcException("Context not of type IfcGeometricRepresentationContext");
|
||||||
}
|
}
|
||||||
IfcSchema::IfcGeometricRepresentationContext* context = (IfcSchema::IfcGeometricRepresentationContext*) ctx;
|
IfcSchema::IfcGeometricRepresentationContext* context = (IfcSchema::IfcGeometricRepresentationContext*) ctx;
|
||||||
if (context->is(IfcSchema::Type::IfcGeometricRepresentationSubContext)) {
|
if (context->declaration().is(IfcSchema::Type::IfcGeometricRepresentationSubContext)) {
|
||||||
IfcSchema::IfcGeometricRepresentationSubContext* subcontext = (IfcSchema::IfcGeometricRepresentationSubContext*) context;
|
IfcSchema::IfcGeometricRepresentationSubContext* subcontext = (IfcSchema::IfcGeometricRepresentationSubContext*) context;
|
||||||
context = subcontext->ParentContext();
|
context = subcontext->ParentContext();
|
||||||
}
|
}
|
||||||
@@ -360,11 +360,11 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!representation) {
|
if (!representation) {
|
||||||
if (instance->is(IfcSchema::Type::IfcRepresentationItem) || instance->is(IfcSchema::Type::IfcRepresentation)) {
|
if (instance->declaration().is(IfcSchema::Type::IfcRepresentationItem) || instance->declaration().is(IfcSchema::Type::IfcRepresentation)) {
|
||||||
IfcGeom::IfcRepresentationShapeItems shapes;
|
IfcGeom::IfcRepresentationShapeItems shapes;
|
||||||
if (kernel.convert_shapes(instance, shapes)) {
|
if (kernel.convert_shapes(instance, shapes)) {
|
||||||
IfcGeom::ElementSettings element_settings(settings, kernel.getValue(IfcGeom::Kernel::GV_LENGTH_UNIT), IfcSchema::Type::ToString(instance->type()));
|
IfcGeom::ElementSettings element_settings(settings, kernel.getValue(IfcGeom::Kernel::GV_LENGTH_UNIT), IfcSchema::Type::ToString(instance->type()));
|
||||||
IfcGeom::Representation::BRep brep(element_settings, instance->entity->id(), shapes);
|
IfcGeom::Representation::BRep brep(element_settings, instance->data().id(), shapes);
|
||||||
try {
|
try {
|
||||||
if (settings.use_brep_data()) {
|
if (settings.use_brep_data()) {
|
||||||
return new IfcGeom::Representation::Serialization(brep);
|
return new IfcGeom::Representation::Serialization(brep);
|
||||||
|
|||||||
@@ -70,6 +70,8 @@
|
|||||||
|
|
||||||
#include "../ifcparse/IfcFile.h"
|
#include "../ifcparse/IfcFile.h"
|
||||||
#include "../ifcparse/IfcLateBoundEntity.h"
|
#include "../ifcparse/IfcLateBoundEntity.h"
|
||||||
|
#include "../ifcparse/IfcSchema.h"
|
||||||
|
#include "../ifcparse/Hdf5Settings.h"
|
||||||
|
|
||||||
#ifdef USE_IFC4
|
#ifdef USE_IFC4
|
||||||
#include "../ifcparse/Ifc4-latebound.h"
|
#include "../ifcparse/Ifc4-latebound.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user