-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying to gh-pages from @ 10d81df 🚀
- Loading branch information
Showing
283 changed files
with
9,475 additions
and
20,803 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 99142181445c475509bfbaf515a4c708 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,5 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
|
@@ -26,7 +15,14 @@ | |
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Authors: Julien Lefevre <[email protected]>\n\n# License: BSD (3-clause)\n# sphinx_gallery_thumbnail_number = 2" | ||
"# Authors: Julien Lefevre <[email protected]>\n\n# License: MIT\n# sphinx_gallery_thumbnail_number = 2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"NOTE: there is no visualization tool in slam, but we provide at the\n end of this script exemplare code to do the visualization with\n an external solution\n##############################################################################\n\n" | ||
] | ||
}, | ||
{ | ||
|
@@ -44,7 +40,7 @@ | |
}, | ||
"outputs": [], | ||
"source": [ | ||
"import slam.plot as splt\nimport slam.curvature as scurv\nimport slam.generate_parametric_surfaces as sgps" | ||
"import slam.curvature as scurv\nimport slam.generate_parametric_surfaces as sgps" | ||
] | ||
}, | ||
{ | ||
|
@@ -62,7 +58,14 @@ | |
}, | ||
"outputs": [], | ||
"source": [ | ||
"hinge_mesh = sgps.generate_hinge(n_hinge=4)\nmesh_curvatures = scurv.curvatures_and_derivatives(hinge_mesh)\nmean_curvature = 1 / 2 * mesh_curvatures[0].sum(axis=0)\n\nvisb_sc = splt.visbrain_plot(\n mesh=hinge_mesh, tex=mean_curvature, caption=\"hinge\", cblabel=\"mean curvature\"\n)\n\nvisb_sc.preview()" | ||
"hinge_mesh = sgps.generate_hinge(n_hinge=4)\nmesh_curvatures = scurv.curvatures_and_derivatives(hinge_mesh)\nmean_curvature = 1 / 2 * mesh_curvatures[0].sum(axis=0)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## VISUALIZATION USING EXTERNAL TOOLS\n# Visualization with visbrain\nvisb_sc = splt.visbrain_plot(\n mesh=hinge_mesh,\n tex=mean_curvature,\n caption=\"hinge\",\n cblabel=\"mean curvature\"\n)\nvisb_sc.preview()\n\n" | ||
] | ||
} | ||
], | ||
|
@@ -82,7 +85,7 @@ | |
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.5" | ||
"version": "3.9.20" | ||
} | ||
}, | ||
"nbformat": 4, | ||
|
Binary file modified
BIN
+17.4 KB
(130%)
_downloads/07fcc19ba03226cd3d83d4e40ec44385/auto_examples_python.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,24 @@ | |
|
||
# Authors: Tianqi SONG <[email protected]> | ||
|
||
# License: BSD (3-clause) | ||
# License: MIT | ||
# sphinx_gallery_thumbnail_number = 2 | ||
|
||
############################################################################### | ||
# NOTE: there is no visualization tool in slam, but we provide at the | ||
# end of this script exemplare code to do the visualization with | ||
# an external solution | ||
############################################################################### | ||
|
||
############################################################################### | ||
# importation of slam modules | ||
import numpy as np | ||
import trimesh.visual.color | ||
|
||
import slam.surface_profiling as surfpf | ||
import slam.io as sio | ||
|
||
############################################################################### | ||
# loading an example mesh | ||
mesh = sio.load_mesh("data/example_mesh.gii") | ||
mesh = sio.load_mesh("../examples/data/example_mesh.gii") | ||
|
||
############################################################################### | ||
# Select a vertex and get the coordinate and normal. | ||
|
@@ -45,43 +48,46 @@ | |
vert0, norm0, init_rot_dir, rot_angle, r_step, max_samples, mesh | ||
) | ||
|
||
############################################################################### | ||
# Visualize result | ||
prof_points_mesh = profile_points.reshape( | ||
profile_points.shape[0] * profile_points.shape[1], 3 | ||
) | ||
prof_points_colors = np.zeros(prof_points_mesh.shape) | ||
points_mesh = trimesh.points.PointCloud( | ||
prof_points_mesh, colors=np.array(prof_points_colors, dtype=np.uint8) | ||
) | ||
|
||
# set the points colors | ||
red, yellow, green, blue = [ | ||
[255, 0, 0, 255], | ||
[255, 255, 0, 255], | ||
[0, 255, 0, 255], | ||
[0, 0, 255, 255], | ||
] | ||
color_i = np.zeros(4) | ||
for i in range(len(prof_points_mesh)): | ||
degree = i / max_samples | ||
num_profiles = int(360 / rot_angle) | ||
segment_color = num_profiles / 3 | ||
|
||
if degree <= segment_color: | ||
color_i = trimesh.visual.color.linear_color_map( | ||
degree / segment_color, [red, yellow] | ||
) | ||
elif segment_color < degree <= segment_color * 2: | ||
color_i = trimesh.visual.color.linear_color_map( | ||
degree / segment_color - 1, [yellow, green] | ||
) | ||
elif segment_color * 2 < degree <= num_profiles: | ||
color_i = trimesh.visual.color.linear_color_map( | ||
degree / segment_color - 2, [green, blue] | ||
) | ||
points_mesh.colors[i] = np.array(color_i) | ||
|
||
# create a scene with the mesh and profiling points | ||
#scene = trimesh.Scene([points_mesh, mesh]) | ||
#scene.show(smooth=False) | ||
############################################################################# | ||
# VISUALIZATION USING EXTERNAL TOOLS | ||
############################################################################# | ||
# import trimesh.visual.color | ||
# ############################################################################### | ||
# # Visualize result | ||
# prof_points_mesh = profile_points.reshape( | ||
# profile_points.shape[0] * profile_points.shape[1], 3 | ||
# ) | ||
# prof_points_colors = np.zeros(prof_points_mesh.shape) | ||
# points_mesh = trimesh.points.PointCloud( | ||
# prof_points_mesh, colors=np.array(prof_points_colors, dtype=np.uint8) | ||
# ) | ||
# # set the points colors | ||
# red, yellow, green, blue = [ | ||
# [255, 0, 0, 255], | ||
# [255, 255, 0, 255], | ||
# [0, 255, 0, 255], | ||
# [0, 0, 255, 255], | ||
# ] | ||
# color_i = np.zeros(4) | ||
# for i in range(len(prof_points_mesh)): | ||
# degree = i / max_samples | ||
# num_profiles = int(360 / rot_angle) | ||
# segment_color = num_profiles / 3 | ||
# | ||
# if degree <= segment_color: | ||
# color_i = trimesh.visual.color.linear_color_map( | ||
# degree / segment_color, [red, yellow] | ||
# ) | ||
# elif segment_color < degree <= segment_color * 2: | ||
# color_i = trimesh.visual.color.linear_color_map( | ||
# degree / segment_color - 1, [yellow, green] | ||
# ) | ||
# elif segment_color * 2 < degree <= num_profiles: | ||
# color_i = trimesh.visual.color.linear_color_map( | ||
# degree / segment_color - 2, [green, blue] | ||
# ) | ||
# points_mesh.colors[i] = np.array(color_i) | ||
# | ||
# # create a scene with the mesh and profiling points | ||
# scene = trimesh.Scene([points_mesh, mesh]) | ||
# scene.show(smooth=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,26 +8,34 @@ | |
|
||
# Authors: Julien Lefevre <[email protected]> | ||
|
||
# License: BSD (3-clause) | ||
# License: MIT | ||
# sphinx_gallery_thumbnail_number = 2 | ||
|
||
############################################################################### | ||
# NOTE: there is no visualization tool in slam, but we provide at the | ||
# end of this script exemplare code to do the visualization with | ||
# an external solution | ||
############################################################################### | ||
|
||
############################################################################### | ||
# importation of slam modules | ||
import slam.plot as splt | ||
import slam.curvature as scurv | ||
import slam.generate_parametric_surfaces as sgps | ||
|
||
|
||
############################################################################### | ||
# Creating an examplar 3-4-...n hinge mesh | ||
|
||
hinge_mesh = sgps.generate_hinge(n_hinge=4) | ||
mesh_curvatures = scurv.curvatures_and_derivatives(hinge_mesh) | ||
mean_curvature = 1 / 2 * mesh_curvatures[0].sum(axis=0) | ||
|
||
visb_sc = splt.visbrain_plot( | ||
mesh=hinge_mesh, tex=mean_curvature, caption="hinge", cblabel="mean curvature" | ||
) | ||
|
||
visb_sc.preview() | ||
############################################################################# | ||
# VISUALIZATION USING EXTERNAL TOOLS | ||
# ############################################################################# | ||
# # Visualization with visbrain | ||
# visb_sc = splt.visbrain_plot( | ||
# mesh=hinge_mesh, | ||
# tex=mean_curvature, | ||
# caption="hinge", | ||
# cblabel="mean curvature" | ||
# ) | ||
# visb_sc.preview() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,67 +8,21 @@ | |
|
||
# Authors: Julien Lefevre <[email protected]> | ||
|
||
# License: BSD (3-clause) | ||
# License: MIT | ||
# sphinx_gallery_thumbnail_number = 2 | ||
|
||
|
||
############################################################################### | ||
# importation of slam modules | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from mpl_toolkits.mplot3d import Axes3D | ||
# NOTE: there is no visualization tool in slam, but we provide at the | ||
# end of this script exemplare code to do the visualization with | ||
# an external solution | ||
############################################################################### | ||
|
||
# importation of slam modules | ||
import slam.generate_parametric_surfaces as sgps | ||
import slam.curvature as scurv | ||
|
||
|
||
############################################################################### | ||
# Visualization of vector fields with matplotlib | ||
|
||
|
||
def visualize(mesh, vector_field, colors=None, params=None): | ||
""" | ||
Visualize a mesh and a vector field over it | ||
:param mesh: a mesh with n points | ||
:param vector_field: (n,3) array | ||
:param colors: (n,3) array | ||
:param params: params[0] is the length of the quivers | ||
:return: | ||
""" | ||
n = mesh.vertices.shape[0] | ||
if colors is None: | ||
colors = np.zeros((n, 3)) | ||
colors[:, 0] = 1 | ||
if params is None: | ||
params = [] | ||
params.append(0.1) | ||
|
||
fig = plt.figure() | ||
ax = Axes3D(fig) | ||
ax.plot_trisurf( | ||
mesh.vertices[:, 0], | ||
mesh.vertices[:, 1], | ||
mesh.vertices[:, 2], | ||
triangles=mesh.faces, | ||
shade=True, | ||
) | ||
plt.quiver( | ||
mesh.vertices[:, 0], | ||
mesh.vertices[:, 1], | ||
mesh.vertices[:, 2], | ||
vector_field[:, 0], | ||
vector_field[:, 1], | ||
vector_field[:, 2], | ||
length=params[0], | ||
colors=colors, | ||
) | ||
|
||
return fig | ||
|
||
|
||
############################################################################### | ||
# Create quadric mesh | ||
|
||
nstep = 20 | ||
equilateral = True | ||
|
||
|
@@ -86,13 +40,56 @@ def visualize(mesh, vector_field, colors=None, params=None): | |
|
||
############################################################################### | ||
# Compute principal directions of curvature | ||
|
||
PrincipalCurvatures, PrincipalDir1, PrincipalDir2 = scurv.curvatures_and_derivatives( | ||
quadric_mesh | ||
) | ||
PrincipalCurvatures, PrincipalDir1, PrincipalDir2 \ | ||
= scurv.curvatures_and_derivatives(quadric_mesh) | ||
|
||
############################################################################### | ||
# Visualization | ||
|
||
visualize(quadric_mesh, PrincipalDir1) | ||
plt.show() | ||
# VISUALIZATION USING EXTERNAL TOOLS | ||
############################################################################### | ||
# import numpy as np | ||
# import matplotlib.pyplot as plt | ||
# from mpl_toolkits.mplot3d import Axes3D | ||
# | ||
# ############################################################################# | ||
# # Visualization of vector fields with matplotlib | ||
# def visualize(mesh, vector_field, colors=None, params=None): | ||
# """ | ||
# Visualize a mesh and a vector field over it | ||
# :param mesh: a mesh with n points | ||
# :param vector_field: (n,3) array | ||
# :param colors: (n,3) array | ||
# :param params: params[0] is the length of the quivers | ||
# :return: | ||
# """ | ||
# n = mesh.vertices.shape[0] | ||
# if colors is None: | ||
# colors = np.zeros((n, 3)) | ||
# colors[:, 0] = 1 | ||
# if params is None: | ||
# params = [] | ||
# params.append(0.1) | ||
# | ||
# fig = plt.figure() | ||
# ax = Axes3D(fig) | ||
# ax.plot_trisurf( | ||
# mesh.vertices[:, 0], | ||
# mesh.vertices[:, 1], | ||
# mesh.vertices[:, 2], | ||
# triangles=mesh.faces, | ||
# shade=True, | ||
# ) | ||
# plt.quiver( | ||
# mesh.vertices[:, 0], | ||
# mesh.vertices[:, 1], | ||
# mesh.vertices[:, 2], | ||
# vector_field[:, 0], | ||
# vector_field[:, 1], | ||
# vector_field[:, 2], | ||
# length=params[0], | ||
# colors=colors, | ||
# ) | ||
# | ||
# return fig | ||
# | ||
# visualize(quadric_mesh, PrincipalDir1) | ||
# plt.show() |
Oops, something went wrong.