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
fbaba3c6
Commit
fbaba3c6
authored
Feb 15, 2012
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MR : regular subdivision
parent
e584d06b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
231 additions
and
3 deletions
+231
-3
include/Topology/map/map2MR/map2MR_Primal.h
include/Topology/map/map2MR/map2MR_Primal.h
+121
-1
src/Topology/map/map2MR/map2MR_Primal.cpp
src/Topology/map/map2MR/map2MR_Primal.cpp
+110
-2
No files found.
include/Topology/map/map2MR/map2MR_Primal.h
View file @
fbaba3c6
...
...
@@ -26,6 +26,7 @@
#define __MAP2MR_PRIMAL__
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include <cmath>
...
...
@@ -33,6 +34,10 @@
namespace
CGoGN
{
/*********************************************************************************
* MAP2 MR PRIMAL ADAPTIVE
*********************************************************************************/
class
Map2MR_PrimalAdapt
:
public
EmbeddedMap2
{
protected:
...
...
@@ -144,6 +149,12 @@ public:
}
;
/*********************************************************************************
* MAP2 MR PRIMAL REGULAR
*********************************************************************************/
class
Map2MR_PrimalRegular
:
public
EmbeddedMap2
{
protected:
...
...
@@ -154,9 +165,119 @@ public:
std
::
string
mapTypeName
()
{
return
"Map2MR_PrimalRegular"
;
}
bool
isOddVertex
(
Dart
d
)
;
void
addNewLevel
()
;
void
analysis
(
FunctorType
*
f
)
;
void
synthesis
(
FunctorType
*
odd
,
FunctorType
*
even
)
;
}
;
template
<
typename
PFP
>
class
PipoAnalysisFunctor
:
public
FunctorType
{
protected:
typename
PFP
::
MAP
&
m_map
;
typename
PFP
::
TVEC3
&
m_position
;
public:
PipoAnalysisFunctor
(
typename
PFP
::
MAP
&
m
,
typename
PFP
::
TVEC3
&
p
)
:
m_map
(
m
),
m_position
(
p
)
{}
bool
operator
()
(
Dart
d
)
{
return
false
;
}
}
;
template
<
typename
PFP
>
class
PipoOddSynthesisFunctor
:
public
FunctorType
{
protected:
typename
PFP
::
MAP
&
m_map
;
typename
PFP
::
TVEC3
&
m_position
;
public:
PipoOddSynthesisFunctor
(
typename
PFP
::
MAP
&
m
,
typename
PFP
::
TVEC3
&
p
)
:
m_map
(
m
),
m_position
(
p
)
{}
bool
operator
()
(
Dart
d
)
{
Dart
it
=
d
;
Dart
d1
=
m_map
.
phi2
(
it
)
;
bool
centerV
=
false
;
while
(
m_map
.
getDartLevel
(
d1
)
==
m_map
.
getCurrentLevel
())
{
it
=
m_map
.
phi1
(
d1
)
;
if
(
it
==
d
)
{
centerV
=
true
;
d1
=
m_map
.
phi1
(
m_map
.
phi1
(
it
))
;
break
;
}
d1
=
m_map
.
phi2
(
it
)
;
}
m_map
.
decCurrentLevel
()
;
typename
PFP
::
VEC3
p
;
if
(
centerV
)
{
unsigned
int
degree
=
0
;
Traversor2FV
<
typename
PFP
::
MAP
>
trav
(
m_map
,
d1
)
;
for
(
Dart
fit
=
trav
.
begin
();
fit
!=
trav
.
end
();
fit
=
trav
.
next
())
{
++
degree
;
p
+=
m_position
[
fit
]
;
}
p
/=
degree
;
}
else
{
Dart
d2
=
m_map
.
phi2
(
d1
)
;
p
=
(
m_position
[
d1
]
+
m_position
[
d2
])
/
2.0
;
}
m_map
.
incCurrentLevel
()
;
m_position
[
d
]
=
p
;
return
false
;
}
}
;
template
<
typename
PFP
>
class
PipoEvenSynthesisFunctor
:
public
FunctorType
{
protected:
typename
PFP
::
MAP
&
m_map
;
typename
PFP
::
TVEC3
&
m_position
;
public:
PipoEvenSynthesisFunctor
(
typename
PFP
::
MAP
&
m
,
typename
PFP
::
TVEC3
&
p
)
:
m_map
(
m
),
m_position
(
p
)
{}
bool
operator
()
(
Dart
d
)
{
typename
PFP
::
VEC3
p
(
0
)
;
unsigned
int
degree
=
0
;
Traversor2VVaE
<
typename
PFP
::
MAP
>
trav
(
m_map
,
d
)
;
for
(
Dart
it
=
trav
.
begin
();
it
!=
trav
.
end
();
it
=
trav
.
next
())
{
++
degree
;
p
+=
m_position
[
it
]
;
}
p
/=
degree
;
p
*=
0.5
;
p
+=
m_position
[
d
]
*
0.5
;
m_position
[
d
]
=
p
;
return
false
;
}
}
;
...
...
@@ -164,7 +285,6 @@ public:
* VERTEX FUNCTORS
*********************************************************************************/
template
<
typename
PFP
>
class
PipoVertexVertexFunctor
:
public
FunctorType
{
...
...
src/Topology/map/map2MR/map2MR_Primal.cpp
View file @
fbaba3c6
...
...
@@ -410,8 +410,8 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d)
dd
=
phi1
(
next
)
;
(
*
vertexVertexFunctor
)(
dd
)
;
dd
=
phi1
(
dd
)
;
while
(
dd
!=
ne
)
// turn around the face and insert new edges
{
// linked to the central vertex
while
(
dd
!=
ne
)
// turn around the face and insert new edges
{
// linked to the central vertex
splitFace
(
phi1
(
ne
),
dd
)
;
dd
=
phi1
(
dd
)
;
(
*
vertexVertexFunctor
)(
dd
)
;
...
...
@@ -492,13 +492,121 @@ Map2MR_PrimalRegular::Map2MR_PrimalRegular() :
initMR
()
;
}
bool
Map2MR_PrimalRegular
::
isOddVertex
(
Dart
d
)
{
assert
(
getDartLevel
(
d
)
<=
getCurrentLevel
()
||
!
"isOddVertex : called with a dart inserted after current level"
)
;
return
getDartLevel
(
d
)
==
getCurrentLevel
()
;
}
void
Map2MR_PrimalRegular
::
addNewLevel
()
{
pushLevel
()
;
addLevel
()
;
setCurrentLevel
(
getMaxLevel
())
;
for
(
unsigned
int
i
=
m_mrattribs
.
begin
();
i
!=
m_mrattribs
.
end
();
m_mrattribs
.
next
(
i
))
{
unsigned
int
newindex
=
copyDartLine
((
*
m_mrDarts
[
m_mrCurrentLevel
])[
i
])
;
// duplicate all darts
(
*
m_mrDarts
[
m_mrCurrentLevel
])[
i
]
=
newindex
;
// on the new max level
if
(
!
shareVertexEmbeddings
)
(
*
m_embeddings
[
VERTEX
])[
newindex
]
=
EMBNULL
;
// set vertex embedding to EMBNULL if no sharing
}
// cut edges
TraversorE
<
Map2MR_PrimalRegular
>
travE
(
*
this
)
;
for
(
Dart
d
=
travE
.
begin
();
d
!=
travE
.
end
();
d
=
travE
.
next
())
{
cutEdge
(
d
)
;
travE
.
mark
(
d
)
;
travE
.
mark
(
phi1
(
d
))
;
}
// split faces
TraversorF
<
Map2MR_PrimalRegular
>
travF
(
*
this
)
;
for
(
Dart
d
=
travF
.
begin
();
d
!=
travF
.
end
();
d
=
travF
.
next
())
{
Dart
old
=
d
;
if
(
getDartLevel
(
old
)
==
getMaxLevel
())
old
=
phi1
(
old
)
;
decCurrentLevel
()
;
unsigned
int
degree
=
faceDegree
(
old
)
;
incCurrentLevel
()
;
if
(
degree
==
3
)
// if subdividing a triangle
{
Dart
dd
=
phi1
(
old
)
;
Dart
e
=
phi1
(
phi1
(
dd
))
;
splitFace
(
dd
,
e
)
;
travF
.
mark
(
dd
)
;
dd
=
e
;
e
=
phi1
(
phi1
(
dd
))
;
splitFace
(
dd
,
e
)
;
travF
.
mark
(
dd
)
;
dd
=
e
;
e
=
phi1
(
phi1
(
dd
))
;
splitFace
(
dd
,
e
)
;
travF
.
mark
(
dd
)
;
travF
.
mark
(
e
)
;
}
else
// if subdividing a polygonal face
{
Dart
dd
=
phi1
(
old
)
;
Dart
next
=
phi1
(
phi1
(
dd
))
;
splitFace
(
dd
,
next
)
;
// insert a first edge
Dart
ne
=
alpha1
(
dd
)
;
cutEdge
(
ne
)
;
// cut the new edge to insert the central vertex
travF
.
mark
(
dd
)
;
dd
=
phi1
(
phi1
(
next
))
;
while
(
dd
!=
ne
)
// turn around the face and insert new edges
{
// linked to the central vertex
Dart
tmp
=
phi1
(
ne
)
;
splitFace
(
tmp
,
dd
)
;
travF
.
mark
(
tmp
)
;
dd
=
phi1
(
phi1
(
dd
))
;
}
travF
.
mark
(
ne
)
;
}
}
popLevel
()
;
}
void
Map2MR_PrimalRegular
::
analysis
(
FunctorType
*
f
)
{
assert
(
getCurrentLevel
()
<
getMaxLevel
()
||
!
"analysis : called on max level"
)
;
TraversorV
<
Map2MR_PrimalRegular
>
travV
(
*
this
)
;
for
(
Dart
d
=
travV
.
begin
();
d
!=
travV
.
end
();
d
=
travV
.
next
())
{
(
*
f
)(
d
)
;
}
}
void
Map2MR_PrimalRegular
::
synthesis
(
FunctorType
*
odd
,
FunctorType
*
even
)
{
assert
(
getCurrentLevel
()
>
0
||
!
"synthesis : called on level 0"
)
;
TraversorV
<
Map2MR_PrimalRegular
>
travV
(
*
this
)
;
for
(
Dart
d
=
travV
.
begin
();
d
!=
travV
.
end
();
d
=
travV
.
next
())
{
if
(
isOddVertex
(
d
))
(
*
odd
)(
d
)
;
}
// for (Dart d = travV.begin(); d != travV.end(); d = travV.next())
// {
// if(!isOddVertex(d))
// (*even)(d) ;
// }
}
}
// 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