mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Add an adapter for IfcGeom::SurfaceStyle so that IfcGeomObjects (and most notably the Python wrapper) need not to be aware of boost::optional
Expose shading and rendering styles to the Python wrapper as well
This commit is contained in:
+37
-1
@@ -19,12 +19,30 @@
|
||||
|
||||
%include "std_vector.i"
|
||||
%include "std_string.i"
|
||||
%include "exception.i"
|
||||
|
||||
%typemap(out) const double* {
|
||||
// This is only used for RGB colours, hence the size of 3
|
||||
$result = PyTuple_New(3);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
PyTuple_SetItem($result, i, PyFloat_FromDouble($1[i]));
|
||||
}
|
||||
}
|
||||
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
} catch(std::runtime_error& e) {
|
||||
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||
} catch(...) {
|
||||
SWIG_exception(SWIG_RuntimeError, "An unknown error occurred");
|
||||
}
|
||||
}
|
||||
|
||||
%include "Interface.h"
|
||||
|
||||
%module IfcImport %{
|
||||
#include "Interface.h"
|
||||
using namespace IfcGeom;
|
||||
using namespace IfcGeomObjects;
|
||||
%}
|
||||
|
||||
@@ -37,6 +55,7 @@
|
||||
faces = property(faces)
|
||||
edges = property(edges)
|
||||
normals = property(normals)
|
||||
material_ids = property(material_ids)
|
||||
materials = property(materials)
|
||||
def __repr__(self): return "RepresentationTriangulation #%d"%self.id
|
||||
%}
|
||||
@@ -84,7 +103,24 @@
|
||||
%}
|
||||
};
|
||||
|
||||
%extend IfcGeomObjects::Material {
|
||||
%pythoncode %{
|
||||
if _newclass:
|
||||
# Hide the getters with read-only property implementations
|
||||
has_diffuse = property(hasDiffuse)
|
||||
has_specular = property(hasSpecular)
|
||||
has_transparency = property(hasTransparency)
|
||||
has_specularity = property(hasSpecularity)
|
||||
diffuse = property(diffuse)
|
||||
specular = property(specular)
|
||||
transparency = property(transparency)
|
||||
specularity = property(specularity)
|
||||
def __repr__(self): return "Material"
|
||||
%}
|
||||
};
|
||||
|
||||
namespace std {
|
||||
%template(IntVector) vector<int>;
|
||||
%template(FloatVector) vector<float>;
|
||||
%template(MaterialVector) vector<IfcGeomObjects::Material>;
|
||||
};
|
||||
+19
-8
@@ -17,11 +17,6 @@
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
namespace IfcGeom {
|
||||
class SurfaceStyle {
|
||||
};
|
||||
}
|
||||
|
||||
namespace IfcGeomObjects {
|
||||
|
||||
const int WELD_VERTICES = 1;
|
||||
@@ -33,6 +28,21 @@ namespace IfcGeomObjects {
|
||||
const int FORCE_CCW_FACE_ORIENTATION = 7;
|
||||
const int DISABLE_OPENING_SUBTRACTIONS = 8;
|
||||
|
||||
class Material {
|
||||
private:
|
||||
void* style;
|
||||
public:
|
||||
bool hasDiffuse() const;
|
||||
bool hasSpecular() const;
|
||||
bool hasTransparency() const;
|
||||
bool hasSpecularity() const;
|
||||
const double* diffuse() const;
|
||||
const double* specular() const;
|
||||
double transparency() const;
|
||||
double specularity() const;
|
||||
const std::string name() const;
|
||||
};
|
||||
|
||||
class IfcRepresentationTriangulation {
|
||||
private:
|
||||
int _id;
|
||||
@@ -40,8 +50,8 @@ namespace IfcGeomObjects {
|
||||
std::vector<int> _faces;
|
||||
std::vector<int> _edges;
|
||||
std::vector<float> _normals;
|
||||
std::vector<int> _materials;
|
||||
std::vector<const IfcGeom::SurfaceStyle*> _surface_styles;
|
||||
std::vector<int> _material_ids;
|
||||
std::vector<Material> _materials;
|
||||
|
||||
IfcRepresentationTriangulation();
|
||||
IfcRepresentationTriangulation(const IfcRepresentationTriangulation&);
|
||||
@@ -53,7 +63,8 @@ namespace IfcGeomObjects {
|
||||
const std::vector<int>& faces() const;
|
||||
const std::vector<int>& edges() const;
|
||||
const std::vector<float>& normals() const;
|
||||
const std::vector<int>& materials() const;
|
||||
const std::vector<int>& material_ids() const;
|
||||
const std::vector<Material>& materials() const;
|
||||
};
|
||||
|
||||
class IfcRepresentationBrepData {
|
||||
|
||||
Reference in New Issue
Block a user