[vtkusers] add/delete point from polydata

nnnn aaaa an.84 at hotmail.fr
Sat Feb 28 10:29:47 EST 2009


Hello;
 I use visual c++ and vtk as development tools, in my project. I work by the snake's method. I implemented functions to add or to remove points of snake is a polydata (it is a circle), after each iteration, I do not have any errors but l' posting of result it does not go (no posting, it posts dubug). Help me please.

Here is my code of function 
void vtkSnake::ResampleSnake(vtkPolyData *snake,int dmax,int dmin)
{
 
   
 int numberOfPoints=snake->GetNumberOfPoints();
            int nbInputPoint,*inputPointsId;
 
            vtkPoints* points = snake->GetPoints();
            // get the number of point of the unregularized snake
            snake->GetLines()->GetCell(0,nbInputPoint,inputPointsId);
    
            for(int i=0;i<numberOfPoints;i++) {
             double pti[3];
             points->GetPoint(inputPointsId[i],pti);
  // TO CHECK THE DISTANCES WITH HALF OF THE FOLLOWING POINTS 
            for(int idp=(1+numberOfPoints)/2;idp>0;idp--)
            {
                         double ptiFlw[3];
               points->GetPoint(inputPointsId[(idp+i)%numberOfPoints],ptiFlw);
               points->GetPoint(inputPointsId[idp],pti);
            double dist = sqrt(pow(ptiFlw[0]-pti[0],2)+pow(ptiFlw[1]-pti[1],2));
             
                if(dist>dmin) continue;
           
             for(int k=0;k<idp;k++) 
            removeSnake(snake,inputPointsId[(i+1)%numberOfPoints]);
            break;
            }
            }
 
            
            for(int idp=0;idp<numberOfPoints;idp++)
            {
                  
            double ptiFlw[3],pti[3];
            
           points->GetPoint(inputPointsId[(idp+1)%numberOfPoints],ptiFlw);
            points->GetPoint(inputPointsId[idp],pti);
          double dist = sqrt(pow(ptiFlw[0]-pti[0],2)+pow(ptiFlw[1]-pti[1],2));
            if(dist>dmax)
                        {
                                   addSnake(snake,idp);
                                   
                        }
            }
}
 
//-------------------------------------------------------------------------
void vtkSnake::addSnake(vtkPolyData *snake,int pos)
{
            int numberOfPoints=snake->GetNumberOfPoints();
            int nbInputPoint,*inputPointsId;
 
            vtkPoints* points = snake->GetPoints();
            // get the number of point of the unregularized snake
            snake->GetLines()->GetCell(0,nbInputPoint,inputPointsId);
           double ptiFlw[3],pti[3];
            points->GetPoint(inputPointsId[(pos+1)%numberOfPoints],ptiFlw);
            points->GetPoint(inputPointsId[pos],pti);
            double newX = (ptiFlw[0]+pti[0])/2.0;
            double newY = (ptiFlw[1]+pti[1])/2.0;
            
            int newId=points->InsertNextPoint(newX,newY,pti[2]);
            points->Modified();
            
            snake->GetLines()->InsertCellPoint(newId);
            snake->GetLines()->UpdateCellCount(numberOfPoints++);
            snake->Modified();
                                   
     numberOfPoints++;                                    
            
            
}
 
//-------------------------------------------------------------------------
void vtkSnake::removeSnake(vtkPolyData *snake,int pos)
{
    int numberOfPoints=snake->GetNumberOfPoints();
            int nbInputPoint,*inputPointsId;
 
            snake->GetLines()->GetCell(0,nbInputPoint,inputPointsId);
            snake->RemoveCellReference(inputPointsId[pos]);
             snake->DeleteCell(inputPointsId[pos]);
             snake->Modified();
     numberOfPoints--;
                        
}

 
 
_________________________________________________________________
Découvrez tout ce que Windows Live a à vous apporter !
http://www.microsoft.com/windows/windowslive/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090228/6e3ca74f/attachment.htm>


More information about the vtkusers mailing list