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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
6982c761
Commit
6982c761
authored
Jun 08, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
colorMap + normal cycles + update BoundingBox
parent
86c7b139
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
278 additions
and
46 deletions
+278
-46
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+3
-7
Apps/Examples/viewer.h
Apps/Examples/viewer.h
+1
-1
include/Algo/Geometry/curvature.h
include/Algo/Geometry/curvature.h
+1
-0
include/Algo/Geometry/normal.hpp
include/Algo/Geometry/normal.hpp
+5
-9
include/Geometry/bounding_box.h
include/Geometry/bounding_box.h
+25
-14
include/Geometry/bounding_box.hpp
include/Geometry/bounding_box.hpp
+63
-13
include/Utils/cgognStream.h
include/Utils/cgognStream.h
+1
-2
include/Utils/colorMaps.h
include/Utils/colorMaps.h
+179
-0
No files found.
Apps/Examples/viewer.cpp
View file @
6982c761
...
...
@@ -185,13 +185,9 @@ void Viewer::importMesh(std::string& filename)
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL2
::
LINES
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
gPosObj
=
bb
.
center
()
;
float
tailleX
=
bb
.
size
(
0
)
;
float
tailleY
=
bb
.
size
(
1
)
;
float
tailleZ
=
bb
.
size
(
2
)
;
gWidthObj
=
std
::
max
<
float
>
(
std
::
max
<
float
>
(
tailleX
,
tailleY
),
tailleZ
)
;
normalBaseSize
=
std
::
min
<
float
>
(
std
::
min
<
float
>
(
tailleX
,
tailleY
),
tailleZ
)
/
50.0
f
;
normalBaseSize
=
bb
.
diagSize
()
/
100.0
f
;
vertexBaseSize
=
normalBaseSize
*
2.0
f
;
if
(
!
normal
.
isValid
())
...
...
@@ -202,7 +198,7 @@ void Viewer::importMesh(std::string& filename)
m_positionVBO
->
updateData
(
position
)
;
m_normalVBO
->
updateData
(
normal
)
;
setParamObject
(
gWidthObj
,
gPosObj
.
data
())
;
setParamObject
(
bb
.
maxSize
()
,
gPosObj
.
data
())
;
updateGLMatrices
()
;
}
...
...
Apps/Examples/viewer.h
View file @
6982c761
...
...
@@ -77,8 +77,8 @@ public:
float
shininess
;
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
;
Geom
::
Vec3f
gPosObj
;
float
gWidthObj
;
float
normalBaseSize
;
float
normalScaleFactor
;
float
vertexBaseSize
;
...
...
include/Algo/Geometry/curvature.h
View file @
6982c761
...
...
@@ -107,6 +107,7 @@ template <typename PFP>
void
computeCurvatureVertex_NormalCycles
(
typename
PFP
::
MAP
&
map
,
Dart
dart
,
typename
PFP
::
REAL
radius
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
const
typename
PFP
::
TREAL
&
angles
,
...
...
include/Algo/Geometry/normal.hpp
View file @
6982c761
...
...
@@ -157,19 +157,15 @@ typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart
typename
PFP
::
REAL
c
=
n1
*
n2
;
typename
PFP
::
REAL
a
(
0
)
;
// the following trick is useful for avoiding NaNs (due to floating point errors)
if
(
c
>
0.5
)
a
=
asin
(
s
)
;
if
(
c
>
0.5
)
a
=
asin
(
s
)
;
else
{
if
(
c
<
-
1
)
c
=
-
1
;
if
(
s
>=
0
)
a
=
acos
(
c
)
;
else
a
=
-
acos
(
c
)
;
if
(
c
<
-
1
)
c
=
-
1
;
if
(
s
>=
0
)
a
=
acos
(
c
)
;
else
a
=
-
acos
(
c
)
;
}
if
(
isnan
(
a
))
std
::
cerr
<<
"Warning : computeAngleBetweenNormalsOnEdge returns NaN on edge "
<<
d
<<
"-"
<<
dd
<<
std
::
endl
;
std
::
cerr
<<
"Warning : computeAngleBetweenNormalsOnEdge returns NaN on edge "
<<
d
<<
"-"
<<
dd
<<
std
::
endl
;
return
a
;
}
...
...
include/Geometry/bounding_box.h
View file @
6982c761
...
...
@@ -42,37 +42,47 @@ class BoundingBox
/* CONSTRUCTORS */
/**********************************************/
// must initialize the bounding box with one first point
BoundingBox
(
const
VEC
&
p
);
BoundingBox
()
;
// initialize the bounding box with one first point
BoundingBox
(
const
VEC
&
p
)
;
/**********************************************/
/* ACCESSORS */
/**********************************************/
VEC
&
min
();
VEC
&
min
()
;
const
VEC
&
min
()
const
;
VEC
&
max
()
;
const
VEC
&
max
()
const
;
const
VEC
&
min
()
const
;
typename
VEC
::
DATA_TYPE
size
(
unsigned
int
coord
)
const
;
VEC
&
max
()
;
typename
VEC
::
DATA_TYPE
maxSize
()
const
;
const
VEC
&
max
()
const
;
typename
VEC
::
DATA_TYPE
minSize
()
const
;
typename
VEC
::
DATA_TYPE
size
(
unsigned
int
coord
)
const
;
VEC
diag
()
const
;
VEC
center
()
const
;
typename
VEC
::
DATA_TYPE
diagSize
()
const
;
VEC
center
()
const
;
/**********************************************/
/* FUNCTIONS */
/**********************************************/
// add a point to the bounding box
void
addPoint
(
const
VEC
&
p
);
void
addPoint
(
const
VEC
&
p
)
;
// return true if bb intersects the bounding box
bool
intersects
(
const
BoundingBox
<
VEC
>&
bb
);
bool
intersects
(
const
BoundingBox
<
VEC
>&
bb
)
;
// fusion with the given bounding box
void
fusion
(
const
BoundingBox
<
VEC
>&
bb
);
void
fusion
(
const
BoundingBox
<
VEC
>&
bb
)
;
/**********************************************/
/* STREAM OPERATORS */
...
...
@@ -82,7 +92,6 @@ class BoundingBox
//
// friend std::istream& operator>>(std::istream& in, BoundingBox<VEC>& bb);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
BoundingBox
<
VEC
>&
bb
)
{
out
<<
bb
.
min
()
<<
" "
<<
bb
.
max
()
;
...
...
@@ -96,11 +105,13 @@ class BoundingBox
}
private:
bool
m_initialized
;
VEC
m_pMin
,
m_pMax
;
}
;
}
}
}
// namespace Geom
}
// namespace CGoGN
#include "bounding_box.hpp"
#endif
include/Geometry/bounding_box.hpp
View file @
6982c761
...
...
@@ -29,11 +29,18 @@ namespace Geom
{
template
<
typename
VEC
>
BoundingBox
<
VEC
>::
BoundingBox
(
const
VEC
&
p
)
:
m_pMin
(
p
),
m_pMax
(
p
)
BoundingBox
<
VEC
>::
BoundingBox
()
:
m_initialized
(
false
),
m_pMin
(
0
),
m_pMax
(
0
)
{}
template
<
typename
VEC
>
BoundingBox
<
VEC
>::
BoundingBox
(
const
VEC
&
p
)
:
m_initialized
(
true
),
m_pMin
(
p
),
m_pMax
(
p
)
{}
template
<
typename
VEC
>
VEC
&
BoundingBox
<
VEC
>::
min
()
...
...
@@ -66,6 +73,44 @@ typename VEC::DATA_TYPE BoundingBox<VEC>::size(unsigned int coord) const
return
m_pMax
[
coord
]
-
m_pMin
[
coord
]
;
}
template
<
typename
VEC
>
typename
VEC
::
DATA_TYPE
BoundingBox
<
VEC
>::
maxSize
()
const
{
typename
VEC
::
DATA_TYPE
max
=
m_pMax
[
0
]
-
m_pMin
[
0
]
;
for
(
unsigned
int
i
=
1
;
i
<
m_pMax
.
dimension
();
++
i
)
{
typename
VEC
::
DATA_TYPE
size
=
m_pMax
[
i
]
-
m_pMin
[
i
]
;
if
(
size
>
max
)
max
=
size
;
}
return
max
;
}
template
<
typename
VEC
>
typename
VEC
::
DATA_TYPE
BoundingBox
<
VEC
>::
minSize
()
const
{
typename
VEC
::
DATA_TYPE
min
=
m_pMax
[
0
]
-
m_pMin
[
0
]
;
for
(
unsigned
int
i
=
1
;
i
<
m_pMax
.
dimension
();
++
i
)
{
typename
VEC
::
DATA_TYPE
size
=
m_pMax
[
i
]
-
m_pMin
[
i
]
;
if
(
size
<
min
)
min
=
size
;
}
return
min
;
}
template
<
typename
VEC
>
VEC
BoundingBox
<
VEC
>::
diag
()
const
{
return
m_pMax
-
m_pMin
;
}
template
<
typename
VEC
>
typename
VEC
::
DATA_TYPE
BoundingBox
<
VEC
>::
diagSize
()
const
{
return
(
m_pMax
-
m_pMin
).
norm
()
;
}
template
<
typename
VEC
>
VEC
BoundingBox
<
VEC
>::
center
()
const
{
...
...
@@ -80,12 +125,20 @@ VEC BoundingBox<VEC>::center() const
template
<
typename
VEC
>
void
BoundingBox
<
VEC
>::
addPoint
(
const
VEC
&
p
)
{
for
(
unsigned
int
i
=
0
;
i
<
p
.
dimension
();
++
i
)
if
(
!
m_initialized
)
{
m_pMin
=
p
;
m_pMax
=
p
;
}
else
{
if
(
p
[
i
]
<
m_pMin
[
i
])
m_pMin
[
i
]
=
p
[
i
]
;
if
(
p
[
i
]
>
m_pMax
[
i
])
m_pMax
[
i
]
=
p
[
i
]
;
for
(
unsigned
int
i
=
0
;
i
<
p
.
dimension
();
++
i
)
{
if
(
p
[
i
]
<
m_pMin
[
i
])
m_pMin
[
i
]
=
p
[
i
]
;
if
(
p
[
i
]
>
m_pMax
[
i
])
m_pMax
[
i
]
=
p
[
i
]
;
}
}
}
...
...
@@ -118,7 +171,6 @@ void BoundingBox<VEC>::fusion(const BoundingBox<VEC>& bb)
}
}
//template <typename VEC>
//friend std::ostream& BoundingBox<VEC>::operator<<(std::ostream& out, const BoundingBox<VEC>& bb)
//{
...
...
@@ -133,8 +185,6 @@ void BoundingBox<VEC>::fusion(const BoundingBox<VEC>& bb)
// return in ;
//}
//end namespace
}
}
}
// namespace Geom
}
// namespace CGoGN
include/Utils/cgognStream.h
View file @
6982c761
...
...
@@ -42,7 +42,7 @@ class QTextEdit;
namespace
CGoGN
{
namespace
CGoGNStream
namespace
CGoGNStream
{
/**
...
...
@@ -202,5 +202,4 @@ extern CGoGNStream::Special CGoGNflush;
}
// namespace CGoGN
#endif
/* CGOGNSTREAM_H_ */
include/Utils/colorMaps.h
0 → 100644
View file @
6982c761
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __COLOR_MAPS_H__
#define __COLOR_MAPS_H__
namespace
CGoGN
{
namespace
Utils
{
inline
Geom
::
Vec3f
color_map_blue_green_red
(
float
x
)
{
Geom
::
Vec3f
r
(
0.0
f
)
;
if
(
x
<
0.0
f
)
r
[
2
]
=
1.0
f
;
else
if
(
x
<
0.5
f
)
{
r
[
1
]
=
2.0
f
*
x
;
r
[
2
]
=
1.0
f
-
2.0
f
*
x
;
}
else
if
(
x
<
1.0
f
)
{
r
[
0
]
=
2.0
f
*
x
-
1.0
f
;
r
[
1
]
=
2.0
f
-
2.0
f
*
x
;
}
else
r
[
0
]
=
1.0
f
;
return
r
;
}
inline
Geom
::
Vec3f
color_map_BCGYR
(
float
x
)
{
Geom
::
Vec3f
r
(
0.0
f
)
;
if
(
x
<
0.0
f
)
r
[
2
]
=
1.0
f
;
else
if
(
x
<
0.25
f
)
{
r
[
0
]
=
0.0
f
;
r
[
1
]
=
4.0
f
*
x
;
r
[
2
]
=
1.0
f
;
}
else
if
(
x
<
0.5
f
)
{
r
[
0
]
=
0.0
f
;
r
[
1
]
=
1.0
f
;
r
[
2
]
=
2.0
f
-
4.0
f
*
x
;
}
else
if
(
x
<
0.75
f
)
{
r
[
0
]
=
4.0
f
*
x
-
2.0
f
;
r
[
1
]
=
1.0
f
;
r
[
2
]
=
0.0
f
;
}
else
if
(
x
<
1.0
f
)
{
r
[
0
]
=
1.0
f
;
r
[
1
]
=
4.0
f
-
4.0
f
*
x
;
r
[
2
]
=
0.0
f
;
}
else
r
[
0
]
=
1.0
f
;
return
r
;
}
inline
Geom
::
Vec3f
color_map_blue_white_red
(
float
x
)
{
Geom
::
Vec3f
r
(
0.0
f
);
if
(
x
<
0.0
f
)
r
[
2
]
=
1.0
f
;
else
if
(
x
<
0.5
f
)
{
r
[
0
]
=
2.0
f
*
x
;
r
[
1
]
=
2.0
f
*
x
;
r
[
2
]
=
1.0
f
;
}
else
if
(
x
<
1.0
f
)
{
r
[
0
]
=
1.0
f
;
r
[
1
]
=
2.0
f
-
2.0
f
*
x
;
r
[
2
]
=
2.0
f
-
2.0
f
*
x
;
}
else
r
[
0
]
=
1.0
f
;
return
r
;
}
inline
Geom
::
Vec3f
color_map_cyan_white_red
(
float
x
)
{
Geom
::
Vec3f
r
(
0.0
f
);
if
(
x
<
0.0
f
)
r
[
2
]
=
1.0
f
;
else
if
(
x
<
0.5
f
)
{
r
[
0
]
=
2.0
f
*
x
;
r
[
1
]
=
1.0
f
;
r
[
2
]
=
1.0
f
;
}
else
if
(
x
<
1.0
f
)
{
r
[
0
]
=
1.0
f
;
r
[
1
]
=
2.0
f
-
2.0
f
*
x
;
r
[
2
]
=
2.0
f
-
2.0
f
*
x
;
}
else
r
[
0
]
=
1.0
f
;
return
r
;
}
inline
float
scale_expand_within_0_1
(
float
x
,
int
n
)
{
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
x
=
(
1.0
f
-
cos
(
M_PI
*
x
))
/
2.0
f
;
for
(
int
i
=
-
1
;
i
>=
n
;
i
--
)
x
=
acos
(
1.0
f
-
2.0
f
*
x
)
/
M_PI
;
return
x
;
}
inline
float
scale_expand_towards_1
(
float
x
,
int
n
)
{
for
(
int
i
=
1
;
i
<=
n
;
i
++
)
x
=
sin
(
x
*
M_PI
/
2.0
f
);
for
(
int
i
=
-
1
;
i
>=
n
;
i
--
)
x
=
asin
(
x
)
*
2.0
f
/
M_PI
;
return
x
;
}
inline
float
scale_to_0_1
(
float
x
,
float
min
,
float
max
)
{
return
(
x
-
min
)
/
(
max
-
min
);
}
inline
float
scale_and_clamp_to_0_1
(
float
x
,
float
min
,
float
max
)
{
float
v
=
(
x
-
min
)
/
(
max
-
min
);
return
v
<
0.0
f
?
0.0
f
:
(
v
>
1.0
f
?
1.0
f
:
v
);
}
inline
void
scale_centering_around_0
(
float
&
min
,
float
&
max
)
{
float
new_max
=
std
::
max
(
max
,
-
min
);
min
=
std
::
min
(
min
,
-
max
);
max
=
new_max
;
}
inline
float
scale_to_0_1_around_one_half
(
float
x
,
float
min
,
float
max
)
{
float
ma
=
std
::
max
(
max
,
-
min
);
float
mi
=
std
::
min
(
min
,
-
max
);
return
(
x
-
mi
)
/
(
ma
-
mi
);
}
}
// namespace Utils
}
// namespace CGoGN
#endif
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