[vtkusers] a surprise questuion about show some clouds!

David Doria daviddoria at gmail.com
Sat Jan 7 08:34:57 EST 2012


On Fri, Jan 6, 2012 at 10:10 PM, seaer <wuweitianye at yahoo.com.cn> wrote:
>  hi David,
>
>   // here are some code
> //____________________________________________________________________________
>    openFileNames = QFileDialog::getOpenFileNames(this,tr("open
> files"),"/home/xiushan08");
>
>    QFile openfile(openFileNames);
>
>     vtkIdType vtkPointCount = 0;
>
>
>     if(openfile.open(QFile::ReadOnly|QFile::Text))
>     {
>         QTextStream inn(&openfile);
>         QString line;
>         double x=0;
>         double y=0;
>         double z=0;
>
>         while(!inn.atEnd())
>         {
>            line = inn.readLine();
>            QStringList list = line.split(' ');
>            x = list.takeFirst().toDouble();
>            y = list.takeFirst().toDouble();
>            z = list.takeFirst().toDouble();
>            vtkpoints->InsertPoint(vtkPointCount++,x,y,z);
>         }
>
>     }
>     openfile.close();
>
>     pdata->SetPoints(vtkpoints);
>
>
>     int num = pdata->GetNumberOfPoints();
>     std::cout<<"pointsNums:"<<num <<std::endl;
>     cell->InsertNextCell(num); //cell is vtkCellArray*
>
>     for(int i = 0;i < num; i++)
>        {
>            cell->InsertCellPoint(i);
>        }
>
>      pdata->SetVerts(cell);   // pdata  is vtkPolyData*
>
>
>
>         mapper->SetInput(pdata);
>         actor->SetMapper(mapper);
>         actor->GetProperty()->SetPointSize(20);
>         ren->AddViewProp(actor);
>         ren->ResetCamera();
>         ren->SetBackground(0.1, 0.2, 0.4 );
>         QVTKWt->GetRenderWindow()->Render();
>        double xyz[3];
>         for(int i =0;i< vtkpoints->GetNumberOfPoints();i++)
>         {
>             vtkpoints->GetPoint(i,xyz);
>             std::cout <<std::setprecision(10)<<xyz[0]<< "
> "<<xyz[1]<< "  "<<xyz[2]<< std::endl;
>
>         }
>
> //____________________________________________________________________________
>  According to these codes,  it can show points cloud in QVTKWidget.
>
>  for aa.txt , the following debug news:
>   pointsNums:5
>   1.021  1.548  93.725
>   1.011  1.555  93.735
>   1.023  1.588  93.711
>   1.009  1.591  93.726
>   1.001  1.601  93.732
>
>  for bb.txt, the following debug news:
>
>   pointsNums:5
>   607645.021  3623761.548  93.725
>   607645.011  3623761.555  93.735
>   607645.023  3623761.588  93.711
>   607645.009  3623761.591  93.726
>   607645.001  3623761.601  93.732
>
>
>  that's all right.
>    for aa.txt input, you can zoom in/zoom out viewPort and see five 5
> points in viewPort,  but for bb.txt,  you can also zoom in/zoom out
> viewPort, but see only a point in viewPort. generally, by the mean of using
> ren->ResetCamera(), you can see all points in viewPort, but for bb.txt, it
> can no t do it .whether bb.txt data 's very big basic number, for example ,
> 607645.021  3623761.548  93.725;  607645.011  3623761.555  93.735 .these
> point's  basic number is  607645,  whether these can affect do good!

Please send fully compilable code. With files this small, you should
hard code the values into the code so your example doesn't rely on
external files. This allows us to copy->paste->compile. This will also
immediately tell you if you had a problem with your input code or if
the problem lies elsewhere.

David



More information about the vtkusers mailing list