OpenMesh: OpenMesh/Core/Mesh/AttribKernelT.hh Source File

| OpenMesh

AttribKernelT.hh
1 /* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openmesh.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenMesh. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 * ========================================================================= */
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $Date$ *
46 * *
47 \*===========================================================================*/
48
49 #ifndef OPENMESH_ATTRIBKERNEL_HH
50 #define OPENMESH_ATTRIBKERNEL_HH
51
52
53 //== INCLUDES =================================================================
54
55 #include <OpenMesh/Core/Mesh/Attributes.hh>
56 #include <OpenMesh/Core/Utils/GenProg.hh>
57 #include <OpenMesh/Core/Utils/vector_traits.hh>
58 #include <vector>
59 #include <algorithm>
60
61 //== NAMESPACES ===============================================================
62
63 namespace OpenMesh {
64
65
66 //== CLASS DEFINITION =========================================================
67
76 template <class MeshItems, class Connectivity>
77 class AttribKernelT : public Connectivity
78 {
79 public:
80
81 //---------------------------------------------------------------- item types
82
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;
89
90 typedef typename MeshItems::Point Point;
91 typedef typename MeshItems::Normal Normal;
92 typedef typename MeshItems::Color Color;
93 typedef typename MeshItems::TexCoord1D TexCoord1D;
94 typedef typename MeshItems::TexCoord2D TexCoord2D;
95 typedef typename MeshItems::TexCoord3D TexCoord3D;
96 typedef typename MeshItems::Scalar Scalar;
97 typedef typename MeshItems::TextureIndex TextureIndex;
98
99 typedef typename MeshItems::VertexData VertexData;
100 typedef typename MeshItems::HalfedgeData HalfedgeData;
101 typedef typename MeshItems::EdgeData EdgeData;
102 typedef typename MeshItems::FaceData FaceData;
103
104 typedef AttribKernelT<MeshItems,Connectivity> AttribKernel;
105
106 enum Attribs {
107 VAttribs = MeshItems::VAttribs,
108 HAttribs = MeshItems::HAttribs,
109 EAttribs = MeshItems::EAttribs,
110 FAttribs = MeshItems::FAttribs
111 };
112
113 typedef VPropHandleT<VertexData> DataVPropHandle;
114 typedef HPropHandleT<HalfedgeData> DataHPropHandle;
115 typedef EPropHandleT<EdgeData> DataEPropHandle;
116 typedef FPropHandleT<FaceData> DataFPropHandle;
117
118 public:
119
120 //-------------------------------------------------- constructor / destructor
121
122 AttribKernelT()
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)
137 {
138 this->add_property( points_, "v:points" );
139
140 if (VAttribs & Attributes::Normal)
141 request_vertex_normals();
142
143 if (VAttribs & Attributes::Color)
144 request_vertex_colors();
145
146 if (VAttribs & Attributes::TexCoord1D)
147 request_vertex_texcoords1D();
148
149 if (VAttribs & Attributes::TexCoord2D)
150 request_vertex_texcoords2D();
151
152 if (VAttribs & Attributes::TexCoord3D)
153 request_vertex_texcoords3D();
154
155 if (HAttribs & Attributes::TexCoord1D)
156 request_halfedge_texcoords1D();
157
158 if (HAttribs & Attributes::TexCoord2D)
159 request_halfedge_texcoords2D();
160
161 if (HAttribs & Attributes::TexCoord3D)
162 request_halfedge_texcoords3D();
163
164 if (HAttribs & Attributes::Color)
165 request_halfedge_colors();
166
167 if (VAttribs & Attributes::Status)
168 Connectivity::request_vertex_status();
169
170 if (HAttribs & Attributes::Status)
171 Connectivity::request_halfedge_status();
172
173 if (HAttribs & Attributes::Normal)
174 request_halfedge_normals();
175
176 if (EAttribs & Attributes::Status)
177 Connectivity::request_edge_status();
178
179 if (EAttribs & Attributes::Color)
180 request_edge_colors();
181
182 if (FAttribs & Attributes::Normal)
183 request_face_normals();
184
185 if (FAttribs & Attributes::Color)
186 request_face_colors();
187
188 if (FAttribs & Attributes::Status)
189 Connectivity::request_face_status();
190
191 if (FAttribs & Attributes::TextureIndex)
192 request_face_texture_index();
193
194 //FIXME: data properties might actually cost storage even
195 //if there are no data traits??
196 this->add_property(data_vpph_);
197 this->add_property(data_fpph_);
198 this->add_property(data_hpph_);
199 this->add_property(data_epph_);
200 }
201
202 virtual ~AttribKernelT()
203 {
204 // should remove properties, but this will be done in
205 // BaseKernel's destructor anyway...
206 }
207
215 template <class _AttribKernel>
216 void assign(const _AttribKernel& _other, bool copyStandardProperties = false)
217 {
218 //copy standard properties if necessary
219 if(copyStandardProperties)
220 this->copy_all_kernel_properties(_other);
221
222 this->assign_connectivity(_other);
223 for (typename Connectivity::VertexIter v_it = Connectivity::vertices_begin();
224 v_it != Connectivity::vertices_end(); ++v_it)
225 {//assumes Point constructor supports cast from _AttribKernel::Point
226 set_point(*v_it, (Point)_other.point(*v_it));
227 }
228
229 //initialize standard properties if necessary
230 if(copyStandardProperties)
231 initializeStandardProperties();
232 }
233
234 //-------------------------------------------------------------------- points
235
236 const Point* points() const
237 { return this->property(points_).data(); }
238
239 const Point& point(VertexHandle _vh) const
240 { return this->property(points_, _vh); }
241
242 Point& point(VertexHandle _vh)
243 { return this->property(points_, _vh); }
244
245 void set_point(VertexHandle _vh, const Point& _p)
246 { this->property(points_, _vh) = _p; }
247
248
249 //------------------------------------------------------------ vertex normals
250
251 const Normal* vertex_normals() const
252 { return this->property(vertex_normals_).data(); }
253
254 const Normal& normal(VertexHandle _vh) const
255 { return this->property(vertex_normals_, _vh); }
256
257 void set_normal(VertexHandle _vh, const Normal& _n)
258 { this->property(vertex_normals_, _vh) = _n; }
259
260
261 //------------------------------------------------------------- vertex colors
262
263 const Color* vertex_colors() const
264 { return this->property(vertex_colors_).data(); }
265
266 const Color& color(VertexHandle _vh) const
267 { return this->property(vertex_colors_, _vh); }
268
269 void set_color(VertexHandle _vh, const Color& _c)
270 { this->property(vertex_colors_, _vh) = _c; }
271
272
273 //------------------------------------------------------- vertex 1D texcoords
274
275 const TexCoord1D* texcoords1D() const {
276 return this->property(vertex_texcoords1D_).data();
277 }
278
279 const TexCoord1D& texcoord1D(VertexHandle _vh) const {
280 return this->property(vertex_texcoords1D_, _vh);
281 }
282
283 void set_texcoord1D(VertexHandle _vh, const TexCoord1D& _t) {
284 this->property(vertex_texcoords1D_, _vh) = _t;
285 }
286
287
288 //------------------------------------------------------- vertex 2D texcoords
289
290 const TexCoord2D* texcoords2D() const {
291 return this->property(vertex_texcoords2D_).data();
292 }
293
294 const TexCoord2D& texcoord2D(VertexHandle _vh) const {
295 return this->property(vertex_texcoords2D_, _vh);
296 }
297
298 void set_texcoord2D(VertexHandle _vh, const TexCoord2D& _t) {
299 this->property(vertex_texcoords2D_, _vh) = _t;
300 }
301
302
303 //------------------------------------------------------- vertex 3D texcoords
304
305 const TexCoord3D* texcoords3D() const {
306 return this->property(vertex_texcoords3D_).data();
307 }
308
309 const TexCoord3D& texcoord3D(VertexHandle _vh) const {
310 return this->property(vertex_texcoords3D_, _vh);
311 }
312
313 void set_texcoord3D(VertexHandle _vh, const TexCoord3D& _t) {
314 this->property(vertex_texcoords3D_, _vh) = _t;
315 }
316
317 //.------------------------------------------------------ halfedge 1D texcoords
318
319 const TexCoord1D* htexcoords1D() const {
320 return this->property(halfedge_texcoords1D_).data();
321 }
322
323 const TexCoord1D& texcoord1D(HalfedgeHandle _heh) const {
324 return this->property(halfedge_texcoords1D_, _heh);
325 }
326
327 void set_texcoord1D(HalfedgeHandle _heh, const TexCoord1D& _t) {
328 this->property(halfedge_texcoords1D_, _heh) = _t;
329 }
330
331
332 //------------------------------------------------------- halfedge 2D texcoords
333
334 const TexCoord2D* htexcoords2D() const {
335 return this->property(halfedge_texcoords2D_).data();
336 }
337
338 const TexCoord2D& texcoord2D(HalfedgeHandle _heh) const {
339 return this->property(halfedge_texcoords2D_, _heh);
340 }
341
342 void set_texcoord2D(HalfedgeHandle _heh, const TexCoord2D& _t) {
343 this->property(halfedge_texcoords2D_, _heh) = _t;
344 }
345
346
347 //------------------------------------------------------- halfedge 3D texcoords
348
349 const TexCoord3D* htexcoords3D() const {
350 return this->property(halfedge_texcoords3D_).data();
351 }
352
353 const TexCoord3D& texcoord3D(HalfedgeHandle _heh) const {
354 return this->property(halfedge_texcoords3D_, _heh);
355 }
356
357 void set_texcoord3D(HalfedgeHandle _heh, const TexCoord3D& _t) {
358 this->property(halfedge_texcoords3D_, _heh) = _t;
359 }
360
361 //------------------------------------------------------------- edge colors
362
363 const Color* edge_colors() const
364 { return this->property(edge_colors_).data(); }
365
366 const Color& color(EdgeHandle _eh) const
367 { return this->property(edge_colors_, _eh); }
368
369 void set_color(EdgeHandle _eh, const Color& _c)
370 { this->property(edge_colors_, _eh) = _c; }
371
372
373 //------------------------------------------------------------- halfedge normals
374
375 const Normal& normal(HalfedgeHandle _heh) const
376 { return this->property(halfedge_normals_, _heh); }
377
378 void set_normal(HalfedgeHandle _heh, const Normal& _n)
379 { this->property(halfedge_normals_, _heh) = _n; }
380
381
382 //------------------------------------------------------------- halfedge colors
383
384 const Color* halfedge_colors() const
385 { return this->property(halfedge_colors_).data(); }
386
387 const Color& color(HalfedgeHandle _heh) const
388 { return this->property(halfedge_colors_, _heh); }
389
390 void set_color(HalfedgeHandle _heh, const Color& _c)
391 { this->property(halfedge_colors_, _heh) = _c; }
392
393 //-------------------------------------------------------------- face normals
394
395 const Normal& normal(FaceHandle _fh) const
396 { return this->property(face_normals_, _fh); }
397
398 void set_normal(FaceHandle _fh, const Normal& _n)
399 { this->property(face_normals_, _fh) = _n; }
400
401 //-------------------------------------------------------------- per Face Texture index
402
403 const TextureIndex& texture_index(FaceHandle _fh) const
404 { return this->property(face_texture_index_, _fh); }
405
406 void set_texture_index(FaceHandle _fh, const TextureIndex& _t)
407 { this->property(face_texture_index_, _fh) = _t; }
408
409 //--------------------------------------------------------------- face colors
410
411 const Color& color(FaceHandle _fh) const
412 { return this->property(face_colors_, _fh); }
413
414 void set_color(FaceHandle _fh, const Color& _c)
415 { this->property(face_colors_, _fh) = _c; }
416
417 //------------------------------------------------ request / alloc properties
418
419 void request_vertex_normals()
420 {
421 if (!refcount_vnormals_++)
422 this->add_property( vertex_normals_, "v:normals" );
423 }
424
425 void request_vertex_colors()
426 {
427 if (!refcount_vcolors_++)
428 this->add_property( vertex_colors_, "v:colors" );
429 }
430
431 void request_vertex_texcoords1D()
432 {
433 if (!refcount_vtexcoords1D_++)
434 this->add_property( vertex_texcoords1D_, "v:texcoords1D" );
435 }
436
437 void request_vertex_texcoords2D()
438 {
439 if (!refcount_vtexcoords2D_++)
440 this->add_property( vertex_texcoords2D_, "v:texcoords2D" );
441 }
442
443 void request_vertex_texcoords3D()
444 {
445 if (!refcount_vtexcoords3D_++)
446 this->add_property( vertex_texcoords3D_, "v:texcoords3D" );
447 }
448
449 void request_halfedge_texcoords1D()
450 {
451 if (!refcount_htexcoords1D_++)
452 this->add_property( halfedge_texcoords1D_, "h:texcoords1D" );
453 }
454
455 void request_halfedge_texcoords2D()
456 {
457 if (!refcount_htexcoords2D_++)
458 this->add_property( halfedge_texcoords2D_, "h:texcoords2D" );
459 }
460
461 void request_halfedge_texcoords3D()
462 {
463 if (!refcount_htexcoords3D_++)
464 this->add_property( halfedge_texcoords3D_, "h:texcoords3D" );
465 }
466
467 void request_edge_colors()
468 {
469 if (!refcount_ecolors_++)
470 this->add_property( edge_colors_, "e:colors" );
471 }
472
473 void request_halfedge_normals()
474 {
475 if (!refcount_henormals_++)
476 this->add_property( halfedge_normals_, "h:normals" );
477 }
478
479 void request_halfedge_colors()
480 {
481 if (!refcount_hecolors_++)
482 this->add_property( halfedge_colors_, "h:colors" );
483 }
484
485 void request_face_normals()
486 {
487 if (!refcount_fnormals_++)
488 this->add_property( face_normals_, "f:normals" );
489 }
490
491 void request_face_colors()
492 {
493 if (!refcount_fcolors_++)
494 this->add_property( face_colors_, "f:colors" );
495 }
496
497 void request_face_texture_index()
498 {
499 if (!refcount_ftextureIndex_++)
500 this->add_property( face_texture_index_, "f:textureindex" );
501 }
502
503 //------------------------------------------------- release / free properties
504
505 void release_vertex_normals()
506 {
507 if ((refcount_vnormals_ > 0) && (! --refcount_vnormals_))
508 this->remove_property(vertex_normals_);
509 }
510
511 void release_vertex_colors()
512 {
513 if ((refcount_vcolors_ > 0) && (! --refcount_vcolors_))
514 this->remove_property(vertex_colors_);
515 }
516
517 void release_vertex_texcoords1D() {
518 if ((refcount_vtexcoords1D_ > 0) && (! --refcount_vtexcoords1D_))
519 this->remove_property(vertex_texcoords1D_);
520 }
521
522 void release_vertex_texcoords2D() {
523 if ((refcount_vtexcoords2D_ > 0) && (! --refcount_vtexcoords2D_))
524 this->remove_property(vertex_texcoords2D_);
525 }
526
527 void release_vertex_texcoords3D() {
528 if ((refcount_vtexcoords3D_ > 0) && (! --refcount_vtexcoords3D_))
529 this->remove_property(vertex_texcoords3D_);
530 }
531
532 void release_halfedge_texcoords1D() {
533 if ((refcount_htexcoords1D_ > 0) && (! --refcount_htexcoords1D_))
534 this->remove_property(halfedge_texcoords1D_);
535 }
536
537 void release_halfedge_texcoords2D() {
538 if ((refcount_htexcoords2D_ > 0) && (! --refcount_htexcoords2D_))
539 this->remove_property(halfedge_texcoords2D_);
540 }
541
542 void release_halfedge_texcoords3D() {
543 if ((refcount_htexcoords3D_ > 0) && (! --refcount_htexcoords3D_))
544 this->remove_property(halfedge_texcoords3D_);
545 }
546
547 void release_edge_colors()
548 {
549 if ((refcount_ecolors_ > 0) && (! --refcount_ecolors_))
550 this->remove_property(edge_colors_);
551 }
552
553 void release_halfedge_normals()
554 {
555 if ((refcount_henormals_ > 0) && (! --refcount_henormals_))
556 this->remove_property(halfedge_normals_);
557 }
558
559 void release_halfedge_colors()
560 {
561 if ((refcount_hecolors_ > 0) && (! --refcount_hecolors_))
562 this->remove_property(halfedge_colors_);
563 }
564
565 void release_face_normals()
566 {
567 if ((refcount_fnormals_ > 0) && (! --refcount_fnormals_))
568 this->remove_property(face_normals_);
569 }
570
571 void release_face_colors()
572 {
573 if ((refcount_fcolors_ > 0) && (! --refcount_fcolors_))
574 this->remove_property(face_colors_);
575 }
576
577 void release_face_texture_index()
578 {
579 if ((refcount_ftextureIndex_ > 0) && (! --refcount_ftextureIndex_))
580 this->remove_property(face_texture_index_);
581 }
582
583 //---------------------------------------------- dynamic check for properties
584
585 bool has_vertex_normals() const { return vertex_normals_.is_valid(); }
586 bool has_vertex_colors() const { return vertex_colors_.is_valid(); }
587 bool has_vertex_texcoords1D() const { return vertex_texcoords1D_.is_valid(); }
588 bool has_vertex_texcoords2D() const { return vertex_texcoords2D_.is_valid(); }
589 bool has_vertex_texcoords3D() const { return vertex_texcoords3D_.is_valid(); }
590 bool has_halfedge_texcoords1D() const { return halfedge_texcoords1D_.is_valid();}
591 bool has_halfedge_texcoords2D() const { return halfedge_texcoords2D_.is_valid();}
592 bool has_halfedge_texcoords3D() const { return halfedge_texcoords3D_.is_valid();}
593 bool has_edge_colors() const { return edge_colors_.is_valid(); }
594 bool has_halfedge_normals() const { return halfedge_normals_.is_valid(); }
595 bool has_halfedge_colors() const { return halfedge_colors_.is_valid(); }
596 bool has_face_normals() const { return face_normals_.is_valid(); }
597 bool has_face_colors() const { return face_colors_.is_valid(); }
598 bool has_face_texture_index() const { return face_texture_index_.is_valid(); }
599
600 public:
601
602 typedef VPropHandleT<Point> PointsPropertyHandle;
603 typedef VPropHandleT<Normal> VertexNormalsPropertyHandle;
604 typedef VPropHandleT<Color> VertexColorsPropertyHandle;
605 typedef VPropHandleT<TexCoord1D> VertexTexCoords1DPropertyHandle;
606 typedef VPropHandleT<TexCoord2D> VertexTexCoords2DPropertyHandle;
607 typedef VPropHandleT<TexCoord3D> VertexTexCoords3DPropertyHandle;
608 typedef HPropHandleT<TexCoord1D> HalfedgeTexCoords1DPropertyHandle;
609 typedef HPropHandleT<TexCoord2D> HalfedgeTexCoords2DPropertyHandle;
610 typedef HPropHandleT<TexCoord3D> HalfedgeTexCoords3DPropertyHandle;
611 typedef EPropHandleT<Color> EdgeColorsPropertyHandle;
612 typedef HPropHandleT<Normal> HalfedgeNormalsPropertyHandle;
613 typedef HPropHandleT<Color> HalfedgeColorsPropertyHandle;
614 typedef FPropHandleT<Normal> FaceNormalsPropertyHandle;
615 typedef FPropHandleT<Color> FaceColorsPropertyHandle;
616 typedef FPropHandleT<TextureIndex> FaceTextureIndexPropertyHandle;
617
618 public:
619 //standard vertex properties
620 PointsPropertyHandle points_pph() const
621 { return points_; }
622
623 VertexNormalsPropertyHandle vertex_normals_pph() const
624 { return vertex_normals_; }
625
626 VertexColorsPropertyHandle vertex_colors_pph() const
627 { return vertex_colors_; }
628
629 VertexTexCoords1DPropertyHandle vertex_texcoords1D_pph() const
630 { return vertex_texcoords1D_; }
631
632 VertexTexCoords2DPropertyHandle vertex_texcoords2D_pph() const
633 { return vertex_texcoords2D_; }
634
635 VertexTexCoords3DPropertyHandle vertex_texcoords3D_pph() const
636 { return vertex_texcoords3D_; }
637
638 //standard halfedge properties
639 HalfedgeTexCoords1DPropertyHandle halfedge_texcoords1D_pph() const
640 { return halfedge_texcoords1D_; }
641
642 HalfedgeTexCoords2DPropertyHandle halfedge_texcoords2D_pph() const
643 { return halfedge_texcoords2D_; }
644
645 HalfedgeTexCoords3DPropertyHandle halfedge_texcoords3D_pph() const
646 { return halfedge_texcoords3D_; }
647
648 // standard edge properties
649 HalfedgeNormalsPropertyHandle halfedge_normals_pph() const
650 { return halfedge_normals_; }
651
652
653 // standard edge properties
654 HalfedgeColorsPropertyHandle halfedge_colors_pph() const
655 { return halfedge_colors_; }
656
657 // standard edge properties
658 EdgeColorsPropertyHandle edge_colors_pph() const
659 { return edge_colors_; }
660
661 //standard face properties
662 FaceNormalsPropertyHandle face_normals_pph() const
663 { return face_normals_; }
664
665 FaceColorsPropertyHandle face_colors_pph() const
666 { return face_colors_; }
667
668 FaceTextureIndexPropertyHandle face_texture_index_pph() const
669 { return face_texture_index_; }
670
671 VertexData& data(VertexHandle _vh)
672 { return this->property(data_vpph_, _vh); }
673
674 const VertexData& data(VertexHandle _vh) const
675 { return this->property(data_vpph_, _vh); }
676
677 FaceData& data(FaceHandle _fh)
678 { return this->property(data_fpph_, _fh); }
679
680 const FaceData& data(FaceHandle _fh) const
681 { return this->property(data_fpph_, _fh); }
682
683 EdgeData& data(EdgeHandle _eh)
684 { return this->property(data_epph_, _eh); }
685
686 const EdgeData& data(EdgeHandle _eh) const
687 { return this->property(data_epph_, _eh); }
688
689 HalfedgeData& data(HalfedgeHandle _heh)
690 { return this->property(data_hpph_, _heh); }
691
692 const HalfedgeData& data(HalfedgeHandle _heh) const
693 { return this->property(data_hpph_, _heh); }
694
695 private:
696 //standard vertex properties
697 PointsPropertyHandle points_;
698 VertexNormalsPropertyHandle vertex_normals_;
699 VertexColorsPropertyHandle vertex_colors_;
700 VertexTexCoords1DPropertyHandle vertex_texcoords1D_;
701 VertexTexCoords2DPropertyHandle vertex_texcoords2D_;
702 VertexTexCoords3DPropertyHandle vertex_texcoords3D_;
703 //standard halfedge properties
704 HalfedgeTexCoords1DPropertyHandle halfedge_texcoords1D_;
705 HalfedgeTexCoords2DPropertyHandle halfedge_texcoords2D_;
706 HalfedgeTexCoords3DPropertyHandle halfedge_texcoords3D_;
707 HalfedgeNormalsPropertyHandle halfedge_normals_;
708 HalfedgeColorsPropertyHandle halfedge_colors_;
709 // standard edge properties
710 EdgeColorsPropertyHandle edge_colors_;
711 //standard face properties
712 FaceNormalsPropertyHandle face_normals_;
713 FaceColorsPropertyHandle face_colors_;
714 FaceTextureIndexPropertyHandle face_texture_index_;
715 //data properties handles
716 DataVPropHandle data_vpph_;
717 DataHPropHandle data_hpph_;
718 DataEPropHandle data_epph_;
719 DataFPropHandle data_fpph_;
720
721 unsigned int refcount_vnormals_;
722 unsigned int refcount_vcolors_;
723 unsigned int refcount_vtexcoords1D_;
724 unsigned int refcount_vtexcoords2D_;
725 unsigned int refcount_vtexcoords3D_;
726 unsigned int refcount_htexcoords1D_;
727 unsigned int refcount_htexcoords2D_;
728 unsigned int refcount_htexcoords3D_;
729 unsigned int refcount_henormals_;
730 unsigned int refcount_hecolors_;
731 unsigned int refcount_ecolors_;
732 unsigned int refcount_fnormals_;
733 unsigned int refcount_fcolors_;
734 unsigned int refcount_ftextureIndex_;
735
740 void initializeStandardProperties()
741 {
742 if(!this->get_property_handle(points_,
743 "v:points"))
744 {
745 //mesh has no points?
746 }
747 refcount_vnormals_ = this->get_property_handle(vertex_normals_,
748 "v:normals") ? 1 : 0 ;
749 refcount_vcolors_ = this->get_property_handle(vertex_colors_,
750 "v:colors") ? 1 : 0 ;
751 refcount_vtexcoords1D_ = this->get_property_handle(vertex_texcoords1D_,
752 "v:texcoords1D") ? 1 : 0 ;
753 refcount_vtexcoords2D_ = this->get_property_handle(vertex_texcoords2D_,
754 "v:texcoords2D") ? 1 : 0 ;
755 refcount_vtexcoords3D_ = this->get_property_handle(vertex_texcoords3D_,
756 "v:texcoords3D") ? 1 : 0 ;
757 refcount_htexcoords1D_ = this->get_property_handle(halfedge_texcoords1D_,
758 "h:texcoords1D") ? 1 : 0 ;
759 refcount_htexcoords2D_ = this->get_property_handle(halfedge_texcoords2D_,
760 "h:texcoords2D") ? 1 : 0 ;
761 refcount_htexcoords3D_ = this->get_property_handle(halfedge_texcoords3D_,
762 "h:texcoords3D") ? 1 : 0 ;
763 refcount_henormals_ = this->get_property_handle(halfedge_normals_,
764 "h:normals") ? 1 : 0 ;
765 refcount_hecolors_ = this->get_property_handle(halfedge_colors_,
766 "h:colors") ? 1 : 0 ;
767 refcount_ecolors_ = this->get_property_handle(edge_colors_,
768 "e:colors") ? 1 : 0 ;
769 refcount_fnormals_ = this->get_property_handle(face_normals_,
770 "f:normals") ? 1 : 0 ;
771 refcount_fcolors_ = this->get_property_handle(face_colors_,
772 "f:colors") ? 1 : 0 ;
773 refcount_ftextureIndex_ = this->get_property_handle(face_texture_index_,
774 "f:textureindex") ? 1 : 0 ;
775 }
776 };
777
778 //=============================================================================
779 } // namespace OpenMesh
780 //=============================================================================
781 #endif // OPENMESH_ATTRIBKERNEL_HH defined
782 //=============================================================================
OpenMesh::HalfedgeHandle
Handle for a halfedge entity.
Definition: Handles.hh:132
OpenMesh::Attributes::TextureIndex
Add texture index (faces)
Definition: Attributes.hh:94
OpenMesh::FaceHandle
Handle for a face entity.
Definition: Handles.hh:146
Attributes.hh
This file provides some macros containing attribute usage.
OpenMesh::BaseHandle::is_valid
bool is_valid() const
The handle is valid iff the index is not negative.
Definition: Handles.hh:77
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
OpenMesh::FPropHandleT< FaceData >
OpenMesh::Attributes::TexCoord3D
Add 3D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:93
OpenMesh::VPropHandleT< VertexData >
OpenMesh::VertexHandle
Handle for a vertex entity.
Definition: Handles.hh:125
OpenMesh::Attributes::Normal
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:87
OpenMesh::AttribKernelT::assign
void assign(const _AttribKernel &_other, bool copyStandardProperties=false)
Assignment from another mesh of another type.
Definition: AttribKernelT.hh:216
OpenMesh::EPropHandleT< EdgeData >
OpenMesh::Attributes::Color
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:88
OpenMesh::AttribKernelT
The attribute kernel adds all standard properties to the kernel.
Definition: AttribKernelT.hh:77
OpenMesh::Attributes::Status
Add status to mesh item (all items)
Definition: Attributes.hh:90
OpenMesh::HPropHandleT< HalfedgeData >
OpenMesh::EdgeHandle
Handle for a edge entity.
Definition: Handles.hh:139
OpenMesh::Attributes::TexCoord1D
Add 1D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:91
OpenMesh::Attributes::TexCoord2D
Add 2D texture coordinates (vertices, halfedges)
Definition: Attributes.hh:92