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
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
Hide 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)
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'
:
{
CellMarker
markVisit
(
myMap
,
VERTEX_CELL
)
;
...
...
include/Algo/Import/importMesh.hpp
View file @
54d09f40
...
...
@@ -40,7 +40,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
{
typedef
typename
PFP
::
VEC3
VEC3
;
AutoAttributeHandler
<
NoMathIONameAttribute
<
std
::
vector
<
Dart
>
>
>
vecDartsPerVertex
(
map
,
VERTEX_ORBIT
,
"incidents"
);
AutoAttributeHandler
<
NoMathIONameAttribute
<
std
::
vector
<
Dart
>
>
>
vecDartsPerVertex
(
map
,
VERTEX_ORBIT
,
"incidents"
);
unsigned
nbf
=
mts
.
getNbFaces
();
int
index
=
0
;
...
...
@@ -106,7 +106,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
if
(
good_dart
!=
Dart
::
nil
())
{
Dart
aze
=
map
.
phi2
(
good_dart
)
;
if
(
good_dart
==
map
.
phi2
(
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
* Dual mesh computation
*/
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
...
...
include/Algo/Modelisation/subdivision.hpp
View file @
54d09f40
...
...
@@ -435,32 +435,33 @@ void LoopSubdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, cons
}
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
>
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_phi_1
=
map
.
template
addAttribute
<
Dart
>(
DART_ORBIT
,
"new_phi_1"
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
Dart
dd
=
map
.
alpha1
(
d
)
;
new_phi1
[
d
]
=
dd
;
phi_1
[
dd
]
=
d
;
new_
phi_1
[
dd
]
=
d
;
}
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_phi_1
)
;
map
.
swapEmbeddingContainers
(
VERTEX_ORBIT
,
FACE_ORBIT
)
;
}
template
<
typename
PFP
>
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
);
}
...
...
include/Algo/Render/topo_vboRender.h
View file @
54d09f40
...
...
@@ -49,7 +49,6 @@ namespace VBO
class
topo_VBORender
{
protected:
/**
* vbo buffers
* 0: vertices darts
...
...
@@ -78,7 +77,6 @@ protected:
*/
float
m_topo_relation_width
;
/**
* attribut d'index dans le VBO
*/
...
...
@@ -157,11 +155,9 @@ public:
* @param b blue !
*/
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:
/**
...
...
@@ -176,7 +172,7 @@ public:
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:
/**
...
...
include/Algo/Render/topo_vboRender.hpp
View file @
54d09f40
...
...
@@ -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
);
GLvoid
*
PositionDartsBuffer
=
glMapBufferARB
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
VEC3
*
positionDartBuf
=
reinterpret_cast
<
VEC3
*>
(
PositionDartsBuffer
);
unsigned
int
posDBI
=
0
;
unsigned
int
posDBI
=
0
;
DartMarker
mf
(
map
);
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::
glBindBufferARB
(
GL_ELEMENT_ARRAY_BUFFER
,
m_VBOBuffers
[
2
]);
glUnmapBufferARB
(
GL_ELEMENT_ARRAY_BUFFER
);
}
template
<
typename
PFP
>
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:
*/
std
::
vector
<
AttributeMultiVectorGen
*>
m_tableAttribs
;
std
::
vector
<
unsigned
int
>
m_freeIndices
;
/**
* map de correspondance string / indice pour les attributs
*/
...
...
@@ -246,7 +248,7 @@ public:
* @param strings (OUT) tableau des noms 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
...
...
@@ -394,11 +396,6 @@ public:
*/
unsigned
int
memoryTotalSize
()
;
/**
* Nombre d'attributs
*/
unsigned
int
nbAttributes
();
/**
* Nombre de reference d'une ligne
*/
...
...
include/Container/attributeContainer.hpp
View file @
54d09f40
//#include <typeinfo>
//#include <stdio.h>
//#include <string.h>
//#include <libxml/encoding.h>
//#include <libxml/xmlwriter.h>
#include<iostream>
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <iostream>
#include <cassert>
#include "Container/registered.h"
#include "Utils/nameTypes.h"
...
...
@@ -27,16 +44,24 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName)
{
MapNameId
::
iterator
it
=
m_attribNameMap
.
find
(
attribName
);
if
(
it
!=
m_attribNameMap
.
end
())
{
return
UNKNOWN
;
}
}
// new attribut
AttributeMultiVector
<
T
>*
ptr
=
new
AttributeMultiVector
<
T
>
(
attribName
,
nametype
);
unsigned
int
idxAttrib
=
m_tableAttribs
.
size
();
// add it to table of attribut_manager
m_tableAttribs
.
push_back
(
ptr
);
AttributeMultiVector
<
T
>*
amv
=
new
AttributeMultiVector
<
T
>
(
attribName
,
nametype
);
unsigned
int
idxAttrib
;
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
if
(
attribName
==
""
)
// if no name, generate a fake name
...
...
@@ -44,6 +69,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& 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
));
...
...
@@ -53,7 +79,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName)
// resize the new attribute container to have same size than others
int
nbb
=
m_holesBlocks
.
size
();
ptr
->
setNbBlocks
(
nbb
);
amv
->
setNbBlocks
(
nbb
);
m_nbAttributes
++
;
...
...
@@ -68,24 +94,30 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName, con
{
MapNameId
::
iterator
it
=
m_attribNameMap
.
find
(
attribName
);
if
(
it
!=
m_attribNameMap
.
end
())
{
return
UNKNOWN
;
}
}
// 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
m_tableAttribs
[
idxAttrib
]
=
ptr
;
m_tableAttribs
[
idxAttrib
]
=
amv
;
// add it in the map
m_attribNameMap
.
insert
(
std
::
pair
<
std
::
string
,
unsigned
int
>
(
attribName
,
idxAttrib
));
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
));
// 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
();
ptr
->
setNbBlocks
(
nbb
);
amv
->
setNbBlocks
(
nbb
);
m_nbAttributes
++
;
...
...
@@ -94,7 +126,7 @@ unsigned int AttributeContainer::addAttribute(const std::string& attribName, con
inline
unsigned
int
AttributeContainer
::
getNbAttributes
()
{
return
m_
tableAttribs
.
size
()
;
return
m_
nbAttributes
;
}
///////////////////////////
...
...
@@ -104,12 +136,12 @@ inline unsigned int AttributeContainer::getNbAttributes()
template
<
typename
T
>
T
&
AttributeContainer
::
getData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
)
{
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"
);
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"
);
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
);
}
...
...
@@ -117,12 +149,12 @@ T& AttributeContainer::getData(unsigned int codeAttrib, unsigned int eltIdx)
template
<
typename
T
>
const
T
&
AttributeContainer
::
getData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
)
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"
);
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"
);
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
);
}
...
...
@@ -130,13 +162,12 @@ const T& AttributeContainer::getData(unsigned int codeAttrib, unsigned int eltId
template
<
typename
T
>
void
AttributeContainer
::
setData
(
unsigned
int
codeAttrib
,
unsigned
int
eltIdx
,
const
T
&
data
)
{
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"
);
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"
);
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
;
}
...
...
@@ -152,11 +183,11 @@ void AttributeContainer::setData(unsigned int codeAttrib, unsigned int eltIdx,
template
<
typename
T
>
AttributeMultiVector
<
T
>&
AttributeContainer
::
getDataVector
(
unsigned
int
codeAttrib
)
{
assert
((
codeAttrib
<
m_tableAttribs
.
size
())
&&
"Attribut inexistant"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
&&
"Attribut detruit"
);
assert
((
codeAttrib
<
m_tableAttribs
.
size
())
||
!
"Attribut inexistant"
);
assert
((
m_tableAttribs
[
codeAttrib
]
!=
NULL
)
||
!
"Attribut detruit"
);
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
;
}
...
...
@@ -169,11 +200,11 @@ bool AttributeContainer::getAttributesVector(const std::string& attribName, Attr
int
codeAttrib
=
it
->
second
;
if
(
m_tableAttribs
[
codeAttrib
]
==
NULL
)
if
(
m_tableAttribs
[
codeAttrib
]
==
NULL
)
return
false
;
AttributeMultiVector
<
T
>*
atm
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
m_tableAttribs
[
codeAttrib
]);
if
(
atm
==
NULL
)
if
(
atm
==
NULL
)
return
false
;
*
ptr
=
atm
;
...
...
@@ -188,7 +219,7 @@ template <typename T>
unsigned
int
AttributeContainer
::
getAddresses
(
unsigned
int
attr
,
std
::
vector
<
T
*>&
vect_adr
)
{
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
);
}
...
...
include/Container/attributeMultiVector.h
View file @
54d09f40
...
...
@@ -99,9 +99,13 @@ public:
/**
* 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
;
}
virtual
void
saveBin
(
CGoGNostream
&
fs
,
unsigned
int
id
)
=
0
;
...
...
@@ -115,8 +119,6 @@ public:
virtual
void
input
(
unsigned
int
i
,
const
std
::
string
&
st
)
=
0
;
virtual
bool
swap
(
AttributeMultiVectorGen
&
att
)
=
0
;
virtual
bool
merge
(
const
AttributeMultiVectorGen
&
att
)
=
0
;
virtual
void
addBlocksBefore
(
unsigned
int
nbb
)
=
0
;
...
...
@@ -162,13 +164,12 @@ public:
};
template
<
typename
T
>
class
AttributeMultiVector
:
public
AttributeMultiVectorGen
class
AttributeMultiVector
:
public
AttributeMultiVectorGen
{
/**
* table of blocks of data ptr: vectors!
*/
std
::
vector
<
T
*
>
m_tableData
;
std
::
vector
<
T
*>
m_tableData
;
public:
...
...
@@ -184,8 +185,6 @@ public:
AttributeMultiVectorGen
*
new_obj
();
bool
swap
(
AttributeMultiVectorGen
&
att
);
bool
merge
(
const
AttributeMultiVectorGen
&
att
);
/**
...
...
@@ -256,14 +255,12 @@ public:
*/
void
saveBin
(
CGoGNostream
&
fs
,
unsigned
int
id
);
/**
* lecture binaire
* @param fs filestream
*/
bool
loadBin
(
CGoGNistream
&
fs
);
// Processing attributes
void
affect
(
unsigned
int
i
,
unsigned
int
j
);
...
...
@@ -279,7 +276,7 @@ public:
void
lerp
(
unsigned
res
,
unsigned
int
i
,
unsigned
int
j
,
double
alpha
);
};
}
}
// namespace CGoGN
#include "attributeMultiVector.hpp"
...
...
include/Container/attributeMultiVector.hpp
View file @
54d09f40
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace
CGoGN
{
inline
AttributeMultiVectorGen
::
AttributeMultiVectorGen
(
const
std
::
string
&
strName
,
const
std
::
string
&
strType
)
:
m_attName
(
strName
),
m_typeName
(
strType
),
m_toProcess
(
true
)
m_attName
(
strName
),
m_typeName
(
strType
),
m_toProcess
(
true
)
{}
inline
AttributeMultiVectorGen
::
AttributeMultiVectorGen
()
:
m_toProcess
(
true
)
...
...
@@ -70,7 +93,12 @@ bool AttributeMultiVector<T>::copy(const AttributeMultiVectorGen* atmvg)
if
(
atmv
==
NULL
)
{
std
::
cerr
<<
"copy attribute of different type"
<<
std
::
endl
;
std
::
cerr
<<
"trying to copy attributes of different type"
<<
std
::
endl
;
return
false
;
}
if
(
atmv
->
m_typeName
!=
m_typeName
)
{
std
::
cerr
<<
"trying to swap attributes with different type names"
<<
std
::
endl
;
return
false
;
}
...
...
@@ -88,35 +116,40 @@ bool AttributeMultiVector<T>::swap(AttributeMultiVectorGen* atmvg)
if
(
atmv
==
NULL
)
{
std
::
cerr
<<
"swap attribute of different type"
<<
std
::
endl
;
return
false
;
}
m_tableData
.
swap
(
atmv
->
m_tableData
)
;
return
true
;
}
template
<
typename
T
>
bool
AttributeMultiVector
<
T
>::
swap
(
AttributeMultiVectorGen
&
att
)
{
AttributeMultiVector
<
T
>*
attrib
=
dynamic_cast
<
AttributeMultiVector
<
T
>*
>
(
&
att
);
if
(
attrib
==
NULL
)
{
std
::
cerr
<<
"Erreur, swap de container de types differents"
<<
std
::
endl
;
std
::
cerr
<<
"trying to swap attributes of different type"
<<
std
::
endl
;
return
false
;
}
if
(
at
trib
->
m_typeName
!=
m_typeName
)
if
(
at
mv
->
m_typeName
!=
m_typeName
)
{
std
::
cerr
<<
"
Erreur, swap de container avec noms de type differents"
<<
std
::
endl
;
std
::
cerr
<<
"
trying to swap attributes with different type names"
<<
std
::
endl
;
return
false
;
}
m_tableData
.
swap
(
attrib
->
m_tableData
);
m_typeName
.
swap
(
attrib
->
m_typeName
);
m_tableData
.
swap
(
atmv
->
m_tableData
)
;
return
true
;
}
//template <typename T>
//bool AttributeMultiVector<T>::swap(AttributeMultiVectorGen& att)
//{
// AttributeMultiVector<T>* attrib = dynamic_cast<AttributeMultiVector<T>*>(&att);
// if (attrib==NULL)
// {
// std::cerr << "Erreur, swap de container de types differents"<<std::endl;
// return false;
// }
// if (attrib->m_typeName != m_typeName)