Beispiel #1
0
    def Geometry(self):
        theta = 2*npy.pi/Z #theta=theta2 +theta3
        
        R = O.Translation(vm.point2D((self.L8*npy.cos(alphaR),-self.L8*npy.sin(alphaR))))
        
        K = R.Translation(vm.point2D((0,DF/2)))
        H = K.Rotation(R,theta2)
        M = K.Rotation(R,theta2+theta3)
        a1 = vm.Arc2D(K,H,M)
        
        J1 = R.Translation(vm.Point2D((0,DI/2)))
        J=J1.Rotation(R,(theta2-theta1)/2)
        #est ce un probleme de ne pas controler directement la pente du créneau ? (on ne se sert pas de alphaJ)
        #sinon on pourrait remplacer les deux lignes précédentes par:J=K.Translation(vm.point2D((-self.L9*npy.sin(alphaJ),-self.L9*npy.cos(alphaJ))))
        #Dans ce cas il faudrait peut être paramétrer H de la même façon
        I=J.Rotation(R,theta1)
        
        l1=primitives2D.RoundedLineSegments2D([K,J,I,H],{'''je ne sais pas trop quoi mettre ici'''})
        
        L=[a1,l1]
        for i in range(Z-1):
            thetar=(i+1)*theta
            L.append(a1.Rotation(R,thetar,True))
            L.append(l1.Rotation(R,thetar,True))

        c1=vm.Contour2D(L)
        c1.MPLPlot()
Beispiel #2
0
    def contour(self):
        points = [
            vm.Point2D((0, 0)),
            vm.Point2D((0, 1)),
            vm.Point2D((1, 1)),
            vm.Point2D((1, 0))
        ]

        crls = p2d.ClosedRoundedLineSegments2D(points=points, radius={})
        return vm.Contour2D(crls.primitives)
Beispiel #3
0
    def update(self, new_height, new_side):
        return Component(self.center, new_side, self.vectors[0],
                         self.vectors[1], new_height, self.plane)

        self.points = self.compo_points()
        self.primitives = [
            vm.LineSegment2D(self.points[0], self.points[1]),
            vm.LineSegment2D(self.points[1], self.points[2]),
            vm.LineSegment2D(self.points[2], self.points[3]),
            vm.LineSegment2D(self.points[3], self.points[0])
        ]
        self.contour = vm.Contour2D(self.primitives)
        self.solid = self.compo_solid()
        return
Beispiel #4
0
    def __init__(self, center, compo_side, vector1, vector2, height, plane):
        self.center = center
        self.compo_side = compo_side
        self.vectors = [vector1, vector2]
        self.height = height
        self.plane = plane

        self.points = self.compo_points()
        self.primitives = [
            vm.LineSegment2D(self.points[0], self.points[1]),
            vm.LineSegment2D(self.points[1], self.points[2]),
            vm.LineSegment2D(self.points[2], self.points[3]),
            vm.LineSegment2D(self.points[3], self.points[0])
        ]
        self.contour = vm.Contour2D(self.primitives)
        self.solid = self.compo_solid()
    def babylon(self, xy_position, z_position):
        primitives = []

        ## AFFICHAGE EN CYLINDRE ##
        #        pos = vm.Point3D((xy_position[0], xy_position[1], z_position))
        #        axis = vm.Vector3D((0,0,1))
        #        radius = self.diameter/2
        #        length = self.length
        #        cylinder = p3d.Cylinder(pos, axis, radius, length)
        #        primitives.append(cylinder)

        ## AFFICHAGE EN ROUE DENTEE ##
        plane_origin = vm.Point3D(
            (xy_position[0], xy_position[1], z_position - self.length / 2))
        x = vm.x3D
        y = vm.y3D
        vector = vm.Vector3D((0, 0, self.length))

        if self.n_teeth is None:
            n_teeth = int(round(self.diameter * 100, 0))
        else:
            n_teeth = self.n_teeth
        angle = 2 * math.pi / n_teeth
        inner_diameter = 0.90 * self.diameter
        teeth_l = (2 * math.pi * self.diameter / 2) / (1.5 * n_teeth)
        pt1 = vm.Point2D(
            (-teeth_l / 2, (inner_diameter**2 / 4 - teeth_l**2 / 4)**0.5))
        pt5 = vm.Point2D(
            (teeth_l / 2, (inner_diameter**2 / 4 - teeth_l**2 / 4)**0.5))
        pt2 = vm.Point2D((pt1.vector[0] / 2, self.diameter / 2))
        pt4 = vm.Point2D((pt5.vector[0] / 2, self.diameter / 2))
        rls_points = [pt1, pt2, pt4, pt5]
        for i in range(n_teeth - 1):
            new_pt1 = rls_points[-4].Rotation(vm.o2D, -angle)
            new_pt2 = rls_points[-3].Rotation(vm.o2D, -angle)
            new_pt4 = rls_points[-2].Rotation(vm.o2D, -angle)
            new_pt5 = rls_points[-1].Rotation(vm.o2D, -angle)
            rls_points.extend([new_pt1, new_pt2, new_pt4, new_pt5])

        rls_points.reverse()
        rls = p2d.OpenedRoundedLineSegments2D(rls_points, {})
        outer_contour2d = vm.Contour2D([rls])
        extrusion = p3d.ExtrudedProfile(plane_origin, x, y, outer_contour2d,
                                        [], vector)
        primitives.append(extrusion)
        return primitives
Beispiel #6
0
p5 = p4.Rotation(pc, theta2)
p6 = p1.Rotation(pc, theta)

l1 = primitives2D.RoundedLineSegments2D([p3, p4, p5, p6], {1: r3, 2: r3})

#l1=primitives2D.RoundedLines2D([p1,p2,p3,p4],{0:0.01,2:0.01})
#l2=vm.Circle2D(p5,0.01)
L = [a1, l1]
for i in range(Z - 1):
    thetar = (i + 1) * theta
    L.append(a1.Rotation(pc, thetar, True))
    L.append(l1.Rotation(pc, thetar, True))
#p7=vm.Point2D((0,r4))
l2 = vm.Circle2D(pc, r4)

c1 = vm.Contour2D(L)
c2 = vm.Contour2D([l2])

po = vm.Point3D((0, 0, 0))
xp = vm.Vector3D((1, 0, 0))
yp = vm.Vector3D((0, 1, 0))

#c1.MPLPlot()
#extr_vect=vm.Vector3D((0,0,e))

profile_straight = primitives3D.ExtrudedProfile(po,
                                                xp,
                                                yp,
                                                c1, [c2], (0, 0, e),
                                                name='straight')
#
Beispiel #7
0
                               20) / 100  #Idem but with circle's normal

print('param1', phi1, theta1, offset_phi1, offset_theta1)

#You have to create a cutting pattern in 2D

pt1, pt2, pt3, pt4 = volmdlr.Point2D(
    (offset_theta1, offset_phi1)), volmdlr.Point2D(
        (offset_theta1, offset_phi1 + phi1)), volmdlr.Point2D(
            (offset_theta1 + theta1, offset_phi1 + phi1)), volmdlr.Point2D(
                (offset_theta1 + theta1, offset_phi1))
seg1, seg2, seg3, seg4 = volmdlr.LineSegment2D(
    pt1, pt2), volmdlr.LineSegment2D(pt2, pt3), volmdlr.LineSegment2D(
        pt3, pt4), volmdlr.LineSegment2D(pt4, pt1)
edges = [seg1, seg2, seg3, seg4]
contours2d = [volmdlr.Contour2D(edges)]
points = [theta1, phi1]

theta2 = random.randrange(angle_min, angle_max, 20) / 100  #Tore's length
phi2 = random.randrange(angle_min, angle_max, 20) / 100  #angle of circle
offset_theta2 = random.randrange(
    angle_min, angle_max,
    20) / 100  #Theta's offset if you want to turn it with normal's reference
offset_phi2 = random.randrange(angle_min, angle_max,
                               20) / 100  #Idem but with circle's normal

print('param2', phi2, theta2, offset_phi2, offset_theta2)

#You have to create a cutting pattern in 2D

pt1_2, pt2_2, pt3_2, pt4_2 = volmdlr.Point2D(
Beispiel #8
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 12 10:04:09 2017

@author: steven
"""

import volmdlr as vm

l = 0.1

p1 = vm.Point2D((0, 0))
p2 = vm.Point2D((l, 0))
p3 = vm.Point2D((l, l))
p4 = vm.Point2D((0, l))

l1 = vm.LineSegment2D(p1, p2)
l2 = vm.LineSegment2D(p2, p3)
l3 = vm.LineSegment2D(p3, p4)
l4 = vm.LineSegment2D(p4, p1)

p5 = vm.Point2D((l / 2, l / 2))
c1 = vm.Circle2D(p5, l / 5)

ct1 = vm.Contour2D([l4, l3, l2, l1])
ct2 = vm.Contour2D([c1])
mesh = vm.Mesh2D([ct1, ct2], {}, 0.01)

print(mesh.GeoScript('mesh2D.geo'))
Beispiel #9
0
import volmdlr as vm
import volmdlr.primitives3D as primitives3D
import volmdlr.primitives2D as primitives2D
#import math

p1=vm.Point2D((0, 0))
p2=vm.Point2D((0.1, 0.))
p3=vm.Point2D((0.1, 0.2))
p4=vm.Point2D((0, 0.1))
p5=vm.Point2D((-0.01, 0.05))

#p6=vm.Point2D((0.1,0.3))

l1=primitives2D.RoundedLineSegments2D([p1, p2, p3, p4], {2: 0.01}, False)
l2=vm.Arc2D(p4, p5, p1)
c1=vm.Contour2D([l1, l2])
c2=c1.Rotation(vm.Point2D((0,0)),npy.pi,True)
c1.MPLPlot()
c2.MPLPlot()
c3=vm.Contour2D([c1, c2])
c3.MPLPlot()

po = vm.Point3D((0, 0, 0))
xp = vm.Vector3D((1, 0, 0))
yp = vm.Vector3D((0, 1, 0))


profile = primitives3D.ExtrudedProfile(po, xp, yp, c1, [], vm.Vector3D((0, 0.1, 0.2)))

model = vm.VolumeModel([('', [profile])])
Beispiel #10
0
"""

import numpy as npy
import volmdlr as volmdlr
import volmdlr.primitives3D as primitives3D
import volmdlr.primitives2D as primitives2D
import matplotlib.pyplot as plt
import random

######## SWEEP TEST RANDOM

nb_point1, nb_point2 = 6, 5

radius_circle1, radius_circle2 = 0.008, 0.01
c1 = volmdlr.Circle2D(volmdlr.Point2D((0, 0)), radius_circle1)
contour1 = volmdlr.Contour2D([c1])

c2 = volmdlr.Circle2D(volmdlr.Point2D((0, 0)), radius_circle2)
contour2 = volmdlr.Contour2D([c2])

mini, maxi = -1, 1
pts1 = []
for k in range(nb_point1):
    a1, a2, a3 = random.randint(mini, maxi), random.randint(
        mini, maxi), random.randint(mini, maxi)
    c1, c2, c3 = random.randrange(0, 100, 1), random.randrange(
        0, 100, 1), random.randrange(0, 100, 1)
    pts1.append(volmdlr.Point3D((a1 * c1 / 100, a2 * c2 / 100, a3 * c3 / 100)))

radius1 = {
    1: 0.03,
Beispiel #11
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 19:23:27 2019

@author: steven
"""

import volmdlr as vm
import math

r = 0.23

p1 = vm.Point2D((0, 0))
p2 = vm.Point2D((r, r))
p3 = vm.Point2D((2 * r, 0))

a = vm.Arc2D(p1, p2, p3)
l = vm.LineSegment2D(p3, p1)

c = vm.Contour2D([a, l])
f, ax = c.MPLPlot()
cog = c.CenterOfMass()
cog.MPLPlot(ax)

assert math.isclose(a.radius, r)
assert math.isclose(c.Area(), math.pi * r**2 / 2.)
assert math.isclose(cog[0], r)
print(cog[1], 4 * r / 3. * math.pi)
assert math.isclose(cog[1], 4 * r / 3. / math.pi)
Beispiel #12
0
#%%

p1 = vm.Point2D((0, 0))
p2 = vm.Point2D((0, 2))
p3 = vm.Point2D((2, 4))
p4 = vm.Point2D((4, 4))
p5 = vm.Point2D((4, 3))
p6 = vm.Point2D((3, 2))
p7 = vm.Point2D((3, 0))

l1 = p2d.OpenedRoundedLineSegments2D([p7, p1, p2], {})
l2 = vm.Arc2D(p2, vm.Point2D((math.sqrt(2) / 2, 3 + math.sqrt(2) / 2)), p3)
l3 = p2d.OpenedRoundedLineSegments2D([p3, p4, p5, p6], {}, adapt_radius=True)
l4 = vm.Arc2D(p6, vm.Point2D((4, 1)), p7)
#l4=vm.Arc2D(p7, vm.Point2D((4, 1)), p6)
c1 = vm.Contour2D([l1, l2, l3, l4])

p8 = vm.Point2D((1, 1))
p9 = vm.Point2D((2, 1))
p10 = vm.Point2D((2, 2))
p11 = vm.Point2D((1, 2))
#inner=vm.Circle2D(vm.Point2D((2,2)), 0.5)
inner = p2d.ClosedRoundedLineSegments2D([p8, p9, p10, p11], {})
c2 = vm.Contour2D([inner])

#ax = l1.MPLPlot()
#l2.MPLPlot(ax=ax)
#l3.MPLPlot(ax=ax)
#l4.MPLPlot(ax=ax)

profile = p3d.ExtrudedProfile(vm.o3D, vm.x3D, vm.y3D, c1, [c2],
Beispiel #13
0
p2 = vm.Point2D((0.3, 0))
p3 = vm.Point2D((0.33, 0.22))
p4 = vm.Point2D((0.2, 0.08))
p5 = vm.Point2D((0.16, 0.18))
p6 = vm.Point2D((0.05, 0.20))

inner_rl = primitives2D.RoundedLineSegments2D([p1, p2, p3, p4, p5, p6], {
    0: 0.01,
    1: 0.01,
    2: 0.015,
    3: 0.010,
    4: 0.012,
    5: 0.008
}, True)
outer_rl = inner_rl.Offset(-thickness)
inner_contour = vm.Contour2D([inner_rl])
outer_contour = vm.Contour2D([outer_rl])

f, a = inner_contour.MPLPlot()
outer_contour.MPLPlot(a)

sides = primitives3D.ExtrudedProfile(vm.o3D, vm.x3D, vm.y3D, outer_contour,
                                     [inner_contour],
                                     (height - 2 * thickness) * vm.z3D,
                                     'sides')
bottom = primitives3D.ExtrudedProfile(vm.o3D, vm.x3D, vm.y3D, outer_contour,
                                      [], -thickness * vm.z3D, 'bottom')

screw_holes_rl = inner_rl.Offset(-(thickness + screw_holes_clearance +
                                   0.5 * screw_holes_diameter))
screw_holes = []
Beispiel #14
0
    p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15
]
c1 = primitives2D.ClosedRoundedLineSegments2D(points1, {
    2: 0.005,
    3: 0.005,
    4: 0.005,
    8: 0.005,
    9: 0.005,
    10: 0.005,
    14: 0.005
})

circle0 = vm.Circle2D(vm.Point2D((0.12, 0.25)), 0.02)
circle1 = vm.Circle2D(vm.Point2D((0.19, 0.25)), 0.02)
circle2 = vm.Circle2D(vm.Point2D((0.15, 0.08)), 0.08)
c2 = vm.Contour2D([circle0])
c3 = vm.Contour2D([circle1])
c4 = vm.Contour2D([circle2])

e0 = vm.Point2D((0, 0.00))
e1 = vm.Point2D((0, 0.03))
e2 = vm.Point2D((0.11, 0.03))
e3 = vm.Point2D((0.11, 0.04))
e4 = vm.Point2D((0.13, 0.04))
e5 = vm.Point2D((0.13, 0))

points2 = [e0, e1, e2, e3, e4, e5]
c5 = primitives2D.ClosedRoundedLineSegments2D(points2, {})

profile = primitives3D.ExtrudedProfile(vm.O3D,
                                       vm.Y3D,
Beispiel #15
0
            name='sides_floor')

        list_component_hat.append(sides_floor)
        primitive_of_floor.append(sides_floor)

        if with_borders:
            r = 0.15
            arc = vm.Arc2D(
                vm.Point2D((0, 0)),
                vm.Point2D(
                    ((-1 + math.sqrt(2) / 2) * r, r * math.sqrt(2) / 2)),
                vm.Point2D((-r, r)))

            contour_sweep = outer_contour_floor.Offset(r)

            contour = vm.Contour2D([arc])
            wire_sweep = vm.Wire3D([
                p.To3D(
                    origin +
                    extrusion_vector * list_height_polyfloor[enum + 1], x, y)
                for p in contour_sweep.primitives
            ])
            sweep = primitives3D.Sweep(contour,
                                       wire_sweep,
                                       alpha=alpha,
                                       name='congé')

            list_component_hat.append(sweep)
            list_contour_floor.append(contour_sweep)
        else:
            r = 0
Beispiel #16
0
"""
Created on Tue May 12 17:14:06 2020

@author: masfaraud
"""

import numpy as npy
import volmdlr as volmdlr
import volmdlr.primitives3D as primitives3D
import volmdlr.primitives2D as primitives2D
import matplotlib.pyplot as plt
import random

radius_circle = 0.008
c = volmdlr.Circle2D(volmdlr.Point2D((0, 0)), radius_circle)
contour = volmdlr.Contour2D([c])
pt0 = volmdlr.Point3D((0.01, 0.04, 0.16))
pt1 = volmdlr.Point3D((0.03, 0, 0.2))
pt2 = volmdlr.Point3D((0.45, 0.01, 0.1))
pt3 = volmdlr.Point3D((0.45, 0, -0.1))
pt4 = volmdlr.Point3D((0.3, 0.04, -0.02))
pts = [pt0, pt1, pt2, pt3, pt4]
radius = {1: 0.03, 2: 0.01, 3: 0.07}
rl = primitives3D.OpenedRoundedLineSegments3D(pts,
                                              radius,
                                              adapt_radius=True,
                                              name='wire')
sweep = primitives3D.Sweep(contour, rl, name='pipe')

pt10 = volmdlr.Point3D((0.02, 0.22, 0.25))
pt11 = volmdlr.Point3D((0.02, 0.24, 0.25))
Beispiel #17
0
circles = []
delta_angle = 2*math.pi/number_holes
inner_circle = volmdlr.Circle2D(volmdlr.O2D, 0.04)
first_circle = volmdlr.Circle2D(volmdlr.Point2D((0, 0.05)), 0.005)
circles = [inner_circle, first_circle]
for i in range(1, number_holes):
    circles.append(first_circle.Rotation(volmdlr.O2D, i*delta_angle))
    
xn, yn, zn = random.randrange(posmin, posmax, 1)/100, random.randrange(posmin, posmax, 1)/100, random.randrange(posmin, posmax, 1)/100
xc, yc, zc = random.randrange(posmin, posmax, 1)/100, random.randrange(posmin, posmax, 1)/100, random.randrange(posmin, posmax, 1)/100

n = volmdlr.Vector3D([xn,yn,zn])
n.Normalize()
c = volmdlr.Point3D((xc,yc,zc))

#Plane to place your PlaneFace3D
plane = volmdlr.Plane3D.from_normal(c, n)

#To do a PlaneFace3D, you need to use contours2D
#The first is always the basis, the others are used to cut the basis

contours = [volmdlr.Contour2D([outer_circle]), volmdlr.Contour2D([circles[0]]),
            volmdlr.Contour2D([circles[1]]), volmdlr.Contour2D([circles[2]]),
            volmdlr.Contour2D([circles[3]]),volmdlr.Contour2D([circles[4]]),
            volmdlr.Contour2D([circles[5]])]

planeface = volmdlr.PlaneFace3D(contours,  plane)

shell = volmdlr.Shell3D([planeface])
m = volmdlr.VolumeModel([shell])
m.babylonjs()
Beispiel #18
0
pi1 = vm.Point2D((-B / 2, d / 2))
pi2 = vm.Point2D((-B / 2, d1 / 2))
pi3 = vm.Point2D((-0.5 * D_balls * math.sin(theta_b), d1 / 2))
pi4 = vm.Point2D((0, y_ball0 - D_balls / 2))
pi5 = vm.Point2D((0.5 * D_balls * math.sin(theta_b), d1 / 2))
pi6 = vm.Point2D((B / 2, d1 / 2))
pi7 = vm.Point2D((B / 2, d / 2))

li1 = vm.Line2D(pi1, pi2)
li2 = vm.Line2D(pi2, pi3)
ci3 = vm.Arc2D(pi3, pi4, pi5)
li4 = vm.Line2D(pi5, pi6)
li5 = vm.Line2D(pi6, pi7)
li6 = vm.Line2D(pi7, pi1)

ci = vm.Contour2D([li1, li2, ci3, li4, li5, li6])
inner = primitives3D.RevolvedProfile(center, x, y, [ci], center, x,
                                     math.pi * 2, 'innerring')
primitives.append(inner)

# outter
po1 = vm.Point2D((-B / 2, D / 2))
po2 = vm.Point2D((-B / 2, D1 / 2))
po3 = vm.Point2D((-0.5 * D_balls * math.sin(theta_b), D1 / 2))
po4 = vm.Point2D((0, y_ball0 + D_balls / 2))
po5 = vm.Point2D((0.5 * D_balls * math.sin(theta_b), D1 / 2))
po6 = vm.Point2D((B / 2, D1 / 2))
po7 = vm.Point2D((B / 2, D / 2))

lo1 = vm.Line2D(po1, po2)
lo2 = vm.Line2D(po2, po3)
Beispiel #19
0
h1 = random.randrange(hmin, hmax, 5) / 100

center2d = c1.To2D(c1, plane1.vectors[0], plane1.vectors[1])
#Classic Contour
segbh = volmdlr.LineSegment2D(center2d, center2d + volmdlr.Point2D(
    (0, h1)))  #### Minus Pt2D because of Step adaptation
circlestart = volmdlr.LineSegment2D(
    segbh.points[1], segbh.points[1] + volmdlr.Point2D(
        (2 * math.pi * 3 / 4, 0)))  #You can change 2*pi by an other angle
seghb = volmdlr.LineSegment2D(circlestart.points[1],
                              circlestart.points[1] - segbh.points[1])
circlend = volmdlr.LineSegment2D(seghb.points[1], segbh.points[0])
edges = [segbh, circlestart, seghb, circlend]
points = edges[0].points
contours = [volmdlr.Contour2D(edges)]

cyl1 = volmdlr.CylindricalFace3D(contours, cylsurface1, points)

pts1, tangle1 = cyl1.triangulation(resolution=12)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
[pt.MPLPlot(ax=ax) for pt in pts1]

# number_holes = 5

# outer_circle = volmdlr.Circle2D(volmdlr.O2D, 0.06)

# circles = []
# delta_angle = 2*math.pi/number_holes
Beispiel #20
0
cylsurface1 = volmdlr.CylindricalSurface3D(frame1, r1) 
cylsurface2 = volmdlr.CylindricalSurface3D(frame2, r2)

hmin, hmax = 0, 100

h1, h2 = random.randrange(hmin, hmax, 5)/100, random.randrange(hmin, hmax, 5)/100 #Height of cylinder

# center2d = c1.To2D(c1, plane1.vectors[0], plane1.vectors[1])
center2d = volmdlr.Point2D((0,0))
segbh = volmdlr.LineSegment2D(center2d, center2d + volmdlr.Point2D((0,h1))) #### Minus Pt2D because of Step adaptation
circlestart = volmdlr.LineSegment2D(segbh.points[1], segbh.points[1]+volmdlr.Point2D((2*math.pi*3/4,0))) #You can change 2*pi by an other angle
seghb = volmdlr.LineSegment2D(circlestart.points[1],circlestart.points[1]-segbh.points[1])
circlend = volmdlr.LineSegment2D(seghb.points[1],segbh.points[0])
edges = [segbh, circlestart, seghb, circlend]
points = edges[0].points 
contours =  [volmdlr.Contour2D(edges)]

# center2d2 = c2.To2D(c2, plane2.vectors[0], plane2.vectors[1])
center2d2 = volmdlr.Point2D((0,0))
segbh2 = volmdlr.LineSegment2D(center2d2, center2d2 + volmdlr.Point2D((0,h2))) #### Minus Pt2D because of Step adaptation
circlestart2 = volmdlr.LineSegment2D(segbh2.points[1], segbh2.points[1]+volmdlr.Point2D((2*math.pi,0))) #You can change 2*pi by an other angle
seghb2 = volmdlr.LineSegment2D(circlestart2.points[1],circlestart2.points[1]-segbh2.points[1])
circlend2 = volmdlr.LineSegment2D(seghb2.points[1],segbh2.points[0])
edges2 = [segbh2, circlestart2, seghb2, circlend2]
points2 = edges2[0].points 
contours2 =  [volmdlr.Contour2D(edges2)]


cyl1 = volmdlr.CylindricalFace3D(contours, cylsurface1, points)
cyl2 = volmdlr.CylindricalFace3D(contours2, cylsurface2, points2)
Beispiel #21
0
center = vm.Point3D([0, 0, 0])  #Choose the coordinate of the center
normal1 = vm.Vector3D([0, 0, 1])  #Choose the normal of the generative
normal1.Normalize()  #Normalize the normal if it is not the case
vec1 = normal1.deterministic_unit_normal_vector()

frame = vm.Frame3D(center, vec1, normal1.Cross(vec1),
                   normal1)  #Frame in the center of the generative arc3D
toroidalsurface3d = vm.ToroidalSurface3D(frame, r1, r2)

theta = 4 * math.pi / 3  #Tore's length
phi = 2 * math.pi  #angle of circle
offset_theta = math.pi / 4  #Theta's offset if you want to turn it with normal's reference
offset_phi = math.pi  #Idem but with circle's normal

#You have to create a cutting pattern in 2D

pt1, pt2, pt3, pt4 = vm.Point2D((offset_theta, offset_phi)), vm.Point2D(
    (offset_theta, offset_phi + phi)), vm.Point2D(
        (offset_theta + theta, offset_phi + phi)), vm.Point2D(
            (offset_theta + theta, offset_phi))
seg1, seg2, seg3, seg4 = vm.LineSegment2D(pt1, pt2), vm.LineSegment2D(
    pt2, pt3), vm.LineSegment2D(pt3, pt4), vm.LineSegment2D(pt4, pt1)
edges = [seg1, seg2, seg3, seg4]
contours2d = [vm.Contour2D(edges)]
points = [theta, phi]

toroidalface = vm.ToroidalFace3D(contours2d, toroidalsurface3d, points)

shell = vm.Shell3D([toroidalface])
m = vm.VolumeModel([shell])
m.babylonjs(debug=True)
Beispiel #22
0
Created on Wed Mar 14 15:32:37 2018

@author: Steven Masfaraud [email protected]
"""
import volmdlr as vm
import volmdlr.primitives2D as primitives2D
import numpy as npy

#for i in range(20):
triangle_points = [vm.Point2D(npy.random.random(2)) for i in range(3)]
triangle = vm.Polygon2D(triangle_points)

cog_triangle = triangle.CenterOfMass()
c1 = vm.CompositePrimitive2D([triangle, cog_triangle])
c1.MPLPlot()

print(triangle.Area())

p0 = vm.Point2D((-1, 0))
p1 = vm.Point2D((-npy.cos(npy.pi / 4), npy.sin(npy.pi / 4)))
p2 = vm.Point2D((0, 1))

a = vm.Arc2D(p2, p1, p0)
l = vm.LineSegment2D(p2, a.center)
list_node = a.Discretise()

c = vm.Contour2D([a, l] + list_node)
print(c.plot_data())
c2 = vm.CompositePrimitive2D([c])
c2.MPLPlot(style='ob')
print(c.Area())
Beispiel #23
0
p6 = vm.Point2D((0.05, 0.05))

p7 = vm.Point2D((0.06, 0.05))
p8 = vm.Point2D((0.04, 0.07))

radius = {0: 0.01, 2: 0.01, 3: 0.015}

outer_profile = primitives2D.RoundedLineSegments2D([p1, p2, p3, p4, p5],
                                                   radius,
                                                   closed=True)
#hole = vm.Circle2D(p6, 0.01)
#inner_profile = primitives2D.RoundedLineSegments2D([p6, p7, p8], {0: }, closed = True)
l1 = vm.LineSegment2D(p6, p7)
l2 = vm.LineSegment2D(p7, p8)
l3 = vm.LineSegment2D(p8, p6)
c2 = vm.Contour2D([l1, l2, l3])

c1 = vm.Contour2D([outer_profile])
#c2 = vm.Contour2D([inner_profile])

po = vm.Point3D((0, 0, 0))
xp = vm.Vector3D((1, 0, 0))
yp = vm.Vector3D((0, 1, 0))
f, a = c1.MPLPlot()
c2.MPLPlot(a)

profile = primitives3D.ExtrudedProfile(po,
                                       xp,
                                       yp,
                                       c1, [c2],
                                       vm.Vector3D((0, 0, 0.2)),