当前位置: 首页>>代码示例>>Python>>正文


Python gp.gp_Vec函数代码示例

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


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

示例1: test_gp_Quaternion

 def test_gp_Quaternion(self):
     '''
     Test Interpolate method of qp_QuaternionSLerp.
     This method takes a by ref parameter q.
     '''
     vX = gp_Vec(12, 0, 0)
     vY = gp_Vec(0, 12, 0)
     v45 = (gp_Vec(1, 1, 1).Normalized() * 12)
     q = gp_Quaternion()
     q1 = gp_Quaternion(vX, vX)
     q2 = gp_Quaternion(vX, vY)
     interp = gp_QuaternionSLerp(q1, q2)
     interp.Init(q1, q2)
     for i in range(10):
         i__ = i / 10.
         interp.Interpolate(i__, q)
         if i == 0:
             self.assertEqual(q.X(), 0.)
             self.assertEqual(q.Y(), 0.)
             self.assertEqual(q.Z(), 0.)
             self.assertEqual(q.W(), 1.)
         else:
             self.assertEqual(q.X(), 0.)
             self.assertEqual(q.Y(), 0.)
             assert q.Z() > 0.
             assert q.W() < 1.
开发者ID:jf---,项目名称:pythonocc-core,代码行数:26,代码来源:core_wrapper_features_unittest.py

示例2: brep_feat_rib

def brep_feat_rib(event=None):
    mkw = BRepBuilderAPI_MakeWire()

    mkw.Add(BRepBuilderAPI_MakeEdge(gp_Pnt(0., 0., 0.), gp_Pnt(200., 0., 0.)).Edge())
    mkw.Add(BRepBuilderAPI_MakeEdge(gp_Pnt(200., 0., 0.), gp_Pnt(200., 0., 50.)).Edge())
    mkw.Add(BRepBuilderAPI_MakeEdge(gp_Pnt(200., 0., 50.), gp_Pnt(50., 0., 50.)).Edge())
    mkw.Add(BRepBuilderAPI_MakeEdge(gp_Pnt(50., 0., 50.), gp_Pnt(50., 0., 200.)).Edge())
    mkw.Add(BRepBuilderAPI_MakeEdge(gp_Pnt(50., 0., 200.), gp_Pnt(0., 0., 200.)).Edge())
    mkw.Add(BRepBuilderAPI_MakeEdge(gp_Pnt(0., 0., 200.), gp_Pnt(0., 0., 0.)).Edge())

    S = BRepPrimAPI_MakePrism(BRepBuilderAPI_MakeFace(mkw.Wire()).Face(),
                              gp_Vec(gp_Pnt(0., 0., 0.),
                                     gp_Pnt(0., 100., 0.)))
    display.EraseAll()
    #    display.DisplayShape(S.Shape())

    W = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(gp_Pnt(50., 45., 100.),
                                                        gp_Pnt(100., 45., 50.)).Edge())

    aplane = Geom_Plane(0., 1., 0., -45.)

    aform = BRepFeat_MakeLinearForm(S.Shape(), W.Wire(), aplane.GetHandle(),
                                    gp_Vec(0., 10., 0.), gp_Vec(0., 0., 0.),
                                    1, True)
    aform.Perform()
    display.DisplayShape(aform.Shape())
    display.FitAll()
开发者ID:CrazyHeex,项目名称:pythonocc-core,代码行数:27,代码来源:core_topology_local_ops.py

示例3: get_boundingbox

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)
开发者ID:anwar-hegazy,项目名称:pythonocc-core,代码行数:31,代码来源:core_geometry_utils.py

示例4: rotate

def rotate(event=None):
    display.EraseAll()
    origin = gp_Vec(0, 0, 0)
    origin_pt = as_pnt(origin)

    vX = gp_Vec(12, 0, 0)
    vY = gp_Vec(0, 12, 0)
    vZ = gp_Vec(0, 0, 12)
    v45 = (gp_Vec(1, 1, 1).Normalized() * 12)
    q1 = gp_Quaternion(vX, vY)

    p1 = as_pnt(origin + vX)
    p2 = as_pnt(origin + vY)
    p3 = as_pnt(origin + (q1 * vY))
    p4 = as_pnt(origin + (q1 * v45))

    # RED
    e1 = make_edge(origin_pt, p1)
    e2 = make_edge(origin_pt, p2)
    e3 = make_edge(origin_pt, as_pnt(v45))
    # GREEN -> transformed
    e4 = make_edge(origin_pt, p3)
    e5 = make_edge(origin_pt, p4)

    display.DisplayShape([e1, e2, e3])
    display.DisplayColoredShape([e4, e5], 'GREEN')
    #display.DisplayMessage(p1, 'e1')
    #display.DisplayMessage(p2, 'e2')
    #display.DisplayMessage(v45.as_pnt(), 'e3')
    #display.DisplayMessage(p3, 'q1*vY')
    #display.DisplayMessage(p4, 'q1*v45')
    display.DisplayVector((q1 * vY).Normalized(), as_pnt(origin + q1 * vY / 2.))
    display.DisplayVector((q1 * v45).Normalized(), as_pnt(origin + q1 * v45 / 2.))
    display.FitAll()
开发者ID:gideonmay,项目名称:pythonocc-core,代码行数:34,代码来源:core_geometry_quaternion.py

示例5: angle_bw_2_vecs_w_ref

def angle_bw_2_vecs_w_ref(pyvec1, pyvec2, ref_pyvec):
    """
    This function measures the angle between two vectors regards to a reference vector. 
    The reference vector must be perpendicular to both the vectors. The angle is measured in counter-clockwise direction.
 
    Parameters
    ----------
    pyvec1 : tuple of floats
        The first vector to be measured.  A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
    
    pyvec2 : tuple of floats
        The second vector to be measured.  A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
        
    ref_pyvec : tuple of floats
        The reference vector must be perpendicular to pyvec1 and pyvec2. 
         A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)

    Returns
    -------
    angle : float
        The measured angle between pyvec1 and pyvec2 regards to ref_pyvec, the angle is measured in counter-clockwise direction.
    """
    vec1 = gp_Vec(pyvec1[0], pyvec1[1], pyvec1[2])
    vec2 = gp_Vec(pyvec2[0], pyvec2[1], pyvec2[2])
    ref_vec = gp_Vec(ref_pyvec[0], ref_pyvec[1], ref_pyvec[2])
    radangle = vec1.AngleWithRef(vec2, ref_vec)
    angle = radangle * (180.0/math.pi)
    if angle <0:
        angle = 360+angle
    #the angle is measured in counter-clockwise direction
    return angle
开发者ID:chenkianwee,项目名称:envuo,代码行数:31,代码来源:calculate.py

示例6: midpoint

def midpoint(pntA, pntB):
    '''
    computes the point that lies in the middle between pntA and pntB
    @param pntA:    gp_Pnt
    @param pntB:    gp_Pnt
    '''
    vec1 = gp_Vec(pntA.XYZ())
    vec2 = gp_Vec(pntB.XYZ())
    veccie = (vec1+vec2)/2.
    return gp_Pnt(veccie.XYZ())
开发者ID:chenkianwee,项目名称:envuo,代码行数:10,代码来源:Common.py

示例7: surface_from_curves

def surface_from_curves():
    '''
    @param display:
    '''
    # First spline
    array = []
    array.append(gp_Pnt(-4, 0, 2))
    array.append(gp_Pnt(-7, 2, 2))
    array.append(gp_Pnt(-6, 3, 1))
    array.append(gp_Pnt(-4, 3, -1))
    array.append(gp_Pnt(-3, 5, -2))

    pt_list1 = point_list_to_TColgp_Array1OfPnt(array)
    SPL1 = GeomAPI_PointsToBSpline(pt_list1).Curve()
    SPL1_c = SPL1.GetObject()

    # Second spline
    a2 = []
    a2.append(gp_Pnt(-4, 0, 2))
    a2.append(gp_Pnt(-2, 2, 0))
    a2.append(gp_Pnt(2, 3, -1))
    a2.append(gp_Pnt(3, 7, -2))
    a2.append(gp_Pnt(4, 9, -1))
    pt_list2 = point_list_to_TColgp_Array1OfPnt(a2)
    SPL2 = GeomAPI_PointsToBSpline(pt_list2).Curve()
    SPL2_c = SPL2.GetObject()

    # Fill with StretchStyle
    aGeomFill1 = GeomFill_BSplineCurves(SPL1,
                                        SPL2,
                                        GeomFill_StretchStyle)

    SPL3 = Handle_Geom_BSplineCurve_DownCast(SPL1_c.Translated(gp_Vec(10, 0, 0)))
    SPL4 = Handle_Geom_BSplineCurve_DownCast(SPL2_c.Translated(gp_Vec(10, 0, 0)))
    # Fill with CoonsStyle
    aGeomFill2 = GeomFill_BSplineCurves(SPL3,
                                        SPL4,
                                        GeomFill_CoonsStyle)
    SPL5 = Handle_Geom_BSplineCurve_DownCast(SPL1_c.Translated(gp_Vec(20, 0, 0)))
    SPL6 = Handle_Geom_BSplineCurve_DownCast(SPL2_c.Translated(gp_Vec(20, 0, 0)))
    # Fill with CurvedStyle
    aGeomFill3 = GeomFill_BSplineCurves(SPL5,
                                        SPL6,
                                        GeomFill_CurvedStyle)

    aBSplineSurface1 = aGeomFill1.Surface()
    aBSplineSurface2 = aGeomFill2.Surface()
    aBSplineSurface3 = aGeomFill3.Surface()
    
    display.DisplayShape(make_face(aBSplineSurface1, 1e-6))
    display.DisplayShape(make_face(aBSplineSurface2, 1e-6))
    display.DisplayShape(make_face(aBSplineSurface3, 1e-6), update=True)
开发者ID:CrazyHeex,项目名称:pythonocc-core,代码行数:52,代码来源:core_geometry_surface_from_curves.py

示例8: _triangle_is_valid

    def _triangle_is_valid(self, P1,P2,P3):

        V1 = gp_Vec(P1,P2)
        V2 = gp_Vec(P2,P3)
        V3 = gp_Vec(P3,P1)
        if V1.SquareMagnitude()>1e-10 and V2.SquareMagnitude()>1e-10 and V3.SquareMagnitude()>1e-10:
            V1.Cross(V2)
            if V1.SquareMagnitude()>1e-10:
                return True
            else:
                return False
        else:
            return False
开发者ID:amarh,项目名称:openPLM,代码行数:13,代码来源:mesh.py

示例9: get_mesh_precision

def get_mesh_precision(shape, quality_factor):
    bbox = Bnd_Box()
    BRepBndLib_Add(shape, bbox)
    x_min,y_min,z_min,x_max,y_max,z_max = bbox.Get()
    diagonal_length = gp_Vec(gp_Pnt(x_min, y_min, z_min),
                             gp_Pnt(x_max, y_max, z_max)).Magnitude()
    return (diagonal_length / 20.) / quality_factor
开发者ID:amarh,项目名称:openPLM,代码行数:7,代码来源:mesh.py

示例10: make_plane

def make_plane(center=gp_Pnt(0, 0, 0),
               vec_normal=gp_Vec(0, 0, 1),
               extent_x_min=-100.,
               extent_x_max=100.,
               extent_y_min=-100.,
               extent_y_max=100.,
               depth=0.):
    if depth != 0:
        center = center.add_vec(gp_Vec(0, 0, depth))
    PL = gp_Pln(center, vec_normal.as_dir())
    face = make_face(PL,
                     extent_x_min,
                     extent_x_max,
                     extent_y_min,
                     extent_y_max)
    return face
开发者ID:tpaviot,项目名称:pythonocc-utils,代码行数:16,代码来源:Construct.py

示例11: move_pt

def move_pt(orig_pypt, pydir2move, magnitude):
    """
    This function moves a point.
 
    Parameters
    ----------
    orig_pypt : tuple of floats
        The original point to be moved. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    pydir2move : tuple of floats
        The direction to move the point. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z).
        
    magnitude : float
        The distance of the move.
        
    Returns
    -------
    moved point : pypt
        The moved point.
    """
    gp_orig_pt = gp_Pnt(orig_pypt[0], orig_pypt[1],orig_pypt[2])
    gp_direction2move = gp_Vec(pydir2move[0], pydir2move[1], pydir2move[2])
    gp_moved_pt = gp_orig_pt.Translated(gp_direction2move.Multiplied(magnitude))
    moved_pt = (gp_moved_pt.X(), gp_moved_pt.Y(), gp_moved_pt.Z())
    return moved_pt
开发者ID:chenkianwee,项目名称:envuo,代码行数:25,代码来源:modify.py

示例12: normal_vector_from_plane

def normal_vector_from_plane(plane, vec_length=1.):
    '''
    returns a vector normal to the plane of length vec_length
    @param plane:
    '''
    trns = gp_Vec(plane.Axis().Direction())
    return trns.Normalized() * vec_length
开发者ID:chenkianwee,项目名称:envuo,代码行数:7,代码来源:Common.py

示例13: DisplayShape

 def DisplayShape(self,
                  shape,
                  vertex_shader=None,
                  fragment_shader=None,
                  export_edges=False,
                  color=(0.65, 0.65, 0.65),
                  specular_color=(1, 1, 1),
                  shininess=0.9,
                  transparency=0.,
                  line_color=(0, 0., 0.),
                  line_width=2.,
                  mesh_quality=1.):
     """ Adds a shape to the rendering buffer. This class computes the x3d file
     """
     shape_hash = hash(shape)
     x3d_exporter = X3DExporter(shape, vertex_shader, fragment_shader,
                                export_edges, color,
                                specular_color, shininess, transparency,
                                line_color, line_width, mesh_quality)
     x3d_exporter.compute()
     x3d_filename = os.path.join(self._path, "shp%s.x3d" % shape_hash)
     # the x3d filename is computed from the shape hash
     x3d_exporter.write_to_file(x3d_filename)
     # get shape translation and orientation
     trans = shape.Location().Transformation().TranslationPart().Coord()  # vector
     v = gp_Vec()
     angle = shape.Location().Transformation().GetRotation().GetVectorAndAngle(v)
     ori = (v.X(), v.Y(), v.Z(), angle)  # angles
     # fill the shape dictionnary with shape hash, translation and orientation
     self._x3d_shapes[shape_hash] = [trans, ori]
开发者ID:jf---,项目名称:pythonocc-core,代码行数:30,代码来源:x3dom_renderer.py

示例14: _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

示例15: 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


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