2011-05-08 11:04:32 +00:00
|
|
|
/********************************************************************************
|
2013-05-11 10:03:20 +00:00
|
|
|
* *
|
|
|
|
|
* This file is part of IfcOpenShell. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
2011-05-08 11:04:32 +00:00
|
|
|
* it under the terms of the Lesser GNU General Public License as published by *
|
2013-05-11 10:03:20 +00:00
|
|
|
* 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. *
|
|
|
|
|
* *
|
2011-05-08 11:04:32 +00:00
|
|
|
* You should have received a copy of the Lesser GNU General Public License *
|
2013-05-11 10:03:20 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
* *
|
2011-05-08 11:04:32 +00:00
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
%include "std_vector.i"
|
|
|
|
|
%include "std_string.i"
|
2013-05-11 15:26:35 +00:00
|
|
|
%include "exception.i"
|
|
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
// This is only used for RGB colours, hence the size of 3
|
2013-05-11 15:26:35 +00:00
|
|
|
%typemap(out) const double* {
|
|
|
|
|
$result = PyTuple_New(3);
|
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
|
PyTuple_SetItem($result, i, PyFloat_FromDouble($1[i]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
// Using RTTI return a more specialized type of Element
|
|
|
|
|
%typemap(out) IfcGeom::Element<float>* {
|
|
|
|
|
IfcGeom::SerializedElement<float>* serialized_elem = dynamic_cast<IfcGeom::SerializedElement<float>*>($1);
|
|
|
|
|
IfcGeom::TriangulationElement<float>* triangulation_elem = dynamic_cast<IfcGeom::TriangulationElement<float>*>($1);
|
|
|
|
|
if (triangulation_elem) {
|
|
|
|
|
$result = SWIG_NewPointerObj(SWIG_as_voidptr(triangulation_elem), SWIGTYPE_p_IfcGeom__TriangulationElementT_float_t, 0);
|
|
|
|
|
} else if (serialized_elem) {
|
|
|
|
|
$result = SWIG_NewPointerObj(SWIG_as_voidptr(serialized_elem), SWIGTYPE_p_IfcGeom__SerializedElementT_float_t, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Using RTTI return a more specialized type of Element
|
|
|
|
|
%typemap(out) IfcGeom::Element<double>* {
|
|
|
|
|
IfcGeom::SerializedElement<double>* serialized_elem = dynamic_cast<IfcGeom::SerializedElement<double>*>($1);
|
|
|
|
|
IfcGeom::TriangulationElement<double>* triangulation_elem = dynamic_cast<IfcGeom::TriangulationElement<double>*>($1);
|
|
|
|
|
if (triangulation_elem) {
|
|
|
|
|
$result = SWIG_NewPointerObj(SWIG_as_voidptr(triangulation_elem), SWIGTYPE_p_IfcGeom__TriangulationElementT_double_t, 0);
|
|
|
|
|
} else if (serialized_elem) {
|
|
|
|
|
$result = SWIG_NewPointerObj(SWIG_as_voidptr(serialized_elem), SWIGTYPE_p_IfcGeom__SerializedElementT_double_t, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SWIG does not support bool references in a meaningful way, so the
|
|
|
|
|
// IfcGeom::IteratorSettings functions degrade to return a read only value
|
|
|
|
|
%typemap(out) double& {
|
|
|
|
|
$result = SWIG_From_double(*$1);
|
|
|
|
|
}
|
|
|
|
|
%typemap(out) bool& {
|
|
|
|
|
$result = PyBool_FromLong(static_cast<long>(*$1));
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-11 15:26:35 +00:00
|
|
|
%exception {
|
|
|
|
|
try {
|
|
|
|
|
$action
|
|
|
|
|
} catch(std::runtime_error& e) {
|
|
|
|
|
SWIG_exception(SWIG_RuntimeError, e.what());
|
|
|
|
|
} catch(...) {
|
|
|
|
|
SWIG_exception(SWIG_RuntimeError, "An unknown error occurred");
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-08 11:04:32 +00:00
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
%include "../ifcgeom/IfcGeomIteratorSettings.h"
|
|
|
|
|
%include "../ifcgeom/IfcGeomMaterial.h"
|
|
|
|
|
%include "../ifcgeom/IfcGeomRepresentation.h"
|
|
|
|
|
%include "../ifcgeom/IfcGeomElement.h"
|
|
|
|
|
%include "../ifcgeom/IfcGeomIterator.h"
|
|
|
|
|
|
|
|
|
|
// This does not seem to work:
|
|
|
|
|
%ignore IfcGeom::Iterator<float>::Iterator(const IfcGeom::IteratorSettings&, IfcParse::IfcFile*);
|
|
|
|
|
%ignore IfcGeom::Iterator<float>::Iterator(const IfcGeom::IteratorSettings&, void*, int);
|
|
|
|
|
%ignore IfcGeom::Iterator<float>::Iterator(const IfcGeom::IteratorSettings&, std::istream&, int);
|
|
|
|
|
%ignore IfcGeom::Iterator<double>::Iterator(const IfcGeom::IteratorSettings&, IfcParse::IfcFile*);
|
|
|
|
|
%ignore IfcGeom::Iterator<double>::Iterator(const IfcGeom::IteratorSettings&, void*, int);
|
|
|
|
|
%ignore IfcGeom::Iterator<double>::Iterator(const IfcGeom::IteratorSettings&, std::istream&, int);
|
|
|
|
|
|
|
|
|
|
%extend IfcGeom::IteratorSettings {
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
attrs = ("convert_back_units", "deflection_tolerance", "disable_opening_subtractions", "disable_triangulation", "faster_booleans", "force_ccw_face_orientation", "sew_shells", "use_brep_data", "use_world_coords", "weld_vertices")
|
|
|
|
|
def __repr__(self):
|
|
|
|
|
return "IteratorSettings(%s)"%(",".join(tuple("%s=%r"%(a, getattr(self, a)()) for a in self.attrs)))
|
|
|
|
|
%}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%module ifcopenshell %{
|
|
|
|
|
#include "../ifcgeom/IfcGeomIteratorSettings.h"
|
|
|
|
|
#include "../ifcgeom/IfcGeomMaterial.h"
|
|
|
|
|
#include "../ifcgeom/IfcGeomRepresentation.h"
|
|
|
|
|
#include "../ifcgeom/IfcGeomElement.h"
|
|
|
|
|
#include "../ifcgeom/IfcGeomIterator.h"
|
2011-05-08 11:04:32 +00:00
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
using namespace IfcGeom;
|
2011-05-08 11:04:32 +00:00
|
|
|
%}
|
|
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
%extend IfcGeom::Iterator<float> {
|
|
|
|
|
static int mantissa_size() {
|
|
|
|
|
return std::numeric_limits<float>::digits;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%extend IfcGeom::Iterator<double> {
|
|
|
|
|
static int mantissa_size() {
|
|
|
|
|
return std::numeric_limits<double>::digits;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%extend IfcGeom::Representation::Triangulation {
|
2013-05-11 10:03:20 +00:00
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
|
|
|
|
# Hide the getters with read-only property implementations
|
|
|
|
|
id = property(id)
|
|
|
|
|
verts = property(verts)
|
|
|
|
|
faces = property(faces)
|
|
|
|
|
edges = property(edges)
|
|
|
|
|
normals = property(normals)
|
2013-05-11 15:26:35 +00:00
|
|
|
material_ids = property(material_ids)
|
2013-05-11 10:03:20 +00:00
|
|
|
materials = property(materials)
|
|
|
|
|
%}
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
%extend IfcGeom::Representation::Serialization {
|
2013-05-11 10:03:20 +00:00
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
|
|
|
|
# Hide the getters with read-only property implementations
|
|
|
|
|
id = property(id)
|
|
|
|
|
brep_data = property(brep_data)
|
|
|
|
|
%}
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
%extend IfcGeom::Element {
|
2013-05-11 10:03:20 +00:00
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
|
|
|
|
# Hide the getters with read-only property implementations
|
|
|
|
|
id = property(id)
|
|
|
|
|
parent_id = property(parent_id)
|
|
|
|
|
name = property(name)
|
|
|
|
|
type = property(type)
|
|
|
|
|
guid = property(guid)
|
2014-12-19 12:14:36 +00:00
|
|
|
transformation = property(transformation)
|
2013-05-11 10:03:20 +00:00
|
|
|
%}
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
%extend IfcGeom::TriangulationElement {
|
2013-05-11 10:03:20 +00:00
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
|
|
|
|
# Hide the getters with read-only property implementations
|
2014-12-19 12:14:36 +00:00
|
|
|
geometry = property(geometry)
|
2013-05-11 10:03:20 +00:00
|
|
|
%}
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
%extend IfcGeom::SerializedElement {
|
2013-05-11 10:03:20 +00:00
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
|
|
|
|
# Hide the getters with read-only property implementations
|
2014-12-19 12:14:36 +00:00
|
|
|
geometry = property(geometry)
|
2013-05-11 10:03:20 +00:00
|
|
|
%}
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-19 12:14:36 +00:00
|
|
|
%extend IfcGeom::Material {
|
2013-05-11 15:26:35 +00:00
|
|
|
%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)
|
2013-05-11 17:14:47 +00:00
|
|
|
name = property(name)
|
2014-12-19 12:14:36 +00:00
|
|
|
%}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%extend IfcGeom::Transformation {
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
|
|
|
|
# Hide the getters with read-only property implementations
|
|
|
|
|
matrix = property(matrix)
|
|
|
|
|
%}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%extend IfcGeom::Matrix {
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
|
|
|
|
# Hide the getters with read-only property implementations
|
|
|
|
|
data = property(data)
|
2013-05-11 15:26:35 +00:00
|
|
|
%}
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-08 11:04:32 +00:00
|
|
|
namespace std {
|
2013-05-11 10:03:20 +00:00
|
|
|
%template(IntVector) vector<int>;
|
|
|
|
|
%template(FloatVector) vector<float>;
|
2014-12-19 12:14:36 +00:00
|
|
|
%template(DoubleVector) vector<double>;
|
|
|
|
|
%template(MaterialVector) vector<IfcGeom::Material>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
namespace IfcGeom {
|
|
|
|
|
%template(IteratorSinglePrecision) Iterator<float>;
|
|
|
|
|
%template(IteratorDoublePrecision) Iterator<double>;
|
|
|
|
|
|
|
|
|
|
%template(ElementSinglePrecision) Element<float>;
|
|
|
|
|
%template(ElementDoublePrecision) Element<double>;
|
|
|
|
|
|
|
|
|
|
%template(TriangulationElementSinglePrecision) TriangulationElement<float>;
|
|
|
|
|
%template(TriangulationElementDoublePrecision) TriangulationElement<double>;
|
|
|
|
|
|
|
|
|
|
%template(SerializedElementSinglePrecision) SerializedElement<float>;
|
|
|
|
|
%template(SerializedElementDoublePrecision) SerializedElement<double>;
|
|
|
|
|
|
|
|
|
|
%template(TransformationSinglePrecision) Transformation<float>;
|
|
|
|
|
%template(TransformationDoublePrecision) Transformation<double>;
|
|
|
|
|
|
|
|
|
|
%template(MatrixSinglePrecision) Matrix<float>;
|
|
|
|
|
%template(MatrixDoublePrecision) Matrix<double>;
|
|
|
|
|
|
|
|
|
|
namespace Representation {
|
|
|
|
|
%template(TriangulationSinglePrecision) Triangulation<float>;
|
|
|
|
|
%template(TriangulationDoublePrecision) Triangulation<double>;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Hide templating precision to the user by choosing based on Python's
|
|
|
|
|
// internal float type. This is probably always going to be a double.
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
import sys
|
|
|
|
|
for ty in (IteratorSinglePrecision, IteratorDoublePrecision):
|
|
|
|
|
if ty.mantissa_size() == sys.float_info.mant_dig: Iterator = ty
|
|
|
|
|
%}
|