From 5187ddbfc0f7a6f0caff7caf3690cb19fab851f7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 17 Feb 2024 21:20:24 +0100 Subject: [PATCH] Do not insert the same point twice into edge set in EdgeProcessor - this improves performance in the case of manifold intersecions in one point. Also: added edge count API --- src/db/db/dbEdgeProcessor.cc | 13 +++++++++++++ src/db/db/dbEdgeProcessor.h | 5 +++++ src/db/db/dbShapeProcessor.cc | 6 ++++++ src/db/db/dbShapeProcessor.h | 5 +++++ 4 files changed, 29 insertions(+) diff --git a/src/db/db/dbEdgeProcessor.cc b/src/db/db/dbEdgeProcessor.cc index 9f1c3f11f..4f0534ae8 100644 --- a/src/db/db/dbEdgeProcessor.cc +++ b/src/db/db/dbEdgeProcessor.cc @@ -251,6 +251,13 @@ struct CutPoints } + // do not insert points twice + for (auto c = cut_points.begin (); c != cut_points.end (); ++c) { + if (*c == p) { + return; + } + } + cut_points.push_back (p); } @@ -1057,6 +1064,12 @@ EdgeProcessor::reserve (size_t n) mp_work_edges->reserve (n); } +size_t +EdgeProcessor::count () const +{ + return mp_work_edges->size (); +} + void EdgeProcessor::insert (const db::Edge &e, EdgeProcessor::property_type p) { diff --git a/src/db/db/dbEdgeProcessor.h b/src/db/db/dbEdgeProcessor.h index a6fb2a680..30de5b35d 100644 --- a/src/db/db/dbEdgeProcessor.h +++ b/src/db/db/dbEdgeProcessor.h @@ -695,6 +695,11 @@ public: */ void reserve (size_t n); + /** + * @brief Reports the number of edges stored in the processor + */ + size_t count () const; + /** * @brief Insert an edge */ diff --git a/src/db/db/dbShapeProcessor.cc b/src/db/db/dbShapeProcessor.cc index 518aaa9e7..974fd469b 100644 --- a/src/db/db/dbShapeProcessor.cc +++ b/src/db/db/dbShapeProcessor.cc @@ -53,6 +53,12 @@ ShapeProcessor::reserve (size_t n) m_processor.reserve (n); } +size_t +ShapeProcessor::count () const +{ + return m_processor.count (); +} + void ShapeProcessor::process (db::EdgeSink &es, EdgeEvaluatorBase &op) { diff --git a/src/db/db/dbShapeProcessor.h b/src/db/db/dbShapeProcessor.h index a7afde10c..333c53b69 100644 --- a/src/db/db/dbShapeProcessor.h +++ b/src/db/db/dbShapeProcessor.h @@ -196,6 +196,11 @@ public: */ void reserve (size_t n); + /** + * @brief Reports the number of edges stored in the processor + */ + size_t count () const; + /** * @brief Sets the base verbosity of the processor (see EdgeProcessor::set_base_verbosity for details) */