A limited attempt at some const correctness in the IfcGeomObjects interface

This commit is contained in:
Thomas Krijnen
2013-05-11 10:03:20 +00:00
parent 80bc1b5dab
commit dccbccfa06
8 changed files with 302 additions and 117 deletions
+73 -17
View File
@@ -1,20 +1,20 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* *
* 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. *
* *
* 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/>. *
* *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
%include "std_vector.i"
@@ -24,11 +24,67 @@
%module IfcImport %{
#include "Interface.h"
using namespace IfcGeom;
using namespace IfcGeomObjects;
%}
%extend IfcGeomObjects::IfcRepresentationTriangulation {
%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)
materials = property(materials)
def __repr__(self): return "RepresentationTriangulation #%d"%self.id
%}
};
%extend IfcGeomObjects::IfcRepresentationBrepData {
%pythoncode %{
if _newclass:
# Hide the getters with read-only property implementations
id = property(id)
brep_data = property(brep_data)
def __repr__(self): return "RepresentationBrepData #%d"%self.id
%}
};
%extend IfcGeomObjects::IfcObject {
%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)
matrix = property(matrix)
def __repr__(self): return "Object #%d"%self.id
%}
};
%extend IfcGeomObjects::IfcGeomObject {
%pythoncode %{
if _newclass:
# Hide the getters with read-only property implementations
mesh = property(mesh)
def __repr__(self): return "GeomObject #%d"%self.id
%}
};
%extend IfcGeomObjects::IfcGeomBrepDataObject {
%pythoncode %{
if _newclass:
# Hide the getters with read-only property implementations
mesh = property(mesh)
def __repr__(self): return "GeomBrepDataObject #%d"%self.id
%}
};
namespace std {
%template(IntVector) vector<int>;
%template(FloatVector) vector<float>;
%template(ObjVector) vector<IfcGeomObject>;
%template(IntVector) vector<int>;
%template(FloatVector) vector<float>;
};
+90 -20
View File
@@ -17,6 +17,11 @@
* *
********************************************************************************/
namespace IfcGeom {
class SurfaceStyle {
};
}
namespace IfcGeomObjects {
const int WELD_VERTICES = 1;
@@ -28,37 +33,102 @@ namespace IfcGeomObjects {
const int FORCE_CCW_FACE_ORIENTATION = 7;
const int DISABLE_OPENING_SUBTRACTIONS = 8;
class IfcMesh {
class IfcRepresentationTriangulation {
private:
int _id;
std::vector<float> _verts;
std::vector<int> _faces;
std::vector<int> _edges;
std::vector<float> _normals;
std::vector<int> _materials;
std::vector<const IfcGeom::SurfaceStyle*> _surface_styles;
IfcRepresentationTriangulation();
IfcRepresentationTriangulation(const IfcRepresentationTriangulation&);
IfcRepresentationTriangulation& operator=(const IfcRepresentationTriangulation&);
virtual ~IfcRepresentationTriangulation();
public:
int id;
std::vector<float> verts;
std::vector<int> faces;
std::vector<int> edges;
std::vector<float> normals;
std::string brep_data;
int id() const;
const std::vector<float>& verts() const;
const std::vector<int>& faces() const;
const std::vector<int>& edges() const;
const std::vector<float>& normals() const;
const std::vector<int>& materials() const;
};
class IfcRepresentationBrepData {
private:
int _id;
std::string _brep_data;
IfcRepresentationBrepData();
IfcRepresentationBrepData(const IfcRepresentationBrepData&);
IfcRepresentationBrepData& operator=(const IfcRepresentationBrepData&);
virtual ~IfcRepresentationBrepData();
public:
int id() const;
const std::string& brep_data() const;
};
class IfcObject {
private:
int _id;
int _parent_id;
std::string _name;
std::string _type;
std::string _guid;
std::vector<float> _matrix;
IfcObject();
IfcObject(const IfcObject& other);
IfcObject& operator=(const IfcObject& other);
virtual ~IfcObject() {}
public:
int id;
int parent_id;
std::string name;
std::string type;
std::string guid;
std::vector<float> matrix;
int id() const;
int parent_id() const;
const std::string& name() const;
const std::string& type() const;
const std::string& guid() const;
const std::vector<float>& matrix() const;
};
class IfcGeomObject : public IfcObject {
private:
IfcRepresentationTriangulation* _mesh;
IfcGeomObject();
IfcGeomObject(const IfcGeomObject& other);
IfcGeomObject& operator=(const IfcGeomObject& other);
virtual ~IfcGeomObject();
public:
IfcMesh* mesh;
const IfcRepresentationTriangulation& mesh() const;
};
class IfcGeomBrepDataObject : public IfcObject {
private:
IfcRepresentationBrepData* _mesh;
IfcGeomBrepDataObject();
IfcGeomBrepDataObject(const IfcGeomBrepDataObject& other);
IfcGeomBrepDataObject& operator=(const IfcGeomBrepDataObject& other);
virtual ~IfcGeomBrepDataObject();
public:
const IfcRepresentationBrepData& mesh() const;
};
bool Next();
const IfcGeomObject* Get();
bool Init(const std::string fn);
void Settings(int setting, bool value);
int Progress();
bool Init(const std::string fn);
const IfcGeomObject* Get();
const IfcGeomBrepDataObject* GetBrepData();
const IfcObject* GetObject(int id);
bool CleanUp();
std::string GetLog();
bool Next();
int Progress();
const std::string GetLog();
bool CleanUp();
};