Beispiel #1
0
//! compute C = this + B
bool DenseMatrix::Add(const DenseMatrix & B, DenseMatrix & C ) const
{
	C = *this;
	return C.Add(B);
}
Beispiel #2
0
void VisualizationSceneVector3d::PrepareLines2()
{
   int i, j, k, fn, fo, di;
   double bbox_diam;

   glNewList (linelist, GL_COMPILE);

   int nbe = mesh -> GetNBE();
   DenseMatrix pointmat;
   DenseMatrix vec_vals;
   Vector values;
   RefinedGeometry * RefG;
   Array<int> vertices;

   bbox_diam = sqrt ( (x[1]-x[0])*(x[1]-x[0]) +
                      (y[1]-y[0])*(y[1]-y[0]) +
                      (z[1]-z[0])*(z[1]-z[0]) );
   double sc = FaceShiftScale * bbox_diam;

   for (i = 0; i < nbe; 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
      }

      mesh -> GetBdrElementFace (i, &fn, &fo);
      RefG = GlobGeometryRefiner.Refine (mesh -> GetFaceBaseGeometry (fn),
                                         TimesToRefine);
      // di = GridF -> GetFaceValues (fn, 2, RefG->RefPts, values, pointmat);
      di = fo % 2;
      if (di == 1 && !mesh->FaceIsInterior(fn))
         di = 0;
      GridF -> GetFaceValues (fn, di, RefG->RefPts, values, pointmat);
      VecGridF -> GetFaceVectorValues (fn, di, RefG->RefPts,
                                       vec_vals, pointmat);

      if (ianim > 0)
         pointmat.Add (double(ianim)/ianimmax, vec_vals);

      ShrinkPoints(pointmat, i, fn, di);

      int *RG = &(RefG->RefGeoms[0]);
      double pts[][3] = { { pointmat(0,RG[0]), pointmat(1,RG[0]),
                            pointmat(2,RG[0]) },
                          { pointmat(0,RG[1]), pointmat(1,RG[1]),
                            pointmat(2,RG[1]) },
                          { pointmat(0,RG[2]), pointmat(1,RG[2]),
                            pointmat(2,RG[2]) } };
      double norm[3];
      Compute3DUnitNormal (pts[0], pts[1], pts[2], norm);
      if (di != 0 && sc != 0.0)
      {
         norm[0] = -norm[0];
         norm[1] = -norm[1];
         norm[2] = -norm[2];
      }

      if (drawmesh == 1)
      {
         Array<int> &REdges = RefG->RefEdges;
         glBegin (GL_LINES);
         for (k = 0; k < REdges.Size()/2; k++)
         {
            int *RE = &(REdges[2*k]);

            if (sc == 0.0)
            {
               for (j = 0; j < 2; j++)
                  glVertex3d (pointmat(0, RE[j]), pointmat(1, RE[j]),
                              pointmat(2, RE[j]));
            }
            else
            {
               for (j = 0; j < 2; j++)
               {
                  double val = sc * (values(RE[j]) - minv) / (maxv - minv);
                  glVertex3d (pointmat(0, RE[j])+val*norm[0],
                              pointmat(1, RE[j])+val*norm[1],
                              pointmat(2, RE[j])+val*norm[2]);
               }
            }
         }
         glEnd();
      }
      else if (drawmesh == 2)
      {
         double point[4][4];
         int sides;
         switch (mesh -> GetBdrElementType (i))
         {
         case Element::TRIANGLE:
            sides = 3;
            break;

         case Element::QUADRILATERAL:
         default:
            sides = 4;
            break;
         }
         for (k = 0; k < RefG->RefGeoms.Size()/sides; k++)
         {
            RG = &(RefG->RefGeoms[k*sides]);

            if (sc == 0.0)
            {
               for (j = 0; j < sides; j++)
               {
                  for (int ii = 0; ii < 3; ii++)
                     point[j][ii] = pointmat(ii, RG[j]);
                  point[j][3] = values(RG[j]);
               }
            }
            else
            {
               for (j = 0; j < sides; j++)
               {
                  double val = (values(RG[j]) - minv) / (maxv - minv);
                  val *= sc;
                  for (int ii = 0; ii < 3; ii++)
                     point[j][ii] = pointmat(ii, RG[j])+val*norm[ii];
                  point[j][3] = values(RG[j]);
               }
            }
            DrawPolygonLevelLines(point[0], sides, level, false);
         }
      }
   }
   glEndList();
}