#!/usr/bin/env python

###
### This file is generated automatically by SALOME v9.3.0 with dump python functionality
###

import sys
import salome

salome.salome_init()
import salome_notebook
notebook = salome_notebook.NoteBook()
sys.path.insert(0, r'C:\Users\IGORVI~1\AppData\Local\Temp\cenos\~new-cenos-case//geometry//')

####################################################
##       Begin of NoteBook variables section      ##
####################################################
notebook.set("coil_scanning", 0)
####################################################
##        End of NoteBook variables section       ##
####################################################
###
### GEOM component
###

import GEOM
from salome.geom import geomBuilder
import math
import SALOMEDS


geompy = geomBuilder.New()

O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
geomObj_1 = geompy.MakeVertex(0, -10, 0)
geomObj_2 = geompy.MakeVertex(40, -10, 0)
geomObj_3 = geompy.MakeVertex(40, 0, 0)
geomObj_4 = geompy.MakeVertex(15, 0, 0)
geomObj_5 = geompy.MakeVertex(15, 100, 0)
geomObj_6 = geompy.MakeVertex(0, 100, 0)
geomObj_7 = geompy.MakeLineTwoPnt(geomObj_1, geomObj_2)
geomObj_8 = geompy.MakeLineTwoPnt(geomObj_2, geomObj_3)
geomObj_9 = geompy.MakeLineTwoPnt(geomObj_3, geomObj_4)
geomObj_10 = geompy.MakeLineTwoPnt(geomObj_4, geomObj_5)
geomObj_11 = geompy.MakeLineTwoPnt(geomObj_5, geomObj_6)
geomObj_12 = geompy.MakeLineTwoPnt(geomObj_6, geomObj_1)
WorkpieceFace_1 = geompy.MakeFaceWires([geomObj_7, geomObj_8, geomObj_9, geomObj_10, geomObj_11, geomObj_12], 1)
geomObj_13 = geompy.MakeVertex(21, 6, 0)
geomObj_14 = geompy.MakeVectorDXDYDZ(0, 0, 1)
geomObj_15 = geompy.MakeDiskPntVecR(geomObj_13, geomObj_14, 4)
geomObj_16 = geompy.MakeVectorDXDYDZ(0, 0, 1)
geomObj_17 = geompy.MakeDiskPntVecR(geomObj_13, geomObj_16, 3)
WindingArea_0 = geompy.MakeCutList(geomObj_15, [geomObj_17], True)
geomObj_18 = geompy.MakeVertex(21, 18, 0)
geomObj_19 = geompy.MakeVectorDXDYDZ(0, 0, 1)
geomObj_20 = geompy.MakeDiskPntVecR(geomObj_18, geomObj_19, 4)
geomObj_21 = geompy.MakeVectorDXDYDZ(0, 0, 1)
geomObj_22 = geompy.MakeDiskPntVecR(geomObj_18, geomObj_21, 3)
WindingArea_1 = geompy.MakeCutList(geomObj_20, [geomObj_22], True)
Translation_1 = geompy.MakeTranslation(WindingArea_0, 0, "coil_scanning", 0)
Translation_1_1 = geompy.MakeTranslation(WindingArea_1, 0, "coil_scanning", 0)
geomObj_23 = geompy.MakeVertex(0, -130.0000004, 0)
geomObj_24 = geompy.MakeVertex(170.0000003, -130.0000004, 0)
geomObj_25 = geompy.MakeVertex(170.0000003, 220.0000004, 0)
geomObj_26 = geompy.MakeVertex(0, 220.0000004, 0)
geomObj_27 = geompy.MakeLineTwoPnt(geomObj_23, geomObj_24)
geomObj_28 = geompy.MakeLineTwoPnt(geomObj_24, geomObj_25)
geomObj_29 = geompy.MakeLineTwoPnt(geomObj_25, geomObj_26)
geomObj_30 = geompy.MakeLineTwoPnt(geomObj_26, geomObj_23)
AirFace_1 = geompy.MakeFaceWires([geomObj_27, geomObj_28, geomObj_29, geomObj_30], 1)
Partition_1 = geompy.MakePartition([WorkpieceFace_1, Translation_1, Translation_1_1, AirFace_1], [], [], [], geompy.ShapeType["FACE"], 0, [], 0)
workpiece = geompy.CreateGroup(Partition_1, geompy.ShapeType["FACE"])
geomObj_31 = geompy.GetInPlace(Partition_1, WorkpieceFace_1, False)
geompy.UnionList(workpiece, [geomObj_31])
inductor = geompy.CreateGroup(Partition_1, geompy.ShapeType["FACE"])
winding_0 = geompy.CreateGroup(Partition_1, geompy.ShapeType["FACE"])
geomObj_32 = geompy.GetInPlace(Partition_1, Translation_1, False)
geompy.UnionList(winding_0, [geomObj_32])
geompy.UnionList(inductor, [winding_0])
winding_1 = geompy.CreateGroup(Partition_1, geompy.ShapeType["FACE"])
geomObj_33 = geompy.GetInPlace(Partition_1, Translation_1_1, False)
geompy.UnionList(winding_1, [geomObj_33])
geompy.UnionList(inductor, [winding_1])
[geomObj_34,geomObj_35] = geompy.SubShapeAllSortedCentres(inductor, geompy.ShapeType["FACE"])
air = geompy.CreateGroup(Partition_1, geompy.ShapeType["FACE"])
geomObj_36 = geompy.GetInPlace(Partition_1, AirFace_1, False)
geompy.UnionList(air, [geomObj_36])
geompy.RemoveObject(air, 2)
[geomObj_37,geomObj_38,geomObj_39,geomObj_40,geomObj_41] = geompy.GetSharedShapes(workpiece, air, geompy.ShapeType["EDGE"])
workpiece_surface = geompy.CreateGroup(Partition_1, geompy.ShapeType["EDGE"])
geompy.UnionList(workpiece_surface, [geomObj_37])
geompy.UnionList(workpiece_surface, [geomObj_38])
geompy.UnionList(workpiece_surface, [geomObj_39])
geompy.UnionList(workpiece_surface, [geomObj_40])
geompy.UnionList(workpiece_surface, [geomObj_41])
[geomObj_42,geomObj_43,geomObj_44,geomObj_45,geomObj_46] = geompy.SubShapeAll(workpiece_surface, geompy.ShapeType["EDGE"])
geomObj_47 = geompy.GetInPlace(air, geomObj_30, False)
air_axis = geompy.CreateGroup(Partition_1, geompy.ShapeType["EDGE"])
geompy.UnionList(air_axis, [geomObj_47])
geomObj_48 = geompy.GetInPlace(workpiece, geomObj_30, False)
workpiece_axis = geompy.CreateGroup(Partition_1, geompy.ShapeType["EDGE"])
geompy.UnionList(workpiece_axis, [geomObj_48])
air_infinity = geompy.CreateGroup(Partition_1, geompy.ShapeType["EDGE"])
geomObj_49 = geompy.GetInPlace(air, geomObj_27, False)
geompy.UnionList(air_infinity, [geomObj_49])
geomObj_50 = geompy.GetInPlace(air, geomObj_28, False)
geompy.UnionList(air_infinity, [geomObj_50])
geomObj_51 = geompy.GetInPlace(air, geomObj_29, False)
geompy.UnionList(air_infinity, [geomObj_51])
geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )
geompy.addToStudy( WorkpieceFace_1, 'WorkpieceFace_1' )
geompy.addToStudy( WindingArea_0, 'WindingArea_0' )
geompy.addToStudy( WindingArea_1, 'WindingArea_1' )
geompy.addToStudy( Translation_1, 'Translation_1' )
geompy.addToStudy( Translation_1_1, 'Translation_1' )
geompy.addToStudy( AirFace_1, 'AirFace_1' )
geompy.addToStudy( Partition_1, 'Partition_1' )
geompy.addToStudyInFather( Partition_1, workpiece, 'workpiece' )
geompy.addToStudyInFather( Partition_1, inductor, 'inductor' )
geompy.addToStudyInFather( Partition_1, winding_0, 'winding_0' )
geompy.addToStudyInFather( Partition_1, winding_1, 'winding_1' )
geompy.addToStudyInFather( Partition_1, air, 'air' )
geompy.addToStudyInFather( Partition_1, workpiece_surface, 'workpiece_surface' )
geompy.addToStudyInFather( Partition_1, air_axis, 'air_axis' )
geompy.addToStudyInFather( Partition_1, workpiece_axis, 'workpiece_axis' )
geompy.addToStudyInFather( Partition_1, air_infinity, 'air_infinity' )

###
### SMESH component
###

import  SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New()
#smesh.SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations:
                                 # multiples meshes built in parallel, complex and numerous mesh edition (performance)

Mesh_1 = smesh.Mesh(Partition_1)
NETGEN_2D_1 = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D)
NETGEN_Parameters_2D = NETGEN_2D_1.Parameters()
NETGEN_Parameters_2D.SetMaxSize( 11 )
NETGEN_Parameters_2D.SetSecondOrder( 0 )
NETGEN_Parameters_2D.SetOptimize( 1 )
NETGEN_Parameters_2D.SetFineness( 2 )
NETGEN_Parameters_2D.SetMinSize( 0 )
NETGEN_Parameters_2D.SetUseSurfaceCurvature( 1 )
NETGEN_Parameters_2D.SetFuseEdges( 1 )
NETGEN_Parameters_2D.SetQuadAllowed( 0 )
Regular_1D_2 = Mesh_1.Segment(geom=workpiece)
MaxLength_0_5 = Regular_1D_2.MaxSize(0.5)
NETGEN_2D_1_1 = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D,geom=workpiece)
NETGEN_Parameters_2D_1 = NETGEN_2D_1_1.Parameters()
NETGEN_Parameters_2D_1.SetMinSize( 0.25 )
NETGEN_Parameters_2D_1.SetMaxSize( 0.5 )
NETGEN_Parameters_2D_1.SetFineness( 2 )
NETGEN_Parameters_2D_1.SetSecondOrder( 0 )
NETGEN_Parameters_2D_1.SetOptimize( 1 )
NETGEN_Parameters_2D_1.SetUseSurfaceCurvature( 1 )
NETGEN_Parameters_2D_1.SetFuseEdges( 1 )
NETGEN_Parameters_2D_1.SetQuadAllowed( 0 )
ViscousLayers2D_0_23359 = NETGEN_2D_1_1.ViscousLayers2D(0.233599,7,1.4)
Regular_1D_2_1 = Mesh_1.Segment(geom=inductor)
MaxLength_0_33333_ = Regular_1D_2_1.MaxSize(0.333333)
NETGEN_2D_1_2 = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D,geom=inductor)
NETGEN_Parameters_2D_2 = NETGEN_2D_1_2.Parameters()
NETGEN_Parameters_2D_2.SetMinSize( 0.166667 )
NETGEN_Parameters_2D_2.SetMaxSize( 0.333333 )
NETGEN_Parameters_2D_2.SetFineness( 2 )
NETGEN_Parameters_2D_2.SetSecondOrder( 0 )
NETGEN_Parameters_2D_2.SetOptimize( 1 )
NETGEN_Parameters_2D_2.SetUseSurfaceCurvature( 1 )
NETGEN_Parameters_2D_2.SetFuseEdges( 1 )
NETGEN_Parameters_2D_2.SetQuadAllowed( 0 )
ViscousLayers2D_0_64361 = NETGEN_2D_1_2.ViscousLayers2D(0.643616,7,1.4)
workpiece_1 = Mesh_1.GroupOnGeom(workpiece,'workpiece',SMESH.FACE)
winding_0_1 = Mesh_1.GroupOnGeom(winding_0,'winding_0',SMESH.FACE)
winding_1_1 = Mesh_1.GroupOnGeom(winding_1,'winding_1',SMESH.FACE)
air_1 = Mesh_1.GroupOnGeom(air,'air',SMESH.FACE)
workpiece_surface_1 = Mesh_1.GroupOnGeom(workpiece_surface,'workpiece_surface',SMESH.EDGE)
air_axis_1 = Mesh_1.GroupOnGeom(air_axis,'air_axis',SMESH.EDGE)
workpiece_axis_1 = Mesh_1.GroupOnGeom(workpiece_axis,'workpiece_axis',SMESH.EDGE)
air_infinity_1 = Mesh_1.GroupOnGeom(air_infinity,'air_infinity',SMESH.EDGE)
isDone = Mesh_1.Compute()
[ workpiece_1, winding_0_1, winding_1_1, air_1, workpiece_surface_1, air_axis_1, workpiece_axis_1, air_infinity_1 ] = Mesh_1.GetGroups()
NETGEN_2D = Regular_1D_2.GetSubMesh()
NETGEN_2D_2 = Regular_1D_2_1.GetSubMesh()


## Set names of Mesh objects
smesh.SetName(NETGEN_2D_1.GetAlgorithm(), 'NETGEN_2D_1')
smesh.SetName(Regular_1D_2.GetAlgorithm(), 'Regular_1D_2')
smesh.SetName(MaxLength_0_5, 'MaxLength=0.5')
smesh.SetName(NETGEN_Parameters_2D_1, 'NETGEN_Parameters_2D')
smesh.SetName(NETGEN_Parameters_2D, 'NETGEN_Parameters_2D')
smesh.SetName(NETGEN_Parameters_2D_2, 'NETGEN_Parameters_2D')
smesh.SetName(ViscousLayers2D_0_64361, 'ViscousLayers2D=0.64361...,7,1.4,[],1')
smesh.SetName(workpiece_1, 'workpiece')
smesh.SetName(ViscousLayers2D_0_23359, 'ViscousLayers2D=0.23359...,7,1.4,[4, 7, ...],0')
smesh.SetName(winding_0_1, 'winding_0')
smesh.SetName(MaxLength_0_33333_, 'MaxLength=0.33333...')
smesh.SetName(winding_1_1, 'winding_1')
smesh.SetName(air_1, 'air')
smesh.SetName(NETGEN_2D, 'NETGEN_2D')
smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
smesh.SetName(NETGEN_2D_2, 'NETGEN_2D')
smesh.SetName(workpiece_surface_1, 'workpiece_surface')
smesh.SetName(workpiece_axis_1, 'workpiece_axis')
smesh.SetName(air_axis_1, 'air_axis')
smesh.SetName(air_infinity_1, 'air_infinity')


if salome.sg.hasDesktop():
  salome.sg.updateObjBrowser()
