Пример #1
0
//-----------------------------------------------------------------------------
// Returns the number of faces in the face set
//-----------------------------------------------------------------------------
int CDmeFaceSet::GetFaceCount() const
{
	int nFaceCount = 0;
	int nVertexCount = 0;

	const int nIndexCount = NumIndices();
	for ( int i = 0; i < nIndexCount; ++i )
	{
		if ( GetIndex( i ) < 0 )
		{
			if ( nVertexCount > 0 )
			{
				++nFaceCount;
			}
			nVertexCount = 0;
			continue;
		}

		++nVertexCount;
	}

	if ( nVertexCount > 0 )
	{
		++nFaceCount;
	}

	return nFaceCount;
}
Пример #2
0
//******************************************************************************
//Name:  ResizeField                                                           *
//                                                                             *
//Purpose:  set the number of grid points in the field                         *
//                                                                             *
//Takes: a pointer to an int array                                             *
//******************************************************************************
void field::ResizeField(int *num_grid_pts)
{
   int n, *r, i;

   n = NumIndices();
   r = Ranges();

   for(i = 0; i < 3; i++) r[i] = num_grid_pts[i];

   Resize(n, r);

   delete [] r;
}
Пример #3
0
//******************************************************************************
//Name:  GetTensor                                                             *
//                                                                             *
//Purpose:  get the tensor portion of the field given the position             *
//                                                                             *
//Takes: position stored as a tensor                                           *
//******************************************************************************
tensor  field::GetTensor(int *indices)
{
   tensor temp;
   int n, *r, new_n, *new_r;
   int i, j, dummy;

   //Get the total number of indices and ranges of the field
   n = NumIndices();
   r = Ranges();

   //Determine the number of indices on the temp tensor
   new_n = n  - 3;

   //Make a new array for resizing temp
   new_r = new int[new_n];

   //Pack the new_r array with the
   for( i = 0; i < new_n; i++ )
    {
      new_r[i] = r[i + 3];
    }

   //Resize the temp tensor
   temp.Resize(new_n, new_r);

   //Let the r array do double duty and pack the first three elements with the
   //values in the indices array
   for( i = 0; i < 3; i++) r[i] = indices[i];

   //now pack temp with the components of the tensor portion of the field
   for( i = 0; i < temp.p->product; i++)
	 {
      //Let the last indices of the r array hold the
      //index structure for the temp tensor
      dummy = 0;
      for( j = 0; j < new_n; j++)
       {
         r[j + 3] = (i - i%temp.p->scales[j] - dummy)/temp.p->scales[j];
         dummy += r[j + 3] * temp.p->scales[j];
       }

       temp.p->m[i] = Val(r);
    }

  //Clean up
  delete [] r;
  delete [] new_r;

  //Return the tensor
  return temp;
}
Пример #4
0
bool SORE_Graphics::GraphicsArray::HasRoomFor(size_t numIndices, size_t numVertices) const
{
    return !(NumIndices() + numIndices > std::numeric_limits<unsigned short>::max() ||
             NumVertices() + numVertices > std::numeric_limits<unsigned short>::max());
}