49 #ifndef OPENMESH_ATTRIBKERNEL_HH 50 #define OPENMESH_ATTRIBKERNEL_HH 56 #include <OpenMesh/Core/Utils/GenProg.hh> 57 #include <OpenMesh/Core/Utils/vector_traits.hh> 76 template <
class MeshItems,
class Connectivity>
83 typedef MeshItems MeshItemsT;
84 typedef Connectivity ConnectivityT;
85 typedef typename Connectivity::Vertex Vertex;
86 typedef typename Connectivity::Halfedge Halfedge;
87 typedef typename Connectivity::Edge Edge;
88 typedef typename Connectivity::Face Face;
90 typedef typename MeshItems::Point Point;
96 typedef typename MeshItems::Scalar Scalar;
99 typedef typename MeshItems::VertexData VertexData;
100 typedef typename MeshItems::HalfedgeData HalfedgeData;
101 typedef typename MeshItems::EdgeData EdgeData;
102 typedef typename MeshItems::FaceData FaceData;
107 VAttribs = MeshItems::VAttribs,
108 HAttribs = MeshItems::HAttribs,
109 EAttribs = MeshItems::EAttribs,
110 FAttribs = MeshItems::FAttribs
123 : refcount_vnormals_(0),
124 refcount_vcolors_(0),
125 refcount_vtexcoords1D_(0),
126 refcount_vtexcoords2D_(0),
127 refcount_vtexcoords3D_(0),
128 refcount_htexcoords1D_(0),
129 refcount_htexcoords2D_(0),
130 refcount_htexcoords3D_(0),
131 refcount_henormals_(0),
132 refcount_hecolors_(0),
133 refcount_ecolors_(0),
134 refcount_fnormals_(0),
135 refcount_fcolors_(0),
136 refcount_ftextureIndex_(0)
138 this->add_property( points_,
"v:points" );
141 request_vertex_normals();
144 request_vertex_colors();
147 request_vertex_texcoords1D();
150 request_vertex_texcoords2D();
153 request_vertex_texcoords3D();
155 if (HAttribs & Attributes::TexCoord1D)
156 request_halfedge_texcoords1D();
158 if (HAttribs & Attributes::TexCoord2D)
159 request_halfedge_texcoords2D();
161 if (HAttribs & Attributes::TexCoord3D)
162 request_halfedge_texcoords3D();
164 if (HAttribs & Attributes::Color)
165 request_halfedge_colors();
168 Connectivity::request_vertex_status();
170 if (HAttribs & Attributes::Status)
171 Connectivity::request_halfedge_status();
173 if (HAttribs & Attributes::Normal)
174 request_halfedge_normals();
176 if (EAttribs & Attributes::Status)
177 Connectivity::request_edge_status();
179 if (EAttribs & Attributes::Color)
180 request_edge_colors();
182 if (FAttribs & Attributes::Normal)
183 request_face_normals();
185 if (FAttribs & Attributes::Color)
186 request_face_colors();
188 if (FAttribs & Attributes::Status)
189 Connectivity::request_face_status();
192 request_face_texture_index();
196 this->add_property(data_vpph_);
197 this->add_property(data_fpph_);
198 this->add_property(data_hpph_);
199 this->add_property(data_epph_);
216 template <
class _AttribKernel>
219 this->assign_connectivity(_other);
220 for (
typename Connectivity::VertexIter v_it = Connectivity::vertices_begin();
221 v_it != Connectivity::vertices_end(); ++v_it)
223 set_point(*v_it, (Point)_other.point(*v_it));
229 const Point* points()
const 230 {
return this->property(points_).data(); }
233 {
return this->property(points_, _vh); }
236 {
return this->property(points_, _vh); }
239 { this->property(points_, _vh) = _p; }
244 const Normal* vertex_normals()
const 245 {
return this->property(vertex_normals_).data(); }
248 {
return this->property(vertex_normals_, _vh); }
251 { this->property(vertex_normals_, _vh) = _n; }
256 const Color* vertex_colors()
const 257 {
return this->property(vertex_colors_).data(); }
260 {
return this->property(vertex_colors_, _vh); }
263 { this->property(vertex_colors_, _vh) = _c; }
268 const TexCoord1D* texcoords1D()
const {
269 return this->property(vertex_texcoords1D_).data();
273 return this->property(vertex_texcoords1D_, _vh);
276 void set_texcoord1D(
VertexHandle _vh,
const TexCoord1D& _t) {
277 this->property(vertex_texcoords1D_, _vh) = _t;
283 const TexCoord2D* texcoords2D()
const {
284 return this->property(vertex_texcoords2D_).data();
288 return this->property(vertex_texcoords2D_, _vh);
291 void set_texcoord2D(
VertexHandle _vh,
const TexCoord2D& _t) {
292 this->property(vertex_texcoords2D_, _vh) = _t;
298 const TexCoord3D* texcoords3D()
const {
299 return this->property(vertex_texcoords3D_).data();
303 return this->property(vertex_texcoords3D_, _vh);
306 void set_texcoord3D(
VertexHandle _vh,
const TexCoord3D& _t) {
307 this->property(vertex_texcoords3D_, _vh) = _t;
312 const TexCoord1D* htexcoords1D()
const {
313 return this->property(halfedge_texcoords1D_).data();
317 return this->property(halfedge_texcoords1D_, _heh);
321 this->property(halfedge_texcoords1D_, _heh) = _t;
327 const TexCoord2D* htexcoords2D()
const {
328 return this->property(halfedge_texcoords2D_).data();
332 return this->property(halfedge_texcoords2D_, _heh);
336 this->property(halfedge_texcoords2D_, _heh) = _t;
342 const TexCoord3D* htexcoords3D()
const {
343 return this->property(halfedge_texcoords3D_).data();
347 return this->property(halfedge_texcoords3D_, _heh);
351 this->property(halfedge_texcoords3D_, _heh) = _t;
356 const Color* edge_colors()
const 357 {
return this->property(edge_colors_).data(); }
360 {
return this->property(edge_colors_, _eh); }
362 void set_color(
EdgeHandle _eh,
const Color& _c)
363 { this->property(edge_colors_, _eh) = _c; }
369 {
return this->property(halfedge_normals_, _heh); }
372 { this->property(halfedge_normals_, _heh) = _n; }
377 const Color* halfedge_colors()
const 378 {
return this->property(halfedge_colors_).data(); }
381 {
return this->property(halfedge_colors_, _heh); }
384 { this->property(halfedge_colors_, _heh) = _c; }
389 {
return this->property(face_normals_, _fh); }
391 void set_normal(
FaceHandle _fh,
const Normal& _n)
392 { this->property(face_normals_, _fh) = _n; }
396 const TextureIndex& texture_index(
FaceHandle _fh)
const 397 {
return this->property(face_texture_index_, _fh); }
399 void set_texture_index(
FaceHandle _fh,
const TextureIndex& _t)
400 { this->property(face_texture_index_, _fh) = _t; }
405 {
return this->property(face_colors_, _fh); }
407 void set_color(
FaceHandle _fh,
const Color& _c)
408 { this->property(face_colors_, _fh) = _c; }
412 void request_vertex_normals()
414 if (!refcount_vnormals_++)
415 this->add_property( vertex_normals_,
"v:normals" );
418 void request_vertex_colors()
420 if (!refcount_vcolors_++)
421 this->add_property( vertex_colors_,
"v:colors" );
424 void request_vertex_texcoords1D()
426 if (!refcount_vtexcoords1D_++)
427 this->add_property( vertex_texcoords1D_,
"v:texcoords1D" );
430 void request_vertex_texcoords2D()
432 if (!refcount_vtexcoords2D_++)
433 this->add_property( vertex_texcoords2D_,
"v:texcoords2D" );
436 void request_vertex_texcoords3D()
438 if (!refcount_vtexcoords3D_++)
439 this->add_property( vertex_texcoords3D_,
"v:texcoords3D" );
442 void request_halfedge_texcoords1D()
444 if (!refcount_htexcoords1D_++)
445 this->add_property( halfedge_texcoords1D_,
"h:texcoords1D" );
448 void request_halfedge_texcoords2D()
450 if (!refcount_htexcoords2D_++)
451 this->add_property( halfedge_texcoords2D_,
"h:texcoords2D" );
454 void request_halfedge_texcoords3D()
456 if (!refcount_htexcoords3D_++)
457 this->add_property( halfedge_texcoords3D_,
"h:texcoords3D" );
460 void request_edge_colors()
462 if (!refcount_ecolors_++)
463 this->add_property( edge_colors_,
"e:colors" );
466 void request_halfedge_normals()
468 if (!refcount_henormals_++)
469 this->add_property( halfedge_normals_,
"h:normals" );
472 void request_halfedge_colors()
474 if (!refcount_hecolors_++)
475 this->add_property( halfedge_colors_,
"h:colors" );
478 void request_face_normals()
480 if (!refcount_fnormals_++)
481 this->add_property( face_normals_,
"f:normals" );
484 void request_face_colors()
486 if (!refcount_fcolors_++)
487 this->add_property( face_colors_,
"f:colors" );
490 void request_face_texture_index()
492 if (!refcount_ftextureIndex_++)
493 this->add_property( face_texture_index_,
"f:textureindex" );
498 void release_vertex_normals()
500 if ((refcount_vnormals_ > 0) && (! --refcount_vnormals_))
501 this->remove_property(vertex_normals_);
504 void release_vertex_colors()
506 if ((refcount_vcolors_ > 0) && (! --refcount_vcolors_))
507 this->remove_property(vertex_colors_);
510 void release_vertex_texcoords1D() {
511 if ((refcount_vtexcoords1D_ > 0) && (! --refcount_vtexcoords1D_))
512 this->remove_property(vertex_texcoords1D_);
515 void release_vertex_texcoords2D() {
516 if ((refcount_vtexcoords2D_ > 0) && (! --refcount_vtexcoords2D_))
517 this->remove_property(vertex_texcoords2D_);
520 void release_vertex_texcoords3D() {
521 if ((refcount_vtexcoords3D_ > 0) && (! --refcount_vtexcoords3D_))
522 this->remove_property(vertex_texcoords3D_);
525 void release_halfedge_texcoords1D() {
526 if ((refcount_htexcoords1D_ > 0) && (! --refcount_htexcoords1D_))
527 this->remove_property(halfedge_texcoords1D_);
530 void release_halfedge_texcoords2D() {
531 if ((refcount_htexcoords2D_ > 0) && (! --refcount_htexcoords2D_))
532 this->remove_property(halfedge_texcoords2D_);
535 void release_halfedge_texcoords3D() {
536 if ((refcount_htexcoords3D_ > 0) && (! --refcount_htexcoords3D_))
537 this->remove_property(halfedge_texcoords3D_);
540 void release_edge_colors()
542 if ((refcount_ecolors_ > 0) && (! --refcount_ecolors_))
543 this->remove_property(edge_colors_);
546 void release_halfedge_normals()
548 if ((refcount_henormals_ > 0) && (! --refcount_henormals_))
549 this->remove_property(halfedge_normals_);
552 void release_halfedge_colors()
554 if ((refcount_hecolors_ > 0) && (! --refcount_hecolors_))
555 this->remove_property(halfedge_colors_);
558 void release_face_normals()
560 if ((refcount_fnormals_ > 0) && (! --refcount_fnormals_))
561 this->remove_property(face_normals_);
564 void release_face_colors()
566 if ((refcount_fcolors_ > 0) && (! --refcount_fcolors_))
567 this->remove_property(face_colors_);
570 void release_face_texture_index()
572 if ((refcount_ftextureIndex_ > 0) && (! --refcount_ftextureIndex_))
573 this->remove_property(face_texture_index_);
578 bool has_vertex_normals()
const {
return vertex_normals_.
is_valid(); }
579 bool has_vertex_colors()
const {
return vertex_colors_.
is_valid(); }
580 bool has_vertex_texcoords1D()
const {
return vertex_texcoords1D_.
is_valid(); }
581 bool has_vertex_texcoords2D()
const {
return vertex_texcoords2D_.
is_valid(); }
582 bool has_vertex_texcoords3D()
const {
return vertex_texcoords3D_.
is_valid(); }
583 bool has_halfedge_texcoords1D()
const {
return halfedge_texcoords1D_.
is_valid();}
584 bool has_halfedge_texcoords2D()
const {
return halfedge_texcoords2D_.
is_valid();}
585 bool has_halfedge_texcoords3D()
const {
return halfedge_texcoords3D_.
is_valid();}
586 bool has_edge_colors()
const {
return edge_colors_.
is_valid(); }
587 bool has_halfedge_normals()
const {
return halfedge_normals_.
is_valid(); }
588 bool has_halfedge_colors()
const {
return halfedge_colors_.
is_valid(); }
589 bool has_face_normals()
const {
return face_normals_.
is_valid(); }
590 bool has_face_colors()
const {
return face_colors_.
is_valid(); }
591 bool has_face_texture_index()
const {
return face_texture_index_.
is_valid(); }
613 PointsPropertyHandle points_pph()
const 616 VertexNormalsPropertyHandle vertex_normals_pph()
const 617 {
return vertex_normals_; }
619 VertexColorsPropertyHandle vertex_colors_pph()
const 620 {
return vertex_colors_; }
622 VertexTexCoords1DPropertyHandle vertex_texcoords1D_pph()
const 623 {
return vertex_texcoords1D_; }
625 VertexTexCoords2DPropertyHandle vertex_texcoords2D_pph()
const 626 {
return vertex_texcoords2D_; }
628 VertexTexCoords3DPropertyHandle vertex_texcoords3D_pph()
const 629 {
return vertex_texcoords3D_; }
632 HalfedgeTexCoords1DPropertyHandle halfedge_texcoords1D_pph()
const 633 {
return halfedge_texcoords1D_; }
635 HalfedgeTexCoords2DPropertyHandle halfedge_texcoords2D_pph()
const 636 {
return halfedge_texcoords2D_; }
638 HalfedgeTexCoords3DPropertyHandle halfedge_texcoords3D_pph()
const 639 {
return halfedge_texcoords3D_; }
642 HalfedgeNormalsPropertyHandle halfedge_normals_pph()
const 643 {
return halfedge_normals_; }
647 HalfedgeColorsPropertyHandle halfedge_colors_pph()
const 648 {
return halfedge_colors_; }
651 EdgeColorsPropertyHandle edge_colors_pph()
const 652 {
return edge_colors_; }
655 FaceNormalsPropertyHandle face_normals_pph()
const 656 {
return face_normals_; }
658 FaceColorsPropertyHandle face_colors_pph()
const 659 {
return face_colors_; }
661 FaceTextureIndexPropertyHandle face_texture_index_pph()
const 662 {
return face_texture_index_; }
665 {
return this->property(data_vpph_, _vh); }
668 {
return this->property(data_vpph_, _vh); }
671 {
return this->property(data_fpph_, _fh); }
674 {
return this->property(data_fpph_, _fh); }
677 {
return this->property(data_epph_, _eh); }
680 {
return this->property(data_epph_, _eh); }
683 {
return this->property(data_hpph_, _heh); }
686 {
return this->property(data_hpph_, _heh); }
690 PointsPropertyHandle points_;
691 VertexNormalsPropertyHandle vertex_normals_;
692 VertexColorsPropertyHandle vertex_colors_;
693 VertexTexCoords1DPropertyHandle vertex_texcoords1D_;
694 VertexTexCoords2DPropertyHandle vertex_texcoords2D_;
695 VertexTexCoords3DPropertyHandle vertex_texcoords3D_;
697 HalfedgeTexCoords1DPropertyHandle halfedge_texcoords1D_;
698 HalfedgeTexCoords2DPropertyHandle halfedge_texcoords2D_;
699 HalfedgeTexCoords3DPropertyHandle halfedge_texcoords3D_;
700 HalfedgeNormalsPropertyHandle halfedge_normals_;
701 HalfedgeColorsPropertyHandle halfedge_colors_;
703 EdgeColorsPropertyHandle edge_colors_;
705 FaceNormalsPropertyHandle face_normals_;
706 FaceColorsPropertyHandle face_colors_;
707 FaceTextureIndexPropertyHandle face_texture_index_;
709 DataVPropHandle data_vpph_;
710 DataHPropHandle data_hpph_;
711 DataEPropHandle data_epph_;
712 DataFPropHandle data_fpph_;
714 unsigned int refcount_vnormals_;
715 unsigned int refcount_vcolors_;
716 unsigned int refcount_vtexcoords1D_;
717 unsigned int refcount_vtexcoords2D_;
718 unsigned int refcount_vtexcoords3D_;
719 unsigned int refcount_htexcoords1D_;
720 unsigned int refcount_htexcoords2D_;
721 unsigned int refcount_htexcoords3D_;
722 unsigned int refcount_henormals_;
723 unsigned int refcount_hecolors_;
724 unsigned int refcount_ecolors_;
725 unsigned int refcount_fnormals_;
726 unsigned int refcount_fcolors_;
727 unsigned int refcount_ftextureIndex_;
733 #endif // OPENMESH_ATTRIBKERNEL_HH defined Add texture index (faces)
Definition: Attributes.hh:94
This file provides some macros containing attribute usage.
void assign(const _AttribKernel &_other)
Assignment from another mesh of another type.
Definition: AttribKernelT.hh:217
Add 1D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:91
The attribute kernel adds all standard properties to the kernel.
Definition: AttribKernelT.hh:77
Handle for a vertex entity.
Definition: Handles.hh:125
bool is_valid() const
The handle is valid iff the index is not equal to -1.
Definition: Handles.hh:77
Add status to mesh item (all items)
Definition: Attributes.hh:90
Add 2D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:92
Add 3D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:93
Handle for a face entity.
Definition: Handles.hh:146
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:87
Handle for a edge entity.
Definition: Handles.hh:139
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:88
Handle for a halfedge entity.
Definition: Handles.hh:132