Dllimport/export for IfcGeom. Closes #77

This commit is contained in:
Stinkfist0
2016-07-11 21:36:12 +03:00
parent 17e153d0c5
commit 6bcabfd567
12 changed files with 86 additions and 39 deletions
+4 -15
View File
@@ -432,11 +432,7 @@ if(NOT WIN32)
LINK_DIRECTORIES(${LINK_DIRECTORIES} /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64) LINK_DIRECTORIES(${LINK_DIRECTORIES} /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64)
endif() endif()
if(BUILD_SHARED_LIBS) set(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom)
SET(IFCOPENSHELL_LIBRARIES IfcGeom)
else()
SET(IFCOPENSHELL_LIBRARIES IfcParse IfcGeom)
endif()
# IfcParse # IfcParse
file(GLOB IFCPARSE_H_FILES ../src/ifcparse/*.h) file(GLOB IFCPARSE_H_FILES ../src/ifcparse/*.h)
@@ -464,17 +460,10 @@ file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/*.h)
file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp) file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp)
set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES}) set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES})
IF(BUILD_SHARED_LIBS) add_library(IfcGeom ${IFCGEOM_FILES})
message(WARNING "Building IfcGeom as shared library currently not supported depending on platform and compiler options") set_target_properties(IfcGeom PROPERTIES COMPILE_FLAGS -DIFC_GEOM_EXPORTS)
ENDIF()
if(WIN32) TARGET_LINK_LIBRARIES(IfcGeom IfcParse ${OPENCASCADE_LIBRARIES})
add_library(IfcGeom STATIC ${IFCGEOM_FILES})
else()
add_library(IfcGeom ${IFCGEOM_FILES})
endif()
TARGET_LINK_LIBRARIES(IfcGeom IfcParse)
# IfcConvert # IfcConvert
file(GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp) file(GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp)
+9 -6
View File
@@ -51,6 +51,7 @@ inline static bool ALMOST_THE_SAME(const T& a, const T& b, double tolerance=ALMO
#include "../ifcgeom/IfcGeomRepresentation.h" #include "../ifcgeom/IfcGeomRepresentation.h"
#include "../ifcgeom/IfcRepresentationShapeItem.h" #include "../ifcgeom/IfcRepresentationShapeItem.h"
#include "../ifcgeom/IfcGeomShapeType.h" #include "../ifcgeom/IfcGeomShapeType.h"
#include "ifc_geom_api.h"
// Define this in case you want to conserve memory usage at all cost. This has been // Define this in case you want to conserve memory usage at all cost. This has been
// benchmarked extensively: https://github.com/IfcOpenShell/IfcOpenShell/pull/47 // benchmarked extensively: https://github.com/IfcOpenShell/IfcOpenShell/pull/47
@@ -71,13 +72,13 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
namespace IfcGeom { namespace IfcGeom {
class Cache { class IFC_GEOM_API Cache {
public: public:
#include "IfcRegisterCreateCache.h" #include "IfcRegisterCreateCache.h"
std::map<int, TopoDS_Shape> Shape; std::map<int, TopoDS_Shape> Shape;
}; };
class Kernel { class IFC_GEOM_API Kernel {
private: private:
double deflection_tolerance; double deflection_tolerance;
@@ -230,10 +231,12 @@ public:
IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*); IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*);
template <typename P> template <typename P>
IfcGeom::BRepElement<P>* create_brep_for_representation_and_product(const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*); IfcGeom::BRepElement<P>* create_brep_for_representation_and_product(
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*);
template <typename P> template <typename P>
IfcGeom::BRepElement<P>* create_brep_for_processed_representation(const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*, IfcGeom::BRepElement<P>*); IfcGeom::BRepElement<P>* create_brep_for_processed_representation(
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*, IfcGeom::BRepElement<P>*);
const SurfaceStyle* get_style(const IfcSchema::IfcRepresentationItem*); const SurfaceStyle* get_style(const IfcSchema::IfcRepresentationItem*);
const SurfaceStyle* get_style(const IfcSchema::IfcMaterial*); const SurfaceStyle* get_style(const IfcSchema::IfcMaterial*);
@@ -300,8 +303,8 @@ public:
}; };
IfcSchema::IfcProductDefinitionShape* tesselate(const TopoDS_Shape& shape, double deflection); IFC_GEOM_API IfcSchema::IfcProductDefinitionShape* tesselate(const TopoDS_Shape& shape, double deflection);
IfcSchema::IfcProductDefinitionShape* serialise(const TopoDS_Shape& shape, bool advanced); IFC_GEOM_API IfcSchema::IfcProductDefinitionShape* serialise(const TopoDS_Shape& shape, bool advanced);
} }
#endif #endif
+1
View File
@@ -27,6 +27,7 @@
#include "../ifcgeom/IfcGeomRepresentation.h" #include "../ifcgeom/IfcGeomRepresentation.h"
#include "../ifcgeom/IfcGeomIteratorSettings.h" #include "../ifcgeom/IfcGeomIteratorSettings.h"
#include "ifc_geom_api.h"
namespace IfcGeom { namespace IfcGeom {
+15 -8
View File
@@ -1004,8 +1004,9 @@ IfcSchema::IfcRelVoidsElement::list::ptr IfcGeom::Kernel::find_openings(IfcSchem
} }
template <typename P> template <typename P>
IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_product(const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product) { IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_product(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product)
{
IfcGeom::Representation::BRep* shape; IfcGeom::Representation::BRep* shape;
IfcGeom::IfcRepresentationShapeItems shapes, shapes2; IfcGeom::IfcRepresentationShapeItems shapes, shapes2;
@@ -1116,8 +1117,10 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
} }
template <typename P> template <typename P>
IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_processed_representation(const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<P>* brep) { IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_processed_representation(
const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product,
IfcGeom::BRepElement<P>* brep)
{
int parent_id = -1; int parent_id = -1;
try { try {
IfcSchema::IfcObjectDefinition* parent_object = get_decomposing_entity(product); IfcSchema::IfcObjectDefinition* parent_object = get_decomposing_entity(product);
@@ -1210,11 +1213,15 @@ IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchem
return parent; return parent;
} }
template IfcGeom::BRepElement<float>* IfcGeom::Kernel::create_brep_for_representation_and_product<float>(const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product); template IFC_GEOM_API IfcGeom::BRepElement<float>* IfcGeom::Kernel::create_brep_for_representation_and_product<float>(
template IfcGeom::BRepElement<double>* IfcGeom::Kernel::create_brep_for_representation_and_product<double>(const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product); const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product);
template IFC_GEOM_API IfcGeom::BRepElement<double>* IfcGeom::Kernel::create_brep_for_representation_and_product<double>(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product);
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); template IFC_GEOM_API IfcGeom::BRepElement<float>* IfcGeom::Kernel::create_brep_for_processed_representation<float>(
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); const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<float>* brep);
template IFC_GEOM_API IfcGeom::BRepElement<double>* IfcGeom::Kernel::create_brep_for_processed_representation<double>(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::BRepElement<double>* brep);
std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUnitAssignment* unit_assignment) { std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUnitAssignment* unit_assignment) {
// Set default units, set length to meters, angles to undefined // Set default units, set length to meters, angles to undefined
+8
View File
@@ -82,6 +82,14 @@
#include "../ifcgeom/IfcGeomIteratorSettings.h" #include "../ifcgeom/IfcGeomIteratorSettings.h"
#include "../ifcgeom/IfcRepresentationShapeItem.h" #include "../ifcgeom/IfcRepresentationShapeItem.h"
// The infamous min & max Win32 #defines can leak here from OCE depending on the build configuration
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
namespace IfcGeom { namespace IfcGeom {
template <typename P> template <typename P>
+3 -2
View File
@@ -20,12 +20,13 @@
#ifndef IFCGEOMITERATORSETTINGS_H #ifndef IFCGEOMITERATORSETTINGS_H
#define IFCGEOMITERATORSETTINGS_H #define IFCGEOMITERATORSETTINGS_H
#include "ifc_geom_api.h"
#include "../ifcparse/IfcException.h" #include "../ifcparse/IfcException.h"
#include "../ifcparse/IfcUtil.h" #include "../ifcparse/IfcUtil.h"
namespace IfcGeom namespace IfcGeom
{ {
class IteratorSettings class IFC_GEOM_API IteratorSettings
{ {
public: public:
/// Enumeration of setting identifiers. These settings define the /// Enumeration of setting identifiers. These settings define the
@@ -142,7 +143,7 @@ namespace IfcGeom
double deflection_tolerance_; double deflection_tolerance_;
}; };
class ElementSettings : public IteratorSettings class IFC_GEOM_API ElementSettings : public IteratorSettings
{ {
public: public:
ElementSettings(const IteratorSettings& settings, ElementSettings(const IteratorSettings& settings,
+1 -1
View File
@@ -26,7 +26,7 @@
namespace IfcGeom { namespace IfcGeom {
class Material { class IFC_GEOM_API Material {
private: private:
const IfcGeom::SurfaceStyle* style; const IfcGeom::SurfaceStyle* style;
public: public:
+3 -2
View File
@@ -20,6 +20,7 @@
#ifndef IFCGEOMRENDERSTYLES_H #ifndef IFCGEOMRENDERSTYLES_H
#define IFCGEOMRENDERSTYLES_H #define IFCGEOMRENDERSTYLES_H
#include "ifc_geom_api.h"
#ifdef USE_IFC4 #ifdef USE_IFC4
#include "../ifcparse/Ifc4.h" #include "../ifcparse/Ifc4.h"
#else #else
@@ -27,7 +28,7 @@
#endif #endif
namespace IfcGeom { namespace IfcGeom {
class SurfaceStyle { class IFC_GEOM_API SurfaceStyle {
public: public:
class ColorComponent { class ColorComponent {
private: private:
@@ -92,7 +93,7 @@ namespace IfcGeom {
boost::optional<double>& Specularity() { return specularity; } boost::optional<double>& Specularity() { return specularity; }
}; };
const SurfaceStyle* get_default_style(const std::string& ifc_type); IFC_GEOM_API const SurfaceStyle* get_default_style(const std::string& ifc_type);
} }
#endif #endif
+3 -3
View File
@@ -41,7 +41,7 @@ namespace IfcGeom {
namespace Representation { namespace Representation {
class Representation { class IFC_GEOM_API Representation {
Representation(const Representation&); //N/A Representation(const Representation&); //N/A
Representation& operator =(const Representation&); //N/A Representation& operator =(const Representation&); //N/A
protected: protected:
@@ -54,7 +54,7 @@ namespace IfcGeom {
virtual ~Representation() {} virtual ~Representation() {}
}; };
class BRep : public Representation { class IFC_GEOM_API BRep : public Representation {
private: private:
unsigned int id; unsigned int id;
const IfcGeom::IfcRepresentationShapeItems _shapes; const IfcGeom::IfcRepresentationShapeItems _shapes;
@@ -73,7 +73,7 @@ namespace IfcGeom {
const unsigned int& getId() const { return id; } const unsigned int& getId() const { return id; }
}; };
class Serialization : public Representation { class IFC_GEOM_API Serialization : public Representation {
private: private:
int _id; int _id;
std::string _brep_data; std::string _brep_data;
+1 -1
View File
@@ -26,7 +26,7 @@
#include "../ifcgeom/IfcGeomRenderStyles.h" #include "../ifcgeom/IfcGeomRenderStyles.h"
namespace IfcGeom { namespace IfcGeom {
class IfcRepresentationShapeItem { class IFC_GEOM_API IfcRepresentationShapeItem {
private: private:
gp_GTrsf placement; gp_GTrsf placement;
TopoDS_Shape shape; TopoDS_Shape shape;
+37
View File
@@ -0,0 +1,37 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* 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 *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* 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/>. *
* *
********************************************************************************/
#ifndef IFC_GEOM_API_H
#define IFC_GEOM_API_H
#ifdef BUILD_SHARED_LIBS
#ifdef _WIN32
#ifdef IFC_GEOM_EXPORTS
#define IFC_GEOM_API __declspec(dllexport)
#else
#define IFC_GEOM_API __declspec(dllimport)
#endif
#else // simply assume GCC-like
#define IFC_GEOM_API __attribute__((visibility("default")))
#endif
#else
#define IFC_GEOM_API
#endif
#endif
+1 -1
View File
@@ -21,7 +21,7 @@
#define IfcParse_EXPORT_H #define IfcParse_EXPORT_H
#ifdef BUILD_SHARED_LIBS #ifdef BUILD_SHARED_LIBS
#ifdef _MSC_VER #ifdef _WIN32
#ifdef IfcParse_EXPORTS #ifdef IfcParse_EXPORTS
#define IfcParse_EXPORT __declspec(dllexport) #define IfcParse_EXPORT __declspec(dllexport)
#else #else