2017-01-16 11:53:11 +01:00
|
|
|
/********************************************************************************
|
|
|
|
|
* *
|
|
|
|
|
* 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
|
|
|
|
|
|
2019-01-22 13:00:49 +01:00
|
|
|
#include <boost/property_map/property_map.hpp>
|
|
|
|
|
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
|
|
|
|
#include <CGAL/Polyhedron_3.h>
|
|
|
|
|
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
|
|
|
|
|
#include <CGAL/Polygon_mesh_processing/stitch_borders.h>
|
|
|
|
|
#include <CGAL/Polygon_mesh_processing/orientation.h>
|
|
|
|
|
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
|
|
|
|
|
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
|
|
|
|
|
|
|
|
|
|
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
|
|
|
|
|
|
|
|
|
|
typedef Kernel::Aff_transformation_3 cgal_placement_t;
|
|
|
|
|
typedef Kernel::Point_3 cgal_point_t;
|
|
|
|
|
typedef Kernel::Vector_3 cgal_direction_t;
|
|
|
|
|
typedef std::vector<Kernel::Point_3> cgal_curve_t;
|
|
|
|
|
typedef std::vector<Kernel::Point_3> cgal_wire_t;
|
|
|
|
|
|
|
|
|
|
struct cgal_face_t {
|
|
|
|
|
cgal_wire_t outer;
|
|
|
|
|
std::vector<cgal_wire_t> inner;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef CGAL::Polyhedron_3<Kernel> cgal_shape_t;
|
|
|
|
|
typedef boost::graph_traits<CGAL::Polyhedron_3<Kernel>>::vertex_descriptor cgal_vertex_descriptor_t;
|
|
|
|
|
typedef boost::graph_traits<CGAL::Polyhedron_3<Kernel>>::face_descriptor cgal_face_descriptor_t;
|
2019-01-19 12:39:47 +01:00
|
|
|
|
2019-01-18 16:43:38 +01:00
|
|
|
#include "../../../ifcgeom/schema_agnostic/ConversionResult.h"
|
2017-01-16 11:53:11 +01:00
|
|
|
|
|
|
|
|
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 {
|
2017-02-08 16:56:59 -06:00
|
|
|
// TODO: Check
|
2017-02-21 15:37:38 -06:00
|
|
|
// std::cout << "Getting CgalPlacement with i = " << i << " and j = " << j << std::endl;
|
|
|
|
|
return CGAL::to_double(trsf_.cartesian(i-1, j-1));
|
2017-01-16 11:53:11 +01:00
|
|
|
}
|
2019-01-18 15:19:00 +01:00
|
|
|
|
2017-01-16 11:53:11 +01:00
|
|
|
virtual void Multiply(const ConversionResultPlacement* other) {
|
2017-02-08 16:56:59 -06:00
|
|
|
// TODO: Check
|
|
|
|
|
trsf_ = ((CgalPlacement *)other)->trsf_ * trsf_;
|
2017-01-16 11:53:11 +01:00
|
|
|
}
|
2019-01-18 15:19:00 +01:00
|
|
|
|
2017-01-16 11:53:11 +01:00
|
|
|
virtual void PreMultiply(const ConversionResultPlacement* other) {
|
2017-02-08 16:56:59 -06:00
|
|
|
// TODO: Check
|
|
|
|
|
trsf_ = trsf_ * ((CgalPlacement *)other)->trsf_;
|
2017-01-16 11:53:11 +01:00
|
|
|
}
|
2019-01-18 15:19:00 +01:00
|
|
|
|
2017-01-16 11:53:11 +01:00
|
|
|
virtual ConversionResultPlacement* clone() const {
|
|
|
|
|
return new CgalPlacement(trsf_);
|
|
|
|
|
}
|
2019-01-18 15:19:00 +01:00
|
|
|
|
|
|
|
|
virtual ConversionResultPlacement* inverted() const {
|
|
|
|
|
throw std::runtime_error("Not implemented");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual ConversionResultPlacement* multiplied(const ConversionResultPlacement*) const {
|
|
|
|
|
throw std::runtime_error("Not implemented");
|
|
|
|
|
}
|
2019-01-20 13:16:42 +01:00
|
|
|
|
|
|
|
|
virtual void TranslationPart(double& X, double& Y, double& Z) const {
|
|
|
|
|
throw std::runtime_error("Not implemented");
|
|
|
|
|
}
|
2017-01-16 11:53:11 +01:00
|
|
|
private:
|
|
|
|
|
cgal_placement_t trsf_;
|
|
|
|
|
};
|
2017-02-21 15:37:38 -06:00
|
|
|
|
2017-01-16 11:53:11 +01:00
|
|
|
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_; }
|
|
|
|
|
|
2019-01-18 15:19:00 +01:00
|
|
|
virtual void Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation<float> * t, int surface_style_id) const;
|
|
|
|
|
|
2017-01-16 11:53:11 +01:00
|
|
|
virtual void Triangulate(const IfcGeom::IteratorSettings & settings, const IfcGeom::ConversionResultPlacement * place, IfcGeom::Representation::Triangulation<double>* t, int surface_style_id) const;
|
2019-01-18 15:19:00 +01:00
|
|
|
|
2017-01-16 11:53:11 +01:00
|
|
|
virtual void Serialize(std::string&) const {
|
|
|
|
|
throw std::runtime_error("Not implemented");
|
|
|
|
|
}
|
2019-01-18 15:19:00 +01:00
|
|
|
|
2017-01-16 11:53:11 +01:00
|
|
|
virtual ConversionResultShape* clone() const {
|
|
|
|
|
return new CgalShape(shape_);
|
|
|
|
|
}
|
2019-01-18 15:19:00 +01:00
|
|
|
|
|
|
|
|
virtual int surface_genus() const {
|
|
|
|
|
throw std::runtime_error("Not implemented");
|
|
|
|
|
}
|
2017-01-16 11:53:11 +01:00
|
|
|
private:
|
|
|
|
|
cgal_shape_t shape_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-07 20:37:47 -06:00
|
|
|
#endif
|