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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
CGoGN
Commits
443b9e63
Commit
443b9e63
authored
Feb 22, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grosse mise a jour des Containers, AttributeHandler, etc..
parent
54d09f40
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1408 additions
and
1432 deletions
+1408
-1432
Apps/Examples/miniTest.cpp
Apps/Examples/miniTest.cpp
+8
-24
include/Algo/ImplicitHierarchicalMesh/ihm.h
include/Algo/ImplicitHierarchicalMesh/ihm.h
+1
-1
include/Algo/ImplicitHierarchicalMesh/ihm.hpp
include/Algo/ImplicitHierarchicalMesh/ihm.hpp
+4
-4
include/Algo/Modelisation/subdivision.hpp
include/Algo/Modelisation/subdivision.hpp
+1
-2
include/Algo/Render/vbo_MapRender.hpp
include/Algo/Render/vbo_MapRender.hpp
+3
-16
include/Container/attributeContainer.h
include/Container/attributeContainer.h
+270
-279
include/Container/attributeContainer.hpp
include/Container/attributeContainer.hpp
+257
-154
include/Container/attributeMultiVector.h
include/Container/attributeMultiVector.h
+166
-105
include/Container/attributeMultiVector.hpp
include/Container/attributeMultiVector.hpp
+202
-165
include/Container/holeblockref.h
include/Container/holeblockref.h
+0
-2
include/Container/registered.h
include/Container/registered.h
+3
-3
include/Topology/generic/attribmap.hpp
include/Topology/generic/attribmap.hpp
+16
-19
include/Topology/generic/attributeHandler.h
include/Topology/generic/attributeHandler.h
+13
-10
include/Topology/generic/attributeHandler.hpp
include/Topology/generic/attributeHandler.hpp
+26
-24
include/Topology/generic/autoAttributeHandler.h
include/Topology/generic/autoAttributeHandler.h
+2
-4
include/Topology/generic/genericmap.h
include/Topology/generic/genericmap.h
+8
-6
include/Topology/generic/genericmap.hpp
include/Topology/generic/genericmap.hpp
+20
-8
src/Container/attributeContainer.cpp
src/Container/attributeContainer.cpp
+399
-591
src/Topology/generic/attribmap.cpp
src/Topology/generic/attribmap.cpp
+8
-13
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+1
-2
No files found.
Apps/Examples/miniTest.cpp
View file @
443b9e63
...
...
@@ -536,44 +536,27 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
case
'd'
:
{
GLint
t1
=
glutGet
(
GLUT_ELAPSED_TIME
);
myMap
.
removeAttribute
<
PFP
::
VEC3
>
(
normal
)
;
myMap
.
removeAttribute
<
PFP
::
VEC3
>
(
laplacian
)
;
AttributeHandler
<
PFP
::
VEC3
>
newPosition
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
FACE_ORBIT
,
"position"
)
;
Algo
::
Geometry
::
computeCentroidFaces
<
PFP
>
(
myMap
,
position
,
newPosition
)
;
std
::
vector
<
std
::
string
>
attrNames
;
for
(
unsigned
int
i
=
0
;
i
<
NB_ORBITS
;
++
i
)
{
AttributeContainer
&
cont
=
myMap
.
getAttributeContainer
(
i
)
;
std
::
cout
<<
"container "
<<
i
<<
" ("
<<
cont
.
getNbAttributes
()
<<
") :"
<<
std
::
endl
;
cont
.
getAttributesNames
(
attrNames
)
;
for
(
unsigned
int
j
=
0
;
j
<
attrNames
.
size
();
++
j
)
std
::
cout
<<
" -> "
<<
attrNames
[
j
]
<<
std
::
endl
;
}
std
::
cout
<<
std
::
endl
;
GLint
t1
=
glutGet
(
GLUT_ELAPSED_TIME
);
Algo
::
Modelisation
::
computeDual
<
PFP
>
(
myMap
)
;
for
(
unsigned
int
i
=
0
;
i
<
NB_ORBITS
;
++
i
)
{
AttributeContainer
&
cont
=
myMap
.
getAttributeContainer
(
i
)
;
std
::
cout
<<
"container "
<<
i
<<
" ("
<<
cont
.
getNbAttributes
()
<<
") :"
<<
std
::
endl
;
cont
.
getAttributesNames
(
attrNames
)
;
for
(
unsigned
int
j
=
0
;
j
<
attrNames
.
size
();
++
j
)
std
::
cout
<<
" -> "
<<
attrNames
[
j
]
<<
std
::
endl
;
}
GLint
t2
=
glutGet
(
GLUT_ELAPSED_TIME
);
GLfloat
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
"dual computation: "
<<
seconds
<<
"sec"
<<
std
::
endl
;
newPosition
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
FACE_ORBIT
,
"position"
)
;
myMap
.
removeAttribute
<
PFP
::
VEC3
>
(
newPosition
)
;
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"position"
)
;
normal
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"normal"
)
;
laplacian
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
"laplacian"
)
;
GLint
t2
=
glutGet
(
GLUT_ELAPSED_TIME
);
GLfloat
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
"dual computation: "
<<
seconds
<<
"sec"
<<
std
::
endl
;
t1
=
glutGet
(
GLUT_ELAPSED_TIME
);
updateVBOprimitives
(
Algo
::
Render
::
VBO
::
TRIANGLES
|
Algo
::
Render
::
VBO
::
LINES
|
Algo
::
Render
::
VBO
::
POINTS
)
;
updateVBOdata
(
Algo
::
Render
::
VBO
::
POSITIONS
|
Algo
::
Render
::
VBO
::
NORMALS
)
;
...
...
@@ -743,6 +726,7 @@ int main(int argc, char** argv)
std
::
cerr
<<
"could not import "
<<
filename
<<
std
::
endl
;
return
1
;
}
mgw
->
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX_ORBIT
,
attrNames
[
0
])
;
GLint
t2
=
glutGet
(
GLUT_ELAPSED_TIME
)
;
GLfloat
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
...
...
include/Algo/ImplicitHierarchicalMesh/ihm.h
View file @
443b9e63
...
...
@@ -211,7 +211,7 @@ public:
AttributeHandler_IHM
()
:
AttributeHandler
<
T
>
()
{}
AttributeHandler_IHM
(
GenericMap
*
m
,
unsigned
int
idAttr
)
:
AttributeHandler
<
T
>
(
m
,
idAttr
)
AttributeHandler_IHM
(
GenericMap
*
m
,
unsigned
int
orbit
,
unsigned
int
index
)
:
AttributeHandler
<
T
>
(
m
,
orbit
,
index
)
{}
AttributeMultiVector
<
T
>*
getDataVector
()
const
...
...
include/Algo/ImplicitHierarchicalMesh/ihm.hpp
View file @
443b9e63
...
...
@@ -54,14 +54,14 @@ AttributeHandler_IHM<T> ImplicitHierarchicalMap::addAttribute(unsigned int orbit
amv
[
i
]
=
EMBNULL
;
}
return
AttributeHandler_IHM
<
T
>
(
this
,
h
.
id
())
;
return
AttributeHandler_IHM
<
T
>
(
this
,
h
.
getOrbit
(),
h
.
getIndex
())
;
}
template
<
typename
T
>
AttributeHandler_IHM
<
T
>
ImplicitHierarchicalMap
::
getAttribute
(
unsigned
int
orbit
,
const
std
::
string
&
nameAttr
)
{
AttributeHandler
<
T
>
h
=
Map2
::
getAttribute
<
T
>
(
orbit
,
nameAttr
)
;
return
AttributeHandler_IHM
<
T
>
(
this
,
h
.
id
())
;
return
AttributeHandler_IHM
<
T
>
(
this
,
h
.
getOrbit
(),
h
.
getIndex
())
;
}
/***************************************************
...
...
@@ -344,7 +344,7 @@ T& AttributeHandler_IHM<T>::operator[](Dart d)
assert
(
m
->
m_dartLevel
[
d
]
<=
m
->
m_curLevel
||
!
"Access to a dart introduced after current level"
)
;
assert
(
m
->
vertexInsertionLevel
(
d
)
<=
m
->
m_curLevel
||
!
"Access to the embedding of a vertex inserted after current level"
)
;
unsigned
int
orbit
=
AttributeContainer
::
orbitAttr
(
this
->
m_id
)
;
unsigned
int
orbit
=
this
->
m_orbit
;
unsigned
int
nbSteps
=
m
->
m_curLevel
-
m
->
vertexInsertionLevel
(
d
)
;
unsigned
int
index
=
m
->
getEmbedding
(
d
,
orbit
)
;
...
...
@@ -381,7 +381,7 @@ const T& AttributeHandler_IHM<T>::operator[](Dart d) const
assert
(
m
->
m_dartLevel
[
d
]
<=
m
->
m_curLevel
||
!
"Access to a dart introduced after current level"
)
;
assert
(
m
->
vertexInsertionLevel
(
d
)
<=
m
->
m_curLevel
||
!
"Access to the embedding of a vertex inserted after current level"
)
;
unsigned
int
orbit
=
AttributeContainer
::
orbitAttr
(
this
->
m_id
)
;
unsigned
int
orbit
=
this
->
m_orbit
;
unsigned
int
nbSteps
=
m
->
m_curLevel
-
m
->
vertexInsertionLevel
(
d
)
;
unsigned
int
index
=
m
->
getEmbedding
(
d
,
orbit
)
;
...
...
include/Algo/Modelisation/subdivision.hpp
View file @
443b9e63
...
...
@@ -444,7 +444,7 @@ void computeDual(typename PFP::MAP& map, const FunctorSelect& selected)
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
Dart
dd
=
map
.
alpha1
(
d
)
;
Dart
dd
=
map
.
alpha
_
1
(
d
)
;
new_phi1
[
d
]
=
dd
;
new_phi_1
[
dd
]
=
d
;
}
...
...
@@ -469,7 +469,6 @@ template <typename PFP, typename EMBV, typename EMB>
void
quadranguleFacesVolume
(
typename
PFP
::
MAP
&
map
,
EMBV
&
attributs
,
const
FunctorSelect
&
selected
)
{
}
template
<
typename
PFP
,
typename
EMBV
,
typename
EMB
>
...
...
include/Algo/Render/vbo_MapRender.hpp
View file @
443b9e63
...
...
@@ -36,8 +36,6 @@ namespace Render
namespace
VBO
{
template
<
typename
ATTR_HANDLER
>
void
MapRender_VBO
::
updateData
(
int
upType
,
const
ATTR_HANDLER
&
attrib
,
ConvertAttrib
*
conv
)
{
...
...
@@ -64,8 +62,6 @@ void MapRender_VBO::updateData(int upType, const ATTR_HANDLER& attrib, ConvertAt
fillBufferDirect
(
indexVBO
,
attrib
)
;
}
template
<
typename
ATTR_HANDLER
>
void
MapRender_VBO
::
fillBufferDirect
(
unsigned
int
indexVBO
,
const
ATTR_HANDLER
&
attrib
)
{
...
...
@@ -73,7 +69,7 @@ void MapRender_VBO::fillBufferDirect(unsigned int indexVBO, const ATTR_HANDLER&
std
::
vector
<
void
*>
addr
;
unsigned
int
byteTableSize
;
unsigned
int
nbb
=
mv
->
get
StartAddresse
s
(
addr
,
byteTableSize
);
unsigned
int
nbb
=
mv
->
get
BlocksPointer
s
(
addr
,
byteTableSize
);
glBindBufferARB
(
GL_ARRAY_BUFFER
,
m_VBOBuffers
[
indexVBO
]);
glBufferDataARB
(
GL_ARRAY_BUFFER
,
nbb
*
byteTableSize
,
0
,
GL_STREAM_DRAW
);
...
...
@@ -88,7 +84,6 @@ void MapRender_VBO::fillBufferDirect(unsigned int indexVBO, const ATTR_HANDLER&
}
}
template
<
typename
ATTR_HANDLER
>
void
MapRender_VBO
::
fillBufferConvert
(
unsigned
int
indexVBO
,
const
ATTR_HANDLER
&
attrib
,
ConvertAttrib
*
conv
)
{
...
...
@@ -96,10 +91,10 @@ void MapRender_VBO::fillBufferConvert(unsigned int indexVBO, const ATTR_HANDLER&
std
::
vector
<
void
*>
addr
;
unsigned
int
byteTableSize
;
unsigned
int
nbb
=
mv
->
get
StartAddresse
s
(
addr
,
byteTableSize
);
unsigned
int
nbb
=
mv
->
get
BlocksPointer
s
(
addr
,
byteTableSize
);
// alloue la memoire pour le buffer et initialise le conv
conv
->
reserve
(
mv
->
BlockSize
());
conv
->
reserve
(
mv
->
get
BlockSize
());
// bind buffer to update
glBindBufferARB
(
GL_ARRAY_BUFFER
,
m_VBOBuffers
[
indexVBO
]);
...
...
@@ -338,9 +333,6 @@ void MapRender_VBO::initPrimitives(typename PFP::MAP& map, const FunctorSelect&
glBufferDataARB
(
GL_ELEMENT_ARRAY_BUFFER
,
size
*
sizeof
(
GLuint
),
&
(
tableIndices
[
0
]),
GL_STREAM_DRAW
);
}
template
<
typename
PFP
>
void
MapRender_VBO
::
initFlatTriangles
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
)
{
...
...
@@ -393,13 +385,8 @@ void MapRender_VBO::initFlatTriangles(typename PFP::MAP& map, const FunctorSelec
//creating VBO for flat
glBindBufferARB
(
GL_ARRAY_BUFFER
,
m_VBOBuffers
[
FLAT_BUFFER
]);
glBufferDataARB
(
GL_ARRAY_BUFFER
,
tableFlat
.
size
()
*
sizeof
(
Geom
::
Vec3f
),
(
char
*
)(
&
(
tableFlat
[
0
])),
GL_STREAM_DRAW
);
}
}
// namespace VBO
}
// namespace Render
...
...
include/Container/attributeContainer.h
View file @
443b9e63
This diff is collapsed.
Click to expand it.
include/Container/attributeContainer.hpp
View file @
443b9e63
...
...
@@ -30,278 +30,381 @@
namespace
CGoGN
{
///////////////////////////
// GESTION DES ATTRIBUTS
///////////////////////////
inline
unsigned
int
AttributeContainer
::
getOrbit
()
{
return
m_orbit
;
}
template
<
typename
T
>
unsigned
int
AttributeContainer
::
addAttribute
(
const
std
::
string
&
attribName
)
inline
void
AttributeContainer
::
setOrbit
(
unsigned
int
orbit
)
{
m_orbit
=
orbit
;
for
(
unsigned
int
i
=
0
;
i
<
m_tableAttribs
.
size
();
++
i
)
{
if
(
m_tableAttribs
[
i
]
!=
NULL
)
m_tableAttribs
[
i
]
->
setOrbit
(
orbit
);
}
}
inline
void
AttributeContainer
::
setRegistry
(
std
::
map
<
std
::
string
,
RegisteredBaseAttribute
*
>*
re
)
{
std
::
string
nametype
=
nameOfType
(
T
());
m_attributes_registry_map
=
re
;
}
/**************************************
* BASIC FEATURES *
**************************************/
template
<
typename
T
>
AttributeMultiVector
<
T
>*
AttributeContainer
::
addAttribute
(
const
std
::
string
&
attribName
)
{
// first check if attribute already exist
unsigned
int
index
;
if
(
attribName
!=
""
)
{
MapNameId
::
iterator
it
=
m_attribNameMap
.
find
(
attribName
)
;
if
(
i
t
!=
m_attribNameMap
.
end
()
)
return
UNKNOWN
;
index
=
getAttributeIndex
(
attribName
)
;
if
(
i
ndex
!=
UNKNOWN
)
return
NULL
;
}
// new attribut
AttributeMultiVector
<
T
>*
amv
=
new
AttributeMultiVector
<
T
>
(
attribName
,
nametype
);
// create the new attribute
std
::
string
typeName
=
nameOfType
(
T
())
;
AttributeMultiVector
<
T
>*
amv
=
new
AttributeMultiVector
<
T
>
(
attribName
,
typeName
)
;
unsigned
int
idxAttrib
;
if
(
!
m_freeIndices
.
empty
())
{
i
dxAttrib
=
m_freeIndices
.
back
()
;
i
ndex
=
m_freeIndices
.
back
()
;
m_freeIndices
.
pop_back
()
;
m_tableAttribs
[
i
dxAttrib
]
=
amv
;
m_tableAttribs
[
i
ndex
]
=
amv
;
}
else
{
i
dxAttrib
=
m_tableAttribs
.
size
()
;
m_tableAttribs
.
push_back
(
amv
);
i
ndex
=
m_tableAttribs
.
size
()
;
m_tableAttribs
.
push_back
(
amv
)
;
}
// add it in the map
if
(
attribName
==
""
)
// if no name, generate a fake name
amv
->
setOrbit
(
m_orbit
)
;
amv
->
setIndex
(
index
)
;
// generate a name for the attribute if no one was given
if
(
attribName
==
""
)
{
std
::
stringstream
ss
;
ss
<<
"unknown"
<<
m_nbUnknown
++
;
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
ss
.
str
(),
idxAttrib
));
amv
->
setName
(
ss
.
str
());
std
::
stringstream
ss
;
ss
<<
"unknown"
<<
m_nbUnknown
++
;
amv
->
setName
(
ss
.
str
())
;
}
else
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
attribName
,
idxAttrib
));
// maj taille d'une ligne
m_lineCost
+=
sizeof
(
T
);
// resize the new attribute container to have same size than others
int
nbb
=
m_holesBlocks
.
size
();
amv
->
setNbBlocks
(
nbb
);
// update the memory cost of a line
m_lineCost
+=
sizeof
(
T
)
;
m_nbAttributes
++
;
// resize the new attribute so that it has the same size than others
amv
->
setNbBlocks
(
m_holesBlocks
.
size
())
;
m_nbAttributes
++
;
return
idxAttrib
;
return
amv
;
}
template
<
typename
T
>
unsigned
int
AttributeContainer
::
addAttribute
(
const
std
::
string
&
attribName
,
const
std
::
string
&
nametype
,
unsigned
int
idxAttrib
)
void
AttributeContainer
::
addAttribute
(
const
std
::
string
&
attribName
,
const
std
::
string
&
nametype
,
unsigned
int
index
)
{
// first check if attribute already exist
if
(
attribName
!=
""
)
{
MapNameId
::
iterator
it
=
m_attribNameMap
.
find
(
attribName
)
;
if
(
i
t
!=
m_attribNameMap
.
end
()
)
return
UNKNOWN
;
unsigned
int
i
=
getAttributeIndex
(
attribName
)
;
if
(
i
!=
UNKNOWN
)
return
;
}
//
new attribut
//
create the new attribute
AttributeMultiVector
<
T
>*
amv
=
new
AttributeMultiVector
<
T
>
(
attribName
,
nametype
);
// add it to table of attribut_manager
m_tableAttribs
[
idxAttrib
]
=
amv
;
// add it in the map
if
(
attribName
==
""
)
// if no name, generate a fake name
m_tableAttribs
[
index
]
=
amv
;
amv
->
setOrbit
(
m_orbit
)
;
amv
->
setIndex
(
index
)
;
// generate a name for the attribute if no one was given
if
(
attribName
==
""
)
{
std
::
stringstream
ss
;
ss
<<
"unknown"
<<
m_nbUnknown
++
;
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
ss
.
str
(),
idxAttrib
));
amv
->
setName
(
ss
.
str
());
}
else
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
attribName
,
idxAttrib
));
//
maj taille d'une lig
ne
m_lineCost
+=
sizeof
(
T
);
//
update the memory cost of a li
ne
m_lineCost
+=
sizeof
(
T
)
;
// resize the new attribute container to have same size than others
int
nbb
=
m_holesBlocks
.
size
();
amv
->
setNbBlocks
(
nbb
);
// resize the new attribute so that it has the same size than others
amv
->
setNbBlocks
(
m_holesBlocks
.
size
())
;
m_nbAttributes
++
;
return
idxAttrib
;
}
inline
unsigned
int
AttributeContainer
::
getNbAttributes
()
/**************************************
* INFO ABOUT THE CONTAINER *
**************************************/
inline
unsigned
int
AttributeContainer
::
getNbAttributes
()
const
{
return
m_nbAttributes
;
}
///////////////////////////
// ACCES AUX DONNEES
///////////////////////////
inline
unsigned
int
AttributeContainer
::
size
()
const
{
return
m_size
;
}
template
<
typename
T
>
T
&
AttributeContainer
::
getData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
)
inline
unsigned
int
AttributeContainer
::
capacity
()
const
{
assert
(
eltIdx
<
m_maxSize
||
!
"Attribut non existant (indice trop grand)"
);
assert
(
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
)
||
!
"Attribut non existant"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
||
!
"Attribut detruit"
);
return
m_holesBlocks
.
size
()
*
_BLOCKSIZE_
;
}
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
inline
unsigned
int
AttributeContainer
::
memoryTotalSize
()
const
{
return
_BLOCKSIZE_
*
(
m_holesBlocks
.
size
()
*
m_lineCost
+
8
);
}
return
atm
->
operator
[](
eltIdx
);
inline
bool
AttributeContainer
::
used
(
unsigned
int
index
)
const
{
return
m_holesBlocks
[
index
/
_BLOCKSIZE_
]
->
used
(
index
%
_BLOCKSIZE_
);
}
template
<
typename
T
>
const
T
&
AttributeContainer
::
getData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
)
const
/**************************************
* CONTAINER TRAVERSAL *
**************************************/
inline
unsigned
int
AttributeContainer
::
begin
()
const
{
assert
(
eltIdx
<
m_maxSize
||
!
"Attribut non existant (indice trop grand)"
);
assert
(
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
)
||
!
"Attribut non existant"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
||
!
"Attribut detruit"
);
unsigned
int
it
=
0
;
while
((
it
<
m_maxSize
)
&&
(
!
used
(
it
)))
++
it
;
return
it
;
}
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
inline
unsigned
int
AttributeContainer
::
end
()
const
{
return
m_maxSize
;
}
return
atm
->
operator
[](
eltIdx
);
inline
void
AttributeContainer
::
next
(
unsigned
int
&
it
)
const
{
do
{
++
it
;
}
while
((
it
<
m_maxSize
)
&&
(
!
used
(
it
)));
}
template
<
typename
T
>
void
AttributeContainer
::
setData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
,
const
T
&
data
)
/**************************************
* LINES MANAGEMENT *
**************************************/
inline
void
AttributeContainer
::
initLine
(
unsigned
int
index
)
{
assert
(
eltIdx
<
m_maxSize
||
!
"Attribut non existant (indice trop grand)"
);
assert
(
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
)
||
!
"Attribut non existant"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
||
!
"Attribut detruit"
);
for
(
unsigned
int
i
=
0
;
i
<
m_tableAttribs
.
size
();
++
i
)
{
if
(
m_tableAttribs
[
i
]
!=
NULL
)
m_tableAttribs
[
i
]
->
initElt
(
index
);
}
}
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
inline
void
AttributeContainer
::
copyLine
(
unsigned
int
dstIndex
,
unsigned
int
srcIndex
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_tableAttribs
.
size
();
++
i
)
{
if
(
m_tableAttribs
[
i
]
!=
NULL
)
m_tableAttribs
[
i
]
->
copyElt
(
dstIndex
,
srcIndex
);
}
}
atm
->
operator
[](
eltIdx
)
=
data
;
inline
void
AttributeContainer
::
refLine
(
unsigned
int
index
)
{
m_holesBlocks
[
index
/
_BLOCKSIZE_
]
->
ref
(
index
%
_BLOCKSIZE_
);
}
//template <typename T>
//unsigned int AttributeContainer::insertLineWidthData(unsigned int codeAttrib,const T& data)
//{
// unsigned int it = insertLine();
// setData<T>(codeAttrib, it, data);
// return it;
//}
inline
bool
AttributeContainer
::
unrefLine
(
unsigned
int
index
)
{
if
(
m_holesBlocks
[
index
/
_BLOCKSIZE_
]
->
unref
(
index
%
_BLOCKSIZE_
))
{
--
m_size
;
return
true
;
}
return
false
;
}
template
<
typename
T
>
AttributeMultiVector
<
T
>&
AttributeContainer
::
getDataVector
(
unsigned
int
codeAttrib
)
inline
unsigned
int
AttributeContainer
::
getNbRefs
(
unsigned
int
index
)
{
assert
((
codeAttrib
<
m_tableAttribs
.
size
())
||
!
"Attribut inexistant"
)
;
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
||
!
"Attribut detruit"
)
;
unsigned
int
bi
=
index
/
_BLOCKSIZE_
;
unsigned
int
j
=
index
%
_BLOCKSIZE_
;
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
return
*
atm
;
return
m_holesBlocks
[
bi
]
->
nbRefs
(
j
);
}
template
<
typename
T
>
bool
AttributeContainer
::
getAttributesVector
(
const
std
::
string
&
attribName
,
AttributeMultiVector
<
T
>**
ptr
)
inline
void
AttributeContainer
::
setNbRefs
(
unsigned
int
index
,
unsigned
int
nb
)
{
MapNameId
::
iterator
it
=
m_attribNameMap
.
find
(
attribName
);
if
(
it
==
m_attribNameMap
.
end
())
return
false
;
int
codeAttrib
=
it
->
second
;
m_holesBlocks
[
index
/
_BLOCKSIZE_
]
->
setNbRefs
(
index
%
_BLOCKSIZE_
,
nb
);
}
if
(
m_tableAttribs
[
codeAttrib
]
==
NULL
)
return
false
;
/**************************************
* ATTRIBUTES MANAGEMENT *
**************************************/
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
if
(
atm
==
NULL
)
return
false
;
inline
bool
AttributeContainer
::
copyAttribute
(
unsigned
int
index_dst
,
unsigned
int
index_src
)
{
return
m_tableAttribs
[
index_dst
]
->
copy
(
m_tableAttribs
[
index_src
]);
}
*
ptr
=
atm
;
return
true
;
inline
bool
AttributeContainer
::
swapAttributes
(
unsigned
int
index1
,
unsigned
int
index2
)
{
return
m_tableAttribs
[
index1
]
->
swap
(
m_tableAttribs
[
index2
]);
}
/
//////////////////////////
// ADRESSES MEMOIRES
//////////////////////////
/
/
**************************************
* ATTRIBUTES DATA ACCESS *
**************************************
/
template
<
typename
T
>
unsigned
int
AttributeContainer
::
getAddresses
(
unsigned
int
attr
,
std
::
vector
<
T
*>&
vect_adr
)
AttributeMultiVector
<
T
>&
AttributeContainer
::
getDataVector
(
unsigned
int
attrIndex
)
{
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
attr
]);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
return
atm
->
getStartAddresses
(
vect_adr
);
assert
(
attrIndex
<
m_tableAttribs
.
size
()
||
!
"getDataVector: attribute index out of bounds"
);
assert
(
m_tableAttribs
[
attrIndex
]
!=
NULL
||
!
"getDataVector: attribute does not exist"
);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*>
(
m_tableAttribs
[
attrIndex
]);
assert
((
atm
!=
NULL
)
||
!
"getDataVector: wrong type"
);
return
*
atm
;
}
//////////////////////////////
// Enregistrement attributs
//////////////////////////////
inline
AttributeMultiVectorGen
&
AttributeContainer
::
getVirtualDataVector
(
unsigned
int
attrIndex
)
{
return
*
(
m_tableAttribs
[
attrIndex
]);
}
//// INLINED FUNCTIONS
inline
bool
AttributeContainer
::
used
(
unsigned
int
eltIdx
)
const
template
<
typename
T
>
AttributeMultiVector
<
T
>&
AttributeContainer
::
getDataVector
(
const
std
::
string
&
attribName
)
{
return
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
);
unsigned
int
index
=
getAttributeIndex
(
attribName
)
;
assert
(
index
!=
UNKNOWN
)
;
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*>
(
m_tableAttribs
[
index
]);
assert
((
atm
!=
NULL
)
||
!
"getDataVector: wrong type"
);
return
*
atm
;
}
inline
void
AttributeContainer
::
setRegistry
(
std
::
map
<
std
::
string
,
RegisteredBaseAttribute
*
>*
r
e
)
inline
AttributeMultiVectorGen
&
AttributeContainer
::
getVirtualDataVector
(
const
std
::
string
&
attribNam
e
)
{
m_attributes_registry_map
=
re
;
unsigned
int
index
=
getAttributeIndex
(
attribName
)
;
assert
(
index
!=
UNKNOWN
)
;
return
*
(
m_tableAttribs
[
index
]);
}
<