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
e069adeb
Commit
e069adeb
authored
Oct 23, 2014
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add addAttribute with type in string
parent
f80538a5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
1 deletion
+91
-1
Apps/Tuto/Attributes/simple_attribs.cpp
Apps/Tuto/Attributes/simple_attribs.cpp
+24
-1
include/Container/attributeContainer.h
include/Container/attributeContainer.h
+9
-0
include/Container/registered.h
include/Container/registered.h
+7
-0
include/Topology/generic/mapCommon.h
include/Topology/generic/mapCommon.h
+10
-0
include/Topology/generic/mapCommon.hpp
include/Topology/generic/mapCommon.hpp
+13
-0
src/Container/attributeContainer.cpp
src/Container/attributeContainer.cpp
+28
-0
No files found.
Apps/Tuto/Attributes/simple_attribs.cpp
View file @
e069adeb
...
...
@@ -55,7 +55,7 @@ void testVAbyNames(MAP& map, const std::string& name)
if
(
testPos
.
isValid
())
std
::
cout
<<
"Attribute "
<<
name
<<
" valid"
<<
std
::
endl
;
else
std
::
cout
<<
"Attribute "
<<
name
<<
"invalid"
<<
std
::
endl
;
std
::
cout
<<
"Attribute "
<<
name
<<
"
invalid"
<<
std
::
endl
;
}
/**
...
...
@@ -240,6 +240,7 @@ int main()
computeNewPositions
(
myMap
,
positionAtt
);
dumpAttribute
(
positionAtt
);
//check if there is a Vertex Attribute of VEC3 named position => yes
testVAbyNames
(
myMap
,
"position"
);
...
...
@@ -247,7 +248,29 @@ int main()
myMap
.
removeAttribute
(
positionAtt
);
//check if there is a Vertex Attribute of VEC3 named position => no
std
::
cout
<<
"after removing position"
<<
std
::
endl
;
testVAbyNames
(
myMap
,
"position"
);
// its also possible to add an attribute only with name of type in a string (if type has been registred)
if
(
myMap
.
addAttribute
<
VERTEX
>
(
"double"
,
"pipo_double"
))
{
VertexAttribute
<
double
,
MAP
>
position_double
=
myMap
.
getAttribute
<
double
,
VERTEX
,
MAP
>
(
"pipo_double"
);
position_double
[
v
]
=
3.1415926
;
}
if
(
!
myMap
.
addAttribute
<
VERTEX
>
(
"double"
,
"pipo_double"
))
{
std
::
cout
<<
"problem"
<<
std
::
endl
;
}
if
(
!
myMap
.
addAttribute
<
VERTEX
>
(
"triple"
,
"pipo_triple"
))
{
std
::
cout
<<
"problem"
<<
std
::
endl
;
}
return
0
;
}
include/Container/attributeContainer.h
View file @
e069adeb
...
...
@@ -161,6 +161,15 @@ public:
template
<
typename
T
>
AttributeMultiVector
<
T
>*
addAttribute
(
const
std
::
string
&
attribName
);
/**
* add a new attribute to the container
* @param typeName type of the new attribute in a string
* @param attribName name of the new attribute
* @return pointer to the new AttributeMultiVectorGen (unknown type inside)
*/
AttributeMultiVectorGen
*
addAttribute
(
const
std
::
string
&
typeName
,
const
std
::
string
&
attribName
);
protected:
/**
* add a new attribute with a given index (for load only)
...
...
include/Container/registered.h
View file @
e069adeb
...
...
@@ -49,6 +49,8 @@ public:
*/
const
std
::
string
&
getTypeName
()
{
return
m_name
;
}
virtual
unsigned
int
size
()
=
0
;
/**
* Ajout de l'attribut au container (A IMPLEMENTER)
*/
...
...
@@ -75,6 +77,11 @@ public:
// or existing one
return
container
.
getDataVector
<
T
>
(
id
);
}
unsigned
int
size
()
{
return
sizeof
(
T
);
}
};
}
// namespace CGoGN
...
...
include/Topology/generic/mapCommon.h
View file @
e069adeb
...
...
@@ -125,6 +125,16 @@ public:
* ATTRIBUTES MANAGEMENT *
****************************************/
/**
* Create an attribute for a given orbit
* @param typeName type in aa string
* @param nameAttr attribute name
* @return true if created
*/
template
<
unsigned
int
ORBIT
>
bool
addAttribute
(
const
std
::
string
&
typeName
,
const
std
::
string
&
nameAttr
);
/**
* Create an attribute for a given orbit
* @param nameAttr attribute name
...
...
include/Topology/generic/mapCommon.hpp
View file @
e069adeb
...
...
@@ -166,6 +166,19 @@ void MapCommon<MAP_IMPL>::boundaryUnmarkAll()
* ATTRIBUTES MANAGEMENT *
****************************************/
template
<
typename
MAP_IMPL
>
template
<
unsigned
int
ORBIT
>
inline
bool
MapCommon
<
MAP_IMPL
>::
addAttribute
(
const
std
::
string
&
typeName
,
const
std
::
string
&
nameAttr
)
{
if
(
!
this
->
template
isOrbitEmbedded
<
ORBIT
>())
this
->
template
addEmbedding
<
ORBIT
>()
;
AttributeMultiVectorGen
*
amv
=
this
->
m_attribs
[
ORBIT
].
addAttribute
(
typeName
,
nameAttr
)
;
return
amv
!=
NULL
;
}
template
<
typename
MAP_IMPL
>
template
<
typename
T
,
unsigned
int
ORBIT
,
typename
MAP
>
inline
AttributeHandler
<
T
,
ORBIT
,
MAP
>
MapCommon
<
MAP_IMPL
>::
addAttribute
(
const
std
::
string
&
nameAttr
)
...
...
src/Container/attributeContainer.cpp
View file @
e069adeb
...
...
@@ -925,5 +925,33 @@ void AttributeContainer::dumpByLines() const
}
AttributeMultiVectorGen
*
AttributeContainer
::
addAttribute
(
const
std
::
string
&
typeName
,
const
std
::
string
&
attribName
)
{
// first check if attribute already exist
unsigned
int
index
=
UNKNOWN
;
if
(
attribName
!=
""
)
{
index
=
getAttributeIndex
(
attribName
)
;
if
(
index
!=
UNKNOWN
)
{
CGoGNerr
<<
"attribute "
<<
attribName
<<
" already found.."
<<
CGoGNendl
;
return
NULL
;
}
}
// create the new attribute
std
::
map
<
std
::
string
,
RegisteredBaseAttribute
*>::
iterator
itAtt
=
m_attributes_registry_map
->
find
(
typeName
);
if
(
itAtt
==
m_attributes_registry_map
->
end
())
{
CGoGNerr
<<
"type "
<<
typeName
<<
" not registred.."
<<
CGoGNendl
;
return
NULL
;
}
RegisteredBaseAttribute
*
ra
=
itAtt
->
second
;
AttributeMultiVectorGen
*
amv
=
ra
->
addAttribute
(
*
this
,
attribName
);
return
amv
;
}
}
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