Skip to content

Commit

Permalink
Add stripe patterns algorithm (#89)
Browse files Browse the repository at this point in the history
* add stripe patterns

* add comments

* add isoline extraction

* fix warnings

* clean up isolines code

* fix isolines extraction

* detect multiple stripes on individual triangles

* extract multiple isolines per triangle

* fix

* proper isoline connection strategy
  • Loading branch information
DavidJourdan authored Oct 20, 2023
1 parent 0717561 commit d604089
Show file tree
Hide file tree
Showing 3 changed files with 598 additions and 0 deletions.
36 changes: 36 additions & 0 deletions include/geometrycentral/surface/stripe_patterns.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#include "geometrycentral/surface/embedded_geometry_interface.h"
#include "geometrycentral/surface/intrinsic_geometry_interface.h"
#include <vector>

namespace geometrycentral {
namespace surface {

// Implementation of "Stripe Patterns on Surfaces" [Knoppel et al. 2015]
// Based on Keenan Crane's original implementation available here:
// https://www.cs.cmu.edu/~kmcrane/Projects/StripePatterns/code.zip

// Takes as input a geometry along with vertex-based frequencies and a line field (2-RoSy) and outputs a 2\pi-periodic
// function defined on triangle corners such that the 0 (mod 2\pi)
// Isolines of this function are stripes perpendicular to the direction field spaced according to the target frequencies
std::tuple<CornerData<double>, FaceData<int>, FaceData<int>>
computeStripePattern(IntrinsicGeometryInterface& geometry, const VertexData<double>& frequencies,
const VertexData<Vector2>& directionField);

// Extracts the zero (mod 2pi) level set of the function values defined on the corners
// Returns a list of vertices and edges suitable for rendering (e.g. with Polyscope)
// (requires access to explicit vertex positions)
std::tuple<std::vector<Vector3>, std::vector<std::array<size_t, 2>>>
extractPolylinesFromStripePattern(EmbeddedGeometryInterface& geometry, const CornerData<double>& values,
const FaceData<int>& stripeIndices, const FaceData<int>& fieldIndices,
const VertexData<Vector2>& directionField, bool connectOnSingularities);

// Runs both of the above functions (per-corner data computation and polyline extraction)
// can optionally connect isolines separated by a singularity using a directionField alignment heuristic
std::tuple<std::vector<Vector3>, std::vector<std::array<size_t, 2>>>
computeStripePatternPolylines(EmbeddedGeometryInterface& geometry, const VertexData<double>& frequencies,
const VertexData<Vector2>& directionField, bool connectIsolinesOnSingularities = true);

} // namespace surface
} // namespace geometrycentral
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ SET(SRCS
surface/intrinsic_mollification.cpp
surface/tufted_laplacian.cpp
surface/flip_geodesics.cpp
surface/stripe_patterns.cpp
surface/transfer_functions.cpp
surface/quadric_error_simplification.cpp
surface/subdivide.cpp
Expand Down Expand Up @@ -130,6 +131,7 @@ SET(HEADERS
${INCLUDE_ROOT}/surface/signpost_intrinsic_triangulation.ipp
${INCLUDE_ROOT}/surface/simple_idt.h
${INCLUDE_ROOT}/surface/simple_polygon_mesh.h
${INCLUDE_ROOT}/surface/stripe_patterns.h
${INCLUDE_ROOT}/surface/subdivide.h
${INCLUDE_ROOT}/surface/surface_centers.h
${INCLUDE_ROOT}/surface/surface_mesh.h
Expand Down
Loading

0 comments on commit d604089

Please sign in to comment.