23#ifndef VCL_MESH_COMPONENTS_DETAIL_COMPONENT_DATA_H
24#define VCL_MESH_COMPONENTS_DETAIL_COMPONENT_DATA_H
26#include <vclib/concepts/mesh/components/component.h>
28namespace vcl::comp::detail {
31template<
typename Data,
bool VERTICAL>
37 template<
typename,
typename Comp>
43 template<
typename,
typename Comp>
44 const Data& get(
const Comp*)
const
49 template<
typename,
typename Comp>
50 constexpr bool isComponentAvailable(
const Comp*)
const
58template<
typename Data>
59class ComponentData<Data, true>
86 template<
typename ElementType,
typename ComponentType>
87 Data& get(ComponentType* comp)
89 ElementType* elem =
static_cast<ElementType*
>(comp);
90 assert(elem->parentMesh());
94 elem->parentMesh()->template verticalComponents<ElementType>();
97 auto& vc = tvc.template vector<ComponentType>();
100 return vc[elem->index()];
103 template<
typename ElementType,
typename ComponentType>
104 const Data& get(
const ComponentType* comp)
const
106 const ElementType* elem =
static_cast<const ElementType*
>(comp);
107 assert(elem->parentMesh());
111 elem->parentMesh()->template verticalComponents<ElementType>();
114 auto& vc = tvc.template vector<ComponentType>();
117 return vc[elem->index()];
120 template<
typename ElementType,
typename ComponentType>
121 bool isComponentAvailable(
const ComponentType* comp)
const
124 if constexpr (!IsOptionalComponent<ComponentType>) {
129 const ElementType* elem =
static_cast<const ElementType*
>(comp);
130 assert(elem->parentMesh());
134 elem->parentMesh()->template verticalComponents<ElementType>();
136 return tvc.template isComponentEnabled<ComponentType>();