|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +##Copyright 2009-2013 Thomas Paviot (tpaviot@gmail.com) |
| 4 | +## |
| 5 | +##This file is part of pythonOCC. |
| 6 | +## |
| 7 | +##pythonOCC is free software: you can redistribute it and/or modify |
| 8 | +##it under the terms of the GNU Lesser General Public License as published by |
| 9 | +##the Free Software Foundation, either version 3 of the License, or |
| 10 | +##(at your option) any later version. |
| 11 | +## |
| 12 | +##pythonOCC is distributed in the hope that it will be useful, |
| 13 | +##but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +##GNU Lesser General Public License for more details. |
| 16 | +## |
| 17 | +##You should have received a copy of the GNU Lesser General Public License |
| 18 | +##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. |
| 19 | + |
| 20 | +from __future__ import print_function |
| 21 | + |
| 22 | +import unittest |
| 23 | +import os |
| 24 | + |
| 25 | +from OCC.BRepPrimAPI import BRepPrimAPI_MakeSphere |
| 26 | + |
| 27 | +from OCC.SMESH import SMESH_Gen, SMESH_MeshVSLink |
| 28 | +from OCC.StdMeshers import (StdMeshers_Arithmetic1D, StdMeshers_TrianglePreference, |
| 29 | + StdMeshers_Regular_1D, StdMeshers_Quadrangle_2D) |
| 30 | + |
| 31 | +class TestSMESH(unittest.TestCase): |
| 32 | + def test_mesh_sphere_quadrangle(self): |
| 33 | + aShape = BRepPrimAPI_MakeSphere(10.).Shape() |
| 34 | + # Create the Mesh |
| 35 | + aMeshGen = SMESH_Gen() |
| 36 | + aMesh = aMeshGen.CreateMesh(0, True) |
| 37 | + # 1D |
| 38 | + an1DHypothesis = StdMeshers_Arithmetic1D(0, 0, aMeshGen)#discretization of the wire |
| 39 | + an1DHypothesis.SetLength(0.1, False) #the smallest distance between 2 points |
| 40 | + an1DHypothesis.SetLength(0.5, True) # the longest distance between 2 points |
| 41 | + an1DAlgo = StdMeshers_Regular_1D(1, 0, aMeshGen) # interpolation |
| 42 | + # 2D |
| 43 | + a2dHypothseis = StdMeshers_TrianglePreference(2, 0, aMeshGen) #define the boundary |
| 44 | + a2dAlgo = StdMeshers_Quadrangle_2D(3, 0, aMeshGen) # the 2D mesh |
| 45 | + #Calculate mesh |
| 46 | + aMesh.ShapeToMesh(aShape) |
| 47 | + #Assign hyptothesis to mesh |
| 48 | + aMesh.AddHypothesis(aShape, 0) |
| 49 | + aMesh.AddHypothesis(aShape, 1) |
| 50 | + aMesh.AddHypothesis(aShape, 2) |
| 51 | + aMesh.AddHypothesis(aShape, 3) |
| 52 | + #Compute the data |
| 53 | + aMeshGen.Compute(aMesh, aMesh.GetShapeToMesh()) |
| 54 | + |
| 55 | + |
| 56 | +def suite(): |
| 57 | + suite = unittest.TestSuite() |
| 58 | + suite.addTest(unittest.makeSuite(TestSMESH)) |
| 59 | + return suite |
| 60 | + |
| 61 | +if __name__ == "__main__": |
| 62 | + unittest.main() |
0 commit comments