# python – Integral of a function around a 3D curve in STL format

As the title suggests, I am trying to perform the integral of some functions around the shape of a custom curve saved as a STL file (I also have STP and SKP). The integrals would look something similar to the following one:

Where B(x) is the length of the curve in an YZ section at point x and the integral is taken accross the length of the shape (note that, without the x term multiplying B(x), the result of the integral would correspond to the surface of the curve).

I thought it would be possible to do it in an easy way by converting the STL model into a bidimensional array and performing something like (pseudocode warning):

int = 0
for x in model[:]:
for y in model[x][:]:
int += x * model[x][y]


I definitely have no clue about how to do this. I tried coding some Python with the numpy-stl package but an STL file contains data about the mesh itself (specific triangles) I am not able to express my 3D curve as a matrix of points in a uniformly distributed lattice

Any help will be welcome.