Comments (6)
An 8 gets created for the LHS but not RHS in this example even though points are only assigned labels 0 or 9.
import numpy as np
import vedo
sphere = vedo.Sphere()
sphere.pointdata["Labels"] = np.zeros(sphere.npoints).astype(np.uint16)
sphere.copy().cut_with_plane(origin=(0, 0, 0), normal=(0, 0, -1))
xmin, xmax, ymin, ymax, zmin, zmax = sphere.bounds()
sphere.pointdata["Labels"][np.nonzero(sphere.vertices[:, 1] > (ymin + ymax) / 2)[0]] = 0
sphere.pointdata["Labels"][np.nonzero(sphere.vertices[:, 1] <= (ymin + ymax) / 2)[0]] = 9
sphere.cmap("jet", sphere.pointdata["Labels"])
vedo.show(sphere, axes=1).close()
left = sphere.copy().cut_with_plane(
origin=((xmin + xmax) / 2 + 0.001, (ymin + ymax) / 2 + 0.001, (zmin + zmax) / 2 + 0.001), normal=(1, 0, 0)
)
l_labels = left.pointdata["Labels"]
print(np.unique(l_labels))
left.show().close()
right = sphere.copy().cut_with_plane(
origin=sphere.vertices[0],
normal=(1, 0, 0),
invert=True,
)
r_labels = right.pointdata["Labels"]
print(np.unique(r_labels))
right.show().close()
The reason seems to be if cut_with_plane has some value that the vertices don't directly touch, therefore the algorithm generates new faces for some reason.
from vedo.
Hi - yes this is how VTK works, it interpolates the values to the new created vertices (which must be created to match the cutting plane surface):
import numpy as np
import vedo
vedo.settings.interpolate_scalars_before_mapping = False
sphere = vedo.Sphere(res=12).lw(1)
sphere.pointdata["Labels"] = np.zeros(sphere.npoints).astype(np.uint16)
xmin, xmax, ymin, ymax, zmin, zmax = sphere.bounds()
ids0 = np.nonzero(sphere.vertices[:, 1] > 0)[0]
ids9 = np.nonzero(sphere.vertices[:, 1] <= 0)[0]
sphere.pointdata["Labels"][ids0] = 0
sphere.pointdata["Labels"][ids9] = 9
print(np.unique(sphere.pointdata["Labels"]))
sphere.cmap("jet", "Labels", vmin=0, vmax=9)
# vedo.show(sphere, axes=1).close()
left = sphere.copy().cut_with_plane(origin=[0.1,0,0])
l_labels = left.pointdata["Labels"]
print(np.unique(l_labels))
left.show(axes=1).close()
[0 9]
[0 3 4 5 6 9]
this is an expected behavior..
from vedo.
Is there a way to cut_with_plane
without creating the new points and faces? Or to customise the interpolation method/get the newly generated point IDs?
from vedo.
you can grab the resulting array and threshold it manually in python/numpy.
Or check out examples:
examples/basic/mesh_threshold.py
from vedo.
Is it possible to output the ids of the new vertices to make it a bit simpler? Or to assign them a pointdata?
from vedo.
the only thing that comes up to my mind is again the .add_ids()
...
from vedo.
Related Issues (20)
- AttributeError: partially initialized module 'vedo' has no attribute 'Cone' (most likely due to a circular import) HOT 1
- Axisymmetric mesh with extrude HOT 4
- Is vedo thread-safe? HOT 1
- Want to use vedo to display and reconstruct 3D CT images HOT 4
- Data type discrepancies between numpy and VTK HOT 11
- About the button in vedo. HOT 2
- How to set a camera with given intrinsic and extrinsic parameters HOT 1
- How to add the slider? HOT 1
- How to load multiple Volumes in 1 3D interactive plane HOT 4
- Segmentation and Visualization of CT Scan Structures Based on Density in Vedo HOT 4
- Overlap on inside of Tube HOT 1
- Mesh cut with cut_with_box results in non water tight mesh HOT 2
- Optimize Loading and Visualization of Multiple .nii.gz Segments in Vedo HOT 1
- Issue with `mask` Function Example and Request for Assistance with `hide_voxels()` Function HOT 8
- How to flatten mesh to 2D and get its internal and external boundaries? HOT 8
- Vedo only render the change when I move my mouse on the screen HOT 6
- Vedo and torch.multiprocessing HOT 1
- How to change ImageScalars from volume.slice_plane() to be turned to image (numpy) ? HOT 3
- How to integrate interactive volume objects on Webpage?
- Running vedo in a Docker container not working. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vedo.