Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future functionality for IntrinsicTriangulation IO #166

Open
JeffreyLayton opened this issue Nov 19, 2023 · 2 comments
Open

Future functionality for IntrinsicTriangulation IO #166

JeffreyLayton opened this issue Nov 19, 2023 · 2 comments

Comments

@JeffreyLayton
Copy link

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
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant