Exemple #1
0
 def setUpClass(cls):
     shape = brep.read_brep('./test_io/rhs_wing.brep')
     cls.wing = Body(shape, 'wing')
     face = brep.read_brep('./test_io/rhs_wing_sref.brep')
     sref = face.surface
     cls.wing.set_sref(sref)
     shape = brep.read_brep('./test_io/fuselage.brep')
     cls.fuselage = Body(shape, 'fuselage')
Exemple #2
0
    def test_cut_fail_10232017(self):
        shape1 = brep.read_brep('./test_io/cut_fail_10232017_shape1.brep')
        shape2 = brep.read_brep('./test_io/cut_fail_10232017_shape2.brep')

        cut = CutShapes(shape1, shape2)
        self.assertTrue(cut.is_done)

        shape = cut.shape
        self.assertTrue(CheckShape(shape).is_valid)
Exemple #3
0
    def test_section_fail_08292017(self):
        """
        Intersection between a planar face and an edge. Should result in a
        vertex but finds nothing. Appears to be OCCT bug. Same behavior in
        SALOME 8.2.0.
        """
        shape1 = brep.read_brep('./test_io/section_fail_08292017_shape1.brep')
        shape2 = brep.read_brep('./test_io/section_fail_08292017_shape2.brep')

        section = IntersectShapes(shape1, shape2)
        self.assertTrue(section.is_done)

        verts = section.vertices
        self.assertEqual(len(verts), 1)
Exemple #4
0
    def test_common_fail_02282018(self):
        """
        Common operation between a wing solid and a basis shell. The result
        is empty but should not be.
        """
        shape1 = brep.read_brep('./test_io/common_fail_02282018_shape1.brep')
        shape2 = brep.read_brep('./test_io/common_fail_02282018_shape2.brep')

        common = CommonShapes(shape1, shape2)
        self.assertTrue(common.is_done)

        shape = common.shape
        self.assertTrue(CheckShape(shape).is_valid)

        faces = shape.faces
        self.assertGreater(len(faces), 0)
Exemple #5
0
    def test_section_fail_03012018(self):
        """
        Intersection between xz-plane and a face. The intersection should be
        a single edge, but it's sometimes two edges with a gap in between or
        an edge and a single vertex.
        """
        shape1 = brep.read_brep('./test_io/section_fail_03012018_shape1.brep')
        shape2 = brep.read_brep('./test_io/section_fail_03012018_shape2.brep')

        section = IntersectShapes(shape1, shape2)
        self.assertTrue(section.is_done)

        shape = section.shape
        self.assertTrue(CheckShape(shape).is_valid)

        self.assertEqual(len(section.edges), 1)
        self.assertEqual(len(section.vertices), 2)
Exemple #6
0
    def test_fuse_fail_09142017(self):
        """
        In OCE 0.18 these shapes fail to fuse. In SALOME 8.2.0, they will fuse
        with the "Remove extra edges" set to OFF.
        """
        shape1 = brep.read_brep('./test_io/fuse_fail_09142017_shape1.brep')
        shape2 = brep.read_brep('./test_io/fuse_fail_09142017_shape2.brep')

        fuse = FuseShapes(shape1, shape2)
        self.assertTrue(fuse.is_done)

        shape = fuse.shape
        self.assertTrue(CheckShape(shape).is_valid)
        faces = shape.faces
        self.assertEqual(len(faces), 4)

        section_edges = fuse.section_edges
        self.assertEqual(len(section_edges), 1)
Exemple #7
0
    def test_section_fail_0912017(self):
        """
        Intersection between wing solid and planar face near a wing cross
        section.
        """
        shape1 = brep.read_brep('./test_io/section_fail_09122017_shape1.brep')
        shape2 = brep.read_brep('./test_io/section_fail_09122017_shape2.brep')

        section = IntersectShapes(shape1, shape2)
        self.assertTrue(section.is_done)

        shape = section.shape
        self.assertTrue(CheckShape(shape).is_valid)

        self.assertEqual(len(section.edges), 6)

        builder = WiresByShape(shape)
        self.assertEqual(builder.nwires, 1)
        wire = builder.wires[0]
        self.assertTrue(wire.closed)
Exemple #8
0
    def setUpClass(cls):
        shape = brep.read_brep('./test_io/rhs_wing.brep')
        cls.wing = Body(shape, 'wing')
        face = brep.read_brep('./test_io/rhs_wing_sref.brep')
        sref = face.surface
        cls.wing.set_sref(sref)
        shape = brep.read_brep('./test_io/fuselage.brep')
        cls.fuselage = Body(shape, 'fuselage')

        cls.fspar = SparByParameters('fspar', 0.15, 0.15, 0.15, 0.5,
                                     cls.wing).part
        cls.rspar = SparByParameters('rspar', 0.65, 0.15, 0.65, 0.5,
                                     cls.wing).part
        cls.part1 = RibByPoints('rib1', cls.fspar.p1, cls.rspar.p1,
                                cls.wing).part
        cls.part2 = RibByPoints('rib2', cls.fspar.p2, cls.rspar.p2,
                                cls.wing).part

        cls.null_rib = RibByParameters('null rib', 0.15, 0.5, 0.65, 0.5,
                                       cls.wing).part
        cls.null_rib.shape.nullify()
import time

from afem.exchange import brep
from afem.graphics import Viewer
from afem.smesh import *

fn = 'wing_body.brep'
shape = brep.read_brep(fn)

# MeshGems
the_gen = MeshGen()
the_mesh = the_gen.create_mesh(shape)
alg2d = MeshGemsAlgo2D(the_gen)
hyp2d = MeshGemsHypo2D(the_gen, 4.)
the_mesh.add_hypotheses([alg2d, hyp2d])
print('Computing mesh with MeshGems...')
start = time.time()
the_gen.compute(the_mesh)
print('MeshGems complete in ', time.time() - start, ' seconds.')

gui = Viewer()
gui.add(the_mesh)
gui.start()
from afem.geometry import *
from afem.graphics import Viewer
from afem.smesh import *
from afem.oml import Body
from afem.structure import *
from afem.topology import *

Settings.set_units('in')
Settings.log_to_console()

# IMPORT SOLIDS ---------------------------------------------------------------
fn1 = r'..\models\uCRM\fuselage.brep'
fn2 = r'..\models\uCRM\lhs_wing.brep'
fn3 = r'..\models\uCRM\rhs_wing.brep'

shape1 = brep.read_brep(fn1)
shape2 = brep.read_brep(fn2)
shape3 = brep.read_brep(fn3)

fuselage = Body(shape1, 'fuselage')
lhs_wing = Body(shape2, 'lhs wing')
rhs_wing = Body(shape3, 'rhs wing')

fuselage.set_transparency(0.75)
fuselage.set_color(0.5, 0.5, 0.5)
lhs_wing.set_transparency(0.75)
lhs_wing.set_color(0.5, 0.5, 0.5)
rhs_wing.set_transparency(0.75)
rhs_wing.set_color(0.5, 0.5, 0.5)

# BUILD REFERENCE SURFACES ----------------------------------------------------