mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
[read carefully before decide merge] !!! normalize line endings of src files (#1268)
* all source: prepare to normalize line ending * all src: normalize line endings
This commit is contained in:
@@ -19,34 +19,45 @@
|
|||||||
|
|
||||||
|
|
||||||
# normalize the line endings of the following files
|
# normalize the line endings of the following files
|
||||||
# standard files
|
*.cpp text
|
||||||
|
*.css text
|
||||||
|
*.csv text
|
||||||
*.feature text
|
*.feature text
|
||||||
|
*.gitattributes text
|
||||||
|
*.gitignore text
|
||||||
|
*.gitkeep
|
||||||
|
*.h text
|
||||||
*.html text
|
*.html text
|
||||||
*.ifc text
|
*.ifc text
|
||||||
|
*.json text
|
||||||
*.md text
|
*.md text
|
||||||
*.po text
|
*.po text
|
||||||
*.pot text
|
*.pot text
|
||||||
*.py text
|
*.py text
|
||||||
|
*.txt text
|
||||||
|
|
||||||
|
|
||||||
# files which are human readable
|
# files not normalized ATM
|
||||||
# but for which it is not sure if normalize is ok
|
# bat
|
||||||
# svg
|
# bnf
|
||||||
|
# blend
|
||||||
|
# i
|
||||||
# binary files
|
|
||||||
# ico
|
# ico
|
||||||
# mo
|
# mo
|
||||||
|
# mpass
|
||||||
|
# png
|
||||||
|
# pth
|
||||||
|
# pyc
|
||||||
|
# rst
|
||||||
|
# svg
|
||||||
|
# ttf
|
||||||
|
# xsd
|
||||||
|
|
||||||
|
|
||||||
# line endings of the directories commented will be normalized
|
# line endings of all directories will be normalized
|
||||||
# bimtester/** -text
|
# to exclude a directory from being normalized add it here
|
||||||
# examples/** -text
|
# example: to exclude dirctory ifcbimtester use the following line without #
|
||||||
|
# ifcbimtester/** -text
|
||||||
|
|
||||||
# line endings of the directories NOT commented will NOT be normalized
|
|
||||||
# Be carefully changes here could affect a lot of files automatically!
|
|
||||||
# none ATM
|
|
||||||
|
|
||||||
|
|
||||||
# use git to manually correct the file endings
|
# use git to manually correct the file endings
|
||||||
+143
-143
@@ -1,143 +1,143 @@
|
|||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* *
|
* *
|
||||||
* This file is part of IfcOpenShell. *
|
* This file is part of IfcOpenShell. *
|
||||||
* *
|
* *
|
||||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||||
* it under the terms of the Lesser GNU General Public License as published by *
|
* it under the terms of the Lesser GNU General Public License as published by *
|
||||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
* *
|
* *
|
||||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
* Lesser GNU General Public License for more details. *
|
* Lesser GNU General Public License for more details. *
|
||||||
* *
|
* *
|
||||||
* You should have received a copy of the Lesser GNU General Public License *
|
* You should have received a copy of the Lesser GNU General Public License *
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
* *
|
* *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* *
|
* *
|
||||||
* Example of curve rebar. *
|
* Example of curve rebar. *
|
||||||
* *
|
* *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "ifcparse\Ifc2x3.h"
|
#include "ifcparse\Ifc2x3.h"
|
||||||
#include "ifcparse\IfcUtil.h"
|
#include "ifcparse\IfcUtil.h"
|
||||||
#include "ifcparse\IfcHierarchyHelper.h"
|
#include "ifcparse\IfcHierarchyHelper.h"
|
||||||
#include "ifcgeom\IfcGeom.h"
|
#include "ifcgeom\IfcGeom.h"
|
||||||
|
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
typedef IfcParse::IfcGlobalId guid;
|
typedef IfcParse::IfcGlobalId guid;
|
||||||
boost::none_t const null = boost::none;
|
boost::none_t const null = boost::none;
|
||||||
|
|
||||||
void create_curve_rebar(IfcHierarchyHelper& file)
|
void create_curve_rebar(IfcHierarchyHelper& file)
|
||||||
{
|
{
|
||||||
int dia = 24;
|
int dia = 24;
|
||||||
int R = 3 * dia;
|
int R = 3 * dia;
|
||||||
int length = 12 * dia;
|
int length = 12 * dia;
|
||||||
|
|
||||||
double crossSectionarea = M_PI * (dia / 2) * 2;
|
double crossSectionarea = M_PI * (dia / 2) * 2;
|
||||||
IfcSchema::IfcReinforcingBar* rebar = new IfcSchema::IfcReinforcingBar(
|
IfcSchema::IfcReinforcingBar* rebar = new IfcSchema::IfcReinforcingBar(
|
||||||
guid(), 0, S("test"), null,
|
guid(), 0, S("test"), null,
|
||||||
null, 0, 0,
|
null, 0, 0,
|
||||||
null, S("SR24"), //SteelGrade
|
null, S("SR24"), //SteelGrade
|
||||||
dia, //diameter
|
dia, //diameter
|
||||||
crossSectionarea, //crossSectionarea = math.pi*(12.0/2)**2
|
crossSectionarea, //crossSectionarea = math.pi*(12.0/2)**2
|
||||||
0,
|
0,
|
||||||
IfcSchema::IfcReinforcingBarRoleEnum::IfcReinforcingBarRoleEnum::IfcReinforcingBarRole_LIGATURE,
|
IfcSchema::IfcReinforcingBarRoleEnum::IfcReinforcingBarRoleEnum::IfcReinforcingBarRole_LIGATURE,
|
||||||
IfcSchema::IfcReinforcingBarSurfaceEnum::IfcReinforcingBarSurfaceEnum::IfcReinforcingBarSurface_PLAIN //PLAIN or TEXTURED
|
IfcSchema::IfcReinforcingBarSurfaceEnum::IfcReinforcingBarSurfaceEnum::IfcReinforcingBarSurface_PLAIN //PLAIN or TEXTURED
|
||||||
);
|
);
|
||||||
|
|
||||||
file.addBuildingProduct(rebar);
|
file.addBuildingProduct(rebar);
|
||||||
rebar->setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
|
rebar->setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
|
||||||
|
|
||||||
IfcSchema::IfcCompositeCurveSegment::list::ptr segments(new IfcSchema::IfcCompositeCurveSegment::list());
|
IfcSchema::IfcCompositeCurveSegment::list::ptr segments(new IfcSchema::IfcCompositeCurveSegment::list());
|
||||||
|
|
||||||
IfcSchema::IfcCartesianPoint* p1 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, 0, 1000.);
|
IfcSchema::IfcCartesianPoint* p1 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, 0, 1000.);
|
||||||
IfcSchema::IfcCartesianPoint* p2 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, 0, 0);
|
IfcSchema::IfcCartesianPoint* p2 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, 0, 0);
|
||||||
IfcSchema::IfcCartesianPoint* p3 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, R, 0);
|
IfcSchema::IfcCartesianPoint* p3 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, R, 0);
|
||||||
IfcSchema::IfcCartesianPoint* p4 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, R, -R);
|
IfcSchema::IfcCartesianPoint* p4 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, R, -R);
|
||||||
IfcSchema::IfcCartesianPoint* p5 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, R + length, -R);
|
IfcSchema::IfcCartesianPoint* p5 = file.addTriplet<IfcSchema::IfcCartesianPoint>(0, R + length, -R);
|
||||||
|
|
||||||
/*first segment - line */
|
/*first segment - line */
|
||||||
IfcSchema::IfcCartesianPoint::list::ptr points1(new IfcSchema::IfcCartesianPoint::list());
|
IfcSchema::IfcCartesianPoint::list::ptr points1(new IfcSchema::IfcCartesianPoint::list());
|
||||||
points1->push(p1);
|
points1->push(p1);
|
||||||
points1->push(p2);
|
points1->push(p2);
|
||||||
file.addEntities(points1->generalize());
|
file.addEntities(points1->generalize());
|
||||||
IfcSchema::IfcPolyline* poly1 = new IfcSchema::IfcPolyline(points1);
|
IfcSchema::IfcPolyline* poly1 = new IfcSchema::IfcPolyline(points1);
|
||||||
file.addEntity(poly1);
|
file.addEntity(poly1);
|
||||||
|
|
||||||
IfcSchema::IfcCompositeCurveSegment* segment1 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, poly1);
|
IfcSchema::IfcCompositeCurveSegment* segment1 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, poly1);
|
||||||
file.addEntity(segment1);
|
file.addEntity(segment1);
|
||||||
segments->push(segment1);
|
segments->push(segment1);
|
||||||
|
|
||||||
/*second segment - arc */
|
/*second segment - arc */
|
||||||
IfcSchema::IfcAxis2Placement3D* axis1 = new IfcSchema::IfcAxis2Placement3D(p3, file.addTriplet<IfcSchema::IfcDirection>(1, 0, 0), file.addTriplet<IfcSchema::IfcDirection>(0, 1, 0));
|
IfcSchema::IfcAxis2Placement3D* axis1 = new IfcSchema::IfcAxis2Placement3D(p3, file.addTriplet<IfcSchema::IfcDirection>(1, 0, 0), file.addTriplet<IfcSchema::IfcDirection>(0, 1, 0));
|
||||||
file.addEntity(axis1);
|
file.addEntity(axis1);
|
||||||
IfcSchema::IfcCircle* circle = new IfcSchema::IfcCircle(axis1, R);
|
IfcSchema::IfcCircle* circle = new IfcSchema::IfcCircle(axis1, R);
|
||||||
file.addEntity(circle);
|
file.addEntity(circle);
|
||||||
|
|
||||||
IfcEntityList::ptr trim1(new IfcEntityList);
|
IfcEntityList::ptr trim1(new IfcEntityList);
|
||||||
IfcEntityList::ptr trim2(new IfcEntityList);
|
IfcEntityList::ptr trim2(new IfcEntityList);
|
||||||
|
|
||||||
trim1->push(new IfcSchema::IfcParameterValue(180));
|
trim1->push(new IfcSchema::IfcParameterValue(180));
|
||||||
trim1->push(p2);
|
trim1->push(p2);
|
||||||
|
|
||||||
trim2->push(new IfcSchema::IfcParameterValue(270));
|
trim2->push(new IfcSchema::IfcParameterValue(270));
|
||||||
trim2->push(p4);
|
trim2->push(p4);
|
||||||
IfcSchema::IfcTrimmedCurve* trimmed_curve = new IfcSchema::IfcTrimmedCurve(circle, trim1, trim2, false, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER);
|
IfcSchema::IfcTrimmedCurve* trimmed_curve = new IfcSchema::IfcTrimmedCurve(circle, trim1, trim2, false, IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER);
|
||||||
file.addEntity(trimmed_curve);
|
file.addEntity(trimmed_curve);
|
||||||
|
|
||||||
IfcSchema::IfcCompositeCurveSegment* segment2 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT, false, trimmed_curve);
|
IfcSchema::IfcCompositeCurveSegment* segment2 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTSAMEGRADIENT, false, trimmed_curve);
|
||||||
file.addEntity(segment2);
|
file.addEntity(segment2);
|
||||||
segments->push(segment2);
|
segments->push(segment2);
|
||||||
|
|
||||||
/*third segment - line */
|
/*third segment - line */
|
||||||
IfcSchema::IfcCartesianPoint::list::ptr points2(new IfcSchema::IfcCartesianPoint::list());
|
IfcSchema::IfcCartesianPoint::list::ptr points2(new IfcSchema::IfcCartesianPoint::list());
|
||||||
points2->push(p4);
|
points2->push(p4);
|
||||||
points2->push(p5);
|
points2->push(p5);
|
||||||
file.addEntities(points2->generalize());
|
file.addEntities(points2->generalize());
|
||||||
IfcSchema::IfcPolyline* poly2 = new IfcSchema::IfcPolyline(points2);
|
IfcSchema::IfcPolyline* poly2 = new IfcSchema::IfcPolyline(points2);
|
||||||
file.addEntity(poly2);
|
file.addEntity(poly2);
|
||||||
|
|
||||||
IfcSchema::IfcCompositeCurveSegment* segment3 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, poly2);
|
IfcSchema::IfcCompositeCurveSegment* segment3 = new IfcSchema::IfcCompositeCurveSegment(IfcSchema::IfcTransitionCode::IfcTransitionCode_CONTINUOUS, true, poly2);
|
||||||
file.addEntity(segment3);
|
file.addEntity(segment3);
|
||||||
segments->push(segment3);
|
segments->push(segment3);
|
||||||
|
|
||||||
IfcSchema::IfcCompositeCurve* curve = new IfcSchema::IfcCompositeCurve(segments, false);
|
IfcSchema::IfcCompositeCurve* curve = new IfcSchema::IfcCompositeCurve(segments, false);
|
||||||
file.addEntity(curve);
|
file.addEntity(curve);
|
||||||
|
|
||||||
IfcSchema::IfcSweptDiskSolid* solid = new IfcSchema::IfcSweptDiskSolid(curve, dia / 2, null, 0, 1);
|
IfcSchema::IfcSweptDiskSolid* solid = new IfcSchema::IfcSweptDiskSolid(curve, dia / 2, null, 0, 1);
|
||||||
|
|
||||||
IfcSchema::IfcRepresentation::list::ptr reps(new IfcSchema::IfcRepresentation::list());
|
IfcSchema::IfcRepresentation::list::ptr reps(new IfcSchema::IfcRepresentation::list());
|
||||||
IfcSchema::IfcRepresentationItem::list::ptr items(new IfcSchema::IfcRepresentationItem::list());
|
IfcSchema::IfcRepresentationItem::list::ptr items(new IfcSchema::IfcRepresentationItem::list());
|
||||||
items->push(solid);
|
items->push(solid);
|
||||||
IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation(
|
IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation(
|
||||||
file.getSingle<IfcSchema::IfcRepresentationContext>(), S("Body"), S("AdvancedSweptSolid"), items);
|
file.getSingle<IfcSchema::IfcRepresentationContext>(), S("Body"), S("AdvancedSweptSolid"), items);
|
||||||
reps->push(rep);
|
reps->push(rep);
|
||||||
|
|
||||||
IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(null, null, reps);
|
IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(null, null, reps);
|
||||||
file.addEntity(shape);
|
file.addEntity(shape);
|
||||||
|
|
||||||
rebar->setRepresentation(shape);
|
rebar->setRepresentation(shape);
|
||||||
|
|
||||||
IfcSchema::IfcObjectPlacement* storey_placement = file.getSingle<IfcSchema::IfcBuildingStorey>()->ObjectPlacement();
|
IfcSchema::IfcObjectPlacement* storey_placement = file.getSingle<IfcSchema::IfcBuildingStorey>()->ObjectPlacement();
|
||||||
rebar->setObjectPlacement(file.addLocalPlacement(storey_placement, 0, 0, 0));
|
rebar->setObjectPlacement(file.addLocalPlacement(storey_placement, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
IfcHierarchyHelper file;
|
IfcHierarchyHelper file;
|
||||||
file.header().file_name().name("ifc_curve_rebar.ifc");
|
file.header().file_name().name("ifc_curve_rebar.ifc");
|
||||||
create_curve_rebar(file);
|
create_curve_rebar(file);
|
||||||
std::ofstream f("ifc_curve_rebar.ifc");
|
std::ofstream f("ifc_curve_rebar.ifc");
|
||||||
f << file;
|
f << file;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+903
-903
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,27 @@
|
|||||||
* { stroke-linecap: round; }
|
* { stroke-linecap: round; }
|
||||||
.cut { fill: black; stroke: black; stroke-linecap: 'round'; stroke-width: 0.35; }
|
.cut { fill: black; stroke: black; stroke-linecap: 'round'; stroke-width: 0.35; }
|
||||||
.background { fill: white; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
|
.background { fill: white; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
|
||||||
.annotation { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
|
.annotation { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
|
||||||
.hidden { stroke-dasharray: 3, 2; }
|
.hidden { stroke-dasharray: 3, 2; }
|
||||||
.solid {}
|
.solid {}
|
||||||
.leader { marker-end: url(#leader-marker); }
|
.leader { marker-end: url(#leader-marker); }
|
||||||
.stair { marker-start: url(#stair-marker-start); marker-end: url(#stair-marker-end); }
|
.stair { marker-start: url(#stair-marker-start); marker-end: url(#stair-marker-end); }
|
||||||
.break { fill: white; }
|
.break { fill: white; }
|
||||||
.breakline { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; marker-mid: url(#breakline-marker); }
|
.breakline { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; marker-mid: url(#breakline-marker); }
|
||||||
.material-blank { fill: white; }
|
.material-blank { fill: white; }
|
||||||
.material-diagonal1 { fill: url(#diagonal1); }
|
.material-diagonal1 { fill: url(#diagonal1); }
|
||||||
.material-diagonal2 { fill: url(#diagonal2); }
|
.material-diagonal2 { fill: url(#diagonal2); }
|
||||||
.material-diagonal3 { fill: url(#diagonal3); }
|
.material-diagonal3 { fill: url(#diagonal3); }
|
||||||
.material-crosshatch1 { fill: url(#crosshatch1); }
|
.material-crosshatch1 { fill: url(#crosshatch1); }
|
||||||
.material-crosshatch2 { fill: url(#crosshatch2); }
|
.material-crosshatch2 { fill: url(#crosshatch2); }
|
||||||
.material-crosshatch3 { fill: url(#crosshatch3); }
|
.material-crosshatch3 { fill: url(#crosshatch3); }
|
||||||
.material-brick { fill: url(#brick); }
|
.material-brick { fill: url(#brick); }
|
||||||
.material-earth { fill: url(#earth); }
|
.material-earth { fill: url(#earth); }
|
||||||
.material-glass { fill: url(#glass); }
|
.material-glass { fill: url(#glass); }
|
||||||
.material-liquid { fill: url(#liquid); }
|
.material-liquid { fill: url(#liquid); }
|
||||||
.material-grass { fill: url(#grass); }
|
.material-grass { fill: url(#grass); }
|
||||||
.material-honeycomb { fill: url(#honeycomb); }
|
.material-honeycomb { fill: url(#honeycomb); }
|
||||||
.material-sand { fill: url(#sand); }
|
.material-sand { fill: url(#sand); }
|
||||||
.material-concrete { fill: url(#concrete); stroke-width: 0.5; }
|
.material-concrete { fill: url(#concrete); stroke-width: 0.5; }
|
||||||
.material-boundary { fill: none; stroke: red; stroke-width: 1; stroke-dasharray: 12,4,3,4,3,4; }
|
.material-boundary { fill: none; stroke: red; stroke-width: 1; stroke-dasharray: 12,4,3,4,3,4; }
|
||||||
.IfcSpace { fill: none; stroke: none; }
|
.IfcSpace { fill: none; stroke: none; }
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+339
-339
@@ -1,339 +1,339 @@
|
|||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* *
|
* *
|
||||||
* This file is part of IfcOpenShell. *
|
* This file is part of IfcOpenShell. *
|
||||||
* *
|
* *
|
||||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||||
* it under the terms of the Lesser GNU General Public License as published by *
|
* it under the terms of the Lesser GNU General Public License as published by *
|
||||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
* *
|
* *
|
||||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
* Lesser GNU General Public License for more details. *
|
* Lesser GNU General Public License for more details. *
|
||||||
* *
|
* *
|
||||||
* You should have received a copy of the Lesser GNU General Public License *
|
* You should have received a copy of the Lesser GNU General Public License *
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
* *
|
* *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOMINMAX
|
#ifndef NOMINMAX
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOMSG
|
#ifndef NOMSG
|
||||||
#define NOMSG NOMSG
|
#define NOMSG NOMSG
|
||||||
#endif
|
#endif
|
||||||
#ifndef NODRAWTEXT
|
#ifndef NODRAWTEXT
|
||||||
#define NODRAWTEXT NODRAWTEXT
|
#define NODRAWTEXT NODRAWTEXT
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOGDI
|
#ifndef NOGDI
|
||||||
#define NOGDI NOGDI
|
#define NOGDI NOGDI
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOSERVICE
|
#ifndef NOSERVICE
|
||||||
#define NOSERVICE NOSERVICE
|
#define NOSERVICE NOSERVICE
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOKERNEL
|
#ifndef NOKERNEL
|
||||||
#define NOKERNEL NOKERNEL
|
#define NOKERNEL NOKERNEL
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOUSER
|
#ifndef NOUSER
|
||||||
#define NOUSER NOUSER
|
#define NOUSER NOUSER
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOMCX
|
#ifndef NOMCX
|
||||||
#define NOMCX NOMCX
|
#define NOMCX NOMCX
|
||||||
#endif
|
#endif
|
||||||
#ifndef NOIME
|
#ifndef NOIME
|
||||||
#define NOIME NOIME
|
#define NOIME NOIME
|
||||||
#endif
|
#endif
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../ifcparse/IfcBaseClass.h"
|
#include "../ifcparse/IfcBaseClass.h"
|
||||||
#include "../ifcparse/Argument.h"
|
#include "../ifcparse/Argument.h"
|
||||||
#include "../ifcparse/utils.h"
|
#include "../ifcparse/utils.h"
|
||||||
#include "../ifcparse/IfcException.h"
|
#include "../ifcparse/IfcException.h"
|
||||||
#include "../ifcparse/IfcEntityList.h"
|
#include "../ifcparse/IfcEntityList.h"
|
||||||
|
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
void IfcEntityList::push(IfcUtil::IfcBaseClass* l) {
|
void IfcEntityList::push(IfcUtil::IfcBaseClass* l) {
|
||||||
if (l) {
|
if (l) {
|
||||||
ls.push_back(l);
|
ls.push_back(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void IfcEntityList::push(const IfcEntityList::ptr& l) {
|
void IfcEntityList::push(const IfcEntityList::ptr& l) {
|
||||||
if (l) {
|
if (l) {
|
||||||
for( it i = l->begin(); i != l->end(); ++i ) {
|
for( it i = l->begin(); i != l->end(); ++i ) {
|
||||||
if ( *i ) ls.push_back(*i);
|
if ( *i ) ls.push_back(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned int IfcEntityList::size() const { return (unsigned int) ls.size(); }
|
unsigned int IfcEntityList::size() const { return (unsigned int) ls.size(); }
|
||||||
void IfcEntityList::reserve(unsigned capacity) { ls.reserve((size_t)capacity); }
|
void IfcEntityList::reserve(unsigned capacity) { ls.reserve((size_t)capacity); }
|
||||||
IfcEntityList::it IfcEntityList::begin() { return ls.begin(); }
|
IfcEntityList::it IfcEntityList::begin() { return ls.begin(); }
|
||||||
IfcEntityList::it IfcEntityList::end() { return ls.end(); }
|
IfcEntityList::it IfcEntityList::end() { return ls.end(); }
|
||||||
IfcUtil::IfcBaseClass* IfcEntityList::operator[] (int i) {
|
IfcUtil::IfcBaseClass* IfcEntityList::operator[] (int i) {
|
||||||
return ls[i];
|
return ls[i];
|
||||||
}
|
}
|
||||||
bool IfcEntityList::contains(IfcUtil::IfcBaseClass* instance) const {
|
bool IfcEntityList::contains(IfcUtil::IfcBaseClass* instance) const {
|
||||||
return std::find(ls.begin(), ls.end(), instance) != ls.end();
|
return std::find(ls.begin(), ls.end(), instance) != ls.end();
|
||||||
}
|
}
|
||||||
void IfcEntityList::remove(IfcUtil::IfcBaseClass* instance) {
|
void IfcEntityList::remove(IfcUtil::IfcBaseClass* instance) {
|
||||||
std::vector<IfcUtil::IfcBaseClass*>::iterator it;
|
std::vector<IfcUtil::IfcBaseClass*>::iterator it;
|
||||||
while ((it = std::find(ls.begin(), ls.end(), instance)) != ls.end()) {
|
while ((it = std::find(ls.begin(), ls.end(), instance)) != ls.end()) {
|
||||||
ls.erase(it);
|
ls.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcEntityList::ptr IfcEntityList::filtered(const std::set<const IfcParse::declaration*>& entities) {
|
IfcEntityList::ptr IfcEntityList::filtered(const std::set<const IfcParse::declaration*>& entities) {
|
||||||
IfcEntityList::ptr return_value(new IfcEntityList);
|
IfcEntityList::ptr return_value(new IfcEntityList);
|
||||||
for (it it = begin(); it != end(); ++it) {
|
for (it it = begin(); it != end(); ++it) {
|
||||||
bool contained = false;
|
bool contained = false;
|
||||||
for (std::set<const IfcParse::declaration*>::const_iterator jt = entities.begin(); jt != entities.end(); ++jt) {
|
for (std::set<const IfcParse::declaration*>::const_iterator jt = entities.begin(); jt != entities.end(); ++jt) {
|
||||||
if ((*it)->declaration().is(**jt)) {
|
if ((*it)->declaration().is(**jt)) {
|
||||||
contained = true;
|
contained = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!contained) {
|
if (!contained) {
|
||||||
return_value->push(*it);
|
return_value->push(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcEntityList::ptr IfcEntityList::unique() {
|
IfcEntityList::ptr IfcEntityList::unique() {
|
||||||
std::set<IfcUtil::IfcBaseClass*> encountered;
|
std::set<IfcUtil::IfcBaseClass*> encountered;
|
||||||
IfcEntityList::ptr return_value(new IfcEntityList);
|
IfcEntityList::ptr return_value(new IfcEntityList);
|
||||||
for (it it = begin(); it != end(); ++it) {
|
for (it it = begin(); it != end(); ++it) {
|
||||||
if (encountered.find(*it) == encountered.end()) {
|
if (encountered.find(*it) == encountered.end()) {
|
||||||
return_value->push(*it);
|
return_value->push(*it);
|
||||||
encountered.insert(*it);
|
encountered.insert(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Note: some of these methods are overloaded in derived classes
|
//Note: some of these methods are overloaded in derived classes
|
||||||
Argument::operator int() const { throw IfcParse::IfcException("Argument is not an integer"); }
|
Argument::operator int() const { throw IfcParse::IfcException("Argument is not an integer"); }
|
||||||
Argument::operator bool() const { throw IfcParse::IfcException("Argument is not a boolean"); }
|
Argument::operator bool() const { throw IfcParse::IfcException("Argument is not a boolean"); }
|
||||||
Argument::operator double() const { throw IfcParse::IfcException("Argument is not a number"); }
|
Argument::operator double() const { throw IfcParse::IfcException("Argument is not a number"); }
|
||||||
Argument::operator std::string() const { throw IfcParse::IfcException("Argument is not a string"); }
|
Argument::operator std::string() const { throw IfcParse::IfcException("Argument is not a string"); }
|
||||||
Argument::operator boost::dynamic_bitset<>() const { throw IfcParse::IfcException("Argument is not a binary"); }
|
Argument::operator boost::dynamic_bitset<>() const { throw IfcParse::IfcException("Argument is not a binary"); }
|
||||||
Argument::operator IfcUtil::IfcBaseClass*() const { throw IfcParse::IfcException("Argument is not an entity instance"); }
|
Argument::operator IfcUtil::IfcBaseClass*() const { throw IfcParse::IfcException("Argument is not an entity instance"); }
|
||||||
Argument::operator std::vector<double>() const { throw IfcParse::IfcException("Argument is not a list of floats"); }
|
Argument::operator std::vector<double>() const { throw IfcParse::IfcException("Argument is not a list of floats"); }
|
||||||
Argument::operator std::vector<int>() const { throw IfcParse::IfcException("Argument is not a list of ints"); }
|
Argument::operator std::vector<int>() const { throw IfcParse::IfcException("Argument is not a list of ints"); }
|
||||||
Argument::operator std::vector<std::string>() const { throw IfcParse::IfcException("Argument is not a list of strings"); }
|
Argument::operator std::vector<std::string>() const { throw IfcParse::IfcException("Argument is not a list of strings"); }
|
||||||
Argument::operator std::vector<boost::dynamic_bitset<> >() const { throw IfcParse::IfcException("Argument is not a list of binaries"); }
|
Argument::operator std::vector<boost::dynamic_bitset<> >() const { throw IfcParse::IfcException("Argument is not a list of binaries"); }
|
||||||
Argument::operator IfcEntityList::ptr() const { throw IfcParse::IfcException("Argument is not a list of entity instances"); }
|
Argument::operator IfcEntityList::ptr() const { throw IfcParse::IfcException("Argument is not a list of entity instances"); }
|
||||||
Argument::operator std::vector< std::vector<int> >() const { throw IfcParse::IfcException("Argument is not a list of list of ints"); }
|
Argument::operator std::vector< std::vector<int> >() const { throw IfcParse::IfcException("Argument is not a list of list of ints"); }
|
||||||
Argument::operator std::vector< std::vector<double> >() const { throw IfcParse::IfcException("Argument is not a list of list of floats"); }
|
Argument::operator std::vector< std::vector<double> >() const { throw IfcParse::IfcException("Argument is not a list of list of floats"); }
|
||||||
Argument::operator IfcEntityListList::ptr() const { throw IfcParse::IfcException("Argument is not a list of list of entity instances"); }
|
Argument::operator IfcEntityListList::ptr() const { throw IfcParse::IfcException("Argument is not a list of list of entity instances"); }
|
||||||
|
|
||||||
|
|
||||||
static const char* const argument_type_string[] = {
|
static const char* const argument_type_string[] = {
|
||||||
"NULL",
|
"NULL",
|
||||||
"DERIVED",
|
"DERIVED",
|
||||||
"INT",
|
"INT",
|
||||||
"BOOL",
|
"BOOL",
|
||||||
"DOUBLE",
|
"DOUBLE",
|
||||||
"STRING",
|
"STRING",
|
||||||
"BINARY",
|
"BINARY",
|
||||||
"ENUMERATION",
|
"ENUMERATION",
|
||||||
"ENTITY INSTANCE",
|
"ENTITY INSTANCE",
|
||||||
|
|
||||||
"EMPTY AGGREGATE",
|
"EMPTY AGGREGATE",
|
||||||
"AGGREGATE OF INT",
|
"AGGREGATE OF INT",
|
||||||
"AGGREGATE OF DOUBLE",
|
"AGGREGATE OF DOUBLE",
|
||||||
"AGGREGATE OF STRING",
|
"AGGREGATE OF STRING",
|
||||||
"AGGREGATE OF BINARY",
|
"AGGREGATE OF BINARY",
|
||||||
"AGGREGATE OF ENTITY INSTANCE",
|
"AGGREGATE OF ENTITY INSTANCE",
|
||||||
|
|
||||||
"AGGREGATE OF EMPTY AGGREGATE",
|
"AGGREGATE OF EMPTY AGGREGATE",
|
||||||
"AGGREGATE OF AGGREGATE OF INT",
|
"AGGREGATE OF AGGREGATE OF INT",
|
||||||
"AGGREGATE OF AGGREGATE OF DOUBLE",
|
"AGGREGATE OF AGGREGATE OF DOUBLE",
|
||||||
"AGGREGATE OF AGGREGATE OF ENTITY INSTANCE",
|
"AGGREGATE OF AGGREGATE OF ENTITY INSTANCE",
|
||||||
|
|
||||||
"UNKNOWN"
|
"UNKNOWN"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* IfcUtil::ArgumentTypeToString(ArgumentType argument_type) {
|
const char* IfcUtil::ArgumentTypeToString(ArgumentType argument_type) {
|
||||||
return argument_type_string[static_cast<int>(argument_type)];
|
return argument_type_string[static_cast<int>(argument_type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfcUtil::valid_binary_string(const std::string& s) {
|
bool IfcUtil::valid_binary_string(const std::string& s) {
|
||||||
for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
||||||
if (*it != '0' && *it != '1') return false;
|
if (*it != '0' && *it != '1') return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcUtil::sanitate_material_name(std::string &str)
|
void IfcUtil::sanitate_material_name(std::string &str)
|
||||||
{
|
{
|
||||||
// Spaces in material names have been observed to cause problems with obj and dae importers.
|
// Spaces in material names have been observed to cause problems with obj and dae importers.
|
||||||
// Handle other potential problematic characters here too if observing problems.
|
// Handle other potential problematic characters here too if observing problems.
|
||||||
boost::replace_all(str, " ", "_");
|
boost::replace_all(str, " ", "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcUtil::escape_xml(std::string &str)
|
void IfcUtil::escape_xml(std::string &str)
|
||||||
{
|
{
|
||||||
boost::replace_all(str, "&", "&");
|
boost::replace_all(str, "&", "&");
|
||||||
boost::replace_all(str, "\"", """);
|
boost::replace_all(str, "\"", """);
|
||||||
boost::replace_all(str, "'", "'");
|
boost::replace_all(str, "'", "'");
|
||||||
boost::replace_all(str, "<", "<");
|
boost::replace_all(str, "<", "<");
|
||||||
boost::replace_all(str, ">", ">");
|
boost::replace_all(str, ">", ">");
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcUtil::unescape_xml(std::string &str)
|
void IfcUtil::unescape_xml(std::string &str)
|
||||||
{
|
{
|
||||||
boost::replace_all(str, "&", "&");
|
boost::replace_all(str, "&", "&");
|
||||||
boost::replace_all(str, """, "\"");
|
boost::replace_all(str, """, "\"");
|
||||||
boost::replace_all(str, "'", "'");
|
boost::replace_all(str, "'", "'");
|
||||||
boost::replace_all(str, "<", "<");
|
boost::replace_all(str, "<", "<");
|
||||||
boost::replace_all(str, ">", ">");
|
boost::replace_all(str, ">", ">");
|
||||||
}
|
}
|
||||||
|
|
||||||
Argument* IfcUtil::IfcBaseEntity::get(const std::string& name) const {
|
Argument* IfcUtil::IfcBaseEntity::get(const std::string& name) const {
|
||||||
return data().getArgument(declaration().attribute_index(name));
|
return data().getArgument(declaration().attribute_index(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcEntityList::ptr IfcUtil::IfcBaseEntity::get_inverse(const std::string& name) const {
|
IfcEntityList::ptr IfcUtil::IfcBaseEntity::get_inverse(const std::string& name) const {
|
||||||
const std::vector<const IfcParse::inverse_attribute*> attrs = declaration().as_entity()->all_inverse_attributes();
|
const std::vector<const IfcParse::inverse_attribute*> attrs = declaration().as_entity()->all_inverse_attributes();
|
||||||
std::vector<const IfcParse::inverse_attribute*>::const_iterator it = attrs.begin();
|
std::vector<const IfcParse::inverse_attribute*>::const_iterator it = attrs.begin();
|
||||||
for (; it != attrs.end(); ++it) {
|
for (; it != attrs.end(); ++it) {
|
||||||
if ((*it)->name() == name) {
|
if ((*it)->name() == name) {
|
||||||
return data().getInverse(
|
return data().getInverse(
|
||||||
(*it)->entity_reference(),
|
(*it)->entity_reference(),
|
||||||
(*it)->entity_reference()->attribute_index((*it)->attribute_reference()));
|
(*it)->entity_reference()->attribute_index((*it)->attribute_reference()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw IfcParse::IfcException(name + " not found on " + declaration().name());
|
throw IfcParse::IfcException(name + " not found on " + declaration().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcUtil::IfcBaseClass::data(IfcEntityInstanceData* d) {
|
void IfcUtil::IfcBaseClass::data(IfcEntityInstanceData* d) {
|
||||||
delete data_;
|
delete data_;
|
||||||
data_ = d;
|
data_ = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcUtil::ArgumentType IfcUtil::make_aggregate(IfcUtil::ArgumentType elem_type) {
|
IfcUtil::ArgumentType IfcUtil::make_aggregate(IfcUtil::ArgumentType elem_type) {
|
||||||
if (elem_type == IfcUtil::Argument_INT) {
|
if (elem_type == IfcUtil::Argument_INT) {
|
||||||
return IfcUtil::Argument_AGGREGATE_OF_INT;
|
return IfcUtil::Argument_AGGREGATE_OF_INT;
|
||||||
} else if (elem_type == IfcUtil::Argument_DOUBLE) {
|
} else if (elem_type == IfcUtil::Argument_DOUBLE) {
|
||||||
return IfcUtil::Argument_AGGREGATE_OF_DOUBLE;
|
return IfcUtil::Argument_AGGREGATE_OF_DOUBLE;
|
||||||
} else if (elem_type == IfcUtil::Argument_STRING) {
|
} else if (elem_type == IfcUtil::Argument_STRING) {
|
||||||
return IfcUtil::Argument_AGGREGATE_OF_STRING;
|
return IfcUtil::Argument_AGGREGATE_OF_STRING;
|
||||||
} else if (elem_type == IfcUtil::Argument_BINARY) {
|
} else if (elem_type == IfcUtil::Argument_BINARY) {
|
||||||
return IfcUtil::Argument_AGGREGATE_OF_BINARY;
|
return IfcUtil::Argument_AGGREGATE_OF_BINARY;
|
||||||
} else if (elem_type == IfcUtil::Argument_ENTITY_INSTANCE) {
|
} else if (elem_type == IfcUtil::Argument_ENTITY_INSTANCE) {
|
||||||
return IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE;
|
return IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE;
|
||||||
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_INT) {
|
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_INT) {
|
||||||
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT;
|
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT;
|
||||||
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) {
|
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) {
|
||||||
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE;
|
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE;
|
||||||
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
|
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
|
||||||
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE;
|
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE;
|
||||||
} else if (elem_type == IfcUtil::Argument_EMPTY_AGGREGATE) {
|
} else if (elem_type == IfcUtil::Argument_EMPTY_AGGREGATE) {
|
||||||
return IfcUtil::Argument_AGGREGATE_OF_EMPTY_AGGREGATE;
|
return IfcUtil::Argument_AGGREGATE_OF_EMPTY_AGGREGATE;
|
||||||
} else {
|
} else {
|
||||||
return IfcUtil::Argument_UNKNOWN;
|
return IfcUtil::Argument_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcUtil::ArgumentType IfcUtil::from_parameter_type(const IfcParse::parameter_type* pt) {
|
IfcUtil::ArgumentType IfcUtil::from_parameter_type(const IfcParse::parameter_type* pt) {
|
||||||
// TODO: How to detect derived types here without a reference to the refering entity?
|
// TODO: How to detect derived types here without a reference to the refering entity?
|
||||||
|
|
||||||
const IfcParse::aggregation_type* at = pt->as_aggregation_type();
|
const IfcParse::aggregation_type* at = pt->as_aggregation_type();
|
||||||
const IfcParse::named_type* nt = pt->as_named_type();
|
const IfcParse::named_type* nt = pt->as_named_type();
|
||||||
const IfcParse::simple_type* st = pt->as_simple_type();
|
const IfcParse::simple_type* st = pt->as_simple_type();
|
||||||
|
|
||||||
if (at) {
|
if (at) {
|
||||||
return make_aggregate(from_parameter_type(at->type_of_element()));
|
return make_aggregate(from_parameter_type(at->type_of_element()));
|
||||||
} else if (nt) {
|
} else if (nt) {
|
||||||
if (nt->declared_type()->as_entity()) {
|
if (nt->declared_type()->as_entity()) {
|
||||||
return IfcUtil::Argument_ENTITY_INSTANCE;
|
return IfcUtil::Argument_ENTITY_INSTANCE;
|
||||||
} else if (nt->declared_type()->as_enumeration_type()) {
|
} else if (nt->declared_type()->as_enumeration_type()) {
|
||||||
return IfcUtil::Argument_ENUMERATION;
|
return IfcUtil::Argument_ENUMERATION;
|
||||||
} else if (nt->declared_type()->as_select_type()) {
|
} else if (nt->declared_type()->as_select_type()) {
|
||||||
return IfcUtil::Argument_ENTITY_INSTANCE;
|
return IfcUtil::Argument_ENTITY_INSTANCE;
|
||||||
} else if (nt->declared_type()->as_type_declaration()) {
|
} else if (nt->declared_type()->as_type_declaration()) {
|
||||||
return from_parameter_type(nt->declared_type()->as_type_declaration()->declared_type());
|
return from_parameter_type(nt->declared_type()->as_type_declaration()->declared_type());
|
||||||
}
|
}
|
||||||
} else if (st) {
|
} else if (st) {
|
||||||
switch (st->declared_type()) {
|
switch (st->declared_type()) {
|
||||||
case IfcParse::simple_type::binary_type:
|
case IfcParse::simple_type::binary_type:
|
||||||
return IfcUtil::Argument_BINARY;
|
return IfcUtil::Argument_BINARY;
|
||||||
case IfcParse::simple_type::boolean_type:
|
case IfcParse::simple_type::boolean_type:
|
||||||
return IfcUtil::Argument_BOOL;
|
return IfcUtil::Argument_BOOL;
|
||||||
case IfcParse::simple_type::integer_type:
|
case IfcParse::simple_type::integer_type:
|
||||||
return IfcUtil::Argument_INT;
|
return IfcUtil::Argument_INT;
|
||||||
case IfcParse::simple_type::logical_type:
|
case IfcParse::simple_type::logical_type:
|
||||||
return IfcUtil::Argument_BOOL;
|
return IfcUtil::Argument_BOOL;
|
||||||
case IfcParse::simple_type::number_type:
|
case IfcParse::simple_type::number_type:
|
||||||
return IfcUtil::Argument_DOUBLE;
|
return IfcUtil::Argument_DOUBLE;
|
||||||
case IfcParse::simple_type::real_type:
|
case IfcParse::simple_type::real_type:
|
||||||
return IfcUtil::Argument_DOUBLE;
|
return IfcUtil::Argument_DOUBLE;
|
||||||
case IfcParse::simple_type::string_type:
|
case IfcParse::simple_type::string_type:
|
||||||
return IfcUtil::Argument_STRING;
|
return IfcUtil::Argument_STRING;
|
||||||
case IfcParse::simple_type::datatype_COUNT:
|
case IfcParse::simple_type::datatype_COUNT:
|
||||||
throw IfcParse::IfcException("Invalid simple type encountered");
|
throw IfcParse::IfcException("Invalid simple type encountered");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return IfcUtil::Argument_UNKNOWN;
|
return IfcUtil::Argument_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
std::string IfcUtil::path::to_utf8(const std::wstring& str) {
|
std::string IfcUtil::path::to_utf8(const std::wstring& str) {
|
||||||
int buffer_size = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, 0, 0, 0, 0);
|
int buffer_size = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, 0, 0, 0, 0);
|
||||||
char* buffer = new char[buffer_size];
|
char* buffer = new char[buffer_size];
|
||||||
WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, buffer, buffer_size, 0, 0);
|
WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, buffer, buffer_size, 0, 0);
|
||||||
std::string str_utf8(buffer);
|
std::string str_utf8(buffer);
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
return str_utf8;
|
return str_utf8;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring IfcUtil::path::from_utf8(const std::string& str) {
|
std::wstring IfcUtil::path::from_utf8(const std::string& str) {
|
||||||
int buffer_size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0);
|
int buffer_size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0);
|
||||||
wchar_t* buffer = new wchar_t[buffer_size];
|
wchar_t* buffer = new wchar_t[buffer_size];
|
||||||
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, buffer, buffer_size);
|
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, buffer, buffer_size);
|
||||||
std::wstring str_wide(buffer);
|
std::wstring str_wide(buffer);
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
return str_wide;
|
return str_wide;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFC_PARSE_API bool IfcUtil::path::rename_file(const std::string& old_filename, const std::string& new_filename) {
|
IFC_PARSE_API bool IfcUtil::path::rename_file(const std::string& old_filename, const std::string& new_filename) {
|
||||||
std::wstring old_filename_w = from_utf8(old_filename);
|
std::wstring old_filename_w = from_utf8(old_filename);
|
||||||
std::wstring new_filename_w = from_utf8(new_filename);
|
std::wstring new_filename_w = from_utf8(new_filename);
|
||||||
delete_file(new_filename);
|
delete_file(new_filename);
|
||||||
const bool success = !!MoveFileW(old_filename_w.c_str(), new_filename_w.c_str());
|
const bool success = !!MoveFileW(old_filename_w.c_str(), new_filename_w.c_str());
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFC_PARSE_API bool IfcUtil::path::delete_file(const std::string& filename) {
|
IFC_PARSE_API bool IfcUtil::path::delete_file(const std::string& filename) {
|
||||||
std::wstring filename_w = from_utf8(filename);
|
std::wstring filename_w = from_utf8(filename);
|
||||||
const bool success = !!DeleteFileW(filename_w.c_str());
|
const bool success = !!DeleteFileW(filename_w.c_str());
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
IFC_PARSE_API bool IfcUtil::path::rename_file(const std::string& old_filename, const std::string& new_filename) {
|
IFC_PARSE_API bool IfcUtil::path::rename_file(const std::string& old_filename, const std::string& new_filename) {
|
||||||
// Whether or not rename() replaces an existing file is implementation-specific,
|
// Whether or not rename() replaces an existing file is implementation-specific,
|
||||||
// so remove() possible existing file always.
|
// so remove() possible existing file always.
|
||||||
delete_file(new_filename);
|
delete_file(new_filename);
|
||||||
return std::rename(old_filename.c_str(), new_filename.c_str()) == 0;
|
return std::rename(old_filename.c_str(), new_filename.c_str()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFC_PARSE_API bool IfcUtil::path::delete_file(const std::string& filename) {
|
IFC_PARSE_API bool IfcUtil::path::delete_file(const std::string& filename) {
|
||||||
return std::remove(filename.c_str());
|
return std::remove(filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,58 +1,58 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import ifcopenshell.util.selector
|
import ifcopenshell.util.selector
|
||||||
|
|
||||||
|
|
||||||
class Patcher:
|
class Patcher:
|
||||||
def __init__(self, src, file, logger, args=None):
|
def __init__(self, src, file, logger, args=None):
|
||||||
self.src = src
|
self.src = src
|
||||||
self.file = file
|
self.file = file
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self.args = args
|
self.args = args
|
||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
self.contained_ins = {}
|
self.contained_ins = {}
|
||||||
self.aggregates = {}
|
self.aggregates = {}
|
||||||
self.new = ifcopenshell.file(schema=self.file.wrapped_data.schema)
|
self.new = ifcopenshell.file(schema=self.file.wrapped_data.schema)
|
||||||
self.owner_history = None
|
self.owner_history = None
|
||||||
for owner_history in self.file.by_type("IfcOwnerHistory"):
|
for owner_history in self.file.by_type("IfcOwnerHistory"):
|
||||||
self.owner_history = self.new.add(owner_history)
|
self.owner_history = self.new.add(owner_history)
|
||||||
break
|
break
|
||||||
selector = ifcopenshell.util.selector.Selector()
|
selector = ifcopenshell.util.selector.Selector()
|
||||||
for element in selector.parse(self.file, self.args[0]):
|
for element in selector.parse(self.file, self.args[0]):
|
||||||
self.add_element(element)
|
self.add_element(element)
|
||||||
self.create_spatial_tree()
|
self.create_spatial_tree()
|
||||||
self.file = self.new
|
self.file = self.new
|
||||||
|
|
||||||
def add_element(self, element):
|
def add_element(self, element):
|
||||||
new_element = self.new.add(element)
|
new_element = self.new.add(element)
|
||||||
for rel in element.ContainedInStructure:
|
for rel in element.ContainedInStructure:
|
||||||
spatial_element = rel.RelatingStructure
|
spatial_element = rel.RelatingStructure
|
||||||
new_spatial_element = self.new.add(spatial_element)
|
new_spatial_element = self.new.add(spatial_element)
|
||||||
self.contained_ins.setdefault(spatial_element.GlobalId, set()).add(new_element)
|
self.contained_ins.setdefault(spatial_element.GlobalId, set()).add(new_element)
|
||||||
self.add_spatial_tree(spatial_element, new_spatial_element)
|
self.add_spatial_tree(spatial_element, new_spatial_element)
|
||||||
|
|
||||||
def add_spatial_tree(self, spatial_element, new_spatial_element):
|
def add_spatial_tree(self, spatial_element, new_spatial_element):
|
||||||
for rel in spatial_element.Decomposes:
|
for rel in spatial_element.Decomposes:
|
||||||
new = self.new.add(rel.RelatingObject)
|
new = self.new.add(rel.RelatingObject)
|
||||||
self.aggregates.setdefault(rel.RelatingObject.GlobalId, set()).add(new_spatial_element)
|
self.aggregates.setdefault(rel.RelatingObject.GlobalId, set()).add(new_spatial_element)
|
||||||
self.add_spatial_tree(rel.RelatingObject, new)
|
self.add_spatial_tree(rel.RelatingObject, new)
|
||||||
|
|
||||||
def create_spatial_tree(self):
|
def create_spatial_tree(self):
|
||||||
for relating_structure, related_elements in self.contained_ins.items():
|
for relating_structure, related_elements in self.contained_ins.items():
|
||||||
self.new.createIfcRelContainedInSpatialStructure(
|
self.new.createIfcRelContainedInSpatialStructure(
|
||||||
ifcopenshell.guid.new(),
|
ifcopenshell.guid.new(),
|
||||||
self.owner_history,
|
self.owner_history,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
list(related_elements),
|
list(related_elements),
|
||||||
self.new.by_guid(relating_structure),
|
self.new.by_guid(relating_structure),
|
||||||
)
|
)
|
||||||
for relating_object, related_objects in self.aggregates.items():
|
for relating_object, related_objects in self.aggregates.items():
|
||||||
self.new.createIfcRelAggregates(
|
self.new.createIfcRelAggregates(
|
||||||
ifcopenshell.guid.new(),
|
ifcopenshell.guid.new(),
|
||||||
self.owner_history,
|
self.owner_history,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
self.new.by_guid(relating_object),
|
self.new.by_guid(relating_object),
|
||||||
list(related_objects),
|
list(related_objects),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user