当前位置: 首页>>代码示例>>C++>>正文


C++ Array::Elem方法代码示例

本文整理汇总了C++中Array::Elem方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::Elem方法的具体用法?C++ Array::Elem怎么用?C++ Array::Elem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Array的用法示例。


在下文中一共展示了Array::Elem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QickSortRec

void QickSortRec (const Array<double> & values,
		  Array<int> & order, 
		  int left, int right)
{
  int i, j;
  double midval;

  i = left;
  j = right;
  midval = values.Get(order.Get((i+j)/2));
  
  do
    {
      while (values.Get(order.Get(i)) < midval) i++;
      while (midval < values.Get(order.Get(j))) j--;
      
      if (i <= j)
	{
	  Swap (order.Elem(i), order.Elem(j));
	  i++; j--;
	}
    }
  while (i <= j);
  if (left < j) QickSortRec (values, order, left, j);
  if (i < right) QickSortRec (values, order, i, right);
}
开发者ID:OpenCMISS-Dependencies,项目名称:netgen,代码行数:26,代码来源:sort.cpp

示例2: ToPlain

void referencetransform :: ToPlain (const Array<Point3d> & p,
                                    Array<Point3d> & pp) const
{
  Vec3d v;
  int i;

  pp.SetSize (p.Size());
  for (i = 1; i <= p.Size(); i++)
    {
      v = p.Get(i) - rp;
      pp.Elem(i).X() = (ex_h * v);
      pp.Elem(i).Y() = (ey_h * v);
      pp.Elem(i).Z() = (ez_h * v);
    }
}
开发者ID:SeregaGomen,项目名称:qng,代码行数:15,代码来源:geom3d.cpp

示例3: Set

 void Set (const INDEX & ahash, const T & acont)
 {
   int pos;
   PositionCreate (ahash, pos);
   hash.Elem(pos) = ahash;
   cont.Elem(pos) = acont;
 }
开发者ID:Resistancerus,项目名称:Netgen,代码行数:7,代码来源:hashtabl.hpp

示例4: Sort

void Sort (const Array<double> & values,
	   Array<int> & order)
{
  int n = values.Size();
  int i, j;

  order.SetSize (n);

  for (i = 1; i <= n; i++)
    order.Elem(i) = i;
  for (i = 1; i <= n-1; i++)
    for (j = 1; j <= n-1; j++)
      if (values.Get(order.Elem(j)) > values.Get(order.Elem(j+1)))
	{
	  Swap (order.Elem(j), order.Elem(j+1));
	}
}
开发者ID:OpenCMISS-Dependencies,项目名称:netgen,代码行数:17,代码来源:sort.cpp

示例5: QickSort

void QickSort (const Array<double> & values,
	       Array<int> & order)
{
  int i, n = values.Size();
  order.SetSize (n);
  for (i = 1; i <= n; i++)
    order.Elem(i) = i;

  QickSortRec (values, order, 1, order.Size());
}
开发者ID:OpenCMISS-Dependencies,项目名称:netgen,代码行数:10,代码来源:sort.cpp

示例6: PositionCreate

  // returns 1, if new postion is created
  int PositionCreate (const INDEX_2 & ind, int & apos)
  {
    int i = HashValue (ind);
    if (hash.Get(i) == ind) 
      {
	apos = i;
	return 0;
      }
    if (hash.Get(i).I1() == invalid)
      {
	hash.Elem(i) = ind; 
	apos = i;
	return 1;
      }
    return PositionCreate2 (ind, apos);    
  }
开发者ID:Resistancerus,项目名称:Netgen,代码行数:17,代码来源:hashtabl.hpp

示例7: GetIntersecting

  void ADTree3M :: GetIntersecting (const float * bmin, 
				    const float * bmax,
				    Array<int> & pis) const
  {
    static Array<ADTreeNode3M*> stack(1000);
    static Array<int> stackdir(1000);
    ADTreeNode3M * node;
    int dir, i, stacks;

    stack.SetSize (1000);
    stackdir.SetSize(1000);
    pis.SetSize(0);

    stack.Elem(1) = root;
    stackdir.Elem(1) = 0;
    stacks = 1;

    while (stacks)
      {
	node = stack.Get(stacks);
	dir = stackdir.Get(stacks); 
	stacks--;

	int * hpi = node->pi;
	for (i = 0; i < ADTN_SIZE; i++)
	  if (hpi[i])
	    {
	      float * datai = &node->data[i][0];
	      if (datai[0] >= bmin[0] && datai[0] <= bmax[0] &&
		  datai[1] >= bmin[1] && datai[1] <= bmax[1] &&
		  datai[2] >= bmin[2] && datai[2] <= bmax[2])
	      
		pis.Append (node->pi[i]);
	    }


	int ndir = dir+1;
	if (ndir == 3)
	  ndir = 0;

	if (node->left && bmin[dir] <= node->sep)
	  {
	    stacks++;
	    stack.Elem(stacks) = node->left;
	    stackdir.Elem(stacks) = ndir;
	  }
	if (node->right && bmax[dir] >= node->sep)
	  {
	    stacks++;
	    stack.Elem(stacks) = node->right;
	    stackdir.Elem(stacks) = ndir;
	  }
      }
  }
开发者ID:11235813,项目名称:netgen-csg2d,代码行数:54,代码来源:adtree.cpp

示例8: SetPrimitiveData

void Brick :: SetPrimitiveData (Array<double> & coeffs)
{
  p1(0) = coeffs.Elem(1);
  p1(1) = coeffs.Elem(2);
  p1(2) = coeffs.Elem(3);

  p2(0) = coeffs.Elem(4);
  p2(1) = coeffs.Elem(5);
  p2(2) = coeffs.Elem(6);

  p3(0) = coeffs.Elem(7);
  p3(1) = coeffs.Elem(8);
  p3(2) = coeffs.Elem(9);

  p4(0) = coeffs.Elem(10);
  p4(1) = coeffs.Elem(11);
  p4(2) = coeffs.Elem(12);

  CalcData();
}
开发者ID:GuMiner,项目名称:Surface-Netgen-Fork,代码行数:20,代码来源:brick.cpp

示例9:

void Brick :: 
GetPrimitiveData (const char *& classname, Array<double> & coeffs) const
{
  classname = "brick";
  coeffs.SetSize(12);
  coeffs.Elem(1) = p1(0);
  coeffs.Elem(2) = p1(1);
  coeffs.Elem(3) = p1(2);

  coeffs.Elem(4) = p2(0);
  coeffs.Elem(5) = p2(1);
  coeffs.Elem(6) = p2(2);

  coeffs.Elem(7) = p3(0);
  coeffs.Elem(8) = p3(1);
  coeffs.Elem(9) = p3(2);

  coeffs.Elem(10) = p4(0);
  coeffs.Elem(11) = p4(1);
  coeffs.Elem(12) = p4(2);
}
开发者ID:GuMiner,项目名称:Surface-Netgen-Fork,代码行数:21,代码来源:brick.cpp

示例10: SetData

 inline void SetData (int pos, const T & acont)
 {
   cont.Elem(pos) = acont;
 }
开发者ID:Resistancerus,项目名称:Netgen,代码行数:4,代码来源:hashtabl.hpp

示例11: GetTriangle

 STLTriangle & GetTriangle (int nr) { return trias.Elem(nr); }
开发者ID:liangcheng,项目名称:netgen,代码行数:1,代码来源:stltopology.hpp

示例12: GetTopEdge

 STLTopEdge & GetTopEdge (int nr)  { return topedges.Elem(nr); }
开发者ID:liangcheng,项目名称:netgen,代码行数:1,代码来源:stltopology.hpp

示例13: GenerateBoundaryLayer

/*
    Philippose Rajan - 11 June 2009
    
    Added an initial experimental function for 
    generating prismatic boundary layers on 
    a given set of surfaces.
    
    The number of layers, height of the first layer 
    and the growth / shrink factor can be specified 
    by the user

    Currently, the layer height is calculated using:
    height = h_first_layer * (growth_factor^(num_layers - 1))
*/
   void GenerateBoundaryLayer (Mesh & mesh, MeshingParameters & mp)
   {
      int i, j;

      ofstream dbg("BndLayerDebug.log");

      // Angle between a surface element and a growth-vector below which 
      // a prism is project onto that surface as a quad
      // (in degrees)
      double angleThreshold = 5.0;
      
      cout << "Generate Prismatic Boundary Layers (Experimental)...." << endl;

      // Use an array to support creation of boundary 
      // layers for multiple surfaces in the future...
      Array<int> surfid;
      int surfinp = 0;
      int prismlayers = 1;
      double hfirst = 0.01;
      double growthfactor = 1.0;

      // Monitor and print out the number of prism and quad elements 
      // added to the mesh
      int numprisms = 0;
      int numquads = 0;

      while(surfinp >= 0)
      {
         cout << "Enter Surface ID (-1 to end list): ";
         cin >> surfinp;
         if(surfinp >= 0) surfid.Append(surfinp);
      }

      cout << "Number of surfaces entered = " << surfid.Size() << endl; 
      cout << "Selected surfaces are:" << endl;

      for(i = 1; i <= surfid.Size(); i++)
      {
         cout << "Surface " << i << ": " << surfid.Elem(i) << endl;
      }
      
      cout << endl << "Enter number of prism layers: ";
      cin >> prismlayers;
      if(prismlayers < 1) prismlayers = 1;

      cout << "Enter height of first layer: ";
      cin >> hfirst;
      if(hfirst <= 0.0) hfirst = 0.01;

      cout << "Enter layer growth / shrink factor: ";
      cin >> growthfactor;
      if(growthfactor <= 0.0) growthfactor = 0.5;

      cout << "Old NP: " << mesh.GetNP() << endl;
      cout << "Old NSE: " << mesh.GetNSE() << endl;
      
      for(int layer = prismlayers; layer >= 1; layer--)
      {
         cout << "Generating layer: " << layer << endl;

         const MeshTopology& meshtopo = mesh.GetTopology();
         const_cast<MeshTopology &> (meshtopo).SetBuildEdges(true);
         const_cast<MeshTopology &> (meshtopo).SetBuildFaces(true);
         const_cast<MeshTopology &> (meshtopo).Update();

         double layerht = hfirst;

         if(growthfactor == 1)
         {
            layerht = layer * hfirst;
         }
         else
         {
            layerht = hfirst*(pow(growthfactor,(layer+1)) - 1)/(growthfactor - 1);
         }

         cout << "Layer Height = " << layerht << endl;

         // Need to store the old number of points and 
         // surface elements because there are new points and 
         // surface elements being added during the process
         int np = mesh.GetNP();
         int nse = mesh.GetNSE();

         // Safety measure to ensure no issues with mesh 
         // consistency
//.........这里部分代码省略.........
开发者ID:Resistancerus,项目名称:Netgen,代码行数:101,代码来源:boundarylayer.cpp

示例14: reg

  int AdFront2 :: GetLocals (int baselineindex,
			     Array<Point3d> & locpoints,
			     Array<MultiPointGeomInfo> & pgeominfo,
			     Array<INDEX_2> & loclines,   // local index
			     Array<INDEX> & pindex,
			     Array<INDEX> & lindex,
			     double xh)
  {
    static int timer = NgProfiler::CreateTimer ("adfront2::GetLocals");
    NgProfiler::RegionTimer reg (timer);


    int pstind;
    Point<3>  midp, p0;

    pstind = lines[baselineindex].L().I1();
    p0 = points[pstind].P();

    loclines.Append(lines[baselineindex].L());
    lindex.Append(baselineindex);  

    ArrayMem<int, 1000> nearlines(0);
    ArrayMem<int, 1000> nearpoints(0);

    // dominating costs !!
    linesearchtree.GetIntersecting (p0 - Vec3d(xh, xh, xh),
				    p0 + Vec3d(xh, xh, xh),
				    nearlines);

    pointsearchtree.GetIntersecting (p0 - Vec3d(xh, xh, xh),
                                     p0 + Vec3d(xh, xh, xh),
                                     nearpoints);
    
    for (int ii = 0; ii < nearlines.Size(); ii++)
      {
	int i = nearlines[ii];
	if (lines[i].Valid() && i != baselineindex) 
	  {
            loclines.Append(lines[i].L());
            lindex.Append(i);
	  }
      }

    // static Array<int> invpindex;
    invpindex.SetSize (points.Size()); 
    // invpindex = -1;
    for (int i = 0; i < nearpoints.Size(); i++)
      invpindex[nearpoints[i]] = -1;

    for (int i = 0; i < loclines.Size(); i++)
      {
	invpindex[loclines[i].I1()] = 0;
	invpindex[loclines[i].I2()] = 0;
      }


    for (int i = 0; i < loclines.Size(); i++)
      {
	for (int j = 0; j < 2; j++)
	  {
	    int pi = loclines[i][j];
	    if (invpindex[pi] == 0)
	      {
		pindex.Append (pi);
		invpindex[pi] = pindex.Size();
		loclines[i][j] = locpoints.Append (points[pi].P());
	      }
	    else
	      loclines[i][j] = invpindex[pi];
	  }
      }


    // double xh2 = xh*xh;
    for (int ii = 0; ii < nearpoints.Size(); ii++)
      {
        int i = nearpoints[ii];
	if (points[i].Valid() && 
	    points[i].OnSurface() &&
	    // Dist2 (points.Get(i).P(), p0) <= xh2 &&
	    invpindex[i] <= 0)
	  {
	    invpindex[i] = locpoints.Append (points[i].P());
	    pindex.Append(i);
	  }
      }
    /*
    double xh2 = xh*xh;
    for (i = 1; i <= points.Size(); i++)
      {
	if (points.Get(i).Valid() && 
	    points.Get(i).OnSurface() &&
	    Dist2 (points.Get(i).P(), p0) <= xh2 &&
	    invpindex.Get(i) <= 0)
	  {
	    invpindex.Elem(i) =
	      locpoints.Append (points.Get(i).P());
	    pindex.Append(i);
	  }
      }
//.........这里部分代码省略.........
开发者ID:Resistancerus,项目名称:Netgen,代码行数:101,代码来源:adfront2.cpp

示例15: SetPoint

 void SetPoint(int nr, const Point<3> & p) { points.Elem(nr) = p; }
开发者ID:liangcheng,项目名称:netgen,代码行数:1,代码来源:stltopology.hpp


注:本文中的Array::Elem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。