<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi all,<BR>
I write a piont set by ofstream like this:<BR>
<BR>
typedef itk::PointSet< float, Dimension > PointSetType;<BR>
<BR>
typedef PointSetType::PointType PointType;<BR>
<BR>
std::cout << "begin write point set ..." << std::endl;<BR>
<BR>
std::ofstream skeltonPointsFile;<BR> skeltonPointsFile.open( argv[7] );<BR> <BR> typedef PointSetType::PointsContainer PointsContainer;<BR> PointsContainer::Pointer points = SkelPointSet->GetPoints();<BR> typedef PointsContainer::Iterator PointsIterator;<BR> PointsIterator pointIterator = points->Begin();<BR> PointsIterator end = points->End();<BR> while( pointIterator != end ) <BR> {<BR> PointType p = pointIterator.Value(); // access the point<BR> skeltonPointsFile << p; // print the point<BR> ++pointIterator;<BR> }<BR> <BR> skeltonPointsFile.close();<BR>
std::cout << "write point set done..." << std::endl;<BR>
<BR>
<BR>
I can open the pointset txt file, the points are saved as following format:<BR>
[-104.98, -144.511, -1035.9][133.301, -144.511, -1035.9]<BR>
<BR>
when I want to read it out to a pointset, my code as folloing:<BR>
<BR>
typedef itk::PointSet< float, Dimension > PointSetType;<BR>
typedef PointSetType::PointType PointType;<BR>
PointType fixedPoint;<BR>
<BR>
std::ifstream fixedFile;<BR> fixedFile.open( argv[1] );<BR> if( fixedFile.fail() )<BR> {<BR> std::cerr << "Error opening points file with name : " << std::endl;<BR> std::cerr << argv[1] << std::endl;<BR> return 2;<BR> }<BR>
unsigned int pointId = 0;<BR> fixedFile >> fixedPoint;<BR> while( !fixedFile.eof() )<BR> {<BR> fixedPointContainer->InsertElement( pointId, fixedPoint );<BR> fixedFile >> fixedPoint;<BR> pointId++;<BR> }<BR> fixedPointSet->SetPoints( fixedPointContainer );<BR> std::cout << <BR> "Number of fixed Points = " << fixedPointSet->GetNumberOfPoints() <BR> << std::endl;<BR>
<BR>
But I can not read the points correctly, dose anyone can help me?<BR>
Thx.<RTE_TEXT></RTE_TEXT><BR><br /><hr />八卦娱乐包打听,MSN资讯速递帮你忙! <a href='http://im.live.cn/newsexpress' target='_new'>了解详细!</a></body>
</html>