Esempio n. 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)
Esempio n. 2
0
    def test_LocalEdgeLength(self):
        """
        Test a mesh on a box with a local edge length enforced on one edge.
        """
        box = BRepPrimAPI_MakeBox(10, 10, 10).Solid()
        edge = TopExp_Explorer(box, TopAbs_EDGE).Current()

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

        hyp3d = NETGENPlugin_SimpleHypothesis_3D(0, 0, gen)
        hyp3d.SetLocalLength(1.0)
        NETGENPlugin_NETGEN_2D3D(1, 0, gen)

        hyp1d = StdMeshers_LocalLength(2, 0, gen)
        hyp1d.SetLength(0.1)
        StdMeshers_Regular_1D(3, 0, gen)

        mesh.ShapeToMesh(box)
        mesh.AddHypothesis(box, 0)
        mesh.AddHypothesis(box, 1)
        mesh.AddHypothesis(edge, 2)
        mesh.AddHypothesis(edge, 3)

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

        self.assertEqual(mesh.NbTetras(), 31547)
        self.assertEqual(mesh.NbNodes(), 6205)
Esempio n. 3
0
def test_Box3D():
    """
    Test a tetrahedral mesh of a simple solid box
    """
    from OCCT.BRepPrimAPI import BRepPrimAPI_MakeBox
    from OCCT.NETGENPlugin import (NETGENPlugin_SimpleHypothesis_3D,
                                   NETGENPlugin_NETGEN_2D3D)
    from OCCT.SMESH import SMESH_Gen

    box = BRepPrimAPI_MakeBox(10, 10, 10).Solid()

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

    hyp = NETGENPlugin_SimpleHypothesis_3D(0, 0, gen)
    hyp.SetLocalLength(1.0)

    NETGENPlugin_NETGEN_2D3D(1, 0, gen)

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

    success = gen.Compute(mesh, box)
    assert success

    assert mesh.NbTetras() == 4767
    assert mesh.NbNodes() == 1189
Esempio n. 4
0
    def test_Box3D(self):
        """
        Test a tetrahedral mesh of a simple solid box.
        """
        box = BRepPrimAPI_MakeBox(10, 10, 10).Solid()

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

        hyp = NETGENPlugin_SimpleHypothesis_3D(0, 0, gen)
        hyp.SetLocalLength(1.0)

        NETGENPlugin_NETGEN_2D3D(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.NbTetras(), 4741)
        self.assertEqual(mesh.NbNodes(), 1185)
Esempio n. 5
0
from OCCT.NETGENPlugin import (NETGENPlugin_SimpleHypothesis_3D,
                               NETGENPlugin_NETGEN_2D3D)
from OCCT.SMESH import SMESH_Gen

from OCCT.Exchange import ExchangeBasic
from OCCT.Visualization.WxViewer import ViewerWx

fn = './models/shape_names.step'
shape = ExchangeBasic.read_step(fn)

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

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

hyp = NETGENPlugin_SimpleHypothesis_3D(0, 0, gen)
hyp.SetLocalLength(5)

alg = NETGENPlugin_NETGEN_2D3D(1, 0, gen)

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

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

v = ViewerWx()
##
##You should have received a copy of the GNU Lesser General Public License
##along with pythonOCC.  If not, see <http://www.gnu.org/licenses/>.

from OCCT.BRepPrimAPI import BRepPrimAPI_MakeBox
from OCCT.SMESH import SMESH_Gen
from OCCT.StdMeshers import (StdMeshers_Arithmetic1D, StdMeshers_Regular_1D,
                            StdMeshers_TrianglePreference, StdMeshers_MEFISTO_2D,
                            StdMeshers_QuadranglePreference, StdMeshers_Quadrangle_2D)

#Create the shape to mesh

aShape = BRepPrimAPI_MakeBox(10, 20, 40).Shape()

aMeshGen = SMESH_Gen()
aMesh = aMeshGen.CreateMesh(0, True)

def ComputeMesh(MEFISTO2=False):
    an1DHypothesis = StdMeshers_Arithmetic1D(0,0,aMeshGen)
    #print dir(an1DHypothesis)
    #print an1DHypothesis.SaveTo()
    
    an1DHypothesis.SetLength(1.,False)
    an1DHypothesis.SetLength(2.,True)
    an1DAlgo = StdMeshers_Regular_1D(1,0,aMeshGen)
    
    if MEFISTO2:
    #2D
        a2dHypothseis = StdMeshers_TrianglePreference(2,0,aMeshGen) #define the boundary
        a2dAlgo = StdMeshers_MEFISTO_2D(3,0,aMeshGen)
    else: