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
05b0276d
Commit
05b0276d
authored
Jun 23, 2014
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compact + test
parent
614de846
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
135 additions
and
105 deletions
+135
-105
Apps/Benches/CMakeLists.txt
Apps/Benches/CMakeLists.txt
+6
-0
Apps/Tests/CMakeLists.txt
Apps/Tests/CMakeLists.txt
+4
-0
Apps/Tests/compact.cpp
Apps/Tests/compact.cpp
+2
-2
include/Container/attributeContainer.h
include/Container/attributeContainer.h
+18
-2
include/Container/attributeContainer.hpp
include/Container/attributeContainer.hpp
+26
-1
include/Container/holeblockref.h
include/Container/holeblockref.h
+8
-0
include/Topology/generic/mapImpl/mapMono.h
include/Topology/generic/mapImpl/mapMono.h
+1
-1
include/Topology/generic/mapImpl/mapMono.hpp
include/Topology/generic/mapImpl/mapMono.hpp
+0
-27
src/Container/attributeContainer.cpp
src/Container/attributeContainer.cpp
+39
-72
src/Topology/generic/mapMono.cpp
src/Topology/generic/mapMono.cpp
+31
-0
No files found.
Apps/Benches/CMakeLists.txt
View file @
05b0276d
...
@@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 2.8)
...
@@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 2.8)
project
(
examples
)
project
(
examples
)
SET
(
CMAKE_BUILD_TYPE Release
)
SET
(
CMAKE_BUILD_TYPE Release
)
#SET(CMAKE_BUILD_TYPE Debug)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DNOTOPOWARNING"
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DNOTOPOWARNING"
)
...
@@ -26,3 +29,6 @@ target_link_libraries( bench_trav ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
...
@@ -26,3 +29,6 @@ target_link_libraries( bench_trav ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
add_executable
(
bench_remesh bench_remesh.cpp
)
add_executable
(
bench_remesh bench_remesh.cpp
)
target_link_libraries
(
bench_remesh
${
CGoGN_LIBS_R
}
${
CGoGN_EXT_LIBS
}
)
target_link_libraries
(
bench_remesh
${
CGoGN_LIBS_R
}
${
CGoGN_EXT_LIBS
}
)
add_executable
(
bench_compact bench_compact.cpp
)
target_link_libraries
(
bench_compact
${
CGoGN_LIBS_R
}
${
CGoGN_EXT_LIBS
}
)
Apps/Tests/CMakeLists.txt
View file @
05b0276d
...
@@ -50,3 +50,7 @@ target_link_libraries( movefrom
...
@@ -50,3 +50,7 @@ target_link_libraries( movefrom
add_executable
(
compact ./compact.cpp
)
add_executable
(
compact ./compact.cpp
)
target_link_libraries
(
compact
target_link_libraries
(
compact
${
CGoGN_LIBS_D
}
${
CGoGN_EXT_LIBS
}
)
${
CGoGN_LIBS_D
}
${
CGoGN_EXT_LIBS
}
)
add_executable
(
reusememory ./reusememory.cpp
)
target_link_libraries
(
reusememory
${
CGoGN_LIBS_D
}
${
CGoGN_EXT_LIBS
}
)
Apps/Tests/compact.cpp
View file @
05b0276d
...
@@ -107,8 +107,8 @@ int main()
...
@@ -107,8 +107,8 @@ int main()
myMap
.
dumpCSV
();
myMap
.
dumpCSV
();
std
::
cout
<<
"MAP with holes dumped in compact_before.csv"
<<
std
::
endl
;
std
::
cout
<<
"MAP with holes dumped in compact_before.csv"
<<
std
::
endl
;
std
::
cout
<<
"Total area "
<<
Algo
::
Surface
::
Geometry
::
totalArea
<
PFP2
>
(
myMap
,
position
)
<<
std
::
endl
;
std
::
cout
<<
"Total area before simplif "
<<
Algo
::
Surface
::
Geometry
::
totalArea
<
PFP2
>
(
myMap
,
position
)
<<
std
::
endl
;
myMap
.
compact
();
myMap
.
compact
();
...
@@ -116,7 +116,7 @@ int main()
...
@@ -116,7 +116,7 @@ int main()
myMap
.
dumpCSV
();
myMap
.
dumpCSV
();
std
::
cout
<<
"Compacted MAP dumped in compact_after.csv"
<<
std
::
endl
;
std
::
cout
<<
"Compacted MAP dumped in compact_after.csv"
<<
std
::
endl
;
std
::
cout
<<
"Total area "
<<
Algo
::
Surface
::
Geometry
::
totalArea
<
PFP2
>
(
myMap
,
position
)
<<
std
::
endl
;
std
::
cout
<<
"Total area
after simplif
"
<<
Algo
::
Surface
::
Geometry
::
totalArea
<
PFP2
>
(
myMap
,
position
)
<<
std
::
endl
;
myMap
.
saveMapBin
(
"compacted_map2.map"
);
myMap
.
saveMapBin
(
"compacted_map2.map"
);
...
...
include/Container/attributeContainer.h
View file @
05b0276d
...
@@ -231,7 +231,7 @@ public:
...
@@ -231,7 +231,7 @@ public:
unsigned
int
begin
()
const
;
unsigned
int
begin
()
const
;
/**
/**
* return the index
of
the last line of the container
* return the index
after
the last line of the container
*/
*/
unsigned
int
end
()
const
;
unsigned
int
end
()
const
;
...
@@ -249,7 +249,7 @@ public:
...
@@ -249,7 +249,7 @@ public:
unsigned
int
realBegin
()
const
;
unsigned
int
realBegin
()
const
;
/**
/**
* return the index
of
the last line of the container
* return the index
after
the last line of the container
*/
*/
unsigned
int
realEnd
()
const
;
unsigned
int
realEnd
()
const
;
...
@@ -260,6 +260,22 @@ public:
...
@@ -260,6 +260,22 @@ public:
void
realNext
(
unsigned
int
&
it
)
const
;
void
realNext
(
unsigned
int
&
it
)
const
;
/**
* return the index of the last line of the container
*/
unsigned
int
realRBegin
()
const
;
/**
* return the index before the first line of the container
*/
unsigned
int
realREnd
()
const
;
/**
* get the index of the line before "it" in the container
* MUST BE USED INSTEAD OF ++ !
*/
void
realRNext
(
unsigned
int
&
it
)
const
;
/**************************************
/**************************************
* INFO ABOUT ATTRIBUTES *
* INFO ABOUT ATTRIBUTES *
**************************************/
**************************************/
...
...
include/Container/attributeContainer.hpp
View file @
05b0276d
...
@@ -224,7 +224,7 @@ inline unsigned int AttributeContainer::memorySize() const
...
@@ -224,7 +224,7 @@ inline unsigned int AttributeContainer::memorySize() const
inline
bool
AttributeContainer
::
used
(
unsigned
int
index
)
const
inline
bool
AttributeContainer
::
used
(
unsigned
int
index
)
const
{
{
return m_holesBlocks[index / _BLOCKSIZE_]->used(index % _BLOCKSIZE_);
return
m_holesBlocks
[
index
/
_BLOCKSIZE_
]
->
used
(
index
%
_BLOCKSIZE_
)
!=
0
;
}
}
/**************************************
/**************************************
...
@@ -295,6 +295,31 @@ inline void AttributeContainer::realNext(unsigned int &it) const
...
@@ -295,6 +295,31 @@ inline void AttributeContainer::realNext(unsigned int &it) const
}
while
((
it
<
m_maxSize
)
&&
(
!
used
(
it
)));
}
while
((
it
<
m_maxSize
)
&&
(
!
used
(
it
)));
}
}
inline
unsigned
int
AttributeContainer
::
realRBegin
()
const
{
unsigned
int
it
=
m_maxSize
-
1
;
while
((
it
!=
0xffffffff
)
&&
(
!
used
(
it
)))
--
it
;
return
it
;
}
inline
unsigned
int
AttributeContainer
::
realREnd
()
const
{
return
0xffffffff
;
// -1
}
inline
void
AttributeContainer
::
realRNext
(
unsigned
int
&
it
)
const
{
do
{
--
it
;
}
while
((
it
!=
0xffffffff
)
&&
(
!
used
(
it
)));
}
/**************************************
/**************************************
* LINES MANAGEMENT *
* LINES MANAGEMENT *
**************************************/
**************************************/
...
...
include/Container/holeblockref.h
View file @
05b0276d
...
@@ -128,6 +128,14 @@ public:
...
@@ -128,6 +128,14 @@ public:
*/
*/
bool
compressFree
();
bool
compressFree
();
inline
void
compressFull
(
unsigned
int
nb
)
{
m_nbfree
=
0
;
m_nbref
=
nb
;
m_nb
=
nb
;
}
/**
/**
* clear the container of free block
* clear the container of free block
*/
*/
...
...
include/Topology/generic/mapImpl/mapMono.h
View file @
05b0276d
...
@@ -103,7 +103,7 @@ protected:
...
@@ -103,7 +103,7 @@ protected:
template
<
int
I
>
template
<
int
I
>
inline
void
permutationUnsew
(
Dart
d
);
inline
void
permutationUnsew
(
Dart
d
);
inline
virtual
void
compactTopo
();
virtual
void
compactTopo
();
/****************************************
/****************************************
* DARTS TRAVERSALS *
* DARTS TRAVERSALS *
...
...
include/Topology/generic/mapImpl/mapMono.hpp
View file @
05b0276d
...
@@ -186,33 +186,6 @@ inline void MapMono::permutationUnsew(Dart d)
...
@@ -186,33 +186,6 @@ inline void MapMono::permutationUnsew(Dart d)
(
*
m_permutation_inv
[
I
])[
e
.
index
]
=
e
;
(
*
m_permutation_inv
[
I
])[
e
.
index
]
=
e
;
}
}
inline
void
MapMono
::
compactTopo
()
{
std
::
vector
<
unsigned
int
>
oldnew
;
m_attribs
[
DART
].
compact
(
oldnew
);
for
(
unsigned
int
i
=
m_attribs
[
DART
].
begin
();
i
!=
m_attribs
[
DART
].
end
();
m_attribs
[
DART
].
next
(
i
))
{
for
(
unsigned
int
j
=
0
;
j
<
m_permutation
.
size
();
++
j
)
{
Dart
d
=
(
*
m_permutation
[
j
])[
i
];
if
(
d
.
index
!=
oldnew
[
d
.
index
])
(
*
m_permutation
[
j
])[
i
]
=
Dart
(
oldnew
[
d
.
index
]);
}
for
(
unsigned
int
j
=
0
;
j
<
m_permutation_inv
.
size
();
++
j
)
{
Dart
d
=
(
*
m_permutation_inv
[
j
])[
i
];
if
(
d
.
index
!=
oldnew
[
d
.
index
])
(
*
m_permutation_inv
[
j
])[
i
]
=
Dart
(
oldnew
[
d
.
index
]);
}
for
(
unsigned
int
j
=
0
;
j
<
m_involution
.
size
();
++
j
)
{
Dart
d
=
(
*
m_involution
[
j
])[
i
];
if
(
d
.
index
!=
oldnew
[
d
.
index
])
(
*
m_involution
[
j
])[
i
]
=
Dart
(
oldnew
[
d
.
index
]);
}
}
}
/****************************************
/****************************************
* DARTS TRAVERSALS *
* DARTS TRAVERSALS *
...
...
src/Container/attributeContainer.cpp
View file @
05b0276d
...
@@ -213,100 +213,67 @@ void AttributeContainer::clear(bool removeAttrib)
...
@@ -213,100 +213,67 @@ void AttributeContainer::clear(bool removeAttrib)
void AttributeContainer::compact(std::vector<unsigned int>& mapOldNew)
void AttributeContainer::compact(std::vector<unsigned int>& mapOldNew)
{
{
unsigned int nbe = _BLOCKSIZE_ * m_holesBlocks.size();
unsigned int nbb = m_holesBlocks.size() - 1;
while ((m_holesBlocks[nbb])->empty())
{
--nbb;
nbe -= _BLOCKSIZE_;
}
++nbb;
mapOldNew.clear();
mapOldNew.clear();
mapOldNew.res
erve(nbe
);
mapOldNew.res
ize(realEnd(),0xffffffff
);
// now get the holes
// fill the holes with data & create the map Old->New
unsigned int baseAdr = 0;
unsigned int up = realRBegin();
for (unsigned int i = 0; i < nbb; ++i)
unsigned int down = 0;
{
HoleBlockRef* block = m_holesBlocks[i];
for (unsigned int j = 0; j < _BLOCKSIZE_; ++j)
while (down < up)
{
if (!used(down))
{
{
if (j < block->sizeTable())
mapOldNew[up] = down;
{
// copy data
if (block->used(j))
copyLine(down,up);
mapOldNew.push_back(baseAdr);
// copy ref counter
else
setNbRefs(down,getNbRefs(up));
mapOldNew.push_back(0xffffffff);
// set next element to catch for hole filling
}
realRNext(up);
else
mapOldNew.push_back(0xffffffff);
baseAdr++;
}
}
down++;
}
}
unsigned int last = mapOldNew.size() - 1;
// end of table = nb elements
m_maxSize = m_size;
for (unsigned int i = 0 ; i < last; ++i)
// no more blocks empty
{
m_tableBlocksEmpty.clear();
unsigned int val = mapOldNew[i];
if (val == 0xffffffff)
{
// first find last element
while (mapOldNew[last] == 0xffffffff)
--last;
// store it in the hole
// find the blocks and indices
unsigned int bi = i / _BLOCKSIZE_;
unsigned int ib = i % _BLOCKSIZE_;
unsigned int bj = last / _BLOCKSIZE_;
unsigned int jb = last % _BLOCKSIZE_;
//overwrite attributes
for(unsigned int j = 0; j < m_tableAttribs.size(); ++j)
{
if (m_tableAttribs[j] != NULL)
m_tableAttribs[j]->overwrite(bj, jb, bi, ib);
}
// overwrite emptyLine with last line in free block
s
// only the last block has free indice
s
m_holesBlocks[bi]->overwrite(ib, m_holesBlocks[bj], jb
);
m_tableBlocksWithFree.clear(
);
// set the map value
// compute nb block full
mapOldNew[last] = i
;
unsigned int nbb = m_size / _BLOCKSIZE_
;
--last;
// update holeblock
}
for (unsigned int i=0; i<nbb; ++i)
}
m_holesBlocks[i]->compressFull(_BLOCKSIZE_);
for (int i = m_holesBlocks.size() - 1; i >= 0; --i)
//update last holeblock
unsigned int nbe = m_size % _BLOCKSIZE_;
if (nbe != 0)
{
{
HoleBlockRef* ptr = m_holesBlocks[i];
m_holesBlocks[nbb]->compressFull(nbe);
if (ptr->compressFree())
m_tableBlocksWithFree.push_back(nbb);
{
nbb++;
delete ptr;
m_holesBlocks.pop_back();
}
}
}
//
maj de la table de block libr
e
//
free memory and resiz
e
m_tableBlocksWithFree.clear();
for (int i = m_holesBlocks.size() - 1; i > nbb; --i)
HoleBlockRef* block = m_holesBlocks.back()
;
delete m_holesBlocks[i]
;
if (!block->full())
m_holesBlocks.resize(nbb);
m_tableBlocksWithFree.push_back(m_holesBlocks.size() - 1);
//
detruit les blocks de donnees inutiles
//
release unused data memory
for(unsigned int j = 0; j < m_tableAttribs.size(); ++j)
for(unsigned int j = 0; j < m_tableAttribs.size(); ++j)
{
{
if (m_tableAttribs[j] != NULL)
if (m_tableAttribs[j] != NULL)
m_tableAttribs[j]->setNbBlocks(m_holesBlocks.size());
m_tableAttribs[j]->setNbBlocks(m_holesBlocks.size());
}
}
m_maxSize = (m_holesBlocks.back())->sizeTable() + (m_holesBlocks.size() - 1) * _BLOCKSIZE_;
}
}
/**************************************
/**************************************
* LINES MANAGEMENT *
* LINES MANAGEMENT *
**************************************/
**************************************/
...
...
src/Topology/generic/mapMono.cpp
View file @
05b0276d
...
@@ -190,4 +190,35 @@ void MapMono::restore_topo_shortcuts()
...
@@ -190,4 +190,35 @@ void MapMono::restore_topo_shortcuts()
}
}
}
}
void
MapMono
::
compactTopo
()
{
std
::
vector
<
unsigned
int
>
oldnew
;
m_attribs
[
DART
].
compact
(
oldnew
);
for
(
unsigned
int
i
=
m_attribs
[
DART
].
begin
();
i
!=
m_attribs
[
DART
].
end
();
m_attribs
[
DART
].
next
(
i
))
{
for
(
unsigned
int
j
=
0
;
j
<
m_permutation
.
size
();
++
j
)
{
Dart
d
=
(
*
m_permutation
[
j
])[
i
];
if
(
oldnew
[
d
.
index
]
!=
AttributeContainer
::
UNKNOWN
)
(
*
m_permutation
[
j
])[
i
]
=
Dart
(
oldnew
[
d
.
index
]);
}
for
(
unsigned
int
j
=
0
;
j
<
m_permutation_inv
.
size
();
++
j
)
{
Dart
d
=
(
*
m_permutation_inv
[
j
])[
i
];
if
(
oldnew
[
d
.
index
]
!=
AttributeContainer
::
UNKNOWN
)
(
*
m_permutation_inv
[
j
])[
i
]
=
Dart
(
oldnew
[
d
.
index
]);
}
for
(
unsigned
int
j
=
0
;
j
<
m_involution
.
size
();
++
j
)
{
Dart
d
=
(
*
m_involution
[
j
])[
i
];
if
(
oldnew
[
d
.
index
]
!=
AttributeContainer
::
UNKNOWN
)
(
*
m_involution
[
j
])[
i
]
=
Dart
(
oldnew
[
d
.
index
]);
}
}
}
}
//namespace CGoGN
}
//namespace CGoGN
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