1#include <Core/Geometry/IndexedGeometry.hpp>
8MultiIndexedGeometry::MultiIndexedGeometry(
const MultiIndexedGeometry& other ) :
9 AttribArrayGeometry( other ) {
13MultiIndexedGeometry::MultiIndexedGeometry( MultiIndexedGeometry&& other ) :
14 AttribArrayGeometry(
std::
move( other ) ), m_indices(
std::
move( other.m_indices ) ) {}
16MultiIndexedGeometry::MultiIndexedGeometry(
const AttribArrayGeometry& other ) :
17 AttribArrayGeometry( other ) {}
19MultiIndexedGeometry::MultiIndexedGeometry( AttribArrayGeometry&& other ) :
20 AttribArrayGeometry(
std::
move( other ) ) {}
22MultiIndexedGeometry& MultiIndexedGeometry::operator=(
const MultiIndexedGeometry& other ) {
24 AttribArrayGeometry::operator=( other );
30MultiIndexedGeometry& MultiIndexedGeometry::operator=( MultiIndexedGeometry&& other ) {
32 AttribArrayGeometry::operator=(
std::move( other ) );
38void MultiIndexedGeometry::clear() {
40 AttribArrayGeometry::clear();
47 AttribArrayGeometry::copyBaseGeometry( other );
53void MultiIndexedGeometry::checkConsistency()
const {
59 bool dataHasBeenCopied =
false;
60 for (
const auto& [key, value] : other.m_indices ) {
61 auto it = m_indices.find( key );
62 if ( it == m_indices.end() )
67 dataHasBeenCopied =
true;
71 if ( it->second.second->append( *( value.second ) ) ) { dataHasBeenCopied =
true; }
74 "Inconsistency: layers with different semantics shares the same key" );
79 if ( dataHasBeenCopied ) {
89bool MultiIndexedGeometry::containsLayer(
const LayerSemantic& semanticName )
const {
90 for (
const auto& [key, value] : m_indices ) {
91 if ( key.first.find( semanticName ) != key.first.end() )
return true;
97 for (
const auto& [key, value] : m_indices ) {
98 if ( key.first == semantics )
return true;
106size_t MultiIndexedGeometry::countLayers(
const LayerSemantic& semanticName )
const {
108 for (
const auto& [key, value] : m_indices ) {
109 if ( key.first.find( semanticName ) != key.first.end() ) ++c;
116 for (
const auto& [key, value] : m_indices ) {
117 if ( key.first == semantics ) ++c;
126MultiIndexedGeometry::getFirstLayerOccurrence(
const LayerSemantic& semanticName )
const {
127 for (
const auto& [key, value] : m_indices ) {
128 if ( key.first.find( semanticName ) != key.first.end() )
129 return { key, *( value.second.get() ) };
136 for (
const auto& [key, value] : m_indices ) {
137 if ( key.first == semantics )
return { key, *( value.second.get() ) };
146MultiIndexedGeometry::getFirstLayerOccurrenceWithLock(
const LayerSemantic& semanticName ) {
147 for (
auto& [key, value] : m_indices ) {
148 if ( key.first.find( semanticName ) != key.first.end() ) {
149 CORE_ASSERT( !value.first,
"try to get already locked layer" );
151 return { key, *( value.second.get() ) };
159 for (
auto& [key, value] : m_indices ) {
160 if ( key.first == semantics ) {
161 CORE_ASSERT( !value.first,
"try to get already locked layer" );
163 return { key, *( value.second.get() ) };
170 auto& p = m_indices.at( layerKey );
171 CORE_ASSERT( !p.first,
"try to get already locked layer" );
173 return *( p.second.get() );
179void MultiIndexedGeometry::unlockFirstLayerOccurrence(
const LayerSemantic& semanticName ) {
180 for (
auto& [key, value] : m_indices ) {
181 if ( key.first.find( semanticName ) != key.first.end() ) {
182 CORE_ASSERT( value.first,
"try to release unlocked layer" );
192 for (
auto& [key, value] : m_indices ) {
193 if ( key.first == semantics ) {
194 CORE_ASSERT( value.first,
"try to release unlocked layer" );
203void MultiIndexedGeometry::unlockLayer(
const LayerKeyType& layerKey ) {
204 auto& p = m_indices.at( layerKey );
205 CORE_ASSERT( p.first,
"try to release unlocked layer" );
219 auto [pos, inserted] = m_indices.insert(
std::move( elt ) );
223 CORE_ASSERT( !pos->second.first,
"try to get already locked layer" );
224 pos->second.first =
true;
229 return { inserted, *( pos->second.second ) };
235 for (
const auto& [key, value] : other.m_indices ) {
241void MultiIndexedGeometry::deepClear() {
248std::size_t MultiIndexedGeometry::KeyHash::operator()(
const LayerKeyType& k )
const {
263 auto nbVert = attr.
vertices().size();
264 collection().resize( nbVert );
265 collection().getMap() = IndexContainerType::Matrix::LinSpaced( nbVert, 0, nbVert - 1 );
This class represents vertex + attributes per vertex. Toplogy is handled in MultiIndexedGeometry subc...
const PointAttribHandle::Container & vertices() const
Access the vertices positions.
Base class for index collections stored in MultiIndexedGeometry.
AbstractGeometry with per-vertex attributes and layers of indices. Each layer represents a different ...
@ Geometry
"Geometry" render objects are those loaded using Radium::IO and generated by GeometrySystem
hepler function to manage enum as underlying types in VariableSet