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
Revision a1bf1ebae522a8f2ec5c0603420b7cd99db354fe authored by Patrick Schmidt on 23 January 2023, 11:04:23 UTC, committed by Patrick Schmidt on 23 January 2023, 11:04:23 UTC
Initial commit
0 parent
  • Files
  • Changes
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • a1bf1ebae522a8f2ec5c0603420b7cd99db354fe
    No releases to show
  • 3040667
  • /
  • apps
  • /
  • adaptive_triangulations
  • /
  • approximation.cc
Raw File Download
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.

  • revision
  • directory
  • content
  • snapshot
origin badgerevision badge
swh:1:rev:a1bf1ebae522a8f2ec5c0603420b7cd99db354fe
origin badgedirectory badge
swh:1:dir:026d10c3e5f007f6c85d650b7014824054983d79
origin badgecontent badge
swh:1:cnt:8dff902123a987e38f89846113389300aecf07b1
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.

  • revision
  • directory
  • content
  • 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: a1bf1ebae522a8f2ec5c0603420b7cd99db354fe authored by Patrick Schmidt on 23 January 2023, 11:04:23 UTC
Initial commit
Tip revision: a1bf1eb
approximation.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, Dörte Pieper
 */
#include <SurfaceMaps/Init.hh>
#include <SurfaceMaps/Viewer/MeshView.hh>
#include <SurfaceMaps/AdaptiveTriangulations/InitSphereEmbeddings.hh>
#include <SurfaceMaps/AdaptiveTriangulations/OptimizeCoarseToFine.hh>
#include <SurfaceMaps/AdaptiveTriangulations/OptimizeWithRemeshing.hh>

const bool open_viewer = false; // or write screenshots

namespace SurfaceMaps
{

void run(
        const double w_approx)
{
    // Prepare output dir
    fs::path output_dir = OUTPUT_PATH / "approximation";
    fs::path screenshot_dir = output_dir / "screenshots";
    fs::create_directories(screenshot_dir);
    const std::string name = "w_approx_" + std::to_string(w_approx);

    const fs::path mesh_path_A = DATA_PATH / "meshes/hand/hand_plain.obj";
    const fs::path mesh_path_B = DATA_PATH / "meshes/hand/hand_vulcan.obj";
    const fs::path landmarks_path_A = DATA_PATH / "meshes/hand/hand_plain.pinned";
    const fs::path landmarks_path_B = DATA_PATH / "meshes/hand/hand_vulcan_0.pinned";
    const fs::path embedding_path_A = output_dir / "embedding_A.obj";
    const fs::path embedding_path_B = output_dir / "embedding_B.obj";

    // Init map
    MapState map_state;
    init_map(map_state, { mesh_path_A, mesh_path_B }, { landmarks_path_A, landmarks_path_B }, { embedding_path_A, embedding_path_B }, false);

    // Optimize map
    landmark_phase(map_state);
    release_landmarks(map_state);
    coarse_phase(map_state);

    AdaptiveTriangulationsSettings fine_settings = fine_phase_settings();
    fine_settings.w_approx = w_approx;
    optimize_with_remeshing(map_state, fine_settings, "");

    // Visualization
    std::vector<TriMesh> lifted_Ts = lifted_meshes_from_mapstate(map_state);

    // Screenshot T_A
    {
        auto cam_pos = glow::viewer::camera_transform(tg::pos3(1.732203f, 0.442215f, 3.076327f), tg::pos3(0.045052f, -0.113123f, -0.014236f));
        auto cam_config = gv::config(cam_pos);
        auto s = screenshot_config(open_viewer, screenshot_dir / (name + ".png"), tg::ivec2(1920, 1080), true);

        auto v = gv::view();
        auto style = gv::config(gv::sun_scale_factor(1.5));
        view_mesh(map_state.meshes_input[0], Color(1.0, 1.0, 1.0, 0.5));
        view_mesh(lifted_Ts[0], Color(1.0, 1.0, 1.0, 0.8));
        view_wireframe(lifted_Ts[0], MAGENTA, WidthScreen(0.7));
    }
}

}

int main()
{
    glow::glfw::GlfwContext ctx;
    using namespace SurfaceMaps;
    init_lib_surface_maps();

    for (double w_approx : { 0.0, 1.0 })
        run(w_approx);

    return 0;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

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