7979%newobject IfcGeom::OpaqueNumber::operator *;
8080%newobject IfcGeom::OpaqueNumber::operator /;
8181
82+ %inline %{
83+ template <typename T>
84+ std::pair<char const *, size_t > vector_to_buffer (const T& t) {
85+ using V = typename std::remove_reference<decltype (t)>::type;
86+ return { reinterpret_cast <const char *>(t.data ()), t.size () * sizeof (V::value_type) };
87+ }
88+ %}
89+
8290%include " ../ifcgeom/ifc_geom_api.h"
8391%include " ../ifcgeom/Converter.h"
8492%include " ../ifcgeom/ConversionResult.h"
@@ -288,6 +296,31 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
288296%}
289297
290298%extend IfcGeom::Representation::Triangulation {
299+
300+ std::pair<const char *, size_t > faces_buffer () const {
301+ return vector_to_buffer (self->faces ());
302+ }
303+
304+ std::pair<const char *, size_t > edges_buffer () const {
305+ return vector_to_buffer (self->edges ());
306+ }
307+
308+ std::pair<const char *, size_t > material_ids_buffer () const {
309+ return vector_to_buffer (self->material_ids ());
310+ }
311+
312+ std::pair<const char *, size_t > item_ids_buffer () const {
313+ return vector_to_buffer (self->item_ids ());
314+ }
315+
316+ std::pair<const char *, size_t > verts_buffer () const {
317+ return vector_to_buffer (self->verts ());
318+ }
319+
320+ std::pair<const char *, size_t > normals_buffer () const {
321+ return vector_to_buffer (self->normals ());
322+ }
323+
291324 %pythoncode %{
292325 # Hide the getters with read-only property implementations
293326 id = property (id)
@@ -298,6 +331,13 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
298331 verts = property (verts)
299332 normals = property (normals)
300333 item_ids = property (item_ids)
334+
335+ faces_buffer = property (faces_buffer)
336+ edges_buffer = property (edges_buffer)
337+ material_ids_buffer = property (material_ids_buffer)
338+ item_ids_buffer = property (item_ids_buffer)
339+ verts_buffer = property (verts_buffer)
340+ normals = property (normals)
301341 %}
302342};
303343
@@ -312,12 +352,17 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
312352};
313353
314354%extend IfcGeom::Element {
355+ std::pair<const char *, size_t > transformation_buffer () const {
356+ // @todo check whether needs to be transposed
357+ const double * data = self->transformation ().data ()->ccomponents ().data ();
358+ return { reinterpret_cast <const char *>(data), 16 * sizeof (double ) };
359+ }
315360
316- const IfcUtil::IfcBaseClass* product_ () const {
317- return $self->product ();
318- }
361+ const IfcUtil::IfcBaseClass* product_ () const {
362+ return $self->product ();
363+ }
319364
320- %pythoncode %{
365+ %pythoncode %{
321366 # Hide the getters with read-only property implementations
322367 id = property (id)
323368 parent_id = property (parent_id)
@@ -328,8 +373,9 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
328373 unique_id = property (unique_id)
329374 transformation = property (transformation)
330375 product = property (product_)
331- %}
332376
377+ transformation_buffer = property (transformation_buffer)
378+ %}
333379};
334380
335381%extend IfcGeom::TriangulationElement {
0 commit comments