Skip to content

Commit

Permalink
Add plot_function
Browse files Browse the repository at this point in the history
  • Loading branch information
gviga authored and luisfpereira committed Dec 27, 2024
1 parent 12df9aa commit 0c83c5c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions geomfum/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@
'''

class ShapePlotter(abc.ABC):
'''
Primitive Calss to plot meshes, pointclouds or specific useful informations (scalar functions, landmarks, etc..)
'''
def plot(self, mesh):
'''
Function to plot a mesh
'''
raise NotImplementedError("This method should be overridden by subclasses")

def plot_function(self, mesh, function):
'''
Function to plot a mesh
'''
raise NotImplementedError("This method should be overridden by subclasses")

class MeshPlotter(WhichRegistryMixins, ShapePlotter):
Expand Down
17 changes: 16 additions & 1 deletion geomfum/wrap/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class PlotlyMeshPlotter(ShapePlotter):

def plot(self,mesh):
def plot(self, mesh):
vertices=mesh.vertices
faces=mesh.faces
x, y, z = vertices[:,0], vertices[:,1], vertices[:,2]
Expand All @@ -13,4 +13,19 @@ def plot(self,mesh):
fig = go.Figure(data=[go.Mesh3d(x=x,y=y,z=z, i=f1, j=f2, k=f3)])
fig.show()

def plot_function(self, mesh, function):
#TODO: add parameters
#TODO: add assertion


vertices=mesh.vertices
faces=mesh.faces
x, y, z = vertices[:,0], vertices[:,1], vertices[:,2]
f1,f2,f3= faces[:,0], faces[:,1], faces[:,2]
fig = go.Figure(data=[go.Mesh3d(x=x,y=y,z=z, i=f1, j=f2, k=f3,
intensity = function,
colorscale = 'viridis', #TODO: MAKE THIS A PARAMETER
)])
fig.show()


0 comments on commit 0c83c5c

Please sign in to comment.