mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
WARNING: more function renames
This commit is contained in:
@@ -258,7 +258,7 @@ int main(int argc, char** argv) {
|
|||||||
IfcEntityList::ptr geometrical_entities(new IfcEntityList);
|
IfcEntityList::ptr geometrical_entities(new IfcEntityList);
|
||||||
IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(shape, 100., geometrical_entities);
|
IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(shape, 100., geometrical_entities);
|
||||||
file.getSingle<IfcSchema::IfcSite>()->setRepresentation(ground_representation);
|
file.getSingle<IfcSchema::IfcSite>()->setRepresentation(ground_representation);
|
||||||
file.AddEntities(geometrical_entities);
|
file.addEntities(geometrical_entities);
|
||||||
IfcSchema::IfcShapeRepresentation::list::ptr ground_reps = geometrical_entities->as<IfcSchema::IfcShapeRepresentation>();
|
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) {
|
for (IfcSchema::IfcShapeRepresentation::list::it it = ground_reps->begin(); it != ground_reps->end(); ++it) {
|
||||||
(*it)->setContextOfItems(file.getRepresentationContext("Model"));
|
(*it)->setContextOfItems(file.getRepresentationContext("Model"));
|
||||||
@@ -313,9 +313,9 @@ int main(int argc, char** argv) {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
#ifdef USE_IFC4
|
#ifdef USE_IFC4
|
||||||
file.EntitiesByType<IfcSchema::IfcWallStandardCase>()->generalize(),
|
file.entitiesByType<IfcSchema::IfcWallStandardCase>()->generalize(),
|
||||||
#else
|
#else
|
||||||
file.EntitiesByType<IfcSchema::IfcWallStandardCase>()->as<IfcSchema::IfcRoot>(),
|
file.entitiesByType<IfcSchema::IfcWallStandardCase>()->as<IfcSchema::IfcRoot>(),
|
||||||
#endif
|
#endif
|
||||||
layer_usage);
|
layer_usage);
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
// Lets get a list of IfcBuildingElements, this is the parent
|
// Lets get a list of IfcBuildingElements, this is the parent
|
||||||
// type of things like walls, windows and doors.
|
// type of things like walls, windows and doors.
|
||||||
// EntitiesByType is a templated function and returns a
|
// entitiesByType is a templated function and returns a
|
||||||
// templated class that behaves like a std::vector.
|
// templated class that behaves like a std::vector.
|
||||||
// Note that the return types are all typedef'ed as members of
|
// Note that the return types are all typedef'ed as members of
|
||||||
// the generated classes, ::list for the templated vector class,
|
// the generated classes, ::list for the templated vector class,
|
||||||
@@ -54,7 +54,7 @@ int main(int argc, char** argv) {
|
|||||||
// we need to cast them to IfcWindows. Since these properties
|
// we need to cast them to IfcWindows. Since these properties
|
||||||
// are optional we need to make sure the properties are
|
// are optional we need to make sure the properties are
|
||||||
// defined for the window in question before accessing them.
|
// defined for the window in question before accessing them.
|
||||||
IfcBuildingElement::list::ptr elements = file.EntitiesByType<IfcBuildingElement>();
|
IfcBuildingElement::list::ptr elements = file.entitiesByType<IfcBuildingElement>();
|
||||||
|
|
||||||
std::cout << "Found " << elements->size() << " elements in " << argv[1] << ":" << std::endl;
|
std::cout << "Found " << elements->size() << " elements in " << argv[1] << ":" << std::endl;
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ int main(int argc, char** argv) {
|
|||||||
IfcSchema::IfcCartesianPoint::list points (new IfcTemplatedEntityList<IfcSchema::IfcCartesianPoint>());
|
IfcSchema::IfcCartesianPoint::list points (new IfcTemplatedEntityList<IfcSchema::IfcCartesianPoint>());
|
||||||
points->push(new IfcSchema::IfcCartesianPoint(std::vector<double>(coords1, coords1+2)));
|
points->push(new IfcSchema::IfcCartesianPoint(std::vector<double>(coords1, coords1+2)));
|
||||||
points->push(new IfcSchema::IfcCartesianPoint(std::vector<double>(coords2, coords2+2)));
|
points->push(new IfcSchema::IfcCartesianPoint(std::vector<double>(coords2, coords2+2)));
|
||||||
file.AddEntities(points->generalize());
|
file.addEntities(points->generalize());
|
||||||
IfcSchema::IfcPolyline* poly = new IfcSchema::IfcPolyline(points);
|
IfcSchema::IfcPolyline* poly = new IfcSchema::IfcPolyline(points);
|
||||||
file.addEntity(poly);
|
file.addEntity(poly);
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ int main(int argc, char** argv) {
|
|||||||
profiles->push(p6);
|
profiles->push(p6);
|
||||||
profiles->push(p4);
|
profiles->push(p4);
|
||||||
|
|
||||||
file.AddEntities(profiles->generalize());
|
file.addEntities(profiles->generalize());
|
||||||
|
|
||||||
IfcSchema::IfcCompositeProfileDef* composite = new IfcSchema::IfcCompositeProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, S("IFC"), profiles, null);
|
IfcSchema::IfcCompositeProfileDef* composite = new IfcSchema::IfcCompositeProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, S("IFC"), profiles, null);
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ void create_testcase_for(IfcHierarchyHelper& file, const EllipsePie& pie, Ifc2x3
|
|||||||
points->push(p3);
|
points->push(p3);
|
||||||
points->push(p1);
|
points->push(p1);
|
||||||
points->push(p2);
|
points->push(p2);
|
||||||
file.AddEntities(points->generalize());
|
file.addEntities(points->generalize());
|
||||||
|
|
||||||
|
|
||||||
Ifc2x3::IfcEllipse* ellipse = new Ifc2x3::IfcEllipse(file.addPlacement2d(), pie.r1, pie.r2);
|
Ifc2x3::IfcEllipse* ellipse = new Ifc2x3::IfcEllipse(file.addPlacement2d(), pie.r1, pie.r2);
|
||||||
@@ -88,7 +88,7 @@ void create_testcase_for(IfcHierarchyHelper& file, const EllipsePie& pie, Ifc2x3
|
|||||||
segments->push(s1);
|
segments->push(s1);
|
||||||
|
|
||||||
segments->push(s2);
|
segments->push(s2);
|
||||||
file.AddEntities(segments->generalize());
|
file.addEntities(segments->generalize());
|
||||||
|
|
||||||
Ifc2x3::IfcCompositeCurve* ccurve = new Ifc2x3::IfcCompositeCurve(segments, false);
|
Ifc2x3::IfcCompositeCurve* ccurve = new Ifc2x3::IfcCompositeCurve(segments, false);
|
||||||
Ifc2x3::IfcArbitraryClosedProfileDef* profile = new Ifc2x3::IfcArbitraryClosedProfileDef(Ifc2x3::IfcProfileTypeEnum::IfcProfileType_AREA, null, ccurve);
|
Ifc2x3::IfcArbitraryClosedProfileDef* profile = new Ifc2x3::IfcArbitraryClosedProfileDef(Ifc2x3::IfcProfileTypeEnum::IfcProfileType_AREA, null, ccurve);
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ void format_properties(IfcProperty::list::ptr properties, ptree& node) {
|
|||||||
void XmlSerializer::finalize() {
|
void XmlSerializer::finalize() {
|
||||||
argument_name_map.insert(std::make_pair("GlobalId", "id"));
|
argument_name_map.insert(std::make_pair("GlobalId", "id"));
|
||||||
|
|
||||||
IfcProject::list::ptr projects = file->EntitiesByType<IfcProject>();
|
IfcProject::list::ptr projects = file->entitiesByType<IfcProject>();
|
||||||
if (projects->size() != 1) {
|
if (projects->size() != 1) {
|
||||||
Logger::Message(Logger::LOG_ERROR, "Expected a single IfcProject");
|
Logger::Message(Logger::LOG_ERROR, "Expected a single IfcProject");
|
||||||
return;
|
return;
|
||||||
@@ -234,7 +234,7 @@ void XmlSerializer::finalize() {
|
|||||||
descend(project, decomposition);
|
descend(project, decomposition);
|
||||||
|
|
||||||
// Write all property sets and values as XML nodes.
|
// Write all property sets and values as XML nodes.
|
||||||
IfcPropertySet::list::ptr psets = file->EntitiesByType<IfcPropertySet>();
|
IfcPropertySet::list::ptr psets = file->entitiesByType<IfcPropertySet>();
|
||||||
for (IfcPropertySet::list::it it = psets->begin(); it != psets->end(); ++it) {
|
for (IfcPropertySet::list::it it = psets->begin(); it != psets->end(); ++it) {
|
||||||
IfcPropertySet* pset = *it;
|
IfcPropertySet* pset = *it;
|
||||||
ptree& node = format_entity_instance(pset, properties);
|
ptree& node = format_entity_instance(pset, properties);
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ namespace IfcGeom {
|
|||||||
P unit_magnitude;
|
P unit_magnitude;
|
||||||
|
|
||||||
void initUnits() {
|
void initUnits() {
|
||||||
IfcSchema::IfcProject::list::ptr projects = ifc_file->EntitiesByType<IfcSchema::IfcProject>();
|
IfcSchema::IfcProject::list::ptr projects = ifc_file->entitiesByType<IfcSchema::IfcProject>();
|
||||||
if (projects->size() == 1) {
|
if (projects->size() == 1) {
|
||||||
IfcSchema::IfcProject* project = *projects->begin();
|
IfcSchema::IfcProject* project = *projects->begin();
|
||||||
std::pair<std::string, double> length_unit = kernel.initializeUnits(project->UnitsInContext());
|
std::pair<std::string, double> length_unit = kernel.initializeUnits(project->UnitsInContext());
|
||||||
@@ -165,7 +165,7 @@ namespace IfcGeom {
|
|||||||
IfcSchema::IfcGeometricRepresentationContext::list::it it;
|
IfcSchema::IfcGeometricRepresentationContext::list::it it;
|
||||||
IfcSchema::IfcGeometricRepresentationSubContext::list::it jt;
|
IfcSchema::IfcGeometricRepresentationSubContext::list::it jt;
|
||||||
IfcSchema::IfcGeometricRepresentationContext::list::ptr contexts =
|
IfcSchema::IfcGeometricRepresentationContext::list::ptr contexts =
|
||||||
ifc_file->EntitiesByType<IfcSchema::IfcGeometricRepresentationContext>();
|
ifc_file->entitiesByType<IfcSchema::IfcGeometricRepresentationContext>();
|
||||||
|
|
||||||
IfcSchema::IfcGeometricRepresentationContext::list::ptr filtered_contexts (new IfcSchema::IfcGeometricRepresentationContext::list);
|
IfcSchema::IfcGeometricRepresentationContext::list::ptr filtered_contexts (new IfcSchema::IfcGeometricRepresentationContext::list);
|
||||||
|
|
||||||
@@ -384,7 +384,7 @@ namespace IfcGeom {
|
|||||||
std::string instance_type, product_name, product_guid;
|
std::string instance_type, product_name, product_guid;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const IfcUtil::IfcBaseClass* ifc_entity = ifc_file->EntityById(id);
|
const IfcUtil::IfcBaseClass* ifc_entity = ifc_file->entityById(id);
|
||||||
instance_type = IfcSchema::Type::ToString(ifc_entity->type());
|
instance_type = IfcSchema::Type::ToString(ifc_entity->type());
|
||||||
if ( ifc_entity->is(IfcSchema::Type::IfcProduct) ) {
|
if ( ifc_entity->is(IfcSchema::Type::IfcProduct) ) {
|
||||||
IfcSchema::IfcProduct* ifc_product = (IfcSchema::IfcProduct*)ifc_entity;
|
IfcSchema::IfcProduct* ifc_product = (IfcSchema::IfcProduct*)ifc_entity;
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ namespace IfcGeom {
|
|||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
// TODO: Catch outside
|
// TODO: Catch outside
|
||||||
// Logger::Message(Logger::LOG_ERROR,"Failed to triangulate shape:",ifc_file->EntityById(_id)->entity);
|
// Logger::Message(Logger::LOG_ERROR,"Failed to triangulate shape:",ifc_file->entityById(_id)->entity);
|
||||||
Logger::Message(Logger::LOG_ERROR,"Failed to triangulate shape");
|
Logger::Message(Logger::LOG_ERROR,"Failed to triangulate shape");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-10
@@ -65,17 +65,19 @@ public:
|
|||||||
IfcFile(bool create_latebound_entities = false);
|
IfcFile(bool create_latebound_entities = false);
|
||||||
~IfcFile();
|
~IfcFile();
|
||||||
|
|
||||||
/// Returns the first entity in the file, this probably is the entity with the lowest id (EXPRESS ENTITY_INSTANCE_NAME)
|
/// Returns the first entity in the file, this probably is the entity
|
||||||
|
/// with the lowest id (EXPRESS ENTITY_INSTANCE_NAME)
|
||||||
const_iterator begin() const;
|
const_iterator begin() const;
|
||||||
/// Returns the last entity in the file, this probably is the entity with the highes id (EXPRESS ENTITY_INSTANCE_NAME)
|
/// Returns the last entity in the file, this probably is the entity
|
||||||
|
/// with the highest id (EXPRESS ENTITY_INSTANCE_NAME)
|
||||||
const_iterator end() const;
|
const_iterator end() const;
|
||||||
|
|
||||||
/// Returns all entities in the file that match the template argument.
|
/// Returns all entities in the file that match the template argument.
|
||||||
/// NOTE: This also returns subtypes of the requested type, for example:
|
/// NOTE: This also returns subtypes of the requested type, for example:
|
||||||
/// IfcWall will also return IfcWallStandardCase entities
|
/// IfcWall will also return IfcWallStandardCase entities
|
||||||
template <class T>
|
template <class T>
|
||||||
typename T::list::ptr EntitiesByType() {
|
typename T::list::ptr entitiesByType() {
|
||||||
IfcEntityList::ptr untyped_list = EntitiesByType(T::Class());
|
IfcEntityList::ptr untyped_list = entitiesByType(T::Class());
|
||||||
if (untyped_list) {
|
if (untyped_list) {
|
||||||
return untyped_list->as<T>();
|
return untyped_list->as<T>();
|
||||||
} else {
|
} else {
|
||||||
@@ -86,21 +88,21 @@ public:
|
|||||||
/// Returns all entities in the file that match the positional argument.
|
/// Returns all entities in the file that match the positional argument.
|
||||||
/// NOTE: This also returns subtypes of the requested type, for example:
|
/// NOTE: This also returns subtypes of the requested type, for example:
|
||||||
/// IfcWall will also return IfcWallStandardCase entities
|
/// IfcWall will also return IfcWallStandardCase entities
|
||||||
IfcEntityList::ptr EntitiesByType(IfcSchema::Type::Enum t);
|
IfcEntityList::ptr entitiesByType(IfcSchema::Type::Enum t);
|
||||||
|
|
||||||
/// Returns all entities in the file that match the positional argument.
|
/// Returns all entities in the file that match the positional argument.
|
||||||
/// NOTE: This also returns subtypes of the requested type, for example:
|
/// NOTE: This also returns subtypes of the requested type, for example:
|
||||||
/// IfcWall will also return IfcWallStandardCase entities
|
/// IfcWall will also return IfcWallStandardCase entities
|
||||||
IfcEntityList::ptr EntitiesByType(const std::string& t);
|
IfcEntityList::ptr entitiesByType(const std::string& t);
|
||||||
|
|
||||||
/// Returns all entities in the file that reference the id
|
/// Returns all entities in the file that reference the id
|
||||||
IfcEntityList::ptr EntitiesByReference(int id);
|
IfcEntityList::ptr entitiesByReference(int id);
|
||||||
|
|
||||||
/// Returns the entity with the specified id
|
/// Returns the entity with the specified id
|
||||||
IfcUtil::IfcBaseClass* EntityById(int id);
|
IfcUtil::IfcBaseClass* entityById(int id);
|
||||||
|
|
||||||
/// Returns the entity with the specified GlobalId
|
/// Returns the entity with the specified GlobalId
|
||||||
IfcSchema::IfcRoot* EntityByGuid(const std::string& guid);
|
IfcSchema::IfcRoot* entityByGuid(const std::string& guid);
|
||||||
|
|
||||||
/// Performs a depth-first traversal, returning all entity instance
|
/// Performs a depth-first traversal, returning all entity instance
|
||||||
/// attributes as a flat list. NB: includes the root instance specified
|
/// attributes as a flat list. NB: includes the root instance specified
|
||||||
@@ -117,7 +119,7 @@ public:
|
|||||||
unsigned int FreshId() { return ++MaxId; }
|
unsigned int FreshId() { return ++MaxId; }
|
||||||
|
|
||||||
IfcUtil::IfcBaseClass* addEntity(IfcUtil::IfcBaseClass* entity);
|
IfcUtil::IfcBaseClass* addEntity(IfcUtil::IfcBaseClass* entity);
|
||||||
void AddEntities(IfcEntityList::ptr es);
|
void addEntities(IfcEntityList::ptr es);
|
||||||
|
|
||||||
void removeEntity(IfcUtil::IfcBaseClass* entity);
|
void removeEntity(IfcUtil::IfcBaseClass* entity);
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T* getSingle() {
|
T* getSingle() {
|
||||||
typename T::list::ptr ts = EntitiesByType<T>();
|
typename T::list::ptr ts = entitiesByType<T>();
|
||||||
if (ts->size() != 1) return 0;
|
if (ts->size() != 1) return 0;
|
||||||
return *ts->begin();
|
return *ts->begin();
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
void addRelatedObject(IfcSchema::IfcObjectDefinition* related_object,
|
void addRelatedObject(IfcSchema::IfcObjectDefinition* related_object,
|
||||||
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist = 0)
|
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist = 0)
|
||||||
{
|
{
|
||||||
typename T::list::ptr li = EntitiesByType<T>();
|
typename T::list::ptr li = entitiesByType<T>();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (typename T::list::it i = li->begin(); i != li->end(); ++i) {
|
for (typename T::list::it i = li->begin(); i != li->end(); ++i) {
|
||||||
T* rel = *i;
|
T* rel = *i;
|
||||||
@@ -175,7 +175,7 @@ template <>
|
|||||||
inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSpatialStructure> (IfcSchema::IfcObjectDefinition* related_object,
|
inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSpatialStructure> (IfcSchema::IfcObjectDefinition* related_object,
|
||||||
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist)
|
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist)
|
||||||
{
|
{
|
||||||
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr li = EntitiesByType<IfcSchema::IfcRelContainedInSpatialStructure>();
|
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr li = entitiesByType<IfcSchema::IfcRelContainedInSpatialStructure>();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (IfcSchema::IfcRelContainedInSpatialStructure::list::it i = li->begin(); i != li->end(); ++i) {
|
for (IfcSchema::IfcRelContainedInSpatialStructure::list::it i = li->begin(); i != li->end(); ++i) {
|
||||||
IfcSchema::IfcRelContainedInSpatialStructure* rel = *i;
|
IfcSchema::IfcRelContainedInSpatialStructure* rel = *i;
|
||||||
|
|||||||
+20
-20
@@ -635,7 +635,7 @@ 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<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<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 std::vector<std::string>() const { throw IfcException("Argument is not a list of strings"); }
|
||||||
TokenArgument::operator IfcUtil::IfcBaseClass*() const { return token.first->file->EntityById(TokenFunc::asInt(token)); }
|
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 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"); }
|
TokenArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of entity lists"); }
|
||||||
unsigned int TokenArgument::size() const { return 1; }
|
unsigned int TokenArgument::size() const { return 1; }
|
||||||
@@ -882,7 +882,7 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
|
|||||||
|
|
||||||
IfcSchema::Type::Enum ty = entity->type();
|
IfcSchema::Type::Enum ty = entity->type();
|
||||||
do {
|
do {
|
||||||
IfcEntityList::ptr instances_by_type = EntitiesByType(ty);
|
IfcEntityList::ptr instances_by_type = entitiesByType(ty);
|
||||||
if (!instances_by_type) {
|
if (!instances_by_type) {
|
||||||
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
|
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
|
||||||
bytype[ty] = instances_by_type;
|
bytype[ty] = instances_by_type;
|
||||||
@@ -912,7 +912,7 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
|
|||||||
if ( TokenFunc::isOperator(token,'=') ) {
|
if ( TokenFunc::isOperator(token,'=') ) {
|
||||||
currentId = id;
|
currentId = id;
|
||||||
} else if (entity) {
|
} else if (entity) {
|
||||||
IfcEntityList::ptr instances_by_ref = EntitiesByReference(id);
|
IfcEntityList::ptr instances_by_ref = entitiesByReference(id);
|
||||||
if (!instances_by_ref) {
|
if (!instances_by_ref) {
|
||||||
instances_by_ref = IfcEntityList::ptr(new IfcEntityList());
|
instances_by_ref = IfcEntityList::ptr(new IfcEntityList());
|
||||||
byref[id] = instances_by_ref;
|
byref[id] = instances_by_ref;
|
||||||
@@ -963,7 +963,7 @@ IfcEntityList::ptr IfcFile::traverse(IfcUtil::IfcBaseClass* instance, int max_le
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcFile::AddEntities(IfcEntityList::ptr es) {
|
void IfcFile::addEntities(IfcEntityList::ptr es) {
|
||||||
for( IfcEntityList::it i = es->begin(); i != es->end(); ++ i ) {
|
for( IfcEntityList::it i = es->begin(); i != es->end(); ++ i ) {
|
||||||
addEntity(*i);
|
addEntity(*i);
|
||||||
}
|
}
|
||||||
@@ -1078,7 +1078,7 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
|
|||||||
// The mapping by entity type is updated.
|
// The mapping by entity type is updated.
|
||||||
IfcSchema::Type::Enum ty = entity->type();
|
IfcSchema::Type::Enum ty = entity->type();
|
||||||
do {
|
do {
|
||||||
IfcEntityList::ptr instances_by_type = EntitiesByType(ty);
|
IfcEntityList::ptr instances_by_type = entitiesByType(ty);
|
||||||
if (!instances_by_type) {
|
if (!instances_by_type) {
|
||||||
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
|
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
|
||||||
bytype[ty] = instances_by_type;
|
bytype[ty] = instances_by_type;
|
||||||
@@ -1113,7 +1113,7 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
|
|||||||
try {
|
try {
|
||||||
if (!IfcSchema::Type::IsSimple(entity_attribute->type())) {
|
if (!IfcSchema::Type::IsSimple(entity_attribute->type())) {
|
||||||
unsigned entity_attribute_id = entity_attribute->entity->id();
|
unsigned entity_attribute_id = entity_attribute->entity->id();
|
||||||
IfcEntityList::ptr refs = EntitiesByReference(entity_attribute_id);
|
IfcEntityList::ptr refs = entitiesByReference(entity_attribute_id);
|
||||||
if (!refs) {
|
if (!refs) {
|
||||||
refs = IfcEntityList::ptr(new IfcEntityList);
|
refs = IfcEntityList::ptr(new IfcEntityList);
|
||||||
byref[entity_attribute_id] = refs;
|
byref[entity_attribute_id] = refs;
|
||||||
@@ -1138,7 +1138,7 @@ IfcWrite::IfcWritableEntity* make_writable(IfcUtil::IfcBaseClass* instance) {
|
|||||||
|
|
||||||
void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
||||||
const unsigned id = entity->entity->id();
|
const unsigned id = entity->entity->id();
|
||||||
IfcUtil::IfcBaseClass* file_entity = EntityById(id);
|
IfcUtil::IfcBaseClass* file_entity = entityById(id);
|
||||||
|
|
||||||
// TODO: Create a set of weak relations. Inverse relations that do not dictate an
|
// TODO: Create a set of weak relations. Inverse relations that do not dictate an
|
||||||
// instance to be retained. For example: when deleting an IfcRepresentation, the
|
// instance to be retained. For example: when deleting an IfcRepresentation, the
|
||||||
@@ -1152,7 +1152,7 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::set<IfcUtil::IfcBaseClass*> deletion_queue;
|
std::set<IfcUtil::IfcBaseClass*> deletion_queue;
|
||||||
IfcEntityList::ptr references = EntitiesByReference(id);
|
IfcEntityList::ptr references = entitiesByReference(id);
|
||||||
|
|
||||||
// Alter entity instances with INVERSE relations to the entity being
|
// Alter entity instances with INVERSE relations to the entity being
|
||||||
// deleted. This is necessary to maintain a valid IFC file, because
|
// deleted. This is necessary to maintain a valid IFC file, because
|
||||||
@@ -1214,8 +1214,8 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
|||||||
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
|
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
|
||||||
IfcUtil::IfcBaseClass* entity_attribute = *it;
|
IfcUtil::IfcBaseClass* entity_attribute = *it;
|
||||||
if (entity_attribute == entity) continue;
|
if (entity_attribute == entity) continue;
|
||||||
EntitiesByReference(entity_attribute->entity->id())->remove(entity);
|
entitiesByReference(entity_attribute->entity->id())->remove(entity);
|
||||||
if (EntitiesByReference(entity_attribute->entity->id())->filtered(weak_roots)->size() == 0) {
|
if (entitiesByReference(entity_attribute->entity->id())->filtered(weak_roots)->size() == 0) {
|
||||||
deletion_queue.insert(entity_attribute);
|
deletion_queue.insert(entity_attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1227,7 +1227,7 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
|||||||
|
|
||||||
byid.erase(byid.find(id));
|
byid.erase(byid.find(id));
|
||||||
|
|
||||||
IfcEntityList::ptr instances_of_same_type = EntitiesByType(entity->type());
|
IfcEntityList::ptr instances_of_same_type = entitiesByType(entity->type());
|
||||||
instances_of_same_type->remove(entity);
|
instances_of_same_type->remove(entity);
|
||||||
|
|
||||||
while (!deletion_queue.empty()) {
|
while (!deletion_queue.empty()) {
|
||||||
@@ -1239,23 +1239,23 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
|||||||
delete entity;
|
delete entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcEntityList::ptr IfcFile::EntitiesByType(IfcSchema::Type::Enum t) {
|
IfcEntityList::ptr IfcFile::entitiesByType(IfcSchema::Type::Enum t) {
|
||||||
entities_by_type_t::const_iterator it = bytype.find(t);
|
entities_by_type_t::const_iterator it = bytype.find(t);
|
||||||
return (it == bytype.end()) ? IfcEntityList::ptr() : it->second;
|
return (it == bytype.end()) ? IfcEntityList::ptr() : it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcEntityList::ptr IfcFile::EntitiesByType(const std::string& t) {
|
IfcEntityList::ptr IfcFile::entitiesByType(const std::string& t) {
|
||||||
std::string ty = t;
|
std::string ty = t;
|
||||||
for (std::string::iterator p = ty.begin(); p != ty.end(); ++p ) *p = toupper(*p);
|
for (std::string::iterator p = ty.begin(); p != ty.end(); ++p ) *p = toupper(*p);
|
||||||
return EntitiesByType(IfcSchema::Type::FromString(ty));
|
return entitiesByType(IfcSchema::Type::FromString(ty));
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcEntityList::ptr IfcFile::EntitiesByReference(int t) {
|
IfcEntityList::ptr IfcFile::entitiesByReference(int t) {
|
||||||
entities_by_ref_t::const_iterator it = byref.find(t);
|
entities_by_ref_t::const_iterator it = byref.find(t);
|
||||||
return (it == byref.end()) ? IfcEntityList::ptr() : it->second;
|
return (it == byref.end()) ? IfcEntityList::ptr() : it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcUtil::IfcBaseClass* IfcFile::EntityById(int id) {
|
IfcUtil::IfcBaseClass* IfcFile::entityById(int id) {
|
||||||
entity_by_id_t::const_iterator it = byid.find(id);
|
entity_by_id_t::const_iterator it = byid.find(id);
|
||||||
if (it == byid.end()) {
|
if (it == byid.end()) {
|
||||||
throw IfcException("Entity not found");
|
throw IfcException("Entity not found");
|
||||||
@@ -1263,7 +1263,7 @@ IfcUtil::IfcBaseClass* IfcFile::EntityById(int id) {
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcSchema::IfcRoot* IfcFile::EntityByGuid(const std::string& guid) {
|
IfcSchema::IfcRoot* IfcFile::entityByGuid(const std::string& guid) {
|
||||||
entity_by_guid_t::const_iterator it = byguid.find(guid);
|
entity_by_guid_t::const_iterator it = byguid.find(guid);
|
||||||
if ( it == byguid.end() ) {
|
if ( it == byguid.end() ) {
|
||||||
throw IfcException("Entity not found");
|
throw IfcException("Entity not found");
|
||||||
@@ -1327,10 +1327,10 @@ std::string IfcFile::createTimestamp() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum type, int attribute_index) {
|
IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum type, int attribute_index) {
|
||||||
IfcUtil::IfcBaseClass* instance = EntityById(instance_id);
|
IfcUtil::IfcBaseClass* instance = entityById(instance_id);
|
||||||
|
|
||||||
IfcEntityList::ptr l = IfcEntityList::ptr(new IfcEntityList);
|
IfcEntityList::ptr l = IfcEntityList::ptr(new IfcEntityList);
|
||||||
IfcEntityList::ptr all = EntitiesByReference(instance_id);
|
IfcEntityList::ptr all = entitiesByReference(instance_id);
|
||||||
if (!all) return l;
|
if (!all) return l;
|
||||||
|
|
||||||
for(IfcEntityList::it it = all->begin(); it != all->end(); ++it) {
|
for(IfcEntityList::it it = all->begin(); it != all->end(); ++it) {
|
||||||
@@ -1378,7 +1378,7 @@ void IfcFile::setDefaultHeaderValues() {
|
|||||||
|
|
||||||
std::pair<IfcSchema::IfcNamedUnit*, double> IfcFile::getUnit(IfcSchema::IfcUnitEnum::IfcUnitEnum type) {
|
std::pair<IfcSchema::IfcNamedUnit*, double> IfcFile::getUnit(IfcSchema::IfcUnitEnum::IfcUnitEnum type) {
|
||||||
std::pair<IfcSchema::IfcNamedUnit*, double> return_value((IfcSchema::IfcNamedUnit*)0, 1.);
|
std::pair<IfcSchema::IfcNamedUnit*, double> return_value((IfcSchema::IfcNamedUnit*)0, 1.);
|
||||||
IfcSchema::IfcProject::list::ptr projects = EntitiesByType<IfcSchema::IfcProject>();
|
IfcSchema::IfcProject::list::ptr projects = entitiesByType<IfcSchema::IfcProject>();
|
||||||
if (projects->size() == 1) {
|
if (projects->size() == 1) {
|
||||||
IfcSchema::IfcProject* project = *projects->begin();
|
IfcSchema::IfcProject* project = *projects->begin();
|
||||||
IfcEntityList::ptr units = project->UnitsInContext()->Units();
|
IfcEntityList::ptr units = project->UnitsInContext()->Units();
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
if (instance->is(IfcSchema::Type::IfcProduct)) {
|
if (instance->is(IfcSchema::Type::IfcProduct)) {
|
||||||
IfcParse::IfcFile* file = instance->entity->file;
|
IfcParse::IfcFile* file = instance->entity->file;
|
||||||
|
|
||||||
IfcSchema::IfcProject::list::ptr projects = file->EntitiesByType<IfcSchema::IfcProject>();
|
IfcSchema::IfcProject::list::ptr projects = file->entitiesByType<IfcSchema::IfcProject>();
|
||||||
if (projects->size() != 1) {
|
if (projects->size() != 1) {
|
||||||
throw IfcParse::IfcException("Not a single IfcProject instance");
|
throw IfcParse::IfcException("Not a single IfcProject instance");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ namespace IfcUtil {
|
|||||||
%ignore IfcParse::IfcLateBoundEntity::IfcLateBoundEntity(IfcAbstractEntity*);
|
%ignore IfcParse::IfcLateBoundEntity::IfcLateBoundEntity(IfcAbstractEntity*);
|
||||||
|
|
||||||
%ignore IfcParse::IfcFile::Init;
|
%ignore IfcParse::IfcFile::Init;
|
||||||
%ignore IfcParse::IfcFile::EntityById;
|
%ignore IfcParse::IfcFile::entityById;
|
||||||
%ignore IfcParse::IfcFile::EntityByGuid;
|
%ignore IfcParse::IfcFile::entityByGuid;
|
||||||
%ignore IfcParse::IfcFile::addEntity;
|
%ignore IfcParse::IfcFile::addEntity;
|
||||||
%ignore IfcParse::IfcFile::removeEntity;
|
%ignore IfcParse::IfcFile::removeEntity;
|
||||||
%ignore IfcParse::IfcFile::traverse(IfcUtil::IfcBaseClass*, int);
|
%ignore IfcParse::IfcFile::traverse(IfcUtil::IfcBaseClass*, int);
|
||||||
@@ -54,7 +54,7 @@ namespace IfcUtil {
|
|||||||
%ignore IfcParse::IfcSpfHeader::stream;
|
%ignore IfcParse::IfcSpfHeader::stream;
|
||||||
%ignore IfcParse::HeaderEntity::is;
|
%ignore IfcParse::HeaderEntity::is;
|
||||||
|
|
||||||
%rename("by_type") EntitiesByType;
|
%rename("by_type") entitiesByType;
|
||||||
%rename("__len__") getArgumentCount;
|
%rename("__len__") getArgumentCount;
|
||||||
%rename("get_argument_type") getArgumentType;
|
%rename("get_argument_type") getArgumentType;
|
||||||
%rename("get_argument_name") getArgumentName;
|
%rename("get_argument_name") getArgumentName;
|
||||||
@@ -180,10 +180,10 @@ namespace IfcUtil {
|
|||||||
|
|
||||||
%extend IfcParse::IfcFile {
|
%extend IfcParse::IfcFile {
|
||||||
IfcParse::IfcLateBoundEntity* by_id(unsigned id) {
|
IfcParse::IfcLateBoundEntity* by_id(unsigned id) {
|
||||||
return (IfcParse::IfcLateBoundEntity*) $self->EntityById(id);
|
return (IfcParse::IfcLateBoundEntity*) $self->entityById(id);
|
||||||
}
|
}
|
||||||
IfcParse::IfcLateBoundEntity* by_guid(const std::string& guid) {
|
IfcParse::IfcLateBoundEntity* by_guid(const std::string& guid) {
|
||||||
return (IfcParse::IfcLateBoundEntity*) $self->EntityByGuid(guid);
|
return (IfcParse::IfcLateBoundEntity*) $self->entityByGuid(guid);
|
||||||
}
|
}
|
||||||
IfcParse::IfcLateBoundEntity* add(IfcParse::IfcLateBoundEntity* e) {
|
IfcParse::IfcLateBoundEntity* add(IfcParse::IfcLateBoundEntity* e) {
|
||||||
return (IfcParse::IfcLateBoundEntity*) $self->addEntity(e);
|
return (IfcParse::IfcLateBoundEntity*) $self->addEntity(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user