[vtkusers] a surprise questuion about show some clouds!
seaer
wuweitianye at yahoo.com.cn
Fri Jan 6 22:10:27 EST 2012
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!
--
View this message in context: http://vtk.1045678.n5.nabble.com/a-surprise-questuion-about-show-some-clouds-tp5126976p5127124.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list