26 #include <vtkActorCollection.h>
27 #include <vtkCellArray.h>
28 #include <vtkCommand.h>
30 #include <vtkObjectFactory.h>
31 #include <vtkPoints.h>
32 #include <vtkPolyLine.h>
33 #include <vtkPolyData.h>
34 #include <vtkPolyDataMapper.h>
35 #include <vtkProperty.h>
36 #include <vtkSmartPointer.h>
37 #include <vtkTubeFilter.h>
42 #if (VTK_MAJOR_VERSION <= 5)
52 class axlActorCurveBSplinePrivate
56 vtkSmartPointer<vtkTubeFilter> splineCurveTubeFilter;
64 d->splineCurveTubeFilter = vtkSmartPointer<vtkTubeFilter>::New();
65 d->splineCurveTubeFilter->SetNumberOfSides(8);
77 return d->splineCurve;
83 d->splineCurve = spline_curve;
85 this->
setPoints(vtkSmartPointer<vtkPoints>::New());
86 this->
setMapper(vtkSmartPointer<vtkPolyDataMapper>::New());
87 this->
setActor(vtkSmartPointer<vtkActor>::New());
88 this->
setPolyData(vtkSmartPointer<vtkPolyData>::New());
89 this->
setCellArray(vtkSmartPointer<vtkCellArray>::New());
97 #if (VTK_MAJOR_VERSION <= 5)
115 QColor color = d->splineCurve->color();
116 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
118 QString shader = d->splineCurve->shader();
119 if(!shader.isEmpty())
126 connect(d->splineCurve, SIGNAL(modifiedGeometry()),
this, SLOT(
onUpdateGeometry()));
127 connect(d->splineCurve, SIGNAL(modifiedProperty()),
this, SLOT(
onUpdateProperty()));
137 #if (VTK_MAJOR_VERSION <= 5)
138 d->splineCurveTubeFilter->SetInput(this->
getPolyData());
139 this->
getMapper()->SetInput(d->splineCurveTubeFilter->GetOutput());
141 d->splineCurveTubeFilter->SetInputData(this->
getPolyData());
142 this->
getMapper()->SetInputData(d->splineCurveTubeFilter->GetOutput());
144 d->splineCurveTubeFilter->SetRadius(d->splineCurve->size());
145 d->splineCurveTubeFilter->Update();
154 if(d->splineCurve->rational())
156 d->splineCurve->updateRcoeff();
160 double start = d->splineCurve->startParam();
161 double end = d->splineCurve->endParam();
162 double paramCourant = start;
168 int n = d->splineCurve->numSamples();
169 points->SetNumberOfPoints(n);
171 double interval = (double)(end-start) / (n -1);
173 for (
int i = 0; i < n-1; i++) {
174 d->splineCurve->eval(pointCourant, paramCourant);
176 paramCourant += interval;
180 d->splineCurve->eval(pointCourant, end);
181 points->SetPoint(n - 1, pointCourant->
coordinates());
188 int n = d->splineCurve->numSamples();
190 vtkSmartPointer<vtkLine> currentline = vtkSmartPointer<vtkLine>::New();
191 currentline->GetPointIds()->SetNumberOfIds(2);
193 for(
int i= 0; i < n - 1; i++) {
194 currentline->GetPointIds()->SetId(0 , i);
195 currentline->GetPointIds()->SetId(1 , i + 1);
202 if (d->splineCurve) {
225 #if (VTK_MAJOR_VERSION <= 5)
226 d->splineCurveTubeFilter->SetInput(this->
getPolyData());
227 this->
getMapper()->SetInput(d->splineCurveTubeFilter->GetOutput());
229 d->splineCurveTubeFilter->SetInputData(this->
getPolyData());
230 this->
getMapper()->SetInputData(d->splineCurveTubeFilter->GetOutput());
233 d->splineCurveTubeFilter->SetRadius(d->splineCurve->size());
234 d->splineCurveTubeFilter->Update();
236 if (d->splineCurve->fields().count() != 0)
237 d->splineCurve->touchField();
245 #if (VTK_MAJOR_VERSION <= 5)
246 d->splineCurveTubeFilter->SetInput(this->
getPolyData());
247 this->
getMapper()->SetInput(d->splineCurveTubeFilter->GetOutput());
249 d->splineCurveTubeFilter->SetInputData(this->
getPolyData());
250 this->
getMapper()->SetInputData(d->splineCurveTubeFilter->GetOutput());
253 d->splineCurveTubeFilter->SetRadius(radius);
255 d->splineCurveTubeFilter->Update();
263 return d->splineCurveTubeFilter->GetOutput();
Class axlPoint defines 3D points.
vtkSmartPointer< vtkCellArray > getCellArray(void)
virtual axlControlPointsWidget * getControlPoints(void)
vtkCxxRevisionMacro(axlActorCurveBSpline,"$Revision: 0.0.1 $")
double * coordinates(void) const
Returns coordinates of this point.
vtkStandardNewMacro(axlActorCurveBSpline)
vtkSmartPointer< vtkPolyData > getPolyData(void)
virtual void setData(dtkAbstractData *spline_curve1)
void setCellArray(vtkSmartPointer< vtkCellArray > cellArray)
virtual void onSamplingChanged(void)
~axlActorCurveBSpline(void)
virtual void onTubeFilterRadiusChanged(double radius)
static axlActorCurveBSpline * New(void)
axlActorCurveBSpline(void)
vtkSmartPointer< vtkPoints > getPoints(void)
void polyDataUpdate(void)
virtual void setShader(QString vsfile)
void setPolyData(vtkSmartPointer< vtkPolyData > polyData)
void setMapper(vtkSmartPointer< vtkPolyDataMapper > mapper)
dtkAbstractData * data(void)
vtkPolyData * getCurveMapperInput(void)
void setActor(vtkSmartPointer< vtkActor > actor)
vtkSmartPointer< vtkActor > getActor(void)
virtual void onUpdateProperty(void)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
void setObserverData(dtkAbstractData *data)
axlActorControlPolygonObserver * getObserver(void)
void setPoints(vtkSmartPointer< vtkPoints > points)
axlAbstractActor * createAxlActorCurveBSpline(void)
void onUpdateGeometry(void)