MCPcopy Create free account
hub / github.com/ImageEngine/cortex / operator()

Method operator()

src/IECoreScene/MeshAlgoResample.cpp:62–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 }
61
62 template<typename From> ReturnType operator()( const From* data )
63 {
64 typename From::Ptr result = static_cast< From* >( Object::create( data->typeId() ).get() );
65 typename From::ValueType &trg = result->writable();
66 const typename From::ValueType &src = data->readable();
67
68 // TODO sipmlify this code by using polygon face & vertex iterators
69 trg.reserve( m_mesh->numFaces() );
70
71 std::vector<int>::const_iterator vId = m_mesh->vertexIds()->readable().begin();
72 const std::vector<int> &verticesPerFace = m_mesh->verticesPerFace()->readable();
73 for( std::vector<int>::const_iterator it = verticesPerFace.begin(); it < verticesPerFace.end(); ++it )
74 {
75 Canceller::check( m_canceller );
76
77 // initialize with the first value to avoid
78 // ambiguitity during default construction
79 typename From::ValueType::value_type total = src[ *vId ];
80 ++vId;
81
82 for( int j = 1; j < *it; ++j, ++vId )
83 {
84 total += src[ *vId ];
85 }
86
87 trg.push_back( total / *it );
88 }
89
90 IECoreScene::PrimitiveVariableAlgos::GeometricInterpretationCopier<From> copier;
91 copier( data, result.get() );
92
93 return result;
94 }
95
96 const MeshPrimitive *m_mesh;
97 const Canceller *m_canceller;

Callers

nothing calls this directly

Calls 10

createFunction · 0.85
typeIdMethod · 0.80
readableMethod · 0.80
numFacesMethod · 0.80
vertexIdsMethod · 0.80
verticesPerFaceMethod · 0.80
getMethod · 0.45
writableMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected