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
  • /
  • GarbageCollectionImpl.hh
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:d4cdb3517379ebce3e48382b367c2420f522c0cf
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
GarbageCollectionImpl.hh
/*
 * 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
 */
#pragma once

#include <SurfaceMaps/Utils/GarbageCollection.hh>
#include <SurfaceMaps/Utils/ExternalProperty.hh>

namespace SurfaceMaps
{

template <typename Mesh>
void garbage_collection_with_index_maps(
        Mesh& _mesh,
        std::vector<VH>& _vertex_map,
        std::vector<HEH>& _halfedge_map,
        std::vector<FH>& _face_map)
{
    // Init identity maps
    _vertex_map.resize(_mesh.n_vertices());
    for (int i = 0; i < (int)_vertex_map.size(); ++i)
        _vertex_map[i] = VH(i);
    _halfedge_map.resize(_mesh.n_halfedges());
    for (int i = 0; i < (int)_halfedge_map.size(); ++i)
        _halfedge_map[i] = HEH(i);
    _face_map.resize(_mesh.n_faces());
    for (int i = 0; i < (int)_face_map.size(); ++i)
        _face_map[i] = FH(i);

    // Init vectors of pointers to handles
    std::vector<VH*> vh_ptrs(_vertex_map.size());
    std::vector<HEH*> heh_ptrs(_halfedge_map.size());
    std::vector<FH*> fh_ptrs(_face_map.size());
    for (int i = 0; i < (int)_vertex_map.size(); ++i)
        vh_ptrs[i] = &_vertex_map[i];
    for (int i = 0; i < (int)_halfedge_map.size(); ++i)
        heh_ptrs[i] = &_halfedge_map[i];
    for (int i = 0; i < (int)_face_map.size(); ++i)
        fh_ptrs[i] = &_face_map[i];

    // Perform garbage collection and adjust vertex maps
    // Deleted handles will be set to -1
    _mesh.garbage_collection(vh_ptrs, heh_ptrs, fh_ptrs);
}

template <typename Mesh, typename HandleType, typename ValueType>
ExternalProperty<HandleType, ValueType> apply_index_map(
        const Mesh& _mesh,
        const ExternalProperty<HandleType, ValueType>& _prop_old,
        const std::vector<HandleType>& _idx_map)
{
    ExternalProperty<HandleType, ValueType> prop_new(_mesh);
    for (int i = 0; i < (int)_prop_old.size(); ++i)
    {
        HandleType handle_new = _idx_map[i];
        if (handle_new.is_valid())
            prop_new[handle_new] = _prop_old[HandleType(i)];
    }

    return prop_new;
}

template <typename Mesh, typename ValueType>
void garbage_collection(
        Mesh& _mesh,
        ExternalProperty<VH, ValueType>& _v_prop)
{
    ISM_ASSERT(_v_prop.size_okay(_mesh));

    std::vector<VH> v_map;
    std::vector<HEH> h_map;
    std::vector<FH> f_map;
    garbage_collection_with_index_maps(_mesh, v_map, h_map, f_map);

    _v_prop = apply_index_map(_mesh, _v_prop, v_map);
}

template <typename Mesh, typename ValueType1, typename ValueType2>
void garbage_collection(
        Mesh& _mesh,
        ExternalProperty<VH, ValueType1>& _v_prop1,
        ExternalProperty<VH, ValueType2>& _v_prop2)
{
    ISM_ASSERT(_v_prop1.size_okay(_mesh));
    ISM_ASSERT(_v_prop2.size_okay(_mesh));

    std::vector<VH> v_map;
    std::vector<HEH> h_map;
    std::vector<FH> f_map;
    garbage_collection_with_index_maps(_mesh, v_map, h_map, f_map);

    _v_prop1 = apply_index_map(_mesh, _v_prop1, v_map);
    _v_prop2 = apply_index_map(_mesh, _v_prop2, v_map);
}

}

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