Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
KennethVanhoey
CGoGN
Commits
94bef722
Commit
94bef722
authored
Jan 05, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of cgogn:~cgogn/CGoGN
parents
6680d88d
7ae912f0
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
369 additions
and
350 deletions
+369
-350
include/Algo/Modelisation/polyhedron.hpp
include/Algo/Modelisation/polyhedron.hpp
+8
-7
include/Algo/MovingObjects/particle_cell_2DandHalf.h
include/Algo/MovingObjects/particle_cell_2DandHalf.h
+18
-11
include/Algo/MovingObjects/particle_cell_2DandHalf.hpp
include/Algo/MovingObjects/particle_cell_2DandHalf.hpp
+60
-41
include/Geometry/frame.h
include/Geometry/frame.h
+10
-8
include/Geometry/intersection.h
include/Geometry/intersection.h
+1
-7
include/Geometry/intersection.hpp
include/Geometry/intersection.hpp
+77
-87
include/Geometry/orientation.h
include/Geometry/orientation.h
+2
-2
include/Geometry/transfo.h
include/Geometry/transfo.h
+4
-1
include/Geometry/transfo.hpp
include/Geometry/transfo.hpp
+185
-182
src/Topology/map/map2.cpp
src/Topology/map/map2.cpp
+4
-4
No files found.
include/Algo/Modelisation/polyhedron.hpp
View file @
94bef722
...
@@ -431,7 +431,7 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo
...
@@ -431,7 +431,7 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo
if (top_closed)
if (top_closed)
{
{
Dart d = m_map.phi_1(m_tableVertDarts[n*z]);
Dart d = m_map.phi_1(m_tableVertDarts[n*z]);
if
(
m_map
.
closeHole
(
d
,
tru
e
))
if(m_map.closeHole(d,
fals
e))
{
{
d = m_map.phi2(d);
d = m_map.phi2(d);
if(m_map.faceDegree(d) > 3)
if(m_map.faceDegree(d) > 3)
...
@@ -597,7 +597,7 @@ Dart Polyhedron<PFP>::cube_topo(unsigned int x, unsigned int y, unsigned int z)
...
@@ -597,7 +597,7 @@ Dart Polyhedron<PFP>::cube_topo(unsigned int x, unsigned int y, unsigned int z)
{
{
if (m_kind != NONE) return m_dart;
if (m_kind != NONE) return m_dart;
m_dart
=
cylinder_topo
(
2
*
(
x
+
y
),
z
,
false
,
false
);
m_dart = cylinder_topo(2*(x+y),
z, false,
false);
m_kind = CUBE;
m_kind = CUBE;
m_nx = x;
m_nx = x;
m_ny = y;
m_ny = y;
...
@@ -697,17 +697,17 @@ Dart Polyhedron<PFP>::tore_topo(unsigned int m, unsigned int n)
...
@@ -697,17 +697,17 @@ Dart Polyhedron<PFP>::tore_topo(unsigned int m, unsigned int n)
if (m_kind != NONE) return m_dart;
if (m_kind != NONE) return m_dart;
m_dart = cylinder_topo(n, m, false, false);
m_dart = cylinder_topo(n, m, false, false);
m_nx
=
n
;
m_nx
=
n;
m_ny
=
m
;
m_ny
=
m;
m_kind = TORE;
m_kind = TORE;
// just
e
finish to sew
// just finish to sew
for(unsigned int i = 0; i < n; ++i)
for(unsigned int i = 0; i < n; ++i)
{
{
Dart d = m_tableVertDarts[i];
Dart d = m_tableVertDarts[i];
Dart e = m_tableVertDarts[(m*n)+i];
Dart e = m_tableVertDarts[(m*n)+i];
e = m_map.phi_1(e);
e = m_map.phi_1(e);
m_map
.
sewFaces
(
d
,
e
,
true
);
m_map.sewFaces(d, e);
}
}
// remove the last n vertex darts that are no more necessary (sewed with n first)
// remove the last n vertex darts that are no more necessary (sewed with n first)
...
@@ -722,7 +722,8 @@ void Polyhedron<PFP>::embedGrid(float x, float y, float z)
...
@@ -722,7 +722,8 @@ void Polyhedron<PFP>::embedGrid(float x, float y, float z)
{
{
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::VEC3 VEC3 ;
if
(
m_kind
!=
GRID
)
{
if (m_kind != GRID)
{
CGoGNerr << "Warning try to embedGrid something that is not a grid"<<CGoGNendl;
CGoGNerr << "Warning try to embedGrid something that is not a grid"<<CGoGNendl;
return;
return;
}
}
...
...
include/Algo/MovingObjects/particle_cell_2DandHalf.h
View file @
94bef722
#ifndef PARTCELL_H
#ifndef PARTCELL_H
#define PARTCELL_H
#define PARTCELL_H
#include "particle_base.h"
#include "
Algo/MovingObjects/
particle_base.h"
#include "Algo/Geometry/inclusion.h"
#include "Algo/Geometry/inclusion.h"
#include "Algo/Geometry/plane.h"
#include "Geometry/intersection.h"
#include "Geometry/intersection.h"
#include "Geometry/orientation.h"
#include "Geometry/orientation.h"
#include <iostream>
#include <iostream>
...
@@ -20,7 +21,8 @@ namespace Algo
...
@@ -20,7 +21,8 @@ namespace Algo
namespace
MovingObjects
namespace
MovingObjects
{
{
enum
{
enum
{
NO_CROSS
,
NO_CROSS
,
CROSS_EDGE
,
CROSS_EDGE
,
CROSS_OTHER
CROSS_OTHER
...
@@ -45,15 +47,19 @@ public :
...
@@ -45,15 +47,19 @@ public :
unsigned
int
crossCell
;
unsigned
int
crossCell
;
float
distance
;
ParticleCell2DAndHalf
(
Map
&
map
)
:
m
(
map
)
ParticleCell2DAndHalf
(
Map
&
map
)
:
m
(
map
)
{}
{}
ParticleCell2DAndHalf
(
Map
&
map
,
Dart
belonging_cell
,
VEC3
pos
,
const
TAB_POS
&
tabPos
)
:
ParticleCell2DAndHalf
(
Map
&
map
,
Dart
belonging_cell
,
VEC3
pos
,
const
TAB_POS
&
tabPos
)
:
ParticleBase
(
pos
),
m
(
map
),
m_positions
(
tabPos
),
d
(
belonging_cell
),
lastCrossed
(
belonging_cell
),
state
(
FACE
),
crossCell
(
NO_CROSS
)
ParticleBase
(
pos
),
m
(
map
),
m_positions
(
tabPos
),
d
(
belonging_cell
),
lastCrossed
(
belonging_cell
),
state
(
FACE
),
crossCell
(
NO_CROSS
)
,
distance
(
0
)
{}
{}
Dart
getCell
()
{
return
d
;
}
Dart
getCell
()
{
return
d
;
}
float
getDistance
()
{
return
distance
;
}
Geom
::
Orientation3D
getOrientationEdge
(
const
VEC3
&
point
,
Dart
d
);
Geom
::
Orientation3D
getOrientationEdge
(
const
VEC3
&
point
,
Dart
d
);
void
display
();
void
display
();
...
@@ -77,28 +83,29 @@ public :
...
@@ -77,28 +83,29 @@ public :
void
move
(
const
VEC3
&
newCurrent
)
void
move
(
const
VEC3
&
newCurrent
)
{
{
distance
=
0
;
crossCell
=
NO_CROSS
;
crossCell
=
NO_CROSS
;
if
(
!
Geom
::
arePointsEquals
(
newCurrent
,
m_position
))
if
(
!
Geom
::
arePointsEquals
(
newCurrent
,
m_position
))
{
{
switch
(
state
)
{
switch
(
state
)
{
case
VERTEX
:
vertexState
(
newCurrent
);
break
;
case
VERTEX
:
vertexState
(
newCurrent
);
break
;
case
EDGE
:
edgeState
(
newCurrent
);
break
;
case
EDGE
:
edgeState
(
newCurrent
);
break
;
case
FACE
:
faceState
(
newCurrent
);
break
;
case
FACE
:
faceState
(
newCurrent
);
break
;
}
}
display
();
//
display();
}
}
else
else
m_position
=
newCurrent
;
m_position
=
newCurrent
;
}
}
};
};
#include "particle_cell_2DandHalf.hpp"
}
// namespace MovingObjects
}
}
// namespace Algo
}
}
// namespace CGoGN
}
#include "Algo/MovingObjects/particle_cell_2DandHalf.hpp"
#endif
#endif
include/Algo/MovingObjects/particle_cell_2DandHalf.hpp
View file @
94bef722
//#define DEBUG
//#define DEBUG
#include "Geometry/frame.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
MovingObjects
{
template
<
typename
PFP
>
template
<
typename
PFP
>
void
ParticleCell2DAndHalf
<
PFP
>::
display
()
void
ParticleCell2DAndHalf
<
PFP
>::
display
()
{
{
...
@@ -11,50 +22,50 @@ void ParticleCell2DAndHalf<PFP>::display()
...
@@ -11,50 +22,50 @@ void ParticleCell2DAndHalf<PFP>::display()
template
<
typename
PFP
>
template
<
typename
PFP
>
typename
PFP
::
VEC3
ParticleCell2DAndHalf
<
PFP
>::
pointInFace
(
Dart
d
)
typename
PFP
::
VEC3
ParticleCell2DAndHalf
<
PFP
>::
pointInFace
(
Dart
d
)
{
{
const
VEC3
&
p1
(
m_positions
[
d
]);
const
VEC3
&
p1
(
m_positions
[
d
])
;
Dart
dd
=
m
.
phi1
(
d
);
Dart
dd
=
m
.
phi1
(
d
)
;
const
VEC3
&
p2
(
m_positions
[
dd
]);
const
VEC3
&
p2
(
m_positions
[
dd
])
;
dd
=
m
.
phi1
(
dd
);
dd
=
m
.
phi1
(
dd
)
;
VEC3
&
p3
(
m_positions
[
dd
]);
VEC3
&
p3
(
m_positions
[
dd
])
;
VEC3
v1
(
p2
-
p1
);
VEC3
v1
(
p2
-
p1
)
;
while
((
v1
^
VEC3
(
p3
-
p1
)).
norm2
()
==
0.0
f
)
while
((
v1
^
VEC3
(
p3
-
p1
)).
norm2
()
==
0.0
f
)
{
{
dd
=
m
.
phi1
(
dd
);
dd
=
m
.
phi1
(
dd
)
;
p3
=
m_positions
[
dd
];
p3
=
m_positions
[
dd
]
;
}
}
CGoGNout
<<
"pointInFace "
<<
(
p1
+
p3
)
*
0.5
f
<<
CGoGNendl
;
CGoGNout
<<
"pointInFace "
<<
(
p1
+
p3
)
*
0.5
f
<<
CGoGNendl
;
return
(
p1
+
p3
)
*
0.5
f
;
return
(
p1
+
p3
)
*
0.5
f
;
}
}
template
<
typename
PFP
>
template
<
typename
PFP
>
Geom
::
Orientation3D
ParticleCell2DAndHalf
<
PFP
>::
getOrientationEdge
(
const
VEC3
&
point
,
Dart
d
)
Geom
::
Orientation3D
ParticleCell2DAndHalf
<
PFP
>::
getOrientationEdge
(
const
VEC3
&
point
,
Dart
d
)
{
{
const
VEC3
&
endPoint
=
m_positions
[
m
.
phi
2
(
d
)];
const
VEC3
&
endPoint
=
m_positions
[
m
.
phi
1
(
d
)];
const
VEC3
&
vertexPoint
=
m_positions
[
d
];
const
VEC3
&
vertexPoint
=
m_positions
[
d
];
const
VEC3
&
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
const
VEC3
&
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
//orientation relative to the plane orthogonal to the face going through the edge
//orientation relative to the plane orthogonal to the face going through the edge
return
Geom
::
testOrientation3D
(
point
,
vertexPoint
,
endPoint
,
vertexPoint
+
n1
);
return
Geom
::
testOrientation3D
(
point
,
vertexPoint
,
endPoint
,
vertexPoint
+
n1
);
}
}
template
<
typename
PFP
>
template
<
typename
PFP
>
typename
PFP
::
VEC3
ParticleCell2DAndHalf
<
PFP
>::
intersectLineEdge
(
const
VEC3
&
pA
,
const
VEC3
&
pB
,
Dart
d
)
typename
PFP
::
VEC3
ParticleCell2DAndHalf
<
PFP
>::
intersectLineEdge
(
const
VEC3
&
pA
,
const
VEC3
&
pB
,
Dart
d
)
{
{
const
VEC3
&
q1
=
m_positions
[
d
];
const
VEC3
&
q1
=
m_positions
[
d
];
const
VEC3
&
q2
=
m_positions
[
m
.
phi
2
(
d
)];
const
VEC3
&
q2
=
m_positions
[
m
.
phi
1
(
d
)];
VEC3
Inter
;
VEC3
Inter
;
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
VEC3
n
=
(
q2
-
q1
)
^
n1
;
VEC3
n
=
(
q2
-
q1
)
^
n1
;
Geom
::
intersectionLinePlane
(
pA
,
pB
-
pA
,
q1
,
n
,
Inter
);
Geom
::
intersectionLinePlane
(
pA
,
pB
-
pA
,
q1
,
n
,
Inter
)
;
Geom
::
Plane3D
<
float
>
pl
=
Algo
::
Geometry
::
facePlane
<
PFP
>
(
m
,
d
,
m_positions
);
Geom
::
Plane3D
<
float
>
pl
=
Algo
::
Geometry
::
facePlane
<
PFP
>
(
m
,
d
,
m_positions
);
pl
.
project
(
Inter
);
pl
.
project
(
Inter
);
return
Inter
;
return
Inter
;
...
@@ -65,7 +76,7 @@ Geom::Orientation3D ParticleCell2DAndHalf<PFP>::getOrientationFace(VEC3 point, V
...
@@ -65,7 +76,7 @@ Geom::Orientation3D ParticleCell2DAndHalf<PFP>::getOrientationFace(VEC3 point, V
{
{
const
VEC3
&
dPoint
=
m_positions
[
d
];
const
VEC3
&
dPoint
=
m_positions
[
d
];
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
return
Geom
::
testOrientation3D
(
point
,
sourcePoint
,
dPoint
+
n1
,
dPoint
);
return
Geom
::
testOrientation3D
(
point
,
sourcePoint
,
dPoint
+
n1
,
dPoint
);
}
}
...
@@ -163,32 +174,31 @@ void ParticleCell2DAndHalf<PFP>::edgeState(VEC3 current, Geom::Orientation3D sid
...
@@ -163,32 +174,31 @@ void ParticleCell2DAndHalf<PFP>::edgeState(VEC3 current, Geom::Orientation3D sid
switch
(
sideOfEdge
)
switch
(
sideOfEdge
)
{
{
case
Geom
::
UNDER
:
case
Geom
::
UNDER
:
{
d
=
m
.
phi1
(
d
);
d
=
m
.
phi1
(
d
);
faceState
(
current
);
faceState
(
current
);
return
;
return
;
}
case
Geom
::
OVER
:
case
Geom
::
OVER
:
{
{
//transform the displacement into the new entered face
//transform the displacement into the new entered face
VEC3
displ
=
current
-
m_position
;
VEC3
displ
=
current
-
m_position
;
VEC3
edge
=
Algo
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
m
,
m
.
phi2
(
d
),
m_positions
);
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
VEC3
n2
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
m
.
phi2
(
d
),
m_positions
);
float
angle
=
acos
(
n1
*
n2
);
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
VEC3
n2
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
m
.
phi2
(
d
),
m_positions
);
VEC3
axis
=
n1
^
n2
;
Geom
::
Matrix
<
4
,
4
,
float
>
mRot
;
float
angle
=
Geom
::
angle
(
n1
,
n2
)
;
mRot
.
identity
();
Geom
::
rotate
(
edge
[
0
],
edge
[
1
],
edge
[
2
],
angle
,
mRot
);
displ
=
Geom
::
rotate
(
axis
,
angle
,
displ
)
;
current
=
m_position
+
displ
;
displ
=
Geom
::
transform
(
displ
,
mRot
);
current
=
m_position
+
displ
;
d
=
m
.
phi1
(
m
.
phi2
(
d
));
d
=
m
.
phi1
(
m
.
phi2
(
d
));
faceState
(
current
);
faceState
(
current
);
return
;
return
;
}
}
default
:
default
:
state
=
EDGE
;
state
=
EDGE
;
}
}
...
@@ -221,14 +231,14 @@ void ParticleCell2DAndHalf<PFP>::faceState(VEC3 current)
...
@@ -221,14 +231,14 @@ void ParticleCell2DAndHalf<PFP>::faceState(VEC3 current)
assert
(
std
::
isfinite
(
current
[
0
])
&&
std
::
isfinite
(
current
[
1
])
&&
std
::
isfinite
(
current
[
2
]));
assert
(
std
::
isfinite
(
current
[
0
])
&&
std
::
isfinite
(
current
[
1
])
&&
std
::
isfinite
(
current
[
2
]));
// assert(Algo::Geometry::isPointInConvexFace2D<PFP>(m,d,m_positions,m_position,true));
// assert(Algo::Geometry::isPointInConvexFace2D<PFP>(m,d,m_positions,m_position,true));
//project current within plane
//project current within
face
plane
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
VEC3
n1
=
Algo
::
Geometry
::
faceNormal
<
PFP
>
(
m
,
d
,
m_positions
);
VEC3
n2
=
current
-
m_position
;
VEC3
n2
=
current
-
m_position
;
n1
.
normalize
();
//
n1.normalize();
VEC3
n3
=
n1
^
n2
;
VEC3
n3
=
n1
^
n2
;
n3
.
normalize
();
n3
.
normalize
();
VEC3
n4
=
n3
^
n1
;
VEC3
n4
=
n3
^
n1
;
current
=
m_position
+
(
n2
*
n4
)
*
n4
;
current
=
m_position
+
(
n2
*
n4
)
*
n4
;
//track new position within map
//track new position within map
Dart
dd
=
d
;
Dart
dd
=
d
;
...
@@ -326,8 +336,9 @@ void ParticleCell2DAndHalf<PFP>::faceState(VEC3 current)
...
@@ -326,8 +336,9 @@ void ParticleCell2DAndHalf<PFP>::faceState(VEC3 current)
switch
(
getOrientationEdge
(
current
,
d
))
switch
(
getOrientationEdge
(
current
,
d
))
{
{
case
Geom
::
UNDER
:
case
Geom
::
UNDER
:
distance
+=
(
current
-
m_position
).
norm
();
m_position
=
current
;
m_position
=
current
;
state
=
FACE
;
;
state
=
FACE
;
break
;
break
;
default
:
default
:
if
(
wsoe
==
Geom
::
ON
)
if
(
wsoe
==
Geom
::
ON
)
...
@@ -338,14 +349,22 @@ void ParticleCell2DAndHalf<PFP>::faceState(VEC3 current)
...
@@ -338,14 +349,22 @@ void ParticleCell2DAndHalf<PFP>::faceState(VEC3 current)
//
//
// vertexState(current);
// vertexState(current);
}
}
//
else
else
{
{
// CGoGNout << "wsoe : " << wsoe << CGoGNendl;
// CGoGNout << "wsoe : " << wsoe << CGoGNendl;
// CGoGNout << "current " << current << " " << m_position << CGoGNendl;
// CGoGNout << "current " << current << " " << m_position << CGoGNendl;
// CGoGNout << "d " << d << "d1 " << m_positions[d] << " d2 " << m_positions[m.phi2(d)] << CGoGNendl;
// CGoGNout << "d " << d << "d1 " << m_positions[d] << " d2 " << m_positions[m.phi2(d)] << CGoGNendl;
m_position
=
intersectLineEdge
(
current
,
m_position
,
d
);
VEC3
isect
=
intersectLineEdge
(
current
,
m_position
,
d
);
distance
+=
(
isect
-
m_position
).
norm
();
m_position
=
isect
;
// CGoGNout << " inter : " << m_position << CGoGNendl;
// CGoGNout << " inter : " << m_position << CGoGNendl;
edgeState
(
current
,
Geom
::
OVER
);
edgeState
(
current
,
Geom
::
OVER
);
}
}
}
}
}
}
}
// namespace MovingObjects
}
// namespace Algo
}
// namespace CGoGN
include/Geometry/frame.h
View file @
94bef722
...
@@ -22,14 +22,16 @@
...
@@ -22,14 +22,16 @@
* *
* *
*******************************************************************************/
*******************************************************************************/
#ifndef
LOCAL
FRAME_H_
#ifndef
_
FRAME_H_
#define
LOCAL
FRAME_H_
#define
_
FRAME_H_
#include <cmath>
#include <cmath>
namespace
CGoGN
{
namespace
CGoGN
{
namespace
Geom
{
namespace
Geom
{
/**
/**
* Util for rotation of a 3D point (or vector) around a given line (going through the origin) and of a given angle
* Util for rotation of a 3D point (or vector) around a given line (going through the origin) and of a given angle
...
@@ -213,10 +215,10 @@ private : // private constants
...
@@ -213,10 +215,10 @@ private : // private constants
}
;
}
;
}
// Geom
}
//
namespace
Geom
}
// CGoGN
}
//
namespace
CGoGN
#include "frame.hpp"
#include "
Geometry/
frame.hpp"
#endif
/*
LOCAL
FRAME_H_ */
#endif
/*
_
FRAME_H_ */
include/Geometry/intersection.h
View file @
94bef722
...
@@ -43,7 +43,6 @@ enum Intersection
...
@@ -43,7 +43,6 @@ enum Intersection
FACE_INTERSECTION
=
3
FACE_INTERSECTION
=
3
}
;
}
;
/**
/**
* test the intersection between a line and a triangle
* test the intersection between a line and a triangle
* @param P a point on the line
* @param P a point on the line
...
@@ -54,9 +53,7 @@ enum Intersection
...
@@ -54,9 +53,7 @@ enum Intersection
* @return the intersection ( FACE_INTERSECTION = OK, EDGE_INTERSECTION = line inside of plane)
* @return the intersection ( FACE_INTERSECTION = OK, EDGE_INTERSECTION = line inside of plane)
*/
*/
template
<
typename
VEC3
>
template
<
typename
VEC3
>
Intersection
intersectionLinePlane
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
PlaneP
,
const
VEC3
&
NormP
,
VEC3
&
Inter
)
;
Intersection
intersectionLinePlane
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
PlaneP
,
const
VEC3
&
NormP
,
VEC3
&
Inter
)
;
/**
/**
* test the intersection between a ray and a triangle (optimized version with triple product
* test the intersection between a ray and a triangle (optimized version with triple product
...
@@ -84,8 +81,6 @@ Intersection intersectionRayTriangle(const VEC3& P, const VEC3& Dir, const VEC3&
...
@@ -84,8 +81,6 @@ Intersection intersectionRayTriangle(const VEC3& P, const VEC3& Dir, const VEC3&
template
<
typename
VEC3
>
template
<
typename
VEC3
>
Intersection
intersectionRayTriangleOpt
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
Ta
,
const
VEC3
&
Tb
,
const
VEC3
&
Tc
,
VEC3
&
Inter
);
Intersection
intersectionRayTriangleOpt
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
Ta
,
const
VEC3
&
Tb
,
const
VEC3
&
Tc
,
VEC3
&
Inter
);
/**
/**
* test the intersection between a ray and a triangle (optimized version with triple product
* test the intersection between a ray and a triangle (optimized version with triple product
* @param P a point on the line
* @param P a point on the line
...
@@ -98,7 +93,6 @@ Intersection intersectionRayTriangleOpt(const VEC3& P, const VEC3& Dir, const VE
...
@@ -98,7 +93,6 @@ Intersection intersectionRayTriangleOpt(const VEC3& P, const VEC3& Dir, const VE
template
<
typename
VEC3
>
template
<
typename
VEC3
>
Intersection
intersectionRayTriangleOpt
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
Ta
,
const
VEC3
&
Tb
,
const
VEC3
&
Tc
);
Intersection
intersectionRayTriangleOpt
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
Ta
,
const
VEC3
&
Tb
,
const
VEC3
&
Tc
);
/**
/**
* test the intersection between a ray and a triangle, but test only face intersection and
* test the intersection between a ray and a triangle, but test only face intersection and
* @param P a point on the line
* @param P a point on the line
...
...
include/Geometry/intersection.hpp
View file @
94bef722
...
@@ -28,32 +28,30 @@ namespace CGoGN
...
@@ -28,32 +28,30 @@ namespace CGoGN
namespace
Geom
namespace
Geom
{
{
template
<
typename
VEC3
>
template
<
typename
VEC3
>
Intersection
intersectionLinePlane
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
PlaneP
,
const
VEC3
&
NormP
,
VEC3
&
Inter
)
Intersection
intersectionLinePlane
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
PlaneP
,
const
VEC3
&
NormP
,
VEC3
&
Inter
)
{
{
float
b
=
NormP
*
Dir
;
float
b
=
NormP
*
Dir
;
#define PRECISION 1e-20
#define PRECISION 1e-20
if
(
fabs
(
b
)
<
PRECISION
)
//ray parallel to triangle
if
(
fabs
(
b
)
<
PRECISION
)
//ray parallel to triangle
{
{
VEC3
v
=
PlaneP
-
P
;
VEC3
v
=
PlaneP
-
P
;
float
c
=
NormP
*
v
;
float
c
=
NormP
*
v
;
if
(
fabs
(
c
)
<
PRECISION
)
if
(
fabs
(
c
)
<
PRECISION
)
return
EDGE_INTERSECTION
;
return
EDGE_INTERSECTION
;
return
NO_INTERSECTION
;
return
NO_INTERSECTION
;
}
}
#undef PRECISION
#undef PRECISION
float
a
=
NormP
*
(
PlaneP
-
P
);
float
a
=
NormP
*
(
PlaneP
-
P
)
;
Inter
=
P
+
(
a
/
b
)
*
Dir
;
Inter
=
P
+
(
a
/
b
)
*
Dir
;
return
FACE_INTERSECTION
;
return
FACE_INTERSECTION
;
}
}
template
<
typename
VEC3
>
template
<
typename
VEC3
>
Intersection
intersectionRayTriangleOpt
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
Ta
,
const
VEC3
&
Tb
,
const
VEC3
&
Tc
,
VEC3
&
Inter
)
Intersection
intersectionRayTriangleOpt
(
const
VEC3
&
P
,
const
VEC3
&
Dir
,
const
VEC3
&
Ta
,
const
VEC3
&
Tb
,
const
VEC3
&
Tc
,
VEC3
&
Inter
)
{