[vtkusers] Problem with sub-classing vtkContourLineInterpolator

Gishara Indeewarie gish.777 at gmail.com
Thu Aug 2 07:55:31 EDT 2012


Below is the piece of code where I call for the sub class.

vtkSmartPointer<CnurbsInterpolate> cnurbInterpolater =
    vtkSmartPointer<CnurbsInterpolate>::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;
//outfile <<xn << " " << yn << " " << zn << " "<<"\n";
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;
}

This adds the defined points plus the straight lines between nodes.
And also when I drag the control points only the straight lines get changed.
Please help me.
Thanks a lot.

On Thu, Aug 2, 2012 at 3:06 PM, Gishara Indeewarie <gish.777 at gmail.com>wrote:

> Dear all,
>
> 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 the
> points added by default. (The default points have been added
> as 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.
>
> Please help me.
> Thanks.
>
>


-- 
Gish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120802/926bd70b/attachment.htm>


More information about the vtkusers mailing list