Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
3288e972
Commit
3288e972
authored
Apr 10, 2012
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ridge lines computation
parent
9567ab6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
385 additions
and
294 deletions
+385
-294
include/Algo/Geometry/feature.h
include/Algo/Geometry/feature.h
+130
-53
include/Algo/Geometry/feature.hpp
include/Algo/Geometry/feature.hpp
+255
-241
No files found.
include/Algo/Geometry/feature.h
View file @
3288e972
...
...
@@ -36,64 +36,141 @@ namespace Algo
namespace
Geometry
{
#define EMPTY 0
#define SEGMENT 1
#define BARY 2
enum
{
EMPTY
,
SEGMENT
,
BARY
};
//#define EMPTY 0
//#define SEGMENT 1
//#define BARY 2
typedef
struct
{
Dart
d
;
float
w
;
}
e0point
;
typedef
struct
{
e0point
p1
;
e0point
p2
;
int
valid
;
}
e0segment
;
typedef
struct
{
e0point
p1
;
e0point
p2
;
unsigned
char
type
;
}
e0segment
;
typedef
NoMathIONameAttribute
<
e0segment
>
ridgeSegment
;
template
<
typename
PFP
>
void
featureEdgeDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
featureEdge
)
;
template
<
typename
PFP
>
void
computeArea
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TREAL
&
area
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeFaceGradient
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
face_gradient
,
const
typename
PFP
::
TVEC3
&
face_normal
,
const
typename
PFP
::
TREAL
&
kmax
,
const
typename
PFP
::
TREAL
&
area
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeGradient
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
gradient
,
typename
PFP
::
TVEC3
&
face_gradient
,
const
typename
PFP
::
TREAL
&
area
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeTriangleType
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeRidgeLines
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
const
typename
PFP
::
TVEC3
&
faceGradient
,
const
typename
PFP
::
TREAL
&
area
,
typename
PFP
::
TVEC3
&
k
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
initRidgeSegments
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeSingularTriangle
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
typename
PFP
::
TVEC3
&
k
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
std
::
vector
<
typename
PFP
::
VEC3
>
occludingContoursDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
VEC3
&
cameraPosition
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
)
;
template
<
typename
PFP
>
typename
PFP
::
TREAL
faceArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
;
template
<
typename
PFP
>
typename
PFP
::
VEC3
faceGradient
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
face_normal
,
const
typename
PFP
::
TREAL
&
kmax
,
const
typename
PFP
::
TREAL
&
area
)
;
template
<
typename
PFP
>
bool
triangleType
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
;
template
<
typename
PFP
>
bool
isInSameOctant
(
const
typename
PFP
::
VEC3
&
pos1
,
const
typename
PFP
::
VEC3
&
pos2
)
;
template
<
typename
PFP
>
void
ridgeLines
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
typename
PFP
::
TVEC3
&
k
,
const
typename
PFP
::
TVEC3
&
faceGradient
,
const
typename
PFP
::
TREAL
&
area
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
extremality
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
k
,
const
typename
PFP
::
TVEC3
&
faceGradient
,
const
typename
PFP
::
TREAL
&
area
)
;
template
<
typename
PFP
>
typename
PFP
::
TVEC3
vertexGradient
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
face_gradient
,
const
typename
PFP
::
TREAL
&
area
)
;
template
<
typename
PFP
>
void
singularTriangle
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
)
;
void
featureEdgeDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
featureEdge
)
;
template
<
typename
PFP
>
void
computeFaceGradient
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
face_gradient
,
const
typename
PFP
::
TVEC3
&
face_normal
,
const
typename
PFP
::
TREAL
&
kmax
,
const
typename
PFP
::
TREAL
&
area
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
//template <typename PFP>
//void computeVertexGradient(
// typename PFP::MAP& map,
// const typename PFP::TVEC3& position,
// typename PFP::TVEC3& gradient,
// typename PFP::TVEC3& face_gradient,
// const typename PFP::TREAL& area,
// const FunctorSelect& select = allDarts,
// unsigned int thread = 0) ;
template
<
typename
PFP
>
void
computeTriangleType
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
Kmax
,
CellMarker
&
regularMarker
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeRidgeLines
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
const
typename
PFP
::
TVEC3
&
faceGradient
,
const
typename
PFP
::
TREAL
&
area
,
const
typename
PFP
::
TVEC3
&
K
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
initRidgeSegments
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
computeSingularTriangle
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
typename
PFP
::
TVEC3
&
k
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
std
::
vector
<
typename
PFP
::
VEC3
>
occludingContoursDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
VEC3
&
cameraPosition
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
)
;
template
<
typename
PFP
>
typename
PFP
::
VEC3
faceGradient
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
face_normal
,
const
typename
PFP
::
TREAL
&
kmax
,
const
typename
PFP
::
TREAL
&
area
)
;
template
<
typename
PFP
>
bool
isTriangleRegular
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
Kmax
)
;
//template <typename PFP>
//bool isInSameOctant(const typename PFP::VEC3& pos1, const typename PFP::VEC3& pos2) ;
template
<
typename
PFP
>
void
ridgeLines
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
K
,
const
typename
PFP
::
TVEC3
&
faceGradient
,
const
typename
PFP
::
TREAL
&
area
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
)
;
template
<
typename
PFP
>
typename
PFP
::
REAL
extremality
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
VEC3
&
K
,
const
typename
PFP
::
TVEC3
&
faceGradient
,
const
typename
PFP
::
TREAL
&
area
)
;
//template <typename PFP>
//typename PFP::TVEC3 vertexGradient(
// typename PFP::MAP& map,
// Dart d,
// const typename PFP::TVEC3& position,
// const typename PFP::TVEC3& face_gradient,
// const typename PFP::TREAL& area) ;
template
<
typename
PFP
>
void
singularTriangle
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
)
;
template
<
typename
PFP
>
bool
isEdgeInTriangle
(
typename
PFP
::
MAP
&
map
,
Dart
edge
,
Dart
triangle
)
;
...
...
include/Algo/Geometry/feature.hpp
View file @
3288e972
...
...
@@ -36,7 +36,10 @@ namespace Geometry
{
template
<
typename
PFP
>
void
featureEdgeDetection
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
featureEdge
)
void
featureEdgeDetection
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
featureEdge
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -59,76 +62,106 @@ void featureEdgeDetection(typename PFP::MAP& map, typename PFP::TVEC3& position,
}
template
<
typename
PFP
>
void
compute
Area
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TREAL
&
area
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
{
TraversorF
<
typename
PFP
::
MAP
>
trav
(
map
,
select
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
area
[
d
]
=
faceArea
<
PFP
>
(
map
,
d
,
position
)[
1
]
;
}
template
<
typename
PFP
>
void
computeFaceGradient
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
face_gradient
,
const
typename
PFP
::
TVEC3
&
face_normal
,
const
typename
PFP
::
TREAL
&
kmax
,
const
typename
PFP
::
TREAL
&
area
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
void
compute
FaceGradient
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
face_gradient
,
const
typename
PFP
::
TVEC3
&
face_normal
,
const
typename
PFP
::
TREAL
&
kmax
,
const
typename
PFP
::
TREAL
&
area
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
TraversorF
<
typename
PFP
::
MAP
>
trav
(
map
,
select
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
face_gradient
[
d
]
=
faceGradient
<
PFP
>
(
map
,
d
,
position
,
face_normal
,
kmax
,
area
)
;
}
template
<
typename
PFP
>
void
computeGradient
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
gradient
,
typename
PFP
::
TVEC3
&
face_gradient
,
const
typename
PFP
::
TREAL
&
area
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
{
TraversorV
<
typename
PFP
::
MAP
>
trav
(
map
,
select
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
gradient
[
d
]
=
vertexGradient
<
PFP
>
(
map
,
d
,
position
,
face_gradient
,
area
)
;
}
//template <typename PFP>
//void computeVertexGradient(
// typename PFP::MAP& map,
// const typename PFP::TVEC3& position,
// typename PFP::TVEC3& gradient,
// typename PFP::TVEC3& face_gradient,
// const typename PFP::TREAL& area,
// const FunctorSelect& select,
// unsigned int thread)
//{
// TraversorV<typename PFP::MAP> trav(map, select, thread);
// for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
// gradient[d] = vertexGradient<PFP>(map, d, position, face_gradient, area) ;
//}
template
<
typename
PFP
>
void
computeTriangleType
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
void
computeTriangleType
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
Kmax
,
CellMarker
&
regularMarker
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
TraversorF
<
typename
PFP
::
MAP
>
trav
(
map
,
select
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
if
(
triangleType
<
PFP
>
(
map
,
d
,
position
))
if
(
isTriangleRegular
<
PFP
>
(
map
,
d
,
Kmax
))
regularMarker
.
mark
(
d
)
;
}
template
<
typename
PFP
>
void
computeRidgeLines
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
const
typename
PFP
::
TVEC3
&
faceGradient
,
const
typename
PFP
::
TREAL
&
area
,
typename
PFP
::
TVEC3
&
k
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
void
computeRidgeLines
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
const
typename
PFP
::
TVEC3
&
faceGradient
,
const
typename
PFP
::
TREAL
&
area
,
const
typename
PFP
::
TVEC3
&
K
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
TraversorF
<
typename
PFP
::
MAP
>
trav
(
map
,
select
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
if
(
regularMarker
.
isMarked
(
d
))
{
ridgeLines
<
PFP
>
(
map
,
d
,
position
,
regularMarker
,
k
,
faceGradient
,
area
,
ridge_segments
)
;
}
ridgeLines
<
PFP
>
(
map
,
d
,
position
,
K
,
faceGradient
,
area
,
ridge_segments
)
;
}
}
template
<
typename
PFP
>
void
initRidgeSegments
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
void
initRidgeSegments
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
TraversorF
<
typename
PFP
::
MAP
>
trav
(
map
,
select
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
ridge_segments
[
d
].
valid
=
EMPTY
;
}
ridge_segments
[
d
].
type
=
EMPTY
;
}
template
<
typename
PFP
>
void
computeSingularTriangle
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
void
computeSingularTriangle
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
regularMarker
,
AttributeHandler
<
ridgeSegment
>&
ridge_segments
,
const
FunctorSelect
&
select
=
allDarts
,
unsigned
int
thread
=
0
)
{
TraversorF
<
typename
PFP
::
MAP
>
trav
(
map
,
select
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
if
(
!
regularMarker
.
isMarked
(
d
))
{
singularTriangle
<
PFP
>
(
map
,
d
,
position
,
regularMarker
,
ridge_segments
)
;
}
}
}
template
<
typename
PFP
>
std
::
vector
<
typename
PFP
::
VEC3
>
occludingContoursDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
VEC3
&
cameraPosition
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
)
std
::
vector
<
typename
PFP
::
VEC3
>
occludingContoursDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
VEC3
&
cameraPosition
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -182,250 +215,223 @@ std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& ma
}
template
<
typename
PFP
>
float
faceArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
typename
PFP
::
VEC3
faceGradient
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
face_normal
,
const
typename
PFP
::
TREAL
&
kmax
,
const
typename
PFP
::
TREAL
&
area
)
{
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
float
A
[
1
]
;
VEC3
pos1
(
0
)
;
VEC3
pos2
(
0
)
;
VEC3
pos3
(
0
)
;
Traversor2FV
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
Dart
it
=
t
.
begin
()
;
pos1
+=
position
[
it
]
;
it
=
t
.
next
;
pos2
+=
position
[
it
]
;
it
=
t
.
next
;
pos3
+=
position
[
it
]
;
A
=
1
/
2
*
abs
(
(
(
pos2
.
x
-
pos1
.
x
)
*
(
pos3
.
y
-
pos1
.
y
)
)
-
(
(
pos3
.
x
-
pos1
.
x
)
*
(
pos2
.
y
-
pos1
.
y
)
)
)
;
return
A
;
}
template
<
typename
PFP
>
typename
PFP
::
VEC3
faceGradient
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
face_normal
,
const
typename
PFP
::
TREAL
&
kmax
,
const
typename
PFP
::
TREAL
&
area
)
{
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
VEC3
G
(
0
)
;
VEC3
pos1
(
0
)
;
VEC3
pos2
(
0
)
;
VEC3
pos3
(
0
)
;
VEC3
n
=
face_normal
[
d
]
;
REAL
k1
;
REAL
k2
;
REAL
k3
;
REAL
a
=
area
[
d
]
;
Traversor2FV
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
Dart
it
=
t
.
begin
()
;
VEC3
pos1
=
position
[
it
]
;
REAL
k1
=
kmax
[
it
]
;
pos1
+=
position
[
it
]
;
k1
=
kmax
[
it
]
;
it
=
t
.
next
()
;
pos2
+=
position
[
it
]
;
k2
=
kmax
[
it
]
;
VEC3
pos2
=
position
[
it
]
;
REAL
k2
=
kmax
[
it
]
;
it
=
t
.
next
()
;
pos3
+
=
position
[
it
]
;
k3
=
kmax
[
it
]
;
VEC3
pos3
=
position
[
it
]
;
REAL
k3
=
kmax
[
it
]
;
G
+=
k1
*
(
(
n
^
(
pos3
-
pos2
)
)
/
(
2
*
a
)
)
+
k2
*
(
(
n
^
(
pos1
-
pos3
)
)
/
(
2
*
a
)
)
+
k3
*
(
(
n
^
(
pos2
-
pos1
)
)
/
(
2
*
a
)
)
;
VEC3
n
=
face_normal
[
d
]
;
REAL
a
=
area
[
d
]
;
VEC3
G
=
k1
*
(
(
n
^
(
pos3
-
pos2
)
)
/
(
2
*
a
)
)
+
k2
*
(
(
n
^
(
pos1
-
pos3
)
)
/
(
2
*
a
)
)
+
k3
*
(
(
n
^
(
pos2
-
pos1
)
)
/
(
2
*
a
)
)
;
G
.
normalize
()
;
return
G
;
}
template
<
typename
PFP
>
bool
triangleType
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
)
bool
mutuallyPositive
(
typename
PFP
::
VEC3
&
v1
,
typename
PFP
::
VEC3
&
v2
,
typename
PFP
::
VEC3
&
v3
)
{
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
VEC3
pos1
(
0
)
;
VEC3
pos2
(
0
)
;
VEC3
pos3
(
0
)
;
Traversor2FV
<
typename
PFP
::
MAP
>
t
(
map
,
d
)
;
Dart
it
=
t
.
begin
()
;
pos1
+=
position
[
it
]
;
it
=
t
.
next
()
;
pos2
+=
position
[
it
]
;
it
=
t
.
next
()
;
pos3
+=
position
[
it
]
;
if
(
isInSameOctant
<
PFP
>
(
pos1
,
pos2
)
&&
isInSameOctant
<
PFP
>
(
pos1
,
pos3
)
)
{
//regular triangle
typename
PFP
::
REAL
v1v2
=
v1
*
v2
;
typename
PFP
::
REAL
v1v3
=
v1
*
v3
;
typename
PFP
::
REAL
v2v3
=
v2
*
v3
;
if
(
v1v2
>
0
&&
v1v3
>
0
&&
v2v3
>
0
)
return
true
;
}
else
{
//singular triangle
return
false
;
}
return
false
;
}
template
<
typename
PFP
>
bool
is
InSameOctant
(
const
typename
PFP
::
VEC3
&
pos1
,
const
typename
PFP
::
VEC3
&
pos2
)
bool
is
TriangleRegular
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
Kmax
)
{
return
(
(
pos1
[
0
]
>
0
&&
pos1
[
1
]
>
0
&&
pos1
[
2
]
>
0
&&
//one of the eight octant
(
(
pos2
[
0
]
>
0
&&
pos2
[
1
]
>
0
&&
pos2
[
2
]
>
0
)
or
//one choice of sign
(
pos2
[
0
]
<
0
&&
pos2
[
1
]
<
0
&&
pos2
[
2
]
<
0
)
)
)
or
//the other choice
(
pos1
[
0
]
>
0
&&
pos1
[
1
]
>
0
&&
pos1
[
2
]
<
0
&&
(
(
pos2
[
0
]
>
0
&&
pos2
[
1
]
>
0
&&
pos2
[
2
]
<
0
)
or
(
pos2
[
0
]
<
0
&&
pos2
[
1
]
<
0
&&
pos2
[
2
]
>
0
)
)
)
or
(
pos1
[
0
]
>
0
&&
pos1
[
1
]
<
0
&&
pos1
[
2
]
>
0
&&
(
(
pos2
[
0
]
>
0
&&
pos2
[
1
]
<
0
&&
pos2
[
2
]
>
0
)
or
(
pos2
[
0
]
<
0
&&
pos2
[
1
]
>
0
&&
pos2
[
2
]
<
0
)
)
)
or
typedef
typename
PFP
::
REAL
REAL
;
typedef
typename
PFP
::
VEC3
VEC3
;
(
pos1
[
0
]
>
0
&&
pos1
[
1
]
<
0
&&
pos1
[
2
]
<
0
&&
(
(
pos2
[
0
]
>
0
&&
pos2
[
1
]
<
0
&&
pos2
[
2
]
<
0
)
or
(
pos2
[
0
]
<
0
&&
pos2
[
1
]
>
0
&&
pos2
[
2
]
>
0
)
)
)
or
Dart
v1
=
d
;
Dart
v2
=
map
.
phi1
(
v1
)
;
Dart
v3
=
map
.
phi1
(
v2
)
;
(
pos1
[
0
]
<
0
&&
pos1
[
1
]
>
0
&&
pos1
[
2
]
>
0
&&
(
(
pos2
[
0
]
<
0
&&
pos2
[
1
]
>
0
&&
pos2
[
2
]
>
0
)
or
(
pos2
[
0
]
>
0
&&
pos2
[
1
]
<
0
&&
pos2
[
2
]
<
0
)
)
)
or
VEC3
K1
=
Kmax
[
v1
]
;
VEC3
K2
=
Kmax
[
v2
]
;
VEC3
K3
=
Kmax
[
v3
]
;
(
pos1
[
0
]
<
0
&&
pos1
[
1
]
>
0
&&
pos1
[
2
]
<
0
&&
(
(
pos2
[
0
]
<
0
&&
pos2
[
1
]
>
0
&&
pos2
[
2
]
<
0
)
or
(
pos2
[
0
]
>
0
&&
pos2
[
1
]
<
0
&&
pos2
[
2
]
>
0
)
)
)
or
// VEC3 K1n = typename VEC3::DATA_TYPE(-1) * K1 ;
VEC3
K2n
=
typename
VEC3
::
DATA_TYPE
(
-
1
)
*
K2
;
VEC3
K3n
=
typename
VEC3
::
DATA_TYPE
(
-
1
)
*
K3
;
(
pos1
[
0
]
<
0
&&
pos1
[
1
]
<
0
&&
pos1
[
2
]
>
0
&&
(
(
pos2
[
0
]
<
0
&&
pos2
[
1
]
<
0
&&
pos2
[
2
]
>
0
)
or
(
pos2
[
0
]
>
0
&&
pos2
[
1
]
>
0
&&
pos2
[
2
]
<
0
)
)
)
or
if
(
mutuallyPositive
<
PFP
>
(
K1
,
K2
,
K3
))
return
true
;
if
(
mutuallyPositive
<
PFP
>
(
K1
,
K2
,
K3n
))
return
true
;
if
(
mutuallyPositive
<
PFP
>
(
K1
,
K2n
,
K3
))
return
true
;
if
(
mutuallyPositive
<
PFP
>
(
K1
,
K2n
,
K3n
))
return
true
;
(
pos1
[
0
]
<
0
&&
pos1
[
1
]
<
0
&&
pos1
[
2
]
<
0
&&
(
(
pos2
[
0
]
<
0
&&
pos2
[
1
]
<
0
&&
pos2
[
2
]
<
0
)
or
(
pos2
[
0
]
>
0
&&
pos2
[
1
]
>
0
&&
pos2
[
2
]
>
0
)
)
)
)
;
// if(mutuallyPositive<PFP>(K1n, K2, K3))
// return true ;
// if(mutuallyPositive<PFP>(K1n, K2, K3n))
// return true ;
// if(mutuallyPositive<PFP>(K1n, K2n, K3))
// return true ;
// if(mutuallyPositive<PFP>(K1n, K2n, K3n))
// return true ;
return
false
;
// if ( isInSameOctant<PFP>(K1, K2) && isInSameOctant<PFP>(K1, K3) )
// {
// //regular triangle
// return true ;
// }
// else
// {
// //singular triangle
// return false ;
// }
}
//template <typename PFP>
//bool isInSameOctant(const typename PFP::VEC3& pos1, const typename PFP::VEC3& pos2)
//{
// return ( ( pos1[0] > 0 && pos1[1] > 0 && pos1[2] > 0 && //one of the eight octant
// ( ( pos2[0] > 0 && pos2[1] > 0 && pos2[2] > 0 ) or //one choice of sign
// ( pos2[0] < 0 && pos2[1] < 0 && pos2[2] < 0 ) ) ) or //the other choice
//
// ( pos1[0] > 0 && pos1[1] > 0 && pos1[2] < 0 &&
// ( ( pos2[0] > 0 && pos2[1] > 0 && pos2[2] < 0 ) or
// ( pos2[0] < 0 && pos2[1] < 0 && pos2[2] > 0 ) ) ) or
//
// ( pos1[0] > 0 && pos1[1] < 0 && pos1[2] > 0 &&
// ( ( pos2[0] > 0 && pos2[1] < 0 && pos2[2] > 0 ) or
// ( pos2[0] < 0 && pos2[1] > 0 && pos2[2] < 0 ) ) ) or
//
// ( pos1[0] > 0 && pos1[1] < 0 && pos1[2] < 0 &&
// ( ( pos2[0] > 0 && pos2[1] < 0 && pos2[2] < 0 ) or
// ( pos2[0] < 0 && pos2[1] > 0 && pos2[2] > 0 ) ) ) or
//