def UpdateZone(self, Surfaces, display): print(self.Surfaces) sewing = BRepBuilderAPI_Sewing() for i in self.Surfaces: sewing.Add(Surfaces[i].GHShape) sewing.Perform() sewed_shape = sewing.SewedShape() tds = topods() # FixedShape = ShapeFix_Shell(tds.Shell(sewed_shape)) # FixedShape.Perform() solid = BRepBuilderAPI_MakeSolid(tds.Shell(sewed_shape)) # Test = BRepClass3d_SolidClassifier() # Test.Perform() display.DisplayShape(solid.Shape()) #print('done') Props = GProp_GProps() brepgprop.VolumeProperties(solid.Shape(), Props) self.Vol = Props.Mass() print(self.Vol) return display
def make_solid(*args): sld = BRepBuilderAPI_MakeSolid(*args) with assert_isdone(sld, 'failed to produce solid'): result = sld.Solid() sld.Delete() return result
def get_current_loft(self): wires = [] curves = [] propeller_number_, xz_mirror_, xy_mirror_, yz_mirror_ \ , rot_x_, hub_length, pitch_angle, root_le_pos_x_, \ root_le_pos_y_, root_le_pos_z_, section_1_length_, section_2_length_, \ section_3_length_, section_4_length_, section_5_length_, section_1_profile_, \ section_2_profile_, section_3_profile_, section_4_profile_, section_5_profile_, \ section_1_z_, section_2_z_, section_3_z_, section_4_z_, section_5_z_ \ , section_1_chord_, section_2_chord_, section_3_chord_, section_4_chord_, \ section_5_chord_, section_1_pitch_angle_, section_2_pitch_angle_, \ section_3_pitch_angle_, section_4_pitch_angle_, section_5_pitch_angle_ = read_propeller_parameters( name=self.name) interval = 5 chords = [ section_1_chord_, section_1_chord_, section_2_chord_, section_3_chord_, section_4_chord_, section_5_chord_, 0.001 ] profile = [ section_1_profile_, section_1_profile_, section_2_profile_, section_3_profile_, section_4_profile_, section_5_profile_, section_5_profile_ ] length = [ 0, section_1_length_, section_2_length_, section_3_length_, section_4_length_, section_5_length_ / 2, section_5_length_ / 2 ] z = [ section_1_z_, section_1_z_, section_2_z_, section_3_z_, section_4_z_, section_5_z_, section_5_z_ ] pitch = [ 0, section_1_pitch_angle_, section_2_pitch_angle_, section_3_pitch_angle_, section_4_pitch_angle_, section_5_pitch_angle_, section_5_pitch_angle_ ] n = random.random() lifting_surface = self.config.get_wings().create_wing( f"{n}", len(chords), f"naca4412") sections = [-hub_length / 2, 0.1 * hub_length, hub_length / 2] radius = [ 0.00, rot_x_ / 2, rot_x_ / 2, ] x_ = [] x_.extend(np.linspace(sections[0], sections[1], num=interval)) x_.append(0.9 * hub_length) radii = [] radii.extend(np.linspace(radius[0], radius[1], num=interval)) radii.append((rot_x_ / 2)) print(x_, radii) n = random.random() hub = self.config.get_fuselages().create_fuselage( f"hub{n}", len(x_), "circularProfile") for (x, rad, index) in zip(x_, radii, range(1, len(x_) + 1)): section = hub.get_section(index) sectionElement = section.get_section_element(1) sectionElementCenter = sectionElement.get_ctigl_section_element() sectionElementCenter.set_center(tigl3.geometry.CTiglPoint(x, 0, 0)) sectionElementCenter.set_area(getArea(rad)) n_sections = lifting_surface.get_section_count() lifting_surface.set_root_leposition( tigl3.geometry.CTiglPoint(-chords[0] / 2, 0, 0)) print(n_sections) y = 0.0 x = hub_length / 2 for (z_, chord, length_, pitch_, profile_, idx) in zip(z, chords, length, pitch, profile, range(1, n_sections + 1)): profile__ = "naca" + profile_ constant = 0.0 nacanumber = profile__.split("naca")[1] if nacanumber.isdigit(): if len(nacanumber) == 4: constant = int(nacanumber[2:]) * 0.01 s = lifting_surface.get_section(idx) e = s.get_section_element(1) ce = e.get_ctigl_section_element() ce.set_width(chord) ce.set_height(chord * constant) center = ce.get_center() y += length_ center.x = x center.y = y center.z = 0.0 ce.set_center(center) ce.set_profile_uid(f"{profile_}") e.set_rotation(tigl3.geometry.CTiglPoint(0, pitch_, 0)) lifting_surface.set_rotation( tigl3.geometry.CTiglPoint(0, pitch_angle, 0)) for idx in range(1, n_sections + 1): s = lifting_surface.get_section(idx) e = s.get_section_element(1) ce = e.get_ctigl_section_element() wires.append(ce.get_wire()) for l in wires: adapt = BRepAdaptor_CompCurve(l) curve = Handle_BRepAdaptor_HCompCurve( BRepAdaptor_HCompCurve(adapt)) approx = Approx_Curve3d(curve, 0.001, GeomAbs_C2, 200, 12) if (approx.IsDone() and approx.HasResult()): curves.append(approx.Curve()) surface1 = tigl3.surface_factories.interpolate_curves(curves) face1 = BRepBuilderAPI_MakeFace(surface1, 1e-6).Face() face2 = BRepBuilderAPI_MakeFace(surface1, 1e-6).Face() sew = BRepBuilderAPI_Sewing() sew.Add(face1) sew.Add(face2) sew.Perform() shape = sew.SewedShape() print(shape) tds = topods() model = BRepBuilderAPI_MakeSolid() model.Add(tds.Shell(shape)) solid = model.Solid() print(solid) rot_trafo = tigl3.geometry.CTiglTransformation() rot_trafo.add_rotation_x(90) loft = [] loft.append(hub.get_loft().shape()) loft.append( tigl3.geometry.CNamedShape(rot_trafo.transform(solid), "cut").shape()) if propeller_number_ == 2: trafo = tigl3.geometry.CTiglTransformation() trafo.add_mirroring_at_xzplane() loft.append( tigl3.geometry.CNamedShape(trafo.transform(loft[1]), "cut").shape()) elif propeller_number_ >= 3: delta = 360 / propeller_number_ for i in range(1, propeller_number_ + 1): loft_copy = deepcopy(loft[1]) trafo = tigl3.geometry.CTiglTransformation() trafo.add_rotation_x(delta * i) print(delta * i) loft.append( tigl3.geometry.CNamedShape(trafo.transform(loft_copy), "cut").shape()) builder = BRep_Builder() assembly = TopoDS_Compound() builder.MakeCompound(assembly) for l in loft: builder.Add(assembly, l) trafo = tigl3.geometry.CTiglTransformation() trafo.add_translation(root_le_pos_x_, root_le_pos_y_, root_le_pos_z_) assembly = trafo.transform(assembly) return [assembly]
def curved_surface(self): self.read_parameters() n = random.random() self.lifting_surface = self.wings.create_wing(f"{n}", 5, self.airfoil_type) chords = [ self.section_1_chord_, self.section_2_chord_, self.section_3_chord_, self.section_4_chord_, self.section_5_chord_ ] y = [ self.section_1_y_, self.section_2_y_, self.section_3_y_, self.section_4_y_, self.section_5_y_ ] x = [ self.section_1_x_, self.section_2_x_, self.section_3_x_, self.section_4_x_, self.section_5_x_ ] z = [ self.section_1_z_, self.section_2_z_, self.section_3_z_, self.section_4_z_, self.section_5_z_ ] twist = [ self.section_1_twist_angle_, self.section_2_twist_angle_, self.section_3_twist_angle_, self.section_4_twist_angle_, self.section_5_twist_angle_ ] profile = self.airfoil_type constant = 0.5 nacanumber = profile.split("naca")[1] if nacanumber.isdigit(): if len(nacanumber) == 4: constant = int(nacanumber[2:]) * 0.01 # decrease section size towards wing tips wires = [] curves = [] n_sections = self.lifting_surface.get_section_count() for idx in range(1, n_sections + 1): s = self.lifting_surface.get_section(idx) e = s.get_section_element(1) ce = e.get_ctigl_section_element() ce.set_width(chords[idx - 1]) ce.set_height(chords[idx - 1] * constant) center = ce.get_center() center.x = x[idx - 1] center.y = y[idx - 1] center.z = z[idx - 1] ce.set_center(center) self.lifting_surface.set_rotation( tigl3.geometry.CTiglPoint(self.rot_x_, self.rot_y_, self.rot_z_)) self.lifting_surface.set_root_leposition( tigl3.geometry.CTiglPoint(self.root_le_pos_x_, self.root_le_pos_y_, self.root_le_pos_z_)) for idx in range(1, n_sections + 1): s = self.lifting_surface.get_section(idx) e = s.get_section_element(1) ce = e.get_ctigl_section_element() wires.append(ce.get_wire()) for l in wires: adapt = BRepAdaptor_CompCurve(l) curve = Handle_BRepAdaptor_HCompCurve( BRepAdaptor_HCompCurve(adapt)) approx = Approx_Curve3d(curve, 0.001, GeomAbs_C2, 200, 12) if (approx.IsDone() and approx.HasResult()): curves.append(approx.Curve()) surface = tigl3.surface_factories.interpolate_curves(curves) sew = BRepBuilderAPI_Sewing() face1 = BRepBuilderAPI_MakeFace(surface, 1e-6).Face() face2 = BRepBuilderAPI_MakeFace(surface, 1e-6).Face() sew.Add(face1) sew.Add(face2) sew.Perform() shape = sew.SewedShape() tds = topods() model = BRepBuilderAPI_MakeSolid() model.Add(tds.Shell(shape)) solid = model.Solid() loft = [] loft.append(solid) if self.xy_mirror_: trafo = tigl3.geometry.CTiglTransformation() trafo.add_mirroring_at_xyplane() loft.append( tigl3.geometry.CNamedShape(trafo.transform(loft[0]), "cut").shape()) elif self.xz_mirror_: trafo = tigl3.geometry.CTiglTransformation() trafo.add_mirroring_at_xzplane() loft.append( tigl3.geometry.CNamedShape(trafo.transform(loft[0]), "cut").shape()) elif self.yz_mirror_: trafo = tigl3.geometry.CTiglTransformation() trafo.add_mirroring_at_yzplane() loft.append( tigl3.geometry.CNamedShape(trafo.transform(loft[0]), "cut").shape()) self.old_profile = self.airfoil_type return loft
def make_solid_from_shell_list(occ_shell_list): ms = BRepBuilderAPI_MakeSolid() for occ_shell in occ_shell_list: ms.Add(occ_shell) return ms.Solid()
def make_solid(occ_shell): ms = BRepBuilderAPI_MakeSolid() ms.Add(occ_shell) return ms.Solid()