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
66788fb7
Commit
66788fb7
authored
Jan 06, 2013
by
Sauvage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edgeSelector_CurvatureTensor : début de la prog, voire les TODO
parent
190b5f75
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
272 additions
and
0 deletions
+272
-0
include/Algo/Decimation/decimation.hpp
include/Algo/Decimation/decimation.hpp
+3
-0
include/Algo/Decimation/edgeSelector.h
include/Algo/Decimation/edgeSelector.h
+59
-0
include/Algo/Decimation/edgeSelector.hpp
include/Algo/Decimation/edgeSelector.hpp
+209
-0
include/Algo/Decimation/selector.h
include/Algo/Decimation/selector.h
+1
-0
No files found.
include/Algo/Decimation/decimation.hpp
View file @
66788fb7
...
...
@@ -163,6 +163,9 @@ void decimate(
case
S_NormalArea
:
selector
=
new
EdgeSelector_NormalArea
<
PFP
>
(
map
,
position
,
approximators
,
selected
)
;
break
;
case
S_CurvatureTensor
:
selector
=
new
EdgeSelector_CurvatureTensor
<
PFP
>
(
map
,
position
,
approximators
,
selected
)
;
break
;
case
S_MinDetail
:
selector
=
new
EdgeSelector_MinDetail
<
PFP
>
(
map
,
position
,
approximators
,
selected
)
;
break
;
...
...
include/Algo/Decimation/edgeSelector.h
View file @
66788fb7
...
...
@@ -422,6 +422,65 @@ public:
void
updateWithoutCollapse
();
}
;
template
<
typename
PFP
>
class
EdgeSelector_CurvatureTensor
:
public
EdgeSelector
<
PFP
>
{
public:
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
private:
typedef
struct
{
typename
std
::
multimap
<
float
,
Dart
>::
iterator
it
;
bool
valid
;
static
std
::
string
CGoGNnameOfType
()
{
return
"CurvatureTensorEdgeInfo"
;
}
}
CurvatureTensorEdgeInfo
;
typedef
NoMathIOAttribute
<
CurvatureEdgeInfo
>
EdgeInfo
;
EdgeAttribute
<
EdgeInfo
>
edgeInfo
;
EdgeAttribute
<
REAL
>
edgeangle
;
std
::
multimap
<
float
,
Dart
>
edges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
Approximator
<
PFP
,
VEC3
,
EDGE
>*
m_positionApproximator
;
void
initEdgeInfo
(
Dart
d
)
;
void
updateEdgeInfo
(
Dart
d
,
bool
recompute
)
;
void
computeEdgeInfo
(
Dart
d
,
EdgeInfo
&
einfo
)
;
public:
EdgeSelector_CurvatureTensor
(
MAP
&
m
,
VertexAttribute
<
VEC3
>&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
)
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
),
m_positionApproximator
(
NULL
)
{
edgeangle
=
m
.
template
getAttribute
<
REAL
,
EDGE
>(
"edgeangle"
)
;
if
(
!
edgeangle
.
isValid
())
{
edgeangle
=
m
.
template
addAttribute
<
REAL
,
EDGE
>(
"edgeangle"
)
;
Algo
::
Geometry
::
computeAnglesBetweenNormalsOnEdges
<
PFP
>
(
m
,
pos
,
edgeangle
)
;
}
edgeInfo
=
m
.
template
addAttribute
<
EdgeInfo
,
EDGE
>(
"edgeInfo"
)
;
}
~
EdgeSelector_CurvatureTensor
()
{
this
->
m_map
.
removeAttribute
(
edgeangle
)
;
// TODO : pas malin s'il existait avant
this
->
m_map
.
removeAttribute
(
edgeInfo
)
;
}
SelectorType
getType
()
{
return
S_CurvatureTensor
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d
)
;
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
void
updateWithoutCollapse
()
{};
}
;
template
<
typename
PFP
>
class
EdgeSelector_MinDetail
:
public
EdgeSelector
<
PFP
>
{
...
...
include/Algo/Decimation/edgeSelector.hpp
View file @
66788fb7
...
...
@@ -1220,6 +1220,215 @@ void EdgeSelector_Curvature<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
einfo.valid = true ;
}
/************************************************************************************
* CURVATURE TENSOR *
************************************************************************************/
template <typename PFP>
bool CurvatureTensor<PFP>::init()
{
MAP& m = this->m_map ;
bool ok = false ;
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = this->m_approximators.begin();
it != this->m_approximators.end() && !ok;
++it)
{
if((*it)->getApproximatedAttributeName() == "position")
{
assert((*it)->getType() == A_MidEdge || !"Only MidEdge Approximator is valid") ;
m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3,EDGE>* >(*it) ;
ok = true ;
}
}
if(!ok)
return false ;
edges.clear() ;
// TraversorE<MAP> travE(m);
// for(Dart dit = travE.begin() ; dit != travE.end() ; dit = travE.next())
// {
// computeEdgeMatrix(dit);
// }
for(Dart dit = travE.begin() ; dit != travE.end() ; dit = travE.next())
{
initEdgeInfo(dit) ; // init "edgeInfo" and "edges"
}
cur = edges.begin() ; // init the current edge to the first one
return true ;
}
template <typename PFP>
bool CurvatureTensor<PFP>::nextEdge(Dart& d)
{
if(cur == edges.end() || edges.empty())
return false ;
d = (*cur).second ;
return true ;
}
template <typename PFP>
void CurvatureTensor<PFP>::updateBeforeCollapse(Dart d)
{
MAP& m = this->m_map ;
assert(!m.isBoundaryEdge(d));
EdgeInfo* edgeE = &(edgeInfo[d]) ;
if(edgeE->valid)
{
edges.erase(edgeE->it) ;
edgeE->valid = false;
}
edgeE = &(edgeInfo[m.phi1(d)]) ;
if(edgeE->valid) // remove all
{
edges.erase(edgeE->it) ;
edgeE->valid = false;
}
edgeE = &(edgeInfo[m.phi_1(d)]) ; // the concerned edges
if(edgeE->valid)
{
edges.erase(edgeE->it) ;
edgeE->valid = false;
}
// from the multimap
Dart dd = m.phi2(d) ;
edgeE = &(edgeInfo[m.phi1(dd)]) ;
if(edgeE->valid)
{
edges.erase(edgeE->it) ;
edgeE->valid = false;
}
edgeE = &(edgeInfo[m.phi_1(dd)]) ;
if(edgeE->valid)
{
edges.erase(edgeE->it) ;
edgeE->valid = false;
}
}
template <typename PFP>
void CurvatureTensor<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
{
MAP& m = this->m_map ;
// TODO : here update edge angles : should look like :
// edgeangle[d] = computeAngleBetweenNormalsOnEdge<PFP>(map, d, this->m_position) ;
// update the edge matrices
// Traversor2VE<MAP> te (m,d2);
// for(Dart dit = te.begin() ; dit != te.end() ; dit = te.next())
// {
// computeEdgeMatrix(dit);
// }
// update the multimap
Traversor2VVaE<MAP> tv (m,d2);
CellMarker<EDGE> eMark (m);
for(Dart dit = tv.begin() ; dit != tv.end() ; dit = tv.next())
{
Traversor2VE<MAP> te2 (m,dit);
for(Dart dit2 = te2.begin() ; dit2 != te2.end() ; dit2 = te2.next())
{
if (!eMark.isMarked(dit2))
{
updateEdgeInfo(dit2) ;
eMark.mark(dit2);
}
}
}
cur = edges.begin() ; // set the current edge to the first one
}
template <typename PFP>
void CurvatureTensor<PFP>::initEdgeInfo(Dart d)
{
MAP& m = this->m_map ;
EdgeInfo einfo ;
if(m.edgeCanCollapse(d))
computeEdgeInfo(d, einfo) ;
else
einfo.valid = false ;
edgeInfo[d] = einfo ;
}
template <typename PFP>
void CurvatureTensor<PFP>::updateEdgeInfo(Dart d)
{
MAP& m = this->m_map ;
EdgeInfo& einfo = edgeInfo[d] ;
if(einfo.valid)
edges.erase(einfo.it) ; // remove the edge from the multimap
if(m.edgeCanCollapse(d))
computeEdgeInfo(d, einfo) ;
else
einfo.valid = false ;
}
template <typename PFP>
void EdgeSelector_CurvatureTensor<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
{
// TODO : code this function : everything complex is here
MAP& m = this->m_map ;
Dart dd = m.phi2(d);
Geom::Matrix33f M1; // init zero included
Geom::Matrix33f M2; // init zero included
assert(! m.isBoundaryEdge(d));
Traversor2VF<MAP> td (m,d);
Dart it = td.begin();
it = td.next();
Dart it2 = td.next();
while( it2 != td.end())
{
M1 += edgeMatrix[m.phi1(it)];
it = it2;
it2 = td.next();
}
Traversor2VF<MAP> tdd (m,dd);
it = tdd.begin();
it = tdd.next();
it2 = tdd.next();
while( it2 != tdd.end())
{
M2 += edgeMatrix[m.phi1(it)];
it = it2;
it2 = tdd.next();
}
m_positionApproximator->approximate(d) ;
const VEC3& a = m_positionApproximator->getApprox(d) ;
const VEC3 av1 = a - this->m_position[d] ;
const VEC3 av2 = a - this->m_position[dd] ;
REAL err = av1 * (M1 * av1) + av2 * (M2 * av2);
einfo.it = edges.insert(std::make_pair(err, d)) ;
einfo.valid = true ;
}
/************************************************************************************
* MIN DETAIL *
************************************************************************************/
...
...
include/Algo/Decimation/selector.h
View file @
66788fb7
...
...
@@ -44,6 +44,7 @@ enum SelectorType
S_MinDetail
,
S_Curvature
,
S_NormalArea
,
S_CurvatureTensor
,
S_ColorNaive
,
S_QEMextColor
,
S_Lightfield
,
...
...
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