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
7b93a4a0
Commit
7b93a4a0
authored
Sep 02, 2011
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update AttributeHandlers management
parent
ad2de7a7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
92 additions
and
67 deletions
+92
-67
include/Algo/Import/import2tables.h
include/Algo/Import/import2tables.h
+5
-5
include/Algo/Import/import2tablesSurface.hpp
include/Algo/Import/import2tablesSurface.hpp
+1
-1
include/Topology/generic/attribmap.h
include/Topology/generic/attribmap.h
+0
-1
include/Topology/generic/attribmap.hpp
include/Topology/generic/attribmap.hpp
+1
-0
include/Topology/generic/attributeHandler.h
include/Topology/generic/attributeHandler.h
+18
-15
include/Topology/generic/attributeHandler.hpp
include/Topology/generic/attributeHandler.hpp
+61
-43
include/Topology/generic/autoAttributeHandler.h
include/Topology/generic/autoAttributeHandler.h
+3
-1
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+1
-0
src/Utils/Shaders/shaderSimpleColor.cpp
src/Utils/Shaders/shaderSimpleColor.cpp
+2
-1
No files found.
include/Algo/Import/import2tables.h
View file @
7b93a4a0
...
...
@@ -65,9 +65,9 @@ class MeshTablesSurface
protected:
typename
PFP
::
MAP
&
m_map
;
unsigned
m_nbVertices
;
unsigned
int
m_nbVertices
;
unsigned
m_nbFaces
;
unsigned
int
m_nbFaces
;
unsigned
int
m_lab
;
...
...
@@ -138,11 +138,11 @@ class MeshTablesVolume
protected:
typename
PFP
::
MAP
&
m_map
;
unsigned
m_nbVertices
;
unsigned
int
m_nbVertices
;
unsigned
m_nbFaces
;
unsigned
int
m_nbFaces
;
unsigned
m_nbVolumes
;
unsigned
int
m_nbVolumes
;
/**
* number of edges per face
...
...
include/Algo/Import/import2tablesSurface.hpp
View file @
7b93a4a0
...
...
@@ -267,7 +267,7 @@ bool MeshTablesSurface<PFP>::importTrianBinGz(const std::string& filename, std::
template
<
typename
PFP
>
bool
MeshTablesSurface
<
PFP
>::
importOff
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
attrNames
)
{
AttributeHandler
<
typename
PFP
::
VEC3
>
positions
=
m_map
.
template
getAttribute
<
typename
PFP
::
VEC3
>(
VERTEX
,
"position"
)
;
AttributeHandler
<
typename
PFP
::
VEC3
>
positions
=
m_map
.
template
getAttribute
<
typename
PFP
::
VEC3
>(
VERTEX
,
"position"
)
;
if
(
!
positions
.
isValid
())
positions
=
m_map
.
template
addAttribute
<
typename
PFP
::
VEC3
>(
VERTEX
,
"position"
)
;
...
...
include/Topology/generic/attribmap.h
View file @
7b93a4a0
...
...
@@ -35,7 +35,6 @@ class AttribMap : public GenericMap
{
private:
friend
class
CellMarkerGen
;
template
<
typename
T
>
friend
class
AutoAttributeHandler
;
void
init
()
;
...
...
include/Topology/generic/attribmap.hpp
View file @
7b93a4a0
...
...
@@ -44,6 +44,7 @@ inline bool AttribMap::removeAttribute(AttributeHandler<T>& attr)
std
::
pair
<
IT
,
IT
>
bounds
=
attributeHandlers
.
equal_range
(
attr
.
getDataVector
())
;
for
(
IT
i
=
bounds
.
first
;
i
!=
bounds
.
second
;
++
i
)
(
*
i
).
second
->
setInvalid
()
;
attributeHandlers
.
erase
(
bounds
.
first
,
bounds
.
second
)
;
return
true
;
}
return
false
;
...
...
include/Topology/generic/attributeHandler.h
View file @
7b93a4a0
...
...
@@ -36,14 +36,16 @@ namespace CGoGN
class
AttributeHandlerGen
{
protected:
friend
class
GenericMap
;
friend
class
AttribMap
;
// the map that contains the linked attribute
GenericMap
*
m_map
;
GenericMap
*
m_map
;
// boolean that states the validity of the handler
bool
valid
;
public:
AttributeHandlerGen
()
:
m_map
(
NULL
)
{}
AttributeHandlerGen
(
GenericMap
*
m
)
:
m_map
(
m
)
AttributeHandlerGen
(
GenericMap
*
m
,
bool
v
)
:
m_map
(
m
),
valid
(
v
)
{}
GenericMap
*
map
()
const
...
...
@@ -51,11 +53,17 @@ public:
return
m_map
;
}
bool
isValid
()
const
{
return
valid
;
}
protected:
void
setInvalid
()
{
m_map
=
NULL
;
valid
=
false
;
}
};
}
;
/**
* Class that create an access-table to an existing attribute
...
...
@@ -71,6 +79,9 @@ protected:
// the multi-vector that contains attribute data
AttributeMultiVector
<
T
>*
m_attrib
;
void
registerInMap
()
;
void
unregisterFromMap
()
;
public:
typedef
T
DATA_TYPE
;
...
...
@@ -124,14 +135,6 @@ public:
*/
const
std
::
string
&
name
()
const
;
/**
* check if the attribute handler is linked to a valid attribute
* -> MUST BE USED AFTER A CALL TO :
* getAttribute(unsigned int orbit, const std::string& nameAttr)
* addAttribute(unsigned int orbit, const std::string& nameAttr)
*/
bool
isValid
()
const
;
/**
* [] operator with dart parameter
*/
...
...
include/Topology/generic/attributeHandler.hpp
View file @
7b93a4a0
...
...
@@ -25,47 +25,73 @@
namespace
CGoGN
{
template
<
typename
T
>
void
AttributeHandler
<
T
>::
registerInMap
()
{
m_map
->
attributeHandlers
.
insert
(
std
::
pair
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>
(
m_attrib
,
this
))
;
}
template
<
typename
T
>
void
AttributeHandler
<
T
>::
unregisterFromMap
()
{
typedef
std
::
multimap
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>::
iterator
IT
;
std
::
pair
<
IT
,
IT
>
bounds
=
m_map
->
attributeHandlers
.
equal_range
(
m_attrib
)
;
for
(
IT
i
=
bounds
.
first
;
i
!=
bounds
.
second
;
++
i
)
{
if
((
*
i
).
second
==
this
)
{
m_map
->
attributeHandlers
.
erase
(
i
)
;
return
;
}
}
assert
(
false
||
!
"Should not get here"
)
;
}
// =================================================================
template
<
typename
T
>
AttributeHandler
<
T
>::
AttributeHandler
()
:
AttributeHandlerGen
(),
m_attrib
(
NULL
)
AttributeHandlerGen
(
NULL
,
false
),
m_attrib
(
NULL
)
{}
template
<
typename
T
>
AttributeHandler
<
T
>::
AttributeHandler
(
GenericMap
*
m
,
AttributeMultiVector
<
T
>*
amv
)
:
AttributeHandlerGen
(
m
),
m_attrib
(
amv
)
AttributeHandlerGen
(
m
,
false
),
m_attrib
(
amv
)
{
m
->
attributeHandlers
.
insert
(
std
::
pair
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>
(
amv
,
this
))
;
if
(
amv
!=
NULL
&&
amv
->
getIndex
()
!=
AttributeContainer
::
UNKNOWN
)
{
valid
=
true
;
registerInMap
()
;
}
else
valid
=
false
;
}
template
<
typename
T
>
AttributeHandler
<
T
>::
AttributeHandler
(
const
AttributeHandler
<
T
>&
ta
)
:
AttributeHandlerGen
(
ta
.
m_map
),
m_attrib
(
ta
.
m_attrib
)
AttributeHandlerGen
(
ta
.
m_map
,
ta
.
valid
),
m_attrib
(
ta
.
m_attrib
)
{
this
->
m_map
->
attributeHandlers
.
insert
(
std
::
pair
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>
(
m_attrib
,
this
))
;
if
(
valid
)
registerInMap
()
;
}
template
<
typename
T
>
inline
void
AttributeHandler
<
T
>::
operator
=
(
const
AttributeHandler
<
T
>&
ta
)
{
this
->
m_map
=
ta
.
m_map
;
if
(
valid
)
unregisterFromMap
()
;
m_map
=
ta
.
m_map
;
m_attrib
=
ta
.
m_attrib
;
this
->
m_map
->
attributeHandlers
.
insert
(
std
::
pair
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>
(
m_attrib
,
this
))
;
valid
=
ta
.
valid
;
if
(
valid
)
registerInMap
()
;
}
template
<
typename
T
>
AttributeHandler
<
T
>::~
AttributeHandler
()
{
typedef
std
::
multimap
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>::
iterator
IT
;
std
::
pair
<
IT
,
IT
>
bounds
=
this
->
m_map
->
attributeHandlers
.
equal_range
(
m_attrib
)
;
for
(
IT
i
=
bounds
.
first
;
i
!=
bounds
.
second
;
++
i
)
{
if
((
*
i
).
second
==
this
)
{
this
->
m_map
->
attributeHandlers
.
erase
(
i
)
;
return
;
}
}
assert
(
false
||
!
"Should not get here"
)
;
if
(
valid
)
unregisterFromMap
()
;
}
template
<
typename
T
>
...
...
@@ -92,23 +118,15 @@ const std::string& AttributeHandler<T>::name() const
return
m_attrib
->
getName
()
;
}
template
<
typename
T
>
bool
AttributeHandler
<
T
>::
isValid
()
const
{
return
!
(
this
->
m_map
==
NULL
||
m_attrib
==
NULL
||
m_attrib
->
getIndex
()
==
AttributeContainer
::
UNKNOWN
)
;
}
template
<
typename
T
>
inline
T
&
AttributeHandler
<
T
>::
operator
[](
Dart
d
)
{
assert
(
isValid
()
||
!
"Invalid AttributeHandler"
)
;
assert
(
valid
||
!
"Invalid AttributeHandler"
)
;
unsigned
int
orbit
=
m_attrib
->
getOrbit
()
;
unsigned
int
a
=
this
->
m_map
->
getEmbedding
(
orbit
,
d
)
;
unsigned
int
a
=
m_map
->
getEmbedding
(
orbit
,
d
)
;
if
(
a
==
EMBNULL
)
a
=
this
->
m_map
->
embedNewCell
(
orbit
,
d
)
;
a
=
m_map
->
embedNewCell
(
orbit
,
d
)
;
return
m_attrib
->
operator
[](
a
)
;
}
...
...
@@ -116,30 +134,30 @@ inline T& AttributeHandler<T>::operator[](Dart d)
template
<
typename
T
>
inline
const
T
&
AttributeHandler
<
T
>::
operator
[](
Dart
d
)
const
{
assert
(
isValid
()
||
!
"Invalid AttributeHandler"
)
;
unsigned
int
a
=
this
->
m_map
->
getEmbedding
(
m_attrib
->
getOrbit
(),
d
)
;
assert
(
valid
||
!
"Invalid AttributeHandler"
)
;
unsigned
int
a
=
m_map
->
getEmbedding
(
m_attrib
->
getOrbit
(),
d
)
;
return
m_attrib
->
operator
[](
a
)
;
}
template
<
typename
T
>
inline
T
&
AttributeHandler
<
T
>::
operator
[](
unsigned
int
a
)
{
assert
(
isValid
()
||
!
"Invalid AttributeHandler"
)
;
assert
(
valid
||
!
"Invalid AttributeHandler"
)
;
return
m_attrib
->
operator
[](
a
)
;
}
template
<
typename
T
>
inline
const
T
&
AttributeHandler
<
T
>::
operator
[](
unsigned
int
a
)
const
{
assert
(
isValid
()
||
!
"Invalid AttributeHandler"
)
;
assert
(
valid
||
!
"Invalid AttributeHandler"
)
;
return
m_attrib
->
operator
[](
a
)
;
}
template
<
typename
T
>
inline
unsigned
int
AttributeHandler
<
T
>::
insert
(
const
T
&
elt
)
{
assert
(
isValid
()
||
!
"Invalid AttributeHandler"
)
;
unsigned
int
idx
=
this
->
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
insertLine
()
;
assert
(
valid
||
!
"Invalid AttributeHandler"
)
;
unsigned
int
idx
=
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
insertLine
()
;
m_attrib
->
operator
[](
idx
)
=
elt
;
return
idx
;
}
...
...
@@ -147,8 +165,8 @@ inline unsigned int AttributeHandler<T>::insert(const T& elt)
template
<
typename
T
>
inline
unsigned
int
AttributeHandler
<
T
>::
newElt
()
{
assert
(
isValid
()
||
!
"Invalid AttributeHandler"
)
;
unsigned
int
idx
=
this
->
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
insertLine
()
;
assert
(
valid
||
!
"Invalid AttributeHandler"
)
;
unsigned
int
idx
=
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
insertLine
()
;
return
idx
;
}
...
...
@@ -162,22 +180,22 @@ inline void AttributeHandler<T>::setAllValues(T& v)
template
<
typename
T
>
inline
unsigned
int
AttributeHandler
<
T
>::
begin
()
const
{
assert
(
isValid
()
||
!
"Invalid AttributeHandler"
)
;
return
this
->
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
begin
()
;
assert
(
valid
||
!
"Invalid AttributeHandler"
)
;
return
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
begin
()
;
}
template
<
typename
T
>
inline
unsigned
int
AttributeHandler
<
T
>::
end
()
const
{
assert
(
isValid
()
||
!
"Invalid AttributeHandler"
)
;
return
this
->
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
end
()
;
assert
(
valid
||
!
"Invalid AttributeHandler"
)
;
return
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
end
()
;
}
template
<
typename
T
>
inline
void
AttributeHandler
<
T
>::
next
(
unsigned
int
&
iter
)
const
{
assert
(
isValid
()
||
!
"Invalid AttributeHandler"
)
;
this
->
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
next
(
iter
)
;
assert
(
valid
||
!
"Invalid AttributeHandler"
)
;
m_map
->
getAttributeContainer
(
m_attrib
->
getOrbit
()).
next
(
iter
)
;
}
}
//namespace CGoGN
include/Topology/generic/autoAttributeHandler.h
View file @
7b93a4a0
...
...
@@ -55,13 +55,15 @@ public:
AttributeContainer
&
cellCont
=
this
->
m_map
->
m_attribs
[
orbit
]
;
AttributeMultiVector
<
T
>*
amv
=
cellCont
.
addAttribute
<
T
>
(
nameAttr
)
;
this
->
m_attrib
=
amv
;
this
->
valid
=
true
;
this
->
registerInMap
()
;
}
~
AutoAttributeHandler
()
{
reinterpret_cast
<
AttribMap
*>
(
this
->
m_map
)
->
removeAttribute
<
T
>
(
*
this
)
;
}
};
}
;
}
// namespace CGoGN
...
...
src/Topology/generic/genericmap.cpp
View file @
7b93a4a0
...
...
@@ -117,6 +117,7 @@ void GenericMap::clear(bool removeAttrib)
{
for
(
std
::
multimap
<
AttributeMultiVectorGen
*
,
AttributeHandlerGen
*>::
iterator
it
=
attributeHandlers
.
begin
();
it
!=
attributeHandlers
.
end
();
++
it
)
(
*
it
).
second
->
setInvalid
()
;
attributeHandlers
.
clear
()
;
}
}
...
...
src/Utils/Shaders/shaderSimpleColor.cpp
View file @
7b93a4a0
...
...
@@ -30,6 +30,7 @@ namespace CGoGN
namespace
Utils
{
#include "shaderSimpleColor.vert"
#include "shaderSimpleColor.frag"
...
...
@@ -49,7 +50,7 @@ namespace Utils
// "FRAG_OUT_DEF;\n"
// "void main()\n"
// "{\n"
// " gl_FragColor
=
color;\n"
// " gl_FragColor
=
color;\n"
// "}";
...
...
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