Commit 77001f34 authored by Jan Möbius's avatar Jan Möbius

Save function moved into file polyline plugin

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17370 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 29fde76b
......@@ -1007,171 +1007,6 @@ print() const
//-----------------------------------------------------------------------------
template <class PointT>
void
PolyLineT<PointT>::
load(const char* _filename)
{
// clear old polyline
clear();
std::ifstream fin(_filename, std::ios::in);
// closed ?
fin >> closed_;
// number of points
int num_points;
fin >> num_points;
// std::cerr << "read " << _filename << std::endl;
// std::cerr << "#points: " << num_points << std::endl;
// read points
for(int i=0; i<num_points; ++i)
{
Scalar x,y,z;
fin >> x;
fin >> y;
fin >> z;
Point p(x,y,z);
add_point(p);
}
// ###########################
// READ properties
std::string token;
while(true)
{
token = "-";
fin >> token;
if(token == "VVHANDLES")
{
if(!vertex_vhandles_available()) request_vertex_vhandles();
for(unsigned int i=0; i<n_vertices(); ++i)
fin >> vertex_vhandle(i);
}
else if(token == "VEHANDLES")
{
if(!vertex_ehandles_available()) request_vertex_ehandles();
for(unsigned int i=0; i<n_vertices(); ++i)
fin >> vertex_ehandle(i);
}
else if(token == "VFHANDLES")
{
if(!vertex_fhandles_available()) request_vertex_fhandles();
for(unsigned int i=0; i<n_vertices(); ++i)
fin >> vertex_fhandle(i);
}
else if(token == "VNORMALS")
{
if(!vertex_normals_available()) request_vertex_normals();
for(unsigned int i=0; i<n_vertices(); ++i)
{
fin >> vertex_normal(i)[0];
fin >> vertex_normal(i)[1];
fin >> vertex_normal(i)[2];
}
}
else if(token == "VBINORMALS")
{
if(!vertex_binormals_available()) request_vertex_binormals();
for(unsigned int i=0; i<n_vertices(); ++i)
{
fin >> vertex_binormal(i)[0];
fin >> vertex_binormal(i)[1];
fin >> vertex_binormal(i)[2];
}
}
else if(token != "") break; //eat up empty lines
}
fin.close();
}
//-----------------------------------------------------------------------------
template <class PointT>
void
PolyLineT<PointT>::
save(const char* _filename) const
{
std::ofstream fout(_filename, std::ios::out);
// is polyline closed?
fout << closed_ << std::endl;
// number of points
fout << points_.size() << std::endl;
std::cerr << "write " << _filename << std::endl;
std::cerr << "#points: " << points_.size() << std::endl;
// write each point
for(unsigned int i=0; i<points_.size(); ++i)
{
fout << points_[i][0] << " ";
fout << points_[i][1] << " ";
fout << points_[i][2] << std::endl;
}
// ###########################
// Write properties
if(vertex_vhandles_available())
{
fout << "VVHANDLES" << std::endl;
for( unsigned int i=0; i<n_vertices(); ++i)
fout << vertex_vhandle(i) << std::endl;
}
if(vertex_ehandles_available())
{
fout << "VEHANDLES" << std::endl;
for( unsigned int i=0; i<n_vertices(); ++i)
fout << vertex_ehandle(i) << std::endl;
}
if(vertex_fhandles_available())
{
fout << "VFHANDLES" << std::endl;
for( unsigned int i=0; i<n_vertices(); ++i)
fout << vertex_fhandle(i) << std::endl;
}
if(vertex_normals_available())
{
fout << "VNORMALS" << std::endl;
for( unsigned int i=0; i<n_vertices(); ++i)
{
fout << vnormals_[i][0] << " ";
fout << vnormals_[i][1] << " ";
fout << vnormals_[i][2] << std::endl;
}
}
if(vertex_binormals_available())
{
fout << "VBINORMALS" << std::endl;
for( unsigned int i=0; i<n_vertices(); ++i)
{
fout << vbinormals_[i][0] << " ";
fout << vbinormals_[i][1] << " ";
fout << vbinormals_[i][2] << std::endl;
}
}
fout.close();
}
//-----------------------------------------------------------------------------
template <class PointT>
template <class PropT>
void
......
......@@ -289,12 +289,6 @@ public:
/// \brief Print information string to cerr
void print() const;
/// \brief Load polyline from a file
void load( const char* _filename);
/// \brief Save polyline to a file
void save( const char* _filename) const;
// ############################### Standard Property Handling #############################
// request properties
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment