Part of a cone
Giling, Erwin
Giling at TPD.TNO.NL
Fri Oct 29 07:00:09 EDT 1999
Hi Stephane,
You wrote:
> Which is the best way to build a 3D cylinder with different radius to
> each extremeties ? (a part of a cone)
I had the same need just one week ago.
My approach was to start with a copy of the vtkCylinderSource source file
and modify it to include a different radius at each end. You just have to
compute different xbot and xtop variables depending on the radius. The
vertices are not difficult, and polygon generation code is not changed. But,
my normal vectors are not right, yet so I won't post my code here. I'm not
sure if I would be allowed to distribute this source in the first place
because it is a modified vtk source...
Maybe you could use a combination of vtk objects to do the job, but IMHO
there are so many classes and so few examples that you just don't know where
all the stuff can be used for.
My header file tpdConeSource.h is below so you get the idea. I also added a
"AlongX" variable, which creates the cone "horizontally" in stead of
"vertically".
Regards,
Erwin
-----
#include "vtkPolyDataSource.h"
class VTK_EXPORT tpdConeSource : public vtkPolyDataSource
{
public:
tpdConeSource(int res=6);
static tpdConeSource *New() {return new tpdConeSource;};
const char *GetClassName() {return "tpdConeSource";};
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set the height of the Cone.
vtkSetClampMacro(Length,float,0.0,VTK_LARGE_FLOAT)
vtkGetMacro(Length,float);
// Description:
// Set the first radius of the Cone.
vtkSetClampMacro(Radius1,float,0.0,VTK_LARGE_FLOAT)
vtkGetMacro(Radius1,float);
// Description:
// Set the second radius of the Cone.
vtkSetClampMacro(Radius2,float,0.0,VTK_LARGE_FLOAT)
vtkGetMacro(Radius2,float);
// Description:
// Set/Get Cone center
vtkSetVector3Macro(Center,float);
vtkGetVectorMacro(Center,float,3);
// Description:
// Set the number of facets used to define Cone.
vtkSetClampMacro(Resolution,int,0,VTK_CELL_SIZE)
vtkGetMacro(Resolution,int);
// Description:
// Turn on/off whether to cap Cone with polygons.
vtkSetMacro(Capping,int);
vtkGetMacro(Capping,int);
vtkBooleanMacro(Capping,int);
// Description:
// create aligend along x or y axis
vtkSetMacro(AlongX,int);
vtkGetMacro(AlongX,int);
vtkBooleanMacro(AlongX,int);
protected:
void Execute();
float Length;
float Radius1;
float Radius2;
float Center[3];
int Resolution;
int Capping;
int AlongX;
};
>
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list