Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/patr-schm/surface-maps-via-adaptive-triangulations
30 May 2023, 12:10:02 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    No releases to show
  • 3367d82
  • /
  • src
  • /
  • SurfaceMaps
  • /
  • Utils
  • /
  • Helpers.cc
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:70c229f632e678fc8c2f88c8709e99ae372e51c5
origin badgedirectory badge
swh:1:dir:c2f78cca852cb7cbbf962da63e033e1992b1c0f2
origin badgerevision badge
swh:1:rev:da768497f0b8a84088b7f0d839b8b40a1780c672
origin badgesnapshot badge
swh:1:snp:b226c256e24f85cfb68346d404868c5d0bb72cfd

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: da768497f0b8a84088b7f0d839b8b40a1780c672 authored by Patrick Schmidt on 11 May 2023, 16:25:14 UTC
Add grsi-thumbnail.png
Tip revision: da76849
Helpers.cc
/*
 * This file is part of
 * Surface Maps via Adaptive Triangulations
 * (https://github.com/patr-schm/surface-maps-via-adaptive-triangulations)
 * and is released under the MIT license.
 *
 * Authors: Patrick Schmidt, Janis Born
 */

#include "Helpers.hh"

namespace SurfaceMaps
{

Vec3d center_of_gravity(
        const TriMesh& _mesh)
{
    Vec3d cog = Vec3d::Zero();
    for (auto v : _mesh.vertices())
        cog += _mesh.point(v);
    cog /= _mesh.n_vertices();

    return cog;
}

Vec3d center_of_gravity(
        const TriMesh& _mesh,
        const ExternalProperty<VH, Vec3d>& _embedding)
{
    Vec3d cog = Vec3d::Zero();
    for (auto v : _mesh.vertices())
        cog += _embedding[v];
    cog /= _mesh.n_vertices();

    return cog;
}

double total_area(
        const TriMesh &_mesh)
{
    double result = 0.0;
    for (auto fh : _mesh.faces())
        result += _mesh.calc_face_area(fh);

    return result;
}

double total_area(
        const TriMesh& _mesh,
        const ExternalProperty<VH, Vec3d>& _embedding)
{
    double result = 0.0;
    for (auto fh : _mesh.faces())
    {
        VH vh_a, vh_b, vh_c;
        handles(_mesh, fh, vh_a, vh_b, vh_c);
        const Vec3d a = _embedding[vh_a];
        const Vec3d b = _embedding[vh_b];
        const Vec3d c = _embedding[vh_c];

        result += 0.5 * (b-a).cross(c-a).norm();
    }

    return result;
}

ExternalProperty<VH, double> vertex_areas(
        const TriMesh& _mesh)
{
    ExternalProperty<VH, double> areas(_mesh, 0.0);
    for (auto f : _mesh.faces())
    {
        const double area = _mesh.calc_face_area(f);
        for (auto v : f.vertices())
            areas[v] += area / 3.0;
    }

    return areas;
}

ExternalProperty<VH, double> rel_vertex_areas(
        const TriMesh& _mesh)
{
    const double total = total_area(_mesh);

    ExternalProperty<VH, double> areas(_mesh, 0.0);
    for (auto f : _mesh.faces())
    {
        const double area = _mesh.calc_face_area(f);
        for (auto v : f.vertices())
            areas[v] += area / 3.0 / total;
    }

    return areas;
}

std::pair<Vec3d, Vec3d> bounding_box(
        const TriMesh& _mesh)
{
    Vec3d pmin(+INF_DOUBLE, +INF_DOUBLE, +INF_DOUBLE);
    Vec3d pmax(-INF_DOUBLE, -INF_DOUBLE, -INF_DOUBLE);
    for (const auto& vh : _mesh.vertices())
    {
        const Vec3d& p = _mesh.point(vh);
        pmin = pmin.cwiseMin(p);
        pmax = pmax.cwiseMax(p);
    }
    return {pmin, pmax};
}

double bounding_box_diagonal(
        const TriMesh& _mesh)
{
    const auto [pmin, pmax] = bounding_box(_mesh);
    return (pmax - pmin).norm();
}

bool incident(const TriMesh& _mesh, const VH _vh, const FH _fh)
{
    ISM_ASSERT(_mesh.is_valid_handle(_fh));
    for (const auto& vh : _mesh.fv_range(_fh))
        if (vh == _vh)
            return true;
    return false;
}

VH closest_vertex(
        const TriMesh& _mesh,
        const Vec3d& _p)
{
    double closest_dist = INF_DOUBLE;
    VH closest_vh;
    for (auto v : _mesh.vertices())
    {
        const double dist = (_mesh.point(v) - _p).norm();
        if (dist < closest_dist)
        {
            closest_dist = dist;
            closest_vh = v;
        }
    }

    return closest_vh;
}

void rotate(
        TriMesh& _mesh,
        const double _angle,
        const Vec3d& _axis)
{
     Mat3d R = Eigen::AngleAxis(_angle, _axis.normalized()).matrix();
     for (auto v : _mesh.vertices())
         _mesh.point(v) = R * _mesh.point(v);
}

void rotate(
        const TriMesh& _mesh,
        ExternalProperty<VH, Vec3d>& _embedding,
        const double _angle,
        const Vec3d& _axis)
{
    Mat3d R = Eigen::AngleAxis(_angle, _axis.normalized()).matrix();
    for (auto v : _mesh.vertices())
        _embedding[v] = R * _embedding[v];
}

void translate(
        TriMesh& _mesh,
        const Vec3d& _t)
{
     for (auto v : _mesh.vertices())
         _mesh.point(v) += _t;
}

}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API