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
54d09f40
Commit
54d09f40
authored
Feb 18, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Suite essais compute dual
Mise a jour stockage des AttributeMultiVector dans les AttributeContainer
parent
cc7691b9
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
255 additions
and
136 deletions
+255
-136
Apps/Examples/miniTest.cpp
Apps/Examples/miniTest.cpp
+52
-0
include/Algo/Import/importMesh.hpp
include/Algo/Import/importMesh.hpp
+1
-2
include/Algo/Modelisation/subdivision.h
include/Algo/Modelisation/subdivision.h
+1
-1
include/Algo/Modelisation/subdivision.hpp
include/Algo/Modelisation/subdivision.hpp
+8
-7
include/Algo/Render/topo_vboRender.h
include/Algo/Render/topo_vboRender.h
+2
-6
include/Algo/Render/topo_vboRender.hpp
include/Algo/Render/topo_vboRender.hpp
+1
-5
include/Container/attributeContainer.h
include/Container/attributeContainer.h
+3
-6
include/Container/attributeContainer.hpp
include/Container/attributeContainer.hpp
+72
-41
include/Container/attributeMultiVector.h
include/Container/attributeMultiVector.h
+9
-12
include/Container/attributeMultiVector.hpp
include/Container/attributeMultiVector.hpp
+63
-24
include/Topology/generic/autoAttributeHandler.h
include/Topology/generic/autoAttributeHandler.h
+2
-2
include/Topology/generic/genericmap.h
include/Topology/generic/genericmap.h
+5
-0
include/Topology/generic/genericmap.hpp
include/Topology/generic/genericmap.hpp
+10
-0
src/Container/attributeContainer.cpp
src/Container/attributeContainer.cpp
+23
-29
src/Topology/generic/attribmap.cpp
src/Topology/generic/attribmap.cpp
+2
-0
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+1
-1
No files found.
Apps/Examples/miniTest.cpp
View file @
54d09f40
...
@@ -534,6 +534,58 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
...
@@ -534,6 +534,58 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
break
;
break
;
}
}
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
;
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
;
}
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
)
;
topo_render
->
updateData
<
PFP
>
(
myMap
,
position
,
0.9
f
,
0.9
f
)
;
t2
=
glutGet
(
GLUT_ELAPSED_TIME
);
seconds
=
(
t2
-
t1
)
/
1000.0
f
;
std
::
cout
<<
"display update: "
<<
seconds
<<
"sec"
<<
std
::
endl
;
glutPostRedisplay
()
;
break
;
}
case
'3'
:
case
'3'
:
{
{
CellMarker
markVisit
(
myMap
,
VERTEX_CELL
)
;
CellMarker
markVisit
(
myMap
,
VERTEX_CELL
)
;
...
...
include/Algo/Import/importMesh.hpp
View file @
54d09f40
...
@@ -106,7 +106,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
...
@@ -106,7 +106,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
if
(
good_dart
!=
Dart
::
nil
())
if
(
good_dart
!=
Dart
::
nil
())
{
{
Dart
aze
=
map
.
phi2
(
good_dart
)
;
if
(
good_dart
==
map
.
phi2
(
good_dart
))
if
(
good_dart
==
map
.
phi2
(
good_dart
))
{
{
map
.
sewFaces
(
d
,
good_dart
);
map
.
sewFaces
(
d
,
good_dart
);
...
...
include/Algo/Modelisation/subdivision.h
View file @
54d09f40
...
@@ -95,7 +95,7 @@ void LoopSubdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, cons
...
@@ -95,7 +95,7 @@ void LoopSubdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, cons
* Dual mesh computation
* Dual mesh computation
*/
*/
template
<
typename
PFP
>
template
<
typename
PFP
>
void
computeDual
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
selected
=
SelectorTrue
())
;
void
computeDual
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
selected
=
SelectorTrue
())
;
/**
/**
* Sqrt(3) subdivision scheme
* Sqrt(3) subdivision scheme
...
...
include/Algo/Modelisation/subdivision.hpp
View file @
54d09f40
...
@@ -435,32 +435,33 @@ void LoopSubdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, cons
...
@@ -435,32 +435,33 @@ void LoopSubdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, cons
}
}
template
<
typename
PFP
>
template
<
typename
PFP
>
void
computeDual
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
selected
)
void
computeDual
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
selected
)
{
{
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
AttributeHandler
<
Dart
>
phi1
=
map
.
template
getAttribute
<
Dart
>(
DART_ORBIT
,
"phi1"
)
;
AttributeHandler
<
Dart
>
phi1
=
map
.
template
getAttribute
<
Dart
>(
DART_ORBIT
,
"phi1"
)
;
AttributeHandler
<
Dart
>
phi_1
=
map
.
template
getAttribute
<
Dart
>(
DART_ORBIT
,
"phi_1"
)
;
AttributeHandler
<
Dart
>
phi_1
=
map
.
template
getAttribute
<
Dart
>(
DART_ORBIT
,
"phi_1"
)
;
AttributeHandler
<
Dart
>
new_phi1
=
map
.
template
addAttribute
<
Dart
>(
DART_ORBIT
,
"new_phi1"
)
;
AttributeHandler
<
Dart
>
new_phi1
=
map
.
template
addAttribute
<
Dart
>(
DART_ORBIT
,
"new_phi1"
)
;
AttributeHandler
<
Dart
>
new_phi_1
=
map
.
template
addAttribute
<
Dart
>(
DART_ORBIT
,
"new_phi_1"
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
{
Dart
dd
=
map
.
alpha1
(
d
)
;
Dart
dd
=
map
.
alpha1
(
d
)
;
new_phi1
[
d
]
=
dd
;
new_phi1
[
d
]
=
dd
;
phi_1
[
dd
]
=
d
;
new_
phi_1
[
dd
]
=
d
;
}
}
map
.
template
swapAttributes
<
Dart
>(
phi1
,
new_phi1
)
;
map
.
template
swapAttributes
<
Dart
>(
phi1
,
new_phi1
)
;
map
.
template
swapAttributes
<
Dart
>(
phi_1
,
new_phi_1
)
;
map
.
template
removeAttribute
<
Dart
>(
new_phi1
)
;
map
.
template
removeAttribute
<
Dart
>(
new_phi1
)
;
map
.
template
removeAttribute
<
Dart
>(
new_phi_1
)
;
map
.
swapEmbeddingContainers
(
VERTEX_ORBIT
,
FACE_ORBIT
)
;
}
}
template
<
typename
PFP
>
template
<
typename
PFP
>
void
Sqrt3Subdivision
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
selected
)
void
Sqrt3Subdivision
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
selected
)
{
{
computeDual
<
PFP
>
(
map
,
position
,
selected
);
// computeDual<PFP>(map
, selected);
trianguleFaces
<
PFP
>
(
map
,
position
,
selected
);
trianguleFaces
<
PFP
>
(
map
,
position
,
selected
);
}
}
...
...
include/Algo/Render/topo_vboRender.h
View file @
54d09f40
...
@@ -49,7 +49,6 @@ namespace VBO
...
@@ -49,7 +49,6 @@ namespace VBO
class
topo_VBORender
class
topo_VBORender
{
{
protected:
protected:
/**
/**
* vbo buffers
* vbo buffers
* 0: vertices darts
* 0: vertices darts
...
@@ -78,7 +77,6 @@ protected:
...
@@ -78,7 +77,6 @@ protected:
*/
*/
float
m_topo_relation_width
;
float
m_topo_relation_width
;
/**
/**
* attribut d'index dans le VBO
* attribut d'index dans le VBO
*/
*/
...
@@ -157,11 +155,9 @@ public:
...
@@ -157,11 +155,9 @@ public:
* @param b blue !
* @param b blue !
*/
*/
void
overdrawDart
(
Dart
d
,
float
width
,
float
r
,
float
g
,
float
b
);
void
overdrawDart
(
Dart
d
,
float
width
,
float
r
,
float
g
,
float
b
);
};
};
class
topo_VBORenderMapD
:
public
topo_VBORender
class
topo_VBORenderMapD
:
public
topo_VBORender
{
{
public:
public:
/**
/**
...
@@ -176,7 +172,7 @@ public:
...
@@ -176,7 +172,7 @@ public:
void
updateData
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
const
FunctorSelect
&
good
=
SelectorTrue
());
void
updateData
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
const
FunctorSelect
&
good
=
SelectorTrue
());
};
};
class
topo_VBORenderGMap
:
public
topo_VBORender
class
topo_VBORenderGMap
:
public
topo_VBORender
{
{
public:
public:
/**
/**
...
...
include/Algo/Render/topo_vboRender.hpp
View file @
54d09f40
...
@@ -78,7 +78,7 @@ void topo_VBORenderMapD::updateData(typename PFP::MAP& map, const typename PFP::
...
@@ -78,7 +78,7 @@ void topo_VBORenderMapD::updateData(typename PFP::MAP& map, const typename PFP::
glBufferDataARB
(
GL_ARRAY_BUFFER
,
2
*
m_nbDarts
*
sizeof
(
VEC3
),
0
,
GL_STREAM_DRAW
);
glBufferDataARB
(
GL_ARRAY_BUFFER
,
2
*
m_nbDarts
*
sizeof
(
VEC3
),
0
,
GL_STREAM_DRAW
);
GLvoid
*
PositionDartsBuffer
=
glMapBufferARB
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
GLvoid
*
PositionDartsBuffer
=
glMapBufferARB
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
VEC3
*
positionDartBuf
=
reinterpret_cast
<
VEC3
*>
(
PositionDartsBuffer
);
VEC3
*
positionDartBuf
=
reinterpret_cast
<
VEC3
*>
(
PositionDartsBuffer
);
unsigned
int
posDBI
=
0
;
unsigned
int
posDBI
=
0
;
DartMarker
mf
(
map
);
DartMarker
mf
(
map
);
for
(
std
::
vector
<
Dart
>::
iterator
id
=
vecDarts
.
begin
();
id
!=
vecDarts
.
end
();
id
++
)
for
(
std
::
vector
<
Dart
>::
iterator
id
=
vecDarts
.
begin
();
id
!=
vecDarts
.
end
();
id
++
)
...
@@ -176,12 +176,8 @@ void topo_VBORenderMapD::updateData(typename PFP::MAP& map, const typename PFP::
...
@@ -176,12 +176,8 @@ void topo_VBORenderMapD::updateData(typename PFP::MAP& map, const typename PFP::
glBindBufferARB
(
GL_ELEMENT_ARRAY_BUFFER
,
m_VBOBuffers
[
2
]);
glBindBufferARB
(
GL_ELEMENT_ARRAY_BUFFER
,
m_VBOBuffers
[
2
]);
glUnmapBufferARB
(
GL_ELEMENT_ARRAY_BUFFER
);
glUnmapBufferARB
(
GL_ELEMENT_ARRAY_BUFFER
);
}
}
template
<
typename
PFP
>
template
<
typename
PFP
>
void
topo_VBORenderGMap
::
updateData
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
const
FunctorSelect
&
good
)
void
topo_VBORenderGMap
::
updateData
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
const
FunctorSelect
&
good
)
{
{
...
...
include/Container/attributeContainer.h
View file @
54d09f40
...
@@ -71,6 +71,8 @@ protected:
...
@@ -71,6 +71,8 @@ protected:
*/
*/
std
::
vector
<
AttributeMultiVectorGen
*>
m_tableAttribs
;
std
::
vector
<
AttributeMultiVectorGen
*>
m_tableAttribs
;
std
::
vector
<
unsigned
int
>
m_freeIndices
;
/**
/**
* map de correspondance string / indice pour les attributs
* map de correspondance string / indice pour les attributs
*/
*/
...
@@ -246,7 +248,7 @@ public:
...
@@ -246,7 +248,7 @@ public:
* @param strings (OUT) tableau des noms d'attributs
* @param strings (OUT) tableau des noms d'attributs
* @return le nombre d'attributs
* @return le nombre d'attributs
*/
*/
unsigned
int
getAttributes
Strings
(
std
::
vector
<
std
::
string
>&
string
s
);
unsigned
int
getAttributes
Names
(
std
::
vector
<
std
::
string
>&
name
s
);
/**
/**
* get the name of an attribute, given its index in the container
* get the name of an attribute, given its index in the container
...
@@ -394,11 +396,6 @@ public:
...
@@ -394,11 +396,6 @@ public:
*/
*/
unsigned
int
memoryTotalSize
()
;
unsigned
int
memoryTotalSize
()
;
/**
* Nombre d'attributs
*/
unsigned
int
nbAttributes
();
/**
/**
* Nombre de reference d'une ligne
* Nombre de reference d'une ligne
*/
*/
...
...
include/Container/attributeContainer.hpp
View file @
54d09f40
/*******************************************************************************
//#include <typeinfo>
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
//#include <stdio.h>
* version 0.1 *
//#include <string.h>
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
//#include <libxml/encoding.h>
* *
//#include <libxml/xmlwriter.h>
* 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 *
#include<iostream>
* 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: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <iostream>
#include <cassert>
#include <cassert>
#include "Container/registered.h"
#include "Container/registered.h"
#include "Utils/nameTypes.h"
#include "Utils/nameTypes.h"
...
@@ -27,16 +44,24 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName)
...
@@ -27,16 +44,24 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName)
{
{
MapNameId
::
iterator
it
=
m_attribNameMap
.
find
(
attribName
);
MapNameId
::
iterator
it
=
m_attribNameMap
.
find
(
attribName
);
if
(
it
!=
m_attribNameMap
.
end
())
if
(
it
!=
m_attribNameMap
.
end
())
{
return
UNKNOWN
;
return
UNKNOWN
;
}
}
}
// new attribut
// new attribut
AttributeMultiVector
<
T
>*
ptr
=
new
AttributeMultiVector
<
T
>
(
attribName
,
nametype
);
AttributeMultiVector
<
T
>*
amv
=
new
AttributeMultiVector
<
T
>
(
attribName
,
nametype
);
unsigned
int
idxAttrib
=
m_tableAttribs
.
size
();
// add it to table of attribut_manager
unsigned
int
idxAttrib
;
m_tableAttribs
.
push_back
(
ptr
);
if
(
!
m_freeIndices
.
empty
())
{
idxAttrib
=
m_freeIndices
.
back
()
;
m_freeIndices
.
pop_back
()
;
m_tableAttribs
[
idxAttrib
]
=
amv
;
}
else
{
idxAttrib
=
m_tableAttribs
.
size
();
m_tableAttribs
.
push_back
(
amv
);
}
// add it in the map
// add it in the map
if
(
attribName
==
""
)
// if no name, generate a fake name
if
(
attribName
==
""
)
// if no name, generate a fake name
...
@@ -44,6 +69,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName)
...
@@ -44,6 +69,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName)
std
::
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
"unknown"
<<
m_nbUnknown
++
;
ss
<<
"unknown"
<<
m_nbUnknown
++
;
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
ss
.
str
(),
idxAttrib
));
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
ss
.
str
(),
idxAttrib
));
amv
->
setName
(
ss
.
str
());
}
}
else
else
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
attribName
,
idxAttrib
));
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
attribName
,
idxAttrib
));
...
@@ -53,7 +79,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName)
...
@@ -53,7 +79,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName)
// resize the new attribute container to have same size than others
// resize the new attribute container to have same size than others
int
nbb
=
m_holesBlocks
.
size
();
int
nbb
=
m_holesBlocks
.
size
();
ptr
->
setNbBlocks
(
nbb
);
amv
->
setNbBlocks
(
nbb
);
m_nbAttributes
++
;
m_nbAttributes
++
;
...
@@ -68,16 +94,22 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName, con
...
@@ -68,16 +94,22 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName, con
{
{
MapNameId
::
iterator
it
=
m_attribNameMap
.
find
(
attribName
);
MapNameId
::
iterator
it
=
m_attribNameMap
.
find
(
attribName
);
if
(
it
!=
m_attribNameMap
.
end
())
if
(
it
!=
m_attribNameMap
.
end
())
{
return
UNKNOWN
;
return
UNKNOWN
;
}
}
}
// new attribut
// new attribut
AttributeMultiVector
<
T
>*
ptr
=
new
AttributeMultiVector
<
T
>
(
attribName
,
nametype
);
AttributeMultiVector
<
T
>*
amv
=
new
AttributeMultiVector
<
T
>
(
attribName
,
nametype
);
// add it to table of attribut_manager
// add it to table of attribut_manager
m_tableAttribs
[
idxAttrib
]
=
ptr
;
m_tableAttribs
[
idxAttrib
]
=
amv
;
// add it in the map
// add it in the map
if
(
attribName
==
""
)
// if no name, generate a fake name
{
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
));
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
attribName
,
idxAttrib
));
// maj taille d'une ligne
// maj taille d'une ligne
...
@@ -85,7 +117,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName, con
...
@@ -85,7 +117,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName, con
// resize the new attribute container to have same size than others
// resize the new attribute container to have same size than others
int
nbb
=
m_holesBlocks
.
size
();
int
nbb
=
m_holesBlocks
.
size
();
ptr
->
setNbBlocks
(
nbb
);
amv
->
setNbBlocks
(
nbb
);
m_nbAttributes
++
;
m_nbAttributes
++
;
...
@@ -94,7 +126,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName, con
...
@@ -94,7 +126,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName, con
inline
unsigned
int
AttributeContainer
::
getNbAttributes
()
inline
unsigned
int
AttributeContainer
::
getNbAttributes
()
{
{
return
m_
tableAttribs
.
size
()
;
return
m_
nbAttributes
;
}
}
///////////////////////////
///////////////////////////
...
@@ -104,12 +136,12 @@ inline unsigned int AttributeContainer::getNbAttributes()
...
@@ -104,12 +136,12 @@ inline unsigned int AttributeContainer::getNbAttributes()
template
<
typename
T
>
template
<
typename
T
>
T
&
AttributeContainer
::
getData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
)
T
&
AttributeContainer
::
getData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
)
{
{
assert
(
eltIdx
<
m_maxSize
&&
"Attribut non existant (indice trop grand)"
);
assert
(
eltIdx
<
m_maxSize
||
!
"Attribut non existant (indice trop grand)"
);
assert
(
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
)
&&
"Attribut non existant"
);
assert
(
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
)
||
!
"Attribut non existant"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
&&
"Attribut detruit"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
||
!
"Attribut detruit"
);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
assert
((
atm
!=
NULL
)
&&
"type attribut non concordant"
);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
return
atm
->
operator
[](
eltIdx
);
return
atm
->
operator
[](
eltIdx
);
}
}
...
@@ -117,12 +149,12 @@ T& AttributeContainer::getData(unsigned int codeAttrib, unsigned int eltIdx)
...
@@ -117,12 +149,12 @@ T& AttributeContainer::getData(unsigned int codeAttrib, unsigned int eltIdx)
template
<
typename
T
>
template
<
typename
T
>
const
T
&
AttributeContainer
::
getData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
)
const
const
T
&
AttributeContainer
::
getData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
)
const
{
{
assert
(
eltIdx
<
m_maxSize
&&
"Attribut non existant (indice trop grand)"
);
assert
(
eltIdx
<
m_maxSize
||
!
"Attribut non existant (indice trop grand)"
);
assert
(
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
)
&&
"Attribut non existant"
);
assert
(
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
)
||
!
"Attribut non existant"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
&&
"Attribut detruit"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
||
!
"Attribut detruit"
);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
assert
((
atm
!=
NULL
)
&&
"type attribut non concordant"
);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
return
atm
->
operator
[](
eltIdx
);
return
atm
->
operator
[](
eltIdx
);
}
}
...
@@ -130,13 +162,12 @@ const T& AttributeContainer::getData(unsigned int codeAttrib, unsigned int eltId
...
@@ -130,13 +162,12 @@ const T& AttributeContainer::getData(unsigned int codeAttrib, unsigned int eltId
template
<
typename
T
>
template
<
typename
T
>
void
AttributeContainer
::
setData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
,
const
T
&
data
)
void
AttributeContainer
::
setData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
,
const
T
&
data
)
{
{
assert
(
eltIdx
<
m_maxSize
||
!
"Attribut non existant (indice trop grand)"
);
assert
(
eltIdx
<
m_maxSize
&&
"Attribut non existant (indice trop grand)"
);
assert
(
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
)
||
!
"Attribut non existant"
);
assert
(
m_holesBlocks
[
eltIdx
/
_BLOCKSIZE_
]
->
used
(
eltIdx
%
_BLOCKSIZE_
)
&&
"Attribut non existant"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
||
!
"Attribut detruit"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
&&
"Attribut detruit"
);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
assert
((
atm
!=
NULL
)
&&
"type attribut non concordant"
);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
atm
->
operator
[](
eltIdx
)
=
data
;
atm
->
operator
[](
eltIdx
)
=
data
;
}
}
...
@@ -152,11 +183,11 @@ void AttributeContainer::setData(unsigned int codeAttrib, unsigned int eltIdx,
...
@@ -152,11 +183,11 @@ void AttributeContainer::setData(unsigned int codeAttrib, unsigned int eltIdx,
template
<
typename
T
>
template
<
typename
T
>
AttributeMultiVector
<
T
>&
AttributeContainer
::
getDataVector
(
unsigned
int
codeAttrib
)
AttributeMultiVector
<
T
>&
AttributeContainer
::
getDataVector
(
unsigned
int
codeAttrib
)
{
{
assert
((
codeAttrib
<
m_tableAttribs
.
size
())
&&
"Attribut inexistant"
);
assert
((
codeAttrib
<
m_tableAttribs
.
size
())
||
!
"Attribut inexistant"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
&&
"Attribut detruit"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
||
!
"Attribut detruit"
);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
assert
((
atm
!=
NULL
)
&&
"type attribut non concordant"
);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
return
*
atm
;
return
*
atm
;
}
}
...
@@ -169,11 +200,11 @@ bool AttributeContainer::getAttributesVector(const std::string& attribName, Attr
...
@@ -169,11 +200,11 @@ bool AttributeContainer::getAttributesVector(const std::string& attribName, Attr
int
codeAttrib
=
it
->
second
;
int
codeAttrib
=
it
->
second
;
if
(
m_tableAttribs
[
codeAttrib
]
==
NULL
)
if
(
m_tableAttribs
[
codeAttrib
]
==
NULL
)
return
false
;
return
false
;
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
if
(
atm
==
NULL
)
if
(
atm
==
NULL
)
return
false
;
return
false
;
*
ptr
=
atm
;
*
ptr
=
atm
;
...
@@ -188,7 +219,7 @@ template <typename T>
...
@@ -188,7 +219,7 @@ template <typename T>
unsigned
int
AttributeContainer
::
getAddresses
(
unsigned
int
attr
,
std
::
vector
<
T
*>&
vect_adr
)
unsigned
int
AttributeContainer
::
getAddresses
(
unsigned
int
attr
,
std
::
vector
<
T
*>&
vect_adr
)
{
{
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
attr
]);
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
attr
]);
assert
((
atm
!=
NULL
)
&&
"type attribut non concordant"
);
assert
((
atm
!=
NULL
)
||
!
"type attribut non concordant"
);
return
atm
->
getStartAddresses
(
vect_adr
);
return
atm
->
getStartAddresses
(
vect_adr
);
}
}
...
...
include/Container/attributeMultiVector.h
View file @
54d09f40
...
@@ -99,9 +99,13 @@ public:
...
@@ -99,9 +99,13 @@ public:
/**
/**
* get name of the type of attribute
* get name of the type of attribute
*/
*/
const
std
::
string
&
getTypeName
()
{
return
m_typeName
;}
const
std
::
string
&
getTypeName
()
{
return
m_typeName
;
}
const
std
::
string
&
getName
()
{
return
m_attName
;}
void
setTypeName
(
const
std
::
string
&
n
)
{
m_typeName
=
n
;
}
const
std
::
string
&
getName
()
{
return
m_attName
;
}
void
setName
(
const
std
::
string
&
n
)
{
m_attName
=
n
;
}