Exemplo n.º 1
0
void VisualizationSceneVector3d::PrepareDisplacedMesh()
{
   int i, j, ne = mesh -> GetNBE();
   DenseMatrix pointmat;
   Array<int> vertices;

   // prepare the displaced mesh
   glNewList(displinelist, GL_COMPILE);

   for (i = 0; i < ne; i++)
   {
      glBegin(GL_LINE_LOOP);
      mesh->GetBdrPointMatrix (i, pointmat);
      mesh->GetBdrElementVertices (i, vertices);

      for (j = 0; j < pointmat.Size(); j++)
      {
         pointmat(0, j) += (*solx)(vertices[j])*(ianimd)/ianimmax;
         pointmat(1, j) += (*soly)(vertices[j])*(ianimd)/ianimmax;
         pointmat(2, j) += (*solz)(vertices[j])*(ianimd)/ianimmax;
      }

      for (j = 0; j < pointmat.Size(); j++)
         glVertex3d (pointmat(0, j), pointmat(1, j), pointmat(2, j) );
      glEnd();
   }
   glEndList();
}
Exemplo n.º 2
0
void VisualizationSceneVector3d::PrepareLines()
{
   if (!drawmesh) return;

   if (shading == 2)
   {
      PrepareLines2();
      return;
   }

   int i, j, ne = mesh->GetNBE();
   DenseMatrix pointmat;
   Array<int> vertices;

   glNewList(linelist, GL_COMPILE);

   for (i = 0; i < ne; i++)
   {
      if (!bdr_attr_to_show[mesh->GetBdrAttribute(i)-1]) continue;

      mesh->GetBdrElementVertices(i, vertices);
      if (cplane == 2)
      {
         int n = 0;
         for (j = 0; j < vertices.Size(); j ++)
            if (node_pos[vertices[j]] >= 0.0)
               n++;
         if (n < vertices.Size())
            continue;  // with the next boundary element
      }

      double point[4][4];
      mesh->GetBdrPointMatrix(i, pointmat);
      for (j = 0; j < pointmat.Size(); j++)
      {
         pointmat(0, j) += (*solx)(vertices[j])*(ianim)/ianimmax;
         pointmat(1, j) += (*soly)(vertices[j])*(ianim)/ianimmax;
         pointmat(2, j) += (*solz)(vertices[j])*(ianim)/ianimmax;
      }

      switch (drawmesh)
      {
      case 1:
         glBegin(GL_LINE_LOOP);

         for (j = 0; j < pointmat.Size(); j++)
            glVertex3d (pointmat(0, j), pointmat(1, j), pointmat(2, j));
         glEnd();
         break;

      case 2:
         for (j = 0; j < pointmat.Size(); j++)
         {
            for (int k = 0; k < 3; k++)
               point[j][k] = pointmat(k,j);
            point[j][3] = (*sol)(vertices[j]);
         }
         DrawPolygonLevelLines(point[0], pointmat.Size(), level, false);
         break;
      }
   }
   glEndList();
}
Exemplo n.º 3
0
void VisualizationSceneVector3d::Prepare()
{
   int i,j;

   switch (shading)
   {
   case 0:
      PrepareFlat();
      return;
   case 2:
      PrepareFlat2();
      return;
   default:
      break;
   }

   glNewList(displlist, GL_COMPILE);

   int ne = mesh -> GetNBE();
   int nv = mesh -> GetNV();
   DenseMatrix pointmat;
   Array<int> vertices;
   double nor[3];

   Vector nx(nv);
   Vector ny(nv);
   Vector nz(nv);

   for (int d = 0; d < mesh -> bdr_attributes.Size(); d++)
   {
      if (!bdr_attr_to_show[mesh -> bdr_attributes[d]-1]) continue;

      nx=0.;
      ny=0.;
      nz=0.;

      for (i = 0; i < ne; i++)
         if (mesh -> GetBdrAttribute(i) == mesh -> bdr_attributes[d])
         {
            mesh->GetBdrPointMatrix (i, pointmat);
            mesh->GetBdrElementVertices (i, vertices);

            for (j = 0; j < pointmat.Size(); j++)
            {
               pointmat(0, j) += (*solx)(vertices[j])*(ianim)/ianimmax;
               pointmat(1, j) += (*soly)(vertices[j])*(ianim)/ianimmax;
               pointmat(2, j) += (*solz)(vertices[j])*(ianim)/ianimmax;
            }

            if (pointmat.Width() == 3)
               j = Compute3DUnitNormal(&pointmat(0,0), &pointmat(0,1),
                                       &pointmat(0,2), nor);
            else
               j = Compute3DUnitNormal(&pointmat(0,0), &pointmat(0,1),
                                       &pointmat(0,2), &pointmat(0,3), nor);
            if (j == 0)
               for (j = 0; j < pointmat.Size(); j++)
               {
                  nx(vertices[j]) += nor[0];
                  ny(vertices[j]) += nor[1];
                  nz(vertices[j]) += nor[2];
               }
         }

      for (i = 0; i < ne; i++)
         if (mesh -> GetBdrAttribute(i) == mesh -> bdr_attributes[d])
         {
            switch (mesh->GetBdrElementType(i))
            {
            case Element::TRIANGLE:
               glBegin (GL_TRIANGLES);
               break;

            case Element::QUADRILATERAL:
               glBegin (GL_QUADS);
               break;
            }
            mesh->GetBdrPointMatrix (i, pointmat);
            mesh->GetBdrElementVertices (i, vertices);
            for (j = 0; j < pointmat.Size(); j++)
            {
               pointmat(0, j) += (*solx)(vertices[j])*(ianim)/ianimmax;
               pointmat(1, j) += (*soly)(vertices[j])*(ianim)/ianimmax;
               pointmat(2, j) += (*solz)(vertices[j])*(ianim)/ianimmax;
            }
            for (j = 0; j < pointmat.Size(); j++)
            {
               MySetColor((*sol)(vertices[j]), minv, maxv);
               glNormal3d(nx(vertices[j]), ny(vertices[j]), nz(vertices[j]));
               glVertex3dv(&pointmat(0, j));
            }
            glEnd();
         }
   }
   glEndList();
}