if not isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object):
raise ValueError("geom argument must be a geometry")
- import SHAPERSTUDY
- import shaperBuilder
+ try:
+ import SHAPERSTUDY
+ shaper_object = SHAPERSTUDY.SHAPERSTUDY_ORB._objref_SHAPER_Object
+ has_shaper = True
+ except ImportError:
+ shaper_object = int
+ has_shaper = False
+
# If we have a shaper object converting it into geom (temporary solution)
- if isinstance(geom, SHAPERSTUDY.SHAPERSTUDY_ORB._objref_SHAPER_Object):
- self._geom_obj = _shaperstudy2geom(geompyD, geom)
+ if isinstance(geom, shaper_object):
+ geom_obj = _shaperstudy2geom(geompyD, geom)
+ elif isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object):
+ geom_obj = geom
else:
- self._geom_obj = geom
+ msg= ""
+ if not has_shaper:
+ msg = "\nShaper was not compiled"
+ raise Exception("Could not handle geom format {}.{} ".format(type(geom), msg))
# Splitting geometry into one geom containing 1D and 2D elements and a
# list of 3D elements
salome.salome_init_without_session()
import GEOM
-import SHAPERSTUDY
from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
from salome.shaper import model
if ( abs(a-b) < tol ):
return True
else:
- print( "not close vals", a, b )
+ print( "not close vals", a, b )
return False
MesherShinkBox = smesh_builder.Mesh(ShrinkBox, "ShrinkMesh")
ShrinkBoxMesh = MesherShinkBox.Tetrahedron(smeshBuilder.NETGEN_1D2D3D)
-#Compute
+#Compute
success = MesherShinkBox.Compute()
assert( success )
assert( MesherShinkBox.NbVolumes() == 5 ) # if Fails! change the default value of volumes when meshing with Netgen!
MesherShinkBox2 = smesh_builder.Mesh(ShrinkBox2, "ShrinkMesh2")
ShrinkBoxMesh2 = MesherShinkBox2.Tetrahedron(smeshBuilder.NETGEN_1D2D3D)
-#Compute
+#Compute
success = MesherShinkBox2.Compute()
assert( success )
numOfSegments = 4
algo.NumberOfSegments(numOfSegments)
ShrinkFaceMesh = MesherShinkFace.Triangle()
-#Compute
+#Compute
success = MesherShinkFace.Compute()
assert( success )
numFaceElementShrinkGeom = MesherShinkFace.NbFaces()
algo.NumberOfSegments(numOfSegments)
ShrinkCircleMesh = MesherShinkCircle.Triangle()
-#Compute
+#Compute
success = MesherShinkCircle.Compute()
numFaceElementShrinkGeom = MesherShinkCircle.NbFaces()
assert( success )
FinalCircleMesh = viscousBuilder.AddLayers( MesherShinkCircle )
finalNumOfElements = FinalCircleMesh.NbFaces()
assert( numFaceElementShrinkGeom + numOfSegments * numberOfLayers == finalNumOfElements )
-#############END MESH CIRCULAR FACE
\ No newline at end of file
+#############END MESH CIRCULAR FACE
salome.salome_init_without_session()
import GEOM
-import SHAPERSTUDY
from salome.geom import geomBuilder
from salome.smesh import smeshBuilder
from salome.shaper import model
if ( abs(a-b) < tol ):
return True
else:
- print( "not close vals", a, b )
+ print( "not close vals", a, b )
return False
assert( assertAlmostEqual( BoxProperties[2], (10.0)**(3.0), 1e-12 ) )
#The geometry is shrank in all directions
-assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0-offset*2)**(3), 1e-12 ) )
+assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0-offset*2)**(3), 1e-12 ) )
####END SHRINK THE BOX IN ALL DIRECTIONS
####SHRINK THE BOX EXCEPT FOR ONE FACE
ShrinkBox = viscousBuilder.GetShrinkGeometry()
ShrinkBoxProperties = geompy.BasicProperties(ShrinkBox)
selectableShrinkFaces = geompy.SubShapeAllSortedCentresIDs(ShrinkBox, geompy.ShapeType["FACE"])
-assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0-offset*2)**(2)*(10.0-offset), 1e-12 ) )
+assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0-offset*2)**(2)*(10.0-offset), 1e-12 ) )
####END SHRINK THE BOX EXCEPT FOR ONE FACE
####SHRINK THE BOX IN DIRECTION OF ONLY ONE FACE
viscousBuilder.setBuilderParameters( offset, 4, 1.2, [ selectableFaces[ 0 ] ], False ) # Shrink only the faceid
ShrinkBox = viscousBuilder.GetShrinkGeometry()
ShrinkBoxProperties = geompy.BasicProperties(ShrinkBox)
-assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0)**(2)*(10.0-offset), 1e-12 ) )
+assert( assertAlmostEqual( ShrinkBoxProperties[2], (10.0)**(2)*(10.0-offset), 1e-12 ) )
selectableShrinkFaces = geompy.SubShapeAllSortedCentresIDs(ShrinkBox, geompy.ShapeType["FACE"])
####END SHRINK THE BOX IN DIRECTION OF ONLY ONE FACE
ShrinkSphere = viscousBuilder.GetShrinkGeometry()
ShrinkSphereProperties = geompy.BasicProperties(ShrinkSphere)
assert( ShrinkSphereProperties[2] < 4.0/3.0*math.pi * Radius**3 )
-assert( assertAlmostEqual( ShrinkSphereProperties[2], 4.0/3.0*math.pi*(10.0-offset)**(3), 1e-12 ) )
+assert( assertAlmostEqual( ShrinkSphereProperties[2], 4.0/3.0*math.pi*(10.0-offset)**(3), 1e-12 ) )
####END SHRINK THE ENTIRE SPHERE
####SHRINK THE ENTIRE CYLINDER
-#Test shrinking cylinder
+#Test shrinking cylinder
Cylinder = geompy.MakeCylinderRH(10,30)
MesherCylinder = smesh_builder.Mesh(Cylinder, "Cylinder")
viscousBuilder = MesherCylinder.ViscousLayerBuilder()
# 4 left, 34 middle, 50 right
ignoreFaces = [4,34,50]
geompy.addToStudy( sBox, "SisterBox" )
-MesherSBox = smesh_builder.Mesh( sBox, "SisterBoxMesh")
+MesherSBox = smesh_builder.Mesh( sBox, "SisterBoxMesh")
ViscousBuilder = MesherSBox.ViscousLayerBuilder()
-thickness = 20
+thickness = 20
numberOfLayers = 10
stretchFactor = 1.5
ViscousBuilder.setBuilderParameters( thickness, numberOfLayers, stretchFactor, ignoreFaces )
######SHRINK CIRCLE
Disk = geompy.MakeDiskR(5, 1)
-#Test with circle
+#Test with circle
MesherCircle = smesh_builder.Mesh(Disk, "Disk")
viscousBuilder = MesherCircle.ViscousLayerBuilder()
viscousBuilder.setBuilderParameters( offset, numberOfLayers, 1.2 )