def _update(self): """ """ # TODO: perhaps should take an argument until which topological level # topological entities bound to the vertex should be updated too... reshape = ShapeBuild_ReShape() reshape.Replace(self._vertex, make_vertex(self._pnt))
class RebuildShapeWithShapes(object): """ Rebuild a shape by requesting substitutions on a shape. :param afem.topology.entities.Shape old_shape: The old shape. """ def __init__(self, old_shape): self._tool = ShapeBuild_ReShape() self._old_shape = old_shape def remove(self, old_shape): """ Request to remove the old shape. :param afem.topology.entities.Shape old_shape: The old shape. This is usually a sub-shape of the original old shape. :return: None. """ self._tool.Remove(old_shape.object) def replace(self, old_shape, new_shapes): """ Request to replace the old shape with a list of new shapes. :param afem.topology.entities.Shape old_shape: The old shape. This is usually a sub-shape of the original old shape. :param list(afem.topology.entities.Shape) new_shapes: The new shapes. :return: None. """ compound = Compound.by_shapes(new_shapes) self._tool.Replace(old_shape.object, compound.object) def apply(self): """ Apply the substitutions to the original old shape and return a new shape. :return: The new shape. :rtype: afem.topology.entities.Shape """ return Shape.wrap(self._tool.Apply(self._old_shape.object))
def __init__(self, shape, precision=None, min_tol=None, max_tol=None, context=None): self._tool = ShapeFix_Shape() if precision is not None: self._tool.SetPrecision(precision) if min_tol is not None: self._tool.SetMinTolerance(min_tol) if max_tol is not None: self._tool.SetMaxTolerance(max_tol) if context is not None: reshape = ShapeBuild_ReShape() reshape.Apply(context.object) self._tool.SetContext(reshape) self._tool.Init(shape.object) self._tool.Perform()
def __init__(self, old_shapes, tool): reshape = ShapeBuild_ReShape() self._new_shapes = TopTools_DataMapOfShapeShape() index_map = TopTools_IndexedMapOfShape() for old_shape in old_shapes: # Old shapes shapes = old_shape.faces if not shapes: shapes = old_shape.edges if not shapes: shapes = old_shape.vertices if not shapes: continue # Delete and replace for shape in shapes: # Deleted if tool.is_deleted(shape): reshape.Remove(shape.object) continue # Modified considering shapes already used mod_shapes = tool.modified(shape) replace_shapes = [] for mod_shape in mod_shapes: if index_map.Contains(mod_shape.object): continue replace_shapes.append(mod_shape) index_map.Add(mod_shape.object) if replace_shapes: new_shape = Compound.by_shapes(replace_shapes) reshape.Replace(shape.object, new_shape.object) new_shape = Shape.wrap(reshape.Apply(old_shape.object)) self._new_shapes.Bind(old_shape.object, new_shape.object)
def __init__(self, old_shape): self._tool = ShapeBuild_ReShape() self._old_shape = old_shape