PolyMesh#
shrinkWrap#
- shrinkWrap(parts=None, voxelSize=-1, merge=True, sharpen=False)#
Creates a new part/parts from the selected parts with a single isosurface
The shrinkwrap is useful when you want to merge optimized results with non-design-space regions.
You would do this so you can fit a single PolyNURBS over the entire model. By default, the selected parts are merged into a single part. This option can be disabled by setting merge to False.
- Parameters:
parts (list[Part]) – A list of parts to be shrink wrapped.
voxelSize (float) – Size of each voxel of the shrink wrapped part. Size value should be in the range 0 to 1 Defaults to -1 to auto compute the voxel dimension of the part.
merge (bool) – Merge the shrink wrapped parts into single or multiple parts.
sharpen (bool) – If set to True, then sharpen the edges of the new shrink wrapped part.
- Returns:
Returns a new shrink wrapped part
- Return type:
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
# There are two ways to create a shrinkWrap over a Part
# First is using the shrinkWrap method
wrappedPart1 = inspire.shrinkWrap(parts=box)
wrappedPart1.location = (1.5, 0, 0)
inspire.fitView()
print("New part added in the model: ", wrappedPart1)
print("New Part location: ", wrappedPart1.location)
box = model.createSolidBlock(location=(0, 0, 1))
#Second calling the shrinkWrap method on the part
wrappedPart2 = box.shrinkWrap(voxelSize=0.1, merge=False, sharpen=True)
inspire.fitView()
print("New part added in the model: ", wrappedPart2)
model = inspire.newModel()
model.createSolidBlock()
model.createSolidBlock(location=(0, 0, 1))
wrappedParts = inspire.shrinkWrap(parts=model.parts)
inspire.fitView()
print("New part added in the model: ", wrappedParts)
makeSmooth#
- makeSmooth(parts=None, maintainVolume=True, intensity=0.5, iterations=40)#
Smoothens parts from the selected parts with passed params.
- Parameters:
parts (list[Part]) – A list of parts to smooth
maintainVolume (bool) – If True part volume is targeted to be preserved. If false smoothening is done more aggressively every iteration
intensity (float[0.2, 0.9]) – this control how aggressive the smoothening operation is every iteration.
iterations (int) – The number of iterations algorithm does smoothening. Higher number results in smoother mesh
Example
from hwx import inspire
model = inspire.newModel()
inspire.openTutorialFile('Structures/Compare_Optimization.stmod')
synthesis = model.getChild(type=inspire.TopologyOptimization)
synthesis.switchToOptimizedParts()
part = model.getChild("Part 1",True)
# There are two ways to create a makeSmooth or removeSmooth over a Part
# First is using the makeSmooth or removeSmooth method
inspire.makeSmooth(parts = part, maintainVolume=True, intensity=0.6, iterations=25)
print("Smooth is applied on "+ str(model.getChild(type=inspire.TopologyOptimization)))
#Second calling the makeSmooth or removeSmooth method on the part
part.removeSmooth()
print("Smooth is removed on "+ str(model.getChild(type=inspire.TopologyOptimization)))
part.makeSmooth(iterations=45)
print("Smooth is applied on "+ str(model.getChild(type=inspire.TopologyOptimization)))
inspire.fitView()
removeSmooth#
- removeSmooth(parts=None)#
Removes any existing smoothening from passed parts
- Parameters:
parts (list[Part]) – A list of parts to removing smooothing from.
Example
from hwx import inspire
model = inspire.newModel()
inspire.openTutorialFile('Structures/Compare_Optimization.stmod')
synthesis = model.getChild(type=inspire.TopologyOptimization)
synthesis.switchToOptimizedParts()
part = model.getChild("Part 1",True)
# There are two ways to create a makeSmooth or removeSmooth over a Part
# First is using the makeSmooth or removeSmooth method
inspire.makeSmooth(parts = part, maintainVolume=True, intensity=0.6, iterations=25)
print("Smooth is applied on "+ str(model.getChild(type=inspire.TopologyOptimization)))
#Second calling the makeSmooth or removeSmooth method on the part
part.removeSmooth()
print("Smooth is removed on "+ str(model.getChild(type=inspire.TopologyOptimization)))
part.makeSmooth(iterations=45)
print("Smooth is applied on "+ str(model.getChild(type=inspire.TopologyOptimization)))
inspire.fitView()
removeIsland#
- removeIsland(part)#
Finds small disconnected regions of a mesh part and delete them.
- Parameters:
part (Part) – Part having island.
Example
from hwx import inspire
from hwx.inspire.demo import openDemoFile
model = openDemoFile("radial_with_obstacle_constraint.stmod")
part = model.parts[-1]
part.removeIsland()
print("Island has been removed from part")
inspire.fitView()
convertToTriangleMesh#
- convertToTriangleMesh(parts)#
Convert Parts to triangle mesh.
- Parameters:
parts (list[Part]) – Parts to be converted in triangle mesh.
Example
from hwx import inspire
model = inspire.newModel()
box1 = model.createSolidBlock()
box1.convertToTriangleMesh()
print("Box1 has been converted in to triangle mesh")
inspire.fitView()