Exemple #1
0
class Box(ComplexSection):
    dimensions = Dimensions(a=None, b=None, ta=None, tb=None)
    sections = [Polygon]

    def check_dimensions(self, dims):
        if dims.a <= 0:
            raise ValueError("Invalid dimensions: a <= 0")
        if dims.b <= 0:
            raise ValueError("Invalid dimensions: b <= 0")
        if dims.ta <= 0:
            raise ValueError("Invalid dimensions: ta <= 0")
        if dims.tb <= 0:
            raise ValueError("Invalid dimensions: tb <= 0")
        if dims.a <= 2 * dims.tb:
            raise ValueError("Invalid dimensions: a <= 2*tb")
        if dims.b <= 2 * dims.ta:
            raise ValueError("Invalid dimensions: b <= 2*ta")

    def update_sections(self):
        ao = 0.5 * self.a
        ai = 0.5 * (self.a - 2 * self.tb)
        bo = 0.5 * self.b
        bi = 0.5 * (self.b - 2 * self.ta)

        polygon = self.sections[0]
        polygon[:] = [(-ao, -bo), (ao, -bo), (ao, bo), (-ao, bo), (-ao, -bi),
                      (-ai, -bi), (-ai, bi), (ai, bi), (ai, -bi), (-ao, -bi)]
Exemple #2
0
class Ring(ComplexSection):
    sections = [CircularSector]
    dimensions = Dimensions(ro=None, ri=None)

    def update_sections(self):
        self.sections[0].set_dimensions(ro=self.ro, ri=self.ri, phi=2 * pi)

    def check_dimensions(self, dims):
        super(Ring, self).check_dimensions(dims)
Exemple #3
0
class BaseFillet(ComplexSection):
    sections = [Triangle, CircularSegment]
    dimensions = Dimensions(r=None, phi=None)
    densities = [1.0, -1.0]

    def check_dimensions(self, dims):
        if dims.r <= 0:
            raise ValueError("Invalid dimensions: r <= 0")
        if dims.phi <= 0:
            raise ValueError("Invalid dimensions: phi <= 0")
        if dims.phi == pi:
            raise ValueError("Invalid dimensions: phi = pi")
        if dims.phi >= 2 * pi:
            raise ValueError("Invalid dimensions: phi >= 2*pi")

    def update_sections(self):
        def sign(x):
            return x / abs(x)

        alpha = self.phi / 2
        beta = abs(pi - self.phi)
        theta = pi * (self.phi < pi)
        a = self.r * cos(alpha) / sin(alpha)
        b = self.r * cos(alpha)**2 / sin(alpha) * sign(a)
        c = self.r * cos(alpha)
        d = self.r / sin(alpha) * sign(a)

        triangle = self.sections[0]
        triangle[:] = [(0, 0), (b, c), (b, -c)]

        segment = self.sections[1]
        segment.set_dimensions(r=self.r, phi=beta)
        segment.set_position(d1=d, d2=0, theta=theta)

        if self.phi > pi:
            self.densities = [-d for d in self.__class__.densities]
        else:
            self.densities = self.__class__.densities[:]
        self.set_density(self.density)
Exemple #4
0
class Wedge(ComplexSection):
    sections = [CircularSector]
    dimensions = Dimensions(r=None, phi=None)

    def update_sections(self):
        self.sections[0].set_dimensions(ro=self.r, ri=0, phi=self.phi)
Exemple #5
0
class Circle(ComplexSection):
    dimensions = Dimensions(r=None)
    sections = [CircularSector]

    def update_sections(self):
        self.sections[0].set_dimensions(ri=0, ro=self.r, phi=2 * pi)