diff --git a/Filters/FlowPaths/CMakeLists.txt b/Filters/FlowPaths/CMakeLists.txt index 09402f7a7f7f754ae921b919c7303849c023053e..ba342e0cb995b9a6ed9b59437d82a92b9a510d93 100644 --- a/Filters/FlowPaths/CMakeLists.txt +++ b/Filters/FlowPaths/CMakeLists.txt @@ -31,17 +31,4 @@ set_source_files_properties( WRAP_EXCLUDE ) -if(NOT VTK_LEGACY_REMOVE) - list(APPEND Module_SRCS - vtkDashedStreamLine.cxx - vtkStreamLine.cxx - vtkStreamPoints.cxx - vtkStreamer.cxx) - - set_source_files_properties( - vtkStreamer - ABSTRACT - ) -endif () - vtk_module_library(vtkFiltersFlowPaths ${Module_SRCS}) diff --git a/Filters/FlowPaths/vtkDashedStreamLine.cxx b/Filters/FlowPaths/vtkDashedStreamLine.cxx deleted file mode 100644 index 8a9089bb5a78258f00391551ac167f793eed3d8e..0000000000000000000000000000000000000000 --- a/Filters/FlowPaths/vtkDashedStreamLine.cxx +++ /dev/null @@ -1,203 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkDashedStreamLine.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkDashedStreamLine.h" - -#ifndef VTK_LEGACY_REMOVE - -#include "vtkCellArray.h" -#include "vtkDataSet.h" -#include "vtkFloatArray.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkPolyData.h" - -vtkStandardNewMacro(vtkDashedStreamLine); - -vtkDashedStreamLine::vtkDashedStreamLine() -{ - this->DashFactor = 0.75; - - VTK_LEGACY_BODY(vtkDashedStreamLine::vtkDashedStreamLine, "VTK 6.3"); -} - -int vtkDashedStreamLine::RequestData(vtkInformation *, - vtkInformationVector **inputVector, - vtkInformationVector *outputVector) -{ - vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); - vtkInformation *outInfo = outputVector->GetInformationObject(0); - vtkInformation *sourceInfo = inputVector[1]->GetInformationObject(0); - - vtkStreamer::StreamPoint *sPrev, *sPtr; - vtkPoints *newPts; - vtkFloatArray *newVectors; - vtkFloatArray *newScalars=NULL; - vtkCellArray *newLines; - int i, ptId, j; - vtkIdType pts[2]; - double tOffset, x[3], v[3], r, xPrev[3], vPrev[3], scalarPrev; - double s = 0; - double xEnd[3], vEnd[3], sEnd; - vtkDataSet *input = vtkDataSet::SafeDownCast( - inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkPolyData *output = vtkPolyData::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkDataSet *source = 0; - if (sourceInfo) - { - source = vtkDataSet::SafeDownCast( - sourceInfo->Get(vtkDataObject::DATA_OBJECT())); - } - - this->SavePointInterval = this->StepLength; - this->vtkStreamer::Integrate(input, source); - if ( this->NumberOfStreamers <= 0 ) - { - return 1; - } - // - // Convert streamer into lines. Lines may be dashed. - // - newPts = vtkPoints::New(); - newPts->Allocate(1000); - newVectors = vtkFloatArray::New(); - newVectors->SetNumberOfComponents(3); - newVectors->Allocate(1000); - if ( input->GetPointData()->GetScalars() || this->SpeedScalars ) - { - newScalars = vtkFloatArray::New(); - newScalars->Allocate(1000); - } - newLines = vtkCellArray::New(); - newLines->Allocate(newLines->EstimateSize(2*this->NumberOfStreamers,VTK_CELL_SIZE)); - // - // Loop over all streamers generating points - // - for (ptId=0; ptId < this->NumberOfStreamers; ptId++) - { - if ( this->Streamers[ptId].GetNumberOfPoints() < 2 ) - { - continue; - } - sPrev = this->Streamers[ptId].GetStreamPoint(0); - sPtr = this->Streamers[ptId].GetStreamPoint(1); - for (j=0; j<3; j++) - { - xPrev[j] = sPrev->x[j]; - vPrev[j] = sPrev->v[j]; - } - scalarPrev = sPrev->s; - - if ( this->Streamers[ptId].GetNumberOfPoints() == 2 && sPtr->cellId < 0 ) - { - continue; - } - - tOffset = sPrev->t; - - for ( i=1; - i < this->Streamers[ptId].GetNumberOfPoints() && sPtr->cellId >= 0; - i++, sPrev=sPtr, sPtr=this->Streamers[ptId].GetStreamPoint(i) ) - { -// -// Search for end of dash...create end of one dash, beginning of next -// - while ( tOffset >= sPrev->t && tOffset < sPtr->t ) - { - r = (tOffset - sPrev->t) / (sPtr->t - sPrev->t); - - for (j=0; j<3; j++) - { - x[j] = sPrev->x[j] + r * (sPtr->x[j] - sPrev->x[j]); - v[j] = sPrev->v[j] + r * (sPtr->v[j] - sPrev->v[j]); - xEnd[j] = xPrev[j] + this->DashFactor * (x[j] - xPrev[j]); - vEnd[j] = vPrev[j] + this->DashFactor * (v[j] - vPrev[j]); - } - - // create this dash - pts[0] = newPts->InsertNextPoint(x); - newVectors->InsertTuple(pts[0],v); - - pts[1] = newPts->InsertNextPoint(xEnd); - newVectors->InsertTuple(pts[1],vEnd); - - if ( newScalars ) - { - s = sPrev->s + r * (sPtr->s - sPrev->s); - newScalars->InsertTuple(pts[0],&s); - sEnd = scalarPrev + this->DashFactor * (s - scalarPrev); - newScalars->InsertTuple(pts[1],&sEnd); - } - - newLines->InsertNextCell(2,pts); - - for (j=0; j<3; j++) - { - xPrev[j] = x[j]; - vPrev[j] = v[j]; - } - if ( newScalars ) - { - scalarPrev = s; - } - tOffset += this->StepLength; - - } // while - } //for this streamer - } //for all streamers -// -// Update ourselves and release memory -// - vtkDebugMacro(<<"Created " << newPts->GetNumberOfPoints() << " points, " - << newLines->GetNumberOfCells() << " lines"); - - output->SetPoints(newPts); - newPts->Delete(); - - output->GetPointData()->SetVectors(newVectors); - newVectors->Delete(); - - if ( newScalars ) - { - int idx = output->GetPointData()->AddArray(newScalars); - output->GetPointData()->SetActiveAttribute(idx, - vtkDataSetAttributes::SCALARS); - newScalars->Delete(); - } - - output->SetLines(newLines); - newLines->Delete(); - - // Delete the streamers since they are no longer needed - delete[] this->Streamers; - this->Streamers = 0; - this->NumberOfStreamers = 0; - - output->Squeeze(); - - return 1; -} - -void vtkDashedStreamLine::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); - - os << indent << "Dash Factor: " << this->DashFactor << " <<\n"; - -} - -#endif // VTK_LEGACY_REMOVE diff --git a/Filters/FlowPaths/vtkDashedStreamLine.h b/Filters/FlowPaths/vtkDashedStreamLine.h deleted file mode 100644 index 550aec01626d57b333486d28f90eb909e4b1bb18..0000000000000000000000000000000000000000 --- a/Filters/FlowPaths/vtkDashedStreamLine.h +++ /dev/null @@ -1,76 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkDashedStreamLine.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkDashedStreamLine - * @brief generate constant-time dashed streamline in arbitrary dataset - * - * vtkDashedStreamLine is a filter that generates a "dashed" streamline for - * an arbitrary dataset. The streamline consists of a series of dashes, each - * of which represents (approximately) a constant time increment. Thus, in the - * resulting visual representation, relatively long dashes represent areas of - * high velocity, and small dashes represent areas of low velocity. - * - * vtkDashedStreamLine introduces the instance variable DashFactor. - * DashFactor interacts with its superclass' instance variable StepLength to - * create the dashes. DashFactor is the percentage of the StepLength line - * segment that is visible. Thus, if the DashFactor=0.75, the dashes will be - * "three-quarters on" and "one-quarter off". - * - * @sa - * vtkStreamer vtkStreamLine vtkStreamPoints -*/ - -#ifndef vtkDashedStreamLine_h -#define vtkDashedStreamLine_h - -#include "vtkFiltersFlowPathsModule.h" // For export macro -#include "vtkStreamLine.h" - -#ifndef VTK_LEGACY_REMOVE - -class VTKFILTERSFLOWPATHS_EXPORT vtkDashedStreamLine : public vtkStreamLine -{ -public: - static vtkDashedStreamLine *New(); - vtkTypeMacro(vtkDashedStreamLine,vtkStreamLine); - void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; - - //@{ - /** - * For each dash, specify the fraction of the dash that is "on". A factor - * of 1.0 will result in a continuous line, a factor of 0.5 will result in - * dashed that are half on and half off. - */ - vtkSetClampMacro(DashFactor,double,0.01,1.0); - vtkGetMacro(DashFactor,double); - //@} - -protected: - vtkDashedStreamLine(); - ~vtkDashedStreamLine() VTK_OVERRIDE {} - - // Convert streamer array into vtkPolyData - int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE; - - // the fraction of on versus off in dash - double DashFactor; - -private: - vtkDashedStreamLine(const vtkDashedStreamLine&) VTK_DELETE_FUNCTION; - void operator=(const vtkDashedStreamLine&) VTK_DELETE_FUNCTION; -}; - -#endif // VTK_LEGACY_REMOVE -#endif diff --git a/Filters/FlowPaths/vtkStreamLine.cxx b/Filters/FlowPaths/vtkStreamLine.cxx deleted file mode 100644 index 40060b7eb31012a83123a1b75a37afd9ffa9e984..0000000000000000000000000000000000000000 --- a/Filters/FlowPaths/vtkStreamLine.cxx +++ /dev/null @@ -1,265 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkStreamLine.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkStreamLine.h" - -#ifndef VTK_LEGACY_REMOVE - -#include "vtkCellArray.h" -#include "vtkDataSet.h" -#include "vtkFloatArray.h" -#include "vtkFloatArray.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkMath.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkPolyData.h" -#include "vtkPolyLine.h" - -vtkStandardNewMacro(vtkStreamLine); - -// Construct object with step size set to 1.0. -vtkStreamLine::vtkStreamLine() -{ - this->StepLength = 1.0; - this->NumberOfStreamers = 0; - - VTK_LEGACY_BODY(vtkStreamLine::vtkStreamLine, "VTK 6.3"); -} - -int vtkStreamLine::RequestData( - vtkInformation *, - vtkInformationVector **inputVector, - vtkInformationVector *outputVector) -{ - vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); - vtkInformation *outInfo = outputVector->GetInformationObject(0); - vtkInformation *sourceInfo = inputVector[1]->GetInformationObject(0); - - vtkDataSet *input = vtkDataSet::SafeDownCast( - inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkPolyData *output = vtkPolyData::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkDataSet *source = 0; - if (sourceInfo) - { - source = vtkDataSet::SafeDownCast( - sourceInfo->Get(vtkDataObject::DATA_OBJECT())); - } - - vtkStreamer::StreamPoint *sPrev, *sPtr; - vtkPoints *newPts; - vtkFloatArray *newVectors; - vtkFloatArray *newScalars=NULL; - vtkCellArray *newLines; - vtkIdType ptId, i, id; - int j; - vtkIdList *pts; - double tOffset, x[3], v[3], s, r; - double theta; - vtkPolyLine* lineNormalGenerator = NULL; - vtkFloatArray* normals = NULL; - vtkFloatArray* rotation = 0; - - this->SavePointInterval = this->StepLength; - this->vtkStreamer::Integrate(input, source); - if ( this->NumberOfStreamers <= 0 ) {return 1;} - - pts = vtkIdList::New(); - pts->Allocate(2500); - - // - // Convert streamer into lines. Lines may be dashed. - // - newPts = vtkPoints::New(); - newPts->Allocate(1000); - newVectors = vtkFloatArray::New(); - newVectors->SetNumberOfComponents(3); - newVectors->Allocate(3000); - if ( this->Vorticity ) - { - lineNormalGenerator = vtkPolyLine::New(); - normals = vtkFloatArray::New(); - normals->SetNumberOfComponents(3); - normals->Allocate(3000); - rotation = vtkFloatArray::New(); - rotation->SetNumberOfComponents(1); - rotation->Allocate(1000); - rotation->SetName("Thetas"); - output->GetPointData()->AddArray(rotation); - } - - if ( input->GetPointData()->GetScalars() || this->SpeedScalars - || this->OrientationScalars) - { - newScalars = vtkFloatArray::New(); - newScalars->Allocate(1000); - } - newLines = vtkCellArray::New(); - newLines->Allocate(newLines->EstimateSize(2*this->NumberOfStreamers, - VTK_CELL_SIZE)); - // - // Loop over all streamers generating points - // - for (ptId=0; ptId < this->NumberOfStreamers; ptId++) - { - if ( this->Streamers[ptId].GetNumberOfPoints() < 2 ) - { - continue; - } - sPrev = this->Streamers[ptId].GetStreamPoint(0); - sPtr = this->Streamers[ptId].GetStreamPoint(1); - - if ( this->Streamers[ptId].GetNumberOfPoints() == 2 && sPtr->cellId >= 0 ) - { - continue; - } - - tOffset = sPrev->t; - - for ( i=1; - i < this->Streamers[ptId].GetNumberOfPoints() && sPtr->cellId >= 0; - i++, sPrev=sPtr, sPtr=this->Streamers[ptId].GetStreamPoint(i) ) - { - // - // Create points for line - // - while ( tOffset >= sPrev->t && tOffset < sPtr->t ) - { - r = (tOffset - sPrev->t) / (sPtr->t - sPrev->t); - - for (j=0; j<3; j++) - { - x[j] = sPrev->x[j] + r * (sPtr->x[j] - sPrev->x[j]); - v[j] = sPrev->v[j] + r * (sPtr->v[j] - sPrev->v[j]); - } - - // add point to line - id = newPts->InsertNextPoint(x); - pts->InsertNextId(id); - newVectors->InsertTuple(id,v); - - if ( newScalars ) - { - s = sPrev->s + r * (sPtr->s - sPrev->s); - newScalars->InsertTuple(id,&s); - } - - if ( this->Vorticity ) - { - // Store the rotation values. Used after all the streamlines - // are generated. - theta = sPrev->theta + r * (sPtr->theta - sPrev->theta); - rotation->InsertTuple(id, &theta); - } - - tOffset += this->StepLength; - - } // while - } //for this streamer - - if ( pts->GetNumberOfIds() > 1 ) - { - newLines->InsertNextCell(pts); - pts->Reset(); - } - } //for all streamers - - vtkDebugMacro(<<"Created " << newPts->GetNumberOfPoints() << " points, " - << newLines->GetNumberOfCells() << " lines"); - - if (this->Vorticity) - { - // Rotate the normal vectors with stream vorticity - vtkIdType nPts=0; - vtkIdType *linePts=0; - double normal[3], local1[3], local2[3], length, costheta, sintheta; - - lineNormalGenerator->GenerateSlidingNormals(newPts,newLines,normals); - - // Loop over all lines, from the above code we are know that each line - // will have at least two points and that no points will be shared - // between lines. It is important to loop over the points used by the - // lines because newPts may actually contain points that are not used by - // any lines. The normals are only calculated for points that are used - // in lines so referencing normals for all points can lead to UMRs - for (newLines->InitTraversal(); newLines->GetNextCell(nPts,linePts); ) - { - for(i=0; i<nPts; i++) - { - normals->GetTuple(linePts[i], normal); - newVectors->GetTuple(linePts[i], v); - // obtain two unit orthogonal vectors on the plane perpendicular to - // the streamline - for(j=0; j<3; j++) - { - local1[j] = normal[j]; - } - length = vtkMath::Normalize(local1); - vtkMath::Cross(local1, v, local2); - vtkMath::Normalize(local2); - // Rotate the normal with theta - rotation->GetTuple(linePts[i], &theta); - costheta = cos(theta); - sintheta = sin(theta); - for(j=0; j<3; j++) - { - normal[j] = length* (costheta*local1[j] + sintheta*local2[j]); - } - normals->SetTuple(linePts[i], normal); - } - } - output->GetPointData()->SetNormals(normals); - normals->Delete(); - lineNormalGenerator->Delete(); - rotation->Delete(); - } - - output->SetPoints(newPts); - newPts->Delete(); - - output->GetPointData()->SetVectors(newVectors); - newVectors->Delete(); - - if ( newScalars ) - { - int idx = output->GetPointData()->AddArray(newScalars); - output->GetPointData()->SetActiveAttribute(idx, vtkDataSetAttributes::SCALARS); - newScalars->Delete(); - } - - pts->Delete(); - output->SetLines(newLines); - newLines->Delete(); - - // Delete the streamers since they are no longer needed - delete[] this->Streamers; - this->Streamers = 0; - this->NumberOfStreamers = 0; - - output->Squeeze(); - - return 1; -} - -void vtkStreamLine::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); - - os << indent << "Step Length: " << this->StepLength << "\n"; - -} - -#endif // VTK_LEGACY_REMOVE diff --git a/Filters/FlowPaths/vtkStreamLine.h b/Filters/FlowPaths/vtkStreamLine.h deleted file mode 100644 index 2c46a9c2c24692180b11a0ba436de673e79f1a38..0000000000000000000000000000000000000000 --- a/Filters/FlowPaths/vtkStreamLine.h +++ /dev/null @@ -1,92 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkStreamLine.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkStreamLine - * @brief generate streamline in arbitrary dataset - * - * vtkStreamLine is a filter that generates a streamline for an arbitrary - * dataset. A streamline is a line that is everywhere tangent to the vector - * field. Scalar values also are calculated along the streamline and can be - * used to color the line. Streamlines are calculated by integrating from - * a starting point through the vector field. Integration can be performed - * forward in time (see where the line goes), backward in time (see where the - * line came from), or in both directions. It also is possible to compute - * vorticity along the streamline. Vorticity is the projection (i.e., dot - * product) of the flow rotation on the velocity vector, i.e., the rotation - * of flow around the streamline. - * - * vtkStreamLine defines the instance variable StepLength. This parameter - * controls the time increment used to generate individual points along - * the streamline(s). Smaller values result in more line - * primitives but smoother streamlines. The StepLength instance variable is - * defined in terms of time (i.e., the distance that the particle travels in - * the specified time period). Thus, the line segments will be smaller in areas - * of low velocity and larger in regions of high velocity. (NOTE: This is - * different than the IntegrationStepLength defined by the superclass - * vtkStreamer. IntegrationStepLength is used to control integration step - * size and is expressed as a fraction of the cell length.) The StepLength - * instance variable is important because subclasses of vtkStreamLine (e.g., - * vtkDashedStreamLine) depend on this value to build their representation. - * - * @sa - * vtkStreamer vtkDashedStreamLine vtkStreamPoints -*/ - -#ifndef vtkStreamLine_h -#define vtkStreamLine_h - -#include "vtkFiltersFlowPathsModule.h" // For export macro -#include "vtkStreamer.h" - -#ifndef VTK_LEGACY_REMOVE - -class VTKFILTERSFLOWPATHS_EXPORT vtkStreamLine : public vtkStreamer -{ -public: - vtkTypeMacro(vtkStreamLine,vtkStreamer); - void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; - - /** - * Construct object with step size set to 1.0. - */ - static vtkStreamLine *New(); - - //@{ - /** - * Specify the length of a line segment. The length is expressed in terms of - * elapsed time. Smaller values result in smoother appearing streamlines, but - * greater numbers of line primitives. - */ - vtkSetClampMacro(StepLength,double,0.000001,VTK_DOUBLE_MAX); - vtkGetMacro(StepLength,double); - //@} - -protected: - vtkStreamLine(); - ~vtkStreamLine() VTK_OVERRIDE {} - - // Convert streamer array into vtkPolyData - int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE; - - // the length of line primitives - double StepLength; - -private: - vtkStreamLine(const vtkStreamLine&) VTK_DELETE_FUNCTION; - void operator=(const vtkStreamLine&) VTK_DELETE_FUNCTION; -}; - -#endif // VTK_LEGACY_REMOVE -#endif diff --git a/Filters/FlowPaths/vtkStreamPoints.cxx b/Filters/FlowPaths/vtkStreamPoints.cxx deleted file mode 100644 index 8bc769101c5cbaa50a3352a950d5d65980bf8a5b..0000000000000000000000000000000000000000 --- a/Filters/FlowPaths/vtkStreamPoints.cxx +++ /dev/null @@ -1,181 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkStreamPoints.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkStreamPoints.h" - -#ifndef VTK_LEGACY_REMOVE - -#include "vtkCellArray.h" -#include "vtkDataSet.h" -#include "vtkFloatArray.h" -#include "vtkIdList.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkPoints.h" -#include "vtkPolyData.h" - -vtkStandardNewMacro(vtkStreamPoints); - -// Construct object with time increment set to 1.0. -vtkStreamPoints::vtkStreamPoints() -{ - this->TimeIncrement = 1.0; - this->NumberOfStreamers = 0; - - VTK_LEGACY_BODY(vtkStreamPoints::vtkStreamPoints, "VTK 6.3"); -} - -int vtkStreamPoints::RequestData( - vtkInformation *, - vtkInformationVector **inputVector, - vtkInformationVector *outputVector) -{ - vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); - vtkInformation *outInfo = outputVector->GetInformationObject(0); - vtkInformation *sourceInfo = inputVector[1]->GetInformationObject(0); - - vtkStreamer::StreamPoint *sPrev, *sPtr; - vtkPoints *newPts; - vtkFloatArray *newVectors; - vtkFloatArray *newScalars=NULL; - vtkCellArray *newVerts; - vtkIdType i, ptId, id; - int j; - double tOffset, x[3], v[3], s, r; - vtkPolyData *output = vtkPolyData::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkDataSet *input = vtkDataSet::SafeDownCast( - inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkDataSet *source = 0; - if (sourceInfo) - { - source = vtkDataSet::SafeDownCast( - sourceInfo->Get(vtkDataObject::DATA_OBJECT())); - } - vtkIdList *pts; - - this->SavePointInterval = this->TimeIncrement; - this->vtkStreamer::Integrate(input, source); - if ( this->NumberOfStreamers <= 0 ) - { - return 1; - } - - pts = vtkIdList::New(); - pts->Allocate(2500); - newPts = vtkPoints::New(); - newPts ->Allocate(1000); - newVectors = vtkFloatArray::New(); - newVectors->SetNumberOfComponents(3); - newVectors ->Allocate(3000); - if ( input->GetPointData()->GetScalars() || this->SpeedScalars - || this->OrientationScalars) - { - newScalars = vtkFloatArray::New(); - newScalars->Allocate(1000); - } - newVerts = vtkCellArray::New(); - newVerts->Allocate(newVerts->EstimateSize(2*this->NumberOfStreamers,VTK_CELL_SIZE)); - - // - // Loop over all streamers generating points - // - for (ptId=0; ptId < this->NumberOfStreamers; ptId++) - { - // tOffset is the time that the next point will have. - tOffset = 0.0; - - for ( sPrev=sPtr=this->Streamers[ptId].GetStreamPoint(0), i=0; - i < this->Streamers[ptId].GetNumberOfPoints() && sPtr->cellId >= 0; - i++, sPrev=sPtr, sPtr=this->Streamers[ptId].GetStreamPoint(i) ) - { - // - // For each streamer, create points "time increment" apart - // - if ( tOffset < sPtr->t ) - { - while ( tOffset < sPtr->t ) - { - r = (tOffset - sPrev->t) / (sPtr->t - sPrev->t); - - for (j=0; j<3; j++) - { - x[j] = sPrev->x[j] + r * (sPtr->x[j] - sPrev->x[j]); - v[j] = sPrev->v[j] + r * (sPtr->v[j] - sPrev->v[j]); - } - - // add point to line - id = newPts->InsertNextPoint(x); - pts->InsertNextId(id); - newVectors->InsertTuple(id,v); - - if ( newScalars ) - { - s = sPrev->s + r * (sPtr->s - sPrev->s); - newScalars->InsertTuple(id,&s); - } - - tOffset += this->TimeIncrement; - } // while - - } //if points should be created - - } //for this streamer - if ( pts->GetNumberOfIds() > 1 ) - { - newVerts->InsertNextCell(pts); - pts->Reset(); - } - } //for all streamers - // - // Update ourselves - // - vtkDebugMacro(<<"Created " << newPts->GetNumberOfPoints() << " points"); - - output->SetPoints(newPts); - newPts->Delete(); - output->SetVerts(newVerts); - newVerts->Delete(); - - output->GetPointData()->SetVectors(newVectors); - newVectors->Delete(); - - if ( newScalars ) - { - int idx = output->GetPointData()->AddArray(newScalars); - output->GetPointData()->SetActiveAttribute(idx, vtkDataSetAttributes::SCALARS); - newScalars->Delete(); - } - - // Delete the streamers since they are no longer needed - delete[] this->Streamers; - this->Streamers = 0; - this->NumberOfStreamers = 0; - - output->Squeeze(); - pts->Delete(); - - return 1; -} - -void vtkStreamPoints::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); - - os << indent << "Time Increment: " << this->TimeIncrement << " <<\n"; -} - -#endif // VTK_LEGACY_REMOVE diff --git a/Filters/FlowPaths/vtkStreamPoints.h b/Filters/FlowPaths/vtkStreamPoints.h deleted file mode 100644 index 280c63f1bf8222b08cb3b1ddbc6d239baf36928e..0000000000000000000000000000000000000000 --- a/Filters/FlowPaths/vtkStreamPoints.h +++ /dev/null @@ -1,71 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkStreamPoints.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkStreamPoints - * @brief generate points along streamer separated by constant time increment - * - * vtkStreamPoints is a filter that generates points along a streamer. - * The points are separated by a constant time increment. The resulting visual - * effect (especially when coupled with vtkGlyph3D) is an indication of - * particle speed. - * - * @sa - * vtkStreamer vtkStreamLine vtkDashedStreamLine -*/ - -#ifndef vtkStreamPoints_h -#define vtkStreamPoints_h - -#include "vtkFiltersFlowPathsModule.h" // For export macro -#include "vtkStreamer.h" - -#ifndef VTK_LEGACY_REMOVE - -class VTKFILTERSFLOWPATHS_EXPORT vtkStreamPoints : public vtkStreamer -{ -public: - vtkTypeMacro(vtkStreamPoints,vtkStreamer); - void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; - - /** - * Construct object with time increment set to 1.0. - */ - static vtkStreamPoints *New(); - - //@{ - /** - * Specify the separation of points in terms of absolute time. - */ - vtkSetClampMacro(TimeIncrement,double,0.000001,VTK_DOUBLE_MAX); - vtkGetMacro(TimeIncrement,double); - //@} - -protected: - vtkStreamPoints(); - ~vtkStreamPoints() VTK_OVERRIDE {} - - // Convert streamer array into vtkPolyData - int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE; - - // the separation of points - double TimeIncrement; - -private: - vtkStreamPoints(const vtkStreamPoints&) VTK_DELETE_FUNCTION; - void operator=(const vtkStreamPoints&) VTK_DELETE_FUNCTION; -}; - -#endif // VTK_LEGACY_REMOVE -#endif diff --git a/Filters/FlowPaths/vtkStreamer.cxx b/Filters/FlowPaths/vtkStreamer.cxx deleted file mode 100644 index 49091e8666bcb6c3df3adda4505f8771bbce82b8..0000000000000000000000000000000000000000 --- a/Filters/FlowPaths/vtkStreamer.cxx +++ /dev/null @@ -1,773 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkStreamer.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkStreamer.h" - -#ifndef VTK_LEGACY_REMOVE - -#include "vtkCell.h" -#include "vtkDataSet.h" -#include "vtkDoubleArray.h" -#include "vtkExecutive.h" -#include "vtkGenericCell.h" -#include "vtkInformation.h" -#include "vtkInterpolatedVelocityField.h" -#include "vtkMath.h" -#include "vtkMultiThreader.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkRungeKutta2.h" - -vtkCxxSetObjectMacro(vtkStreamer,Integrator,vtkInitialValueProblemSolver); - -#define VTK_START_FROM_POSITION 0 -#define VTK_START_FROM_LOCATION 1 - -static const double VTK_EPSILON=1E-12; - -struct vtkStreamerThreadStruct -{ - vtkStreamer *Filter; - vtkDataSet *Input; - vtkDataSet *Source; -}; - -vtkStreamer::StreamArray::StreamArray() -{ - this->MaxId = -1; - this->Array = new vtkStreamer::StreamPoint[1000]; - this->Size = 1000; - this->Extend = 5000; - this->Direction = VTK_INTEGRATE_FORWARD; -} - -vtkStreamer::StreamPoint *vtkStreamer::StreamArray::Resize(vtkIdType sz) -{ - vtkStreamer::StreamPoint *newArray; - vtkIdType newSize; - - if (sz >= this->Size) - { - newSize = this->Size + - this->Extend*(((sz-this->Size)/this->Extend)+1); - } - else - { - newSize = sz; - } - - newArray = new vtkStreamer::StreamPoint[newSize]; - - memcpy(newArray, this->Array, - static_cast<size_t>(sz < this->Size ? sz : this->Size) - * sizeof(vtkStreamer::StreamPoint)); - - this->Size = newSize; - delete [] this->Array; - this->Array = newArray; - - return this->Array; -} - -// Construct object to start from position (0,0,0); integrate forward; terminal -// speed 0.0; vorticity computation off; integrations step length 0.2; and -// maximum propagation time 100.0. -vtkStreamer::vtkStreamer() -{ - this->StartFrom = VTK_START_FROM_POSITION; - - this->StartCell = 0; - this->StartSubId = 0; - this->StartPCoords[0] = this->StartPCoords[1] = this->StartPCoords[2] = 0.5; - this->StartPosition[0] = this->StartPosition[1] = this->StartPosition[2] = 0.0; - this->Streamers = NULL; - this->MaximumPropagationTime = 100.0; - this->IntegrationDirection = VTK_INTEGRATE_FORWARD; - this->IntegrationStepLength = 0.2; - this->Vorticity = 0; - this->TerminalSpeed = 0.0; - this->SpeedScalars = 0; - this->OrientationScalars = 0; - this->NumberOfStreamers = 0; - this->Epsilon=VTK_EPSILON; - - this->Threader = vtkMultiThreader::New(); - this->NumberOfThreads = this->Threader->GetNumberOfThreads(); - this->Integrator = vtkRungeKutta2::New(); - this->SavePointInterval = 0.00001; - - this->SetNumberOfInputPorts(2); - - VTK_LEGACY_BODY(vtkStreamer::vtkStreamer, "VTK 6.3"); -} - -vtkStreamer::~vtkStreamer() -{ - delete [] this->Streamers; - - if (this->Threader) - { - this->Threader->Delete(); - } - this->SetIntegrator(0); -} - -void vtkStreamer::SetSourceConnection(vtkAlgorithmOutput* algOutput) -{ - this->SetInputConnection(1,algOutput); -} - -void vtkStreamer::SetSourceData(vtkDataSet *source) -{ - this->SetInputData(1, source); -} - -vtkDataSet *vtkStreamer::GetSource() -{ - if (this->GetNumberOfInputConnections(1) < 1) - { - return NULL; - } - return vtkDataSet::SafeDownCast( - this->GetExecutive()->GetInputData(1, 0)); -} - -// Specify the start of the streamline in the cell coordinate system. That is, -// cellId and subId (if composite cell), and parametric coordinates. -void vtkStreamer::SetStartLocation(vtkIdType cellId, int subId, - double pcoords[3]) -{ - if ( cellId != this->StartCell || subId != this->StartSubId || - pcoords[0] != this->StartPCoords[0] || - pcoords[1] != this->StartPCoords[1] || - pcoords[2] != this->StartPCoords[2] ) - { - this->Modified(); - this->StartFrom = VTK_START_FROM_LOCATION; - - this->StartCell = cellId; - this->StartSubId = subId; - this->StartPCoords[0] = pcoords[0]; - this->StartPCoords[1] = pcoords[1]; - this->StartPCoords[2] = pcoords[2]; - } -} - -// Specify the start of the streamline in the cell coordinate system. That is, -// cellId and subId (if composite cell), and parametric coordinates. -void vtkStreamer::SetStartLocation(vtkIdType cellId, int subId, double r, - double s, double t) -{ - double pcoords[3]; - pcoords[0] = r; - pcoords[1] = s; - pcoords[2] = t; - - this->SetStartLocation(cellId, subId, pcoords); -} - -// Get the starting location of the streamline in the cell coordinate system. -vtkIdType vtkStreamer::GetStartLocation(int& subId, double pcoords[3]) -{ - subId = this->StartSubId; - pcoords[0] = this->StartPCoords[0]; - pcoords[1] = this->StartPCoords[1]; - pcoords[2] = this->StartPCoords[2]; - return this->StartCell; -} - -// Specify the start of the streamline in the global coordinate system. Search -// must be performed to find initial cell to start integration from. -void vtkStreamer::SetStartPosition(double x[3]) -{ - if ( x[0] != this->StartPosition[0] || x[1] != this->StartPosition[1] || - x[2] != this->StartPosition[2] ) - { - this->Modified(); - this->StartFrom = VTK_START_FROM_POSITION; - - this->StartPosition[0] = x[0]; - this->StartPosition[1] = x[1]; - this->StartPosition[2] = x[2]; - } -} - -// Specify the start of the streamline in the global coordinate system. Search -// must be performed to find initial cell to start integration from. -void vtkStreamer::SetStartPosition(double x, double y, double z) -{ - double pos[3]; - pos[0] = x; - pos[1] = y; - pos[2] = z; - - this->SetStartPosition(pos); -} - -// Get the start position in global x-y-z coordinates. -double *vtkStreamer::GetStartPosition() -{ - return this->StartPosition; -} - -VTK_THREAD_RETURN_TYPE vtkStreamer::ThreadedIntegrate( void *arg ) -{ - vtkStreamer *self; - vtkStreamerThreadStruct *str; - int thread_count; - int thread_id; - vtkStreamer::StreamArray *streamer; - vtkStreamer::StreamPoint *sNext = 0, *sPtr; - vtkStreamer::StreamPoint pt1, pt2; - int i; - vtkIdType idxNext, ptId; - double d, step, dir; - double xNext[3], vel[3]; - double *cellVel; - double derivs[9]; - double pcoords[3]; - double coords[4]; - vtkDataSet *input; - vtkGenericCell *cell; - vtkPointData *pd; - vtkDataArray *inScalars; - vtkDataArray *inVectors; - vtkDoubleArray *cellVectors; - vtkDataArray *cellScalars=0; - double tOffset, vort[3]; - double err; - int counter=0; - - vtkMultiThreader::ThreadInfo *info= - static_cast<vtkMultiThreader::ThreadInfo *>(arg); - - thread_id = info->ThreadID; - thread_count = info->NumberOfThreads; - str = static_cast<vtkStreamerThreadStruct *>(info->UserData); - self = str->Filter; - - input = str->Input; - pd = input->GetPointData(); - inScalars = pd->GetScalars(); - inVectors = pd->GetVectors(); - - cell = vtkGenericCell::New(); - cellVectors = vtkDoubleArray::New(); - cellVectors->SetNumberOfComponents(3); - cellVectors->Allocate(3*VTK_CELL_SIZE); - if (inScalars) - { - cellScalars = inScalars->NewInstance(); - cellScalars->SetNumberOfComponents(inScalars->GetNumberOfComponents()); - cellScalars->Allocate(inScalars->GetNumberOfComponents()*VTK_CELL_SIZE); - } - - // Set the function set to be integrated - vtkInterpolatedVelocityField* func = vtkInterpolatedVelocityField::New(); - func->AddDataSet(input); - - if (self->GetIntegrator() == 0) - { - vtkGenericWarningMacro("No integrator is specified."); - return VTK_THREAD_RETURN_VALUE; - } - - double *w = new double[input->GetMaxCellSize()]; - - // Create a new integrator, the type is the same as Integrator - vtkInitialValueProblemSolver* integrator = - self->GetIntegrator()->NewInstance(); - integrator->SetFunctionSet(func); - - // Used to avoid calling these function many times during - // the integration - double termspeed = self->GetTerminalSpeed(); - double maxtime = self->GetMaximumPropagationTime(); - double savePointInterval = self->GetSavePointInterval(); - - // For each streamer, integrate in appropriate direction - // Do only the streamers that this thread should handle. - for (ptId=0; ptId < self->GetNumberOfStreamers(); ptId++) - { - if ( ptId % thread_count == thread_id ) - { - // Get starting step - streamer = self->GetStreamers() + ptId; - sPtr = streamer->GetStreamPoint(0); - if ( sPtr->cellId < 0 ) - { - continue; - } - // Set the last cell id in the vtkInterpolatedVelocityField - // object to speed up FindCell calls - func->SetLastCellId(sPtr->cellId); - - dir = streamer->Direction; - - // Copy the first point - pt1 = *sPtr; - pt2 = *sPtr; - tOffset = pt1.t; - - //integrate until time has been exceeded - while ( pt1.cellId >= 0 && pt1.speed > termspeed && pt1.t < maxtime ) - { - - if ( counter++ % 1000 == 0 ) - { - if (!thread_id) - { - self->UpdateProgress( - static_cast<double>(ptId) - /static_cast<double>(self->GetNumberOfStreamers()) - +pt1.t/maxtime/static_cast<double>(self->GetNumberOfStreamers())); - } - if (self->GetAbortExecute()) - { - break; - } - } - - // Set the integration step to be characteristic cell length - // time IntegrationStepLength - input->GetCell(pt1.cellId, cell); - step = dir*self->GetIntegrationStepLength() - * sqrt(static_cast<double>(cell->GetLength2()))/pt1.speed; - - // Calculate the next step using the integrator provided - if (integrator->ComputeNextStep(pt1.x, pt1.v, xNext, 0, step, 0, err) - != 0) - { - break; - } - - for(i=0; i<3; i++) - { - coords[i] = xNext[i]; - } - - // Interpolate the velocity field at coords - if ( !func->FunctionValues(coords, vel) ) - { - break; - } - - for(i=0; i<3; i++) - { - pt2.v[i] = vel[i]; - } - - for (i=0; i<3; i++) - { - pt2.x[i] = xNext[i]; - } - - pt2.cellId = func->GetLastCellId(); - func->GetLastWeights(w); - func->GetLastLocalCoordinates(pcoords); - input->GetCell(pt2.cellId, cell); - - if ( inScalars ) - { - // Interpolate scalars - inScalars->GetTuples(cell->PointIds, cellScalars); - for (pt2.s=0.0, i=0; i < cell->GetNumberOfPoints(); i++) - { - pt2.s += cellScalars->GetComponent(i,0) * w[i]; - } - } - - pt2.speed = vtkMath::Norm(pt2.v); - - d = sqrt(static_cast<double>( - vtkMath::Distance2BetweenPoints(pt1.x,pt2.x))); - pt2.d = pt1.d + d; - // If at stagnation region, stop the integration - if ( d <= self->Epsilon || (pt1.speed + pt2.speed) <= self->Epsilon) - { - pt2.t = pt1.t; - break; - } - pt2.t = pt1.t + (2.0 * d / (pt1.speed + pt2.speed)); - - if (self->GetVorticity() && inVectors) - { - // compute vorticity - inVectors->GetTuples(cell->PointIds, cellVectors); - cellVel = cellVectors->GetPointer(0); - cell->Derivatives(0, pcoords, cellVel, 3, derivs); - vort[0] = derivs[7] - derivs[5]; - vort[1] = derivs[2] - derivs[6]; - vort[2] = derivs[3] - derivs[1]; - // rotation - pt2.omega = vtkMath::Dot(vort, pt2.v); - pt2.omega /= pt2.speed; - pt2.theta += (pt1.omega+pt2.omega)/2 * (pt2.t - pt1.t); - } - - - // Store only points which have a point to be displayed - // between them - if (tOffset >= pt1.t && tOffset <= pt2.t) - { - // Do not store if same as the last point. - // To avoid storing some points twice. - if ( !sNext || sNext->x[0] != pt1.x[0] || sNext->x[1] != pt1.x[1] - || sNext->x[2] != pt1.x[2] ) - { - idxNext = streamer->InsertNextStreamPoint(); - sNext = streamer->GetStreamPoint(idxNext); - *sNext = pt1; - } - idxNext = streamer->InsertNextStreamPoint(); - sNext = streamer->GetStreamPoint(idxNext); - *sNext = pt2; - } - if (tOffset < pt2.t) - { - tOffset += (static_cast<int>( - ( pt2.t - tOffset) / savePointInterval) - + 1) * savePointInterval; - } - pt1 = pt2; - - } - // Store the last point anyway. - if ( !sNext || sNext->x[0] != pt2.x[0] || sNext->x[1] != pt2.x[1] - || sNext->x[2] != pt2.x[2] ) - { - idxNext = streamer->InsertNextStreamPoint(); - sNext = streamer->GetStreamPoint(idxNext); - *sNext = pt2; - } - // Clear the last cell to avoid starting a search from - // the last point in the streamline - func->ClearLastCellId(); - } - } - - integrator->Delete(); - func->Delete(); - - cell->Delete(); - cellVectors->Delete(); - if (cellScalars) - { - cellScalars->Delete(); - } - delete[] w; - - return VTK_THREAD_RETURN_VALUE; -} - -void vtkStreamer::Integrate(vtkDataSet *input, vtkDataSet *source) -{ - vtkPointData *pd = input->GetPointData(); - vtkDataArray *inScalars; - vtkDataArray *inVectors; - vtkIdType numSourcePts, idx, idxNext; - vtkStreamer::StreamPoint *sNext, *sPtr; - vtkIdType ptId, i; - int j, offset; - vtkCell *cell; - double v[3], *cellVel, derivs[9], xNext[3], vort[3]; - double tol2; - double *w = new double[input->GetMaxCellSize()]; - vtkDoubleArray *cellVectors; - vtkDataArray *cellScalars=0; - - vtkDebugMacro(<<"Generating streamers"); - this->NumberOfStreamers = 0; - - // reexecuting - delete old stuff - delete [] this->Streamers; - this->Streamers = NULL; - - if ( ! (inVectors=pd->GetVectors()) ) - { - delete [] w; - vtkErrorMacro(<<"No vector data defined!"); - return; - } - - cellVectors = vtkDoubleArray::New(); - cellVectors->SetNumberOfComponents(3); - cellVectors->Allocate(3*VTK_CELL_SIZE); - - inScalars = pd->GetScalars(); - - if (inScalars) - { - cellScalars = inScalars->NewInstance(); - cellScalars->SetNumberOfComponents(inScalars->GetNumberOfComponents()); - cellScalars->Allocate(cellScalars->GetNumberOfComponents()*VTK_CELL_SIZE); - } - - tol2 = input->GetLength()/1000; - tol2 = tol2*tol2; - - // - // Create starting points - // - this->NumberOfStreamers = numSourcePts = offset = 1; - if ( source ) - { - this->NumberOfStreamers = numSourcePts = source->GetNumberOfPoints(); - } - - if ( this->IntegrationDirection == VTK_INTEGRATE_BOTH_DIRECTIONS ) - { - offset = 2; - this->NumberOfStreamers *= 2; - } - - this->Streamers = new vtkStreamer::StreamArray[this->NumberOfStreamers]; - - if ( this->StartFrom == VTK_START_FROM_POSITION && !source ) - { - idx = this->Streamers[0].InsertNextStreamPoint(); - sPtr = this->Streamers[0].GetStreamPoint(idx); - sPtr->subId = 0; - for (i=0; i<3; i++) - { - sPtr->x[i] = this->StartPosition[i]; - } - sPtr->cellId = input->FindCell(this->StartPosition, NULL, -1, 0.0, - sPtr->subId, sPtr->p, w); - } - - else if ( this->StartFrom == VTK_START_FROM_LOCATION && !source ) - { - idx = this->Streamers[0].InsertNextStreamPoint(); - sPtr = this->Streamers[0].GetStreamPoint(idx); - sPtr->subId = 0; - cell = input->GetCell(sPtr->cellId); - cell->EvaluateLocation(sPtr->subId, sPtr->p, sPtr->x, w); - } - - else //VTK_START_FROM_SOURCE - { - for (ptId=0; ptId < numSourcePts; ptId++) - { - idx = this->Streamers[offset*ptId].InsertNextStreamPoint(); - sPtr = this->Streamers[offset*ptId].GetStreamPoint(idx); - sPtr->subId = 0; - source->GetPoint(ptId,sPtr->x); - sPtr->cellId = input->FindCell(sPtr->x, NULL, -1, tol2, - sPtr->subId, sPtr->p, w); - } - } - - // Finish initializing each streamer - // - for (idx=0, ptId=0; ptId < numSourcePts; ptId++) - { - this->Streamers[offset*ptId].Direction = 1.0; - sPtr = this->Streamers[offset*ptId].GetStreamPoint(idx); - sPtr->d = 0.0; - sPtr->t = 0.0; - sPtr->s = 0.0; - sPtr->theta = 0.0; - sPtr->omega = 0.0; - - if ( sPtr->cellId >= 0 ) //starting point in dataset - { - cell = input->GetCell(sPtr->cellId); - cell->EvaluateLocation(sPtr->subId, sPtr->p, xNext, w); - - inVectors->GetTuples(cell->PointIds, cellVectors); - sPtr->v[0] = sPtr->v[1] = sPtr->v[2] = 0.0; - for (i=0; i < cell->GetNumberOfPoints(); i++) - { - cellVectors->GetTuple(i, v); - for (j=0; j<3; j++) - { - sPtr->v[j] += v[j] * w[i]; - } - } - - sPtr->speed = vtkMath::Norm(sPtr->v); - - if (this->GetVorticity() && inVectors) - { - // compute vorticity - inVectors->GetTuples(cell->PointIds, cellVectors); - cellVel = cellVectors->GetPointer(0); - cell->Derivatives(0, sPtr->p, cellVel, 3, derivs); - vort[0] = derivs[7] - derivs[5]; - vort[1] = derivs[2] - derivs[6]; - vort[2] = derivs[3] - derivs[1]; - // rotation - sPtr->omega = vtkMath::Dot(vort, sPtr->v); - sPtr->omega /= sPtr->speed; - sPtr->theta = 0; - } - - if ( inScalars ) - { - inScalars->GetTuples(cell->PointIds, cellScalars); - for (sPtr->s=0, i=0; i < cell->GetNumberOfPoints(); i++) - { - sPtr->s += cellScalars->GetComponent(i,0) * w[i]; - } - } - } - else - { - for (j=0; j<3; j++) - { - sPtr->p[j] = 0.0; - sPtr->v[j] = 0.0; - } - sPtr->speed = 0; - } - - if ( this->IntegrationDirection == VTK_INTEGRATE_BOTH_DIRECTIONS ) - { - this->Streamers[offset*ptId+1].Direction = -1.0; - idxNext = this->Streamers[offset*ptId+1].InsertNextStreamPoint(); - sNext = this->Streamers[offset*ptId+1].GetStreamPoint(idxNext); - sPtr = this->Streamers[offset*ptId].GetStreamPoint(idx); - *sNext = *sPtr; - } - else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) - { - this->Streamers[offset*ptId].Direction = -1.0; - } - - - } //for each streamer - - // Some data access methods must be called once from a single thread before they - // can safely be used. Call those now - vtkGenericCell *gcell = vtkGenericCell::New(); - input->GetCell(0,gcell); - gcell->Delete(); - - // Set up and execute the thread - this->Threader->SetNumberOfThreads( this->NumberOfThreads ); - vtkStreamerThreadStruct str; - str.Filter = this; - str.Input = input; - str.Source = source; - this->Threader->SetSingleMethod( vtkStreamer::ThreadedIntegrate, &str ); - this->Threader->SingleMethodExecute(); - - // - // Now create appropriate representation - // - if ( this->OrientationScalars && !this->SpeedScalars) - { - for (ptId=0; ptId < this->NumberOfStreamers; ptId++) - { - for ( sPtr=this->Streamers[ptId].GetStreamPoint(0), i=0; - i < this->Streamers[ptId].GetNumberOfPoints() && sPtr->cellId >= 0; - i++, sPtr=this->Streamers[ptId].GetStreamPoint(i) ) - { - sPtr->s = sPtr->theta; - } - } - } - - if ( this->SpeedScalars ) - { - for (ptId=0; ptId < this->NumberOfStreamers; ptId++) - { - for ( sPtr=this->Streamers[ptId].GetStreamPoint(0), i=0; - i < this->Streamers[ptId].GetNumberOfPoints() && sPtr->cellId >= 0; - i++, sPtr=this->Streamers[ptId].GetStreamPoint(i) ) - { - sPtr->s = sPtr->speed; - } - } - } - delete [] w; - cellVectors->Delete(); - if (cellScalars) - { - cellScalars->Delete(); - } -} - -int vtkStreamer::FillInputPortInformation(int port, vtkInformation *info) -{ - info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet"); - - if (port == 1) - { - info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), 1); - } - return 1; -} - -void vtkStreamer::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); - - if ( this->StartFrom == VTK_START_FROM_POSITION && !this->GetSource()) - { - os << indent << "Starting Position: (" << this->StartPosition[0] << "," - << this->StartPosition[1] << ", " << this->StartPosition[2] << ")\n"; - } - else if ( this->StartFrom == VTK_START_FROM_LOCATION && !this->GetSource()) - { - os << indent << "Starting Location:\n\tCell: " << this->StartCell - << "\n\tSubId: " << this->StartSubId << "\n\tP.Coordinates: (" - << this->StartPCoords[0] << ", " - << this->StartPCoords[1] << ", " - << this->StartPCoords[2] << ")\n"; - } - else - { - os << indent << "Starting Source: " - << static_cast<void *>(this->GetSource()) << "\n"; - } - - os << indent << "Maximum Propagation Time: " - << this->MaximumPropagationTime << "\n"; - - if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) - { - os << indent << "Integration Direction: FORWARD\n"; - } - else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) - { - os << indent << "Integration Direction: BACKWARD\n"; - } - else - { - os << indent << "Integration Direction: FORWARD & BACKWARD\n"; - } - - os << indent << "Integration Step Length: " << this->IntegrationStepLength << "\n"; - - os << indent << "Vorticity: " << (this->Vorticity ? "On\n" : "Off\n"); - - os << indent << "Terminal Speed: " << this->TerminalSpeed << "\n"; - - os << indent << "Speed Scalars: " << (this->SpeedScalars ? "On\n" : "Off\n"); - - os << indent << "Orientation Scalars: " << (this->OrientationScalars ? "On\n" : "Off\n"); - - os << indent << "Interval with which points are stored:" - << this->SavePointInterval << endl; - - os << indent << "Integrator: " << this->Integrator << endl; - - os << indent << "Number Of Streamers: " << this->NumberOfStreamers << "\n"; - os << indent << "Number Of Threads: " << this->NumberOfThreads << "\n"; - os << indent << "Epsilon: " << this->Epsilon << "\n"; -} - -#endif // VTK_LEGACY_REMOVE diff --git a/Filters/FlowPaths/vtkStreamer.h b/Filters/FlowPaths/vtkStreamer.h deleted file mode 100644 index a7994bdaf8192fbb02556c006b42b52168d8de4d..0000000000000000000000000000000000000000 --- a/Filters/FlowPaths/vtkStreamer.h +++ /dev/null @@ -1,385 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkStreamer.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkStreamer - * @brief abstract object implements integration of massless particle through vector field - * - * vtkStreamer is a filter that integrates a massless particle through a vector - * field. The integration is performed using second order Runge-Kutta method. - * vtkStreamer often serves as a base class for other classes that perform - * numerical integration through a vector field (e.g., vtkStreamLine). - * - * Note that vtkStreamer can integrate both forward and backward in time, - * or in both directions. The length of the streamer is controlled by - * specifying an elapsed time. (The elapsed time is the time each particle - * travels.) Otherwise, the integration terminates after exiting the dataset or - * if the particle speed is reduced to a value less than the terminal speed. - * - * vtkStreamer integrates through any type of dataset. As a result, if the - * dataset contains 2D cells such as polygons or triangles, the integration is - * constrained to lie on the surface defined by the 2D cells. - * - * The starting point of streamers may be defined in three different ways. - * Starting from global x-y-z "position" allows you to start a single streamer - * at a specified x-y-z coordinate. Starting from "location" allows you to - * start at a specified cell, subId, and parametric coordinate. Finally, you - * may specify a source object to start multiple streamers. If you start - * streamers using a source object, for each point in the source that is - * inside the dataset a streamer is created. - * - * vtkStreamer implements the integration process in the Integrate() method. - * Because vtkStreamer does not implement the Execute() method that its - * superclass (i.e., Filter) requires, it is an abstract class. Its subclasses - * implement the execute method and use the Integrate() method, and then build - * their own representation of the integration path (i.e., lines, dashed - * lines, points, etc.). - * - * @sa - * vtkStreamLine vtkDashedStreamLine vtkStreamPoints -*/ - -#ifndef vtkStreamer_h -#define vtkStreamer_h - -#include "vtkFiltersFlowPathsModule.h" // For export macro -#include "vtkPolyDataAlgorithm.h" - -class vtkInitialValueProblemSolver; -class vtkMultiThreader; - -#ifndef VTK_LEGACY_REMOVE - -#define VTK_INTEGRATE_FORWARD 0 -#define VTK_INTEGRATE_BACKWARD 1 -#define VTK_INTEGRATE_BOTH_DIRECTIONS 2 - -class VTKFILTERSFLOWPATHS_EXPORT vtkStreamer : public vtkPolyDataAlgorithm -{ -public: - vtkTypeMacro(vtkStreamer,vtkPolyDataAlgorithm); - void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE; - - /** - * Specify the start of the streamline in the cell coordinate system. That - * is, cellId and subId (if composite cell), and parametric coordinates. - */ - void SetStartLocation(vtkIdType cellId, int subId, double pcoords[3]); - - /** - * Specify the start of the streamline in the cell coordinate system. That - * is, cellId and subId (if composite cell), and parametric coordinates. - */ - void SetStartLocation(vtkIdType cellId, int subId, double r, double s, - double t); - - /** - * Get the starting location of the streamline in the cell coordinate system. - */ - vtkIdType GetStartLocation(int& subId, double pcoords[3]); - - /** - * Specify the start of the streamline in the global coordinate - * system. Search must be performed to find initial cell to start - * integration from. - */ - void SetStartPosition(double x[3]); - - /** - * Specify the start of the streamline in the global coordinate - * system. Search must be performed to find initial cell to start - * integration from. - */ - void SetStartPosition(double x, double y, double z); - - /** - * Get the start position in global x-y-z coordinates. - */ - double *GetStartPosition(); - - //@{ - /** - * Specify the source object used to generate starting points. - */ - void SetSourceData(vtkDataSet *source); - vtkDataSet *GetSource(); - //@} - - /** - * Specify the source object used to generate starting points - * by making a pipeline connection - */ - void SetSourceConnection(vtkAlgorithmOutput* algOutput); - - //@{ - /** - * Specify the maximum length of the Streamer expressed in elapsed time. - */ - vtkSetClampMacro(MaximumPropagationTime,double,0.0,VTK_DOUBLE_MAX); - vtkGetMacro(MaximumPropagationTime,double); - //@} - - //@{ - /** - * Specify the direction in which to integrate the Streamer. - */ - vtkSetClampMacro(IntegrationDirection,int, - VTK_INTEGRATE_FORWARD,VTK_INTEGRATE_BOTH_DIRECTIONS); - vtkGetMacro(IntegrationDirection,int); - void SetIntegrationDirectionToForward() - {this->SetIntegrationDirection(VTK_INTEGRATE_FORWARD);}; - void SetIntegrationDirectionToBackward() - {this->SetIntegrationDirection(VTK_INTEGRATE_BACKWARD);}; - void SetIntegrationDirectionToIntegrateBothDirections() - {this->SetIntegrationDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);}; - const char *GetIntegrationDirectionAsString(); - //@} - - //@{ - /** - * Specify a nominal integration step size (expressed as a fraction of - * the size of each cell). This value can be larger than 1. - */ - vtkSetClampMacro(IntegrationStepLength,double,0.0000001,VTK_DOUBLE_MAX); - vtkGetMacro(IntegrationStepLength,double); - //@} - - //@{ - /** - * Turn on/off the creation of scalar data from velocity magnitude. If off, - * and input dataset has scalars, input dataset scalars are used. - */ - vtkSetMacro(SpeedScalars,int); - vtkGetMacro(SpeedScalars,int); - vtkBooleanMacro(SpeedScalars,int); - //@} - - //@{ - /** - * Turn on/off the creation of scalar data from vorticity information. - * The scalar information is currently the orientation value "theta" - * used in rotating stream tubes. If off, and input dataset has scalars, - * then input dataset scalars are used, unless SpeedScalars is also on. - * SpeedScalars takes precedence over OrientationScalars. - */ - vtkSetMacro(OrientationScalars, int); - vtkGetMacro(OrientationScalars, int); - vtkBooleanMacro(OrientationScalars, int); - //@} - - //@{ - /** - * Set/get terminal speed (i.e., speed is velocity magnitude). Terminal - * speed is speed at which streamer will terminate propagation. - */ - vtkSetClampMacro(TerminalSpeed,double,0.0,VTK_DOUBLE_MAX); - vtkGetMacro(TerminalSpeed,double); - //@} - - //@{ - /** - * Turn on/off the computation of vorticity. Vorticity is an indication of - * the rotation of the flow. In combination with vtkStreamLine and - * vtkTubeFilter can be used to create rotated tubes. - * If vorticity is turned on, in the output, the velocity vectors - * are replaced by vorticity vectors. - */ - vtkSetMacro(Vorticity,int); - vtkGetMacro(Vorticity,int); - vtkBooleanMacro(Vorticity,int); - //@} - - vtkSetMacro( NumberOfThreads, int ); - vtkGetMacro( NumberOfThreads, int ); - - vtkSetMacro( SavePointInterval, double ); - vtkGetMacro( SavePointInterval, double ); - - //@{ - /** - * Set/get the integrator type to be used in the stream line - * calculation. The object passed is not actually used but - * is cloned with NewInstance by each thread/process in the - * process of integration (prototype pattern). The default is - * 2nd order Runge Kutta. - */ - void SetIntegrator(vtkInitialValueProblemSolver *); - vtkGetObjectMacro ( Integrator, vtkInitialValueProblemSolver ); - //@} - - //@{ - /** - * A positive value, as small as possible for numerical comparison. - * The initial value is 1E-12. - */ - vtkSetMacro(Epsilon,double); - vtkGetMacro(Epsilon,double); - //@} - -protected: - //@{ - /** - * Construct object to start from position (0,0,0); integrate forward; - * terminal speed 0.0; vorticity computation off; integrations step length - * 0.2; and maximum propagation time 100.0. - */ - vtkStreamer(); - ~vtkStreamer() VTK_OVERRIDE; - //@} - - // Integrate data - void Integrate(vtkDataSet *input, vtkDataSet *source); - - // Controls where streamlines start from (either position or location). - int StartFrom; - - // Starting from cell location - vtkIdType StartCell; - int StartSubId; - double StartPCoords[3]; - - // starting from global x-y-z position - double StartPosition[3]; - - // - // Special classes for manipulating data - // - class StreamPoint { - public: - double x[3]; // position - vtkIdType cellId; // cell - int subId; // cell sub id - double p[3]; // parametric coords in cell - double v[3]; // velocity - double speed; // velocity norm - double s; // scalar value - double t; // time travelled so far - double d; // distance travelled so far - double omega; // stream vorticity, if computed - double theta; // rotation angle, if vorticity is computed - }; - - class StreamArray; - friend class StreamArray; - class StreamArray { //;prevent man page generation - public: - StreamArray(); - ~StreamArray() - { - delete [] this->Array; - }; - vtkIdType GetNumberOfPoints() {return this->MaxId + 1;}; - StreamPoint *GetStreamPoint(vtkIdType i) {return this->Array + i;}; - vtkIdType InsertNextStreamPoint() - { - if ( ++this->MaxId >= this->Size ) - { - this->Resize(this->MaxId); - } - return this->MaxId; //return offset from array - } - StreamPoint *Resize(vtkIdType sz); //reallocates data - void Reset() {this->MaxId = -1;}; - - StreamPoint *Array; // pointer to data - vtkIdType MaxId; // maximum index inserted thus far - vtkIdType Size; // allocated size of data - vtkIdType Extend; // grow array by this amount - double Direction; // integration direction - }; - - // - - //array of streamers - StreamArray *Streamers; - vtkIdType NumberOfStreamers; - - // length of Streamer is generated by time, or by MaximumSteps - double MaximumPropagationTime; - - // integration direction - int IntegrationDirection; - - // the length (fraction of cell size) of integration steps - double IntegrationStepLength; - - // boolean controls whether vorticity is computed - int Vorticity; - - // terminal propagation speed - double TerminalSpeed; - - // boolean controls whether data scalars or velocity magnitude are used - int SpeedScalars; - - // boolean controls whether data scalars or vorticity orientation are used - int OrientationScalars; - - // Prototype showing the integrator type to be set by the user. - vtkInitialValueProblemSolver* Integrator; - - // A positive value, as small as possible for numerical comparison. - // The initial value is 1E-12. - double Epsilon; - - // Interval with which the stream points will be stored. - // Useful in reducing the memory footprint. Since the initial - // value is small, by default, it will store all/most points. - double SavePointInterval; - - static VTK_THREAD_RETURN_TYPE ThreadedIntegrate( void *arg ); - - //@{ - /** - * These methods were added to allow access to these variables from the - * threads. - */ - vtkGetMacro( NumberOfStreamers, vtkIdType ); - StreamArray *GetStreamers() { return this->Streamers; }; - //@} - - void InitializeThreadedIntegrate(); - vtkMultiThreader *Threader; - int NumberOfThreads; - - int FillInputPortInformation(int port, vtkInformation *info) VTK_OVERRIDE; - -private: - vtkStreamer(const vtkStreamer&) VTK_DELETE_FUNCTION; - void operator=(const vtkStreamer&) VTK_DELETE_FUNCTION; -}; - -//@{ -/** - * Return the integration direction as a character string. - */ -inline const char *vtkStreamer::GetIntegrationDirectionAsString() -{ - if ( this->IntegrationDirection == VTK_INTEGRATE_FORWARD ) - { - return "IntegrateForward"; - } - else if ( this->IntegrationDirection == VTK_INTEGRATE_BACKWARD ) - { - return "IntegrateBackward"; - } - else - { - return "IntegrateBothDirections"; - } -} -//@} - -#endif // VTK_LEGACY_REMOVE -#endif