Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2410700
Testing | Test for collapsing points with inner dented contour
carlosgonzalez-elemwave Nov 11, 2025
28659e0
Tessellator | Implement Splicer
carlosgonzalez-elemwave Nov 12, 2025
190e777
Tessellator | Implement method to remove null area triangles
carlosgonzalez-elemwave Nov 17, 2025
a22ecac
Tessellator | Transform RedundancyCleaner into a namespace
carlosgonzalez-elemwave Nov 18, 2025
173f6c7
WIP | DRAFT | Checking overlapped triangles in conformal
carlosgonzalez-elemwave Nov 20, 2025
4dd5420
WIP | DRAFT | fixing wrong orientation in selective staircaser
carlosgonzalez-elemwave Nov 20, 2025
49d23ee
Fix triangle orientation check in splitLinesWithNeighborTriangle
ashybabashyba Nov 21, 2025
d64f024
WIP | DRAFT | fixing wrong orientation in selective staircaser
carlosgonzalez-elemwave Nov 21, 2025
dcbb720
WIP | DRAFT | fixing errors in original selective staircasing
carlosgonzalez-elemwave Nov 24, 2025
24242e3
WIP | DRAFT | Adding tests for selective staircasing overlapped
carlosgonzalez-elemwave Nov 26, 2025
6a50619
WIP | DRAFT | tests for selective staircasing with overlapping
carlosgonzalez-elemwave Nov 27, 2025
b7e5409
Core | Make delaunator without cgal
carlosgonzalez-elemwave Dec 15, 2025
85baff3
WIP | DRAFT | Use delaunator in smoother
carlosgonzalez-elemwave Dec 15, 2025
c6b8afa
WIP | DRAFT | Use delaunator in smoother
carlosgonzalez-elemwave Dec 16, 2025
819e776
WIP | DRAFT | Use delaunator in smoother
carlosgonzalez-elemwave Dec 17, 2025
9b23db4
WIP | DRAFT | Fix delaunator repeated vertex issue
carlosgonzalez-elemwave Dec 19, 2025
23fe6d1
WIP | DRAFT | Use delaunator in smoother
carlosgonzalez-elemwave Jan 12, 2026
a05bb1c
WIP | DRAFT | Use delaunator in smoother
carlosgonzalez-elemwave Jan 13, 2026
9b08248
WIP | DRAFT | Fix bug mistaking a parallel plane for a face while com…
carlosgonzalez-elemwave Jan 14, 2026
d033e40
WIP | DRAFT | Use delaunator in smoother
carlosgonzalez-elemwave Jan 14, 2026
77081e5
WIP | DRAFT | Fix bug mistaking a parallel plane for a face while com…
carlosgonzalez-elemwave Jan 15, 2026
6b8b0c3
WIP | DRAFT | Slice without collapsing
carlosgonzalez-elemwave Jan 19, 2026
cd60b77
WIP | DRAFT | Allow delaunating of non-planar points
carlosgonzalez-elemwave Jan 19, 2026
f041918
WIP | DRAFT | Calculate getLSFPlaneNormal
carlosgonzalez-elemwave Jan 19, 2026
d02db6d
GridTools | Make CellElem map that only maps elements to one cell
carlosgonzalez-elemwave Jan 22, 2026
131a678
get LSFPlane Normal
carlosgonzalez-elemwave Jan 23, 2026
a07e186
WIP | DRAFT | Update edge calculation to include degenerate elements
carlosgonzalez-elemwave Jan 23, 2026
e09e398
WIP | DRAFT | debugging code
carlosgonzalez-elemwave Jan 23, 2026
f58baab
WIP | DRAFT | Readjust angles after initial sweep
carlosgonzalez-elemwave Jan 28, 2026
57d1d2a
WIP | DRAFT | Fix wrong orientation
carlosgonzalez-elemwave Jan 29, 2026
04de6ef
WIP | DRAFT | Redefine corner ids
carlosgonzalez-elemwave Feb 17, 2026
068f3da
WIP | DRAFT | Improving corner ids
carlosgonzalez-elemwave Mar 9, 2026
7ccf060
Fixes issue with slashes in include
lmdiazangulo May 19, 2026
fa3767b
Fix cone test failure caused by buildCellElemMapLax in buildSingularIds
lmdiazangulo May 19, 2026
976666f
Fix failing unit tests by restoring slicer pre-collapse and smoother …
lmdiazangulo May 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ This code and its copyright is property of to the University of Granada (UGR), C

testData/cervezas_alhambra logo has been downloaded from https://cults3d.com/es/modelo-3d/arte/celosia-alhambra-logo-cervezas-alhambra where is available with license CC BY-NC-SA.

Third party library CDT has been used as an external library. Its source code can be found in https://github.com/artem-ogre/CDT, licensed under the MPL-2.0 license.

## Funding

- Spanish Ministry of Science and Innovation (MICIN/AEI) (Grant Number: PID2022-137495OB-C31)
Expand Down
2 changes: 1 addition & 1 deletion src/cgal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
message(STATUS "Creating build system for tessellator-cgal")

add_library(tessellator-cgal
"Delaunator.cpp"
"DelaunatorCGAL.cpp"
"HPolygonSet.cpp"
"Manifolder.cpp"
"PolyhedronTools.cpp"
Expand Down
38 changes: 19 additions & 19 deletions src/cgal/Delaunator.cpp → src/cgal/DelaunatorCGAL.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "Delaunator.h"
#include "DelaunatorCGAL.h"
#include "utils/Geometry.h"
#include "LSFPlane.h"

namespace meshlib::cgal {

using namespace utils;

const double Delaunator::COPLANARITY_ANGLE_TOLERANCE = 0.1;
const double DelaunatorCGAL::COPLANARITY_ANGLE_TOLERANCE = 0.1;

Delaunator::Delaunator(const Coordinates* global, const ElementsView& elements)
DelaunatorCGAL::DelaunatorCGAL(const Coordinates* global, const ElementsView& elements)
{
if (global == nullptr) {
throw std::runtime_error("Global list of coordinates must be defined");
Expand All @@ -20,18 +20,18 @@ Delaunator::Delaunator(const Coordinates* global, const ElementsView& elements)
}
}

std::vector<Element> Delaunator::mesh(
std::vector<Element> DelaunatorCGAL::mesh(
const IdSet& inIds,
const std::vector<Polygon>& constrainingPolygons) const
{
auto ids = filterIdsByConstraints(inIds, constrainingPolygons);
checkIdsAreInRange(ids, constrainingPolygons);
const IndexPointToId pointToId = buildPointsInIndex(ids, constrainingPolygons);
CDT cdt = buildCDT(pointToId, ids, constrainingPolygons);
Triangulation cdt = buildCDT(pointToId, ids, constrainingPolygons);
return convertFromCDT(cdt, pointToId);
}

void Delaunator::checkIdsAreInRange(
void DelaunatorCGAL::checkIdsAreInRange(
const IdSet& inIds,
const std::vector<Polygon>& constrainingPolygons) const
{
Expand All @@ -53,8 +53,8 @@ void Delaunator::checkIdsAreInRange(
}
}

std::vector<Element> Delaunator::convertFromCDT(
const CDT& cdt, const IndexPointToId& pointToId) const
std::vector<Element> DelaunatorCGAL::convertFromCDT(
const Triangulation& cdt, const IndexPointToId& pointToId) const
{
for (auto v : cdt.finite_vertex_handles()) {
if (pointToId.left.count(v->point()) == 0) {
Expand All @@ -79,12 +79,12 @@ std::vector<Element> Delaunator::convertFromCDT(
return res;
}

Delaunator::CDT Delaunator::buildCDT(
DelaunatorCGAL::Triangulation DelaunatorCGAL::buildCDT(
const IndexPointToId& pointToId,
const IdSet& inIds,
const Polygons& constrainingPolygons)
{
CDT cdt;
Triangulation cdt;
for (auto const& polygon : constrainingPolygons) {
Polygon_2 cgalPoly;
for (auto const& id : polygon) {
Expand All @@ -101,7 +101,7 @@ Delaunator::CDT Delaunator::buildCDT(
return cdt;
}

void Delaunator::mark_domains(CDT& ct, Face_handle start, int index, std::list<CDT::Edge>& border)
void DelaunatorCGAL::mark_domains(Triangulation& ct, Face_handle start, int index, std::list<Triangulation::Edge>& border)
{
if (start->info().nesting_level != -1) {
return;
Expand All @@ -114,7 +114,7 @@ void Delaunator::mark_domains(CDT& ct, Face_handle start, int index, std::list<C
if (fh->info().nesting_level == -1) {
fh->info().nesting_level = index;
for (int i = 0; i < 3; i++) {
CDT::Edge e(fh, i);
Triangulation::Edge e(fh, i);
Face_handle n = fh->neighbor(i);
if (n->info().nesting_level == -1) {
if (ct.is_constrained(e)) border.push_back(e);
Expand All @@ -125,7 +125,7 @@ void Delaunator::mark_domains(CDT& ct, Face_handle start, int index, std::list<C
}
}

IdSet Delaunator::filterIdsByConstraints(
IdSet DelaunatorCGAL::filterIdsByConstraints(
const IdSet& ids, const Polygons& polys)
{
IdSet res = ids;
Expand All @@ -138,15 +138,15 @@ IdSet Delaunator::filterIdsByConstraints(
}


void Delaunator::mark_domains(CDT& cdt)
void DelaunatorCGAL::mark_domains(Triangulation& cdt)
{
for (CDT::Face_handle f : cdt.all_face_handles()) {
for (Triangulation::Face_handle f : cdt.all_face_handles()) {
f->info().nesting_level = -1;
}
std::list<CDT::Edge> border;
std::list<Triangulation::Edge> border;
mark_domains(cdt, cdt.infinite_face(), 0, border);
while (!border.empty()) {
CDT::Edge e = border.front();
Triangulation::Edge e = border.front();
border.pop_front();
Face_handle n = e.first->neighbor(e.second);
if (n->info().nesting_level == -1) {
Expand All @@ -155,7 +155,7 @@ void Delaunator::mark_domains(CDT& cdt)
}
}

Delaunator::IndexPointToId Delaunator::buildPointsInIndex(
DelaunatorCGAL::IndexPointToId DelaunatorCGAL::buildPointsInIndex(
const IdSet& inIds,
const Polygons& constrainingPolygons) const
{
Expand Down Expand Up @@ -189,7 +189,7 @@ Delaunator::IndexPointToId Delaunator::buildPointsInIndex(
IndexPointToId res;
for (std::size_t i = 0; i < cs.size(); i++) {
res.insert( IndexPointToId::value_type(
CDT::Point(cs[i](0), cs[i](1)),
Triangulation::Point(cs[i](0), cs[i](1)),
originalIds[i])
);
}
Expand Down
20 changes: 10 additions & 10 deletions src/cgal/Delaunator.h → src/cgal/DelaunatorCGAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace meshlib {
namespace cgal {


class Delaunator {
class DelaunatorCGAL {
public:
typedef std::vector<CoordinateId> Polygon;
typedef std::vector<Polygon> Polygons;

Delaunator(const Coordinates* globalCoordinates, const ElementsView& elems = ElementsView());
DelaunatorCGAL(const Coordinates* globalCoordinates, const ElementsView& elems = ElementsView());

std::vector<Element> mesh(
const IdSet& vertexIds,
Expand Down Expand Up @@ -48,22 +48,22 @@ class Delaunator {
typedef CGAL::Constrained_triangulation_face_base_2<K, Fbb> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> TDS;
typedef CGAL::Exact_predicates_tag Itag;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, TDS, Itag> CDT;
typedef CDT::Point Point;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, TDS, Itag> Triangulation;
typedef Triangulation::Point Point;
typedef CGAL::Polygon_2<K> Polygon_2;
typedef CDT::Face_handle Face_handle;
typedef Triangulation::Face_handle Face_handle;

typedef boost::bimap<CDT::Point, CoordinateId> IndexPointToId;
typedef boost::bimap<Triangulation::Point, CoordinateId> IndexPointToId;

IndexPointToId buildPointsInIndex(const IdSet& inIds, const Polygons& constraint) const;
static CDT buildCDT(
static Triangulation buildCDT(
const IndexPointToId& pointToId,
const IdSet& inIds,
const Polygons& constrainingPolygons);
std::vector<Element> convertFromCDT(const CDT& cdt, const IndexPointToId& pointToId) const;
std::vector<Element> convertFromCDT(const Triangulation& cdt, const IndexPointToId& pointToId) const;

static void mark_domains(CDT& cdt);
static void mark_domains(CDT& ct, Face_handle start, int index, std::list<CDT::Edge>& border);
static void mark_domains(Triangulation& cdt);
static void mark_domains(Triangulation& ct, Face_handle start, int index, std::list<Triangulation::Edge>& border);
void checkIdsAreInRange(
const IdSet& inIds,
const std::vector<Polygon>& constrainingPolygons) const;
Expand Down
2 changes: 1 addition & 1 deletion src/cgal/Manifolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Mesh Manifolder::getSurfacesMesh() const
{
Mesh m = getClosedSurfacesMesh();
utils::meshTools::mergeMesh(m, getOpenSurfacesMesh());
utils::RedundancyCleaner::cleanCoords(m);
utils::redundancyCleaner::cleanCoords(m);
return m;
}

Expand Down
6 changes: 3 additions & 3 deletions src/cgal/Repairer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ Mesh repair(const Mesh& m)
repairGroup(r.coordinates, r.groups[gId], m.coordinates, g);
}

RedundancyCleaner::fuseCoords(r);
RedundancyCleaner::removeDegenerateElements(r);
RedundancyCleaner::cleanCoords(r);
redundancyCleaner::fuseCoords(r);
redundancyCleaner::removeDegenerateElements(r);
redundancyCleaner::cleanCoords(r);

return r;
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ add_library(tessellator-core
"Smoother.cpp"
"SmootherTools.cpp"
"Staircaser.cpp"
"Splicer.cpp"
"Delaunator.cpp"
)

target_link_libraries(tessellator-core tessellator-utils)
31 changes: 24 additions & 7 deletions src/core/Collapser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
#include "utils/RedundancyCleaner.h"
#include "utils/MeshTools.h"

#include "Collapser.h"

namespace meshlib {
namespace core {

using namespace utils;

Collapser::Collapser(const Mesh& in, int decimalPlaces, const std::vector<Element::Type>& dimensionPolicy)
{

if (dimensionPolicy.size() == 0) {
dimensionPolicy_ = std::vector<Element::Type>(in.groups.size(), Element::Type::Surface);
}
Expand All @@ -21,16 +20,19 @@ Collapser::Collapser(const Mesh& in, int decimalPlaces, const std::vector<Elemen
}

mesh_ = in;

double factor = std::pow(10.0, decimalPlaces);
for (auto& v : mesh_.coordinates) {
v = v.round(factor);
}

RedundancyCleaner::fuseCoords(mesh_);
RedundancyCleaner::cleanCoords(mesh_);
redundancyCleaner::fuseCoords(mesh_);
redundancyCleaner::cleanCoords(mesh_);

collapseDegenerateElements(mesh_, 0.4 / (factor * factor));
RedundancyCleaner::removeOverlappedElementsByDimension(mesh_, dimensionPolicy_);

redundancyCleaner::removeOverlappedElementsByDimension(mesh_, dimensionPolicy_);

utils::meshTools::checkNoNullAreasExist(mesh_);
}

Expand All @@ -54,6 +56,14 @@ void Collapser::collapseDegenerateElements(Mesh& mesh, const double& areaThresho
degeneratedTrianglesFound = true;
Coordinates& coords = mesh.coordinates;
const std::vector<CoordinateId>& v = element.vertices;
/*
bool relevantTriangleFound = true;
for (auto& coordId : v) {
if (coords[v[X]] < 1.0 && coords[v[Y]] > 2.0 && coords[v[Y]] < 3.0) {
relevantTriangleFound = false;
}
}
*/
std::pair<std::size_t, CoordinateId> replace;

std::array<double, 3> sumOfDistances{ 0,0,0 };
Expand All @@ -75,11 +85,18 @@ void Collapser::collapseDegenerateElements(Mesh& mesh, const double& areaThresho
else {
coords[element.vertices[midId]] = coords[element.vertices[(midId + 2) % 3]];
}
/*
for (auto& coordId : v) {
if (coords[v[X]] < 1.0 && coords[v[Y]] > 2.0 && coords[v[Y]] < 3.0) {
bool noop = true;
}
}
*/
}
}

RedundancyCleaner::fuseCoords(mesh);
RedundancyCleaner::cleanCoords(mesh);
redundancyCleaner::fuseCoords(mesh);
redundancyCleaner::cleanCoords(mesh);

for (auto & group : mesh.groups) {
for (auto& element : group.elements) {
Expand Down
Loading
Loading