From 146697c7cddd96662c3dea52a2213ffc60194512 Mon Sep 17 00:00:00 2001 From: Tibor Stanko Date: Fri, 16 Feb 2018 14:54:05 +0100 Subject: [PATCH] Modification for boundary vertices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not sure if you want to change this file, but here is a modified computation of the discrete Gaussian curvature for boundary vertices. It's backwards-compatible — by default, the (2π - ∑θj) is used for all vertices. --- mesh/discrete_gaussian_curvature.m | 34 +++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/mesh/discrete_gaussian_curvature.m b/mesh/discrete_gaussian_curvature.m index 6fda5ab7..780f9506 100644 --- a/mesh/discrete_gaussian_curvature.m +++ b/mesh/discrete_gaussian_curvature.m @@ -1,4 +1,4 @@ -function k = discrete_gaussian_curvature(V,F) +function k = discrete_gaussian_curvature(V,F,varargin) % DISCRETE_GAUSSIAN_CURVATURE Compute discrete gaussian curvature according % to (9) in "Discrete Differential-Geometry Operators for Triangulated % 2-Manifolds" [Meyer et al. 02] but without the inverse area term. @@ -8,13 +8,41 @@ % Inputs: % V #V by 3 list of vertex positions % F #F by 3 list of face indies + % Optional: + % 'ModifyBoundary' followed by true of {false} whether to subtract π + % at boundary vertices % Outputs: % k #V by 1 list of discrete gaussian curvature values % + + % Default value + boundary = false; + % Map of parameter names to variable names + params_to_variables = containers.Map( ... + {'ModifyBoundary'}, {'boundary'}); + v = 1; + while v <= numel(varargin) + param_name = varargin{v}; + if isKey(params_to_variables,param_name) + assert(v+1<=numel(varargin)); + v = v+1; + % Trick: use feval on anonymous function to use assignin to this workspace + feval(@()assignin('caller',params_to_variables(param_name),varargin{v})); + else + error('Unsupported parameter: %s',varargin{v}); + end + v=v+1; + end %K_G(x_i) = (2π - ∑θj) k = 2*pi - sparse(F,1,internalangles(V,F),size(V,1),1); - - + + % Boundary vertices + %K_G(x_i) = (π - ∑θj) + if boundary + b = outline(F); + b = unique(b(:)); + k(b) = k(b) - pi; + end end