FiberVISH
0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
fiber
fiberop
ExtractSlice.hpp
1
#ifndef __FIBEROPERATIONS_EXTRACT_SLICE
2
#define __FIBEROPERATIONS_EXTRACT_SLICE
3
4
#include <field/MemBase.hpp>
5
#include <meta/LIST.hpp>
6
#include "SliceSelection.hpp"
7
8
namespace
Fiber
9
{
10
11
template
<
class
Array2D>
12
struct
ArrayCollector
13
{
14
typedef
RefPtr<Array2D>
result_t
;
15
16
result_t
result;
17
Array2D
& dst;
18
19
ArrayCollector
(
const
MultiIndex<2>
&Dims)
20
: result(
new
Array2D
(Dims) )
21
, dst( *result )
22
{
23
24
}
25
26
template
<
class
ElementType>
27
void
collect(
const
MultiIndex<2>
&Dims,
const
ElementType
&T)
28
{
29
dst[ Dims ] = T;
30
}
31
32
static
result_t
Invalid()
33
{
34
return
MemCore::NullPtr
();
35
}
36
};
37
38
template
<
class
Operator,
class
Array3D>
39
struct
ExtractSlice
40
{
41
42
static
typename
Operator::result_t get(
const
MultiIndex<3>
&Dims,
43
const
RefPtr<MemBase>
&
Data
,
const
SliceSelection
&
GO
,
44
index_t
SliceID,
const
MultiIndex<3>
&
FragmentOffset
)
45
{
46
RefPtr<Array3D>
src
=
Data
;
47
if
(!
src
)
48
return
Operator::Invalid();
49
50
index_t
Xsize
= Dims[
GO
.X ];
51
index_t
Ysize
= Dims[
GO
.Y ];
52
53
Operator
Op( MIndex(
Xsize
,
Ysize
) );
54
55
const
Array3D
&Src = *
src
;
56
57
for
(
index_t
iy = 0; iy<
Ysize
; iy++)
58
for
(
index_t
ix = 0; ix<
Xsize
; ix++)
59
{
60
MultiIndex<3>
P
=
FragmentOffset
;
61
P
[
GO
.X] += ix;
P
[
GO
.Y] += iy;
P
[
GO
.Z] += SliceID;
62
63
MultiIndex<2>
Pdst
;
64
Pdst
[ 0 ] = ix;
65
Pdst
[ 1 ] = iy;
66
67
Op.collect(
Pdst
, Src[
P
] );
68
}
69
70
return
Op.result;
71
}
72
};
73
74
template
<
class
Operator,
class
Array3D,
class
NEXT>
75
struct
ExtractSlice
<
Operator
,
META
::
LIST
<Array3D, NEXT> >
76
{
77
78
static
typename
Operator::result_t get(
const
MultiIndex<3>
&Dims,
79
const
RefPtr<MemBase>
&
Data
,
const
SliceSelection
&
O
,
80
index_t
SliceID,
const
MultiIndex<3>
&
FragmentOffset
)
81
{
82
if
(
typename
Operator::result_t result =
83
ExtractSlice<Operator, Array3D>::get
(Dims,
Data
,
O
, SliceID,
FragmentOffset
) )
84
{
85
return
result;
86
}
87
return
ExtractSlice<Operator, NEXT>::get
(Dims,
Data
,
O
, SliceID,
FragmentOffset
);
88
}
89
};
90
91
template
<
class
Operator>
92
struct
ExtractSlice
<
Operator
,
META
::
NIL
>
93
{
94
95
static
typename
Operator::result_t get(
const
MultiIndex<3>
&Dims,
96
const
RefPtr<MemBase>
&
Data
,
const
SliceSelection
&
O
,
97
index_t
SliceID,
const
MultiIndex<3>
&
FragmentOffset
)
98
{
99
return
Operator::Invalid();
100
}
101
};
102
103
}
// namespace Fiber
104
105
#endif
//__FIBEROPERATIONS_EXTRACT_SLICE
Fiber::CreativeIterator
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition
CreativeIterator.hpp:34
Eagle::Operator
Fiber
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition
FAQ.dox:2
META
MemCore::NullPtr
std::nullptr_t NullPtr
Data
Fiber::ArrayCollector
Definition
ExtractSlice.hpp:13
Fiber::ExtractSlice
Definition
ExtractSlice.hpp:40
Generated on Sun Mar 1 2026 10:23:04 for FiberVISH by
1.9.8