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
Hurstel
CGoGN
Commits
708ce60e
Commit
708ce60e
authored
Feb 07, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MR: update of load/save/compact/clear
parent
4797d495
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
343 additions
and
93 deletions
+343
-93
include/Topology/generic/genericmap.h
include/Topology/generic/genericmap.h
+40
-24
include/Topology/generic/genericmap.hpp
include/Topology/generic/genericmap.hpp
+38
-0
src/Topology/generic/genericmap.cpp
src/Topology/generic/genericmap.cpp
+174
-13
src/Topology/map/map1.cpp
src/Topology/map/map1.cpp
+21
-14
src/Topology/map/map2.cpp
src/Topology/map/map2.cpp
+30
-18
src/Topology/map/map3.cpp
src/Topology/map/map3.cpp
+40
-24
No files found.
include/Topology/generic/genericmap.h
View file @
708ce60e
...
...
@@ -112,13 +112,29 @@ protected:
static
const
bool
m_isMultiRes
=
false
;
#endif
/**
* container for mr-darts that store indices in attribs[DART] for each level
*/
AttributeContainer
m_mrattribs
;
/**
* pointer to indices mvectors (one for each level)
*/
std
::
vector
<
AttributeMultiVector
<
unsigned
int
>*
>
m_mrDarts
;
/**
* pointers to mvector of levels
*/
AttributeMultiVector
<
unsigned
char
>*
m_mrLevels
;
/**
* current level of multiresoltion
*/
unsigned
int
m_mrCurrentLevel
;
/**
* stack for current level temporary storage
*/
std
::
vector
<
unsigned
int
>
m_mrLevelStack
;
public:
...
...
@@ -147,34 +163,34 @@ public:
* MULTIRES *
****************************************/
unsigned
int
getCurrentLevel
()
{
return
m_mrCurrentLevel
;
}
void
setCurrentLevel
(
unsigned
int
l
)
{
if
(
l
<
m_mrDarts
.
size
())
m_mrCurrentLevel
=
l
;
else
CGoGNout
<<
"try to access inexisting resolution level"
<<
CGoGNendl
;
}
void
pushLevel
()
{
m_mrLevelStack
.
push_back
(
m_mrCurrentLevel
)
;
}
/**
* get the current level of multi-resolution (use only in MRMaps)
*/
unsigned
int
getCurrentLevel
()
;
void
popLevel
()
{
m_mrCurrentLevel
=
m_mrLevelStack
.
back
()
;
m_mrLevelStack
.
pop_back
()
;
}
/**
* set the current level of multi-resolution (use only in MRMaps)
*/
void
setCurrentLevel
(
unsigned
int
l
)
;
/**
* store current level of multi-resolution on a stack (use only in MRMaps)
*/
void
pushLevel
()
;
unsigned
int
getMaxLevel
()
{
return
m_mrDarts
.
size
()
-
1
;
}
/**
* get back level of multi-resolution of the stack in current (use only in MRMaps)
*/
void
popLevel
()
;
void
addLevel
()
{
unsigned
int
level
=
m_mrDarts
.
size
()
;
std
::
stringstream
ss
;
ss
<<
"MRdart_"
<<
level
;
AttributeMultiVector
<
unsigned
int
>*
amvMR
=
m_mrattribs
.
addAttribute
<
unsigned
int
>
(
ss
.
str
())
;
/**
* get the max level of multi-resolution (use only in MRMaps)
*/
unsigned
int
getMaxLevel
()
;
m_mrDarts
.
push_back
(
amvMR
)
;
// copy the darts pointers of the previous level
if
(
m_mrDarts
.
size
()
>
1
)
m_mrattribs
.
copyAttribute
(
amvMR
->
getIndex
(),
m_mrDarts
[
m_mrDarts
.
size
()
-
2
]
->
getIndex
())
;
}
/**
* add a level of multi-resolution (use only in MRMaps)
*/
void
addLevel
()
;
/****************************************
* DARTS MANAGEMENT *
...
...
include/Topology/generic/genericmap.hpp
View file @
708ce60e
...
...
@@ -259,4 +259,42 @@ inline AttributeMultiVector<Dart>* GenericMap::getRelation(const std::string& na
return
amv
;
}
/******************************************
* TOPOLOGICAL MULTIRESOLUTION MANAGEMENT*
******************************************/
unsigned
int
GenericMap
::
getCurrentLevel
()
{
return
m_mrCurrentLevel
;
}
inline
void
GenericMap
::
setCurrentLevel
(
unsigned
int
l
)
{
if
(
l
<
m_mrDarts
.
size
())
m_mrCurrentLevel
=
l
;
else
CGoGNout
<<
"try to access inexisting resolution level"
<<
CGoGNendl
;
}
inline
void
GenericMap
::
pushLevel
()
{
m_mrLevelStack
.
push_back
(
m_mrCurrentLevel
)
;
}
inline
void
GenericMap
::
popLevel
()
{
m_mrCurrentLevel
=
m_mrLevelStack
.
back
()
;
m_mrLevelStack
.
pop_back
()
;
}
inline
unsigned
int
GenericMap
::
getMaxLevel
()
{
return
m_mrDarts
.
size
()
-
1
;
}
}
//namespace CGoGN
src/Topology/generic/genericmap.cpp
View file @
708ce60e
...
...
@@ -152,6 +152,17 @@ void GenericMap::clear(bool removeAttrib)
m_attribs
[
i
].
clear
(
false
)
;
}
}
if
(
m_isMultiRes
)
{
m_mrattribs
.
clear
(
true
);
m_mrLevels
=
NULL
;
unsigned
int
nb
=
m_mrDarts
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
m_mrDarts
[
i
]
=
NULL
;
m_mrCurrentLevel
=
0
;
m_mrLevelStack
.
clear
();
}
}
/****************************************
...
...
@@ -332,8 +343,16 @@ bool GenericMap::saveMapBin(const std::string& filename)
char
*
buff
=
new
char
[
256
];
for
(
int
i
=
0
;
i
<
256
;
++
i
)
buff
[
i
]
=
char
(
255
);
const
char
*
cgogn
=
"CGoGN_Map"
;
memcpy
(
buff
,
cgogn
,
10
);
if
(
m_isMultiRes
)
{
const
char
*
cgogn
=
"CGoGN_MRMap"
;
memcpy
(
buff
,
cgogn
,
12
);
}
else
{
const
char
*
cgogn
=
"CGoGN_Map"
;
memcpy
(
buff
,
cgogn
,
10
);
}
std
::
string
mt
=
mapTypeName
();
const
char
*
mtc
=
mt
.
c_str
();
memcpy
(
buff
+
32
,
mtc
,
mt
.
size
()
+
1
);
...
...
@@ -346,6 +365,9 @@ bool GenericMap::saveMapBin(const std::string& filename)
for
(
unsigned
int
i
=
0
;
i
<
NB_ORBITS
;
++
i
)
m_attribs
[
i
].
saveBin
(
fs
,
i
);
if
(
m_isMultiRes
)
m_mrattribs
.
saveBin
(
fs
,
00
);
return
true
;
}
...
...
@@ -367,11 +389,33 @@ bool GenericMap::loadMapBin(const std::string& filename)
std
::
string
buff_str
(
buff
);
// Check file type
if
(
buff_str
!=
"CGoGN_Map"
)
if
(
m_isMultiRes
)
{
CGoGNerr
<<
"Wrong binary file format"
<<
CGoGNendl
;
return
false
;
if
(
buff_str
==
"CGoGN_Map"
)
{
CGoGNerr
<<
"Wrong binary file format, file is not a MR-Map"
<<
CGoGNendl
;
return
false
;
}
if
(
buff_str
!=
"CGoGN_MRMap"
)
{
CGoGNerr
<<
"Wrong binary file format"
<<
CGoGNendl
;
return
false
;
}
}
else
{
if
(
buff_str
==
"CGoGN_MRMap"
)
{
CGoGNerr
<<
"Wrong binary file format, file is a MR-Map"
<<
CGoGNendl
;
return
false
;
}
if
(
buff_str
!=
"CGoGN_Map"
)
{
CGoGNerr
<<
"Wrong binary file format"
<<
CGoGNendl
;
return
false
;
}
}
// Check map type
buff_str
=
std
::
string
(
buff
+
32
);
...
...
@@ -402,11 +446,17 @@ bool GenericMap::loadMapBin(const std::string& filename)
m_attribs
[
id
].
loadBin
(
fs
);
}
// retrieve m_embeddings (from m_attribs[DART]
if
(
m_isMultiRes
)
m_mrattribs
.
loadBin
(
fs
);
// retrieve m_embeddings (from m_attribs)
update_m_emb_afterLoad
();
// recursive call from real type of map (for topo relation attributes pointers) down to GenericMap (for Marker_cleaning & pointers)
update_topo_shortcuts
();
return
true
;
}
...
...
@@ -470,6 +520,41 @@ void GenericMap::update_topo_shortcuts()
}
}
}
if
(
m_isMultiRes
)
{
std
::
vector
<
std
::
string
>
names
;
m_mrattribs
.
getAttributesNames
(
names
);
m_mrDarts
.
resize
(
names
.
size
()
-
1
);
for
(
unsigned
int
i
=
0
;
i
<
m_mrDarts
.
size
();
++
i
)
m_mrDarts
[
i
]
=
NULL
;
for
(
unsigned
int
i
=
0
;
i
<
names
.
size
();
++
i
)
{
std
::
string
sub
=
names
[
i
].
substr
(
0
,
7
);
if
(
sub
==
"MRLevel"
)
m_mrLevels
=
m_mrattribs
.
getDataVector
<
unsigned
char
>
(
i
);
if
(
sub
==
"MRdart_"
)
{
sub
=
names
[
i
].
substr
(
7
);
// compute number following MT_Dart_
unsigned
int
idx
=
0
;
for
(
unsigned
int
j
=
0
;
j
<
sub
.
length
();
j
++
)
idx
=
10
*
idx
+
(
sub
[
j
]
-
'0'
);
if
(
idx
<
names
.
size
()
-
1
)
m_mrDarts
[
idx
]
=
m_mrattribs
.
getDataVector
<
unsigned
char
>
(
i
);
else
CGoGNerr
<<
"Warning problem updating MR_DARTS"
<<
CGoGNendl
;
}
}
// check if all pointers are != NULL
for
(
unsigned
int
i
=
0
;
i
<
m_mrDarts
.
size
();
++
i
)
{
if
(
m_mrDarts
[
i
]
==
NULL
)
CGoGNerr
<<
"Warning problem MR_DARTS = NULL"
<<
CGoGNendl
;
}
}
}
void
GenericMap
::
dumpAttributesAndMarkers
()
...
...
@@ -514,30 +599,82 @@ void GenericMap::dumpAttributesAndMarkers()
void
GenericMap
::
compact
()
{
std
::
vector
<
unsigned
int
>
oldnew
;
// if MR compact the MR attrib container
std
::
vector
<
unsigned
int
>
oldnewMR
;
if
(
m_isMultiRes
)
m_mrattribs
.
compact
(
oldnewMR
);
// compacting the orbits attributes
// for (unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
// {
// if ((orbit != DART) && (isOrbitEmbedded(orbit)))
// {
// m_attribs[orbit].compact(oldnew);
//
// for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i))
// {
// unsigned int& idx = m_embeddings[orbit]->operator [](i);
// unsigned int jdx = oldnew[idx];
// if ((jdx != 0xffffffff) && (jdx != idx))
// idx = jdx;
// }
// }
// }
// compact embedding attribs
std
::
vector
<
std
::
vector
<
unsigned
int
>*
>
oldnews
;
oldnews
.
resize
(
NB_ORBITS
);
for
(
unsigned
int
orbit
=
0
;
orbit
<
NB_ORBITS
;
++
orbit
)
{
if
((
orbit
!=
DART
)
&&
(
isOrbitEmbedded
(
orbit
)))
{
m_attribs
[
orbit
].
compact
(
oldnew
);
oldnews
[
orbit
]
=
new
std
::
vector
<
unsigned
int
>
;
m_attribs
[
orbit
].
compact
(
*
(
oldnews
[
orbit
]));
}
}
for
(
unsigned
int
i
=
m_attribs
[
DART
].
begin
();
i
!=
m_attribs
[
DART
].
end
();
m_attribs
[
DART
].
next
(
i
))
// update embedding indices of topo
for
(
unsigned
int
i
=
m_attribs
[
DART
].
begin
();
i
!=
m_attribs
[
DART
].
end
();
m_attribs
[
DART
].
next
(
i
))
{
for
(
unsigned
int
orbit
=
0
;
orbit
<
NB_ORBITS
;
++
orbit
)
{
if
((
orbit
!=
DART
)
&&
(
isOrbitEmbedded
(
orbit
)))
{
unsigned
int
&
idx
=
m_embeddings
[
orbit
]
->
operator
[](
i
);
unsigned
int
jdx
=
oldnew
[
idx
]
;
unsigned
int
&
idx
=
m_embeddings
[
orbit
]
->
operator
[](
i
);
unsigned
int
jdx
=
oldnew
s
[
orbit
]
->
operator
[](
idx
)
;
if
((
jdx
!=
0xffffffff
)
&&
(
jdx
!=
idx
))
idx
=
jdx
;
}
}
}
// delete allocated vectors
for
(
unsigned
int
orbit
=
0
;
orbit
<
NB_ORBITS
;
++
orbit
)
if
((
orbit
!=
DART
)
&&
(
isOrbitEmbedded
(
orbit
)))
delete
[]
oldnews
[
orbit
];
//compacting the topo
std
::
vector
<
unsigned
int
>
oldnew
;
m_attribs
[
DART
].
compact
(
oldnew
);
// update topo relations: recurvise call from real map down to generic
compactTopoRelations
(
oldnew
);
// update MR indices to attribs[DART]
if
(
m_isMultiRes
)
{
unsigned
int
nbl
=
m_mrDarts
.
size
();
for
(
unsigned
int
i
=
m_mrattribs
.
begin
();
i
!=
m_mrattribs
.
end
();
m_mrattribs
.
next
(
i
))
{
for
(
unsigned
int
j
=
0
;
j
<
nbl
;
++
j
)
{
unsigned
int
d_index
=
m_mrDarts
[
j
][
i
];
if
(
d_index
!=
oldnew
[
d_index
])
m_mrDarts
[
j
][
i
]
=
Dart
(
oldnew
[
d_index
]);
}
}
}
// update topo relations from real map
compactTopoRelations
(
oldnewMR
);
// dumpAttributesAndMarkers();
}
...
...
@@ -664,6 +801,30 @@ void GenericMap::boundaryUnmarkAll()
m_markTables
[
DART
][
0
]
->
operator
[](
i
).
unsetMark
(
m_boundaryMarker
);
}
void
GenericMap
::
addLevel
()
{
unsigned
int
level
=
m_mrDarts
.
size
()
;
std
::
stringstream
ss
;
ss
<<
"MRdart_"
<<
level
;
AttributeMultiVector
<
unsigned
int
>*
amvMR
=
m_mrattribs
.
addAttribute
<
unsigned
int
>
(
ss
.
str
())
;
m_mrDarts
.
push_back
(
amvMR
)
;
// copy the darts pointers of the previous level
if
(
m_mrDarts
.
size
()
>
1
)
m_mrattribs
.
copyAttribute
(
amvMR
->
getIndex
(),
m_mrDarts
[
m_mrDarts
.
size
()
-
2
]
->
getIndex
())
;
}
}
// namespace CGoGN
//
...
...
src/Topology/map/map1.cpp
View file @
708ce60e
...
...
@@ -31,20 +31,27 @@ void Map1::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for
(
unsigned
int
i
=
m_attribs
[
DART
].
begin
();
i
!=
m_attribs
[
DART
].
end
();
m_attribs
[
DART
].
next
(
i
))
{
{
Dart
&
d
=
m_phi1
->
operator
[](
i
);
// ???????????????
unsigned
int
d_index
=
dartIndex
(
d
);
Dart
e
=
Dart
(
oldnew
[
d_index
]);
if
(
d
!=
e
)
d
=
e
;
}
{
Dart
&
d
=
m_phi_1
->
operator
[](
i
);
unsigned
int
d_index
=
dartIndex
(
d
);
Dart
e
=
Dart
(
oldnew
[
d_index
]);
if
(
d
!=
e
)
d
=
e
;
}
unsigned
int
d_index
=
dartIndex
(
m_phi1
->
operator
[](
i
));
if
(
d_index
!=
oldnew
[
d_index
])
m_phi1
->
operator
[](
i
)
=
Dart
(
oldnew
[
d_index
]);
d_index
=
dartIndex
(
m_phi_1
->
operator
[](
i
));
if
(
d_index
!=
oldnew
[
d_index
])
m_phi_1
->
operator
[](
i
)
=
Dart
(
oldnew
[
d_index
]);
// {
// Dart d = m_phi1->operator [](i);
// unsigned int d_index = dartIndex(m_phi1->operator [](i));
// Dart e = Dart(oldnew[d_index]);
// if (d != e)
// d = e;
// }
// {
// Dart& d = m_phi_1->operator [](i);
// unsigned int d_index = dartIndex(d);
// Dart e = Dart(oldnew[d_index]);
// if (d != e)
// d = e;
// }
}
}
...
...
src/Topology/map/map2.cpp
View file @
708ce60e
...
...
@@ -71,24 +71,36 @@ void Map2::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for
(
unsigned
int
i
=
m_attribs
[
DART
].
begin
();
i
!=
m_attribs
[
DART
].
end
();
m_attribs
[
DART
].
next
(
i
))
{
{
Dart
&
d
=
m_phi1
->
operator
[](
i
);
Dart
e
=
Dart
(
oldnew
[
d
.
index
]);
if
(
d
!=
e
)
d
=
e
;
}
{
Dart
&
d
=
m_phi_1
->
operator
[](
i
);
Dart
e
=
Dart
(
oldnew
[
d
.
index
]);
if
(
d
!=
e
)
d
=
e
;
}
{
Dart
&
d
=
m_phi2
->
operator
[](
i
);
Dart
e
=
Dart
(
oldnew
[
d
.
index
]);
if
(
d
!=
e
)
d
=
e
;
}
unsigned
int
d_index
=
dartIndex
(
m_phi1
->
operator
[](
i
));
if
(
d_index
!=
oldnew
[
d_index
])
m_phi1
->
operator
[](
i
)
=
Dart
(
oldnew
[
d_index
]);
d_index
=
dartIndex
(
m_phi_1
->
operator
[](
i
));
if
(
d_index
!=
oldnew
[
d_index
])
m_phi_1
->
operator
[](
i
)
=
Dart
(
oldnew
[
d_index
]);
d_index
=
dartIndex
(
m_phi2
->
operator
[](
i
));
if
(
d_index
!=
oldnew
[
d_index
])
m_phi2
->
operator
[](
i
)
=
Dart
(
oldnew
[
d_index
]);
// {
// Dart& d = m_phi1->operator [](i);
// Dart e = Dart(oldnew[d.index]);
// if (d != e)
// d = e;
// }
// {
// Dart& d = m_phi_1->operator [](i);
// Dart e = Dart(oldnew[d.index]);
// if (d != e)
// d = e;
// }
// {
// Dart& d = m_phi2->operator [](i);
// Dart e = Dart(oldnew[d.index]);
// if (d != e)
// d = e;
// }
}
}
...
...
src/Topology/map/map3.cpp
View file @
708ce60e
...
...
@@ -31,30 +31,46 @@ void Map3::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for
(
unsigned
int
i
=
m_attribs
[
DART
].
begin
();
i
!=
m_attribs
[
DART
].
end
();
m_attribs
[
DART
].
next
(
i
))
{
{
Dart
&
d
=
m_phi1
->
operator
[](
i
);
Dart
e
=
Dart
(
oldnew
[
d
.
index
]);
if
(
d
!=
e
)
d
=
e
;
}
{
Dart
&
d
=
m_phi_1
->
operator
[](
i
);
Dart
e
=
Dart
(
oldnew
[
d
.
index
]);
if
(
d
!=
e
)
d
=
e
;
}
{
Dart
&
d
=
m_phi2
->
operator
[](
i
);
Dart
e
=
Dart
(
oldnew
[
d
.
index
]);
if
(
d
!=
e
)
d
=
e
;
}
{
Dart
&
d
=
m_phi3
->
operator
[](
i
);
Dart
e
=
Dart
(
oldnew
[
d
.
index
]);
if
(
d
!=
e
)
d
=
e
;
}
unsigned
int
d_index
=
dartIndex
(
m_phi1
->
operator
[](
i
));
if
(
d_index
!=
oldnew
[
d_index
])
m_phi1
->
operator
[](
i
)
=
Dart
(
oldnew
[
d_index
]);
d_index
=
dartIndex
(
m_phi_1
->
operator
[](
i
));
if
(
d_index
!=
oldnew
[
d_index
])
m_phi_1
->
operator
[](
i
)
=
Dart
(
oldnew
[
d_index
]);
d_index
=
dartIndex
(
m_phi2
->
operator
[](
i
));
if
(
d_index
!=
oldnew
[
d_index
])
m_phi2
->
operator
[](
i
)
=
Dart
(
oldnew
[
d_index
]);
d_index
=
dartIndex
(
m_phi3
->
operator
[](
i
));
if
(
d_index
!=
oldnew
[
d_index
])
m_phi3
->
operator
[](
i
)
=
Dart
(
oldnew
[
d_index
]);
//
// {
// Dart& d = m_phi1->operator [](i);
// Dart e = Dart(oldnew[d.index]);
// if (d != e)
// d = e;
// }
// {
// Dart& d = m_phi_1->operator [](i);
// Dart e = Dart(oldnew[d.index]);
// if (d != e)
// d = e;
// }
// {
// Dart& d = m_phi2->operator [](i);
// Dart e = Dart(oldnew[d.index]);
// if (d != e)
// d = e;
// }
// {
// Dart& d = m_phi3->operator [](i);
// Dart e = Dart(oldnew[d.index]);
// if (d != e)
// d = e;
// }
}
}
...
...
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