Commit 1915dab2 authored by whitlocb's avatar whitlocb

Fix some issues identified by Klocwork.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@16460 18c085ea-50e0-402c-830e-de6fd14e8384
parent 6a41fb72
......@@ -1456,22 +1456,28 @@ avtTransformManager::AddVertexCellsToPointsOnlyDataset(avtDatabaseMetaData *md,
if (doType == VTK_POLY_DATA)
{
vtkPolyData *pd = vtkPolyData::SafeDownCast(ds);
pd->Allocate(ds->GetNumberOfPoints());
for (i = 0; i < ds->GetNumberOfPoints(); i++)
if(pd != NULL)
{
onevertex[0] = i;
pd->InsertNextCell(VTK_VERTEX, 1, onevertex);
pd->Allocate(ds->GetNumberOfPoints());
for (i = 0; i < ds->GetNumberOfPoints(); i++)
{
onevertex[0] = i;
pd->InsertNextCell(VTK_VERTEX, 1, onevertex);
}
}
}
else // must be VTK_UNSTRUCTURED_GRID
{
vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::SafeDownCast(ds);
ugrid->Allocate(ds->GetNumberOfPoints());
for (i = 0; i < ds->GetNumberOfPoints(); i++)
if(ugrid != NULL)
{
onevertex[0] = i;
ugrid->InsertNextCell(VTK_VERTEX, 1, onevertex);
ugrid->Allocate(ds->GetNumberOfPoints());
for (i = 0; i < ds->GetNumberOfPoints(); i++)
{
onevertex[0] = i;
ugrid->InsertNextCell(VTK_VERTEX, 1, onevertex);
}
}
}
......
......@@ -1254,17 +1254,22 @@ avtGradientExpression::NodalToZonalQuadHexGrad(vtkStructuredGrid *in_ds,
if( val != NULL)
{
vtkDataSet *new_ds = (vtkDataSet*) in_ds->NewInstance();
new_ds->CopyStructure(in_ds);
char *name = val->GetName();
new_ds->GetCellData()->AddArray(val);
vtkCellDataToPointData *cd2pd = vtkCellDataToPointData::New();
cd2pd->SetInput(new_ds);
cd2pd->Update();
val = cd2pd->GetOutput()->GetPointData()->GetArray(name);
val->Register(NULL);
own_values_array =true;
new_ds->Delete();
cd2pd->Delete();
if (new_ds != NULL && cd2pd != NULL)
{
new_ds->CopyStructure(in_ds);
char *name = val->GetName();
new_ds->GetCellData()->AddArray(val);
cd2pd->SetInput(new_ds);
cd2pd->Update();
val = cd2pd->GetOutput()->GetPointData()->GetArray(name);
val->Register(NULL);
own_values_array = true;
}
if (new_ds != NULL)
new_ds->Delete();
if (cd2pd != NULL)
cd2pd->Delete();
}
if( val == NULL || val->GetNumberOfComponents() != 1 )
......
......@@ -137,7 +137,7 @@ avtCornerAngle::GetCornerAngle(vtkCell *cell)
int ID = cell->GetPointId(i);
double ptV[3];
cell->GetPoints()->GetPoint(i, ptV);
double A[3][3];
double A[4][3];
// Identify the edges adjacent to this vertex.
int numEdges = 0;
......
......@@ -84,11 +84,11 @@ using std::map;
class vtkVisItERIACamera : vtkCamera
{
public:
int GetLeftEye() const { return LeftEye; };
virtual int GetLeftEye() { return LeftEye; };
};
static bool GetCameraLeftEye(const vtkCamera *const vtkCam)
static bool GetCameraLeftEye(vtkCamera *vtkCam)
{
const vtkVisItERIACamera *const eriaCam = (vtkVisItERIACamera*) vtkCam;
vtkVisItERIACamera *eriaCam = (vtkVisItERIACamera*)vtkCam;
return eriaCam->GetLeftEye() == 1;
}
......@@ -291,7 +291,7 @@ avtExternallyRenderedImagesActor::DoExternalRender(avtDataObject_p &dob,
// ****************************************************************************
void
avtExternallyRenderedImagesActor::PrepareForRender(const vtkCamera *const cam)
avtExternallyRenderedImagesActor::PrepareForRender(vtkCamera *cam)
{
// return early if we're not supposed to be making external render requests
if (!makeExternalRenderRequests)
......
......@@ -163,7 +163,7 @@ class PLOTTER_API avtExternallyRenderedImagesActor
// used to send essential information to ERIA so that it will have that
// information when it receives a render request
void PrepareForRender(const vtkCamera *const cam);
void PrepareForRender(vtkCamera *cam);
// used to temporarily control visibility of ERIA while its in a window
bool SetVisibility(const bool mode);
......
......@@ -372,6 +372,13 @@ void vtkOpenGLStructuredGridMapper::Render(vtkRenderer *ren, vtkActor *act)
int vtkOpenGLStructuredGridMapper::Draw(vtkRenderer *ren, vtkActor *act)
{
vtkStructuredGrid *input = this->GetInput();
if (input == NULL)
{
vtkErrorMacro("The input to the Structured grid mapper was NULL");
return 0;
}
int dims[3];
input->GetDimensions(dims);
bool flatI = (dims[0] <= 1);
......@@ -380,7 +387,7 @@ int vtkOpenGLStructuredGridMapper::Draw(vtkRenderer *ren, vtkActor *act)
if (!flatI && !flatJ && !flatK)
{
vtkErrorMacro("One of the dimensions must be flat!!\n"
"Rectilinear grid mapper unable to render");
"Structured grid mapper unable to render");
return 0;
}
......
......@@ -102,8 +102,11 @@ double *vtkStructuredGridMapper::GetBounds()
if (this->GetNumberOfInputConnections(0))
{
this->Update();
this->GetInput()->GetBounds(this->Bounds);
return this->Bounds;
if(this->GetInput() != NULL)
{
this->GetInput()->GetBounds(this->Bounds);
return this->Bounds;
}
}
return bounds;
......
......@@ -106,7 +106,8 @@ vtkVisItTextActor::ComputeScaledFont(vtkViewport *viewport)
// Override the behavior for viewport scaling mode.
if (this->TextScaleMode == TEXT_SCALE_MODE_VIEWPORT)
{
if (this->ScaledTextProperty->GetMTime() < this->TextProperty->GetMTime())
if (this->TextProperty != NULL &&
this->ScaledTextProperty->GetMTime() < this->TextProperty->GetMTime())
{
this->ScaledTextProperty->ShallowCopy(this->TextProperty);
}
......
......@@ -37,7 +37,7 @@
*****************************************************************************/
// ************************************************************************* //
// avtEnSightFileFormat.C //
// avtEnSightFileFormat.C //
// ************************************************************************* //
#include <avtEnSightFileFormat.h>
......@@ -579,7 +579,8 @@ avtEnSightFileFormat::GetMesh(int ts, int dom, const char *name)
doneUpdate = true;
}
vtkDataSet *rv = (vtkDataSet *)reader->GetOutput()->GetBlock(dom)->NewInstance();
rv->CopyStructure((vtkDataSet *)reader->GetOutput()->GetBlock(dom));
if(rv != NULL)
rv->CopyStructure((vtkDataSet *)reader->GetOutput()->GetBlock(dom));
return rv;
}
......
......@@ -1152,7 +1152,7 @@ avtGMVFileFormat::ReadData()
meshdata.material = NULL;
meshdata.materialCentering = CELL;
avtMeshType mt;
avtMeshType mt = AVT_UNKNOWN_MESH;
int topological_dimension = 3;
if(gmv_data.datatype == UNSTRUCT)
{
......@@ -1222,7 +1222,7 @@ avtGMVFileFormat::ReadData()
#ifndef MDSERVER
vtkDataArray *mats = gmvCreateVariable("material");
// Expand out the data if we needed to split cells or add nodes.
if(pos->second.polyhedralSplit != NULL)
if(mats != NULL && pos->second.polyhedralSplit != NULL)
{
vtkDataArray *expanded = pos->second.polyhedralSplit->
ExpandDataArray(mats, gmv_data.datatype == CELL, false);
......
......@@ -2906,7 +2906,8 @@ avtPLOT3DFileFormat::GetMesh(int dom, const char *name)
reader->SetVectorFunctionNumber(-1);
reader->GetOutput()->Update();
vtkDataSet *rv = (vtkDataSet *) reader->GetOutput()->NewInstance();
rv->ShallowCopy(reader->GetOutput());
if(rv != NULL)
rv->ShallowCopy(reader->GetOutput());
return rv;
}
......
......@@ -373,6 +373,7 @@ avtTSurfFileFormat::ReadFile(const char *name, int nLines)
}
fseek(fp, 0, SEEK_END);
fileSize = ftell(fp);
fclose(fp);
debug4 << "File is " << fileSize << " bytes long." << endl;
// Make a guess about the number of cells and points based on
......@@ -453,17 +454,17 @@ avtTSurfFileFormat::ReadFile(const char *name, int nLines)
else if(strncmp(line, "TRGL", 4) == 0)
{
recognized = true;
int iverts[3] = {1,1,1};
if(sscanf(line, "TRGL %d %d %d",
&verts[0], &verts[1], &verts[2]) != 3)
&iverts[0], &iverts[1], &iverts[2]) != 3)
{
debug4 << "Error at line: " << line << endl;
}
// Make them be zero offset.
--verts[0];
--verts[1];
--verts[2];
verts[0] = iverts[0]-1;
verts[1] = iverts[1]-1;
verts[2] = iverts[2]-1;
#if 0
debug4 << verts[0]
<< ", " << verts[1]
......
......@@ -1000,7 +1000,7 @@ CumulativeQuery::SelectAndHistogram(const SelectionProperties &props,
// We need to bin the index array into some number of bins and select
// the cells in the selected bins into our new narrowed selection.
int *binPoints, numBins;
int *binPoints = NULL, numBins = 0;
// For IDs the bins are based on the number of cells
if(props.GetHistogramType() == SelectionProperties::HistogramID)
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC
* Copyright (c) 2000 - 2011, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400142
* All rights reserved.
......@@ -980,19 +980,31 @@ void write_regular_mesh(const char *filename, int ub, int *dims,
float *y = (float *) malloc(sizeof(float)*dims[1]);
float *z = (float *) malloc(sizeof(float)*dims[2]);
for (i = 0 ; i < dims[0] ; i++)
x[i] = (float) i;
for (i = 0 ; i < dims[1] ; i++)
y[i] = (float) i;
for (i = 0 ; i < dims[2] ; i++)
z[i] = (float) i;
if (x != NULL)
{
for (i = 0 ; i < dims[0] ; i++)
x[i] = (float) i;
}
if(y != NULL)
{
for (i = 0 ; i < dims[1] ; i++)
y[i] = (float) i;
}
if(z != NULL)
{
for (i = 0 ; i < dims[2] ; i++)
z[i] = (float) i;
}
write_rectilinear_mesh(filename, ub, dims, x, y, z, nvars, vardim,
centering, varnames, vars);
free(x);
free(y);
free(z);
if(x != NULL)
free(x);
if(y != NULL)
free(y);
if(z != NULL)
free(z);
}
......
......@@ -148,6 +148,11 @@ void vtkVisItCellDataToPointData::Execute()
vars_out[i] = (float *) outPD->GetArray(inPD->GetArray(i)->GetName())
->GetVoidPointer(0);
}
for (i = nvals ; i < maxArrays ; i++)
{
vars_in[i] = NULL;
vars_out[i] = NULL;
}
for (k = 0 ; k < dims[2] ; k++)
{
......
......@@ -754,10 +754,11 @@ void vtkVisItCellLocator::FindClosestPoint(double x[3], double closestPoint[3],
int closestSubCell = -1;
int leafStart;
int level;
int ijk[3];
int ijk[3]={0,0,0};
double minDist2, refinedRadius2, distance2ToBucket;
double distance2ToCellBounds, cellBounds[6];
double pcoords[3], point[3], cachedPoint[3], weightsArray[6];
double pcoords[3]={0.,0.,0.}, point[3]={0.,0.,0.},
cachedPoint[3]={0.,0.,0.}, weightsArray[6]={0.,0.,0.,0.,0.,0.};
double *weights = weightsArray;
int nWeights = 6, nPoints, cellIsGhost;
vtkIdList *cellIds;
......
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