Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
2018e88a
Commit
2018e88a
authored
Jul 20, 2012
by
Pierre Kraemer
Browse files
added a collector based on a normal angle threshold
parent
c4277eaa
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/Algo/Selection/collector.h
View file @
2018e88a
...
...
@@ -164,6 +164,40 @@ public:
inline
typename
PFP
::
REAL
getArea
()
const
{
return
area
;
}
};
/*********************************************************
* Collector Normal Angle
*********************************************************/
/*
* collect all primitives of the connected component containing "centerDart"
* the angle between the included vertices normal vectors and the central normal vector
* stays under a given threshold
*/
template
<
typename
PFP
>
class
Collector_NormalAngle
:
public
Collector
<
PFP
>
{
protected:
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
;
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
normal
;
typename
PFP
::
REAL
angleThreshold
;
public:
Collector_NormalAngle
(
typename
PFP
::
MAP
&
m
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
p
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
n
,
typename
PFP
::
REAL
a
)
:
Collector
<
PFP
>
(
m
),
position
(
p
),
normal
(
n
),
angleThreshold
(
a
)
{}
inline
void
setAngleThreshold
(
typename
PFP
::
REAL
a
)
{
angleThreshold
=
a
;
}
inline
typename
PFP
::
REAL
getAngleThreshold
()
const
{
return
angleThreshold
;
}
inline
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
getPosition
()
const
{
return
position
;
}
inline
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
getNormal
()
const
{
return
normal
;
}
void
collectAll
(
Dart
d
)
;
void
collectBorder
(
Dart
d
)
;
};
}
// namespace Selection
}
// namespace Algo
...
...
include/Algo/Selection/collector.hpp
View file @
2018e88a
...
...
@@ -280,6 +280,127 @@ void Collector_WithinSphere<PFP>::computeArea()
}
}
/*********************************************************
* Collector Normal Angle
*********************************************************/
template
<
typename
PFP
>
void
Collector_NormalAngle
<
PFP
>::
collectAll
(
Dart
d
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
this
->
init
(
d
);
this
->
insideEdges
.
reserve
(
32
);
this
->
insideFaces
.
reserve
(
32
);
this
->
border
.
reserve
(
32
);
CellMarkerStore
<
VERTEX
>
vm
(
this
->
map
);
// mark the collected inside-vertices
CellMarkerStore
<
EDGE
>
em
(
this
->
map
);
// mark the collected inside-edges + border-edges
CellMarkerStore
<
FACE
>
fm
(
this
->
map
);
// mark the collected inside-faces + border-faces
this
->
insideVertices
.
push_back
(
this
->
centerDart
);
vm
.
mark
(
this
->
centerDart
);
VEC3
centerNormal
=
this
->
normal
[
d
];
unsigned
int
i
=
0
;
while
(
i
<
this
->
insideVertices
.
size
())
{
Dart
end
=
this
->
insideVertices
[
i
];
Dart
e
=
end
;
do
{
if
(
!
em
.
isMarked
(
e
)
||
!
fm
.
isMarked
(
e
))
// are both tests useful ?
{
const
Dart
f
=
this
->
map
.
phi1
(
e
);
const
Dart
g
=
this
->
map
.
phi1
(
f
);
REAL
a
=
Geom
::
angle
(
centerNormal
,
this
->
normal
[
f
]);
if
(
a
>
angleThreshold
)
{
this
->
border
.
push_back
(
e
);
// add to border
em
.
mark
(
e
);
fm
.
mark
(
e
);
// is it useful ?
}
else
{
if
(
!
vm
.
isMarked
(
f
))
{
this
->
insideVertices
.
push_back
(
f
);
vm
.
mark
(
f
);
}
if
(
!
em
.
isMarked
(
e
))
{
this
->
insideEdges
.
push_back
(
e
);
em
.
mark
(
e
);
}
REAL
b
=
Geom
::
angle
(
centerNormal
,
this
->
normal
[
g
]);
if
(
!
fm
.
isMarked
(
e
)
&&
b
<
angleThreshold
)
{
this
->
insideFaces
.
push_back
(
e
);
fm
.
mark
(
e
);
}
}
}
e
=
this
->
map
.
phi2_1
(
e
);
}
while
(
e
!=
end
);
++
i
;
}
}
template
<
typename
PFP
>
void
Collector_NormalAngle
<
PFP
>::
collectBorder
(
Dart
d
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
this
->
init
(
d
);
this
->
border
.
reserve
(
128
);
this
->
insideVertices
.
reserve
(
128
);
CellMarkerStore
<
VERTEX
>
vm
(
this
->
map
);
// mark the collected inside-vertices
CellMarkerStore
<
EDGE
>
em
(
this
->
map
);
// mark the collected inside-edges + border-edges
this
->
insideVertices
.
push_back
(
this
->
centerDart
);
vm
.
mark
(
this
->
centerDart
);
VEC3
centerNormal
=
this
->
normal
[
d
];
unsigned
int
i
=
0
;
while
(
i
<
this
->
insideVertices
.
size
())
{
Dart
end
=
this
->
insideVertices
[
i
];
Dart
e
=
end
;
do
{
if
(
!
em
.
isMarked
(
e
)
)
{
const
Dart
f
=
this
->
map
.
phi1
(
e
);
REAL
a
=
Geom
::
angle
(
centerNormal
,
this
->
normal
[
f
]);
if
(
a
>
angleThreshold
)
{
this
->
border
.
push_back
(
e
);
// add to border
}
else
{
if
(
!
vm
.
isMarked
(
f
))
{
this
->
insideVertices
.
push_back
(
f
);
vm
.
mark
(
f
);
}
}
em
.
mark
(
e
);
}
e
=
this
->
map
.
phi2_1
(
e
);
}
while
(
e
!=
end
);
++
i
;
}
this
->
insideVertices
.
clear
();
}
}
// namespace Selection
}
// namespace Algo
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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