IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_representation_and_product(const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product) {
IfcGeom::Representation::BRep* shape;
@@ -898,7 +1106,12 @@ IfcGeom::BRepElement
* IfcGeom::Kernel::create_brep_for_representation_and_pro
if ( !settings.disable_opening_subtractions() && openings && openings->size() ) {
IfcGeom::IfcRepresentationShapeItems opened_shapes;
try {
- if ( settings.faster_booleans() ) {
+#if OCC_VERSION_HEX < 0x60900
+ const bool faster_booleans = settings.faster_booleans();
+#else
+ const bool faster_booleans = true;
+#endif
+ if (faster_booleans) {
bool succes = convert_openings_fast(product,openings,shapes,trsf,opened_shapes);
if ( ! succes ) {
opened_shapes.clear();
@@ -1065,4 +1278,26 @@ std::pair IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn
}
return std::pair(unit_name, unit_magnitude);
-}
\ No newline at end of file
+}
+
+const IfcSchema::IfcRepresentationItem* IfcGeom::Kernel::find_item_carrying_style(const IfcSchema::IfcRepresentationItem* item) {
+ if (item->StyledByItem()->size()) {
+ return item;
+ }
+
+ while (item->declaration().is(IfcSchema::Type::IfcBooleanClippingResult)) {
+ // All instantiations of IfcBooleanOperand (type of FirstOperand) are subtypes of
+ // IfcGeometricRepresentationItem
+ item = (IfcSchema::IfcGeometricRepresentationItem*) ((IfcSchema::IfcBooleanClippingResult*) item)->FirstOperand();
+ if (item->StyledByItem()->size()) {
+ return item;
+ }
+ }
+
+ // TODO: Ideally this would be done for other entities (such as IfcCsgSolid) as well.
+ // But neither are these very prevalent, nor does the current IfcOpenShell style
+ // mechanism enable to conveniently style subshapes, which would be necessary for
+ // distinctly styled union operands.
+
+ return item;
+}
diff --git a/src/ifcgeom/IfcGeomHelpers.cpp b/src/ifcgeom/IfcGeomHelpers.cpp
index 932896a95b..075ebebfd2 100644
--- a/src/ifcgeom/IfcGeomHelpers.cpp
+++ b/src/ifcgeom/IfcGeomHelpers.cpp
@@ -287,7 +287,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
return false;
}
IfcSchema::IfcLocalPlacement* current = (IfcSchema::IfcLocalPlacement*)l;
- while (1) {
+ for (;;) {
gp_Trsf trsf2;
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
if ( relplacement->declaration().is(IfcSchema::Type::IfcAxis2Placement3D) ) {
diff --git a/src/ifcgeom/IfcGeomIterator.h b/src/ifcgeom/IfcGeomIterator.h
index 475fb50509..9913b1e876 100644
--- a/src/ifcgeom/IfcGeomIterator.h
+++ b/src/ifcgeom/IfcGeomIterator.h
@@ -64,6 +64,8 @@
#include
#include
+#include
+
#include
#include
#include
@@ -125,10 +127,7 @@ namespace IfcGeom {
void populate_set(const std::set& include_or_ignore) {
entities_to_include_or_exclude.clear();
for (std::set::const_iterator it = include_or_ignore.begin(); it != include_or_ignore.end(); ++it) {
- std::string uppercase_type = *it;
- for (std::string::iterator c = uppercase_type.begin(); c != uppercase_type.end(); ++c) {
- *c = toupper(*c);
- }
+ const std::string uppercase_type = boost::to_upper_copy(*it);
IfcSchema::Type::Enum ty;
try {
ty = IfcSchema::Type::FromString(uppercase_type);
@@ -181,15 +180,15 @@ namespace IfcGeom {
// by the parent's context inverse attributes.
continue;
}
- if (context->hasContextType()) {
- std::string context_type_lc = context->ContextType();
- for (std::string::iterator c = context_type_lc.begin(); c != context_type_lc.end(); ++c) {
- *c = tolower(*c);
+ try {
+ if (context->hasContextType()) {
+ std::string context_type = context->ContextType();
+ boost::to_lower(context_type);
+ if (context_types.find(context_type) != context_types.end()) {
+ filtered_contexts->push(context);
+ }
}
- if (context_types.find(context_type_lc) != context_types.end()) {
- filtered_contexts->push(context);
- }
- }
+ } catch (const IfcParse::IfcException&) {}
}
// In case no contexts are identified based on their ContextType, all contexts are
@@ -207,10 +206,12 @@ namespace IfcGeom {
IfcSchema::IfcGeometricRepresentationContext* context = *it;
representations->push(context->RepresentationsInContext());
- if (context->hasPrecision() && context->Precision() < lowest_precision_encountered) {
- lowest_precision_encountered = context->Precision();
- any_precision_encountered = true;
- }
+ try {
+ if (context->hasPrecision() && context->Precision() < lowest_precision_encountered) {
+ lowest_precision_encountered = context->Precision();
+ any_precision_encountered = true;
+ }
+ } catch (const IfcParse::IfcException&) {}
IfcSchema::IfcGeometricRepresentationSubContext::list::ptr sub_contexts = context->HasSubContexts();
for (jt = sub_contexts->begin(); jt != sub_contexts->end(); ++jt) {
representations->push((*jt)->RepresentationsInContext());
@@ -288,7 +289,7 @@ namespace IfcGeom {
}
BRepElement* create_shape_model_for_next_entity() {
- while ( true ) {
+ for (;;) {
IfcSchema::IfcRepresentation* representation;
// Have we reached the end of our list of representations?
@@ -321,16 +322,16 @@ namespace IfcGeom {
// Filter the products based on the set of entities being included or excluded for
// processing. The set is iterated over te able to filter on subtypes.
- for ( IfcSchema::IfcProduct::list::it it = unfiltered_products->begin(); it != unfiltered_products->end(); ++it ) {
+ for ( IfcSchema::IfcProduct::list::it jt = unfiltered_products->begin(); jt != unfiltered_products->end(); ++jt ) {
bool found = false;
- for (std::set::const_iterator jt = entities_to_include_or_exclude.begin(); jt != entities_to_include_or_exclude.end(); ++jt) {
- if ((*it)->declaration().is(*jt)) {
+ for (std::set::const_iterator kt = entities_to_include_or_exclude.begin(); kt != entities_to_include_or_exclude.end(); ++kt) {
+ if ((*jt)->declaration().is(*kt)) {
found = true;
break;
}
}
if (found == include_entities_in_processing) {
- ifcproducts->push(*it);
+ ifcproducts->push(*jt);
}
}
diff --git a/src/ifcgeom/IfcGeomRenderStyles.cpp b/src/ifcgeom/IfcGeomRenderStyles.cpp
index b88899cd6c..b931ffdce3 100644
--- a/src/ifcgeom/IfcGeomRenderStyles.cpp
+++ b/src/ifcgeom/IfcGeomRenderStyles.cpp
@@ -21,7 +21,7 @@
#include "IfcGeom.h"
-bool process_colour(IfcSchema::IfcColourRgb* colour, std::tr1::array& rgb) {
+bool process_colour(IfcSchema::IfcColourRgb* colour, double* rgb) {
if (colour != 0) {
rgb[0] = colour->Red();
rgb[1] = colour->Green();
@@ -30,7 +30,7 @@ bool process_colour(IfcSchema::IfcColourRgb* colour, std::tr1::array&
return colour != 0;
}
-bool process_colour(IfcSchema::IfcNormalisedRatioMeasure* factor, std::tr1::array& rgb) {
+bool process_colour(IfcSchema::IfcNormalisedRatioMeasure* factor, double* rgb) {
if (factor != 0) {
const double f = *factor;
rgb[0] = rgb[1] = rgb[2] = f;
@@ -38,7 +38,7 @@ bool process_colour(IfcSchema::IfcNormalisedRatioMeasure* factor, std::tr1::arra
return factor != 0;
}
-bool process_colour(IfcSchema::IfcColourOrFactor* colour_or_factor, std::tr1::array& rgb) {
+bool process_colour(IfcSchema::IfcColourOrFactor* colour_or_factor, double* rgb) {
if (colour_or_factor == 0) {
return false;
} else if (colour_or_factor->declaration().is(IfcSchema::Type::IfcColourRgb)) {
@@ -66,7 +66,7 @@ const IfcGeom::SurfaceStyle* IfcGeom::Kernel::get_style(const IfcSchema::IfcRepr
} else {
surface_style = SurfaceStyle(surface_style_id);
}
- std::tr1::array rgb;
+ double rgb[3];
if (process_colour(shading_styles.second->SurfaceColour(), rgb)) {
surface_style.Diffuse().reset(SurfaceStyle::ColorComponent(rgb[0], rgb[1], rgb[2]));
}
diff --git a/src/ifcgeom/IfcGeomRenderStyles.h b/src/ifcgeom/IfcGeomRenderStyles.h
index cd8d771246..d84b85d737 100644
--- a/src/ifcgeom/IfcGeomRenderStyles.h
+++ b/src/ifcgeom/IfcGeomRenderStyles.h
@@ -20,16 +20,6 @@
#ifndef IFCGEOMRENDERSTYLES_H
#define IFCGEOMRENDERSTYLES_H
-#ifdef __GNUC__
-#include
-#else
-#if _MSC_VER < 1600
-#include
-#else
-#include
-#endif
-#endif
-
#ifdef USE_IFC4
#include "../ifcparse/Ifc4.h"
#else
@@ -41,7 +31,7 @@ namespace IfcGeom {
public:
class ColorComponent {
private:
- std::tr1::array data;
+ double data[3];
public:
ColorComponent(double r, double g, double b) {
data[0] = r; data[1] = g; data[2] = b;
diff --git a/src/ifcgeom/IfcGeomRepresentation.h b/src/ifcgeom/IfcGeomRepresentation.h
index 4448a07b86..4561e71c91 100644
--- a/src/ifcgeom/IfcGeomRepresentation.h
+++ b/src/ifcgeom/IfcGeomRepresentation.h
@@ -41,6 +41,8 @@ namespace IfcGeom {
namespace Representation {
class Representation {
+ Representation(const Representation&); //N/A
+ Representation& operator =(const Representation&); //N/A
protected:
const ElementSettings _settings;
public:
@@ -116,33 +118,33 @@ namespace IfcGeom {
: Representation(shape_model.settings())
, _id(shape_model.getId())
{
- for ( IfcGeom::IfcRepresentationShapeItems::const_iterator it = shape_model.begin(); it != shape_model.end(); ++ it ) {
+ for ( IfcGeom::IfcRepresentationShapeItems::const_iterator iit = shape_model.begin(); iit != shape_model.end(); ++ iit ) {
int surface_style_id = -1;
- if (it->hasStyle()) {
- Material adapter(&it->Style());
+ if (iit->hasStyle()) {
+ Material adapter(&iit->Style());
std::vector::const_iterator jt = std::find(_materials.begin(), _materials.end(), adapter);
if (jt == _materials.end()) {
- surface_style_id = _materials.size();
+ surface_style_id = (int)_materials.size();
_materials.push_back(adapter);
} else {
- surface_style_id = jt - _materials.begin();
+ surface_style_id = (int)(jt - _materials.begin());
}
}
if (settings().apply_default_materials() && surface_style_id == -1) {
Material material(IfcGeom::get_default_style(settings().element_type()));
- std::vector::const_iterator it = std::find(_materials.begin(), _materials.end(), material);
- if (it == _materials.end()) {
- surface_style_id = _materials.size();
+ std::vector::const_iterator mit = std::find(_materials.begin(), _materials.end(), material);
+ if (mit == _materials.end()) {
+ surface_style_id = (int)_materials.size();
_materials.push_back(material);
} else {
- surface_style_id = it - _materials.begin();
+ surface_style_id = (int)(mit - _materials.begin());
}
}
- const TopoDS_Shape& s = it->Shape();
- const gp_GTrsf& trsf = it->Placement();
+ const TopoDS_Shape& s = iit->Shape();
+ const gp_GTrsf& trsf = iit->Placement();
// Triangulate the shape
try {
@@ -231,11 +233,11 @@ namespace IfcGeom {
addEdge(dict[n2], dict[n3], edgecount, edges_temp);
addEdge(dict[n3], dict[n1], edgecount, edges_temp);
}
- for ( std::vector >::const_iterator it = edges_temp.begin(); it != edges_temp.end(); ++it ) {
- if (edgecount[*it] == 1) {
+ for ( std::vector >::const_iterator jt = edges_temp.begin(); jt != edges_temp.end(); ++jt ) {
+ if (edgecount[*jt] == 1) {
// non manifold edge, face boundary
- _edges.push_back(it->first);
- _edges.push_back(it->second);
+ _edges.push_back(jt->first);
+ _edges.push_back(jt->second);
}
}
}
@@ -245,11 +247,11 @@ namespace IfcGeom {
// Edges are only emitted if there are no faces. A mixed representation of faces
// and loose edges is discouraged by the standard. An alternative would be to use
// TopExp::MapShapesAndAncestors() to find edges that do not belong to any face.
- for (TopExp_Explorer exp(s, TopAbs_EDGE); exp.More(); exp.Next()) {
- BRepAdaptor_Curve crv(TopoDS::Edge(exp.Current()));
+ for (TopExp_Explorer texp(s, TopAbs_EDGE); texp.More(); texp.Next()) {
+ BRepAdaptor_Curve crv(TopoDS::Edge(texp.Current()));
GCPnts_QuasiUniformDeflection tessellater(crv, settings().deflection_tolerance());
int n = tessellater.NbPoints();
- int start = _verts.size() / 3;
+ int start = (int)_verts.size() / 3;
for (int i = 1; i <= n; ++i) {
gp_XYZ p = tessellater.Value(i).XYZ();
trsf.Transforms(p);
diff --git a/src/ifcgeom/IfcGeomShapes.cpp b/src/ifcgeom/IfcGeomShapes.cpp
index 15e5f30f0f..ade88c0adc 100644
--- a/src/ifcgeom/IfcGeomShapes.cpp
+++ b/src/ifcgeom/IfcGeomShapes.cpp
@@ -65,6 +65,8 @@
#include
#include
#include
+#include
+
#include
#include
@@ -99,10 +101,15 @@
#include "../ifcgeom/IfcGeom.h"
bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_Shape& shape) {
+ const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
+ if (height < getValue(GV_PRECISION)) {
+ Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", l);
+ return false;
+ }
+
TopoDS_Shape face;
if ( !convert_face(l->SweptArea(),face) ) return false;
- const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
gp_Trsf trsf;
IfcGeom::Kernel::convert(l->Position(),trsf);
@@ -244,10 +251,20 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcHalfSpaceSolid* l, TopoDS_Shap
bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalBoundedHalfSpace* l, TopoDS_Shape& shape) {
TopoDS_Shape halfspace;
if ( ! IfcGeom::Kernel::convert((IfcSchema::IfcHalfSpaceSolid*)l,halfspace) ) return false;
+
TopoDS_Wire wire;
- if ( ! convert_wire(l->PolygonalBoundary(),wire) || ! wire.Closed() ) return false;
+ if ( ! convert_wire(l->PolygonalBoundary(),wire) || ! wire.Closed() ) return false;
+
gp_Trsf trsf;
- convert(l->Position(),trsf);
+ if ( ! convert(l->Position(),trsf) ) return false;
+
+ TColgp_SequenceOfPnt points;
+ if (wire_to_sequence_of_point(wire, points)) {
+ remove_duplicate_points_from_loop(points, wire.Closed()); // Note: wire always closed, as per if statement above
+ remove_collinear_points_from_loop(points, wire.Closed());
+ sequence_of_point_to_wire(points, wire, wire.Closed());
+ }
+
TopoDS_Shape prism = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(wire),gp_Vec(0,0,200));
gp_Trsf down; down.SetTranslation(gp_Vec(0,0,-100.0));
prism.Move(trsf*down);
@@ -272,6 +289,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcShellBasedSurfaceModel* l, Ifc
}
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape& shape) {
+
TopoDS_Shape s1, s2;
IfcRepresentationShapeItems items1, items2;
TopoDS_Wire boundary_wire;
@@ -325,10 +343,36 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
const IfcSchema::IfcBooleanOperator::IfcBooleanOperator op = l->Operator();
+ /*
+ // TK: A little debugging trick to output both operands for visual inspection
+
+ BRep_Builder builder;
+ TopoDS_Compound compound;
+ builder.MakeCompound(compound);
+ builder.Add(compound, s1);
+ builder.Add(compound, s2);
+ shape = compound;
+ return true;
+ */
+
if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE) {
bool valid_cut = false;
- BRepAlgoAPI_Cut brep_cut(s1,s2);
+
+#if OCC_VERSION_HEX < 0x60900
+ BRepAlgoAPI_Cut brep_cut(s1, s2);
+#else
+ BRepAlgoAPI_Cut brep_cut;
+ TopTools_ListOfShape s1s;
+ s1s.Append(s1);
+ TopTools_ListOfShape s2s;
+ s2s.Append(s2);
+ brep_cut.SetFuzzyValue(getValue(GV_PRECISION));
+ brep_cut.SetArguments(s1s);
+ brep_cut.SetTools(s2s);
+ brep_cut.Build();
+#endif
+
if ( brep_cut.IsDone() ) {
TopoDS_Shape result = brep_cut;
@@ -399,7 +443,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
bool IfcGeom::Kernel::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Shape& shape) {
IfcSchema::IfcFace::list::ptr faces = l->CfsFaces();
bool facesAdded = false;
- const unsigned int num_faces = faces->size();
+ const unsigned int num_faces = (unsigned)faces->size();
bool valid_shell = false;
if ( num_faces < getValue(GV_MAX_FACES_TO_SEW) ) {
BRepOffsetAPI_Sewing builder;
@@ -492,11 +536,22 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcMappedItem* l, IfcRepresentati
trsf = trsf_2d;
}
gtrsf.Multiply(trsf);
+
+ const IfcGeom::SurfaceStyle* mapped_item_style = get_style(l);
+
const unsigned int previous_size = (const unsigned int) shapes.size();
- bool b = convert_shapes(map->MappedRepresentation(),shapes);
+ bool b = convert_shapes(map->MappedRepresentation(), shapes);
+
for ( unsigned int i = previous_size; i < shapes.size(); ++ i ) {
shapes[i].append(gtrsf);
+
+ // Apply styles assigned to the mapped item only if on
+ // a more granular level no styles have been applied
+ if (!shapes[i].hasStyle()) {
+ shapes[i].setStyle(mapped_item_style);
+ }
}
+
return b;
}
@@ -627,9 +682,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCurveBoundedPlane* l, TopoDS_S
BRepBuilderAPI_MakeFace mf (outer);
mf.Add(outer);
- IfcSchema::IfcCurve::list::ptr inner = l->InnerBoundaries();
+ IfcSchema::IfcCurve::list::ptr boundaries = l->InnerBoundaries();
- for (IfcSchema::IfcCurve::list::it it = inner->begin(); it != inner->end(); ++it) {
+ for (IfcSchema::IfcCurve::list::it it = boundaries->begin(); it != boundaries->end(); ++it) {
TopoDS_Wire inner;
convert_wire(*it, inner);
@@ -762,8 +817,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shap
// Subtraction of pipes with small radii is unstable.
hasInnerRadius = false;
} else {
- Handle(Geom_Circle) circle = new Geom_Circle(directrix, r2);
- section2 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle));
+ Handle(Geom_Circle) circle2 = new Geom_Circle(directrix, r2);
+ section2 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle2));
}
}
@@ -817,7 +872,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCylindricalSurface* l, TopoDS_
gp_Trsf trsf;
IfcGeom::Kernel::convert(l->Position(),trsf);
+#if OCC_VERSION_HEX < 0x60502
+ face = BRepBuilderAPI_MakeFace(new Geom_CylindricalSurface(gp::XOY(), l->Radius())).Face().Moved(trsf);
+#else
face = BRepBuilderAPI_MakeFace(new Geom_CylindricalSurface(gp::XOY(), l->Radius()), getValue(GV_PRECISION)).Face().Moved(trsf);
+#endif
return true;
}
@@ -882,7 +941,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS
if (faces.empty()) return false;
- const unsigned int num_faces = indices.size();
+ const unsigned int num_faces = (unsigned)indices.size();
bool valid_shell = false;
if (faces.size() < getValue(GV_MAX_FACES_TO_SEW)) {
diff --git a/src/ifcgeom/IfcGeomWires.cpp b/src/ifcgeom/IfcGeomWires.cpp
index eb7b086c00..4fc056f640 100644
--- a/src/ifcgeom/IfcGeomWires.cpp
+++ b/src/ifcgeom/IfcGeomWires.cpp
@@ -168,6 +168,25 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire
//last_vertex = w.Vertex();
if ( w.Error() != BRepBuilderAPI_WireDone ) {
Logger::Message(Logger::LOG_ERROR, "Failed to join curve segments:", l);
+
+ TopoDS_Vertex v1, v2, last;
+ last = w.Vertex();
+
+ if (!last.IsNull()) {
+ std::stringstream ss;
+ gp_Pnt p = BRep_Tool::Pnt(last);
+ ss << std::setprecision(4) << "Last vertex at (" << p.X() << " " << p.Y() << " " << p.Z() << ")";
+ Logger::Message(Logger::LOG_NOTICE, ss.str());
+ }
+
+ TopExp::Vertices(wire2, v1, v2);
+ if (!v1.IsNull()) {
+ std::stringstream ss;
+ gp_Pnt p = BRep_Tool::Pnt(v1);
+ ss << std::setprecision(4) << "Segment starts at (" << p.X() << " " << p.Y() << " " << p.Z() << ") for:";
+ Logger::Message(Logger::LOG_NOTICE, ss.str(), *it);
+ }
+
return false;
}
}
@@ -184,8 +203,6 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
bool trim_cartesian = l->MasterRepresentation() == IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN;
IfcEntityList::ptr trims1 = l->Trim1();
IfcEntityList::ptr trims2 = l->Trim2();
- bool trimmed1 = false;
- bool trimmed2 = false;
unsigned sense_agreement = l->SenseAgreement() ? 0 : 1;
double flts[2];
gp_Pnt pnts[2];
@@ -257,7 +274,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
flts[1] -= M_PI / 2.;
}
}
- if ( isConic && ALMOST_THE_SAME(fmod(flts[1]-flts[0],(double)(M_PI*2.0)),0.0f) ) {
+ if ( isConic && ALMOST_THE_SAME(fmod(flts[1]-flts[0],M_PI*2.),0.) ) {
w.Add(BRepBuilderAPI_MakeEdge(curve));
} else {
BRepBuilderAPI_MakeEdge e (curve,flts[0],flts[1]);
@@ -286,7 +303,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolyline* l, TopoDS_Wire& resu
}
// Remove points that are too close to one another
- remove_redundant_points_from_loop(polygon, false);
+ remove_duplicate_points_from_loop(polygon, false);
BRepBuilderAPI_MakePolygon w;
for (int i = 1; i <= polygon.Length(); ++i) {
@@ -316,7 +333,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolyLoop* l, TopoDS_Wire& resu
}
// Remove points that are too close to one another
- remove_redundant_points_from_loop(polygon, true);
+ remove_duplicate_points_from_loop(polygon, true);
int count = polygon.Length();
if (original_count - count != 0) {
@@ -411,9 +428,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEdgeLoop* l, TopoDS_Wire& resu
TopoDS_Wire w;
if (convert_wire(*it, w)) {
if (!(*it)->Orientation()) w.Reverse();
- TopoDS_Iterator it(w, false);
- for (; it.More(); it.Next()) {
- const TopoDS_Edge& e = TopoDS::Edge(it.Value());
+ TopoDS_Iterator topoit(w, false);
+ for (; topoit.More(); topoit.Next()) {
+ const TopoDS_Edge& e = TopoDS::Edge(topoit.Value());
mw.Add(e);
}
// mw.Add(w);
diff --git a/src/ifcgeom/IfcRegister.cpp b/src/ifcgeom/IfcRegister.cpp
index 5a639f96dc..942d7df5c6 100644
--- a/src/ifcgeom/IfcRegister.cpp
+++ b/src/ifcgeom/IfcRegister.cpp
@@ -24,6 +24,15 @@ using namespace IfcSchema;
using namespace IfcUtil;
bool IfcGeom::Kernel::convert_shapes(const IfcBaseClass* l, IfcRepresentationShapeItems& r) {
+ if (shape_type(l) != ST_SHAPELIST) {
+ TopoDS_Shape shp;
+ if (convert_shape(l, shp)) {
+ r.push_back(IfcGeom::IfcRepresentationShapeItem(shp, get_style(l->as())));
+ return true;
+ }
+ return false;
+ }
+
#include "IfcRegisterConvertShapes.h"
Logger::Message(Logger::LOG_ERROR, "No operation defined for:", l);
return false;
diff --git a/src/ifcgeom/IfcRegister.h b/src/ifcgeom/IfcRegister.h
index dc231b2b40..305c0c9f5e 100644
--- a/src/ifcgeom/IfcRegister.h
+++ b/src/ifcgeom/IfcRegister.h
@@ -53,9 +53,9 @@ SHAPE(IfcCylindricalSurface);
SHAPE(IfcAdvancedBrep);
// FIXME: Surfaces should have a shape type of their own
SHAPE(IfcBSplineSurfaceWithKnots);
-SHAPE(IfcPlane);
SHAPE(IfcTriangulatedFaceSet);
#endif
+SHAPE(IfcPlane);
SHAPE(IfcExtrudedAreaSolid);
SHAPE(IfcRevolvedAreaSolid);
SHAPE(IfcConnectedFaceSet);
diff --git a/src/ifcgeom/IfcRepresentationShapeItem.h b/src/ifcgeom/IfcRepresentationShapeItem.h
index 88ac340214..1d2c3fa8b5 100644
--- a/src/ifcgeom/IfcRepresentationShapeItem.h
+++ b/src/ifcgeom/IfcRepresentationShapeItem.h
@@ -46,6 +46,7 @@ namespace IfcGeom {
const gp_GTrsf& Placement() const { return placement; }
bool hasStyle() const { return style != 0; }
const SurfaceStyle& Style() const { return *style; }
+ void setStyle(const SurfaceStyle* style) { this->style = style; }
};
typedef std::vector IfcRepresentationShapeItems;
}
diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp
index 22eaca9844..975c3c471e 100644
--- a/src/ifcgeomserver/IfcGeomServer.cpp
+++ b/src/ifcgeomserver/IfcGeomServer.cpp
@@ -37,6 +37,10 @@
#include "../ifcgeom/IfcGeomIterator.h"
+#if USE_VLD
+#include
+#endif
+
using namespace boost;
template
@@ -69,7 +73,7 @@ void swrite(std::ostream& s, T t) {
template <>
void swrite(std::ostream& s, std::string t) {
- int32_t len = t.size();
+ int32_t len = (int32_t)t.size();
swrite(s, len);
s.write(t.c_str(), len);
while (len++ % 4) s.put(0);
@@ -156,16 +160,16 @@ public:
class Get : public Command {
protected:
- void read_content(std::istream& s) {}
- void write_content(std::ostream& s) {}
+ void read_content(std::istream& /*s*/) {}
+ void write_content(std::ostream& /*s*/) {}
public:
Get() : Command(GET) {};
};
class GetLog : public Command {
protected:
- void read_content(std::istream& s) {}
- void write_content(std::ostream& s) {}
+ void read_content(std::istream& /*s*/) {}
+ void write_content(std::ostream& /*s*/) {}
public:
GetLog() : Command(GET_LOG) {};
};
@@ -189,7 +193,7 @@ private:
const IfcGeom::TriangulationElement* geom;
bool append_line_data;
protected:
- void read_content(std::istream& s) {}
+ void read_content(std::istream& /*s*/) {}
void write_content(std::ostream& s) {
swrite(s, geom->id());
swrite(s, geom->guid());
@@ -238,9 +242,9 @@ protected:
}
{ std::vector diffuse_color_array;
for (std::vector::const_iterator it = geom->geometry().materials().begin(); it != geom->geometry().materials().end(); ++it) {
- const IfcGeom::Material& m = *it;
- if (m.hasDiffuse()) {
- const double* color = m.diffuse();
+ const IfcGeom::Material& mat = *it;
+ if (mat.hasDiffuse()) {
+ const double* color = mat.diffuse();
diffuse_color_array.push_back(static_cast(color[0]));
diffuse_color_array.push_back(static_cast(color[1]));
diffuse_color_array.push_back(static_cast(color[2]));
@@ -249,8 +253,8 @@ protected:
diffuse_color_array.push_back(0.f);
diffuse_color_array.push_back(0.f);
}
- if (m.hasTransparency()) {
- diffuse_color_array.push_back(static_cast(1. - m.transparency()));
+ if (mat.hasTransparency()) {
+ diffuse_color_array.push_back(static_cast(1. - mat.transparency()));
} else {
diffuse_color_array.push_back(1.f);
}
@@ -268,25 +272,21 @@ public:
class Next : public Command {
protected:
- void read_content(std::istream& s) {}
- void write_content(std::ostream& s) {}
+ void read_content(std::istream& /*s*/) {}
+ void write_content(std::ostream& /*s*/) {}
public:
Next() : Command(NEXT) {};
};
class Bye : public Command {
protected:
- void read_content(std::istream& s) {}
- void write_content(std::ostream& s) {}
+ void read_content(std::istream& /*s*/) {}
+ void write_content(std::ostream& /*s*/) {}
public:
Bye() : Command(BYE) {};
};
-int main (int argc, char** argv) {
- if (sizeof(float) != 4 || sizeof(int32_t) != 4) {
- return 1;
- }
-
+int main () {
// Redirect stdout to this stream, so that involuntary
// writes to stdout do not interfere with our protocol.
std::ostringstream oss;
@@ -308,7 +308,7 @@ int main (int argc, char** argv) {
Hello().write(std::cout);
int exit_code = 0;
- while (1) {
+ for (;;) {
const int32_t msg_type = sread(std::cin);
switch (msg_type) {
case IFC_MODEL: {
@@ -323,7 +323,7 @@ int main (int argc, char** argv) {
settings.convert_back_units() = true;
settings.include_curves() = true;
- iterator = new IfcGeom::Iterator(settings, data, len);
+ iterator = new IfcGeom::Iterator(settings, data, (int)len);
has_more = iterator->initialize();
More(has_more).write(std::cout);
diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py
index 4d9f8b4d34..eb14ece33a 100644
--- a/src/ifcopenshell-python/ifcopenshell/__init__.py
+++ b/src/ifcopenshell-python/ifcopenshell/__init__.py
@@ -82,6 +82,9 @@ class entity_instance(object):
attr_type = self.attribute_type(idx).title().replace(' ', '')
attr_type = attr_type.replace('Binary', 'String')
attr_type = attr_type.replace('Enumeration', 'String')
+ try:
+ if isinstance(value, unicode): value = value.encode("utf-8")
+ except: pass
getattr(self.wrapped_data, "setArgumentAs%s" % attr_type)(idx, entity_instance.unwrap_value(value))
return value
def __len__(self): return len(self.wrapped_data)
@@ -141,3 +144,6 @@ def create_entity(type,*args,**kwargs):
for idx, arg in attrs: e[idx] = arg
return e
+
+version = ifcopenshell_wrapper.version()
+schema_identifier = ifcopenshell_wrapper.schema_identifier()
diff --git a/src/ifcopenshell-python/ifcopenshell/geom/__init__.py b/src/ifcopenshell-python/ifcopenshell/geom/__init__.py
index 8550f4013d..f4d05f86dc 100644
--- a/src/ifcopenshell-python/ifcopenshell/geom/__init__.py
+++ b/src/ifcopenshell-python/ifcopenshell/geom/__init__.py
@@ -31,7 +31,7 @@ def has_occ():
has_occ = has_occ()
wrap_shape_creation = lambda settings, shape: shape
if has_occ:
- import occ_utils as utils
+ from . import occ_utils as utils
wrap_shape_creation = lambda settings, shape: utils.create_shape_from_serialization(shape) if getattr(settings, 'use_python_opencascade', False) else shape
diff --git a/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py b/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py
index be5c93e8b3..004151ec1e 100644
--- a/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py
+++ b/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py
@@ -1,3 +1,22 @@
+###############################################################################
+# #
+# 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. #
+# #
+# You should have received a copy of the Lesser GNU General Public License #
+# along with this program. If not, see . #
+# #
+###############################################################################
+
import random
from collections import namedtuple
@@ -52,8 +71,14 @@ def get_bounding_box_center(bbox):
def create_shape_from_serialization(brep_object):
brep_data, occ_shape = None, None
- try: brep_data = brep_object.geometry.brep_data
- except: pass
+ is_product_shape = True
+ try:
+ brep_data = brep_object.geometry.brep_data
+ except:
+ try:
+ brep_data = brep_object.brep_data
+ is_product_shape = False
+ except: pass
if not brep_data: return tuple(brep_object, None)
try:
@@ -62,5 +87,8 @@ def create_shape_from_serialization(brep_object):
occ_shape = ss.Shape(ss.NbShapes())
except: pass
- return tuple(brep_object, occ_shape)
+ if is_product_shape:
+ return tuple(brep_object, occ_shape)
+ else:
+ return occ_shape
diff --git a/src/ifcparse/Ifc2x3-latebound.cpp b/src/ifcparse/Ifc2x3-latebound.cpp
index 289b4279c4..fcc21020e0 100644
--- a/src/ifcparse/Ifc2x3-latebound.cpp
+++ b/src/ifcparse/Ifc2x3-latebound.cpp
@@ -4247,48 +4247,48 @@ std::pair Type::GetEnumerationIndex(Enum t, const std::string&
}
std::pair Type::GetInverseAttribute(Enum t, const std::string& a) {
- if (inverse_map.empty()) ::InitInverseMap();
- inverse_map_t::const_iterator it;
- inverse_map_t::mapped_type::const_iterator jt;
- while (true) {
+ if (inverse_map.empty()) ::InitInverseMap();
+ inverse_map_t::const_iterator it;
+ inverse_map_t::mapped_type::const_iterator jt;
+ for(;;) {
it = inverse_map.find(t);
if (it != inverse_map.end()) {
- jt = it->second.find(a);
- if (jt != it->second.end()) {
- return jt->second;
- }
- }
+ jt = it->second.find(a);
+ if (jt != it->second.end()) {
+ return jt->second;
+ }
+ }
if ((t = Parent(t)) == -1) break;
}
throw IfcException("Attribute not found");
}
std::set Type::GetInverseAttributeNames(Enum t) {
- if (inverse_map.empty()) ::InitInverseMap();
- inverse_map_t::const_iterator it;
- inverse_map_t::mapped_type::const_iterator jt;
+ if (inverse_map.empty()) ::InitInverseMap();
+ inverse_map_t::const_iterator it;
+ inverse_map_t::mapped_type::const_iterator jt;
- std::set return_value;
+ std::set return_value;
- while (true) {
+ for (;;) {
it = inverse_map.find(t);
if (it != inverse_map.end()) {
- for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
- return_value.insert(jt->first);
- }
- }
+ for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
+ return_value.insert(jt->first);
+ }
+ }
if ((t = Parent(t)) == -1) break;
}
-
- return return_value;
+
+ return return_value;
}
void Type::PopulateDerivedFields(IfcWrite::IfcWritableEntity* e) {
std::map >::const_iterator i = derived_map.find(e->type());
- if (i != derived_map.end()) {
- for (std::set::const_iterator it = i->second.begin(); it != i->second.end(); ++it) {
- e->setArgumentDerived(*it);
- }
- }
+ if (i != derived_map.end()) {
+ for (std::set::const_iterator it = i->second.begin(); it != i->second.end(); ++it) {
+ e->setArgumentDerived(*it);
+ }
+ }
}
#endif
diff --git a/src/ifcparse/Ifc2x3.cpp b/src/ifcparse/Ifc2x3.cpp
index bc9cdb79b4..dfd535c7ba 100644
--- a/src/ifcparse/Ifc2x3.cpp
+++ b/src/ifcparse/Ifc2x3.cpp
@@ -32,6 +32,8 @@
#include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcWritableEntity.h"
+#include