60 #ifndef ACG_POLYLINET_HH 61 #define ACG_POLYLINET_HH 67 #include <ACG/Config/ACGDefines.hh> 68 #include <OpenMesh/Core/Utils/PropertyManager.hh> 69 #include <OpenMesh/Core/Utils/Property.hh> 89 template <
class Po
intT>
96 typedef typename Point::value_type Scalar;
131 void resize(
unsigned int _n);
187 Point
position(
const Scalar _t)
const;
264 void set_to_circle(
const PointT _center,
const PointT _normal,
double _radius,
unsigned int _n_samples = 100);
273 template <
class MeshT,
class SpatialSearchT>
275 SpatialSearchT* _ssearch = 0);
287 template <
class MeshT,
class SpatialSearchT>
289 std::vector<SpatialSearchT*>* _ssearch = 0);
295 template <
class MeshT,
class SpatialSearchT>
297 SpatialSearchT &_ssearch);
305 template <
class MeshT,
class SpatialSearchT>
307 SpatialSearchT &_ssearch,
308 std::vector<PolyLineT> &out_polylines);
312 #ifdef EXTENDED_POLY_LINE 313 #include <libs/MeshIntegration/PolyLineIntegrationT.hh> 333 template <
class LineNodeT>
334 LineNodeT*
get_line_node( LineNodeT*& _line_node,
int _mode = 0);
341 template <
class LineNodeT>
363 void request_vertex_normals() { request_prop( ref_count_vnormals_ , vnormals_);}
364 void request_vertex_binormals() { request_prop( ref_count_vbinormals_ , vbinormals_);}
365 void request_vertex_colors() { request_prop( ref_count_vcolors_ , vcolors_ );}
366 void request_vertex_scalars() { request_prop( ref_count_vscalars_ , vscalars_);}
367 void request_vertex_selections() { request_prop( ref_count_vselections_, vselections_);}
368 void request_vertex_vhandles() { request_prop( ref_count_vvhandles_ , vvhandles_);}
369 void request_vertex_ehandles() { request_prop( ref_count_vehandles_ , vehandles_);}
370 void request_vertex_fhandles() { request_prop( ref_count_vfhandles_ , vfhandles_);}
372 void request_edge_normals() { request_prop( ref_count_enormals_ , enormals_);}
373 void request_edge_colors() { request_prop( ref_count_ecolors_ , ecolors_ );}
374 void request_edge_scalars() { request_prop( ref_count_escalars_ , escalars_);}
375 void request_edge_selections() { request_prop( ref_count_eselections_, eselections_);}
376 void request_preimage_directions() { request_prop( ref_count_epreimage_direction_, epreimage_direction_);}
379 void release_vertex_normals() { release_prop( ref_count_vnormals_ , vnormals_);}
380 void release_vertex_binormals() { release_prop( ref_count_vbinormals_ , vbinormals_);}
381 void release_vertex_colors() { release_prop( ref_count_vcolors_ , vcolors_ );}
382 void release_vertex_scalars() { release_prop( ref_count_vscalars_ , vscalars_);}
383 void release_vertex_selections() { release_prop( ref_count_vselections_, vselections_);}
384 void release_vertex_vhandles() { release_prop( ref_count_vvhandles_ , vvhandles_);}
385 void release_vertex_ehandles() { release_prop( ref_count_vehandles_ , vehandles_);}
386 void release_vertex_fhandles() { release_prop( ref_count_vfhandles_ , vfhandles_);}
388 void release_edge_normals() { release_prop( ref_count_enormals_ , enormals_);}
389 void release_edge_colors() { release_prop( ref_count_ecolors_ , ecolors_ );}
390 void release_edge_scalars() { release_prop( ref_count_escalars_ , escalars_);}
391 void release_edge_selections() { release_prop( ref_count_eselections_, eselections_);}
392 void release_preimage_directions() { release_prop( ref_count_epreimage_direction_, epreimage_direction_);}
395 bool vertex_normals_available()
const {
return (ref_count_vnormals_ != 0 ); }
396 bool vertex_binormals_available()
const {
return (ref_count_vbinormals_ != 0 ); }
397 bool vertex_colors_available()
const {
return (ref_count_vcolors_ != 0 ); }
398 bool vertex_scalars_available()
const {
return (ref_count_vscalars_ != 0 ); }
399 bool vertex_selections_available()
const {
return (ref_count_vselections_ != 0 ); }
400 bool vertex_vhandles_available()
const {
return (ref_count_vvhandles_ != 0 ); }
401 bool vertex_ehandles_available()
const {
return (ref_count_vehandles_ != 0 ); }
402 bool vertex_fhandles_available()
const {
return (ref_count_vfhandles_ != 0 ); }
404 bool edge_normals_available()
const {
return (ref_count_enormals_ != 0 ); }
405 bool edge_colors_available()
const {
return (ref_count_ecolors_ != 0 ); }
406 bool edge_scalars_available()
const {
return (ref_count_escalars_ != 0 ); }
407 bool edge_selections_available()
const {
return (ref_count_eselections_ != 0 ); }
408 bool edge_preimage_directions_available()
const {
return (ref_count_epreimage_direction_ != 0 ); }
411 Point& vertex_normal(
unsigned int _i) {
return vnormals_[_i];}
412 const Point& vertex_normal(
unsigned int _i)
const {
return vnormals_[_i];}
414 Point& vertex_binormal(
unsigned int _i) {
return vbinormals_[_i];}
415 const Point& vertex_binormal(
unsigned int _i)
const {
return vbinormals_[_i];}
417 Point & vertex_color(
unsigned int _i) {
return vcolors_[_i];}
418 const Point & vertex_color(
unsigned int _i)
const {
return vcolors_[_i];}
420 Scalar& vertex_scalar(
unsigned int _i) {
return vscalars_[_i];}
421 const Scalar& vertex_scalar(
unsigned int _i)
const {
return vscalars_[_i];}
423 unsigned char& vertex_selection(
unsigned int _i) {
return vselections_[_i];}
424 const unsigned char& vertex_selection(
unsigned int _i)
const {
return vselections_[_i];}
426 int& vertex_vhandle(
unsigned int _i) {
return vvhandles_[_i];}
427 const int& vertex_vhandle(
unsigned int _i)
const {
return vvhandles_[_i];}
429 int& vertex_ehandle(
unsigned int _i) {
return vehandles_[_i];}
430 const int& vertex_ehandle(
unsigned int _i)
const {
return vehandles_[_i];}
432 int& vertex_fhandle(
unsigned int _i) {
return vfhandles_[_i];}
433 const int& vertex_fhandle(
unsigned int _i)
const {
return vfhandles_[_i];}
435 Point& edge_normal(
unsigned int _i) {
return enormals_[_i];}
436 const Point& edge_normal(
unsigned int _i)
const {
return enormals_[_i];}
438 Point & edge_color(
unsigned int _i) {
return ecolors_[_i];}
439 const Point & edge_color(
unsigned int _i)
const {
return ecolors_[_i];}
441 Scalar& edge_scalar(
unsigned int _i) {
return escalars_[_i];}
442 const Scalar& edge_scalar(
unsigned int _i)
const {
return escalars_[_i];}
444 unsigned char& edge_selection(
unsigned int _i) {
return eselections_[_i];}
445 const unsigned char& edge_selection(
unsigned int _i)
const {
return eselections_[_i];}
447 Point & preimage_direction(
unsigned int _i) {
return epreimage_direction_[_i];}
448 const Point & preimage_direction(
unsigned int _i)
const {
return epreimage_direction_[_i];}
491 typedef int CustomPropertyHandle;
494 CustomPropertyHandle request_custom_property(
const std::string& _name,
unsigned int _prop_size);
497 void release_custom_property(
const std::string& _name);
498 void release_custom_property(CustomPropertyHandle _prop_handle);
501 bool custom_property_available(CustomPropertyHandle _property_handle)
const;
502 bool custom_property_available(
const std::string& _name)
const;
505 void set_custom_property(CustomPropertyHandle _property_handle,
unsigned int _vertex,
const void* _data);
506 void get_custom_property(CustomPropertyHandle _property_handle,
unsigned int _vertex,
void* _dst)
const;
509 void set_custom_property(
const std::string& _name,
unsigned int _vertex,
const void* _data);
510 void get_custom_property(
const std::string& _name,
unsigned int _vertex,
void* _dst)
const;
540 CustomPropertyHandle get_custom_property_handle(
const std::string& _name)
const;
543 const std::string get_custom_property_name(CustomPropertyHandle _property_handle)
const;
546 unsigned int get_num_custom_properties()
const;
549 const void* get_custom_property_buffer(CustomPropertyHandle _property_handle)
const;
553 CustomPropertyHandle enumerate_custom_property_handles(
unsigned int _i)
const;
558 bool vertex_selected(
unsigned int _i) {
return (_i < vselections_.size() ? vertex_selection(_i) == 1 :
false); }
559 bool edge_selected(
unsigned int _i) {
return (_i < eselections_.size() ? edge_selection(_i) == 1 :
false); }
561 void select_vertex(
unsigned int _i) {
if(_i < vselections_.size()) vertex_selection(_i) = 1; }
562 void select_edge(
unsigned int _i) {
if(_i < eselections_.size()) edge_selection(_i) = 1; }
564 void deselect_vertex(
unsigned int _i) {
if(_i < vselections_.size()) vertex_selection(_i) = 0; }
565 void deselect_edge(
unsigned int _i) {
if(_i < eselections_.size()) edge_selection(_i) = 0; }
571 void copy_vertex_complete(
const PolyLineT<PointT>& _pl,
unsigned int _i,
unsigned int _j);
575 void copy_edge_complete(
const PolyLineT<PointT>& _pl,
unsigned int _i,
unsigned int _j);
588 template <
class MeshT,
class SpatialSearchT>
591 typename MeshT::FaceHandle &_fh,
592 SpatialSearchT * _ssearch = 0,
600 template<
class MeshT,
class SpatialSearchT>
606 SpatialSearchT &_ssearch);
612 template <
class MeshT>
619 template <
class PropT>
620 void request_prop(
unsigned int& _ref_count, PropT& _prop);
621 template <
class PropT>
622 void release_prop(
unsigned int& _ref_count, PropT& _prop);
633 template <
class IPo
int>
635 const IPoint& _n_plane,
640 template<
class MeshT>
641 void edge_points_in_segment(
const MeshT& _mesh,
644 const typename MeshT::FaceHandle _fh0,
645 const typename MeshT::FaceHandle _fh1,
646 std::vector<Point> & _points,
647 std::vector<typename MeshT::EdgeHandle>& _ehandles );
667 std::vector<Point> vnormals_;
668 std::vector<Point> vbinormals_;
669 std::vector<Point> vcolors_;
670 std::vector<Scalar> vscalars_;
671 std::vector<unsigned char> vselections_;
672 std::vector<int> vvhandles_;
673 std::vector<int> vehandles_;
674 std::vector<int> vfhandles_;
676 std::vector<Point> enormals_;
677 std::vector<Point> ecolors_;
678 std::vector<Scalar> escalars_;
679 std::vector<unsigned char> eselections_;
680 std::vector<Point> epreimage_direction_;
684 unsigned int ref_count_vnormals_;
685 unsigned int ref_count_vbinormals_;
686 unsigned int ref_count_vcolors_;
687 unsigned int ref_count_vscalars_;
688 unsigned int ref_count_vselections_;
689 unsigned int ref_count_vvhandles_;
690 unsigned int ref_count_vehandles_;
691 unsigned int ref_count_vfhandles_;
693 unsigned int ref_count_enormals_;
694 unsigned int ref_count_ecolors_;
695 unsigned int ref_count_escalars_;
696 unsigned int ref_count_eselections_;
697 unsigned int ref_count_epreimage_direction_;
708 unsigned int prop_size;
711 std::vector<char> prop_data;
714 unsigned int datatype;
717 std::string shader_binding;
719 char* buffer() {
return prop_data.empty() ? 0 : &prop_data[0];}
720 const char* buffer()
const {
return prop_data.empty() ? 0 : &prop_data[0];}
723 typedef std::map< std::string, CustomProperty* > CustomPropertyMap;
726 const CustomProperty* custom_prop(CustomPropertyHandle _handle)
const;
728 CustomPropertyHandle custom_prop_handle(
const CustomProperty*)
const;
731 CustomPropertyMap custom_properties;
734 std::vector<CustomProperty*> cprop_enum;
741 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_POLYLINET_C) 742 #define ACG_POLYLINET_TEMPLATES 743 #include "PolyLineT.cc" 746 #ifdef EXTENDED_POLY_LINE 747 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_POLYLINE_INTEGRATIONT_C) 748 #define ACG_POLYLINE_INTEGRATIONT_TEMPLATES 749 #include <libs/MeshIntegration/PolyLineIntegrationT.cc> 755 #endif // ACG_POLYLINET_HH defined bool plane_line_intersection(const IPoint &_p_plane, const IPoint &_n_plane, const IPoint &_p0, const IPoint &_p1, IPoint &_p_int)
void mark_components(OpenMesh::PropertyManager< OpenMesh::FPropHandleT< unsigned int >, MeshT > &component)
Point find_nearest_point(const MeshT &_mesh, const Point &_point, typename MeshT::FaceHandle &_fh, SpatialSearchT *_ssearch=0, double *_dbest=0)
size_t n_edges() const
Get number of edges.
const Point & front() const
Get first point of the polyline ( no range check!!!)
LineNodeT * get_line_node(LineNodeT *&_line_node, int _mode=0)
Conversion PolyLine <-> LineNode.
void append(const PolyLineT< PointT > &_pl)
Append second polyline _pl to this one.
bool on_multiple_components(MeshT &_mesh, SpatialSearchT &_ssearch)
void project_to_mesh(const MeshT &_mesh, SpatialSearchT *_ssearch=0)
Project polyline points to nearest surface points (use spatial search!!!)
void collapse(Scalar _smallest)
Collapse polyline.
void delete_point(int _idx)
Delete point at _idx.
Scalar vertex_radius() const
get ball-radius of vertices
void smooth_uniform_laplace2()
Squared laplacian smoothing.
PolyLineT(bool _closed=false)
Constructor.
void resample_arclength_uniform(const unsigned int _n)
Perform an uniform arclength resampling while maintaining the start and end point.
const Point & back() const
Get last point of the polyline ( no range check!!!)
Point & back()
Get last point of the polyline ( no range check!!!)
Scalar total_gaussian_curvature()
compute total gaussian curvature of enclosed surface (via Gauss-Bonnet)
void invert()
Invert polyline that first vertex becomes last.
bool closed_
Connect first and last point?
bool is_closed() const
Check if the polyline is marked as closed.
void set_closed(const bool _c)
Set if the polyline should be closed and therefore forms a loop.
void clear()
Clear the current 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 ...
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 set_vertex_radius(const Scalar _r)
set ball-radius of vertices
void resize(unsigned int _n)
Resize current polyline.
void prepend(const PolyLineT< PointT > &_pl)
Prepend second polyline _pl to polyline.
void print() const
Print information string to cerr.
void set_edge_radius(const Scalar _r)
set cylinder-radius of edges
void bind_custom_property_to_shader(CustomPropertyHandle _property_handle, const std::string &_shader_input_name, unsigned int _datatype)
Binding to vertex shader (optional)
std::vector< Point > & points()
Get all points of the polyline.
void insert_point(int _idx, const Point &_p)
insert _p at _idx into polyline
void smooth_uniform_laplace3()
Cubic laplacian smoothing.
Point edge_vector(unsigned int _i) const
get the i-th oriented edge vector
Scalar edge_radius() const
get cylinder-radius of edges
void subdivide(Scalar _largest)
Subdivide polyline.
void split(unsigned int _split_idx, PolyLineT< PointT > &_new_pl)
Split closed polyline at vertex with index _split_idx.
Point & point(unsigned int _i)
Get a point of the polyline.
std::vector< Point > points_
List of points in the polyline.
Namespace providing different geometric functions concerning angles.
Scalar length() const
Compute the length of the polyline (in future cached method)
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 add_point(const Point &_p)
Append a point to the 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.
unsigned int component_of(const OpenMesh::PropertyManager< OpenMesh::FPropHandleT< unsigned int >, MeshT > &component, const PointT &pt, SpatialSearchT &_ssearch)
Scalar vertex_radius_
ball-radius of vertices
Point & front()
Get first point of the polyline ( no range check!!!)
Scalar edge_radius_
cylinder-radius of edges
void smooth_uniform_laplace()
Laplacian smoothing.
const Point & point(unsigned int _i) const
Get a point of the polyline.
Point position(const Scalar _t) const
Provide linear paremterization of the polyline in [0,1].
void split_into_one_per_component(MeshT &_mesh, SpatialSearchT &_ssearch, std::vector< PolyLineT > &out_polylines)
size_t n_vertices() const
Get number of vertices.
Point position_arclength(const Scalar _t) const
Same as position but with an arclength parameterization in [0,length()].
void split_closed(unsigned int _split_idx)
Split closed polyline at vertex with index _split_idx.
const std::vector< Point > & points() const
Get all points of the polyline.