54 #ifndef ACG_POLYLINET_HH 55 #define ACG_POLYLINET_HH 61 #include <ACG/Config/ACGDefines.hh> 62 #include <OpenMesh/Core/Utils/PropertyManager.hh> 63 #include <OpenMesh/Core/Utils/Property.hh> 83 template <
class Po
intT>
90 typedef typename Point::value_type Scalar;
93 explicit PolyLineT(
bool _closed =
false );
125 void resize(
unsigned int _n);
181 Point
position(
const Scalar _t)
const;
258 void set_to_circle(
const PointT _center,
const PointT _normal,
double _radius,
unsigned int _n_samples = 100);
267 template <
class MeshT,
class SpatialSearchT>
269 SpatialSearchT* _ssearch = 0);
281 template <
class MeshT,
class SpatialSearchT>
283 std::vector<SpatialSearchT*>* _ssearch = 0);
289 template <
class MeshT,
class SpatialSearchT>
291 SpatialSearchT &_ssearch);
299 template <
class MeshT,
class SpatialSearchT>
301 SpatialSearchT &_ssearch,
302 std::vector<PolyLineT> &out_polylines);
306 #ifdef EXTENDED_POLY_LINE 307 #include <libs/MeshIntegration/PolyLineIntegrationT.hh> 327 template <
class LineNodeT>
328 LineNodeT*
get_line_node( LineNodeT*& _line_node,
int _mode = 0);
335 template <
class LineNodeT>
357 void request_vertex_normals() { request_prop( ref_count_vnormals_ , vnormals_);}
358 void request_vertex_binormals() { request_prop( ref_count_vbinormals_ , vbinormals_);}
359 void request_vertex_colors() { request_prop( ref_count_vcolors_ , vcolors_ );}
360 void request_vertex_scalars() { request_prop( ref_count_vscalars_ , vscalars_);}
361 void request_vertex_selections() { request_prop( ref_count_vselections_, vselections_);}
362 void request_vertex_vhandles() { request_prop( ref_count_vvhandles_ , vvhandles_);}
363 void request_vertex_ehandles() { request_prop( ref_count_vehandles_ , vehandles_);}
364 void request_vertex_fhandles() { request_prop( ref_count_vfhandles_ , vfhandles_);}
366 void request_edge_normals() { request_prop( ref_count_enormals_ , enormals_);}
367 void request_edge_colors() { request_prop( ref_count_ecolors_ , ecolors_ );}
368 void request_edge_scalars() { request_prop( ref_count_escalars_ , escalars_);}
369 void request_edge_selections() { request_prop( ref_count_eselections_, eselections_);}
370 void request_preimage_directions() { request_prop( ref_count_epreimage_direction_, epreimage_direction_);}
373 void release_vertex_normals() { release_prop( ref_count_vnormals_ , vnormals_);}
374 void release_vertex_binormals() { release_prop( ref_count_vbinormals_ , vbinormals_);}
375 void release_vertex_colors() { release_prop( ref_count_vcolors_ , vcolors_ );}
376 void release_vertex_scalars() { release_prop( ref_count_vscalars_ , vscalars_);}
377 void release_vertex_selections() { release_prop( ref_count_vselections_, vselections_);}
378 void release_vertex_vhandles() { release_prop( ref_count_vvhandles_ , vvhandles_);}
379 void release_vertex_ehandles() { release_prop( ref_count_vehandles_ , vehandles_);}
380 void release_vertex_fhandles() { release_prop( ref_count_vfhandles_ , vfhandles_);}
382 void release_edge_normals() { release_prop( ref_count_enormals_ , enormals_);}
383 void release_edge_colors() { release_prop( ref_count_ecolors_ , ecolors_ );}
384 void release_edge_scalars() { release_prop( ref_count_escalars_ , escalars_);}
385 void release_edge_selections() { release_prop( ref_count_eselections_, eselections_);}
386 void release_preimage_directions() { release_prop( ref_count_epreimage_direction_, epreimage_direction_);}
389 bool vertex_normals_available()
const {
return (ref_count_vnormals_ != 0 ); }
390 bool vertex_binormals_available()
const {
return (ref_count_vbinormals_ != 0 ); }
391 bool vertex_colors_available()
const {
return (ref_count_vcolors_ != 0 ); }
392 bool vertex_scalars_available()
const {
return (ref_count_vscalars_ != 0 ); }
393 bool vertex_selections_available()
const {
return (ref_count_vselections_ != 0 ); }
394 bool vertex_vhandles_available()
const {
return (ref_count_vvhandles_ != 0 ); }
395 bool vertex_ehandles_available()
const {
return (ref_count_vehandles_ != 0 ); }
396 bool vertex_fhandles_available()
const {
return (ref_count_vfhandles_ != 0 ); }
398 bool edge_normals_available()
const {
return (ref_count_enormals_ != 0 ); }
399 bool edge_colors_available()
const {
return (ref_count_ecolors_ != 0 ); }
400 bool edge_scalars_available()
const {
return (ref_count_escalars_ != 0 ); }
401 bool edge_selections_available()
const {
return (ref_count_eselections_ != 0 ); }
402 bool edge_preimage_directions_available()
const {
return (ref_count_epreimage_direction_ != 0 ); }
405 Point& vertex_normal(
unsigned int _i) {
return vnormals_[_i];}
406 const Point& vertex_normal(
unsigned int _i)
const {
return vnormals_[_i];}
408 Point& vertex_binormal(
unsigned int _i) {
return vbinormals_[_i];}
409 const Point& vertex_binormal(
unsigned int _i)
const {
return vbinormals_[_i];}
411 Point & vertex_color(
unsigned int _i) {
return vcolors_[_i];}
412 const Point & vertex_color(
unsigned int _i)
const {
return vcolors_[_i];}
414 Scalar& vertex_scalar(
unsigned int _i) {
return vscalars_[_i];}
415 const Scalar& vertex_scalar(
unsigned int _i)
const {
return vscalars_[_i];}
417 unsigned char& vertex_selection(
unsigned int _i) {
return vselections_[_i];}
418 const unsigned char& vertex_selection(
unsigned int _i)
const {
return vselections_[_i];}
420 int& vertex_vhandle(
unsigned int _i) {
return vvhandles_[_i];}
421 const int& vertex_vhandle(
unsigned int _i)
const {
return vvhandles_[_i];}
423 int& vertex_ehandle(
unsigned int _i) {
return vehandles_[_i];}
424 const int& vertex_ehandle(
unsigned int _i)
const {
return vehandles_[_i];}
426 int& vertex_fhandle(
unsigned int _i) {
return vfhandles_[_i];}
427 const int& vertex_fhandle(
unsigned int _i)
const {
return vfhandles_[_i];}
429 Point& edge_normal(
unsigned int _i) {
return enormals_[_i];}
430 const Point& edge_normal(
unsigned int _i)
const {
return enormals_[_i];}
432 Point & edge_color(
unsigned int _i) {
return ecolors_[_i];}
433 const Point & edge_color(
unsigned int _i)
const {
return ecolors_[_i];}
435 Scalar& edge_scalar(
unsigned int _i) {
return escalars_[_i];}
436 const Scalar& edge_scalar(
unsigned int _i)
const {
return escalars_[_i];}
438 unsigned char& edge_selection(
unsigned int _i) {
return eselections_[_i];}
439 const unsigned char& edge_selection(
unsigned int _i)
const {
return eselections_[_i];}
441 Point & preimage_direction(
unsigned int _i) {
return epreimage_direction_[_i];}
442 const Point & preimage_direction(
unsigned int _i)
const {
return epreimage_direction_[_i];}
485 typedef int CustomPropertyHandle;
488 CustomPropertyHandle request_custom_property(
const std::string& _name,
unsigned int _prop_size);
491 void release_custom_property(
const std::string& _name);
492 void release_custom_property(CustomPropertyHandle _prop_handle);
495 bool custom_property_available(CustomPropertyHandle _property_handle)
const;
496 bool custom_property_available(
const std::string& _name)
const;
499 void set_custom_property(CustomPropertyHandle _property_handle,
unsigned int _vertex,
const void* _data);
500 void get_custom_property(CustomPropertyHandle _property_handle,
unsigned int _vertex,
void* _dst)
const;
503 void set_custom_property(
const std::string& _name,
unsigned int _vertex,
const void* _data);
504 void get_custom_property(
const std::string& _name,
unsigned int _vertex,
void* _dst)
const;
534 CustomPropertyHandle get_custom_property_handle(
const std::string& _name)
const;
537 const std::string get_custom_property_name(CustomPropertyHandle _property_handle)
const;
540 unsigned int get_num_custom_properties()
const;
543 const void* get_custom_property_buffer(CustomPropertyHandle _property_handle)
const;
547 CustomPropertyHandle enumerate_custom_property_handles(
unsigned int _i)
const;
552 bool vertex_selected(
unsigned int _i) {
return (_i < vselections_.size() ? vertex_selection(_i) == 1 :
false); }
553 bool edge_selected(
unsigned int _i) {
return (_i < eselections_.size() ? edge_selection(_i) == 1 :
false); }
555 void select_vertex(
unsigned int _i) {
if(_i < vselections_.size()) vertex_selection(_i) = 1; }
556 void select_edge(
unsigned int _i) {
if(_i < eselections_.size()) edge_selection(_i) = 1; }
558 void deselect_vertex(
unsigned int _i) {
if(_i < vselections_.size()) vertex_selection(_i) = 0; }
559 void deselect_edge(
unsigned int _i) {
if(_i < eselections_.size()) edge_selection(_i) = 0; }
565 void copy_vertex_complete(
const PolyLineT<PointT>& _pl,
unsigned int _i,
unsigned int _j);
569 void copy_edge_complete(
const PolyLineT<PointT>& _pl,
unsigned int _i,
unsigned int _j);
582 template <
class MeshT,
class SpatialSearchT>
585 typename MeshT::FaceHandle &_fh,
586 SpatialSearchT * _ssearch = 0,
594 template<
class MeshT,
class SpatialSearchT>
600 SpatialSearchT &_ssearch);
606 template <
class MeshT>
613 template <
class PropT>
614 void request_prop(
unsigned int& _ref_count, PropT& _prop);
615 template <
class PropT>
616 void release_prop(
unsigned int& _ref_count, PropT& _prop);
627 template <
class IPo
int>
629 const IPoint& _n_plane,
634 template<
class MeshT>
635 void edge_points_in_segment(
const MeshT& _mesh,
638 const typename MeshT::FaceHandle& _fh0,
639 const typename MeshT::FaceHandle& _fh1,
640 std::vector<Point> & _points,
641 std::vector<typename MeshT::EdgeHandle>& _ehandles );
661 std::vector<Point> vnormals_;
662 std::vector<Point> vbinormals_;
663 std::vector<Point> vcolors_;
664 std::vector<Scalar> vscalars_;
665 std::vector<unsigned char> vselections_;
666 std::vector<int> vvhandles_;
667 std::vector<int> vehandles_;
668 std::vector<int> vfhandles_;
670 std::vector<Point> enormals_;
671 std::vector<Point> ecolors_;
672 std::vector<Scalar> escalars_;
673 std::vector<unsigned char> eselections_;
674 std::vector<Point> epreimage_direction_;
678 unsigned int ref_count_vnormals_;
679 unsigned int ref_count_vbinormals_;
680 unsigned int ref_count_vcolors_;
681 unsigned int ref_count_vscalars_;
682 unsigned int ref_count_vselections_;
683 unsigned int ref_count_vvhandles_;
684 unsigned int ref_count_vehandles_;
685 unsigned int ref_count_vfhandles_;
687 unsigned int ref_count_enormals_;
688 unsigned int ref_count_ecolors_;
689 unsigned int ref_count_escalars_;
690 unsigned int ref_count_eselections_;
691 unsigned int ref_count_epreimage_direction_;
702 unsigned int prop_size;
705 std::vector<char> prop_data;
708 unsigned int datatype;
711 std::string shader_binding;
713 char* buffer() {
return prop_data.empty() ? 0 : &prop_data[0];}
714 const char* buffer()
const {
return prop_data.empty() ? 0 : &prop_data[0];}
717 typedef std::map< std::string, CustomProperty* > CustomPropertyMap;
720 const CustomProperty* custom_prop(CustomPropertyHandle _handle)
const;
722 CustomPropertyHandle custom_prop_handle(
const CustomProperty*)
const;
725 CustomPropertyMap custom_properties;
728 std::vector<CustomProperty*> cprop_enum;
735 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_POLYLINET_C) 736 #define ACG_POLYLINET_TEMPLATES 737 #include "PolyLineT_impl.hh" 740 #ifdef EXTENDED_POLY_LINE 741 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_POLYLINE_INTEGRATIONT_C) 742 #define ACG_POLYLINE_INTEGRATIONT_TEMPLATES 743 #include <libs/MeshIntegration/PolyLineIntegrationT.cc> 749 #endif // ACG_POLYLINET_HH defined void append(const PolyLineT< PointT > &_pl)
Append second polyline _pl to this one.
Point & front()
Get first point of the polyline ( no range check!!!)
void add_point(const Point &_p)
Append a point to the polyline.
Namespace providing different geometric functions concerning angles.
void smooth_uniform_laplace2()
Squared laplacian smoothing.
Point & point(unsigned int _i)
Get a point of the polyline.
void delete_point(int _idx)
Delete point at _idx.
void resample_arclength_uniform(const unsigned int _n)
Perform an uniform arclength resampling while maintaining the start and end point.
Point position(const Scalar _t) const
Provide linear paremterization of the polyline in [0,1].
Point & back()
Get last point of the polyline ( no range check!!!)
bool on_multiple_components(MeshT &_mesh, SpatialSearchT &_ssearch)
size_t n_vertices() const
Get number of vertices.
void project_to_mesh(const MeshT &_mesh, SpatialSearchT *_ssearch=0)
Project polyline points to nearest surface points (use spatial search!!!)
void remove_subsequent_identical_points(const bool _keep_edge_vertices=false, const double _epsilon=1e-6)
remove points which are subsequent and lie at the same position
void print() const
Print information string to cerr.
Scalar edge_radius() const
get cylinder-radius of edges
void prepend(const PolyLineT< PointT > &_pl)
Prepend second polyline _pl to polyline.
void set_vertex_radius(const Scalar _r)
set ball-radius of vertices
void set_closed(const bool _c)
Set if the polyline should be closed and therefore forms a loop.
Scalar vertex_radius_
ball-radius of vertices
const std::vector< Point > & points() const
Get all points of the polyline.
void bind_custom_property_to_shader(CustomPropertyHandle _property_handle, const std::string &_shader_input_name, unsigned int _datatype)
Binding to vertex shader (optional)
Scalar length() const
Compute the length of the polyline (in future cached method)
void set_edge_radius(const Scalar _r)
set cylinder-radius of edges
Scalar total_gaussian_curvature()
compute total gaussian curvature of enclosed surface (via Gauss-Bonnet)
void set_line_node(LineNodeT *&_line_node, int _mode=0)
Takes a line node and sets the points of this polyline to the points of the node. ...
void split_into_one_per_component(MeshT &_mesh, SpatialSearchT &_ssearch, std::vector< PolyLineT > &out_polylines)
void smooth_uniform_laplace3()
Cubic laplacian smoothing.
const Point & point(unsigned int _i) const
Get a point of the polyline.
void mark_components(OpenMesh::PropertyManager< OpenMesh::FPropHandleT< unsigned int >, MeshT > &component)
LineNodeT * get_line_node(LineNodeT *&_line_node, int _mode=0)
Conversion PolyLine <-> LineNode.
void clear()
Clear the current polyline.
size_t n_edges() const
Get number of edges.
bool closed_
Connect first and last point?
PolyLineT(bool _closed=false)
Constructor.
void insert_point(int _idx, const Point &_p)
insert _p at _idx into polyline
unsigned int component_of(const OpenMesh::PropertyManager< OpenMesh::FPropHandleT< unsigned int >, MeshT > &component, const PointT &pt, SpatialSearchT &_ssearch)
void resize(unsigned int _n)
Resize current polyline.
void collapse(Scalar _smallest)
Collapse polyline.
Point find_nearest_point(const MeshT &_mesh, const Point &_point, typename MeshT::FaceHandle &_fh, SpatialSearchT *_ssearch=0, double *_dbest=0)
Point position_arclength(const Scalar _t) const
Same as position but with an arclength parameterization in [0,length()].
void smooth_uniform_laplace()
Laplacian smoothing.
void subdivide(Scalar _largest)
Subdivide polyline.
bool get_custom_property_shader_binding(CustomPropertyHandle _property_handle, unsigned int *_propsize, const char **_input_name, unsigned int *_datatype) const
Get shader binding information.
const Point & back() const
Get last point of the polyline ( no range check!!!)
Point edge_vector(unsigned int _i) const
get the i-th oriented edge vector
std::vector< Point > & points()
Get all points of the polyline.
std::vector< Point > points_
List of points in the polyline.
void set_to_circle(const PointT _center, const PointT _normal, double _radius, unsigned int _n_samples=100)
creating a circle with center _center and radius _radius lying in tangent plane specified by _normal ...
bool is_closed() const
Check if the polyline is marked as closed.
void split(unsigned int _split_idx, PolyLineT< PointT > &_new_pl)
Split closed polyline at vertex with index _split_idx.
void invert()
Invert polyline that first vertex becomes last.
Scalar edge_radius_
cylinder-radius of edges
bool plane_line_intersection(const IPoint &_p_plane, const IPoint &_n_plane, const IPoint &_p0, const IPoint &_p1, IPoint &_p_int)
Scalar vertex_radius() const
get ball-radius of vertices
void split_closed(unsigned int _split_idx)
Split closed polyline at vertex with index _split_idx.
const Point & front() const
Get first point of the polyline ( no range check!!!)