<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
I have the problem mentioned in the subject:<br>
My source - is the collection of points (particles) and there are
several vector fields associated to them. I want to render the
points (as small spheres- vtkGlyph3d is used here) and the vector
fields associated to them. Say, that there are 2 vector fields, one
will be rendered as green arrows, the second - as red arrows. I know
how to connect the first field. But I don't know how to do the same
with the second.<br>
I wrote a the new class for my data source, here is the way I add
vector fields to them:<br>
<br>
int cVtkMoleculeModelSource::RequestData(<br>
vtkInformation *vtkNotUsed(request),<br>
vtkInformationVector **vtkNotUsed(inputVector),<br>
vtkInformationVector *outputVector)<br>
{<br>
<br>
vtkDebugMacro("Molecule Source Executing");<br>
<br>
vtkInformation *outInfo =
outputVector->GetInformationObject(0);<br>
<br>
vtkPolyData *output =
vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));<br>
<br>
size_t numPts = mMolecularModel->NumOfMolecules() ;<br>
<br>
vtkPoints* newPoints = vtkPoints::New();<br>
newPoints->SetDataTypeToDouble(); //used later during
transformation<br>
newPoints->Allocate(numPts);<br>
<br>
mForces = vtkDoubleArray::New();<br>
mForces->SetNumberOfComponents(3); //used later during
transformation<br>
mForces->SetName("Resultant_F") ;<br>
<br>
mLoads= vtkDoubleArray::New();<br>
mLoads->SetNumberOfComponents(3); //used later during
transformation<br>
mLoads->SetName("External_F") ;<br>
<br>
<br>
vtkCellArray* newVerts = vtkCellArray::New();<br>
<br>
for( size_t i = 0; i < numPts; ++i)<br>
{<br>
const GLW::Molecule & mol =
mMolecularModel->getMolecule(i) ;<br>
const GLW::Point & x = mol.getCoord() ;<br>
const GLW::Point f =
mMolecularModel->getResultantForce(i) ;<br>
const GLW::Point L = mol.getForce();<br>
<br>
vtkIdType id = newPoints->InsertNextPoint(x[0],x[1], x[2]
) ;<br>
newVerts->InsertNextCell(1,&id ) ;<br>
//mNodeMap[node.GetNumber()] = id ;<br>
<br>
mForces->InsertNextTuple3(f[0],f[1],f[2]) ;<br>
mLoads->InsertNextTuple3(L[0],L[1],L[2]) ;<br>
}<br>
<br>
output->SetPoints(newPoints);<br>
// TODO: what are verts? Are they necessary ?<br>
output->SetVerts(newVerts) ;<br>
<br>
output->GetPointData()->SetVectors(mForces) ;<br>
output->GetPointData()->AddArray(mLoads) ; ;<br>
<br>
<br>
newPoints->Delete();<br>
newVerts->Delete() ;<br>
<br>
return 1 ;<br>
<br>
}<br>
<br>
Note the lines:<br>
output->GetPointData()->SetVectors(mForces) ;<br>
output->GetPointData()->AddArray(mLoads) ; <br>
What I understand from the documentations is, that we have 2 vector
fields added to the data set, but one of them is treated in a
special way - mForces. And this is the field, which will be rendered
by arrows, when this source will be set as input to the vtkGlyph3d
object, and calling the vtkGlyph3D::SetVectorModeToUseVector()
function. But I want to have another vtkGlyph3d object
(simultaneously), but connected to mLoads field ? How to achieve
this ?<br>
One of my first thoughts is to write a filter wich takes the second
vector field associated whith input and calls
output->GetPointData()->SetVectors(input->GetPointData()->GetArray(1)<br>
<br>
Does it looks reasonable ? Or perhaps there is already a simpler way
?<br>
<br>
Regards, <br>
M.H.<br>
<table class="memname">
<tbody>
<tr>
<td class="memname"><br>
</td>
<td><br>
</td>
<td class="paramname"><br>
</td>
<td><br>
</td>
</tr>
</tbody>
</table>
</body>
</html>