本文整理汇总了C++中vtkSmartPointer::GetCellData方法的典型用法代码示例。如果您正苦于以下问题:C++ vtkSmartPointer::GetCellData方法的具体用法?C++ vtkSmartPointer::GetCellData怎么用?C++ vtkSmartPointer::GetCellData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtkSmartPointer
的用法示例。
在下文中一共展示了vtkSmartPointer::GetCellData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
vtkSmartPointer<vtkArrayType> FlowAnalysis::vtkMakeArray(const vtkSmartPointer<vtkUniformGrid>& grid, const string& name, size_t numComponents, bool fillZero){
auto arr=vtkSmartPointer<vtkArrayType>::New();
arr->SetNumberOfComponents(numComponents);
arr->SetNumberOfTuples(boxCells.prod());
arr->SetName(name.c_str());
if(cellData) grid->GetCellData()->AddArray(arr);
else grid->GetPointData()->AddArray(arr);
if(fillZero){ for(int _i=0; _i<(int)numComponents; _i++) arr->FillComponent(_i,0.); }
return arr;
}
示例2: dumpMeshSpecificData
void VTKEulerMeshSnapshotWriter::dumpMeshSpecificData(EulerMesh* mesh, vtkSmartPointer<vtkStructuredGrid>& grid, vtkSmartPointer<vtkPoints>& points) const
{
auto nodeDims = mesh->getNodeDimensions();
auto cellDims = mesh->getDimensions();
auto cellStatus = vtkSmartPointer<vtkIntArray>::New();
cellStatus->SetName("cellStatus");
auto cellError = vtkSmartPointer<vtkIntArray>::New();
cellError->SetName("cellError");
for (uint k = 0; k < nodeDims.z; k++)
for (uint j = 0; j < nodeDims.y; j++)
for (uint i = 0; i < nodeDims.x; i++)
{
auto& node = mesh->getNodeByEulerMeshIndex(vector3u(i, j, k));
points->InsertNextPoint(node.coords.x, node.coords.y, node.coords.z);
}
for (uint k = 0; k < cellDims.z; k++)
for (uint j = 0; j < cellDims.y; j++)
for (uint i = 0; i < cellDims.x; i++)
{
cellStatus->InsertNextValue(mesh->getCellStatus(vector3u(i, j, k)));
char flag = 0;
for (uint p = 0; p <= 1; p++)
for (uint q = 0; q <= 1; q++)
for (uint s = 0; s <= 1; s++)
if ((flag = mesh->getNodeByEulerMeshIndex(vector3u(i+p, j+q, k+s)).getErrorFlags()))
break;
cellError->InsertNextValue(flag);
}
grid->GetCellData()->AddArray(cellStatus);
grid->GetCellData()->AddArray(cellError);
grid->SetDimensions(nodeDims.x, nodeDims.y, nodeDims.z);
}
示例3: memcpy
void
pcl::io::pointCloudTovtkPolyData(const pcl::PCLPointCloud2Ptr& cloud, vtkSmartPointer<vtkPolyData>& poly_data)
{
if (!poly_data.GetPointer())
poly_data = vtkSmartPointer<vtkPolyData>::New (); // OR poly_data->Reset();
// Add Points
size_t x_idx = pcl::getFieldIndex (*cloud, std::string ("x") );
vtkSmartPointer<vtkPoints> cloud_points = vtkSmartPointer<vtkPoints>::New ();
vtkSmartPointer<vtkCellArray> cloud_vertices = vtkSmartPointer<vtkCellArray>::New ();
vtkIdType pid[1];
for (size_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++)
{
float point[3];
int point_offset = (int (point_idx) * cloud->point_step);
int offset = point_offset + cloud->fields[x_idx].offset;
memcpy (&point, &cloud->data[offset], sizeof (float)*3);
pid[0] = cloud_points->InsertNextPoint (point);
cloud_vertices->InsertNextCell (1, pid);
}
//set the points and vertices we created as the geometry and topology of the polydata
poly_data->SetPoints (cloud_points);
poly_data->SetVerts (cloud_vertices);
// Add RGB
int rgb_idx = pcl::getFieldIndex (*cloud, "rgb");
if (rgb_idx != -1)
{
//std::cout << "Adding rgb" << std::endl;
vtkSmartPointer<vtkUnsignedCharArray> colors = vtkSmartPointer<vtkUnsignedCharArray>::New ();
colors->SetNumberOfComponents (3);
colors->SetName ("rgb");
for (size_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++)
{
unsigned char bgr[3];
int point_offset = (int (point_idx) * cloud->point_step);
int offset = point_offset + cloud->fields[rgb_idx].offset;
memcpy (&bgr, &cloud->data[offset], sizeof (unsigned char)*3);
colors->InsertNextTuple3(bgr[2], bgr[1], bgr[0]);
}
poly_data->GetCellData()->SetScalars(colors);
}
// Add Intensity
int intensity_idx = pcl::getFieldIndex (*cloud, "intensity");
if (intensity_idx != -1)
{
//std::cout << "Adding intensity" << std::endl;
vtkSmartPointer<vtkFloatArray> cloud_intensity = vtkSmartPointer<vtkFloatArray>::New ();
cloud_intensity->SetNumberOfComponents (1);
cloud_intensity->SetName("intensity");
for (size_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++)
{
float intensity;
int point_offset = (int (point_idx) * cloud->point_step);
int offset = point_offset + cloud->fields[intensity_idx].offset;
memcpy (&intensity, &cloud->data[offset], sizeof(float));
cloud_intensity->InsertNextValue(intensity);
}
poly_data->GetCellData()->AddArray(cloud_intensity);
if (rgb_idx == -1)
poly_data->GetCellData()->SetActiveAttribute("intensity", vtkDataSetAttributes::SCALARS);
}
// Add Normals
int normal_x_idx = pcl::getFieldIndex (*cloud, std::string ("normal_x") );
if (normal_x_idx != -1)
{
//std::cout << "Adding normals" << std::endl;
vtkSmartPointer<vtkFloatArray> normals = vtkSmartPointer<vtkFloatArray>::New();
normals->SetNumberOfComponents(3); //3d normals (ie x,y,z)
normals->SetName("normals");
for (size_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++)
{
float normal[3];
int point_offset = (int (point_idx) * cloud->point_step);
int offset = point_offset + cloud->fields[normal_x_idx].offset;
memcpy (&normal, &cloud->data[offset], sizeof (float)*3);
normals->InsertNextTuple(normal);
}
poly_data->GetCellData()->SetNormals(normals);
//poly_data->GetCellData()->SetActiveAttribute("normals", vtkDataSetAttributes::SCALARS);
//.........这里部分代码省略.........
示例4: mtrx
//keyword "cellvars" in OOFEM input file
void
VTKXMLExportModule :: exportCellVarAs(InternalStateType type, int region,
#ifdef __VTK_MODULE
vtkSmartPointer<vtkUnstructuredGrid> &stream,
#else
FILE *stream,
#endif
TimeStep *tStep)
{
Domain *d = emodel->giveDomain(1);
int ielem, nelem = d->giveNumberOfElements();
int pos;
Element *elem;
FloatMatrix mtrx(3, 3);
IntegrationRule *iRule;
GaussPoint *gp;
FloatArray answer, temp;
double gptot;
int ncomponents = 1;
#ifdef __VTK_MODULE
vtkSmartPointer<vtkDoubleArray> cellVarsArray = vtkSmartPointer<vtkDoubleArray>::New();
cellVarsArray->SetName(__InternalStateTypeToString(type));
#endif
switch ( type ) {
case IST_MaterialNumber:
case IST_ElementNumber:
case IST_Pressure:
// if it wasn't for IST_Pressure,
#ifdef __VTK_MODULE
cellVarsArray->SetNumberOfComponents(1);
cellVarsArray->SetNumberOfTuples(nelem);
#else
fprintf( stream, "<DataArray type=\"Float64\" Name=\"%s\" format=\"ascii\">\n", __InternalStateTypeToString(type) );
#endif
for ( ielem = 1; ielem <= nelem; ielem++ ) {
elem = d->giveElement(ielem);
if ( (( region > 0 ) && ( this->smoother->giveElementVirtualRegionNumber(ielem) != region ))
|| this->isElementComposite(elem) || !elem-> isActivated(tStep) ) { // composite cells exported individually
continue;
}
#ifdef __PARALLEL_MODE
if ( elem->giveParallelMode() != Element_local ) {
continue;
}
#endif
if ( type == IST_MaterialNumber ) {
#ifdef __VTK_MODULE
cellVarsArray->SetTuple1(ielem-1, elem->giveMaterial()->giveNumber() ); // Should be integer..
#else
fprintf( stream, "%d ", elem->giveMaterial()->giveNumber() );
#endif
} else if ( type == IST_ElementNumber ) {
#ifdef __VTK_MODULE
cellVarsArray->SetTuple1(ielem-1, elem->giveNumber() ); // Should be integer..
#else
fprintf( stream, "%d ", elem->giveNumber() );
#endif
} else if (type == IST_Pressure) { ///@todo Why this special treatment for pressure? / Mikael
if (elem->giveNumberOfInternalDofManagers() == 1) {
IntArray pmask(1); pmask.at(1) = P_f;
elem->giveInternalDofManager(1)->giveUnknownVector (answer, pmask,EID_ConservationEquation, VM_Total, tStep);
#ifdef __VTK_MODULE
cellVarsArray->SetTuple1(ielem-1, answer.at(1) ); // Should be integer..
#else
fprintf( stream, "%f ", answer.at(1) );
#endif
}
}
}
#ifdef __VTK_MODULE
stream->GetCellData()->SetActiveScalars(__InternalStateTypeToString(type));
stream->GetCellData()->SetScalars(cellVarsArray);
#endif
break;
case IST_MaterialOrientation_x:
case IST_MaterialOrientation_y:
case IST_MaterialOrientation_z:
#ifdef __VTK_MODULE
cellVarsArray->SetNumberOfComponents(3);
cellVarsArray->SetNumberOfTuples(nelem);
ncomponents = 3;
#else
fprintf( stream, "<DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"3\" format=\"ascii\">\n", __InternalStateTypeToString(type) );
#endif
if ( type == IST_MaterialOrientation_x ) {
pos = 1;
}
if ( type == IST_MaterialOrientation_y ) {
pos = 2;
}
if ( type == IST_MaterialOrientation_z ) {
//.........这里部分代码省略.........