mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
hierarchy helper ifc4 RepresentationContexts compatibility
This commit is contained in:
@@ -861,6 +861,23 @@ typename Schema::IfcShapeRepresentation* IfcHierarchyHelper<Schema>::addEmptyRep
|
|||||||
return shape_rep;
|
return shape_rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
// In IFC4 the IfcContext.RepresentationContexts has been made optional, so we need
|
||||||
|
// some boiler plate to push back to a list that might be optional.
|
||||||
|
template <typename T, typename U>
|
||||||
|
void push_back_to_maybe_optional(boost::optional<typename T::ptr>& t, U* u) {
|
||||||
|
if (!t) {
|
||||||
|
t->emplace(new T);
|
||||||
|
}
|
||||||
|
(*t)->push(u);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
void push_back_to_maybe_optional(T& t, U* u) {
|
||||||
|
t->push(u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Schema>
|
template <typename Schema>
|
||||||
typename Schema::IfcGeometricRepresentationContext* IfcHierarchyHelper<Schema>::getRepresentationContext(const std::string& s) {
|
typename Schema::IfcGeometricRepresentationContext* IfcHierarchyHelper<Schema>::getRepresentationContext(const std::string& s) {
|
||||||
typename std::map<std::string, typename Schema::IfcGeometricRepresentationContext*>::const_iterator it = contexts.find(s);
|
typename std::map<std::string, typename Schema::IfcGeometricRepresentationContext*>::const_iterator it = contexts.find(s);
|
||||||
@@ -870,11 +887,12 @@ typename Schema::IfcGeometricRepresentationContext* IfcHierarchyHelper<Schema>::
|
|||||||
if (!project) {
|
if (!project) {
|
||||||
project = addProject();
|
project = addProject();
|
||||||
}
|
}
|
||||||
typename Schema::IfcRepresentationContext::list::ptr project_contexts = project->RepresentationContexts();
|
auto project_contexts = project->RepresentationContexts();
|
||||||
typename Schema::IfcGeometricRepresentationContext* context = new typename Schema::IfcGeometricRepresentationContext(
|
typename Schema::IfcGeometricRepresentationContext* context = new typename Schema::IfcGeometricRepresentationContext(
|
||||||
boost::none, s, 3, 1e-5, addPlacement3d(), addDoublet<typename Schema::IfcDirection>(0, 1));
|
boost::none, s, 3, 1e-5, addPlacement3d(), addDoublet<typename Schema::IfcDirection>(0, 1));
|
||||||
addEntity(context);
|
addEntity(context);
|
||||||
project_contexts->push(context);
|
push_back_to_maybe_optional(project_contexts, context);
|
||||||
|
|
||||||
project->setRepresentationContexts(project_contexts);
|
project->setRepresentationContexts(project_contexts);
|
||||||
return contexts[s] = context;
|
return contexts[s] = context;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user