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
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
cb2b0201
Commit
cb2b0201
authored
Apr 19, 2013
by
Kenneth Vanhoey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup of all files in namespace ALGO::SURFACE::DECIMATION
parent
bb0f0406
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
245 additions
and
152 deletions
+245
-152
include/Algo/Decimation/approximator.h
include/Algo/Decimation/approximator.h
+23
-152
include/Algo/Decimation/approximator.hpp
include/Algo/Decimation/approximator.hpp
+222
-0
No files found.
include/Algo/Decimation/approximator.h
View file @
cb2b0201
...
...
@@ -109,162 +109,33 @@ protected:
std
::
vector
<
T
>
m_app
;
public:
Approximator
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
T
>*
>
va
,
Predictor
<
PFP
,
T
>
*
predictor
)
:
ApproximatorGen
<
PFP
>
(
m
),
m_predictor
(
predictor
),
m_attrV
(
va
)
{
const
unsigned
int
&
size
=
m_attrV
.
size
()
;
assert
(
size
>
0
||
!
"Approximator: no attributes provided"
)
;
m_approx
.
resize
(
size
)
;
m_detail
.
resize
(
size
)
;
m_app
.
resize
(
size
)
;
for
(
unsigned
int
i
=
0
;
i
<
size
;
++
i
)
{
if
(
!
m_attrV
[
i
]
->
isValid
())
std
::
cerr
<<
"Approximator Warning: attribute number "
<<
i
<<
" is not valid"
<<
std
::
endl
;
std
::
stringstream
aname
;
aname
<<
"approx_"
<<
m_attrV
[
i
]
->
name
()
;
m_approx
[
i
]
=
this
->
m_map
.
template
addAttribute
<
T
,
ORBIT
>(
aname
.
str
())
;
if
(
m_predictor
)
// if predictors are associated to the approximator
{
// create attributes to store the details needed for reconstruction
std
::
stringstream
dname
;
dname
<<
"detail_"
<<
m_attrV
[
i
]
->
name
()
;
m_detail
[
i
]
=
this
->
m_map
.
template
addAttribute
<
T
,
ORBIT
>(
dname
.
str
())
;
}
}
}
virtual
~
Approximator
()
{
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
this
->
m_map
.
template
removeAttribute
(
m_approx
[
i
])
;
if
(
m_predictor
)
this
->
m_map
.
template
removeAttribute
(
m_detail
[
i
])
;
}
}
const
std
::
string
&
getApproximatedAttributeName
(
unsigned
int
index
=
0
)
const
{
return
m_attrV
[
index
]
->
name
()
;
}
unsigned
int
getNbApproximated
()
const
{
return
m_attrV
.
size
()
;
}
void
saveApprox
(
Dart
d
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
m_app
[
i
]
=
m_approx
[
i
][
d
]
;
}
}
void
affectApprox
(
Dart
d
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
m_attrV
[
i
]
->
operator
[](
d
)
=
m_app
[
i
]
;
}
}
const
T
&
getApprox
(
Dart
d
,
unsigned
int
index
=
0
)
const
{
return
m_approx
[
index
][
d
]
;
}
const
VertexAttribute
<
T
>&
getAttr
(
unsigned
int
index
=
0
)
const
{
return
*
(
m_attrV
[
index
])
;
}
VertexAttribute
<
T
>&
getAttr
(
unsigned
int
index
=
0
)
{
return
*
(
m_attrV
[
index
])
;
}
std
::
vector
<
T
>
getAllApprox
(
Dart
d
)
const
{
std
::
vector
<
T
>
res
;
res
.
resize
(
m_attrV
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
res
[
i
]
=
m_approx
[
i
][
d
]
;
return
res
;
}
const
Predictor
<
PFP
,
T
>*
getPredictor
()
const
{
return
m_predictor
;
}
const
T
&
getDetail
(
Dart
d
,
unsigned
int
index
=
0
)
const
{
assert
(
m_predictor
||
!
"Trying to get detail on a non-predictive scheme"
)
;
return
m_detail
[
index
][
d
]
;
}
std
::
vector
<
T
>
getAllDetail
(
Dart
d
)
const
{
assert
(
m_predictor
||
!
"Trying to get detail on a non-predictive scheme"
)
;
std
::
vector
<
T
>
res
;
res
.
resize
(
m_attrV
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
res
[
i
]
=
m_detail
[
i
][
d
]
;
return
res
;
}
void
setDetail
(
Dart
d
,
unsigned
int
index
,
T
&
val
)
{
assert
(
m_predictor
||
!
"Trying to set detail on a non-predictive scheme"
)
;
m_detail
[
index
][
d
]
=
val
;
}
void
setDetail
(
Dart
d
,
std
::
vector
<
T
>&
val
)
{
assert
(
m_predictor
||
!
"Trying to set detail on a non-predictive scheme"
)
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
m_detail
[
index
][
d
]
=
val
[
i
]
;
}
// // TODO works only for vector types !!
// REAL detailMagnitude(Dart d)
// {
// assert(m_predictor || !"Trying to get detail magnitude on a non-predictive scheme") ;
// return m_detail[d].norm2() ;
// }
void
addDetail
(
Dart
d
,
double
amount
,
bool
sign
,
typename
PFP
::
MATRIX33
*
detailTransform
)
{
assert
(
m_predictor
||
!
"Trying to add detail on a non-predictive scheme"
)
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
T
det
=
m_detail
[
i
][
d
]
;
if
(
detailTransform
)
det
=
(
*
detailTransform
)
*
det
;
det
*=
amount
;
if
(
!
sign
)
det
*=
REAL
(
-
1
)
;
m_attrV
[
i
]
->
operator
[](
d
)
+=
det
;
}
}
Approximator
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
T
>*
>
va
,
Predictor
<
PFP
,
T
>
*
predictor
)
;
~
Approximator
()
;
const
std
::
string
&
getApproximatedAttributeName
(
unsigned
int
index
=
0
)
const
;
unsigned
int
getNbApproximated
()
const
;
void
saveApprox
(
Dart
d
)
;
void
affectApprox
(
Dart
d
)
;
const
T
&
getApprox
(
Dart
d
,
unsigned
int
index
=
0
)
const
;
const
VertexAttribute
<
T
>&
getAttr
(
unsigned
int
index
=
0
)
const
;
VertexAttribute
<
T
>&
getAttr
(
unsigned
int
index
=
0
)
;
std
::
vector
<
T
>
getAllApprox
(
Dart
d
)
const
;
const
Predictor
<
PFP
,
T
>*
getPredictor
()
const
;
const
T
&
getDetail
(
Dart
d
,
unsigned
int
index
=
0
)
const
;
std
::
vector
<
T
>
getAllDetail
(
Dart
d
)
const
;
void
setDetail
(
Dart
d
,
unsigned
int
index
,
T
&
val
)
;
void
setDetail
(
Dart
d
,
std
::
vector
<
T
>&
val
)
;
// REAL detailMagnitude(Dart d) ; // TODO works only for vector types !!
void
addDetail
(
Dart
d
,
double
amount
,
bool
sign
,
typename
PFP
::
MATRIX33
*
detailTransform
)
;
}
;
}
//namespace Decimation
}
// namespace Decimation
}
// namespace surface
}
//
surface
}
//
namespace Algo
}
//
namespace Algo
}
//
namespace CGoGN
}
//namespace CGoGN
#include "Algo/Decimation/approximator.hpp"
#endif
include/Algo/Decimation/approximator.hpp
0 → 100644
View file @
cb2b0201
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2013, IGG Team, ICube, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace
CGoGN
{
namespace
Algo
{
namespace
Surface
{
namespace
Decimation
{
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
Approximator
<
PFP
,
T
,
ORBIT
>::
Approximator
(
MAP
&
m
,
std
::
vector
<
VertexAttribute
<
T
>*
>
va
,
Predictor
<
PFP
,
T
>
*
predictor
)
:
ApproximatorGen
<
PFP
>
(
m
),
m_predictor
(
predictor
),
m_attrV
(
va
)
{
const
unsigned
int
&
size
=
m_attrV
.
size
()
;
assert
(
size
>
0
||
!
"Approximator: no attributes provided"
)
;
m_approx
.
resize
(
size
)
;
m_detail
.
resize
(
size
)
;
m_app
.
resize
(
size
)
;
for
(
unsigned
int
i
=
0
;
i
<
size
;
++
i
)
{
if
(
!
m_attrV
[
i
]
->
isValid
())
std
::
cerr
<<
"Approximator Warning: attribute number "
<<
i
<<
" is not valid"
<<
std
::
endl
;
std
::
stringstream
aname
;
aname
<<
"approx_"
<<
m_attrV
[
i
]
->
name
()
;
m_approx
[
i
]
=
this
->
m_map
.
template
addAttribute
<
T
,
ORBIT
>(
aname
.
str
())
;
if
(
m_predictor
)
// if predictors are associated to the approximator
{
// create attributes to store the details needed for reconstruction
std
::
stringstream
dname
;
dname
<<
"detail_"
<<
m_attrV
[
i
]
->
name
()
;
m_detail
[
i
]
=
this
->
m_map
.
template
addAttribute
<
T
,
ORBIT
>(
dname
.
str
())
;
}
}
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
Approximator
<
PFP
,
T
,
ORBIT
>::~
Approximator
()
{
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
this
->
m_map
.
template
removeAttribute
(
m_approx
[
i
])
;
if
(
m_predictor
)
this
->
m_map
.
template
removeAttribute
(
m_detail
[
i
])
;
}
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
const
std
::
string
&
Approximator
<
PFP
,
T
,
ORBIT
>::
getApproximatedAttributeName
(
unsigned
int
index
)
const
{
return
m_attrV
[
index
]
->
name
()
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
unsigned
int
Approximator
<
PFP
,
T
,
ORBIT
>::
getNbApproximated
()
const
{
return
m_attrV
.
size
()
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
void
Approximator
<
PFP
,
T
,
ORBIT
>::
saveApprox
(
Dart
d
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
m_app
[
i
]
=
m_approx
[
i
][
d
]
;
}
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
void
Approximator
<
PFP
,
T
,
ORBIT
>::
affectApprox
(
Dart
d
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
m_attrV
[
i
]
->
operator
[](
d
)
=
m_app
[
i
]
;
}
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
const
T
&
Approximator
<
PFP
,
T
,
ORBIT
>::
getApprox
(
Dart
d
,
unsigned
int
index
)
const
{
return
m_approx
[
index
][
d
]
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
const
VertexAttribute
<
T
>&
Approximator
<
PFP
,
T
,
ORBIT
>::
getAttr
(
unsigned
int
index
)
const
{
return
*
(
m_attrV
[
index
])
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
VertexAttribute
<
T
>&
Approximator
<
PFP
,
T
,
ORBIT
>::
getAttr
(
unsigned
int
index
)
{
return
*
(
m_attrV
[
index
])
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
std
::
vector
<
T
>
Approximator
<
PFP
,
T
,
ORBIT
>::
getAllApprox
(
Dart
d
)
const
{
std
::
vector
<
T
>
res
;
res
.
resize
(
m_attrV
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
res
[
i
]
=
m_approx
[
i
][
d
]
;
return
res
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
const
Predictor
<
PFP
,
T
>*
Approximator
<
PFP
,
T
,
ORBIT
>::
getPredictor
()
const
{
return
m_predictor
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
const
T
&
Approximator
<
PFP
,
T
,
ORBIT
>::
getDetail
(
Dart
d
,
unsigned
int
index
)
const
{
assert
(
m_predictor
||
!
"Trying to get detail on a non-predictive scheme"
)
;
return
m_detail
[
index
][
d
]
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
std
::
vector
<
T
>
Approximator
<
PFP
,
T
,
ORBIT
>::
getAllDetail
(
Dart
d
)
const
{
assert
(
m_predictor
||
!
"Trying to get detail on a non-predictive scheme"
)
;
std
::
vector
<
T
>
res
;
res
.
resize
(
m_attrV
.
size
())
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
res
[
i
]
=
m_detail
[
i
][
d
]
;
return
res
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
void
Approximator
<
PFP
,
T
,
ORBIT
>::
setDetail
(
Dart
d
,
unsigned
int
index
,
T
&
val
)
{
assert
(
m_predictor
||
!
"Trying to set detail on a non-predictive scheme"
)
;
m_detail
[
index
][
d
]
=
val
;
}
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
void
Approximator
<
PFP
,
T
,
ORBIT
>::
setDetail
(
Dart
d
,
std
::
vector
<
T
>&
val
)
{
assert
(
m_predictor
||
!
"Trying to set detail on a non-predictive scheme"
)
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
m_detail
[
index
][
d
]
=
val
[
i
]
;
}
// // TODO works only for vector types !!
// REAL detailMagnitude(Dart d)
// {
// assert(m_predictor || !"Trying to get detail magnitude on a non-predictive scheme") ;
// return m_detail[d].norm2() ;
// }
template
<
typename
PFP
,
typename
T
,
unsigned
int
ORBIT
>
void
Approximator
<
PFP
,
T
,
ORBIT
>::
addDetail
(
Dart
d
,
double
amount
,
bool
sign
,
typename
PFP
::
MATRIX33
*
detailTransform
)
{
assert
(
m_predictor
||
!
"Trying to add detail on a non-predictive scheme"
)
;
for
(
unsigned
int
i
=
0
;
i
<
m_attrV
.
size
()
;
++
i
)
{
T
det
=
m_detail
[
i
][
d
]
;
if
(
detailTransform
)
det
=
(
*
detailTransform
)
*
det
;
det
*=
amount
;
if
(
!
sign
)
det
*=
REAL
(
-
1
)
;
m_attrV
[
i
]
->
operator
[](
d
)
+=
det
;
}
}
}
//namespace Decimation
}
// namespace surface
}
//namespace Algo
}
//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