def test_complex_net(self): coords1 = [(0.0, 0.0, 0.0), (0.5, 0.0, 1.0), (1.0, -0.2, 0.5), (1.5, 0.0, 0.0), (2.0, -0.1, 0.5)] cpoints1 = [geom.Vertex(coord) for coord in coords1] curve1 = geom.generate_spline(cpoints1, mmath.interp_bezier_curve_2) coords2 = [(2.0, -0.1, 0.5), (2.0, 1.0, 1.0), (2.1, 2.0, 0.0)] cpoints2 = [geom.Vertex(coord) for coord in coords2] curve2 = geom.generate_spline(cpoints2, mmath.interp_bezier_curve_2) coords3 = [(2.1, 2.0, 0.0), (1.5, 2.0, 0.0), (1.0, 2.1, 0.5), (0.5, 2.0, 1.0), (0.0, 2.0, 0.0)] cpoints3 = [geom.Vertex(coord) for coord in coords3] curve3 = geom.generate_spline(cpoints3, mmath.interp_bezier_curve_2) coords4 = [(0.0, 2.0, 0.0), (-0.5, 1.0, 0.0), (0.0, 0.0, 0.0)] cpoints4 = [geom.Vertex(coord) for coord in coords4] curve4 = geom.generate_spline(cpoints4, mmath.interp_bezier_curve_2) polygon = geom.PolygonsNetQuad((curve1, curve2, curve3, curve4)) points = list(geom.sample_patch_samples(polygon, 50)) c1_points = list(geom.sample_curve_samples(curve1, 20)) c2_points = list(geom.sample_curve_samples(curve2, 20)) c3_points = list(geom.sample_curve_samples(curve3, 20)) c4_points = list(geom.sample_curve_samples(curve4, 20)) if DRAW_GRAPHS: fig = plt.figure() ax = fig.gca(projection="3d") ax.plot([p.x for p in c1_points], [p.y for p in c1_points], [p.z for p in c1_points]) ax.plot([p.x for p in c2_points], [p.y for p in c2_points], [p.z for p in c2_points]) ax.plot([p.x for p in c3_points], [p.y for p in c3_points], [p.z for p in c3_points]) ax.plot([p.x for p in c4_points], [p.y for p in c4_points], [p.z for p in c4_points]) ax.plot([p.x for p in points], [p.y for p in points], [p.z for p in points], "o", label="Geometry points") plt.show()
def test_simple_net(self): v0 = geom.Vertex((0.0, 0.0, 0.0)) v1 = geom.Vertex((1.0, 0.0, 0.0)) v2 = geom.Vertex((1.0, 1.0, 0.0)) v3 = geom.Vertex((0.0, 1.0, 0.0)) disp = geom.Vertex((0.0, 0.0, 0.5)) m0 = (v0 + v1) / 2.0 + disp m1 = (v1 + v2) / 2.0 + disp m2 = (v2 + v3) / 2.0 + disp m3 = (v3 + v0) / 2.0 + disp c1 = geom.SuperCurve([geom.BaseCurve((v0, m0, v1), mmath.interp_bezier_curve_2)]) c2 = geom.BaseCurve((v1, m1, v2), mmath.interp_bezier_curve_2) c3 = geom.BaseCurve((v2, m2, v3), mmath.interp_bezier_curve_2) c4 = geom.BaseCurve((v3, m3, v0), mmath.interp_bezier_curve_2) c1_points = list(geom.sample_curve_samples(c1, 10)) c2_points = list(geom.sample_curve_samples(c2, 10)) c3_points = list(geom.sample_curve_samples(c3, 10)) c4_points = list(geom.sample_curve_samples(c4, 10)) polygon = geom.PolygonsNetQuad((c1, c2, c3, c4)) points = list(geom.sample_patch_samples(polygon, 70)) if DRAW_GRAPHS: fig = plt.figure() ax = fig.gca(projection="3d") ax.plot([p.x for p in c1_points], [p.y for p in c1_points], [p.z for p in c1_points]) ax.plot([p.x for p in c2_points], [p.y for p in c2_points], [p.z for p in c2_points]) ax.plot([p.x for p in c3_points], [p.y for p in c3_points], [p.z for p in c3_points]) ax.plot([p.x for p in c4_points], [p.y for p in c4_points], [p.z for p in c4_points]) ax.plot([p.x for p in points], [p.y for p in points], [p.z for p in points], "o", label="Geometry points") plt.show()
def test_complex_net(self): coords1 = [(0.0, 0.0, 0.0), (0.5, 0.0, 1.0), (1.0, -0.2, 0.5), (1.5, 0.0, 0.0), (2.0, -0.1, 0.5)] cpoints1 = [geom.Vertex(coord) for coord in coords1] curve1 = geom.generate_spline(cpoints1, mmath.interp_bezier_curve_2) coords2 = [(2.0, -0.1, 0.5), (2.0, 1.0, 1.0), (2.1, 2.0, 0.0)] cpoints2 = [geom.Vertex(coord) for coord in coords2] curve2 = geom.generate_spline(cpoints2, mmath.interp_bezier_curve_2) coords3 = [(2.1, 2.0, 0.0), (1.5, 2.0, 0.0), (1.0, 2.1, 0.5), (0.5, 2.0, 1.0), (0.0, 2.0, 0.0)] cpoints3 = [geom.Vertex(coord) for coord in coords3] curve3 = geom.generate_spline(cpoints3, mmath.interp_bezier_curve_2) coords4 = [(0.0, 2.0, 0.0), (-0.5, 1.0, 0.0), (0.0, 0.0, 0.0)] cpoints4 = [geom.Vertex(coord) for coord in coords4] curve4 = geom.generate_spline(cpoints4, mmath.interp_bezier_curve_2) polygon = geom.PolygonsNetQuad((curve1, curve2, curve3, curve4)) points = list(geom.sample_patch_samples(polygon, 50)) c1_points = list(geom.sample_curve_samples(curve1, 20)) c2_points = list(geom.sample_curve_samples(curve2, 20)) c3_points = list(geom.sample_curve_samples(curve3, 20)) c4_points = list(geom.sample_curve_samples(curve4, 20)) if DRAW_GRAPHS: fig = plt.figure() ax = fig.gca(projection='3d') ax.plot([p.x for p in c1_points], [p.y for p in c1_points], [p.z for p in c1_points]) ax.plot([p.x for p in c2_points], [p.y for p in c2_points], [p.z for p in c2_points]) ax.plot([p.x for p in c3_points], [p.y for p in c3_points], [p.z for p in c3_points]) ax.plot([p.x for p in c4_points], [p.y for p in c4_points], [p.z for p in c4_points]) ax.plot([p.x for p in points], [p.y for p in points], [p.z for p in points], "o", label="Geometry points") plt.show()
def test_simple_net(self): v0 = geom.Vertex((0.0, 0.0, 0.0)) v1 = geom.Vertex((1.0, 0.0, 0.0)) v2 = geom.Vertex((1.0, 1.0, 0.0)) v3 = geom.Vertex((0.0, 1.0, 0.0)) disp = geom.Vertex((0.0, 0.0, 0.5)) m0 = (v0 + v1) / 2.0 + disp m1 = (v1 + v2) / 2.0 + disp m2 = (v2 + v3) / 2.0 + disp m3 = (v3 + v0) / 2.0 + disp c1 = geom.SuperCurve( [geom.BaseCurve((v0, m0, v1), mmath.interp_bezier_curve_2)]) c2 = geom.BaseCurve((v1, m1, v2), mmath.interp_bezier_curve_2) c3 = geom.BaseCurve((v2, m2, v3), mmath.interp_bezier_curve_2) c4 = geom.BaseCurve((v3, m3, v0), mmath.interp_bezier_curve_2) c1_points = list(geom.sample_curve_samples(c1, 10)) c2_points = list(geom.sample_curve_samples(c2, 10)) c3_points = list(geom.sample_curve_samples(c3, 10)) c4_points = list(geom.sample_curve_samples(c4, 10)) polygon = geom.PolygonsNetQuad((c1, c2, c3, c4)) points = list(geom.sample_patch_samples(polygon, 70)) if DRAW_GRAPHS: fig = plt.figure() ax = fig.gca(projection='3d') ax.plot([p.x for p in c1_points], [p.y for p in c1_points], [p.z for p in c1_points]) ax.plot([p.x for p in c2_points], [p.y for p in c2_points], [p.z for p in c2_points]) ax.plot([p.x for p in c3_points], [p.y for p in c3_points], [p.z for p in c3_points]) ax.plot([p.x for p in c4_points], [p.y for p in c4_points], [p.z for p in c4_points]) ax.plot([p.x for p in points], [p.y for p in points], [p.z for p in points], "o", label="Geometry points") plt.show()