IfcConvert links on windows

This commit is contained in:
Thomas Krijnen
2019-08-18 14:31:22 +02:00
parent 85171bb5df
commit 8f88c601c6
20 changed files with 173 additions and 228 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ namespace geometry {
virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseClass*) = 0; virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseClass*) = 0;
virtual void get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters, settings& s) = 0; virtual void get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters, settings& s) = 0;
virtual IfcUtil::IfcBaseEntity* get_decomposing_entity(IfcUtil::IfcBaseEntity* product, bool include_openings = true) = 0; virtual IfcUtil::IfcBaseEntity* get_decomposing_entity(IfcUtil::IfcBaseEntity* product, bool include_openings = true) = 0;
virtual std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*); virtual std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*) = 0;
}; };
namespace impl { namespace impl {
@@ -1,6 +1,7 @@
#include "AbstractKernel.h" #include "AbstractKernel.h"
#include "../../ifcgeom/schema_agnostic/IfcGeomElement.h" #include "../../ifcgeom/schema_agnostic/IfcGeomElement.h"
#include "../../ifcgeom/kernels/opencascade/OpenCascadeKernel.h"
namespace { namespace {
/* A compile-time for loop over the taxonomy kinds */ /* A compile-time for loop over the taxonomy kinds */
@@ -28,6 +29,15 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::it
return dispatch_conversion<0>::dispatch(this, item, results); return dispatch_conversion<0>::dispatch(this, item, results);
} }
ifcopenshell::geometry::kernels::AbstractKernel* ifcopenshell::geometry::kernels::construct(const std::string& geometry_library, IfcParse::IfcFile* file) {
const std::string geometry_library_lower = boost::to_lower_copy(geometry_library);
if (geometry_library_lower == "opencascade") {
return new OpenCascadeKernel;
} else {
throw IfcParse::IfcException("No geometry kernel registered for " + geometry_library);
}
}
//void ifcopenshell::geometry::kernels::AbstractKernel::set_conversion_placement_rel_to(const IfcParse::declaration* type) { //void ifcopenshell::geometry::kernels::AbstractKernel::set_conversion_placement_rel_to(const IfcParse::declaration* type) {
// placement_rel_to = type; // placement_rel_to = type;
//} //}
+1 -12
View File
@@ -53,18 +53,7 @@ namespace ifcopenshell { namespace geometry { namespace kernels {
virtual bool convert_impl(const taxonomy::node*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); } virtual bool convert_impl(const taxonomy::node*, ifcopenshell::geometry::ConversionResults&) { throw std::runtime_error("Not implemented"); }
}; };
namespace impl { AbstractKernel* construct(const std::string& geometry_library, IfcParse::IfcFile*);
typedef boost::function1 < AbstractKernel*, const std::string&> kernel_fn;
class KernelFactoryImplementation : public std::map<std::string, kernel_fn> {
public:
KernelFactoryImplementation();
void bind(const std::string& geometry_library, kernel_fn);
AbstractKernel* construct(const std::string& geometry_library, IfcParse::IfcFile*);
};
KernelFactoryImplementation& kernel_implementations();
}
} }
} }
@@ -24,7 +24,7 @@
#include "../../../ifcgeom/schema_agnostic/IfcGeomElement.h" #include "../../../ifcgeom/schema_agnostic/IfcGeomElement.h"
#include "../../../ifcgeom/schema_agnostic/IfcGeomIterator.h" #include "../../../ifcgeom/schema_agnostic/IfcGeomIterator.h"
#include "../../../ifcgeom/schema_agnostic/Kernel.h" #include "../../../ifcgeom/schema_agnostic/Kernel.h"
#include "../../../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include "../../../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
#include <NCollection_UBTree.hxx> #include <NCollection_UBTree.hxx>
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
@@ -7,17 +7,19 @@
#include <map> #include <map>
template <typename Precision> void ifcopenshell::geometry::OpenCascadeShape::Triangulate(const settings& settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int surface_style_id) const {
void triangulate_helper(const TopoDS_Shape& s, const IfcGeom::IteratorSettings& settings, const IfcGeom::ConversionResultPlacement* place, IfcGeom::Representation::Triangulation<Precision>* t, int surface_style_id) {
// @todo check
gp_GTrsf trsf; gp_GTrsf trsf;
if (place) { for (int i = 0; i < 3; ++i) {
trsf = dynamic_cast<const IfcGeom::OpenCascadePlacement*>(place)->trsf(); for (int j = 0; j < j; ++i) {
trsf.SetValue(i + 1, j + 1, place.components(i, j));
}
} }
// Triangulate the shape // Triangulate the shape
try { try {
BRepMesh_IncrementalMesh(s, settings.deflection_tolerance()); BRepMesh_IncrementalMesh(shape_, settings.deflection_tolerance());
} catch (...) { } catch (...) {
// TODO: Catch outside // TODO: Catch outside
@@ -29,7 +31,7 @@ void triangulate_helper(const TopoDS_Shape& s, const IfcGeom::IteratorSettings&
// Iterates over the faces of the shape // Iterates over the faces of the shape
int num_faces = 0; int num_faces = 0;
TopExp_Explorer exp; TopExp_Explorer exp;
for (exp.Init(s, TopAbs_FACE); exp.More(); exp.Next(), ++num_faces) { for (exp.Init(shape_, TopAbs_FACE); exp.More(); exp.Next(), ++num_faces) {
TopoDS_Face face = TopoDS::Face(exp.Current()); TopoDS_Face face = TopoDS::Face(exp.Current());
TopLoc_Location loc; TopLoc_Location loc;
Handle_Poly_Triangulation tri = BRep_Tool::Triangulation(face, loc); Handle_Poly_Triangulation tri = BRep_Tool::Triangulation(face, loc);
@@ -51,8 +53,8 @@ void triangulate_helper(const TopoDS_Shape& s, const IfcGeom::IteratorSettings&
std::map<int, int> dict; std::map<int, int> dict;
// Vertex normals are only calculated if vertices are not welded and calculation is not disable explicitly. // Vertex normals are only calculated if vertices are not welded and calculation is not disable explicitly.
const bool calculate_normals = !settings.get(IfcGeom::IteratorSettings::WELD_VERTICES) && const bool calculate_normals = !settings.get(ifcopenshell::geometry::settings::WELD_VERTICES) &&
!settings.get(IfcGeom::IteratorSettings::NO_NORMALS); !settings.get(ifcopenshell::geometry::settings::NO_NORMALS);
for (int i = 1; i <= nodes.Length(); ++i) { for (int i = 1; i <= nodes.Length(); ++i) {
coords.push_back(nodes(i).Transformed(loc).XYZ()); coords.push_back(nodes(i).Transformed(loc).XYZ());
@@ -184,18 +186,13 @@ void triangulate_helper(const TopoDS_Shape& s, const IfcGeom::IteratorSettings&
*/ */
BRepTools::Clean(s); BRepTools::Clean(shape_);
} }
void IfcGeom::OpenCascadeShape::Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation<float>* t, int surface_style_id) const { int ifcopenshell::geometry::OpenCascadeShape::surface_genus() const {
triangulate_helper(shape_, settings, place, t, surface_style_id); throw std::runtime_error("Not implemented");
} }
void IfcGeom::OpenCascadeShape::Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation<double>* t, int surface_style_id) const { bool ifcopenshell::geometry::OpenCascadeShape::is_manifold() const {
triangulate_helper(shape_, settings, place, t, surface_style_id);
}
int IfcGeom::OpenCascadeShape::surface_genus() const {
throw std::runtime_error("Not implemented"); throw std::runtime_error("Not implemented");
// return IfcGeom::Kernel::surface_genus(shape_);
} }
@@ -47,7 +47,7 @@ namespace ifcopenshell {
const TopoDS_Shape& shape() const { return shape_; } const TopoDS_Shape& shape() const { return shape_; }
operator const TopoDS_Shape& () { return shape_; } operator const TopoDS_Shape& () { return shape_; }
virtual void Triangulate(const settings & settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int surface_style_id) const; virtual void Triangulate(const settings& settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int surface_style_id) const;
virtual void Serialize(std::string&) const { virtual void Serialize(std::string&) const {
throw std::runtime_error("Not implemented"); throw std::runtime_error("Not implemented");
@@ -55,7 +55,7 @@ inline static bool ALMOST_THE_SAME(const T& a, const T& b, double tolerance=ALMO
#include "../../../ifcgeom/schema_agnostic/ConversionResult.h" #include "../../../ifcgeom/schema_agnostic/ConversionResult.h"
#include "../../../ifcgeom/kernels/opencascade/IfcGeomShapeType.h" #include "../../../ifcgeom/kernels/opencascade/IfcGeomShapeType.h"
#include "../../../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include "../../../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
#include "../../../ifcgeom/schema_agnostic/ifc_geom_api.h" #include "../../../ifcgeom/schema_agnostic/ifc_geom_api.h"
+16
View File
@@ -699,3 +699,19 @@ IfcUtil::IfcBaseEntity* mapping::get_decomposing_entity(IfcUtil::IfcBaseEntity*
return parent; return parent;
} }
std::map<std::string, IfcUtil::IfcBaseEntity*> mapping::get_layers(IfcUtil::IfcBaseEntity* inst) {
auto prod = inst->as<IfcSchema::IfcProduct>();
std::map<std::string, IfcUtil::IfcBaseEntity*> layers;
if (prod->hasRepresentation()) {
IfcEntityList::ptr r = IfcParse::traverse(prod->Representation());
IfcSchema::IfcRepresentation::list::ptr representations = r->as<IfcSchema::IfcRepresentation>();
for (IfcSchema::IfcRepresentation::list::it it = representations->begin(); it != representations->end(); ++it) {
IfcSchema::IfcPresentationLayerAssignment::list::ptr a = (*it)->LayerAssignments();
for (IfcSchema::IfcPresentationLayerAssignment::list::it jt = a->begin(); jt != a->end(); ++jt) {
layers[(*jt)->Name()] = *jt;
}
}
}
return layers;
}
+1
View File
@@ -20,6 +20,7 @@ namespace geometry {
POSTFIX_SCHEMA(mapping)(IfcParse::IfcFile* file) : file_(file) {} POSTFIX_SCHEMA(mapping)(IfcParse::IfcFile* file) : file_(file) {}
virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseClass*); virtual ifcopenshell::geometry::taxonomy::item* map(const IfcUtil::IfcBaseClass*);
virtual void get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters, settings& s); virtual void get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters, settings& s);
virtual std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*);
const IfcSchema::IfcMaterial* get_single_material_association(const IfcSchema::IfcProduct* product); const IfcSchema::IfcMaterial* get_single_material_association(const IfcSchema::IfcProduct* product);
IfcSchema::IfcRepresentation* representation_mapped_to(const IfcSchema::IfcRepresentation* representation); IfcSchema::IfcRepresentation* representation_mapped_to(const IfcSchema::IfcRepresentation* representation);
+74 -74
View File
@@ -24,110 +24,110 @@
* * * *
********************************************************************************/ ********************************************************************************/
BIND(IfcShellBasedSurfaceModel); // BIND(IfcShellBasedSurfaceModel);
BIND(IfcFaceBasedSurfaceModel); // BIND(IfcFaceBasedSurfaceModel);
BIND(IfcRepresentation); // BIND(IfcRepresentation);
BIND(IfcMappedItem); // BIND(IfcMappedItem);
// IfcFacetedBrep included // IfcFacetedBrep included
// IfcAdvancedBrep included // IfcAdvancedBrep included
// IfcFacetedBrepWithVoids included // IfcFacetedBrepWithVoids included
// IfcAdvancedBrepWithVoids included // IfcAdvancedBrepWithVoids included
BIND(IfcManifoldSolidBrep); // BIND(IfcManifoldSolidBrep);
BIND(IfcGeometricSet); // BIND(IfcGeometricSet);
#ifdef SCHEMA_HAS_IfcCylindricalSurface #ifdef SCHEMA_HAS_IfcCylindricalSurface
BIND(IfcCylindricalSurface); // BIND(IfcCylindricalSurface);
#endif #endif
#ifdef SCHEMA_HAS_IfcAdvancedBrep #ifdef SCHEMA_HAS_IfcAdvancedBrep
BIND(IfcAdvancedBrep); // BIND(IfcAdvancedBrep);
#endif #endif
// FIXME: Surfaces should have a shape type of their own // FIXME: Surfaces should have a shape type of their own
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots #ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
BIND(IfcBSplineSurfaceWithKnots); // BIND(IfcBSplineSurfaceWithKnots);
#endif #endif
#ifdef SCHEMA_HAS_IfcTriangulatedFaceSet #ifdef SCHEMA_HAS_IfcTriangulatedFaceSet
BIND(IfcTriangulatedFaceSet); // BIND(IfcTriangulatedFaceSet);
#endif #endif
#ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered #ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered
BIND(IfcExtrudedAreaSolidTapered); // BIND(IfcExtrudedAreaSolidTapered);
#endif #endif
BIND(IfcExtrudedAreaSolid); BIND(IfcExtrudedAreaSolid);
BIND(IfcRevolvedAreaSolid); // BIND(IfcRevolvedAreaSolid);
BIND(IfcConnectedFaceSet); // BIND(IfcConnectedFaceSet);
BIND(IfcBooleanResult); // BIND(IfcBooleanResult);
BIND(IfcPolygonalBoundedHalfSpace); // BIND(IfcPolygonalBoundedHalfSpace);
BIND(IfcHalfSpaceSolid); // BIND(IfcHalfSpaceSolid);
BIND(IfcSurfaceOfLinearExtrusion); // BIND(IfcSurfaceOfLinearExtrusion);
BIND(IfcSurfaceOfRevolution); // BIND(IfcSurfaceOfRevolution);
BIND(IfcBlock); // BIND(IfcBlock);
BIND(IfcRectangularPyramid); // BIND(IfcRectangularPyramid);
BIND(IfcRightCircularCylinder); // BIND(IfcRightCircularCylinder);
BIND(IfcRightCircularCone); // BIND(IfcRightCircularCone);
BIND(IfcSphere); // BIND(IfcSphere);
BIND(IfcCsgSolid); // BIND(IfcCsgSolid);
BIND(IfcCurveBoundedPlane); // BIND(IfcCurveBoundedPlane);
BIND(IfcRectangularTrimmedSurface); // BIND(IfcRectangularTrimmedSurface);
BIND(IfcSurfaceCurveSweptAreaSolid); // BIND(IfcSurfaceCurveSweptAreaSolid);
BIND(IfcSweptDiskSolid); // BIND(IfcSweptDiskSolid);
BIND(IfcArbitraryProfileDefWithVoids); // BIND(IfcArbitraryProfileDefWithVoids);
BIND(IfcArbitraryClosedProfileDef); // BIND(IfcArbitraryClosedProfileDef);
BIND(IfcRoundedRectangleProfileDef); // BIND(IfcRoundedRectangleProfileDef);
BIND(IfcRectangleHollowProfileDef); // BIND(IfcRectangleHollowProfileDef);
BIND(IfcRectangleProfileDef); // BIND(IfcRectangleProfileDef);
BIND(IfcTrapeziumProfileDef) // BIND(IfcTrapeziumProfileDef)
BIND(IfcCShapeProfileDef); // BIND(IfcCShapeProfileDef);
// IfcAsymmetricIShapeProfileDef included // IfcAsymmetricIShapeProfileDef included
BIND(IfcIShapeProfileDef); // BIND(IfcIShapeProfileDef);
BIND(IfcLShapeProfileDef); // BIND(IfcLShapeProfileDef);
BIND(IfcTShapeProfileDef); // BIND(IfcTShapeProfileDef);
BIND(IfcUShapeProfileDef); // BIND(IfcUShapeProfileDef);
BIND(IfcZShapeProfileDef); // BIND(IfcZShapeProfileDef);
BIND(IfcCircleHollowProfileDef); // BIND(IfcCircleHollowProfileDef);
BIND(IfcCircleProfileDef); // BIND(IfcCircleProfileDef);
BIND(IfcEllipseProfileDef); // BIND(IfcEllipseProfileDef);
BIND(IfcCenterLineProfileDef); // BIND(IfcCenterLineProfileDef);
BIND(IfcCompositeProfileDef); // BIND(IfcCompositeProfileDef);
BIND(IfcDerivedProfileDef); // BIND(IfcDerivedProfileDef);
// IfcFaceSurface included // IfcFaceSurface included
// IfcAdvancedFace included in case of IFC4 // IfcAdvancedFace included in case of IFC4
BIND(IfcFace); // BIND(IfcFace);
BIND(IfcEdgeCurve); // BIND(IfcEdgeCurve);
BIND(IfcSubedge); // BIND(IfcSubedge);
BIND(IfcOrientedEdge); // BIND(IfcOrientedEdge);
BIND(IfcEdge); // BIND(IfcEdge);
BIND(IfcEdgeLoop); // BIND(IfcEdgeLoop);
BIND(IfcPolyline); // BIND(IfcPolyline);
BIND(IfcPolyLoop); // BIND(IfcPolyLoop);
BIND(IfcCompositeCurve); // BIND(IfcCompositeCurve);
BIND(IfcTrimmedCurve); // BIND(IfcTrimmedCurve);
BIND(IfcArbitraryOpenProfileDef); // BIND(IfcArbitraryOpenProfileDef);
#ifdef SCHEMA_HAS_IfcIndexedPolyCurve #ifdef SCHEMA_HAS_IfcIndexedPolyCurve
BIND(IfcIndexedPolyCurve) // BIND(IfcIndexedPolyCurve)
#endif #endif
BIND(IfcCircle); // BIND(IfcCircle);
BIND(IfcEllipse); // BIND(IfcEllipse);
BIND(IfcLine); // BIND(IfcLine);
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots #ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
// IfcRationalBSplineCurveWithKnots included // IfcRationalBSplineCurveWithKnots included
BIND(IfcBSplineCurveWithKnots); // BIND(IfcBSplineCurveWithKnots);
#endif #endif
BIND(IfcCartesianPoint); // BIND(IfcCartesianPoint);
BIND(IfcDirection); // BIND(IfcDirection);
BIND(IfcAxis2Placement2D); // BIND(IfcAxis2Placement2D);
BIND(IfcAxis2Placement3D); BIND(IfcAxis2Placement3D);
BIND(IfcAxis1Placement); // BIND(IfcAxis1Placement);
BIND(IfcCartesianTransformationOperator2DnonUniform); // BIND(IfcCartesianTransformationOperator2DnonUniform);
BIND(IfcCartesianTransformationOperator3DnonUniform); // BIND(IfcCartesianTransformationOperator3DnonUniform);
BIND(IfcCartesianTransformationOperator2D); // BIND(IfcCartesianTransformationOperator2D);
BIND(IfcCartesianTransformationOperator3D); // BIND(IfcCartesianTransformationOperator3D);
BIND(IfcObjectPlacement); // BIND(IfcObjectPlacement);
BIND(IfcVector); // BIND(IfcVector);
BIND(IfcPlane); // BIND(IfcPlane);
BIND(IfcColourRgb); // BIND(IfcColourRgb);
BIND(IfcMaterial); BIND(IfcMaterial);
BIND(IfcStyledItem); BIND(IfcStyledItem);
+20 -96
View File
@@ -3,7 +3,7 @@
#include "../../ifcgeom/schema_agnostic/IfcGeomElement.h" #include "../../ifcgeom/schema_agnostic/IfcGeomElement.h"
ifcopenshell::geometry::Converter::Converter(const std::string& geometry_library, IfcParse::IfcFile* file) { ifcopenshell::geometry::Converter::Converter(const std::string& geometry_library, IfcParse::IfcFile* file) {
kernel_ = kernels::impl::kernel_implementations().construct(geometry_library, file); kernel_ = kernels::construct(geometry_library, file);
mapping_ = impl::mapping_implementations().construct(file); mapping_ = impl::mapping_implementations().construct(file);
} }
@@ -26,15 +26,6 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
Logger::Error(e); Logger::Error(e);
} }
ConversionResultPlacement* trsf = nullptr;
try {
convert_placement(product, trsf);
} catch (const std::exception& e) {
Logger::Error(e);
} catch (...) {
Logger::Error("Failed to construct placement");
}
const std::string guid = product->get_value<std::string>("GlobalId"); const std::string guid = product->get_value<std::string>("GlobalId");
const std::string name = product->get_value_or<std::string>("Name", ""); const std::string name = product->get_value_or<std::string>("Name", "");
@@ -44,7 +35,8 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
ifcopenshell::geometry::ConversionResults shapes; ifcopenshell::geometry::ConversionResults shapes;
auto rep_item = mapping_->map(representation); auto rep_item = mapping_->map(representation);
auto placement = mapping_->map(product); // @todo decide how to get placement from product
auto placement = (taxonomy::geom_item*) mapping_->map(product);
kernel_->convert(rep_item, shapes); kernel_->convert(rep_item, shapes);
shape = new ifcopenshell::geometry::Representation::BRep(s, representation_id_builder.str(), shapes); shape = new ifcopenshell::geometry::Representation::BRep(s, representation_id_builder.str(), shapes);
@@ -57,7 +49,7 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
guid, guid,
// @todo // @todo
"", "",
trsf, placement->matrix,
boost::shared_ptr<ifcopenshell::geometry::Representation::BRep>(shape), boost::shared_ptr<ifcopenshell::geometry::Representation::BRep>(shape),
product product
); );
@@ -202,55 +194,50 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
*/ */
} }
/* ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create_brep_for_processed_representation(
template <typename P, typename PP> const ifcopenshell::geometry::settings& /* settings */, IfcUtil::IfcBaseEntity* /* representation */, IfcUtil::IfcBaseEntity* product,
ifcopenshell::geometry::kernels::NativeElement<P, PP>* ifcopenshell::geometry::kernels::AbstractKernel::create_brep_for_processed_representation( ifcopenshell::geometry::NativeElement* brep)
const IteratorSettings& //* settings /, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, {
ifcopenshell::geometry::kernels::NativeElement<P, PP>* brep) {
int parent_id = -1; int parent_id = -1;
try { try {
IfcUtil::IfcBaseEntity* parent_object = get_decomposing_entity(product); IfcUtil::IfcBaseEntity* parent_object = mapping_->get_decomposing_entity(product);
if (parent_object && parent_object->as<IfcSchema::IfcObjectDefinition>()) { if (parent_object) {
parent_id = parent_object->data().id(); parent_id = parent_object->data().id();
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
Logger::Error(e); Logger::Error(e);
} }
const std::string name = product->hasName() ? product->Name() : ""; const std::string guid = product->get_value<std::string>("GlobalId");
const std::string guid = product->GlobalId(); const std::string name = product->get_value_or<std::string>("Name", "");
ConversionResultPlacement* trsf = nullptr; auto placement = (taxonomy::geom_item*) mapping_->map(product);
try {
convert_placement(product->ObjectPlacement(), trsf);
} catch (const std::exception& e) {
Logger::Error(e);
} catch (...) {
Logger::Error("Failed to construct placement");
}
/*
std::string context_string = ""; std::string context_string = "";
if (representation->hasRepresentationIdentifier()) { if (representation->hasRepresentationIdentifier()) {
context_string = representation->RepresentationIdentifier(); context_string = representation->RepresentationIdentifier();
} else if (representation->ContextOfItems()->hasContextType()) { } else if (representation->ContextOfItems()->hasContextType()) {
context_string = representation->ContextOfItems()->ContextType(); context_string = representation->ContextOfItems()->ContextType();
} }
*/
const std::string product_type = product->declaration().name(); const std::string product_type = product->declaration().name();
return new NativeElement<P, PP>( return new NativeElement(
product->data().id(), product->data().id(),
parent_id, parent_id,
name, name,
product_type, product_type,
guid, guid,
context_string, // @todo
trsf, "",
placement->matrix,
brep->geometry_pointer(), brep->geometry_pointer(),
product product
); );
} }
*/
//#include "../../ifcparse/Ifc2x3.h" //#include "../../ifcparse/Ifc2x3.h"
//#include "../../ifcparse/Ifc4.h" //#include "../../ifcparse/Ifc4.h"
// //
@@ -308,42 +295,6 @@ ifcopenshell::geometry::kernels::NativeElement<P, PP>* ifcopenshell::geometry::k
// return genus; // return genus;
//} //}
// //
//IfcGeom::impl::KernelFactoryImplementation& IfcGeom::impl::kernel_implementations() {
// static KernelFactoryImplementation impl;
// return impl;
//}
//
//extern void init_KernelImplementation_opencascade_Ifc2x3(IfcGeom::impl::KernelFactoryImplementation*);
//extern void init_KernelImplementation_opencascade_Ifc4(IfcGeom::impl::KernelFactoryImplementation*);
//#ifdef IFOPSH_USE_CGAL
//extern void init_KernelImplementation_cgal_Ifc2x3(IfcGeom::impl::KernelFactoryImplementation*);
//extern void init_KernelImplementation_cgal_Ifc4(IfcGeom::impl::KernelFactoryImplementation*);
//#endif
//
//IfcGeom::impl::KernelFactoryImplementation::KernelFactoryImplementation() {
// init_KernelImplementation_opencascade_Ifc2x3(this);
// init_KernelImplementation_opencascade_Ifc4(this);
//#ifdef IFOPSH_USE_CGAL
// init_KernelImplementation_cgal_Ifc2x3(this);
// init_KernelImplementation_cgal_Ifc4(this);
//#endif
//}
//
//void IfcGeom::impl::KernelFactoryImplementation::bind(const std::string& schema_name, const std::string& geometry_library, IfcGeom::impl::kernel_fn fn) {
// const std::string schema_name_lower = boost::to_lower_copy(schema_name);
// this->insert(std::make_pair(std::make_pair(schema_name_lower, geometry_library), fn));
//}
//
//IfcGeom::Kernel* IfcGeom::impl::KernelFactoryImplementation::construct(const std::string& schema_name, const std::string& geometry_library, IfcParse::IfcFile* file) {
// const std::string schema_name_lower = boost::to_lower_copy(schema_name);
// std::map<std::pair<std::string, std::string>, IfcGeom::impl::kernel_fn>::const_iterator it;
// it = this->find(std::make_pair(schema_name_lower, geometry_library));
// if (it == end()) {
// throw IfcParse::IfcException("No geometry kernel registered for " + schema_name);
// }
// return it->second(file);
//}
//
// //
//IfcUtil::IfcBaseEntity* IfcGeom::Kernel::get_decomposing_entity(IfcUtil::IfcBaseEntity* inst, bool include_openings) { //IfcUtil::IfcBaseEntity* IfcGeom::Kernel::get_decomposing_entity(IfcUtil::IfcBaseEntity* inst, bool include_openings) {
// if (inst->as<Ifc2x3::IfcProduct>()) { // if (inst->as<Ifc2x3::IfcProduct>()) {
@@ -357,33 +308,6 @@ ifcopenshell::geometry::kernels::NativeElement<P, PP>* ifcopenshell::geometry::k
// } // }
//} //}
// //
//namespace {
// template <typename Schema>
// static std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers_impl(typename Schema::IfcProduct* prod) {
// std::map<std::string, IfcUtil::IfcBaseEntity*> layers;
// if (prod->hasRepresentation()) {
// IfcEntityList::ptr r = IfcParse::traverse(prod->Representation());
// typename Schema::IfcRepresentation::list::ptr representations = r->template as<typename Schema::IfcRepresentation>();
// for (typename Schema::IfcRepresentation::list::it it = representations->begin(); it != representations->end(); ++it) {
// typename Schema::IfcPresentationLayerAssignment::list::ptr a = (*it)->LayerAssignments();
// for (typename Schema::IfcPresentationLayerAssignment::list::it jt = a->begin(); jt != a->end(); ++jt) {
// layers[(*jt)->Name()] = *jt;
// }
// }
// }
// return layers;
// }
//}
//
//std::map<std::string, IfcUtil::IfcBaseEntity*> IfcGeom::Kernel::get_layers(IfcUtil::IfcBaseEntity* inst) {
// if (inst->as<Ifc2x3::IfcProduct>()) {
// return get_layers_impl<Ifc2x3>(inst->as<Ifc2x3::IfcProduct>());
// } else if (inst->as<Ifc4::IfcProduct>()) {
// return get_layers_impl<Ifc4>(inst->as<Ifc4::IfcProduct>());
// } else {
// throw IfcParse::IfcException("Unexpected entity " + inst->declaration().name());
// }
//}
// //
//bool IfcGeom::Kernel::is_manifold(const ConversionResultShape* s_) { //bool IfcGeom::Kernel::is_manifold(const ConversionResultShape* s_) {
// // @todo make kernel agnostic // // @todo make kernel agnostic
-6
View File
@@ -81,11 +81,6 @@ namespace ifcopenshell { namespace geometry {
return results; return results;
} }
bool convert_placement(IfcUtil::IfcBaseClass* item, ifcopenshell::geometry::ConversionResultPlacement*& trsf) {
throw std::runtime_error("not implemented");
// return implementation_->convert_placement(item, trsf);
}
ifcopenshell::geometry::NativeElement* create_brep_for_representation_and_product(const ifcopenshell::geometry::settings& settings, IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product); ifcopenshell::geometry::NativeElement* create_brep_for_representation_and_product(const ifcopenshell::geometry::settings& settings, IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product);
ifcopenshell::geometry::NativeElement* create_brep_for_processed_representation(const ifcopenshell::geometry::settings& settings, IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product, ifcopenshell::geometry::NativeElement* brep); ifcopenshell::geometry::NativeElement* create_brep_for_processed_representation(const ifcopenshell::geometry::settings& settings, IfcUtil::IfcBaseEntity* representation, IfcUtil::IfcBaseEntity* product, ifcopenshell::geometry::NativeElement* brep);
@@ -95,7 +90,6 @@ namespace ifcopenshell { namespace geometry {
static bool is_manifold(const ifcopenshell::geometry::ConversionResultShape*); static bool is_manifold(const ifcopenshell::geometry::ConversionResultShape*);
static IfcUtil::IfcBaseEntity* get_decomposing_entity(IfcUtil::IfcBaseEntity*, bool include_openings=true); static IfcUtil::IfcBaseEntity* get_decomposing_entity(IfcUtil::IfcBaseEntity*, bool include_openings=true);
static std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*);
static IfcEntityList::ptr find_openings(IfcUtil::IfcBaseEntity* product); static IfcEntityList::ptr find_openings(IfcUtil::IfcBaseEntity* product);
*/ */
}; };
@@ -54,6 +54,9 @@ namespace ifcopenshell { namespace geometry {
} }
} }
const ifcopenshell::geometry::taxonomy::matrix4& data() const { return matrix_; } const ifcopenshell::geometry::taxonomy::matrix4& data() const { return matrix_; }
const element_settings& settings() const { return settings_; }
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
}; };
class Element { class Element {
@@ -131,7 +134,10 @@ namespace ifcopenshell { namespace geometry {
_unique_id = oss.str(); _unique_id = oss.str();
} }
virtual ~Element() {} virtual ~Element() {}
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
}; };
class NativeElement : public Element { class NativeElement : public Element {
@@ -28,7 +28,7 @@
#include <BRepGProp.hxx> #include <BRepGProp.hxx>
#include "IfcGeomRepresentation.h" #include "IfcGeomRepresentation.h"
#include "../../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include "../../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
ifcopenshell::geometry::Representation::Serialization::Serialization(const BRep& brep) ifcopenshell::geometry::Representation::Serialization::Serialization(const BRep& brep)
: Representation(brep.settings()) : Representation(brep.settings())
+1
View File
@@ -39,6 +39,7 @@ struct matrix4 : public item {
Eigen::Matrix4d components; Eigen::Matrix4d components;
matrix4(const Eigen::Matrix4d& c) : components(c), tag(OTHER) {}
matrix4() : components(Eigen::Matrix4d::Identity()), tag(IDENTITY) {} matrix4() : components(Eigen::Matrix4d::Identity()), tag(IDENTITY) {}
virtual item* clone() const { return new matrix4(*this); } virtual item* clone() const { return new matrix4(*this); }
+1 -1
View File
@@ -47,7 +47,7 @@
#include <vld.h> #include <vld.h>
#endif #endif
#include "../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
#include <GProp_GProps.hxx> #include <GProp_GProps.hxx>
#include <BRepGProp.hxx> #include <BRepGProp.hxx>
+11 -8
View File
@@ -191,20 +191,20 @@ void ColladaSerializer::ColladaExporter::ColladaScene::add(
node.setNodeName(node_name); node.setNodeName(node_name);
node.setType(COLLADASW::Node::NODE); node.setType(COLLADASW::Node::NODE);
// The matrix attribute of an entity is basically a 4x3 representation of its ObjectPlacement.
// Note that this placement is absolute, ie it is multiplied with all parent placements.
ifcopenshell::geometry::Transformation* relative_trsf = 0; ifcopenshell::geometry::Transformation* relative_trsf = 0;
const ifcopenshell::geometry::Transformation* transformation_towrite = &transformation; const ifcopenshell::geometry::Transformation* transformation_towrite = &transformation;
// If this is not the first parent, get the relative placement // If this is not the first parent, get the relative placement
if (parentNodes.size() > 0) if (parentNodes.size() > 0)
{ {
relative_trsf = new ifcopenshell::geometry::Transformation(matrixStack.top().multiplied(transformation)); auto m4 = ifcopenshell::geometry::taxonomy::matrix4(matrixStack.top().data().components * transformation.data().components);
relative_trsf = new ifcopenshell::geometry::Transformation(transformation.settings(), m4);
transformation_towrite = relative_trsf; transformation_towrite = relative_trsf;
} }
const std::vector<real_t>& posmatrix = transformation_towrite->matrix().data(); // @todo verify
const double* posmatrix = transformation_towrite->data().components.data();
double matrix_array[4][4] = { double matrix_array[4][4] = {
{ (double)posmatrix[0], (double)posmatrix[3], (double)posmatrix[6], (double)posmatrix[9] }, { (double)posmatrix[0], (double)posmatrix[3], (double)posmatrix[6], (double)posmatrix[9] },
@@ -251,11 +251,14 @@ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const ifcopensh
// If this is not the first parent, get the relative placement // If this is not the first parent, get the relative placement
if (parentNodes.size() > 0) if (parentNodes.size() > 0)
{ {
relative_trsf = new ifcopenshell::geometry::Transformation(matrixStack.top().multiplied(parent_trsf)); auto m4 = ifcopenshell::geometry::taxonomy::matrix4(matrixStack.top().data().components * parent_trsf.data().components);
relative_trsf = new ifcopenshell::geometry::Transformation(parent_trsf.settings(), m4);
transformation_towrite = relative_trsf; transformation_towrite = relative_trsf;
} }
const std::vector<real_t>& parentMatrix = transformation_towrite->matrix().data(); // @todo verify
const double* parentMatrix = transformation_towrite->data().components.data();
double matrix_array[4][4] = { double matrix_array[4][4] = {
{ (double)parentMatrix[0], (double)parentMatrix[3], (double)parentMatrix[6], (double)parentMatrix[9] }, { (double)parentMatrix[0], (double)parentMatrix[3], (double)parentMatrix[6], (double)parentMatrix[9] },
@@ -277,7 +280,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const ifcopensh
current_node->addMatrix(matrix_array); current_node->addMatrix(matrix_array);
// Add the node to the parent stack // Add the node to the parent stack
matrixStack.push(parent_trsf.inverted()); matrixStack.push(ifcopenshell::geometry::Transformation(parent_trsf.settings(), ifcopenshell::geometry::taxonomy::matrix4(parent_trsf.data().components.inverse())));
parentNodes.push(current_node); parentNodes.push(current_node);
serializer->parentStackId.push(parent.id()); serializer->parentStackId.push(parent.id());
} }
+1 -1
View File
@@ -20,7 +20,7 @@
#ifndef OPENCASCADEBASEDSERIALIZER_H #ifndef OPENCASCADEBASEDSERIALIZER_H
#define OPENCASCADEBASEDSERIALIZER_H #define OPENCASCADEBASEDSERIALIZER_H
#include "../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
#include "../serializers/GeometrySerializer.h" #include "../serializers/GeometrySerializer.h"
class OpenCascadeBasedSerializer : public GeometrySerializer { class OpenCascadeBasedSerializer : public GeometrySerializer {
+1 -1
View File
@@ -19,7 +19,7 @@
* * * *
********************************************************************************/ ********************************************************************************/
#include "../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h" #include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
#include <string> #include <string>
#include <fstream> #include <fstream>
+8 -4
View File
@@ -1,11 +1,15 @@
#include "XmlSerializer.h" #include "XmlSerializer.h"
extern void init_XmlSerializerIfc2x3(XmlSerializerFactory::Factory*); extern void init_XmlSerializer_Ifc2x3(XmlSerializerFactory::Factory*);
extern void init_XmlSerializerIfc4(XmlSerializerFactory::Factory*); extern void init_XmlSerializer_Ifc4(XmlSerializerFactory::Factory*);
extern void init_XmlSerializer_Ifc4x1(XmlSerializerFactory::Factory*);
extern void init_XmlSerializer_Ifc4x2(XmlSerializerFactory::Factory*);
XmlSerializerFactory::Factory::Factory() { XmlSerializerFactory::Factory::Factory() {
init_XmlSerializerIfc2x3(this); init_XmlSerializer_Ifc2x3(this);
init_XmlSerializerIfc4(this); init_XmlSerializer_Ifc4(this);
init_XmlSerializer_Ifc4x1(this);
init_XmlSerializer_Ifc4x2(this);
} }
void XmlSerializerFactory::Factory::bind(const std::string& schema_name, fn f) { void XmlSerializerFactory::Factory::bind(const std::string& schema_name, fn f) {