[Work in progress] Start adding support for IfcSurfaceStyleShading and -Rendering

This commit is contained in:
Thomas Krijnen
2013-05-05 08:49:25 +00:00
parent 5d4ff0b54a
commit 80bc1b5dab
17 changed files with 308 additions and 195 deletions
+8 -5
View File
@@ -40,7 +40,7 @@
#include "../ifcparse/IfcParse.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcgeom/IfcShapeList.h"
#include "../ifcgeom/IfcRepresentationShapeItem.h"
namespace IfcGeom {
@@ -76,14 +76,15 @@ namespace IfcGeom {
};
bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face);
bool convert_shapes(const IfcUtil::IfcBaseClass* L, ShapeList& result);
bool convert_shapes(const IfcUtil::IfcBaseClass* L, IfcRepresentationShapeItems& result);
bool is_shape_collection(const IfcUtil::IfcBaseClass* L);
const TopoDS_Shape* convert_shape(const IfcUtil::IfcBaseClass* L, TopoDS_Shape& result);
bool convert_shape(const IfcUtil::IfcBaseClass* L, TopoDS_Shape& result);
bool convert_wire(const IfcUtil::IfcBaseClass* L, TopoDS_Wire& result);
bool convert_curve(const IfcUtil::IfcBaseClass* L, Handle(Geom_Curve)& result);
bool convert_face(const IfcUtil::IfcBaseClass* L, TopoDS_Face& result);
bool convert_openings(const Ifc2x3::IfcProduct::ptr entity, const Ifc2x3::IfcRelVoidsElement::list& openings, const ShapeList& entity_shapes, const gp_Trsf& entity_trsf, ShapeList& cut_shapes);
bool convert_openings_fast(const Ifc2x3::IfcProduct::ptr entity, const Ifc2x3::IfcRelVoidsElement::list& openings, const ShapeList& entity_shapes, const gp_Trsf& entity_trsf, ShapeList& cut_shapes);
bool convert_openings(const Ifc2x3::IfcProduct::ptr entity, const Ifc2x3::IfcRelVoidsElement::list& openings, const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes);
bool convert_openings_fast(const Ifc2x3::IfcProduct::ptr entity, const Ifc2x3::IfcRelVoidsElement::list& openings, const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes);
Ifc2x3::IfcSurfaceStyleShading* get_surface_style(Ifc2x3::IfcRepresentationItem* item);
bool create_solid_from_compound(const TopoDS_Shape& compound, TopoDS_Shape& solid);
bool is_compound(const TopoDS_Shape& shape);
bool is_convex(const TopoDS_Wire& wire);
@@ -97,6 +98,8 @@ namespace IfcGeom {
void SetValue(GeomValue var, double value);
double GetValue(GeomValue var);
Ifc2x3::IfcProductDefinitionShape* tesselate(TopoDS_Shape& shape, double deflection, IfcEntities es);
namespace Cache {
void Purge();
+19 -27
View File
@@ -131,9 +131,9 @@ const TopoDS_Shape& IfcGeom::ensure_fit_for_subtraction(const TopoDS_Shape& shap
}
bool IfcGeom::convert_openings(const Ifc2x3::IfcProduct::ptr entity, const Ifc2x3::IfcRelVoidsElement::list& openings,
const ShapeList& entity_shapes, const gp_Trsf& entity_trsf, ShapeList& cut_shapes) {
const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes) {
// Iterate over IfcOpeningElements
IfcGeom::ShapeList opening_shapes;
IfcGeom::IfcRepresentationShapeItems opening_shapes;
unsigned int last_size = 0;
for ( Ifc2x3::IfcRelVoidsElement::it it = openings->begin(); it != openings->end(); ++ it ) {
Ifc2x3::IfcRelVoidsElement::ptr v = *it;
@@ -156,17 +156,17 @@ bool IfcGeom::convert_openings(const Ifc2x3::IfcProduct::ptr entity, const Ifc2x
const unsigned int current_size = (const unsigned int) opening_shapes.size();
for ( unsigned int i = last_size; i < current_size; ++ i ) {
opening_shapes[i].first->PreMultiply(opening_trsf);
opening_shapes[i].move(opening_trsf);
}
last_size = current_size;
}
}
// Iterate over the shapes of the IfcProduct
for ( IfcGeom::ShapeList::const_iterator it3 = entity_shapes.begin(); it3 != entity_shapes.end(); ++ it3 ) {
for ( IfcGeom::IfcRepresentationShapeItems::const_iterator it3 = entity_shapes.begin(); it3 != entity_shapes.end(); ++ it3 ) {
TopoDS_Shape entity_shape_solid;
const TopoDS_Shape& entity_shape_unlocated = IfcGeom::ensure_fit_for_subtraction(*(it3->second),entity_shape_solid);
const gp_GTrsf& entity_shape_gtrsf = *(it3->first);
const TopoDS_Shape& entity_shape_unlocated = IfcGeom::ensure_fit_for_subtraction(it3->Shape(),entity_shape_solid);
const gp_GTrsf& entity_shape_gtrsf = it3->Placement();
TopoDS_Shape entity_shape;
if ( entity_shape_gtrsf.Form() == gp_Other ) {
Logger::Message(Logger::LOG_WARNING,"Applying non uniform transformation to:",entity->entity);
@@ -176,10 +176,10 @@ bool IfcGeom::convert_openings(const Ifc2x3::IfcProduct::ptr entity, const Ifc2x
}
// Iterate over the shapes of the IfcOpeningElements
for ( IfcGeom::ShapeList::const_iterator it4 = opening_shapes.begin(); it4 != opening_shapes.end(); ++ it4 ) {
for ( IfcGeom::IfcRepresentationShapeItems::const_iterator it4 = opening_shapes.begin(); it4 != opening_shapes.end(); ++ it4 ) {
TopoDS_Shape opening_shape_solid;
const TopoDS_Shape& opening_shape_unlocated = IfcGeom::ensure_fit_for_subtraction(*(it4->second),opening_shape_solid);
const gp_GTrsf& opening_shape_gtrsf = *(it4->first);
const TopoDS_Shape& opening_shape_unlocated = IfcGeom::ensure_fit_for_subtraction(it4->Shape(),opening_shape_solid);
const gp_GTrsf& opening_shape_gtrsf = it4->Placement();
if ( opening_shape_gtrsf.Form() == gp_Other ) {
Logger::Message(Logger::LOG_WARNING,"Applying non uniform transformation to opening of:",entity->entity);
}
@@ -218,19 +218,14 @@ bool IfcGeom::convert_openings(const Ifc2x3::IfcProduct::ptr entity, const Ifc2x
}
}
cut_shapes.push_back(IfcGeom::LocationShape(new gp_GTrsf(),new TopoDS_Shape(entity_shape)));
}
// Delete references to opening transformations, but keep shapes in the cache
for ( IfcGeom::ShapeList::const_iterator it5 = opening_shapes.begin(); it5 != opening_shapes.end(); ++ it5 ) {
delete it5->first;
cut_shapes.push_back(IfcGeom::IfcRepresentationShapeItem(entity_shape, &it3->Style()));
}
return true;
}
bool IfcGeom::convert_openings_fast(const Ifc2x3::IfcProduct::ptr entity, const Ifc2x3::IfcRelVoidsElement::list& openings,
const ShapeList& entity_shapes, const gp_Trsf& entity_trsf, ShapeList& cut_shapes) {
const IfcRepresentationShapeItems& entity_shapes, const gp_Trsf& entity_trsf, IfcRepresentationShapeItems& cut_shapes) {
// Create a compound of all opening shapes in order to speed up the boolean operations
TopoDS_Compound opening_compound;
@@ -252,32 +247,29 @@ bool IfcGeom::convert_openings_fast(const Ifc2x3::IfcProduct::ptr entity, const
Ifc2x3::IfcProductRepresentation::ptr prodrep = fes->Representation();
Ifc2x3::IfcRepresentation::list reps = prodrep->Representations();
IfcGeom::ShapeList opening_shapes;
IfcGeom::IfcRepresentationShapeItems opening_shapes;
for ( Ifc2x3::IfcRepresentation::it it2 = reps->begin(); it2 != reps->end(); ++ it2 ) {
IfcGeom::convert_shapes(*it2,opening_shapes);
}
for ( unsigned int i = 0; i < opening_shapes.size(); ++ i ) {
gp_GTrsf& gtrsf = *opening_shapes[i].first;
gp_GTrsf gtrsf = opening_shapes[i].Placement();
gtrsf.PreMultiply(opening_trsf);
const TopoDS_Shape& opening_shape = gtrsf.Form() == gp_Other
? BRepBuilderAPI_GTransform(*opening_shapes[i].second,gtrsf,true).Shape()
: (*opening_shapes[i].second).Moved(gtrsf.Trsf());
? BRepBuilderAPI_GTransform(opening_shapes[i].Shape(),gtrsf,true).Shape()
: (opening_shapes[i].Shape()).Moved(gtrsf.Trsf());
builder.Add(opening_compound,opening_shape);
}
for ( IfcGeom::ShapeList::const_iterator it5 = opening_shapes.begin(); it5 != opening_shapes.end(); ++ it5 ) {
delete it5->first;
}
}
}
// Iterate over the shapes of the IfcProduct
for ( IfcGeom::ShapeList::const_iterator it3 = entity_shapes.begin(); it3 != entity_shapes.end(); ++ it3 ) {
for ( IfcGeom::IfcRepresentationShapeItems::const_iterator it3 = entity_shapes.begin(); it3 != entity_shapes.end(); ++ it3 ) {
TopoDS_Shape entity_shape_solid;
const TopoDS_Shape& entity_shape_unlocated = IfcGeom::ensure_fit_for_subtraction(*(it3->second),entity_shape_solid);
const gp_GTrsf& entity_shape_gtrsf = *(it3->first);
const TopoDS_Shape& entity_shape_unlocated = IfcGeom::ensure_fit_for_subtraction(it3->Shape(),entity_shape_solid);
const gp_GTrsf& entity_shape_gtrsf = it3->Placement();
TopoDS_Shape entity_shape;
if ( entity_shape_gtrsf.Form() == gp_Other ) {
Logger::Message(Logger::LOG_WARNING,"Applying non uniform transformation to:",entity->entity);
@@ -294,7 +286,7 @@ bool IfcGeom::convert_openings_fast(const Ifc2x3::IfcProduct::ptr entity, const
BRepCheck_Analyzer analyser(brep_cut_result);
is_valid = analyser.IsValid() != 0;
if ( is_valid ) {
cut_shapes.push_back(IfcGeom::LocationShape(new gp_GTrsf(),new TopoDS_Shape(brep_cut_result)));
cut_shapes.push_back(IfcGeom::IfcRepresentationShapeItem(brep_cut_result, &it3->Style()));
}
}
if ( !is_valid ) {
+28 -22
View File
@@ -53,13 +53,13 @@ bool use_faster_booleans = false;
bool disable_subtractions = false;
bool disable_triangulation = false;
int IfcGeomObjects::IfcRepresentationTriangulation::addvert(const gp_XYZ& p) {
int IfcGeomObjects::IfcRepresentationTriangulation::addvert(int material_index, const gp_XYZ& p) {
const float X = convert_back_units ? (float) (p.X() / IfcGeom::GetValue(IfcGeom::GV_LENGTH_UNIT)) : (float)p.X();
const float Y = convert_back_units ? (float) (p.Y() / IfcGeom::GetValue(IfcGeom::GV_LENGTH_UNIT)) : (float)p.Y();
const float Z = convert_back_units ? (float) (p.Z() / IfcGeom::GetValue(IfcGeom::GV_LENGTH_UNIT)) : (float)p.Z();
int i = (int) verts.size() / 3;
if ( weld_vertices ) {
const VertKey key = VertKey(X,std::pair<float,float>(Y,Z));
const VertKey key = std::make_pair(material_index, std::make_pair(X, std::make_pair(Y, Z)));
VertKeyMap::const_iterator it = welds.find(key);
if ( it != welds.end() ) return it->second;
i = (int) welds.size();
@@ -83,9 +83,9 @@ IfcGeomObjects::IfcRepresentationBrepData::IfcRepresentationBrepData(const IfcRe
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
const TopoDS_Shape& s = *(*it).second;
const gp_GTrsf& trsf = *(*it).first;
for ( IfcGeom::IfcRepresentationShapeItems::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
const TopoDS_Shape& s = it->Shape();
const gp_GTrsf& trsf = it->Placement();
bool trsf_valid = false;
gp_Trsf _trsf;
try {
@@ -107,10 +107,21 @@ IfcGeomObjects::IfcRepresentationBrepData::IfcRepresentationBrepData(const IfcRe
IfcGeomObjects::IfcRepresentationTriangulation::IfcRepresentationTriangulation(const IfcRepresentationShapeModel& shapes)
: id(shapes.getId())
{
for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
for ( IfcGeom::IfcRepresentationShapeItems::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
const TopoDS_Shape& s = *it->second;
const gp_GTrsf& trsf = *it->first;
int surface_style_id = -1;
if (it->hasStyle()) {
std::vector<const IfcGeom::SurfaceStyle*>::const_iterator jt = std::find(surface_styles.begin(), surface_styles.end(), &it->Style());
if (jt == surface_styles.end()) {
surface_style_id = surface_styles.size();
surface_styles.push_back(&it->Style());
} else {
surface_style_id = jt - surface_styles.begin();
}
}
const TopoDS_Shape& s = it->Shape();
const gp_GTrsf& trsf = it->Placement();
// Triangulate the shape
try {
@@ -150,7 +161,7 @@ IfcGeomObjects::IfcRepresentationTriangulation::IfcRepresentationTriangulation(c
for( int i = 1; i <= nodes.Length(); ++ i ) {
coords.push_back(nodes(i).Transformed(loc).XYZ());
trsf.Transforms(*coords.rbegin());
dict[i] = addvert(*coords.rbegin());
dict[i] = addvert(surface_style_id, *coords.rbegin());
if ( calculate_normals ) {
const gp_Pnt2d& uv = uvs(i);
@@ -189,6 +200,8 @@ IfcGeomObjects::IfcRepresentationTriangulation::IfcRepresentationTriangulation(c
faces.push_back(dict[n2]);
faces.push_back(dict[n3]);
materials.push_back(surface_style_id);
addedge(n1,n2,edgecount,edges_temp);
addedge(n2,n3,edgecount,edges_temp);
addedge(n3,n1,edgecount,edges_temp);
@@ -369,7 +382,7 @@ IfcGeomObjects::IfcGeomShapeModelObject* create_shape_model_for_next_entity() {
}
IfcGeomObjects::IfcRepresentationShapeModel* shape;
IfcGeom::ShapeList shapes;
IfcGeom::IfcRepresentationShapeItems shapes;
if ( !IfcGeom::convert_shapes(shaperep,shapes) ) {
_nextShape();
@@ -412,15 +425,11 @@ IfcGeomObjects::IfcGeomShapeModelObject* create_shape_model_for_next_entity() {
}
if ( !disable_subtractions && openings && openings->Size() ) {
IfcGeom::ShapeList opened_shapes;
IfcGeom::IfcRepresentationShapeItems opened_shapes;
try {
if ( use_faster_booleans ) {
bool succes = IfcGeom::convert_openings_fast(ifc_product,openings,shapes,trsf,opened_shapes);
if ( ! succes ) {
for ( IfcGeom::ShapeList::const_iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++ it ) {
delete it->first;
delete it->second;
}
opened_shapes.clear();
IfcGeom::convert_openings(ifc_product,openings,shapes,trsf,opened_shapes);
}
@@ -431,18 +440,15 @@ IfcGeomObjects::IfcGeomShapeModelObject* create_shape_model_for_next_entity() {
Logger::Message(Logger::LOG_ERROR,"Error processing openings for:",ifc_product->entity);
}
if ( use_world_coords ) {
for ( IfcGeom::ShapeList::const_iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++ it ) {
it->first->PreMultiply(trsf);
for ( IfcGeom::IfcRepresentationShapeItems::iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++ it ) {
it->move(trsf);
}
trsf = gp_Trsf();
}
shape = new IfcGeomObjects::IfcRepresentationShapeModel(shaperep->entity->id(),opened_shapes,true);
for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
delete it->first;
}
} else if ( use_world_coords ) {
for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
it->first->PreMultiply(trsf);
for ( IfcGeom::IfcRepresentationShapeItems::iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
it->move(trsf);
}
trsf = gp_Trsf();
shape = new IfcGeomObjects::IfcRepresentationShapeModel(shaperep->entity->id(),shapes);
+14 -19
View File
@@ -63,7 +63,7 @@
#include <gp_Trsf2d.hxx>
#include "../ifcparse/IfcParse.h"
#include "../ifcgeom/IfcShapeList.h"
#include "../ifcgeom/IfcRepresentationShapeItem.h"
namespace IfcGeomObjects {
@@ -107,11 +107,9 @@ namespace IfcGeomObjects {
// End of settings enumeration.
// Some typedefs for convenience
typedef std::vector<int>::const_iterator IntIt;
typedef std::vector<float>::const_iterator FltIt;
// A nested pair of doubles to be able to store an XYZ coordinate in a map.
typedef std::pair< float,std::pair<float,float> > VertKey;
// A nested pair of floats and a material index to be able to store an XYZ coordinate in a map.
// TODO: Make this a std::tuple when compilers add support for that.
typedef std::pair<int, std::pair<float,std::pair<float,float> > > VertKey;
typedef std::map<VertKey,int> VertKeyMap;
typedef std::pair<int,int> Edge;
@@ -119,25 +117,18 @@ namespace IfcGeomObjects {
private:
unsigned int id;
bool owns_shapes;
const IfcGeom::ShapeList shapes;
const IfcGeom::IfcRepresentationShapeItems shapes;
IfcRepresentationShapeModel(const IfcRepresentationShapeModel& other);
IfcRepresentationShapeModel& operator=(const IfcRepresentationShapeModel& other);
public:
IfcRepresentationShapeModel(unsigned int id, const IfcGeom::ShapeList& shapes, bool owns_shapes = false)
IfcRepresentationShapeModel(unsigned int id, const IfcGeom::IfcRepresentationShapeItems& shapes, bool owns_shapes = false)
: id(id)
, shapes(shapes)
, owns_shapes(owns_shapes)
{}
~IfcRepresentationShapeModel() {
for ( IfcGeom::ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
delete it->first;
if (owns_shapes) {
delete it->second;
}
}
}
IfcGeom::ShapeList::const_iterator begin() const { return shapes.begin(); }
IfcGeom::ShapeList::const_iterator end() const { return shapes.end(); }
virtual ~IfcRepresentationShapeModel() {}
IfcGeom::IfcRepresentationShapeItems::const_iterator begin() const { return shapes.begin(); }
IfcGeom::IfcRepresentationShapeItems::const_iterator end() const { return shapes.end(); }
const unsigned int& getId() const { return id; }
};
@@ -146,6 +137,7 @@ namespace IfcGeomObjects {
int id;
std::string brep_data;
IfcRepresentationBrepData(const IfcRepresentationShapeModel& s);
virtual ~IfcRepresentationBrepData() {}
};
class IfcRepresentationTriangulation {
@@ -155,11 +147,14 @@ 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;
VertKeyMap welds;
IfcRepresentationTriangulation(const IfcRepresentationShapeModel& s);
virtual ~IfcRepresentationTriangulation() {}
private:
int addvert(const gp_XYZ& p);
int addvert(int material_index, const gp_XYZ& p);
inline void addedge(int n1, int n2, std::map<std::pair<int,int>,int>& edgecount, std::vector<std::pair<int,int> >& edges_temp) {
const Edge e = Edge( (std::min)(n1,n2),(std::max)(n1,n2) );
if ( edgecount.find(e) == edgecount.end() ) edgecount[e] = 1;
+25 -15
View File
@@ -92,20 +92,22 @@ bool IfcGeom::convert(const Ifc2x3::IfcExtrudedAreaSolid::ptr l, TopoDS_Shape& s
shape.Move(trsf);
return ! shape.IsNull();
}
bool IfcGeom::convert(const Ifc2x3::IfcFacetedBrep::ptr l, ShapeList& shape) {
bool IfcGeom::convert(const Ifc2x3::IfcFacetedBrep::ptr l, IfcRepresentationShapeItems& shape) {
TopoDS_Shape s;
if ( const TopoDS_Shape* shape_id = IfcGeom::convert_shape(l->Outer(),s) ) {
shape.push_back(LocationShape(new gp_GTrsf(),shape_id));
if (IfcGeom::convert_shape(l->Outer(),s) ) {
shape.push_back(IfcRepresentationShapeItem(s, get_style(l->Outer())));
return true;
}
return false;
}
bool IfcGeom::convert(const Ifc2x3::IfcFaceBasedSurfaceModel::ptr l, ShapeList& shapes) {
bool IfcGeom::convert(const Ifc2x3::IfcFaceBasedSurfaceModel::ptr l, IfcRepresentationShapeItems& shapes) {
Ifc2x3::IfcConnectedFaceSet::list facesets = l->FbsmFaces();
const SurfaceStyle* collective_style = get_style(l);
for( Ifc2x3::IfcConnectedFaceSet::it it = facesets->begin(); it != facesets->end(); ++ it ) {
TopoDS_Shape s;
if ( const TopoDS_Shape* shape_id = IfcGeom::convert_shape(*it,s) ) {
shapes.push_back(LocationShape(new gp_GTrsf(),shape_id));
const SurfaceStyle* shell_style = get_style(*it);
if (IfcGeom::convert_shape(*it,s)) {
shapes.push_back(IfcRepresentationShapeItem(s, shell_style ? shell_style : collective_style));
}
}
return true;
@@ -135,12 +137,17 @@ bool IfcGeom::convert(const Ifc2x3::IfcPolygonalBoundedHalfSpace::ptr l, TopoDS_
shape = BRepAlgoAPI_Common(halfspace,prism);
return true;
}
bool IfcGeom::convert(const Ifc2x3::IfcShellBasedSurfaceModel::ptr l, ShapeList& shapes) {
bool IfcGeom::convert(const Ifc2x3::IfcShellBasedSurfaceModel::ptr l, IfcRepresentationShapeItems& shapes) {
IfcUtil::IfcAbstractSelect::list shells = l->SbsmBoundary();
const SurfaceStyle* collective_style = get_style(l);
for( IfcUtil::IfcAbstractSelect::it it = shells->begin(); it != shells->end(); ++ it ) {
TopoDS_Shape s;
if ( const TopoDS_Shape* shape_id = IfcGeom::convert_shape(*it,s) ) {
shapes.push_back(LocationShape(new gp_GTrsf(),shape_id));
const SurfaceStyle* shell_style = 0;
if ((*it)->is(Ifc2x3::Type::IfcRepresentationItem)) {
shell_style = get_style((Ifc2x3::IfcRepresentationItem*)*it);
}
if (IfcGeom::convert_shape(*it,s)) {
shapes.push_back(IfcRepresentationShapeItem(s, shell_style ? shell_style : collective_style));
}
}
return true;
@@ -334,7 +341,7 @@ bool IfcGeom::convert(const Ifc2x3::IfcConnectedFaceSet::ptr l, TopoDS_Shape& sh
}
return true;
}
bool IfcGeom::convert(const Ifc2x3::IfcMappedItem::ptr l, ShapeList& shapes) {
bool IfcGeom::convert(const Ifc2x3::IfcMappedItem::ptr l, IfcRepresentationShapeItems& shapes) {
gp_GTrsf gtrsf;
Ifc2x3::IfcCartesianTransformationOperator::ptr transform = l->MappingTarget();
if ( transform->is(Ifc2x3::Type::IfcCartesianTransformationOperator3DnonUniform) ) {
@@ -367,19 +374,22 @@ bool IfcGeom::convert(const Ifc2x3::IfcMappedItem::ptr l, ShapeList& shapes) {
const unsigned int previous_size = (const unsigned int) shapes.size();
bool b = IfcGeom::convert_shapes(map->MappedRepresentation(),shapes);
for ( unsigned int i = previous_size; i < shapes.size(); ++ i ) {
shapes[i].first->Multiply(gtrsf);
shapes[i].move(gtrsf);
}
return b;
}
bool IfcGeom::convert(const Ifc2x3::IfcShapeRepresentation::ptr l, ShapeList& shapes) {
bool IfcGeom::convert(const Ifc2x3::IfcShapeRepresentation::ptr l, IfcRepresentationShapeItems& shapes) {
Ifc2x3::IfcRepresentationItem::list items = l->Items();
if ( ! items->Size() ) return false;
for ( Ifc2x3::IfcRepresentationItem::it it = items->begin(); it != items->end(); ++ it ) {
if ( IfcGeom::is_shape_collection(*it) ) IfcGeom::convert_shapes(*it,shapes);
Ifc2x3::IfcRepresentationItem* representation_item = *it;
if ( IfcGeom::is_shape_collection(representation_item) ) IfcGeom::convert_shapes(*it,shapes);
else {
TopoDS_Shape s;
if ( const TopoDS_Shape* shape_id = IfcGeom::convert_shape(*it,s))
shapes.push_back(LocationShape(new gp_GTrsf(),shape_id));
if (IfcGeom::convert_shape(representation_item,s)) {
shapes.push_back(IfcRepresentationShapeItem(s, get_style(representation_item)));
}
}
}
return true;
+3 -3
View File
@@ -31,7 +31,7 @@ namespace IfcGeom {
using namespace Ifc2x3;
using namespace IfcUtil;
bool IfcGeom::convert_shapes(const IfcBaseClass* l, ShapeList& r) {
bool IfcGeom::convert_shapes(const IfcBaseClass* l, IfcRepresentationShapeItems& r) {
#include "IfcRegisterConvertShapes.h"
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
return false;
@@ -40,10 +40,10 @@ bool IfcGeom::is_shape_collection(const IfcBaseClass* l) {
#include "IfcRegisterIsShapeCollection.h"
return false;
}
const TopoDS_Shape* IfcGeom::convert_shape(const IfcBaseClass* l, TopoDS_Shape& r) {
bool IfcGeom::convert_shape(const IfcBaseClass* l, TopoDS_Shape& r) {
const unsigned int id = l->entity->id();
std::map<int,TopoDS_Shape>::const_iterator it = Cache::Shape.find(id);
if ( it != Cache::Shape.end() ) { r = it->second; return &(it->second); }
if ( it != Cache::Shape.end() ) { r = it->second; return true; }
#include "IfcRegisterConvertShape.h"
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
return 0;
+1 -1
View File
@@ -4,7 +4,7 @@
try { \
if ( convert((T*)l,r) ) { \
Cache::Shape[id] = r; \
return &(Cache::Shape[id]); \
return true; \
} \
} catch(...) { } \
Logger::Message(Logger::LOG_ERROR,"Failed to convert:",l->entity); \
+1 -1
View File
@@ -1,6 +1,6 @@
#include "IfcRegisterUndef.h"
#define CLASS(T,V) bool convert(const T::ptr L, V& r);
#define SHAPES(T) CLASS(T,ShapeList)
#define SHAPES(T) CLASS(T,IfcRepresentationShapeItems)
#define SHAPE(T) CLASS(T,TopoDS_Shape)
#define WIRE(T) CLASS(T,TopoDS_Wire)
#define FACE(T) CLASS(T,TopoDS_Face)