mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Cgal kernel skeleton
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
#include "CgalKernel.h"
|
||||||
|
#include "CgalConversionResult.h"
|
||||||
|
|
||||||
|
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcRepresentation* l, ConversionResults& shapes) {
|
||||||
|
IfcSchema::IfcRepresentationItem::list::ptr items = l->Items();
|
||||||
|
bool part_succes = false;
|
||||||
|
if (items->size()) {
|
||||||
|
for (IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++it) {
|
||||||
|
IfcSchema::IfcRepresentationItem* representation_item = *it;
|
||||||
|
if (shape_type(representation_item) == ST_SHAPELIST) {
|
||||||
|
part_succes |= convert_shapes(*it, shapes);
|
||||||
|
} else {
|
||||||
|
cgal_shape_t s;
|
||||||
|
if (convert_shape(representation_item, s)) {
|
||||||
|
shapes.push_back(ConversionResult(new CgalShape(s), get_style(representation_item)));
|
||||||
|
part_succes |= true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return part_succes;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IfcGeom::CgalKernel::convert(const Ifc2x3::IfcExtrudedAreaSolid*, cgal_shape_t&) {
|
||||||
|
throw std::runtime_error("Not implemented IfcExtrudedAreaSolid");
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "CgalKernel.h"
|
||||||
|
#include "CgalConversionResult.h"
|
||||||
|
|
||||||
|
void IfcGeom::CgalShape::Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation<double>* t, int surface_style_id) const {
|
||||||
|
throw std::runtime_error("Not implemented Triangulate()");
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CGALCONVERSIONRESULT_H
|
||||||
|
#define CGALCONVERSIONRESULT_H
|
||||||
|
|
||||||
|
#include "../../../ifcgeom/ConversionResult.h"
|
||||||
|
|
||||||
|
namespace IfcGeom {
|
||||||
|
|
||||||
|
class CgalPlacement : public ConversionResultPlacement {
|
||||||
|
public:
|
||||||
|
CgalPlacement(const cgal_placement_t& trsf)
|
||||||
|
: trsf_(trsf)
|
||||||
|
{}
|
||||||
|
|
||||||
|
const cgal_placement_t& trsf() const { return trsf_; }
|
||||||
|
operator const cgal_placement_t& () { return trsf_; }
|
||||||
|
|
||||||
|
virtual double Value(int i, int j) const {
|
||||||
|
// Get cell from placement as 4x3 matrix as implemented in OCCT. We'll have to check exact semantics.
|
||||||
|
throw std::runtime_error("Not implemented");
|
||||||
|
}
|
||||||
|
virtual void Multiply(const ConversionResultPlacement* other) {
|
||||||
|
// Multiply matrix as implemented in OCCT. We'll have to check exact semantics.
|
||||||
|
throw std::runtime_error("Not implemented");
|
||||||
|
}
|
||||||
|
virtual void PreMultiply(const ConversionResultPlacement* other) {
|
||||||
|
// PreMultiply matrix as implemented in OCCT. We'll have to check exact semantics.
|
||||||
|
throw std::runtime_error("Not implemented");
|
||||||
|
}
|
||||||
|
virtual ConversionResultPlacement* clone() const {
|
||||||
|
return new CgalPlacement(trsf_);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
cgal_placement_t trsf_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CgalShape : public ConversionResultShape {
|
||||||
|
public:
|
||||||
|
CgalShape(const cgal_shape_t& shape)
|
||||||
|
: shape_(shape)
|
||||||
|
{}
|
||||||
|
|
||||||
|
const cgal_shape_t& shape() const { return shape_; }
|
||||||
|
operator const cgal_shape_t& () { return shape_; }
|
||||||
|
|
||||||
|
virtual void Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation<double>* t, int surface_style_id) const;
|
||||||
|
virtual void Serialize(std::string&) const {
|
||||||
|
throw std::runtime_error("Not implemented");
|
||||||
|
}
|
||||||
|
virtual ConversionResultShape* clone() const {
|
||||||
|
return new CgalShape(shape_);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
cgal_shape_t shape_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include "../../../ifcgeom/IfcGeomShapeType.h"
|
||||||
|
#include "../../../ifcgeom/IfcGeom.h"
|
||||||
|
|
||||||
|
#include "CgalKernel.h"
|
||||||
|
#include "CgalConversionResult.h"
|
||||||
|
|
||||||
|
using namespace IfcSchema;
|
||||||
|
using namespace IfcUtil;
|
||||||
|
|
||||||
|
|
||||||
|
bool IfcGeom::CgalKernel::convert_shapes(const IfcBaseClass* l, ConversionResults& r) {
|
||||||
|
if (shape_type(l) != ST_SHAPELIST) {
|
||||||
|
cgal_shape_t shp;
|
||||||
|
if (convert_shape(l, shp)) {
|
||||||
|
r.push_back(IfcGeom::ConversionResult(new CgalShape(shp), get_style(l->as<IfcSchema::IfcRepresentationItem>())));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "CgalEntityMappingShapes.h"
|
||||||
|
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IfcGeom::ShapeType IfcGeom::CgalKernel::shape_type(const IfcBaseClass* l) {
|
||||||
|
#include "CgalEntityMappingShapeType.h"
|
||||||
|
return ST_OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IfcGeom::CgalKernel::convert_shape(const IfcBaseClass* l, cgal_shape_t& r) {
|
||||||
|
const unsigned int id = l->entity->id();
|
||||||
|
bool success = false;
|
||||||
|
bool processed = false;
|
||||||
|
bool ignored = false;
|
||||||
|
|
||||||
|
#ifndef NO_CACHE
|
||||||
|
std::map<int, cgal_shape_t>::const_iterator it = cache.Shape.find(id);
|
||||||
|
if ( it != cache.Shape.end() ) { r = it->second; return true; }
|
||||||
|
#endif
|
||||||
|
const bool include_curves = getValue(GV_DIMENSIONALITY) != +1;
|
||||||
|
const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1;
|
||||||
|
|
||||||
|
IfcGeom::ShapeType st = shape_type(l);
|
||||||
|
ignored = (!include_solids_and_surfaces && (st == ST_SHAPE || st == ST_FACE)) || (!include_curves && (st == ST_WIRE || st == ST_CURVE));
|
||||||
|
if (st == ST_SHAPE && include_solids_and_surfaces) {
|
||||||
|
#include "CgalEntityMappingShape.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( processed && success ) {
|
||||||
|
const double precision = getValue(GV_PRECISION);
|
||||||
|
// apply_tolerance(r, precision);
|
||||||
|
#ifndef NO_CACHE
|
||||||
|
cache.Shape[id] = r;
|
||||||
|
#endif
|
||||||
|
} else if (!ignored) {
|
||||||
|
const char* const msg = processed
|
||||||
|
? "Failed to convert:"
|
||||||
|
: "No operation defined for:";
|
||||||
|
Logger::Message(Logger::LOG_ERROR, msg, l->entity);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IfcGeom::CgalKernel::convert_wire(const IfcBaseClass* l, cgal_wire_t& r) {
|
||||||
|
#include "CgalEntityMappingWire.h"
|
||||||
|
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IfcGeom::CgalKernel::convert_face(const IfcBaseClass* l, cgal_face_t& r) {
|
||||||
|
#include "CgalEntityMappingFace.h"
|
||||||
|
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IfcGeom::CgalKernel::convert_curve(const IfcBaseClass* l, cgal_curve_t& r) {
|
||||||
|
#include "CgalEntityMappingCurve.h"
|
||||||
|
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
/********************************************************************************
|
||||||
|
* *
|
||||||
|
* This file registers function prototypes for all supported IFC geometrical *
|
||||||
|
* entities. For entities of type CLASS an std::map is also created to cache *
|
||||||
|
* the output of the conversion functions *
|
||||||
|
* *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include "../../../ifcparse/IfcUtil.h"
|
||||||
|
#include "../../../ifcparse/IfcParse.h"
|
||||||
|
|
||||||
|
SHAPES(IfcRepresentation);
|
||||||
|
|
||||||
|
SHAPE(IfcExtrudedAreaSolid);
|
||||||
|
|
||||||
|
CLASS(IfcCartesianPoint,cgal_point_t);
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "CgalEntityMappingUndefine.h"
|
||||||
|
#define CLASS(T,V) \
|
||||||
|
std::map<int,V> T;
|
||||||
|
#include "CgalEntityMappingDefine.h"
|
||||||
|
|
||||||
|
#include "CgalEntityMapping.h"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "CgalEntityMappingUndefine.h"
|
||||||
|
#define CURVE(T) \
|
||||||
|
if ( l->is(T::Class()) ) return convert((T*)l,r);
|
||||||
|
#include "CgalEntityMappingDefine.h"
|
||||||
|
|
||||||
|
#include "CgalEntityMapping.h"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include "CgalEntityMappingUndefine.h"
|
||||||
|
#define CLASS(T,V) bool convert(const IfcSchema::T* L, V& r);
|
||||||
|
#define SHAPES(T) CLASS(T,ConversionResults)
|
||||||
|
#define SHAPE(T) CLASS(T,cgal_shape_t)
|
||||||
|
#define WIRE(T) CLASS(T,cgal_wire_t)
|
||||||
|
#define FACE(T) CLASS(T,cgal_face_t)
|
||||||
|
#define CURVE(T) CLASS(T,cgal_curve_t)
|
||||||
|
#include "CgalEntityMappingDefine.h"
|
||||||
|
|
||||||
|
#include "CgalEntityMapping.h"
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef SHAPES
|
||||||
|
#define SHAPES(T)
|
||||||
|
#endif
|
||||||
|
#ifndef SHAPE
|
||||||
|
#define SHAPE(T)
|
||||||
|
#endif
|
||||||
|
#ifndef WIRE
|
||||||
|
#define WIRE(T)
|
||||||
|
#endif
|
||||||
|
#ifndef FACE
|
||||||
|
#define FACE(T)
|
||||||
|
#endif
|
||||||
|
#ifndef CURVE
|
||||||
|
#define CURVE(T)
|
||||||
|
#endif
|
||||||
|
#ifndef CLASS
|
||||||
|
#define CLASS(T,V)
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "CgalEntityMappingUndefine.h"
|
||||||
|
#define FACE(T) \
|
||||||
|
if ( l->is(T::Class()) ) return convert((T*)l,r);
|
||||||
|
#include "CgalEntityMappingDefine.h"
|
||||||
|
|
||||||
|
#include "CgalEntityMapping.h"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "CgalEntityMappingUndefine.h"
|
||||||
|
#define CLASS(T,V) \
|
||||||
|
T.clear();
|
||||||
|
#include "CgalEntityMappingDefine.h"
|
||||||
|
|
||||||
|
#include "CgalEntityMapping.h"
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include "CgalEntityMappingUndefine.h"
|
||||||
|
#define SHAPE(T) \
|
||||||
|
if ( !processed && l->is(T::Class()) ) { \
|
||||||
|
processed = true; \
|
||||||
|
try { \
|
||||||
|
if ( convert((T*)l,r) ) { \
|
||||||
|
success = true; \
|
||||||
|
} \
|
||||||
|
} catch (const std::exception& e) { \
|
||||||
|
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l->entity); \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
if (!success) { \
|
||||||
|
Logger::Message(Logger::LOG_ERROR,"Failed to convert:",l->entity); \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
#include "CgalEntityMappingDefine.h"
|
||||||
|
|
||||||
|
#include "CgalEntityMapping.h"
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#include "CgalEntityMappingUndefine.h"
|
||||||
|
#define SHAPES(T) \
|
||||||
|
if ( l->is(T::Class()) ) return ST_SHAPELIST;
|
||||||
|
#define SHAPE(T) \
|
||||||
|
if ( l->is(T::Class()) ) return ST_SHAPE;
|
||||||
|
#define WIRE(T) \
|
||||||
|
if ( l->is(T::Class()) ) return ST_WIRE;
|
||||||
|
#define FACE(T) \
|
||||||
|
if ( l->is(T::Class()) ) return ST_FACE;
|
||||||
|
#define CURVE(T) \
|
||||||
|
if ( l->is(T::Class()) ) return ST_CURVE;
|
||||||
|
#include "CgalEntityMappingDefine.h"
|
||||||
|
|
||||||
|
#include "CgalEntityMapping.h"
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#include "CgalEntityMappingUndefine.h"
|
||||||
|
#define SHAPES(T) \
|
||||||
|
if ( l->is(T::Class()) ) { \
|
||||||
|
try { \
|
||||||
|
return convert((T*)l,r); \
|
||||||
|
} catch (const std::exception& e) { \
|
||||||
|
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + "\nFailed to convert:", l->entity); \
|
||||||
|
} \
|
||||||
|
return false; \
|
||||||
|
}
|
||||||
|
#include "CgalEntityMappingDefine.h"
|
||||||
|
|
||||||
|
#include "CgalEntityMapping.h"
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifdef SHAPES
|
||||||
|
#undef SHAPES
|
||||||
|
#endif
|
||||||
|
#ifdef SHAPE
|
||||||
|
#undef SHAPE
|
||||||
|
#endif
|
||||||
|
#ifdef WIRE
|
||||||
|
#undef WIRE
|
||||||
|
#endif
|
||||||
|
#ifdef FACE
|
||||||
|
#undef FACE
|
||||||
|
#endif
|
||||||
|
#ifdef CURVE
|
||||||
|
#undef CURVE
|
||||||
|
#endif
|
||||||
|
#ifdef CLASS
|
||||||
|
#undef CLASS
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "CgalEntityMappingUndefine.h"
|
||||||
|
#define WIRE(T) \
|
||||||
|
if ( l->is(T::Class()) ) return convert((T*)l,r);
|
||||||
|
#include "CgalEntityMappingDefine.h"
|
||||||
|
|
||||||
|
#include "CgalEntityMapping.h"
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include "../../../ifcgeom/IfcGeomShapeType.h"
|
||||||
|
#include "../../../ifcgeom/IfcGeom.h"
|
||||||
|
|
||||||
|
#include "CgalKernel.h"
|
||||||
|
#include "CgalConversionResult.h"
|
||||||
|
|
||||||
|
bool IfcGeom::CgalKernel::is_identity_transform(IfcUtil::IfcBaseClass* l) {
|
||||||
|
Logger::Message(Logger::LOG_ERROR, "Not implemented is_identity_transform()");
|
||||||
|
return false;
|
||||||
|
/*
|
||||||
|
// OpenCascade kernel code below
|
||||||
|
|
||||||
|
IfcSchema::IfcAxis2Placement2D* ax2d;
|
||||||
|
IfcSchema::IfcAxis2Placement3D* ax3d;
|
||||||
|
|
||||||
|
IfcSchema::IfcCartesianTransformationOperator2D* op2d;
|
||||||
|
IfcSchema::IfcCartesianTransformationOperator3D* op3d;
|
||||||
|
IfcSchema::IfcCartesianTransformationOperator2DnonUniform* op2dnonu;
|
||||||
|
IfcSchema::IfcCartesianTransformationOperator3DnonUniform* op3dnonu;
|
||||||
|
|
||||||
|
if ((op2dnonu = l->as<IfcSchema::IfcCartesianTransformationOperator2DnonUniform>()) != 0) {
|
||||||
|
gp_GTrsf2d gtrsf2d;
|
||||||
|
convert(op2dnonu, gtrsf2d);
|
||||||
|
return gtrsf2d.Form() == gp_Identity;
|
||||||
|
} else if ((op2d = l->as<IfcSchema::IfcCartesianTransformationOperator2D>()) != 0) {
|
||||||
|
gp_Trsf2d trsf2d;
|
||||||
|
convert(op2d, trsf2d);
|
||||||
|
return trsf2d.Form() == gp_Identity;
|
||||||
|
} else if ((op3dnonu = l->as<IfcSchema::IfcCartesianTransformationOperator3DnonUniform>()) != 0) {
|
||||||
|
gp_GTrsf gtrsf;
|
||||||
|
convert(op3dnonu, gtrsf);
|
||||||
|
return gtrsf.Form() == gp_Identity;
|
||||||
|
} else if ((op3d = l->as<IfcSchema::IfcCartesianTransformationOperator3D>()) != 0) {
|
||||||
|
gp_Trsf trsf;
|
||||||
|
convert(op3d, trsf);
|
||||||
|
return trsf.Form() == gp_Identity;
|
||||||
|
} else if ((ax2d = l->as<IfcSchema::IfcAxis2Placement2D>()) != 0) {
|
||||||
|
gp_Trsf2d trsf2d;
|
||||||
|
convert(ax2d, trsf2d);
|
||||||
|
return trsf2d.Form() == gp_Identity;
|
||||||
|
} else if ((ax3d = l->as<IfcSchema::IfcAxis2Placement3D>()) != 0) {
|
||||||
|
gp_Trsf trsf;
|
||||||
|
convert(ax3d, trsf);
|
||||||
|
return trsf.Form() == gp_Identity;
|
||||||
|
} else {
|
||||||
|
throw IfcParse::IfcException("Invalid valuation for IfcAxis2Placement / IfcCartesianTransformationOperator");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
IfcGeom::NativeElement<double>* IfcGeom::CgalKernel::create_brep_for_representation_and_product(
|
||||||
|
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product)
|
||||||
|
{
|
||||||
|
IfcGeom::Representation::Native* shape;
|
||||||
|
IfcGeom::ConversionResults shapes, shapes2;
|
||||||
|
|
||||||
|
if (!convert_shapes(representation, shapes)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.get(IteratorSettings::APPLY_LAYERSETS)) {
|
||||||
|
Logger::Message(Logger::LOG_ERROR, "Not implemented APPLY_LAYERSETS");
|
||||||
|
}
|
||||||
|
|
||||||
|
int parent_id = -1;
|
||||||
|
try {
|
||||||
|
IfcSchema::IfcObjectDefinition* parent_object = get_decomposing_entity(product);
|
||||||
|
if (parent_object) {
|
||||||
|
parent_id = parent_object->entity->id();
|
||||||
|
}
|
||||||
|
} catch (...) {}
|
||||||
|
|
||||||
|
const std::string name = product->hasName() ? product->Name() : "";
|
||||||
|
const std::string guid = product->GlobalId();
|
||||||
|
|
||||||
|
cgal_placement_t trsf;
|
||||||
|
try {
|
||||||
|
// convert(product->ObjectPlacement(), trsf);
|
||||||
|
} catch (...) {}
|
||||||
|
|
||||||
|
// Does the IfcElement have any IfcOpenings?
|
||||||
|
// Note that openings for IfcOpeningElements are not processed
|
||||||
|
IfcSchema::IfcRelVoidsElement::list::ptr openings = find_openings(product);
|
||||||
|
|
||||||
|
const std::string product_type = IfcSchema::Type::ToString(product->type());
|
||||||
|
ElementSettings element_settings(settings, getValue(GV_LENGTH_UNIT), product_type);
|
||||||
|
|
||||||
|
if (!settings.get(IfcGeom::IteratorSettings::DISABLE_OPENING_SUBTRACTIONS) && openings && openings->size()) {
|
||||||
|
Logger::Message(Logger::LOG_ERROR, "Not implemented opening subtractions");
|
||||||
|
}
|
||||||
|
|
||||||
|
shape = new IfcGeom::Representation::Native(element_settings, representation->entity->id(), shapes);
|
||||||
|
|
||||||
|
std::string context_string = "";
|
||||||
|
if (representation->hasRepresentationIdentifier()) {
|
||||||
|
context_string = representation->RepresentationIdentifier();
|
||||||
|
} else if (representation->ContextOfItems()->hasContextType()) {
|
||||||
|
context_string = representation->ContextOfItems()->ContextType();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new NativeElement<double>(
|
||||||
|
product->entity->id(),
|
||||||
|
parent_id,
|
||||||
|
name,
|
||||||
|
product_type,
|
||||||
|
guid,
|
||||||
|
context_string,
|
||||||
|
new CgalPlacement(trsf),
|
||||||
|
boost::shared_ptr<IfcGeom::Representation::Native>(shape)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
IfcGeom::NativeElement<double>* IfcGeom::CgalKernel::create_brep_for_processed_representation(
|
||||||
|
const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product,
|
||||||
|
IfcGeom::NativeElement<double>* brep)
|
||||||
|
{
|
||||||
|
int parent_id = -1;
|
||||||
|
try {
|
||||||
|
IfcSchema::IfcObjectDefinition* parent_object = get_decomposing_entity(product);
|
||||||
|
if (parent_object) {
|
||||||
|
parent_id = parent_object->entity->id();
|
||||||
|
}
|
||||||
|
} catch (...) {}
|
||||||
|
|
||||||
|
const std::string name = product->hasName() ? product->Name() : "";
|
||||||
|
const std::string guid = product->GlobalId();
|
||||||
|
|
||||||
|
cgal_placement_t trsf;
|
||||||
|
try {
|
||||||
|
// convert(product->ObjectPlacement(), trsf);
|
||||||
|
} catch (...) {}
|
||||||
|
|
||||||
|
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 = IfcSchema::Type::ToString(product->type());
|
||||||
|
|
||||||
|
return new NativeElement<double>(
|
||||||
|
product->entity->id(),
|
||||||
|
parent_id,
|
||||||
|
name,
|
||||||
|
product_type,
|
||||||
|
guid,
|
||||||
|
context_string,
|
||||||
|
new CgalPlacement(trsf),
|
||||||
|
brep->geometry_pointer()
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CGAL_KERNEL_H
|
||||||
|
#define CGAL_KERNEL_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
#ifdef NO_CACHE
|
||||||
|
|
||||||
|
#define IN_CACHE(T,E,t,e)
|
||||||
|
#define CACHE(T,E,e)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define IN_CACHE(T,E,t,e) std::map<int,t>::const_iterator it = cache.T.find(E->entity->id());\
|
||||||
|
if ( it != cache.T.end() ) { e = it->second; return true; }
|
||||||
|
#define CACHE(T,E,e) cache.T[E->entity->id()] = e;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../../../ifcgeom/IfcGeom.h"
|
||||||
|
|
||||||
|
typedef void* cgal_shape_t;
|
||||||
|
typedef void* cgal_face_t;
|
||||||
|
typedef void* cgal_wire_t;
|
||||||
|
typedef void* cgal_curve_t;
|
||||||
|
typedef void* cgal_placement_t;
|
||||||
|
typedef void* cgal_point_t;
|
||||||
|
|
||||||
|
namespace IfcGeom {
|
||||||
|
|
||||||
|
class IFC_GEOM_API CgalCache {
|
||||||
|
public:
|
||||||
|
#include "CgalEntityMappingCreateCache.h"
|
||||||
|
std::map<int, cgal_shape_t> Shape;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IFC_GEOM_API CgalKernel : public AbstractKernel {
|
||||||
|
public:
|
||||||
|
|
||||||
|
#ifndef NO_CACHE
|
||||||
|
CgalCache cache;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IfcGeom::ShapeType shape_type(const IfcUtil::IfcBaseClass* L);
|
||||||
|
|
||||||
|
bool convert_shapes(const IfcUtil::IfcBaseClass* L, ConversionResults& result);
|
||||||
|
bool convert_shape(const IfcUtil::IfcBaseClass* L, cgal_shape_t& result);
|
||||||
|
bool convert_wire(const IfcUtil::IfcBaseClass* L, cgal_wire_t& result);
|
||||||
|
bool convert_curve(const IfcUtil::IfcBaseClass* L, cgal_curve_t& result);
|
||||||
|
bool convert_face(const IfcUtil::IfcBaseClass* L, cgal_face_t& result);
|
||||||
|
|
||||||
|
// bool convert_openings(const IfcSchema::IfcProduct* entity, const IfcSchema::IfcRelVoidsElement::list::ptr& openings, const ConversionResults& entity_shapes, const gp_Trsf& entity_trsf, ConversionResults& cut_shapes);
|
||||||
|
|
||||||
|
void purge_cache() {
|
||||||
|
// Rather hack-ish, but a stopgap solution to keep memory under control
|
||||||
|
// for large files. SurfaceStyles need to be kept at all costs, as they
|
||||||
|
// are read later on when serializing Collada files.
|
||||||
|
#ifndef NO_CACHE
|
||||||
|
cache = CgalCache();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool is_identity_transform(IfcUtil::IfcBaseClass*);
|
||||||
|
virtual IfcGeom::NativeElement<double>* create_brep_for_representation_and_product(
|
||||||
|
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*);
|
||||||
|
virtual IfcGeom::NativeElement<double>* create_brep_for_processed_representation(
|
||||||
|
const IteratorSettings&, IfcSchema::IfcRepresentation*, IfcSchema::IfcProduct*, IfcGeom::NativeElement<double>*);
|
||||||
|
|
||||||
|
#include "CgalEntityMappingDeclaration.h"
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user