def make_face_to_contour_from(): v1 = make_vertex(gp_Pnt(0, 0, 0)) v2 = make_vertex(gp_Pnt(10, 0, 0)) v3 = make_vertex(gp_Pnt(7, 10, 0)) v4 = make_vertex(gp_Pnt(10, 20, 0)) v5 = make_vertex(gp_Pnt(0, 20, 0)) v6 = make_vertex(gp_Pnt(3, 10, 0)) e1 = make_edge(v1, v2) e2 = make_edge(v2, v3) e3 = make_edge(v3, v4) e4 = make_edge(v4, v5) e5 = make_edge(v5, v6) e6 = make_edge(v6, v1) v7 = make_vertex(gp_Pnt(2, 2, 0)) v8 = make_vertex(gp_Pnt(8, 2, 0)) v9 = make_vertex(gp_Pnt(7, 3, 0)) v10 = make_vertex(gp_Pnt(3, 3, 0)) e7 = make_edge(v7, v8) e8 = make_edge(v8, v9) e9 = make_edge(v9, v10) e10 = make_edge(v10, v7) w1 = make_wire([e1, e2, e3, e4, e5, e6]) f = make_face(w1) w2 = make_wire(e7, e8, e9, e10) f2 = make_face(w2) f3 = boolean_cut(f, f2) return f3
def make_shape(self): # 1 - retrieve the data from the UIUC airfoil data page foil_dat_url = 'http://www.ae.illinois.edu/m-selig/ads/coord_seligFmt/%s.dat' % self.profile if py2: f = urllib2.urlopen(foil_dat_url) else: http = urllib3.PoolManager() f = http.urlopen('GET', foil_dat_url).data.decode() f = io.StringIO(f) plan = gp_Pln(gp_Pnt(0., 0., 0.), gp_Dir(0., 0., 1.)) # Z=0 plan / XY plan section_pts_2d = [] for line in f.readlines()[1:]: # The first line contains info only # 2 - do some cleanup on the data (mostly dealing with spaces) line = line.lstrip().rstrip().replace(' ', ' ').replace( ' ', ' ').replace(' ', ' ') data = line.split(' ') # data[0] = x coord. data[1] = y coord. # 3 - create an array of points if len(data) == 2: # two coordinates for each point section_pts_2d.append( gp_Pnt2d( float(data[0]) * self.chord, float(data[1]) * self.chord)) # 4 - use the array to create a spline describing the airfoil section spline_2d = Geom2dAPI_PointsToBSpline( point2d_list_to_TColgp_Array1OfPnt2d(section_pts_2d), len(section_pts_2d) - 1, # order min len(section_pts_2d)) # order max spline = geomapi.To3d(spline_2d.Curve(), plan) # 5 - figure out if the trailing edge has a thickness or not, # and create a Face try: # first and last point of spline -> trailing edge trailing_edge = make_edge( gp_Pnt(section_pts_2d[0].X(), section_pts_2d[0].Y(), 0.0), gp_Pnt(section_pts_2d[-1].X(), section_pts_2d[-1].Y(), 0.0)) face = BRepBuilderAPI_MakeFace( make_wire([make_edge(spline), trailing_edge])) except AssertionError: # the trailing edge segment could not be created, probably because # the points are too close # No need to build a trailing edge face = BRepBuilderAPI_MakeFace(make_wire(make_edge(spline))) # 6 - extrude the Face to create a Solid return BRepPrimAPI_MakePrism( face.Face(), gp_Vec(gp_Pnt(0., 0., 0.), gp_Pnt(0., 0., self.span))).Shape()
def make_shape(self): # 1 - retrieve the data from the UIUC airfoil data page foil_dat_url = 'http://www.ae.illinois.edu/m-selig/ads/coord_seligFmt/%s.dat' % self.profile f = urllib2.urlopen(foil_dat_url) plan = gp_Pln(gp_Pnt(0., 0., 0.), gp_Dir(0., 0., 1.)) # Z=0 plan / XY plan section_pts_2d = [] for line in f.readlines()[1:]: # The first line contains info only # 2 - do some cleanup on the data (mostly dealing with spaces) line = line.lstrip().rstrip().replace(' ', ' ').replace(' ', ' ').replace(' ', ' ') data = line.split(' ') # data[0] = x coord. data[1] = y coord. # 3 - create an array of points if len(data) == 2: # two coordinates for each point section_pts_2d.append(gp_Pnt2d(float(data[0])*self.chord, float(data[1])*self.chord)) # 4 - use the array to create a spline describing the airfoil section spline_2d = Geom2dAPI_PointsToBSpline(point2d_list_to_TColgp_Array1OfPnt2d(section_pts_2d), len(section_pts_2d)-1, # order min len(section_pts_2d)) # order max spline = geomapi.To3d(spline_2d.Curve(), plan) # 5 - figure out if the trailing edge has a thickness or not, # and create a Face try: #first and last point of spline -> trailing edge trailing_edge = make_edge(gp_Pnt(section_pts_2d[0].X(), section_pts_2d[0].Y(), 0.0), gp_Pnt(section_pts_2d[-1].X(), section_pts_2d[-1].Y(), 0.0)) face = BRepBuilderAPI_MakeFace(make_wire([make_edge(spline), trailing_edge])) except AssertionError: # the trailing edge segment could not be created, probably because # the points are too close # No need to build a trailing edge face = BRepBuilderAPI_MakeFace(make_wire(make_edge(spline))) # 6 - extrude the Face to create a Solid return BRepPrimAPI_MakePrism(face.Face(), gp_Vec(gp_Pnt(0., 0., 0.), gp_Pnt(0., 0., self.span))).Shape()
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. from OCC.gp import gp_Pnt, gp_Dir, gp_Pln from OCC.Display.SimpleGui import init_display from OCC.ChFi2d import ChFi2d_AnaFilletAlgo from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire from core_geometry_utils import make_wire display, start_display, add_menu, add_functionto_menu = init_display() # Defining the points p1 = gp_Pnt(0, 0, 0) p2 = gp_Pnt(5, 5, 0) p3 = gp_Pnt(-5, 5, 0) # Making the edges ed1 = BRepBuilderAPI_MakeEdge(p3, p2).Edge() ed2 = BRepBuilderAPI_MakeEdge(p2, p1).Edge() #Making the 2dFillet f = ChFi2d_AnaFilletAlgo() f.Init(ed1, ed2, gp_Pln()) radius = 1.0 f.Perform(radius) fillet2d = f.Result(ed1, ed2) # Create and display a wire w = make_wire([ed1, fillet2d, ed2]) display.DisplayShape(w) start_display()
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. from OCC.gp import gp_Pnt,gp_Dir,gp_Pln from OCC.Display.SimpleGui import init_display from OCC.ChFi2d import ChFi2d_AnaFilletAlgo from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeEdge,BRepBuilderAPI_MakeWire from core_geometry_utils import make_wire display,start_display, add_menu,add_functionto_menu = init_display() # Defining the points p1 = gp_Pnt(0, 0, 0) p2 = gp_Pnt(5, 5, 0) p3 = gp_Pnt(-5,5, 0) # Making the edges ed1 = BRepBuilderAPI_MakeEdge(p3,p2).Edge() ed2 = BRepBuilderAPI_MakeEdge(p2,p1).Edge() #Making the 2dFillet f = ChFi2d_AnaFilletAlgo() f.Init(ed1,ed2,gp_Pln()) radius = 1.0 f.Perform(radius) fillet2d = f.Result(ed1,ed2) # Create and display a wire w = make_wire([ed1, fillet2d, ed2]) display.DisplayShape(w) start_display()