← Back to team overview

yade-users team mailing list archive

Re: [Question #406791]: error in making the .gts file from .stl file

 

Question #406791 on Yade changed:
https://answers.launchpad.net/yade/+question/406791

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi Alma,
sorry, there is no .gts file :-(

anyway, you can construct a gts surface based on facets, try the following
approach:

###################
import gts
from yade import ymport,pack
facets = ymport.stl('test.stl')
#O.bodies.append(facets)
s = gts.Surface()
for facet in facets: # creates fts.Face for each facet. The vertices and
edges are duplicated
vs = [facet.state.pos + facet.state.ori*v for v in facet.shape.vertices]
vs = [gts.Vertex(v[0],v[1],v[2]) for v in vs]
es = [gts.Edge(vs[i],vs[j]) for i,j in ((0,1),(1,2),(2,0))]
f = gts.Face(es[0],es[1],es[2])
s.add(f)
print s.is_closed() # since the vertices are duplicated, the surface is not
closed
threshold = 1e-3 # since using ori*v, the coordinates are not exactly same,
some nonzero threshold is needed
s.cleanup(threshold) # removes duplicated vertices and edges
print s.is_closed()
assert s.is_closed()
pred = pack.inGtsSurface(s)
r = 3
sphs = pack.regularHexa(pred,r,0)
O.bodies.append(sphs)
###################

cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.