DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
IntersectionTarget.h
1
16
17
#pragma once
18
27
28
#if !defined IntersectionTarget_h
30
#define IntersectionTarget_h
31
32
#include "DGtal/helpers/StdDefs.h"
33
#include "DGtal/base/ConstAlias.h"
34
#include "DGtal/shapes/Mesh.h"
35
#include "DGtal/shapes/IntersectionTarget.h"
36
#include "DGtal/kernel/SpaceND.h"
37
#include "DGtal/kernel/sets/CDigitalSet.h"
38
#include "DGtal/geometry/tools/determinant/PredicateFromOrientationFunctor2.h"
39
#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
40
41
namespace
DGtal
42
{
43
45
56
template
<
typename
TSpace,
size_t
TSeparation,
size_t
TDimension = 1>
57
struct
IntersectionTargetTrait
58
{
60
BOOST_STATIC_ASSERT_MSG
( TSpace::dimension == 3,
"DigitalSet dimension must be 3"
);
61
63
BOOST_STATIC_ASSERT_MSG
( TSeparation == 6 || TSeparation == 26,
"Separation must be 6 or 26"
);
64
66
BOOST_STATIC_ASSERT_MSG
( TDimension == 1,
"Currently only 1D intersection target is implemented"
);
67
71
IntersectionTargetTrait
() =
delete
;
72
74
template
<
typename
Space,
size_t
Separation,
size_t
Dimension = 1>
75
struct
IntersectionTarget
;
76
77
/****** Associated types *********************/
78
using
Space2D
=
SpaceND<2, typename TSpace::Integer>
;
79
using
PointR3
=
typename
TSpace::RealPoint;
80
using
VectorR3
=
typename
TSpace::RealPoint;
81
using
PointR2
=
typename
Space2D::RealPoint
;
82
using
Type
=
IntersectionTarget<TSpace, TSeparation, TDimension>
;
83
/*********************************************/
84
86
struct
Edge
87
{
88
PointR3
myFirst
,
mySecond
;
89
Edge
() =
default
;
90
Edge
(
const
Edge
&) =
default
;
91
Edge
(
const
PointR3
& mf,
const
PointR3
& ms) :
myFirst
(mf),
mySecond
(ms) {}
92
};
93
97
template
<
typename
Space>
98
struct
IntersectionTarget
<
Space
, 6, 1>
99
{
100
// ----------------------- Members ------------------------------
101
103
const
std::array<Edge, 3>
myTarget
{{
104
{ { 0.5, 0.0, 0.0 }, { -0.5, 0.0, 0.0} } ,
// AB
105
{ { 0.0, 0.0, 0.5 }, { 0.0, 0.0, -0.5} } ,
// CD
106
{ { 0.0, 0.5, 0.0 }, { 0.0, -0.5, 0.0} }
// EF
107
}};
108
109
// ----------------------- Standard services --------------------
110
115
const
std::array<Edge, 3>&
operator()
() {
116
return
myTarget
;
117
}
118
124
const
Edge
&
operator()
(
int
i) {
125
return
myTarget
[i];
126
}
127
134
PointR2
project
(
int
i,
const
PointR3
& p)
const
{
135
ASSERT( 0 <= i && i <= 2 );
136
137
if
(
myTarget
[i].myFirst[0] == 0.5)
138
return
{ p[1], p[2] };
// ignore x
139
else
if
(
myTarget
[i].myFirst[1] == 0.5)
140
return
{ p[0], p[2] };
// ignore y
141
else
142
return
{ p[0], p[1] };
// ignore z
143
}
144
};
145
149
template
<
typename
Space>
150
struct
IntersectionTarget
<
Space
, 26, 1>
151
{
152
// ----------------------- Members ------------------------------
153
155
const
std::array<Edge, 4>
myTarget
{{
156
{ { -0.5, 0.5, 0.5}, { 0.5, -0.5, -0.5} } ,
// AG
157
{ { 0.5, 0.5, 0.5}, { -0.5, -0.5, -0.5} } ,
// BH
158
{ { 0.5, 0.5, -0.5}, { -0.5, -0.5, 0.5} } ,
// CE
159
{ { -0.5, 0.5, -0.5}, { 0.5, -0.5, 0.5} }
// DF
160
}};
161
163
std::array<VectorR3, 4>
myE1base
;
164
166
std::array<VectorR3, 4>
myE2base
;
167
171
IntersectionTarget
()
172
{
173
const
double
coef = 1. / std::sqrt(3.);
174
175
std::array<VectorR3, 4> myNormal {{
176
{ coef, -coef, -coef } ,
177
{ -coef, -coef, -coef } ,
178
{ -coef, -coef, coef } ,
179
{ coef, -coef, coef }
180
}};
181
182
// computation of each e1/e2 bases foreach normal
183
for
(
int
i = 0; i < 4; i++)
184
{
185
auto
& x = myNormal[i][0];
186
auto
& y = myNormal[i][1];
187
auto
& z = myNormal[i][2];
188
189
myE1base
[i] = std::move(
VectorR3
(-y, x, 0).getNormalized() );
190
myE2base
[i] = std::move(
VectorR3
(-x*z, -y*z, x*x + y*y).getNormalized() );
191
}
192
}
193
194
// ----------------------- Standard services --------------------
195
200
const
std::array<Edge, 4>&
operator()
()
const
{
201
return
myTarget
;
202
}
203
209
const
Edge
&
operator()
(
int
i)
const
{
210
return
myTarget
[i];
211
}
212
219
PointR2
project
(
int
i,
const
PointR3
& p)
const
{
220
ASSERT( 0 <= i && i <= 3 );
221
222
return
{
myE1base
[i].dot(p),
myE2base
[i].dot(p) };
223
}
224
};
225
};
226
}
227
228
#endif
// !defined MeshVoxelizer_h
DGtal::SpaceND
Definition
SpaceND.h:96
DGtal::SpaceND< 2, typename TSpace::Integer >::RealPoint
PointVector< dim, double > RealPoint
Definition
SpaceND.h:117
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::Space
DGtal::IntersectionTargetTrait::Edge
Internal Edge structure.
Definition
IntersectionTarget.h:87
DGtal::IntersectionTargetTrait::Edge::Edge
Edge(const Edge &)=default
DGtal::IntersectionTargetTrait::Edge::Edge
Edge(const PointR3 &mf, const PointR3 &ms)
Definition
IntersectionTarget.h:91
DGtal::IntersectionTargetTrait::Edge::Edge
Edge()=default
DGtal::IntersectionTargetTrait::Edge::myFirst
PointR3 myFirst
Definition
IntersectionTarget.h:88
DGtal::IntersectionTargetTrait::Edge::mySecond
PointR3 mySecond
Definition
IntersectionTarget.h:88
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 26, 1 >::operator()
const std::array< Edge, 4 > & operator()() const
Definition
IntersectionTarget.h:200
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 26, 1 >::myTarget
const std::array< Edge, 4 > myTarget
Target.
Definition
IntersectionTarget.h:155
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 26, 1 >::operator()
const Edge & operator()(int i) const
Definition
IntersectionTarget.h:209
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 26, 1 >::myE1base
std::array< VectorR3, 4 > myE1base
E1 base for each target's edge.
Definition
IntersectionTarget.h:163
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 26, 1 >::myE2base
std::array< VectorR3, 4 > myE2base
E2 base for each target's edge.
Definition
IntersectionTarget.h:166
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 26, 1 >::project
PointR2 project(int i, const PointR3 &p) const
Definition
IntersectionTarget.h:219
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 26, 1 >::IntersectionTarget
IntersectionTarget()
Definition
IntersectionTarget.h:171
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 6, 1 >::operator()
const Edge & operator()(int i)
Definition
IntersectionTarget.h:124
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 6, 1 >::operator()
const std::array< Edge, 3 > & operator()()
Definition
IntersectionTarget.h:115
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 6, 1 >::project
PointR2 project(int i, const PointR3 &p) const
Definition
IntersectionTarget.h:134
DGtal::IntersectionTargetTrait::IntersectionTarget< Space, 6, 1 >::myTarget
const std::array< Edge, 3 > myTarget
Target.
Definition
IntersectionTarget.h:103
DGtal::IntersectionTargetTrait::IntersectionTarget
Internal intersection target structure.
Definition
IntersectionTarget.h:75
DGtal::IntersectionTargetTrait::PointR2
typename Space2D::RealPoint PointR2
Definition
IntersectionTarget.h:81
DGtal::IntersectionTargetTrait::Type
IntersectionTarget< TSpace, TSeparation, TDimension > Type
Definition
IntersectionTarget.h:82
DGtal::IntersectionTargetTrait::VectorR3
typename TSpace::RealPoint VectorR3
Definition
IntersectionTarget.h:80
DGtal::IntersectionTargetTrait::BOOST_STATIC_ASSERT_MSG
BOOST_STATIC_ASSERT_MSG(TSeparation==6||TSeparation==26, "Separation must be 6 or 26")
Separation Checking.
DGtal::IntersectionTargetTrait::BOOST_STATIC_ASSERT_MSG
BOOST_STATIC_ASSERT_MSG(TSpace::dimension==3, "DigitalSet dimension must be 3")
Digital Set dimension Checking.
DGtal::IntersectionTargetTrait::Space2D
SpaceND< 2, typename TSpace::Integer > Space2D
Definition
IntersectionTarget.h:78
DGtal::IntersectionTargetTrait::PointR3
typename TSpace::RealPoint PointR3
Definition
IntersectionTarget.h:79
DGtal::IntersectionTargetTrait::IntersectionTargetTrait
IntersectionTargetTrait()=delete
DGtal::IntersectionTargetTrait::BOOST_STATIC_ASSERT_MSG
BOOST_STATIC_ASSERT_MSG(TDimension==1, "Currently only 1D intersection target is implemented")
Dimension of the intersection target checking.
src
DGtal
shapes
IntersectionTarget.h
Generated on
for DGtal by
1.18.0