Beispiel #1
0
def get_boundingbox(shape: TopoDS_Shape,
                    tol=1e-6,
                    use_mesh=True) -> Tuple[tuple, tuple]:
    """

    :param shape: TopoDS_Shape or a subclass such as TopoDS_Face the shape to compute the bounding box from
    :param tol: tolerance of the computed boundingbox
    :param use_mesh: a flag that tells whether or not the shape has first to be meshed before the bbox computation.
                     This produces more accurate results
    :return: return the bounding box of the TopoDS_Shape `shape`
    """

    bbox = Bnd_Box()
    bbox.SetGap(tol)
    if use_mesh:
        mesh = BRepMesh_IncrementalMesh()
        mesh.SetParallelDefault(True)
        mesh.SetShape(shape)
        mesh.Perform()
        if not mesh.IsDone():
            raise AssertionError("Mesh not done.")
    brepbndlib_Add(shape, bbox, use_mesh)

    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    return (xmin, ymin, zmin), (xmax, ymax, zmax)
def get_boundingbox(shape, tol=1e-6, use_mesh=True):
    """ return the bounding box of the TopoDS_Shape `shape`
    Parameters
    ----------
    shape : TopoDS_Shape or a subclass such as TopoDS_Face
        the shape to compute the bounding box from
    tol: float
        tolerance of the computed boundingbox
    use_mesh : bool
        a flag that tells whether or not the shape has first to be meshed before the bbox
        computation. This produces more accurate results
    """
    bbox = Bnd_Box()
    bbox.SetGap(tol)
    if use_mesh:
        mesh = BRepMesh_IncrementalMesh()
        mesh.SetParallel(True)
        mesh.SetShape(shape)
        mesh.Perform()
        if not mesh.IsDone():
            raise AssertionError("Mesh not done.")
    brepbndlib_Add(shape, bbox, use_mesh)

    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    return xmin, ymin, zmin, xmax, ymax, zmax, xmax - xmin, ymax - ymin, zmax - zmin
Beispiel #3
0
 def _bounding_box(self, obj, tol=1e-5):
     bbox = Bnd_Box()
     bbox.SetGap(self.tol)
     brepbndlib_Add(obj, bbox, True)
     values = bbox.Get()
     return (values[0], values[3], values[1], values[4], values[2],
             values[5])
Beispiel #4
0
def get_boundingbox(shape, tol=1e-6, as_vec=False):
    """ return the bounding box of the TopoDS_Shape `shape`

    Parameters
    ----------

    shape : TopoDS_Shape or a subclass such as TopoDS_Face
        the shape to compute the bounding box from

    tol: float
        tolerance of the computed boundingbox

    as_vec : bool
        wether to return the lower and upper point of the bounding box as gp_Vec instances

    Returns
    -------
        if `as_vec` is True, return a tuple of gp_Vec instances
         for the lower and another for the upper X,Y,Z values representing the bounding box

        if `as_vec` is False, return a tuple of lower and then upper X,Y,Z values
         representing the bounding box
    """
    bbox = Bnd_Box()
    bbox.SetGap(tol)
    brepbndlib_Add(shape, bbox)
    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    if as_vec is False:
        return xmin, ymin, zmin, xmax, ymax, zmax
    else:
        return gp_Vec(xmin, ymin, zmin), gp_Vec(xmax, ymax, zmax)
Beispiel #5
0
 def __init__(self, shape_or_values, tol=1.e-5):
     if isinstance(shape_or_values, tuple):
         self.values = shape_or_values
     else:
         bbox = Bnd_Box()
         bbox.SetGap(tol)
         brepbndlib_Add(shape_or_values, bbox, True)  # use the shape triangulation
         self.values = bbox.Get()
Beispiel #6
0
def get_boundingbox(shape, tol=TOLERANCE):
    '''
    :param shape: TopoDS_Shape such as TopoDS_Face
    :param tol: tolerance
    :return: xmin, ymin, zmin, xmax, ymax, zmax
    '''
    bbox = Bnd_Box()
    bbox.SetGap(tol)
    brepbndlib_Add(shape, bbox)
    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    return xmin, ymin, zmin, xmax, ymax, zmax
Beispiel #7
0
def point_in_boundingbox(solid, pnt, tolerance=1e-5):
    """returns True if *pnt* lies in *boundingbox*, False if not
    this is a much speedier test than checking the TopoDS_Solid
    Args:
        solid   TopoDS_Solid
        pnt:    gp_Pnt
    Returns: bool
    """
    bbox = Bnd_Box()
    bbox.SetGap(tolerance)
    brepbndlib_Add(solid, bbox)
    return not bbox.IsOut(pnt)
Beispiel #8
0
def measure(shape):
    bbox = Bnd_Box()
    #bbox.SetGap(tol)
    #bbox.SetShape(shape)

    brepbndlib_Add(shape, bbox)

    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    my_box = BRepPrimAPI_MakeBox(gp_Pnt(xmin, ymin, zmin), gp_Pnt(xmax, ymax, zmax)).Shape()

    #display.SetBackgroundImage('nevers-pont-de-loire.jpg', stretch=True)
    display.DisplayShape(my_box, color='GREEN', transparency=0.9)
    print(zmin, zmax, 'zzzzzzzzzzzzz')
Beispiel #9
0
def compute_bbox(shp, *kwargs):
    print("Compute bbox for %s " % shp)
    for shape in shp:
        bbox = Bnd_Box()
        brepbndlib_Add(shape, bbox)
        xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
        dx = xmax - xmin
        dy = ymax - ymin
        dz = zmax - zmin
        print("Selected shape bounding box : dx=%f, dy=%f, dz=%f." % (dx, dy, dz))
        print("               bounding box center: x=%f, y=%f, z=%f" % (xmin + dx/2.,
                                                                        ymin + dy/2.,
                                                                        zmin + dz/2.))
def get_boundingbox(shape: TopoDS_Shape, tol=1e-6, use_mesh=True):
    bbox = Bnd_Box()
    bbox.SetGap(tol)
    if use_mesh:
        mesh = BRepMesh_IncrementalMesh()
        mesh.SetParallelDefault(True)
        mesh.SetShape(shape)
        mesh.Perform()
        if not mesh.IsDone():
            raise AssertionError("Mesh not done.")
    brepbndlib_Add(shape, bbox, use_mesh)

    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    return xmin, ymin, zmin, xmax, ymax, zmax, xmax - xmin, ymax - ymin, zmax - zmin
Beispiel #11
0
 def detectCenter(self, nativeObj):
     if not nativeObj:  #pass non exist obj name
         return gp_Pnt(0, 0, 0)
     if isinstance(nativeObj, AIS_Point):
         return nativeObj.Component().Pnt()
     if self.isInit:
         box = Bnd_Box()
         nativeObj.BoundingBox(box)
         xmin, ymin, zmin, xmax, ymax, zmax = box.Get()
         x = (xmax + xmin) / 2
         y = (ymax + ymin) / 2
         z = (zmax + zmin) / 2
         return gp_Pnt(x, y, z)
     return gp_Pnt(0, 0, 0)
def z_max_finder(stl_shp,tol=1e-6,use_mesh=True):
    """first change the model to mesh form in order to get an
    accurate MAX and Min bounfing box from topology"""
    bbox = Bnd_Box()
    bbox.SetGap(tol)
    if use_mesh:
        mesh = BRepMesh_IncrementalMesh()
        mesh.SetParallelDefault(True)
        mesh.SetShape(stl_shp)
        mesh.Perform()
        if not mesh.IsDone():
            raise AssertionError("Mesh not done.")
    brepbndlib_Add(stl_shp, bbox, use_mesh)
    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    return zmax
Beispiel #13
0
 def get_bounding_box(self, tol=TOLERANCE):
     bbox = Bnd_Box()
     brepbndlib_Add(self.shape, bbox)
     xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
     return [
         "%.2f" % xmin,
         "%.2f" % ymin,
         "%.2f" % zmin,
         "%.2f" % xmax,
         "%.2f" % ymax,
         "%.2f" % zmax,
         "%.2f" % (xmax - xmin),
         "%.2f" % (ymax - ymin),
         "%.2f" % (zmax - zmin)
     ]
Beispiel #14
0
def get_boundingbox(shape, tol=1e-6, use_mesh=True):
    bbox = Bnd_Box()
    bbox.SetGap(tol)
    if use_mesh:
        mesh = BRepMesh_IncrementalMesh()
        mesh.SetParallel(True)
        mesh.SetShape(shape)
        mesh.Perform()
        assert mesh.IsDone()
    brepbndlib_Add(shape, bbox, use_mesh)

    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    return [
        xmin, ymin, zmin, xmax, ymax, zmax, xmax - xmin, ymax - ymin,
        zmax - zmin
    ]
 def test_DumpJsonToString(self):
     """ Since opencascade 7x, some objects can be serialized to json
     """
     # create a sphere with a radius of 10.
     sph= BRepPrimAPI_MakeSphere(10.).Shape()
     # compute the Bnd box for this sphere
     bnd_box = Bnd_Box()
     brepbndlib_Add(sph, bnd_box)
     # check the result
     corner_min = bnd_box.CornerMin()
     self.assertEqual([round(corner_min.X(), 3), round(corner_min.Y(), 3), round(corner_min.Z(), 3)],
                      [-10., -10., -10.])
     # check dump json is working
     json_string = bnd_box.DumpJsonToString()
     expected_output = '"Bnd_Box": {"CornerMin": [-10, -10, -10], "CornerMax": [10, 10, 10], "Gap": 1e-07, "Flags": 0}'
     self.assertEqual(json_string, expected_output)
 def test_DumpJsonToString(self) -> None:
     """ Since opencascade 7x, some objects can be serialized to json
     """
     # create a sphere with a radius of 10.
     sph = BRepPrimAPI_MakeSphere(10.).Shape()
     # compute the Bnd box for this sphere
     bnd_box = Bnd_Box()
     brepbndlib_Add(sph, bnd_box)
     # check the result
     corner_min = bnd_box.CornerMin()
     self.assertEqual([round(corner_min.X(), 3), round(corner_min.Y(), 3), round(corner_min.Z(), 3)],
                      [-10., -10., -10.])
     # check dump json export is working
     json_string = bnd_box.DumpJsonToString()
     # try to load the output string
     json_imported_dict = json.loads("{" + json_string + "}")
     self.assertTrue(len(json_imported_dict) > 0)  # at least one entry
Beispiel #17
0
    def _fromTopoDS(cls, shape, tol=None, optimal=False):
        '''
        Constructs a bounding box from a TopoDS_Shape
        '''
        tol = TOL if tol is None else tol  # tol = TOL (by default)
        bbox = Bnd_Box()
        bbox.SetGap(tol)
        if optimal:
            raise NotImplementedError
            # brepbndlib_AddOptimal(shape, bbox) #this is 'exact' but expensive - not yet wrapped by PythonOCC
        else:
            mesh = BRepMesh_IncrementalMesh(shape, TOL, True)
            mesh.Perform()
            # this is adds +margin but is faster
            brepbndlib_Add(shape, bbox, True)

        return cls(bbox)
Beispiel #18
0
    def glue_solids(self, S2):

        bbox = Bnd_Box()
        brepbndlib_Add(S2, bbox)
        xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
        p0 = gp_Pnt(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2,
                    zmin + 0.1)

        vnorm = gp_Dir(0, 0, 1)
        pln = gp_Pln(p0, vnorm)
        face = BRepBuilderAPI_MakeFace(pln, -(xmax - xmin) / 2 - 1,
                                       (xmax - xmin) / 2 + 1,
                                       -(ymax - ymin) / 2 - 1,
                                       (ymax - ymin) / 2 + 1).Face()

        facesS_2 = BRepAlgoAPI_Section(face, S2).Shape()

        return self.max_counter(facesS_2)
def get_aligned_boundingbox(shape, tol=1e-6, optimal_BB=True):
    """return the bounding box of the TopoDS_Shape `shape`

    Parameters
    ----------

    shape : TopoDS_Shape or a subclass such as TopoDS_Face
        the shape to compute the bounding box from

    tol: float
        tolerance of the computed boundingbox

    use_triangulation : bool, True by default
        This makes the computation more accurate

    Returns
    -------
        if `as_pnt` is True, return a tuple of gp_Pnt instances
         for the lower and another for the upper X,Y,Z values representing the bounding box

        if `as_pnt` is False, return a tuple of lower and then upper X,Y,Z values
         representing the bounding box
    """
    bbox = Bnd_Box()
    bbox.SetGap(tol)

    # note: useTriangulation is True by default, we set it explicitly, but t's not necessary
    if optimal_BB:
        use_triangulation = True
        use_shapetolerance = True
        brepbndlib_AddOptimal(shape, bbox, use_triangulation,
                              use_shapetolerance)
    else:
        brepbndlib_Add(shape, bbox)
    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    corner1 = gp_Pnt(xmin, ymin, zmin)
    corner2 = gp_Pnt(xmax, ymax, zmax)
    center = midpoint(corner1, corner2)
    dx = xmax - xmin
    dy = ymax - ymin
    dz = zmax - zmin
    box_shp = BRepPrimAPI_MakeBox(corner1, corner2).Shape()
    return center, [dx, dy, dz], box_shp
Beispiel #20
0
    def __init__(self, frame, modules):

        self.name_frame = frame
        self.modules = {}
        self.names_models = []
        self.history_args = {}
        self.valume_inter_obj = defaultdict(dict)

        # for testing, remove later
        self.progress = []

        self.test_var = 40
        self.test_2_var = 0.0000
        self.current_body = ''
        self.iteration = 1

        self.d = 3.1
        self.px = 220 - self.d
        self.py = 220 - self.d
        self.pz = 246

        self.peep_factor = 0
        self.peep_list = {}

        self.dimensoins = {}
        self.profiles = {}
        self.valume_inter = {}
        self.inter_mass = 0
        # self.display, self.start_display, self.add_menu, self.add_function_to_menu = init_display()
        for model in modules:
            self.modules[model[2]] = read_step_file(
                os.path.join(model[0], model[1], model[2]))
            self.names_models.append(model[2])

        self.reserv_models = self.modules.copy()

        for model in self.modules:
            bbox = Bnd_Box()
            brepbndlib_Add(self.modules[model], bbox)
            xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
            self.dimensoins[model] = [xmin, xmax, ymin, ymax, zmin, zmax]
            # print(model)
            self.profiles[model] = [self.glue_solids(self.modules[model])]
Beispiel #21
0
 def __init__(self, name, dict_of_shells, solid):
     from OCC.Core.Bnd import Bnd_Box
     from OCC.Core.BRepBndLib import brepbndlib_Add
     from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox
     bbox = Bnd_Box()
     bbox.SetGap(1.e-6)
     self.name = name
     self.solid = solid
     self.dico = {}
     self.dicosplit = {}
     self.kept = []
     self.to_check = []
     self.splitsolid = []
     brepbndlib_Add(solid, bbox, False)
     xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
     self.box = BRepPrimAPI_MakeBox(gp_Pnt(xmin, ymin, zmin),
                                    gp_Pnt(xmax, ymax, zmax))
     for k in dict_of_shells:
         new_k = name + k
         self.dico[k] = dict_of_shells[k]
         self.dicosplit[k] = None
Beispiel #22
0
    def recognize_clicked(self, shp, *kwargs):
        """ This is the function called every time
        a face is clicked in the 3d view
        """
        '''t = TopologyExplorer(self.frame)
        for shape in t.faces():  # this should be a TopoDS_Face TODO check it is
            print("Face selected: ", shape)
            self.recognize_face(topods_Face(shape))'''

        for shape in shp:  # this should be a TopoDS_Face TODO check it is
            print("Face selected: ", shape)
            bbox = Bnd_Box()
            brepbndlib_Add(shape, bbox)
            xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
            bounds = [
                sorted([xmax - xmin, ymax - ymin, zmax - zmin])[1],
                sorted([xmax - xmin, ymax - ymin, zmax - zmin])[2]
            ]
            print('--> Bounds', xmax - xmin, ymax - ymin, zmax - zmin)
            centre, normal, X_axis = self.recognize_face(topods_Face(shape))
            self.faces.append([centre, normal, X_axis, bounds])
Beispiel #23
0
    def aabb(self, precision=0.0, optimal=False):
        """Compute the axis aligned bounding box of the surface.

        Parameters
        ----------
        precision : float, optional
        optimal : bool, optional

        Returns
        -------
        :class:`~compas.geometry.Box`

        """
        box = Bnd_Box()
        if optimal:
            add = BndLib_AddSurface_AddOptimal
        else:
            add = BndLib_AddSurface_Add
        add(GeomAdaptor_Surface(self.occ_surface), precision, box)
        return Box.from_diagonal(
            (Point.from_occ(box.CornerMin()), Point.from_occ(box.CornerMax())))
Beispiel #24
0
    def recognize_clicked(self, shp, *kwargs):
        """ This is the function called every time
        a face is clicked in the 3d view
        """

        '''t = TopologyExplorer(self.frame)
        for shape in t.faces():  # this should be a TopoDS_Face TODO check it is
            print("Face selected: ", shape)
            self.recognize_face(topods_Face(shape))'''

        for shape in shp:  # this should be a TopoDS_Face TODO check it is
            print("Face selected: ", shape)
            bbox = Bnd_Box()
            brepbndlib_Add(shape, bbox)
            xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
            bounds = [sorted([xmax - xmin, ymax - ymin, zmax - zmin])[1],
                      sorted([xmax - xmin, ymax - ymin, zmax - zmin])[2]]
            print('--> Bounds', xmax - xmin, ymax - ymin, zmax - zmin)
            centre, normal, X_axis = self.recognize_face(topods_Face(shape))
            if shape in self.faces_shape:
                # self.display.DisplayShape(shape, color='GREEN', transparency=0.9)
                # self.display.Context.Remove(shape)#######
                # self.display.Context.
                ind = self.faces_shape.index(shape)

                self.faces_shape.pop(ind)
                self.faces.pop(ind)
                self.faces_name.pop(ind)

            else:
                # self.display.DisplayShape(shape, color='RED', transparency=0.8)
                # self.display.FitAll()
                self.faces.append([centre, normal, X_axis, bounds])
                self.faces_shape.append(shape)
                self.faces_name.append(bounds[0] * bounds[1])

            # self.display.SetCloseAllContexts()
            self.reload_faces()
            self.display.SetSelectionModeFace()  # switch to Face selection mode
Beispiel #25
0
def display_extra_info(shp, *kwargs):
    r"""Display extra info (properties) about a shape

    The message box is triggered by a shape selection in the viewer

    Parameters
    ----------
    shp : list
        List of selected shapes
    kwargs : dict

    """

    for shape in shp:
        message = ["%s" % shp, ""]

        bbox = Bnd_Box()
        brepbndlib_Add(shape, bbox)
        xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
        dx = xmax - xmin
        dy = ymax - ymin
        dz = zmax - zmin
        message.append("Bounding box :")
        message.append("  dx=%f, dy=%f, dz=%f." % (dx, dy, dz))
        message.append("Bounding box center :")
        message.append("  x=%f, y=%f, z=%f" %
                       (xmin + dx / 2., ymin + dy / 2., zmin + dz / 2.))

        message.append("")

        for prop_name, prop_value in extra_info[shape].items():
            message.append(" %s : %s %s" %
                           (prop_name, str(
                               prop_value["value"]), "[" + prop_value["unit"] +
                            "]" if prop_value["unit"] is not None else ""))

        _ = wx.MessageBox("\n".join(message),
                          caption="Part Info",
                          style=wx.OK | wx.ICON_INFORMATION)
Beispiel #26
0
    def add(self, obj, tol=1e-8):
        """Returns a modified (expanded) bounding box

        obj can be one of several things:
            1. a 3-tuple corresponding to x,y, and z amounts to add
            2. a vector, containing the x,y,z values to add
            3. another bounding box, where a new box will be created that
               encloses both.

        This bounding box is not changed.
        """

        tmp = Bnd_Box()
        tmp.SetGap(tol)
        tmp.Add(self.wrapped)

        if isinstance(obj, tuple):
            tmp.Update(*obj)
        elif isinstance(obj, Vector):
            tmp.Update(*obj.toTuple())
        elif isinstance(obj, BoundBox):
            tmp.Add(obj.wrapped)

        return BoundBox(tmp)
Beispiel #27
0
def get_aligned_boundingbox_ratio(shape, tol=1e-6, optimal_BB=True, ratio=1):
    """ return the bounding box of the TopoDS_Shape `shape`

    Parameters
    ----------

    shape : TopoDS_Shape or a subclass such as TopoDS_Face
        the shape to compute the bounding box from

    tol: float
        tolerance of the computed boundingbox

    use_triangulation : bool, True by default
        This makes the computation more accurate

    ratio : float, 1.0 by default.

    Returns
    -------
        if `as_pnt` is True, return a tuple of gp_Pnt instances
         for the lower and another for the upper X,Y,Z values representing the bounding box

        if `as_pnt` is False, return a tuple of lower and then upper X,Y,Z values
         representing the bounding box
    """
    bbox = Bnd_Box()
    bbox.SetGap(tol)

    # note: useTriangulation is True by default, we set it explicitely, but t's not necessary
    if optimal_BB:
        use_triangulation = True
        use_shapetolerance = True
        brepbndlib_AddOptimal(shape, bbox, use_triangulation,
                              use_shapetolerance)
    else:
        brepbndlib_Add(shape, bbox)

    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    dx, mx = (xmax - xmin) * ratio, (xmax + xmin) / 2
    dy, my = (ymax - ymin) * ratio, (ymax + ymin) / 2
    dz, mz = (zmax - zmin) * ratio, (zmax + zmin) / 2
    x0, x1 = mx - dx / 2, mx + dx / 2
    y0, y1 = my - dy / 2, my + dy / 2
    z0, z1 = mz - dz / 2, mz + dz / 2
    corner1 = gp_Pnt(x0, y0, z0)
    corner2 = gp_Pnt(x1, y1, z1)
    center = midpoint(corner1, corner2)

    rim0 = make_polygon([
        gp_Pnt(x0, y0, z0),
        gp_Pnt(x1, y0, z0),
        gp_Pnt(x1, y1, z0),
        gp_Pnt(x0, y1, z0)
    ],
                        closed=True)

    rim1 = make_polygon([
        gp_Pnt(x0, y0, z1),
        gp_Pnt(x1, y0, z1),
        gp_Pnt(x1, y1, z1),
        gp_Pnt(x0, y1, z1)
    ],
                        closed=True)
    api = BRepOffsetAPI_ThruSections(True, False, 1.0E-9)
    api.AddWire(rim0)
    api.AddWire(rim1)
    box_shp = api.Shape()
    #box_shp = BRepPrimAPI_MakeBox(corner1, corner2).Shape()
    return center, [dx, dy, dz], box_shp
Beispiel #28
0
def GetHeight(shape):
    bbox = Bnd_Box()
    brepbndlib_Add(shape, bbox, False)
    xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
    return zmax,zmin
Beispiel #29
0
 def boundbox(self):
     box = Bnd_Box()
     brepbndlib.Add(self.Shape(), box)
     xl, yl, zl, xh, yh, zh = box.Get()
     return BoundaryBox(xl, xh, yl, yh, zl, zh)
Beispiel #30
0
    def Locate_centre_face(self, number, name_body, angle, x_drive, y_drive):
        cp = BRepBuilderAPI_Copy(self.reserv_models[name_body])
        cp.Perform(self.reserv_models[name_body])
        shape = cp.Shape()

        # move to zero
        bbox = Bnd_Box()
        brepbndlib_Add(shape, bbox)
        xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()

        trsf = gp_Trsf()
        trsf.SetTranslation(
            gp_Vec(-xmin - (xmax - xmin) / 2, -ymin - (ymax - ymin) / 2,
                   -zmin))
        shape.Move(TopLoc_Location(trsf))

        # Process vector of rotation to face
        x = -self.walls[number][1][1]
        y = self.walls[number][1][0]
        z = 0
        P0 = gp_Pnt(0, 0, 0)
        P1 = gp_Pnt(0, 0, 1)
        P2 = gp_Pnt(self.walls[number][1][0], self.walls[number][1][1],
                    self.walls[number][1][2])

        # rotation to Ax z
        v_x = gp_Vec(P0, gp_Pnt(0, 1, 0))
        v_r = gp_Vec(P0, gp_Pnt(x, y, z))
        if v_x.X != v_r.X and v_x.Y != v_r.Y and v_x.Z != v_r.Z:
            trsf = gp_Trsf()
            #print(v_r.Angle(v_x))
            trsf.SetRotation(gp_Ax1(P0, gp_Dir(0, 0, 1)), v_r.Angle(v_x))
            shape.Move(TopLoc_Location(trsf))

        # rotation in parallel to face
        v0 = gp_Vec(P0, P1)
        v1 = gp_Vec(P0, P2)
        # print(v1.Angle(v0))
        if v1.X != v0.X and v1.Y != v0.Y and v1.Z != v0.Z:
            trsf = gp_Trsf()
            trsf.SetRotation(gp_Ax1(P0, gp_Dir(x, y, z)), v1.Angle(v0))
            # move to face
            shape.Move(TopLoc_Location(trsf))
        trsf = gp_Trsf()
        trsf.SetTranslation(
            gp_Vec(self.walls[number][0][0], self.walls[number][0][1],
                   self.walls[number][0][2]))
        shape.Move(TopLoc_Location(trsf))

        # Rotation by given angle
        trsf = gp_Trsf()
        trsf.SetRotation(
            gp_Ax1(
                P0,
                gp_Dir(self.walls[number][1][0], self.walls[number][1][1],
                       self.walls[number][1][2])), angle)
        shape.Move(TopLoc_Location(trsf))

        # initional x, y
        offset_y, offset_x = self.rot_point(xmax - xmin, ymax - ymin, angle)

        limit_x = self.walls[number][3][0] / 2 - offset_x
        limit_y = self.walls[number][3][1] / 2 - offset_y

        move_x = limit_x * x_drive
        move_y = limit_y * y_drive

        # Move to x and y
        x_axy = self.walls[number][1][1] * self.walls[number][2][
            2] - self.walls[number][1][2] * self.walls[number][2][1]
        y_axy = -(self.walls[number][1][0] * self.walls[number][2][2] -
                  self.walls[number][1][2] * self.walls[number][2][0])
        z_axy = self.walls[number][1][0] * self.walls[number][2][
            1] - self.walls[number][1][1] * self.walls[number][2][0]

        x_axy *= move_y
        y_axy *= move_y
        z_axy *= move_y

        trsf = gp_Trsf()
        trsf.SetTranslation(gp_Vec(x_axy, y_axy, z_axy))
        shape.Move(TopLoc_Location(trsf))

        trsf = gp_Trsf()
        trsf.SetTranslation(
            gp_Vec(self.walls[number][2][0] * move_x,
                   self.walls[number][2][1] * move_x,
                   self.walls[number][2][2] * move_x))
        shape.Move(TopLoc_Location(trsf))
        #print(name_body, shape)

        self.modules[name_body] = shape