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
a84e1f2d
Commit
a84e1f2d
authored
Nov 08, 2011
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
foreach_orbit use traversor
parent
d2336a45
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
118 additions
and
97 deletions
+118
-97
include/Topology/generic/attribmap.h
include/Topology/generic/attribmap.h
+0
-20
include/Topology/generic/attribmap.hpp
include/Topology/generic/attribmap.hpp
+0
-15
include/Topology/generic/cellmarker.h
include/Topology/generic/cellmarker.h
+6
-6
include/Topology/generic/genericmap.h
include/Topology/generic/genericmap.h
+21
-0
include/Topology/generic/genericmap.hpp
include/Topology/generic/genericmap.hpp
+17
-0
include/Topology/generic/traversorCell.h
include/Topology/generic/traversorCell.h
+16
-15
src/Topology/generic/attribmap.cpp
src/Topology/generic/attribmap.cpp
+0
-30
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+58
-11
No files found.
include/Topology/generic/attribmap.h
View file @
a84e1f2d
...
@@ -34,7 +34,6 @@ namespace CGoGN
...
@@ -34,7 +34,6 @@ namespace CGoGN
class
AttribMap
:
public
GenericMap
class
AttribMap
:
public
GenericMap
{
{
private:
private:
friend
class
CellMarkerGen
;
template
<
typename
T
>
friend
class
AutoAttributeHandler
;
template
<
typename
T
>
friend
class
AutoAttributeHandler
;
void
init
()
;
void
init
()
;
...
@@ -94,25 +93,6 @@ public:
...
@@ -94,25 +93,6 @@ public:
*/
*/
unsigned
int
getNbCells
(
unsigned
int
orbit
);
unsigned
int
getNbCells
(
unsigned
int
orbit
);
protected:
/****************************************
* EMBEDDING ATTRIBUTES MANAGEMENT *
****************************************/
/**
* Create the dart attribute to store the embedding of this orbit (for internal use only)
* Also adds a Marker attribute to the container
*/
void
addEmbedding
(
unsigned
int
orbit
)
;
/****************************************
* TOPOLOGICAL ATTRIBUTES MANAGEMENT *
****************************************/
/**
* Add a toological relation in the map
* @param name name of relation
*/
AttributeMultiVector
<
Dart
>*
addRelation
(
const
std
::
string
&
name
)
;
public:
public:
/****************************************
/****************************************
...
...
include/Topology/generic/attribmap.hpp
View file @
a84e1f2d
...
@@ -88,20 +88,5 @@ inline unsigned int AttribMap::getNbCells(unsigned int orbit)
...
@@ -88,20 +88,5 @@ inline unsigned int AttribMap::getNbCells(unsigned int orbit)
return
this
->
m_attribs
[
orbit
].
size
()
;
return
this
->
m_attribs
[
orbit
].
size
()
;
}
}
/****************************************
* TOPOLOGICAL ATTRIBUTES MANAGEMENT *
****************************************/
inline
AttributeMultiVector
<
Dart
>*
AttribMap
::
addRelation
(
const
std
::
string
&
name
)
{
AttributeContainer
&
cont
=
m_attribs
[
DART
]
;
AttributeMultiVector
<
Dart
>*
amv
=
cont
.
addAttribute
<
Dart
>
(
name
)
;
// set new relation to fix point for all the darts of the map
for
(
unsigned
int
i
=
cont
.
begin
();
i
<
cont
.
end
();
cont
.
next
(
i
))
amv
->
operator
[](
i
)
=
i
;
return
amv
;
}
}
// namespace CGoGN
}
// namespace CGoGN
include/Topology/generic/cellmarker.h
View file @
a84e1f2d
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#define __CELL_MARKER__
#define __CELL_MARKER__
#include "Topology/generic/marker.h"
#include "Topology/generic/marker.h"
#include "Topology/generic/
attrib
map.h"
#include "Topology/generic/
generic
map.h"
#include "Topology/generic/functor.h"
#include "Topology/generic/functor.h"
#include "Utils/static_assert.h"
#include "Utils/static_assert.h"
...
@@ -42,7 +42,7 @@ class CellMarkerGen
...
@@ -42,7 +42,7 @@ class CellMarkerGen
{
{
protected:
protected:
Mark
m_mark
;
Mark
m_mark
;
Attrib
Map
&
m_map
;
Generic
Map
&
m_map
;
unsigned
int
m_cell
;
unsigned
int
m_cell
;
unsigned
int
m_thread
;
unsigned
int
m_thread
;
...
@@ -52,7 +52,7 @@ public:
...
@@ -52,7 +52,7 @@ public:
* @param map the map on which we work
* @param map the map on which we work
* @param cell the type of cell we want to mark VERTEX, EDGE,...
* @param cell the type of cell we want to mark VERTEX, EDGE,...
*/
*/
CellMarkerGen
(
Attrib
Map
&
map
,
unsigned
int
cell
,
unsigned
int
thread
=
0
)
:
m_map
(
map
),
m_cell
(
cell
),
m_thread
(
thread
)
CellMarkerGen
(
Generic
Map
&
map
,
unsigned
int
cell
,
unsigned
int
thread
=
0
)
:
m_map
(
map
),
m_cell
(
cell
),
m_thread
(
thread
)
{
{
if
(
!
map
.
isOrbitEmbedded
(
cell
))
if
(
!
map
.
isOrbitEmbedded
(
cell
))
map
.
addEmbedding
(
cell
)
;
map
.
addEmbedding
(
cell
)
;
...
@@ -189,7 +189,7 @@ public:
...
@@ -189,7 +189,7 @@ public:
class
CellMarker
:
public
CellMarkerGen
class
CellMarker
:
public
CellMarkerGen
{
{
public:
public:
CellMarker
(
Attrib
Map
&
map
,
unsigned
int
cell
,
unsigned
int
thread
=
0
)
:
CellMarkerGen
(
map
,
cell
,
thread
)
CellMarker
(
Generic
Map
&
map
,
unsigned
int
cell
,
unsigned
int
thread
=
0
)
:
CellMarkerGen
(
map
,
cell
,
thread
)
{}
{}
virtual
~
CellMarker
()
virtual
~
CellMarker
()
...
@@ -225,7 +225,7 @@ protected:
...
@@ -225,7 +225,7 @@ protected:
std
::
vector
<
unsigned
int
>
m_markedCells
;
std
::
vector
<
unsigned
int
>
m_markedCells
;
public:
public:
CellMarkerStore
(
Attrib
Map
&
map
,
unsigned
int
cell
,
unsigned
int
thread
=
0
)
:
CellMarkerGen
(
map
,
cell
,
thread
)
CellMarkerStore
(
Generic
Map
&
map
,
unsigned
int
cell
,
unsigned
int
thread
=
0
)
:
CellMarkerGen
(
map
,
cell
,
thread
)
{}
{}
...
@@ -272,7 +272,7 @@ public:
...
@@ -272,7 +272,7 @@ public:
class
CellMarkerNoUnmark
:
public
CellMarkerGen
class
CellMarkerNoUnmark
:
public
CellMarkerGen
{
{
public:
public:
CellMarkerNoUnmark
(
Attrib
Map
&
map
,
unsigned
int
cell
,
unsigned
int
thread
=
0
)
:
CellMarkerGen
(
map
,
cell
,
thread
)
CellMarkerNoUnmark
(
Generic
Map
&
map
,
unsigned
int
cell
,
unsigned
int
thread
=
0
)
:
CellMarkerGen
(
map
,
cell
,
thread
)
{}
{}
virtual
~
CellMarkerNoUnmark
()
virtual
~
CellMarkerNoUnmark
()
...
...
include/Topology/generic/genericmap.h
View file @
a84e1f2d
...
@@ -77,6 +77,7 @@ class GenericMap : public MapBrowser
...
@@ -77,6 +77,7 @@ class GenericMap : public MapBrowser
{
{
template
<
typename
T
>
friend
class
AttributeHandler
;
template
<
typename
T
>
friend
class
AttributeHandler
;
template
<
typename
T
>
friend
class
AutoAttributeHandler
;
template
<
typename
T
>
friend
class
AutoAttributeHandler
;
friend
class
CellMarkerGen
;
protected:
protected:
/**
/**
...
@@ -272,6 +273,26 @@ public:
...
@@ -272,6 +273,26 @@ public:
*/
*/
void
initOrbitEmbedding
(
unsigned
int
orbit
,
bool
realloc
=
false
)
;
void
initOrbitEmbedding
(
unsigned
int
orbit
,
bool
realloc
=
false
)
;
protected:
/****************************************
* EMBEDDING ATTRIBUTES MANAGEMENT *
****************************************/
/**
* Create the dart attribute to store the embedding of this orbit (for internal use only)
* Also adds a Marker attribute to the container
*/
void
addEmbedding
(
unsigned
int
orbit
)
;
/****************************************
* TOPOLOGICAL ATTRIBUTES MANAGEMENT *
****************************************/
/**
* Add a toological relation in the map
* @param name name of relation
*/
AttributeMultiVector
<
Dart
>*
addRelation
(
const
std
::
string
&
name
)
;
/****************************************
/****************************************
* THREAD MANAGEMENT *
* THREAD MANAGEMENT *
****************************************/
****************************************/
...
...
include/Topology/generic/genericmap.hpp
View file @
a84e1f2d
...
@@ -218,4 +218,21 @@ inline void GenericMap::next(Dart& d)
...
@@ -218,4 +218,21 @@ inline void GenericMap::next(Dart& d)
m_attribs
[
DART
].
next
(
d
.
index
)
;
m_attribs
[
DART
].
next
(
d
.
index
)
;
}
}
/****************************************
* TOPOLOGICAL ATTRIBUTES MANAGEMENT *
****************************************/
inline
AttributeMultiVector
<
Dart
>*
GenericMap
::
addRelation
(
const
std
::
string
&
name
)
{
AttributeContainer
&
cont
=
m_attribs
[
DART
]
;
AttributeMultiVector
<
Dart
>*
amv
=
cont
.
addAttribute
<
Dart
>
(
name
)
;
// set new relation to fix point for all the darts of the map
for
(
unsigned
int
i
=
cont
.
begin
();
i
<
cont
.
end
();
cont
.
next
(
i
))
amv
->
operator
[](
i
)
=
i
;
return
amv
;
}
}
//namespace CGoGN
}
//namespace CGoGN
include/Topology/generic/traversorCell.h
View file @
a84e1f2d
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
namespace
CGoGN
namespace
CGoGN
{
{
template
<
typename
MAP
,
unsigned
int
ORBIT
>
template
<
typename
MAP
>
class
TraversorCell
class
TraversorCell
{
{
private:
private:
...
@@ -41,13 +41,14 @@ private:
...
@@ -41,13 +41,14 @@ private:
CellMarker
*
cmark
;
CellMarker
*
cmark
;
Dart
current
;
Dart
current
;
bool
firstTraversal
;
bool
firstTraversal
;
unsigned
int
m_orbit
;
public:
public:
TraversorCell
(
MAP
&
map
,
unsigned
int
thread
=
0
)
:
TraversorCell
(
MAP
&
map
,
unsigned
int
orbit
,
unsigned
int
thread
=
0
)
:
m
(
map
),
dmark
(
NULL
),
cmark
(
NULL
),
current
(
NIL
),
firstTraversal
(
true
)
m
(
map
),
dmark
(
NULL
),
cmark
(
NULL
),
current
(
NIL
),
firstTraversal
(
true
)
,
m_orbit
(
orbit
)
{
{
if
(
map
.
isOrbitEmbedded
(
ORBIT
))
if
(
map
.
isOrbitEmbedded
(
m_orbit
))
cmark
=
new
CellMarker
(
map
,
ORBIT
,
thread
)
;
cmark
=
new
CellMarker
(
map
,
m_orbit
,
thread
)
;
else
else
dmark
=
new
DartMarker
(
map
,
thread
)
;
dmark
=
new
DartMarker
(
map
,
thread
)
;
}
}
...
@@ -79,7 +80,7 @@ public:
...
@@ -79,7 +80,7 @@ public:
else
else
{
{
if
(
dmark
)
if
(
dmark
)
dmark
->
markOrbit
(
ORBIT
,
current
)
;
dmark
->
markOrbit
(
m_orbit
,
current
)
;
else
else
cmark
->
mark
(
current
)
;
cmark
->
mark
(
current
)
;
}
}
...
@@ -117,7 +118,7 @@ public:
...
@@ -117,7 +118,7 @@ public:
if
(
current
!=
NIL
)
if
(
current
!=
NIL
)
{
{
if
(
dmark
)
if
(
dmark
)
dmark
->
markOrbit
(
ORBIT
,
current
)
;
dmark
->
markOrbit
(
m_orbit
,
current
)
;
else
else
cmark
->
mark
(
current
)
;
cmark
->
mark
(
current
)
;
}
}
...
@@ -127,34 +128,34 @@ public:
...
@@ -127,34 +128,34 @@ public:
}
;
}
;
template
<
typename
MAP
>
template
<
typename
MAP
>
class
TraversorV
:
public
TraversorCell
<
MAP
,
VERTEX
>
class
TraversorV
:
public
TraversorCell
<
MAP
>
{
{
public:
public:
TraversorV
(
MAP
&
m
,
unsigned
int
thread
=
0
)
:
TraversorCell
<
MAP
,
VERTEX
>
(
m
,
thread
)
TraversorV
(
MAP
&
m
,
unsigned
int
thread
=
0
)
:
TraversorCell
<
MAP
>
(
m
,
VERTEX
,
thread
)
{}
{}
};
};
template
<
typename
MAP
>
template
<
typename
MAP
>
class
TraversorE
:
public
TraversorCell
<
MAP
,
EDGE
>
class
TraversorE
:
public
TraversorCell
<
MAP
>
{
{
public:
public:
TraversorE
(
MAP
&
m
,
unsigned
int
thread
=
0
)
:
TraversorCell
<
MAP
,
EDGE
>
(
m
,
thread
)
TraversorE
(
MAP
&
m
,
unsigned
int
thread
=
0
)
:
TraversorCell
<
MAP
>
(
m
,
EDGE
,
thread
)
{}
{}
};
};
template
<
typename
MAP
>
template
<
typename
MAP
>
class
TraversorF
:
public
TraversorCell
<
MAP
,
FACE
>
class
TraversorF
:
public
TraversorCell
<
MAP
>
{
{
public:
public:
TraversorF
(
MAP
&
m
,
unsigned
int
thread
=
0
)
:
TraversorCell
<
MAP
,
FACE
>
(
m
,
thread
)
TraversorF
(
MAP
&
m
,
unsigned
int
thread
=
0
)
:
TraversorCell
<
MAP
>
(
m
,
FACE
,
thread
)
{}
{}
};
};
template
<
typename
MAP
>
template
<
typename
MAP
>
class
TraversorW
:
public
TraversorCell
<
MAP
,
VOLUME
>
class
TraversorW
:
public
TraversorCell
<
MAP
>
{
{
public:
public:
TraversorW
(
MAP
&
m
,
unsigned
int
thread
=
0
)
:
TraversorCell
<
MAP
,
VOLUME
>
(
m
,
thread
)
TraversorW
(
MAP
&
m
,
unsigned
int
thread
=
0
)
:
TraversorCell
<
MAP
>
(
m
,
VOLUME
,
thread
)
{}
{}
};
};
...
...
src/Topology/generic/attribmap.cpp
View file @
a84e1f2d
...
@@ -53,36 +53,6 @@ void AttribMap::clear(bool removeAttrib)
...
@@ -53,36 +53,6 @@ void AttribMap::clear(bool removeAttrib)
init
()
;
init
()
;
}
}
/****************************************
* EMBEDDING ATTRIBUTES MANAGEMENT *
****************************************/
void
AttribMap
::
addEmbedding
(
unsigned
int
orbit
)
{
assert
(
!
isOrbitEmbedded
(
orbit
)
||
!
"Invalid parameter: orbit already embedded"
)
;
std
::
ostringstream
oss
;
oss
<<
"EMB_"
<<
orbit
;
AttributeContainer
&
dartCont
=
m_attribs
[
DART
]
;
AttributeMultiVector
<
unsigned
int
>*
amv
=
dartCont
.
addAttribute
<
unsigned
int
>
(
oss
.
str
())
;
m_embeddings
[
orbit
]
=
amv
;
// set new embedding to EMBNULL for all the darts of the map
for
(
unsigned
int
i
=
dartCont
.
begin
();
i
<
dartCont
.
end
();
dartCont
.
next
(
i
))
amv
->
operator
[](
i
)
=
EMBNULL
;
AttributeContainer
&
cellCont
=
m_attribs
[
orbit
];
for
(
unsigned
int
t
=
0
;
t
<
m_nbThreads
;
++
t
)
{
std
::
stringstream
ss
;
ss
<<
"Mark_"
<<
t
;
AttributeMultiVector
<
Mark
>*
amvMark
=
cellCont
.
addAttribute
<
Mark
>
(
ss
.
str
())
;
for
(
unsigned
int
i
=
cellCont
.
begin
();
i
<
cellCont
.
end
();
cellCont
.
next
(
i
))
amvMark
->
operator
[](
i
).
clear
()
;
m_markTables
[
orbit
][
t
]
=
amvMark
;
}
}
/****************************************
/****************************************
* UTILITIES *
* UTILITIES *
...
...
src/Topology/generic/genericmap.cpp
View file @
a84e1f2d
...
@@ -25,6 +25,8 @@
...
@@ -25,6 +25,8 @@
#include "Topology/generic/genericmap.h"
#include "Topology/generic/genericmap.h"
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/dartmarker.h"
#include "Topology/generic/dartmarker.h"
#include "Topology/generic/traversorCell.h"
#include "Geometry/vector_gen.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Geometry/matrix.h"
#include "Container/registered.h"
#include "Container/registered.h"
...
@@ -193,6 +195,38 @@ bool GenericMap::registerAttribute(const std::string &nameType)
...
@@ -193,6 +195,38 @@ bool GenericMap::registerAttribute(const std::string &nameType)
return
true
;
return
true
;
}
}
/****************************************
* EMBEDDING ATTRIBUTES MANAGEMENT *
****************************************/
void
GenericMap
::
addEmbedding
(
unsigned
int
orbit
)
{
assert
(
!
isOrbitEmbedded
(
orbit
)
||
!
"Invalid parameter: orbit already embedded"
)
;
std
::
ostringstream
oss
;
oss
<<
"EMB_"
<<
orbit
;
AttributeContainer
&
dartCont
=
m_attribs
[
DART
]
;
AttributeMultiVector
<
unsigned
int
>*
amv
=
dartCont
.
addAttribute
<
unsigned
int
>
(
oss
.
str
())
;
m_embeddings
[
orbit
]
=
amv
;
// set new embedding to EMBNULL for all the darts of the map
for
(
unsigned
int
i
=
dartCont
.
begin
();
i
<
dartCont
.
end
();
dartCont
.
next
(
i
))
amv
->
operator
[](
i
)
=
EMBNULL
;
AttributeContainer
&
cellCont
=
m_attribs
[
orbit
];
for
(
unsigned
int
t
=
0
;
t
<
m_nbThreads
;
++
t
)
{
std
::
stringstream
ss
;
ss
<<
"Mark_"
<<
t
;
AttributeMultiVector
<
Mark
>*
amvMark
=
cellCont
.
addAttribute
<
Mark
>
(
ss
.
str
())
;
for
(
unsigned
int
i
=
cellCont
.
begin
();
i
<
cellCont
.
end
();
cellCont
.
next
(
i
))
amvMark
->
operator
[](
i
).
clear
()
;
m_markTables
[
orbit
][
t
]
=
amvMark
;
}
}
/****************************************
/****************************************
* THREAD MANAGEMENT *
* THREAD MANAGEMENT *
****************************************/
****************************************/
...
@@ -592,24 +626,37 @@ bool GenericMap::foreach_dart_of_orbit(unsigned int orbit, Dart d, FunctorType&
...
@@ -592,24 +626,37 @@ bool GenericMap::foreach_dart_of_orbit(unsigned int orbit, Dart d, FunctorType&
bool
GenericMap
::
foreach_orbit
(
unsigned
int
orbit
,
FunctorType
&
fonct
,
const
FunctorSelect
&
good
,
unsigned
int
thread
)
bool
GenericMap
::
foreach_orbit
(
unsigned
int
orbit
,
FunctorType
&
fonct
,
const
FunctorSelect
&
good
,
unsigned
int
thread
)
{
{
DartMarker
marker
(
*
this
,
thread
);
// Lock a marker
TraversorCell
<
GenericMap
>
trav
(
*
this
,
orbit
,
thread
);
bool
found
=
false
;
// Store the result
bool
found
=
false
;
// Store the result
// Scan all darts of the map
for
(
Dart
d
=
trav
.
begin
();
!
found
&&
d
!=
trav
.
end
();
d
=
trav
.
next
())
for
(
Dart
d
=
begin
();
!
found
&&
d
!=
end
();
next
(
d
))
{
{
if
(
good
(
d
))
// If d is selected
if
(
good
(
d
))
// If d is selected
{
{
if
(
!
marker
.
isMarked
(
d
))
// If d is in a not yet visited cell
if
((
fonct
)(
d
))
// Apply functor
{
found
=
true
;
if
((
fonct
)(
d
))
// Apply functor
found
=
true
;
else
marker
.
markOrbit
(
orbit
,
d
);
// Mark the cell as visited
}
}
}
}
}
return
found
;
return
found
;
// DartMarker marker(*this, thread); // Lock a marker
// bool found = false; // Store the result
//
// // Scan all darts of the map
// for (Dart d = begin(); !found && d != end(); next(d))
// {
// if (good(d)) // If d is selected
// {
// if (!marker.isMarked(d)) // If d is in a not yet visited cell
// {
// if ((fonct)(d)) // Apply functor
// found = true;
// else
// marker.markOrbit(orbit, d); // Mark the cell as visited
// }
// }
// }
// return found;
}
}
unsigned
int
GenericMap
::
getNbOrbits
(
unsigned
int
orbit
,
const
FunctorSelect
&
good
)
unsigned
int
GenericMap
::
getNbOrbits
(
unsigned
int
orbit
,
const
FunctorSelect
&
good
)
...
...
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