Skip to content

Commit 9b36321

Browse files
committed
Rewritten library to use code generated from IFC2X3_TC1.exp
1 parent 75c26a3 commit 9b36321

30 files changed

Lines changed: 20757 additions & 344 deletions

cmake/CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,23 @@ CHECK_ADD_OCE_OCC_DEF(iomanip.h)
5858
CHECK_ADD_OCE_OCC_DEF(iostream)
5959
CHECK_ADD_OCE_OCC_DEF(iostream.h)
6060

61-
ADD_DEFINITIONS(-O3)
61+
ADD_DEFINITIONS(-O2)
6262
ADD_DEFINITIONS(-fPIC)
6363

6464
INCLUDE_DIRECTORIES(${OCC_INCLUDE_DIR})
65-
ADD_LIBRARY(IfcParse STATIC ../src/ifcparse/IfcEnum.cpp ../src/ifcparse/IfcTypes.cpp ../src/ifcparse/IfcParse.cpp ../src/ifcparse/IfcGeom.cpp ../src/ifcparse/IfcGeomObjects.cpp)
65+
ADD_LIBRARY(IfcParse STATIC
66+
../src/ifcparse/IfcGeomWires.cpp
67+
../src/ifcparse/Ifc2x3.cpp
68+
../src/ifcparse/IfcGeomHelpers.cpp
69+
../src/ifcparse/IfcGeomFunctions.cpp
70+
../src/ifcparse/IfcGeomObjects.cpp
71+
../src/ifcparse/IfcGeomShapes.cpp
72+
../src/ifcparse/IfcGeomFaces.cpp
73+
../src/ifcparse/IfcRegister.cpp
74+
../src/ifcparse/IfcUtil.cpp
75+
../src/ifcparse/IfcGeomCurves.cpp
76+
../src/ifcparse/IfcParse.cpp
77+
)
6678

6779
LINK_DIRECTORIES (${IfcOpenShell_BINARY_DIR} /usr/lib)
6880
ADD_EXECUTABLE(IfcObj ../src/ifcobj/IfcObj.cpp)

src/ifcobj/IfcObj.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
********************************************************************************/
2727

2828
#include <fstream>
29+
#include <sstream>
2930
#include <set>
3031
#include <time.h>
3132

@@ -46,9 +47,12 @@ int main ( int argc, char** argv ) {
4647
return 1;
4748
}
4849

50+
// Stream for log messages, we don't want to interupt our new progress bar...
51+
std::stringstream ss;
52+
4953
// Parse the file supplied in argv[1]. Returns true on succes.
5054
// The second argument defines whether geometry will be defined using global or local coordinates.
51-
if ( ! IfcGeomObjects::Init(argv[1],true) ) {
55+
if ( ! IfcGeomObjects::Init(argv[1],true,&ss) ) {
5256
std::cout << "[Error] unable to parse .ifc file or no geometrical entities found" << std::endl;
5357
return 1;
5458
}
@@ -59,6 +63,8 @@ int main ( int argc, char** argv ) {
5963

6064
time_t start,end;
6165
time(&start);
66+
int old_progress = -1;
67+
std::cout << "Creating geometry..." << std::endl;
6268

6369
// The functions IfcGeomObjects::Get() and IfcGeomObjects::Next() wrap an iterator of all geometrical entities in the Ifc file.
6470
// IfcGeomObjects::Get() returns an IfcGeomObjects::IfcGeomObject (see IfcObjects.h for definition)
@@ -82,15 +88,24 @@ int main ( int argc, char** argv ) {
8288
const int v3 = *(it++)-vcount;
8389
fObj << "f " << v1 << " " << v2 << " " << v3 << std::endl;
8490
}
91+
92+
const int progress = IfcGeomObjects::Progress() / 2;
93+
if ( old_progress!= progress ) std::cout << "\r[" << std::string(progress,'#') << std::string(50 - progress,' ') << "]" << std::flush;
94+
old_progress = progress;
95+
8596
} while ( IfcGeomObjects::Next() );
97+
std::cout << "\rDone creating geometry " << std::endl;
8698

8799
// Writes the material settings, defined in Materials.h
88100
fMtl << "# File generated by IfcOpenShell" << std::endl;
89101
for( std::set<std::string>::iterator it = materials.begin(); it != materials.end(); ++ it ) {
90102
fMtl << GetMaterial(*it);
91103
}
92104

105+
std::cout << std::endl << "Log:" << std::endl;
106+
std::cout << ss.str();
107+
93108
time(&end);
94109
int dif = (int) difftime (end,start);
95-
printf ("Conversion took %d seconds\n", dif );
110+
printf ("\nConversion took %d seconds\n", dif );
96111
}

src/ifcparse/Ifc2x3.cpp

Lines changed: 9482 additions & 0 deletions
Large diffs are not rendered by default.

src/ifcparse/Ifc2x3.h

Lines changed: 9289 additions & 0 deletions
Large diffs are not rendered by default.

src/ifcparse/Ifc2x3enum.h

Lines changed: 42 additions & 0 deletions
Large diffs are not rendered by default.

src/ifcparse/IfcGeom.h

Lines changed: 38 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,50 @@
1+
/********************************************************************************
2+
* *
3+
* This file is part of IfcOpenShell. *
4+
* *
5+
* IfcOpenShell is free software: you can redistribute it and/or modify *
6+
* it under the terms of the Lesser GNU General Public License as published by *
7+
* the Free Software Foundation, either version 3.0 of the License, or *
8+
* (at your option) any later version. *
9+
* *
10+
* IfcOpenShell is distributed in the hope that it will be useful, *
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13+
* Lesser GNU General Public License for more details. *
14+
* *
15+
* You should have received a copy of the Lesser GNU General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
* *
18+
********************************************************************************/
19+
120
#ifndef IFCGEOM_H
221
#define IFCGEOM_H
3-
#include "../ifcparse/IfcParse.h"
4-
#include "../ifcparse/IfcTypes.h"
522

623
#include <gp_Pnt.hxx>
724
#include <gp_Vec.hxx>
8-
#include <gp_Pnt2d.hxx>
9-
#include <gp_Vec2d.hxx>
1025
#include <gp_Trsf.hxx>
1126
#include <gp_Trsf2d.hxx>
12-
#include <gp_Mat.hxx>
13-
#include <gp_Ax3.hxx>
14-
#include <gp_Ax2d.hxx>
15-
#include <gp_Pln.hxx>
16-
17-
#include <TColgp_Array1OfPnt.hxx>
18-
#include <TColgp_Array1OfPnt2d.hxx>
19-
#include <TColStd_Array1OfReal.hxx>
20-
#include <TColStd_Array1OfInteger.hxx>
21-
#include <Geom2d_BSplineCurve.hxx>
22-
#include <Geom_BSplineCurve.hxx>
23-
24-
#include <BRepOffsetAPI_Sewing.hxx>
25-
#include <BRepBuilderAPI_MakeFace.hxx>
26-
#include <BRepBuilderAPI_MakeEdge.hxx>
27-
#include <BRepBuilderAPI_MakeWire.hxx>
28-
#include <BRepBuilderAPI_MakePolygon.hxx>
29-
3027
#include <TopoDS.hxx>
3128
#include <TopoDS_Wire.hxx>
3229
#include <TopoDS_Face.hxx>
30+
#include <Geom_Curve.hxx>
31+
#include <gp_Pln.hxx>
3332

34-
#include <BRepPrimAPI_MakePrism.hxx>
35-
#include <BRepBuilderAPI_MakeShell.hxx>
36-
#include <BRepBuilderAPI_MakeSolid.hxx>
37-
#include <BRepPrimAPI_MakeHalfSpace.hxx>
38-
#include <BRepAlgoAPI_Cut.hxx>
39-
40-
#include <ShapeFix_Shape.hxx>
41-
#include <ShapeFix_ShapeTolerance.hxx>
42-
43-
#include <TopLoc_Location.hxx>
44-
45-
#define SCALE 1000.0f
46-
47-
/*
48-
namespace IFCgeom {
49-
bool convert( Entity* L, gp_Vec*& CC );
50-
bool convert( Entity* L, gp_Pnt*& CC );
51-
bool convert( Entity* L, gp_Vec2d*& CC );
52-
bool convert( Entity* L, gp_Pnt2d*& CC );
53-
bool convert ( Entity* L, gp_Ax3*& ax3 );
54-
bool convert ( Entity* L, gp_Trsf*& trsf );
55-
bool convert ( Entity* L, gp_Trsf2d*& trsf );
56-
bool convert ( Entity* L, gp_Pln*& pln );
57-
bool convert ( const Entity* L, TopoDS_Wire& wire, int& count );
58-
bool convert( const Entity* L, TopoDS_Face& face);
59-
bool convert( const Entity* L, TopoDS_Shape& shape);
60-
bool move ( const Entity* L, gp_Trsf& trsf );
61-
bool move ( const Entity* L, TopoDS_Shape& shape );
62-
bool hasopenings( const Entity* L );
63-
bool open( const Entity* L, TopoDS_Shape& shape );
64-
bool open( const Entity* L, TopoDS_Shape& shape, gp_Trsf trsf2 );
33+
#include "../ifcparse/IfcParse.h"
34+
#include "../ifcparse/IfcUtil.h"
35+
36+
namespace IfcGeom {
37+
bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face);
38+
bool convert_shape(const SHARED_PTR<IfcUtil::IfcBaseClass>& L, TopoDS_Shape& result);
39+
bool convert_wire(const SHARED_PTR<IfcUtil::IfcBaseClass>& L, TopoDS_Wire& result);
40+
bool convert_curve(const SHARED_PTR<IfcUtil::IfcBaseClass>& L, Handle(Geom_Curve)& result);
41+
bool convert_face(const SHARED_PTR<IfcUtil::IfcBaseClass>& L, TopoDS_Face& result);
42+
bool convert_openings(const Ifc2x3::IfcProduct::ptr& L, const Ifc2x3::IfcRelVoidsElement::list& openings, TopoDS_Shape& result, const gp_Trsf& trsf);
43+
bool profile_helper(int numVerts, float* verts, int numFillets, int* filletIndices, float* filletRadii, gp_Trsf2d trsf, TopoDS_Face& face);
44+
namespace Cache {
45+
void Purge();
46+
void PurgeShapeCache();
47+
}
48+
#include "IfcRegisterGeomHeader.h"
6549
}
66-
*/
67-
#endif
50+
#endif

src/ifcparse/IfcGeomCurves.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/********************************************************************************
2+
* *
3+
* This file is part of IfcOpenShell. *
4+
* *
5+
* IfcOpenShell is free software: you can redistribute it and/or modify *
6+
* it under the terms of the Lesser GNU General Public License as published by *
7+
* the Free Software Foundation, either version 3.0 of the License, or *
8+
* (at your option) any later version. *
9+
* *
10+
* IfcOpenShell is distributed in the hope that it will be useful, *
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13+
* Lesser GNU General Public License for more details. *
14+
* *
15+
* You should have received a copy of the Lesser GNU General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
* *
18+
********************************************************************************/
19+
20+
/********************************************************************************
21+
* *
22+
* Implementations of the various conversion functions defined in IfcRegister.h *
23+
* *
24+
********************************************************************************/
25+
26+
#include <gp_Pnt.hxx>
27+
#include <gp_Vec.hxx>
28+
#include <gp_Dir.hxx>
29+
#include <gp_Pnt2d.hxx>
30+
#include <gp_Vec2d.hxx>
31+
#include <gp_Dir2d.hxx>
32+
#include <gp_Trsf.hxx>
33+
#include <gp_Trsf2d.hxx>
34+
#include <gp_Mat.hxx>
35+
#include <gp_Ax3.hxx>
36+
#include <gp_Ax2d.hxx>
37+
#include <gp_Pln.hxx>
38+
#include <gp_Circ.hxx>
39+
40+
#include <TColgp_Array1OfPnt.hxx>
41+
#include <TColgp_Array1OfPnt2d.hxx>
42+
#include <TColStd_Array1OfReal.hxx>
43+
#include <TColStd_Array1OfInteger.hxx>
44+
#include <Geom_Line.hxx>
45+
#include <Geom_Circle.hxx>
46+
#include <Geom_Ellipse.hxx>
47+
#include <Geom_TrimmedCurve.hxx>
48+
49+
#include <BRepOffsetAPI_Sewing.hxx>
50+
#include <BRepBuilderAPI_MakeFace.hxx>
51+
#include <BRepBuilderAPI_MakeEdge.hxx>
52+
#include <BRepBuilderAPI_MakeWire.hxx>
53+
#include <BRepBuilderAPI_MakePolygon.hxx>
54+
#include <BRepBuilderAPI_MakeVertex.hxx>
55+
56+
#include <TopoDS.hxx>
57+
#include <TopoDS_Wire.hxx>
58+
#include <TopoDS_Face.hxx>
59+
#include <TopExp_Explorer.hxx>
60+
61+
#include <BRepPrimAPI_MakePrism.hxx>
62+
#include <BRepBuilderAPI_MakeShell.hxx>
63+
#include <BRepBuilderAPI_MakeSolid.hxx>
64+
#include <BRepPrimAPI_MakeHalfSpace.hxx>
65+
#include <BRepAlgoAPI_Cut.hxx>
66+
67+
#include <ShapeFix_Shape.hxx>
68+
#include <ShapeFix_ShapeTolerance.hxx>
69+
#include <ShapeFix_Solid.hxx>
70+
71+
#include <BRepFilletAPI_MakeFillet2d.hxx>
72+
73+
#include <TopLoc_Location.hxx>
74+
75+
#include "../ifcparse/IfcGeom.h"
76+
77+
bool IfcGeom::convert(const Ifc2x3::IfcCircle::ptr& l, Handle(Geom_Curve)& curve) {
78+
const float r = l->Radius() * Ifc::LengthUnit;
79+
if ( r <= 0.0f ) { return false; }
80+
gp_Trsf trsf;
81+
Ifc2x3::IfcAxis2Placement placement = l->Position();
82+
if (placement->is(Ifc2x3::Type::IfcAxis2Placement3D)) {
83+
IfcGeom::convert(reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,Ifc2x3::IfcAxis2Placement3D>(placement),trsf);
84+
} else {
85+
gp_Trsf2d trsf2d;
86+
IfcGeom::convert(reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,Ifc2x3::IfcAxis2Placement2D>(placement),trsf2d);
87+
trsf = trsf2d;
88+
}
89+
gp_Ax2 ax = gp_Ax2().Transformed(trsf);
90+
curve = new Geom_Circle(ax, r);
91+
return true;
92+
}
93+
bool IfcGeom::convert(const Ifc2x3::IfcEllipse::ptr& l, Handle(Geom_Curve)& curve) {
94+
float x = l->SemiAxis1() * Ifc::LengthUnit;
95+
float y = l->SemiAxis2() * Ifc::LengthUnit;
96+
if ( x == 0.0f || y == 0.0f || y > x ) { return false; }
97+
gp_Trsf trsf;
98+
Ifc2x3::IfcAxis2Placement placement = l->Position();
99+
if (placement->is(Ifc2x3::Type::IfcAxis2Placement3D)) {
100+
IfcGeom::convert(reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,Ifc2x3::IfcAxis2Placement3D>(placement),trsf);
101+
} else {
102+
gp_Trsf2d trsf2d;
103+
IfcGeom::convert(reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,Ifc2x3::IfcAxis2Placement2D>(placement),trsf2d);
104+
trsf = trsf2d;
105+
}
106+
gp_Ax2 ax = gp_Ax2().Transformed(trsf);
107+
curve = new Geom_Ellipse(ax, x, y);
108+
return true;
109+
}
110+
bool IfcGeom::convert(const Ifc2x3::IfcLine::ptr& l, Handle(Geom_Curve)& curve) {
111+
gp_Pnt pnt;gp_Vec vec;
112+
IfcGeom::convert(l->Pnt(),pnt);
113+
IfcGeom::convert(l->Dir(),vec);
114+
curve = new Geom_Line(pnt,vec);
115+
return true;
116+
}

0 commit comments

Comments
 (0)