• 主页

# 关于vtk HedgeHog算法的一个问题请教一下各位大佬

``````void CreateData(vtkStructuredGrid* sgrid)
{
int i, j, k, kOffset, jOffset, offset;
float x[3], v[3], rMin=0.5, rMax=1.0, deltaRad, deltaZ;
static int dims[3]={13,11,11};
sgrid->SetDimensions(dims);

// We also create the points and vectors. The points
// form a hemi-cylinder of data.
vtkSmartPointer<vtkFloatArray> vectors =
vtkSmartPointer<vtkFloatArray>::New();
vectors->SetNumberOfComponents(3);
vectors->SetNumberOfTuples(dims[0]*dims[1]*dims[2]);

vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
points->Allocate(dims[0]*dims[1]*dims[2]);

deltaZ = 2.0 / (dims[2]-1);
v[2]=0.0;
for ( k=0; k<dims[2]; k++)
{
x[2] = -1.0 + k*deltaZ;
kOffset = k * dims[0] * dims[1];
for (j=0; j<dims[1]; j++)
{
jOffset = j * dims[0];
for (i=0; i<dims[0]; i++)
{
v[0] = -x[1];
v[1] = x[0];
offset = i + jOffset + kOffset;
points->InsertPoint(offset,x);
vectors->InsertTuple(offset,v);
}
}
}
sgrid->SetPoints(points);

sgrid->GetPointData()->SetVectors(vectors);
}``````
...全文
232 点赞 收藏 5

5 条回复

xuzuning 2018年01月25日

xuzuning 2018年01月25日

C#

8.4w+

64.0w+

.NET技术 C#