Comments (11)
I see why that happens. Would this be an acceptable solution?
settings.force_single_precision_points = False
a = vedo.Mesh([np.array([[1.5146416416146161461, 2.464164164164161461254, 3.145315134513465161441]], dtype=np.float64), [], []])
print(a.vertices.dtype)
# float64
(just pushed a version on master)
from vedo.
Yep, that's perfect! Thanks!
from vedo.
Hi, actually i'm not completely sure that that is the case.. e.g.
from vedo import *
Sphere().vertices.dtype
dtype('float32')
from vedo.
It doesn't occur with the bunny.obj dummy example but it does occur for high fidelity meshes. For example: https://www.artec3d.com/3d-models/buggy.
import vedo
import numpy as np
path = "Buggy.ply"
mesh = vedo.Mesh(path)
a = mesh.center_of_mass()
b = mesh.vertices.copy()
b.mean(axis=0)
c = b.astype(np.float64)
c.mean(axis=0)
# PLY: (Same for STL)
# A: array([-160.66834098, 23.57756032, -87.22478219])
# B: array([-160.66664 , 23.578615, -87.15967 ], dtype=float32)
# C: array([-160.66834098, 23.57756032, -87.22478219])
# Difference between B and A/C is floating point precision.
Note that vedo's definition of center of mass is actually just the mean for x, y and z (another topic).
As you can see from the above, computations are done in float64 in VTK but the data type outputted is float32. Therefore, any usage of numpy without explicitly setting the data type may result in this issue.
from vedo.
I don't fully understand though what is the issue here if I run
import vedo
mesh = vedo.Mesh("Buggy.ply")
a = mesh.center_of_mass()
print(a.dtype)
b = mesh.vertices#.copy()
print(b.dtype)
I get
float64
float32
but why do you say that this would cause problems?
from vedo.
There are several areas within the codebase where numpy is used within functions, with np.array(x) or np.array().float(), without specifying the data type. I've had to accommodate for this difference in a few areas. There are a few spots in my codebase where I round to 6 dp for comparisons and recently realised it's due to this issue.
For instance:
Line 791 in db0c0bf
- Vertices being converted to float32 here:
Line 1435 in db0c0bf
- Possibly here too
Line 203 in db0c0bf
from vedo.
Hi, the vtk2numpy()
function is not overriding the input type so it looks to me it's doing the right thing(?)
The other ones in file_io and backends are rather innocuous.
Note that you should not compare floats to floats and doubles to doubles directly without declaring a tolerance.
from vedo.
Fair. It isn't explicitly mentioned for users developing with vedo that VTK uses doubles by default. Could maybe throw something into the getting started section of the documents but regardless, will close this issue.
from vedo.
This is still causing me problems. Here's a useful example:
a = vedo.Mesh([np.array([[1.5146416416146161461, 2.464164164164161461254, 3145315134513465161441]], dtype=np.float64), [], []])
print(a.vertices)
# array([[1.5146416e+00, 2.4641643e+00, 3.1453151e+21]], dtype=float32)
from vedo.
Hi @marcomusy, currently running into a problem with this solution:
from vedo import Axes, Box, show
settings.force_single_precision_points = False
box = Box(pos=(1,2,3), length=8, width=9, height=7).alpha(0.1)
axs = Axes(box, c='k')
Running this gives: "TypeError: Could not find a suitable VTK type for float16". From what I can tell it looks like a problem with the Axes -- specifically it seems that the mesh for the fonts has its vertices in Float16 which now don't get converted into Float32 anymore.
from vedo.
Thanks for spotting the bug, This should now be fixed in master.
from vedo.
Related Issues (20)
- 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 4
- How to integrate interactive volume objects on Webpage? HOT 1
- Running vedo in a Docker container not working. HOT 2
- (x,y) coordinate format not working on LegendBox HOT 1
- test extract_cells_by_type() failing on 32-bit arches: Expecting a numpy.int32 array, got int64 instead. HOT 2
- Close an extruded mesh with a cover HOT 4
- Access faces of a mesh based on their ouput colour HOT 3
- DistanceTool Not Working HOT 2
- plane normal HOT 3
- Adding item to Group HOT 2
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.