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
1083e150
Commit
1083e150
authored
May 07, 2014
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc tuto
parent
45d57d02
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
13 deletions
+37
-13
Apps/Tuto/Attributes/multi_attribs.cpp
Apps/Tuto/Attributes/multi_attribs.cpp
+7
-1
Apps/Tuto/Attributes/simple_attribs.cpp
Apps/Tuto/Attributes/simple_attribs.cpp
+30
-12
No files found.
Apps/Tuto/Attributes/multi_attribs.cpp
View file @
1083e150
...
...
@@ -50,7 +50,13 @@ typedef PFP::VEC4 VEC4;
/**
* Example of function that work with any kin of Vertex Attribute
* Example of function that work with any kind of Vertex Attribute (normal/2/3/4)
*
* operators on multi-attribute are limited to:
* affectation
* +, -, +=, -=
* *(double) /(double) *=(double) /=(double)
*
*/
template
<
typename
MAP
,
typename
ATT
>
typename
ATT
::
DATA_TYPE
smooth
(
MAP
&
map
,
Vertex
v
,
const
ATT
&
attributs
)
...
...
Apps/Tuto/Attributes/simple_attribs.cpp
View file @
1083e150
...
...
@@ -46,10 +46,11 @@ typedef PFP::MAP::IMPL MAP_IMPL ; // map implementation
typedef
PFP
::
VEC3
VEC3
;
// type of R³ vector
/**
* @brief get attribute
* @param map
* @brief test if map has a Vertex Attribute of VEC3 named name
* @param map the map
* @param name name of attribute
*/
void
byNames
(
MAP
&
map
,
const
std
::
string
&
name
)
void
testVA
byNames
(
MAP
&
map
,
const
std
::
string
&
name
)
{
VertexAttribute
<
VEC3
,
MAP_IMPL
>
testPos
=
map
.
getAttribute
<
VEC3
,
VERTEX
>
(
name
);
if
(
testPos
.
isValid
())
...
...
@@ -60,6 +61,7 @@ void byNames(MAP& map, const std::string& name)
/**
* @brief computeLengthEdges
* Demonstrate usage of 2 attributes on 2 differents orbits.
* @param map the map
* @param pos attribute handler of position of vertices
* @param len attribute handler of length of edges
...
...
@@ -76,10 +78,12 @@ void computeLengthEdges(MAP& map,const VertexAttribute<VEC3, MAP_IMPL>& pos, Edg
});
}
/**
* @brief computeNewPositions Demonstrate the usage of AutoAttributes
*/
void
computeNewPositions
(
MAP
&
map
,
VertexAttribute
<
VEC3
,
MAP_IMPL
>&
pos
)
{
// here we need new and old positions simultaneously so create temporary position
// here we need new and old positions simultaneously so create temporary
attribute
position
VertexAutoAttribute
<
VEC3
,
MAP_IMPL
>
pos2
(
map
);
...
...
@@ -96,7 +100,10 @@ void computeNewPositions(MAP& map, VertexAttribute<VEC3, MAP_IMPL>& pos)
});
// swap attribute position with temporary (constant complexity !)
// only possible with same type and same orbit attribute.
map
.
swapAttributes
(
pos
,
pos2
);
// destruction of VertexAutoAttribute handller remove the attribute from the map.
}
/**
...
...
@@ -134,6 +141,8 @@ int main()
grid
.
embedIntoGrid
(
positionAtt
,
1.
,
1.
,
0.
);
// ATTRIBUTE DECLARATION
// add an attribute of type float on orbit EDGE
EdgeAttribute
<
float
,
MAP_IMPL
>
lengthAtt
=
myMap
.
addAttribute
<
float
,
EDGE
>
(
"length"
);
if
(
!
lengthAtt
.
isValid
())
...
...
@@ -157,6 +166,9 @@ int main()
// define a face from a dart
Face
f
(
d
);
// ATTRIBUTE ACCESS
// [] operator can take a dart, a cell (only same off attribute), or an unsigned inf
// access to any attributes with darts
std
::
cout
<<
positionAtt
[
d
]
<<
std
::
endl
;
...
...
@@ -173,11 +185,15 @@ int main()
// access to FaceAttribute with a Face
std
::
cout
<<
nameAtt
[
f
]
<<
std
::
endl
;
// following line does not compile because of wrong cell type
// std::cout << positionAtt[f]<< std::endl;
// possible to bypass using dart access
// following line does not compile because of wrong cell type
// std::cout << positionAtt[f]<< std::endl;
// possible to bypass using dart access
std
::
cout
<<
positionAtt
[
f
.
dart
]
<<
std
::
endl
;
// access with unsigned int is dangerous, index must be obtain with begin/end/next (see dumpAttribute)
// COPY, REMOVE, SWAP
// possible to have any number of attribute a same ORBIT
VertexAttribute
<
VEC3
,
MAP_IMPL
>
position2Att
=
myMap
.
addAttribute
<
VEC3
,
VERTEX
>
(
"other_position"
);
...
...
@@ -187,14 +203,16 @@ int main()
positionAtt
[
v
]
+=
VEC3
(
0
,
0
,
1
);
computeNewPositions
(
myMap
,
positionAtt
);
dumpAttribute
(
positionAtt
);
byNames
(
myMap
,
"position"
);
//check if there is a Vertex Attribute of VEC3 named position => yes
testVAbyNames
(
myMap
,
"position"
);
myMap
.
removeAttribute
<
VEC3
,
VERTEX
>
(
positionAtt
);
// remove the attribute
myMap
.
removeAttribute
(
positionAtt
);
byNames
(
myMap
,
"position"
);
//check if there is a Vertex Attribute of VEC3 named position => no
testVAbyNames
(
myMap
,
"position"
);
return
0
;
...
...
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