def build_curve_network(event=None): ''' mimic the curve network surfacing command from rhino ''' print 'Importing IGES file...', pth = os.path.dirname(os.path.abspath(__file__)) pth = os.path.abspath( os.path.join(pth, '../data/IGES/curve_geom_plate.igs')) import ipdb ipdb.set_trace() iges = IGESImporter(pth) iges.read_file() print 'done.' # GetShapes returns 36 TopoDS_Shape, while the TopoDS_Compound contains # just the 6 curves I made in rhino... hmmm... print 'Building geomplate...', topo = Topo(iges.get_compound()) edges_list = list(topo.edges()) face = build_geom_plate(edges_list) print 'done.' print 'Cutting out of edges...', # Make a wire from outer edges _edges = [edges_list[2], edges_list[3], edges_list[4], edges_list[5]] outer_wire = make_wire(_edges)
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()
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()
def build_curve_network(event=None): ''' mimic the curve network surfacing command from rhino ''' print 'Importing IGES file...', pth = os.path.dirname(os.path.abspath(__file__)) pth = os.path.abspath(os.path.join(pth, '../../data/IGES/curve_geom_plate.igs')) iges = IGESImporter(pth) iges.read_file() print 'done.' # GetShapes returns 36 TopoDS_Shape, while the TopoDS_Compound contains # just the 6 curves I made in rhino... hmmm... print 'Building geomplate...', topo = Topo(iges.get_compound()) edges_list = list(topo.edges()) face = build_geom_plate(edges_list) print 'done.' print 'Cutting out of edges...', # Make a wire from outer edges _edges = [edges_list[2], edges_list[3], edges_list[4], edges_list[5]] outer_wire = make_wire(_edges)
def build_curve_network(event=None): ''' mimic the curve network surfacing command from rhino ''' print 'Importing IGES file...', pth = os.path.dirname(os.path.abspath(__file__)) pth = os.path.abspath(os.path.join(pth, '../../data/IGES/curve_geom_plate.igs')) iges = IGESImporter(pth) iges.read_file() print 'done.' print 'Building geomplate...', topo = Topo(iges.get_compound()) edges_list = list(topo.edges()) face = build_geom_plate(edges_list) print 'done.' display.EraseAll() display.DisplayShape(edges_list) display.FitAll() print 'Cutting out of edges...', # Make a wire from outer edges _edges = [edges_list[2], edges_list[3], edges_list[4], edges_list[5]] outer_wire = make_wire(_edges)
def build_curve_network(event=None): ''' mimic the curve network surfacing command from rhino ''' print 'Importing IGES file...', pth = os.path.dirname(os.path.abspath(__file__)) pth = os.path.abspath(os.path.join(pth, '../data/IGES/curve_geom_plate.igs')) iges = IGESImporter(pth) iges.read_file() print 'done.' print 'Building geomplate...', topo = Topo(iges.get_compound()) edges_list = list(topo.edges()) face = build_geom_plate(edges_list) print 'done.' display.EraseAll() display.DisplayShape(edges_list) display.DisplayShape(face) display.FitAll() print 'Cutting out of edges...', # Make a wire from outer edges _edges = [edges_list[2], edges_list[3], edges_list[4], edges_list[5]] outer_wire = make_wire(_edges)