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

ENH: Enhanced for Tcl wrapping.

parent b4046e84
......@@ -67,10 +67,12 @@ public:
// Insert normal into object. Range checking performed and memory
// allocated as necessary.
virtual void InsertNormal(int id, float n[3]) = 0;
void InsertNormal(int id, float nx, float ny, float nz);
// Description:
// Insert normal into next available slot. Returns point id of slot.
virtual int InsertNextNormal(float n[3]) = 0;
int InsertNextNormal(float nx, float ny, float nz);
// Description:
// Reclaim any extra memory.
......
......@@ -66,10 +66,12 @@ public:
// Insert point into object. Range checking performed and memory
// allocated as necessary.
virtual void InsertPoint(int id, float x[3]) = 0;
void InsertPoint(int id, float x, float y, float z);
// Description:
// Insert point into next available slot. Returns point id of slot.
virtual int InsertNextPoint(float x[3]) = 0;
int InsertNextPoint(float x, float y, float z);
// Description:
// Reclaim any extra memory.
......
......@@ -68,11 +68,13 @@ public:
// Insert texture coordinate into object. Range checking performed and
// memory allocated as necessary.
virtual void InsertTCoord(int id, float *tc) = 0;
void InsertTCoord(int id, float tc1, float tc2, float tc3);
// Description:
// Insert texture coordinate into next available slot. Returns point
// id of slot.
virtual int InsertNextTCoord(float *tc) = 0;
int InsertNextTCoord(float tc1, float tc2, float tc3);
// Description:
// Reclaim any extra memory.
......
......@@ -67,11 +67,17 @@ public:
// Insert tensor into object. Range checking performed and
// memory allocated as necessary.
virtual void InsertTensor(int id, vtkTensor &t) = 0;
void InsertTensor(int id, float t11, float t12, float t13,
float t21, float t22, float t23,
float t31, float t32, float t33);
// Description:
// Insert tensor into next available slot. Returns point
// id of slot.
virtual int InsertNextTensor(vtkTensor &t) = 0;
int InsertNextTensor(float t11, float t12, float t13,
float t21, float t22, float t23,
float t31, float t32, float t33);
// Description:
// Reclaim any extra memory.
......
......@@ -66,10 +66,12 @@ public:
// Insert vector into object. Range checking performed and memory
// allocated as necessary.
virtual void InsertVector(int id, float v[3]) = 0;
void InsertVector(int id, float vx, float vy, float vz);
// Description:
// Insert vector into next available slot. Returns point id of slot.
virtual int InsertNextVector(float v[3]) = 0;
int InsertNextVector(float vx, float vy, float vz);
// Description:
// Reclaim any extra memory.
......
......@@ -18,6 +18,10 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
// vtkWarpScalar is a filter that modifies point coordinates by moving
// points along point normals by the scalar amount times the scale factor.
// Useful for creating carpet or x-y-z plots.
// If normals are not present in data, the Normal instance variable will
// be used as the direction along which to warp the geometry. If normals are
// present but you would like to use the Normals instance variable, set the
// UseNormals boolean to true.
#ifndef __vtkWarpScalar_h
#define __vtkWarpScalar_h
......@@ -27,7 +31,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
class vtkWarpScalar : public vtkPointSetToPointSetFilter
{
public:
vtkWarpScalar() : ScaleFactor(1.0) {};
vtkWarpScalar();
~vtkWarpScalar() {};
char *GetClassName() {return "vtkWarpScalar";};
void PrintSelf(ostream& os, vtkIndent indent);
......@@ -37,9 +41,31 @@ public:
vtkSetMacro(ScaleFactor,float);
vtkGetMacro(ScaleFactor,float);
// Description:
// Turn on/off use of user specified normal. If on, data normals
// will be ignored and instance variable Normal will be used instead.
vtkSetMacro(UseNormal,int);
vtkGetMacro(UseNormal,int);
vtkBooleanMacro(UseNormal,int);
// Description:
// Normal (i.e., direction) along which to warp geometry. Only used
// if UseNormal boolean set to true or no normals available in data.
vtkSetVector3Macro(Normal,float);
vtkGetVectorMacro(Normal,float,3);
protected:
void Execute();
float ScaleFactor;
int UseNormal;
float Normal[3];
//BTX
float *(vtkWarpScalar::*PointNormal)(int id, vtkNormals *normals);
float *DataNormal(int id, vtkNormals *normals=NULL);
float *InstanceNormal(int id, vtkNormals *normals=NULL);
//ETX
};
#endif
......
......@@ -23,6 +23,30 @@ void vtkNormals::GetNormal(int id, float n[3])
for (int i=0; i<3; i++) n[i] = np[i];
}
// Description:
// Insert normal into position indicated.
void vtkNormals::InsertNormal(int id, float nx, float ny, float nz)
{
float n[3];
n[0] = nx;
n[1] = ny;
n[2] = nz;
this->InsertNormal(id,n);
}
// Description:
// Insert normal into position indicated.
int vtkNormals::InsertNextNormal(float nx, float ny, float nz)
{
float n[3];
n[0] = nx;
n[1] = ny;
n[2] = nz;
return this->InsertNextNormal(n);
}
// Description:
// Given a list of pt ids, return an array of corresponding normals.
void vtkNormals::GetNormals(vtkIdList& ptId, vtkFloatNormals& fp)
......
......@@ -21,6 +21,30 @@ vtkPoints::vtkPoints()
this->Bounds[1] = this->Bounds[3] = this->Bounds[5] = 1.0;
}
// Description:
// Insert point into position indicated.
void vtkPoints::InsertPoint(int id, float x, float y, float z)
{
float X[3];
X[0] = x;
X[1] = y;
X[2] = z;
this->InsertPoint(id,X);
}
// Description:
// Insert point into position indicated.
int vtkPoints::InsertNextPoint(float x, float y, float z)
{
float X[3];
X[0] = x;
X[1] = y;
X[2] = z;
return this->InsertNextPoint(X);
}
void vtkPoints::GetPoint(int id, float x[3])
{
float *xp = this->GetPoint(id);
......
......@@ -23,6 +23,34 @@ void vtkTCoords::GetTCoord(int id, float tc[3])
for (int i=0; i<this->Dimension; i++) tc[i] = tcp[i];
}
// Description:
// Insert texture coordinate into position indicated. Although up to three
// texture components may be specified (i.e., tc1, tc2, tc3), if the texture
// coordinates are less than 3 dimensions the extra components will be ignored.
void vtkTCoords::InsertTCoord(int id, float tc1, float tc2, float tc3)
{
float tc[3];
tc[0] = tc1;
tc[1] = tc2;
tc[2] = tc3;
this->InsertTCoord(id,tc);
}
// Description:
// Insert texture coordinate into position indicated. Although up to three
// texture components may be specified (i.e., tc1, tc2, tc3), if the texture
// coordinates are less than 3 dimensions the extra components will be ignored.
int vtkTCoords::InsertNextTCoord(float tc1, float tc2, float tc3)
{
float tc[3];
tc[0] = tc1;
tc[1] = tc2;
tc[2] = tc3;
return this->InsertNextTCoord(tc);
}
// Description:
// Construct object whose texture coordinates are of specified dimension.
vtkTCoords::vtkTCoords(int dim)
......
......@@ -26,6 +26,42 @@ void vtkTensors::GetTensor(int id, vtkTensor &ft)
ft = t;
}
void vtkTensors::InsertTensor(int id, float t11, float t12, float t13,
float t21, float t22, float t23,
float t31, float t32, float t33)
{
vtkTensor t;
t.SetComponent(0,0,t11);
t.SetComponent(0,1,t12);
t.SetComponent(0,2,t13);
t.SetComponent(1,0,t21);
t.SetComponent(1,1,t22);
t.SetComponent(1,2,t23);
t.SetComponent(2,0,t31);
t.SetComponent(2,1,t32);
t.SetComponent(2,2,t33);
this->InsertTensor(id,t);
}
int vtkTensors::InsertNextTensor(float t11, float t12, float t13,
float t21, float t22, float t23,
float t31, float t32, float t33)
{
vtkTensor t;
t.SetComponent(0,0,t11);
t.SetComponent(0,1,t12);
t.SetComponent(0,2,t13);
t.SetComponent(1,0,t21);
t.SetComponent(1,1,t22);
t.SetComponent(1,2,t23);
t.SetComponent(2,0,t31);
t.SetComponent(2,1,t32);
t.SetComponent(2,2,t33);
return this->InsertNextTensor(t);
}
// Description:
// Given a list of pt ids, return an array of tensors.
void vtkTensors::GetTensors(vtkIdList& ptId, vtkFloatTensors& ft)
......
......@@ -29,6 +29,30 @@ void vtkVectors::GetVector(int id, float v[3])
for (int i=0; i<3; i++) v[i] = vp[i];
}
// Description:
// Insert vector into position indicated.
void vtkVectors::InsertVector(int id, float vx, float vy, float vz)
{
float v[3];
v[0] = vx;
v[1] = vy;
v[2] = vz;
this->InsertVector(id,v);
}
// Description:
// Insert vector into position indicated.
int vtkVectors::InsertNextVector(float vx, float vy, float vz)
{
float v[3];
v[0] = vx;
v[1] = vy;
v[2] = vz;
return this->InsertNextVector(v);
}
// Description:
// Given a list of pt ids, return an array of vectors.
void vtkVectors::GetVectors(vtkIdList& ptId, vtkFloatVectors& fp)
......
......@@ -15,6 +15,25 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "WarpScal.hh"
vtkWarpScalar::vtkWarpScalar()
{
this->ScaleFactor = 1.0;
this->UseNormal = 0;
this->Normal[0] = 0.0;
this->Normal[1] = 0.0;
this->Normal[2] = 1.0;
}
float *vtkWarpScalar::DataNormal(int id, vtkNormals *normals)
{
return normals->GetNormal(id);
}
float *vtkWarpScalar::InstanceNormal(int id, vtkNormals *normals)
{
return this->Normal;
}
void vtkWarpScalar::Execute()
{
vtkPoints *inPts;
......@@ -34,12 +53,23 @@ void vtkWarpScalar::Execute()
inNormals = pd->GetNormals();
inScalars = pd->GetScalars();
if ( !inNormals || !inPts || !inScalars )
if ( !inPts || !inScalars )
{
vtkErrorMacro(<<"No input data");
vtkErrorMacro(<<"No data to warp");
return;
}
if ( inNormals && !this->UseNormal )
{
this->PointNormal = &vtkWarpScalar::DataNormal;
vtkDebugMacro(<<"Using data normals");
}
else
{
this->PointNormal = &vtkWarpScalar::InstanceNormal;
vtkDebugMacro(<<"Using Normal instance variable");
}
newPts = new vtkFloatPoints(inPts->GetNumberOfPoints());
//
// Loop over all points, adjusting locations
......@@ -47,7 +77,7 @@ void vtkWarpScalar::Execute()
for (ptId=0; ptId < inPts->GetNumberOfPoints(); ptId++)
{
x = inPts->GetPoint(ptId);
n = inNormals->GetNormal(ptId);
n = (this->*(PointNormal))(ptId,inNormals);
s = inScalars->GetScalar(ptId);
for (i=0; i<3; i++)
{
......@@ -69,4 +99,7 @@ void vtkWarpScalar::PrintSelf(ostream& os, vtkIndent indent)
vtkPointSetToPointSetFilter::PrintSelf(os,indent);
os << indent << "Scale Factor: " << this->ScaleFactor << "\n";
os << indent << "Use Normal: " << (this->UseNormal ? "On\n" : "Off\n");
os << indent << "Normal: (" << this->Normal[0] << ", "
<< this->Normal[1] << ", " << this->Normal[2] << ")\n";
}
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