- // Traverse all Input points, transforming Source points and copying
- // point attributes.
- //
- ptIncr=0;
- for (inPtId=0; inPtId < numPts; inPtId++)
- {
- scalex = scaley = scalez = 1.0;
- if ( ! (inPtId % 10000) )
- {
- this->UpdateProgress ((double)inPtId/numPts);
- if (this->GetAbortExecute())
- {
- break;
- }
- }
-
- // Get the scalar and vector data
- if ( inSScalars )
- {
- s = inSScalars->GetComponent(inPtId, 0);
- if ( this->ScaleMode == VTK_SCALE_BY_SCALAR ||
- this->ScaleMode == VTK_DATA_SCALING_OFF )
- {
- scalex = scaley = scalez = s;
- }
- }
-
- if ( haveVectors )
- {
- if ( this->VectorMode == VTK_USE_NORMAL )
- {
- inNormals->GetTuple(inPtId, v);
- }
- else
- {
- inVectors->GetTuple(inPtId, v);
- }
-
- vMag = vtkMath::Norm(v);
- if ( this->ScaleMode == VTK_SCALE_BY_VECTORCOMPONENTS )
- {
- scalex = v[0];
- scaley = v[1];
- scalez = v[2];
- }
- else if ( this->ScaleMode == VTK_SCALE_BY_VECTOR )
- {
- scalex = scaley = scalez = vMag;
- }
- }
-
- // Clamp data scale if enabled
- if ( this->Clamping )
- {
- scalex = (scalex < this->Range[0] ? this->Range[0] :
- (scalex > this->Range[1] ? this->Range[1] : scalex));
- scalex = (scalex - this->Range[0]) / den;
- scaley = (scaley < this->Range[0] ? this->Range[0] :
- (scaley > this->Range[1] ? this->Range[1] : scaley));
- scaley = (scaley - this->Range[0]) / den;
- scalez = (scalez < this->Range[0] ? this->Range[0] :
- (scalez > this->Range[1] ? this->Range[1] : scalez));
- scalez = (scalez - this->Range[0]) / den;
- }
-
- // Compute index into table of glyphs
- if ( this->IndexMode == VTK_INDEXING_OFF )
- {
- index = 0;
- }
- else
- {
- if ( this->IndexMode == VTK_INDEXING_BY_SCALAR )
- {
- value = s;
- }
- else
- {
- value = vMag;
- }
-
- index = (int) ((double)(value - this->Range[0]) * numberOfSources / den);
- index = (index < 0 ? 0 :
- (index >= numberOfSources ? (numberOfSources-1) : index));
-
- source = this->GetSource(index, inputVector[1]);
- if ( source != NULL )
- {
- sourcePts = source->GetPoints();
- sourceNormals = source->GetPointData()->GetNormals();
- numSourcePts = sourcePts->GetNumberOfPoints();
- numSourceCells = source->GetNumberOfCells();
- }
- }
-
- // Make sure we're not indexing into empty glyph
- if ( this->GetSource(index, inputVector[1]) == NULL )
- {
- continue;
- }
-
- // Check ghost points.
- // If we are processing a piece, we do not want to duplicate
- // glyphs on the borders. The corrct check here is:
- // ghostLevel > 0. I am leaving this over glyphing here because
- // it make a nice example (sphereGhost.tcl) to show the
- // point ghost levels with the glyph filter. I am not certain
- // of the usefullness of point ghost levels over 1, but I will have
- // to think about it.
- if (inGhostLevels && inGhostLevels[inPtId] > requestedGhostLevel)
- {
- continue;
- }
-
- if (!this->IsPointVisible(input, inPtId))
- {
- continue;
- }
-
- // Now begin copying/transforming glyph
- trans->Identity();
-
- // Copy all topology (transformation independent)
- for (cellId=0; cellId < numSourceCells; cellId++)
- {
- cell = this->GetSource(index, inputVector[1])->GetCell(cellId);
- cellPts = cell->GetPointIds();
- npts = cellPts->GetNumberOfIds();
- for (pts->Reset(), i=0; i < npts; i++)
- {
- pts->InsertId(i,cellPts->GetId(i) + ptIncr);
- }
- output->InsertNextCell(cell->GetCellType(),pts);
- }
-
- // translate Source to Input point
- input->GetPoint(inPtId, x);
-
- //projection on the plane orthogonale to the camera
- trans->Scale(mOrientation[0],mOrientation[1],mOrientation[2]);
-
- trans->Translate(x[0], x[1], x[2]);
-
- if ( haveVectors )
- {
- // Copy Input vector
- for (i=0; i < numSourcePts; i++)
- {
- newVectors->InsertTuple(i+ptIncr, v);
- }
- if (this->Orient && (vMag > 0.0))
- {
- // if there is no y or z component
- if ( v[1] == 0.0 && v[2] == 0.0 )
- {
- if (v[0] < 0) //just flip x if we need to
- {
- trans->RotateWXYZ(180.0,0,1,0);
- }
- }
- else
- {
- vNew[0] = (v[0]+vMag) / 2.0;
- vNew[1] = v[1] / 2.0;
- vNew[2] = v[2] / 2.0;
- trans->RotateWXYZ((double)180.0,vNew[0],vNew[1],vNew[2]);
- }
- }
- }
-
- if (haveTCoords)
- {
- for (i = 0; i < numSourcePts; i++)
- {
- sourceTCoords->GetTuple(i, tc);
- newTCoords->InsertTuple(i+ptIncr, tc);
- }
- }
-
- // determine scale factor from scalars if appropriate
- // Copy scalar value
- if (inSScalars && (this->ColorMode == VTK_COLOR_BY_SCALE))
- {
- for (i=0; i < numSourcePts; i++)
- {
- newScalars->InsertTuple(i+ptIncr, &scalex); // = scaley = scalez
- }
- }
- else if (inCScalars && (this->ColorMode == VTK_COLOR_BY_SCALAR))
- {
- for (i=0; i < numSourcePts; i++)
- {
- outputPD->CopyTuple(inCScalars, newScalars, inPtId, ptIncr+i);
- }
- }
- if (haveVectors && this->ColorMode == VTK_COLOR_BY_VECTOR)
- {
- double color = 1;
- for (i=0; i < numSourcePts; i++)
- {
- newScalars->InsertTuple(i+ptIncr, &color);
- }
- }
-
- // scale data if appropriate
- if ( this->Scaling )
- {
- if ( this->ScaleMode == VTK_DATA_SCALING_OFF )
- {
- scalex = scaley = scalez = this->ScaleFactor;
- }
- else
- {
- scalex *= this->ScaleFactor;
- scaley *= this->ScaleFactor;
- scalez *= this->ScaleFactor;
- }
-
- if ( scalex == 0.0 )
- {
- scalex = 1.0e-10;
- }
- if ( scaley == 0.0 )
- {
- scaley = 1.0e-10;
- }
- if ( scalez == 0.0 )
- {
- scalez = 1.0e-10;
- }
- trans->Scale(scalex,scaley,scalez);
- }
- // multiply points and normals by resulting matrix
- trans->TransformPoints(sourcePts,newPts);
-
- if ( haveNormals )
- {
- trans->TransformNormals(sourceNormals,newNormals);
- }