SINTEF / Splipy

Spline modelling made easy.
GNU General Public License v3.0
100 stars 18 forks source link

Loft operation #102

Closed VictorAlulema closed 4 years ago

VictorAlulema commented 4 years ago

Dear Andre, Could you provide an example code for the generation of the loft operation you present here: https://github.com/VikingScientist/Splipy/blob/master/images/loft.png https://github.com/VikingScientist/Splipy/blob/master/images/loft.png?raw=true

VikingScientist commented 4 years ago
# import just the parts we need
from splipy.io import G2
from splipy import curve_factory
from splipy import surface_factory
from splipy.utils.NACA import NACA
import numpy as np

# let the two first slices be circles
# scale them so they lie in the range x=(0,1)
c1 = curve_factory.circle(r=0.5) + (0.5, 0)
c2 = c1                + (0,0,1)

# create different NACA profiles. Multiplying them scales them,
# while the addition moves them to the right z-coordinate (height)
c3 = 1.0*NACA(2,4,40)  + (0,0,2)
c4 = 0.8*NACA(2,4,30)  + (0,0,3)
c5 = 0.7*NACA(2,4,20)  + (0,0,4)
c6 = 0.5*NACA(2,4,20)  + (0,0,5)
c7 = 0.2*NACA(2,4,20)  + (0,0,6)

# loft the surface
surf = surface_factory.loft(c1,c2,c3,c4,c5,c6,c7)

# strictly not neccessary, but swapping the parametric directions makes the
# current visualizer point outwards (right-hand rule). Inside is typically dark
surf.swap()

# dump the result in whatever format you fancy. g2 is the GoTools format and
# is accepted by our inhouse visualizer
with G2("out.g2") as f:
   f.write(surf)

More on the definition of NACA wing profiles: http://airfoiltools.com/airfoil/naca4digit

More on the definition of GoTools (G2) file format: https://github.com/SINTEF-Geometry/GoTools

Visualizer for G2 files: https://github.com/VikingScientist/SplineGUI

loft

VikingScientist commented 4 years ago

Was this helpful? Do you need any more assistance or can I close the thread?

VictorAlulema commented 4 years ago

Dear Kjetil In fact, it was very useful. However, I am having trouble when creating a lofted surface defined by two guide curves. According to the figure below, in addition to the profiles (red color), I want to define guide curves (blue color) to create the lofted surface. In the example you sent me, you create a series of airfoil cross sections and then they are blended using the loft function. Is it possible tu use the loft function with cross section profiles and also guide curves?

Thank you for your really valuable help. [Image]

Get Outlook for Androidhttps://aka.ms/ghei36


From: Kjetil Andre Johannessen notifications@github.com Sent: Monday, November 4, 2019, 3:39 AM To: sintefmath/Splipy Cc: Victor Hugo Alulema; Author Subject: Re: [sintefmath/Splipy] Loft operation (#102)

Was this helpful? Do you need any more assistance or can I close the thread?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/sintefmath/Splipy/issues/102?email_source=notifications&email_token=AK62JCU7TYVPC3WUSTPE2A3QR7NSHA5CNFSM4I4NK5GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC6Q6GI#issuecomment-549261081, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AK62JCQTJ2Z5NPLWFFW554TQR7NSHANCNFSM4I4NK5GA.

VikingScientist commented 4 years ago

The image was not attached properly so I will have to guess a little bit on your problem setup.

The loft operation is combining multiple cross sections into a combined surface. If you want to provide a guiding curve on which to drag a cross-sectional curve, then this functionality is covered by the sweep function: https://sintefmath.github.io/Splipy/factories.html?highlight=sweep#splipy.surface_factory.sweep

Also note that the loft operation assumes multiple curves. If you only have two curves then use edge_curves, and I think it might fail with exactly 3 curves, but for 4-5 or more it should behave as intended.

-- Kjetil

On Mon, Nov 4, 2019 at 12:34 PM Victor Hugo Alulema < notifications@github.com> wrote:

Dear Kjetil In fact, it was very useful. However, I am having trouble when creating a lofted surface defined by two guide curves. According to the figure below, in addition to the profiles (red color), I want to define guide curves (blue color) to create the lofted surface. In the example you sent me, you create a series of airfoil cross sections and then they are blended using the loft function. Is it possible tu use the loft function with cross section profiles and also guide curves?

Thank you for your really valuable help. [Image]

Get Outlook for Androidhttps://aka.ms/ghei36


From: Kjetil Andre Johannessen notifications@github.com Sent: Monday, November 4, 2019, 3:39 AM To: sintefmath/Splipy Cc: Victor Hugo Alulema; Author Subject: Re: [sintefmath/Splipy] Loft operation (#102)

Was this helpful? Do you need any more assistance or can I close the thread?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub< https://github.com/sintefmath/Splipy/issues/102?email_source=notifications&email_token=AK62JCU7TYVPC3WUSTPE2A3QR7NSHA5CNFSM4I4NK5GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC6Q6GI#issuecomment-549261081>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/AK62JCQTJ2Z5NPLWFFW554TQR7NSHANCNFSM4I4NK5GA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sintefmath/Splipy/issues/102?email_source=notifications&email_token=AA2WSWCXWEM7P7EAUJATLGTQSACFZA5CNFSM4I4NK5GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC66JYQ#issuecomment-549315810, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2WSWAWXNEYX32375X2NITQSACFZANCNFSM4I4NK5GA .

VikingScientist commented 4 years ago

@VictorAlulema seem to get the answer he was looking for, so I'm closing this issue. If you have any more questions or problems, just open more issues and I'll see if we can't get them solved.