mathLab / PyGeM

Python Geometrical Morphing
http://mathlab.github.io/PyGeM/
Other
333 stars 116 forks source link

Problem in reading stl from exemple 5 #238

Closed Lyshtar closed 2 years ago

Lyshtar commented 3 years ago

Hello, i am currently interesting in using stl files, i tryed exemple 5 but when i run it i got an error with stl_content = io.STLHandler.read(stl_filename)

telling that : File "/home/lcalmett/Documents/untitled0.py", line 67, in stl_content = io.STLHandler.read(stl_filename)

File "/home/lcalmett/anaconda3/envs/py37/lib/python3.7/site-packages/smithers-0.0.1-py3.7.egg/smithers/io/stlhandler.py", line 32, in read result['points'] = cls._vtk_tonumpy(data.GetPoints().GetData())

AttributeError: 'NoneType' object has no attribute 'GetData'

the exemple 5 work perfetly for VTP files but not STL, Do you have an idea to solve this issue? Best regards, Lucie

ndem0 commented 3 years ago

Dear @Lyshtar, It is not totally clear to me if you are running the tutorial or a modified version of the latter. I've just tried again the STL deformation and the points seem to be correctly extracted by the STL. Have you try to visualize the cube.stl file you downloaded, e.g. using Paraview?

Lyshtar commented 3 years ago

Dear @ndem0 , I tried to run the tutorial and got the previous error: " File "/home/lcalmett/anaconda3/envs/py37/lib/python3.7/site-packages/smithers-0.0.1-py3.7.egg/smithers/io/stlhandler.py", line 32, in read result['points'] = cls.vtk_to_numpy(data.GetPoints().GetData())

AttributeError: 'NoneType' object has no attribute 'GetData' " Yes, i tried to visualize it with paraview i get no problem, i tried to use different geometry but i always have this error when i use stlhandler, its seems to have trouble to read the stl file. When i print the data obtain from the cube.stl i got this: vtkPolyData (0x5645527f4950) Debug: Off Modified Time: 10891 Reference Count: 2 Registered Events: (none) Information: 0x564552f08bf0 Data Released: False Global Release Data: Off UpdateTime: 10910 Field Data: Debug: Off Modified Time: 10881 Reference Count: 1 Registered Events: (none) Number Of Arrays: 0 Number Of Components: 0 Number Of Tuples: 0 Number Of Points: 0 Number Of Cells: 0 Cell Data: Debug: Off Modified Time: 10889 Reference Count: 1 Registered Events: Registered Observers: vtkObserver (0x56455319d930) Event: 33 EventName: ModifiedEvent Command: 0x564552999270 Priority: 0 Tag: 1 Number Of Arrays: 0 Number Of Components: 0 Number Of Tuples: 0 Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 1 1 1 ) Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 ) Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 ) Scalars: (none) Vectors: (none) Normals: (none) TCoords: (none) Tensors: (none) GlobalIds: (none) PedigreeIds: (none) EdgeFlag: (none) Tangents: (none) RationalWeights: (none) HigherOrderDegrees: (none) Point Data: Debug: Off Modified Time: 10891 Reference Count: 1 Registered Events: Registered Observers: vtkObserver (0x564552efb2f0) Event: 33 EventName: ModifiedEvent Command: 0x564552999270 Priority: 0 Tag: 1 Number Of Arrays: 0 Number Of Components: 0 Number Of Tuples: 0 Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 1 1 1 ) Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 ) Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 ) Scalars: (none) Vectors: (none) Normals: (none) TCoords: (none) Tensors: (none) GlobalIds: (none) PedigreeIds: (none) EdgeFlag: (none) Tangents: (none) RationalWeights: (none) HigherOrderDegrees: (none) Bounds: Xmin,Xmax: (1, -1) Ymin,Ymax: (1, -1) Zmin,Zmax: (1, -1) Compute Time: 0 Editable: false Number Of Points: 0 Point Coordinates: 0 PointLocator: 0 CellLocator: 0 Number Of Vertices: 0 Number Of Lines: 0 Number Of Polygons: 0 Number Of Triangle Strips: 0 Number Of Pieces: 1 Piece: 0 Ghost Level: 0

I got no infomations in points, vertices.... I dont have this problem with VTPhandler

ndem0 commented 3 years ago

We have checked again the tutorial, on different computer and different environments, and no errors occur. Are you sure the STL file is not corrupted? Both the STLHandler and VTPHandler are based on the same library, the vtk module for Python. Have you tried to run the Smithers tests regarding the STLHandler? BTW I guess is a problem of the handler, not directly connected to PyGeM

Lyshtar commented 2 years ago

Thank you for your answer i've tried to run the smithers test, it work perfectly for vtp files but i have exactly the same mistake for stl file, maybe my problem is with the vtk module, i've read that some of people got mistakes with this module. I've tried different STL file, so i guess its not a corruption problem

Lyshtar commented 2 years ago

Hello, i've find a solution to make it work, in my STL description I need to replace all the . by , For exemple the STL format is normally: solid ascii facet normal -1 0 0 outer loop vertex -0.5 -0.5 -0.5 vertex -0.5 -0.5 0.5 vertex -0.5 0.5 -0.5 endloop endfacet .... and i change it by : solid ascii facet normal -1 0 0 outer loop vertex -0,5 -0,5 -0,5 vertex -0,5 -0,5 0,5 vertex -0,5 0,5 -0,5 endloop endfacet ....

Sadly paraview can't read it, i need to reconvert, this is a strange error, i guess it's from vtk, i have no clue on how to change it, do you think it's possible?