Radium Engine  1.5.20
Loading...
Searching...
No Matches
TopologicalMesh.hpp
1#pragma once
2
3#include <Core/RaCore.hpp>
4
5#include <Core/Containers/VectorArray.hpp>
6#include <Core/Geometry/OpenMesh.hpp>
7#include <Core/Geometry/StandardAttribNames.hpp>
8#include <Core/Geometry/TriangleMesh.hpp>
9#include <Core/Types.hpp>
10#include <Core/Utils/Index.hpp>
11#include <Core/Utils/StdOptional.hpp>
12
13#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
14#include <OpenMesh/Core/Mesh/Traits.hh>
15#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
16#include <OpenMesh/Core/Utils/Property.hh>
17#include <OpenMesh/Core/Utils/PropertyManager.hh>
18
19#include <Eigen/Core>
20#include <Eigen/Geometry>
21
22#include <set>
23#include <typeinfo>
24#include <unordered_map>
25
26namespace Ra {
27namespace Core {
28namespace Geometry {
29namespace deprecated {
30using namespace Utils; // log, AttribXXX
31
35struct TopologicalMeshTraits : OpenMesh::DefaultTraits {
36 using Point = Ra::Core::Vector3;
37 using Normal = Ra::Core::Vector3;
38
39 VertexAttributes( OpenMesh::Attributes::Status | OpenMesh::Attributes::Normal );
40 FaceAttributes( OpenMesh::Attributes::Status | OpenMesh::Attributes::Normal );
41 EdgeAttributes( OpenMesh::Attributes::Status );
42 // Add OpenMesh::Attributes::PrevHalfedge for efficiency ?
43 HalfedgeAttributes( OpenMesh::Attributes::Status | OpenMesh::Attributes::Normal );
44};
45
56class RA_CORE_API TopologicalMesh : public OpenMesh::PolyMesh_ArrayKernelT<TopologicalMeshTraits>
57{
58 private:
59 using base = OpenMesh::PolyMesh_ArrayKernelT<TopologicalMeshTraits>;
60 using base::PolyMesh_ArrayKernelT;
61 using Index = Ra::Core::Utils::Index;
62 using Vector3 = Ra::Core::Vector3;
63
64 public:
77 template <typename NonManifoldFaceCommand>
78 explicit TopologicalMesh( const Ra::Core::Geometry::TriangleMesh& triMesh,
79 NonManifoldFaceCommand command );
80
85 explicit TopologicalMesh( const Ra::Core::Geometry::TriangleMesh& triMesh );
86
90 explicit TopologicalMesh();
91
96 TriangleMesh toTriangleMesh();
97
103 void updateTriangleMesh( Ra::Core::Geometry::TriangleMesh& mesh );
104
105 // import other version of halfedge_handle method
106 using base::halfedge_handle;
107
112 inline HalfedgeHandle halfedge_handle( VertexHandle vh, FaceHandle fh ) const;
113
118 [[deprecated]] inline const Normal& normal( VertexHandle vh, FaceHandle fh ) const;
119
124 [[deprecated]] void set_normal( VertexHandle vh, FaceHandle fh, const Normal& n );
125
128 using base::normal;
129 using base::set_normal;
131
138 [[deprecated]] void propagate_normal_to_halfedges( VertexHandle vh );
139
144 inline const OpenMesh::HPropHandleT<Index>& getInputTriangleMeshIndexPropHandle() const;
145
151 inline const OpenMesh::HPropHandleT<Index>& getOutputTriangleMeshIndexPropHandle() const;
152
158 [[deprecated]] inline const std::vector<OpenMesh::HPropHandleT<Scalar>>&
159 getFloatPropsHandles() const;
160 [[deprecated]] inline const std::vector<OpenMesh::HPropHandleT<Vector2>>&
161 getVector2PropsHandles() const;
162 [[deprecated]] inline const std::vector<OpenMesh::HPropHandleT<Vector3>>&
163 getVector3PropsHandles() const;
164 [[deprecated]] inline const std::vector<OpenMesh::HPropHandleT<Vector4>>&
165 getVector4PropsHandles() const;
167
173
179 inline void createNormalPropOnFaces( OpenMesh::FPropHandleT<Normal>& fProp );
180
185 inline void clearProp( OpenMesh::FPropHandleT<Normal>& fProp );
186
190 inline void copyNormal( HalfedgeHandle input_heh, HalfedgeHandle copy_heh );
191
195 inline void
196 copyNormalFromFace( FaceHandle fh, HalfedgeHandle heh, OpenMesh::FPropHandleT<Normal> fProp );
197
201 inline void
202 interpolateNormal( HalfedgeHandle in_a, HalfedgeHandle in_b, HalfedgeHandle out, Scalar f );
203
207 inline void interpolateNormalOnFaces( FaceHandle fh, OpenMesh::FPropHandleT<Normal> fProp );
209
215
221 template <typename T>
222 void createPropsOnFaces( const std::vector<OpenMesh::HPropHandleT<T>>& input,
223 std::vector<OpenMesh::FPropHandleT<T>>& output );
224
229 template <typename T>
230 void clearProps( std::vector<OpenMesh::FPropHandleT<T>>& props );
231
235 template <typename T>
236 void copyProps( HalfedgeHandle input_heh,
237 HalfedgeHandle copy_heh,
238 const std::vector<OpenMesh::HPropHandleT<T>>& props );
239
244 template <typename T>
245 void copyPropsFromFace( FaceHandle fh,
246 HalfedgeHandle heh,
247 const std::vector<OpenMesh::FPropHandleT<T>>& fProps,
248 const std::vector<OpenMesh::HPropHandleT<T>>& hProps );
249
253 template <typename T>
254 void interpolateProps( HalfedgeHandle in_a,
255 HalfedgeHandle in_b,
256 HalfedgeHandle out,
257 Scalar f,
258 const std::vector<OpenMesh::HPropHandleT<T>>& props );
259
264 template <typename T>
265 void interpolatePropsOnFaces( FaceHandle fh,
266 const std::vector<OpenMesh::HPropHandleT<T>>& hProps,
267 const std::vector<OpenMesh::FPropHandleT<T>>& fProps );
269
274
281 inline void createAllPropsOnFaces( OpenMesh::FPropHandleT<Normal>& normalProp,
282 std::vector<OpenMesh::FPropHandleT<Scalar>>& floatProps,
283 std::vector<OpenMesh::FPropHandleT<Vector2>>& vec2Props,
284 std::vector<OpenMesh::FPropHandleT<Vector3>>& vec3Props,
285 std::vector<OpenMesh::FPropHandleT<Vector4>>& vec4Props );
286
291 inline void clearAllProps( OpenMesh::FPropHandleT<Normal>& normalProp,
292 std::vector<OpenMesh::FPropHandleT<Scalar>>& floatProps,
293 std::vector<OpenMesh::FPropHandleT<Vector2>>& vec2Props,
294 std::vector<OpenMesh::FPropHandleT<Vector3>>& vec3Props,
295 std::vector<OpenMesh::FPropHandleT<Vector4>>& vec4Props );
296
300 inline void copyAllProps( HalfedgeHandle input_heh, HalfedgeHandle copy_heh );
301
308 inline void copyAllPropsFromFace( FaceHandle fh,
309 HalfedgeHandle heh,
310 OpenMesh::FPropHandleT<Normal> normalProp,
311 std::vector<OpenMesh::FPropHandleT<Scalar>>& floatProps,
312 std::vector<OpenMesh::FPropHandleT<Vector2>>& vec2Props,
313 std::vector<OpenMesh::FPropHandleT<Vector3>>& vec3Props,
314 std::vector<OpenMesh::FPropHandleT<Vector4>>& vec4Props );
315
319 inline void
320 interpolateAllProps( HalfedgeHandle in_a, HalfedgeHandle in_b, HalfedgeHandle out, Scalar f );
321
328 inline void
329 interpolateAllPropsOnFaces( FaceHandle fh,
330 OpenMesh::FPropHandleT<Normal> normalProp,
331 std::vector<OpenMesh::FPropHandleT<Scalar>>& floatProps,
332 std::vector<OpenMesh::FPropHandleT<Vector2>>& vec2Props,
333 std::vector<OpenMesh::FPropHandleT<Vector3>>& vec3Props,
334 std::vector<OpenMesh::FPropHandleT<Vector4>>& vec4Props );
336
341
353 bool splitEdge( TopologicalMesh::EdgeHandle eh, Scalar f );
354 bool splitEdgeWedge( TopologicalMesh::EdgeHandle eh, Scalar f );
355
357
358 private:
359 template <typename T>
362 Eigen::aligned_allocator<std::pair<AttribHandle<T>, T>>>;
363
364 template <typename T>
365 using PropPair = std::pair<AttribHandle<T>, OpenMesh::HPropHandleT<T>>;
366
367 template <typename T>
368 inline void copyAttribToTopo( const TriangleMesh& triMesh,
369 const std::vector<PropPair<T>>& vprop,
370 TopologicalMesh::HalfedgeHandle heh,
371 unsigned int vindex );
372
373 template <typename T>
374 inline void addAttribPairToTopo( const TriangleMesh& triMesh,
376 std::vector<PropPair<T>>& vprop,
377 std::vector<OpenMesh::HPropHandleT<T>>& pph );
378
379 void split_copy( EdgeHandle _eh, VertexHandle _vh );
380 void split( EdgeHandle _eh, VertexHandle _vh );
381
383 OpenMesh::HPropHandleT<Index> m_inputTriangleMeshIndexPph;
384 OpenMesh::HPropHandleT<Index> m_outputTriangleMeshIndexPph;
385 [[deprecated]] std::vector<OpenMesh::HPropHandleT<Scalar>> m_floatPph;
386 [[deprecated]] std::vector<OpenMesh::HPropHandleT<Vector2>> m_vec2Pph;
387 [[deprecated]] std::vector<OpenMesh::HPropHandleT<Vector3>> m_vec3Pph;
388 [[deprecated]] std::vector<OpenMesh::HPropHandleT<Vector4>> m_vec4Pph;
389
390 friend class TMOperations;
391};
392
393template <typename NonManifoldFaceCommand>
394inline TopologicalMesh::TopologicalMesh( const TriangleMesh& triMesh,
395 NonManifoldFaceCommand command ) :
397
398 LOG( logINFO ) << "TopologicalMesh: load triMesh with " << triMesh.getIndices().size()
399 << " faces and " << triMesh.vertices().size() << " vertices.";
400
401 struct hash_vec {
402 size_t operator()( const Vector3& lvalue ) const {
403 size_t hx = std::hash<Scalar>()( lvalue[0] );
404 size_t hy = std::hash<Scalar>()( lvalue[1] );
405 size_t hz = std::hash<Scalar>()( lvalue[2] );
406 return ( hx ^ ( hy << 1 ) ) ^ hz;
407 }
408 };
409 // use a hashmap for fast search of existing vertex position
411 VertexMap vertexHandles;
412
413 std::vector<PropPair<Scalar>> vprop_float;
414 std::vector<std::pair<AttribHandle<Vector2>, OpenMesh::HPropHandleT<Vector2>>> vprop_vec2;
415 std::vector<std::pair<AttribHandle<Vector3>, OpenMesh::HPropHandleT<Vector3>>> vprop_vec3;
416 std::vector<std::pair<AttribHandle<Vector4>, OpenMesh::HPropHandleT<Vector4>>> vprop_vec4;
417
418 // loop over all attribs and build correspondance pair
420 [&triMesh, this, &vprop_float, &vprop_vec2, &vprop_vec3, &vprop_vec4]( const auto& attr ) {
421 // skip builtin attribs
422 if ( attr->getName() != std::string( getAttribName( MeshAttrib::VERTEX_POSITION ) ) &&
423 attr->getName() != std::string( getAttribName( MeshAttrib::VERTEX_NORMAL ) ) ) {
424 if ( attr->isFloat() )
425 addAttribPairToTopo( triMesh, attr, vprop_float, m_floatPph );
426 else if ( attr->isVector2() )
427 addAttribPairToTopo( triMesh, attr, vprop_vec2, m_vec2Pph );
428 else if ( attr->isVector3() )
429 addAttribPairToTopo( triMesh, attr, vprop_vec3, m_vec3Pph );
430 else if ( attr->isVector4() )
431 addAttribPairToTopo( triMesh, attr, vprop_vec4, m_vec4Pph );
432 else
433 LOG( logWARNING )
434 << "Warning, mesh attribute " << attr->getName()
435 << " type is not supported (only float, vec2, vec3 nor vec4 are supported)";
436 }
437 } );
438
439 size_t num_triangles = triMesh.getIndices().size();
440
441 command.initialize( triMesh );
442
443 const bool hasNormals = !triMesh.normals().empty();
444 if ( !hasNormals ) {
445 release_face_normals();
446 release_vertex_normals();
447 release_halfedge_normals();
448 }
449 for ( unsigned int i = 0; i < num_triangles; i++ ) {
451 std::vector<TopologicalMesh::Normal> face_normals( 3 );
452 std::vector<unsigned int> face_vertexIndex( 3 );
453 const auto& triangle = triMesh.getIndices()[i];
454 for ( size_t j = 0; j < 3; ++j ) {
455 unsigned int inMeshVertexIndex = triangle[j];
456 const Vector3& p = triMesh.vertices()[inMeshVertexIndex];
457
458 typename VertexMap::iterator vtr = vertexHandles.find( p );
459
460 TopologicalMesh::VertexHandle vh;
461 if ( vtr == vertexHandles.end() ) {
462 vh = add_vertex( p );
463 vertexHandles.insert( vtr, typename VertexMap::value_type( p, vh ) );
464 }
465 else { vh = vtr->second; }
466
467 face_vhandles[j] = vh;
468 face_vertexIndex[j] = inMeshVertexIndex;
469 if ( hasNormals ) face_normals[j] = triMesh.normals()[inMeshVertexIndex];
470 }
471
472 TopologicalMesh::FaceHandle fh;
473
474 // skip 2 vertex face
475 if ( face_vhandles.size() > 2 ) fh = add_face( face_vhandles );
476 // x-----------------------------------------------------------------------------------x
477
478 if ( fh.is_valid() ) {
479 for ( size_t vindex = 0; vindex < face_vhandles.size(); vindex++ ) {
480 TopologicalMesh::HalfedgeHandle heh = halfedge_handle( face_vhandles[vindex], fh );
481 if ( hasNormals ) set_normal( heh, face_normals[vindex] );
482 property( m_inputTriangleMeshIndexPph, heh ) = face_vertexIndex[vindex];
483 copyAttribToTopo( triMesh, vprop_float, heh, face_vertexIndex[vindex] );
484 copyAttribToTopo( triMesh, vprop_vec2, heh, face_vertexIndex[vindex] );
485 copyAttribToTopo( triMesh, vprop_vec3, heh, face_vertexIndex[vindex] );
486 copyAttribToTopo( triMesh, vprop_vec4, heh, face_vertexIndex[vindex] );
487 }
488 }
489 else { command.process( face_vhandles ); }
490 face_vhandles.clear();
491 face_normals.clear();
492 face_vertexIndex.clear();
493 }
494 command.postProcess( *this );
495
496 // grabage collect since some wedge might already be deleted
497 garbage_collection();
498}
499
500template <typename T>
501void TopologicalMesh::addAttribPairToTopo( const TriangleMesh& triMesh,
504 std::vector<OpenMesh::HPropHandleT<T>>& pph ) {
505 AttribHandle<T> h = triMesh.getAttribHandle<T>( attr->getName() );
506 if ( attr->getSize() == triMesh.vertices().size() ) {
507 OpenMesh::HPropHandleT<T> oh;
508 this->add_property( oh, attr->getName() );
509 vprop.push_back( std::make_pair( h, oh ) );
510 pph.push_back( oh );
511 }
512 else {
513 LOG( logWARNING ) << "[TopologicalMesh] Skip badly sized attribute " << attr->getName()
514 << ".";
515 }
516}
517
518template <typename T>
519void TopologicalMesh::copyAttribToTopo( const TriangleMesh& triMesh,
520 const std::vector<PropPair<T>>& vprop,
521 TopologicalMesh::HalfedgeHandle heh,
522 unsigned int vindex ) {
523 for ( auto pp : vprop ) {
524 this->property( pp.second, heh ) = triMesh.getAttrib( pp.first ).data()[vindex];
525 }
526}
527
528inline const TopologicalMesh::Normal& TopologicalMesh::normal( VertexHandle vh,
529 FaceHandle fh ) const {
530 // find halfedge that point to vh and member of fh
531 if ( !has_halfedge_normals() ) {
532 LOG( logERROR ) << "TopologicalMesh has no normals, return dummy ref to (0,0,0)";
533 static TopologicalMesh::Normal dummy { 0_ra, 0_ra, 0_ra };
534 return dummy;
535 }
536 return normal( halfedge_handle( vh, fh ) );
537}
538
539inline void TopologicalMesh::set_normal( VertexHandle vh, FaceHandle fh, const Normal& n ) {
540 if ( !has_halfedge_normals() ) {
541 LOG( logERROR ) << "TopologicalMesh has no normals, nothing set";
542 return;
543 }
544
545 set_normal( halfedge_handle( vh, fh ), n );
546}
547
549 if ( !has_halfedge_normals() ) {
550 LOG( logERROR ) << "TopologicalMesh has no normals, nothing set";
551 return;
552 }
553 for ( VertexIHalfedgeIter vih_it = vih_iter( vh ); vih_it.is_valid(); ++vih_it ) {
554 set_normal( *vih_it, normal( vh ) );
555 }
556}
557
558inline TopologicalMesh::HalfedgeHandle TopologicalMesh::halfedge_handle( VertexHandle vh,
559 FaceHandle fh ) const {
560 for ( ConstVertexIHalfedgeIter vih_it = cvih_iter( vh ); vih_it.is_valid(); ++vih_it ) {
561 if ( face_handle( *vih_it ) == fh ) { return *vih_it; }
562 }
563 CORE_ASSERT( false, "vh is not a vertex of face fh" );
564 return HalfedgeHandle();
565}
566
567inline const OpenMesh::HPropHandleT<TopologicalMesh::Index>&
569 return m_inputTriangleMeshIndexPph;
570}
571
572inline const OpenMesh::HPropHandleT<TopologicalMesh::Index>&
574 return m_outputTriangleMeshIndexPph;
575}
576
578TopologicalMesh::getFloatPropsHandles() const {
579 return m_floatPph;
580}
581
583TopologicalMesh::getVector2PropsHandles() const {
584 return m_vec2Pph;
585}
586
588TopologicalMesh::getVector3PropsHandles() const {
589 return m_vec3Pph;
590}
591
593TopologicalMesh::getVector4PropsHandles() const {
594 return m_vec4Pph;
595}
596
597inline void TopologicalMesh::createNormalPropOnFaces( OpenMesh::FPropHandleT<Normal>& fProp ) {
598 if ( !has_halfedge_normals() ) {
599 LOG( logERROR ) << "TopologicalMesh has no normals, nothing set";
600 return;
601 }
602 auto nph = halfedge_normals_pph();
603 add_property( fProp, property( nph ).name() + "_subdiv_copy_F" );
604}
605
606inline void TopologicalMesh::clearProp( OpenMesh::FPropHandleT<Normal>& fProp ) {
607 remove_property( fProp );
608}
609
610inline void TopologicalMesh::copyNormal( HalfedgeHandle input_heh, HalfedgeHandle copy_heh ) {
611 if ( !has_halfedge_normals() ) {
612 LOG( logERROR ) << "TopologicalMesh has no normals, nothing set";
613 return;
614 }
615 auto nph = halfedge_normals_pph();
616 property( nph, copy_heh ) = property( nph, input_heh );
617}
618
619inline void TopologicalMesh::copyNormalFromFace( FaceHandle fh,
620 HalfedgeHandle heh,
621 OpenMesh::FPropHandleT<Normal> fProp ) {
622 if ( !has_halfedge_normals() ) {
623 LOG( logERROR ) << "TopologicalMesh has no normals, nothing set";
624 return;
625 }
626 auto nph = halfedge_normals_pph();
627 property( nph, heh ) = property( fProp, fh );
628}
629
630inline void TopologicalMesh::interpolateNormal( HalfedgeHandle in_a,
631 HalfedgeHandle in_b,
632 HalfedgeHandle out,
633 Scalar f ) {
634 auto nph = halfedge_normals_pph();
635 property( nph, out ) =
636 ( ( 1 - f ) * property( nph, in_a ) + f * property( nph, in_b ) ).normalized();
637}
638
640 OpenMesh::FPropHandleT<Normal> fProp ) {
641 if ( !has_halfedge_normals() ) {
642 LOG( logERROR ) << "TopologicalMesh has no normals, nothing set";
643 return;
644 }
645 auto nph = halfedge_normals_pph();
646
647 // init sum to first
648 auto heh = halfedge_handle( fh );
649 property( fProp, fh ) = property( nph, heh );
650 heh = next_halfedge_handle( heh );
651
652 // sum others
653 for ( size_t i = 1; i < valence( fh ); ++i ) {
654 property( fProp, fh ) += property( nph, heh );
655 heh = next_halfedge_handle( heh );
656 }
657
658 // normalize
659 property( fProp, fh ) = property( fProp, fh ).normalized();
660}
661
662template <typename T>
663void TopologicalMesh::createPropsOnFaces( const std::vector<OpenMesh::HPropHandleT<T>>& input,
664 std::vector<OpenMesh::FPropHandleT<T>>& output ) {
665 output.reserve( input.size() );
666 for ( const auto& oh : input ) {
667 OpenMesh::FPropHandleT<T> oh_;
668 add_property( oh_, property( oh ).name() + "_subdiv_copy_F" );
669 output.push_back( oh_ );
670 }
671}
672
673template <typename T>
674void TopologicalMesh::clearProps( std::vector<OpenMesh::FPropHandleT<T>>& props ) {
675 for ( auto& oh : props ) {
676 remove_property( oh );
677 }
678 props.clear();
679}
680
681template <typename T>
682void TopologicalMesh::copyProps( HalfedgeHandle input_heh,
683 HalfedgeHandle copy_heh,
684 const std::vector<OpenMesh::HPropHandleT<T>>& props ) {
685 for ( const auto& oh : props ) {
686 property( oh, copy_heh ) = property( oh, input_heh );
687 }
688}
689
690template <typename T>
692 HalfedgeHandle heh,
693 const std::vector<OpenMesh::FPropHandleT<T>>& fProps,
694 const std::vector<OpenMesh::HPropHandleT<T>>& hProps ) {
695 for ( uint i = 0; i < fProps.size(); ++i ) {
696 auto hp = hProps[i];
697 auto fp = fProps[i];
698 property( hp, heh ) = property( fp, fh );
699 }
700}
701
702template <typename T>
703void TopologicalMesh::interpolateProps( HalfedgeHandle in_a,
704 HalfedgeHandle in_b,
705 HalfedgeHandle out,
706 Scalar f,
707 const std::vector<OpenMesh::HPropHandleT<T>>& props ) {
708 // interpolate properties
709 for ( const auto& oh : props ) {
710 property( oh, out ) = ( 1 - f ) * property( oh, in_a ) + f * property( oh, in_b );
711 }
712}
713
714template <typename T>
716 FaceHandle fh,
717 const std::vector<OpenMesh::HPropHandleT<T>>& hProps,
718 const std::vector<OpenMesh::FPropHandleT<T>>& fProps ) {
719 auto heh = halfedge_handle( fh );
720 const size_t v = valence( fh );
721
722 // init sum to first
723 for ( size_t j = 0; j < fProps.size(); ++j ) {
724 auto hp = hProps[j];
725 auto fp = fProps[j];
726 property( fp, fh ) = property( hp, heh );
727 }
728 heh = next_halfedge_handle( heh );
729 // sum others
730 for ( size_t i = 1; i < v; ++i ) {
731 for ( size_t j = 0; j < fProps.size(); ++j ) {
732 auto hp = hProps[j];
733 auto fp = fProps[j];
734 property( fp, fh ) += property( hp, heh );
735 }
736 heh = next_halfedge_handle( heh );
737 }
738 // normalize
739 for ( size_t j = 0; j < fProps.size(); ++j ) {
740 auto fp = fProps[j];
741 property( fp, fh ) = property( fp, fh ) / v;
742 }
743}
744
745inline void
746TopologicalMesh::createAllPropsOnFaces( OpenMesh::FPropHandleT<Normal>& normalProp,
747 std::vector<OpenMesh::FPropHandleT<Scalar>>& floatProps,
748 std::vector<OpenMesh::FPropHandleT<Vector2>>& vec2Props,
749 std::vector<OpenMesh::FPropHandleT<Vector3>>& vec3Props,
750 std::vector<OpenMesh::FPropHandleT<Vector4>>& vec4Props ) {
751 createNormalPropOnFaces( normalProp );
752 createPropsOnFaces( getFloatPropsHandles(), floatProps );
753 createPropsOnFaces( getVector2PropsHandles(), vec2Props );
754 createPropsOnFaces( getVector3PropsHandles(), vec3Props );
755 createPropsOnFaces( getVector4PropsHandles(), vec4Props );
756}
757
758inline void
759TopologicalMesh::clearAllProps( OpenMesh::FPropHandleT<Normal>& normalProp,
760 std::vector<OpenMesh::FPropHandleT<Scalar>>& floatProps,
761 std::vector<OpenMesh::FPropHandleT<Vector2>>& vec2Props,
762 std::vector<OpenMesh::FPropHandleT<Vector3>>& vec3Props,
763 std::vector<OpenMesh::FPropHandleT<Vector4>>& vec4Props ) {
764 clearProp( normalProp );
765 clearProps( floatProps );
766 clearProps( vec2Props );
767 clearProps( vec3Props );
768 clearProps( vec4Props );
769}
770
771inline void TopologicalMesh::copyAllProps( HalfedgeHandle input_heh, HalfedgeHandle copy_heh ) {
772 copyNormal( input_heh, copy_heh );
773 copyProps( input_heh, copy_heh, getFloatPropsHandles() );
774 copyProps( input_heh, copy_heh, getVector2PropsHandles() );
775 copyProps( input_heh, copy_heh, getVector3PropsHandles() );
776 copyProps( input_heh, copy_heh, getVector4PropsHandles() );
777}
778
779inline void
781 HalfedgeHandle heh,
782 OpenMesh::FPropHandleT<Normal> normalProp,
783 std::vector<OpenMesh::FPropHandleT<Scalar>>& floatProps,
784 std::vector<OpenMesh::FPropHandleT<Vector2>>& vec2Props,
785 std::vector<OpenMesh::FPropHandleT<Vector3>>& vec3Props,
786 std::vector<OpenMesh::FPropHandleT<Vector4>>& vec4Props ) {
787 copyNormalFromFace( fh, heh, normalProp );
788 copyPropsFromFace( fh, heh, floatProps, getFloatPropsHandles() );
789 copyPropsFromFace( fh, heh, vec2Props, getVector2PropsHandles() );
790 copyPropsFromFace( fh, heh, vec3Props, getVector3PropsHandles() );
791 copyPropsFromFace( fh, heh, vec4Props, getVector4PropsHandles() );
792}
793
794inline void TopologicalMesh::interpolateAllProps( HalfedgeHandle in_a,
795 HalfedgeHandle in_b,
796 HalfedgeHandle out,
797 Scalar f ) {
798 interpolateNormal( in_a, in_b, out, f );
799 interpolateProps( in_a, in_b, out, f, getFloatPropsHandles() );
800 interpolateProps( in_a, in_b, out, f, getVector2PropsHandles() );
801 interpolateProps( in_a, in_b, out, f, getVector3PropsHandles() );
802 interpolateProps( in_a, in_b, out, f, getVector4PropsHandles() );
803}
804
806 FaceHandle fh,
807 OpenMesh::FPropHandleT<Normal> normalProp,
808 std::vector<OpenMesh::FPropHandleT<Scalar>>& floatProps,
809 std::vector<OpenMesh::FPropHandleT<Vector2>>& vec2Props,
810 std::vector<OpenMesh::FPropHandleT<Vector3>>& vec3Props,
811 std::vector<OpenMesh::FPropHandleT<Vector4>>& vec4Props ) {
812 interpolateNormalOnFaces( fh, normalProp );
813 interpolatePropsOnFaces( fh, getFloatPropsHandles(), floatProps );
814 interpolatePropsOnFaces( fh, getVector2PropsHandles(), vec2Props );
815 interpolatePropsOnFaces( fh, getVector3PropsHandles(), vec3Props );
816 interpolatePropsOnFaces( fh, getVector4PropsHandles(), vec4Props );
817}
818
819} // namespace deprecated
820} // namespace Geometry
821} // namespace Core
822} // namespace Ra
Utils::AttribHandle< T > getAttribHandle(const std::string &name) const
const NormalAttribHandle::Container & normals() const
Access the vertices normals.
const PointAttribHandle::Container & vertices() const
Access the vertices positions.
Utils::Attrib< T > & getAttrib(const Utils::AttribHandle< T > &h)
void copyNormal(HalfedgeHandle input_heh, HalfedgeHandle copy_heh)
void copyNormalFromFace(FaceHandle fh, HalfedgeHandle heh, OpenMesh::FPropHandleT< Normal > fProp)
void createNormalPropOnFaces(OpenMesh::FPropHandleT< Normal > &fProp)
void interpolateAllPropsOnFaces(FaceHandle fh, OpenMesh::FPropHandleT< Normal > normalProp, std::vector< OpenMesh::FPropHandleT< Scalar > > &floatProps, std::vector< OpenMesh::FPropHandleT< Vector2 > > &vec2Props, std::vector< OpenMesh::FPropHandleT< Vector3 > > &vec3Props, std::vector< OpenMesh::FPropHandleT< Vector4 > > &vec4Props)
void interpolateProps(HalfedgeHandle in_a, HalfedgeHandle in_b, HalfedgeHandle out, Scalar f, const std::vector< OpenMesh::HPropHandleT< T > > &props)
void set_normal(VertexHandle vh, FaceHandle fh, const Normal &n)
void copyAllPropsFromFace(FaceHandle fh, HalfedgeHandle heh, OpenMesh::FPropHandleT< Normal > normalProp, std::vector< OpenMesh::FPropHandleT< Scalar > > &floatProps, std::vector< OpenMesh::FPropHandleT< Vector2 > > &vec2Props, std::vector< OpenMesh::FPropHandleT< Vector3 > > &vec3Props, std::vector< OpenMesh::FPropHandleT< Vector4 > > &vec4Props)
const OpenMesh::HPropHandleT< Index > & getInputTriangleMeshIndexPropHandle() const
const Normal & normal(VertexHandle vh, FaceHandle fh) const
const OpenMesh::HPropHandleT< Index > & getOutputTriangleMeshIndexPropHandle() const
void copyAllProps(HalfedgeHandle input_heh, HalfedgeHandle copy_heh)
void interpolateAllProps(HalfedgeHandle in_a, HalfedgeHandle in_b, HalfedgeHandle out, Scalar f)
void createPropsOnFaces(const std::vector< OpenMesh::HPropHandleT< T > > &input, std::vector< OpenMesh::FPropHandleT< T > > &output)
void createAllPropsOnFaces(OpenMesh::FPropHandleT< Normal > &normalProp, std::vector< OpenMesh::FPropHandleT< Scalar > > &floatProps, std::vector< OpenMesh::FPropHandleT< Vector2 > > &vec2Props, std::vector< OpenMesh::FPropHandleT< Vector3 > > &vec3Props, std::vector< OpenMesh::FPropHandleT< Vector4 > > &vec4Props)
void copyProps(HalfedgeHandle input_heh, HalfedgeHandle copy_heh, const std::vector< OpenMesh::HPropHandleT< T > > &props)
void updateTriangleMesh(Ra::Core::Geometry::TriangleMesh &mesh)
void interpolatePropsOnFaces(FaceHandle fh, const std::vector< OpenMesh::HPropHandleT< T > > &hProps, const std::vector< OpenMesh::FPropHandleT< T > > &fProps)
HalfedgeHandle halfedge_handle(VertexHandle vh, FaceHandle fh) const
void clearProps(std::vector< OpenMesh::FPropHandleT< T > > &props)
void interpolateNormal(HalfedgeHandle in_a, HalfedgeHandle in_b, HalfedgeHandle out, Scalar f)
void copyPropsFromFace(FaceHandle fh, HalfedgeHandle heh, const std::vector< OpenMesh::FPropHandleT< T > > &fProps, const std::vector< OpenMesh::HPropHandleT< T > > &hProps)
void interpolateNormalOnFaces(FaceHandle fh, OpenMesh::FPropHandleT< Normal > fProp)
void clearProp(OpenMesh::FPropHandleT< Normal > &fProp)
void clearAllProps(OpenMesh::FPropHandleT< Normal > &normalProp, std::vector< OpenMesh::FPropHandleT< Scalar > > &floatProps, std::vector< OpenMesh::FPropHandleT< Vector2 > > &vec2Props, std::vector< OpenMesh::FPropHandleT< Vector3 > > &vec3Props, std::vector< OpenMesh::FPropHandleT< Vector4 > > &vec4Props)
std::string getName() const
Return the attribute's name.
Definition Attribs.hpp:448
An attrib handle basically store an Index and a name.
Definition Attribs.hpp:146
void for_each_attrib(const F &func) const
Definition Attribs.hpp:754
T clear(T... args)
T make_pair(T... args)
@ Geometry
"Geometry" render objects are those loaded using Radium::IO and generated by GeometrySystem
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3
T size(T... args)