mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
#2805 IfcGeom updates
This commit is contained in:
@@ -985,12 +985,12 @@ std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn
|
|||||||
bool length_unit_encountered = false, angle_unit_encountered = false;
|
bool length_unit_encountered = false, angle_unit_encountered = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
aggregate_of_instance::ptr units = unit_assignment->Units();
|
auto units = unit_assignment->Units();
|
||||||
if (!units || !units->size()) {
|
if (!units || !units->size()) {
|
||||||
Logger::Warning("No unit information found");
|
Logger::Warning("No unit information found");
|
||||||
} else {
|
} else {
|
||||||
for (aggregate_of_instance::it it = units->begin(); it != units->end(); ++it) {
|
for (auto it = units->begin(); it != units->end(); ++it) {
|
||||||
IfcUtil::IfcBaseClass* base = *it;
|
IfcSchema::IfcUnit* base = *it;
|
||||||
if (base->declaration().is(IfcSchema::IfcNamedUnit::Class())) {
|
if (base->declaration().is(IfcSchema::IfcNamedUnit::Class())) {
|
||||||
IfcSchema::IfcNamedUnit* named_unit = base->as<IfcSchema::IfcNamedUnit>();
|
IfcSchema::IfcNamedUnit* named_unit = base->as<IfcSchema::IfcNamedUnit>();
|
||||||
if (named_unit->UnitType() == IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT ||
|
if (named_unit->UnitType() == IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT ||
|
||||||
|
|||||||
@@ -299,8 +299,8 @@ public:
|
|||||||
std::vector<IfcSchema::IfcPresentationStyle*> prs_styles;
|
std::vector<IfcSchema::IfcPresentationStyle*> prs_styles;
|
||||||
|
|
||||||
#ifdef SCHEMA_HAS_IfcStyleAssignmentSelect
|
#ifdef SCHEMA_HAS_IfcStyleAssignmentSelect
|
||||||
aggregate_of_instance::ptr style_assignments = si->Styles();
|
auto style_assignments = si->Styles();
|
||||||
for (aggregate_of_instance::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
|
for (auto kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
|
||||||
|
|
||||||
// Using IfcPresentationStyleAssignment is deprecated, use the direct assignment of a subtype of IfcPresentationStyle instead.
|
// Using IfcPresentationStyleAssignment is deprecated, use the direct assignment of a subtype of IfcPresentationStyle instead.
|
||||||
auto style_k = (*kt)->as<IfcSchema::IfcPresentationStyle>();
|
auto style_k = (*kt)->as<IfcSchema::IfcPresentationStyle>();
|
||||||
@@ -345,8 +345,8 @@ public:
|
|||||||
if (style->declaration().is(IfcSchema::IfcSurfaceStyle::Class())) {
|
if (style->declaration().is(IfcSchema::IfcSurfaceStyle::Class())) {
|
||||||
IfcSchema::IfcSurfaceStyle* surface_style = (IfcSchema::IfcSurfaceStyle*) style;
|
IfcSchema::IfcSurfaceStyle* surface_style = (IfcSchema::IfcSurfaceStyle*) style;
|
||||||
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
|
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
|
||||||
aggregate_of_instance::ptr styles_elements = surface_style->Styles();
|
auto styles_elements = surface_style->Styles();
|
||||||
for (aggregate_of_instance::it mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
|
for (auto mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
|
||||||
if ((*mt)->declaration().is(T::Class())) {
|
if ((*mt)->declaration().is(T::Class())) {
|
||||||
return std::make_pair(surface_style, (T*) *mt);
|
return std::make_pair(surface_style, (T*) *mt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta
|
|||||||
const bool include_curves = getValue(GV_DIMENSIONALITY) != +1;
|
const bool include_curves = getValue(GV_DIMENSIONALITY) != +1;
|
||||||
const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1;
|
const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1;
|
||||||
|
|
||||||
aggregate_of_instance::ptr elements = l->Elements();
|
auto elements = l->Elements();
|
||||||
if ( !elements->size() ) return false;
|
if (!elements->size()) return false;
|
||||||
bool part_succes = false;
|
bool part_succes = false;
|
||||||
auto parent_style = get_style(l);
|
auto parent_style = get_style(l);
|
||||||
for (aggregate_of_instance::it it = elements->begin(); it != elements->end(); ++it) {
|
for (auto it = elements->begin(); it != elements->end(); ++it) {
|
||||||
auto element = *it;
|
auto element = *it;
|
||||||
TopoDS_Shape s;
|
TopoDS_Shape s;
|
||||||
if (shape_type(element) == ST_SHAPELIST) {
|
if (shape_type(element) == ST_SHAPELIST) {
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wi
|
|||||||
double u, v;
|
double u, v;
|
||||||
|
|
||||||
if(l->Segments()) {
|
if(l->Segments()) {
|
||||||
aggregate_of_instance::ptr segments = *l->Segments();
|
auto segments = *l->Segments();
|
||||||
for (aggregate_of_instance::it it = segments->begin(); it != segments->end(); ++it) {
|
for (auto it = segments->begin(); it != segments->end(); ++it) {
|
||||||
IfcUtil::IfcBaseClass* segment = *it;
|
auto segment = *it;
|
||||||
if (segment->declaration().is(IfcSchema::IfcLineIndex::Class())) {
|
if (segment->declaration().is(IfcSchema::IfcLineIndex::Class())) {
|
||||||
IfcSchema::IfcLineIndex* line = (IfcSchema::IfcLineIndex*) segment;
|
IfcSchema::IfcLineIndex* line = (IfcSchema::IfcLineIndex*) segment;
|
||||||
std::vector<int> indices = *line;
|
std::vector<int> indices = *line;
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
#define Kernel MAKE_TYPE_NAME(Kernel)
|
#define Kernel MAKE_TYPE_NAME(Kernel)
|
||||||
|
|
||||||
bool IfcGeom::Kernel::convert(const IfcSchema::IfcShellBasedSurfaceModel* l, IfcRepresentationShapeItems& shapes) {
|
bool IfcGeom::Kernel::convert(const IfcSchema::IfcShellBasedSurfaceModel* l, IfcRepresentationShapeItems& shapes) {
|
||||||
aggregate_of_instance::ptr shells = l->SbsmBoundary();
|
auto shells = l->SbsmBoundary();
|
||||||
auto collective_style = get_style(l);
|
auto collective_style = get_style(l);
|
||||||
for( aggregate_of_instance::it it = shells->begin(); it != shells->end(); ++ it ) {
|
for(auto it = shells->begin(); it != shells->end(); ++ it) {
|
||||||
TopoDS_Shape s;
|
TopoDS_Shape s;
|
||||||
decltype(collective_style) shell_style;
|
decltype(collective_style) shell_style;
|
||||||
if ((*it)->declaration().is(IfcSchema::IfcRepresentationItem::Class())) {
|
if ((*it)->declaration().is(IfcSchema::IfcRepresentationItem::Class())) {
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool trim_cartesian = l->MasterRepresentation() != IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER;
|
bool trim_cartesian = l->MasterRepresentation() != IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER;
|
||||||
aggregate_of_instance::ptr trims1 = l->Trim1();
|
auto trims1 = l->Trim1();
|
||||||
aggregate_of_instance::ptr trims2 = l->Trim2();
|
auto trims2 = l->Trim2();
|
||||||
|
|
||||||
unsigned sense_agreement = l->SenseAgreement() ? 0 : 1;
|
unsigned sense_agreement = l->SenseAgreement() ? 0 : 1;
|
||||||
double flts[2];
|
double flts[2];
|
||||||
@@ -83,8 +83,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
|
|||||||
|
|
||||||
TopoDS_Edge e;
|
TopoDS_Edge e;
|
||||||
|
|
||||||
for ( aggregate_of_instance::it it = trims1->begin(); it != trims1->end(); it ++ ) {
|
for (auto it = trims1->begin(); it != trims1->end(); it ++ ) {
|
||||||
IfcUtil::IfcBaseClass* i = *it;
|
auto i = *it;
|
||||||
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
|
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
|
||||||
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[sense_agreement] );
|
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[sense_agreement] );
|
||||||
has_pnts[sense_agreement] = true;
|
has_pnts[sense_agreement] = true;
|
||||||
@@ -95,8 +95,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( aggregate_of_instance::it it = trims2->begin(); it != trims2->end(); it ++ ) {
|
for (auto it = trims2->begin(); it != trims2->end(); it ++ ) {
|
||||||
IfcUtil::IfcBaseClass* i = *it;
|
auto i = *it;
|
||||||
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
|
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
|
||||||
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[1-sense_agreement] );
|
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[1-sense_agreement] );
|
||||||
has_pnts[1-sense_agreement] = true;
|
has_pnts[1-sense_agreement] = true;
|
||||||
|
|||||||
@@ -395,8 +395,8 @@ int convert_to_ifc(const TopoDS_Edge& e, IfcSchema::IfcCurve*& c, bool advanced)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
aggregate_of_instance::ptr trim1(new aggregate_of_instance);
|
IfcSchema::IfcTrimmingSelect::list::ptr trim1(new IfcSchema::IfcTrimmingSelect::list);
|
||||||
aggregate_of_instance::ptr trim2(new aggregate_of_instance);
|
IfcSchema::IfcTrimmingSelect::list::ptr trim2(new IfcSchema::IfcTrimmingSelect::list);
|
||||||
trim1->push(new IfcSchema::IfcParameterValue(a));
|
trim1->push(new IfcSchema::IfcParameterValue(a));
|
||||||
trim2->push(new IfcSchema::IfcParameterValue(b));
|
trim2->push(new IfcSchema::IfcParameterValue(b));
|
||||||
|
|
||||||
@@ -631,7 +631,7 @@ IfcUtil::IfcBaseClass* IfcGeom::MAKE_TYPE_NAME(serialise_)(const TopoDS_Shape& s
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If not, see if there is a shell
|
// If not, see if there is a shell
|
||||||
IfcSchema::IfcOpenShell::list::ptr shells(new IfcSchema::IfcOpenShell::list);
|
IfcSchema::IfcShell::list::ptr shells(new IfcSchema::IfcShell::list);
|
||||||
for (TopExp_Explorer exp(shape, TopAbs_SHELL); exp.More(); exp.Next()) {
|
for (TopExp_Explorer exp(shape, TopAbs_SHELL); exp.More(); exp.Next()) {
|
||||||
IfcSchema::IfcOpenShell* shell;
|
IfcSchema::IfcOpenShell* shell;
|
||||||
if (!convert_to_ifc(exp.Current(), shell, advanced)) {
|
if (!convert_to_ifc(exp.Current(), shell, advanced)) {
|
||||||
@@ -641,7 +641,7 @@ IfcUtil::IfcBaseClass* IfcGeom::MAKE_TYPE_NAME(serialise_)(const TopoDS_Shape& s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shells->size() > 0) {
|
if (shells->size() > 0) {
|
||||||
items->push(new IfcSchema::IfcShellBasedSurfaceModel(shells->generalize()));
|
items->push(new IfcSchema::IfcShellBasedSurfaceModel(shells));
|
||||||
rep = new IfcSchema::IfcShapeRepresentation(0, std::string("Body"), advanced ? std::string("AdvancedBrep") : std::string("Brep"), items);
|
rep = new IfcSchema::IfcShapeRepresentation(0, std::string("Body"), advanced ? std::string("AdvancedBrep") : std::string("Brep"), items);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -674,7 +674,7 @@ IfcUtil::IfcBaseClass* IfcGeom::MAKE_TYPE_NAME(serialise_)(const TopoDS_Shape& s
|
|||||||
rep = new IfcSchema::IfcShapeRepresentation(0, std::string("Axis"), std::string("Curve2D"), edges->as<IfcSchema::IfcRepresentationItem>());
|
rep = new IfcSchema::IfcShapeRepresentation(0, std::string("Axis"), std::string("Curve2D"), edges->as<IfcSchema::IfcRepresentationItem>());
|
||||||
} else {
|
} else {
|
||||||
// A geometric set is created as that probably (?) makes more sense in IFC
|
// A geometric set is created as that probably (?) makes more sense in IFC
|
||||||
IfcSchema::IfcGeometricCurveSet* curves = new IfcSchema::IfcGeometricCurveSet(edges);
|
IfcSchema::IfcGeometricCurveSet* curves = new IfcSchema::IfcGeometricCurveSet(edges->as<IfcSchema::IfcGeometricSetSelect>());
|
||||||
items->push(curves);
|
items->push(curves);
|
||||||
rep = new IfcSchema::IfcShapeRepresentation(0, std::string("Axis"), std::string("GeometricCurveSet"), items->as<IfcSchema::IfcRepresentationItem>());
|
rep = new IfcSchema::IfcShapeRepresentation(0, std::string("Axis"), std::string("GeometricCurveSet"), items->as<IfcSchema::IfcRepresentationItem>());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -747,8 +747,8 @@ void MAKE_TYPE_NAME(XmlSerializer)::finalize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write all assigned units as XML nodes.
|
// Write all assigned units as XML nodes.
|
||||||
aggregate_of_instance::ptr unit_assignments = project->UnitsInContext()->Units();
|
auto unit_assignments = project->UnitsInContext()->Units();
|
||||||
for (aggregate_of_instance::it it = unit_assignments->begin(); it != unit_assignments->end(); ++it) {
|
for (auto it = unit_assignments->begin(); it != unit_assignments->end(); ++it) {
|
||||||
if ((*it)->declaration().is(IfcSchema::IfcNamedUnit::Class())) {
|
if ((*it)->declaration().is(IfcSchema::IfcNamedUnit::Class())) {
|
||||||
IfcSchema::IfcNamedUnit* named_unit = (*it)->as<IfcSchema::IfcNamedUnit>();
|
IfcSchema::IfcNamedUnit* named_unit = (*it)->as<IfcSchema::IfcNamedUnit>();
|
||||||
ptree* node = format_entity_instance(named_unit, units);
|
ptree* node = format_entity_instance(named_unit, units);
|
||||||
|
|||||||
Reference in New Issue
Block a user