Commit 442656c4 authored by Ellen Dekkers's avatar Ellen Dekkers
Browse files

ACG/Geometry/Types: PolyLine has new functions for inserting and deleting points at any position

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6948 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 59def2d5
......@@ -257,6 +257,104 @@ add_point(const Point& _p)
eselections_.push_back(false);
}
//-----------------------------------------------------------------------------
template <class PointT>
void
PolyLineT<PointT>::
insert_point(int _idx, const Point& _p)
{
assert(_idx < (int)n_vertices() );
// insert new point
points_.insert(points_.begin()+_idx, _p);
// insert available properties
if( vertex_normals_available() )
vnormals_.insert(points_.begin()+_idx, Point(0,0,0));
if( vertex_colors_available())
vcolors_.insert(points_.begin()+_idx, Point(1,0,1));
if( vertex_scalars_available())
vscalars_.insert(points_.begin()+_idx, 0.0 );
if( vertex_selections_available())
vselections_.insert(points_.begin()+_idx, false);
if( vertex_vhandles_available())
vvhandles_.insert(points_.begin()+_idx, -1);
if( vertex_ehandles_available())
vehandles_.insert(points_.begin()+_idx, -1);
if( vertex_fhandles_available())
vfhandles_.insert(points_.begin()+_idx, -1);
if( edge_normals_available())
enormals_.insert(points_.begin()+_idx, Point(0,0,0));
if( edge_colors_available())
ecolors_.insert(points_.begin()+_idx, Point(1,0,1));
if( edge_scalars_available())
escalars_.insert(points_.begin()+_idx, 0.0);
if( edge_selections_available())
eselections_.insert(points_.begin()+_idx, false);
}
//-----------------------------------------------------------------------------
template <class PointT>
void
PolyLineT<PointT>::
delete_point(int _idx)
{
assert(_idx < (int)n_vertices() );
// delete point at given index
points_.erase(points_.begin()+_idx);
// delete available properties
if( vertex_normals_available() )
vnormals_.erase(points_.begin()+_idx);
if( vertex_colors_available())
vcolors_.erase(points_.begin()+_idx);
if( vertex_scalars_available())
vscalars_.erase(points_.begin()+_idx);
if( vertex_selections_available())
vselections_.erase(points_.begin()+_idx);
if( vertex_vhandles_available())
vvhandles_.erase(points_.begin()+_idx);
if( vertex_ehandles_available())
vehandles_.erase(points_.begin()+_idx);
if( vertex_fhandles_available())
vfhandles_.erase(points_.begin()+_idx);
if( edge_normals_available())
enormals_.erase(points_.begin()+_idx);
if( edge_colors_available())
ecolors_.erase(points_.begin()+_idx);
if( edge_scalars_available())
escalars_.erase(points_.begin()+_idx);
if( edge_selections_available())
eselections_.erase(points_.begin()+_idx);
}
//-----------------------------------------------------------------------------
......
......@@ -112,9 +112,17 @@ public:
// resize current polyline
void resize( unsigned int _n);
// add a point
void add_point(const Point& _p);
// insert _p at _idx into polyline
void insert_point(int _idx, const Point& _p);
// delete point at _idx
void delete_point(int _idx);
// get a point of the polyline
Point& point(unsigned int _i) { return points_[_i];}
const Point& point(unsigned int _i) const { return points_[_i];}
......
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