Actual source code: meshDraw.c

  1: #ifdef PETSC_RCS_HEADER
  2: static char vcid[] = "$Id: meshDraw.c,v 1.00 2001/09/25 06:48:57 knepley Exp $";
  3: #endif

  5: /*
  6:      Defines the interface to functions for drawing a mesh
  7: */

 9:  #include src/mesh/meshimpl.h

 11: #undef  __FUNCT__
 13: /*@
 14:   MeshDrawLine - This function draws a line, taking into account the
 15:   periodicity of the mesh.

 17:   Collective on Mesh

 19:   Input Parameters:
 20: + mesh  - The mesh
 21: . draw  - The PetscDraw context
 22: . xA,yA - The coordinates of an endpoint
 23: . xB,yB - The coordinates of the other endpoint
 24: - color - The line color

 26:   Level: intermediate

 28: .keywords mesh, draw
 29: .seealso MeshDrawTriangle()
 30: @*/
 31: int MeshDrawLine(Mesh mesh, PetscDraw draw, double xA, double yA, double xB, double yB, int color)
 32: {

 36:   if (mesh->isPeriodic == PETSC_TRUE) {
 37:     PetscDrawLine(draw, xA, yA, MeshPeriodicRelativeX(mesh, xB, xA), MeshPeriodicRelativeY(mesh, yB, yA), color);
 38: 
 39:   } else {
 40:     PetscDrawLine(draw, xA, yA, xB, yB, color);
 41:   }
 42:   PetscFunctionReturn(ierr);
 43: }

 45: #undef  __FUNCT__
 47: /*@
 48:   MeshDrawTriangle - This function draws a triangle, taking into account the
 49:   periodicity of the mesh.

 51:   Collective on Mesh

 53:   Input Parameters:
 54: + mesh  - The mesh
 55: . draw  - The PetscDraw context
 56: . xA,yA - The coordinates of the first corner
 57: . xB,yB - The coordinates of the second corner
 58: . xC,yC - The coordinates of the third corner
 59: . colorA, colorB, colorC - The colors of the corners

 61:   Level: intermediate

 63: .keywords mesh, draw
 64: .seealso MeshDrawLine()
 65: @*/
 66: int MeshDrawTriangle(Mesh mesh, PetscDraw draw, double xA, double yA, double xB, double yB, double xC, double yC, int colorA,
 67:                      int colorB, int colorC)
 68: {

 72:   if (mesh->isPeriodic == PETSC_TRUE) {
 73:     PetscDrawTriangle(draw, xA, yA, MeshPeriodicRelativeX(mesh, xB, xA), MeshPeriodicRelativeY(mesh, yB, yA),
 74:                         MeshPeriodicRelativeX(mesh, xC, xA), MeshPeriodicRelativeY(mesh, yC, yA), colorA, colorB, colorC);
 75: 
 76:   } else {
 77:     PetscDrawTriangle(draw, xA, yA, xB, yB, xC, yC, colorA, colorB, colorC);
 78:   }
 79:   PetscFunctionReturn(ierr);
 80: }

 82: #undef  __FUNCT__
 84: /*@C
 85:   MeshSetHighlightElement - This function highlights the given element when the mesh is displayed.

 87:   Collective on Mesh

 89:   Input Parameters:
 90: + mesh    - The mesh
 91: - element - The local element index to highlight

 93:   Level: intermediate

 95:   Note: You can retrieve the local element index from the global element index using
 96:   the Partition function PartitionGlobalToLocalElementIndex()

 98: .keywords mesh, element
 99: .seealso MeshGetHighlightElement(), MeshView()
100: @*/
101: int MeshSetHighlightElement(Mesh mesh, int element)
102: {
105:   mesh->highlightElement = element;
106:   return(0);
107: }

109: #undef  __FUNCT__
111: /*@C
112:   MeshGetHighlightElement - This function returns the element which is highlighted when the mesh is displayed.

114:   Collective on Mesh

116:   Input Parameter:
117: . mesh  - The mesh

119:   Output Parameter:
120: . element - The local element element to highlight, or -1 for no highlighting

122:   Level: intermediate

124:   Note: You can retrieve the global element index from the local element index using
125:   the Partition function PartitionLocalToGlobalElementIndex()

127: .keywords mesh, element
128: .seealso MeshSetHighlightElement(), MeshView()
129: @*/
130: int MeshGetHighlightElement(Mesh mesh, int *element)
131: {
135:   *element = mesh->highlightElement;
136:   return(0);
137: }