Commit fdff30c6 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Improved FindCell interface

parent 73ecf2ed
......@@ -62,8 +62,10 @@ public:
// Locate cell based on global coordinate x and tolerance squared. If cell
// is non-Null, then search starts from this cell and looks at
// immediate neighbors. Returns cellId >= 0 if inside, < 0 otherwise.
virtual int FindCell(float x[3], vlCell *cell, float tol2) = 0;
// immediate neighbors. Returns cellId >= 0 if inside, < 0 otherwise. The
// parametric coords are provided in pcoords[3].
virtual int FindCell(float x[3], vlCell *cell, float tol2,
int& subId, float pcoords[3]) = 0;
// some data sets are composite objects and need to check each part for MTime
unsigned long int GetMTime();
......
......@@ -43,7 +43,8 @@ public:
// Locate cell based on global coordinate x and tolerance squared. If cell
// is non-Null, then search starts from this cell and looks at
// immediate neighbors. Returns cellId >= 0 if inside, < 0 otherwise.
int FindCell(float x[3], vlCell *cell, float tol2);
int FindCell(float x[3], vlCell *cell, float tol2,
int& subId, float pcoords[3]);
// some data sets are composite objects and need to check each part for MTime
unsigned long int GetMTime();
......
......@@ -37,7 +37,8 @@ public:
vlCell *GetCell(int cellId);
vlMapper *MakeMapper() {return (vlMapper *)0;};
void Initialize();
int FindCell(float x[3], vlCell *cell, float tol2);
int FindCell(float x[3], vlCell *cell, float tol2,
int& subId, float pcoords[3]);
int GetCellType(int cellId);
vlSetVector3Macro(AspectRatio,float);
......
......@@ -87,7 +87,8 @@ void vlPointSet::PrintSelf(ostream& os, vlIndent indent)
}
}
int vlPointSet::FindCell(float x[3], vlCell *cell, float tol2)
int vlPointSet::FindCell(float x[3], vlCell *cell, float tol2, int& subId,
float pcoords[3])
{
int i;
int closestCell = -1;
......@@ -95,8 +96,8 @@ int vlPointSet::FindCell(float x[3], vlCell *cell, float tol2)
int ptId, cellId;
float dist2;
static vlIdList cellIds(MAX_CELL_SIZE);
int subId;
float pcoords[3], weights[MAX_CELL_SIZE];
int sId;
float pc[3], weights[MAX_CELL_SIZE];
float closestPoint[3];
if ( !this->Points ) return -1;
......@@ -122,8 +123,13 @@ int vlPointSet::FindCell(float x[3], vlCell *cell, float tol2)
{
cellId = cellIds.GetId(i);
cell = this->GetCell(cellId);
cell->EvaluatePosition(x,closestPoint,subId,pcoords,dist2,weights);
if ( dist2 <= tol2 ) closestCell = cellId;
cell->EvaluatePosition(x,closestPoint,sId,pc,dist2,weights);
if ( dist2 <= tol2 )
{
closestCell = cellId;
subId = sId;
pcoords[0] = pc[0]; pcoords[1] = pc[1]; pcoords[2] = pc[2];
}
}
}
return closestCell;
......
......@@ -227,10 +227,11 @@ void vlStructuredPoints::Initialize()
this->SetOrigin(0,0,0);
}
int vlStructuredPoints::FindCell(float x[3], vlCell *cell, float tol2)
int vlStructuredPoints::FindCell(float x[3], vlCell *cell, float tol2,
int& subId, float pcoords[3])
{
int i, loc[3];
float d;
float d, floatLoc[3];
//
// Compute the ijk location
//
......@@ -243,12 +244,15 @@ int vlStructuredPoints::FindCell(float x[3], vlCell *cell, float tol2)
}
else
{
loc[i] = d / this->AspectRatio[i];
floatLoc[i] = d / this->AspectRatio[i];
loc[i] = (int) floatLoc[i];
pcoords[i] = floatLoc[i] - (float)loc[i];
}
}
//
// From this location get the cell number
//
subId = 0;
return loc[2] * (this->Dimensions[0]-1)*(this->Dimensions[1]-1) +
loc[1] * (this->Dimensions[0]-1) + loc[0];
}
......
Supports Markdown
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