Skip to content

Commit 6bcabfd

Browse files
committed
Dllimport/export for IfcGeom. Closes IfcOpenShell#77
1 parent 17e153d commit 6bcabfd

12 files changed

+86
-39
lines changed

cmake/CMakeLists.txt

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,7 @@ if(NOT WIN32)
432432
LINK_DIRECTORIES(${LINK_DIRECTORIES} /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64)
433433
endif()
434434

435-
if(BUILD_SHARED_LIBS)
436-
SET(IFCOPENSHELL_LIBRARIES IfcGeom)
437-
else()
438-
SET(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom)
439-
endif()
435+
set(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom)
440436

441437
# IfcParse
442438
file(GLOB IFCPARSE_H_FILES ../src/ifcparse/*.h)
@@ -464,17 +460,10 @@ file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/*.h)
464460
file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp)
465461
set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES})
466462

467-
IF(BUILD_SHARED_LIBS)
468-
message(WARNING "Building IfcGeom as shared library currently not supported depending on platform and compiler options")
469-
ENDIF()
470-
471-
if(WIN32)
472-
add_library(IfcGeom STATIC ${IFCGEOM_FILES})
473-
else()
474-
add_library(IfcGeom ${IFCGEOM_FILES})
475-
endif()
463+
add_library(IfcGeom ${IFCGEOM_FILES})
464+
set_target_properties(IfcGeom PROPERTIES COMPILE_FLAGS -DIFC_GEOM_EXPORTS)
476465

477-
TARGET_LINK_LIBRARIES(IfcGeom IfcParse)
466+
TARGET_LINK_LIBRARIES(IfcGeom IfcParse ${OPENCASCADE_LIBRARIES})
478467

479468
# IfcConvert
480469
file(GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp)

src/ifcgeom/IfcGeom.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ inline static bool ALMOST_THE_SAME(const T& a, const T& b, double tolerance=ALMO
5151
#include "../ifcgeom/IfcGeomRepresentation.h"
5252
#include "../ifcgeom/IfcRepresentationShapeItem.h"
5353
#include "../ifcgeom/IfcGeomShapeType.h"
54+
#include "ifc_geom_api.h"
5455

5556
// Define this in case you want to conserve memory usage at all cost. This has been
5657
// benchmarked extensively: https://github.com/IfcOpenShell/IfcOpenShell/pull/47
@@ -71,13 +72,13 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
7172

7273
namespace IfcGeom {
7374

74-
class Cache {
75+
class IFC_GEOM_API Cache {
7576
public:
7677
#include "IfcRegisterCreateCache.h"
7778
std::map<int, TopoDS_Shape> Shape;
7879
};
7980

80-
class Kernel {
81+
class IFC_GEOM_API Kernel {
8182
private:
8283

8384
double deflection_tolerance;
@@ -230,10 +231,12 @@ class Kernel {
230231
IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*);
231232

232233
template <typename P>
233-
IfcGeom::BRepElement<P>* create_brep_for_representation_and_product(const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*);
234+
IfcGeom::BRepElement<P>* create_brep_for_representation_and_product(
235+
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*);
234236

235237
template <typename P>
236-
IfcGeom::BRepElement<P>* create_brep_for_processed_representation(const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*, IfcGeom::BRepElement<P>*);
238+
IfcGeom::BRepElement<P>* create_brep_for_processed_representation(
239+
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*, IfcGeom::BRepElement<P>*);
237240

238241
const SurfaceStyle* get_style(const IfcSchema::IfcRepresentationItem*);
239242
const SurfaceStyle* get_style(const IfcSchema::IfcMaterial*);
@@ -300,8 +303,8 @@ class Kernel {
300303

301304
};
302305

303-
IfcSchema::IfcProductDefinitionShape* tesselate(const TopoDS_Shape& shape, double deflection);
304-
IfcSchema::IfcProductDefinitionShape* serialise(const TopoDS_Shape& shape, bool advanced);
306+
IFC_GEOM_API IfcSchema::IfcProductDefinitionShape* tesselate(const TopoDS_Shape& shape, double deflection);
307+
IFC_GEOM_API IfcSchema::IfcProductDefinitionShape* serialise(const TopoDS_Shape& shape, bool advanced);
305308

306309
}
307310
#endif

src/ifcgeom/IfcGeomElement.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "../ifcgeom/IfcGeomRepresentation.h"
2929
#include "../ifcgeom/IfcGeomIteratorSettings.h"
30+
#include "ifc_geom_api.h"
3031

3132
namespace IfcGeom {
3233

src/ifcgeom/IfcGeomFunctions.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,9 @@ IfcSchema::IfcRelVoidsElement::list::ptr IfcGeom::Kernel::find_openings(IfcSchem
10041004
}
10051005

10061006
template <typename P>
1007-
IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_product(const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product) {
1008-
1007+
IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_product(
1008+
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product)
1009+
{
10091010
IfcGeom::Representation::BRep* shape;
10101011
IfcGeom::IfcRepresentationShapeItems shapes, shapes2;
10111012

@@ -1116,8 +1117,10 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
11161117
}
11171118

11181119
template <typename P>
1119-
IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_processed_representation(const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<P>* brep) {
1120-
1120+
IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_processed_representation(
1121+
const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product,
1122+
IfcGeom::BRepElement<P>* brep)
1123+
{
11211124
int parent_id = -1;
11221125
try {
11231126
IfcSchema::IfcObjectDefinition* parent_object = get_decomposing_entity(product);
@@ -1210,11 +1213,15 @@ IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchem
12101213
return parent;
12111214
}
12121215

1213-
template IfcGeom::BRepElement<float>* IfcGeom::Kernel::create_brep_for_representation_and_product<float>(const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product);
1214-
template IfcGeom::BRepElement<double>* IfcGeom::Kernel::create_brep_for_representation_and_product<double>(const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product);
1216+
template IFC_GEOM_API IfcGeom::BRepElement<float>* IfcGeom::Kernel::create_brep_for_representation_and_product<float>(
1217+
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product);
1218+
template IFC_GEOM_API IfcGeom::BRepElement<double>* IfcGeom::Kernel::create_brep_for_representation_and_product<double>(
1219+
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product);
12151220

1216-
template IfcGeom::BRepElement<float>* IfcGeom::Kernel::create_brep_for_processed_representation<float>(const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<float>* brep);
1217-
template IfcGeom::BRepElement<double>* IfcGeom::Kernel::create_brep_for_processed_representation<double>(const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<double>* brep);
1221+
template IFC_GEOM_API IfcGeom::BRepElement<float>* IfcGeom::Kernel::create_brep_for_processed_representation<float>(
1222+
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<float>* brep);
1223+
template IFC_GEOM_API IfcGeom::BRepElement<double>* IfcGeom::Kernel::create_brep_for_processed_representation<double>(
1224+
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<double>* brep);
12181225

12191226
std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUnitAssignment* unit_assignment) {
12201227
// Set default units, set length to meters, angles to undefined

src/ifcgeom/IfcGeomIterator.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@
8282
#include "../ifcgeom/IfcGeomIteratorSettings.h"
8383
#include "../ifcgeom/IfcRepresentationShapeItem.h"
8484

85+
// The infamous min & max Win32 #defines can leak here from OCE depending on the build configuration
86+
#ifdef min
87+
#undef min
88+
#endif
89+
#ifdef max
90+
#undef max
91+
#endif
92+
8593
namespace IfcGeom {
8694

8795
template <typename P>

src/ifcgeom/IfcGeomIteratorSettings.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
#ifndef IFCGEOMITERATORSETTINGS_H
2121
#define IFCGEOMITERATORSETTINGS_H
2222

23+
#include "ifc_geom_api.h"
2324
#include "../ifcparse/IfcException.h"
2425
#include "../ifcparse/IfcUtil.h"
2526

2627
namespace IfcGeom
2728
{
28-
class IteratorSettings
29+
class IFC_GEOM_API IteratorSettings
2930
{
3031
public:
3132
/// Enumeration of setting identifiers. These settings define the
@@ -142,7 +143,7 @@ namespace IfcGeom
142143
double deflection_tolerance_;
143144
};
144145

145-
class ElementSettings : public IteratorSettings
146+
class IFC_GEOM_API ElementSettings : public IteratorSettings
146147
{
147148
public:
148149
ElementSettings(const IteratorSettings& settings,

src/ifcgeom/IfcGeomMaterial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
namespace IfcGeom {
2828

29-
class Material {
29+
class IFC_GEOM_API Material {
3030
private:
3131
const IfcGeom::SurfaceStyle* style;
3232
public:

src/ifcgeom/IfcGeomRenderStyles.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
#ifndef IFCGEOMRENDERSTYLES_H
2121
#define IFCGEOMRENDERSTYLES_H
2222

23+
#include "ifc_geom_api.h"
2324
#ifdef USE_IFC4
2425
#include "../ifcparse/Ifc4.h"
2526
#else
2627
#include "../ifcparse/Ifc2x3.h"
2728
#endif
2829

2930
namespace IfcGeom {
30-
class SurfaceStyle {
31+
class IFC_GEOM_API SurfaceStyle {
3132
public:
3233
class ColorComponent {
3334
private:
@@ -92,7 +93,7 @@ namespace IfcGeom {
9293
boost::optional<double>& Specularity() { return specularity; }
9394
};
9495

95-
const SurfaceStyle* get_default_style(const std::string& ifc_type);
96+
IFC_GEOM_API const SurfaceStyle* get_default_style(const std::string& ifc_type);
9697
}
9798

9899
#endif

src/ifcgeom/IfcGeomRepresentation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace IfcGeom {
4141

4242
namespace Representation {
4343

44-
class Representation {
44+
class IFC_GEOM_API Representation {
4545
Representation(const Representation&); //N/A
4646
Representation& operator =(const Representation&); //N/A
4747
protected:
@@ -54,7 +54,7 @@ namespace IfcGeom {
5454
virtual ~Representation() {}
5555
};
5656

57-
class BRep : public Representation {
57+
class IFC_GEOM_API BRep : public Representation {
5858
private:
5959
unsigned int id;
6060
const IfcGeom::IfcRepresentationShapeItems _shapes;
@@ -73,7 +73,7 @@ namespace IfcGeom {
7373
const unsigned int& getId() const { return id; }
7474
};
7575

76-
class Serialization : public Representation {
76+
class IFC_GEOM_API Serialization : public Representation {
7777
private:
7878
int _id;
7979
std::string _brep_data;

src/ifcgeom/IfcRepresentationShapeItem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "../ifcgeom/IfcGeomRenderStyles.h"
2727

2828
namespace IfcGeom {
29-
class IfcRepresentationShapeItem {
29+
class IFC_GEOM_API IfcRepresentationShapeItem {
3030
private:
3131
gp_GTrsf placement;
3232
TopoDS_Shape shape;

0 commit comments

Comments
 (0)