[vtkusers] Sub-classing vtkContourLineInterpolator - adds default straight lines also
Gishara Indeewarie
gish.777 at gmail.com
Mon Aug 20 05:42:32 EDT 2012
Hi all,
I am sorry have asked this question once and did not get any response, I am
still trying this , So I am asking the question again.
I wanted to add cnurb interpolation to my contour representation. So I
sub-classed the vtkContourLineInterpolator and added my interpolation in
the method, virtual int InterpolateLine. My problem is I am getting the
intermediate points I have added plus straight lines between nodes. I am
using AddIntermediatePointWorldPosition method to add points between nodes.
And when I try to change the contour by dragging control points the
straight lines are changed (which were added by deafault.), not the points
I have added. Below is the piece of code where I call for the sub class.
vtkSmartPointer cnurbInterpolater = vtkSmartPointer::New();
cnurbInterpolater->pNurb = pNurb;
cnurbInterpolater->size = size;
cnurbInterpolater->x = x;
cnurbInterpolater->y = y;
cnurbInterpolater->z = z;
cnurbInterpolater->MaximumCurveError = 0.0000001;
cnurbInterpolater->MaximumCurveLineSegments = 10000;
contourRep->SetLineInterpolator(cnurbInterpolater);
And below is my class that sub classed the vtkContourLineInterpolator:
class CnurbsInterpolate:public vtkContourLineInterpolator {
public:
CNurbsCurve* pNurb;
vtkSmartPointer<vtkPoints> points;
double * x;
double * y;
double * z;
double MaximumCurveError ;
int MaximumCurveLineSegments;
int size;
public:
static CnurbsInterpolate *New()
{
return new CnurbsInterpolate;
}CnurbsInterpolate() {}
int InterpolateLine( vtkRenderer *vtkNotUsed(ren),
vtkContourRepresentation *rep,
int idx1, int idx2 )
{
double *controlPointsStack2 = new double[3];
this->pNurb->Interpolate(x,y,z, size+2 );
for(int i=0; i<=100; i++)
{
double Uiter = double(i)/100.0;
double xn,yn,zn;
this->pNurb->GetPoint(Uiter,xn,yn,zn);
controlPointsStack2[0] = xn;
controlPointsStack2[1] = yn;
controlPointsStack2[2] = zn;
if(i>=0 && i<12){
rep->AddIntermediatePointWorldPosition(0,controlPointsStack2);
}
else if (i>=12 && i<57){
rep->AddIntermediatePointWorldPosition(1,controlPointsStack2);
}else if (i>=57 && i<95){
this->Representation->AddIntermediatePointWorldPosition(2,controlPointsStack2);
}
else{
rep->AddIntermediatePointWorldPosition(3,controlPointsStack2);
}
}
delete [] controlPointsStack2;
return 1;}
I have discussed the problem in stackoverflow as well:
http://stackoverflow.com/questions/11789097/sub-classing-vtkcontourlineinterpolator-adds-default-straight-lines-also
Please help me. Thanks a lot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120820/0bed83b0/attachment.htm>
More information about the vtkusers
mailing list