mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 01:31:00 +00:00
Virtual inheritance prototype for select
This commit is contained in:
@@ -489,6 +489,11 @@ if(ENABLE_BUILD_OPTIMIZATIONS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
|
# warning due to virtual inheritance
|
||||||
|
ADD_DEFINITIONS(-wd4250)
|
||||||
|
# warning due to select definitions in the schema being redundant
|
||||||
|
ADD_DEFINITIONS(-wd4584)
|
||||||
|
|
||||||
# didn't work well on ifcopenbot, @todo make configurable
|
# didn't work well on ifcopenbot, @todo make configurable
|
||||||
# add_definitions(/MP)
|
# add_definitions(/MP)
|
||||||
|
|
||||||
|
|||||||
@@ -353,13 +353,13 @@ public:
|
|||||||
bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face);
|
bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face);
|
||||||
bool convert_wire_to_faces(const TopoDS_Wire& wire, TopoDS_Compound& face);
|
bool convert_wire_to_faces(const TopoDS_Wire& wire, TopoDS_Compound& face);
|
||||||
bool convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoDS_Wire& wire);
|
bool convert_curve_to_wire(const Handle(Geom_Curve)& curve, TopoDS_Wire& wire);
|
||||||
bool convert_shapes(const IfcUtil::IfcBaseClass* L, IfcRepresentationShapeItems& result);
|
bool convert_shapes(const IfcUtil::IfcBaseInterface* L, IfcRepresentationShapeItems& result);
|
||||||
IfcGeom::ShapeType shape_type(const IfcUtil::IfcBaseClass* L);
|
IfcGeom::ShapeType shape_type(const IfcUtil::IfcBaseInterface* L);
|
||||||
bool convert_shape(const IfcUtil::IfcBaseClass* L, TopoDS_Shape& result);
|
bool convert_shape(const IfcUtil::IfcBaseInterface* L, TopoDS_Shape& result);
|
||||||
bool flatten_shape_list(const IfcGeom::IfcRepresentationShapeItems& shapes, TopoDS_Shape& result, bool fuse);
|
bool flatten_shape_list(const IfcGeom::IfcRepresentationShapeItems& shapes, TopoDS_Shape& result, bool fuse);
|
||||||
bool convert_wire(const IfcUtil::IfcBaseClass* L, TopoDS_Wire& result);
|
bool convert_wire(const IfcUtil::IfcBaseInterface* L, TopoDS_Wire& result);
|
||||||
bool convert_curve(const IfcUtil::IfcBaseClass* L, Handle(Geom_Curve)& result);
|
bool convert_curve(const IfcUtil::IfcBaseInterface* L, Handle(Geom_Curve)& result);
|
||||||
bool convert_face(const IfcUtil::IfcBaseClass* L, TopoDS_Shape& result);
|
bool convert_face(const IfcUtil::IfcBaseInterface* L, TopoDS_Shape& result);
|
||||||
bool convert_openings(const IfcSchema::IfcProduct* entity, const IfcSchema::IfcRelVoidsElement::list::ptr& openings, const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes);
|
bool convert_openings(const IfcSchema::IfcProduct* entity, const IfcSchema::IfcRelVoidsElement::list::ptr& openings, const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes);
|
||||||
bool convert_openings_fast(const IfcSchema::IfcProduct* entity, const IfcSchema::IfcRelVoidsElement::list::ptr& openings, const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes);
|
bool convert_openings_fast(const IfcSchema::IfcProduct* entity, const IfcSchema::IfcRelVoidsElement::list::ptr& openings, const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes);
|
||||||
void assert_closed_wire(TopoDS_Wire& wire);
|
void assert_closed_wire(TopoDS_Wire& wire);
|
||||||
@@ -426,7 +426,7 @@ public:
|
|||||||
static TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_Trsf&);
|
static TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_Trsf&);
|
||||||
static TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_GTrsf&);
|
static TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_GTrsf&);
|
||||||
|
|
||||||
bool is_identity_transform(IfcUtil::IfcBaseClass*);
|
bool is_identity_transform(IfcUtil::IfcBaseInterface*);
|
||||||
|
|
||||||
IfcSchema::IfcRelVoidsElement::list::ptr find_openings(IfcSchema::IfcProduct* product);
|
IfcSchema::IfcRelVoidsElement::list::ptr find_openings(IfcSchema::IfcProduct* product);
|
||||||
|
|
||||||
@@ -545,7 +545,7 @@ public:
|
|||||||
const IteratorSettings& settings, IfcUtil::IfcBaseClass* representation,
|
const IteratorSettings& settings, IfcUtil::IfcBaseClass* representation,
|
||||||
IfcUtil::IfcBaseClass* product)
|
IfcUtil::IfcBaseClass* product)
|
||||||
{
|
{
|
||||||
return create_brep_for_representation_and_product(settings, (IfcSchema::IfcRepresentation*) representation, (IfcSchema::IfcProduct*) product);
|
return create_brep_for_representation_and_product(settings, representation->as<IfcSchema::IfcRepresentation>(), product->as<IfcSchema::IfcProduct>());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual IfcRepresentationShapeItems convert(IfcUtil::IfcBaseClass* item) {
|
virtual IfcRepresentationShapeItems convert(IfcUtil::IfcBaseClass* item) {
|
||||||
|
|||||||
@@ -3459,7 +3459,7 @@ const IfcSchema::IfcRepresentationItem* IfcGeom::Kernel::find_item_carrying_styl
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfcGeom::Kernel::is_identity_transform(IfcUtil::IfcBaseClass* l) {
|
bool IfcGeom::Kernel::is_identity_transform(IfcUtil::IfcBaseInterface* l) {
|
||||||
IfcSchema::IfcAxis2Placement2D* ax2d;
|
IfcSchema::IfcAxis2Placement2D* ax2d;
|
||||||
IfcSchema::IfcAxis2Placement3D* ax3d;
|
IfcSchema::IfcAxis2Placement3D* ax3d;
|
||||||
|
|
||||||
|
|||||||
@@ -895,7 +895,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta
|
|||||||
bool part_succes = false;
|
bool part_succes = false;
|
||||||
const IfcGeom::SurfaceStyle* parent_style = get_style(l);
|
const IfcGeom::SurfaceStyle* parent_style = get_style(l);
|
||||||
for (aggregate_of_instance::it it = elements->begin(); it != elements->end(); ++it) {
|
for (aggregate_of_instance::it it = elements->begin(); it != elements->end(); ++it) {
|
||||||
IfcSchema::IfcGeometricSetSelect* element = *it;
|
auto element = *it;
|
||||||
TopoDS_Shape s;
|
TopoDS_Shape s;
|
||||||
if (shape_type(element) == ST_SHAPELIST) {
|
if (shape_type(element) == ST_SHAPELIST) {
|
||||||
IfcRepresentationShapeItems items;
|
IfcRepresentationShapeItems items;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
using namespace IfcUtil;
|
using namespace IfcUtil;
|
||||||
|
|
||||||
bool IfcGeom::Kernel::convert_shapes(const IfcBaseClass* l, IfcRepresentationShapeItems& r) {
|
bool IfcGeom::Kernel::convert_shapes(const IfcBaseInterface* l, IfcRepresentationShapeItems& r) {
|
||||||
if (shape_type(l) != ST_SHAPELIST) {
|
if (shape_type(l) != ST_SHAPELIST) {
|
||||||
TopoDS_Shape shp;
|
TopoDS_Shape shp;
|
||||||
if (convert_shape(l, shp)) {
|
if (convert_shape(l, shp)) {
|
||||||
@@ -45,12 +45,12 @@ bool IfcGeom::Kernel::convert_shapes(const IfcBaseClass* l, IfcRepresentationSha
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcGeom::ShapeType IfcGeom::Kernel::shape_type(const IfcBaseClass* l) {
|
IfcGeom::ShapeType IfcGeom::Kernel::shape_type(const IfcBaseInterface* l) {
|
||||||
#include "IfcRegisterShapeType.h"
|
#include "IfcRegisterShapeType.h"
|
||||||
return ST_OTHER;
|
return ST_OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfcGeom::Kernel::convert_shape(const IfcBaseClass* l, TopoDS_Shape& r) {
|
bool IfcGeom::Kernel::convert_shape(const IfcBaseInterface* l, TopoDS_Shape& r) {
|
||||||
const unsigned int id = l->data().id();
|
const unsigned int id = l->data().id();
|
||||||
bool success = false;
|
bool success = false;
|
||||||
bool processed = false;
|
bool processed = false;
|
||||||
@@ -111,7 +111,7 @@ bool IfcGeom::Kernel::convert_shape(const IfcBaseClass* l, TopoDS_Shape& r) {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfcGeom::Kernel::convert_wire(const IfcBaseClass* l, TopoDS_Wire& r) {
|
bool IfcGeom::Kernel::convert_wire(const IfcBaseInterface* l, TopoDS_Wire& r) {
|
||||||
#include "IfcRegisterConvertWire.h"
|
#include "IfcRegisterConvertWire.h"
|
||||||
Handle(Geom_Curve) curve;
|
Handle(Geom_Curve) curve;
|
||||||
if (IfcGeom::Kernel::convert_curve(l, curve)) {
|
if (IfcGeom::Kernel::convert_curve(l, curve)) {
|
||||||
@@ -121,13 +121,13 @@ bool IfcGeom::Kernel::convert_wire(const IfcBaseClass* l, TopoDS_Wire& r) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfcGeom::Kernel::convert_face(const IfcBaseClass* l, TopoDS_Shape& r) {
|
bool IfcGeom::Kernel::convert_face(const IfcBaseInterface* l, TopoDS_Shape& r) {
|
||||||
#include "IfcRegisterConvertFace.h"
|
#include "IfcRegisterConvertFace.h"
|
||||||
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l);
|
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfcGeom::Kernel::convert_curve(const IfcBaseClass* l, Handle(Geom_Curve)& r) {
|
bool IfcGeom::Kernel::convert_curve(const IfcBaseInterface* l, Handle(Geom_Curve)& r) {
|
||||||
#include "IfcRegisterConvertCurve.h"
|
#include "IfcRegisterConvertCurve.h"
|
||||||
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l);
|
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "IfcRegisterUndef.h"
|
#include "IfcRegisterUndef.h"
|
||||||
#define CURVE(T) \
|
#define CURVE(T) \
|
||||||
if ( l->declaration().is(IfcSchema::T::Class()) ) return convert((IfcSchema::T*)l,r);
|
if (l->as<IfcSchema::T>()) return convert(l->as<IfcSchema::T>(), r);
|
||||||
#include "IfcRegisterDef.h"
|
#include "IfcRegisterDef.h"
|
||||||
|
|
||||||
#include "IfcRegister.h"
|
#include "IfcRegister.h"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "IfcRegisterUndef.h"
|
#include "IfcRegisterUndef.h"
|
||||||
#define FACE(T) \
|
#define FACE(T) \
|
||||||
if ( l->declaration().is(IfcSchema::T::Class()) ) return convert((IfcSchema::T*)l,r);
|
if (l->as<IfcSchema::T>()) return convert(l->as<IfcSchema::T>(), r);
|
||||||
#include "IfcRegisterDef.h"
|
#include "IfcRegisterDef.h"
|
||||||
|
|
||||||
#include "IfcRegister.h"
|
#include "IfcRegister.h"
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "IfcRegisterUndef.h"
|
#include "IfcRegisterUndef.h"
|
||||||
#define SHAPE(T) \
|
#define SHAPE(T) \
|
||||||
if ( !processed && l->declaration().is(IfcSchema::T::Class()) ) { \
|
if (!processed && l->as<IfcSchema::T>()) { \
|
||||||
processed = true; \
|
processed = true; \
|
||||||
try { \
|
try { \
|
||||||
if ( convert((IfcSchema::T*)l,r) ) { \
|
if ( convert(l->as<IfcSchema::T>(),r) ) { \
|
||||||
success = true; \
|
success = true; \
|
||||||
} \
|
} \
|
||||||
} catch (const std::exception& e) { \
|
} catch (const std::exception& e) { \
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "IfcRegisterUndef.h"
|
#include "IfcRegisterUndef.h"
|
||||||
#define SHAPES(T) \
|
#define SHAPES(T) \
|
||||||
if ( l->declaration().is(IfcSchema::T::Class()) ) { \
|
if (l->as<IfcSchema::T>()) { \
|
||||||
try { \
|
try { \
|
||||||
return convert((IfcSchema::T*)l,r); \
|
return convert(l->as<IfcSchema::T>(), r); \
|
||||||
} catch (const std::exception& e) { \
|
} catch (const std::exception& e) { \
|
||||||
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l); \
|
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l); \
|
||||||
} catch (const Standard_Failure& f) { \
|
} catch (const Standard_Failure& f) { \
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "IfcRegisterUndef.h"
|
#include "IfcRegisterUndef.h"
|
||||||
#define WIRE(T) \
|
#define WIRE(T) \
|
||||||
if ( l->declaration().is(IfcSchema::T::Class()) ) return convert((IfcSchema::T*)l,r);
|
if (l->as<IfcSchema::T>()) return convert(l->as<IfcSchema::T>(), r);
|
||||||
#include "IfcRegisterDef.h"
|
#include "IfcRegisterDef.h"
|
||||||
|
|
||||||
#include "IfcRegister.h"
|
#include "IfcRegister.h"
|
||||||
@@ -23,11 +23,16 @@ import codegen
|
|||||||
import templates
|
import templates
|
||||||
import documentation
|
import documentation
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
class Header(codegen.Base):
|
class Header(codegen.Base):
|
||||||
def __init__(self, mapping):
|
def __init__(self, mapping):
|
||||||
declarations = []
|
declarations = []
|
||||||
|
|
||||||
|
case_lookup = lambda nm: [k for k in mapping.schema.keys if k.lower() == nm.lower()][0]
|
||||||
|
case_normalize = lambda nm: nm if nm.startswith("IfcUtil::") else case_lookup(nm)
|
||||||
|
create_supertype_statement = lambda nms: ", ".join("public %s %s" % ("" if c.startswith("IfcUtil::") else "",c) for c in nms)
|
||||||
|
|
||||||
write = lambda str, **kwargs: declarations.append(
|
write = lambda str, **kwargs: declarations.append(
|
||||||
str
|
str
|
||||||
% dict({"documentation": templates.multi_line_comment(documentation.description(kwargs["name"]))}, **kwargs)
|
% dict({"documentation": templates.multi_line_comment(documentation.description(kwargs["name"]))}, **kwargs)
|
||||||
@@ -36,9 +41,19 @@ class Header(codegen.Base):
|
|||||||
forward_names = list(mapping.schema.entities.keys()) + list(mapping.schema.simpletypes.keys())
|
forward_names = list(mapping.schema.entities.keys()) + list(mapping.schema.simpletypes.keys())
|
||||||
forward_definitions = "".join(["class %s; " % n for n in forward_names])
|
forward_definitions = "".join(["class %s; " % n for n in forward_names])
|
||||||
|
|
||||||
|
select_super_types = defaultdict(list)
|
||||||
|
|
||||||
for name, type in mapping.schema.selects.items():
|
for name, type in mapping.schema.selects.items():
|
||||||
|
for nm in type.values:
|
||||||
|
select_super_types[str(nm).lower()].append(name)
|
||||||
write(templates.select, name=name)
|
write(templates.select, name=name)
|
||||||
|
|
||||||
|
def get_select_super_types(nm):
|
||||||
|
x = list(select_super_types[nm.lower()])
|
||||||
|
for y in x:
|
||||||
|
x.extend(get_select_super_types(y))
|
||||||
|
return set(x)
|
||||||
|
|
||||||
for name, type in mapping.schema.enumerations.items():
|
for name, type in mapping.schema.enumerations.items():
|
||||||
short_name = name[:-4] if name.endswith("Enum") else name
|
short_name = name[:-4] if name.endswith("Enum") else name
|
||||||
write(templates.enumeration, name=name, values=", ".join(["%s_%s" % (short_name, v) for v in type.values]))
|
write(templates.enumeration, name=name, values=", ".join(["%s_%s" % (short_name, v) for v in type.values]))
|
||||||
@@ -46,19 +61,31 @@ class Header(codegen.Base):
|
|||||||
emitted_simpletypes = set()
|
emitted_simpletypes = set()
|
||||||
while len(emitted_simpletypes) < len(mapping.schema.simpletypes):
|
while len(emitted_simpletypes) < len(mapping.schema.simpletypes):
|
||||||
for name, type in mapping.schema.simpletypes.items():
|
for name, type in mapping.schema.simpletypes.items():
|
||||||
|
|
||||||
if name.lower() in emitted_simpletypes:
|
if name.lower() in emitted_simpletypes:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
type_str = mapping.make_type_string(mapping.flatten_type_string(type))
|
type_str = mapping.make_type_string(mapping.flatten_type_string(type))
|
||||||
attr_type = mapping.make_argument_type(type)
|
attr_type = mapping.make_argument_type(type)
|
||||||
superclass = mapping.simple_type_parent(name)
|
superclass = mapping.simple_type_parent(name)
|
||||||
if superclass is None:
|
|
||||||
superclass = "IfcUtil::IfcBaseType"
|
superclasses = []
|
||||||
elif superclass.lower() not in emitted_simpletypes:
|
if superclass is not None:
|
||||||
continue
|
superclasses.append(superclass)
|
||||||
else:
|
else:
|
||||||
# Case normalize
|
superclasses.append("IfcUtil::IfcBaseType")
|
||||||
superclass = [k for k in mapping.schema.simpletypes.keys() if k.lower() == superclass.lower()][0]
|
superclasses.extend(get_select_super_types(name))
|
||||||
|
|
||||||
|
is_emitted = lambda nm: nm == "IfcUtil::IfcBaseType" or nm in mapping.schema.selects or nm.lower() in emitted_simpletypes
|
||||||
|
if not all(map(is_emitted, superclasses)):
|
||||||
|
continue
|
||||||
|
|
||||||
|
superclasses = list(map(case_normalize, superclasses))
|
||||||
|
|
||||||
emitted_simpletypes.add(name.lower())
|
emitted_simpletypes.add(name.lower())
|
||||||
|
|
||||||
|
superclass = create_supertype_statement(superclasses)
|
||||||
|
|
||||||
write(templates.simpletype, name=name, type=type_str, attr_type=attr_type, superclass=superclass)
|
write(templates.simpletype, name=name, type=type_str, attr_type=attr_type, superclass=superclass)
|
||||||
|
|
||||||
class_definitions = []
|
class_definitions = []
|
||||||
@@ -73,6 +100,7 @@ class Header(codegen.Base):
|
|||||||
for name, type in mapping.schema.entities.items():
|
for name, type in mapping.schema.entities.items():
|
||||||
if name.lower() in emitted_entities:
|
if name.lower() in emitted_entities:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if len(type.supertypes) == 0 or set(map(str.lower, type.supertypes)) <= emitted_entities:
|
if len(type.supertypes) == 0 or set(map(str.lower, type.supertypes)) <= emitted_entities:
|
||||||
attr_lines = []
|
attr_lines = []
|
||||||
|
|
||||||
@@ -106,13 +134,11 @@ class Header(codegen.Base):
|
|||||||
if len(inverse):
|
if len(inverse):
|
||||||
inverse += "\n"
|
inverse += "\n"
|
||||||
|
|
||||||
def case_norm(n):
|
supertypes = list(type.supertypes) if len(type.supertypes) else ["IfcUtil::IfcBaseEntity"]
|
||||||
n = n.lower()
|
supertypes.extend(get_select_super_types(name))
|
||||||
return [k for k in mapping.schema.entities.keys() if k.lower() == n][0]
|
supertypes = list(map(case_normalize, supertypes))
|
||||||
|
superclass = create_supertype_statement(supertypes)
|
||||||
supertypes = map(case_norm, type.supertypes) if len(type.supertypes) else ["IfcUtil::IfcBaseEntity"]
|
|
||||||
superclass = ": %s " % (", ".join(["public %s" % c for c in supertypes]))
|
|
||||||
|
|
||||||
argument_count = mapping.argument_count(type)
|
argument_count = mapping.argument_count(type)
|
||||||
|
|
||||||
argument_start = argument_count - len(type.attributes)
|
argument_start = argument_count - len(type.attributes)
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ derived_field_statement = " {std::set<int> idxs; %(statements)sderived_map[Ty
|
|||||||
derived_field_statement_attrs = "idxs.insert(%d); "
|
derived_field_statement_attrs = "idxs.insert(%d); "
|
||||||
|
|
||||||
simpletype = """%(documentation)s
|
simpletype = """%(documentation)s
|
||||||
class IFC_PARSE_API %(name)s : public %(superclass)s {
|
class IFC_PARSE_API %(name)s : %(superclass)s {
|
||||||
public:
|
public:
|
||||||
virtual const IfcParse::type_declaration& declaration() const;
|
virtual const IfcParse::type_declaration& declaration() const;
|
||||||
static const IfcParse::type_declaration& Class();
|
static const IfcParse::type_declaration& Class();
|
||||||
@@ -137,7 +137,7 @@ simpletype_impl_cast_templated = (
|
|||||||
simpletype_impl_declaration = "return *%(schema_name_upper)s_%(class_name)s_type;"
|
simpletype_impl_declaration = "return *%(schema_name_upper)s_%(class_name)s_type;"
|
||||||
|
|
||||||
select = """%(documentation)s
|
select = """%(documentation)s
|
||||||
typedef IfcUtil::IfcBaseClass %(name)s;
|
class IFC_PARSE_API %(name)s : public virtual IfcUtil::IfcBaseInterface {};
|
||||||
"""
|
"""
|
||||||
|
|
||||||
enumeration = """class IFC_PARSE_API %(name)s : public IfcUtil::IfcBaseType {
|
enumeration = """class IFC_PARSE_API %(name)s : public IfcUtil::IfcBaseType {
|
||||||
@@ -157,7 +157,7 @@ public:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
entity = """%(documentation)s
|
entity = """%(documentation)s
|
||||||
class IFC_PARSE_API %(name)s %(superclass)s{
|
class IFC_PARSE_API %(name)s : %(superclass)s {
|
||||||
public:
|
public:
|
||||||
%(attributes)s %(inverse)s virtual const IfcParse::entity& declaration() const;
|
%(attributes)s %(inverse)s virtual const IfcParse::entity& declaration() const;
|
||||||
static const IfcParse::entity& Class();
|
static const IfcParse::entity& Class();
|
||||||
|
|||||||
+816
-816
File diff suppressed because it is too large
Load Diff
+966
-966
File diff suppressed because it is too large
Load Diff
+991
-991
File diff suppressed because it is too large
Load Diff
+1006
-1006
File diff suppressed because it is too large
Load Diff
+1075
-1075
File diff suppressed because it is too large
Load Diff
+1082
-1082
File diff suppressed because it is too large
Load Diff
+1071
-1071
File diff suppressed because it is too large
Load Diff
+1070
-1070
File diff suppressed because it is too large
Load Diff
+35
-24
@@ -33,14 +33,46 @@ class aggregate_of_instance;
|
|||||||
|
|
||||||
namespace IfcUtil {
|
namespace IfcUtil {
|
||||||
|
|
||||||
class IFC_PARSE_API IfcBaseClass {
|
class IFC_PARSE_API IfcBaseInterface {
|
||||||
|
protected:
|
||||||
|
static bool is_null(const IfcBaseInterface* not_this) {
|
||||||
|
return !not_this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual const IfcEntityInstanceData& data() const = 0;
|
||||||
|
virtual IfcEntityInstanceData& data() = 0;
|
||||||
|
virtual const IfcParse::declaration& declaration() const = 0;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
T* as() {
|
||||||
|
// @todo: do not allow this to be null in the first place
|
||||||
|
if (is_null(this)) {
|
||||||
|
return static_cast<T*>(0);
|
||||||
|
}
|
||||||
|
return declaration().is(T::Class())
|
||||||
|
? dynamic_cast<T*>(this)
|
||||||
|
: static_cast<T*>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
const T* as() const {
|
||||||
|
if (is_null(this)) {
|
||||||
|
return static_cast<const T*>(0);
|
||||||
|
}
|
||||||
|
return declaration().is(T::Class())
|
||||||
|
? dynamic_cast<const T*>(this)
|
||||||
|
: static_cast<const T*>(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IFC_PARSE_API IfcBaseClass : public virtual IfcBaseInterface {
|
||||||
protected:
|
protected:
|
||||||
IfcEntityInstanceData* data_;
|
IfcEntityInstanceData* data_;
|
||||||
|
|
||||||
static bool is_null(const IfcBaseClass* not_this) {
|
static bool is_null(const IfcBaseClass* not_this) {
|
||||||
return !not_this;
|
return !not_this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IfcBaseClass() : data_(0) {}
|
IfcBaseClass() : data_(0) {}
|
||||||
IfcBaseClass(IfcEntityInstanceData* d) : data_(d) {}
|
IfcBaseClass(IfcEntityInstanceData* d) : data_(d) {}
|
||||||
@@ -51,27 +83,6 @@ namespace IfcUtil {
|
|||||||
void data(IfcEntityInstanceData* d);
|
void data(IfcEntityInstanceData* d);
|
||||||
|
|
||||||
virtual const IfcParse::declaration& declaration() const = 0;
|
virtual const IfcParse::declaration& declaration() const = 0;
|
||||||
|
|
||||||
template <class T>
|
|
||||||
T* as() {
|
|
||||||
// @todo: do not allow this to be null in the first place
|
|
||||||
if (is_null(this)) {
|
|
||||||
return static_cast<T*>(0);
|
|
||||||
}
|
|
||||||
return declaration().is(T::Class())
|
|
||||||
? static_cast<T*>(this)
|
|
||||||
: static_cast<T*>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
const T* as() const {
|
|
||||||
if (is_null(this)) {
|
|
||||||
return static_cast<const T*>(0);
|
|
||||||
}
|
|
||||||
return declaration().is(T::Class())
|
|
||||||
? static_cast<const T*>(this)
|
|
||||||
: static_cast<const T*>(0);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class IFC_PARSE_API IfcLateBoundEntity : public IfcBaseClass {
|
class IFC_PARSE_API IfcLateBoundEntity : public IfcBaseClass {
|
||||||
|
|||||||
@@ -395,11 +395,13 @@ void IfcHierarchyHelper<Schema>::clipRepresentation(typename Schema::IfcRepresen
|
|||||||
typename Schema::IfcRepresentationItem::list::ptr items = rep->Items();
|
typename Schema::IfcRepresentationItem::list::ptr items = rep->Items();
|
||||||
typename Schema::IfcRepresentationItem::list::ptr new_items (new typename Schema::IfcRepresentationItem::list);
|
typename Schema::IfcRepresentationItem::list::ptr new_items (new typename Schema::IfcRepresentationItem::list);
|
||||||
for (typename Schema::IfcRepresentationItem::list::it i = items->begin(); i != items->end(); ++i) {
|
for (typename Schema::IfcRepresentationItem::list::it i = items->begin(); i != items->end(); ++i) {
|
||||||
typename Schema::IfcRepresentationItem* item = *i;
|
auto item = dynamic_cast<typename Schema::IfcBooleanOperand*>(*i);
|
||||||
typename Schema::IfcBooleanClippingResult* clip = new typename Schema::IfcBooleanClippingResult(
|
if (item) {
|
||||||
Schema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE, item, half_space);
|
typename Schema::IfcBooleanClippingResult* clip = new typename Schema::IfcBooleanClippingResult(
|
||||||
addEntity(clip);
|
Schema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE, item, half_space);
|
||||||
new_items->push(clip);
|
addEntity(clip);
|
||||||
|
new_items->push(clip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rep->setItems(new_items);
|
rep->setItems(new_items);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace {
|
|||||||
const std::array<std::basic_string<wchar_t>, 4> severity_strings<wchar_t>::value = { L"Debug", L"Notice", L"Warning", L"Error" };
|
const std::array<std::basic_string<wchar_t>, 4> severity_strings<wchar_t>::value = { L"Debug", L"Notice", L"Warning", L"Error" };
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void plain_text_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance) {
|
void plain_text_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||||
os << "[" << severity_strings<typename T::char_type>::value[type] << "] ";
|
os << "[" << severity_strings<typename T::char_type>::value[type] << "] ";
|
||||||
if (current_product) {
|
if (current_product) {
|
||||||
std::string global_id = *((IfcUtil::IfcBaseEntity*)*current_product)->get("GlobalId");
|
std::string global_id = *((IfcUtil::IfcBaseEntity*)*current_product)->get("GlobalId");
|
||||||
@@ -71,7 +71,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void json_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance) {
|
void json_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||||
boost::property_tree::basic_ptree<std::basic_string<typename T::char_type>, std::basic_string<typename T::char_type> > pt;
|
boost::property_tree::basic_ptree<std::basic_string<typename T::char_type>, std::basic_string<typename T::char_type> > pt;
|
||||||
|
|
||||||
// @todo this is crazy
|
// @todo this is crazy
|
||||||
@@ -117,7 +117,7 @@ void Logger::SetOutput(std::wostream* l1, std::wostream* l2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Message(Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance) {
|
void Logger::Message(Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||||
static std::mutex m;
|
static std::mutex m;
|
||||||
std::lock_guard<std::mutex> lk(m);
|
std::lock_guard<std::mutex> lk(m);
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ void Logger::Message(Logger::Severity type, const std::string& message, const If
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Message(Logger::Severity type, const std::exception& exception, const IfcUtil::IfcBaseClass* instance) {
|
void Logger::Message(Logger::Severity type, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance) {
|
||||||
Message(type, std::string(exception.what()), instance);
|
Message(type, std::string(exception.what()), instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,16 +72,16 @@ public:
|
|||||||
static Format OutputFormat();
|
static Format OutputFormat();
|
||||||
|
|
||||||
/// Log a message to the output stream
|
/// Log a message to the output stream
|
||||||
static void Message(Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance = 0);
|
static void Message(Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0);
|
||||||
static void Message(Severity type, const std::exception& message, const IfcUtil::IfcBaseClass* instance = 0);
|
static void Message(Severity type, const std::exception& message, const IfcUtil::IfcBaseInterface* instance = 0);
|
||||||
|
|
||||||
static void Notice(const std::string& message, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_NOTICE, message, instance); }
|
static void Notice(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, message, instance); }
|
||||||
static void Warning(const std::string& message, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_WARNING, message, instance); }
|
static void Warning(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, message, instance); }
|
||||||
static void Error(const std::string& message, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_ERROR, message, instance); }
|
static void Error(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, message, instance); }
|
||||||
|
|
||||||
static void Notice(const std::exception& exception, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_NOTICE, exception, instance); }
|
static void Notice(const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, exception, instance); }
|
||||||
static void Warning(const std::exception& exception, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_WARNING, exception, instance); }
|
static void Warning(const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, exception, instance); }
|
||||||
static void Error(const std::exception& exception, const IfcUtil::IfcBaseClass* instance = 0) { Message(LOG_ERROR, exception, instance); }
|
static void Error(const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, exception, instance); }
|
||||||
|
|
||||||
static void Status(const std::string& message, bool new_line=true);
|
static void Status(const std::string& message, bool new_line=true);
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ ptree* format_entity_instance(IfcUtil::IfcBaseEntity* instance, ptree& tree, boo
|
|||||||
return format_entity_instance(instance, child, tree, as_link);
|
return format_entity_instance(instance, child, tree, as_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string qualify_unrooted_instance(IfcUtil::IfcBaseClass* inst) {
|
std::string qualify_unrooted_instance(IfcUtil::IfcBaseInterface* inst) {
|
||||||
return inst->declaration().name() + "_" + boost::lexical_cast<std::string>(inst->data().id());
|
return inst->declaration().name() + "_" + boost::lexical_cast<std::string>(inst->data().id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user