Example #1
0
def ask_point_uv(xyz, face, uvrange):
    """
    This is a general function which gives the uv coordiates from the xyz coordinates.
    The uv value is not normlized.
    """
    gpPnt = gp_Pnt(float(xyz[0]), float(xyz[1]), float(xyz[2]))
    surface = BRep_Tool().Surface(face)  ### Handle_Geom_Surface

    sas = ShapeAnalysis_Surface(surface)
    gpPnt2D = sas.ValueOfUV(gpPnt, 0.01)
    uv = list(gpPnt2D.Coord())
    #    print(uvrange)
    #    print(uv)
    geom_surface = surface.GetObject()
    tol = 0.001
    if geom_surface.IsUPeriodic() == True:
        #        print (geom_surface.UPeriod())
        if uv[0] < uvrange[0] and uvrange[0] - uv[0] > tol:
            uv[0] = uv[0] + geom_surface.UPeriod()
        if uv[0] > uvrange[1] and uv[0] - uvrange[1] > tol:
            uv[0] = uv[0] - geom_surface.UPeriod()

    if geom_surface.IsVPeriodic() == True:
        if uv[1] < uvrange[2] and uvrange[2] - uv[1] > tol:
            uv[1] = uv[1] + geom_surface.VPeriod()
        if uv[1] > uvrange[3] and uv[1] - uvrange[3] > tol:
            uv[1] = uv[1] - geom_surface.VPeriod()
    #    print(uv)
    return uv
Example #2
0
 def point_to_parameter(self, pt):
     '''
     returns the uv value of a point on a surface
     @param pt:
     '''
     sas = ShapeAnalysis_Surface(self.surface_handle)
     uv = sas.ValueOfUV(pt, self.tolerance)
     return uv.Coord()
def uv_from_projected_point_on_face(face, pt):
    '''
    returns the uv coordinate from a projected point on a face
    '''
    srf = BRep_Tool().Surface(face)
    sas = ShapeAnalysis_Surface(srf)
    uv = sas.ValueOfUV(pt, 1e-2)
    print('distance', sas.Value(uv).Distance(pt))
    return uv.Coord()
Example #4
0
 def project_to_UV(self):
     assert self.face != None
     surface = BRep_Tool.Surface(self.face)
     analysis_surface = ShapeAnalysis_Surface(surface)
     xyz = gp_Pnt(self.x, self.y, self.z)
     uv = analysis_surface.ValueOfUV(xyz, 0.0001)
     self.u = uv.X()
     self.v = uv.Y()
     if self.face.Orientation() == TopAbs_REVERSED:
         self.reverse_u()
Example #5
0
def ask_point_uv2(xyz, face):
    """
    This is a general function which gives the uv coordiates from the xyz coordinates.
    The uv value is not normlized.
    """
    gpPnt = gp_Pnt(float(xyz[0]), float(xyz[1]), float(xyz[2]))
    surface = BRep_Tool().Surface(face)  ### Handle_Geom_Surface

    sas = ShapeAnalysis_Surface(surface)
    gpPnt2D = sas.ValueOfUV(gpPnt, 0.01)
    uv = list(gpPnt2D.Coord())

    return uv