Closed VikingScientist closed 6 years ago
Not especially nice interface right now, and very limited functionality, but it is a start on which we can build on.
with G2('g2_files_with_trimmed_surfaces.g2') as myfile:
my_model = myfile.read()
trim_loop = [CurveFactory.line([.25,.25], [.75,.25]),
CurveFactory.line([.75,.25], [.75,.75]),
CurveFactory.line([.75,.75], [.25,.75]),
CurveFactory.line([.25,.75], [.25,.25])]
# defaults basis1=basis2=linear, unit square identity parametrization
s = TrimmedSurface(loops=[trim_loop])
I kind of like this one
for loop in surface.boundaries:
for curve in loop:
x = lambda t: surface(curve(t)[:,0], curve(t)[:,1], tensor=False)
my_crvs.append(CurveFactory.fit(x, curve.start(0), curve.end(0)))
for all curve pieces, for all closed trimming loops you evaluate the points of that curve, to get the parametric points of the underlying surface. This surface then needs to be sampled to get the final coordinates in physical space. Using a lambda to wrap this "double"-evaluation makes it possible to use CurveFactory.fit( )
which does non-uniform adaptive refinement up to some desired tolerance. Pretty compact, powerful and neat.
Also support for more g2 classes:
Also fixed some numerical precision bugs
CurveFactory.fit( )