Option to select Kernel from IfcConvert

This commit is contained in:
Thomas Krijnen
2019-01-19 12:39:47 +01:00
parent 5a7c7ed048
commit fa0a33f3c0
18 changed files with 99 additions and 101 deletions
@@ -1,5 +1,5 @@
#include "CgalKernel.h"
#include "CgalConversionResult.h"
#include "../../../ifcgeom/schema_agnostic/cgal/CgalConversionResult.h"
#define CgalKernel MAKE_TYPE_NAME(CgalKernel)
@@ -1,15 +0,0 @@
#include "CgalKernel.h"
#include "CgalConversionResult.h"
template <typename Precision>
void triangulate_helper(const cgal_shape_t, const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation<Precision>* t, int surface_style_id) {
throw std::runtime_error("Not implemented Triangulate()");
}
void IfcGeom::CgalShape::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::CgalShape::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);
}
@@ -1,96 +0,0 @@
/********************************************************************************
* *
* 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/schema_agnostic/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_);
}
virtual ConversionResultPlacement* inverted() const {
throw std::runtime_error("Not implemented");
}
virtual ConversionResultPlacement* multiplied(const ConversionResultPlacement*) const {
throw std::runtime_error("Not implemented");
}
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<float> * t, int surface_style_id) const;
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_);
}
virtual int surface_genus() const {
throw std::runtime_error("Not implemented");
}
private:
cgal_shape_t shape_;
};
}
#endif
@@ -18,7 +18,6 @@
********************************************************************************/
#include "CgalKernel.h"
#include "CgalConversionResult.h"
#define CgalKernel MAKE_TYPE_NAME(CgalKernel)
+24 -1
View File
@@ -18,7 +18,6 @@
********************************************************************************/
#include "CgalKernel.h"
#include "CgalConversionResult.h"
namespace {
struct MAKE_TYPE_NAME(factory_t) {
@@ -208,3 +207,27 @@ template IFC_GEOM_API IfcGeom::NativeElement<float, double>* IfcGeom::CgalKernel
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::NativeElement<float, double>* brep);
template IFC_GEOM_API IfcGeom::NativeElement<double, double>* IfcGeom::CgalKernel::create_brep_for_processed_representation<double, double>(
const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product, IfcGeom::NativeElement<double, double>* brep);
void IfcGeom::CgalKernel::setValue(GeomValue var, double value) {
switch (var) {
case GV_DEFLECTION_TOLERANCE:
deflection_tolerance = value;
break;
case GV_DIMENSIONALITY:
dimensionality = value;
break;
default:
throw std::runtime_error("Not implemented for this kernel");
}
}
double IfcGeom::CgalKernel::getValue(GeomValue var) const {
switch (var) {
case GV_DEFLECTION_TOLERANCE:
return deflection_tolerance;
case GV_DIMENSIONALITY:
return dimensionality;
}
throw std::runtime_error("Not implemented for this kernel");
}
+7 -7
View File
@@ -38,6 +38,7 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
#include "../../../ifcparse/macros.h"
#include "../../../ifcgeom/schema_agnostic/Kernel.h"
#include "../../../ifcgeom/schema_agnostic/IfcGeomElement.h"
#include "../../../ifcgeom/schema_agnostic/cgal/CgalConversionResult.h"
// @todo create separate shapetype enum?
#include "../../../ifcgeom/kernels/opencascade/IfcGeomShapeType.h"
@@ -46,13 +47,6 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
#include INCLUDE_SCHEMA(IfcSchema)
#undef INCLUDE_SCHEMA
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 {
@@ -78,6 +72,9 @@ namespace IfcGeom {
bool convert_curve(const IfcUtil::IfcBaseClass* L, cgal_curve_t& result);
bool convert_face(const IfcUtil::IfcBaseClass* L, cgal_face_t& result);
virtual void setValue(GeomValue var, double value);
virtual double getValue(GeomValue var) const;
// 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() {
@@ -102,6 +99,9 @@ namespace IfcGeom {
#include "CgalEntityMappingDeclaration.h"
private:
double deflection_tolerance;
double dimensionality;
};
}