Commit 8b32854b authored by Sean McBride's avatar Sean McBride
Browse files

const improvements to APIs and internal usage

- Made a few APIs' params const
- Changed many usages of the evil GetBounds() to expect a const
  return value, even though it does not (yet?) return const
- Slightly changed return values of vtkTextActor3D::GetBounds()
  to return its own ivar instead of its ImageActor's
parent 644efb1f
......@@ -1056,7 +1056,7 @@ public:
/**
* Are the bounds initialized?
*/
static vtkTypeBool AreBoundsInitialized(double bounds[6]){
static vtkTypeBool AreBoundsInitialized(const double bounds[6]){
if ( bounds[1]-bounds[0]<0.0 )
{
return 0;
......
......@@ -217,7 +217,7 @@ void vtkPoints::PrintSelf(ostream& os, vtkIndent indent)
}
os << indent << "Number Of Points: " << this->GetNumberOfPoints() << "\n";
double *bounds = this->GetBounds();
const double *bounds = this->GetBounds();
os << indent << "Bounds: \n";
os << indent << " Xmin,Xmax: (" << bounds[0] << ", " << bounds[1] << ")\n";
os << indent << " Ymin,Ymax: (" << bounds[2] << ", " << bounds[3] << ")\n";
......
......@@ -228,7 +228,7 @@ void vtkPoints2D::PrintSelf(ostream& os, vtkIndent indent)
}
os << indent << "Number Of Points: " << this->GetNumberOfPoints() << "\n";
double *bounds = this->GetBounds();
const double *bounds = this->GetBounds();
os << indent << "Bounds: \n";
os << indent << " Xmin,Xmax: (" << bounds[0] << ", " << bounds[1] << ")\n";
os << indent << " Ymin,Ymax: (" << bounds[2] << ", " << bounds[3] << ")\n";
......
......@@ -206,7 +206,7 @@ void vtkCell::PrintSelf(ostream& os, vtkIndent indent)
if ( numIds > 0 )
{
double *bounds=this->GetBounds();
const double *bounds=this->GetBounds();
os << indent << "Bounds: \n";
os << indent << " Xmin,Xmax: (" << bounds[0] << ", " << bounds[1] << ")\n";
......
......@@ -1195,7 +1195,7 @@ void vtkCellLocator::ForceBuildLocator()
//
void vtkCellLocator::BuildLocatorInternal()
{
double *bounds, length, cellBounds[6], *boundsPtr;
double length, cellBounds[6], *boundsPtr;
vtkIdType numCells;
int ndivs, product;
int i, j, k, ijkMin[3], ijkMax[3];
......@@ -1227,7 +1227,7 @@ void vtkCellLocator::BuildLocatorInternal()
// Size the root cell. Initialize cell data structure, compute
// level and divisions.
//
bounds = this->DataSet->GetBounds();
const double *bounds = this->DataSet->GetBounds();
length = this->DataSet->GetLength();
for (i=0; i<3; i++)
{
......
......@@ -372,7 +372,8 @@ double *vtkConvexPointSet::GetParametricCoords()
this->ParametricCoords->SetNumberOfComponents(3);
this->ParametricCoords->SetNumberOfTuples(numPts);
double p[3], x[3], *bounds = this->GetBounds();
double p[3], x[3];
const double *bounds = this->GetBounds();
int i, j;
for (i=0; i < numPts; i++)
{
......
......@@ -716,8 +716,6 @@ void vtkDataSet::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
double *bounds;
os << indent << "Number Of Points: " << this->GetNumberOfPoints() << "\n";
os << indent << "Number Of Cells: " << this->GetNumberOfCells() << "\n";
......@@ -727,7 +725,7 @@ void vtkDataSet::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "Point Data:\n";
this->PointData->PrintSelf(os,indent.GetNextIndent());
bounds = this->GetBounds();
const double *bounds = this->GetBounds();
os << indent << "Bounds: \n";
os << indent << " Xmin,Xmax: (" <<bounds[0] << ", " << bounds[1] << ")\n";
os << indent << " Ymin,Ymax: (" <<bounds[2] << ", " << bounds[3] << ")\n";
......
......@@ -181,13 +181,11 @@ vtkPoints *vtkGraph::GetPoints()
//----------------------------------------------------------------------------
void vtkGraph::ComputeBounds()
{
double *bounds;
if ( this->Points )
{
if ( this->GetMTime() >= this->ComputeTime )
{
bounds = this->Points->GetBounds();
const double *bounds = this->Points->GetBounds();
for (int i=0; i<6; i++)
{
this->Bounds[i] = bounds[i];
......
......@@ -851,7 +851,6 @@ void vtkPointLocator::FindPointsWithinRadius(double R, const double x[3],
//
void vtkPointLocator::BuildLocator()
{
double *bounds;
vtkIdType numBuckets;
double level;
int ndivs[3];
......@@ -887,7 +886,7 @@ void vtkPointLocator::BuildLocator()
// Size the root bucket. Initialize bucket data structure, compute
// level and divisions.
//
bounds = this->DataSet->GetBounds();
const double *bounds = this->DataSet->GetBounds();
for (i=0; i<3; i++)
{
this->Bounds[2*i] = bounds[2*i];
......
......@@ -90,13 +90,11 @@ void vtkPointSet::Initialize()
//----------------------------------------------------------------------------
void vtkPointSet::ComputeBounds()
{
double *bounds;
if ( this->Points )
{
if ( this->GetMTime() >= this->ComputeTime )
{
bounds = this->Points->GetBounds();
const double *bounds = this->Points->GetBounds();
for (int i=0; i<6; i++)
{
this->Bounds[i] = bounds[i];
......
......@@ -840,19 +840,16 @@ int vtkPolygon::PointInPolygon (double x[3], int numPts, double *pts,
//
int vtkPolygon::Triangulate(vtkIdList *outTris)
{
int success;
double *bounds, d;
bounds = this->GetBounds();
const double *bounds = this->GetBounds();
d = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
(bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
(bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
double d = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
(bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
(bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
this->Tolerance = VTK_POLYGON_TOLERANCE * d;
this->SuccessfulTriangulation = 1;
this->Tris->Reset();
success = this->EarCutTriangulation();
int success = this->EarCutTriangulation();
if ( !success ) //degenerate triangle encountered
{
......@@ -1439,16 +1436,15 @@ void vtkPolygon::Contour(double value, vtkDataArray *cellScalars,
vtkCellData *outCd)
{
int i, success;
double *bounds, d;
int p1, p2, p3;
this->TriScalars->SetNumberOfTuples(3);
bounds = this->GetBounds();
const double *bounds = this->GetBounds();
d = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
(bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
(bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
double d = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
(bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
(bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
this->Tolerance = VTK_POLYGON_TOLERANCE * d;
this->SuccessfulTriangulation = 1;
this->ComputeNormal(this->Points, this->Normal);
......@@ -1694,15 +1690,14 @@ void vtkPolygon::Clip(double value, vtkDataArray *cellScalars,
int insideOut)
{
int i, success;
double *bounds, d;
int p1, p2, p3;
this->TriScalars->SetNumberOfTuples(3);
bounds = this->GetBounds();
d = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
(bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
(bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
const double *bounds = this->GetBounds();
double d = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
(bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
(bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
this->Tolerance = VTK_POLYGON_TOLERANCE * d;
this->SuccessfulTriangulation = 1;
......
......@@ -1372,7 +1372,6 @@ void vtkStaticPointLocator::FreeSearchStructure()
//
void vtkStaticPointLocator::BuildLocator()
{
double *bounds;
vtkIdType numBuckets;
double level;
int ndivs[3];
......@@ -1405,7 +1404,7 @@ void vtkStaticPointLocator::BuildLocator()
// level and divisions. The GetBounds() method below can be very slow;
// hopefully it is cached or otherwise accelerated.
//
bounds = this->DataSet->GetBounds();
const double *bounds = this->DataSet->GetBounds();
int numNonZeroWidths = 3;
for (i=0; i<3; i++)
{
......
......@@ -74,7 +74,7 @@ int TestPDBBallAndStickShadows(int argc, char *argv[])
// add a plane
vtkNew<vtkPlaneSource> plane;
double *bounds = molmapper->GetBounds();
const double *bounds = molmapper->GetBounds();
plane->SetOrigin(bounds[0], bounds[2], bounds[4]);
plane->SetPoint1(bounds[1], bounds[2], bounds[4]);
plane->SetPoint2(bounds[0], bounds[2], bounds[5]);
......
......@@ -113,7 +113,7 @@ int TestPDBBallAndStickShadowsDOFSSAA(int argc, char *argv[])
// add a plane
vtkNew<vtkPlaneSource> plane;
double *bounds = molmapper->GetBounds();
const double *bounds = molmapper->GetBounds();
plane->SetOrigin(bounds[0], bounds[2], bounds[4]);
plane->SetPoint1(bounds[1], bounds[2], bounds[4]);
plane->SetPoint2(bounds[0], bounds[2], bounds[5]);
......
......@@ -119,7 +119,7 @@ void gridLayoutActors( std::vector<vtkActor*> actors )
{
// move to the origin
(*it)->SetPosition( 0.0, 0.0, 0.0 );
double *b = (*it)->GetBounds();
const double *b = (*it)->GetBounds();
// X
if( b[0]<bounds[0] ) bounds[0] = b[0];
if( b[1]>bounds[1] ) bounds[1] = b[1];
......
......@@ -876,7 +876,7 @@ void vtkDataObjectGenerator::MakeValues(vtkDataSet *ds)
for (vtkIdType i = 0; i < num; i++)
{
ids->SetValue(i, this->CellIdCounter++);
double *bds = ds->GetCell(i)->GetBounds();
const double *bds = ds->GetCell(i)->GetBounds();
xcoords->SetValue(i, (bds[0]+bds[1])*0.5);
ycoords->SetValue(i, (bds[2]+bds[3])*0.5);
zcoords->SetValue(i, (bds[4]+bds[5])*0.5);
......
......@@ -141,7 +141,7 @@ int vtkDecimatePro::RequestData(
vtkIdType pt1, pt2, cellId, fedges[2];
vtkIdType *cells;
vtkIdList *CollapseTris;
double max, *bounds;
double max;
if (!input)
{
vtkErrorMacro(<<"No input!");
......@@ -166,7 +166,7 @@ int vtkDecimatePro::RequestData(
}
// Initialize
bounds = input->GetBounds();
const double *bounds = input->GetBounds();
for (max=0.0, i=0; i<3; i++)
{
max = ((bounds[2*i+1]-bounds[2*i]) > max ?
......
......@@ -321,7 +321,6 @@ int vtkDelaunay2D::RequestData(
double center[3], radius, tol, x[3];
double n1[3], n2[3];
int *triUse = NULL;
double *bounds;
vtkDebugMacro(<<"Generating 2D Delaunay triangulation");
......@@ -404,7 +403,7 @@ int vtkDelaunay2D::RequestData(
tPoints = NULL;
}
bounds = points->GetBounds();
const double *bounds = points->GetBounds();
center[0] = (bounds[0]+bounds[1])/2.0;
center[1] = (bounds[2]+bounds[3])/2.0;
center[2] = (bounds[4]+bounds[5])/2.0;
......
......@@ -484,7 +484,7 @@ int vtkHull::RequestData(
vtkIdType numPoints;
vtkPoints *outPoints;
vtkCellArray *outPolys;
double *bounds = input->GetBounds();
const double *bounds = input->GetBounds();
// Get the number of points in the input data
numPoints = input->GetNumberOfPoints();
......@@ -572,7 +572,7 @@ void vtkHull::ComputePlaneDistances(vtkPolyData *input)
// other planes to clip this polygon.
void vtkHull::ClipPolygonsFromPlanes( vtkPoints *outPoints,
vtkCellArray *outPolys,
double *bounds)
const double *bounds)
{
int i, j, k, q;
double previousD, d, crosspoint;
......@@ -686,7 +686,7 @@ void vtkHull::ClipPolygonsFromPlanes( vtkPoints *outPoints,
delete [] pnts;
}
void vtkHull::CreateInitialPolygon( double *verts, int i, double *bounds)
void vtkHull::CreateInitialPolygon( double *verts, int i, const double *bounds)
{
double center[3], d, planeCenter[3];
double v1[3], v2[3], norm, dotProduct;
......
......@@ -184,12 +184,12 @@ protected:
// Internal method used to create the actual polygons from the set
// of planes
void ClipPolygonsFromPlanes( vtkPoints *points, vtkCellArray *polys,
double *bounds );
const double *bounds );
// Internal method used to create the initial "big" polygon from the
// plane equation. This polygon is clipped by all other planes to form
// the final polygon (or it may be clipped entirely)
void CreateInitialPolygon( double *, int, double * );
void CreateInitialPolygon( double *, int, const double * );
// The method that does it all...
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment