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
b2e6f0ef
Commit
b2e6f0ef
authored
Mar 14, 2014
by
untereiner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
triangular tiling
parent
c052557b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
481 additions
and
67 deletions
+481
-67
Apps/SandBox/tilings.cpp
Apps/SandBox/tilings.cpp
+67
-38
include/Algo/Tiling/Surface/triangular.h
include/Algo/Tiling/Surface/triangular.h
+91
-0
include/Algo/Tiling/Surface/triangular.hpp
include/Algo/Tiling/Surface/triangular.hpp
+321
-29
include/Algo/Tiling/tiling.hpp
include/Algo/Tiling/tiling.hpp
+2
-0
No files found.
Apps/SandBox/tilings.cpp
View file @
b2e6f0ef
...
...
@@ -31,7 +31,8 @@
#include "Utils/GLSLShader.h"
//#include "Algo/Geometry/area.h"
#include "Algo/Geometry/normal.h"
#include "Geometry/matrix.h"
#include "Geometry/transfo.h"
#include "Utils/cgognStream.h"
#include "Utils/chrono.h"
...
...
@@ -104,7 +105,12 @@ void MyQT::squareTiling(int code)
{
std
::
cout
<<
"square grid tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Square
::
Grid
<
PFP
>
g
(
myMap
,
10
,
10
,
true
);
g
.
embedIntoGrid
(
position
,
50
,
50
);
g
.
embedIntoGrid
(
position
,
1.0
,
1.0
,
0.0
);
Geom
::
Matrix44f
trf
;
trf
.
identity
();
Geom
::
translate
<
float
>
(
0.5
,
0.5
,
0.0
,
trf
);
g
.
transform
(
position
,
trf
);
g
.
exportPositions
(
position
,
"grid.bs"
);
...
...
@@ -114,7 +120,13 @@ void MyQT::squareTiling(int code)
{
std
::
cout
<<
"square grid twisted strip tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Square
::
Grid
<
PFP
>
g
(
myMap
,
10
,
10
,
true
);
g
.
embedIntoTwistedStrip
(
position
,
0.3
,
0.8
,
5
);
g
.
embedIntoTwistedStrip
(
position
,
0.2
,
0.7
,
5
);
Geom
::
Matrix44f
trf
;
trf
.
identity
();
Geom
::
translate
<
float
>
(
0.5
,
0.5
,
0.0
,
trf
);
g
.
transform
(
position
,
trf
);
g
.
exportPositions
(
position
,
"gridtwisted.bs"
);
...
...
@@ -124,7 +136,13 @@ void MyQT::squareTiling(int code)
{
std
::
cout
<<
"square grid helicoid tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Square
::
Grid
<
PFP
>
g
(
myMap
,
20
,
20
,
true
);
g
.
embedIntoHelicoid
(
position
,
0.3
,
0.8
,
5.0
,
2.0
);
g
.
embedIntoHelicoid
(
position
,
0.2
,
0.3
,
0.8
,
2.0
);
// Geom::Matrix44f trf;
// trf.identity();
// Geom::translate<float>(0.5,0.5,0.0,trf);
// g.transform(position, trf);
g
.
exportPositions
(
position
,
"gridhelicoid.bs"
);
...
...
@@ -134,7 +152,13 @@ void MyQT::squareTiling(int code)
{
std
::
cout
<<
"square cylinder tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Square
::
Cylinder
<
PFP
>
c
(
myMap
,
20
,
20
);
c
.
embedIntoCylinder
(
position
,
0.5
,
0.7
,
5.0
);
c
.
embedIntoCylinder
(
position
,
0.5
,
0.7
,
1.0
);
Geom
::
Matrix44f
trf
;
trf
.
identity
();
Geom
::
translate
<
float
>
(
0.5
,
0.5
,
0.0
,
trf
);
c
.
transform
(
position
,
trf
);
c
.
exportPositions
(
position
,
"cylinder.bs"
);
...
...
@@ -146,7 +170,7 @@ void MyQT::squareTiling(int code)
Algo
::
Surface
::
Tilings
::
Square
::
Cylinder
<
PFP
>
c
(
myMap
,
20
,
20
);
c
.
triangleBottom
();
c
.
triangleTop
();
c
.
embedIntoCylinder
(
position
,
0.5
,
0.7
,
5
.0
);
c
.
embedIntoCylinder
(
position
,
0.5
,
0.7
,
1
.0
);
break
;
}
...
...
@@ -166,7 +190,7 @@ void MyQT::squareTiling(int code)
Algo
::
Surface
::
Tilings
::
Square
::
Cylinder
<
PFP
>
c
(
myMap
,
20
,
20
);
c
.
triangleTop
();
c
.
triangleBottom
();
c
.
embedIntoCone
(
position
,
0.5
,
5
.0
);
c
.
embedIntoCone
(
position
,
0.5
,
1
.0
);
break
;
}
...
...
@@ -174,7 +198,12 @@ void MyQT::squareTiling(int code)
{
std
::
cout
<<
"square cylinder cone tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Square
::
Cube
<
PFP
>
c
(
myMap
,
20
,
20
,
20
);
c
.
embedIntoCube
(
position
,
5.0
,
5.0
,
5.0
);
c
.
embedIntoCube
(
position
,
1.0
,
1.0
,
1.0
);
Geom
::
Matrix44f
trf
;
trf
.
identity
();
Geom
::
translate
<
float
>
(
0.5
,
0.5
,
0.5
,
trf
);
c
.
transform
(
position
,
trf
);
c
.
exportPositions
(
position
,
"cube.bs"
);
...
...
@@ -184,7 +213,7 @@ void MyQT::squareTiling(int code)
{
std
::
cout
<<
"square tore tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Square
::
Tore
<
PFP
>
c
(
myMap
,
20
,
10
);
c
.
embedIntoTore
(
position
,
5.0
,
2.0
);
c
.
embedIntoTore
(
position
,
0.9
,
0.5
);
c
.
exportPositions
(
position
,
"tore.bs"
);
break
;
...
...
@@ -206,69 +235,69 @@ void MyQT::triangularTiling(int code)
{
case
1
:
{
std
::
cout
<<
"
squar
e grid tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Grid
<
PFP
>
g
(
myMap
,
10
,
10
,
true
);
g
.
embedIntoGrid
(
position
,
50
,
50
);
std
::
cout
<<
"
triangl
e grid tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Grid
<
PFP
>
g
(
myMap
,
10
,
6
,
true
);
g
.
embedIntoGrid
(
position
,
1
,
1
);
break
;
}
case
2
:
{
// std::cout << "squar
e grid twisted strip tiling" << std::endl;
// Algo::Surface::Tilings::Square
::Grid<PFP> g(myMap,10,10,true);
//
g.embedIntoTwistedStrip(position, 0.3, 0.8, 5);
std
::
cout
<<
"triangl
e grid twisted strip tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Grid
<
PFP
>
g
(
myMap
,
10
,
10
,
true
);
g
.
embedIntoTwistedStrip
(
position
,
0.3
,
0.8
,
5
);
break
;
}
case
3
:
{
// std::cout << "squar
e grid helocoid tiling" << std::endl;
// Algo::Surface::Tilings::Square
::Grid<PFP> g(myMap,20,20,true);
//
g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0);
std
::
cout
<<
"triangl
e grid helocoid tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Grid
<
PFP
>
g
(
myMap
,
20
,
20
,
true
);
g
.
embedIntoHelicoid
(
position
,
0.3
,
0.8
,
5.0
,
2.0
);
break
;
}
case
4
:
{
// std::cout << "squar
e cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Square
::Cylinder<PFP> c(myMap,20,20);
//
c.embedIntoCylinder(position,0.5,0.7,5.0);
std
::
cout
<<
"triangl
e cylinder tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Cylinder
<
PFP
>
c
(
myMap
,
20
,
20
);
c
.
embedIntoCylinder
(
position
,
0.5
,
0.7
,
5.0
);
break
;
}
case
5
:
{
// std::cout << "squar
e cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Square
::Cylinder<PFP> c(myMap,20,20);
//
c.triangleBottom();
//
c.triangleTop();
//
c.embedIntoCylinder(position,0.5,0.7,5.0);
std
::
cout
<<
"triangl
e cylinder tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Cylinder
<
PFP
>
c
(
myMap
,
20
,
20
);
c
.
triangleBottom
();
c
.
triangleTop
();
c
.
embedIntoCylinder
(
position
,
0.5
,
0.7
,
5.0
);
break
;
}
case
6
:
{
// std::cout << "squar
e cylinder sphere tiling" << std::endl;
// Algo::Surface::Tilings::Square
::Cylinder<PFP> c(myMap,20,20);
//
c.triangleTop();
//
c.triangleBottom();
//
c.embedIntoSphere(position,0.5);
std
::
cout
<<
"triangl
e cylinder sphere tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Cylinder
<
PFP
>
c
(
myMap
,
20
,
20
);
c
.
triangleTop
();
c
.
triangleBottom
();
c
.
embedIntoSphere
(
position
,
0.5
);
break
;
}
case
7
:
{
// std::cout << "squar
e cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square
::Cylinder<PFP> c(myMap,20,20);
//
c.triangleTop();
//
c.triangleBottom();
//
c.embedIntoCone(position,0.5, 5.0);
std
::
cout
<<
"triangl
e cylinder cone tiling"
<<
std
::
endl
;
Algo
::
Surface
::
Tilings
::
Triangular
::
Cylinder
<
PFP
>
c
(
myMap
,
20
,
20
);
c
.
triangleTop
();
c
.
triangleBottom
();
c
.
embedIntoCone
(
position
,
0.5
,
5.0
);
break
;
}
case
8
:
{
// std::cout << "
squar
e cylinder cone tiling" << std::endl;
// std::cout << "
triangl
e cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cube<PFP> c(myMap,20,20,20);
// c.embedIntoCube(position,5.0,5.0, 5.0);
...
...
@@ -276,7 +305,7 @@ void MyQT::triangularTiling(int code)
}
case
9
:
{
// std::cout << "
squar
e cylinder cone tiling" << std::endl;
// std::cout << "
triangl
e cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
// c.embedIntoTore(position,5.0,2.0);
...
...
include/Algo/Tiling/Surface/triangular.h
View file @
b2e6f0ef
...
...
@@ -111,6 +111,97 @@ protected:
};
/*! \brief The class of regular cylinder square tiling or subdivided sphere (with pole)
*/
template
<
typename
PFP
>
class
Cylinder
:
public
Tiling
<
PFP
>
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
private:
bool
m_top_closed
,
m_bottom_closed
;
bool
m_top_triangulated
,
m_bottom_triangulated
;
Dart
m_topVertDart
,
m_bottomVertDart
;
public:
Cylinder
(
MAP
&
map
,
unsigned
int
n
,
unsigned
int
z
,
bool
close_top
,
bool
close_bottom
)
:
Tiling
<
PFP
>
(
map
,
n
,
-
1
,
z
),
m_top_closed
(
close_top
),
m_bottom_closed
(
close_bottom
),
m_top_triangulated
(
false
),
m_bottom_triangulated
(
false
)
{
cylinder
(
n
,
z
);
}
Cylinder
(
MAP
&
map
,
unsigned
int
n
,
unsigned
int
z
)
:
Tiling
<
PFP
>
(
map
,
n
,
-
1
,
z
),
m_top_closed
(
true
),
m_bottom_closed
(
true
),
m_top_triangulated
(
false
),
m_bottom_triangulated
(
false
)
{
cylinder
(
n
,
z
);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological cylinder
/*! @param position Attribute used to store vertices positions
* @param bottom_radius
* @param top_radius
* @param height
*/
void
embedIntoCylinder
(
VertexAttribute
<
VEC3
>&
position
,
float
bottom_radius
,
float
top_radius
,
float
height
);
//! Embed a topological sphere
/*! @param position Attribute used to store vertices positions
* @param radius
* @param height
*/
void
embedIntoSphere
(
VertexAttribute
<
VEC3
>&
position
,
float
radius
);
//! Embed a topological cone
/*! @param position Attribute used to store vertices positions
* @param radius
* @param height
*/
void
embedIntoCone
(
VertexAttribute
<
VEC3
>&
position
,
float
radius
,
float
height
);
//@}
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
//@{
//! Close the top with a n-sided face
void
closeTop
();
//! Triangulate the top face with triangles fan
void
triangleTop
();
//! Close the bottom with a n-sided face
void
closeBottom
();
//! Triangulate the bottom face with triangles fan
void
triangleBottom
();
protected:
//! Create a subdivided 2D cylinder
/*! @param n nb of squares around circumference
* @param z nb of squares in height
* @param top_closed close the top (with triangles fan)
* @param bottom_closed close the bottom (with triangles fan)
*/
//square -> cylinder -> grid + finish sewing -> open or closed (closeHole) -> triangule face ?
void
cylinder
(
unsigned
int
n
,
unsigned
int
z
);
//@}
};
}
// namespace Triangular
}
// namespace Tilings
...
...
include/Algo/Tiling/Surface/triangular.hpp
View file @
b2e6f0ef
...
...
@@ -44,9 +44,9 @@ template <typename PFP>
void
Grid
<
PFP
>::
grid
(
unsigned
int
x
,
unsigned
int
y
,
bool
close
)
{
// nb vertices
int
nb
=
x
*
y
+
1
;
int
nb
=
(
x
+
1
)
*
(
y
+
1
)
;
// vertice
reservation
// vertices
reservation
this
->
m_tableVertDarts
.
reserve
(
nb
);
// creation of triangles and storing vertices
...
...
@@ -55,62 +55,354 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
for
(
unsigned
int
j
=
1
;
j
<=
x
;
++
j
)
{
Dart
d
=
this
->
m_map
.
newFace
(
3
,
false
);
this
->
m_tableVertDarts
.
push_back
(
d
);
Dart
d2
=
this
->
m_map
.
newFace
(
3
,
false
);
this
->
m_map
.
sewFaces
(
this
->
m_map
.
phi1
(
d
),
this
->
m_map
.
phi_1
(
d2
),
false
);
this
->
m_tableVertDarts
.
push_back
(
d
);
if
(
j
==
x
)
this
->
m_tableVertDarts
.
push_back
(
this
->
m_map
.
phi1
(
d
)
);
this
->
m_tableVertDarts
.
push_back
(
d2
);
}
}
// store last row of vertices
for
(
unsigned
int
i
=
0
;
i
<
x
;
++
i
)
{
this
->
m_tableVertDarts
.
push_back
(
this
->
m_map
.
phi_1
(
this
->
m_tableVertDarts
[(
y
-
1
)
*
(
x
+
1
)
+
i
])
);
}
this
->
m_tableVertDarts
.
push_back
(
this
->
m_map
.
phi_1
(
this
->
m_tableVertDarts
[(
y
-
1
)
*
(
x
+
1
)
+
i
]));
}
this
->
m_tableVertDarts
.
push_back
(
this
->
m_map
.
phi1
(
this
->
m_tableVertDarts
[(
y
-
1
)
*
(
x
+
1
)
+
x
]));
//sewing the
triangles
//sewing pairs of
triangles
for
(
unsigned
int
i
=
0
;
i
<
y
;
++
i
)
{
for
(
unsigned
int
j
=
0
;
j
<
x
;
++
j
)
{
if
(
i
>
0
)
// sew with preceeding row
{
// int pos = i*(x+1)+j;
// Dart d = this->m_tableVertDarts[pos];
// Dart e = this->m_tableVertDarts[pos-(x+1)];
// e = this->m_map.phi_1(e);
// this->m_map.sewFaces(d, e, false);
}
if
(
j
>
0
)
// sew with preceeding column
{
int
pos
=
i
*
(
x
+
1
)
+
j
;
Dart
d
=
this
->
m_tableVertDarts
[
pos
];
d
=
this
->
m_map
.
phi_1
(
d
);
Dart
e
=
this
->
m_tableVertDarts
[
pos
-
1
];
e
=
this
->
m_map
.
phi1
(
e
);
this
->
m_map
.
sewFaces
(
d
,
e
,
false
);
}
if
(
i
>
0
)
// sew with preceeding row
{
int
pos
=
i
*
(
x
+
1
)
+
j
;
Dart
d
=
this
->
m_tableVertDarts
[
pos
];
Dart
e
=
this
->
m_tableVertDarts
[
pos
-
(
x
+
1
)];
e
=
this
->
m_map
.
phi_1
(
this
->
m_map
.
phi2
(
this
->
m_map
.
phi1
(
e
)));
this
->
m_map
.
sewFaces
(
d
,
e
,
false
);
}
if
(
j
>
0
)
// sew with preceeding column
{
int
pos
=
i
*
(
x
+
1
)
+
j
;
Dart
d
=
this
->
m_tableVertDarts
[
pos
];
d
=
this
->
m_map
.
phi_1
(
d
);
Dart
e
=
this
->
m_tableVertDarts
[
pos
-
1
];
e
=
this
->
m_map
.
phi1
(
this
->
m_map
.
phi2
(
this
->
m_map
.
phi1
(
e
)));
this
->
m_map
.
sewFaces
(
d
,
e
,
false
);
}
}
}
if
(
close
)
this
->
m_map
.
closeHole
(
this
->
m_tableVertDarts
[
0
])
;
this
->
m_dart
=
this
->
m_tableVertDarts
[
0
];
}
template
<
typename
PFP
>
void
Grid
<
PFP
>::
embedIntoGrid
(
VertexAttribute
<
VEC3
>&
position
,
float
x
,
float
y
,
float
z
)
{
float
dx
=
x
/
float
(
this
->
m_nx
);
float
dy
=
y
/
float
(
this
->
m_ny
);
float
dx
=
x
/
float
(
this
->
m_nx
);
float
dy
=
y
/
float
(
this
->
m_ny
);
for
(
unsigned
int
i
=
0
;
i
<=
this
->
m_ny
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<=
this
->
m_ny
;
++
i
)
{
for
(
unsigned
int
j
=
0
;
j
<=
this
->
m_nx
;
++
j
)
{
position
[
this
->
m_tableVertDarts
[
i
*
(
this
->
m_nx
+
1
)
+
j
]
]
=
VEC3
(
dx
*
float
(
j
)
+
0.5
f
*
float
(
i
),
dy
*
float
(
i
)
*
sqrtf
(
3.0
f
)
/
2.0
f
,
z
);
{
position
[
this
->
m_tableVertDarts
[
i
*
(
this
->
m_nx
+
1
)
+
j
]
]
=
VEC3
(
dx
*
float
(
j
)
+
dx
*
0.5
f
*
float
(
i
),
dy
*
float
(
i
)
*
sqrtf
(
3.0
f
)
/
2.0
f
,
z
);
}
}
}
template
<
typename
PFP
>
void
Grid
<
PFP
>::
embedIntoTwistedStrip
(
VertexAttribute
<
VEC3
>&
position
,
float
radius_min
,
float
radius_max
,
float
turns
)
{
float
alpha
=
float
(
2.0
*
M_PI
/
this
->
m_ny
);
float
beta
=
turns
/
float
(
this
->
m_ny
);
float
radius
=
(
radius_max
+
radius_min
)
/
2.0
f
;
float
rdiff
=
(
radius_max
-
radius_min
)
/
2.0
f
;
for
(
unsigned
int
i
=
0
;
i
<=
this
->
m_ny
;
++
i
)
{
for
(
unsigned
int
j
=
0
;
j
<=
this
->
m_nx
;
++
j
)
{
float
rw
=
-
rdiff
+
float
(
j
)
*
2.0
f
*
rdiff
/
float
(
this
->
m_nx
);
float
r
=
radius
+
rw
*
cos
(
beta
*
float
(
i
));
VEC3
pos
(
r
*
cos
(
alpha
*
float
(
i
)),
r
*
sin
(
alpha
*
float
(
i
)),
rw
*
sin
(
beta
*
float
(
i
)));
position
[
this
->
m_tableVertDarts
[
i
*
(
this
->
m_nx
+
1
)
+
j
]
]
=
pos
;
}
}
}
template
<
typename
PFP
>
void
Grid
<
PFP
>::
embedIntoHelicoid
(
VertexAttribute
<
VEC3
>&
position
,
float
radius_min
,
float
radius_max
,
float
maxHeight
,
float
nbTurn
,
int
orient
)
{
float
alpha
=
float
(
2.0
*
M_PI
/
this
->
m_nx
)
*
nbTurn
;
float
hS
=
maxHeight
/
this
->
m_nx
;
// float radius = (radius_max + radius_min)/2.0f;
// float rdiff = (radius_max - radius_min)/2.0f;
for
(
unsigned
int
i
=
0
;
i
<=
this
->
m_ny
;
++
i
)
{
for
(
unsigned
int
j
=
0
;
j
<=
this
->
m_nx
;
++
j
)
{
// float r = radius_max + radius_min*cos(beta*float(j));
float
r
,
x
,
y
;
// if(i==1) {
// r = radius_max;
// }
// else {
r
=
radius_min
+
(
radius_max
-
radius_min
)
*
float
(
i
)
/
float
(
this
->
m_ny
);
// }
x
=
orient
*
r
*
sin
(
alpha
*
float
(
j
));
y
=
orient
*
r
*
cos
(
alpha
*
float
(
j
));
VEC3
pos
(
x
,
y
,
j
*
hS
);
Dart
d
=
this
->
m_tableVertDarts
[
i
*
(
this
->
m_nx
+
1
)
+
j
];
position
[
d
]
=
pos
;
}
}
}
/*! Cylinder
*************************************************************************/
template
<
typename
PFP
>
void
Cylinder
<
PFP
>::
cylinder
(
unsigned
int
n
,
unsigned
int
z
)
{
// nb vertices
int
nb
=
(
n
)
*
(
z
+
1
)
+
2
;
// vertices reservation
this
->
m_tableVertDarts
.
reserve
(
nb
);
// creation of triangles and storing vertices
for
(
unsigned
int
i
=
0
;
i
<
z
;
++
i
)
{
for
(
unsigned
int
j
=
0
;
j
<
n
;
++
j
)
{
Dart
d
=
this
->
m_map
.
newFace
(
3
,
false
);
Dart
d2
=
this
->
m_map
.
newFace
(
3
,
false
);
this
->
m_map
.
sewFaces
(
this
->
m_map
.
phi1
(
d
),
this
->
m_map
.
phi_1
(
d2
),
false
);
this
->
m_tableVertDarts
.
push_back
(
d
);
}
}
// store last row of vertices
for
(
unsigned
int
i
=
0
;
i
<
n
;
++
i
)
{
this
->
m_tableVertDarts
.
push_back
(
this
->
m_map
.
phi_1
(
this
->
m_tableVertDarts
[(
z
-
1
)
*
n
+
i
]));
}
//sewing pairs of triangles
for
(
unsigned
int
i
=
0
;
i
<
z
;
++
i
)
{
for
(
unsigned
int
j
=
0
;
j
<
n
;
++
j
)
{
if
(
i
>
0
)
// sew with preceeding row
{
int
pos
=
i
*
n
+
j
;
Dart
d
=
this
->
m_tableVertDarts
[
pos
];
Dart
e
=
this
->
m_tableVertDarts
[
pos
-
n
];
e
=
this
->
m_map
.
phi_1
(
this
->
m_map
.
phi2
(
this
->
m_map
.
phi1
(
e
)));
this
->
m_map
.
sewFaces
(
d
,
e
,
false
);
}
if
(
j
>
0
)
// sew with preceeding column
{
int
pos
=
i
*
n
+
j
;
Dart
d
=
this
->
m_tableVertDarts
[
pos
];
d
=
this
->
m_map
.
phi_1
(
d
);
Dart
e
=
this
->
m_tableVertDarts
[
pos
-
1
];
e
=
this
->
m_map
.
phi1
(
this
->
m_map
.
phi2
(
this
->
m_map
.
phi1
(
e
)));
this
->
m_map
.
sewFaces
(
d
,
e
,
false
);
}
else
{
int
pos
=
i
*
n
;
Dart
d
=
this
->
m_tableVertDarts
[
pos
];
d
=
this
->
m_map
.
phi_1
(
d
);
Dart
e
=
this
->
m_tableVertDarts
[
pos
+
(
n
-
1
)];
e
=
this
->
m_map
.
phi1
(
this
->
m_map
.
phi2
(
this
->
m_map
.
phi1
(
e
)));
this
->
m_map
.
sewFaces
(
d
,
e
,
false
);
}
}
}
if
(
m_top_closed
)
closeTop
();
if
(
m_bottom_closed
)
closeBottom
();
this
->
m_dart
=
this
->
m_tableVertDarts
.
front
();
}
template
<
typename
PFP
>
void
Cylinder
<
PFP
>::
closeTop
()
{
this
->
m_map
.
closeHole
(
this
->
m_map
.
phi1
(
this
->
m_map
.
phi2
(
this
->
m_tableVertDarts
[
this
->
m_nx
*
this
->
m_nz
])));
m_top_closed
=
true
;
}
template
<
typename
PFP
>
void
Cylinder
<
PFP
>::
triangleTop
()
{
if
(
m_top_closed
)
{
Dart
d
=
this
->
m_map
.
phi1
(
this
->
m_map
.
phi2
(
this
->
m_tableVertDarts
[
this
->
m_nx
*
this
->
m_nz
]));
this
->
m_map
.
fillHole
(
d
);
d
=
this
->
m_map
.
phi2
(
d
);
if
(
this
->
m_map
.
faceDegree
(
d
)
>
3
)
{
Algo
::
Surface
::
Modelisation
::
trianguleFace
<
PFP
>
(
this
->
m_map
,
d
);
//this->m_tableVertDarts.push_back(this->m_map.phi_1(d));
m_topVertDart
=
this
->
m_map
.
phi_1
(
d
);
}
m_top_triangulated
=
true
;
}
}
template
<
typename
PFP
>
void
Cylinder
<
PFP
>::
closeBottom
()
{
this
->
m_map
.
closeHole
(
this
->
m_tableVertDarts
[
0
]);
m_bottom_closed
=
true
;
}
template
<
typename
PFP
>
void
Cylinder
<
PFP
>::
triangleBottom
()
{
if
(
m_bottom_closed
)
{
Dart
d
=
this
->
m_tableVertDarts
[
0
];
this
->
m_map
.
fillHole
(
d
);
d
=
this
->
m_map
.
phi2
(
d
);
if
(
this
->
m_map
.
faceDegree
(
d
)
>
3
)
{
Algo
::
Surface
::
Modelisation
::
trianguleFace
<
PFP
>
(
this
->
m_map
,
d
);
//this->m_tableVertDarts.push_back(this->m_map.phi_1(d));
m_bottomVertDart
=
this
->
m_map
.
phi_1
(
d
);
}
m_bottom_triangulated
=
true
;
}
}
template
<
typename
PFP
>
void
Cylinder
<
PFP
>::
embedIntoCylinder
(
VertexAttribute
<
VEC3
>&
position
,
float
bottom_radius
,
float
top_radius
,
float
height
)
{
float
alpha
=
float
(
2.0
*
M_PI
/
this
->
m_nx
);
float
dz
=
height
/
float
(
this
->
m_nz
);
for
(
unsigned
int
i
=
0
;
i
<=
this
->
m_nz
;
++
i
)
{
float
a
=
float
(
i
)
/
float
(
this
->
m_nz
);
float
radius
=
a
*
top_radius
+
(
1.0
f
-
a
)
*
bottom_radius
;
for
(
unsigned
int
j
=
0
;
j
<
this
->
m_nx
;
++
j
)
{
float
x
=
radius
*
cos
(
alpha
*
float
(
j
));
float
y
=
radius
*
sin
(
alpha
*
float
(
j
));
position
[
this
->
m_tableVertDarts
[
i
*
(
this
->
m_nx
)
+
j
]
]
=
VEC3
(
x
,
y
,
-
height
/
2
+
dz
*
float
(
i
));
}
}
//int indexUmbrella = this->m_nx*(this->m_nz+1);