Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
School_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
encinass1u
School_project
Merge requests
!2
Update README.md
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Update README.md
Student
into
main
Overview
0
Commits
51
Pipelines
0
Changes
1
Merged
encinass1u
requested to merge
Student
into
main
3 years ago
Overview
0
Commits
51
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
1cbc1375
Prev
Next
Show latest version
1 file
+
109
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
1cbc1375
Update and order files
· 1cbc1375
encinass1u
authored
3 years ago
stl_atributes.py
0 → 100644
+
109
−
0
Options
#Pyvista information from stl file
import
pyvista
as
pv
# operating system import
import
os
from
scipy
import
misc
from
mpl_toolkits
import
mplot3d
from
matplotlib
import
pyplot
as
plt
import
pyvista
test_list
=
[
"
SMAT
"
,
\
]
# file path
file_path
=
os
.
getcwd
()
+
os
.
sep
+
"
data
"
# file path
result_path
=
os
.
getcwd
()
+
os
.
sep
+
"
results
"
if
os
.
path
.
isdir
(
result_path
)
==
False
:
os
.
mkdir
(
result_path
)
name
=
'
Surface
'
# post processing loop
for
i
,
m
in
enumerate
(
test_list
)
:
# TRA filename
filename
=
m
+
"
.stl
"
tata
=
pv
.
read
(
file_path
+
os
.
sep
+
filename
)
#Printing and saving stl parameters
cells
=
tata
.
n_cells
points
=
tata
.
n_points
bounds
=
tata
.
bounds
arrays
=
tata
.
n_arrays
print
(
tata
.
n_cells
)
print
(
tata
.
n_points
)
print
(
tata
.
bounds
)
print
(
tata
.
n_arrays
)
print
(
tata
.
area
)
#show surface with metallic attributes for a clearer view and roughness signaling
tata
.
plot
(
cpos
=
'
xy
'
,
cmap
=
'
plasma
'
,
pbr
=
True
,
metallic
=
1.0
,
roughness
=
0.3
,
zoom
=
0.7
,
text
=
'
SMATed surface
'
,
return_cpos
=
False
,
hidden_line_removal
=
True
,
anti_aliasing
=
True
)
#Filter to obtain curvature values of the surface for further treatment into values of 0 and 1.
tata_filtered
=
tata
.
plot_curvature
(
curv_type
=
'
gaussian
'
,
smooth_shading
=
True
,
clim
=
[
0
,
1
])
Gaus
=
tata
.
get_array
(
'
Gaussian Curvature
'
)
print
(
Gaus
)
#Locate the arrays inside the PolyData, this provides the arrays containing values of scalars, normals
#faces and points.
print
(
tata
.
array_names
)
#printing the array founded and saving it as a tuple inside a callable variable
choc
=
tata
.
get_array
(
'
Normals
'
)
tata
.
save
(
'
tata.vtk
'
)
#Data range, min,max given
tata_r
=
tata
.
get_data_range
()
#Edges showing in red
tata
.
plot_boundaries
(
line_width
=
5
)
choc
=
choc
.
plot_curvature
(
curv_type
=
'
gaussian
'
,
smooth_shading
=
True
,
clim
=
[
0
,
1
])
#Make a plane figure with edges planed, erased the edges due to the high aglomeration
#In this model we can see how the values change along the plane
projected
=
tata
.
project_points_to_plane
()
projected
.
plot
(
show_edges
=
False
,
line_width
=
0.3
)
#Code to show the mesh that composes the figure
mesh
=
tata
mesh
.
point_data
.
clear
()
centers
=
mesh
.
cell_centers
()
pl
=
pyvista
.
Plotter
()
actor
=
pl
.
add_mesh
(
mesh
,
show_edges
=
False
)
actor
=
pl
.
add_points
(
centers
,
render_points_as_spheres
=
True
,
color
=
'
red
'
,
point_size
=
10
)
pl
.
show
()
#Code to show the elevation in the Z plane
tata_elv
=
tata
.
elevation
()
print
(
tata_elv
)
tata_elv
.
plot
(
smooth_shading
=
True
)
# Calculate de distance of entitites from a plane in the middle, doesnt stays in the middle the plane
plane
=
pv
.
Plane
()
_
=
tata
.
compute_implicit_distance
(
plane
,
inplace
=
True
)
dist
=
tata
[
'
implicit_distance
'
]
type
(
dist
)
pl
=
pv
.
Plotter
()
_
=
pl
.
add_mesh
(
tata
,
scalars
=
'
implicit_distance
'
,
cmap
=
'
bwr
'
)
_
=
pl
.
add_mesh
(
plane
,
color
=
'
w
'
,
style
=
'
wireframe
'
)
pl
.
show
()
merged
=
tata
.
merge
(
plane
)
merged
.
plot
(
style
=
'
wireframe
'
,
color
=
'
tan
'
)
ow
=
tata
.
overwrite
(
plane
)
merged
.
plot
(
style
=
'
wireframe
'
,
color
=
'
tan
'
)
#Interpolation of our data in a mesh
pdata
=
pyvista
.
PolyData
(
tata
)
plane
=
pyvista
.
Plane
()
plane
.
clear_data
()
plane
=
plane
.
interpolate
(
pdata
,
sharpness
=
3
)
pl
=
pyvista
.
Plotter
()
_
=
pl
.
add_mesh
(
pdata
,
render_points_as_spheres
=
True
,
point_size
=
50
)
_
=
pl
.
add_mesh
(
plane
,
style
=
'
wireframe
'
,
line_width
=
5
)
pl
.
show
()
# Normal ploting
tata
.
plot_normals
(
mag
=
0.1
,
faces
=
False
,
show_edges
=
False
)
\ No newline at end of file
Loading