125 force[0] = force[1] = force[2] = 0.0;
132 vtkWarningMacro(
"Point out of extent.");
138 if (cell->GetCellType() == VTK_VOXEL)
140 vtkVoxel::InterpolationFunctions(pcoords,weights);
142 else if (cell->GetCellType() == VTK_PIXEL)
144 vtkPixel::InterpolationFunctions(pcoords,weights);
148 vtkErrorMacro(
"Non voxel or pixel cell found in PotentialImage");
151 int numberOfCellPoints = cell->GetNumberOfPoints();
155 for (i=0; i<numberOfCellPoints; i++)
157 double vectorValue[3];
158 gradientVectorsArray->GetTuple(cell->GetPointId(i),vectorValue);
159 force[0] += weights[i] * vectorValue[0];
160 force[1] += weights[i] * vectorValue[1];
161 force[2] += weights[i] * vectorValue[2];
184 double potential = 0.0;
186 inBounds = this->
PotentialImage->ComputeStructuredCoordinates(point,ijk,pcoords);
191 vtkWarningMacro(
"Point out of extent.");
197 if (cell->GetCellType() == VTK_VOXEL)
199 vtkVoxel::InterpolationFunctions(pcoords,weights);
201 else if (cell->GetCellType() == VTK_PIXEL)
203 vtkPixel::InterpolationFunctions(pcoords,weights);
207 vtkErrorMacro(
"Non voxel or pixel cell found in PotentialImage");
211 int numberOfCellPoints = cell->GetNumberOfPoints();
213 vtkDataArray* potentialArray = this->
PotentialImage->GetPointData()->GetScalars();
215 for (i=0; i<numberOfCellPoints; i++)
217 double value = potentialArray->GetTuple1(cell->GetPointId(i));
218 potential += weights[i] * value;
236 double inflation = 0.0;
238 inBounds = this->
InflationImage->ComputeStructuredCoordinates(point,ijk,pcoords);
243 vtkWarningMacro(
"Point out of extent.");
249 if (cell->GetCellType() == VTK_VOXEL)
251 vtkVoxel::InterpolationFunctions(pcoords,weights);
253 else if (cell->GetCellType() == VTK_PIXEL)
255 vtkPixel::InterpolationFunctions(pcoords,weights);
259 vtkErrorMacro(
"Non voxel or pixel cell found in PotentialImage");
263 int numberOfCellPoints = cell->GetNumberOfPoints();
265 vtkDataArray* inflationArray = this->
InflationImage->GetPointData()->GetScalars();
267 for (i=0; i<numberOfCellPoints; i++)
269 double value = inflationArray->GetTuple1(cell->GetPointId(i));
270 inflation += weights[i] * value;
291 double laplacianPoint[3], neighborhoodPoint[3];
292 vtkIdType numberOfNeighborhoodPoints;
296 output = this->GetOutput();
297 neighborhood = this->
Neighborhoods->GetNeighborhood(pointId);
299 output->GetPoint(pointId,point);
301 stiffnessDisplacement[0] = stiffnessDisplacement[1] = stiffnessDisplacement[2] = 0.0;
307 laplacianPoint[0] = laplacianPoint[1] = laplacianPoint[2] = 0.0;
309 for (j=0; j<numberOfNeighborhoodPoints; j++)
311 output->GetPoint(neighborhood->
GetPointId(j),neighborhoodPoint);
313 laplacianPoint[0] += neighborhoodPoint[0];
314 laplacianPoint[1] += neighborhoodPoint[1];
315 laplacianPoint[2] += neighborhoodPoint[2];
323 laplacianPoint[0] /= (double)numberOfNeighborhoodPoints;
324 laplacianPoint[1] /= (double)numberOfNeighborhoodPoints;
325 laplacianPoint[2] /= (double)numberOfNeighborhoodPoints;
330 stiffnessDisplacement[0] = laplacianPoint[0] - point[0];
331 stiffnessDisplacement[1] = laplacianPoint[1] - point[1];
332 stiffnessDisplacement[2] = laplacianPoint[2] - point[2];
338 double point[3], inputOutwardNormal[3];
339 double neighborhoodVector[3], firstNeighborhoodVector[3];
340 double cross[3], neighborhoodNormal[3];
341 double neighborhoodPoint[3];
343 vtkIdType numberOfNeighborhoodPoints;
347 output = this->GetOutput();
348 neighborhood = this->
Neighborhoods->GetNeighborhood(pointId);
352 inflationDisplacement[0] = 0.0;
353 inflationDisplacement[1] = 0.0;
354 inflationDisplacement[2] = 0.0;
358 output->GetPoint(pointId,point);
359 this->
Normals->GetTuple(pointId,inputOutwardNormal);
362 double potential = 1.0;
367 neighborhoodNormal[0] = 0.0;
368 neighborhoodNormal[1] = 0.0;
369 neighborhoodNormal[2] = 0.0;
371 output->GetPoint(neighborhood->
GetPointId(0),neighborhoodPoint);
372 firstNeighborhoodVector[0] = neighborhoodPoint[0] - point[0];
373 firstNeighborhoodVector[1] = neighborhoodPoint[1] - point[1];
374 firstNeighborhoodVector[2] = neighborhoodPoint[2] - point[2];
377 for (j=1; j<numberOfNeighborhoodPoints; j++)
379 output->GetPoint(neighborhood->
GetPointId(j),neighborhoodPoint);
380 neighborhoodVector[0] = neighborhoodPoint[0] - point[0];
381 neighborhoodVector[1] = neighborhoodPoint[1] - point[1];
382 neighborhoodVector[2] = neighborhoodPoint[2] - point[2];
383 vtkMath::Cross(firstNeighborhoodVector,neighborhoodVector,cross);
384 neighborhoodNormal[0] += cross[0];
385 neighborhoodNormal[1] += cross[1];
386 neighborhoodNormal[2] += cross[2];
388 vtkMath::Normalize(neighborhoodNormal);
390 dot = vtkMath::Dot(inputOutwardNormal,neighborhoodNormal);
394 neighborhoodNormal[0] *= -1.0;
395 neighborhoodNormal[1] *= -1.0;
396 neighborhoodNormal[2] *= -1.0;
399 inflationDisplacement[0] = inflation * potential * neighborhoodNormal[0];
400 inflationDisplacement[1] = inflation * potential * neighborhoodNormal[1];
401 inflationDisplacement[2] = inflation * potential * neighborhoodNormal[2];
407 vtkIdType numberOfPoints;
408 double displacement[3];
409 double potentialDisplacement[3];
410 double stiffnessDisplacement[3];
411 double inflationDisplacement[3];
412 double displacementNorm;
414 numberOfPoints = this->GetOutput()->GetNumberOfPoints();
418 for (i=0; i<numberOfPoints; i++)
420 displacement[0] = displacement[1] = displacement[2] = 0.0;
447 displacementNorm = vtkMath::Norm(displacement);
480 vtkIdType numberOfPoints;
481 double point[3], displacement[3], newPoint[3];
484 points = this->GetOutput()->GetPoints();
485 numberOfPoints = points->GetNumberOfPoints();
487 for (i=0; i<numberOfPoints; i++)
489 points->GetPoint(i,point);
494 points->SetPoint(i,newPoint);
511 vtkInformation *vtkNotUsed(request),
512 vtkInformationVector **inputVector,
513 vtkInformationVector *outputVector)
515 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
516 vtkInformation *outInfo = outputVector->GetInformationObject(0);
518 vtkPolyData *input = vtkPolyData::SafeDownCast(
519 inInfo->Get(vtkDataObject::DATA_OBJECT()));
520 vtkPolyData *output = vtkPolyData::SafeDownCast(
521 outInfo->Get(vtkDataObject::DATA_OBJECT()));
523 bool potential, stiffness, inflation;
525 vtkIdType numberOfPoints;
526 vtkPoints *newPoints;
528 numberOfPoints = input->GetNumberOfPoints();
530 newPoints = vtkPoints::New();
531 newPoints->DeepCopy(input->GetPoints());
543 vtkImageGradient* gradientFilter = vtkImageGradient::New();
546 gradientFilter->Update();
557 gradientFilter->Delete();
559 output->SetPoints(newPoints);
560 output->SetVerts(input->GetVerts());
561 output->SetLines(input->GetLines());
562 output->SetPolys(input->GetPolys());
563 output->SetStrips(input->GetStrips());
564 output->GetPointData()->PassData(input->GetPointData());
565 output->GetCellData()->PassData(input->GetCellData());
576 this->
Neighborhoods->SetNeighborhoodTypeToPolyDataManifoldNeighborhood();
580 vtkPolyDataNormals* surfaceNormals = vtkPolyDataNormals::New();
581 surfaceNormals->SetInputData(input);
582 surfaceNormals->SplittingOff();
583 surfaceNormals->AutoOrientNormalsOn();
585 surfaceNormals->ComputePointNormalsOn();
586 surfaceNormals->ConsistencyOn();
587 surfaceNormals->Update();
589 this->
Normals = surfaceNormals->GetOutput()->GetPointData()->GetNormals();
630 surfaceNormals->Delete();