Skip to content

Commit

Permalink
Remove fast-csg (openscad#5529)
Browse files Browse the repository at this point in the history
  • Loading branch information
kintel authored Dec 24, 2024
1 parent 5ab27e0 commit 481186b
Show file tree
Hide file tree
Showing 39 changed files with 6 additions and 2,003 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -935,13 +935,9 @@ endif()
set(CGAL_SOURCES
src/geometry/cgal/cgalutils.cc
src/geometry/cgal/cgalutils-applyops.cc
src/geometry/cgal/cgalutils-applyops-hybrid.cc
src/geometry/cgal/cgalutils-applyops-hybrid-minkowski.cc
src/geometry/cgal/cgalutils-closed.cc
src/geometry/cgal/cgalutils-convex.cc
src/geometry/cgal/cgalutils-corefine.cc
src/geometry/cgal/cgalutils-kernel.cc
src/geometry/cgal/cgalutils-hybrid.cc
src/geometry/cgal/cgalutils-mesh.cc
src/geometry/cgal/cgalutils-minkowski.cc
src/geometry/cgal/cgalutils-nef.cc
Expand All @@ -950,7 +946,6 @@ set(CGAL_SOURCES
src/geometry/cgal/cgalutils-project.cc
src/geometry/cgal/cgalutils-tess.cc
src/geometry/cgal/cgalutils-triangulate.cc
src/geometry/cgal/CGALHybridPolyhedron.cc
src/geometry/cgal/CGAL_Nef_polyhedron.cc
src/geometry/cgal/CGALCache.cc
src/io/export_nef.cc
Expand Down
3 changes: 0 additions & 3 deletions src/Feature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ Feature::list_t Feature::feature_list; // Double-listed values. --^
* (well-defined) order of object construction, matching the order of the
* const Features listed below.
*/
const Feature Feature::ExperimentalFastCsg("fast-csg", "Enable much faster CSG operations with corefinement instead of nef when possible.", /*hidden=*/true);
const Feature Feature::ExperimentalFastCsgSafer("fast-csg-safer", "Don't use corefinement in cases it doesn't supports and risks crashing. This will fallback to slower operations on Nef polyhedra.", /*hidden=*/true);
const Feature Feature::ExperimentalFastCsgDebug("fast-csg-debug", "Debug mode for fast-csg: adds logs with extra costly checks and dumps .off files with the last corefinement operands.", /*hidden=*/true);
const Feature Feature::ExperimentalRoof("roof", "Enable <code>roof</code>");
const Feature Feature::ExperimentalInputDriverDBus("input-driver-dbus", "Enable DBus input drivers (requires restart)");
const Feature Feature::ExperimentalLazyUnion("lazy-union", "Enable lazy unions.");
Expand Down
3 changes: 0 additions & 3 deletions src/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class Feature
using list_t = std::vector<Feature *>;
using iterator = list_t::iterator;

static const Feature ExperimentalFastCsg;
static const Feature ExperimentalFastCsgSafer;
static const Feature ExperimentalFastCsgDebug;
static const Feature ExperimentalRoof;
static const Feature ExperimentalInputDriverDBus;
static const Feature ExperimentalLazyUnion;
Expand Down
29 changes: 0 additions & 29 deletions src/RenderStatistic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "geometry/Polygon2d.h"
#ifdef ENABLE_CGAL
#include "geometry/cgal/CGAL_Nef_polyhedron.h"
#include "geometry/cgal/CGALHybridPolyhedron.h"
#include "geometry/cgal/CGALCache.h"
#endif // ENABLE_CGAL

Expand Down Expand Up @@ -83,7 +82,6 @@ struct LogVisitor : public StatisticVisitor
void visit(const Polygon2d& node) override;
#ifdef ENABLE_CGAL
void visit(const CGAL_Nef_polyhedron& node) override;
void visit(const CGALHybridPolyhedron& node) override;
#endif // ENABLE_CGAL
#ifdef ENABLE_MANIFOLD
void visit(const ManifoldGeometry& node) override;
Expand All @@ -108,7 +106,6 @@ struct StreamVisitor : public StatisticVisitor
void visit(const Polygon2d& node) override;
#ifdef ENABLE_CGAL
void visit(const CGAL_Nef_polyhedron& node) override;
void visit(const CGALHybridPolyhedron& node) override;
#endif // ENABLE_CGAL
#ifdef ENABLE_MANIFOLD
void visit(const ManifoldGeometry& node) override;
Expand Down Expand Up @@ -279,18 +276,6 @@ void LogVisitor::visit(const CGAL_Nef_polyhedron& nef)
printBoundingBox3(nef.getBoundingBox());
}
}
void LogVisitor::visit(const CGALHybridPolyhedron& poly)
{
bool simple = poly.isManifold();
LOG(" Top level object is a 3D object (fast-csg):");
LOG(" Simple: %1$s", (simple ? "yes" : "no"));
LOG(" Vertices: %1$6d", poly.numVertices());
LOG(" Facets: %1$6d", poly.numFacets());
if (!simple) {
LOG(message_group::UI_Warning, "Object may not be a valid 2-manifold and may need repair!");
}
printBoundingBox3(poly.getBoundingBox());
}
#endif // ENABLE_CGAL

#ifdef ENABLE_MANIFOLD
Expand Down Expand Up @@ -392,20 +377,6 @@ void StreamVisitor::visit(const CGAL_Nef_polyhedron& nef)
json["geometry"] = geometryJson;
}
}
void StreamVisitor::visit(const CGALHybridPolyhedron& poly)
{
if (is_enabled(RenderStatistic::GEOMETRY)) {
nlohmann::json geometryJson;
geometryJson["dimensions"] = 3;
geometryJson["simple"] = poly.isManifold();
geometryJson["vertices"] = poly.numVertices();
geometryJson["facets"] = poly.numFacets();
if (is_enabled(RenderStatistic::BOUNDING_BOX)) {
geometryJson["bounding_box"] = getBoundingBox3(poly);
}
json["geometry"] = geometryJson;
}
}
#endif // ENABLE_CGAL

#ifdef ENABLE_MANIFOLD
Expand Down
2 changes: 0 additions & 2 deletions src/geometry/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class AbstractNode;
class CGAL_Nef_polyhedron;
class CGALHybridPolyhedron;
class GeometryList;
class GeometryVisitor;
class Polygon2d;
Expand Down Expand Up @@ -65,7 +64,6 @@ class GeometryVisitor
virtual void visit(const Polygon2d& node) = 0;
#ifdef ENABLE_CGAL
virtual void visit(const CGAL_Nef_polyhedron& node) = 0;
virtual void visit(const CGALHybridPolyhedron& node) = 0;
#endif
#ifdef ENABLE_MANIFOLD
virtual void visit(const ManifoldGeometry& node) = 0;
Expand Down
10 changes: 1 addition & 9 deletions src/geometry/GeometryEvaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "geometry/boolean_utils.h"
#ifdef ENABLE_CGAL
#include "geometry/cgal/CGALCache.h"
#include "geometry/cgal/CGALHybridPolyhedron.h"
#include "geometry/cgal/cgalutils.h"
#include <CGAL/convex_hull_2.h>
#include <CGAL/Point_2.h>
Expand All @@ -63,7 +62,7 @@ GeometryEvaluator::GeometryEvaluator(const Tree& tree) : tree(tree) { }
There are some guarantees on the returned geometry:
* 2D and 3D geometry cannot be mixed; we will return either _only_ 2D or _only_ 3D geometries
* PolySet geometries are always 3D. 2D Polysets are only created for special-purpose rendering operations downstream from here.
* Needs validation: Implementation-specific geometries shouldn't be mixed (Nef polyhedron, Manifold, CGAL Hybrid polyhedrons)
* Needs validation: Implementation-specific geometries shouldn't be mixed (Nef polyhedron, Manifold)
*/
std::shared_ptr<const Geometry> GeometryEvaluator::evaluateGeometry(const AbstractNode& node,
bool allownef)
Expand Down Expand Up @@ -169,9 +168,6 @@ GeometryEvaluator::ResultObject GeometryEvaluator::applyToChildren3D(const Abstr
}
#endif
#ifdef ENABLE_CGAL
else if (Feature::ExperimentalFastCsg.is_enabled()) {
return ResultObject::mutableResult(std::shared_ptr<Geometry>(CGALUtils::applyUnion3DHybrid(actualchildren.begin(), actualchildren.end())));
}
return ResultObject::constResult(std::shared_ptr<const Geometry>(CGALUtils::applyUnion3D(actualchildren.begin(), actualchildren.end())));
#else
assert(false && "No boolean backend available");
Expand All @@ -186,10 +182,6 @@ GeometryEvaluator::ResultObject GeometryEvaluator::applyToChildren3D(const Abstr
}
#endif
#ifdef ENABLE_CGAL
if (Feature::ExperimentalFastCsg.is_enabled()) {
// FIXME: It's annoying to have to disambiguate here:
return ResultObject::mutableResult(std::shared_ptr<Geometry>(CGALUtils::applyOperator3DHybrid(children, op)));
}
return ResultObject::constResult(CGALUtils::applyOperator3D(children, op));
#else
assert(false && "No boolean backend available");
Expand Down
21 changes: 5 additions & 16 deletions src/geometry/GeometryUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#ifdef ENABLE_CGAL
#include "geometry/cgal/cgalutils.h"
#include "geometry/cgal/CGALHybridPolyhedron.h"
#endif

#ifdef ENABLE_MANIFOLD
Expand Down Expand Up @@ -536,22 +535,12 @@ std::shared_ptr<const Geometry> GeometryUtils::getBackendSpecificGeometry(const
}
#endif
#if ENABLE_CGAL
if (Feature::ExperimentalFastCsg.is_enabled()) {
if (auto ps = std::dynamic_pointer_cast<const PolySet>(geom)) {
return CGALUtils::createHybridPolyhedronFromPolySet(*ps);
} else if (auto poly = std::dynamic_pointer_cast<const CGALHybridPolyhedron>(geom)) {
return geom;
} else {
assert(false && "Unexpected geometry");
}
if (auto ps = std::dynamic_pointer_cast<const PolySet>(geom)) {
return CGALUtils::createNefPolyhedronFromPolySet(*ps);
} else if (auto poly = std::dynamic_pointer_cast<const CGAL_Nef_polyhedron>(geom)) {
return geom;
} else {
if (auto ps = std::dynamic_pointer_cast<const PolySet>(geom)) {
return CGALUtils::createNefPolyhedronFromPolySet(*ps);
} else if (auto poly = std::dynamic_pointer_cast<const CGAL_Nef_polyhedron>(geom)) {
return geom;
} else {
assert(false && "Unexpected geometry");
}
assert(false && "Unexpected geometry");
}
#endif
return nullptr;
Expand Down
4 changes: 0 additions & 4 deletions src/geometry/PolySetBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#ifdef ENABLE_CGAL
#include "geometry/cgal/cgalutils.h"
#include "geometry/cgal/CGAL_Nef_polyhedron.h"
#include "geometry/cgal/CGALHybridPolyhedron.h"
#endif
#ifdef ENABLE_MANIFOLD
#include "geometry/manifold/ManifoldGeometry.h"
Expand Down Expand Up @@ -89,9 +88,6 @@ void PolySetBuilder::appendGeometry(const std::shared_ptr<const Geometry>& geom)
else {
LOG(message_group::Error, "Nef->PolySet failed");
}
} else if (const auto hybrid = std::dynamic_pointer_cast<const CGALHybridPolyhedron>(geom)) {
// TODO(ochafik): Implement appendGeometry(Surface_mesh) instead of converting to PolySet
appendPolySet(*hybrid->toPolySet());
#endif // ifdef ENABLE_CGAL
#ifdef ENABLE_MANIFOLD
} else if (const auto mani = std::dynamic_pointer_cast<const ManifoldGeometry>(geom)) {
Expand Down
4 changes: 0 additions & 4 deletions src/geometry/PolySetUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "geometry/GeometryUtils.h"
#ifdef ENABLE_CGAL
#include "geometry/cgal/cgalutils.h"
#include "geometry/cgal/CGALHybridPolyhedron.h"
#endif
#ifdef ENABLE_MANIFOLD
#include "geometry/manifold/ManifoldGeometry.h"
Expand Down Expand Up @@ -194,9 +193,6 @@ std::shared_ptr<const PolySet> getGeometryAsPolySet(const std::shared_ptr<const
}
return PolySet::createEmpty();
}
if (auto hybrid = std::dynamic_pointer_cast<const CGALHybridPolyhedron>(geom)) {
return hybrid->toPolySet();
}
#endif
#ifdef ENABLE_MANIFOLD
if (auto mani = std::dynamic_pointer_cast<const ManifoldGeometry>(geom)) {
Expand Down
10 changes: 0 additions & 10 deletions src/geometry/boolean_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#ifdef ENABLE_CGAL
#include "geometry/cgal/cgal.h"
#include "geometry/cgal/CGALHybridPolyhedron.h"
#include "geometry/cgal/CGAL_Nef_polyhedron.h"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/normal_vector_newell_3.h>
Expand Down Expand Up @@ -60,12 +59,6 @@ std::unique_ptr<PolySet> applyHull(const Geometry::Geometries& children)
addPoint(CGALUtils::vector_convert<K::Point_3>(i->point()));
}
}
} else if (const auto *hybrid = dynamic_cast<const CGALHybridPolyhedron*>(chgeom.get())) {
addCapacity(hybrid->numVertices());
hybrid->foreachVertexUntilTrue([&](auto& p) {
addPoint(CGALUtils::vector_convert<K::Point_3>(p));
return false;
});
#endif // ENABLE_CGAL
#ifdef ENABLE_MANIFOLD
} else if (const auto *mani = dynamic_cast<const ManifoldGeometry*>(chgeom.get())) {
Expand Down Expand Up @@ -119,9 +112,6 @@ std::shared_ptr<const Geometry> applyMinkowski(const Geometry::Geometries& child
return ManifoldUtils::applyMinkowskiManifold(children);
}
#endif // ENABLE_MANIFOLD
if (Feature::ExperimentalFastCsg.is_enabled()) {
return CGALUtils::applyMinkowskiHybrid(children);
}
CGAL::Timer t, t_tot;
assert(children.size() >= 2);
auto it = children.begin();
Expand Down
2 changes: 0 additions & 2 deletions src/geometry/cgal/CGALCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "utils/printutils.h"
#include "geometry/cgal/CGAL_Nef_polyhedron.h"
#include "geometry/cgal/CGALHybridPolyhedron.h"
#ifdef ENABLE_MANIFOLD
#include "geometry/manifold/ManifoldGeometry.h"
#endif
Expand All @@ -29,7 +28,6 @@ std::shared_ptr<const Geometry> CGALCache::get(const std::string& id) const

bool CGALCache::acceptsGeometry(const std::shared_ptr<const Geometry>& geom) {
return
std::dynamic_pointer_cast<const CGALHybridPolyhedron>(geom) ||
std::dynamic_pointer_cast<const CGAL_Nef_polyhedron>(geom)
#ifdef ENABLE_MANIFOLD
|| std::dynamic_pointer_cast<const ManifoldGeometry>(geom)
Expand Down
Loading

0 comments on commit 481186b

Please sign in to comment.