Commit 66b49de0 authored by Will Schroeder's avatar Will Schroeder
Browse files

*** empty log message ***

parent b5c217d2
......@@ -47,10 +47,11 @@ public:
// Dimensionality of cell (0,1,2, or 3)
virtual int CellDimension() = 0;
// return inside cell (!=0) if <= tolerance squared; evaluate parametric
// coordinates, sub-cell id (if cell is composite), and distance squared
// of point x[3] to cell.
virtual float EvaluatePosition(float x[3], int& subId, float pcoords[3]) = 0;
// given a point x[3] return inside(=1) or outside(=0) cell; evaluate
// parametric coordinates, sub-cell id (!=0 only if cell is composite), and
// distance squared of point x[3] to cell (in particular, the sub-cell
// indicated).
virtual int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2) = 0;
// Determine global coordinate from subId and parametric coordinates
virtual void EvaluateLocation(int& subId, float pcoords[3], float x[3]) = 0;
......
......@@ -33,7 +33,7 @@ public:
void Contour(float value, vlFloatScalars *cellScalars,
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys, vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
void ShapeFunctions(float pcoords[3], float sf[8]);
void ShapeDerivs(float pcoords[3], float derivs[24]);
......
......@@ -34,7 +34,7 @@ public:
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys,
vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
Intersection(float x[3], float xray[3], float x1[3], float x2[3],
......
......@@ -33,7 +33,7 @@ public:
void Contour(float value, vlFloatScalars *cellScalars,
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys, vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
};
......
......@@ -41,7 +41,7 @@ public:
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys,
vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
};
......
......@@ -33,7 +33,7 @@ public:
void Contour(float value, vlFloatScalars *cellScalars,
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys, vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
};
......
......@@ -40,7 +40,7 @@ public:
void Contour(float value, vlFloatScalars *cellScalars,
vlFloatPoints *points,vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys, vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
int ParameterizePolygon(float p0[3], float p10[3], float &l10,
......
......@@ -33,7 +33,7 @@ public:
void Contour(float value, vlFloatScalars *cellScalars,
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys, vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
void ShapeFunctions(float pcoords[3], float sf[4]);
void ShapeDerivs(float pcoords[3], float derivs[12]);
......
......@@ -33,7 +33,7 @@ public:
void Contour(float value, vlFloatScalars *cellScalars,
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys, vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
};
......@@ -41,3 +41,4 @@ public:
#endif
......@@ -34,7 +34,7 @@ public:
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys,
vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
};
......
......@@ -34,7 +34,7 @@ public:
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys,
vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
};
......
......@@ -33,7 +33,7 @@ public:
void Contour(float value, vlFloatScalars *cellScalars,
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys, vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
};
......
......@@ -33,7 +33,7 @@ public:
void Contour(float value, vlFloatScalars *cellScalars,
vlFloatPoints *points, vlCellArray *verts,
vlCellArray *lines, vlCellArray *polys, vlFloatScalars *s);
float EvaluatePosition(float x[3], int& subId, float pcoords[3]);
int EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2);
void EvaluateLocation(int& subId, float pcoords[3], float x[3]);
void ShapeFunctions(float pcoords[3], float sf[8]);
void ShapeDerivs(float pcoords[3], float derivs[24]);
......
......@@ -27,14 +27,14 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
//
// Method to calculate parametric coordinates in an eight noded
// linear hexahedron element from global coordinates. Note: the natural
// formulation calls for r,s,t parametric coordinates to range range
// formulation calls for r,s,t parametric coordinates to range
// from -1<=r,s,t<=1. We need to shift to 0<=r,s,t<=1.
// Uses Newton's method to solve the non-linear equations.
//
#define MAX_ITERATION 10
#define CONVERGED 1.e-03
float vlHexahedron::EvaluatePosition(float x[3], int& subId, float pcoords[3])
int vlHexahedron::EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2)
{
int iteration, converged;
float params[3];
......@@ -85,7 +85,8 @@ float vlHexahedron::EvaluatePosition(float x[3], int& subId, float pcoords[3])
//
if ( (d=math.Determinate3x3(rcol,scol,tcol)) == 0.0 )
{
return LARGE_FLOAT;
dist2 = LARGE_FLOAT;
return 0;
}
pcoords[0] = params[0] - math.Determinate3x3 (fcol,scol,tcol) / d;
......@@ -117,7 +118,8 @@ float vlHexahedron::EvaluatePosition(float x[3], int& subId, float pcoords[3])
if ( !converged )
{
pcoords[0] = pcoords[1] = pcoords[2] = 10.0;
return LARGE_FLOAT;
dist2 = LARGE_FLOAT;
return 0;
}
else
{
......@@ -126,7 +128,8 @@ float vlHexahedron::EvaluatePosition(float x[3], int& subId, float pcoords[3])
pcoords[2] >= -1.0 && pcoords[2] <= 1.0 )
{
for(i=0; i<3; i++) pcoords[i] = 0.5*(pcoords[i]+1.0); // shift to (0,1)
return 0.0; // inside hexahedron
dist2 = 0.0; // inside hexahedron
return 1;
}
else
{
......@@ -137,7 +140,8 @@ float vlHexahedron::EvaluatePosition(float x[3], int& subId, float pcoords[3])
}
this->EvaluateLocation(subId, pcoords, closestPoint);
for(i=0; i<3; i++) pcoords[i] = 0.5*(pcoords[i]+1.0); // shift to (0,1)
return math.Distance2BetweenPoints(closestPoint,x);
dist2 = math.Distance2BetweenPoints(closestPoint,x);
return 0;
}
}
}
......
......@@ -144,7 +144,7 @@ void vlImplicitModeller::Execute()
x[0] = this->AspectRatio[0] * i + this->Origin[0];
idx = jkFactor*k + this->Dimension[0]*j + i;
prevDistance2 = newScalars->GetScalar(idx);
distance2 = cell->EvaluatePosition(x,subId,pcoords);
cell->EvaluatePosition(x, subId, pcoords, distance2);
if (distance2 < prevDistance2)
newScalars->SetScalar(idx,distance2);
}
......
......@@ -22,10 +22,11 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#define INTERSECTION 2
#define ON_LINE 6
float vlLine::EvaluatePosition(float x[3], int& subId, float pcoords[3])
int vlLine::EvaluatePosition(float x[3], int& subId,
float pcoords[3], float& dist2)
{
float *a1, *a2, a21[3], denom, num, *closestPoint;
int i, numPts;
int i, numPts, return_status;
vlMath math;
subId = 0;
......@@ -45,7 +46,7 @@ float vlLine::EvaluatePosition(float x[3], int& subId, float pcoords[3])
if ( (denom = math.Dot(a21,a21)) < fabs(TOL*num) )
{
return LARGE_FLOAT;
dist2 = LARGE_FLOAT;
}
else
{
......@@ -58,18 +59,22 @@ float vlLine::EvaluatePosition(float x[3], int& subId, float pcoords[3])
if ( pcoords[0] < 0.0 )
{
closestPoint = a1;
return_status = 0;
}
else if ( pcoords[0] > 1.0 )
{
closestPoint = a2;
return_status = 0;
}
else
{
closestPoint = a21;
for (i=0; i<3; i++) a21[i] = a1[i] + pcoords[0]*a21[i];
return_status = 1;
}
return math.Distance2BetweenPoints(closestPoint,x);
dist2 = math.Distance2BetweenPoints(closestPoint,x);
return return_status;
}
void vlLine::EvaluateLocation(int& subId, float pcoords[3], float x[3])
......
......@@ -25,7 +25,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
// Note: the ordering of the Points and PointIds is important. See text.
//
float vlRectangle::EvaluatePosition(float x[3], int& subId, float pcoords[3])
int vlRectangle::EvaluatePosition(float x[3], int& subId, float pcoords[3], float& dist2)
{
float *pt1, *pt2, *pt3;
vlPolygon poly;
......@@ -60,23 +60,25 @@ float vlRectangle::EvaluatePosition(float x[3], int& subId, float pcoords[3])
if ( (l21=math.Norm(p21)) == 0.0 ) l21 = 1.0;
if ( (l31=math.Norm(p31)) == 0.0 ) l31 = 1.0;
pcoords[0] = math.Dot(p21,p) / l21;
pcoords[1] = math.Dot(p31,p) / l31;
pcoords[0] = math.Dot(p21,p) / (l21*l21);
pcoords[1] = math.Dot(p31,p) / (l31*l31);
if ( pcoords[0] >= -1.0 && pcoords[1] <= 1.0 &&
pcoords[1] >= -1.0 && pcoords[1] <= 1.0 )
if ( pcoords[0] >= 0.0 && pcoords[1] <= 1.0 &&
pcoords[1] >= 0.0 && pcoords[1] <= 1.0 )
{
return math.Distance2BetweenPoints(xProj,x); //projection distance
dist2 = math.Distance2BetweenPoints(xProj,x); //projection distance
return 1;
}
else
{
for (i=0; i<2; i++)
{
if (pcoords[i] < -1.0) pcoords[i] = -1.0;
if (pcoords[i] < 0.0) pcoords[i] = 0.0;
if (pcoords[i] > 1.0) pcoords[i] = 1.0;
}
this->EvaluateLocation(subId, pcoords, closestPoint);
return math.Distance2BetweenPoints(closestPoint,x);
dist2 = math.Distance2BetweenPoints(closestPoint,x);
return 0;
}
}
......
......@@ -90,27 +90,29 @@ int vlPolyLine::GenerateNormals(vlPoints *pts, vlCellArray *lines, vlFloatNormal
//
static vlLine line;
float vlPolyLine::EvaluatePosition(float x[3], int& subId, float pcoords[3])
int vlPolyLine::EvaluatePosition(float x[3], int& subId, float pcoords[3], float& minDist2)
{
float pc[3], dist2, minDist2;
int ignoreId, i;
float pc[3], dist2;
int ignoreId, i, return_status, status;
pcoords[1] = pcoords[2] = 0.0;
return_status = 0;
for (minDist2=LARGE_FLOAT,i=0; i<this->Points.GetNumberOfPoints()-1; i++)
{
line.Points.SetPoint(0,this->Points.GetPoint(i));
line.Points.SetPoint(1,this->Points.GetPoint(i+1));
dist2 = line.EvaluatePosition(x, ignoreId, pc);
status = line.EvaluatePosition(x, ignoreId, pc, dist2);
if ( dist2 < minDist2 )
{
return_status = status;
subId = i;
pcoords[0] = pc[0];
minDist2 = dist2;
}
}
return minDist2;
return return_status;
}
void vlPolyLine::EvaluateLocation(int& subId, float pcoords[3], float x[3])
......
......@@ -18,11 +18,11 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "PolyPts.hh"
#include "vlMath.hh"
float vlPolyPoints::EvaluatePosition(float x[3], int& subId, float pcoords[3])
int vlPolyPoints::EvaluatePosition(float x[3], int& subId, float pcoords[3], float& minDist2)
{
int numPts=this->Points.GetNumberOfPoints();
float *X;
float dist2, minDist2;
float dist2;
int i;
vlMath math;
......@@ -39,14 +39,14 @@ float vlPolyPoints::EvaluatePosition(float x[3], int& subId, float pcoords[3])
if (minDist2 == 0.0)
{
return 1;
pcoords[0] = 0.0;
}
else
{
return 0;
pcoords[0] = -10.0;
}
return minDist2;
}
void vlPolyPoints::EvaluateLocation(int& subId, float pcoords[3], float x[3])
......
......@@ -138,7 +138,7 @@ void vlPolygon::ComputeNormal(vlFloatPoints *p, float *n)
}
}
float vlPolygon::EvaluatePosition(float x[3], int& subId, float pcoords[3])
int vlPolygon::EvaluatePosition(float x[3], int& subId, float pcoords[3], float& minDist2)
{
int i;
float p0[3], p10[3], l10, p20[3], l20, n[3];
......@@ -157,13 +157,14 @@ float vlPolygon::EvaluatePosition(float x[3], int& subId, float pcoords[3])
pcoords[1] >= 0.0 && pcoords[1] <= 1.0 &&
this->PointInPolygon(this->GetBounds(),xproj,n) == INSIDE )
{
return math.Distance2BetweenPoints(x,xproj);
minDist2 = math.Distance2BetweenPoints(x,xproj);
return 1;
}
//
// If here, point is outside of polygon, so need to find distance to boundary
//
vlLine line;
float pc[3], dist2, minDist2;
float pc[3], dist2;
int ignoreId, numPts;
vlFloatPoints pts(2);
......@@ -172,14 +173,14 @@ float vlPolygon::EvaluatePosition(float x[3], int& subId, float pcoords[3])
{
line.Points.SetPoint(0,this->Points.GetPoint(i));
line.Points.SetPoint(1,this->Points.GetPoint(i+1));
dist2 = line.EvaluatePosition(x, ignoreId, pc);
line.EvaluatePosition(x, ignoreId, pc, dist2);
if ( dist2 < minDist2 )
{
minDist2 = dist2;
}
}
return minDist2;
return 0;
}
void vlPolygon::EvaluateLocation(int& subId, float pcoords[3], float x[3])
......
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