70 #include "vtkImageData.h"
71 #include "vtkInformation.h"
72 #include "vtkInformationVector.h"
73 #include "vtkObjectFactory.h"
74 #include "vtkStreamingDemandDrivenPipeline.h"
75 #include "vtkPoints.h"
98 vtkInformation *vtkNotUsed(request),
99 vtkInformationVector **inputVector,
100 vtkInformationVector *outputVector)
105 vtkInformation *outInfo = outputVector->GetInformationObject(0);
110 vtkDataObject::SetPointDataActiveScalarInfo(outInfo, VTK_UNSIGNED_CHAR, 1);
117 this->Superclass::PrintSelf(os, indent);
120 os << indent <<
"PolyData: \n";
130 vtkImageData *inData,
132 vtkImageData *outData,
133 unsigned char *outPtr,
134 int id,
int slice,
double bbox[6])
136 int idx0, idx1, idx2;
137 vtkIdType in1Inc0, in1Inc1, in1Inc2;
138 vtkIdType outInc0, outInc1, outInc2;
139 unsigned long count = 0;
140 unsigned long target;
146 inData->GetContinuousIncrements(ext, in1Inc0, in1Inc1, in1Inc2);
147 outData->GetContinuousIncrements(ext, outInc0, outInc1, outInc2);
148 int num0 = ext[1] - ext[0] + 1;
149 int num1 = ext[3] - ext[2] + 1;
150 int num2 = ext[5] - ext[4] + 1;
152 double outVal =
self->GetInsidePixelValue();
154 vtkPoints *points =
self->GetPolyData()->GetPoints();
155 vtkIdType numP =
self->GetPolyData()->GetNumberOfPoints();
157 double *spacing = inData->GetSpacing();
158 double *origin = inData->GetOrigin();
160 target = (
unsigned long)( num2 * num1 / 50.0 );
164 for ( idx2 = ext[4]; idx2 < ext[4] + num2; ++idx2 )
166 for ( idx1 = ext[2]; !
self->AbortExecute && idx1 < ext[2] + num1; ++idx1 )
170 if ( !( count % target ) )
172 self->UpdateProgress( static_cast< double >( count )
173 / ( 50.0 * static_cast< double >( target ) ) );
178 for ( idx0 = ext[0]; idx0 < ext[0] + num0; ++idx0 )
183 double x = idx0 * spacing[0] + origin[0];
184 double y = idx1 * spacing[1] + origin[1];
186 if ( x >= bbox[0] && x <= bbox[1] && y >= bbox[2] && y <= bbox[3] )
190 for (
int i = 0; i < numP; i++ )
192 double p1[3], p2[3], dp1[2], dp2[2];
193 points->GetPoint (i, p1);
194 points->GetPoint ( ( i + 1 ) % numP, p2 );
202 angle +=
self->Angle2D (dp1, dp2);
204 if ( fabs (angle) >= vtkMath::Pi() ) { val = outVal; }
208 *outPtr = (
unsigned char)( val );
224 vtkImageData *inData, T *in1Ptr,
225 vtkImageData *outData,
unsigned char *outPtr,
226 int id,
int slice,
double bbox[6])
228 int idx0, idx1, idx2;
229 vtkIdType in1Inc0, in1Inc1, in1Inc2;
230 vtkIdType outInc0, outInc1, outInc2;
231 unsigned long count = 0;
232 unsigned long target;
238 inData->GetContinuousIncrements(ext, in1Inc0, in1Inc1, in1Inc2);
239 outData->GetContinuousIncrements(ext, outInc0, outInc1, outInc2);
240 int num0 = ext[1] - ext[0] + 1;
241 int num1 = ext[3] - ext[2] + 1;
242 int num2 = ext[5] - ext[4] + 1;
244 vtkPoints *points =
self->GetPolyData()->GetPoints();
245 vtkIdType numP =
self->GetPolyData()->GetNumberOfPoints();
247 double *spacing = inData->GetSpacing();
248 double *origin = inData->GetOrigin();
250 target = (
unsigned long)( num2 * num1 / 50.0 );
254 for ( idx2 = ext[4]; idx2 < ext[4] + num2; ++idx2 )
256 for ( idx1 = ext[2]; !
self->AbortExecute && idx1 < ext[2] + num1; ++idx1 )
260 if ( !( count % target ) )
262 self->UpdateProgress( static_cast< double >( count )
263 / ( 50.0 * static_cast< double >( target ) ) );
268 for ( idx0 = ext[0]; idx0 < ext[0] + num0; ++idx0 )
276 double x = idx0 * spacing[0] + origin[0];
277 double y = idx2 * spacing[2] + origin[2];
279 if ( x >= bbox[0] && x <= bbox[1] && y >= bbox[4] && y <= bbox[5] )
281 for (
int i = 0; i < numP; i++ )
283 double p1[3], p2[3], dp1[2], dp2[2];
284 points->GetPoint (i, p1);
285 points->GetPoint ( ( i + 1 ) % numP, p2 );
293 angle +=
self->Angle2D (dp1, dp2);
296 if ( fabs (angle) >= vtkMath::Pi() ) { val =
self->GetInsidePixelValue(); }
300 *outPtr = (
unsigned char)( val );
316 vtkImageData *inData, T *in1Ptr,
317 vtkImageData *outData,
unsigned char *outPtr,
318 int id,
int slice,
double bbox[6])
320 int num0, num1, num2;
321 int idx0, idx1, idx2;
322 vtkIdType in1Inc0, in1Inc1, in1Inc2;
323 vtkIdType outInc0, outInc1, outInc2;
324 unsigned long count = 0;
325 unsigned long target;
331 inData->GetContinuousIncrements(ext, in1Inc0, in1Inc1, in1Inc2);
332 outData->GetContinuousIncrements(ext, outInc0, outInc1, outInc2);
333 num0 = ext[1] - ext[0] + 1;
334 num1 = ext[3] - ext[2] + 1;
335 num2 = ext[5] - ext[4] + 1;
341 vtkPoints *points =
self->GetPolyData()->GetPoints();
342 vtkIdType numP =
self->GetPolyData()->GetNumberOfPoints();
344 double *spacing = inData->GetSpacing();
345 double *origin = inData->GetOrigin();
347 target = (
unsigned long)( num2 * num1 / 50.0 );
351 for ( idx2 = ext[4]; idx2 < ext[4] + num2; ++idx2 )
353 for ( idx1 = ext[2]; !
self->AbortExecute && idx1 < ext[2] + num1; ++idx1 )
357 if ( !( count % target ) )
359 self->UpdateProgress( static_cast< double >( count )
360 / ( 50.0 * static_cast< double >( target ) ) );
365 for ( idx0 = ext[0]; idx0 < ext[0] + num0; ++idx0 )
373 double x = idx1 * spacing[1] + origin[1];
374 double y = idx2 * spacing[2] + origin[2];
376 if ( x >= bbox[2] && x <= bbox[3] && y >= bbox[4] && y <= bbox[5] )
378 for (
int i = 0; i < numP; i++ )
380 double p1[3], p2[3], dp1[2], dp2[2];
381 points->GetPoint (i, p1);
382 points->GetPoint ( ( i + 1 ) % numP, p2 );
390 angle +=
self->Angle2D (dp1, dp2);
393 if ( fabs (angle) >= vtkMath::Pi() ) { val =
self->GetInsidePixelValue(); }
397 *outPtr = (
unsigned char)( val );
415 vtkInformation *vtkNotUsed(request),
416 vtkInformationVector **vtkNotUsed(inputVector),
417 vtkInformationVector *vtkNotUsed(outputVector),
418 vtkImageData ***inData,
419 vtkImageData **outData,
420 int outExt[6],
int id)
427 vtkErrorMacro(
"PolyData not set");
431 if (
PolyData->GetNumberOfPoints() < 3 )
433 vtkErrorMacro(
"PolyData must have more than 2 points.");
439 double *spacing = inData[0][0]->GetSpacing();
440 double *origin = inData[0][0]->GetOrigin();
442 vtkPoints *points =
PolyData->GetPoints();
444 points->GetPoint (0, pt);
448 vtkErrorMacro(
"Dont know extraction direction.");
453 slice =
static_cast< int >(
458 inPtr1 = inData[0][0]->GetScalarPointerForExtent(outExt);
459 outPtr = outData[0]->GetScalarPointerForExtent(outExt);
463 switch ( inData[0][0]->GetScalarType() )
466 inData[0][0], (VTK_TT *)( inPtr1 ),
467 outData[0], (
unsigned char *)( outPtr ),
id, slice,
BBox) );
469 vtkErrorMacro(<<
"Execute: Unknown ScalarType");
477 switch ( inData[0][0]->GetScalarType() )
480 inData[0][0], (VTK_TT *)( inPtr1 ),
481 outData[0], (
unsigned char *)( outPtr ),
id, slice,
BBox) );
483 vtkErrorMacro(<<
"Execute: Unknown ScalarType");
489 switch ( inData[0][0]->GetScalarType() )
492 inData[0][0], (VTK_TT *)( inPtr1 ),
493 outData[0], (
unsigned char *)( outPtr ),
id, slice,
BBox) );
495 vtkErrorMacro(<<
"Execute: Unknown ScalarType");
506 t1 = atan2 (dp1[0], dp1[1]);
507 t2 = atan2 (dp2[0], dp2[1]);
511 while ( dt > vtkMath::Pi() )
513 dt -= 2. *
static_cast< double >( vtkMath::Pi() );
515 while ( dt < -vtkMath::Pi() )
517 dt += 2. *
static_cast< double >( vtkMath::Pi() );
void vtkFillImageWithPolyDataExecuteX(vtkFillImageWithPolyData *self, int ext[6], vtkImageData *inData, T *in1Ptr, vtkImageData *outData, unsigned char *outPtr, int id, int slice, double bbox[6])
vtkCxxRevisionMacro(vtkFillImageWithPolyData,"$Revision: 490 $")
virtual void ThreadedRequestData(vtkInformation *vtkNotUsed(request), vtkInformationVector **vtkNotUsed(inputVector), vtkInformationVector *vtkNotUsed(outputVector), vtkImageData ***inData, vtkImageData **outData, int extent[6], int threadId)
void PrintSelf(ostream &os, vtkIndent indent)
vtkFillImageWithPolyData()
Constructor.
void vtkFillImageWithPolyDataExecuteY(vtkFillImageWithPolyData *self, int ext[6], vtkImageData *inData, T *in1Ptr, vtkImageData *outData, unsigned char *outPtr, int id, int slice, double bbox[6])
void vtkFillImageWithPolyDataExecuteZ(vtkFillImageWithPolyData *self, int ext[6], vtkImageData *inData, T *in1Ptr, vtkImageData *outData, unsigned char *outPtr, int id, int slice, double bbox[6])
~vtkFillImageWithPolyData()
Destructor.
double Angle2D(const double dp1[2], const double dp2[2])
Compute the angle between the 2 input points.
vtkStandardNewMacro(vtkFillImageWithPolyData)
virtual int RequestInformation(vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector)