def plotNURBSSurfaces(self, left_pts, right_pts, corsequences, lsagsequences, rsagsequences, degree=3, visualization_type=-1): left_surface = self.createNURBSSurface(pts=left_pts, corsequences=corsequences, sagsequences=lsagsequences) right_surface = self.createNURBSSurface(pts=right_pts, corsequences=corsequences, sagsequences=rsagsequences) # Create a MultiSurface surfaces = Multi.MultiSurface() surfaces.add(left_surface) surfaces.add(right_surface) # Set visualization component if visualization_type == 0: surfaces.delta = 0.01 vis_comp = VisMPL.VisSurfScatter() elif visualization_type == 1: vis_comp = VisMPL.VisSurface() elif visualization_type == 2: vis_comp = VisMPL.VisSurfWireframe() else: vis_comp = VisMPL.VisSurfTriangle() surfaces.vis = vis_comp # Render the surface surfaces.render()
def letter_o(): outer = curve2d.full_circle(radius=10.0) operations.translate(outer, (2, 0), inplace=True) inner = curve2d.full_circle(radius=8.0) operations.translate(inner, (2, 0), inplace=True) letter = Multi.MultiCurve() letter.add([outer, inner]) return letter
def run(N, weight): N = N circle = create_curve(N) print(circle) weight = math.cos(math.pi / N) + weight cv = Multi.MultiCurve() k = 0 while k < len(circle) - 1: cv.add( create_bezie_curve(circle[k], circle[k + 1], circle[k + 2], weight)) k = k + 2 vis_compl = VisMPL.VisCurve2D() cv.vis = vis_compl cv.render()
def letter_i(): base = NURBS.Curve() base.degree = 3 base.ctrlptsw = [[1, 20, 1], [0, 10, 0.5], [0, 19, 1], [0, 10, 1], [0, 1, 1], [0, 0, 0.5], [1, 0, 1], [1, 0, 0.5], [2, 1, 1], [2, 10, 1], [2, 19, 1], [1, 10, 0.5], [1, 20, 1]] base.knotvector = utilities.generate_knot_vector(base.degree, len(base.ctrlpts)) hat = curve2d.full_circle(radius=1) operations.translate(hat, (1, 22), inplace=True) letter = Multi.MultiCurve() letter.add([base, hat]) return letter
def draw_curves(self, curvespts): # Try to load the visualization module try: render_curve = True from geomdl.visualization import VisMPL except ImportError: render_curve = False # Plot the curves using the curve container curves = Multi.MultiCurve() curves.delta = 0.01 for curve in curvespts: curves.add(curve) if render_curve: vis_comp = VisMPL.VisCurve3D() curves.vis = vis_comp curves.render()
def default(): # Create the heart heart = generate_heart() print( "Question 1: generating and displaying a heart at scales of [0.5, 1, 2]." ) # Display the heart at three scales heart_1 = generate_heart(0.5) heart_1.name = 'Scale: 0.5' heart_2 = generate_heart(1) heart_2.name = 'Scale: 1' heart_3 = generate_heart(2) heart_3.name = 'Scale: 2' # Set up a MultiCurve to allow displaying all three hearts on one plot three_hearts = Multi.MultiCurve() three_hearts.delta = 0.001 three_hearts.add([heart_1, heart_2, heart_3]) # Display the MultiCurve display_curve(three_hearts)
compute_reactions, reform_dofs_at_each_iteration, move_mesh_flag) solver.SetEchoLevel(1) num_pole = curve_geometry.NbPoles num_load_steps = 10 disp_X = [] disp_Y = [] disp_Z = [] disp_X = np.empty([num_load_steps + 1, num_pole]) disp_Y = np.empty([num_load_steps + 1, num_pole]) disp_Z = np.empty([num_load_steps + 1, num_pole]) # PLOT _________________________________________________________________________________ multi_curve = Multi.MultiCurve() for i in range(0, num_load_steps + 1): F = i * 0.01 / num_load_steps moment_vec = [i * 10 / num_load_steps, 0, 0] model_part.GetNode(curve_geometry.NbPoles).SetSolutionStepValue( POINT_LOAD_Z, F) # model_part.GetElement(n+2) # element_load_properties.SetValue(LOAD_VECTOR_MOMENT, moment_vec) # aktuellen modellzustand kopieren model_part.CloneTimeStep(i + 1) # aktuellen zustand lösen print("solver step: ", i)
# duck3.nurbs # Process control points and weights d3_ctrlpts = exchange.import_txt("duck3.ctrlpts", separator=" ") # Create a NURBS surface duck3 = NURBS.Surface() duck3.order_u = 4 duck3.order_v = 4 duck3.ctrlpts_size_u = 6 duck3.ctrlpts_size_v = 6 duck3.ctrlpts = d3_ctrlpts duck3.knotvector_u = [0, 0, 0, 0, 0.333333, 0.666667, 1, 1, 1, 1] duck3.knotvector_v = [0, 0, 0, 0, 0.333333, 0.666667, 1, 1, 1, 1] # Plotting ducky = Multi.MultiSurface() ducky.add_list([duck1, duck2, duck3]) vis_config = VisMPL.VisConfig(ctrlpts=False, legend=False) # Use Matplotlib's colormaps to color the duck from matplotlib import cm ducky.vis = VisMPL.VisSurfTriangle(vis_config) ducky.sample_size = 50 ducky.render(colormap=[cm.Wistia, cm.copper, cm.copper]) pass
def plotBsplineSurfaces(self, left_pts, right_pts, corsequences, lsagsequences, rsagsequences, degree=3, visualization_type=-1): """ Create B-spline surface Parameters ---------- left_pts: list List of tuples with 3D points that represents the left diaphragmatic surface right_pts: list List of tuples with 3D points that represents the right diaphragmatic surface corsequences: list List of int with the coronal sequences available lsagsequences: list List of int with the sagittal sequences available from the left lung rsagsequences: list List of int with the sagittal sequences available from the right lung degree: int B-spline surface's Degree (Default = 2) visualization_type: int -1: (Default) Wireframe plot for the control points and triangulated plot for the surface points 0: Wireframe plot for the control points and scatter plot for the surface points 1: Triangular mesh plot for the surface and wireframe plot for the control points grid 2: Scatter plot for the control points and wireframe for the surface points """ left_surface = self.createBsplineSurface(pts=left_pts, corsequences=corsequences, sagsequences=lsagsequences) right_surface = self.createBsplineSurface(pts=right_pts, corsequences=corsequences, sagsequences=rsagsequences) # Create a MultiSurface surfaces = Multi.MultiSurface() surfaces.add(left_surface) surfaces.add(right_surface) # Set visualization component if visualization_type == 0: surfaces.delta = 0.01 vis_comp = VisMPL.VisSurfScatter() elif visualization_type == 1: vis_comp = VisMPL.VisSurface() elif visualization_type == 2: vis_comp = VisMPL.VisSurfWireframe() else: vis_comp = VisMPL.VisSurfTriangle() surfaces.vis = vis_comp # Render the surface surfaces.render()
curve.delta = 0.01 # Set up curve curve.read_ctrlpts_from_txt("ex_curve02.cpt") curve.degree = 3 # Auto-generate knot vector curve.knotvector = utilities.generate_knot_vector(curve.degree, len(curve.ctrlpts)) # Split the curve curve1, curve2 = curve.split(0.2) # Move the 1st curve a little bit far away from the 2nd curve c2tan = curve2.tangent(0.0, normalize=True) c2tanvec = [-1 * p for p in c2tan[1]] curve1.translate(c2tanvec) # Plot the curves using the curve container curves = Multi.MultiCurve() curves.delta = 0.01 curves.add(curve1) curves.add(curve2) if render_curve: vis_comp = VisMPL.VisCurve2D() curves.vis = vis_comp curves.render() # Good to have something here to put a breakpoint pass
duck2.knotvector_v = [0, 0, 0, 0, 0.179541, 0.317924, 0.485586, 0.507528, 0.709398, 0.813231, 1, 1, 1, 1] # duck3.nurbs # Process control points and weights d3_ctrlpts = exchange.import_txt("duck3.ctrlpts", separator=" ") # Create a NURBS surface duck3 = NURBS.Surface() duck3.order_u = 4 duck3.order_v = 4 duck3.ctrlpts_size_u = 6 duck3.ctrlpts_size_v = 6 duck3.ctrlpts = d3_ctrlpts duck3.knotvector_u = [0, 0, 0, 0, 0.333333, 0.666667, 1, 1, 1, 1] duck3.knotvector_v = [0, 0, 0, 0, 0.333333, 0.666667, 1, 1, 1, 1] # Plotting ducky = Multi.MultiSurface(duck1, duck2, duck3) vis_config = VisMPL.VisConfig(ctrlpts=False, legend=False) # Use Matplotlib's colormaps to color the duck from matplotlib import cm ducky.vis = VisMPL.VisSurfTriangle(vis_config) ducky.sample_size = 50 ducky.render(colormap=[cm.Wistia, cm.copper, cm.copper]) pass
To display several scales in one plot, with control points, type 'multi_points', followed by your desired scales (one per line), followed by 'plot'\n\ To display several scales in one plot, without control points, type 'multi_no_points', then proceed as above\n\ To quit this program, type 'quit'\n\ Input: ").lower() if UserInput == 'quit' or UserInput == 'q' or UserInput == 'exit': # Exit the program print('Quitting Question 1 program.') break elif UserInput == 'default': # Display the heart at three scales default() elif UserInput == 'multi_points': # Display multiple scales on one plot, with control points showing # Create the multi curve multi_heart = Multi.MultiCurve() multi_heart.delta = 0.001 # Enter a while loop to capture each input scale user_quits = False while (True): UserInput = input("Next scale value: ").lower() if UserInput == 'plot': # Leave the loop with user_quits = False break elif UserInput == 'quit' or UserInput == 'q' or UserInput == 'exit': print('Quitting Question 1 program.') user_quits = True break else: # Expect a scale value input try:
def run(self, N, weight): cv = Multi.MultiCurve() cv.add(self.create_bezie_curve(self.lst[0], self.lst[1], self.lst[2], weight)) vis_compl = VisMPL.VisCurve2D() cv.vis = vis_compl cv.render()