geometry-central icon indicating copy to clipboard operation
geometry-central copied to clipboard

Future functionality for IntrinsicTriangulation IO

Open JeffreyLayton opened this issue 2 years ago • 2 comments

Hey,

My application requires saving the mesh connectivity, mesh geometry, and mesh data for intrinsic triangulation on top of extrinsic input meshes. I tried using RichSurfaceMeshData and creating the intrinsic geometry elements and properties (ply file format); however, there is no way (at least I can see) of restoring the intrinsic triangulation alongside the extrinsic data without saving the history of how the triangulation was formed. My intent was to save a ply with both the input extrinsic structure and the input triangulation(s). Is there any future work for improving the IO of the GC structures?

Jeffrey Layton

JeffreyLayton avatar Nov 19 '23 23:11 JeffreyLayton

I think I almost managed to do the above without any change to the existing code. The only issue is the BaseGeometryInterface has a reference to the intrinsic mesh in IntrinsicTriangulation that fails to be corrected (and I have no way to change without modifying the class(es)). Everything else I was about to restore I believe.

        auto derived_ptr_sp
            = dynamic_cast<geometrycentral::surface::SignpostIntrinsicTriangulation *>(
                globals::generated_triangulation.get()
            );
        auto derived_ptr_ic
            = dynamic_cast<geometrycentral::surface::IntegerCoordinatesIntrinsicTriangulation *>(
                globals::generated_triangulation.get()
            );
        if (derived_ptr_sp != nullptr) { //Sign Post Realization
            auto temp = std::make_unique<geometrycentral::surface::SignpostIntrinsicTriangulation>(
                *globals::mesh_input, *globals::geometry_input
            );
            // Simulate loading Int. Mesh connectivity with a copy
            temp->intrinsicMesh = globals::generated_triangulation->intrinsicMesh->copy(); 
            temp->mesh          = *temp->intrinsicMesh;  // Illegal copy to a reference
            // Edge Length Geometry members
            temp->edgeLengths
                = globals::generated_triangulation->edgeLengths.reinterpretTo(*temp->intrinsicMesh);
            // Intrinsic Triangulation Members
            temp->vertexLocations = globals::generated_triangulation->vertexLocations.reinterpretTo(
                *temp->intrinsicMesh
            );
            // Sign Post Intrinsic Triangulation Members
            temp->signpostAngle = derived_ptr_sp->signpostAngle.reinterpretTo(*temp->intrinsicMesh);
            temp->edgeIsOriginal
                = derived_ptr_sp->edgeIsOriginal.reinterpretTo(*temp->intrinsicMesh);
            // Copy object for use
            globals::generated_triangulation.reset();
            globals::generated_triangulation = std::move(temp);
        }
        else { //Integer Coordinate Realization
            auto temp = std::make_unique<
                geometrycentral::surface::IntegerCoordinatesIntrinsicTriangulation>(
                *globals::mesh_input, *globals::geometry_input
            );
            // Simulate loading Int. Mesh connectivity with a copy
            temp->intrinsicMesh = globals::generated_triangulation->intrinsicMesh->copy();
            temp->mesh          = *temp->intrinsicMesh; // Illegal copy to a reference
            // Edge Length Geometry members
            temp->edgeLengths
                = globals::generated_triangulation->edgeLengths.reinterpretTo(*temp->intrinsicMesh);
            // Intrinsic Triangulation Members
            temp->vertexLocations = globals::generated_triangulation->vertexLocations.reinterpretTo(
                *temp->intrinsicMesh
            );
            // Integer Coordinates Intrinsic Triangulation Members
            new (&temp->normalCoordinates)
                geometrycentral::surface::NormalCoordinates(*temp->intrinsicMesh);
            temp->normalCoordinates.edgeCoords
                = derived_ptr_ic->normalCoordinates.edgeCoords.reinterpretTo(*temp->intrinsicMesh);
            temp->normalCoordinates.roundabouts
                = derived_ptr_ic->normalCoordinates.roundabouts.reinterpretTo(*temp->intrinsicMesh);
            temp->normalCoordinates.roundaboutDegrees
                = derived_ptr_ic->normalCoordinates.roundaboutDegrees.reinterpretTo(
                    *temp->intrinsicMesh
                );
            // Copy object for use
            globals::generated_triangulation.reset();
            globals::generated_triangulation = std::move(temp);
        }

JeffreyLayton avatar Nov 22 '23 23:11 JeffreyLayton

Any thoughts on this? Saving and loading Intrinsic Triangulations would be incredibly useful. My application inserts up to a million intrinsic vertices and takes a long time to reconstruct from the initial Extrinsic mesh

JeffreyLayton avatar Aug 26 '24 20:08 JeffreyLayton