Commit 52b19fad authored by Will Schroeder's avatar Will Schroeder
Browse files

Fixed VTK_MAX_CELL_SIZE

parent 981c7b9f
......@@ -66,6 +66,7 @@ public:
int GetNumberOfScalars() {return (this->S.GetMaxId()+1)/2;};
void Squeeze() {this->S.Squeeze();};
int GetNumberOfValuesPerScalar() {return 2;};
float GetScalar(int i);
// miscellaneous
vtkAGraymap &operator=(const vtkAGraymap& fs);
......@@ -75,7 +76,6 @@ public:
unsigned char *WritePtr(const int id, const int number);
void WrotePtr();
// vtkColorScalar interface.
unsigned char *GetColor(int id);
void GetColor(int id, unsigned char rgba[4]);
......@@ -83,6 +83,13 @@ public:
void InsertColor(int id, unsigned char rgba[4]);
int InsertNextColor(unsigned char rgba[4]);
// methods specific to this class
unsigned char *GetAGrayValue(int id);
void GetAGrayValue(int id, unsigned char ga[2]);
void SetAGrayValue(int id, unsigned char ga[2]);
void InsertAGrayValue(int id, unsigned char ga[2]);
int InsertNextAGrayValue(unsigned char ga[2]);
protected:
vtkUnsignedCharArray S;
};
......@@ -92,9 +99,9 @@ protected:
// range checking.
inline void vtkAGraymap::SetColor(int i, unsigned char rgba[4])
{
float g = 0.30*rgba[0] + 0.59*rgba[1] + 0.11*rgba[2];
i *= 2;
this->S[i] = (rgba[0] > rgba[1] ? (rgba[0] > rgba[2] ? rgba[0] : rgba[2]) :
(rgba[1] > rgba[2] ? rgba[1] : rgba[2]));
this->S[i] = (unsigned char)((g < 1.0 ? g : 1.0)*255);
this->S[i+1] = rgba[3];
}
......@@ -103,9 +110,9 @@ inline void vtkAGraymap::SetColor(int i, unsigned char rgba[4])
// checking and will allocate additional memory if necessary.
inline void vtkAGraymap::InsertColor(int i, unsigned char rgba[4])
{
float g = 0.30*rgba[0] + 0.59*rgba[1] + 0.11*rgba[2];
this->S.InsertValue(2*i+1, rgba[3]);
this->S[2*i] = (rgba[0] > rgba[1] ? (rgba[0] > rgba[2] ? rgba[0] : rgba[2]) :
(rgba[1] > rgba[2] ? rgba[1] : rgba[2]));
this->S[2*i] = (unsigned char)((g < 1.0 ? g : 1.0)*255);
}
// Description:
......@@ -114,12 +121,10 @@ inline void vtkAGraymap::InsertColor(int i, unsigned char rgba[4])
inline int vtkAGraymap::InsertNextColor(unsigned char rgba[4])
{
int id;
unsigned char intensity;
float g = 0.30*rgba[0] + 0.59*rgba[1] + 0.11*rgba[2];
intensity = (rgba[0] > rgba[1] ? (rgba[0] > rgba[2] ? rgba[0] : rgba[2]) :
(rgba[1] > rgba[2] ? rgba[1] : rgba[2]));
id = this->S.InsertNextValue(rgba[3]);
this->S.InsertNextValue(intensity);
this->S.InsertNextValue((unsigned char)(g*255));
return id/2;
}
......
......@@ -47,19 +47,14 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
// vtkPolyData, vtkUnstructuredGrid), and in some cases, the datasets are
// implicitly composed of cells (e.g., vtkStructuredPoints).
// .SECTION Caveats
// The #define VTK_MAX_CELL_SIZE specifies the maximum number of defining
// points for a cell. This parameter is not a hard boundary: in many cases
// you can create cells with more points. However there are certain filters
// (usually recursive) that allocate temporary storage. If these filters treat
// a cell with more points than VTK_MAX_CELL_SIZE they may truncate data.
// Concerns about maximum cell size arise with cells with variable length
// connectivity lists like polylines, triangle strips, or polygons). We will
// most likely eliminate this parameter in future releases of vtk.
// The #define VTK_CELL_SIZE is a parameter used to construct cells and provide
// a general guideline for controlling object execution. This parameter is
// not a hard boundary: you can create cells with more points.
#ifndef __vtkCell_h
#define __vtkCell_h
#define VTK_MAX_CELL_SIZE 512
#define VTK_CELL_SIZE 512
#define VTK_TOL 1.e-05 // Tolerance for geometric calculation
#include "vtkObject.hh"
......@@ -135,21 +130,25 @@ public:
// parametric coordinates, sub-cell id (!=0 only if cell is composite),
// distance squared of point x[3] to cell (in particular, the sub-cell
// indicated), closest point on cell to x[3], and interpolation weights
// in cell. Note: on rare occasions a -1 is returned from the method. This
// means that numerical error has occurred and all data returned from this method
// should be ignored. Also, inside/outside is determine parametrically. That
// is, a point is inside if it satisfies parametric limits. This can cause
// problems for cells of topological dimension 2 or less, since a point in
// 3D can project onto the cell within parametric limits but be "far" from
// the cell. Thus the value dist2 may be checked to determine true in/out.
// in cell. (The number of weights is equal to the number of points
// defining the cell). Note: on rare occasions a -1 is returned from the
// method. This means that numerical error has occurred and all data
// returned from this method should be ignored. Also, inside/outside
// is determine parametrically. That is, a point is inside if it
// satisfies parametric limits. This can cause problems for cells of
// topological dimension 2 or less, since a point in 3D can project
// onto the cell within parametric limits but be "far" from the cell.
// Thus the value dist2 may be checked to determine true in/out.
virtual int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[VTK_MAX_CELL_SIZE]) = 0;
float& dist2, float *weights) = 0;
// Description:
// Determine global coordinate from subId and parametric coordinates
// Determine global coordinate (x[3]) from subId and parametric coordinates.
// Also returns interpolation weights. (The number of weights is equal to
// the number of points in the cell).
virtual void EvaluateLocation(int& subId, float pcoords[3],
float x[3], float weights[VTK_MAX_CELL_SIZE]) = 0;
float x[3], float *weights) = 0;
// Description:
// Generate contouring primitives.
......
......@@ -70,13 +70,9 @@ public:
char *GetClassName() {return "vtkCellArray";};
int GetNumberOfCells();
int InsertNextCell(int npts, int* pts);
int InsertNextCell(int npts);
void InsertCellPoint(int id);
int InsertNextCell(vtkCell *cell);
// estimator for storage allocation
int EstimateSize(int numCells, int maxPtsPerCell);
void Squeeze();
void InitTraversal();
int GetNextCell(int& npts, int* &pts);
......@@ -84,6 +80,14 @@ public:
int GetSize();
void GetCell(int loc, int &npts, int* &pts);
// methods to insert cells. Can be used in combination.
int InsertNextCell(vtkCell *cell);
int InsertNextCell(int npts, int* pts);
int InsertNextCell(vtkIdList &pts);
int InsertNextCell(int npts); //this and next two methods work together
void InsertCellPoint(int id);
void UpdateCellCount(int npts);
int GetLocation(int npts);
void ReverseCell(int loc);
......@@ -96,6 +100,10 @@ public:
int *WritePtr(const int ncells, const int size);
void WrotePtr();
// reuse memory
void Reset();
void Squeeze();
protected:
int NumberOfCells;
int Location;
......@@ -120,10 +128,25 @@ inline int vtkCellArray::InsertNextCell(int npts, int* pts)
return this->NumberOfCells;
}
// Description:
// Create a cell by specifying a list of point ids.
inline int vtkCellArray::InsertNextCell(vtkIdList &pts)
{
int npts = pts.GetNumberOfIds();
int id = this->Ia.GetMaxId() + npts + 1;
this->Ia.InsertValue(id,pts.GetId(npts-1));
this->Ia[id-npts] = npts;
for (int i=0; i<npts-1; i++) this->Ia[id-npts+i+1] = pts.GetId(i);
this->NumberOfCells++;
this->Location += npts + 1;
return this->NumberOfCells;
}
// Description:
// Create cells by specifying count, and then adding points one at a time using
// method InsertCellPoint(). WARNING: it is the user's responsibility not to
// exceed the maximum allowable points per cell (VTK_MAX_CELL_SIZE).
// method InsertCellPoint(). If you don't know the count initially, use the
// method UpdateCellCount() to complete the cell.
inline int vtkCellArray::InsertNextCell(int npts)
{
this->Location = this->Ia.InsertNextValue(npts) + 1;
......@@ -140,6 +163,14 @@ inline void vtkCellArray::InsertCellPoint(int id)
this->Ia.InsertValue(this->Location++,id);
}
// Description:
// Used in conjunction with InsertNextCell(int npts) and InsertCellPoint() to
// update the number of points defining the cell.
inline void vtkCellArray::UpdateCellCount(int npts)
{
this->Ia[this->Location-npts-1] = npts;
}
// Description:
// Insert a cell object.
inline int vtkCellArray::InsertNextCell(vtkCell *cell)
......@@ -167,6 +198,15 @@ inline int vtkCellArray::EstimateSize(int numCells, int maxPtsPerCell)
return numCells*(1+maxPtsPerCell);
}
// Description:
// Reuse list. Reset to initial condition.
inline void vtkCellArray::Reset()
{
this->NumberOfCells = 0;
this->Location = 0;
this->Ia.Reset();
}
// Description:
// Reclaim any extra memory.
inline void vtkCellArray::Squeeze() {this->Ia.Squeeze();}
......
......@@ -73,7 +73,7 @@ public:
// Description:
// Set the number of facets used to represent cone.
vtkSetClampMacro(Resolution,int,0,VTK_MAX_CELL_SIZE)
vtkSetClampMacro(Resolution,int,0,VTK_CELL_SIZE)
vtkGetMacro(Resolution,int);
// Description:
......
......@@ -70,7 +70,7 @@ public:
// Description:
// Set the number of facets used to define cylinder.
vtkSetClampMacro(Resolution,int,0,VTK_MAX_CELL_SIZE)
vtkSetClampMacro(Resolution,int,0,VTK_CELL_SIZE)
vtkGetMacro(Resolution,int);
// Description:
......
......@@ -126,9 +126,11 @@ public:
// cell is non-NULL, then search starts from this cell and looks at
// immediate neighbors. Returns cellId >= 0 if inside, < 0 otherwise.
// The parametric coordinates are provided in pcoords[3]. The interpolation
// weights are returned in weights[]. Tolerance is used to control how close
// the point is to be considered "in" the cell.
virtual int FindCell(float x[3], vtkCell *cell, float tol2, int& subId, float pcoords[3], float weights[VTK_MAX_CELL_SIZE]) = 0;
// weights are returned in weights[]. (The number of weights is equal to the
// number of points in the found cell). Tolerance is used to control how
// close the point is to be considered "in" the cell.
virtual int FindCell(float x[3], vtkCell *cell, float tol2, int& subId,
float pcoords[3], float *weights) = 0;
// Datasets are composite objects and need to check each part for MTime
unsigned long int GetMTime();
......@@ -189,6 +191,11 @@ public:
// otherwise it will return 0 to 1.
float *GetScalarRange();
// Description:
// Convenience method returns largest cell size in dataset. This is generally
// used to allocate memory for supporting data structures.
virtual int GetMaxCellSize() = 0;
protected:
vtkSource *Source; // if I am the output of a Source this is a pntr to it
vtkPointData PointData; // Scalars, vectors, etc. associated w/ each point
......
......@@ -221,7 +221,7 @@ public:
// If the number of triangles connected to a vertex exceeds "Degree", then
// the vertex is considered complex and is never deleted. (NOTE: the
// complexity of the triangulation algorithm is proportional to Degree^2.)
vtkSetClampMacro(Degree,int,25,VTK_MAX_CELL_SIZE);
vtkSetClampMacro(Degree,int,25,VTK_CELL_SIZE);
vtkGetMacro(Degree,int);
protected:
......
......@@ -80,6 +80,12 @@ public:
void InsertColor(int id, unsigned char rgba[4]);
int InsertNextColor(unsigned char rgba[4]);
// Specific to this class
unsigned char GetGrayValue(int id);
void SetGrayValue(int id, unsigned char g);
void InsertGrayValue(int id, unsigned char g);
int InsertNextGrayValue(unsigned char g);
protected:
vtkUnsignedCharArray S;
};
......
......@@ -70,9 +70,9 @@ public:
vtkCellArray *lines, vtkCellArray *polys, vtkFloatScalars *s);
int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[VTK_MAX_CELL_SIZE]);
float& dist2, float *weights);
void EvaluateLocation(int& subId, float pcoords[3], float x[3],
float weights[VTK_MAX_CELL_SIZE]);
float *weights);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
......@@ -82,6 +82,7 @@ public:
// Hexahedron specific
void InterpolationFunctions(float pcoords[3], float weights[8]);
void InterpolationDerivs(float pcoords[3], float derivs[24]);
void JacobianInverse(float pcoords[3], float inverse[9], float derivs[24]);
};
......
......@@ -53,7 +53,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
class vtkIdList : public vtkObject
{
public:
vtkIdList(const int sz=128, const int ext=100):Ia(sz,ext) {};
vtkIdList(const int sz=512, const int ext=1000):Ia(sz,ext) {};
vtkIdList &operator=(const vtkIdList& ids) {this->Ia = ids.Ia; return *this;};
void Squeeze() {this->Ia.Squeeze();};
......
......@@ -70,9 +70,9 @@ public:
vtkFloatScalars *s);
int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[VTK_MAX_CELL_SIZE]);
float& dist2, float *weights);
void EvaluateLocation(int& subId, float pcoords[3], float x[3],
float weights[VTK_MAX_CELL_SIZE]);
float *weights);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
......
......@@ -43,11 +43,18 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
// vtkMCubesReader is a source object that reads binary marching cubes
// files. (Marching cubes is an isosurfacing technique that generates
// many triangles). The binary format is supported by B. Lorensen's
// marching cubes program. The format repeats point coordinates, so
// this object will merge the points with a vtkLocator object. You can
// choose to supply the vtkLocator or use the default.
// marching cubes program (and the vtkSliceCubes object). The format
// repeats point coordinates, so this object will merge the points
// with a vtkLocator object. You can choose to supply the vtkLocator
// or use the default.
// .SECTION Caveats
// Binary files assumed written in sun/hp/sgi form.
//
// Because points are merged when read, degenerate triangles may be removed.
// Thus the number of triangles read may be fewer than the number of triangles
// written.
// .SECTION See Also
// vtkMarchingCubes vtkSliceCubes
#ifndef __vtkMCubesReader_h
#define __vtkMCubesReader_h
......@@ -96,16 +103,15 @@ public:
void CreateDefaultLocator();
protected:
void Execute();
char *Filename;
char *LimitsFilename;
vtkLocator *Locator;
int SelfCreatedLocator;
int FlipNormals;
int Normals;
void Execute();
};
#endif
......
......@@ -71,9 +71,9 @@ public:
vtkCellArray *lines, vtkCellArray *polys, vtkFloatScalars *s);
int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[VTK_MAX_CELL_SIZE]);
float& dist2, float *weights);
void EvaluateLocation(int& subId, float pcoords[3], float x[3],
float weights[VTK_MAX_CELL_SIZE]);
float *weights);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
......
......@@ -68,7 +68,7 @@ public:
float *GetPoint(int ptId) {return this->Points->GetPoint(ptId);};
void GetPoint(int ptId, float x[3]) {this->Points->GetPoint(ptId,x);};
int FindCell(float x[3], vtkCell *cell, float tol2, int& subId,
float pcoords[3], float weights[VTK_MAX_CELL_SIZE]);
float pcoords[3], float *weights);
unsigned long int GetMTime();
......
......@@ -76,6 +76,8 @@ public:
int GetCellType(int cellId);
void GetCellPoints(int cellId, vtkIdList& ptIds);
void GetPointCells(int ptId, vtkIdList& cellIds);
void Squeeze();
int GetMaxCellSize();
// Can't use macros to set/get following cell arrays. This is due to tricks
// required to support traversal methods.
......@@ -98,10 +100,12 @@ public:
// Allocate storage for cells when using the following InsertNextCell method
void Allocate(int numCells=1000, int extSize=1000);
// create verts, lines, polys, tmeshes from cell object
int InsertNextCell(int type, int npts, int pts[VTK_MAX_CELL_SIZE]);
// Use this method to reclaim memory when using InsertNextCell()
void Squeeze();
// create verts, lines, polys, tmeshes from integer connectivity list
int InsertNextCell(int type, int npts, int *pts);
// create verts, lines, polys, tmeshes from id connectivity list
int InsertNextCell(int type, vtkIdList &pts);
// Use this method to start inserting from the beginning
void Reset();
// construct adjacency structure
void BuildCells();
......@@ -122,7 +126,8 @@ public:
void RemoveCellReference(int cellId);
void ResizeCellList(int ptId, int size);
// Restore data object to initial state,
// Restore data object to initial state. Warning: releases memory; may
// have to use Allocate() to reallocate memory.
virtual void Initialize();
protected:
......
......@@ -77,9 +77,9 @@ public:
vtkFloatScalars *s);
int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[VTK_MAX_CELL_SIZE]);
float& dist2, float *weights);
void EvaluateLocation(int& subId, float pcoords[3], float x[3],
float weights[VTK_MAX_CELL_SIZE]);
float *weights);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
......
......@@ -70,9 +70,9 @@ public:
vtkCellArray *lines, vtkCellArray *polys, vtkFloatScalars *s);
int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[VTK_MAX_CELL_SIZE]);
float& dist2, float *weights);
void EvaluateLocation(int& subId, float pcoords[3], float x[3],
float weights[VTK_MAX_CELL_SIZE]);
float *weights);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
......
......@@ -76,9 +76,9 @@ public:
vtkCellArray *lines, vtkCellArray *polys, vtkFloatScalars *s);
int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[VTK_MAX_CELL_SIZE]);
float& dist2, float *weights);
void EvaluateLocation(int& subId, float pcoords[3], float x[3],
float weights[VTK_MAX_CELL_SIZE]);
float *weights);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
......@@ -86,7 +86,7 @@ public:
int dim, float *derivs);
// Polygon specific
void ComputeWeights(float x[3], float weights[VTK_MAX_CELL_SIZE]);
void ComputeWeights(float x[3], float *weights);
int ParameterizePolygon(float p0[3], float p10[3], float &l10,
float p20[3], float &l20, float n[3]);
......
......@@ -70,9 +70,9 @@ public:
vtkCellArray *lines, vtkCellArray *polys, vtkFloatScalars *s);
int EvaluatePosition(float x[3], float closestPoint[3],
int& subId, float pcoords[3],
float& dist2, float weights[VTK_MAX_CELL_SIZE]);
float& dist2, float *weights);
void EvaluateLocation(int& subId, float pcoords[3], float x[3],
float weights[VTK_MAX_CELL_SIZE]);
float *weights);
int IntersectWithLine(float p1[3], float p2[3], float tol, float& t,
float x[3], float pcoords[3], int& subId);
int Triangulate(int index, vtkFloatPoints &pts);
......
......@@ -60,7 +60,7 @@ public:
// Description:
// Specify the maximum number of triangles in a triangle strip.
vtkSetClampMacro(MaximumStripLength,int,4,VTK_MAX_CELL_SIZE-2);
vtkSetClampMacro(MaximumStripLength,int,4,VTK_CELL_SIZE-2);
vtkGetMacro(MaximumStripLength,int);
// Description:
......
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