Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sauvage
CGoGN
Commits
498e5870
Commit
498e5870
authored
Jan 28, 2011
by
Pierre Kraemer
Browse files
Suppression du INIT_STATICS + code mort registered attributes..
parent
f75eb2f8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Apps/Examples/SocialAgents/include/viewer.h
View file @
498e5870
...
...
@@ -42,11 +42,8 @@
// #include "Algo/Render/topo_vboRender.h"
#include
"Algo/Render/topo_render.h"
using
namespace
CGoGN
;
INIT_STATICS_MAP
()
;
typedef
PFP
::
MAP
MAP
;
class
MyGlutWin
:
public
Utils
::
GlutWin_ATB
...
...
Apps/Examples/miniTest.cpp
View file @
498e5870
...
...
@@ -65,8 +65,6 @@ struct PFP
typedef
AttributeHandler
<
MATRIX36
>
TRGBFUNCS
;
};
INIT_STATICS_MAP
()
;
typedef
PFP
::
MAP
MAP
;
MAP
myMap
;
...
...
include/Container/attr_register.h
deleted
100644 → 0
View file @
f75eb2f8
/*
* attr_register.h
*
* Created on: May 28, 2010
* Author: thery
*/
#include
<iostream>
#include
<string>
#include
<libxml/encoding.h>
#include
<libxml/xmlwriter.h>
#include
"attrib_container.h"
namespace
CGoGN
{
/**
* Classe d'enregistrement d'attribut a
*/
class
RegisteredAttribute
{
protected:
std
::
string
m_name
;
public:
/**
* affecte un nom de type a l'attribut
*/
void
setTypeName
(
const
std
::
string
&
nameType
)
{
n_name
=
nameType
;}
/**
* recupere le nom de type affecté à l'attribut
*/
const
std
::
string
&
getTypeName
()
{
return
m_name
;}
/**
* Ajout de l'attribut au container (A INMPLEMENTER)
*/
virtual
AttribContainer
::
Attr_Id
addAttribute
(
AttribContainer
&
container
,
const
std
::
string
&
attribName
,
unsigned
int
id
)
=
0
;
/**
* Lecture en XML d'une donnée et la met dans le container (A INMPLEMENTER)
*/
virtual
bool
readXml
(
xmlNode
*
node
,
AttribContainer
&
container
,
unsigned
int
att_id
,
unsigned
int
index
);
/**
* Ecriture des elements dans un arbre XML (A INMPLEMENTER)
*/
virtual
bool
writeXml
(
xmlTextWriterPtr
writer
,
const
AttribContainer
&
container
,
unsigned
int
att_id
);
/**
* Lecture binaire (A INMPLEMENTER)
*/
virtual
bool
readBin
(
const
std
::
fstream
&
fs
,
AttribContainer
&
container
,
unsigned
int
att_id
);
/**
* Ecriture binaire (A INMPLEMENTER)
*/
virtual
bool
writeBin
(
std
::
fstream
&
fs
,
const
AttribContainer
&
container
,
unsigned
int
att_id
);
};
// version template du type qui marche
//
/**
* Version template de la classe d'enregistrement d'attribut
* Fonction avec tout type qui répond aux contraintes suivantes:
* - I/O avec les flux (operator >> et <<)
* - copie mémoire directe utilisable (pas de pointeurs dans la structure)
*/
template
<
typename
T
>
class
RegisteredAttributeSimple
:
RegisteredAttribute
{
public:
AttribContainer
::
Attr_Id
addAttribute
(
AttribContainer
&
container
,
const
std
::
string
&
attribName
,
unsigned
int
id
)
{
container
.
addAttribute
<
T
>
(
attribName
,
id
);
}
void
readXml
(
xmlNodePtr
node
,
AttribContainer
&
container
,
unsigned
int
codeAttrib
)
{
// recuperer le pseudo-tableau d'attribut
AttribManager
<
T
>&
atm
=
container
.
getDataVector
(
codeAttrib
);
AttribContainer
::
iterator
i
=
container
.
begin
();
std
::
stringstream
ss
;
// lit tous les attributs dans le noeud xml et les inserts dans le container
for
(
xmlNode
*
cur
=
node
->
children
;
cur
!=
NULL
;
cur
=
cur
->
next
)
{
//std::string st((char*)(xmlNodeGetContent(cur)));
ss
.
str
(
std
::
string
((
char
*
)(
xmlNodeGetContent
(
cur
)))
);
ss
>>
atm
[
i
];
container
.
next
(
i
);
}
}
void
writeXml
(
xmlTextWriterPtr
writer
,
const
AttribContainer
&
container
,
unsigned
int
codeAttrib
)
{
// recuperer le pseudo-tableau d'attribut
const
AttribManager
<
T
>&
atm
=
container
.
getDataVector
(
codeAttrib
);
std
::
stringstream
ss
;
// parcours le tableau avec un iterateur du container et ecrit les elements
for
(
AttribContainer
::
const_iterator
i
=
container
.
begin
();
i
!=
container
.
end
();
container
.
next
(
i
))
{
ss
<<
atm
[
i
];
rc
=
xmlTextWriterWriteElement
(
writer
,
BAD_CAST
"val "
,
(
xmlChar
*
)(
ss
.
str
().
c_str
()));
ss
.
str
(
""
);
}
}
bool
readBin
(
const
std
::
fstream
&
fs
,
AttribContainer
&
container
,
unsigned
int
att_id
)
{
// recupere les pointeurs et longueurs des zones contigues dans le container
std
::
vector
<
T
*>
vect_adr
;
std
::
vector
<
unsigned
int
>
vect_len
;
unsigned
int
nb
=
container
.
getAddresses
<
T
>
(
att_id
,
vect_adr
,
vect_len
);
// lit les zones directement depuis le fichier
for
(
int
i
=
0
;
i
<
nb
;
++
i
)
fs
.
read
(
reinterpret_cast
<
const
char
*>
(
vect_adr
[
i
]),
vect_len
[
i
]
*
sizeof
(
T
));
}
bool
writeBin
(
std
::
fstream
&
fs
,
const
AttribContainer
&
container
,
unsigned
int
att_id
)
{
// recupere les pointeurs et longueurs des zones contigues dans le container
std
::
vector
<
T
*>
vect_adr
;
std
::
vector
<
unsigned
int
>
vect_len
;
unsigned
int
nb
=
container
.
getAddresses
<
T
>
(
att_id
,
vect_adr
,
vect_len
);
// ecrit les zones directement dans le fichier
for
(
int
i
=
0
;
i
<
nb
;
++
i
)
fs
.
write
(
reinterpret_cast
<
const
char
*>
(
vect_adr
[
i
]),
vect_len
[
i
]
*
sizeof
(
T
));
}
};
template
<
typename
R
>
bool
registerAttribute
(
const
std
::
string
&
nameType
)
{
R
*
rc
=
new
RegisteredAttributeSimple
<
R
>
;
RegisteredAttribute
*
ra
=
dynamic_cast
<
RegisteredAttribute
*>
(
rc
);
if
(
ra
==
NULL
)
{
std
::
err
<<
"Erreur enregistrement attribut"
<<
std
::
endl
;
return
false
;
}
ra
->
setTypeName
(
nametype
);
m_attributes_registry_map
.
insert
(
std
::
pair
<
std
::
string
,
RegisteredAttribute
*>
(
nametype
),
ra
);
}
}
// registerAttribute< Vec3f >(std::string("Vec3f"));
include/Container/attrib_container.hpp
View file @
498e5870
...
...
@@ -191,23 +191,6 @@ unsigned int AttribContainer::getAddresses(unsigned int attr, std::vector<T*>& v
// Enregistrement attributs
//////////////////////////////
//template <typename R>
//bool AttribContainer::registerAttribute(const std::string &nameType)
//{
// RegisteredBasedAttribute* ra = new RegisteredAttribute<R>;
// if (ra == NULL)
// {
// std::cerr << "Erreur enregistrement attribut"<<std::endl;
// return false;
// }
//
// ra->setTypeName(nameType);
//
// m_attributes_registry_map->insert(std::pair<std::string, RegisteredBasedAttribute*>(nameType,ra));
// return true;
//}
//// INLINED FUNCTIONS
inline
bool
AttribContainer
::
used
(
unsigned
int
eltIdx
)
const
{
...
...
include/Container/registered.h
View file @
498e5870
...
...
@@ -23,12 +23,12 @@ public:
/**
* affecte un nom de type a l'attribut
*/
void
setTypeName
(
const
std
::
string
&
nameType
)
{
m_name
=
nameType
;}
void
setTypeName
(
const
std
::
string
&
nameType
)
{
m_name
=
nameType
;
}
/**
* recupere le nom de type affecté à l'attribut
*/
const
std
::
string
&
getTypeName
()
{
return
m_name
;}
const
std
::
string
&
getTypeName
()
{
return
m_name
;
}
/**
* Ajout de l'attribut au container (A INMPLEMENTER)
...
...
@@ -61,4 +61,3 @@ public:
}
#endif
/* REGISTRED_H_ */
include/Topology/generic/genericmap.h
View file @
498e5870
...
...
@@ -51,12 +51,6 @@
#include
"Topology/generic/functor.h"
// Small macro to init static members
// to be called in main just after the PFP declaration
#define INIT_STATICS_MAP() \
std::map< std::string, RegisteredBaseAttribute* > GenericMap::m_attributes_registry_map = std::map< std::string, RegisteredBaseAttribute* >();
namespace
CGoGN
{
...
...
include/Topology/generic/genericmap.hpp
View file @
498e5870
...
...
@@ -22,8 +22,6 @@
* *
*******************************************************************************/
#include
"Container/registered.h"
namespace
CGoGN
{
...
...
src/Topology/generic/genericmap.cpp
View file @
498e5870
...
...
@@ -26,10 +26,13 @@
#include
"Topology/generic/dartmarker.h"
#include
"Geometry/vector_gen.h"
#include
"Geometry/matrix.h"
#include
"Container/registered.h"
namespace
CGoGN
{
std
::
map
<
std
::
string
,
RegisteredBaseAttribute
*
>
GenericMap
::
m_attributes_registry_map
=
std
::
map
<
std
::
string
,
RegisteredBaseAttribute
*
>
();
GenericMap
::
GenericMap
()
{
// register all known types
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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