import GEOM, geompy, math
import smesh, SMESH, SALOMEDS

import StdMeshers

SB_L=	.126
SB_D= .2984
SB_Box=(SB_D/2.0)*0.8
SB_Mesh_NB=10
MidPlane=False

Sphere_1 = geompy.MakeSphereR(SB_D/2.0)
Sphere_1 = geompy.Rotate( Sphere_1, geompy.MakeVectorDXDYDZ( 1,0,0 ), math.pi / 180 * 45 )

Box_1 = geompy.MakeBoxDXDYDZ(SB_L, 1, 1)
Translation_1 = geompy.MakeTranslation(Box_1, -SB_L/2.0, -0.5, -0.5)
Common_1 = geompy.MakeCommon(Translation_1, Sphere_1)
Box_2 = geompy.MakeBoxDXDYDZ(1, 1, 1)
Translation_2 = geompy.MakeTranslation(Box_2, -0.5, 0, 0)
Common_1 = geompy.MakeCommon(Translation_2, Common_1)
geompy.addToStudy( Common_1, 'Common_1' )

SBV1=geompy.MakeVertex(0,-SB_Box/2.0,SB_Box/2.0)
SBV2=geompy.MakeVertex(0,SB_Box/2.0,SB_Box/2.0)
SBV3=geompy.MakeVertex(0,SB_Box/2.0,-SB_Box/2.0)
SBV5=geompy.MakeVertex(0,SB_D,SB_D)
SBL1=geompy.MakeLineTwoPnt(SBV1,SBV2)
SBL2=geompy.MakeLineTwoPnt(SBV2,SBV3)
SBL5=geompy.MakeLineTwoPnt(SBV2,SBV5)
C1=geompy.MakeCompound([SBL1,SBL2,SBL5])
plane2=geompy.MakePrismDXDYDZ2Ways(C1,SB_L,0,0)
geompy.addToStudy(plane2,'plane2')


Plan1 = geompy.MakePlaneLCS(None, 200, 2)
geompy.addToStudy(Plan1,'Plan1')

if MidPlane:
  SB_1=geompy.MakePartition([Common_1], [plane2,Plan1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
else:
  SB_1=geompy.MakePartition([Common_1], [plane2], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
geompy.addToStudy(SB_1,'SB_1')

Mesh_3 = smesh.Mesh(SB_1)
Regular_1D_3 = Mesh_3.Segment()
Max_Size_1_3 = Regular_1D_3.NumberOfSegments(SB_Mesh_NB)
Quadrangle_2D_3 = Mesh_3.Quadrangle(algo=smesh.QUADRANGLE)
Hexa_3D_3 = Mesh_3.Hexahedron(algo=smesh.Hexa)
Mesh_3.Compute()
