X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_SWIG%2FSMESH_Sphere.py;h=08294eb5e0f19f52c68f9bd3daa9660f476192c1;hp=36767fdbeb35aaae39dfbea80d850c325725d245;hb=2aed859fcd4a79ddeaf25370c39b2ee713fc873c;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce diff --git a/src/SMESH_SWIG/SMESH_Sphere.py b/src/SMESH_SWIG/SMESH_Sphere.py index 36767fdbe..08294eb5e 100644 --- a/src/SMESH_SWIG/SMESH_Sphere.py +++ b/src/SMESH_SWIG/SMESH_Sphere.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -7,7 +7,7 @@ # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -21,16 +21,23 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# GEOM GEOM_SWIG : binding of C++ omplementaion with Python +# GEOM GEOM_SWIG : binding of C++ implementation with Python # File : GEOM_Sphere.py # Author : Damien COQUERET, Open CASCADE # Module : GEOM # $Header: # -from geompy import * -from math import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New() -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +import math # It is an example of creating a hexahedrical mesh on a sphere. # @@ -42,20 +49,20 @@ import smesh Radius = 100. Dist = Radius / 2. Factor = 2.5 -Angle90 = pi / 2. +Angle90 = math.pi / 2. NbSeg = 10 PointsList = [] ShapesList = [] #Basic Elements -P0 = MakeVertex(0., 0., 0.) -P1 = MakeVertex(-Dist, -Dist, -Dist) -P2 = MakeVertex(-Dist, -Dist, Dist) -P3 = MakeVertex(-Dist, Dist, Dist) -P4 = MakeVertex(-Dist, Dist, -Dist) +P0 = geompy.MakeVertex(0., 0., 0.) +P1 = geompy.MakeVertex(-Dist, -Dist, -Dist) +P2 = geompy.MakeVertex(-Dist, -Dist, Dist) +P3 = geompy.MakeVertex(-Dist, Dist, Dist) +P4 = geompy.MakeVertex(-Dist, Dist, -Dist) -VZ = MakeVectorDXDYDZ(0., 0., 1.) +VZ = geompy.MakeVectorDXDYDZ(0., 0., 1.) #Construction Elements PointsList.append(P1) @@ -64,50 +71,51 @@ PointsList.append(P3) PointsList.append(P4) PointsList.append(P1) -PolyLine = MakePolyline(PointsList) +PolyLine = geompy.MakePolyline(PointsList) -Face1 = MakeFace(PolyLine, 1) -Face2 = MakeScaleTransform(Face1, P0, Factor) -Face3 = MakeScaleTransform(Face1, P0, -1.) +Face1 = geompy.MakeFace(PolyLine, 1) +Face2 = geompy.MakeScaleTransform(Face1, P0, Factor) +Face3 = geompy.MakeScaleTransform(Face1, P0, -1.) #Models -Sphere = MakeSphereR(Radius) +Sphere = geompy.MakeSphereR(Radius) -Block = MakeHexa2Faces(Face1, Face2) -Cube = MakeHexa2Faces(Face1, Face3) +Block = geompy.MakeHexa2Faces(Face1, Face2) +Cube = geompy.MakeHexa2Faces(Face1, Face3) -Common1 = MakeBoolean(Sphere, Block, 1) -Common2 = MakeRotation(Common1, VZ, Angle90) +Common1 = geompy.MakeBoolean(Sphere, Block, 1) +Common2 = geompy.MakeRotation(Common1, VZ, Angle90) -MultiBlock1 = MakeMultiTransformation1D(Common1, 20, -1, 3) -MultiBlock2 = MakeMultiTransformation1D(Common2, 30, -1, 3) +MultiBlock1 = geompy.MakeMultiTransformation1D(Common1, 20, -1, 3) +MultiBlock2 = geompy.MakeMultiTransformation1D(Common2, 30, -1, 3) #Reconstruct sphere from several blocks ShapesList.append(Cube) ShapesList.append(MultiBlock1) ShapesList.append(MultiBlock2) -Compound = MakeCompound(ShapesList) +Compound = geompy.MakeCompound(ShapesList) -Result = MakeGlueFaces(Compound, 0.1) +Result = geompy.MakeGlueFaces(Compound, 0.1) #addToStudy -Id_Sphere = addToStudy(Sphere, "Sphere") -Id_Cube = addToStudy(Cube, "Cube") +Id_Sphere = geompy.addToStudy(Sphere, "Sphere") +Id_Cube = geompy.addToStudy(Cube, "Cube") -Id_Common1 = addToStudy(Common1, "Common1") -Id_Common2 = addToStudy(Common2, "Common2") +Id_Common1 = geompy.addToStudy(Common1, "Common1") +Id_Common2 = geompy.addToStudy(Common2, "Common2") -Id_MultiBlock1 = addToStudy(MultiBlock1, "MultiBlock1") -Id_MultiBlock2 = addToStudy(MultiBlock2, "MultiBlock2") +Id_MultiBlock1 = geompy.addToStudy(MultiBlock1, "MultiBlock1") +Id_MultiBlock2 = geompy.addToStudy(MultiBlock2, "MultiBlock2") -Id_Result = addToStudy(Result, "Result") +Id_Result = geompy.addToStudy(Result, "Result") #----------------------------------------------------------------------- #Meshing -smesh.SetCurrentStudy(salome.myStudy) my_hexa = smesh.Mesh(Result, "Sphere_Mesh") algo = my_hexa.Segment() algo.NumberOfSegments(NbSeg) my_hexa.Quadrangle() my_hexa.Hexahedron() my_hexa.Compute() + +salome.sg.updateObjBrowser()