本文整理汇总了C++中teuchos::Array::length方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::length方法的具体用法?C++ Array::length怎么用?C++ Array::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::Array
的用法示例。
在下文中一共展示了Array::length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scNames
// =============================================================================
void
VIO::Image::Writer::Abstract::
setImageData ( const Epetra_MultiVector & x,
const Teuchos::Tuple<unsigned int,2> & Nx,
const Point & h,
const Teuchos::Array<int> & p,
const Teuchos::Array<std::string> & scalarsNames
)
{
int numVecs = x.NumVectors();
int numPoints = ( Nx[0]+1 ) * ( Nx[1]+1 );
// get scalarsNames, and insert default names if empty
Teuchos::Array<std::string> scNames ( scalarsNames );
if ( scNames.empty() )
{
scNames.resize ( numVecs );
for ( int vec=0; vec<numVecs; vec++ )
scNames[vec] = "x" + EpetraExt::toString ( vec );
}
// cast into vtkImageData
vtkSmartPointer<vtkImageData> imageData =
dynamic_cast<vtkImageData*> ( vtkDataSet_.GetPointer() );
TEUCHOS_ASSERT_INEQUALITY( 0, !=, imageData );
// set other image data
imageData->SetDimensions ( Nx[0]+1, Nx[1]+1, 1 );
imageData->SetOrigin ( 0.0, 0.0, 0.0 );
imageData->SetSpacing ( h[0], h[1], 0.0 );
// fill the scalar field
vtkSmartPointer<vtkDoubleArray> scalars =
vtkSmartPointer<vtkDoubleArray>::New();
bool isScrambled = !p.empty();
if ( isScrambled )
{
TEUCHOS_ASSERT_EQUALITY ( numPoints, p.length() );
addFieldData ( p, "p" );
}
// fill the scalars vector and add it to imageData_
if ( isScrambled )
{
double dummy = 0.0;
for ( int vec=0; vec<numVecs; vec++ )
{
scalars->SetName ( scNames[vec].c_str() );
for ( int k=0; k<numPoints; k++ )
scalars->InsertNextValue ( p[k]>=0 ? x[vec][p[k]] : dummy );
imageData->GetPointData()->AddArray ( scalars );
}
}
else
for ( int vec=0; vec<numVecs; vec++ )
{
scalars->SetName ( scNames[vec].c_str() );
for ( int k=0; k<numPoints; k++ )
scalars->InsertNextValue ( x[vec][k] );
imageData->GetPointData()->AddArray ( scalars );
}
return;
}