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
a5ee3a10
Commit
a5ee3a10
authored
Apr 24, 2014
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Algo/Topo/basic.h
parent
b3019bf3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
152 additions
and
0 deletions
+152
-0
include/Algo/Topo/basic.h
include/Algo/Topo/basic.h
+152
-0
No files found.
include/Algo/Topo/basic.h
0 → 100644
View file @
a5ee3a10
/*******************************************************************************
* 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 __ALGO_TOPO_BASIC__
#define __ALGO_TOPO_BASIC__
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/traversor/traversorCell.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
Topo
{
template
<
unsigned
int
ORBIT
,
typename
MAP
>
bool
foreach_orbit
(
const
MAP
&
map
,
FunctorType
&
fonct
,
unsigned
int
thread
=
0
)
{
TraversorCell
<
MAP
,
ORBIT
>
trav
(
map
,
true
,
thread
);
bool
found
=
false
;
for
(
Dart
d
=
trav
.
begin
();
!
found
&&
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
if
((
fonct
)(
d
))
found
=
true
;
}
return
found
;
}
template
<
unsigned
int
ORBIT
,
typename
MAP
>
unsigned
int
getNbOrbits
(
const
MAP
&
map
)
{
unsigned
int
cpt
=
0
;
TraversorCell
<
MAP
,
ORBIT
>
trav
(
map
,
true
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
++
cpt
;
return
cpt
;
}
template
<
typename
MAP
>
unsigned
int
getNbOrbits
(
const
MAP
&
map
,
unsigned
int
orbit
)
{
switch
(
orbit
)
{
case
DART
:
return
getNbOrbits
<
DART
,
MAP
>
(
map
);
case
VERTEX
:
return
getNbOrbits
<
VERTEX
,
MAP
>
(
map
);
case
EDGE
:
return
getNbOrbits
<
EDGE
,
MAP
>
(
map
);
case
FACE
:
return
getNbOrbits
<
FACE
,
MAP
>
(
map
);
case
VOLUME
:
return
getNbOrbits
<
VOLUME
,
MAP
>
(
map
);
case
VERTEX1
:
return
getNbOrbits
<
VERTEX1
,
MAP
>
(
map
);
case
EDGE1
:
return
getNbOrbits
<
EDGE1
,
MAP
>
(
map
);
case
VERTEX2
:
return
getNbOrbits
<
VERTEX2
,
MAP
>
(
map
);
case
EDGE2
:
return
getNbOrbits
<
EDGE2
,
MAP
>
(
map
);
case
FACE2
:
return
getNbOrbits
<
FACE2
,
MAP
>
(
map
);
default:
assert
(
!
"Cells of this dimension are not handled"
);
break
;
}
return
0
;
}
/**
* Traverse the map and embed all orbits of the given dimension with a new cell
* @param realloc if true -> all the orbits are embedded on new cells, if false -> already embedded orbits are not impacted
*/
template
<
unsigned
int
ORBIT
,
typename
MAP
>
void
initAllOrbitsEmbedding
(
MAP
&
map
,
bool
realloc
=
false
)
{
if
(
!
map
.
template
isOrbitEmbedded
<
ORBIT
>())
map
.
template
addEmbedding
<
ORBIT
>()
;
TraversorCell
<
MAP
,
ORBIT
>
trav
(
map
,
true
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
if
(
realloc
||
map
.
template
getEmbedding
<
ORBIT
>(
d
)
==
EMBNULL
)
map
.
template
setOrbitEmbeddingOnNewCell
<
ORBIT
>(
d
)
;
}
}
/**
* use the given attribute to store the indices of the cells of the corresponding orbit
* @return the number of cells of the orbit
*/
template
<
unsigned
int
ORBIT
,
typename
MAP
>
unsigned
int
computeIndexCells
(
MAP
&
map
,
AttributeHandler
<
unsigned
int
,
ORBIT
,
typename
MAP
::
IMPL
>&
idx
)
{
AttributeContainer
&
cont
=
map
.
template
getAttributeContainer
<
ORBIT
>();
unsigned
int
cpt
=
0
;
for
(
unsigned
int
i
=
cont
.
begin
();
i
!=
cont
.
end
();
cont
.
next
(
i
))
idx
[
i
]
=
cpt
++
;
return
cpt
;
}
/**
* ensure that each embedding is pointed by only one orbit
*/
template
<
unsigned
int
ORBIT
,
typename
MAP
>
void
bijectiveOrbitEmbedding
(
MAP
&
map
)
{
if
(
!
map
.
template
isOrbitEmbedded
<
ORBIT
>())
map
.
template
addEmbedding
<
ORBIT
>()
;
AttributeHandler
<
int
,
ORBIT
,
typename
MAP
::
IMPL
>
counter
=
map
.
template
addAttribute
<
int
,
ORBIT
>(
"tmpCounter"
)
;
counter
.
setAllValues
(
int
(
0
))
;
TraversorCell
<
MAP
,
ORBIT
>
trav
(
map
,
true
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
unsigned
int
emb
=
map
.
template
getEmbedding
<
ORBIT
>(
d
)
;
if
(
emb
!=
EMBNULL
)
{
if
(
counter
[
d
]
>
0
)
{
unsigned
int
newEmb
=
map
.
template
setOrbitEmbeddingOnNewCell
<
ORBIT
>(
d
)
;
map
.
template
copyCell
<
ORBIT
>(
newEmb
,
emb
)
;
}
counter
[
d
]
++
;
}
}
map
.
removeAttribute
(
counter
)
;
}
}
// namespace Topo
}
// namespace Algo
}
// 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