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 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 std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*);
virtual std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*) = 0;
};
namespace impl {
@@ -1,6 +1,7 @@
#include "AbstractKernel.h"
#include "../../ifcgeom/schema_agnostic/IfcGeomElement.h"
#include "../../ifcgeom/kernels/opencascade/OpenCascadeKernel.h"
namespace {
/* 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);
}
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) {
// 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"); }
};
namespace impl {
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();
}
AbstractKernel* construct(const std::string& geometry_library, IfcParse::IfcFile*);
}
}
@@ -24,7 +24,7 @@
#include "../../../ifcgeom/schema_agnostic/IfcGeomElement.h"
#include "../../../ifcgeom/schema_agnostic/IfcGeomIterator.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 <BRepBndLib.hxx>
@@ -7,17 +7,19 @@
#include <map>
template <typename Precision>
void triangulate_helper(const TopoDS_Shape& s, const IfcGeom::IteratorSettings& settings, const IfcGeom::ConversionResultPlacement* place, IfcGeom::Representation::Triangulation<Precision>* t, int surface_style_id) {
void ifcopenshell::geometry::OpenCascadeShape::Triangulate(const settings& settings, const ifcopenshell::geometry::taxonomy::matrix4& place, Representation::Triangulation* t, int surface_style_id) const {
// @todo check
gp_GTrsf trsf;
if (place) {
trsf = dynamic_cast<const IfcGeom::OpenCascadePlacement*>(place)->trsf();
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < j; ++i) {
trsf.SetValue(i + 1, j + 1, place.components(i, j));
}
}
// Triangulate the shape
try {
BRepMesh_IncrementalMesh(s, settings.deflection_tolerance());
BRepMesh_IncrementalMesh(shape_, settings.deflection_tolerance());
} catch (...) {
// TODO: Catch outside
@@ -29,7 +31,7 @@ void triangulate_helper(const TopoDS_Shape& s, const IfcGeom::IteratorSettings&
// Iterates over the faces of the shape
int num_faces = 0;
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());
TopLoc_Location 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;
// 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) &&
!settings.get(IfcGeom::IteratorSettings::NO_NORMALS);
const bool calculate_normals = !settings.get(ifcopenshell::geometry::settings::WELD_VERTICES) &&
!settings.get(ifcopenshell::geometry::settings::NO_NORMALS);
for (int i = 1; i <= nodes.Length(); ++i) {
coords.push_back(nodes(i).Transformed(loc).XYZ());
@@ -114,7 +116,7 @@ void triangulate_helper(const TopoDS_Shape& s, const IfcGeom::IteratorSettings&
if (!t.normals().empty() && settings().get(IfcGeom::IteratorSettings::GENERATE_UVS)) {
t.uvs() = box_project_uvs(t.verts(), t.normals());
}
if (num_faces == 0) {
// 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
@@ -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 {
triangulate_helper(shape_, settings, place, t, surface_style_id);
}
void IfcGeom::OpenCascadeShape::Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation<double>* t, int surface_style_id) const {
triangulate_helper(shape_, settings, place, t, surface_style_id);
}
int IfcGeom::OpenCascadeShape::surface_genus() const {
int ifcopenshell::geometry::OpenCascadeShape::surface_genus() const {
throw std::runtime_error("Not implemented");
}
bool ifcopenshell::geometry::OpenCascadeShape::is_manifold() const {
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_; }
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 {
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/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"
+16
View File
@@ -699,3 +699,19 @@ IfcUtil::IfcBaseEntity* mapping::get_decomposing_entity(IfcUtil::IfcBaseEntity*
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) {}
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 std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers(IfcUtil::IfcBaseEntity*);
const IfcSchema::IfcMaterial* get_single_material_association(const IfcSchema::IfcProduct* product);
IfcSchema::IfcRepresentation* representation_mapped_to(const IfcSchema::IfcRepresentation* representation);
+74 -74
View File
@@ -24,110 +24,110 @@
* *
********************************************************************************/
BIND(IfcShellBasedSurfaceModel);
BIND(IfcFaceBasedSurfaceModel);
BIND(IfcRepresentation);
BIND(IfcMappedItem);
// BIND(IfcShellBasedSurfaceModel);
// BIND(IfcFaceBasedSurfaceModel);
// BIND(IfcRepresentation);
// BIND(IfcMappedItem);
// IfcFacetedBrep included
// IfcAdvancedBrep included
// IfcFacetedBrepWithVoids included
// IfcAdvancedBrepWithVoids included
BIND(IfcManifoldSolidBrep);
BIND(IfcGeometricSet);
// BIND(IfcManifoldSolidBrep);
// BIND(IfcGeometricSet);
#ifdef SCHEMA_HAS_IfcCylindricalSurface
BIND(IfcCylindricalSurface);
// BIND(IfcCylindricalSurface);
#endif
#ifdef SCHEMA_HAS_IfcAdvancedBrep
BIND(IfcAdvancedBrep);
// BIND(IfcAdvancedBrep);
#endif
// FIXME: Surfaces should have a shape type of their own
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
BIND(IfcBSplineSurfaceWithKnots);
// BIND(IfcBSplineSurfaceWithKnots);
#endif
#ifdef SCHEMA_HAS_IfcTriangulatedFaceSet
BIND(IfcTriangulatedFaceSet);
// BIND(IfcTriangulatedFaceSet);
#endif
#ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered
BIND(IfcExtrudedAreaSolidTapered);
// BIND(IfcExtrudedAreaSolidTapered);
#endif
BIND(IfcExtrudedAreaSolid);
BIND(IfcRevolvedAreaSolid);
BIND(IfcConnectedFaceSet);
BIND(IfcBooleanResult);
BIND(IfcPolygonalBoundedHalfSpace);
BIND(IfcHalfSpaceSolid);
BIND(IfcSurfaceOfLinearExtrusion);
BIND(IfcSurfaceOfRevolution);
BIND(IfcBlock);
BIND(IfcRectangularPyramid);
BIND(IfcRightCircularCylinder);
BIND(IfcRightCircularCone);
BIND(IfcSphere);
BIND(IfcCsgSolid);
BIND(IfcCurveBoundedPlane);
BIND(IfcRectangularTrimmedSurface);
BIND(IfcSurfaceCurveSweptAreaSolid);
BIND(IfcSweptDiskSolid);
// BIND(IfcRevolvedAreaSolid);
// BIND(IfcConnectedFaceSet);
// BIND(IfcBooleanResult);
// BIND(IfcPolygonalBoundedHalfSpace);
// BIND(IfcHalfSpaceSolid);
// BIND(IfcSurfaceOfLinearExtrusion);
// BIND(IfcSurfaceOfRevolution);
// BIND(IfcBlock);
// BIND(IfcRectangularPyramid);
// BIND(IfcRightCircularCylinder);
// BIND(IfcRightCircularCone);
// BIND(IfcSphere);
// BIND(IfcCsgSolid);
// BIND(IfcCurveBoundedPlane);
// BIND(IfcRectangularTrimmedSurface);
// BIND(IfcSurfaceCurveSweptAreaSolid);
// BIND(IfcSweptDiskSolid);
BIND(IfcArbitraryProfileDefWithVoids);
BIND(IfcArbitraryClosedProfileDef);
BIND(IfcRoundedRectangleProfileDef);
BIND(IfcRectangleHollowProfileDef);
BIND(IfcRectangleProfileDef);
BIND(IfcTrapeziumProfileDef)
BIND(IfcCShapeProfileDef);
// BIND(IfcArbitraryProfileDefWithVoids);
// BIND(IfcArbitraryClosedProfileDef);
// BIND(IfcRoundedRectangleProfileDef);
// BIND(IfcRectangleHollowProfileDef);
// BIND(IfcRectangleProfileDef);
// BIND(IfcTrapeziumProfileDef)
// BIND(IfcCShapeProfileDef);
// IfcAsymmetricIShapeProfileDef included
BIND(IfcIShapeProfileDef);
BIND(IfcLShapeProfileDef);
BIND(IfcTShapeProfileDef);
BIND(IfcUShapeProfileDef);
BIND(IfcZShapeProfileDef);
BIND(IfcCircleHollowProfileDef);
BIND(IfcCircleProfileDef);
BIND(IfcEllipseProfileDef);
BIND(IfcCenterLineProfileDef);
BIND(IfcCompositeProfileDef);
BIND(IfcDerivedProfileDef);
// BIND(IfcIShapeProfileDef);
// BIND(IfcLShapeProfileDef);
// BIND(IfcTShapeProfileDef);
// BIND(IfcUShapeProfileDef);
// BIND(IfcZShapeProfileDef);
// BIND(IfcCircleHollowProfileDef);
// BIND(IfcCircleProfileDef);
// BIND(IfcEllipseProfileDef);
// BIND(IfcCenterLineProfileDef);
// BIND(IfcCompositeProfileDef);
// BIND(IfcDerivedProfileDef);
// IfcFaceSurface included
// IfcAdvancedFace included in case of IFC4
BIND(IfcFace);
// BIND(IfcFace);
BIND(IfcEdgeCurve);
BIND(IfcSubedge);
BIND(IfcOrientedEdge);
BIND(IfcEdge);
BIND(IfcEdgeLoop);
BIND(IfcPolyline);
BIND(IfcPolyLoop);
BIND(IfcCompositeCurve);
BIND(IfcTrimmedCurve);
BIND(IfcArbitraryOpenProfileDef);
// BIND(IfcEdgeCurve);
// BIND(IfcSubedge);
// BIND(IfcOrientedEdge);
// BIND(IfcEdge);
// BIND(IfcEdgeLoop);
// BIND(IfcPolyline);
// BIND(IfcPolyLoop);
// BIND(IfcCompositeCurve);
// BIND(IfcTrimmedCurve);
// BIND(IfcArbitraryOpenProfileDef);
#ifdef SCHEMA_HAS_IfcIndexedPolyCurve
BIND(IfcIndexedPolyCurve)
// BIND(IfcIndexedPolyCurve)
#endif
BIND(IfcCircle);
BIND(IfcEllipse);
BIND(IfcLine);
// BIND(IfcCircle);
// BIND(IfcEllipse);
// BIND(IfcLine);
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
// IfcRationalBSplineCurveWithKnots included
BIND(IfcBSplineCurveWithKnots);
// BIND(IfcBSplineCurveWithKnots);
#endif
BIND(IfcCartesianPoint);
BIND(IfcDirection);
BIND(IfcAxis2Placement2D);
// BIND(IfcCartesianPoint);
// BIND(IfcDirection);
// BIND(IfcAxis2Placement2D);
BIND(IfcAxis2Placement3D);
BIND(IfcAxis1Placement);
BIND(IfcCartesianTransformationOperator2DnonUniform);
BIND(IfcCartesianTransformationOperator3DnonUniform);
BIND(IfcCartesianTransformationOperator2D);
BIND(IfcCartesianTransformationOperator3D);
BIND(IfcObjectPlacement);
BIND(IfcVector);
BIND(IfcPlane);
// BIND(IfcAxis1Placement);
// BIND(IfcCartesianTransformationOperator2DnonUniform);
// BIND(IfcCartesianTransformationOperator3DnonUniform);
// BIND(IfcCartesianTransformationOperator2D);
// BIND(IfcCartesianTransformationOperator3D);
// BIND(IfcObjectPlacement);
// BIND(IfcVector);
// BIND(IfcPlane);
BIND(IfcColourRgb);
// BIND(IfcColourRgb);
BIND(IfcMaterial);
BIND(IfcStyledItem);
+20 -96
View File
@@ -3,7 +3,7 @@
#include "../../ifcgeom/schema_agnostic/IfcGeomElement.h"
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);
}
@@ -26,15 +26,6 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
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 name = product->get_value_or<std::string>("Name", "");
@@ -44,7 +35,8 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
ifcopenshell::geometry::ConversionResults shapes;
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);
shape = new ifcopenshell::geometry::Representation::BRep(s, representation_id_builder.str(), shapes);
@@ -57,7 +49,7 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
guid,
// @todo
"",
trsf,
placement->matrix,
boost::shared_ptr<ifcopenshell::geometry::Representation::BRep>(shape),
product
);
@@ -202,55 +194,50 @@ ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create
*/
}
/*
template <typename P, typename PP>
ifcopenshell::geometry::kernels::NativeElement<P, PP>* ifcopenshell::geometry::kernels::AbstractKernel::create_brep_for_processed_representation(
const IteratorSettings& //* settings /, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product,
ifcopenshell::geometry::kernels::NativeElement<P, PP>* brep) {
ifcopenshell::geometry::NativeElement* ifcopenshell::geometry::Converter::create_brep_for_processed_representation(
const ifcopenshell::geometry::settings& /* settings */, IfcUtil::IfcBaseEntity* /* representation */, IfcUtil::IfcBaseEntity* product,
ifcopenshell::geometry::NativeElement* brep)
{
int parent_id = -1;
try {
IfcUtil::IfcBaseEntity* parent_object = get_decomposing_entity(product);
if (parent_object && parent_object->as<IfcSchema::IfcObjectDefinition>()) {
IfcUtil::IfcBaseEntity* parent_object = mapping_->get_decomposing_entity(product);
if (parent_object) {
parent_id = parent_object->data().id();
}
} catch (const std::exception& e) {
Logger::Error(e);
}
const std::string name = product->hasName() ? product->Name() : "";
const std::string guid = product->GlobalId();
const std::string guid = product->get_value<std::string>("GlobalId");
const std::string name = product->get_value_or<std::string>("Name", "");
ConversionResultPlacement* trsf = nullptr;
try {
convert_placement(product->ObjectPlacement(), trsf);
} catch (const std::exception& e) {
Logger::Error(e);
} catch (...) {
Logger::Error("Failed to construct placement");
}
auto placement = (taxonomy::geom_item*) mapping_->map(product);
/*
std::string context_string = "";
if (representation->hasRepresentationIdentifier()) {
context_string = representation->RepresentationIdentifier();
} else if (representation->ContextOfItems()->hasContextType()) {
context_string = representation->ContextOfItems()->ContextType();
}
*/
const std::string product_type = product->declaration().name();
return new NativeElement<P, PP>(
return new NativeElement(
product->data().id(),
parent_id,
name,
product_type,
guid,
context_string,
trsf,
// @todo
"",
placement->matrix,
brep->geometry_pointer(),
product
);
}
*/
//#include "../../ifcparse/Ifc2x3.h"
//#include "../../ifcparse/Ifc4.h"
//
@@ -308,42 +295,6 @@ ifcopenshell::geometry::kernels::NativeElement<P, PP>* ifcopenshell::geometry::k
// 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) {
// 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_) {
// // @todo make kernel agnostic
-6
View File
@@ -81,11 +81,6 @@ namespace ifcopenshell { namespace geometry {
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_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 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);
*/
};
@@ -54,6 +54,9 @@ namespace ifcopenshell { namespace geometry {
}
}
const ifcopenshell::geometry::taxonomy::matrix4& data() const { return matrix_; }
const element_settings& settings() const { return settings_; }
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
class Element {
@@ -131,7 +134,10 @@ namespace ifcopenshell { namespace geometry {
_unique_id = oss.str();
}
virtual ~Element() {}
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
class NativeElement : public Element {
@@ -28,7 +28,7 @@
#include <BRepGProp.hxx>
#include "IfcGeomRepresentation.h"
#include "../../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h"
#include "../../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
ifcopenshell::geometry::Representation::Serialization::Serialization(const BRep& brep)
: Representation(brep.settings())
+1
View File
@@ -39,6 +39,7 @@ struct matrix4 : public item {
Eigen::Matrix4d components;
matrix4(const Eigen::Matrix4d& c) : components(c), tag(OTHER) {}
matrix4() : components(Eigen::Matrix4d::Identity()), tag(IDENTITY) {}
virtual item* clone() const { return new matrix4(*this); }
+1 -1
View File
@@ -47,7 +47,7 @@
#include <vld.h>
#endif
#include "../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h"
#include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
#include <GProp_GProps.hxx>
#include <BRepGProp.hxx>
+11 -8
View File
@@ -191,20 +191,20 @@ void ColladaSerializer::ColladaExporter::ColladaScene::add(
node.setNodeName(node_name);
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;
const ifcopenshell::geometry::Transformation* transformation_towrite = &transformation;
// If this is not the first parent, get the relative placement
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;
}
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)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 (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;
}
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)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);
// 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);
serializer->parentStackId.push(parent.id());
}
+1 -1
View File
@@ -20,7 +20,7 @@
#ifndef OPENCASCADEBASEDSERIALIZER_H
#define OPENCASCADEBASEDSERIALIZER_H
#include "../ifcgeom/schema_agnostic/opencascade/OpenCascadeConversionResult.h"
#include "../ifcgeom/kernels/opencascade/OpenCascadeConversionResult.h"
#include "../serializers/GeometrySerializer.h"
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 <fstream>
+8 -4
View File
@@ -1,11 +1,15 @@
#include "XmlSerializer.h"
extern void init_XmlSerializerIfc2x3(XmlSerializerFactory::Factory*);
extern void init_XmlSerializerIfc4(XmlSerializerFactory::Factory*);
extern void init_XmlSerializer_Ifc2x3(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() {
init_XmlSerializerIfc2x3(this);
init_XmlSerializerIfc4(this);
init_XmlSerializer_Ifc2x3(this);
init_XmlSerializer_Ifc4(this);
init_XmlSerializer_Ifc4x1(this);
init_XmlSerializer_Ifc4x2(this);
}
void XmlSerializerFactory::Factory::bind(const std::string& schema_name, fn f) {