libigl / libigl-python-bindings

libigl python bindings
https://libigl.github.io/libigl-python-bindings/
GNU General Public License v3.0
315 stars 62 forks source link

Request: Adding isolines_intrinsic to the python bindings #230

Open DanielMezaZ opened 3 months ago

DanielMezaZ commented 3 months ago

Hello,

I believe exposing the isolines_intrinsic function with a Python binding could be highly beneficial. This function can be particularly useful when interpolating data beyond point coordinates. Here is the file I added to my build to access isolines_intrinsic. It seems to work without issues so far:

// This file is part of libigl, a simple c++ geometry processing library.
//
// Copyright (C) 2023 Teseo Schneider
//
// 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/.
//TODO: __example

#include <common.h>
#include <npe.h>
#include <typedefs.h>
#include <igl/isolines_intrinsic.h>

const char *ds_isolines_intrinsic = R"igl_Qu8mg5v7(
 Constructs isolines interpolation parameters for a function z given on a mesh (V,F)

Parameters
----------
  F  #F by 3 list of mesh triangle indices into V
  S  #S by 1 list of per-vertex scalar values
  vals  #vals by 1 list of values to compute isolines for

Returns
-------
   iB  #iB by 3 list of barycentric coordinates
   iFI  #iB list of triangle indices for each row of iB 
   iE  #iE by 2 list of edge indices into iV
   I  #iE by 1 list of indices into vals indicating which value

See also
--------

Notes
-----
None

Examples
--------

)igl_Qu8mg5v7";

npe_function(isolines_intrinsic)
npe_doc(ds_isolines_intrinsic)

npe_arg(F, dense_int32, dense_int64)
npe_arg(S, dense_float, dense_double)
npe_arg(vals, npe_matches(S))

npe_begin_code()

  assert_cols_equals(S, 1, "S");
  Eigen::Matrix<typename npe_Matrix_S::Scalar, Eigen::Dynamic, 3> iB;
  Eigen::Matrix<int, Eigen::Dynamic, 1> iFI;
  EigenDenseLike<npe_Matrix_F> iE;
  Eigen::Matrix<typename npe_Matrix_F::Scalar, Eigen::Dynamic, 1> I;
  Eigen::Matrix<typename npe_Matrix_vals::Scalar, Eigen::Dynamic, 1> vals_copy = vals;
  igl::isolines_intrinsic(F, S.col(0), vals_copy, iB, iFI, iE, I);
  return std::make_tuple(npe::move(iB), npe::move(iFI), npe::move(iE), npe::move(I));

npe_end_code()

This was useful for me, so I though maybe someone else could need it at some point

alecjacobson commented 3 months ago

Thanks!. Would you like to submit that as a pull request?

On Mon, Jun 10, 2024 at 3:21 AM Daniel @.***> wrote:

Hello,

I believe exposing the isolines_intrinsic function with a Python binding could be highly beneficial. This function can be particularly useful when interpolating data beyond point coordinates. Here is the file I added to my build to access isolines_intrinsic. It seems to work without issues so far:

// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2023 Teseo Schneider // // 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/. //TODO: __example

include

include

include

include <igl/isolines_intrinsic.h>

const char *ds_isolines_intrinsic = R"igl_Qu8mg5v7( Constructs isolines interpolation parameters for a function z given on a mesh (V,F)

Parameters

F #F by 3 list of mesh triangle indices into V S #S by 1 list of per-vertex scalar values vals #vals by 1 list of values to compute isolines for

Returns

iB #iB by 3 list of barycentric coordinates iFI #iB list of triangle indices for each row of iB iE #iE by 2 list of edge indices into iV I #iE by 1 list of indices into vals indicating which value

See also

Notes

None

Examples

)igl_Qu8mg5v7";

npe_function(isolines_intrinsic) npe_doc(ds_isolines_intrinsic)

npe_arg(F, dense_int32, dense_int64) npe_arg(S, dense_float, dense_double) npe_arg(vals, npe_matches(S))

npe_begin_code()

assert_cols_equals(S, 1, "S"); Eigen::Matrix<typename npe_Matrix_S::Scalar, Eigen::Dynamic, 3> iB; Eigen::Matrix<int, Eigen::Dynamic, 1> iFI; EigenDenseLike iE; Eigen::Matrix<typename npe_Matrix_F::Scalar, Eigen::Dynamic, 1> I; Eigen::Matrix<typename npe_Matrix_vals::Scalar, Eigen::Dynamic, 1> vals_copy = vals; igl::isolines_intrinsic(F, S.col(0), vals_copy, iB, iFI, iE, I); return std::make_tuple(npe::move(iB), npe::move(iFI), npe::move(iE), npe::move(I));

npe_end_code()

This was useful for me, so I though maybe someone else could need it at some point

— Reply to this email directly, view it on GitHub https://github.com/libigl/libigl-python-bindings/issues/230, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARDJGPU7KIG5ZUEL253EGTZGVHXZAVCNFSM6AAAAABJBWWBA6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGM2DGMBXGI3DCMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>