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
Etienne Schmitt
CGoGN
Commits
fb95e191
Commit
fb95e191
authored
Apr 04, 2011
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of cgogn:~vanhoey/CGoGN
parents
2f7d4461
7af03e77
Changes
31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
2762 additions
and
876 deletions
+2762
-876
include/Algo/Decimation/approximator.h
include/Algo/Decimation/approximator.h
+2
-0
include/Algo/Decimation/decimation.h
include/Algo/Decimation/decimation.h
+2
-1
include/Algo/Decimation/decimation.hpp
include/Algo/Decimation/decimation.hpp
+55
-7
include/Algo/Decimation/edgeSelector.h
include/Algo/Decimation/edgeSelector.h
+362
-0
include/Algo/Decimation/edgeSelector.hpp
include/Algo/Decimation/edgeSelector.hpp
+74
-84
include/Algo/Decimation/geometryApproximator.h
include/Algo/Decimation/geometryApproximator.h
+22
-0
include/Algo/Decimation/geometryApproximator.hpp
include/Algo/Decimation/geometryApproximator.hpp
+63
-0
include/Algo/Decimation/halfEdgeSelector.h
include/Algo/Decimation/halfEdgeSelector.h
+221
-0
include/Algo/Decimation/halfEdgeSelector.hpp
include/Algo/Decimation/halfEdgeSelector.hpp
+807
-0
include/Algo/Decimation/lightfieldApproximator.h
include/Algo/Decimation/lightfieldApproximator.h
+51
-1
include/Algo/Decimation/lightfieldApproximator.hpp
include/Algo/Decimation/lightfieldApproximator.hpp
+167
-30
include/Algo/Decimation/selector.h
include/Algo/Decimation/selector.h
+3
-332
include/Algo/Export/export.h
include/Algo/Export/export.h
+4
-13
include/Algo/Export/export.hpp
include/Algo/Export/export.hpp
+16
-134
include/Algo/Geometry/normalization.h
include/Algo/Geometry/normalization.h
+75
-0
include/Algo/Import/import2tablesSurface.hpp
include/Algo/Import/import2tablesSurface.hpp
+20
-6
include/Algo/Render/map_glRender.h
include/Algo/Render/map_glRender.h
+4
-1
include/Algo/Render/map_glRender.hpp
include/Algo/Render/map_glRender.hpp
+12
-0
include/Algo/Render/renderFunctor.h
include/Algo/Render/renderFunctor.h
+39
-2
include/Algo/Render/renderFunctor.hpp
include/Algo/Render/renderFunctor.hpp
+25
-1
include/Algo/Render/vbo_MapRender.hpp
include/Algo/Render/vbo_MapRender.hpp
+1
-1
include/Geometry/vector_gen.hpp
include/Geometry/vector_gen.hpp
+11
-10
include/Topology/generic/cellmarker.h
include/Topology/generic/cellmarker.h
+1
-0
include/Utils/colourConverter.h
include/Utils/colourConverter.h
+135
-0
include/Utils/colourConverter.hpp
include/Utils/colourConverter.hpp
+367
-0
include/Utils/glutwin_ATBdark.h
include/Utils/glutwin_ATBdark.h
+2
-0
include/Utils/qem.h
include/Utils/qem.h
+3
-0
include/Utils/quadricRGBfunctions.h
include/Utils/quadricRGBfunctions.h
+44
-21
include/Utils/quadricRGBfunctions.hpp
include/Utils/quadricRGBfunctions.hpp
+164
-230
include/Utils/shared_mem.hpp
include/Utils/shared_mem.hpp
+4
-1
src/Utils/glutwin_ATBdark.cpp
src/Utils/glutwin_ATBdark.cpp
+6
-1
No files found.
include/Algo/Decimation/approximator.h
View file @
fb95e191
...
...
@@ -39,11 +39,13 @@ namespace Decimation
enum
ApproximatorType
{
A_QEM
,
A_QEMhalfEdge
,
A_MidEdge
,
A_HalfCollapse
,
A_CornerCutting
,
A_TangentPredict1
,
A_TangentPredict2
,
A_LightfieldHalf
,
A_LightfieldFull
}
;
...
...
include/Algo/Decimation/decimation.h
View file @
fb95e191
...
...
@@ -25,7 +25,8 @@
#ifndef __DECIMATION_H__
#define __DECIMATION_H__
#include "Algo/Decimation/selector.h"
#include "Algo/Decimation/edgeSelector.h"
#include "Algo/Decimation/halfEdgeSelector.h"
#include "Algo/Decimation/geometryApproximator.h"
#include "Algo/Decimation/lightfieldApproximator.h"
...
...
include/Algo/Decimation/decimation.hpp
View file @
fb95e191
...
...
@@ -45,6 +45,9 @@ void decimate(
case
A_QEM
:
approximators
.
push_back
(
new
Approximator_QEM
<
PFP
>
(
map
,
position
))
;
break
;
case
A_QEMhalfEdge
:
approximators
.
push_back
(
new
Approximator_QEMhalfEdge
<
PFP
>
(
map
,
position
))
;
break
;
case
A_MidEdge
:
approximators
.
push_back
(
new
Approximator_MidEdge
<
PFP
>
(
map
,
position
))
;
break
;
...
...
@@ -62,13 +65,44 @@ void decimate(
break
;
case
A_LightfieldFull
:
{
approximators
.
push_back
(
new
Approximator_QEM
<
PFP
>
(
map
,
position
))
;
approximators
.
push_back
(
new
Approximator_QEMhalfEdge
<
PFP
>
(
map
,
position
))
;
/*
PFP::TVEC3 frame[3] ;
frame[0] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "frame_T") ; // Tangent
frame[1] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "frame_B") ; // Bitangent
frame[2] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "frame_N") ; // Normal
for (unsigned int i = 0 ; i < 3 ; ++i)
if (!frame[i].isValid()) {
std::cerr << "In function decimate : frame[" << i << "] is not valid" << std::endl ;
}
AttributeHandler<typename PFP::VEC3> colorPTM[6] ;
colorPTM[0] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_a") ;
colorPTM[1] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_b") ;
colorPTM[2] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_c") ;
colorPTM[3] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_d") ;
colorPTM[4] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_e") ;
colorPTM[5] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "colorPTM_f") ;
for (unsigned int i = 0 ; i < 6 ; ++i)
if (!colorPTM[i].isValid()) {
std::cerr << "In function decimate : colorPTM[" << i << "] is not valid" << std::endl ;
}
*/
AttributeHandler
<
Geom
::
Matrix
<
3
,
3
,
typename
PFP
::
REAL
>
>
frame
=
map
.
template
getAttribute
<
Geom
::
Matrix
<
3
,
3
,
typename
PFP
::
REAL
>
>
(
VERTEX_ORBIT
,
"frame"
)
;
AttributeHandler
<
Geom
::
Matrix
<
3
,
6
,
typename
PFP
::
REAL
>
>
RGBfunctions
=
map
.
template
getAttribute
<
Geom
::
Matrix
<
3
,
6
,
typename
PFP
::
REAL
>
>
(
VERTEX_ORBIT
,
"
RGBfunctions
"
)
;
AttributeHandler
<
Geom
::
Matrix
<
3
,
6
,
typename
PFP
::
REAL
>
>
RGBfunctions
=
map
.
template
getAttribute
<
Geom
::
Matrix
<
3
,
6
,
typename
PFP
::
REAL
>
>
(
VERTEX_ORBIT
,
"
colorPTM
"
)
;
approximators
.
push_back
(
new
Approximator_Frame
<
PFP
>
(
map
,
frame
))
;
approximators
.
push_back
(
new
Approximator_RGBfunctions
<
PFP
>
(
map
,
RGBfunctions
))
;
break
;
}
case
A_LightfieldHalf
:
{
approximators
.
push_back
(
new
Approximator_HalfCollapse
<
PFP
>
(
map
,
position
))
;
AttributeHandler
<
Geom
::
Matrix
<
3
,
3
,
typename
PFP
::
REAL
>
>
frame
=
map
.
template
getAttribute
<
Geom
::
Matrix
<
3
,
3
,
typename
PFP
::
REAL
>
>
(
VERTEX_ORBIT
,
"frame"
)
;
AttributeHandler
<
Geom
::
Matrix
<
3
,
6
,
typename
PFP
::
REAL
>
>
RGBfunctions
=
map
.
template
getAttribute
<
Geom
::
Matrix
<
3
,
6
,
typename
PFP
::
REAL
>
>
(
VERTEX_ORBIT
,
"colorPTM"
)
;
approximators
.
push_back
(
new
Approximator_FrameHalf
<
PFP
>
(
map
,
frame
))
;
approximators
.
push_back
(
new
Approximator_RGBfunctionsHalf
<
PFP
>
(
map
,
RGBfunctions
))
;
break
;
}
}
switch
(
s
)
...
...
@@ -82,18 +116,24 @@ void decimate(
case
S_EdgeLength
:
selector
=
new
EdgeSelector_Length
<
PFP
>
(
map
,
position
,
approximators
)
;
break
;
case
S_QEMml
:
selector
=
new
EdgeSelector_QEMml
<
PFP
>
(
map
,
position
,
approximators
)
;
break
;
case
S_QEM
:
selector
=
new
EdgeSelector_QEM
<
PFP
>
(
map
,
position
,
approximators
)
;
break
;
case
S_Lightfield
:
selector
=
new
EdgeSelector_Lightfield
<
PFP
>
(
map
,
position
,
approximators
)
;
break
;
case
S_Curvature
:
selector
=
new
EdgeSelector_Curvature
<
PFP
>
(
map
,
position
,
approximators
)
;
break
;
case
S_MinDetail
:
selector
=
new
EdgeSelector_Random
<
PFP
>
(
map
,
position
,
approximators
)
;
break
;
case
S_hLightfield
:
selector
=
new
HalfEdgeSelector_Lightfield
<
PFP
>
(
map
,
position
,
approximators
)
;
break
;
case
S_hQEMml
:
selector
=
new
HalfEdgeSelector_QEMml
<
PFP
>
(
map
,
position
,
approximators
)
;
break
;
}
for
(
typename
std
::
vector
<
ApproximatorGen
<
PFP
>*>::
iterator
it
=
approximators
.
begin
();
it
!=
approximators
.
end
();
++
it
)
...
...
@@ -105,10 +145,16 @@ void decimate(
unsigned
int
nbVertices
=
map
.
getNbOrbits
(
VERTEX_ORBIT
)
;
bool
finished
=
false
;
Dart
d
;
while
(
!
finished
)
{
if
(
!
selector
->
nextEdge
(
d
))
std
::
cout
<<
"Countdown : "
;
std
::
cout
<<
std
::
setprecision
(
8
)
<<
(
nbVertices
-
nbWantedVertices
)
<<
"
\r
"
<<
std
::
flush
;
if
(
!
selector
->
nextEdge
(
d
))
{
std
::
cout
<<
std
::
endl
<<
"out"
<<
std
::
endl
;
break
;
}
--
nbVertices
;
...
...
@@ -130,8 +176,10 @@ void decimate(
selector
->
updateAfterCollapse
(
d2
,
dd2
)
;
// update selector
if
(
nbVertices
<=
nbWantedVertices
)
if
(
nbVertices
<=
nbWantedVertices
)
{
finished
=
true
;
std
::
cout
<<
std
::
endl
<<
"done"
<<
std
::
endl
;
}
}
delete
selector
;
...
...
include/Algo/Decimation/edgeSelector.h
0 → 100644
View file @
fb95e191
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, 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: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __EDGESELECTOR_H__
#define __EDGESELECTOR_H__
#include "Algo/Decimation/selector.h"
namespace
CGoGN
{
namespace
Algo
{
namespace
Decimation
{
template
<
typename
PFP
>
class
EdgeSelector_MapOrder
:
public
EdgeSelector
<
PFP
>
{
public:
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
private:
Dart
cur
;
public:
EdgeSelector_MapOrder
(
MAP
&
m
,
typename
PFP
::
TVEC3
&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
SelectorTrue
())
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
)
{}
~
EdgeSelector_MapOrder
()
{}
SelectorType
getType
()
{
return
S_MapOrder
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d
)
{}
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
}
;
template
<
typename
PFP
>
class
EdgeSelector_Random
:
public
EdgeSelector
<
PFP
>
{
public:
typedef
typename
PFP
::
MAP
MAP
;
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
private:
std
::
vector
<
Dart
>
darts
;
unsigned
int
cur
;
bool
allSkipped
;
public:
EdgeSelector_Random
(
MAP
&
m
,
typename
PFP
::
TVEC3
&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
SelectorTrue
())
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
)
{}
~
EdgeSelector_Random
()
{}
SelectorType
getType
()
{
return
S_Random
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d2
)
{}
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
}
;
template
<
typename
PFP
>
class
EdgeSelector_Length
:
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
"LengthEdgeInfo"
;
}
}
LengthEdgeInfo
;
typedef
NoMathIOAttribute
<
LengthEdgeInfo
>
EdgeInfo
;
AttributeHandler
<
EdgeInfo
>
edgeInfo
;
std
::
multimap
<
float
,
Dart
>
edges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
void
initEdgeInfo
(
Dart
d
)
;
void
updateEdgeInfo
(
Dart
d
,
bool
recompute
)
;
void
computeEdgeInfo
(
Dart
d
,
EdgeInfo
&
einfo
)
;
public:
EdgeSelector_Length
(
MAP
&
m
,
typename
PFP
::
TVEC3
&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
SelectorTrue
())
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
)
{
edgeInfo
=
m
.
template
addAttribute
<
EdgeInfo
>(
EDGE_ORBIT
,
"edgeInfo"
)
;
}
~
EdgeSelector_Length
()
{
this
->
m_map
.
removeAttribute
(
edgeInfo
)
;
}
SelectorType
getType
()
{
return
S_EdgeLength
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d
)
;
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
}
;
template
<
typename
PFP
>
class
EdgeSelector_QEM
:
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
"QEMedgeInfo"
;
}
}
QEMedgeInfo
;
typedef
NoMathIOAttribute
<
QEMedgeInfo
>
EdgeInfo
;
AttributeHandler
<
EdgeInfo
>
edgeInfo
;
AttributeHandler
<
Quadric
<
REAL
>
>
quadric
;
Quadric
<
REAL
>
tmpQ
;
std
::
multimap
<
float
,
Dart
>
edges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
Approximator
<
PFP
,
typename
PFP
::
VEC3
>*
m_positionApproximator
;
void
initEdgeInfo
(
Dart
d
)
;
void
updateEdgeInfo
(
Dart
d
,
bool
recompute
)
;
void
computeEdgeInfo
(
Dart
d
,
EdgeInfo
&
einfo
)
;
public:
EdgeSelector_QEM
(
MAP
&
m
,
typename
PFP
::
TVEC3
&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
SelectorTrue
())
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
)
{
edgeInfo
=
m
.
template
addAttribute
<
EdgeInfo
>(
EDGE_ORBIT
,
"edgeInfo"
)
;
quadric
=
m
.
template
addAttribute
<
Quadric
<
REAL
>
>
(
VERTEX_ORBIT
,
"QEMquadric"
)
;
}
~
EdgeSelector_QEM
()
{
this
->
m_map
.
removeAttribute
(
quadric
)
;
this
->
m_map
.
removeAttribute
(
edgeInfo
)
;
}
SelectorType
getType
()
{
return
S_QEM
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d
)
;
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
}
;
template
<
typename
PFP
>
class
EdgeSelector_QEMml
:
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
"QEMedgeInfo"
;
}
}
QEMedgeInfo
;
typedef
NoMathIOAttribute
<
QEMedgeInfo
>
EdgeInfo
;
AttributeHandler
<
EdgeInfo
>
edgeInfo
;
AttributeHandler
<
Quadric
<
REAL
>
>
quadric
;
std
::
multimap
<
float
,
Dart
>
edges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
Approximator
<
PFP
,
typename
PFP
::
VEC3
>*
m_positionApproximator
;
void
initEdgeInfo
(
Dart
d
)
;
void
updateEdgeInfo
(
Dart
d
,
bool
recompute
)
;
void
computeEdgeInfo
(
Dart
d
,
EdgeInfo
&
einfo
)
;
void
recomputeQuadric
(
const
Dart
d
,
const
bool
recomputeNeighbors
=
false
)
;
public:
EdgeSelector_QEMml
(
MAP
&
m
,
typename
PFP
::
TVEC3
&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
SelectorTrue
())
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
)
{
edgeInfo
=
m
.
template
addAttribute
<
EdgeInfo
>(
EDGE_ORBIT
,
"edgeInfo"
)
;
quadric
=
m
.
template
addAttribute
<
Quadric
<
REAL
>
>
(
VERTEX_ORBIT
,
"QEMquadric"
)
;
}
~
EdgeSelector_QEMml
()
{
this
->
m_map
.
removeAttribute
(
quadric
)
;
this
->
m_map
.
removeAttribute
(
edgeInfo
)
;
}
SelectorType
getType
()
{
return
S_QEMml
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d
)
;
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
}
;
template
<
typename
PFP
>
class
EdgeSelector_Curvature
:
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
"CurvatureEdgeInfo"
;
}
}
CurvatureEdgeInfo
;
typedef
NoMathIOAttribute
<
CurvatureEdgeInfo
>
EdgeInfo
;
typename
PFP
::
TVEC3
normal
;
AttributeHandler
<
EdgeInfo
>
edgeInfo
;
typename
PFP
::
TREAL
k1
;
typename
PFP
::
TREAL
k2
;
typename
PFP
::
TVEC3
K1
;
typename
PFP
::
TVEC3
K2
;
std
::
multimap
<
float
,
Dart
>
edges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
Approximator
<
PFP
,
typename
PFP
::
VEC3
>*
m_positionApproximator
;
void
initEdgeInfo
(
Dart
d
)
;
void
updateEdgeInfo
(
Dart
d
,
bool
recompute
)
;
void
computeEdgeInfo
(
Dart
d
,
EdgeInfo
&
einfo
)
;
public:
EdgeSelector_Curvature
(
MAP
&
m
,
typename
PFP
::
TVEC3
&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
SelectorTrue
())
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
)
{
normal
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"normal"
)
;
if
(
!
normal
.
isValid
())
{
normal
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"normal"
)
;
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
m
,
pos
,
normal
)
;
}
k1
=
m
.
template
getAttribute
<
REAL
>(
VERTEX_ORBIT
,
"k1"
)
;
k2
=
m
.
template
getAttribute
<
REAL
>(
VERTEX_ORBIT
,
"k2"
)
;
K1
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"K1"
)
;
K2
=
m
.
template
getAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"K2"
)
;
// as all these attributes are computed simultaneously by computeCurvatureVertices
// one can assume that if one of them is not valid, the others must be created too
if
(
!
k1
.
isValid
())
{
k1
=
m
.
template
addAttribute
<
REAL
>(
VERTEX_ORBIT
,
"k1"
)
;
k2
=
m
.
template
addAttribute
<
REAL
>(
VERTEX_ORBIT
,
"k2"
)
;
K1
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"K1"
)
;
K2
=
m
.
template
addAttribute
<
VEC3
>(
VERTEX_ORBIT
,
"K2"
)
;
Algo
::
Geometry
::
computeCurvatureVertices
<
PFP
>
(
m
,
this
->
m_position
,
normal
,
k1
,
k2
,
K1
,
K2
)
;
}
edgeInfo
=
m
.
template
addAttribute
<
EdgeInfo
>(
EDGE_ORBIT
,
"edgeInfo"
)
;
}
~
EdgeSelector_Curvature
()
{
this
->
m_map
.
removeAttribute
(
k1
)
;
this
->
m_map
.
removeAttribute
(
k2
)
;
this
->
m_map
.
removeAttribute
(
K1
)
;
this
->
m_map
.
removeAttribute
(
K2
)
;
this
->
m_map
.
removeAttribute
(
edgeInfo
)
;
}
SelectorType
getType
()
{
return
S_Curvature
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d
)
;
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
}
;
template
<
typename
PFP
>
class
EdgeSelector_MinDetail
:
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
"MinDetailEdgeInfo"
;
}
}
MinDetailEdgeInfo
;
typedef
NoMathIOAttribute
<
MinDetailEdgeInfo
>
EdgeInfo
;
AttributeHandler
<
EdgeInfo
>
edgeInfo
;
std
::
multimap
<
float
,
Dart
>
edges
;
typename
std
::
multimap
<
float
,
Dart
>::
iterator
cur
;
Approximator
<
PFP
,
typename
PFP
::
VEC3
>*
m_positionApproximator
;
void
initEdgeInfo
(
Dart
d
)
;
void
updateEdgeInfo
(
Dart
d
,
bool
recompute
)
;
void
computeEdgeInfo
(
Dart
d
,
EdgeInfo
&
einfo
)
;
public:
EdgeSelector_MinDetail
(
MAP
&
m
,
typename
PFP
::
TVEC3
&
pos
,
std
::
vector
<
ApproximatorGen
<
PFP
>*>&
approx
,
const
FunctorSelect
&
select
=
SelectorTrue
())
:
EdgeSelector
<
PFP
>
(
m
,
pos
,
approx
,
select
)
{
edgeInfo
=
m
.
template
addAttribute
<
EdgeInfo
>(
EDGE_ORBIT
,
"edgeInfo"
)
;
}
~
EdgeSelector_MinDetail
()
{
this
->
m_map
.
removeAttribute
(
edgeInfo
)
;
}
SelectorType
getType
()
{
return
S_MinDetail
;
}
bool
init
()
;
bool
nextEdge
(
Dart
&
d
)
;
void
updateBeforeCollapse
(
Dart
d
)
;
void
updateAfterCollapse
(
Dart
d2
,
Dart
dd2
)
;
}
;
}
// namespace Decimation
}
// namespace Algo
}
// namespace CGoGN
#include "Algo/Decimation/edgeSelector.hpp"
#endif
include/Algo/Decimation/
s
elector.hpp
→
include/Algo/Decimation/
edgeS
elector.hpp
View file @
fb95e191
...
...
@@ -473,45 +473,34 @@ void EdgeSelector_QEM<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
m_positionApproximator
->
approximate
(
d
)
;
REAL
err
=
quad
(
m_positionApproximator
->
getApprox
(
d
))
;
REAL
err
=
std
::
max
(
REAL
(
0
),
REAL
(
quad
(
m_positionApproximator
->
getApprox
(
d
))))
;
einfo
.
it
=
edges
.
insert
(
std
::
make_pair
(
err
,
d
))
;
einfo
.
valid
=
true
;
}
/************************************************************************************
*
EDGESELECTOR LIGHTFIELD
*
*
QUADRIC ERROR METRIC (Memoryless version)
*
************************************************************************************/
template
<
typename
PFP
>
bool
EdgeSelector_
Lightfield
<
PFP
>::
init
()
bool
EdgeSelector_
QEMml
<
PFP
>::
init
()
{
MAP
&
m
=
this
->
m_map
;
// Verify availability of required approximators
char
ok
=
0
;
bool
ok
=
false
;
for
(
typename
std
::
vector
<
ApproximatorGen
<
PFP
>*>::
iterator
it
=
this
->
m_approximators
.
begin
();
it
!=
this
->
m_approximators
.
end
();
it
!=
this
->
m_approximators
.
end
()
&&
!
ok
;
++
it
)
{
// constraint : 3 approximators in specific order
if
(
ok
==
0
&&
(
*
it
)
->
getApproximatedAttributeName
()
==
"position"
)
{
m_positionApproximator
=
reinterpret_cast
<
Approximator
<
PFP
,
VEC3
>*
>
(
*
it
)
;
// 1) position
++
ok
;
}
else
if
(
ok
==
1
&&
(
*
it
)
->
getApproximatedAttributeName
()
==
"frame"
)
{
m_frameApproximator
=
reinterpret_cast
<
Approximator
<
PFP
,
FRAME
>*
>
(
*
it
)
;
// 2) frame (needs position)
++
ok
;
}
else
if
(
ok
==
2
&&
(
*
it
)
->
getApproximatedAttributeName
()
==
"RGBfunctions"
)
if
((
*
it
)
->
getApproximatedAttributeName
()
==
"position"
)
{
m_
RGBfunctionsApproximator
=
reinterpret_cast
<
Approximator
<
PFP
,
RGBFUNCTIONS
>*
>
(
*
it
)
;
// 3) functions (needs frame)
++
ok
;
m_
positionApproximator
=
reinterpret_cast
<
Approximator
<
PFP
,
VEC3
>*
>
(
*
it
)
;
ok
=
true
;
}
}
if
(
ok
!=
3
)
if
(
!
ok
)
return
false
;
edges
.
clear
()
;
...
...
@@ -521,24 +510,23 @@ bool EdgeSelector_Lightfield<PFP>::init()
{
if
(
!
vMark
.
isMarked
(
d
))
{
Quadric
<
REAL
>
q
;
// create one quadric
quadric
[
d
]
=
q
;
// per vertex
Quadric
<
REAL
>
q
;
// create one quadric
quadric
[
d
]
=
q
;
// per vertex
vMark
.
mark
(
d
)
;
}
}
DartMarker
mark
(
m
)
;
for
(
Dart
d
=
m
.
begin
();
d
!=
m
.
end
();
m
.
next
(
d
))
// init QEM quadrics
for
(
Dart
d
=
m
.
begin
();
d
!=
m
.
end
();
m
.
next
(
d
))
{
if
(
!
mark
.
isMarked
(
d
))
{
Dart
d1
=
m
.
phi1
(
d
)
;
// for each triangle,
Dart
d_1
=
m
.
phi_1
(
d
)
;
// initialize the quadric of the triangle
Dart
d1
=
m
.
phi1
(
d
)
;
// for each triangle,
Dart
d_1
=
m
.
phi_1
(
d
)
;
// initialize the quadric of the triangle
Quadric
<
REAL
>
q
(
this
->
m_position
[
d
],
this
->
m_position
[
d1
],
this
->
m_position
[
d_1
])
;
quadric
[
d
]
+=
q
;
// and add the contribution of
quadric
[
d1
]
+=
q
;
// this quadric to the ones
quadric
[
d_1
]
+=
q
;
// of the 3 incident vertices
quadric
[
d
]
+=
q
;
// and add the contribution of
quadric
[
d1
]
+=
q
;
// this quadric to the ones
quadric
[
d_1
]
+=
q
;
// of the 3 incident vertices
mark
.
markOrbit
(
FACE_ORBIT
,
d
)
;
}
}
...
...
@@ -548,7 +536,7 @@ bool EdgeSelector_Lightfield<PFP>::init()
{
if
(
!
eMark
.
isMarked
(
d
))
{
initEdgeInfo
(
d
)
;
// init the edges with their optimal
info
initEdgeInfo
(
d
)
;
// init the edges with their optimal
position
eMark
.
mark
(
d
)
;
// and insert them in the multimap according to their error
}
}
...
...
@@ -559,7 +547,7 @@ bool EdgeSelector_Lightfield<PFP>::init()
}
template
<
typename
PFP
>
bool
EdgeSelector_
Lightfield
<
PFP
>::
nextEdge
(
Dart
&
d
)
bool
EdgeSelector_
QEMml
<
PFP
>::
nextEdge
(
Dart
&
d
)
{
if
(
cur
==
edges
.
end
()
||
edges
.
empty
())