• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python gp.gp_Trsf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中OCC.gp.gp_Trsf函数的典型用法代码示例。如果您正苦于以下问题:Python gp_Trsf函数的具体用法?Python gp_Trsf怎么用?Python gp_Trsf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了gp_Trsf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _cut_finger_notch

def _cut_finger_notch(front, dx, dz):
    finger_width = 2.0
    finger_height = 1.0
    front = _cut(front, _box(_pnt(dx / 2. - finger_width / 2., 0, dz - finger_height),
                             finger_width, THICKNESS_0, finger_height))
    cyl = BRepPrimAPI_MakeCylinder(finger_width / 2.0, THICKNESS_0).Shape()
    tr = gp.gp_Trsf()
    tr.SetRotation(gp.gp_Ax1(gp.gp_Pnt(0, 0, 0), gp.gp_Dir(1, 0, 0)), math.pi / 2.0)
    tr2 = gp.gp_Trsf()
    tr2.SetTranslation(gp.gp_Vec(dx / 2., THICKNESS_0, dz - finger_height))
    tr2.Multiply(tr)
    cyl = BRepBuilderAPI_Transform(cyl, tr2, True).Shape()
    front = _cut(front, cyl)
    return front
开发者ID:aduston,项目名称:simpledrawers,代码行数:14,代码来源:drawer.py


示例2: scale

def scale(occtopology, scale_factor, ref_pypt):
    """
    This function uniformly scales an OCCtopology based on the reference point and the scale factor.
 
    Parameters
    ----------        
    occtopology : OCCtopology
        The OCCtopology to be scaled.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    scale_factor : float
        The scale factor.
       
    ref_pypt : tuple of floats
        The OCCtopology will scale in reference to this point.
        A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    Returns
    -------
    scaled topology : OCCtopology (OCCshape)
        The scaled OCCtopology.
    """
    xform = gp_Trsf()
    gp_pnt = construct.make_gppnt(ref_pypt)
    xform.SetScale(gp_pnt, scale_factor)
    brep = BRepBuilderAPI_Transform(xform)
    brep.Perform(occtopology, True)
    trsfshape = brep.Shape()
    return trsfshape
开发者ID:chenkianwee,项目名称:envuo,代码行数:29,代码来源:modify.py


示例3: rotate

def rotate(occtopology, rot_pypt, pyaxis, degree):
    """
    This function rotates an OCCtopology based on the rotation point, an axis and the rotation degree.
 
    Parameters
    ----------        
    occtopology : OCCtopology
        The OCCtopology to be rotated.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    rot_pypt : tuple of floats
        The OCCtopology will rotate in reference to this point.
        A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    pyaxis : tuple of floats
        The OCCtopology will rotate along this axis.
        A pyaxis is a tuple that documents the xyz of a direction e.g. (x,y,z)
        
    degree : float
       The degree of rotation.
        
    Returns
    -------
    rotated topology : OCCtopology (OCCshape)
        The rotated OCCtopology.
    """
    
    from math import radians
    gp_ax3 = gp_Ax1(gp_Pnt(rot_pypt[0], rot_pypt[1], rot_pypt[2]), gp_Dir(pyaxis[0], pyaxis[1], pyaxis[2]))
    aTrsf = gp_Trsf()
    aTrsf.SetRotation(gp_ax3, radians(degree))
    rot_brep = BRepBuilderAPI_Transform(aTrsf)
    rot_brep.Perform(occtopology, True)
    rot_shape = rot_brep.Shape()
    return rot_shape
开发者ID:chenkianwee,项目名称:envuo,代码行数:35,代码来源:modify.py


示例4: move

def move(orig_pypt, location_pypt, occtopology):
    """
    This function moves an OCCtopology from the orig_pypt to the location_pypt.
 
    Parameters
    ----------        
    orig_pypt : tuple of floats
        The OCCtopology will move in reference to this point.
        A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    location_pypt : tuple of floats
        The destination of where the OCCtopology will be moved in relation to the orig_pypt.
        A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    occtopology : OCCtopology
        The OCCtopology to be moved.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 

    Returns
    -------
    moved topology : OCCtopology (OCCshape)
        The moved OCCtopology.
    """
    gp_ax31 = gp_Ax3(gp_Pnt(orig_pypt[0], orig_pypt[1], orig_pypt[2]), gp_DZ())
    gp_ax32 = gp_Ax3(gp_Pnt(location_pypt[0], location_pypt[1], location_pypt[2]), gp_DZ())
    aTrsf = gp_Trsf()
    aTrsf.SetTransformation(gp_ax32,gp_ax31)
    trsf_brep = BRepBuilderAPI_Transform(aTrsf)
    trsf_brep.Perform(occtopology, True)
    trsf_shp = trsf_brep.Shape()
    return trsf_shp
开发者ID:chenkianwee,项目名称:envuo,代码行数:31,代码来源:modify.py


示例5: copyToZ

    def copyToZ(self, z, layerNo):
        "makes a copy of this slice, transformed to the specified z height"

        theCopy = Slice()
        theCopy.zLevel = z
        theCopy.fillAngle = self.fillAngle
        theCopy.layerNo = layerNo
        theCopy.thickness = self.thickness

        # make transformation
        p1 = gp.gp_Pnt(0, 0, 0)
        p2 = gp.gp_Pnt(0, 0, z)
        xform = gp.gp_Trsf()
        xform.SetTranslation(p1, p2)
        bt = BRepBuilderAPI.BRepBuilderAPI_Transform(xform)

        # copy all of the faces
        for f in self.faces:

            bt.Perform(f.face, True)
            newFace = Face(OCCUtil.cast(bt.Shape()))

            # copy shells
            for shell in f.shellWires:
                # print shell
                bt.Perform(shell, True)
                newFace.shellWires.append(OCCUtil.cast(bt.Shape()))

            # copy fillWires
            for fill in f.fillWires:
                bt.Perform(fill, True)
                newFace.shellWires.append(OCCUtil.cast(bt.Shape()))
            theCopy.addFace(newFace)

        return theCopy
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:35,代码来源:Slicer.py


示例6: occ

def occ(display):

 	'''
	display, start_display, add_menu, add_function_to_menu = init_display()
	my_box = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()
 
	display.DisplayShape(my_box, update=True)
	#start_display()
	'''
	

	display.EraseAll()
	ais_boxshp = build_shape(display)
	ax1 = gp_Ax1(gp_Pnt(25., 25., 25.), gp_Dir(0., 0., 1.))
	aCubeTrsf = gp_Trsf() 
	angle = 0.0
	tA = time.time()
	n_rotations = 200
	for i in range(n_rotations):
		aCubeTrsf.SetRotation(ax1, angle)
		aCubeToploc = TopLoc_Location(aCubeTrsf)
		display.Context.SetLocation(ais_boxshp, aCubeToploc)
		display.Context.UpdateCurrentViewer()
		angle += 2*pi / n_rotations
	print("%i rotations took %f" % (n_rotations, time.time() - tA))
	
	
	
	
	
开发者ID:small-yellow-duck,项目名称:timelordart,代码行数:25,代码来源:facedetect_render3d_v2.py


示例7: get_transform

 def get_transform(self):
     d = self.declaration
     t = gp_Trsf()
     #: TODO: Order matters... how to configure it???
     if d.mirror:
         try:
             p,v = d.mirror
         except ValueError:
             raise ValueError("You must specify a tuple containing a (point,direction)")
         t.SetMirror(gp_Ax1(gp_Pnt(*p),
                            gp_Dir(*v)))
     if d.scale:
         try:
             p,s = d.scale
         except ValueError:
             raise ValueError("You must specify a tuple containing a (point,scale)")
         t.SetScale(gp_Pnt(*p),s)
     
     if d.translate:
         t.SetTranslation(gp_Vec(*d.translate))
     
     if d.rotate:
         try:
             p,v,a = d.rotate
         except ValueError:
             raise ValueError("You must specify a tuple containing a (point,direction,angle)")
         t.SetRotation(gp_Ax1(gp_Pnt(*p),
                            gp_Dir(*v)),a)
         
     return t
开发者ID:frmdstryr,项目名称:enamlx,代码行数:30,代码来源:occ_algo.py


示例8: copyToZ

    def copyToZ(self, z):
        "makes a copy of this slice, transformed to the specified z height"
        theCopy = Slice()
        theCopy.zLevel = z
        theCopy.zHeight = self.zHeight
        theCopy.sliceHeight = self.sliceHeight
        theCopy.fillWidth = self.fillWidth
        theCopy.hatchDir = self.hatchDir
        theCopy.checkSum = self.checkSum

        # make transformation
        p1 = gp.gp_Pnt(0, 0, 0)
        p2 = gp.gp_Pnt(0, 0, z)
        xform = gp.gp_Trsf()
        xform.SetTranslation(p1, p2)
        bt = BRepBuilderAPI.BRepBuilderAPI_Transform(xform)

        # copy all of the faces
        for f in hSeqIterator(self.faces):
            bt.Perform(f, True)
            theCopy.addFace(Wrappers.cast(bt.Shape()))

            # copy all of the fillWires
        for w in hSeqIterator(self.fillWires):
            bt.Perform(w, True)
            # TestDisplay.display.showShape(bt.Shape() );
            theCopy.fillWires.Append(Wrappers.cast(bt.Shape()))

            # copy all of the fillEdges
        for e in hSeqIterator(self.fillEdges):
            bt.Perform(e, True)
            # TestDisplay.display.showShape(bt.Shape() );
            theCopy.fillEdges.Append(Wrappers.cast(bt.Shape()))

        return theCopy
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:35,代码来源:OccSliceLib.py


示例9: _add_stuff_changed

 def _add_stuff_changed(self, old, new):
     for i in xrange(20):
         brep = BRepPrimAPI_MakeCylinder(random.random()*50, random.random()*50).Shape()
         trsf = gp_Trsf()
         trsf.SetTranslation(gp_Vec(random.random()*100, random.random()*100, random.random()*100))
         brep.Move(TopLoc_Location(trsf))
         self.shapes.append(brep)
开发者ID:imclab,项目名称:pythonocc,代码行数:7,代码来源:trait_editor.py


示例10: rotate

def rotate(brep, axe, degree, copy=False):
    """Rotates the brep
    
    Originally from pythonocc-utils : might add dependency on this?

    Parameters
    ----------
    brep : shape to rotate
    
    axe : axis of rotation
    
    degree : Number of degrees to rotate through
    
    copy : bool (default=False)
    
    Returns
    -------
    BRepBuilderAPI_Transform.Shape : Shape handle
        The handle to the rotated shape
    """
    trns = gp_Trsf()
    trns.SetRotation(axe, np.radians(degree))
    brep_trns = BRepBuilderAPI_Transform(brep, trns, copy)
    brep_trns.Build()
    return brep_trns.Shape()
开发者ID:p-chambers,项目名称:occ_airconics,代码行数:25,代码来源:AirCONICStools.py


示例11: add_labels

def add_labels(product,lr,st):

    if product.links:
        for link in product.links:

            if link.product.doc_id != product.doc_id:

                if not link.product.label_reference:

                    lr_2 = TDF_LabelSequence()
                    si = StepImporter(link.product.doc_path)
                    shape_tool = si.shape_tool
                    shape_tool.GetFreeShapes(lr_2)
                    add_labels(link.product, lr_2.Value(1), shape_tool)
                    link.product.label_reference = lr_2.Value(1)
                    # FIXME: free memory
                    del si
                    gc.collect()
                for d in range(link.quantity):
                    transformation = gp_Trsf()
                    loc = link.locations[d]
                    transformation.SetValues(loc.x1, loc.x2, loc.x3, loc.x4,
                        loc.y1, loc.y2, loc.y3, loc.y4,
                        loc.z1, loc.z2, loc.z3, loc.z4,
                        1, 1)

                    new_label = st.AddComponent(lr, link.product.label_reference,
                            TopLoc_Location(transformation))
                    set_label_name(new_label, link.names[d])
开发者ID:amarh,项目名称:openPLM,代码行数:29,代码来源:generateComposition.py


示例12: translate

 def translate(self, vec):
     tr = gp_Trsf()
     tr.SetTranslation(gp_Vec(*vec))
     loc = TopLoc_Location(tr)
     self.shape.Move(loc)
     self.__extract_curves()
     return self
开发者ID:wgryglas,项目名称:wgpy,代码行数:7,代码来源:curve2D.py


示例13: scale

 def scale(self, scale):
     tr = gp_Trsf()
     #tr.SetScale(gp_Pnt(*point), scale)
     tr.SetScaleFactor(scale)
     self.shape = BRepBuilderAPI_Transform(self.shape, tr).Shape()
     self.__extract_curves()
     return self
开发者ID:wgryglas,项目名称:wgpy,代码行数:7,代码来源:curve2D.py


示例14: init_display

def init_display(backend_str=None, size=(1000, 600)):
    QtCore, QtGui, QtWidgets, QtOpenGL = get_qt_modules()

    class MainWindow(QtWidgets.QMainWindow):
        def __init__(self, *args):
            QtWidgets.QMainWindow.__init__(self, *args)

            self.resize(size[0], size[1])
            self.Viewer = qtViewer2(self)

            self.setCentralWidget(self.Viewer)
            self.centerOnScreen()

        def centerOnScreen(self):
            '''Centers the window on the screen.'''
            resolution = QtWidgets.QDesktopWidget().screenGeometry()
            self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
                      (resolution.height() / 2) - (self.frameSize().height() / 2))

    # following couple of lines is a twek to enable ipython --gui='qt'
    app = QtWidgets.QApplication.instance()  # checks if QApplication already exists
    if not app:  # create QApplication if it doesnt exist
        app = QtWidgets.QApplication(sys.argv)
    win = MainWindow()
    win.show()
    win.Viewer.InitDriver()
    display = win.Viewer._display

    # background gradient
    display.set_bg_gradient_color(206, 215, 222, 128, 128, 128)
    # display black trihedron
    display.display_trihedron()

    def start_display():
        win.raise_()  # make the application float to the top
        app.exec_()

    win.display = display
    win.show()
    win.Viewer.init2()
    # create and add shapes
    box = BRepPrimAPI.BRepPrimAPI_MakeBox(60, 30, 10).Shape()
    cyl = BRepPrimAPI.BRepPrimAPI_MakeCylinder(25, 40).Shape()

    tr = gp.gp_Trsf()
    tr.SetTranslation(gp.gp_Vec(0, 50, 0))
    loc = TopLoc.TopLoc_Location(tr)
    moved_box = box.Moved(loc)

    # these shapes can be deleted by selecting them and pressing 'Del':
    win.Viewer.doc_ctrl.add(box)
    win.Viewer.doc_ctrl.add(cyl)
    # this shape cannot be deleted in this implementation:
    win.Viewer.doc_ctrl.add(moved_box)

    win.Viewer.repaint(Update=False)

    display.FitAll()
    return display, start_display
开发者ID:kozintsev,项目名称:ResearchPythonOCC,代码行数:59,代码来源:TestQtOver.py


示例15: translate

    def translate(self, target):
        transform = gp.gp_Trsf()
        transform.SetTranslation(gp.gp_Vec(*target))

        # FIXME: this needs some explanation... should it be here?
        needle_transform = BRepTransform(self.needle, transform, False)
        needle_transform.Build()
        self.needle = needle_transform.Shape()
开发者ID:go-smart,项目名称:goosefoot,代码行数:8,代码来源:extentbuilder.py


示例16: translate

    def translate(self, target):
        transform = gp.gp_Trsf()
        transform.SetTranslation(gp.gp_Vec(*target))

        for i, needle in enumerate(self.shapes):
            needle_transform = BRepTransform(needle, transform, False)
            needle_transform.Build()
            self.shapes[i] = needle_transform.Shape()
开发者ID:go-smart,项目名称:goosefoot,代码行数:8,代码来源:manipulator.py


示例17: InitDoc

    def InitDoc(self):
        h_shape_tool = XCAFDoc.XCAFDoc_DocumentTool().ShapeTool(doc.Main())
        l_Colors = XCAFDoc.XCAFDoc_DocumentTool().ColorTool(doc.Main())

        shape_tool = h_shape_tool.GetObject()
        colors = l_Colors.GetObject()
        
        self.shape_tool = shape_tool

        top_label = shape_tool.NewShape() #this is the "root" label for the assembly
        self.top_label = top_label

        #Add some shapes
        box = BRepPrimAPI.BRepPrimAPI_MakeBox(10,20,30).Shape()
        box_label = shape_tool.AddShape(box, False)

        cyl = BRepPrimAPI.BRepPrimAPI_MakeCylinder(25,50).Shape()
        cyl_label = shape_tool.AddShape(cyl, False)

        #Add components as references to our shape
        tr = gp.gp_Trsf()
        tr.SetTranslation(gp.gp_Vec(100,100,100))
        loc = TopLoc.TopLoc_Location(tr)
        box_comp1 = shape_tool.AddComponent(top_label, box_label, loc)

        tr = gp.gp_Trsf()
        tr.SetTranslation(gp.gp_Vec(200,200,200))
        loc = TopLoc.TopLoc_Location(tr)
        box_comp2 = shape_tool.AddComponent(top_label, box_label, loc)

        tr = gp.gp_Trsf()
        tr.SetTranslation(gp.gp_Vec(150,200,100))
        loc = TopLoc.TopLoc_Location(tr)
        cyl_comp = shape_tool.AddComponent(top_label, cyl_label, loc)

        #Add some colors
        red = Quantity.Quantity_Color(Quantity.Quantity_NOC_RED)
        green = Quantity.Quantity_Color(Quantity.Quantity_NOC_GREEN)
        colors.SetColor(cyl_comp, red, XCAFDoc.XCAFDoc_ColorGen)
        colors.SetColor(box_comp2, green, XCAFDoc.XCAFDoc_ColorGen)
        
        self.box_label = box_label
        self.cyl_label = cyl_label
        self.box_comp1 = box_comp1
        self.box_comp2 = box_comp2
        self.cyl_comp = cyl_comp
开发者ID:lzweopard,项目名称:pythonocc-examples,代码行数:46,代码来源:DynamicXCAF.py


示例18: rotate

 def rotate(self, angle, axis):
     ax = gp_Ax1(gp_Pnt(*axis[:3]), gp_Dir(*axis[3:]))
     tr = gp_Trsf()
     tr.SetRotation(ax, angle)
     loc = TopLoc_Location(tr)
     self.shape =  BRepBuilderAPI_Transform(self.shape, tr).Shape()
     self.__extract_curves()
     return self
开发者ID:wgryglas,项目名称:wgpy,代码行数:8,代码来源:curve2D.py


示例19: build

    def build(self):
        # Get the subclass-specific reference shape
        shape = self.make_reference(**self.parameters)

        # Transform it as required by our initializing parameters
        transform = gp.gp_Trsf()
        transform.SetScale(self.origin, self.radius)

        shape_transform = BRepTransform(shape, transform, False)
        shape_transform.Build()
        shape = shape_transform.Shape()

        transform = gp.gp_Trsf()
        transform.SetTranslation(gp.gp_Vec(*self.centre))

        shape_transform = BRepTransform(shape, transform, False)
        shape_transform.Build()
        self.shape = shape_transform.Shape()
开发者ID:go-smart,项目名称:goosefoot,代码行数:18,代码来源:extentbuilder.py


示例20: rotating_cube_2_axis

def rotating_cube_2_axis(event=None):
    display.EraseAll()
    ais_boxshp = build_shape()
    ax1 = gp_Ax1(gp_Pnt(0., 0., 0.), gp_Dir(0., 0., 1.))
    ax2 = gp_Ax1(gp_Pnt(0., 0., 0.), gp_Dir(0., 1., 0.))
    a_cube_trsf = gp_Trsf()
    a_cube_trsf2 = gp_Trsf()
    angle = 0.0
    tA = time.time()
    n_rotations = 200
    for i in range(n_rotations):
        a_cube_trsf.SetRotation(ax1, angle)
        a_cube_trsf2.SetRotation(ax2, angle)
        aCubeToploc = TopLoc_Location(a_cube_trsf * a_cube_trsf2)
        display.Context.SetLocation(ais_boxshp, aCubeToploc)
        display.Context.UpdateCurrentViewer()
        angle += 2*pi / n_rotations
    print("%i rotations took %f" % (n_rotations, time.time() - tA))
开发者ID:AlexLee,项目名称:pythonocc-core,代码行数:18,代码来源:core_animation.py



注:本文中的OCC.gp.gp_Trsf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gp.gp_Vec函数代码示例发布时间:2022-05-24
下一篇:
Python gp.gp_Pnt函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap