Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
phcerdan
VTK-m
Commits
74f8885d
Commit
74f8885d
authored
Jun 21, 2018
by
Dave Pugmire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move helper classes into detail namespace.
parent
9fd821ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
92 deletions
+94
-92
vtkm/worklet/CoordinateSystemTransform.h
vtkm/worklet/CoordinateSystemTransform.h
+94
-92
No files found.
vtkm/worklet/CoordinateSystemTransform.h
View file @
74f8885d
...
...
@@ -24,6 +24,7 @@
#include <vtkm/Math.h>
#include <vtkm/Matrix.h>
#include <vtkm/Transform3D.h>
#include <vtkm/VectorAnalysis.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
...
...
@@ -31,50 +32,101 @@ namespace vtkm
{
namespace
worklet
{
namespace
detail
{
template
<
typename
T
>
struct
CylToCar
:
public
vtkm
::
worklet
::
WorkletMapField
{
using
ControlSignature
=
void
(
FieldIn
<
Vec3
>
,
FieldOut
<
Vec3
>
);
using
ExecutionSignature
=
_2
(
_1
);
//Functor
VTKM_EXEC
vtkm
::
Vec
<
T
,
3
>
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
vec
)
const
{
vtkm
::
Vec
<
T
,
3
>
res
(
vec
[
0
]
*
static_cast
<
T
>
(
vtkm
::
Cos
(
vec
[
1
])),
vec
[
0
]
*
static_cast
<
T
>
(
vtkm
::
Sin
(
vec
[
1
])),
vec
[
2
]);
return
res
;
}
};
template
<
typename
T
>
class
CylindricalCoordinateTransform
struct
CarToCyl
:
public
vtkm
::
worklet
::
WorkletMapField
{
public:
struct
CylToCar
:
public
vtkm
::
worklet
::
WorkletMapField
using
ControlSignature
=
void
(
FieldIn
<
Vec3
>
,
FieldOut
<
Vec3
>
);
using
ExecutionSignature
=
_2
(
_1
);
//Functor
VTKM_EXEC
vtkm
::
Vec
<
T
,
3
>
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
vec
)
const
{
using
ControlSignature
=
void
(
FieldIn
<
Vec3
>
,
FieldOut
<
Vec3
>
);
using
ExecutionSignature
=
_2
(
_1
)
;
T
R
=
vtkm
::
Sqrt
(
vec
[
0
]
*
vec
[
0
]
+
vec
[
1
]
*
vec
[
1
]
);
T
Theta
=
0
;
if
(
vec
[
0
]
==
0
&&
vec
[
1
]
==
0
)
Theta
=
0
;
else
if
(
vec
[
0
]
<
0
)
Theta
=
-
vtkm
::
ASin
(
vec
[
1
]
/
R
)
+
static_cast
<
T
>
(
vtkm
::
Pi
());
else
Theta
=
vtkm
::
ASin
(
vec
[
1
]
/
R
);
//Functor
VTKM_EXEC
vtkm
::
Vec
<
T
,
3
>
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
vec
)
const
{
vtkm
::
Vec
<
T
,
3
>
res
(
vec
[
0
]
*
static_cast
<
T
>
(
vtkm
::
Cos
(
vec
[
1
])),
vec
[
0
]
*
static_cast
<
T
>
(
vtkm
::
Sin
(
vec
[
1
])),
vec
[
2
]);
return
res
;
}
};
vtkm
::
Vec
<
T
,
3
>
res
(
R
,
Theta
,
vec
[
2
]);
return
res
;
}
};
template
<
typename
T
>
struct
SphereToCar
:
public
vtkm
::
worklet
::
WorkletMapField
{
using
ControlSignature
=
void
(
FieldIn
<
Vec3
>
,
FieldOut
<
Vec3
>
);
using
ExecutionSignature
=
_2
(
_1
);
struct
CarToCyl
:
public
vtkm
::
worklet
::
WorkletMapField
//Functor
VTKM_EXEC
vtkm
::
Vec
<
T
,
3
>
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
vec
)
const
{
using
ControlSignature
=
void
(
FieldIn
<
Vec3
>
,
FieldOut
<
Vec3
>
);
using
ExecutionSignature
=
_2
(
_1
);
T
R
=
vec
[
0
];
T
Theta
=
vec
[
1
];
T
Phi
=
vec
[
2
];
//Functor
VTKM_EXEC
vtkm
::
Vec
<
T
,
3
>
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
vec
)
const
{
T
R
=
vtkm
::
Sqrt
(
vec
[
0
]
*
vec
[
0
]
+
vec
[
1
]
*
vec
[
1
]);
T
Theta
=
0
;
if
(
vec
[
0
]
==
0
&&
vec
[
1
]
==
0
)
Theta
=
0
;
else
if
(
vec
[
0
]
<
0
)
Theta
=
-
vtkm
::
ASin
(
vec
[
1
]
/
R
)
+
static_cast
<
T
>
(
vtkm
::
Pi
());
else
Theta
=
vtkm
::
ASin
(
vec
[
1
]
/
R
);
vtkm
::
Vec
<
T
,
3
>
res
(
R
,
Theta
,
vec
[
2
]);
return
res
;
}
};
T
sinTheta
=
static_cast
<
T
>
(
vtkm
::
Sin
(
Theta
));
T
cosTheta
=
static_cast
<
T
>
(
vtkm
::
Cos
(
Theta
));
T
sinPhi
=
static_cast
<
T
>
(
vtkm
::
Sin
(
Phi
));
T
cosPhi
=
static_cast
<
T
>
(
vtkm
::
Cos
(
Phi
));
T
x
=
R
*
sinTheta
*
cosPhi
;
T
y
=
R
*
sinTheta
*
sinPhi
;
T
z
=
R
*
cosTheta
;
vtkm
::
Vec
<
T
,
3
>
r
(
x
,
y
,
z
);
return
r
;
}
};
template
<
typename
T
>
struct
CarToSphere
:
public
vtkm
::
worklet
::
WorkletMapField
{
using
ControlSignature
=
void
(
FieldIn
<
Vec3
>
,
FieldOut
<
Vec3
>
);
using
ExecutionSignature
=
_2
(
_1
);
//Functor
VTKM_EXEC
vtkm
::
Vec
<
T
,
3
>
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
vec
)
const
{
T
R
=
vtkm
::
Sqrt
(
vtkm
::
Dot
(
vec
,
vec
));
T
Theta
=
0
;
if
(
R
>
0
)
Theta
=
vtkm
::
ACos
(
vec
[
2
]
/
R
);
T
Phi
=
vtkm
::
ATan2
(
vec
[
1
],
vec
[
0
]);
if
(
Phi
<
0
)
Phi
+=
static_cast
<
T
>
(
vtkm
::
TwoPi
());
return
vtkm
::
Vec
<
T
,
3
>
(
R
,
Theta
,
Phi
);
}
};
};
template
<
typename
T
>
class
CylindricalCoordinateTransform
{
public:
VTKM_CONT
CylindricalCoordinateTransform
()
:
cartesianToCylindrical
(
true
)
...
...
@@ -91,12 +143,12 @@ public:
{
if
(
cartesianToCylindrical
)
{
vtkm
::
worklet
::
DispatcherMapField
<
CarToCyl
>
dispatcher
;
vtkm
::
worklet
::
DispatcherMapField
<
detail
::
CarToCyl
<
T
>
>
dispatcher
;
dispatcher
.
Invoke
(
inPoints
,
outPoints
);
}
else
{
vtkm
::
worklet
::
DispatcherMapField
<
CylToCar
>
dispatcher
;
vtkm
::
worklet
::
DispatcherMapField
<
detail
::
CylToCar
<
T
>
>
dispatcher
;
dispatcher
.
Invoke
(
inPoints
,
outPoints
);
}
}
...
...
@@ -108,12 +160,12 @@ public:
{
if
(
cartesianToCylindrical
)
{
vtkm
::
worklet
::
DispatcherMapField
<
CarToCyl
>
dispatcher
;
vtkm
::
worklet
::
DispatcherMapField
<
detail
::
CarToCyl
<
T
>
>
dispatcher
;
dispatcher
.
Invoke
(
inPoints
,
outPoints
);
}
else
{
vtkm
::
worklet
::
DispatcherMapField
<
CylToCar
>
dispatcher
;
vtkm
::
worklet
::
DispatcherMapField
<
detail
::
CylToCar
<
T
>
>
dispatcher
;
dispatcher
.
Invoke
(
inPoints
,
outPoints
);
}
}
...
...
@@ -126,56 +178,6 @@ template <typename T>
class
SphericalCoordinateTransform
{
public:
struct
SphereToCar
:
public
vtkm
::
worklet
::
WorkletMapField
{
using
ControlSignature
=
void
(
FieldIn
<
Vec3
>
,
FieldOut
<
Vec3
>
);
using
ExecutionSignature
=
_2
(
_1
);
//Functor
VTKM_EXEC
vtkm
::
Vec
<
T
,
3
>
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
vec
)
const
{
T
R
=
vec
[
0
];
T
Theta
=
vec
[
1
];
T
Phi
=
vec
[
2
];
T
sinTheta
=
static_cast
<
T
>
(
vtkm
::
Sin
(
Theta
));
T
cosTheta
=
static_cast
<
T
>
(
vtkm
::
Cos
(
Theta
));
T
sinPhi
=
static_cast
<
T
>
(
vtkm
::
Sin
(
Phi
));
T
cosPhi
=
static_cast
<
T
>
(
vtkm
::
Cos
(
Phi
));
T
x
=
R
*
sinTheta
*
cosPhi
;
T
y
=
R
*
sinTheta
*
sinPhi
;
T
z
=
R
*
cosTheta
;
vtkm
::
Vec
<
T
,
3
>
r
(
x
,
y
,
z
);
return
r
;
}
};
struct
CarToSphere
:
public
vtkm
::
worklet
::
WorkletMapField
{
using
ControlSignature
=
void
(
FieldIn
<
Vec3
>
,
FieldOut
<
Vec3
>
);
using
ExecutionSignature
=
_2
(
_1
);
//Functor
VTKM_EXEC
vtkm
::
Vec
<
T
,
3
>
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
vec
)
const
{
T
x
=
vec
[
0
];
T
y
=
vec
[
1
];
T
z
=
vec
[
2
];
T
R
=
vtkm
::
Sqrt
(
x
*
x
+
y
*
y
+
z
*
z
);
T
Theta
=
0
;
if
(
R
>
0
)
Theta
=
vtkm
::
ACos
(
z
/
R
);
T
Phi
=
vtkm
::
ATan2
(
y
,
x
);
if
(
Phi
<
0
)
Phi
+=
static_cast
<
T
>
(
vtkm
::
TwoPi
());
return
vtkm
::
Vec
<
T
,
3
>
(
R
,
Theta
,
Phi
);
}
};
VTKM_CONT
SphericalCoordinateTransform
()
:
CartesianToSpherical
(
true
)
...
...
@@ -192,12 +194,12 @@ public:
{
if
(
CartesianToSpherical
)
{
vtkm
::
worklet
::
DispatcherMapField
<
CarToSphere
,
DeviceAdapterTag
>
dispatcher
;
vtkm
::
worklet
::
DispatcherMapField
<
detail
::
CarToSphere
<
T
>
,
DeviceAdapterTag
>
dispatcher
;
dispatcher
.
Invoke
(
inPoints
,
outPoints
);
}
else
{
vtkm
::
worklet
::
DispatcherMapField
<
SphereToCar
,
DeviceAdapterTag
>
dispatcher
;
vtkm
::
worklet
::
DispatcherMapField
<
detail
::
SphereToCar
<
T
>
,
DeviceAdapterTag
>
dispatcher
;
dispatcher
.
Invoke
(
inPoints
,
outPoints
);
}
}
...
...
@@ -209,12 +211,12 @@ public:
{
if
(
CartesianToSpherical
)
{
vtkm
::
worklet
::
DispatcherMapField
<
CarToSphere
,
DeviceAdapterTag
>
dispatcher
;
vtkm
::
worklet
::
DispatcherMapField
<
detail
::
CarToSphere
<
T
>
,
DeviceAdapterTag
>
dispatcher
;
dispatcher
.
Invoke
(
inPoints
,
outPoints
);
}
else
{
vtkm
::
worklet
::
DispatcherMapField
<
SphereToCar
,
DeviceAdapterTag
>
dispatcher
;
vtkm
::
worklet
::
DispatcherMapField
<
detail
::
SphereToCar
<
T
>
,
DeviceAdapterTag
>
dispatcher
;
dispatcher
.
Invoke
(
inPoints
,
outPoints
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment