> 
> > Interested in making an airfoil. But how to run this
code. When I double clicked it, a window poped up but soon disappeared.

> 
> Its just a snippet, not a full program.
> 

It's working now. I added z coordinate and drawn two airfoils. Interested in 
building a sureface with it later.

The code is here:


from OCC.Utils.Common import interpolate_points_to_spline_no_tangency
from OCC.Utils.Construct import *
from OCC.KBE.Level2API import Curve
from OCC.Utils.Topology import *

import math

from OCC.Display.SimpleGui import *
from OCC.BRepPrimAPI import *
display, start_display, add_menu, add_function_to_menu = init_display()

#===============================================================================
# CONSTANTS
#===============================================================================
 
TOLERANCE = 1e-6
TRAITS = False
EXPORT = 'iges' # 'step'
#===============================================================================
# FUNCTIONS
#===============================================================================
 
def naca_curve(z,length, thickness_to_chord, show):

    c = length
    t = thickness_to_chord
    
    def y(x):
        x_c = x/c
        x_c2 = x_c * x_c
        x_c3 = x_c2 * x_c
        x_c4 = x_c3 * x_c
        y = 
10*t*c*(0.2929*math.sqrt(x_c)-0.1260*x_c-0.3516*x_c2+0.2843*x_c3-0.1015*x_c4)
        return y
    
    points_coord = []
    x = 0.0
    x_step = 0.1
    while x<=c:
        points_coord.append([x,y(x),z])
        x += x_step
 
    crv1, crv2 = [], []
 
    for point in points_coord:
        P1 = gp_Pnt(point[0], z, point[1])
        P2 = gp_Pnt(point[0], z, -point[1])
        if show:
            display.DisplayShape(map(make_vertex, [P1,P2]))
        
        crv1.append(P1)
        crv2.append(P2)
 
    crv2.reverse()
    crv1 += crv2
    
    interpolated_curve1 = 
make_edge(interpolate_points_to_spline_no_tangency(crv1,
                                                                  False,
                                                                  False
                                                                  )
                                                            )
    return interpolated_curve1

naca_curve(1,10,0.1,1)
naca_curve(2,15,0.2,1)

start_display()




                                          
_________________________________________________________________
一张照片的自白――Windows Live照片的可爱视频介绍
http://windowslivesky.spaces.live.com/blog/cns!5892B6048E2498BD!889.entry
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to