*#FILE_EXTENSION .wrl
*# Interface GID-VRML 2.0
*# To export mesh of triangles and quadrilaterals
*# Written by Kike III - November 1999
*if(nelem(Linear)==0 && nelem(Triangle)==0 && nelem(Quadrilateral)==0)
*MessageBox Error: Must create a mesh of lines, triangles or quadrilaterals.
*endif
*#*if(isquadratic)
*#*MessageBox Error: elements are Quadratic.
*#*endif
*if(nelem(Tetrahedra) || nelem(Hexahedra))
*WarningBox Warning: Exist Bad elements. Only written in the VRML file the lines, triangles and quadrilaterals.
*endif
*realformat "%15.5f"
*intformat "%7i"
#VRML V2.0 utf8
Background{
  groundColor 1.0 1.0 1.0
  skyColor 1.0 1.0 1.0
}
DEF Nodos Coordinate {
  point [
*loop nodes
    *NodesCoord(1,real) *NodesCoord(2,real) *NodesCoord(3,real),
*end nodes
  ]
}

*for(I=1;I<=2;I=I+1)
*if(I==1)
*Set elems(Triangle)
*Add elems(Quadrilateral)
*else
*Set elems(Linear)
*endif
*loop layers
*set var Write=0
*set Layer *LayerName *elems
*loop elems OnlyInLayer
*set var Write=1
*break
*end elems
*if( Write)
Shape {
*set var R=Operation(LayerColorRGB(1)/255.0)
*set var G=Operation(LayerColorRGB(2)/255.0)
*set var B=Operation(LayerColorRGB(3)/255.0)
  appearance Appearance { material Material { diffuseColor *R *G *B } }
  geometry
*if(I==1)
  IndexedFaceSet {
    solid  FALSE
*else
  IndexedLineSet {
*endif
    coord USE Nodos
    coordIndex [
*loop elems OnlyInLayer
*for(INODO=1;INODO<=ElemsNnodeCurt;INODO=INODO+1)
      *operation(elemsConec(*INODO,int)-1) *\
*end for INODO
      -1
*end elems
    ]  
  }
}
*endif

*end layers
*end for I

