Skip to content
Snippets Groups Projects
Commit aa464c4c authored by David E. DeMarle's avatar David E. DeMarle
Browse files

Merge branch 'removed-streamer-and-subs-deprecated-REL' into release

parents 54f33fc1 e05330f9
Branches
Tags v8.0.0.rc2
No related merge requests found
......@@ -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})
/*=========================================================================
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
/*=========================================================================
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
/*=========================================================================
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
/*=========================================================================
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
/*=========================================================================
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
/*=========================================================================
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
This diff is collapsed.
/*=========================================================================
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment