polyscope icon indicating copy to clipboard operation
polyscope copied to clipboard

GeometryCentral Corner Perms

Open JeffreyLayton opened this issue 9 months ago • 2 comments

Hey,

I'm running into issues with getting parameterized data loaded from geometry central. It seems that the permutations for the corners aren't being set correctly. I've verified that the "polyscopePermutations" function produces valid maps at the time of registration (and after). However, it seems to ignore the perms and just reads the corner data using the polyscope index. Here is an example of a simple quad (bisected). When viewing the parameterization channel, it seems to use the "original" values (confirmed by pick functionality). I believe this was working when I was using Polyscope 2.1.0, but now I'm getting this issue on 2.4.0. It may actually be from GC with that official update (1.0.0) but I don't think so. I'm technically running a fork of geometry central 1.0.0 for custom access to intrinsic triangulations, but nothing to do with the extrinsic / embedded code used here.

EDIT: I've cleaned the code and the output, attached an image to better communicate what is happening.

[DEBUG] Corner Parameterization Values:
[DEBUG]    GC Corner ID 0 | Face ID 0 | UV [1,0]
[DEBUG]    GC Corner ID 1 | Face ID 1 | UV [0,1]
[DEBUG]    GC Corner ID 2 | Face ID 0 | UV [0,1]
[DEBUG]    GC Corner ID 4 | Face ID 0 | UV [0,0]
[DEBUG]    GC Corner ID 6 | Face ID 1 | UV [1,0]
[DEBUG]    GC Corner ID 8 | Face ID 1 | UV [1,1]
[DEBUG] Corner permutation (6 entries):
[DEBUG]    Corner IDs (PS, GC) -> UVs (PS, GC)
[DEBUG]    Corner IDs (0, 0) -> UVs ([1,0], [1,0])
[DEBUG]    Corner IDs (1, 2) -> UVs ([0,1], [0,1])
[DEBUG]    Corner IDs (2, 4) -> UVs ([0,1], [0,0])
[DEBUG]    Corner IDs (3, 6) -> UVs ([0,0], [1,0])
[DEBUG]    Corner IDs (4, 8) -> UVs ([0,0], [1,1])
[DEBUG]    Corner IDs (5, 1) -> UVs ([0,0], [0,1])

JeffreyLayton avatar May 17 '25 00:05 JeffreyLayton

    using namespace geometrycentral::surface;
    using namespace geometrycentral;

    auto mesh_data = readParameterizedManifoldSurfaceMesh(globals::extrinsic_mesh_path.string());

    ManifoldSurfaceMesh &mesh_con    = *std::get<0>(mesh_data);
    VertexPositionGeometry &mesh_geo = *std::get<1>(mesh_data);
    CornerData<Vector2> &mesh_par    = *std::get<2>(mesh_data);

    auto perms                 = polyscopePermutations(mesh_con);
    polyscope::SurfaceMesh *ex = polyscope::registerSurfaceMesh(
        "ex", mesh_geo.vertexPositions, mesh_con.getFaceVertexList(), perms
    );
    ex->addParameterizationQuantity("Parameterization", mesh_par);

    auto to_string_vec2 = [](const Vector2 &v) { return to_string(std::vector<double>{v.x, v.y}); };

    // Evaluating the values in mesh_par
    my_library::io::debug("Corner Parameterization Values:");
    for (Corner c : mesh_con.corners()) {
        size_t c_index    = c.getIndex();
        size_t f_index    = c.face().getIndex();
        const Vector2 &uv = mesh_par[c_index];

        my_library::io::debug(
            "   GC Corner ID {} | Face ID {} | UV {}", c_index, f_index, to_string_vec2(uv)
        );
    }

    const std::vector<size_t> &corner_map = perms[4].first;
    my_library::io::debug("Corner permutation ({} entries):", corner_map.size());
    my_library::io::debug("   Corner IDs (PS, GC) -> UVs (PS, GC)");
    for (size_t id_ps = 0; id_ps < corner_map.size(); id_ps++) {
        size_t id_gc = corner_map[id_ps];

        const Vector2 &uv_ps = mesh_par[id_ps];
        const Vector2 &uv_gc = mesh_par[id_gc];

        my_library::io::debug(
            "   Corner IDs ({}, {}) -> UVs ({}, {})",
            id_ps,
            id_gc,
            to_string_vec2(uv_ps),
            to_string_vec2(uv_gc)
        );
    }

JeffreyLayton avatar May 17 '25 00:05 JeffreyLayton

Image

JeffreyLayton avatar May 17 '25 20:05 JeffreyLayton