mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
- Add support for IFC4 nurbs surfaces (IfcBSplineSurfaceWithKnots and IfcAdvancedFace)
- Remove unnecessary typedefs
This commit is contained in:
@@ -213,12 +213,12 @@ int main(int argc, char** argv) {
|
||||
// will be tesselated using the deflection specified.
|
||||
TopoDS_Shape shape;
|
||||
createGroundShape(shape);
|
||||
IfcEntities geometrical_entities(new IfcEntityList());
|
||||
IfcEntityList::ptr geometrical_entities(new IfcEntityList);
|
||||
IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(shape, 100., geometrical_entities);
|
||||
file.getSingle<IfcSchema::IfcSite>()->setRepresentation(ground_representation);
|
||||
file.AddEntities(geometrical_entities);
|
||||
IfcSchema::IfcShapeRepresentation::list ground_reps = geometrical_entities->as<IfcSchema::IfcShapeRepresentation>();
|
||||
for (IfcSchema::IfcShapeRepresentation::it it = ground_reps->begin(); it != ground_reps->end(); ++it) {
|
||||
IfcSchema::IfcShapeRepresentation::list::ptr ground_reps = geometrical_entities->as<IfcSchema::IfcShapeRepresentation>();
|
||||
for (IfcSchema::IfcShapeRepresentation::list::it it = ground_reps->begin(); it != ground_reps->end(); ++it) {
|
||||
(*it)->setContextOfItems(file.getSingle<IfcSchema::IfcRepresentationContext>());
|
||||
}
|
||||
file.setSurfaceColour(ground_representation, 0.15, 0.25, 0.05);
|
||||
@@ -246,7 +246,7 @@ int main(int argc, char** argv) {
|
||||
, null
|
||||
#endif
|
||||
);
|
||||
IfcSchema::IfcMaterialLayer::list layers (new IfcTemplatedEntityList<IfcSchema::IfcMaterialLayer>());
|
||||
IfcSchema::IfcMaterialLayer::list::ptr layers (new IfcTemplatedEntityList<IfcSchema::IfcMaterialLayer>());
|
||||
layers->push(layer);
|
||||
IfcSchema::IfcMaterialLayerSet* layer_set = new IfcSchema::IfcMaterialLayerSet(
|
||||
layers,
|
||||
@@ -324,9 +324,9 @@ int main(int argc, char** argv) {
|
||||
#endif
|
||||
);
|
||||
door->setRepresentation(file.addBox(80, 80, 2120, 0, file.addPlacement3d(460, 0, 0)));
|
||||
IfcSchema::IfcRepresentation::list door_representations = door->Representation()->Representations();
|
||||
IfcSchema::IfcRepresentation::list::ptr door_representations = door->Representation()->Representations();
|
||||
IfcSchema::IfcShapeRepresentation* door_body = 0;
|
||||
for (IfcSchema::IfcRepresentation::it i = door_representations->begin(); i != door_representations->end(); ++i) {
|
||||
for (IfcSchema::IfcRepresentation::list::it i = door_representations->begin(); i != door_representations->end(); ++i) {
|
||||
IfcSchema::IfcRepresentation* rep = *i;
|
||||
if (rep->is(IfcSchema::Type::IfcShapeRepresentation) && rep->RepresentationIdentifier() == "Body") {
|
||||
door_body = (IfcSchema::IfcShapeRepresentation*) rep;
|
||||
@@ -350,7 +350,7 @@ int main(int argc, char** argv) {
|
||||
// Therefore the OverallWidth and OverallHeight of the window attributes will need to
|
||||
// match the bounding box of the representation. Furthermore, the window placement needs
|
||||
// to align with the lowerleft corner of the constituent parts.
|
||||
IfcSchema::IfcProductDefinitionShape::list frame_representations (new IfcTemplatedEntityList<IfcSchema::IfcProductDefinitionShape>());
|
||||
IfcSchema::IfcProductDefinitionShape::list::ptr frame_representations (new IfcTemplatedEntityList<IfcSchema::IfcProductDefinitionShape>());
|
||||
frame_representations->push(file.addBox(1860, 90, 90));
|
||||
frame_representations->push(*frame_representations->begin()); // Add a reference to the shape created above
|
||||
frame_representations->push(file.addBox(90, 90, 1420));
|
||||
@@ -358,7 +358,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
// The beams all have the same surface style assigned
|
||||
IfcSchema::IfcPresentationStyleAssignment* frame_style = 0;
|
||||
for (IfcSchema::IfcProductDefinitionShape::it i = frame_representations->begin(); i != frame_representations->end(); ++i) {
|
||||
for (IfcSchema::IfcProductDefinitionShape::list::it i = frame_representations->begin(); i != frame_representations->end(); ++i) {
|
||||
if (frame_style) {
|
||||
file.setSurfaceColour(*i, frame_style);
|
||||
} else {
|
||||
@@ -368,14 +368,14 @@ int main(int argc, char** argv) {
|
||||
|
||||
// This window will be placed at five locations within the building. A list of placements is
|
||||
// created and is iterated over to create all window instances.
|
||||
IfcSchema::IfcLocalPlacement::list window_placements (new IfcTemplatedEntityList<IfcSchema::IfcLocalPlacement>());
|
||||
IfcSchema::IfcLocalPlacement::list::ptr window_placements (new IfcTemplatedEntityList<IfcSchema::IfcLocalPlacement>());
|
||||
window_placements->push(file.addLocalPlacement(2*-1770-430-930, -45, 400));
|
||||
window_placements->push(file.addLocalPlacement( -1770-430-930, -45, 400));
|
||||
window_placements->push(file.addLocalPlacement( -430-930, -45, 400));
|
||||
window_placements->push(file.addLocalPlacement( 3000-930, -45, 400));
|
||||
window_placements->push(file.addLocalPlacement( -4855+45, 885-930, 400, 0, 0, 1, 0, 1, 0));
|
||||
|
||||
for (IfcSchema::IfcLocalPlacement::it it = window_placements->begin(); it != window_placements->end(); ++it) {
|
||||
for (IfcSchema::IfcLocalPlacement::list::it it = window_placements->begin(); it != window_placements->end(); ++it) {
|
||||
|
||||
// Create the window at the current location
|
||||
IfcSchema::IfcLocalPlacement* place = *it;
|
||||
@@ -390,19 +390,19 @@ int main(int argc, char** argv) {
|
||||
file.addBuildingProduct(window);
|
||||
|
||||
// Initalize a list of parts for the window to be composed of
|
||||
IfcSchema::IfcObjectDefinition::list window_parts(new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
|
||||
IfcSchema::IfcObjectDefinition::list::ptr window_parts(new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
|
||||
|
||||
// The placements for the beams are not shared accross the different windows because every
|
||||
// beam is placed relative to its parent window entity.
|
||||
IfcSchema::IfcLocalPlacement::list frame_placements (new IfcTemplatedEntityList<IfcSchema::IfcLocalPlacement>());
|
||||
IfcSchema::IfcLocalPlacement::list::ptr frame_placements (new IfcTemplatedEntityList<IfcSchema::IfcLocalPlacement>());
|
||||
frame_placements->push(file.addLocalPlacement( 930,45));
|
||||
frame_placements->push(file.addLocalPlacement( 930, 45, 1510));
|
||||
frame_placements->push(file.addLocalPlacement(-885+930, 45, 90));
|
||||
frame_placements->push(file.addLocalPlacement( 885+930, 45, 90));
|
||||
|
||||
// Now iterate over the placements and representations of the beam and add them to list of parts
|
||||
IfcSchema::IfcLocalPlacement::it frame_placement;
|
||||
IfcSchema::IfcProductDefinitionShape::it frame_representation;
|
||||
IfcSchema::IfcLocalPlacement::list::it frame_placement;
|
||||
IfcSchema::IfcProductDefinitionShape::list::it frame_representation;
|
||||
for (frame_placement = frame_placements->begin(), frame_representation = frame_representations->begin();
|
||||
frame_placement != frame_placements->end() && frame_representation != frame_representations->end();
|
||||
++frame_placement, ++frame_representation)
|
||||
|
||||
@@ -64,7 +64,7 @@ int main(int argc, char** argv) {
|
||||
std::cout << element->entity->toString() << std::endl;
|
||||
|
||||
if ( element->is(IfcWindow::Class()) ) {
|
||||
const IfcWindow::ptr window = reinterpret_pointer_cast<IfcBuildingElement,IfcWindow>(element);
|
||||
const IfcWindow::ptr window = (IfcWindow*)element;
|
||||
|
||||
if ( window->hasOverallWidth() && window->hasOverallHeight() ) {
|
||||
const double area = window->OverallWidth()*window->OverallHeight();
|
||||
|
||||
@@ -124,8 +124,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
IfcSchema::IfcEllipse* ellipse = new IfcSchema::IfcEllipse(file.addPlacement2d(), 50., 25.);
|
||||
file.AddEntity(ellipse);
|
||||
IfcEntities trim1(new IfcEntityList());
|
||||
IfcEntities trim2(new IfcEntityList());
|
||||
IfcEntityList::ptr trim1(new IfcEntityList);
|
||||
IfcEntityList::ptr trim2(new IfcEntityList);
|
||||
trim1->push(new IfcWrite::IfcSelectHelper( 0., Ifc2x3::Type::IfcParameterValue));
|
||||
trim2->push(new IfcWrite::IfcSelectHelper(180., Ifc2x3::Type::IfcParameterValue));
|
||||
IfcSchema::IfcTrimmedCurve* trim = new IfcSchema::IfcTrimmedCurve(ellipse, trim1, trim2, true, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER);
|
||||
|
||||
@@ -67,8 +67,8 @@ void create_testcase_for(IfcHierarchyHelper& file, const EllipsePie& pie, Ifc2x3
|
||||
|
||||
Ifc2x3::IfcEllipse* ellipse = new Ifc2x3::IfcEllipse(file.addPlacement2d(), pie.r1, pie.r2);
|
||||
file.AddEntity(ellipse);
|
||||
IfcEntities trim1(new IfcEntityList());
|
||||
IfcEntities trim2(new IfcEntityList());
|
||||
IfcEntityList::ptr trim1(new IfcEntityList);
|
||||
IfcEntityList::ptr trim2(new IfcEntityList);
|
||||
if (pref == Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER) {
|
||||
trim1->push(new IfcWrite::IfcSelectHelper(pie.t1, Ifc2x3::Type::IfcParameterValue));
|
||||
trim2->push(new IfcWrite::IfcSelectHelper(pie.t2, Ifc2x3::Type::IfcParameterValue));
|
||||
|
||||
@@ -65,11 +65,11 @@ class Header:
|
||||
def write_method(attr):
|
||||
if attr.optional:
|
||||
attr_lines.append(templates.optional_attribute_description % (attr.name, name))
|
||||
attr_lines.append("bool has%s();"%(attr.name))
|
||||
attr_lines.append("bool has%s() const;"%(attr.name))
|
||||
attr_lines.extend(["/// %s"%d for d in documentation.description((name, attr.name))])
|
||||
type_str = mapping.get_parameter_type(attr, allow_optional=False, allow_entities=False)
|
||||
if mapping.make_argument_type(attr) != "IfcUtil::Argument_UNKNOWN":
|
||||
attr_lines.append("%s %s();"%(type_str, attr.name))
|
||||
attr_lines.append("%s %s() const;"%(type_str, attr.name))
|
||||
attr_lines.append("void set%s(%s v);"%(attr.name, type_str))
|
||||
|
||||
[write_method(attr) for attr in type.attributes]
|
||||
|
||||
@@ -61,17 +61,26 @@ class Implementation:
|
||||
if not arg['is_inherited'] and not arg['is_derived']:
|
||||
if arg['is_optional']:
|
||||
write_attr(
|
||||
templates.function,
|
||||
templates.const_function,
|
||||
class_name = name,
|
||||
name = 'has%s'%arg['name'],
|
||||
arguments = '',
|
||||
return_type = 'bool',
|
||||
body = templates.optional_attr_stmt % {'index':arg['index']-1}
|
||||
)
|
||||
|
||||
def find_template(arg):
|
||||
simple = mapping.schema.is_simpletype(arg['list_instance_type'])
|
||||
express = arg['list_instance_type'] in mapping.express_to_cpp_typemapping
|
||||
if arg['is_enum']: return templates.get_attr_stmt_enum
|
||||
elif arg['is_nested']: return templates.get_attr_stmt_nested_array
|
||||
elif arg['is_array'] and not (simple or express): return templates.get_attr_stmt_array
|
||||
elif arg['non_optional_type'].endswith('*'): return templates.get_attr_stmt_entity
|
||||
else: return templates.get_attr_stmt
|
||||
|
||||
tmpl = templates.get_attr_stmt_enum if arg['is_enum'] else templates.get_attr_stmt_array if arg['is_array'] and not mapping.schema.is_simpletype(arg['list_instance_type']) and arg['list_instance_type'] not in mapping.express_to_cpp_typemapping else templates.get_attr_stmt_entity if arg['non_optional_type'].endswith('*') else templates.get_attr_stmt
|
||||
tmpl = find_template(arg)
|
||||
write_attr(
|
||||
templates.function,
|
||||
templates.const_function,
|
||||
class_name = name,
|
||||
name = arg['name'],
|
||||
arguments = '',
|
||||
@@ -111,15 +120,15 @@ class Implementation:
|
||||
'stmt' : impl}
|
||||
constructor_implementations.append(impl)
|
||||
|
||||
inverse = [templates.function % {
|
||||
inverse = [templates.const_function % {
|
||||
'class_name' : name,
|
||||
'name' : i.name,
|
||||
'arguments' : '',
|
||||
'return_type' : '%s::list' % i.entity,
|
||||
'return_type' : '%s::list::ptr' % i.entity,
|
||||
'body' : templates.get_inverse % {'type': i.entity}
|
||||
} for i in (type.inverse.elements if type.inverse else [])]
|
||||
|
||||
superclass = "%s((IfcAbstractEntityPtr)0)" % type.supertypes[0] if len(type.supertypes) == 1 else 'IfcUtil::IfcBaseEntity()'
|
||||
superclass = "%s((IfcAbstractEntity*)0)" % type.supertypes[0] if len(type.supertypes) == 1 else 'IfcUtil::IfcBaseEntity()'
|
||||
|
||||
write(
|
||||
templates.entity_implementation,
|
||||
|
||||
@@ -39,7 +39,8 @@ class Mapping:
|
||||
return self.express_to_cpp_typemapping.get(type, type)
|
||||
else:
|
||||
is_list = self.schema.is_entity(type.type)
|
||||
tmpl = templates.list_type if is_list else templates.array_type
|
||||
is_nested_list = isinstance(type.type, nodes.AggregationType)
|
||||
tmpl = templates.list_list_type if is_nested_list else templates.list_type if is_list else templates.array_type
|
||||
return tmpl % {
|
||||
'instance_type' : self.make_type_string(type.type),
|
||||
'lower' : type.bounds.lower,
|
||||
@@ -71,9 +72,9 @@ class Mapping:
|
||||
elif isinstance(type, nodes.AggregationType):
|
||||
ty = _make_argument_type(type.type)
|
||||
if ty == "UNKNOWN": return "UNKNOWN"
|
||||
return "ENTITY_LIST" if ty == "ENTITY" else ("VECTOR_%s"%ty)
|
||||
return "%s_LIST"%ty if ty.startswith("ENTITY") else ("VECTOR_%s"%ty)
|
||||
else: raise ValueError
|
||||
supported = {'INT', 'BOOL', 'DOUBLE', 'STRING', 'VECTOR_INT', 'VECTOR_DOUBLE', 'VECTOR_STRING', 'ENTITY', 'ENTITY_LIST', 'ENUMERATION'}
|
||||
supported = {'INT', 'BOOL', 'DOUBLE', 'STRING', 'VECTOR_INT', 'VECTOR_DOUBLE', 'VECTOR_STRING', 'ENTITY', 'ENTITY_LIST', 'ENTITY_LIST_LIST', 'ENUMERATION'}
|
||||
ty = _make_argument_type(attr.type)
|
||||
if ty not in supported: ty = 'UNKNOWN'
|
||||
return "IfcUtil::Argument_%s" % ty
|
||||
@@ -90,7 +91,8 @@ class Mapping:
|
||||
if self.schema.is_enumeration(attr.type):
|
||||
type_str = '%s::%s'%(attr.type, attr.type)
|
||||
elif isinstance(type_str, nodes.AggregationType):
|
||||
ty = self.get_parameter_type(attr.type, False, allow_entities, allow_pointer=False)
|
||||
is_nested_list = isinstance(attr.type.type, nodes.AggregationType)
|
||||
ty = self.get_parameter_type(attr.type.type if is_nested_list else attr.type, False, allow_entities, allow_pointer=False)
|
||||
if allow_entities and self.schema.is_select(attr.type.type):
|
||||
type_str = templates.untyped_list
|
||||
elif self.schema.is_simpletype(ty) or ty in self.express_to_cpp_typemapping.values():
|
||||
@@ -100,7 +102,8 @@ class Mapping:
|
||||
'upper' : attr.type.bounds.upper
|
||||
}
|
||||
else:
|
||||
type_str = templates.list_type % {
|
||||
tmpl = templates.list_list_type if is_nested_list else templates.list_type
|
||||
type_str = tmpl % {
|
||||
'instance_type': ty
|
||||
}
|
||||
elif allow_pointer and self.schema.is_entity(type_str):
|
||||
@@ -127,11 +130,16 @@ class Mapping:
|
||||
|
||||
def list_instance_type(self, attr):
|
||||
f = lambda v : 'IfcUtil::IfcAbstractSelect' if self.schema.is_select(v) else v
|
||||
if self.is_array(attr.type) and not isinstance(attr.type, str):
|
||||
return f(attr.type.type)
|
||||
elif self.is_array(attr.type) and isinstance(attr.type, str):
|
||||
return f(attr.type)
|
||||
else: return None
|
||||
if self.is_array(attr.type):
|
||||
if not isinstance(attr.type, str) and self.is_array(attr.type.type):
|
||||
if isinstance(attr.type.type, str):
|
||||
return f(attr.type.type)
|
||||
else: return f(attr.type.type.type)
|
||||
else:
|
||||
if isinstance(attr.type, str):
|
||||
return f(attr.type)
|
||||
else: return f(attr.type.type)
|
||||
return None
|
||||
|
||||
def is_templated_list(self, attr):
|
||||
ty = self.list_instance_type(attr)
|
||||
@@ -163,6 +171,7 @@ class Mapping:
|
||||
'is_inherited' : i < num_inherited,
|
||||
'is_enum' : attr.type in self.schema.enumerations,
|
||||
'is_array' : self.is_array(attr.type),
|
||||
'is_nested' : self.is_array(attr.type) and not isinstance(attr.type, str) and self.is_array(attr.type.type),
|
||||
'is_derived' : attr.name in derived,
|
||||
'is_templated_list' : self.is_templated_list(attr)
|
||||
} for i, attr in attrs if include(attr)]
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace %(schema_name)s {
|
||||
|
||||
%(class_definitions)s
|
||||
void InitStringMap();
|
||||
IfcUtil::IfcSchemaEntity SchemaEntity(IfcAbstractEntityPtr e = 0);
|
||||
IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -81,7 +81,7 @@ using namespace %(schema_name)s;
|
||||
using namespace IfcParse;
|
||||
using namespace IfcWrite;
|
||||
|
||||
IfcUtil::IfcSchemaEntity %(schema_name)s::SchemaEntity(IfcAbstractEntityPtr e) {
|
||||
IfcUtil::IfcBaseClass* %(schema_name)s::SchemaEntity(IfcAbstractEntity* e) {
|
||||
switch(e->type()) {
|
||||
%(schema_entity_statements)s
|
||||
default: throw IfcException("Unable to find find keyword in schema"); break;
|
||||
@@ -117,25 +117,6 @@ bool Type::IsSimple(Enum v) {
|
||||
|
||||
%(enumeration_functions)s
|
||||
|
||||
#define RETURN_INVERSE(T) \
|
||||
IfcEntities e = entity->getInverse(T::Class()); \
|
||||
SHARED_PTR< IfcTemplatedEntityList<T> > l ( new IfcTemplatedEntityList<T>() ); \
|
||||
for ( IfcEntityList::it it = e->begin(); it != e->end(); ++ it ) { \
|
||||
l->push(reinterpret_pointer_cast<IfcBaseClass,T>(*it)); \
|
||||
} \
|
||||
return l;
|
||||
|
||||
#define RETURN_AS_SINGLE(T,a) \
|
||||
return reinterpret_pointer_cast<IfcBaseClass,T>(*entity->getArgument(a));
|
||||
|
||||
#define RETURN_AS_LIST(T,a) \
|
||||
IfcEntities e = *entity->getArgument(a); \
|
||||
SHARED_PTR< IfcTemplatedEntityList<T> > l ( new IfcTemplatedEntityList<T>() ); \
|
||||
for ( IfcEntityList::it it = e->begin(); it != e->end(); ++ it ) { \
|
||||
l->push(reinterpret_pointer_cast<IfcBaseClass,T>(*it)); \
|
||||
} \
|
||||
return l;
|
||||
|
||||
%(entity_implementations)s
|
||||
"""
|
||||
|
||||
@@ -144,7 +125,7 @@ typedef %(type)s %(name)s;
|
||||
"""
|
||||
|
||||
select = """%(documentation)s
|
||||
typedef IfcUtil::IfcSchemaEntity %(name)s;
|
||||
typedef IfcUtil::IfcBaseClass* %(name)s;
|
||||
"""
|
||||
|
||||
enumeration = """namespace %(name)s {
|
||||
@@ -161,15 +142,13 @@ public:
|
||||
%(attributes)s virtual unsigned int getArgumentCount() const { return %(argument_count)d; }
|
||||
virtual IfcUtil::ArgumentType getArgumentType(unsigned int i) const {%(argument_type_function_body)s}
|
||||
virtual const char* getArgumentName(unsigned int i) const {%(argument_name_function_body)s}
|
||||
virtual ArgumentPtr getArgument(unsigned int i) const { return entity->getArgument(i); }
|
||||
virtual Argument* getArgument(unsigned int i) const { return entity->getArgument(i); }
|
||||
%(inverse)s bool is(Type::Enum v) const;
|
||||
Type::Enum type() const;
|
||||
static Type::Enum Class();
|
||||
%(name)s (IfcAbstractEntityPtr e);
|
||||
%(name)s (IfcAbstractEntity* e);
|
||||
%(name)s (%(constructor_arguments)s);
|
||||
typedef %(name)s* ptr;
|
||||
typedef SHARED_PTR< IfcTemplatedEntityList< %(name)s > > list;
|
||||
typedef IfcTemplatedEntityList< %(name)s >::it it;
|
||||
typedef IfcTemplatedEntityList< %(name)s > list;
|
||||
};
|
||||
"""
|
||||
|
||||
@@ -190,18 +169,20 @@ entity_implementation = """// Function implementations for %(name)s
|
||||
%(attributes)s%(inverse)sbool %(name)s::is(Type::Enum v) const { return v == Type::%(name)s%(parent_type_test)s; }
|
||||
Type::Enum %(name)s::type() const { return Type::%(name)s; }
|
||||
Type::Enum %(name)s::Class() { return Type::%(name)s; }
|
||||
%(name)s::%(name)s(IfcAbstractEntityPtr e) : %(superclass)s { if (!e) return; if (!e->is(Type::%(name)s)) throw IfcException("Unable to find find keyword in schema"); entity = e; }
|
||||
%(name)s::%(name)s(IfcAbstractEntity* e) : %(superclass)s { if (!e) return; if (!e->is(Type::%(name)s)) throw IfcException("Unable to find find keyword in schema"); entity = e; }
|
||||
%(name)s::%(name)s(%(constructor_arguments)s) : %(superclass)s { IfcWritableEntity* e = new IfcWritableEntity(Class());%(constructor_implementation)s entity = e; EntityBuffer::Add(this); }
|
||||
"""
|
||||
|
||||
optional_attribute_description = "/// Whether the optional attribute %s is defined for this %s"
|
||||
|
||||
function = "%(return_type)s %(class_name)s::%(name)s(%(arguments)s) { %(body)s }"
|
||||
const_function = "%(return_type)s %(class_name)s::%(name)s(%(arguments)s) const { %(body)s }"
|
||||
|
||||
array_type = "std::vector< %(instance_type)s > /*[%(lower)s:%(upper)s]*/"
|
||||
list_type = "SHARED_PTR< IfcTemplatedEntityList< %(instance_type)s > >"
|
||||
untyped_list = "IfcEntities"
|
||||
inverse_attr = "SHARED_PTR< IfcTemplatedEntityList< %(entity)s > > %(name)s(); // INVERSE %(entity)s::%(attribute)s"
|
||||
list_type = "IfcTemplatedEntityList< %(instance_type)s >::ptr"
|
||||
list_list_type = "IfcTemplatedEntityListList< %(instance_type)s >::ptr"
|
||||
untyped_list = "IfcEntityList::ptr"
|
||||
inverse_attr = "IfcTemplatedEntityList< %(entity)s >::ptr %(name)s() const; // INVERSE %(entity)s::%(attribute)s"
|
||||
|
||||
enum_from_string_stmt = ' if (s == "%(value)s") return ::%(schema_name)s::%(name)s::%(short_name)s_%(value)s;'
|
||||
|
||||
@@ -216,10 +197,11 @@ optional_attr_stmt = "return !entity->getArgument(%(index)d)->isNull();"
|
||||
|
||||
get_attr_stmt = "return *entity->getArgument(%(index)d);"
|
||||
get_attr_stmt_enum = "return %(type)s::FromString(*entity->getArgument(%(index)d));"
|
||||
get_attr_stmt_entity = "return (%(type)s)((IfcUtil::IfcSchemaEntity)(*entity->getArgument(%(index)d)));"
|
||||
get_attr_stmt_array = "RETURN_AS_LIST(%(list_instance_type)s,%(index)d)"
|
||||
get_attr_stmt_entity = "return (%(type)s)((IfcUtil::IfcBaseClass*)(*entity->getArgument(%(index)d)));"
|
||||
get_attr_stmt_array = "IfcEntityList::ptr es = *entity->getArgument(%(index)d); return es->as<%(list_instance_type)s>();"
|
||||
get_attr_stmt_nested_array = "IfcEntityListList::ptr es = *entity->getArgument(%(index)d); return es->as<%(list_instance_type)s>();"
|
||||
|
||||
get_inverse = "RETURN_INVERSE(%(type)s)"
|
||||
get_inverse = "return entity->getInverse(Type::%(type)s)->as<%(type)s>();"
|
||||
|
||||
set_attr_stmt = "if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(%(index)d,v);"
|
||||
set_attr_stmt_enum = "if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(%(index)d,v,%(type)s::ToString(v));"
|
||||
|
||||
@@ -87,8 +87,8 @@ namespace IfcGeom {
|
||||
bool convert_wire(const IfcUtil::IfcBaseClass* L, TopoDS_Wire& result);
|
||||
bool convert_curve(const IfcUtil::IfcBaseClass* L, Handle(Geom_Curve)& result);
|
||||
bool convert_face(const IfcUtil::IfcBaseClass* L, TopoDS_Shape& result);
|
||||
bool convert_openings(const IfcSchema::IfcProduct::ptr entity, const IfcSchema::IfcRelVoidsElement::list& openings, const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes);
|
||||
bool convert_openings_fast(const IfcSchema::IfcProduct::ptr entity, const IfcSchema::IfcRelVoidsElement::list& 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);
|
||||
IfcSchema::IfcSurfaceStyleShading* get_surface_style(IfcSchema::IfcRepresentationItem* item);
|
||||
bool create_solid_from_compound(const TopoDS_Shape& compound, TopoDS_Shape& solid);
|
||||
bool is_compound(const TopoDS_Shape& shape);
|
||||
@@ -104,7 +104,7 @@ namespace IfcGeom {
|
||||
void SetValue(GeomValue var, double value);
|
||||
double GetValue(GeomValue var);
|
||||
bool fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape);
|
||||
IfcSchema::IfcProductDefinitionShape* tesselate(TopoDS_Shape& shape, double deflection, IfcEntities es);
|
||||
IfcSchema::IfcProductDefinitionShape* tesselate(TopoDS_Shape& shape, double deflection, IfcEntityList::ptr es);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
|
||||
#include "../ifcgeom/IfcGeom.h"
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCircle::ptr l, Handle(Geom_Curve)& curve) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCircle* l, Handle(Geom_Curve)& curve) {
|
||||
const double r = l->Radius() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
if ( r < ALMOST_ZERO ) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", l->entity);
|
||||
@@ -98,7 +98,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCircle::ptr l, Handle(Geom_Curve)& cur
|
||||
curve = new Geom_Circle(ax, r);
|
||||
return true;
|
||||
}
|
||||
bool IfcGeom::convert(const IfcSchema::IfcEllipse::ptr l, Handle(Geom_Curve)& curve) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcEllipse* l, Handle(Geom_Curve)& curve) {
|
||||
double x = l->SemiAxis1() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
double y = l->SemiAxis2() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
if (x < ALMOST_ZERO || y < ALMOST_ZERO) {
|
||||
@@ -128,7 +128,7 @@ bool IfcGeom::convert(const IfcSchema::IfcEllipse::ptr l, Handle(Geom_Curve)& cu
|
||||
curve = new Geom_Ellipse(ax, x, y);
|
||||
return true;
|
||||
}
|
||||
bool IfcGeom::convert(const IfcSchema::IfcLine::ptr l, Handle(Geom_Curve)& curve) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcLine* l, Handle(Geom_Curve)& curve) {
|
||||
gp_Pnt pnt;gp_Vec vec;
|
||||
IfcGeom::convert(l->Pnt(),pnt);
|
||||
IfcGeom::convert(l->Dir(),vec);
|
||||
|
||||
+131
-27
@@ -85,12 +85,22 @@
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepBuilderAPI_Transform.hxx>
|
||||
|
||||
#ifdef USE_IFC4
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <BRepCheck_Face.hxx>
|
||||
#endif
|
||||
|
||||
#include "../ifcgeom/IfcGeom.h"
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcFace::ptr l, TopoDS_Shape& face) {
|
||||
IfcSchema::IfcFaceBound::list bounds = l->Bounds();
|
||||
IfcSchema::IfcFaceBound::it it = bounds->begin();
|
||||
IfcSchema::IfcLoop::ptr loop = (*it)->Bound();
|
||||
bool IfcGeom::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
|
||||
IfcSchema::IfcFaceBound::list::ptr bounds = l->Bounds();
|
||||
IfcSchema::IfcFaceBound::list::it it = bounds->begin();
|
||||
IfcSchema::IfcLoop* loop = (*it)->Bound();
|
||||
TopoDS_Wire outer_wire;
|
||||
if ( ! IfcGeom::convert_wire(loop,outer_wire) ) return false;
|
||||
BRepBuilderAPI_MakeFace mf (outer_wire);
|
||||
@@ -107,7 +117,7 @@ bool IfcGeom::convert(const IfcSchema::IfcFace::ptr l, TopoDS_Shape& face) {
|
||||
face = mf.Face();
|
||||
} else {
|
||||
for( ++it; it != bounds->end(); ++ it) {
|
||||
IfcSchema::IfcLoop::ptr loop = (*it)->Bound();
|
||||
IfcSchema::IfcLoop* loop = (*it)->Bound();
|
||||
TopoDS_Wire wire;
|
||||
if ( ! IfcGeom::convert_wire(loop,wire) ) return false;
|
||||
mf.Add(wire);
|
||||
@@ -193,7 +203,7 @@ bool IfcGeom::convert(const IfcSchema::IfcFace::ptr l, TopoDS_Shape& face) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcArbitraryClosedProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcArbitraryClosedProfileDef* l, TopoDS_Shape& face) {
|
||||
TopoDS_Wire wire;
|
||||
if ( ! IfcGeom::convert_wire(l->OuterCurve(),wire) ) return false;
|
||||
|
||||
@@ -203,12 +213,12 @@ bool IfcGeom::convert(const IfcSchema::IfcArbitraryClosedProfileDef::ptr l, Topo
|
||||
return success;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcArbitraryProfileDefWithVoids::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcArbitraryProfileDefWithVoids* l, TopoDS_Shape& face) {
|
||||
TopoDS_Wire profile;
|
||||
if ( ! IfcGeom::convert_wire(l->OuterCurve(),profile) ) return false;
|
||||
BRepBuilderAPI_MakeFace mf(profile);
|
||||
IfcSchema::IfcCurve::list voids = l->InnerCurves();
|
||||
for( IfcSchema::IfcCurve::it it = voids->begin(); it != voids->end(); ++ it ) {
|
||||
IfcSchema::IfcCurve::list::ptr voids = l->InnerCurves();
|
||||
for( IfcSchema::IfcCurve::list::it it = voids->begin(); it != voids->end(); ++ it ) {
|
||||
TopoDS_Wire hole;
|
||||
if ( IfcGeom::convert_wire(*it,hole) ) {
|
||||
mf.Add(hole);
|
||||
@@ -220,7 +230,7 @@ bool IfcGeom::convert(const IfcSchema::IfcArbitraryProfileDefWithVoids::ptr l, T
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRectangleProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRectangleProfileDef* l, TopoDS_Shape& face) {
|
||||
const double x = l->XDim() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double y = l->YDim() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
|
||||
@@ -235,7 +245,7 @@ bool IfcGeom::convert(const IfcSchema::IfcRectangleProfileDef::ptr l, TopoDS_Sha
|
||||
return IfcGeom::profile_helper(4,coords,0,0,0,trsf2d,face);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRoundedRectangleProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRoundedRectangleProfileDef* l, TopoDS_Shape& face) {
|
||||
const double x = l->XDim() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double y = l->YDim() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double r = l->RoundingRadius() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
@@ -253,7 +263,7 @@ bool IfcGeom::convert(const IfcSchema::IfcRoundedRectangleProfileDef::ptr l, Top
|
||||
return IfcGeom::profile_helper(4,coords,4,fillets,radii,trsf2d,face);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRectangleHollowProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRectangleHollowProfileDef* l, TopoDS_Shape& face) {
|
||||
const double x = l->XDim() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double y = l->YDim() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double d = l->WallThickness() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
@@ -300,7 +310,7 @@ bool IfcGeom::convert(const IfcSchema::IfcRectangleHollowProfileDef::ptr l, Topo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcTrapeziumProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcTrapeziumProfileDef* l, TopoDS_Shape& face) {
|
||||
const double x1 = l->BottomXDim() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double w = l->TopXDim() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double dx = l->TopXOffset() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
@@ -317,7 +327,7 @@ bool IfcGeom::convert(const IfcSchema::IfcTrapeziumProfileDef::ptr l, TopoDS_Sha
|
||||
return IfcGeom::profile_helper(4,coords,0,0,0,trsf2d,face);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcIShapeProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Shape& face) {
|
||||
const double x = l->OverallWidth() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double y = l->OverallDepth() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double d1 = l->WebThickness() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
@@ -342,7 +352,7 @@ bool IfcGeom::convert(const IfcSchema::IfcIShapeProfileDef::ptr l, TopoDS_Shape&
|
||||
return IfcGeom::profile_helper(12,coords,doFillet ? 4 : 0,fillets,radii,trsf2d,face);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcZShapeProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcZShapeProfileDef* l, TopoDS_Shape& face) {
|
||||
const double x = l->FlangeWidth() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double y = l->Depth() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double dx = l->WebThickness() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
@@ -375,7 +385,7 @@ bool IfcGeom::convert(const IfcSchema::IfcZShapeProfileDef::ptr l, TopoDS_Shape&
|
||||
return IfcGeom::profile_helper(8,coords,(doFillet || doEdgeFillet) ? 4 : 0,fillets,radii,trsf2d,face);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCShapeProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCShapeProfileDef* l, TopoDS_Shape& face) {
|
||||
const double y = l->Depth() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double x = l->Width() / 2.0f * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double d1 = l->WallThickness() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
@@ -402,7 +412,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCShapeProfileDef::ptr l, TopoDS_Shape&
|
||||
return IfcGeom::profile_helper(12,coords,doFillet ? 8 : 0,fillets,radii,trsf2d,face);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcLShapeProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcLShapeProfileDef* l, TopoDS_Shape& face) {
|
||||
const bool hasSlope = l->hasLegSlope();
|
||||
const bool doEdgeFillet = l->hasEdgeRadius();
|
||||
const bool doFillet = l->hasFilletRadius();
|
||||
@@ -471,7 +481,7 @@ bool IfcGeom::convert(const IfcSchema::IfcLShapeProfileDef::ptr l, TopoDS_Shape&
|
||||
return IfcGeom::profile_helper(6,coords,doFillet ? 3 : 0,fillets,radii,trsf2d,face);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcUShapeProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcUShapeProfileDef* l, TopoDS_Shape& face) {
|
||||
const bool doEdgeFillet = l->hasEdgeRadius();
|
||||
const bool doFillet = l->hasFilletRadius();
|
||||
const bool hasSlope = l->hasFlangeSlope();
|
||||
@@ -513,7 +523,7 @@ bool IfcGeom::convert(const IfcSchema::IfcUShapeProfileDef::ptr l, TopoDS_Shape&
|
||||
return IfcGeom::profile_helper(8, coords, (doFillet || doEdgeFillet) ? 4 : 0, fillets, radii, trsf2d, face);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcTShapeProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcTShapeProfileDef* l, TopoDS_Shape& face) {
|
||||
const bool doFlangeEdgeFillet = l->hasFlangeEdgeRadius();
|
||||
const bool doWebEdgeFillet = l->hasWebEdgeRadius();
|
||||
const bool doFillet = l->hasFilletRadius();
|
||||
@@ -596,7 +606,7 @@ bool IfcGeom::convert(const IfcSchema::IfcTShapeProfileDef::ptr l, TopoDS_Shape&
|
||||
return IfcGeom::profile_helper(8, coords, (doFillet || doWebEdgeFillet || doFlangeEdgeFillet) ? 6 : 0, fillets, radii, trsf2d, face);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCircleProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCircleProfileDef* l, TopoDS_Shape& face) {
|
||||
const double r = l->Radius() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
if ( r == 0.0f ) {
|
||||
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
|
||||
@@ -618,7 +628,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCircleProfileDef::ptr l, TopoDS_Shape&
|
||||
return success;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCircleHollowProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCircleHollowProfileDef* l, TopoDS_Shape& face) {
|
||||
const double r = l->Radius() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double t = l->WallThickness() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
|
||||
@@ -647,7 +657,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCircleHollowProfileDef::ptr l, TopoDS_
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcEllipseProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcEllipseProfileDef* l, TopoDS_Shape& face) {
|
||||
double rx = l->SemiAxis1() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
double ry = l->SemiAxis2() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
|
||||
@@ -678,7 +688,7 @@ bool IfcGeom::convert(const IfcSchema::IfcEllipseProfileDef::ptr l, TopoDS_Shape
|
||||
return success;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCenterLineProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCenterLineProfileDef* l, TopoDS_Shape& face) {
|
||||
const double d = l->Thickness() * IfcGeom::GetValue(GV_LENGTH_UNIT) / 2.;
|
||||
|
||||
TopoDS_Wire wire;
|
||||
@@ -727,16 +737,16 @@ bool IfcGeom::convert(const IfcSchema::IfcCenterLineProfileDef::ptr l, TopoDS_Sh
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCompositeProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCompositeProfileDef* l, TopoDS_Shape& face) {
|
||||
// BRepBuilderAPI_MakeFace mf;
|
||||
|
||||
TopoDS_Compound compound;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(compound);
|
||||
|
||||
IfcSchema::IfcProfileDef::list profiles = l->Profiles();
|
||||
IfcSchema::IfcProfileDef::list::ptr profiles = l->Profiles();
|
||||
bool first = true;
|
||||
for (IfcSchema::IfcProfileDef::it it = profiles->begin(); it != profiles->end(); ++it) {
|
||||
for (IfcSchema::IfcProfileDef::list::it it = profiles->begin(); it != profiles->end(); ++it) {
|
||||
TopoDS_Face f;
|
||||
if (IfcGeom::convert_face(*it, f)) {
|
||||
builder.Add(compound, f);
|
||||
@@ -757,7 +767,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCompositeProfileDef::ptr l, TopoDS_Sha
|
||||
return !face.IsNull();
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcDerivedProfileDef::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcDerivedProfileDef* l, TopoDS_Shape& face) {
|
||||
TopoDS_Face f;
|
||||
gp_Trsf2d trsf2d;
|
||||
if (IfcGeom::convert_face(l->ParentProfile(), f) && IfcGeom::convert(l->Operator(), trsf2d)) {
|
||||
@@ -768,3 +778,97 @@ bool IfcGeom::convert(const IfcSchema::IfcDerivedProfileDef::ptr l, TopoDS_Shape
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_IFC4
|
||||
|
||||
bool convert_surf(IfcSchema::IfcBSplineSurfaceWithKnots* l, Handle_Geom_Surface& surf) {
|
||||
SHARED_PTR< IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
|
||||
std::vector<double> uknots = l->UKnots();
|
||||
std::vector<double> vknots = l->VKnots();
|
||||
std::vector<int> umults = l->UMultiplicities();
|
||||
std::vector<int> vmults = l->VMultiplicities();
|
||||
|
||||
TColgp_Array2OfPnt Poles (0, cps->Size() - 1, 0, (*cps->begin()).size() - 1);
|
||||
TColStd_Array1OfReal UKnots(0, uknots.size() - 1);
|
||||
TColStd_Array1OfReal VKnots(0, vknots.size() - 1);
|
||||
TColStd_Array1OfInteger UMults(0, umults.size() - 1);
|
||||
TColStd_Array1OfInteger VMults(0, vmults.size() - 1);
|
||||
Standard_Integer UDegree = l->UDegree();
|
||||
Standard_Integer VDegree = l->VDegree();
|
||||
|
||||
int i = 0, j;
|
||||
for (IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint>::outer_it it = cps->begin(); it != cps->end(); ++it, ++i) {
|
||||
j = 0;
|
||||
for (IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint>::inner_it jt = (*it).begin(); jt != (*it).end(); ++jt, ++j) {
|
||||
IfcSchema::IfcCartesianPoint* p = *jt;
|
||||
gp_Pnt pnt;
|
||||
if (!IfcGeom::convert(p, pnt)) return false;
|
||||
Poles(i, j) = pnt;
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<double>::const_iterator it = uknots.begin(); it != uknots.end(); ++it, ++i) {
|
||||
UKnots(i) = *it;
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<double>::const_iterator it = vknots.begin(); it != vknots.end(); ++it, ++i) {
|
||||
VKnots(i) = *it;
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<int>::const_iterator it = umults.begin(); it != umults.end(); ++it, ++i) {
|
||||
UMults(i) = *it;
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<int>::const_iterator it = vmults.begin(); it != vmults.end(); ++it, ++i) {
|
||||
VMults(i) = *it;
|
||||
}
|
||||
surf = new Geom_BSplineSurface(Poles, UKnots, VKnots, UMults, VMults, UDegree, VDegree);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool convert_surf(IfcSchema::IfcPlane* l, Handle_Geom_Surface& surf) {
|
||||
gp_Pln pln;
|
||||
IfcGeom::convert(l, pln);
|
||||
surf = new Geom_Plane(pln);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcAdvancedFace* l, TopoDS_Shape& face) {
|
||||
IfcSchema::IfcSurface* s = l->FaceSurface();
|
||||
Handle_Geom_Surface surf(0);
|
||||
if (s->is(IfcSchema::Type::IfcBSplineSurfaceWithKnots)) {
|
||||
convert_surf((IfcSchema::IfcBSplineSurfaceWithKnots*)s, surf);
|
||||
} else if (s->is(IfcSchema::Type::IfcPlane)) {
|
||||
convert_surf((IfcSchema::IfcPlane*)s, surf);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
BRepBuilderAPI_MakeFace mf(surf, Precision::Confusion());
|
||||
IfcSchema::IfcFaceBound::list::ptr bounds = l->Bounds();
|
||||
for (IfcSchema::IfcFaceBound::list::it it = bounds->begin(); it != bounds->end(); ++it) {
|
||||
IfcSchema::IfcLoop* loop = (*it)->Bound();
|
||||
TopoDS_Wire outer_wire;
|
||||
if (!IfcGeom::convert_wire(loop, outer_wire)) return false;
|
||||
|
||||
TopoDS_Face temp = BRepBuilderAPI_MakeFace(surf, outer_wire);
|
||||
|
||||
if (BRepCheck_Face(temp).OrientationOfWires() == BRepCheck_BadOrientationOfSubshape) {
|
||||
outer_wire.Reverse();
|
||||
ShapeFix_Face fix(BRepBuilderAPI_MakeFace(surf, outer_wire).Face());
|
||||
fix.FixOrientation();
|
||||
fix.Perform();
|
||||
TopoDS_Face temp = fix.Face();
|
||||
TopExp_Explorer exp(temp, TopAbs_WIRE);
|
||||
outer_wire = TopoDS::Wire(exp.Current());
|
||||
}
|
||||
|
||||
mf.Add(outer_wire);
|
||||
}
|
||||
|
||||
face = mf.Face();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -136,14 +136,14 @@ const TopoDS_Shape& IfcGeom::ensure_fit_for_subtraction(const TopoDS_Shape& shap
|
||||
return solid;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert_openings(const IfcSchema::IfcProduct::ptr entity, const IfcSchema::IfcRelVoidsElement::list& openings,
|
||||
bool IfcGeom::convert_openings(const IfcSchema::IfcProduct* entity, const IfcSchema::IfcRelVoidsElement::list::ptr& openings,
|
||||
const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes) {
|
||||
// Iterate over IfcOpeningElements
|
||||
IfcGeom::IfcRepresentationShapeItems opening_shapes;
|
||||
unsigned int last_size = 0;
|
||||
for ( IfcSchema::IfcRelVoidsElement::it it = openings->begin(); it != openings->end(); ++ it ) {
|
||||
IfcSchema::IfcRelVoidsElement::ptr v = *it;
|
||||
IfcSchema::IfcFeatureElementSubtraction::ptr fes = v->RelatedOpeningElement();
|
||||
for ( IfcSchema::IfcRelVoidsElement::list::it it = openings->begin(); it != openings->end(); ++ it ) {
|
||||
IfcSchema::IfcRelVoidsElement* v = *it;
|
||||
IfcSchema::IfcFeatureElementSubtraction* fes = v->RelatedOpeningElement();
|
||||
if ( fes->is(IfcSchema::Type::IfcOpeningElement) ) {
|
||||
|
||||
// Convert the IfcRepresentation of the IfcOpeningElement
|
||||
@@ -153,10 +153,10 @@ bool IfcGeom::convert_openings(const IfcSchema::IfcProduct::ptr entity, const If
|
||||
// Move the opening into the coordinate system of the IfcProduct
|
||||
opening_trsf.PreMultiply(entity_trsf.Inverted());
|
||||
|
||||
IfcSchema::IfcProductRepresentation::ptr prodrep = fes->Representation();
|
||||
IfcSchema::IfcRepresentation::list reps = prodrep->Representations();
|
||||
IfcSchema::IfcProductRepresentation* prodrep = fes->Representation();
|
||||
IfcSchema::IfcRepresentation::list::ptr reps = prodrep->Representations();
|
||||
|
||||
for ( IfcSchema::IfcRepresentation::it it2 = reps->begin(); it2 != reps->end(); ++ it2 ) {
|
||||
for ( IfcSchema::IfcRepresentation::list::it it2 = reps->begin(); it2 != reps->end(); ++ it2 ) {
|
||||
IfcGeom::convert_shapes(*it2,opening_shapes);
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ bool IfcGeom::convert_openings(const IfcSchema::IfcProduct::ptr entity, const If
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert_openings_fast(const IfcSchema::IfcProduct::ptr entity, const IfcSchema::IfcRelVoidsElement::list& openings,
|
||||
bool IfcGeom::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) {
|
||||
|
||||
// Create a compound of all opening shapes in order to speed up the boolean operations
|
||||
@@ -238,9 +238,9 @@ bool IfcGeom::convert_openings_fast(const IfcSchema::IfcProduct::ptr entity, con
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(opening_compound);
|
||||
|
||||
for ( IfcSchema::IfcRelVoidsElement::it it = openings->begin(); it != openings->end(); ++ it ) {
|
||||
IfcSchema::IfcRelVoidsElement::ptr v = *it;
|
||||
IfcSchema::IfcFeatureElementSubtraction::ptr fes = v->RelatedOpeningElement();
|
||||
for ( IfcSchema::IfcRelVoidsElement::list::it it = openings->begin(); it != openings->end(); ++ it ) {
|
||||
IfcSchema::IfcRelVoidsElement* v = *it;
|
||||
IfcSchema::IfcFeatureElementSubtraction* fes = v->RelatedOpeningElement();
|
||||
if ( fes->is(IfcSchema::Type::IfcOpeningElement) ) {
|
||||
|
||||
// Convert the IfcRepresentation of the IfcOpeningElement
|
||||
@@ -250,12 +250,12 @@ bool IfcGeom::convert_openings_fast(const IfcSchema::IfcProduct::ptr entity, con
|
||||
// Move the opening into the coordinate system of the IfcProduct
|
||||
opening_trsf.PreMultiply(entity_trsf.Inverted());
|
||||
|
||||
IfcSchema::IfcProductRepresentation::ptr prodrep = fes->Representation();
|
||||
IfcSchema::IfcRepresentation::list reps = prodrep->Representations();
|
||||
IfcSchema::IfcProductRepresentation* prodrep = fes->Representation();
|
||||
IfcSchema::IfcRepresentation::list::ptr reps = prodrep->Representations();
|
||||
|
||||
IfcGeom::IfcRepresentationShapeItems opening_shapes;
|
||||
|
||||
for ( IfcSchema::IfcRepresentation::it it2 = reps->begin(); it2 != reps->end(); ++ it2 ) {
|
||||
for ( IfcSchema::IfcRepresentation::list::it it2 = reps->begin(); it2 != reps->end(); ++ it2 ) {
|
||||
IfcGeom::convert_shapes(*it2,opening_shapes);
|
||||
}
|
||||
|
||||
@@ -516,10 +516,10 @@ double IfcGeom::GetValue(GeomValue var) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
IfcSchema::IfcProductDefinitionShape* IfcGeom::tesselate(TopoDS_Shape& shape, double deflection, IfcEntities es) {
|
||||
IfcSchema::IfcProductDefinitionShape* IfcGeom::tesselate(TopoDS_Shape& shape, double deflection, IfcEntityList::ptr es) {
|
||||
BRepMesh::Mesh(shape, deflection);
|
||||
|
||||
IfcSchema::IfcFace::list faces (new IfcTemplatedEntityList<IfcSchema::IfcFace>());
|
||||
IfcSchema::IfcFace::list::ptr faces (new IfcSchema::IfcFace::list);
|
||||
|
||||
for (TopExp_Explorer exp(shape, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
const TopoDS_Face& face = TopoDS::Face(exp.Current());
|
||||
@@ -540,13 +540,13 @@ IfcSchema::IfcProductDefinitionShape* IfcGeom::tesselate(TopoDS_Shape& shape, do
|
||||
for (int i = 1; i <= triangles.Length(); ++ i) {
|
||||
int n1, n2, n3;
|
||||
triangles(i).Get(n1, n2, n3);
|
||||
IfcSchema::IfcCartesianPoint::list points (new IfcTemplatedEntityList<IfcSchema::IfcCartesianPoint>());
|
||||
IfcSchema::IfcCartesianPoint::list::ptr points (new IfcSchema::IfcCartesianPoint::list);
|
||||
points->push(vertices[n1-1]);
|
||||
points->push(vertices[n2-1]);
|
||||
points->push(vertices[n3-1]);
|
||||
IfcSchema::IfcPolyLoop* loop = new IfcSchema::IfcPolyLoop(points);
|
||||
IfcSchema::IfcFaceOuterBound* bound = new IfcSchema::IfcFaceOuterBound(loop, face.Orientation() != TopAbs_REVERSED);
|
||||
IfcSchema::IfcFaceBound::list bounds (new IfcTemplatedEntityList<IfcSchema::IfcFaceBound>());
|
||||
IfcSchema::IfcFaceBound::list::ptr bounds (new IfcSchema::IfcFaceBound::list);
|
||||
bounds->push(bound);
|
||||
IfcSchema::IfcFace* face = new IfcSchema::IfcFace(bounds);
|
||||
es->push(loop);
|
||||
@@ -557,12 +557,12 @@ IfcSchema::IfcProductDefinitionShape* IfcGeom::tesselate(TopoDS_Shape& shape, do
|
||||
}
|
||||
}
|
||||
IfcSchema::IfcOpenShell* shell = new IfcSchema::IfcOpenShell(faces);
|
||||
IfcSchema::IfcConnectedFaceSet::list shells (new IfcTemplatedEntityList<IfcSchema::IfcConnectedFaceSet>());
|
||||
IfcSchema::IfcConnectedFaceSet::list::ptr shells (new IfcSchema::IfcConnectedFaceSet::list);
|
||||
shells->push(shell);
|
||||
IfcSchema::IfcFaceBasedSurfaceModel* surface_model = new IfcSchema::IfcFaceBasedSurfaceModel(shells);
|
||||
|
||||
IfcSchema::IfcRepresentation::list reps (new IfcTemplatedEntityList<IfcSchema::IfcRepresentation>());
|
||||
IfcSchema::IfcRepresentationItem::list items (new IfcTemplatedEntityList<IfcSchema::IfcRepresentationItem>());
|
||||
IfcSchema::IfcRepresentation::list::ptr reps (new IfcSchema::IfcRepresentation::list);
|
||||
IfcSchema::IfcRepresentationItem::list::ptr items (new IfcSchema::IfcRepresentationItem::list);
|
||||
|
||||
items->push(surface_model);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace IfcGeom {
|
||||
if ( it != Cache::T.end() ) { e = it->second; return true; }
|
||||
#define CACHE(T,E,e) Cache::T[E->entity->id()] = e;
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianPoint::ptr l, gp_Pnt& point) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianPoint* l, gp_Pnt& point) {
|
||||
IN_CACHE(IfcCartesianPoint,l,gp_Pnt,point)
|
||||
std::vector<double> xyz = l->Coordinates();
|
||||
point = gp_Pnt(
|
||||
@@ -99,7 +99,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCartesianPoint::ptr l, gp_Pnt& point)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcDirection::ptr l, gp_Dir& dir) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcDirection* l, gp_Dir& dir) {
|
||||
IN_CACHE(IfcDirection,l,gp_Dir,dir)
|
||||
std::vector<double> xyz = l->DirectionRatios();
|
||||
dir = gp_Dir(
|
||||
@@ -111,7 +111,7 @@ bool IfcGeom::convert(const IfcSchema::IfcDirection::ptr l, gp_Dir& dir) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcVector::ptr l, gp_Vec& v) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcVector* l, gp_Vec& v) {
|
||||
IN_CACHE(IfcVector,l,gp_Vec,v)
|
||||
gp_Dir d;
|
||||
IfcGeom::convert(l->Orientation(),d);
|
||||
@@ -120,7 +120,7 @@ bool IfcGeom::convert(const IfcSchema::IfcVector::ptr l, gp_Vec& v) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcAxis2Placement3D::ptr l, gp_Trsf& trsf) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcAxis2Placement3D* l, gp_Trsf& trsf) {
|
||||
IN_CACHE(IfcAxis2Placement3D,l,gp_Trsf,trsf)
|
||||
gp_Pnt o;gp_Dir axis = gp_Dir(0,0,1);gp_Dir refDirection;
|
||||
IfcGeom::convert(l->Location(),o);
|
||||
@@ -135,7 +135,7 @@ bool IfcGeom::convert(const IfcSchema::IfcAxis2Placement3D::ptr l, gp_Trsf& trsf
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcAxis1Placement::ptr l, gp_Ax1& ax) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcAxis1Placement* l, gp_Ax1& ax) {
|
||||
IN_CACHE(IfcAxis1Placement,l,gp_Ax1,ax)
|
||||
gp_Pnt o;gp_Dir axis = gp_Dir(0,0,1);
|
||||
IfcGeom::convert(l->Location(),o);
|
||||
@@ -145,7 +145,7 @@ bool IfcGeom::convert(const IfcSchema::IfcAxis1Placement::ptr l, gp_Ax1& ax) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator3D::ptr l, gp_Trsf& trsf) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator3D* l, gp_Trsf& trsf) {
|
||||
IN_CACHE(IfcCartesianTransformationOperator3D,l,gp_Trsf,trsf)
|
||||
gp_Pnt origin;
|
||||
IfcGeom::convert(l->LocalOrigin(),origin);
|
||||
@@ -165,7 +165,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator3D::ptr
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator2D::ptr l, gp_Trsf2d& trsf) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator2D* l, gp_Trsf2d& trsf) {
|
||||
IN_CACHE(IfcCartesianTransformationOperator2D,l,gp_Trsf2d,trsf)
|
||||
|
||||
gp_Pnt origin;
|
||||
@@ -199,7 +199,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator2D::ptr
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator3DnonUniform::ptr l, gp_GTrsf& gtrsf) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator3DnonUniform* l, gp_GTrsf& gtrsf) {
|
||||
IN_CACHE(IfcCartesianTransformationOperator3DnonUniform,l,gp_GTrsf,gtrsf)
|
||||
gp_Trsf trsf;
|
||||
gp_Pnt origin;
|
||||
@@ -227,7 +227,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator3DnonUn
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator2DnonUniform::ptr l, gp_GTrsf2d& gtrsf) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator2DnonUniform* l, gp_GTrsf2d& gtrsf) {
|
||||
IN_CACHE(IfcCartesianTransformationOperator2DnonUniform,l,gp_GTrsf2d,gtrsf)
|
||||
|
||||
gp_Trsf2d trsf;
|
||||
@@ -263,9 +263,9 @@ bool IfcGeom::convert(const IfcSchema::IfcCartesianTransformationOperator2DnonUn
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcPlane::ptr pln, gp_Pln& plane) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcPlane* pln, gp_Pln& plane) {
|
||||
IN_CACHE(IfcPlane,pln,gp_Pln,plane)
|
||||
IfcSchema::IfcAxis2Placement3D::ptr l = pln->Position();
|
||||
IfcSchema::IfcAxis2Placement3D* l = pln->Position();
|
||||
gp_Pnt o;gp_Dir axis = gp_Dir(0,0,1);gp_Dir refDirection;
|
||||
IfcGeom::convert(l->Location(),o);
|
||||
bool hasRef = l->hasRefDirection();
|
||||
@@ -279,7 +279,7 @@ bool IfcGeom::convert(const IfcSchema::IfcPlane::ptr pln, gp_Pln& plane) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcAxis2Placement2D::ptr l, gp_Trsf2d& trsf) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcAxis2Placement2D* l, gp_Trsf2d& trsf) {
|
||||
IN_CACHE(IfcAxis2Placement2D,l,gp_Trsf2d,trsf)
|
||||
gp_Pnt P; gp_Dir V (1,0,0);
|
||||
IfcGeom::convert(l->Location(),P);
|
||||
@@ -292,13 +292,13 @@ bool IfcGeom::convert(const IfcSchema::IfcAxis2Placement2D::ptr l, gp_Trsf2d& tr
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcObjectPlacement::ptr l, gp_Trsf& trsf) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& trsf) {
|
||||
IN_CACHE(IfcObjectPlacement,l,gp_Trsf,trsf)
|
||||
if ( ! l->is(IfcSchema::Type::IfcLocalPlacement) ) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Unsupported IfcObjectPlacement:", l->entity);
|
||||
return false;
|
||||
}
|
||||
IfcSchema::IfcLocalPlacement::ptr current = reinterpret_pointer_cast<IfcSchema::IfcObjectPlacement,IfcSchema::IfcLocalPlacement>(l);
|
||||
IfcSchema::IfcLocalPlacement* current = (IfcSchema::IfcLocalPlacement*)l;
|
||||
while (1) {
|
||||
gp_Trsf trsf2;
|
||||
IfcSchema::IfcAxis2Placement relplacement = current->RelativePlacement();
|
||||
@@ -307,9 +307,9 @@ bool IfcGeom::convert(const IfcSchema::IfcObjectPlacement::ptr l, gp_Trsf& trsf)
|
||||
trsf.PreMultiply(trsf2);
|
||||
}
|
||||
if ( current->hasPlacementRelTo() ) {
|
||||
IfcSchema::IfcObjectPlacement::ptr relto = current->PlacementRelTo();
|
||||
IfcSchema::IfcObjectPlacement* relto = current->PlacementRelTo();
|
||||
if ( relto->is(IfcSchema::Type::IfcLocalPlacement) )
|
||||
current = reinterpret_pointer_cast<IfcSchema::IfcObjectPlacement,IfcSchema::IfcLocalPlacement>(current->PlacementRelTo());
|
||||
current = (IfcSchema::IfcLocalPlacement*)current->PlacementRelTo();
|
||||
else break;
|
||||
} else break;
|
||||
}
|
||||
|
||||
@@ -279,8 +279,8 @@ IfcGeomObjects::IfcGeomObject::IfcGeomObject(
|
||||
{}
|
||||
|
||||
// A container and iterator for IfcShapeRepresentations
|
||||
static IfcSchema::IfcShapeRepresentation::list shapereps;
|
||||
static IfcSchema::IfcShapeRepresentation::it shaperep_iterator;
|
||||
static IfcSchema::IfcShapeRepresentation::list::ptr shapereps;
|
||||
static IfcSchema::IfcShapeRepresentation::list::it shaperep_iterator;
|
||||
|
||||
// The object is fetched beforehand to be positive an entity actually exists
|
||||
static IfcGeomObjects::IfcGeomObject* current_geom_obj = 0;
|
||||
@@ -288,8 +288,8 @@ static IfcGeomObjects::IfcGeomShapeModelObject* current_shape_model_obj = 0;
|
||||
static IfcGeomObjects::IfcGeomBrepDataObject* current_brep_data_obj = 0;
|
||||
|
||||
// A container and iterator for IfcBuildingElements for the current IfcShapeRepresentation referenced by *shaperep_iterator
|
||||
static IfcSchema::IfcProduct::list entities;
|
||||
static IfcSchema::IfcProduct::it ifcproduct_iterator;
|
||||
static IfcSchema::IfcProduct::list::ptr entities;
|
||||
static IfcSchema::IfcProduct::list::it ifcproduct_iterator;
|
||||
|
||||
static int done;
|
||||
static int total;
|
||||
@@ -301,23 +301,23 @@ void _nextShape() {
|
||||
++ done;
|
||||
}
|
||||
|
||||
int _getParentId(const IfcSchema::IfcProduct::ptr ifc_product) {
|
||||
int _getParentId(IfcSchema::IfcProduct* ifc_product) {
|
||||
int parent_id = -1;
|
||||
// In case of an opening element, parent to the RelatingBuildingElement
|
||||
if ( ifc_product->is(IfcSchema::Type::IfcOpeningElement ) ) {
|
||||
IfcSchema::IfcOpeningElement::ptr opening = reinterpret_pointer_cast<IfcSchema::IfcProduct,IfcSchema::IfcOpeningElement>(ifc_product);
|
||||
IfcSchema::IfcRelVoidsElement::list voids = opening->VoidsElements();
|
||||
IfcSchema::IfcOpeningElement* opening = (IfcSchema::IfcOpeningElement*)ifc_product;
|
||||
IfcSchema::IfcRelVoidsElement::list::ptr voids = opening->VoidsElements();
|
||||
if ( voids->Size() ) {
|
||||
IfcSchema::IfcRelVoidsElement::ptr ifc_void = *voids->begin();
|
||||
IfcSchema::IfcRelVoidsElement* ifc_void = *voids->begin();
|
||||
parent_id = ifc_void->RelatingBuildingElement()->entity->id();
|
||||
}
|
||||
} else if ( ifc_product->is(IfcSchema::Type::IfcElement ) ) {
|
||||
IfcSchema::IfcElement::ptr element = reinterpret_pointer_cast<IfcSchema::IfcProduct,IfcSchema::IfcElement>(ifc_product);
|
||||
IfcSchema::IfcRelFillsElement::list fills = element->FillsVoids();
|
||||
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)ifc_product;
|
||||
IfcSchema::IfcRelFillsElement::list::ptr fills = element->FillsVoids();
|
||||
// Incase of a RelatedBuildingElement parent to the opening element
|
||||
if ( fills->Size() ) {
|
||||
for ( IfcSchema::IfcRelFillsElement::it it = fills->begin(); it != fills->end(); ++ it ) {
|
||||
IfcSchema::IfcRelFillsElement::ptr fill = *it;
|
||||
for ( IfcSchema::IfcRelFillsElement::list::it it = fills->begin(); it != fills->end(); ++ it ) {
|
||||
IfcSchema::IfcRelFillsElement* fill = *it;
|
||||
IfcSchema::IfcObjectDefinition* ifc_objectdef = fill->RelatingOpeningElement();
|
||||
if ( ifc_product == ifc_objectdef ) continue;
|
||||
parent_id = ifc_objectdef->entity->id();
|
||||
@@ -325,19 +325,19 @@ int _getParentId(const IfcSchema::IfcProduct::ptr ifc_product) {
|
||||
}
|
||||
// Else simply parent to the containing structure
|
||||
if ( parent_id == -1 ) {
|
||||
IfcSchema::IfcRelContainedInSpatialStructure::list parents = element->ContainedInStructure();
|
||||
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr parents = element->ContainedInStructure();
|
||||
if ( parents->Size() ) {
|
||||
IfcSchema::IfcRelContainedInSpatialStructure::ptr parent = *parents->begin();
|
||||
IfcSchema::IfcRelContainedInSpatialStructure* parent = *parents->begin();
|
||||
parent_id = parent->RelatingStructure()->entity->id();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Parent decompositions to the RelatingObject
|
||||
if ( parent_id == -1 ) {
|
||||
IfcEntities parents = ifc_product->entity->getInverse(IfcSchema::Type::IfcRelAggregates);
|
||||
IfcEntityList::ptr parents = ifc_product->entity->getInverse(IfcSchema::Type::IfcRelAggregates);
|
||||
parents->push(ifc_product->entity->getInverse(IfcSchema::Type::IfcRelNests));
|
||||
for ( IfcEntityList::it it = parents->begin(); it != parents->end(); ++ it ) {
|
||||
IfcSchema::IfcRelDecomposes::ptr decompose = reinterpret_pointer_cast<IfcUtil::IfcBaseClass,IfcSchema::IfcRelDecomposes>(*it);
|
||||
IfcSchema::IfcRelDecomposes* decompose = (IfcSchema::IfcRelDecomposes*)*it;
|
||||
IfcSchema::IfcObjectDefinition* ifc_objectdef;
|
||||
#ifdef USE_IFC4
|
||||
if (decompose->is(IfcSchema::Type::IfcRelAggregates)) {
|
||||
@@ -357,7 +357,7 @@ int _getParentId(const IfcSchema::IfcProduct::ptr ifc_product) {
|
||||
|
||||
IfcGeomObjects::IfcGeomShapeModelObject* create_shape_model_for_next_entity() {
|
||||
while ( true ) {
|
||||
IfcSchema::IfcShapeRepresentation::ptr shaperep;
|
||||
IfcSchema::IfcShapeRepresentation* shaperep;
|
||||
|
||||
// Have we reached the end of our list of representations?
|
||||
if ( shaperep_iterator == shapereps->end() ) {
|
||||
@@ -378,11 +378,11 @@ IfcGeomObjects::IfcGeomShapeModelObject* create_shape_model_for_next_entity() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
IfcSchema::IfcProductRepresentation::list prodreps = shaperep->OfProductRepresentation();
|
||||
entities = IfcSchema::IfcProduct::list( new IfcTemplatedEntityList<IfcSchema::IfcProduct>() );
|
||||
for ( IfcSchema::IfcProductRepresentation::it it = prodreps->begin(); it != prodreps->end(); ++it ) {
|
||||
IfcSchema::IfcProductRepresentation::list::ptr prodreps = shaperep->OfProductRepresentation();
|
||||
entities = IfcSchema::IfcProduct::list::ptr(new IfcSchema::IfcProduct::list);
|
||||
for ( IfcSchema::IfcProductRepresentation::list::it it = prodreps->begin(); it != prodreps->end(); ++it ) {
|
||||
if ( (*it)->is(IfcSchema::Type::IfcProductDefinitionShape) ) {
|
||||
IfcSchema::IfcProductDefinitionShape::ptr pds = reinterpret_pointer_cast<IfcSchema::IfcProductRepresentation,IfcSchema::IfcProductDefinitionShape>(*it);
|
||||
IfcSchema::IfcProductDefinitionShape* pds = (IfcSchema::IfcProductDefinitionShape*)*it;
|
||||
entities->push(pds->ShapeOfProduct());
|
||||
} else {
|
||||
// http://buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcrepresentationresource/lexical/ifcproductrepresentation.htm
|
||||
@@ -391,9 +391,9 @@ IfcGeomObjects::IfcGeomShapeModelObject* create_shape_model_for_next_entity() {
|
||||
|
||||
// IfcProductRepresentation also lacks the INVERSE relation to IfcProduct
|
||||
// Let's find the IfcProducts that reference the IfcProductRepresentation anyway
|
||||
IfcEntities products = (*it)->entity->getInverse(IfcSchema::Type::IfcProduct);
|
||||
IfcEntityList::ptr products = (*it)->entity->getInverse(IfcSchema::Type::IfcProduct);
|
||||
for ( IfcEntityList::it it = products->begin(); it != products->end(); ++ it ) {
|
||||
entities->push(reinterpret_pointer_cast<IfcUtil::IfcBaseClass,IfcSchema::IfcProduct>(*it));
|
||||
entities->push((IfcSchema::IfcProduct*)*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -418,7 +418,7 @@ IfcGeomObjects::IfcGeomShapeModelObject* create_shape_model_for_next_entity() {
|
||||
continue;
|
||||
}
|
||||
|
||||
IfcSchema::IfcProduct::ptr ifc_product = *ifcproduct_iterator;
|
||||
IfcSchema::IfcProduct* ifc_product = *ifcproduct_iterator;
|
||||
|
||||
int parent_id = -1;
|
||||
try {
|
||||
@@ -435,24 +435,24 @@ IfcGeomObjects::IfcGeomShapeModelObject* create_shape_model_for_next_entity() {
|
||||
|
||||
// Does the IfcElement have any IfcOpenings?
|
||||
// Note that openings for IfcOpeningElements are not processed
|
||||
IfcSchema::IfcRelVoidsElement::list openings = IfcSchema::IfcRelVoidsElement::list();
|
||||
IfcSchema::IfcRelVoidsElement::list::ptr openings;
|
||||
if ( ifc_product->is(IfcSchema::Type::IfcElement) && !ifc_product->is(IfcSchema::Type::IfcOpeningElement) ) {
|
||||
IfcSchema::IfcElement::ptr element = reinterpret_pointer_cast<IfcSchema::IfcProduct,IfcSchema::IfcElement>(ifc_product);
|
||||
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)ifc_product;
|
||||
openings = element->HasOpenings();
|
||||
}
|
||||
// Is the IfcElement a decomposition of an IfcElement with any IfcOpeningElements?
|
||||
if ( ifc_product->is(IfcSchema::Type::IfcBuildingElementPart ) ) {
|
||||
IfcSchema::IfcBuildingElementPart::ptr part = reinterpret_pointer_cast<IfcSchema::IfcProduct,IfcSchema::IfcBuildingElementPart>(ifc_product);
|
||||
IfcSchema::IfcBuildingElementPart* part = (IfcSchema::IfcBuildingElementPart*)ifc_product;
|
||||
#ifdef USE_IFC4
|
||||
IfcSchema::IfcRelAggregates::list decomposes = part->Decomposes();
|
||||
for ( IfcSchema::IfcRelAggregates::it it = decomposes->begin(); it != decomposes->end(); ++ it ) {
|
||||
IfcSchema::IfcRelAggregates::list::ptr decomposes = part->Decomposes();
|
||||
for ( IfcSchema::IfcRelAggregates::list::it it = decomposes->begin(); it != decomposes->end(); ++ it ) {
|
||||
#else
|
||||
IfcSchema::IfcRelDecomposes::list decomposes = part->Decomposes();
|
||||
for ( IfcSchema::IfcRelDecomposes::it it = decomposes->begin(); it != decomposes->end(); ++ it ) {
|
||||
IfcSchema::IfcRelDecomposes::list::ptr decomposes = part->Decomposes();
|
||||
for ( IfcSchema::IfcRelDecomposes::list::it it = decomposes->begin(); it != decomposes->end(); ++ it ) {
|
||||
#endif
|
||||
IfcSchema::IfcObjectDefinition::ptr obdef = (*it)->RelatingObject();
|
||||
IfcSchema::IfcObjectDefinition* obdef = (*it)->RelatingObject();
|
||||
if ( obdef->is(IfcSchema::Type::IfcElement) ) {
|
||||
IfcSchema::IfcElement::ptr element = reinterpret_pointer_cast<IfcSchema::IfcObjectDefinition,IfcSchema::IfcElement>(obdef);
|
||||
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)obdef;
|
||||
openings->push(element->HasOpenings());
|
||||
}
|
||||
}
|
||||
@@ -551,9 +551,9 @@ bool IfcGeomObjects::CleanUp() {
|
||||
const IfcGeomObjects::IfcObject* IfcGeomObjects::GetObject(int id) {
|
||||
IfcObject* ifc_object = 0;
|
||||
try {
|
||||
const IfcParse::IfcEntity& ifc_entity = ifc_file->EntityById(id);
|
||||
const IfcUtil::IfcBaseClass* ifc_entity = ifc_file->EntityById(id);
|
||||
if ( ifc_entity->is(IfcSchema::Type::IfcProduct) ) {
|
||||
IfcSchema::IfcProduct::ptr ifc_product = reinterpret_pointer_cast<IfcUtil::IfcBaseClass,IfcSchema::IfcProduct>(ifc_entity);
|
||||
IfcSchema::IfcProduct* ifc_product = (IfcSchema::IfcProduct*)ifc_entity;
|
||||
int parent_id = -1;
|
||||
try {
|
||||
parent_id = _getParentId(ifc_product);
|
||||
@@ -610,7 +610,7 @@ void IfcGeomObjects::InitPrecision() {
|
||||
IfcGeom::SetValue(IfcGeom::GV_PRECISION, 0.00001);
|
||||
|
||||
try {
|
||||
IfcSchema::IfcGeometricRepresentationContext::list rep_contexts = ifc_file->EntitiesByType<IfcSchema::IfcGeometricRepresentationContext>();
|
||||
IfcSchema::IfcGeometricRepresentationContext::list::ptr rep_contexts = ifc_file->EntitiesByType<IfcSchema::IfcGeometricRepresentationContext>();
|
||||
// Currently, IfcGeometricRepresentationContext aren't used as much as they should be
|
||||
// in the evaluation of shape representations, hence, we try to find the one with the
|
||||
// lowest precision. Typically, a value of 1e-5 is encountered. This value is applied
|
||||
@@ -619,7 +619,7 @@ void IfcGeomObjects::InitPrecision() {
|
||||
// one that is defined in the model file.
|
||||
double lowest_precision_encountered = std::numeric_limits<double>::infinity();
|
||||
bool any_precision_encountered = false;
|
||||
for (IfcSchema::IfcGeometricRepresentationContext::it it = rep_contexts->begin(); it != rep_contexts->end(); ++it) {
|
||||
for (IfcSchema::IfcGeometricRepresentationContext::list::it it = rep_contexts->begin(); it != rep_contexts->end(); ++it) {
|
||||
IfcSchema::IfcGeometricRepresentationContext* rep_context = *it;
|
||||
if (rep_context->is(IfcSchema::Type::IfcGeometricRepresentationSubContext)) continue;
|
||||
if (rep_context->hasPrecision()) {
|
||||
@@ -648,11 +648,11 @@ void IfcGeomObjects::InitUnits() {
|
||||
IfcGeom::SetValue(IfcGeom::GV_LENGTH_UNIT,1.0);
|
||||
IfcGeom::SetValue(IfcGeom::GV_PLANEANGLE_UNIT,-1.0);
|
||||
|
||||
IfcSchema::IfcUnitAssignment::list unit_assignments = ifc_file->EntitiesByType<IfcSchema::IfcUnitAssignment>();
|
||||
IfcUtil::IfcAbstractSelect::list units = IfcUtil::IfcAbstractSelect::list();
|
||||
IfcSchema::IfcUnitAssignment::list::ptr unit_assignments = ifc_file->EntitiesByType<IfcSchema::IfcUnitAssignment>();
|
||||
IfcUtil::IfcAbstractSelect::list::ptr units;
|
||||
try {
|
||||
if ( unit_assignments->Size() ) {
|
||||
IfcSchema::IfcUnitAssignment::ptr unit_assignment = *unit_assignments->begin();
|
||||
IfcSchema::IfcUnitAssignment* unit_assignment = *unit_assignments->begin();
|
||||
units = unit_assignment->Units();
|
||||
}
|
||||
} catch (const IfcParse::IfcException&) {}
|
||||
@@ -660,10 +660,10 @@ void IfcGeomObjects::InitUnits() {
|
||||
if (!units) {
|
||||
// No units eh... Since tolerances and deflection are specified internally in meters
|
||||
// we will try to find another indication of the model size.
|
||||
IfcSchema::IfcExtrudedAreaSolid::list extrusions = ifc_file->EntitiesByType<IfcSchema::IfcExtrudedAreaSolid>();
|
||||
IfcSchema::IfcExtrudedAreaSolid::list::ptr extrusions = ifc_file->EntitiesByType<IfcSchema::IfcExtrudedAreaSolid>();
|
||||
if ( ! extrusions->Size() ) return;
|
||||
double max_height = -1.0f;
|
||||
for ( IfcSchema::IfcExtrudedAreaSolid::it it = extrusions->begin(); it != extrusions->end(); ++ it ) {
|
||||
for ( IfcSchema::IfcExtrudedAreaSolid::list::it it = extrusions->begin(); it != extrusions->end(); ++ it ) {
|
||||
try {
|
||||
const double depth = (*it)->Depth();
|
||||
if ( depth > max_height ) max_height = depth;
|
||||
@@ -677,15 +677,15 @@ void IfcGeomObjects::InitUnits() {
|
||||
}
|
||||
|
||||
try {
|
||||
for ( IfcUtil::IfcAbstractSelect::it it = units->begin(); it != units->end(); ++ it ) {
|
||||
for ( IfcUtil::IfcAbstractSelect::list::it it = units->begin(); it != units->end(); ++ it ) {
|
||||
std::string current_unit_name = "";
|
||||
const IfcUtil::IfcAbstractSelect::ptr base = *it;
|
||||
IfcSchema::IfcSIUnit::ptr unit = IfcSchema::IfcSIUnit::ptr();
|
||||
IfcUtil::IfcAbstractSelect* base = *it;
|
||||
IfcSchema::IfcSIUnit* unit = 0;
|
||||
double value = 1.0f;
|
||||
if ( base->is(IfcSchema::Type::IfcConversionBasedUnit) ) {
|
||||
const IfcSchema::IfcConversionBasedUnit::ptr u = reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,IfcSchema::IfcConversionBasedUnit>(base);
|
||||
IfcSchema::IfcConversionBasedUnit* u = (IfcSchema::IfcConversionBasedUnit*)base;
|
||||
current_unit_name = u->Name();
|
||||
const IfcSchema::IfcMeasureWithUnit::ptr u2 = u->ConversionFactor();
|
||||
IfcSchema::IfcMeasureWithUnit* u2 = u->ConversionFactor();
|
||||
IfcSchema::IfcUnit u3 = u2->UnitComponent();
|
||||
if ( u3->is(IfcSchema::Type::IfcSIUnit) ) {
|
||||
unit = (IfcSchema::IfcSIUnit*) u3;
|
||||
@@ -695,7 +695,7 @@ void IfcGeomObjects::InitUnits() {
|
||||
const double f = *v2->wrappedValue();
|
||||
value *= f;
|
||||
} else if ( base->is(IfcSchema::Type::IfcSIUnit) ) {
|
||||
unit = reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,IfcSchema::IfcSIUnit>(base);
|
||||
unit = (IfcSchema::IfcSIUnit*)base;
|
||||
}
|
||||
if ( unit ) {
|
||||
if ( unit->hasPrefix() ) {
|
||||
|
||||
@@ -59,7 +59,7 @@ bool process_colour(IfcSchema::IfcColourOrFactor colour_or_factor, std::tr1::arr
|
||||
}
|
||||
}
|
||||
|
||||
const IfcGeom::SurfaceStyle* IfcGeom::get_style(IfcSchema::IfcRepresentationItem* item) {
|
||||
const IfcGeom::SurfaceStyle* IfcGeom::get_style(const IfcSchema::IfcRepresentationItem* item) {
|
||||
std::pair<IfcSchema::IfcSurfaceStyle*, IfcSchema::IfcSurfaceStyleShading*> shading_styles = get_surface_style<IfcSchema::IfcSurfaceStyleShading>(item);
|
||||
if (shading_styles.second == 0) {
|
||||
return 0;
|
||||
|
||||
@@ -101,29 +101,29 @@ namespace IfcGeom {
|
||||
boost::optional<double>& Specularity() { return specularity; }
|
||||
};
|
||||
|
||||
template <typename T> std::pair<IfcSchema::IfcSurfaceStyle*, T*> get_surface_style(IfcSchema::IfcRepresentationItem* representation_item) {
|
||||
IfcSchema::IfcStyledItem::list styled_items = representation_item->StyledByItem();
|
||||
for (IfcSchema::IfcStyledItem::it jt = styled_items->begin(); jt != styled_items->end(); ++jt) {
|
||||
template <typename T> std::pair<IfcSchema::IfcSurfaceStyle*, T*> get_surface_style(const IfcSchema::IfcRepresentationItem* representation_item) {
|
||||
IfcSchema::IfcStyledItem::list::ptr styled_items = representation_item->StyledByItem();
|
||||
for (IfcSchema::IfcStyledItem::list::it jt = styled_items->begin(); jt != styled_items->end(); ++jt) {
|
||||
#ifdef USE_IFC4
|
||||
IfcUtil::IfcAbstractSelect::list style_assignments = (*jt)->Styles();
|
||||
for (IfcUtil::IfcAbstractSelect::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
|
||||
IfcUtil::IfcAbstractSelect::list::ptr style_assignments = (*jt)->Styles();
|
||||
for (IfcUtil::IfcAbstractSelect::list::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
|
||||
if (!(*kt)->is(IfcSchema::Type::IfcPresentationStyleAssignment)) {
|
||||
continue;
|
||||
}
|
||||
IfcSchema::IfcPresentationStyleAssignment::ptr style_assignment = (IfcSchema::IfcPresentationStyleAssignment::ptr) *kt;
|
||||
IfcSchema::IfcPresentationStyleAssignment* style_assignment = (IfcSchema::IfcPresentationStyleAssignment*) *kt;
|
||||
#else
|
||||
IfcSchema::IfcPresentationStyleAssignment::list style_assignments = (*jt)->Styles();
|
||||
for (IfcSchema::IfcPresentationStyleAssignment::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
|
||||
IfcSchema::IfcPresentationStyleAssignment::ptr style_assignment = *kt;
|
||||
IfcSchema::IfcPresentationStyleAssignment::list::ptr style_assignments = (*jt)->Styles();
|
||||
for (IfcSchema::IfcPresentationStyleAssignment::list::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
|
||||
IfcSchema::IfcPresentationStyleAssignment* style_assignment = *kt;
|
||||
#endif
|
||||
IfcUtil::IfcAbstractSelect::list styles = style_assignment->Styles();
|
||||
for (IfcUtil::IfcAbstractSelect::it lt = styles->begin(); lt != styles->end(); ++lt) {
|
||||
IfcUtil::IfcAbstractSelect::ptr style = *lt;
|
||||
IfcUtil::IfcAbstractSelect::list::ptr styles = style_assignment->Styles();
|
||||
for (IfcUtil::IfcAbstractSelect::list::it lt = styles->begin(); lt != styles->end(); ++lt) {
|
||||
IfcUtil::IfcAbstractSelect* style = *lt;
|
||||
if (style->is(IfcSchema::Type::IfcSurfaceStyle)) {
|
||||
IfcSchema::IfcSurfaceStyle* surface_style = (IfcSchema::IfcSurfaceStyle*) style;
|
||||
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
|
||||
IfcUtil::IfcAbstractSelect::list styles_elements = surface_style->Styles();
|
||||
for (IfcUtil::IfcAbstractSelect::it mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
|
||||
IfcUtil::IfcAbstractSelect::list::ptr styles_elements = surface_style->Styles();
|
||||
for (IfcUtil::IfcAbstractSelect::list::it mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
|
||||
if ((*mt)->is(T::Class())) {
|
||||
return std::make_pair(surface_style, (T*) *mt);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ namespace IfcGeom {
|
||||
return std::make_pair<IfcSchema::IfcSurfaceStyle*, T*>(0,0);
|
||||
}
|
||||
|
||||
const SurfaceStyle* get_style(IfcSchema::IfcRepresentationItem* representation_item);
|
||||
const SurfaceStyle* get_style(const IfcSchema::IfcRepresentationItem* representation_item);
|
||||
const SurfaceStyle* get_default_style(const std::string& ifc_type);
|
||||
|
||||
namespace Cache {
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
#include "../ifcgeom/IfcGeom.h"
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcExtrudedAreaSolid::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_Shape& shape) {
|
||||
TopoDS_Face face;
|
||||
if ( ! IfcGeom::convert_face(l->SweptArea(),face) ) return false;
|
||||
const double height = l->Depth() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
@@ -109,7 +109,7 @@ bool IfcGeom::convert(const IfcSchema::IfcExtrudedAreaSolid::ptr l, TopoDS_Shape
|
||||
return ! shape.IsNull();
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSurfaceOfLinearExtrusion::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSurfaceOfLinearExtrusion* l, TopoDS_Shape& shape) {
|
||||
TopoDS_Wire wire;
|
||||
if ( !IfcGeom::convert_wire(l->SweptCurve(), wire) ) {
|
||||
TopoDS_Face face;
|
||||
@@ -129,7 +129,7 @@ bool IfcGeom::convert(const IfcSchema::IfcSurfaceOfLinearExtrusion::ptr l, TopoD
|
||||
return !shape.IsNull();
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSurfaceOfRevolution::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSurfaceOfRevolution* l, TopoDS_Shape& shape) {
|
||||
TopoDS_Wire wire;
|
||||
if ( !IfcGeom::convert_wire(l->SweptCurve(), wire) ) {
|
||||
TopoDS_Face face;
|
||||
@@ -150,7 +150,7 @@ bool IfcGeom::convert(const IfcSchema::IfcSurfaceOfRevolution::ptr l, TopoDS_Sha
|
||||
return !shape.IsNull();
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRevolvedAreaSolid::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRevolvedAreaSolid* l, TopoDS_Shape& shape) {
|
||||
const double ang = l->Angle() * IfcGeom::GetValue(GV_PLANEANGLE_UNIT);
|
||||
|
||||
TopoDS_Face face;
|
||||
@@ -172,7 +172,7 @@ bool IfcGeom::convert(const IfcSchema::IfcRevolvedAreaSolid::ptr l, TopoDS_Shape
|
||||
return !shape.IsNull();
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcFacetedBrep::ptr l, IfcRepresentationShapeItems& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcFacetedBrep* l, IfcRepresentationShapeItems& shape) {
|
||||
TopoDS_Shape s;
|
||||
const SurfaceStyle* collective_style = get_style(l);
|
||||
if (IfcGeom::convert_shape(l->Outer(),s) ) {
|
||||
@@ -183,10 +183,10 @@ bool IfcGeom::convert(const IfcSchema::IfcFacetedBrep::ptr l, IfcRepresentationS
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcFaceBasedSurfaceModel::ptr l, IfcRepresentationShapeItems& shapes) {
|
||||
IfcSchema::IfcConnectedFaceSet::list facesets = l->FbsmFaces();
|
||||
bool IfcGeom::convert(const IfcSchema::IfcFaceBasedSurfaceModel* l, IfcRepresentationShapeItems& shapes) {
|
||||
IfcSchema::IfcConnectedFaceSet::list::ptr facesets = l->FbsmFaces();
|
||||
const SurfaceStyle* collective_style = get_style(l);
|
||||
for( IfcSchema::IfcConnectedFaceSet::it it = facesets->begin(); it != facesets->end(); ++ it ) {
|
||||
for( IfcSchema::IfcConnectedFaceSet::list::it it = facesets->begin(); it != facesets->end(); ++ it ) {
|
||||
TopoDS_Shape s;
|
||||
const SurfaceStyle* shell_style = get_style(*it);
|
||||
if (IfcGeom::convert_shape(*it,s)) {
|
||||
@@ -196,22 +196,22 @@ bool IfcGeom::convert(const IfcSchema::IfcFaceBasedSurfaceModel::ptr l, IfcRepre
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcHalfSpaceSolid::ptr l, TopoDS_Shape& shape) {
|
||||
IfcSchema::IfcSurface::ptr surface = l->BaseSurface();
|
||||
bool IfcGeom::convert(const IfcSchema::IfcHalfSpaceSolid* l, TopoDS_Shape& shape) {
|
||||
IfcSchema::IfcSurface* surface = l->BaseSurface();
|
||||
if ( ! surface->is(IfcSchema::Type::IfcPlane) ) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Unsupported BaseSurface:", surface->entity);
|
||||
return false;
|
||||
}
|
||||
gp_Pln pln;
|
||||
IfcGeom::convert(reinterpret_pointer_cast<IfcSchema::IfcSurface,IfcSchema::IfcPlane>(surface),pln);
|
||||
IfcGeom::convert((IfcSchema::IfcPlane*)surface,pln);
|
||||
const gp_Pnt pnt = pln.Location().Translated( l->AgreementFlag() ? -pln.Axis().Direction() : pln.Axis().Direction());
|
||||
shape = BRepPrimAPI_MakeHalfSpace(BRepBuilderAPI_MakeFace(pln),pnt).Solid();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcPolygonalBoundedHalfSpace::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcPolygonalBoundedHalfSpace* l, TopoDS_Shape& shape) {
|
||||
TopoDS_Shape halfspace;
|
||||
if ( ! IfcGeom::convert(reinterpret_pointer_cast<IfcSchema::IfcPolygonalBoundedHalfSpace,IfcSchema::IfcHalfSpaceSolid>(l),halfspace) ) return false;
|
||||
if ( ! IfcGeom::convert((IfcSchema::IfcHalfSpaceSolid*)l,halfspace) ) return false;
|
||||
TopoDS_Wire wire;
|
||||
if ( ! IfcGeom::convert_wire(l->PolygonalBoundary(),wire) || ! wire.Closed() ) return false;
|
||||
gp_Trsf trsf;
|
||||
@@ -223,10 +223,10 @@ bool IfcGeom::convert(const IfcSchema::IfcPolygonalBoundedHalfSpace::ptr l, Topo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcShellBasedSurfaceModel::ptr l, IfcRepresentationShapeItems& shapes) {
|
||||
IfcUtil::IfcAbstractSelect::list shells = l->SbsmBoundary();
|
||||
bool IfcGeom::convert(const IfcSchema::IfcShellBasedSurfaceModel* l, IfcRepresentationShapeItems& shapes) {
|
||||
IfcUtil::IfcAbstractSelect::list::ptr shells = l->SbsmBoundary();
|
||||
const SurfaceStyle* collective_style = get_style(l);
|
||||
for( IfcUtil::IfcAbstractSelect::it it = shells->begin(); it != shells->end(); ++ it ) {
|
||||
for( IfcUtil::IfcAbstractSelect::list::it it = shells->begin(); it != shells->end(); ++ it ) {
|
||||
TopoDS_Shape s;
|
||||
const SurfaceStyle* shell_style = 0;
|
||||
if ((*it)->is(IfcSchema::Type::IfcRepresentationItem)) {
|
||||
@@ -239,7 +239,7 @@ bool IfcGeom::convert(const IfcSchema::IfcShellBasedSurfaceModel::ptr l, IfcRepr
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcBooleanResult::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape& shape) {
|
||||
TopoDS_Shape s1, s2;
|
||||
TopoDS_Wire boundary_wire;
|
||||
IfcSchema::IfcBooleanOperand operand1 = l->FirstOperand();
|
||||
@@ -337,8 +337,8 @@ bool IfcGeom::convert(const IfcSchema::IfcBooleanResult::ptr l, TopoDS_Shape& sh
|
||||
}
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcConnectedFaceSet::ptr l, TopoDS_Shape& shape) {
|
||||
IfcSchema::IfcFace::list faces = l->CfsFaces();
|
||||
bool IfcGeom::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Shape& shape) {
|
||||
IfcSchema::IfcFace::list::ptr faces = l->CfsFaces();
|
||||
bool facesAdded = false;
|
||||
const unsigned int num_faces = faces->Size();
|
||||
if ( num_faces < GetValue(GV_MAX_FACES_TO_SEW) ) {
|
||||
@@ -346,7 +346,7 @@ bool IfcGeom::convert(const IfcSchema::IfcConnectedFaceSet::ptr l, TopoDS_Shape&
|
||||
builder.SetTolerance(GetValue(GV_POINT_EQUALITY_TOLERANCE));
|
||||
builder.SetMaxTolerance(GetValue(GV_POINT_EQUALITY_TOLERANCE));
|
||||
builder.SetMinTolerance(GetValue(GV_POINT_EQUALITY_TOLERANCE));
|
||||
for( IfcSchema::IfcFace::it it = faces->begin(); it != faces->end(); ++ it ) {
|
||||
for( IfcSchema::IfcFace::list::it it = faces->begin(); it != faces->end(); ++ it ) {
|
||||
TopoDS_Face face;
|
||||
if ( IfcGeom::convert_face(*it,face) && face_area(face) > GetValue(GV_MINIMAL_FACE_AREA) ) {
|
||||
builder.Add(face);
|
||||
@@ -367,7 +367,7 @@ bool IfcGeom::convert(const IfcSchema::IfcConnectedFaceSet::ptr l, TopoDS_Shape&
|
||||
TopoDS_Compound compound;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(compound);
|
||||
for( IfcSchema::IfcFace::it it = faces->begin(); it != faces->end(); ++ it ) {
|
||||
for( IfcSchema::IfcFace::list::it it = faces->begin(); it != faces->end(); ++ it ) {
|
||||
TopoDS_Face face;
|
||||
if ( IfcGeom::convert_face(*it,face) && face_area(face) > GetValue(GV_MINIMAL_FACE_AREA) ) {
|
||||
builder.Add(compound,face);
|
||||
@@ -382,27 +382,24 @@ bool IfcGeom::convert(const IfcSchema::IfcConnectedFaceSet::ptr l, TopoDS_Shape&
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcMappedItem::ptr l, IfcRepresentationShapeItems& shapes) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcMappedItem* l, IfcRepresentationShapeItems& shapes) {
|
||||
gp_GTrsf gtrsf;
|
||||
IfcSchema::IfcCartesianTransformationOperator::ptr transform = l->MappingTarget();
|
||||
IfcSchema::IfcCartesianTransformationOperator* transform = l->MappingTarget();
|
||||
if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator3DnonUniform) ) {
|
||||
IfcGeom::convert(reinterpret_pointer_cast<IfcSchema::IfcCartesianTransformationOperator,
|
||||
IfcSchema::IfcCartesianTransformationOperator3DnonUniform>(transform),gtrsf);
|
||||
IfcGeom::convert((IfcSchema::IfcCartesianTransformationOperator3DnonUniform*)transform,gtrsf);
|
||||
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator2DnonUniform) ) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Unsupported MappingTarget:", transform->entity);
|
||||
return false;
|
||||
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator3D) ) {
|
||||
gp_Trsf trsf;
|
||||
IfcGeom::convert(reinterpret_pointer_cast<IfcSchema::IfcCartesianTransformationOperator,
|
||||
IfcSchema::IfcCartesianTransformationOperator3D>(transform),trsf);
|
||||
IfcGeom::convert((IfcSchema::IfcCartesianTransformationOperator3D*)transform,trsf);
|
||||
gtrsf = trsf;
|
||||
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator2D) ) {
|
||||
gp_Trsf2d trsf_2d;
|
||||
IfcGeom::convert(reinterpret_pointer_cast<IfcSchema::IfcCartesianTransformationOperator,
|
||||
IfcSchema::IfcCartesianTransformationOperator2D>(transform),trsf_2d);
|
||||
IfcGeom::convert((IfcSchema::IfcCartesianTransformationOperator2D*)transform,trsf_2d);
|
||||
gtrsf = (gp_Trsf) trsf_2d;
|
||||
}
|
||||
IfcSchema::IfcRepresentationMap::ptr map = l->MappingSource();
|
||||
IfcSchema::IfcRepresentationMap* map = l->MappingSource();
|
||||
IfcSchema::IfcAxis2Placement placement = map->MappingOrigin();
|
||||
gp_Trsf trsf;
|
||||
if (placement->is(IfcSchema::Type::IfcAxis2Placement3D)) {
|
||||
@@ -421,10 +418,10 @@ bool IfcGeom::convert(const IfcSchema::IfcMappedItem::ptr l, IfcRepresentationSh
|
||||
return b;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcShapeRepresentation::ptr l, IfcRepresentationShapeItems& shapes) {
|
||||
IfcSchema::IfcRepresentationItem::list items = l->Items();
|
||||
bool IfcGeom::convert(const IfcSchema::IfcShapeRepresentation* l, IfcRepresentationShapeItems& shapes) {
|
||||
IfcSchema::IfcRepresentationItem::list::ptr items = l->Items();
|
||||
if ( ! items->Size() ) return false;
|
||||
for ( IfcSchema::IfcRepresentationItem::it it = items->begin(); it != items->end(); ++ it ) {
|
||||
for ( IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++ it ) {
|
||||
IfcSchema::IfcRepresentationItem* representation_item = *it;
|
||||
if ( IfcGeom::is_shape_collection(representation_item) ) IfcGeom::convert_shapes(*it,shapes);
|
||||
else {
|
||||
@@ -437,11 +434,11 @@ bool IfcGeom::convert(const IfcSchema::IfcShapeRepresentation::ptr l, IfcReprese
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcGeometricSet::ptr l, IfcRepresentationShapeItems& shapes) {
|
||||
IfcUtil::IfcAbstractSelect::list elements = l->Elements();
|
||||
bool IfcGeom::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresentationShapeItems& shapes) {
|
||||
IfcUtil::IfcAbstractSelect::list::ptr elements = l->Elements();
|
||||
if ( !elements->Size() ) return false;
|
||||
const IfcGeom::SurfaceStyle* parent_style = get_style(l);
|
||||
for ( IfcUtil::IfcAbstractSelect::it it = elements->begin(); it != elements->end(); ++ it ) {
|
||||
for ( IfcUtil::IfcAbstractSelect::list::it it = elements->begin(); it != elements->end(); ++ it ) {
|
||||
IfcSchema::IfcGeometricSetSelect element = *it;
|
||||
if (element->is(IfcSchema::Type::IfcSurface)) {
|
||||
IfcSchema::IfcSurface* surface = (IfcSchema::IfcSurface*) element;
|
||||
@@ -455,7 +452,7 @@ bool IfcGeom::convert(const IfcSchema::IfcGeometricSet::ptr l, IfcRepresentation
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcBlock::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcBlock* l, TopoDS_Shape& shape) {
|
||||
const double dx = l->XLength() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double dy = l->YLength() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double dz = l->ZLength() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
@@ -467,7 +464,7 @@ bool IfcGeom::convert(const IfcSchema::IfcBlock::ptr l, TopoDS_Shape& shape) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRectangularPyramid::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRectangularPyramid* l, TopoDS_Shape& shape) {
|
||||
const double dx = l->XLength() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double dy = l->YLength() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double dz = l->Height() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
@@ -484,7 +481,7 @@ bool IfcGeom::convert(const IfcSchema::IfcRectangularPyramid::ptr l, TopoDS_Shap
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRightCircularCylinder::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRightCircularCylinder* l, TopoDS_Shape& shape) {
|
||||
const double r = l->Radius() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double h = l->Height() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
|
||||
@@ -495,7 +492,7 @@ bool IfcGeom::convert(const IfcSchema::IfcRightCircularCylinder::ptr l, TopoDS_S
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRightCircularCone::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRightCircularCone* l, TopoDS_Shape& shape) {
|
||||
const double r = l->BottomRadius() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
const double h = l->Height() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
|
||||
@@ -506,7 +503,7 @@ bool IfcGeom::convert(const IfcSchema::IfcRightCircularCone::ptr l, TopoDS_Shape
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSphere::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSphere* l, TopoDS_Shape& shape) {
|
||||
const double r = l->Radius() * IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
|
||||
BRepPrimAPI_MakeSphere builder(r);
|
||||
@@ -516,11 +513,11 @@ bool IfcGeom::convert(const IfcSchema::IfcSphere::ptr l, TopoDS_Shape& shape) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCsgSolid::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCsgSolid* l, TopoDS_Shape& shape) {
|
||||
return IfcGeom::convert_shape(l->TreeRootExpression(), shape);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCurveBoundedPlane::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCurveBoundedPlane* l, TopoDS_Shape& face) {
|
||||
gp_Pln pln;
|
||||
IfcGeom::convert(l->BasisSurface(), pln);
|
||||
|
||||
@@ -533,9 +530,9 @@ bool IfcGeom::convert(const IfcSchema::IfcCurveBoundedPlane::ptr l, TopoDS_Shape
|
||||
BRepBuilderAPI_MakeFace mf (outer);
|
||||
mf.Add(outer);
|
||||
|
||||
IfcSchema::IfcCurve::list inner = l->InnerBoundaries();
|
||||
IfcSchema::IfcCurve::list::ptr inner = l->InnerBoundaries();
|
||||
|
||||
for (IfcSchema::IfcCurve::it it = inner->begin(); it != inner->end(); ++it) {
|
||||
for (IfcSchema::IfcCurve::list::it it = inner->begin(); it != inner->end(); ++it) {
|
||||
TopoDS_Wire inner;
|
||||
IfcGeom::convert_wire(*it, inner);
|
||||
|
||||
@@ -549,7 +546,7 @@ bool IfcGeom::convert(const IfcSchema::IfcCurveBoundedPlane::ptr l, TopoDS_Shape
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRectangularTrimmedSurface::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcRectangularTrimmedSurface* l, TopoDS_Shape& face) {
|
||||
if (!l->BasisSurface()->is(IfcSchema::Type::IfcPlane)) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Unsupported BasisSurface:", l->BasisSurface()->entity);
|
||||
return false;
|
||||
@@ -564,7 +561,7 @@ bool IfcGeom::convert(const IfcSchema::IfcRectangularTrimmedSurface::ptr l, Topo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* l, TopoDS_Shape& shape) {
|
||||
gp_Trsf directrix, position;
|
||||
TopoDS_Shape face;
|
||||
TopoDS_Wire wire, section;
|
||||
@@ -637,7 +634,7 @@ bool IfcGeom::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid::ptr l, Top
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSweptDiskSolid::ptr l, TopoDS_Shape& shape) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shape& shape) {
|
||||
TopoDS_Wire wire, section1, section2;
|
||||
|
||||
const bool hasInnerRadius = l->hasInnerRadius();
|
||||
@@ -714,7 +711,7 @@ bool IfcGeom::convert(const IfcSchema::IfcSweptDiskSolid::ptr l, TopoDS_Shape& s
|
||||
|
||||
#ifdef USE_IFC4
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCylindricalSurface::ptr l, TopoDS_Shape& face) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCylindricalSurface* l, TopoDS_Shape& face) {
|
||||
gp_Trsf trsf;
|
||||
IfcGeom::convert(l->Position(),trsf);
|
||||
|
||||
@@ -722,4 +719,8 @@ bool IfcGeom::convert(const IfcSchema::IfcCylindricalSurface::ptr l, TopoDS_Shap
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
bool IfcGeom::convert(const IfcSchema::IfcAdvancedBrep* l, TopoDS_Shape& shape) {
|
||||
return convert(l->Outer(), shape);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+122
-23
@@ -82,7 +82,7 @@
|
||||
|
||||
#include "../ifcgeom/IfcGeom.h"
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCompositeCurve::ptr l, TopoDS_Wire& wire) {
|
||||
bool IfcGeom::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire& wire) {
|
||||
if ( IfcGeom::GetValue(GV_PLANEANGLE_UNIT)<0 ) {
|
||||
Logger::Message(Logger::LOG_WARNING,"Creating a composite curve without unit information:",l->entity);
|
||||
|
||||
@@ -138,11 +138,11 @@ bool IfcGeom::convert(const IfcSchema::IfcCompositeCurve::ptr l, TopoDS_Wire& wi
|
||||
|
||||
return use_radians || use_degrees;
|
||||
}
|
||||
IfcSchema::IfcCompositeCurveSegment::list segments = l->Segments();
|
||||
IfcSchema::IfcCompositeCurveSegment::list::ptr segments = l->Segments();
|
||||
BRepBuilderAPI_MakeWire w;
|
||||
//TopoDS_Vertex last_vertex;
|
||||
for( IfcSchema::IfcCompositeCurveSegment::it it = segments->begin(); it != segments->end(); ++ it ) {
|
||||
const IfcSchema::IfcCurve::ptr curve = (*it)->ParentCurve();
|
||||
for( IfcSchema::IfcCompositeCurveSegment::list::it it = segments->begin(); it != segments->end(); ++ it ) {
|
||||
IfcSchema::IfcCurve* curve = (*it)->ParentCurve();
|
||||
TopoDS_Wire wire2;
|
||||
if ( ! IfcGeom::convert_wire(curve,wire2) ) {
|
||||
Logger::Message(Logger::LOG_ERROR,"Failed to convert curve:",curve->entity);
|
||||
@@ -171,15 +171,16 @@ bool IfcGeom::convert(const IfcSchema::IfcCompositeCurve::ptr l, TopoDS_Wire& wi
|
||||
wire = w.Wire();
|
||||
return true;
|
||||
}
|
||||
bool IfcGeom::convert(const IfcSchema::IfcTrimmedCurve::ptr l, TopoDS_Wire& wire) {
|
||||
IfcSchema::IfcCurve::ptr basis_curve = l->BasisCurve();
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire& wire) {
|
||||
IfcSchema::IfcCurve* basis_curve = l->BasisCurve();
|
||||
bool isConic = basis_curve->is(IfcSchema::Type::IfcConic);
|
||||
double parameterFactor = isConic ? IfcGeom::GetValue(GV_PLANEANGLE_UNIT) : IfcGeom::GetValue(GV_LENGTH_UNIT);
|
||||
Handle(Geom_Curve) curve;
|
||||
if ( ! IfcGeom::convert_curve(basis_curve,curve) ) return false;
|
||||
bool trim_cartesian = l->MasterRepresentation() == IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN;
|
||||
IfcUtil::IfcAbstractSelect::list trims1 = l->Trim1();
|
||||
IfcUtil::IfcAbstractSelect::list trims2 = l->Trim2();
|
||||
IfcUtil::IfcAbstractSelect::list::ptr trims1 = l->Trim1();
|
||||
IfcUtil::IfcAbstractSelect::list::ptr trims2 = l->Trim2();
|
||||
bool trimmed1 = false;
|
||||
bool trimmed2 = false;
|
||||
unsigned sense_agreement = l->SenseAgreement() ? 0 : 1;
|
||||
@@ -188,24 +189,24 @@ bool IfcGeom::convert(const IfcSchema::IfcTrimmedCurve::ptr l, TopoDS_Wire& wire
|
||||
bool has_flts[2] = {false,false};
|
||||
bool has_pnts[2] = {false,false};
|
||||
BRepBuilderAPI_MakeWire w;
|
||||
for ( IfcUtil::IfcAbstractSelect::it it = trims1->begin(); it != trims1->end(); it ++ ) {
|
||||
const IfcUtil::IfcAbstractSelect::ptr i = *it;
|
||||
for ( IfcUtil::IfcAbstractSelect::list::it it = trims1->begin(); it != trims1->end(); it ++ ) {
|
||||
IfcUtil::IfcAbstractSelect* i = *it;
|
||||
if ( i->is(IfcSchema::Type::IfcCartesianPoint) ) {
|
||||
IfcGeom::convert(reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,IfcSchema::IfcCartesianPoint>(i), pnts[sense_agreement] );
|
||||
IfcGeom::convert((IfcSchema::IfcCartesianPoint*)i, pnts[sense_agreement] );
|
||||
has_pnts[sense_agreement] = true;
|
||||
} else if ( i->is(IfcSchema::Type::IfcParameterValue) ) {
|
||||
const double value = *reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,IfcUtil::IfcArgumentSelect>(i)->wrappedValue();
|
||||
const double value = *((IfcUtil::IfcArgumentSelect*)i)->wrappedValue();
|
||||
flts[sense_agreement] = value * parameterFactor;
|
||||
has_flts[sense_agreement] = true;
|
||||
}
|
||||
}
|
||||
for ( IfcUtil::IfcAbstractSelect::it it = trims2->begin(); it != trims2->end(); it ++ ) {
|
||||
const IfcUtil::IfcAbstractSelect::ptr i = *it;
|
||||
for ( IfcUtil::IfcAbstractSelect::list::it it = trims2->begin(); it != trims2->end(); it ++ ) {
|
||||
IfcUtil::IfcAbstractSelect* i = *it;
|
||||
if ( i->is(IfcSchema::Type::IfcCartesianPoint) ) {
|
||||
IfcGeom::convert(reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,IfcSchema::IfcCartesianPoint>(i), pnts[1-sense_agreement] );
|
||||
IfcGeom::convert((IfcSchema::IfcCartesianPoint*)i, pnts[1-sense_agreement] );
|
||||
has_pnts[1-sense_agreement] = true;
|
||||
} else if ( i->is(IfcSchema::Type::IfcParameterValue) ) {
|
||||
const double value = *reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,IfcUtil::IfcArgumentSelect>(i)->wrappedValue();
|
||||
const double value = *((IfcUtil::IfcArgumentSelect*)i)->wrappedValue();
|
||||
flts[1-sense_agreement] = value * parameterFactor;
|
||||
has_flts[1-sense_agreement] = true;
|
||||
}
|
||||
@@ -269,12 +270,13 @@ bool IfcGeom::convert(const IfcSchema::IfcTrimmedCurve::ptr l, TopoDS_Wire& wire
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool IfcGeom::convert(const IfcSchema::IfcPolyline::ptr l, TopoDS_Wire& result) {
|
||||
IfcSchema::IfcCartesianPoint::list points = l->Points();
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcPolyline* l, TopoDS_Wire& result) {
|
||||
IfcSchema::IfcCartesianPoint::list::ptr points = l->Points();
|
||||
|
||||
BRepBuilderAPI_MakeWire w;
|
||||
gp_Pnt P1;gp_Pnt P2;
|
||||
for( IfcSchema::IfcCartesianPoint::it it = points->begin(); it != points->end(); ++ it ) {
|
||||
for( IfcSchema::IfcCartesianPoint::list::it it = points->begin(); it != points->end(); ++ it ) {
|
||||
IfcGeom::convert(*it,P2);
|
||||
if ( it != points->begin() && ( !P1.IsEqual(P2,GetValue(GV_POINT_EQUALITY_TOLERANCE)) ) )
|
||||
w.Add(BRepBuilderAPI_MakeEdge(P1,P2));
|
||||
@@ -284,13 +286,14 @@ bool IfcGeom::convert(const IfcSchema::IfcPolyline::ptr l, TopoDS_Wire& result)
|
||||
result = w.Wire();
|
||||
return true;
|
||||
}
|
||||
bool IfcGeom::convert(const IfcSchema::IfcPolyLoop::ptr l, TopoDS_Wire& result) {
|
||||
IfcSchema::IfcCartesianPoint::list points = l->Polygon();
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcPolyLoop* l, TopoDS_Wire& result) {
|
||||
IfcSchema::IfcCartesianPoint::list::ptr points = l->Polygon();
|
||||
|
||||
BRepBuilderAPI_MakeWire w;
|
||||
gp_Pnt P1;gp_Pnt P2;gp_Pnt F;
|
||||
int count = 0;
|
||||
for( IfcSchema::IfcCartesianPoint::it it = points->begin(); it != points->end(); ++ it ) {
|
||||
for( IfcSchema::IfcCartesianPoint::list::it it = points->begin(); it != points->end(); ++ it ) {
|
||||
IfcGeom::convert(*it,P2);
|
||||
if ( it != points->begin() && ( !P1.IsEqual(P2,GetValue(GV_POINT_EQUALITY_TOLERANCE)) ) ) {
|
||||
w.Add(BRepBuilderAPI_MakeEdge(P1,P2));
|
||||
@@ -307,6 +310,102 @@ bool IfcGeom::convert(const IfcSchema::IfcPolyLoop::ptr l, TopoDS_Wire& result)
|
||||
result = w.Wire();
|
||||
return true;
|
||||
}
|
||||
bool IfcGeom::convert(const IfcSchema::IfcArbitraryOpenProfileDef::ptr l, TopoDS_Wire& result) {
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcArbitraryOpenProfileDef* l, TopoDS_Wire& result) {
|
||||
return IfcGeom::convert_wire(l->Curve(), result);
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcEdgeCurve* l, TopoDS_Wire& result) {
|
||||
IfcSchema::IfcPoint* pnt1 = ((IfcSchema::IfcVertexPoint*) l->EdgeStart())->VertexGeometry();
|
||||
IfcSchema::IfcPoint* pnt2 = ((IfcSchema::IfcVertexPoint*) l->EdgeEnd())->VertexGeometry();
|
||||
if (!pnt1->is(IfcSchema::Type::IfcCartesianPoint) || !pnt2->is(IfcSchema::Type::IfcCartesianPoint)) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Only IfcCartesianPoints are supported for VertexGeometry", l->entity);
|
||||
return false;
|
||||
}
|
||||
|
||||
gp_Pnt p1, p2;
|
||||
if (!IfcGeom::convert(((IfcSchema::IfcCartesianPoint*)pnt1), p1) ||
|
||||
!IfcGeom::convert(((IfcSchema::IfcCartesianPoint*)pnt2), p2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BRepBuilderAPI_MakeWire mw;
|
||||
Handle_Geom_Curve crv;
|
||||
|
||||
// The lack of a clear separation between topological and geometrical entities
|
||||
// is starting to get problematic. If the underlying curve is bounded it is
|
||||
// assumed that a topological wire can be crafted from it. After which an
|
||||
// attempt is made to reconstruct it from the individual curves and the vertices
|
||||
// of the IfcEdgeCurve.
|
||||
const bool is_bounded = l->EdgeGeometry()->is(IfcSchema::Type::IfcBoundedCurve);
|
||||
|
||||
if (!is_bounded && IfcGeom::convert_curve(l->EdgeGeometry(), crv)) {
|
||||
mw.Add(BRepBuilderAPI_MakeEdge(crv, p1, p2));
|
||||
result = mw;
|
||||
return true;
|
||||
} else if (is_bounded && IfcGeom::convert_wire(l->EdgeGeometry(), result)) {
|
||||
if (!l->SameSense()) std::swap(pnt1, pnt2);
|
||||
TopExp_Explorer exp(result, TopAbs_EDGE);
|
||||
bool first = true;
|
||||
while (exp.More()) {
|
||||
const TopoDS_Edge& ed = TopoDS::Edge(exp.Current());
|
||||
Standard_Real u1, u2;
|
||||
Handle(Geom_Curve) ecrv = BRep_Tool::Curve(ed, u1, u2);
|
||||
exp.Next();
|
||||
const bool last = !exp.More();
|
||||
first = false;
|
||||
if (first && last) {
|
||||
mw.Add(BRepBuilderAPI_MakeEdge(ecrv, p1, p2));
|
||||
} else if (first) {
|
||||
gp_Pnt pu;
|
||||
ecrv->D0(u2, pu);
|
||||
mw.Add(BRepBuilderAPI_MakeEdge(ecrv, p1, pu));
|
||||
} else if (last) {
|
||||
gp_Pnt pu;
|
||||
ecrv->D0(u1, pu);
|
||||
mw.Add(BRepBuilderAPI_MakeEdge(ecrv, pu, p2));
|
||||
} else {
|
||||
mw.Add(BRepBuilderAPI_MakeEdge(ecrv, u1, u2));
|
||||
}
|
||||
}
|
||||
result = mw;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IfcGeom::convert(const IfcSchema::IfcEdgeLoop* l, TopoDS_Wire& result) {
|
||||
IfcSchema::IfcOrientedEdge::list::ptr li = l->EdgeList();
|
||||
BRepBuilderAPI_MakeWire mw;
|
||||
for (IfcSchema::IfcOrientedEdge::list::it it = li->begin(); it != li->end(); ++it) {
|
||||
IfcSchema::IfcOrientedEdge* e = *it;
|
||||
|
||||
IfcSchema::IfcPoint* pnt1 = ((IfcSchema::IfcVertexPoint*) e->EdgeStart())->VertexGeometry();
|
||||
IfcSchema::IfcPoint* pnt2 = ((IfcSchema::IfcVertexPoint*) e->EdgeEnd())->VertexGeometry();
|
||||
if (!pnt1->is(IfcSchema::Type::IfcCartesianPoint) || !pnt2->is(IfcSchema::Type::IfcCartesianPoint)) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Only IfcCartesianPoints are supported for VertexGeometry", l->entity);
|
||||
return false;
|
||||
}
|
||||
|
||||
gp_Pnt p1, p2;
|
||||
if (!IfcGeom::convert(((IfcSchema::IfcCartesianPoint*)pnt1), p1) ||
|
||||
!IfcGeom::convert(((IfcSchema::IfcCartesianPoint*)pnt2), p2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
mw.Add(BRepBuilderAPI_MakeEdge(p1, p2));
|
||||
continue;
|
||||
|
||||
IfcSchema::IfcEdge* base = e->EdgeElement();
|
||||
TopoDS_Wire w;
|
||||
if (convert_wire(e->EdgeElement(), w)) {
|
||||
if (!e->Orientation()) w.Reverse();
|
||||
mw.Add(w);
|
||||
}
|
||||
}
|
||||
result = mw;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,10 @@ SHAPES(IfcMappedItem);
|
||||
SHAPES(IfcFacetedBrep);
|
||||
SHAPES(IfcGeometricSet);
|
||||
|
||||
#ifdef USE_IFC4
|
||||
SHAPE(IfcCylindricalSurface);
|
||||
SHAPE(IfcAdvancedBrep);
|
||||
#endif
|
||||
SHAPE(IfcExtrudedAreaSolid);
|
||||
SHAPE(IfcRevolvedAreaSolid);
|
||||
SHAPE(IfcConnectedFaceSet);
|
||||
@@ -68,10 +72,10 @@ SHAPE(IfcCurveBoundedPlane);
|
||||
SHAPE(IfcRectangularTrimmedSurface);
|
||||
SHAPE(IfcSurfaceCurveSweptAreaSolid);
|
||||
SHAPE(IfcSweptDiskSolid);
|
||||
#ifdef USE_IFC4
|
||||
SHAPE(IfcCylindricalSurface);
|
||||
#endif
|
||||
|
||||
#ifdef USE_IFC4
|
||||
FACE(IfcAdvancedFace);
|
||||
#endif
|
||||
FACE(IfcArbitraryProfileDefWithVoids);
|
||||
FACE(IfcArbitraryClosedProfileDef);
|
||||
FACE(IfcRoundedRectangleProfileDef);
|
||||
@@ -92,6 +96,8 @@ FACE(IfcCompositeProfileDef);
|
||||
FACE(IfcDerivedProfileDef);
|
||||
FACE(IfcFace);
|
||||
|
||||
WIRE(IfcEdgeCurve);
|
||||
WIRE(IfcEdgeLoop);
|
||||
WIRE(IfcPolyline);
|
||||
WIRE(IfcPolyLoop);
|
||||
WIRE(IfcCompositeCurve);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "IfcRegisterUndef.h"
|
||||
#define CLASS(T,V) bool convert(const T::ptr L, V& r);
|
||||
#define CLASS(T,V) bool convert(const T* L, V& r);
|
||||
#define SHAPES(T) CLASS(T,IfcRepresentationShapeItems)
|
||||
#define SHAPE(T) CLASS(T,TopoDS_Shape)
|
||||
#define WIRE(T) CLASS(T,TopoDS_Wire)
|
||||
|
||||
+3389
-3395
File diff suppressed because it is too large
Load Diff
+4402
-5708
File diff suppressed because it is too large
Load Diff
+4036
-4053
File diff suppressed because it is too large
Load Diff
+5192
-6722
File diff suppressed because it is too large
Load Diff
@@ -90,13 +90,13 @@ IfcSchema::IfcOwnerHistory* IfcHierarchyHelper::addOwnerHistory() {
|
||||
}
|
||||
|
||||
IfcSchema::IfcProject* IfcHierarchyHelper::addProject(IfcSchema::IfcOwnerHistory* owner_hist) {
|
||||
IfcSchema::IfcRepresentationContext::list rep_contexts (new IfcTemplatedEntityList<IfcSchema::IfcRepresentationContext>());
|
||||
IfcSchema::IfcRepresentationContext::list::ptr rep_contexts (new IfcSchema::IfcRepresentationContext::list);
|
||||
IfcSchema::IfcGeometricRepresentationContext* rep_context = new IfcSchema::IfcGeometricRepresentationContext(
|
||||
std::string("Plan"), std::string("Model"), 3, 1e-5, addPlacement3d(), addTriplet<IfcSchema::IfcDirection>(0, 1, 0));
|
||||
|
||||
rep_contexts->push(rep_context);
|
||||
|
||||
IfcEntities units (new IfcEntityList());
|
||||
IfcEntityList::ptr units (new IfcEntityList);
|
||||
IfcSchema::IfcDimensionalExponents* dimexp = new IfcSchema::IfcDimensionalExponents(0, 0, 0, 0, 0, 0, 0);
|
||||
IfcSchema::IfcSIUnit* unit1 = new IfcSchema::IfcSIUnit(IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT,
|
||||
IfcSchema::IfcSIPrefix::IfcSIPrefix_MILLI, IfcSchema::IfcSIUnitName::IfcSIUnitName_METRE);
|
||||
@@ -236,7 +236,7 @@ void IfcHierarchyHelper::addExtrudedPolyline(IfcSchema::IfcShapeRepresentation*
|
||||
IfcSchema::IfcAxis2Placement2D* place, IfcSchema::IfcAxis2Placement3D* place2,
|
||||
IfcSchema::IfcDirection* dir, IfcSchema::IfcRepresentationContext* context)
|
||||
{
|
||||
IfcSchema::IfcCartesianPoint::list cartesian_points (new IfcTemplatedEntityList<IfcSchema::IfcCartesianPoint>());
|
||||
IfcSchema::IfcCartesianPoint::list::ptr cartesian_points (new IfcSchema::IfcCartesianPoint::list);
|
||||
for (std::vector<std::pair<double, double> >::const_iterator i = points.begin(); i != points.end(); ++i) {
|
||||
cartesian_points->push(addDoublet<IfcSchema::IfcCartesianPoint>(i->first, i->second));
|
||||
}
|
||||
@@ -248,7 +248,7 @@ void IfcHierarchyHelper::addExtrudedPolyline(IfcSchema::IfcShapeRepresentation*
|
||||
IfcSchema::IfcExtrudedAreaSolid* solid = new IfcSchema::IfcExtrudedAreaSolid(
|
||||
profile, place2 ? place2 : addPlacement3d(), dir ? dir : addTriplet<IfcSchema::IfcDirection>(0, 0, 1), h);
|
||||
|
||||
IfcSchema::IfcRepresentationItem::list items = rep->Items();
|
||||
IfcSchema::IfcRepresentationItem::list::ptr items = rep->Items();
|
||||
items->push(solid);
|
||||
rep->setItems(items);
|
||||
|
||||
@@ -261,8 +261,8 @@ IfcSchema::IfcProductDefinitionShape* IfcHierarchyHelper::addExtrudedPolyline(co
|
||||
IfcSchema::IfcAxis2Placement2D* place, IfcSchema::IfcAxis2Placement3D* place2, IfcSchema::IfcDirection* dir,
|
||||
IfcSchema::IfcRepresentationContext* context)
|
||||
{
|
||||
IfcSchema::IfcRepresentation::list reps (new IfcTemplatedEntityList<IfcSchema::IfcRepresentation>());
|
||||
IfcSchema::IfcRepresentationItem::list items (new IfcTemplatedEntityList<IfcSchema::IfcRepresentationItem>());
|
||||
IfcSchema::IfcRepresentation::list::ptr reps (new IfcSchema::IfcRepresentation::list);
|
||||
IfcSchema::IfcRepresentationItem::list::ptr items (new IfcSchema::IfcRepresentationItem::list);
|
||||
IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation(context
|
||||
? context
|
||||
: getSingle<IfcSchema::IfcRepresentationContext>(), std::string("Body"), std::string("SweptSolid"), items);
|
||||
@@ -287,7 +287,7 @@ void IfcHierarchyHelper::addBox(IfcSchema::IfcShapeRepresentation* rep, double w
|
||||
|
||||
AddEntity(profile);
|
||||
AddEntity(solid);
|
||||
IfcSchema::IfcRepresentationItem::list items = rep->Items();
|
||||
IfcSchema::IfcRepresentationItem::list::ptr items = rep->Items();
|
||||
items->push(solid);
|
||||
rep->setItems(items);
|
||||
} else {
|
||||
@@ -304,8 +304,8 @@ void IfcHierarchyHelper::addBox(IfcSchema::IfcShapeRepresentation* rep, double w
|
||||
IfcSchema::IfcProductDefinitionShape* IfcHierarchyHelper::addBox(double w, double d, double h, IfcSchema::IfcAxis2Placement2D* place,
|
||||
IfcSchema::IfcAxis2Placement3D* place2, IfcSchema::IfcDirection* dir, IfcSchema::IfcRepresentationContext* context)
|
||||
{
|
||||
IfcSchema::IfcRepresentation::list reps (new IfcTemplatedEntityList<IfcSchema::IfcRepresentation>());
|
||||
IfcSchema::IfcRepresentationItem::list items (new IfcTemplatedEntityList<IfcSchema::IfcRepresentationItem>());
|
||||
IfcSchema::IfcRepresentation::list::ptr reps (new IfcSchema::IfcRepresentation::list);
|
||||
IfcSchema::IfcRepresentationItem::list::ptr items (new IfcSchema::IfcRepresentationItem::list);
|
||||
IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation(
|
||||
context ? context : getSingle<IfcSchema::IfcRepresentationContext>(), std::string("Body"), std::string("SweptSolid"), items);
|
||||
reps->push(rep);
|
||||
@@ -321,16 +321,16 @@ void IfcHierarchyHelper::clipRepresentation(IfcSchema::IfcProductRepresentation*
|
||||
{
|
||||
IfcSchema::IfcPlane* plane = new IfcSchema::IfcPlane(place);
|
||||
IfcSchema::IfcHalfSpaceSolid* half_space = new IfcSchema::IfcHalfSpaceSolid(plane, agree);
|
||||
IfcSchema::IfcRepresentation::list reps = shape->Representations();
|
||||
for (IfcSchema::IfcRepresentation::it j = reps->begin(); j != reps->end(); ++j) {
|
||||
IfcSchema::IfcRepresentation::list::ptr reps = shape->Representations();
|
||||
for (IfcSchema::IfcRepresentation::list::it j = reps->begin(); j != reps->end(); ++j) {
|
||||
IfcSchema::IfcRepresentation* rep = *j;
|
||||
if (rep->RepresentationIdentifier() != "Body") continue;
|
||||
rep->setRepresentationType("Clipping");
|
||||
IfcSchema::IfcRepresentationItem::list items = rep->Items();
|
||||
IfcSchema::IfcRepresentationItem::list new_items (new IfcTemplatedEntityList<IfcSchema::IfcRepresentationItem>());
|
||||
IfcSchema::IfcRepresentationItem::list::ptr items = rep->Items();
|
||||
IfcSchema::IfcRepresentationItem::list::ptr new_items (new IfcSchema::IfcRepresentationItem::list);
|
||||
AddEntity(plane);
|
||||
AddEntity(half_space);
|
||||
for (IfcSchema::IfcRepresentationItem::it i = items->begin(); i != items->end(); ++i) {
|
||||
for (IfcSchema::IfcRepresentationItem::list::it i = items->begin(); i != items->end(); ++i) {
|
||||
IfcSchema::IfcRepresentationItem* item = *i;
|
||||
IfcSchema::IfcBooleanClippingResult* clip = new IfcSchema::IfcBooleanClippingResult(
|
||||
IfcSchema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE, item, half_space);
|
||||
@@ -351,11 +351,11 @@ IfcSchema::IfcPresentationStyleAssignment* IfcHierarchyHelper::setSurfaceColour(
|
||||
: new IfcSchema::IfcSurfaceStyleRendering(colour, 1.0-a, boost::none, boost::none, boost::none, boost::none,
|
||||
boost::none, boost::none, IfcSchema::IfcReflectanceMethodEnum::IfcReflectanceMethod_FLAT);
|
||||
|
||||
IfcEntities styles(new IfcEntityList());
|
||||
IfcEntityList::ptr styles(new IfcEntityList());
|
||||
styles->push(rendering);
|
||||
IfcSchema::IfcSurfaceStyle* surface_style = new IfcSchema::IfcSurfaceStyle(
|
||||
boost::none, IfcSchema::IfcSurfaceSide::IfcSurfaceSide_BOTH, styles);
|
||||
IfcEntities surface_styles(new IfcEntityList());
|
||||
IfcEntityList::ptr surface_styles(new IfcEntityList());
|
||||
surface_styles->push(surface_style);
|
||||
IfcSchema::IfcPresentationStyleAssignment* style_assignment =
|
||||
new IfcSchema::IfcPresentationStyleAssignment(surface_styles);
|
||||
@@ -371,17 +371,17 @@ void IfcHierarchyHelper::setSurfaceColour(IfcSchema::IfcProductRepresentation* s
|
||||
IfcSchema::IfcPresentationStyleAssignment* style_assignment)
|
||||
{
|
||||
#ifdef USE_IFC4
|
||||
IfcEntities style_assignments (new IfcEntityList());
|
||||
IfcEntityList::ptr style_assignments (new IfcEntityList);
|
||||
#else
|
||||
IfcSchema::IfcPresentationStyleAssignment::list style_assignments (new IfcTemplatedEntityList<IfcSchema::IfcPresentationStyleAssignment>());
|
||||
IfcSchema::IfcPresentationStyleAssignment::list::ptr style_assignments (new IfcSchema::IfcPresentationStyleAssignment::list);
|
||||
#endif
|
||||
style_assignments->push(style_assignment);
|
||||
IfcSchema::IfcRepresentation::list reps = shape->Representations();
|
||||
for (IfcSchema::IfcRepresentation::it j = reps->begin(); j != reps->end(); ++j) {
|
||||
IfcSchema::IfcRepresentation::list::ptr reps = shape->Representations();
|
||||
for (IfcSchema::IfcRepresentation::list::it j = reps->begin(); j != reps->end(); ++j) {
|
||||
IfcSchema::IfcRepresentation* rep = *j;
|
||||
if (rep->RepresentationIdentifier() != "Body" && rep->RepresentationIdentifier() != "Facetation") continue;
|
||||
IfcSchema::IfcRepresentationItem::list items = rep->Items();
|
||||
for (IfcSchema::IfcRepresentationItem::it i = items->begin(); i != items->end(); ++i) {
|
||||
IfcSchema::IfcRepresentationItem::list::ptr items = rep->Items();
|
||||
for (IfcSchema::IfcRepresentationItem::list::it i = items->begin(); i != items->end(); ++i) {
|
||||
IfcSchema::IfcRepresentationItem* item = *i;
|
||||
IfcSchema::IfcStyledItem* styled_item = new IfcSchema::IfcStyledItem(item, style_assignments, boost::none);
|
||||
AddEntity(styled_item);
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
template <class T>
|
||||
T* getSingle() {
|
||||
typename T::list ts = EntitiesByType<T>();
|
||||
typename T::list::ptr ts = EntitiesByType<T>();
|
||||
if (ts->Size() != 1) return 0;
|
||||
return *ts->begin();
|
||||
}
|
||||
@@ -76,12 +76,12 @@ public:
|
||||
void addRelatedObject(IfcSchema::IfcObjectDefinition* related_object,
|
||||
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist = 0)
|
||||
{
|
||||
typename T::list li = EntitiesByType<T>();
|
||||
typename T::list::ptr li = EntitiesByType<T>();
|
||||
bool found = false;
|
||||
for (typename T::it i = li->begin(); i != li->end(); ++i) {
|
||||
for (typename T::list::it i = li->begin(); i != li->end(); ++i) {
|
||||
T* rel = *i;
|
||||
if (rel->RelatingObject() == relating_object) {
|
||||
IfcSchema::IfcObjectDefinition::list products = rel->RelatedObjects();
|
||||
IfcSchema::IfcObjectDefinition::list::ptr products = rel->RelatedObjects();
|
||||
products->push(related_object);
|
||||
rel->setRelatedObjects(products);
|
||||
found = true;
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
if (! owner_hist) {
|
||||
owner_hist = addOwnerHistory();
|
||||
}
|
||||
IfcSchema::IfcObjectDefinition::list relating_objects (new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
|
||||
IfcSchema::IfcObjectDefinition::list::ptr relating_objects (new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
|
||||
relating_objects->push(relating_object);
|
||||
T* t = new T(IfcWrite::IfcGuidHelper(), owner_hist, boost::none, boost::none, related_object, relating_objects);
|
||||
AddEntity(t);
|
||||
@@ -144,12 +144,12 @@ template <>
|
||||
inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSpatialStructure> (IfcSchema::IfcObjectDefinition* related_object,
|
||||
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist)
|
||||
{
|
||||
IfcSchema::IfcRelContainedInSpatialStructure::list li = EntitiesByType<IfcSchema::IfcRelContainedInSpatialStructure>();
|
||||
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr li = EntitiesByType<IfcSchema::IfcRelContainedInSpatialStructure>();
|
||||
bool found = false;
|
||||
for (IfcSchema::IfcRelContainedInSpatialStructure::it i = li->begin(); i != li->end(); ++i) {
|
||||
for (IfcSchema::IfcRelContainedInSpatialStructure::list::it i = li->begin(); i != li->end(); ++i) {
|
||||
IfcSchema::IfcRelContainedInSpatialStructure* rel = *i;
|
||||
if (rel->RelatingStructure() == relating_object) {
|
||||
IfcSchema::IfcProduct::list products = rel->RelatedElements();
|
||||
IfcSchema::IfcProduct::list::ptr products = rel->RelatedElements();
|
||||
products->push((IfcSchema::IfcProduct*)related_object);
|
||||
rel->setRelatedElements(products);
|
||||
found = true;
|
||||
@@ -163,7 +163,7 @@ inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSp
|
||||
if (! owner_hist) {
|
||||
owner_hist = addOwnerHistory();
|
||||
}
|
||||
IfcSchema::IfcProduct::list relating_objects (new IfcTemplatedEntityList<IfcSchema::IfcProduct>());
|
||||
IfcSchema::IfcProduct::list::ptr relating_objects (new IfcTemplatedEntityList<IfcSchema::IfcProduct>());
|
||||
relating_objects->push((IfcSchema::IfcProduct*)relating_object);
|
||||
IfcSchema::IfcRelContainedInSpatialStructure* t = new IfcSchema::IfcRelContainedInSpatialStructure(IfcWrite::IfcGuidHelper(), owner_hist,
|
||||
boost::none, boost::none, relating_objects, (IfcSchema::IfcSpatialStructureElement*)related_object);
|
||||
|
||||
+68
-55
@@ -415,7 +415,7 @@ ArgumentList::ArgumentList(Tokens* t, std::vector<unsigned int>& ids) {
|
||||
}
|
||||
}
|
||||
|
||||
void ArgumentList::Push(ArgumentPtr l) {
|
||||
void ArgumentList::Push(Argument* l) {
|
||||
list.push_back(l);
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ ArgumentList::operator double() const { throw IfcException("Argument is not a nu
|
||||
ArgumentList::operator std::string() const { throw IfcException("Argument is not a string"); }
|
||||
ArgumentList::operator std::vector<double>() const {
|
||||
std::vector<double> r;
|
||||
std::vector<ArgumentPtr>::const_iterator it;
|
||||
std::vector<Argument*>::const_iterator it;
|
||||
for ( it = list.begin(); it != list.end(); ++ it ) {
|
||||
r.push_back(**it);
|
||||
}
|
||||
@@ -436,7 +436,7 @@ ArgumentList::operator std::vector<double>() const {
|
||||
}
|
||||
ArgumentList::operator std::vector<int>() const {
|
||||
std::vector<int> r;
|
||||
std::vector<ArgumentPtr>::const_iterator it;
|
||||
std::vector<Argument*>::const_iterator it;
|
||||
for ( it = list.begin(); it != list.end(); ++ it ) {
|
||||
r.push_back(**it);
|
||||
}
|
||||
@@ -444,26 +444,39 @@ ArgumentList::operator std::vector<int>() const {
|
||||
}
|
||||
ArgumentList::operator std::vector<std::string>() const {
|
||||
std::vector<std::string> r;
|
||||
std::vector<ArgumentPtr>::const_iterator it;
|
||||
std::vector<Argument*>::const_iterator it;
|
||||
for ( it = list.begin(); it != list.end(); ++ it ) {
|
||||
r.push_back(**it);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
ArgumentList::operator IfcUtil::IfcSchemaEntity() const { throw IfcException("Argument is not an IFC type"); }
|
||||
ArgumentList::operator IfcUtil::IfcBaseClass*() const { throw IfcException("Argument is not an IFC type"); }
|
||||
//ArgumentList::operator IfcUtil::IfcAbstractSelect::ptr() const { throw IfcException("Argument is not an IFC type"); }
|
||||
ArgumentList::operator IfcEntities() const {
|
||||
IfcEntities l ( new IfcEntityList() );
|
||||
std::vector<ArgumentPtr>::const_iterator it;
|
||||
ArgumentList::operator IfcEntityList::ptr() const {
|
||||
IfcEntityList::ptr l ( new IfcEntityList() );
|
||||
std::vector<Argument*>::const_iterator it;
|
||||
for ( it = list.begin(); it != list.end(); ++ it ) {
|
||||
// FIXME: account for $
|
||||
const IfcUtil::IfcSchemaEntity entity = **it;
|
||||
IfcUtil::IfcBaseClass* entity = **it;
|
||||
l->push(entity);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
ArgumentList::operator IfcEntityListList::ptr() const {
|
||||
IfcEntityListList::ptr l ( new IfcEntityListList() );
|
||||
std::vector<Argument*>::const_iterator it;
|
||||
for ( it = list.begin(); it != list.end(); ++ it ) {
|
||||
const Argument* arg = *it;
|
||||
const ArgumentList* arg_list;
|
||||
if ((arg_list = dynamic_cast<const ArgumentList*>(arg))) {
|
||||
IfcEntityList::ptr e = *arg_list;
|
||||
l->push(e);
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
unsigned int ArgumentList::Size() const { return (unsigned int) list.size(); }
|
||||
ArgumentPtr ArgumentList::operator [] (unsigned int i) const {
|
||||
Argument* ArgumentList::operator [] (unsigned int i) const {
|
||||
if ( i >= list.size() )
|
||||
throw IfcException("Argument index out of range");
|
||||
return list[i];
|
||||
@@ -471,7 +484,7 @@ ArgumentPtr ArgumentList::operator [] (unsigned int i) const {
|
||||
std::string ArgumentList::toString(bool upper) const {
|
||||
std::stringstream ss;
|
||||
ss << "(";
|
||||
for( std::vector<ArgumentPtr>::const_iterator it = list.begin(); it != list.end(); it ++ ) {
|
||||
for( std::vector<Argument*>::const_iterator it = list.begin(); it != list.end(); it ++ ) {
|
||||
if ( it != list.begin() ) ss << ",";
|
||||
ss << (*it)->toString(upper);
|
||||
}
|
||||
@@ -480,7 +493,7 @@ std::string ArgumentList::toString(bool upper) const {
|
||||
}
|
||||
bool ArgumentList::isNull() const { return false; }
|
||||
ArgumentList::~ArgumentList() {
|
||||
for( std::vector<ArgumentPtr>::iterator it = list.begin(); it != list.end(); it ++ ) {
|
||||
for( std::vector<Argument*>::iterator it = list.begin(); it != list.end(); it ++ ) {
|
||||
delete (*it);
|
||||
}
|
||||
list.clear();
|
||||
@@ -496,10 +509,11 @@ TokenArgument::operator std::string() const { return TokenFunc::asString(token);
|
||||
TokenArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
|
||||
TokenArgument::operator std::vector<int>() const { throw IfcException("Argument is not a list of ints"); }
|
||||
TokenArgument::operator std::vector<std::string>() const { throw IfcException("Argument is not a list of strings"); }
|
||||
TokenArgument::operator IfcUtil::IfcSchemaEntity() const { return token.first->file->EntityById(TokenFunc::asInt(token)); }
|
||||
TokenArgument::operator IfcEntities() const { throw IfcException("Argument is not a list of entities"); }
|
||||
TokenArgument::operator IfcUtil::IfcBaseClass*() const { return token.first->file->EntityById(TokenFunc::asInt(token)); }
|
||||
TokenArgument::operator IfcEntityList::ptr() const { throw IfcException("Argument is not a list of entities"); }
|
||||
TokenArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of entity lists"); }
|
||||
unsigned int TokenArgument::Size() const { return 1; }
|
||||
ArgumentPtr TokenArgument::operator [] (unsigned int i) const { throw IfcException("Argument is not a list of arguments"); }
|
||||
Argument* TokenArgument::operator [] (unsigned int i) const { throw IfcException("Argument is not a list of arguments"); }
|
||||
std::string TokenArgument::toString(bool upper) const {
|
||||
if ( upper && TokenFunc::isString(token) ) {
|
||||
return IfcWrite::IfcCharacterEncoder(TokenFunc::asString(token));
|
||||
@@ -518,13 +532,14 @@ EntityArgument::operator std::string() const { throw IfcException("Argument is n
|
||||
EntityArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
|
||||
EntityArgument::operator std::vector<int>() const { throw IfcException("Argument is not a list of ints"); }
|
||||
EntityArgument::operator std::vector<std::string>() const { throw IfcException("Argument is not a list of strings"); }
|
||||
EntityArgument::operator IfcUtil::IfcSchemaEntity() const { return entity; }
|
||||
EntityArgument::operator IfcUtil::IfcBaseClass*() const { return entity; }
|
||||
//EntityArgument::operator IfcUtil::IfcAbstractSelect::ptr() const { return entity; }
|
||||
EntityArgument::operator IfcEntities() const { throw IfcException("Argument is not a list of entities"); }
|
||||
EntityArgument::operator IfcEntityList::ptr() const { throw IfcException("Argument is not a list of entities"); }
|
||||
EntityArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of entity lists"); }
|
||||
unsigned int EntityArgument::Size() const { return 1; }
|
||||
ArgumentPtr 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 {
|
||||
ArgumentPtr arg = entity->wrappedValue();
|
||||
Argument* arg = entity->wrappedValue();
|
||||
IfcParse::TokenArgument* token_arg = dynamic_cast<IfcParse::TokenArgument*>(arg);
|
||||
const bool is_string = TokenFunc::isString(token_arg->token);
|
||||
std::string token_string = token_arg ? (is_string
|
||||
@@ -548,13 +563,11 @@ EntityArgument::~EntityArgument() { delete entity; }
|
||||
//
|
||||
// Reads an Entity from the list of Tokens
|
||||
//
|
||||
Entity::Entity(unsigned int i, IfcFile* f) { //: file(f) {
|
||||
Entity::Entity(unsigned int i, IfcFile* f) : _id(i), args(0) {
|
||||
file = f;
|
||||
Token datatype = f->tokens->Next();
|
||||
if ( ! TokenFunc::isDatatype(datatype)) throw IfcException("Unexpected token while parsing entity");
|
||||
_type = IfcSchema::Type::FromString(TokenFunc::asString(datatype));
|
||||
_id = i;
|
||||
args = ArgumentPtr();
|
||||
offset = datatype.second;
|
||||
}
|
||||
|
||||
@@ -572,7 +585,7 @@ Entity::Entity(unsigned int i, IfcFile* f, unsigned int o) { // : file(f) {
|
||||
//
|
||||
// Access the Nth argument from the ArgumentList
|
||||
//
|
||||
ArgumentPtr Entity::getArgument(unsigned int i) {
|
||||
Argument* Entity::getArgument(unsigned int i) {
|
||||
if ( ! args ) {
|
||||
std::vector<unsigned int> ids;
|
||||
Load(ids, true);
|
||||
@@ -580,7 +593,7 @@ ArgumentPtr Entity::getArgument(unsigned int i) {
|
||||
return (*args)[i];
|
||||
}
|
||||
|
||||
unsigned int Entity::getArgumentCount() {
|
||||
unsigned int Entity::getArgumentCount() const {
|
||||
if ( ! args ) {
|
||||
std::vector<unsigned int> ids;
|
||||
Load(ids, true);
|
||||
@@ -591,7 +604,7 @@ unsigned int Entity::getArgumentCount() {
|
||||
//
|
||||
// Load the ArgumentList
|
||||
//
|
||||
void Entity::Load(std::vector<unsigned int>& ids, bool seek) {
|
||||
void Entity::Load(std::vector<unsigned int>& ids, bool seek) const {
|
||||
if ( seek ) {
|
||||
file->tokens->stream->Seek(offset);
|
||||
Token datatype = file->tokens->Next();
|
||||
@@ -612,7 +625,7 @@ IfcSchema::Type::Enum Entity::type() const {
|
||||
//
|
||||
// Returns the CamelCase string representation of the datatype as it is defined in the schema
|
||||
//
|
||||
std::string Entity::datatype() {
|
||||
std::string Entity::datatype() const {
|
||||
return IfcSchema::Type::ToString(_type);
|
||||
}
|
||||
|
||||
@@ -620,7 +633,7 @@ std::string Entity::datatype() {
|
||||
// Returns a string representation of the entity
|
||||
// Note that this initializes the entity if it is not initialized
|
||||
//
|
||||
std::string Entity::toString(bool upper) {
|
||||
std::string Entity::toString(bool upper) const {
|
||||
if ( ! args ) {
|
||||
std::vector<unsigned int> ids;
|
||||
Load(ids, true);
|
||||
@@ -641,9 +654,9 @@ Entity::~Entity() {
|
||||
//
|
||||
// Returns the entities of type c that have this entity in their ArgumentList
|
||||
//
|
||||
IfcEntities Entity::getInverse(IfcSchema::Type::Enum c) {
|
||||
IfcEntities l = IfcEntities(new IfcEntityList());
|
||||
IfcEntities all = file->EntitiesByReference(_id);
|
||||
IfcEntityList::ptr Entity::getInverse(IfcSchema::Type::Enum c) {
|
||||
IfcEntityList::ptr l = IfcEntityList::ptr(new IfcEntityList());
|
||||
IfcEntityList::ptr all = file->EntitiesByReference(_id);
|
||||
if ( ! all ) return l;
|
||||
for( IfcEntityList::it it = all->begin(); it != all->end();++ it ) {
|
||||
if ( c == IfcSchema::Type::ALL || (*it)->is(c) ) {
|
||||
@@ -652,9 +665,9 @@ IfcEntities Entity::getInverse(IfcSchema::Type::Enum c) {
|
||||
}
|
||||
return l;
|
||||
}
|
||||
IfcEntities Entity::getInverse(IfcSchema::Type::Enum c, int i, const std::string& a) {
|
||||
IfcEntities l = IfcEntities(new IfcEntityList());
|
||||
IfcEntities all = getInverse(c);
|
||||
IfcEntityList::ptr Entity::getInverse(IfcSchema::Type::Enum c, int i, const std::string& a) {
|
||||
IfcEntityList::ptr l = IfcEntityList::ptr(new IfcEntityList());
|
||||
IfcEntityList::ptr all = getInverse(c);
|
||||
for( IfcEntityList::it it = all->begin(); it != all->end();++ it ) {
|
||||
const std::string s = *(*it)->entity->getArgument(i);
|
||||
if ( s == a ) {
|
||||
@@ -702,8 +715,8 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* f) {
|
||||
unsigned int currentId = 0;
|
||||
lastId = 0;
|
||||
int x = 0;
|
||||
EntityPtr e;
|
||||
IfcUtil::IfcSchemaEntity entity = 0;
|
||||
Entity* e;
|
||||
IfcUtil::IfcBaseClass* entity = 0;
|
||||
Logger::Status("Scanning file...");
|
||||
while ( ! file->eof ) {
|
||||
if ( currentId ) {
|
||||
@@ -721,7 +734,7 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* f) {
|
||||
Logger::Status(ss.str(), false);
|
||||
}
|
||||
if ( entity->is(IfcSchema::Type::IfcRoot) ) {
|
||||
IfcSchema::IfcRoot::ptr ifc_root = (IfcSchema::IfcRoot::ptr) entity;
|
||||
IfcSchema::IfcRoot* ifc_root = (IfcSchema::IfcRoot*) entity;
|
||||
try {
|
||||
const std::string guid = ifc_root->GlobalId();
|
||||
if ( byguid.find(guid) != byguid.end() ) {
|
||||
@@ -736,9 +749,9 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* f) {
|
||||
}
|
||||
IfcSchema::Type::Enum ty = entity->type();
|
||||
do {
|
||||
IfcEntities L = EntitiesByType(ty);
|
||||
IfcEntityList::ptr L = EntitiesByType(ty);
|
||||
if ( L == 0 ) {
|
||||
L = IfcEntities(new IfcEntityList());
|
||||
L = IfcEntityList::ptr(new IfcEntityList());
|
||||
bytype[ty] = L;
|
||||
}
|
||||
L->push(entity);
|
||||
@@ -762,9 +775,9 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* f) {
|
||||
if ( TokenFunc::isOperator(token,'=') ) {
|
||||
currentId = id;
|
||||
} else if (entity) {
|
||||
IfcEntities L = EntitiesByReference(id);
|
||||
IfcEntityList::ptr L = EntitiesByReference(id);
|
||||
if ( L == 0 ) {
|
||||
L = IfcEntities(new IfcEntityList());
|
||||
L = IfcEntityList::ptr(new IfcEntityList());
|
||||
byref[id] = L;
|
||||
}
|
||||
L->push(entity);
|
||||
@@ -775,14 +788,14 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* f) {
|
||||
Logger::Status("\rDone scanning file ");
|
||||
return true;
|
||||
}
|
||||
void IfcFile::AddEntities(IfcEntities es) {
|
||||
void IfcFile::AddEntities(IfcEntityList::ptr es) {
|
||||
for( IfcEntityList::it i = es->begin(); i != es->end(); ++ i ) {
|
||||
AddEntity(*i);
|
||||
}
|
||||
}
|
||||
void IfcFile::AddEntity(IfcUtil::IfcSchemaEntity entity) {
|
||||
void IfcFile::AddEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
if ( entity->is(IfcSchema::Type::IfcRoot) ) {
|
||||
IfcSchema::IfcRoot::ptr ifc_root = (IfcSchema::IfcRoot::ptr) entity;
|
||||
IfcSchema::IfcRoot* ifc_root = (IfcSchema::IfcRoot*) entity;
|
||||
try {
|
||||
const std::string guid = ifc_root->GlobalId();
|
||||
if ( byguid.find(guid) != byguid.end() ) {
|
||||
@@ -797,9 +810,9 @@ void IfcFile::AddEntity(IfcUtil::IfcSchemaEntity entity) {
|
||||
}
|
||||
IfcSchema::Type::Enum ty = entity->type();
|
||||
do {
|
||||
IfcEntities L = EntitiesByType(ty);
|
||||
IfcEntityList::ptr L = EntitiesByType(ty);
|
||||
if ( L == 0 ) {
|
||||
L = IfcEntities(new IfcEntityList());
|
||||
L = IfcEntityList::ptr(new IfcEntityList());
|
||||
bytype[ty] = L;
|
||||
}
|
||||
L->push(entity);
|
||||
@@ -822,33 +835,33 @@ void IfcFile::AddEntity(IfcUtil::IfcSchemaEntity entity) {
|
||||
byid[new_id] = entity;
|
||||
|
||||
}
|
||||
IfcEntities IfcFile::EntitiesByType(IfcSchema::Type::Enum t) {
|
||||
IfcEntityList::ptr IfcFile::EntitiesByType(IfcSchema::Type::Enum t) {
|
||||
MapEntitiesByType::const_iterator it = bytype.find(t);
|
||||
return (it == bytype.end()) ? IfcEntities() : it->second;
|
||||
return (it == bytype.end()) ? IfcEntityList::ptr() : it->second;
|
||||
}
|
||||
IfcEntities IfcFile::EntitiesByType(const std::string& 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));
|
||||
}
|
||||
IfcEntities IfcFile::EntitiesByReference(int t) {
|
||||
IfcEntityList::ptr IfcFile::EntitiesByReference(int t) {
|
||||
MapEntitiesByRef::const_iterator it = byref.find(t);
|
||||
return (it == byref.end()) ? IfcEntities() : it->second;
|
||||
return (it == byref.end()) ? IfcEntityList::ptr() : it->second;
|
||||
}
|
||||
IfcUtil::IfcSchemaEntity IfcFile::EntityById(int id) {
|
||||
IfcUtil::IfcBaseClass* IfcFile::EntityById(int id) {
|
||||
MapEntityById::const_iterator it = byid.find(id);
|
||||
if ( it == byid.end() ) {
|
||||
MapOffsetById::const_iterator it2 = offsets.find(id);
|
||||
if ( it2 == offsets.end() ) throw IfcException("Entity not found");
|
||||
const unsigned int offset = (*it2).second;
|
||||
EntityPtr e = EntityPtr(new Entity(id,this,offset));
|
||||
IfcUtil::IfcSchemaEntity entity = IfcSchema::SchemaEntity(e);
|
||||
Entity* e = new Entity(id,this,offset);
|
||||
IfcUtil::IfcBaseClass* entity = IfcSchema::SchemaEntity(e);
|
||||
byid[id] = entity;
|
||||
return entity;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
IfcSchema::IfcRoot::ptr IfcFile::EntityByGuid(const std::string& guid) {
|
||||
IfcSchema::IfcRoot* IfcFile::EntityByGuid(const std::string& guid) {
|
||||
MapEntityByGuid::const_iterator it = byguid.find(guid);
|
||||
if ( it == byguid.end() ) {
|
||||
throw IfcException("Entity not found");
|
||||
@@ -900,7 +913,7 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
|
||||
os << "DATA;" << std::endl;
|
||||
|
||||
for ( MapEntityById::const_iterator it = f.begin(); it != f.end(); ++ it ) {
|
||||
const IfcEntity e = it->second;
|
||||
const IfcUtil::IfcBaseClass* e = it->second;
|
||||
os << e->entity->toString(true) << ";" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
+43
-45
@@ -52,12 +52,9 @@
|
||||
namespace IfcParse {
|
||||
|
||||
class Entity;
|
||||
class Entities;
|
||||
class IfcFile;
|
||||
typedef Entity* EntityPtr;
|
||||
typedef SHARED_PTR<Entities> EntitiesPtr;
|
||||
|
||||
class Tokens;
|
||||
|
||||
typedef std::pair<Tokens*,unsigned> Token;
|
||||
|
||||
/// Provides functions to convert Tokens to binary data
|
||||
@@ -118,8 +115,8 @@ namespace IfcParse {
|
||||
/// ==========
|
||||
class ArgumentList: public Argument {
|
||||
private:
|
||||
std::vector<ArgumentPtr> list;
|
||||
void Push(ArgumentPtr l);
|
||||
std::vector<Argument*> list;
|
||||
void Push(Argument* l);
|
||||
public:
|
||||
ArgumentList(Tokens* t, std::vector<unsigned int>& ids);
|
||||
~ArgumentList();
|
||||
@@ -130,11 +127,12 @@ namespace IfcParse {
|
||||
operator std::vector<double>() const;
|
||||
operator std::vector<int>() const;
|
||||
operator std::vector<std::string>() const;
|
||||
operator IfcUtil::IfcSchemaEntity() const;
|
||||
operator IfcUtil::IfcBaseClass*() const;
|
||||
//operator IfcUtil::IfcAbstractSelect::ptr() const;
|
||||
operator IfcEntities() const;
|
||||
operator IfcEntityList::ptr() const;
|
||||
operator IfcEntityListList::ptr() const;
|
||||
unsigned int Size() const;
|
||||
ArgumentPtr operator [] (unsigned int i) const;
|
||||
Argument* operator [] (unsigned int i) const;
|
||||
std::string toString(bool upper=false) const;
|
||||
bool isNull() const;
|
||||
};
|
||||
@@ -155,11 +153,12 @@ namespace IfcParse {
|
||||
operator std::vector<double>() const;
|
||||
operator std::vector<int>() const;
|
||||
operator std::vector<std::string>() const;
|
||||
operator IfcUtil::IfcSchemaEntity() const;
|
||||
operator IfcUtil::IfcBaseClass*() const;
|
||||
//operator IfcUtil::IfcAbstractSelect::ptr() const;
|
||||
operator IfcEntities() const;
|
||||
operator IfcEntityList::ptr() const;
|
||||
operator IfcEntityListList::ptr() const;
|
||||
unsigned int Size() const;
|
||||
ArgumentPtr operator [] (unsigned int i) const;
|
||||
Argument* operator [] (unsigned int i) const;
|
||||
std::string toString(bool upper=false) const;
|
||||
bool isNull() const;
|
||||
};
|
||||
@@ -180,11 +179,12 @@ namespace IfcParse {
|
||||
operator std::vector<double>() const;
|
||||
operator std::vector<int>() const;
|
||||
operator std::vector<std::string>() const;
|
||||
operator IfcUtil::IfcSchemaEntity() const;
|
||||
operator IfcUtil::IfcBaseClass*() const;
|
||||
//operator IfcUtil::IfcAbstractSelect::ptr() const;
|
||||
operator IfcEntities() const;
|
||||
operator IfcEntityList::ptr() const;
|
||||
operator IfcEntityListList::ptr() const;
|
||||
unsigned int Size() const;
|
||||
ArgumentPtr operator [] (unsigned int i) const;
|
||||
Argument* operator [] (unsigned int i) const;
|
||||
std::string toString(bool upper=false) const;
|
||||
bool isNull() const;
|
||||
};
|
||||
@@ -194,9 +194,8 @@ namespace IfcParse {
|
||||
/// ============================
|
||||
class Entity : public IfcAbstractEntity {
|
||||
private:
|
||||
//IfcFile* file;
|
||||
ArgumentPtr args;
|
||||
IfcSchema::Type::Enum _type;
|
||||
mutable Argument* args;
|
||||
mutable IfcSchema::Type::Enum _type;
|
||||
public:
|
||||
/// The EXPRESS ENTITY_INSTANCE_NAME
|
||||
unsigned int _id;
|
||||
@@ -205,26 +204,24 @@ namespace IfcParse {
|
||||
Entity(unsigned int i, IfcFile* t);
|
||||
Entity(unsigned int i, IfcFile* t, unsigned int o);
|
||||
~Entity();
|
||||
IfcEntities getInverse(IfcSchema::Type::Enum c = IfcSchema::Type::ALL);
|
||||
IfcEntities getInverse(IfcSchema::Type::Enum c, int i, const std::string& a);
|
||||
void Load(std::vector<unsigned int>& ids, bool seek=false);
|
||||
ArgumentPtr getArgument (unsigned int i);
|
||||
unsigned int getArgumentCount();
|
||||
std::string toString(bool upper=false);
|
||||
std::string datatype();
|
||||
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum c = IfcSchema::Type::ALL);
|
||||
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum c, int i, const std::string& a);
|
||||
void Load(std::vector<unsigned int>& ids, bool seek=false) const;
|
||||
Argument* getArgument (unsigned int i);
|
||||
unsigned int getArgumentCount() const;
|
||||
std::string toString(bool upper=false) const;
|
||||
std::string datatype() const;
|
||||
IfcSchema::Type::Enum type() const;
|
||||
bool is(IfcSchema::Type::Enum v) const;
|
||||
unsigned int id();
|
||||
bool isWritable();
|
||||
};
|
||||
|
||||
typedef IfcUtil::IfcSchemaEntity IfcEntity;
|
||||
//typedef IfcEntities IfcEntities;
|
||||
typedef std::map<IfcSchema::Type::Enum,IfcEntities> MapEntitiesByType;
|
||||
typedef std::map<unsigned int,IfcEntity> MapEntityById;
|
||||
typedef std::map<std::string,IfcSchema::IfcRoot::ptr> MapEntityByGuid;
|
||||
typedef std::map<unsigned int,IfcEntities> MapEntitiesByRef;
|
||||
typedef std::map<unsigned int,unsigned int> MapOffsetById;
|
||||
typedef std::map<IfcSchema::Type::Enum, IfcEntityList::ptr> MapEntitiesByType;
|
||||
typedef std::map<unsigned int, IfcUtil::IfcBaseClass*> MapEntityById;
|
||||
typedef std::map<std::string, IfcSchema::IfcRoot*> MapEntityByGuid;
|
||||
typedef std::map<unsigned int, IfcEntityList::ptr> MapEntitiesByRef;
|
||||
typedef std::map<unsigned int, unsigned int> MapOffsetById;
|
||||
|
||||
/// This class provides several static convenience functions and variables
|
||||
/// and provide access to the entities in an IFC file
|
||||
@@ -257,36 +254,37 @@ public:
|
||||
/// NOTE: This also returns subtypes of the requested type, for example:
|
||||
/// IfcWall will also return IfcWallStandardCase entities
|
||||
template <class T>
|
||||
typename T::list EntitiesByType() {
|
||||
IfcEntities e = EntitiesByType(T::Class());
|
||||
typename T::list l ( new IfcTemplatedEntityList<T>() );
|
||||
if ( e && e->Size() )
|
||||
typename T::list::ptr EntitiesByType() {
|
||||
IfcEntityList::ptr e = EntitiesByType(T::Class());
|
||||
typename T::list::ptr l(new typename T::list);
|
||||
if (e && e->Size()) {
|
||||
for ( IfcEntityList::it it = e->begin(); it != e->end(); ++ it ) {
|
||||
l->push(reinterpret_pointer_cast<IfcUtil::IfcBaseClass,T>(*it));
|
||||
l->push((T*)*it);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
/// Returns all entities in the file that match the positional argument.
|
||||
/// NOTE: This also returns subtypes of the requested type, for example:
|
||||
/// IfcWall will also return IfcWallStandardCase entities
|
||||
IfcEntities EntitiesByType(IfcSchema::Type::Enum t);
|
||||
IfcEntityList::ptr EntitiesByType(IfcSchema::Type::Enum t);
|
||||
/// Returns all entities in the file that match the positional argument.
|
||||
/// NOTE: This also returns subtypes of the requested type, for example:
|
||||
/// IfcWall will also return IfcWallStandardCase entities
|
||||
IfcEntities EntitiesByType(const std::string& t);
|
||||
IfcEntityList::ptr EntitiesByType(const std::string& t);
|
||||
/// Returns all entities in the file that reference the id
|
||||
IfcEntities EntitiesByReference(int id);
|
||||
IfcEntityList::ptr EntitiesByReference(int id);
|
||||
/// Returns the entity with the specified id
|
||||
IfcEntity EntityById(int id);
|
||||
IfcUtil::IfcBaseClass* EntityById(int id);
|
||||
/// Returns the entity with the specified GlobalId
|
||||
IfcSchema::IfcRoot::ptr EntityByGuid(const std::string& guid);
|
||||
IfcSchema::IfcRoot* EntityByGuid(const std::string& guid);
|
||||
bool Init(const std::string& fn);
|
||||
bool Init(std::istream& fn, int len);
|
||||
bool Init(void* data, int len);
|
||||
bool Init(IfcParse::IfcSpfStream* f);
|
||||
unsigned int FreshId() { MaxId ++; return MaxId; }
|
||||
void AddEntity(IfcUtil::IfcSchemaEntity e);
|
||||
void AddEntities(IfcEntities es);
|
||||
void AddEntity(IfcUtil::IfcBaseClass* entity);
|
||||
void AddEntities(IfcEntityList::ptr es);
|
||||
|
||||
void filename(const std::string& s);
|
||||
std::string filename() const;
|
||||
|
||||
+12
-12
@@ -20,10 +20,10 @@
|
||||
#include "IfcUtil.h"
|
||||
#include <iostream>
|
||||
|
||||
void IfcEntityList::push(IfcUtil::IfcSchemaEntity l) {
|
||||
void IfcEntityList::push(IfcUtil::IfcBaseClass* l) {
|
||||
if ( l ) ls.push_back(l);
|
||||
}
|
||||
void IfcEntityList::push(IfcEntities l) {
|
||||
void IfcEntityList::push(const IfcEntityList::ptr& l) {
|
||||
for( it i = l->begin(); i != l->end(); ++i ) {
|
||||
if ( *i ) ls.push_back(*i);
|
||||
}
|
||||
@@ -31,18 +31,18 @@ void IfcEntityList::push(IfcEntities l) {
|
||||
int IfcEntityList::Size() const { return (unsigned int) ls.size(); }
|
||||
IfcEntityList::it IfcEntityList::begin() { return ls.begin(); }
|
||||
IfcEntityList::it IfcEntityList::end() { return ls.end(); }
|
||||
IfcUtil::IfcSchemaEntity IfcEntityList::operator[] (int i) {
|
||||
IfcUtil::IfcBaseClass* IfcEntityList::operator[] (int i) {
|
||||
return ls[i];
|
||||
}
|
||||
IfcEntities IfcEntityList::getInverse(IfcSchema::Type::Enum c) {
|
||||
IfcEntities l = IfcEntities(new IfcEntityList());
|
||||
IfcEntityList::ptr IfcEntityList::getInverse(IfcSchema::Type::Enum c) {
|
||||
IfcEntityList::ptr l = IfcEntityList::ptr(new IfcEntityList());
|
||||
for( it i = begin(); i != end(); ++i ) {
|
||||
l->push((*i)->entity->getInverse(c));
|
||||
}
|
||||
return l;
|
||||
}
|
||||
IfcEntities IfcEntityList::getInverse(IfcSchema::Type::Enum c, int ar, const std::string& a) {
|
||||
IfcEntities l = IfcEntities(new IfcEntityList());
|
||||
IfcEntityList::ptr IfcEntityList::getInverse(IfcSchema::Type::Enum c, int ar, const std::string& a) {
|
||||
IfcEntityList::ptr l = IfcEntityList::ptr(new IfcEntityList());
|
||||
for( it i = begin(); i != end(); ++i ) {
|
||||
l->push((*i)->entity->getInverse(c,ar,a));
|
||||
}
|
||||
@@ -51,15 +51,15 @@ IfcEntities IfcEntityList::getInverse(IfcSchema::Type::Enum c, int ar, const std
|
||||
|
||||
bool IfcUtil::IfcEntitySelect::is(IfcSchema::Type::Enum v) const { return entity->is(v); }
|
||||
IfcSchema::Type::Enum IfcUtil::IfcEntitySelect::type() const { return entity->type(); }
|
||||
IfcUtil::IfcEntitySelect::IfcEntitySelect(IfcSchemaEntity b) { entity = b->entity; }
|
||||
IfcUtil::IfcEntitySelect::IfcEntitySelect(IfcAbstractEntityPtr e) { entity = e; }
|
||||
IfcUtil::IfcEntitySelect::IfcEntitySelect(IfcBaseClass* b) { entity = b->entity; }
|
||||
IfcUtil::IfcEntitySelect::IfcEntitySelect(IfcAbstractEntity* e) { entity = e; }
|
||||
bool IfcUtil::IfcEntitySelect::isSimpleType() { return false; }
|
||||
IfcUtil::IfcEntitySelect::~IfcEntitySelect() { delete entity; }
|
||||
|
||||
bool IfcUtil::IfcArgumentSelect::is(IfcSchema::Type::Enum v) const { return _type == v; }
|
||||
IfcSchema::Type::Enum IfcUtil::IfcArgumentSelect::type() const { return _type; }
|
||||
IfcUtil::IfcArgumentSelect::IfcArgumentSelect(IfcSchema::Type::Enum t, ArgumentPtr a) { _type = t; arg = a; }
|
||||
ArgumentPtr IfcUtil::IfcArgumentSelect::wrappedValue() { return arg; }
|
||||
IfcUtil::IfcArgumentSelect::IfcArgumentSelect(IfcSchema::Type::Enum t, Argument* a) { _type = t; arg = a; }
|
||||
Argument* IfcUtil::IfcArgumentSelect::wrappedValue() { return arg; }
|
||||
bool IfcUtil::IfcArgumentSelect::isSimpleType() { return true; }
|
||||
IfcUtil::IfcArgumentSelect::~IfcArgumentSelect() { delete arg; }
|
||||
|
||||
@@ -70,7 +70,7 @@ void Logger::SetOutput(std::ostream* l1, std::ostream* l2) {
|
||||
log2 = &log_stream;
|
||||
}
|
||||
}
|
||||
void Logger::Message(Logger::Severity type, const std::string& message, const IfcAbstractEntityPtr entity) {
|
||||
void Logger::Message(Logger::Severity type, const std::string& message, IfcAbstractEntity* entity) {
|
||||
if ( log2 && type >= verbosity ) {
|
||||
(*log2) << "[" << severity_strings[type] << "] " << message << std::endl;
|
||||
if ( entity ) (*log2) << entity->toString() << std::endl;
|
||||
|
||||
+113
-69
@@ -32,71 +32,51 @@
|
||||
#include "../ifcparse/Ifc2x3enum.h"
|
||||
#endif
|
||||
|
||||
class IfcAbstractEntity;
|
||||
//typedef SHARED_PTR<IfcAbstractEntity> IfcAbstractEntityPtr;
|
||||
typedef IfcAbstractEntity* IfcAbstractEntityPtr;
|
||||
|
||||
class IfcEntityList;
|
||||
typedef SHARED_PTR<IfcEntityList> IfcEntities;
|
||||
|
||||
class Argument;
|
||||
//typedef SHARED_PTR<Argument> ArgumentPtr;
|
||||
typedef Argument* ArgumentPtr;
|
||||
|
||||
|
||||
template <class F, class T>
|
||||
inline T* reinterpret_pointer_cast(F* from) {
|
||||
return (T*)from;
|
||||
//SHARED_PTR<void> v = std::tr1::static_pointer_cast<void,F>(from);
|
||||
//return std::tr1::static_pointer_cast<T,void>(v);
|
||||
}
|
||||
class IfcEntityList;
|
||||
class IfcEntityListList;
|
||||
class IfcAbstractEntity;
|
||||
|
||||
namespace IfcUtil {
|
||||
enum ArgumentType {
|
||||
Argument_INT, Argument_BOOL, Argument_DOUBLE, Argument_STRING, Argument_VECTOR_INT, Argument_VECTOR_DOUBLE, Argument_VECTOR_STRING, Argument_ENTITY, Argument_ENTITY_LIST, Argument_ENTITY_LIST_LIST, Argument_ENUMERATION, Argument_UNKNOWN
|
||||
};
|
||||
}
|
||||
|
||||
namespace IfcUtil {
|
||||
|
||||
class IfcBaseClass {
|
||||
public:
|
||||
IfcAbstractEntityPtr entity;
|
||||
virtual bool is(IfcSchema::Type::Enum v) const = 0;
|
||||
virtual IfcSchema::Type::Enum type() const = 0;
|
||||
};
|
||||
|
||||
class IfcBaseEntity : public IfcBaseClass {
|
||||
public:
|
||||
virtual unsigned int getArgumentCount() const = 0;
|
||||
virtual ArgumentType getArgumentType(unsigned int i) const = 0;
|
||||
virtual ArgumentPtr getArgument(unsigned int i) const = 0;
|
||||
virtual const char* getArgumentName(unsigned int i) const = 0;
|
||||
};
|
||||
|
||||
//typedef SHARED_PTR<IfcBaseClass> IfcSchemaEntity;
|
||||
typedef IfcBaseClass* IfcSchemaEntity;
|
||||
class IfcBaseClass {
|
||||
public:
|
||||
IfcAbstractEntity* entity;
|
||||
virtual bool is(IfcSchema::Type::Enum v) const = 0;
|
||||
virtual IfcSchema::Type::Enum type() const = 0;
|
||||
};
|
||||
|
||||
class IfcBaseEntity : public IfcBaseClass {
|
||||
public:
|
||||
virtual unsigned int getArgumentCount() const = 0;
|
||||
virtual ArgumentType getArgumentType(unsigned int i) const = 0;
|
||||
virtual Argument* getArgument(unsigned int i) const = 0;
|
||||
virtual const char* getArgumentName(unsigned int i) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
template <class T>
|
||||
class IfcTemplatedEntityList;
|
||||
|
||||
class IfcEntityList {
|
||||
std::vector<IfcUtil::IfcSchemaEntity> ls;
|
||||
std::vector<IfcUtil::IfcBaseClass*> ls;
|
||||
public:
|
||||
typedef std::vector<IfcUtil::IfcSchemaEntity>::const_iterator it;
|
||||
IfcEntities getInverse(IfcSchema::Type::Enum c = IfcSchema::Type::ALL);
|
||||
IfcEntities getInverse(IfcSchema::Type::Enum c, int i, const std::string& a);
|
||||
void push(IfcUtil::IfcSchemaEntity l);
|
||||
void push(IfcEntities l);
|
||||
typedef SHARED_PTR<IfcEntityList> ptr;
|
||||
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator it;
|
||||
ptr getInverse(IfcSchema::Type::Enum c = IfcSchema::Type::ALL);
|
||||
ptr getInverse(IfcSchema::Type::Enum c, int i, const std::string& a);
|
||||
void push(IfcUtil::IfcBaseClass* l);
|
||||
void push(const ptr& l);
|
||||
it begin();
|
||||
it end();
|
||||
IfcUtil::IfcSchemaEntity operator[] (int i);
|
||||
IfcUtil::IfcBaseClass* operator[] (int i);
|
||||
int Size() const;
|
||||
template <class U>
|
||||
typename U::list as() {
|
||||
typename U::list r(new IfcTemplatedEntityList<U>());
|
||||
typename U::list::ptr as() {
|
||||
typename U::list::ptr r(new typename U::list);
|
||||
for ( it i = begin(); i != end(); ++ i ) if ((*i)->is(U::Class())) r->push((U*)*i);
|
||||
return r;
|
||||
}
|
||||
@@ -106,38 +86,101 @@ template <class T>
|
||||
class IfcTemplatedEntityList {
|
||||
std::vector<T*> ls;
|
||||
public:
|
||||
typedef SHARED_PTR< IfcTemplatedEntityList<T> > ptr;
|
||||
typedef typename std::vector<T*>::const_iterator it;
|
||||
inline void push(T* t) {if (t) ls.push_back(t);}
|
||||
inline void push(SHARED_PTR< IfcTemplatedEntityList<T> > t) { for ( typename T::it it = t->begin(); it != t->end(); ++it ) push(*it); }
|
||||
inline void push(ptr t) { for ( typename T::list::it it = t->begin(); it != t->end(); ++it ) push(*it); }
|
||||
inline it begin() { return ls.begin(); }
|
||||
inline it end() { return ls.end(); }
|
||||
inline unsigned int Size() const { return (unsigned int) ls.size(); }
|
||||
IfcEntities generalize() {
|
||||
IfcEntities r (new IfcEntityList());
|
||||
IfcEntityList::ptr generalize() {
|
||||
IfcEntityList::ptr r (new IfcEntityList());
|
||||
for ( it i = begin(); i != end(); ++ i ) r->push(*i);
|
||||
return r;
|
||||
}
|
||||
template <class U>
|
||||
typename U::list as() {
|
||||
typename U::list r(new IfcTemplatedEntityList<U>());
|
||||
typename U::list::ptr as() {
|
||||
typename U::list::ptr r(new typename U::list);
|
||||
for ( it i = begin(); i != end(); ++ i ) if ((*i)->is(U::Class())) r->push(*i);
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class IfcTemplatedEntityListList;
|
||||
|
||||
class IfcEntityListList {
|
||||
std::vector< std::vector<IfcUtil::IfcBaseClass*> > ls;
|
||||
public:
|
||||
typedef 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) {
|
||||
ls.push_back(l);
|
||||
}
|
||||
void push(const IfcEntityList::ptr& l) {
|
||||
std::vector<IfcUtil::IfcBaseClass*> li;
|
||||
for (std::vector<IfcUtil::IfcBaseClass*>::const_iterator jt = l->begin(); jt != l->end(); ++jt) {
|
||||
li.push_back(*jt);
|
||||
}
|
||||
push(li);
|
||||
}
|
||||
outer_it begin() { return ls.begin(); }
|
||||
outer_it end() { return ls.end(); }
|
||||
int Size() const { return ls.size(); }
|
||||
template <class U>
|
||||
typename IfcTemplatedEntityListList<U>::ptr as() {
|
||||
typename IfcTemplatedEntityListList<U>::ptr r(new IfcTemplatedEntityListList<U>);
|
||||
const bool all = U::Class() == IfcSchema::Type::ALL;
|
||||
for (outer_it outer = begin(); outer != end(); ++ outer) {
|
||||
const std::vector<IfcUtil::IfcBaseClass*>& from = *outer;
|
||||
typename std::vector<U*> to;
|
||||
for (inner_it inner = from.begin(); inner != from.end(); ++ inner) {
|
||||
if (all || (*inner)->is(U::Class())) to.push_back((U*)*inner);
|
||||
}
|
||||
r->push(to);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class IfcTemplatedEntityListList {
|
||||
std::vector< std::vector<T*> > ls;
|
||||
public:
|
||||
typedef typename 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(); }
|
||||
unsigned int Size() const { return (unsigned int) ls.size(); }
|
||||
IfcEntityListList::ptr generalize() {
|
||||
IfcEntityListList::ptr r (new IfcEntityListList());
|
||||
for (outer_it outer = begin(); outer != end(); ++ outer) {
|
||||
const std::vector<T*>& from = *outer;
|
||||
std::vector<IfcUtil::IfcBaseClass*> to;
|
||||
for (inner_it inner = from.begin(); inner != from.end(); ++ inner) {
|
||||
to.push_back(*inner);
|
||||
}
|
||||
r->push(to);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
namespace IfcUtil {
|
||||
class IfcAbstractSelect : public IfcBaseClass {
|
||||
public:
|
||||
typedef SHARED_PTR< IfcTemplatedEntityList<IfcAbstractSelect> > list;
|
||||
typedef IfcTemplatedEntityList<IfcAbstractSelect>::it it;
|
||||
typedef IfcAbstractSelect* ptr;
|
||||
typedef IfcTemplatedEntityList<IfcAbstractSelect> list;
|
||||
virtual bool isSimpleType() = 0;
|
||||
static IfcSchema::Type::Enum Class() { return IfcSchema::Type::ALL; }
|
||||
};
|
||||
class IfcEntitySelect : public IfcAbstractSelect {
|
||||
public:
|
||||
typedef IfcEntitySelect* ptr;
|
||||
IfcEntitySelect(IfcSchemaEntity b);
|
||||
IfcEntitySelect(IfcAbstractEntityPtr e);
|
||||
IfcEntitySelect(IfcBaseClass* b);
|
||||
IfcEntitySelect(IfcAbstractEntity* e);
|
||||
~IfcEntitySelect();
|
||||
bool is(IfcSchema::Type::Enum v) const;
|
||||
IfcSchema::Type::Enum type() const;
|
||||
@@ -145,12 +188,12 @@ namespace IfcUtil {
|
||||
};
|
||||
class IfcArgumentSelect : public IfcAbstractSelect {
|
||||
IfcSchema::Type::Enum _type;
|
||||
ArgumentPtr arg;
|
||||
Argument* arg;
|
||||
public:
|
||||
typedef IfcArgumentSelect* ptr;
|
||||
IfcArgumentSelect(IfcSchema::Type::Enum t, ArgumentPtr a);
|
||||
IfcArgumentSelect(IfcSchema::Type::Enum t, Argument* a);
|
||||
~IfcArgumentSelect();
|
||||
ArgumentPtr wrappedValue();
|
||||
Argument* wrappedValue();
|
||||
bool is(IfcSchema::Type::Enum v) const;
|
||||
IfcSchema::Type::Enum type() const;
|
||||
bool isSimpleType();
|
||||
@@ -172,11 +215,12 @@ public:
|
||||
virtual operator std::vector<double>() const = 0;
|
||||
virtual operator std::vector<int>() const = 0;
|
||||
virtual operator std::vector<std::string>() const = 0;
|
||||
virtual operator IfcUtil::IfcSchemaEntity() const = 0;
|
||||
virtual operator IfcUtil::IfcBaseClass*() const = 0;
|
||||
//virtual operator IfcUtil::IfcAbstractSelect::ptr() const = 0;
|
||||
virtual operator IfcEntities() const = 0;
|
||||
virtual operator IfcEntityList::ptr() const = 0;
|
||||
virtual operator IfcEntityListList::ptr() const = 0;
|
||||
virtual unsigned int Size() const = 0;
|
||||
virtual ArgumentPtr operator [] (unsigned int i) const = 0;
|
||||
virtual Argument* operator [] (unsigned int i) const = 0;
|
||||
virtual std::string toString(bool upper=false) const = 0;
|
||||
virtual bool isNull() const = 0;
|
||||
virtual ~Argument() {};
|
||||
@@ -185,15 +229,15 @@ public:
|
||||
class IfcAbstractEntity {
|
||||
public:
|
||||
IfcParse::IfcFile* file;
|
||||
virtual IfcEntities getInverse(IfcSchema::Type::Enum c = IfcSchema::Type::ALL) = 0;
|
||||
virtual IfcEntities getInverse(IfcSchema::Type::Enum c, int i, const std::string& a) = 0;
|
||||
virtual std::string datatype() = 0;
|
||||
virtual ArgumentPtr getArgument (unsigned int i) = 0;
|
||||
virtual unsigned int getArgumentCount() = 0;
|
||||
virtual IfcEntityList::ptr getInverse(IfcSchema::Type::Enum c = IfcSchema::Type::ALL) = 0;
|
||||
virtual IfcEntityList::ptr getInverse(IfcSchema::Type::Enum c, int i, const std::string& a) = 0;
|
||||
virtual std::string datatype() const = 0;
|
||||
virtual Argument* getArgument (unsigned int i) = 0;
|
||||
virtual unsigned int getArgumentCount() const = 0;
|
||||
virtual ~IfcAbstractEntity() {};
|
||||
virtual IfcSchema::Type::Enum type() const = 0;
|
||||
virtual bool is(IfcSchema::Type::Enum v) const = 0;
|
||||
virtual std::string toString(bool upper=false) = 0;
|
||||
virtual std::string toString(bool upper=false) const = 0;
|
||||
virtual unsigned int id() = 0;
|
||||
virtual bool isWritable() = 0;
|
||||
};
|
||||
@@ -214,7 +258,7 @@ public:
|
||||
static void Verbosity(Severity v);
|
||||
static Severity Verbosity();
|
||||
/// Log a message to the output stream
|
||||
static void Message(Severity type, const std::string& message, const IfcAbstractEntityPtr entity=0);
|
||||
static void Message(Severity type, const std::string& message, IfcAbstractEntity* entity=0);
|
||||
static void Status(const std::string& message, bool new_line=true);
|
||||
static void ProgressBar(int progress);
|
||||
static std::string GetLog();
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace IfcWrite {
|
||||
class IfcWritableEntity : public IfcAbstractEntity {
|
||||
private:
|
||||
std::map<int,bool> writemask;
|
||||
std::map<int,ArgumentPtr> args;
|
||||
std::map<int,Argument*> args;
|
||||
IfcSchema::Type::Enum _type;
|
||||
int* _id;
|
||||
bool arg_writable(int i);
|
||||
@@ -50,14 +50,14 @@ namespace IfcWrite {
|
||||
~IfcWritableEntity();
|
||||
int setId(int i=-1);
|
||||
IfcWritableEntity(IfcAbstractEntity* e);
|
||||
IfcEntities getInverse(IfcSchema::Type::Enum c = IfcSchema::Type::ALL);
|
||||
IfcEntities getInverse(IfcSchema::Type::Enum c, int i, const std::string& a);
|
||||
std::string datatype();
|
||||
ArgumentPtr getArgument (unsigned int i);
|
||||
unsigned int getArgumentCount();
|
||||
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum c = IfcSchema::Type::ALL);
|
||||
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum c, int i, const std::string& a);
|
||||
std::string datatype() const;
|
||||
Argument* getArgument (unsigned int i);
|
||||
unsigned int getArgumentCount() const;
|
||||
IfcSchema::Type::Enum type() const;
|
||||
bool is(IfcSchema::Type::Enum v) const;
|
||||
std::string toString(bool upper=false);
|
||||
std::string toString(bool upper=false) const;
|
||||
unsigned int id();
|
||||
bool isWritable();
|
||||
void setArgument(int i);
|
||||
@@ -67,8 +67,9 @@ namespace IfcWrite {
|
||||
void setArgument(int i,int v, const char* c);
|
||||
void setArgument(int i,const std::string& v);
|
||||
void setArgument(int i,double v);
|
||||
void setArgument(int i,IfcUtil::IfcSchemaEntity v);
|
||||
void setArgument(int i,IfcEntities v);
|
||||
void setArgument(int i,IfcUtil::IfcBaseClass* v);
|
||||
void setArgument(int i,IfcEntityList::ptr v);
|
||||
void setArgument(int i,IfcEntityListList::ptr v);
|
||||
void setArgument(int i,const std::vector<double>& v);
|
||||
void setArgument(int i,const std::vector<std::string>& v);
|
||||
void setArgument(int i,const std::vector<int>& v);
|
||||
|
||||
+52
-31
@@ -49,10 +49,10 @@ IfcWritableEntity::IfcWritableEntity(IfcAbstractEntity* e)
|
||||
}
|
||||
}
|
||||
// TODO: Reove redundancy with IfcParse::Entity
|
||||
IfcEntities IfcWritableEntity::getInverse(IfcSchema::Type::Enum c) {
|
||||
IfcEntities l = IfcEntities(new IfcEntityList());
|
||||
IfcEntityList::ptr IfcWritableEntity::getInverse(IfcSchema::Type::Enum c) {
|
||||
IfcEntityList::ptr l = IfcEntityList::ptr(new IfcEntityList);
|
||||
int id = _id ? *_id : setId();
|
||||
IfcEntities all = file->EntitiesByReference(id);
|
||||
IfcEntityList::ptr all = file->EntitiesByReference(id);
|
||||
if ( ! all ) return l;
|
||||
for( IfcEntityList::it it = all->begin(); it != all->end();++ it ) {
|
||||
if ( c == IfcSchema::Type::ALL || (*it)->is(c) ) {
|
||||
@@ -61,9 +61,9 @@ IfcEntities IfcWritableEntity::getInverse(IfcSchema::Type::Enum c) {
|
||||
}
|
||||
return l;
|
||||
}
|
||||
IfcEntities IfcWritableEntity::getInverse(IfcSchema::Type::Enum c, int i, const std::string& a) {
|
||||
IfcEntities l = IfcEntities(new IfcEntityList());
|
||||
IfcEntities all = getInverse(c);
|
||||
IfcEntityList::ptr IfcWritableEntity::getInverse(IfcSchema::Type::Enum c, int i, const std::string& a) {
|
||||
IfcEntityList::ptr l = IfcEntityList::ptr(new IfcEntityList);
|
||||
IfcEntityList::ptr all = getInverse(c);
|
||||
for( IfcEntityList::it it = all->begin(); it != all->end();++ it ) {
|
||||
const std::string s = *(*it)->entity->getArgument(i);
|
||||
if ( s == a ) {
|
||||
@@ -73,12 +73,11 @@ IfcEntities IfcWritableEntity::getInverse(IfcSchema::Type::Enum c, int i, const
|
||||
return l;
|
||||
}
|
||||
|
||||
std::string IfcWritableEntity::datatype() { return IfcSchema::Type::ToString(_type); }
|
||||
ArgumentPtr IfcWritableEntity::getArgument (unsigned int i) { if ( i >= getArgumentCount() ) throw IfcParse::IfcException("Argument not set"); return args[i]; }
|
||||
unsigned int IfcWritableEntity::getArgumentCount() {return args.size(); }
|
||||
std::string IfcWritableEntity::datatype() const { return IfcSchema::Type::ToString(_type); }
|
||||
Argument* IfcWritableEntity::getArgument (unsigned int i) { if ( i >= getArgumentCount() ) throw IfcParse::IfcException("Argument not set"); return args[i]; }unsigned int IfcWritableEntity::getArgumentCount() const {return 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) {
|
||||
std::string IfcWritableEntity::toString(bool upper) const {
|
||||
std::stringstream ss;
|
||||
std::string dt = datatype();
|
||||
if ( upper ) {
|
||||
@@ -86,9 +85,9 @@ std::string IfcWritableEntity::toString(bool upper) {
|
||||
}
|
||||
if ( _id ) ss << "#" << *_id;
|
||||
ss << "=" << dt << "(";
|
||||
for ( std::map<int,ArgumentPtr>::const_iterator it = args.begin(); it != args.end(); ++ it ) {
|
||||
for ( std::map<int,Argument*>::const_iterator it = args.begin(); it != args.end(); ++ it ) {
|
||||
if ( it != args.begin() ) ss << ",";
|
||||
const ArgumentPtr a = it->second;
|
||||
const Argument* a = it->second;
|
||||
ss << it->second->toString(upper);
|
||||
}
|
||||
ss << ")";
|
||||
@@ -139,14 +138,21 @@ void IfcWritableEntity::setArgument(int i,const std::string& v){
|
||||
void IfcWritableEntity::setArgument(int i,double v){
|
||||
_setArgument(i, v);
|
||||
}
|
||||
void IfcWritableEntity::setArgument(int i,IfcUtil::IfcSchemaEntity v){
|
||||
void IfcWritableEntity::setArgument(int i,IfcUtil::IfcBaseClass* v){
|
||||
if ( v ) {
|
||||
_setArgument(i, v);
|
||||
} else {
|
||||
_setArgument(i, boost::none);
|
||||
}
|
||||
}
|
||||
void IfcWritableEntity::setArgument(int i,IfcEntities v){
|
||||
void IfcWritableEntity::setArgument(int i,IfcEntityList::ptr v){
|
||||
if ( v.get() ) {
|
||||
_setArgument(i, v);
|
||||
} else {
|
||||
_setArgument(i, boost::none);
|
||||
}
|
||||
}
|
||||
void IfcWritableEntity::setArgument(int i,IfcEntityListList::ptr v){
|
||||
if ( v.get() ) {
|
||||
_setArgument(i, v);
|
||||
} else {
|
||||
@@ -175,8 +181,9 @@ public:
|
||||
int operator()(const std::vector<double>& i) const { return i.size(); }
|
||||
int operator()(const std::vector<std::string>& i) const { return i.size(); }
|
||||
int operator()(const IfcWriteArgument::EnumerationReference& i) const { return -1; }
|
||||
int operator()(const IfcUtil::IfcSchemaEntity& i) const { return -1; }
|
||||
int operator()(const IfcEntities& i) const { return i->Size(); }
|
||||
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> {
|
||||
@@ -241,7 +248,7 @@ public:
|
||||
void operator()(const IfcWriteArgument::EnumerationReference& i) {
|
||||
data << "." << i.enumeration_value << ".";
|
||||
}
|
||||
void operator()(const IfcUtil::IfcSchemaEntity& i) {
|
||||
void operator()(const IfcUtil::IfcBaseClass* const& i) {
|
||||
IfcAbstractEntity* e = i->entity;
|
||||
if ( IfcSchema::Type::IsSimple(e->type()) ) {
|
||||
data << e->toString(upper);
|
||||
@@ -249,7 +256,7 @@ public:
|
||||
data << "#" << e->id();
|
||||
}
|
||||
}
|
||||
void operator()(const IfcEntities& i) {
|
||||
void operator()(const IfcEntityList::ptr& i) {
|
||||
data << "(";
|
||||
for (IfcEntityList::it it = i->begin(); it != i->end(); ++it) {
|
||||
if (it != i->begin()) data << ",";
|
||||
@@ -257,6 +264,19 @@ public:
|
||||
}
|
||||
data << ")";
|
||||
}
|
||||
void operator()(const IfcEntityListList::ptr& i) {
|
||||
data << "(";
|
||||
for (IfcEntityListList::outer_it outer_it = i->begin(); outer_it != i->end(); ++outer_it) {
|
||||
data << "(";
|
||||
if (outer_it != i->begin()) data << ",";
|
||||
for (IfcEntityListList::inner_it inner_it = outer_it->begin(); inner_it != outer_it->end(); ++inner_it) {
|
||||
if (inner_it != outer_it->begin()) data << ",";
|
||||
(*this)(*inner_it);
|
||||
}
|
||||
data << ")";
|
||||
}
|
||||
data << ")";
|
||||
}
|
||||
operator std::string() { return data.str(); }
|
||||
};
|
||||
|
||||
@@ -267,10 +287,11 @@ IfcWriteArgument::operator std::string() const { return as<std::string>(); }
|
||||
IfcWriteArgument::operator std::vector<double>() const { return as<std::vector<double> >(); }
|
||||
IfcWriteArgument::operator std::vector<int>() const { return as<std::vector<int> >(); }
|
||||
IfcWriteArgument::operator std::vector<std::string>() const { return as<std::vector<std::string > >(); }
|
||||
IfcWriteArgument::operator IfcUtil::IfcSchemaEntity() const { return as<IfcUtil::IfcSchemaEntity>(); }
|
||||
IfcWriteArgument::operator IfcEntities() const { return as<IfcEntities>(); }
|
||||
IfcWriteArgument::operator IfcUtil::IfcBaseClass*() const { return as<IfcUtil::IfcBaseClass*>(); }
|
||||
IfcWriteArgument::operator IfcEntityList::ptr() const { return as<IfcEntityList::ptr>(); }
|
||||
IfcWriteArgument::operator IfcEntityListList::ptr() const { throw; }
|
||||
bool IfcWriteArgument::isNull() const { return argumentType() == argument_type_null; }
|
||||
ArgumentPtr 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;
|
||||
StringBuilderVisitor v(str, upper);
|
||||
@@ -290,17 +311,17 @@ IfcWriteArgument::argument_type IfcWriteArgument::argumentType() const {
|
||||
return static_cast<argument_type>(container.which());
|
||||
}
|
||||
|
||||
IfcEntities IfcSelectHelperEntity::getInverse(IfcSchema::Type::Enum,int,const std::string &) {throw IfcParse::IfcException("Invalid cast");}
|
||||
IfcEntities IfcSelectHelperEntity::getInverse(IfcSchema::Type::Enum) {throw IfcParse::IfcException("Invalid cast");}
|
||||
std::string IfcSelectHelperEntity::datatype() { return IfcSchema::Type::ToString(_type); }
|
||||
ArgumentPtr IfcSelectHelperEntity::getArgument(unsigned int i) {
|
||||
IfcEntityList::ptr IfcSelectHelperEntity::getInverse(IfcSchema::Type::Enum,int,const std::string &) {throw IfcParse::IfcException("Invalid cast");}
|
||||
IfcEntityList::ptr IfcSelectHelperEntity::getInverse(IfcSchema::Type::Enum) {throw IfcParse::IfcException("Invalid cast");}
|
||||
std::string IfcSelectHelperEntity::datatype() const { return IfcSchema::Type::ToString(_type); }
|
||||
Argument* IfcSelectHelperEntity::getArgument(unsigned int i) {
|
||||
if ( i != 0 ) throw IfcParse::IfcException("Invalid cast");
|
||||
return arg;
|
||||
}
|
||||
unsigned int IfcSelectHelperEntity::getArgumentCount() { return 1; }
|
||||
unsigned int IfcSelectHelperEntity::getArgumentCount() const { return 1; }
|
||||
IfcSchema::Type::Enum IfcSelectHelperEntity::type() const { return _type; }
|
||||
bool IfcSelectHelperEntity::is(IfcSchema::Type::Enum t) const { return _type == t; }
|
||||
std::string IfcSelectHelperEntity::toString(bool upper) {
|
||||
std::string IfcSelectHelperEntity::toString(bool upper) const {
|
||||
std::stringstream ss;
|
||||
std::string dt = datatype();
|
||||
if ( upper ) {
|
||||
@@ -344,16 +365,16 @@ EntityBuffer* EntityBuffer::i = 0;
|
||||
EntityBuffer* EntityBuffer::instance() {
|
||||
if ( ! i ) {
|
||||
i = new EntityBuffer();
|
||||
i->buffer = IfcEntities(new IfcEntityList());
|
||||
i->buffer = IfcEntityList::ptr(new IfcEntityList);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
IfcEntities EntityBuffer::Get() {
|
||||
IfcEntityList::ptr EntityBuffer::Get() {
|
||||
return instance()->buffer;
|
||||
}
|
||||
void EntityBuffer::Clear() {
|
||||
instance()->buffer = IfcEntities(new IfcEntityList());
|
||||
instance()->buffer = IfcEntityList::ptr(new IfcEntityList);
|
||||
}
|
||||
void EntityBuffer::Add(IfcUtil::IfcSchemaEntity e) {
|
||||
void EntityBuffer::Add(IfcUtil::IfcBaseClass* e) {
|
||||
instance()->buffer->push(e);
|
||||
}
|
||||
|
||||
+20
-16
@@ -82,11 +82,13 @@ namespace IfcWrite {
|
||||
// An entity instance argument. It will either serialize to
|
||||
// e.g. #123 or datatype identifier for simple types, e.g.
|
||||
// IFCREAL(12.3)
|
||||
IfcUtil::IfcSchemaEntity,
|
||||
IfcUtil::IfcBaseClass*,
|
||||
// An entity list argument. It will either serialize to
|
||||
// e.g. (#1,#2,#3) or datatype identifier for simple types,
|
||||
// e.g. (IFCREAL(1.2),IFCINTEGER(3.))
|
||||
IfcEntities
|
||||
IfcEntityList::ptr,
|
||||
// A list of list of entities. E.g. ((#1, #2), (#3))
|
||||
IfcEntityListList::ptr
|
||||
> container;
|
||||
public:
|
||||
enum argument_type {
|
||||
@@ -100,8 +102,9 @@ namespace IfcWrite {
|
||||
argument_type_vector_double,
|
||||
argument_type_vector_string,
|
||||
argument_type_enumeration,
|
||||
argument_type_schema_entity,
|
||||
argument_type_entities
|
||||
argument_type_entity,
|
||||
argument_type_entity_list,
|
||||
argument_type_entity_list_list
|
||||
};
|
||||
IfcWriteArgument(IfcAbstractEntity* e) : entity(e) {}
|
||||
template <typename T> const T& as() const {
|
||||
@@ -121,10 +124,11 @@ namespace IfcWrite {
|
||||
operator std::vector<double>() const;
|
||||
operator std::vector<int>() const;
|
||||
operator std::vector<std::string>() const;
|
||||
operator IfcUtil::IfcSchemaEntity() const;
|
||||
operator IfcEntities() const;
|
||||
operator IfcUtil::IfcBaseClass*() const;
|
||||
operator IfcEntityList::ptr() const;
|
||||
operator IfcEntityListList::ptr() const;
|
||||
bool isNull() const;
|
||||
ArgumentPtr operator [] (unsigned int i) const;
|
||||
Argument* operator [] (unsigned int i) const;
|
||||
std::string toString(bool upper=false) const;
|
||||
unsigned int Size() const;
|
||||
argument_type argumentType() const;
|
||||
@@ -141,14 +145,14 @@ namespace IfcWrite {
|
||||
public:
|
||||
// FIXME: Make this a non-pointer argument and implement a copy constructor
|
||||
IfcSelectHelperEntity(IfcSchema::Type::Enum t, IfcWriteArgument* a) : _type(t), arg(a) {}
|
||||
IfcEntities getInverse(IfcSchema::Type::Enum,int,const std::string &);
|
||||
IfcEntities getInverse(IfcSchema::Type::Enum);
|
||||
std::string datatype();
|
||||
ArgumentPtr getArgument(unsigned int i);
|
||||
unsigned int getArgumentCount();
|
||||
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum,int,const std::string &);
|
||||
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum);
|
||||
std::string datatype() const;
|
||||
Argument* getArgument(unsigned int i);
|
||||
unsigned int getArgumentCount() const;
|
||||
IfcSchema::Type::Enum type() const;
|
||||
bool is(IfcSchema::Type::Enum t) const;
|
||||
std::string toString(bool upper = false);
|
||||
std::string toString(bool upper = false) const;
|
||||
unsigned int id();
|
||||
bool isWritable();
|
||||
};
|
||||
@@ -183,13 +187,13 @@ namespace IfcWrite {
|
||||
// This way they can be added in a single batch to the IfcFile
|
||||
class EntityBuffer {
|
||||
private:
|
||||
IfcEntities buffer;
|
||||
IfcEntityList::ptr buffer;
|
||||
static EntityBuffer* i;
|
||||
static EntityBuffer* instance();
|
||||
public:
|
||||
static IfcEntities Get();
|
||||
static IfcEntityList::ptr Get();
|
||||
static void Clear();
|
||||
static void Add(IfcUtil::IfcSchemaEntity e);
|
||||
static void Add(IfcUtil::IfcBaseClass* e);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user