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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KennethVanhoey
CGoGN
Commits
941f7fd3
Commit
941f7fd3
authored
Jan 07, 2014
by
Lionel Untereiner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding 2D regular tilings
square tiling -> ok
parent
7825825d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1696 additions
and
0 deletions
+1696
-0
include/Algo/Tiling/hexagonal.h
include/Algo/Tiling/hexagonal.h
+102
-0
include/Algo/Tiling/hexagonal.hpp
include/Algo/Tiling/hexagonal.hpp
+265
-0
include/Algo/Tiling/square.h
include/Algo/Tiling/square.h
+292
-0
include/Algo/Tiling/square.hpp
include/Algo/Tiling/square.hpp
+579
-0
include/Algo/Tiling/tiling.h
include/Algo/Tiling/tiling.h
+83
-0
include/Algo/Tiling/triangular.h
include/Algo/Tiling/triangular.h
+110
-0
include/Algo/Tiling/triangular.hpp
include/Algo/Tiling/triangular.hpp
+265
-0
No files found.
include/Algo/Tiling/hexagonal.h
0 → 100644
View file @
941f7fd3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef _TILINGS_H_
#define _TILINGS_H_
namespace
CGoGN
{
namespace
Algo
{
namespace
Surface
{
namespace
Tilings
{
//square -> grid -> open or closed (closeHole)
//square -> cylinder -> grid + finish sewing -> open or closed (closeHole) -> triangule face
//square -> tore -> cylinder + finish sewing
template
<
typename
PFP
>
class
Square
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
protected:
/**
* Map in which we are working
*/
MAP
&
m_map
;
/**
* Table of vertex darts (one dart per vertex)
* Order depend on Polyhedron kind
*/
std
::
vector
<
Dart
>
m_tableVertDarts
;
public:
Square
(
MAP
&
map
)
:
m_map
(
map
)
{
}
void
grid
(
unsigned
int
x
,
unsigned
int
y
,
bool
closed
);
void
cylinder
(
unsigned
int
n
,
unsigned
int
z
,
bool
top_closed
,
bool
bottom_closed
);
void
tore
(
unsigned
int
n
,
unsigned
int
m
);
void
embedGrid
(
VertexAttribute
<
VEC3
>&
position
,
float
x
,
float
y
,
float
z
=
0.0
f
);
};
//template <typename PFP>
//class Triangular
//{
//};
//template <typename PFP>
//class Hexagonal
//{
//};
//template <typename PFP>
//void triangular(typename PFP::MAP& map, unsigned int rows, unsigned int columns);
}
// namespace Tilings
}
// namespace Surface
}
// namespace Algo
}
// namespace CGoGN
#include "Algo/Modelisation/tilings.hpp"
#endif
include/Algo/Tiling/hexagonal.hpp
0 → 100644
View file @
941f7fd3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace
CGoGN
{
namespace
Algo
{
namespace
Surface
{
namespace
Tilings
{
template
<
typename
PFP
>
void
Square
<
PFP
>::
grid
(
unsigned
int
x
,
unsigned
int
y
,
bool
closed
)
{
// nb vertices
int
nb
=
(
x
+
1
)
*
(
y
+
1
);
// vertice reservation
m_tableVertDarts
.
reserve
(
nb
);
// creation of quads and storing vertices
for
(
unsigned
int
i
=
0
;
i
<
y
;
++
i
)
{
for
(
unsigned
int
j
=
1
;
j
<=
x
;
++
j
)
{
Dart
d
=
m_map
.
newFace
(
4
,
false
);
m_tableVertDarts
.
push_back
(
d
);
if
(
j
==
x
)
m_tableVertDarts
.
push_back
(
m_map
.
phi1
(
d
));
}
}
// store last row of vertices
for
(
unsigned
int
i
=
0
;
i
<
x
;
++
i
)
{
m_tableVertDarts
.
push_back
(
m_map
.
phi_1
(
m_tableVertDarts
[(
y
-
1
)
*
(
x
+
1
)
+
i
])
);
}
m_tableVertDarts
.
push_back
(
m_map
.
phi1
(
m_tableVertDarts
[(
y
-
1
)
*
(
x
+
1
)
+
x
])
);
//sewing the quads
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
=
m_tableVertDarts
[
pos
];
Dart
e
=
m_tableVertDarts
[
pos
-
(
x
+
1
)];
e
=
m_map
.
phi1
(
m_map
.
phi1
(
e
));
m_map
.
sewFaces
(
d
,
e
,
false
);
}
if
(
j
>
0
)
// sew with preceeding column
{
int
pos
=
i
*
(
x
+
1
)
+
j
;
Dart
d
=
m_tableVertDarts
[
pos
];
d
=
m_map
.
phi_1
(
d
);
Dart
e
=
m_tableVertDarts
[
pos
-
1
];
e
=
m_map
.
phi1
(
e
);
m_map
.
sewFaces
(
d
,
e
,
false
);
}
}
}
if
(
closed
)
m_map
.
closeHole
(
m_tableVertDarts
[
0
])
;
}
template
<
typename
PFP
>
void
Square
<
PFP
>::
cylinder
(
unsigned
int
n
,
unsigned
int
z
,
bool
top_closed
,
bool
bottom_closed
)
{
int
nb
=
(
n
)
*
(
z
+
1
)
+
2
;
// vertice reservation
m_tableVertDarts
.
reserve
(
nb
);
// creation of quads and storing vertices
for
(
unsigned
int
i
=
0
;
i
<
z
;
++
i
)
{
for
(
unsigned
int
j
=
0
;
j
<
n
;
++
j
)
{
Dart
d
=
m_map
.
newFace
(
4
,
false
);
m_tableVertDarts
.
push_back
(
d
);
}
}
for
(
unsigned
int
i
=
0
;
i
<
n
;
++
i
)
{
m_tableVertDarts
.
push_back
(
m_map
.
phi_1
(
m_tableVertDarts
[(
z
-
1
)
*
n
+
i
])
);
}
//sewing the quads
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
=
m_tableVertDarts
[
pos
];
Dart
e
=
m_tableVertDarts
[
pos
-
n
];
e
=
m_map
.
phi1
(
m_map
.
phi1
(
e
));
m_map
.
sewFaces
(
d
,
e
,
false
);
}
if
(
j
>
0
)
// sew with preceeding column
{
int
pos
=
i
*
n
+
j
;
Dart
d
=
m_tableVertDarts
[
pos
];
d
=
m_map
.
phi_1
(
d
);
Dart
e
=
m_tableVertDarts
[
pos
-
1
];
e
=
m_map
.
phi1
(
e
);
m_map
.
sewFaces
(
d
,
e
,
false
);
}
else
{
int
pos
=
i
*
n
;
Dart
d
=
m_tableVertDarts
[
pos
];
d
=
m_map
.
phi_1
(
d
);
Dart
e
=
m_tableVertDarts
[
pos
+
(
n
-
1
)];
e
=
m_map
.
phi1
(
e
);
m_map
.
sewFaces
(
d
,
e
,
false
);
}
}
}
if
(
bottom_closed
)
{
Dart
d
=
m_tableVertDarts
[
0
];
if
(
m_map
.
closeHole
(
d
,
false
))
{
d
=
m_map
.
phi2
(
d
);
if
(
m_map
.
faceDegree
(
d
)
>
3
)
{
Modelisation
::
trianguleFace
<
PFP
>
(
m_map
,
d
);
m_tableVertDarts
.
push_back
(
m_map
.
phi_1
(
d
));
}
}
}
else
m_map
.
closeHole
(
m_tableVertDarts
[
0
]);
if
(
top_closed
)
{
Dart
d
=
m_map
.
phi_1
(
m_tableVertDarts
[
n
*
z
]);
if
(
m_map
.
closeHole
(
d
,
false
))
{
d
=
m_map
.
phi2
(
d
);
if
(
m_map
.
faceDegree
(
d
)
>
3
)
{
Modelisation
::
trianguleFace
<
PFP
>
(
m_map
,
d
);
m_tableVertDarts
.
push_back
(
m_map
.
phi_1
(
d
));
}
}
}
else
m_map
.
closeHole
(
m_map
.
phi_1
(
m_tableVertDarts
[
n
*
z
]));
}
template
<
typename
PFP
>
void
Square
<
PFP
>::
tore
(
unsigned
int
n
,
unsigned
int
m
)
{
cylinder_topo
(
n
,
m
,
false
,
false
);
// just finish to sew
for
(
unsigned
int
i
=
0
;
i
<
n
;
++
i
)
{
Dart
d
=
m_tableVertDarts
[
i
];
Dart
e
=
m_tableVertDarts
[(
m
*
n
)
+
i
];
e
=
m_map
.
phi_1
(
e
);
m_map
.
sewFaces
(
d
,
e
);
}
// remove the last n vertex darts that are no more necessary (sewed with n first)
// memory not freed (but will be when destroy the Polyhedron), not important ??
m_tableVertDarts
.
resize
(
m
*
n
);
}
template
<
typename
PFP
>
void
Square
<
PFP
>::
embedGrid
(
VertexAttribute
<
VEC3
>&
position
,
float
x
,
float
y
,
float
z
)
{
float
dx
=
x
/
float
(
m_nx
);
float
dy
=
y
/
float
(
m_ny
);
float
dz
=
z
/
float
(
m_nz
);
unsigned
int
nbs
=
(
m_nx
+
1
)
*
(
m_ny
+
1
);
for
(
unsigned
int
i
=
0
;
i
<=
m_nz
;
++
i
)
{
for
(
unsigned
int
j
=
0
;
j
<=
m_ny
;
++
j
)
{
for
(
unsigned
int
k
=
0
;
k
<=
m_nx
;
++
k
)
{
typename
PFP
::
VEC3
pos
(
-
x
/
2.0
f
+
dx
*
float
(
k
),
-
y
/
2.0
f
+
dy
*
float
(
j
),
-
z
/
2.0
f
+
dz
*
float
(
i
));
Dart
d
=
m_tableVertDarts
[
i
*
nbs
+
j
*
(
m_nx
+
1
)
+
k
];
m_map
.
template
setOrbitEmbeddingOnNewCell
<
VERTEX
>(
d
);
m_positions
[
d
]
=
pos
;
}
}
}
}
//template <typename PFP>
//void triangular(typename PFP::MAP& map, unsigned int rows, unsigned int columns)
//{
// unsigned int nbt = rows * columns;
// std::vector<Dart> m_tableVertDarts;
// m_tableVertDarts.reserve(nbt);
// // creation of triangles around circunference and storing vertices
// for (unsigned int i = 0; i <= nbt; ++i)
// {
// Dart d = map.newFace(3, false);
// m_tableVertDarts.push_back(d);
// }
// for(unsigned int y = 0 ; y < rows-1 ; ++y)
// {
// for(unsigned int x = 0 ; x < columns-1 ; ++x)
// {
// Dart d = m_tableVertDarts[i];
// Dart e = m_tableVertDarts[i+1];
// }
// }
//}
//triangular -> grid -> open or closed (closeHole)
//triangular -> cylinder -> grid + finish sewing -> open or closed (closeHole) -> triangule face
//triangular -> tore -> cylinder + finish sewing
}
// namespace Tilings
}
// namespace Surface
}
// namespace Algo
}
// namespace CGoGN
include/Algo/Tiling/square.h
0 → 100644
View file @
941f7fd3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Algo/Tiling/tiling.h"
#ifndef _TILING_SQUARE_H_
#define _TILING_SQUARE_H_
namespace
CGoGN
{
namespace
Algo
{
namespace
Surface
{
namespace
Tilings
{
namespace
Square
{
/*! \brief The class of regular grid square tiling
*/
template
<
typename
PFP
>
class
Grid
:
public
Tiling
<
PFP
>
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
public:
Grid
(
MAP
&
map
,
unsigned
int
x
,
unsigned
int
y
,
bool
closed
)
:
Tiling
<
PFP
>
(
map
,
x
,
y
,
-
1
)
{
grid
(
x
,
y
,
closed
);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological grid
/*! @param position Attribute used to store vertices positions
* @param x size in X
* @param x size in Y
* @param y position in Z (centered on 0 by default)
*/
void
embedIntoGrid
(
VertexAttribute
<
VEC3
>&
position
,
float
x
,
float
y
,
float
z
=
0.0
f
);
//! Embed a topological grid into a twister open ribbon with turns=PI it is a Moebius strip, needs only to be closed (if model allow it)
/*! @param position Attribute used to store vertices positions
* @param radius_min
* @param radius_max
* @param turns number of turn multiplied by 2*PI
*/
void
embedIntoTwistedStrip
(
VertexAttribute
<
VEC3
>&
position
,
float
radius_min
,
float
radius_max
,
float
turns
);
//! Embed a topological grid into a helicoid
/*! @param position Attribute used to store vertices positions
* @param radius_min
* @param radius_max
* @param maxHeight height to reach
* @param turns number of turn
*/
void
embedIntoHelicoid
(
VertexAttribute
<
VEC3
>&
position
,
float
radius_min
,
float
radius_max
,
float
maxHeight
,
float
nbTurn
,
int
orient
=
1
);
//@}
protected:
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
//@{
//! Create a 2D grid
/*! @param x nb of squares in x
* @param y nb of squares in y
* @param closed close the boundary face of the 2D grid
*/
void
grid
(
unsigned
int
x
,
unsigned
int
y
,
bool
closed
);
//@}
};
/*! \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
;
public:
Cylinder
(
MAP
&
map
,
unsigned
int
n
,
unsigned
int
z
)
:
Tiling
<
PFP
>
(
map
,
n
,
-
1
,
z
),
m_top_closed
(
false
),
m_bottom_closed
(
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
();
//! Create a subdivided 2D cone
/*! @param n nb of squares around circumference (must be >= 3)
* @param z nb of squares in height (must be >= 1)
* @param bottom_closed close the bottom (with triangles fan)
*/
void
cone
(
unsigned
int
x
,
unsigned
int
y
);
private:
//! 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
);
//@}
};
/*! \brief The class of regular cube square tiling
*/
template
<
typename
PFP
>
class
Cube
:
public
Cylinder
<
PFP
>
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
public:
Cube
(
MAP
&
map
,
unsigned
int
x
,
unsigned
int
y
,
unsigned
int
z
)
:
Tiling
<
PFP
>
(
map
)
{
cube
(
x
,
y
,
z
);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological cube
/*! @param position Attribute used to store vertices positions
* @param x
* @param y
* @param z
*/
void
embedIntoCube
(
VertexAttribute
<
VEC3
>&
position
,
float
x
,
float
y
,
float
z
);
//@}
private:
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
//@{
//! Create a subdivided 2D cube
/*! @param x nb of squares in x
* @param y nb of squares in y
* @param z nb of squares un z
*/
void
cube
(
unsigned
int
x
,
unsigned
int
y
,
unsigned
int
z
);
//@}
};
/*! \brief The class of regular tore square tiling
*/
template
<
typename
PFP
>
class
Tore
:
public
Cylinder
<
PFP
>
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
public:
Tore
(
MAP
&
map
,
unsigned
int
n
,
unsigned
int
m
)
:
Tiling
<
PFP
>
(
map
)
{
tore
(
n
,
m
);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological tore
/*! @param position Attribute used to store vertices positions
* @param big_radius
* @param small_radius
*/
void
embedIntoTore
(
VertexAttribute
<
VEC3
>&
position
,
float
big_radius
,
float
small_radius
);
//@}
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
//@{
private:
//! Create a subdivided 2D tore
/*! @param n nb of squares around big circumference
* @param m nb of squares around small circumference
*/
//square -> tore -> cylinder + finish sewing
void
tore
(
unsigned
int
n