def readFromVTK(cls,
                    vtkFile,
                    viewAnchor,
                    xViewBasis,
                    yViewBasis,
                    srcBasisSrc=[[1,0,0],[0,1,0],[0,0,1]]):
        '''
        Construct from a surface saved by OpenFOAM in VTK format.
        '''
        afftrans, lintrans = TriSurface.getTransformation(viewAnchor,
                                                          xViewBasis,
                                                          yViewBasis,
                                                          srcBasisSrc)
       
        # read VTK file
        ptsSrc, triangles, vecsSrc = ParserFunctions.parseVTK_ugly_sampledSurface(vtkFile)
        
        # Transform the points
        ptsTgt = np.zeros((ptsSrc.shape[0],ptsSrc.shape[1]))
        for i in range(ptsSrc.shape[0]):
            ptsTgt[i,:] = afftrans.srcToTgt(ptsSrc[i,:])

        # update class member variables
        return cls(x=ptsTgt[:,0],
                   y=ptsTgt[:,1],
                   z=ptsTgt[:,2],
                   triangles=triangles,
                   mask=None,
                   affTrans=afftrans,
                   linTrans=lintrans)
Ejemplo n.º 2
0
    def readFromVTK(cls,
                    vtkFile,
                    viewAnchor,
                    xViewBasis,
                    yViewBasis,
                    srcBasisSrc=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]):
        '''
        Construct from a surface saved by OpenFOAM in VTK format.
        '''
        afftrans, lintrans = TriSurface.getTransformation(
            viewAnchor, xViewBasis, yViewBasis, srcBasisSrc)

        # read VTK file
        ptsSrc, triangles, vecsSrc = ParserFunctions.parseVTK_ugly_sampledSurface(
            vtkFile)

        # Transform the points
        ptsTgt = np.zeros((ptsSrc.shape[0], ptsSrc.shape[1]))
        for i in range(ptsSrc.shape[0]):
            ptsTgt[i, :] = afftrans.srcToTgt(ptsSrc[i, :])

        # update class member variables
        return cls(x=ptsTgt[:, 0],
                   y=ptsTgt[:, 1],
                   z=ptsTgt[:, 2],
                   triangles=triangles,
                   mask=None,
                   affTrans=afftrans,
                   linTrans=lintrans)
Ejemplo n.º 3
0
def transformPoints(ptsSrc,
                    xViewBasis,
                    yViewBasis=None,
                    viewAnchor=(0, 0, 0),
                    srcBasisSrc=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]):
    '''
    '''
    # create basis vectors if missing
    if not yViewBasis:
        n = getN(ptsSrc)
        yViewBasis = getYBasis(n, xViewBasis)

    # create the transformation objects
    afftrans, lintrans = TriSurface.getTransformation(viewAnchor, xViewBasis,
                                                      yViewBasis, srcBasisSrc)

    # transform the points from the source basis to the target basis
    ptsTgt = np.zeros((ptsSrc.shape[0], ptsSrc.shape[1]))
    for i in range(ptsSrc.shape[0]):
        ptsTgt[i, :] = afftrans.srcToTgt(ptsSrc[i, :])

    return ptsTgt, afftrans, lintrans
def transformPoints(ptsSrc,
                     xViewBasis,
                     yViewBasis=None,
                     viewAnchor=(0,0,0),
                     srcBasisSrc=[[1,0,0],[0,1,0],[0,0,1]]):
    '''
    '''
    # create basis vectors if missing
    if not yViewBasis:
        n=getN(ptsSrc)
        yViewBasis=getYBasis(n,xViewBasis)
    
    # create the transformation objects    
    afftrans, lintrans = TriSurface.getTransformation(viewAnchor,
                                          xViewBasis,
                                          yViewBasis,
                                          srcBasisSrc)
    
    # transform the points from the source basis to the target basis
    ptsTgt = np.zeros((ptsSrc.shape[0],ptsSrc.shape[1]))
    for i in range(ptsSrc.shape[0]):
        ptsTgt[i,:] = afftrans.srcToTgt(ptsSrc[i,:])
        
    return ptsTgt,afftrans,lintrans