Beispiel #1
0
    def test_Box2DQuad(self):
        """
        Test a quadrilateral mesh of a simple box.
        """
        box = BRepPrimAPI_MakeBox(10, 10, 10).Solid()

        gen = SMESH_Gen()
        mesh = gen.CreateMesh(0, True)

        hyp = NETGENPlugin_SimpleHypothesis_2D(0, 0, gen)
        hyp.SetAllowQuadrangles(True)
        hyp.SetLocalLength(1.0)

        NETGENPlugin_NETGEN_2D(1, 0, gen)

        mesh.ShapeToMesh(box)
        mesh.AddHypothesis(box, 0)
        mesh.AddHypothesis(box, 1)

        success = gen.Compute(mesh, box)
        self.assertTrue(success)

        self.assertEqual(mesh.NbTriangles(), 0)
        self.assertEqual(mesh.NbQuadrangles(), 600)
        self.assertEqual(mesh.NbNodes(), 602)
Beispiel #2
0
    def __init__(self,
                 gen,
                 local_length=None,
                 nseg=None,
                 allow_quads=True,
                 length_from_edges=False,
                 max_area=0.):
        hyp = NETGENPlugin_SimpleHypothesis_2D(gen.new_id(), -1, gen.object)
        super(NetgenSimple2D, self).__init__(hyp)

        if local_length is not None:
            self._hyp.SetLocalLength(local_length)
        if nseg is not None:
            self._hyp.SetNumberOfSegments(nseg)
        self._hyp.SetAllowQuadrangles(allow_quads)
        if length_from_edges:
            self._hyp.LengthFromEdges()
        if max_area > 0.:
            self._hyp.SetMaxElementArea(max_area)
Beispiel #3
0
from OCCT.Exchange import ExchangeBasic
from OCCT.Visualization.WxViewer import ViewerWx

fn = './models/wingbox.brep'
shape = ExchangeBasic.read_brep(fn)

v = ViewerWx()
v.add(shape)
v.start()

gen = SMESH_Gen()
mesh = gen.CreateMesh(0, True)
assert isinstance(mesh, SMESH_Mesh)

hyp2d = NETGENPlugin_SimpleHypothesis_2D(0, 0, gen)
hyp2d.SetAllowQuadrangles(True)
hyp2d.SetLocalLength(4.0)

alg2d = NETGENPlugin_NETGEN_2D(1, 0, gen)

mesh.ShapeToMesh(shape)
mesh.AddHypothesis(shape, 0)
mesh.AddHypothesis(shape, 1)

print('Computing mesh...')
done = gen.Compute(mesh, mesh.GetShapeToMesh())
assert done
print('done.')

v = ViewerWx()