mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Merge branch 'v0.8.0' of https://github.com/RickBrice/IfcOpenShell into v0.8.0
This commit is contained in:
@@ -805,6 +805,10 @@ int main(int argc, char** argv) {
|
||||
IfcGeom::update_default_style("IfcSpace").transparency = geometry_settings.get<ifcopenshell::geometry::settings::ForceSpaceTransparency>().get();
|
||||
}
|
||||
|
||||
if (output_extension == OBJ || output_extension == STP || output_extension == IGS) {
|
||||
geometry_settings.get<ifcopenshell::geometry::settings::UseWorldCoords>().value = true;
|
||||
}
|
||||
|
||||
boost::shared_ptr<GeometrySerializer> serializer; /**< @todo use std::unique_ptr when possible */
|
||||
if (output_extension == OBJ) {
|
||||
// Do not use temp file for MTL as it's such a small file.
|
||||
|
||||
@@ -8,3 +8,13 @@ IfcGeom::Representation::Triangulation * IfcGeom::ConversionResultShape::Triangu
|
||||
Triangulate(settings, iden, t, -1);
|
||||
return t;
|
||||
}
|
||||
|
||||
using namespace ifcopenshell::geometry::taxonomy;
|
||||
|
||||
void IfcGeom::ConversionResult::append(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf) {
|
||||
placement_ = make<matrix4>(placement_->ccomponents() * trsf->ccomponents());
|
||||
}
|
||||
|
||||
void IfcGeom::ConversionResult::prepend(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf) {
|
||||
placement_ = make<matrix4>(trsf->ccomponents() * placement_->ccomponents());
|
||||
}
|
||||
|
||||
@@ -245,14 +245,8 @@ namespace IfcGeom {
|
||||
ConversionResult(int id, ConversionResultShape* shape)
|
||||
: id(id), placement_(ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>()), shape_(shape)
|
||||
{}
|
||||
void append(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf) {
|
||||
// @todo verify order
|
||||
placement_->components() = placement_->ccomponents() * trsf->ccomponents();
|
||||
}
|
||||
void prepend(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf) {
|
||||
// @todo verify order
|
||||
placement_->components() = trsf->ccomponents() * placement_->ccomponents();
|
||||
}
|
||||
void append(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf);
|
||||
void prepend(ifcopenshell::geometry::taxonomy::matrix4::ptr trsf);
|
||||
std::shared_ptr<ConversionResultShape> Shape() const { return shape_; }
|
||||
ifcopenshell::geometry::taxonomy::matrix4::ptr Placement() const { return placement_; }
|
||||
bool hasStyle() const { return !!style_; }
|
||||
|
||||
@@ -185,9 +185,9 @@ namespace IfcGeom {
|
||||
tasks_.push_back(res);
|
||||
}
|
||||
|
||||
std::vector<IfcUtil::IfcBaseClass*> products;
|
||||
for (auto& r : reps) {
|
||||
std::copy(r.products->begin(), r.products->end(), std::back_inserter(products));
|
||||
size_t num_products = 0;
|
||||
for (auto& r : tasks_) {
|
||||
num_products += r.products.size();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -220,7 +220,7 @@ namespace IfcGeom {
|
||||
}
|
||||
*/
|
||||
|
||||
Logger::Notice("Created " + boost::lexical_cast<std::string>(tasks_.size()) + " tasks for " + boost::lexical_cast<std::string>(products.size()) + " products");
|
||||
Logger::Notice("Created " + boost::lexical_cast<std::string>(tasks_.size()) + " tasks for " + boost::lexical_cast<std::string>(num_products) + " products");
|
||||
|
||||
if (tasks_.size() == 0) {
|
||||
Logger::Warning("No representations encountered, aborting");
|
||||
|
||||
@@ -18,6 +18,12 @@ using ifcopenshell::geometry::NumberEpeck;
|
||||
#define NumberType NumberEpeck
|
||||
#endif
|
||||
|
||||
ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t & shape) {
|
||||
shape_ = shape;
|
||||
CGAL::Polygon_mesh_processing::triangulate_faces(*shape_);
|
||||
CGAL::Polygon_mesh_processing::remove_degenerate_faces(*shape_);
|
||||
}
|
||||
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
void ifcopenshell::geometry::CgalShape::to_poly() const {
|
||||
if (!shape_) {
|
||||
@@ -259,12 +265,62 @@ std::shared_ptr<OpaqueNumber> ifcopenshell::geometry::CgalShape::volume()
|
||||
|
||||
OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::position()
|
||||
{
|
||||
throw std::runtime_error("Invalid shape type");
|
||||
to_poly();
|
||||
if (shape_->size_of_facets() == 1) {
|
||||
// return centroid;
|
||||
// CGAL::Vector_3<Kernel_> p;
|
||||
std::array<Kernel_::FT, 3> p;
|
||||
for (auto it = shape_->points_begin(); it != shape_->points_end(); ++it) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
p[i] += it->cartesian(i);
|
||||
}
|
||||
}
|
||||
Kernel_::FT N(std::distance(shape_->points_begin(), shape_->points_end()));
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
p[i] /= N;
|
||||
}
|
||||
return OpaqueCoordinate<3>(
|
||||
std::make_shared<NumberType>(p[0]),
|
||||
std::make_shared<NumberType>(p[1]),
|
||||
std::make_shared<NumberType>(p[2])
|
||||
);
|
||||
} else {
|
||||
throw std::runtime_error("Invalid shape type");
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct Plane_equation {
|
||||
template <class Facet>
|
||||
typename Facet::Plane_3 operator()(Facet& f) {
|
||||
// @todo from the docs, but better use Newell's method
|
||||
typename Facet::Halfedge_handle h = f.halfedge();
|
||||
typedef typename Facet::Plane_3 Plane;
|
||||
return Plane(h->vertex()->point(),
|
||||
h->next()->vertex()->point(),
|
||||
h->next()->next()->vertex()->point());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::axis()
|
||||
{
|
||||
throw std::runtime_error("Invalid shape type");
|
||||
to_poly();
|
||||
if (shape_->size_of_facets() == 1) {
|
||||
auto pl = Plane_equation()(*shape_->facets_begin());
|
||||
std::array<typename Kernel_::FT, 3> abc{ pl.a(), pl.b(), pl.c() };
|
||||
auto minel = std::min_element(abc.begin(), abc.end());
|
||||
auto maxel = std::max_element(abc.begin(), abc.end());
|
||||
auto maxval = ((-*minel) > *maxel) ? (-*minel) : *maxel;
|
||||
|
||||
return OpaqueCoordinate<3>(
|
||||
std::make_shared<NumberType>(pl.a() / maxval),
|
||||
std::make_shared<NumberType>(pl.b() / maxval),
|
||||
std::make_shared<NumberType>(pl.c() / maxval)
|
||||
);
|
||||
} else {
|
||||
throw std::runtime_error("Invalid shape type");
|
||||
}
|
||||
}
|
||||
|
||||
OpaqueCoordinate<4> ifcopenshell::geometry::CgalShape::plane_equation()
|
||||
@@ -324,7 +380,24 @@ std::vector<ConversionResultShape*> ifcopenshell::geometry::CgalShape::edges()
|
||||
|
||||
std::vector<ConversionResultShape*> ifcopenshell::geometry::CgalShape::facets()
|
||||
{
|
||||
throw std::runtime_error("Not implemented");
|
||||
to_poly();
|
||||
std::vector<ConversionResultShape*> result;
|
||||
for (auto &face : faces(*shape_)) {
|
||||
std::vector<cgal_point_t> ps;
|
||||
std::vector<std::vector<size_t>> ids(1);
|
||||
|
||||
auto it = face->facet_begin();
|
||||
do {
|
||||
ps.push_back(it->vertex()->point());
|
||||
ids.front().push_back(ids.front().size());
|
||||
} while (++it != face->facet_begin());
|
||||
|
||||
cgal_shape_t poly;
|
||||
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(ps, ids, poly);
|
||||
|
||||
result.push_back(new CgalShape(poly));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ConversionResultShape* ifcopenshell::geometry::CgalShape::add(ConversionResultShape* other)
|
||||
@@ -453,10 +526,14 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::pos
|
||||
OpaqueCoordinate<3> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::axis()
|
||||
{
|
||||
if (planes_.size() == 1) {
|
||||
std::array<typename Kernel_::FT, 3> abc{ planes_.front().a(), planes_.front().b(), planes_.front().c() };
|
||||
auto minel = std::min_element(abc.begin(), abc.end());
|
||||
auto maxel = std::max_element(abc.begin(), abc.end());
|
||||
auto maxval = ((-*minel) > *maxel) ? (-*minel) : *maxel;
|
||||
return OpaqueCoordinate<3>(
|
||||
std::make_shared<NumberType>(planes_.front().a()),
|
||||
std::make_shared<NumberType>(planes_.front().b()),
|
||||
std::make_shared<NumberType>(planes_.front().c())
|
||||
std::make_shared<NumberType>(planes_.front().a() / maxval),
|
||||
std::make_shared<NumberType>(planes_.front().b() / maxval),
|
||||
std::make_shared<NumberType>(planes_.front().c() / maxval)
|
||||
);
|
||||
} else {
|
||||
throw std::runtime_error("Invalid shape type");
|
||||
@@ -466,11 +543,15 @@ OpaqueCoordinate<3> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::axi
|
||||
OpaqueCoordinate<4> ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::plane_equation()
|
||||
{
|
||||
if (planes_.size() == 1) {
|
||||
std::array<typename Kernel_::FT, 3> abc{ planes_.front().a(), planes_.front().b(), planes_.front().c() };
|
||||
auto minel = std::min_element(abc.begin(), abc.end());
|
||||
auto maxel = std::max_element(abc.begin(), abc.end());
|
||||
auto maxval = ((-*minel) > *maxel) ? (-*minel) : *maxel;
|
||||
return OpaqueCoordinate<4>(
|
||||
std::make_shared<NumberType>(planes_.front().a()),
|
||||
std::make_shared<NumberType>(planes_.front().b()),
|
||||
std::make_shared<NumberType>(planes_.front().c()),
|
||||
std::make_shared<NumberType>(planes_.front().d())
|
||||
std::make_shared<NumberType>(planes_.front().a() / maxval),
|
||||
std::make_shared<NumberType>(planes_.front().b() / maxval),
|
||||
std::make_shared<NumberType>(planes_.front().c() / maxval),
|
||||
std::make_shared<NumberType>(planes_.front().d() / maxval)
|
||||
);
|
||||
} else {
|
||||
throw std::runtime_error("Invalid shape type");
|
||||
|
||||
@@ -171,9 +171,7 @@ namespace ifcopenshell { namespace geometry {
|
||||
mutable boost::optional<CGAL::Nef_polyhedron_3<Kernel_>> nef_;
|
||||
#endif
|
||||
public:
|
||||
CgalShape(const cgal_shape_t& shape) {
|
||||
shape_ = shape;
|
||||
}
|
||||
CgalShape(const cgal_shape_t& shape);
|
||||
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
CgalShape(const CGAL::Nef_polyhedron_3<Kernel_>& shape) {
|
||||
|
||||
@@ -631,6 +631,17 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
||||
%template(OpaqueCoordinate_3) IfcGeom::OpaqueCoordinate<3>;
|
||||
%template(OpaqueCoordinate_4) IfcGeom::OpaqueCoordinate<4>;
|
||||
|
||||
%{
|
||||
#include "../ifcgeom/kernels/cgal/CgalConversionResult.h"
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
std::shared_ptr<IfcGeom::OpaqueNumber> create_epeck(int i) {
|
||||
return std::make_shared<ifcopenshell::geometry::NumberEpeck>(i);
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
%naturalvar svgfill::polygon_2::boundary;
|
||||
%naturalvar svgfill::polygon_2::inner_boundaries;
|
||||
%naturalvar svgfill::polygon_2::point_inside;
|
||||
|
||||
Reference in New Issue
Block a user