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

swh:1:snp:5b64a595dd5bf9fb152912f4350a33ad8ffc8534
  • Code
  • Branches (2)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/heads/remove_tbb
    No releases to show
  • 62afcd1
  • /
  • main.cpp
Raw File Download

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
content badge
swh:1:cnt:084a319fb2eb5736f98498a81421a9ff3937b748
directory badge
swh:1:dir:62afcd186765bf0d0998b2532432b53f6298315c
revision badge
swh:1:rev:ca7b4552c3265020f9c568fe90b38255a927f815
snapshot badge
swh:1:snp:5b64a595dd5bf9fb152912f4350a33ad8ffc8534

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: ca7b4552c3265020f9c568fe90b38255a927f815 authored by Alec Jacobson on 19 December 2018, 16:48:27 UTC
revert; this made things worse on elf
Tip revision: ca7b455
main.cpp
// Copyright (C) 2018 Alec Jacobson <alecjacobson@gmail.com>
// 
// This Source Code Form is subject to the terms of the Mozilla Public License 
// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
// obtain one at http://mozilla.org/MPL/2.0/.

#include "WindingNumber/UT_SolidAngle.h"

#include <igl/read_triangle_mesh.h>
#include <igl/parallel_for.h>
#include <igl/readDMAT.h>
#include <igl/writeDMAT.h>
#include <igl/get_seconds.h>

#include <Eigen/Core>

#include <cstdlib>


int main(int argc, char * argv[])
{
  Eigen::MatrixXf V,P;
  Eigen::Matrix<int,Eigen::Dynamic,3,Eigen::RowMajor> F;
  if(argc != 3+1)
  {
    std::cerr<<R"(USAGE:

./fastwinding input.[mesh|msh|obj|off|ply|stl|wrl] query.dmat output.dmat

input.*     contains a 3D triangle mesh
query.dmat  contains a #Q by 3 matrix of input query points

output.dmat will contain a #Q by 1 vector of output winding numbers
)";
    return EXIT_FAILURE;
  }

  igl::read_triangle_mesh(argv[1],V,F);
  igl::readDMAT(argv[2],P);

  HDK_Sample::UT_SolidAngle<float,float> solid_angle;
  int order = 2;
  double accuracy_scale = 2.0;

  std::vector<HDK_Sample::UT_Vector3T<float> > U(V.rows());
  for(int i = 0;i<V.rows();i++)
  {
    for(int j = 0;j<3;j++)
    {
      U[i][j] = V(i,j);
    }
  }
  {
    double t_before = igl::get_seconds();
#define MAX_PRECOMP_RUNS 50
    for(int r = 0;r<MAX_PRECOMP_RUNS;r++)
    {
      solid_angle.clear();
      solid_angle.init(
          F.rows(),
          F.data(),
          V.rows(),
          &U[0],
          order);
    }
    std::cout<<"Precomp: "<<(igl::get_seconds() - t_before)/MAX_PRECOMP_RUNS<<" secs"<<std::endl;
  }

  Eigen::VectorXf W(P.rows());
  {
    double t_before = igl::get_seconds();
#define MAX_RUNS 5
    for(int r = 0;r<MAX_RUNS;r++)
    {
      // Alec: Yes, this parallel_for is helping on pig-head-subd
      igl::parallel_for(P.rows(),[&](int p)
      //for(int p = 0;p<P.rows();p++)
      {
      HDK_Sample::UT_Vector3T<float>Pp;
          Pp[0] = P(p,0);
          Pp[1] = P(p,1);
          Pp[2] = P(p,2);
        W(p) = solid_angle.computeSolidAngle(
          Pp,
          accuracy_scale) 
          / (4.0*M_PI);
      }
      ,1000);
    }
    std::cout<<"Runtime: "<<(igl::get_seconds() - t_before)/MAX_RUNS<<" secs"<<std::endl;
  }

  return
    igl::writeDMAT(argv[3],W,false);
}

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