Skip to content

Commit

Permalink
support tetgenpy
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Dec 7, 2023
1 parent 6761b2e commit f3e2e8b
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 159 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4587871.svg)](https://doi.org/10.5281/zenodo.4587871)
[![Downloads](https://static.pepy.tech/badge/vedo)](https://pepy.tech/project/vedo)
[![CircleCI](https://circleci.com/gh/marcomusy/vedo.svg?style=svg)](https://circleci.com/gh/marcomusy/vedo)


A lightweight and powerful python module
for scientific analysis and **v**isualization of **3d** **o**bjects.<br>

Expand Down
12 changes: 8 additions & 4 deletions docs/changes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

## Main changes

- fixes to `extrude()` thanks to @JeffreyWardman
Expand All @@ -10,6 +9,7 @@
- improvements on `plotter.__init__()`
- fix `labels()` and `labels2d()`
- add `shapes.plot_scalar()` plot a scalar along a line.
- add support for `tetgenpy`


## Breaking changes
Expand All @@ -36,6 +36,10 @@
```
examples/volumetric/slab_vol.py
examples/other/madcad1.py
examples/other/tetgen1.py
tests/issues/issue_968.py
tests/snippets/test_discourse_1956.py
```

### Broken Examples
Expand All @@ -47,9 +51,9 @@ markpoint.py
cut_and_cap.py
volumetric/streamlines1.py
mousehover1.py
mousehover1.py (unstable hovering?)
mousehover2.py (unstable hovering?)
read_volume3.py interactor lost
read_volume3.py interactor is lost
```

#### Broken Projects
Expand All @@ -64,6 +68,6 @@ mesh_lut.py
mesh_map2cell.py
texturecubes.py
meshquality.py
volumetric/streamlines1.py
streamlines1.py


8 changes: 8 additions & 0 deletions docs/examples_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,14 @@ vedo_example_db =
long : 'Use vedo with the'+insertLink('pygmsh library','github.com/nschloe/pygmsh'),
imgsrc: 'images/other/pygmsh_cut.png',
},
{
pyname: 'tetgen1',
kbd : '',
categ : 'other',
short : 'tetgenpy library',
long : 'Interface vedo to the'+insertLink('tetgenpy','github.com/tataratat/tetgenpy')+'library to create tetrahedral meshes.',
imgsrc: 'images/other/tetgen1.png',
},
{
pyname: 'remesh_ACVD',
kbd : 'acvd',
Expand Down
49 changes: 0 additions & 49 deletions examples/other/remesh_tetgen.py

This file was deleted.

59 changes: 59 additions & 0 deletions examples/other/tetgen1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Use tetgenpy to tetrahedralize a cube."""
try:
import tetgenpy
except ImportError:
print("tetgenpy not installed, try: pip install tetgenpy")
import vedo

# Tetrahedralize unit cube, define points
points = [
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[1.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
[1.0, 0.0, 1.0],
[0.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
]

# Define facets, here they are hexa faces
facets = [
[1, 0, 2, 3],
[0, 1, 5, 4],
[2, 0, 4, 6],
[1, 3, 7, 5],
[3, 2, 6, 7],
[4, 5, 7, 6],
]

# Prepare TetgenIO - input for tetgen
tetgen_in = tetgenpy.TetgenIO()

# Set points, facets, and facet_markers.
# facet_markers can be useful for setting boundary conditions
tetgen_in.setup_plc(
points=points,
facets=facets,
facet_markers=[[i] for i in range(1, len(facets) + 1)],
)

# Tetgen's tetraheralize function with switches
tetgen_out = tetgenpy.tetrahedralize("qa.05", tetgen_in)

# Unpack output
# print(tetgen_out.points())
# print(tetgen_out.tetrahedra())
# print(tetgen_out.trifaces())
# print(tetgen_out.trifacemarkers())

plt = vedo.Plotter().add_ambient_occlusion(0.1)
tmesh = vedo.TetMesh(tetgen_out).shrink().color("pink7")
plt.show(tmesh, axes=14).close()

# Or simply:
# vedo.show(tetgen_out, axes=14).close()

# Save to file
# tmesh.write("tetramesh.vtu")

4 changes: 2 additions & 2 deletions examples/volumetric/ugrid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
ug = ug.cut_with_plane(origin=(5,0,1), normal=(1,1,5))
show(repr(ug), ug, axes=1, viewup='z').close()

# Create a polygonal Mesh from the UGrid and shrink it
msh = ug.shrink(0.9).tomesh().c('gold',0.2)
# Shrink the UnstructuredGrid and create a Mesh
msh = ug.shrink(0.9).tomesh().color('gold', 0.2)
show(repr(msh), msh, axes=1, viewup='z').close()
12 changes: 12 additions & 0 deletions tests/issues/issue_968.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from vedo import *

letter = Text3D("A") #can be any Mesh
letter.pointdata["mydata"] = range(letter.npoints)
letter.cmap("Set1")
eletter = letter.clone().extrude(0.1)
eletter.cmap("Set1")
eletter.print()

show(letter, eletter, N=2, axes=1, viewup='z').close()


25 changes: 21 additions & 4 deletions tests/pipeline.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# TEST PIPELINE ################################
- Internal use only
################################################


# INSTALL ######################################
Expand All @@ -16,16 +17,17 @@ pip install meshio -U
pip install morphomatics -U
pip install pygeodesic -U
pip install pygmsh -U
#pip install pyacvd -U
#pip install pymeshfix -U
#pip install tetgen -U
pip install pymeshlab -U
pip install pymadcad -U
pip install pyshtools -U
pip install rtree
pip install trimesh -U
pip install -q trame==2.5.2
pip install qtpy
pip install tetgenpy -U
pip install gustaf -U
#pip install pyacvd -U
#pip install pymeshfix -U


# ENABLE/DISABLE DRY RUN ########################################################
Expand All @@ -40,7 +42,7 @@ cd $VDIR/examples && time ./run_all.sh 2>&1 | tee $VLOGFILE && alert "scan done.

grep -aA 1 "Error" $VLOGFILE
grep -aA 3 "Trace" $VLOGFILE
grep -aA 3 "failure" $VLOGFILE
grep -aA 3 "ailure" $VLOGFILE
code $VLOGFILE #### inspect logfile
# (Try normal run too with visualization to make sure all is ok)

Expand Down Expand Up @@ -125,6 +127,21 @@ cd ~/Projects/server/brainrender_orig/examples
################
cd ~/Projects/clonal_analysis2d_splines
python -m analysis_plots
################
cd ~/Projects/server/gustaf
git pull
pip install -e .
cd examples
python run_all_examples.py
################
cd ~/Projects/server/splinepy
git pull
pip install -e .
cd examples
python run_all_examples.py
################
cd ~/Projects/server/tetgenpy/examples
python plc_to_tets.py


# DOCUMETATION #################################
Expand Down
6 changes: 6 additions & 0 deletions tests/snippets/test_discourse_1956.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from vedo import *
lines = load("https://discourse.vtk.org/uploads/short-url/nC2RjJgTerpHKR0jD02Na6BRHVl.vtp")
for k in lines.pointdata.keys():
print("array:", k, lines.pointdata[k].dtype)
lines.cmap("rainbow", "cluster_idx")
show(lines, axes=1, bg='blackboard')
Loading

0 comments on commit f3e2e8b

Please sign in to comment.