Exemple #1
0
    def VtkLoadElemMesh(self,field,defFScale=0.0,eigenMode=None):
        '''Load the element mesh

        :param field: scalar field to be represented
        :param defFScale: factor to apply to current displacement of nodes 
                  so that the display position of each node equals to
                  the initial position plus its displacement multiplied
                  by this factor. In case of modal analysis, the displayed 
                  position of each node equals to the initial position plus
                  its eigenVector multiplied by this factor.
                  (Defaults to 0.0, i.e. display of initial/undeformed shape)
        :param eigenMode: eigenvibration mode if we want to display the deformed 
                 shape associated with it when a modal analysis has been carried out. 
                 Defaults to None: no modal analysis.

        '''
        # Define grid
        self.nodes= vtk.vtkPoints()
        self.gridRecord.uGrid= vtk.vtkUnstructuredGrid()
        self.gridRecord.uGrid.SetPoints(self.nodes)
        eSet= self.gridRecord.xcSet
        eSet.numerate()
        self.gridRecord.uGrid.name= eSet.name+'_grid'
        # Scalar values.
        nodeSet= eSet.getNodes
        if(field):
            arr= field.fillArray(nodeSet)
            field.creaLookUpTable()      
        # Load nodes in vtk
        setNodes= eSet.getNodes
        if eigenMode==None:
            for n in setNodes:
                pos= n.getCurrentPos3d(defFScale)
                self.nodes.InsertPoint(n.getIdx,pos.x,pos.y,pos.z)
        else:
            for n in setNodes:
                pos= n.getEigenPos3d(defFScale,eigenMode)
                self.nodes.InsertPoint(n.getIdx,pos.x,pos.y,pos.z)
         # Load elements in vtk
        setElems= eSet.getElements
        for e in setElems:
            vertices= xc_base.vector_int_to_py_list(e.getIdxNodes)
            vtx= vtk.vtkIdList()
            for vIndex in vertices:
                vtx.InsertNextId(vIndex)
            if(e.getVtkCellType!= vtk.VTK_VERTEX):
                self.gridRecord.uGrid.InsertNextCell(e.getVtkCellType,vtx)
        setConstraints= eSet.getConstraints
        for c in setConstraints:
            vtx= vtk.vtkIdList()
            vtx.InsertNextId(c.getNodeIdx)
            if(c.getVtkCellType!= vtk.VTK_LINE):
                self.gridRecord.uGrid.InsertNextCell(c.getVtkCellType,vtx)
Exemple #2
0
    def VtkLoadElemMesh(self,field,defFScale=0.0,eigenMode=None):
        '''Load the element mesh

        :param field: scalar field to be represented
        :param defFScale: factor to apply to current displacement of nodes 
                  so that the display position of each node equals to
                  the initial position plus its displacement multiplied
                  by this factor. In case of modal analysis, the displayed 
                  position of each node equals to the initial position plus
                  its eigenVector multiplied by this factor.
                  (Defaults to 0.0, i.e. display of initial/undeformed shape)
        :param eigenMode: eigenvibration mode if we want to display the deformed 
                 shape associated with it when a modal analysis has been carried out. 
                 Defaults to None: no modal analysis.

        '''
        # Define grid
        self.nodes= vtk.vtkPoints()
        self.gridRecord.uGrid= vtk.vtkUnstructuredGrid()
        self.gridRecord.uGrid.SetPoints(self.nodes)
        eSet= self.gridRecord.xcSet
        eSet.numerate()
        self.gridRecord.uGrid.name= eSet.name+'_grid'
        # Scalar values.
        nodeSet= eSet.getNodes
        if(field):
            arr= field.fillArray(nodeSet)
            field.creaLookUpTable()      
        # Load nodes in vtk
        setNodes= eSet.getNodes
        if eigenMode==None:
            for n in setNodes:
                pos= n.getCurrentPos3d(defFScale)
                self.nodes.InsertPoint(n.getIdx,pos.x,pos.y,pos.z)
        else:
            for n in setNodes:
                pos= n.getEigenPos3d(defFScale,eigenMode)
                self.nodes.InsertPoint(n.getIdx,pos.x,pos.y,pos.z)
         # Load elements in vtk
        setElems= eSet.getElements
        for e in setElems:
            vertices= xc_base.vector_int_to_py_list(e.getIdxNodes)
            vtx= vtk.vtkIdList()
            for vIndex in vertices:
                vtx.InsertNextId(vIndex)
            if(e.getVtkCellType!= vtk.VTK_VERTEX):
                self.gridRecord.uGrid.InsertNextCell(e.getVtkCellType,vtx)
        setConstraints= eSet.getConstraints
        for c in setConstraints:
            vtx= vtk.vtkIdList()
            vtx.InsertNextId(c.getNodeIdx)
            if(c.getVtkCellType!= vtk.VTK_LINE):
                self.gridRecord.uGrid.InsertNextCell(c.getVtkCellType,vtx)
Exemple #3
0
  def VtkCargaMallaElem(self,field,deform=False):
    '''Load the element mesh

    :param field: scalar field to be represented
    :param deform:  =True for display of current/deformed shape (defaults
                    to False, i.e. display of initial/undeformed shape)
    '''
    # Definimos grid
    self.nodos= vtk.vtkPoints()
    self.gridRecord.uGrid= vtk.vtkUnstructuredGrid()
    self.gridRecord.uGrid.SetPoints(self.nodos)
    eSet= self.gridRecord.xcSet
    eSet.numerate()
    # Scalar values.
    nodeSet= eSet.getNodes
    if(field):
      arr= field.fillArray(nodeSet)
      field.creaLookUpTable()      
    # Cargamos los nodos en vtk
    setNodos= eSet.getNodes
    if(self.gridRecord.dispScale==0.0):
      for n in setNodos:
        pos= n.getInitialPos3d
        self.nodos.InsertPoint(n.getIdx,pos.x,pos.y,pos.z)
    else:
      posNodo= xc.Vector([0,0,0])
      for n in setNodos:
        posNodo= n.get3dCoo+self.gridRecord.dispScale*n.getDispXYZ
        self.nodos.insertPoint(n.getIdx,posNodo[0],posNodo[1],posNodo[2])
    # Cargamos los elementos en vtk
    setElems= eSet.getElements
    for e in setElems:
      vertices= xc_base.vector_int_to_py_list(e.getIdxNodes)
      vtx= vtk.vtkIdList()
      for vIndex in vertices:
        vtx.InsertNextId(vIndex)
      if(e.getVtkCellType!= vtk.VTK_VERTEX):
        self.gridRecord.uGrid.InsertNextCell(e.getVtkCellType,vtx)
 
    #Cargamos constraint on XXX FALLA
    setConstraints= eSet.getConstraints
    for c in setConstraints:
      vtx= vtk.vtkIdList()
      vtx.InsertNextId(c.getNodeIdx)
      if(c.getVtkCellType!= vtk.VTK_LINE):
        self.gridRecord.uGrid.InsertNextCell(c.getVtkCellType,vtx)
Exemple #4
0
def VtkCargaMalla(recordGrid):
    kpoints = vtk.vtkPoints()
    # Definimos grid
    recordGrid.uGrid.SetPoints(kpoints)
    setToDraw = recordGrid.xcSet
    setToDraw.numerate()
    pnts = setToDraw.getPoints
    for p in pnts:
        kpoints.InsertPoint(p.getIdx, p.getPos.x, p.getPos.y, p.getPos.z)
    cellSet = setToDraw.getLines  # cells are lines as default.
    if (recordGrid.cellType == "faces"):
        cellSet = setToDraw.getSurfaces
    elif (recordGrid.cellType == "bodies"):
        cellSet = setToDraw.getBodies
    for c in cellSet:
        vertices = xc_base.vector_int_to_py_list(c.getIdxVertices)
        vtx = vtk.vtkIdList()
        for vIndex in vertices:
            vtx.InsertNextId(vIndex)
        recordGrid.uGrid.InsertNextCell(c.getVtkCellType, vtx)
Exemple #5
0
def VtkCargaMalla(recordGrid):
  kpoints= vtk.vtkPoints()
  # Definimos grid
  recordGrid.uGrid.SetPoints(kpoints)
  setToDraw= recordGrid.xcSet
  setToDraw.numerate()
  pnts= setToDraw.getPoints
  for p in pnts:
    kpoints.InsertPoint(p.getIdx,p.getPos.x,p.getPos.y,p.getPos.z)
  cellSet= setToDraw.getLines # cells are lines as default.
  if(recordGrid.cellType=="faces"):
    cellSet= setToDraw.getSurfaces
  elif (recordGrid.cellType=="bodies"):
    cellSet= setToDraw.getBodies
  for c in cellSet:
    vertices= xc_base.vector_int_to_py_list(c.getIdxVertices)
    vtx= vtk.vtkIdList()
    for vIndex in vertices:
       vtx.InsertNextId(vIndex)
    recordGrid.uGrid.InsertNextCell(c.getVtkCellType,vtx)
Exemple #6
0
def vtk_load_mesh_data(recordGrid):
    kpoints = vtk.vtkPoints()
    # Grid definition
    recordGrid.uGrid.SetPoints(kpoints)
    setToDraw = recordGrid.xcSet
    setToDraw.numerate()
    pnts = setToDraw.getPoints
    kpoints.SetDataTypeToDouble()
    nPoints = len(pnts)
    kpoints.SetNumberOfPoints(nPoints)
    for p in pnts:
        kpoints.InsertPoint(p.getIdx, p.getPos.x, p.getPos.y, p.getPos.z)
    cellSet = setToDraw.getLines  # cells are lines by default.
    if (recordGrid.cellType == "faces"):
        cellSet = setToDraw.getSurfaces
    elif (recordGrid.cellType == "bodies"):
        cellSet = setToDraw.getBodies
    for c in cellSet:
        vertices = xc_base.vector_int_to_py_list(c.getIdxVertices)
        vtx = vtk.vtkIdList()
        for vIndex in vertices:
            vtx.InsertNextId(vIndex)
        recordGrid.uGrid.InsertNextCell(c.getVtkCellType, vtx)