Skip to main content
added 5 characters in body
Source Link
Greg Hurst
  • 39.3k
  • 1
  • 101
  • 147

We can call libigl in Python through ExternalEvaluate:

$igl = StartExternalSession[ Association["System" -> "Python", "Evaluator" -> <|"Dependencies" -> {"libigl"}, "EnvironmentName" -> "iglenv"|>]]; ExternalEvaluate[$igl, " import igl import numpy as np import os def compute_uv(filename: str) -> np.ndarray: V, F = igl.read_triangle_mesh(filename) bnd = igl.boundary_loop(F) b = np.array([bnd[0], bnd[len(bnd) // 2]]) bc = np.array([[0.0, 0.0], [1.0, 0.0]]) UV = igl.lscm(V, F, b, bc) return UV[0] "]; 

Right now we have to pass in a file. I tried doing stuff like

def compute_uv(V: np.array, F: np.array) -> np.array:

but I couldn't figure out how to pass in arrays to python as the right type.

ptsvertices = Import["/Users/ghurst/Downloads/theX.csv"]; triangles = Import["/Users/ghurst/Downloads/theT.csv"]; Export["temp.obj", MeshRegion[pts, Polygon[triangles]]]; 

And now we get the uv data and plot:

uvs = Normal[ExternalEvaluate[$igl, "compute_uv('temp.obj')"]]; texture = ImageResize[Image[Table[Mod[i + j, 2], {i, 8}, {j, 8}]], Scaled[30], Resampling -> "Nearest"]; Graphics3D[{Texture[texture], EdgeForm[], GraphicsComplex[ vertices, Polygon[triangles], VertexTextureCoordinates -> uvs ]}, Lighting -> "Accent", Boxed -> False, ViewVertical -> {0, 1, 0}, ViewPoint -> {0, 0, 4} ] 

We can call libigl in Python through ExternalEvaluate:

$igl = StartExternalSession[ Association["System" -> "Python", "Evaluator" -> <|"Dependencies" -> {"libigl"}, "EnvironmentName" -> "iglenv"|>]]; ExternalEvaluate[$igl, " import igl import numpy as np import os def compute_uv(filename: str) -> np.ndarray: V, F = igl.read_triangle_mesh(filename) bnd = igl.boundary_loop(F) b = np.array([bnd[0], bnd[len(bnd) // 2]]) bc = np.array([[0.0, 0.0], [1.0, 0.0]]) UV = igl.lscm(V, F, b, bc) return UV[0] "]; 

Right now we have to pass in a file. I tried doing stuff like

def compute_uv(V: np.array, F: np.array) -> np.array:

but I couldn't figure out how to pass in arrays to python as the right type.

pts = Import["/Users/ghurst/Downloads/theX.csv"]; triangles = Import["/Users/ghurst/Downloads/theT.csv"]; Export["temp.obj", MeshRegion[pts, Polygon[triangles]]]; 

And now we get the uv data and plot:

uvs = Normal[ExternalEvaluate[$igl, "compute_uv('temp.obj')"]]; texture = ImageResize[Image[Table[Mod[i + j, 2], {i, 8}, {j, 8}]], Scaled[30], Resampling -> "Nearest"]; Graphics3D[{Texture[texture], EdgeForm[], GraphicsComplex[ vertices, Polygon[triangles], VertexTextureCoordinates -> uvs ]}, Lighting -> "Accent", Boxed -> False, ViewVertical -> {0, 1, 0}, ViewPoint -> {0, 0, 4} ] 

We can call libigl in Python through ExternalEvaluate:

$igl = StartExternalSession[ Association["System" -> "Python", "Evaluator" -> <|"Dependencies" -> {"libigl"}, "EnvironmentName" -> "iglenv"|>]]; ExternalEvaluate[$igl, " import igl import numpy as np import os def compute_uv(filename: str) -> np.ndarray: V, F = igl.read_triangle_mesh(filename) bnd = igl.boundary_loop(F) b = np.array([bnd[0], bnd[len(bnd) // 2]]) bc = np.array([[0.0, 0.0], [1.0, 0.0]]) UV = igl.lscm(V, F, b, bc) return UV[0] "]; 

Right now we have to pass in a file. I tried doing stuff like

def compute_uv(V: np.array, F: np.array) -> np.array:

but I couldn't figure out how to pass in arrays to python as the right type.

vertices = Import["/Users/ghurst/Downloads/theX.csv"]; triangles = Import["/Users/ghurst/Downloads/theT.csv"]; Export["temp.obj", MeshRegion[pts, Polygon[triangles]]]; 

And now we get the uv data and plot:

uvs = Normal[ExternalEvaluate[$igl, "compute_uv('temp.obj')"]]; texture = ImageResize[Image[Table[Mod[i + j, 2], {i, 8}, {j, 8}]], Scaled[30], Resampling -> "Nearest"]; Graphics3D[{Texture[texture], EdgeForm[], GraphicsComplex[ vertices, Polygon[triangles], VertexTextureCoordinates -> uvs ]}, Lighting -> "Accent", Boxed -> False, ViewVertical -> {0, 1, 0}, ViewPoint -> {0, 0, 4} ] 
deleted 83 characters in body
Source Link
Greg Hurst
  • 39.3k
  • 1
  • 101
  • 147

We can call libigl in Python through ExternalEvaluate:

$igl = StartExternalSession[ Association["System" -> "Python", "Evaluator" -> <|"Dependencies" -> {"libigl"}, "EnvironmentName" -> "iglenv"|>]]; ExternalEvaluate[$igl, " import igl import numpy as np import os def compute_uv(filename: str) -> np.ndarray: V, F = igl.read_triangle_mesh(filename) bnd = igl.boundary_loop(F) b = np.array([bnd[0], bnd[len(bnd) // 2]]) bc = np.array([[0.0, 0.0], [1.0, 0.0]]) UV = igl.lscm(V, F, b, bc) return UV[0] "]; 

Right now we have to pass in a file. I tried doing stuff like

def compute_uv(V: np.array, F: np.array) -> np.array:

but I couldn't figure out how to pass in arrays to python as the right type.

pts = Import["/Users/ghurst/Downloads/theX.csv"]; triangles = Import["/Users/ghurst/Downloads/theT.csv"]; Export["temp.obj", MeshRegion[pts, Polygon[triangles]]]; 

And now we get the uv data and plot:

uvs = Normal[ExternalEvaluate[$igl, "compute_uv('temp.obj')"]]; ixtexture = Interpolation[Transpose[{pt[[AllImageResize[Image[Table[Mod[i + j, 2], {1i, 28}]], uv[[All{j, 1]]8}]]],  Scaled[30], InterpolationOrderResampling -> 1];"Nearest"]; iy = Interpolation[Transpose[ Graphics3D[{pt[[AllTexture[texture], {1EdgeForm[], 2}]], uv[[All,   2]]}], GraphicsComplex[   InterpolationOrder -> 1]; ListPlot3D[ptvertices,   ViewPoint -> Top Polygon[triangles], BoxRatios   -> Automatic,    MeshFunctionsVertexTextureCoordinates -> ({ix[#1,uvs  #2] &]},   iy[#1, #2]Lighting &})-> "Accent", Mesh Boxed -> 18False,  MeshShading ViewVertical -> {{Black, Yellow}0, {Yellow1, Black}0},  Method -> {"RotationControl"ViewPoint -> "ArcBall"}{0, Boxed -> False0, 4}  Axes -> False]] 

We can call libigl in Python through ExternalEvaluate:

$igl = StartExternalSession[ Association["System" -> "Python", "Evaluator" -> <|"Dependencies" -> {"libigl"}, "EnvironmentName" -> "iglenv"|>]]; ExternalEvaluate[$igl, " import igl import numpy as np import os def compute_uv(filename: str) -> np.ndarray: V, F = igl.read_triangle_mesh(filename) bnd = igl.boundary_loop(F) b = np.array([bnd[0], bnd[len(bnd) // 2]]) bc = np.array([[0.0, 0.0], [1.0, 0.0]]) UV = igl.lscm(V, F, b, bc) return UV[0] "]; 

Right now we have to pass in a file. I tried doing stuff like

def compute_uv(V: np.array, F: np.array) -> np.array:

but I couldn't figure out how to pass in arrays to python as the right type.

pts = Import["/Users/ghurst/Downloads/theX.csv"]; triangles = Import["/Users/ghurst/Downloads/theT.csv"]; Export["temp.obj", MeshRegion[pts, Polygon[triangles]]]; 

And now we get the uv data and plot:

uvs = Normal[ExternalEvaluate[$igl, "compute_uv('temp.obj')"]]; ix = Interpolation[Transpose[{pt[[All, {1, 2}]], uv[[All, 1]]}],   InterpolationOrder -> 1]; iy = Interpolation[Transpose[{pt[[All, {1, 2}]], uv[[All, 2]]}],   InterpolationOrder -> 1]; ListPlot3D[pt, ViewPoint -> Top, BoxRatios -> Automatic,    MeshFunctions -> ({ix[#1, #2] &, iy[#1, #2] &}), Mesh -> 18,  MeshShading -> {{Black, Yellow}, {Yellow, Black}},  Method -> {"RotationControl" -> "ArcBall"}, Boxed -> False,  Axes -> False] 

We can call libigl in Python through ExternalEvaluate:

$igl = StartExternalSession[ Association["System" -> "Python", "Evaluator" -> <|"Dependencies" -> {"libigl"}, "EnvironmentName" -> "iglenv"|>]]; ExternalEvaluate[$igl, " import igl import numpy as np import os def compute_uv(filename: str) -> np.ndarray: V, F = igl.read_triangle_mesh(filename) bnd = igl.boundary_loop(F) b = np.array([bnd[0], bnd[len(bnd) // 2]]) bc = np.array([[0.0, 0.0], [1.0, 0.0]]) UV = igl.lscm(V, F, b, bc) return UV[0] "]; 

Right now we have to pass in a file. I tried doing stuff like

def compute_uv(V: np.array, F: np.array) -> np.array:

but I couldn't figure out how to pass in arrays to python as the right type.

pts = Import["/Users/ghurst/Downloads/theX.csv"]; triangles = Import["/Users/ghurst/Downloads/theT.csv"]; Export["temp.obj", MeshRegion[pts, Polygon[triangles]]]; 

And now we get the uv data and plot:

uvs = Normal[ExternalEvaluate[$igl, "compute_uv('temp.obj')"]]; texture = ImageResize[Image[Table[Mod[i + j, 2], {i, 8}, {j, 8}]], Scaled[30], Resampling -> "Nearest"];  Graphics3D[{Texture[texture], EdgeForm[],    GraphicsComplex[ vertices,    Polygon[triangles],    VertexTextureCoordinates -> uvs  ]},   Lighting -> "Accent",  Boxed -> False,  ViewVertical -> {0, 1, 0}, ViewPoint -> {0, 0, 4} ] 
deleted 5 characters in body
Source Link
Greg Hurst
  • 39.3k
  • 1
  • 101
  • 147

We can call libigl in Python through ExternalEvaluate:

$igl = StartExternalSession[ Association["System" -> "Python", "Evaluator" -> <|"Dependencies" -> {"libigl"}, "EnvironmentName" -> "iglenv"|>]]; ExternalEvaluate[$igl, " import igl import numpy as np import os def compute_uv(filename: str) -> np.ndarray: V, F = igl.read_triangle_mesh(filename) bnd = igl.boundary_loop(F) b = np.array([bnd[0], bnd[len(bnd) // 2]]) bc = np.array([[0.0, 0.0], [1.0, 0.0]]) UV = igl.lscm(V, F, b, bc) return UV[0] "]; 

Right now we have to pass in a file. I tried doing stuff like

def compute_uv(V: np.array, F: np.array) -> np.array:

but I couldn't figure out how to pass in arrays to python as the right type.

pts = Import["/Users/ghurst/Downloads/theX.csv"]; triangles = Import["/Users/ghurst/Downloads/theT.csv"]; Export["temp.obj", MeshRegion[pts, Polygon[triangles]]]; 

And now we get the uv data and plot:

uvs = Normal[ExternalEvaluate[$igl, "compute_uv_lscm"compute_uv('temp.obj')"]]; ix = Interpolation[Transpose[{pt[[All, {1, 2}]], uv[[All, 1]]}], InterpolationOrder -> 1]; iy = Interpolation[Transpose[{pt[[All, {1, 2}]], uv[[All, 2]]}], InterpolationOrder -> 1]; ListPlot3D[pt, ViewPoint -> Top, BoxRatios -> Automatic, MeshFunctions -> ({ix[#1, #2] &, iy[#1, #2] &}), Mesh -> 18, MeshShading -> {{Black, Yellow}, {Yellow, Black}}, Method -> {"RotationControl" -> "ArcBall"}, Boxed -> False, Axes -> False] 

We can call libigl in Python through ExternalEvaluate:

$igl = StartExternalSession[ Association["System" -> "Python", "Evaluator" -> <|"Dependencies" -> {"libigl"}, "EnvironmentName" -> "iglenv"|>]]; ExternalEvaluate[$igl, " import igl import numpy as np import os def compute_uv(filename: str) -> np.ndarray: V, F = igl.read_triangle_mesh(filename) bnd = igl.boundary_loop(F) b = np.array([bnd[0], bnd[len(bnd) // 2]]) bc = np.array([[0.0, 0.0], [1.0, 0.0]]) UV = igl.lscm(V, F, b, bc) return UV[0] "]; 

Right now we have to pass in a file. I tried doing stuff like

def compute_uv(V: np.array, F: np.array) -> np.array:

but I couldn't figure out how to pass in arrays to python as the right type.

pts = Import["/Users/ghurst/Downloads/theX.csv"]; triangles = Import["/Users/ghurst/Downloads/theT.csv"]; Export["temp.obj", MeshRegion[pts, Polygon[triangles]]]; 

And now we get the uv data and plot:

uvs = Normal[ExternalEvaluate[$igl, "compute_uv_lscm('temp.obj')"]]; ix = Interpolation[Transpose[{pt[[All, {1, 2}]], uv[[All, 1]]}], InterpolationOrder -> 1]; iy = Interpolation[Transpose[{pt[[All, {1, 2}]], uv[[All, 2]]}], InterpolationOrder -> 1]; ListPlot3D[pt, ViewPoint -> Top, BoxRatios -> Automatic, MeshFunctions -> ({ix[#1, #2] &, iy[#1, #2] &}), Mesh -> 18, MeshShading -> {{Black, Yellow}, {Yellow, Black}}, Method -> {"RotationControl" -> "ArcBall"}, Boxed -> False, Axes -> False] 

We can call libigl in Python through ExternalEvaluate:

$igl = StartExternalSession[ Association["System" -> "Python", "Evaluator" -> <|"Dependencies" -> {"libigl"}, "EnvironmentName" -> "iglenv"|>]]; ExternalEvaluate[$igl, " import igl import numpy as np import os def compute_uv(filename: str) -> np.ndarray: V, F = igl.read_triangle_mesh(filename) bnd = igl.boundary_loop(F) b = np.array([bnd[0], bnd[len(bnd) // 2]]) bc = np.array([[0.0, 0.0], [1.0, 0.0]]) UV = igl.lscm(V, F, b, bc) return UV[0] "]; 

Right now we have to pass in a file. I tried doing stuff like

def compute_uv(V: np.array, F: np.array) -> np.array:

but I couldn't figure out how to pass in arrays to python as the right type.

pts = Import["/Users/ghurst/Downloads/theX.csv"]; triangles = Import["/Users/ghurst/Downloads/theT.csv"]; Export["temp.obj", MeshRegion[pts, Polygon[triangles]]]; 

And now we get the uv data and plot:

uvs = Normal[ExternalEvaluate[$igl, "compute_uv('temp.obj')"]]; ix = Interpolation[Transpose[{pt[[All, {1, 2}]], uv[[All, 1]]}], InterpolationOrder -> 1]; iy = Interpolation[Transpose[{pt[[All, {1, 2}]], uv[[All, 2]]}], InterpolationOrder -> 1]; ListPlot3D[pt, ViewPoint -> Top, BoxRatios -> Automatic, MeshFunctions -> ({ix[#1, #2] &, iy[#1, #2] &}), Mesh -> 18, MeshShading -> {{Black, Yellow}, {Yellow, Black}}, Method -> {"RotationControl" -> "ArcBall"}, Boxed -> False, Axes -> False] 
Source Link
Greg Hurst
  • 39.3k
  • 1
  • 101
  • 147
Loading