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
  • /
  • IO.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:efd6fd0b1767040b406e30099bebf2d78f79e0d6
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
IO.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, Janis Born
 */
#pragma once

#include <SurfaceMaps/Types.hh>
#include <SurfaceMaps/Utils/Filesystem.hh>

namespace polymesh
{

class Mesh;
struct vertex_handle;
struct edge_handle;
template <class AttrT> struct vertex_attribute;

}
namespace pm = polymesh;

namespace tg
{

template <int d, typename T> struct pos;
using pos3 = pos<3, float>;

}

namespace glow
{
    class Texture2D;
}

namespace SurfaceMaps
{

/// Create directory (recursive)
void make_directory(
        const std::string& _dir_path);

void make_file_directory(
        const std::string& _file_path);

std::ifstream open_file_read(
        const std::string& _path,
        const bool _throw_if_not_exist = true);

void remove_comment(
        std::string& str,
        std::string comment);

void trim(
        std::string& str);

std::vector<std::string> read_line(
        std::ifstream& _file,
        const char _delimiter);

void append_line(
        const fs::path& _file_path,
        const std::string& _line,
        const bool _silent = false);

template<typename Arg0, typename ...Args>
void append_to_csv(
        const fs::path& _file_path,
        Arg0 arg0,
        Args ...args)
{
    std::stringstream s;
    s << arg0;
    ((s << ", " << args), ...);
    append_line(_file_path, s.str());
}

template<typename Arg0, typename ...Args>
void append_to_csv_silent(
        const fs::path& _file_path,
        Arg0 arg0,
        Args ...args)
{
    std::stringstream s;
    s << arg0;
    ((s << ", " << args), ...);
    append_line(_file_path, s.str(), true);
}

/// Read OpenMesh with per-corner texture coordinates
TriMesh read_mesh(
        const fs::path& _path,
        const bool _silent = false);

/// Write OpenMesh with per-corner texture coordinates
void write_mesh(
        const TriMesh& _mesh,
        const fs::path& _file_path);

/// Get per-corner texture coordinates from mesh
TexCoords tex_coords(
        const TriMesh& _mesh);

enum class LandmarkFormat
{
    Pinned,  // Default: A list of vertex indices
    VTS,     // The format used by the annotated SHREC07 dataset
    Unknown, // Unrecognized format
};

enum class LandmarkType
{
    Init,   // li: Use only for map init, discard afterwards
    PreOpt, // lp: Use for map init and pre-optimization, discard afterwards
    Keep,   // lk: Use in init, pre-optimization and optimization
};

LandmarkFormat guess_landmark_format(const fs::path& _path);

/// Read landmarks from file.
/// Tries to guess the landmark format from the file extension.
std::vector<VH> read_landmarks(
        const fs::path& _path,
        const LandmarkType _type = LandmarkType::Keep,
        const bool _throw_if_not_exist = true);

std::vector<VH> read_landmarks_pinned(
        const fs::path& _path,
        const LandmarkType _type = LandmarkType::Keep,
        const bool _throw_if_not_exist = true);
std::vector<VH> read_landmarks_vts(
        const fs::path& _path,
        const bool _throw_if_not_exist = true);

/// Write landmarks to file.
/// Tries to guess the landmark format from the file extension.
void write_landmarks(
        const std::vector<VH>& _landmarks,
        const fs::path& _path,
        const std::vector<LandmarkType>& _landmark_types = std::vector<LandmarkType>(),
        const bool _overwrite = false);

void write_landmarks_pinned(
        const std::vector<VH>& _landmarks,
        const fs::path& _path,
        const std::vector<LandmarkType>& _landmark_types = std::vector<LandmarkType>(),
        const bool _overwrite = false);
void write_landmarks_vts(
        const std::vector<VH>& _landmarks,
        const fs::path& _path,
        const bool _overwrite = false);

/// Read edge indices from file
std::vector<EH> read_paths(
        const std::string& _path,
        const bool _throw_if_not_exist = true);

std::vector<pm::edge_handle> read_paths(
        const std::string& _path,
        const pm::Mesh& _mesh,
        const bool _throw_if_not_exist = true);

/// Write edge indices to file
void write_paths(
        const std::vector<EH>& _edges,
        const std::string& _path,
        const bool _overwrite = false);

void write_paths(
        const std::vector<pm::edge_handle>& _edges,
        const std::string& _path,
        const bool _overwrite = false);

std::shared_ptr<glow::Texture2D> read_texture(
        const fs::path &_file_path);

ExternalProperty<VH, Vec3d> embedding_from_mesh(
        const TriMesh& _mesh);

/// Read vertex positions from mesh with same connectivity
ExternalProperty<VH, Vec3d> read_embedding(
        const TriMesh& _mesh,
        const fs::path& _path);

/// Write vertex positions to mesh with same connectivity
void write_embedding(
        const TriMesh& _mesh,
        const ExternalProperty<VH, Vec3d>& _embedding,
        const fs::path& _path);

/// Convert OpenMesh to libigl matrix representation
void mesh_to_matrix(
        const TriMesh& _mesh,
        MatXd& _V, MatXi& _F);

/// Convert libigl matrix to OpenMesh
void matrix_to_mesh(
        const MatXd& _V,
        const MatXi& _F,
        TriMesh& _mesh,
        const bool _compute_normals = false);

/// Convert parameterization to libigl matrix
MatXd param_to_matrix(
        const Parametrization& _param,
        const TriMesh& _mesh);

/// Convert libigl matrix to parameterization
Parametrization param_from_matrix(
        const MatXd& _P,
        const TriMesh& _mesh);

/// Convert OpenMesh to polymesh
pm::vertex_attribute<Vec3d> to_polymesh(
        const TriMesh& mesh,
        pm::Mesh& m);

pm::vertex_attribute<tg::pos3> to_polymesh_tg(
        const TriMesh& mesh,
        pm::Mesh& m);

MatXd uv_vector_to_matrix(
        const VecXd& _uv_vec);

Parametrization vector_to_param(
        const VecXd& _x,
        const TriMesh _mesh);

VecXd matrix_to_stacked_vector(
        const MatXd& _mat);

/// Read double per mesh element
ExternalProperty<VH, double> read_per_vertex_data(
        const std::string& _path,
        const TriMesh& _mesh,
        const bool _throw_if_not_exist = true);

/// Write double-valued vertex property
void write_vertex_property(
        const OpenMesh::VPropHandleT<double> _ph,
        const std::string& _path,
        const TriMesh& _mesh,
        const bool _overwrite = false);

void write_vertex_to_point_map(
        const VertexToPointMap& _vtpm,
        const std::string& _path,
        const TriMesh& _source,
        const TriMesh& _target,
        const bool _overwrite = false);

VertexToPointMap read_vertex_to_point_map(
        const std::string& _path,
        const TriMesh& _source,
        const TriMesh& _target,
        const bool _throw_if_not_exist = true);

template <typename T>
void write_matrix(
        const MatX<T>& _M,
        const fs::path& _path,
        const bool _overwrite = false,
        const bool _write_header = true);

MatXd read_matrix(
        const fs::path& _path);

template <typename HandleT>
ExternalProperty<HandleT, double> read_property(
        const fs::path& _path,
        const TriMesh& _mesh,
        const bool _throw_if_not_exist);

template <typename HandleT>
void write_property(
        const ExternalProperty<HandleT, double>& _prop,
        const fs::path& _path,
        const bool _overwrite = false);

std::string folder_name_from_time();

std::string pad_integer(
        const int _i,
        const int _pad = 6);

// True iff _flag occours in _argv
bool flag(const char* _flag, int _argc, char** _argv);

}

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