Skip to content

std::isolines issues #1245

@evouga

Description

@evouga

Describe your issue

There are several issues with std::isolines:

  • the input n seems to be off by one; it either returns one too few or one too many isolines, depending on how you count (see next point);
  • (arguably not a bug) the isolines always include the maximum and minimum isovalue; these will almost always be single disconnected points rather than isolines;
  • the isolines sometimes have incorrect topology (any time two vertices get merged together, I believe).

Here is a minimal example.

Expected behavior: either

  1. a single isoline on the x+y+z=0 plane with isoV.rows() == isoE.rows() (preferred behavior)
  2. an "isoline" with a single vertex at the corner of the cube, and isoE.rows() == 0 (arguably also correct behavior).

Observed behavior:

  • two disconnected points on diametrically opposite corners of the cube, each with 6 redundant self-edges.
#include <igl/opengl/glfw/Viewer.h>
#include <igl/isolines.h>
int main(int argc, char *argv[])
{
  // Inline mesh of a cube
  const Eigen::MatrixXd V= (Eigen::MatrixXd(8,3)<<
    0.0,0.0,0.0,
    0.0,0.0,1.0,
    0.0,1.0,0.0,
    0.0,1.0,1.0,
    1.0,0.0,0.0,
    1.0,0.0,1.0,
    1.0,1.0,0.0,
    1.0,1.0,1.0).finished();
  const Eigen::MatrixXi F = (Eigen::MatrixXi(12,3)<<
    1,7,5,
    1,3,7,
    1,4,3,
    1,2,4,
    3,8,7,
    3,4,8,
    5,7,8,
    5,8,6,
    1,5,6,
    1,6,2,
    2,6,8,
    2,8,4).finished().array()-1;
    
    Eigen::VectorXd f(8);
    Eigen::Vector3d dir(1.0,1.0,1.0);
    for(int i=0; i<8; i++)
    {
        f[i] = V.row(i).dot(dir);
    }
    Eigen::MatrixXd isoV;
    Eigen::MatrixXi isoE;
    igl::isolines(V, F, f, 1, isoV, isoE);   
    Eigen::MatrixXd C(isoE.rows(), 3);
    C.col(0).setConstant(1.0);
    C.col(1).setZero();
    C.col(2).setZero(); 
    
    std::cout << "Isoline vertices: " << isoV << std::endl;
    std::cout << "Isoline edges: " << isoE << std::endl;

  // Plot the mesh
  igl::opengl::glfw::Viewer viewer;
  viewer.data().set_mesh(V, F);
  viewer.data().set_face_based(true);
  viewer.data().set_edges(isoV, isoE, C);
  viewer.launch();
}

Check all that apply (change to [x])

  • Windows
  • Mac OS X
  • Linux
  • I have tried the dev branch and the problem persists

See https://libigl.github.io/CONTRIBUTING/#bugreport for more tips.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions