BrunoLevy / geogram

a programming library with geometric algorithms
Other
1.8k stars 122 forks source link

is there a way to offset/inflate a mesh ? #119

Closed kasunJKD closed 9 months ago

BrunoLevy commented 9 months ago

Yes: inflate_spot

The code:

#include <geogram/mesh/mesh.h>
#include <geogram/mesh/mesh_geometry.h>
#include <geogram/mesh/mesh_surface_intersection.h>

....
       Mesh* mesh = ...;
        compute_normals(*mesh);
        vector<vec3> N(mesh->vertices.nb());
        for(index_t v: mesh->vertices) {
            N[v] = howmuch * normalize(
                Geom::mesh_vertex_normal(*mesh, v)
            );
        }
        for(index_t v: mesh->vertices) {
            double* p = mesh->vertices.point_ptr(v);
            p[0] += N[v].x;
            p[1] += N[v].y;
            p[2] += N[v].z;
        }
        mesh->update();
        MeshSurfaceIntersection I(*mesh);
        I.set_radial_sort(true);
        I.intersect();
        I.remove_internal_shells();
kasunJKD commented 9 months ago

Thank you so much