Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Hurstel
CGoGN
Commits
2c3d4e33
Commit
2c3d4e33
authored
Jun 09, 2011
by
Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajout fction linkVertices
parent
77875017
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
166 additions
and
65 deletions
+166
-65
include/Algo/Import/importSvg.hpp
include/Algo/Import/importSvg.hpp
+113
-65
include/Topology/generic/embeddedMap2.h
include/Topology/generic/embeddedMap2.h
+6
-0
include/Topology/generic/embeddedMap2.hpp
include/Topology/generic/embeddedMap2.hpp
+19
-0
include/Topology/map/map1.h
include/Topology/map/map1.h
+7
-0
include/Topology/map/map1.hpp
include/Topology/map/map1.hpp
+8
-0
include/Topology/map/map2.h
include/Topology/map/map2.h
+7
-0
src/Topology/map/map2.cpp
src/Topology/map/map2.cpp
+6
-0
No files found.
include/Algo/Import/importSvg.hpp
View file @
2c3d4e33
...
...
@@ -23,8 +23,11 @@ inline bool valueOf(const std::string &s, T &obj)
}
template
<
typename
PFP
>
bool
importSVG
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
polygons
)
bool
importSVG
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
polygons
,
CellMarker
&
polygonsFaces
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
std
::
vector
<
VEC3
>
POLYGON
;
xmlDocPtr
doc
=
xmlReadFile
(
filename
.
c_str
(),
NULL
,
0
);
xmlNodePtr
map_node
=
xmlDocGetRootElement
(
doc
);
...
...
@@ -34,7 +37,7 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
return
false
;
}
typedef
std
::
vector
<
typename
PFP
::
VEC3
>
POLYGON
;
std
::
vector
<
POLYGON
>
allPoly
;
for
(
xmlNode
*
cur_node
=
map_node
->
children
;
cur_node
;
cur_node
=
cur_node
->
next
)
...
...
@@ -54,7 +57,7 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
// CGoGNout << "path "<< prop << CGoGNendl;
std
::
string
allcoords
((
reinterpret_cast
<
const
char
*>
(
prop
)));
std
::
stringstream
is
(
allcoords
);
bool
relative
;
bool
relative
=
false
;
bool
push_point
;
std
::
string
coord
;
int
mode
=
-
1
;
...
...
@@ -113,57 +116,61 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
{
switch
(
mode
)
{
case
0
:
//relative
break
;
case
1
:
//absolute
break
;
case
2
:
//horizontal
{
std
::
stringstream
streamCoord
(
coord
);
std
::
string
xS
;
std
::
getline
(
streamCoord
,
xS
,
','
);
valueOf
(
xS
,
x
);
POLYGON
curPoly
=
allPoly
[
allPoly
.
size
()
-
1
];
typename
PFP
::
VEC3
previous
=
(
curPoly
)[(
curPoly
).
size
()
-
1
];
y
=
previous
[
1
];
push_point
=
true
;
case
0
:
//relative
break
;
case
1
:
//absolute
break
;
case
2
:
//horizontal
{
std
::
stringstream
streamCoord
(
coord
);
std
::
string
xS
;
std
::
getline
(
streamCoord
,
xS
,
','
);
valueOf
(
xS
,
x
);
POLYGON
curPoly
=
allPoly
[
allPoly
.
size
()
-
1
];
VEC3
previous
=
(
curPoly
)[(
curPoly
).
size
()
-
1
];
y
=
previous
[
1
];
push_point
=
true
;
}
break
;
case
3
:
//vertical
{
std
::
stringstream
streamCoord
(
coord
);
std
::
string
yS
;
std
::
getline
(
streamCoord
,
yS
,
','
);
valueOf
(
yS
,
y
);
POLYGON
curPoly
=
allPoly
[
allPoly
.
size
()
-
1
];
typename
PFP
::
VEC3
previous
=
(
curPoly
)[(
curPoly
).
size
()
-
1
];
x
=
previous
[
0
];
push_point
=
true
;
}
break
;
case
4
:
//bezier
{
std
::
getline
(
is
,
coord
,
' '
);
//ignore first control point
std
::
getline
(
is
,
coord
,
' '
);
//ignore second control point
}
break
;
case
5
:
//bezier 2
{
std
::
getline
(
is
,
coord
,
' '
);
//ignore control point
}
break
;
case
6
:
//elliptic
std
::
getline
(
is
,
coord
,
' '
);
//ignore rx
std
::
getline
(
is
,
coord
,
' '
);
//ignore ry
std
::
getline
(
is
,
coord
,
' '
);
//ignore x-rotation
std
::
getline
(
is
,
coord
,
' '
);
//ignore large arc flag
std
::
getline
(
is
,
coord
,
' '
);
//ignore sweep flag
break
;
}
break
;
case
3
:
//vertical
{
std
::
stringstream
streamCoord
(
coord
);
std
::
string
yS
;
std
::
getline
(
streamCoord
,
yS
,
','
);
valueOf
(
yS
,
y
);
POLYGON
curPoly
=
allPoly
[
allPoly
.
size
()
-
1
];
typename
PFP
::
VEC3
previous
=
(
curPoly
)[(
curPoly
).
size
()
-
1
];
x
=
previous
[
0
];
push_point
=
true
;
}
break
;
case
4
:
//bezier
{
std
::
getline
(
is
,
coord
,
' '
);
//ignore first control point
std
::
getline
(
is
,
coord
,
' '
);
//ignore second control point
}
break
;
case
5
:
//bezier 2
std
::
getline
(
is
,
coord
,
' '
);
//ignore control point
break
;
case
6
:
//elliptic
std
::
getline
(
is
,
coord
,
' '
);
//ignore rx
std
::
getline
(
is
,
coord
,
' '
);
//ignore ry
std
::
getline
(
is
,
coord
,
' '
);
//ignore x-rotation
std
::
getline
(
is
,
coord
,
' '
);
//ignore large arc flag
std
::
getline
(
is
,
coord
,
' '
);
//ignore sweep flag
break
;
}
std
::
stringstream
streamCoord
(
coord
);
std
::
string
xS
,
yS
;
std
::
getline
(
streamCoord
,
xS
,
','
);
...
...
@@ -182,15 +189,29 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
if
(
relative
&&
curPoly
.
size
()
>
0
)
{
typename
PFP
::
VEC3
previous
=
(
curPoly
)[(
curPoly
).
size
()
-
1
];
VEC3
previous
=
(
curPoly
)[(
curPoly
).
size
()
-
1
];
x
+=
previous
[
0
];
y
+=
previous
[
1
];
}
//
std::cout << "coord " << x << " " << y << std::endl;
curPoly
.
push_back
(
typename
PFP
::
VEC3
(
x
,
y
,
0
));
std
::
cout
<<
"coord "
<<
x
<<
" "
<<
y
<<
std
::
endl
;
curPoly
.
push_back
(
VEC3
(
x
,
y
,
0
));
}
}
//check orientation : set in CCW
POLYGON
&
curPoly
=
allPoly
[
allPoly
.
size
()
-
1
];
if
(
curPoly
.
size
()
>
2
)
{
VEC3
v1
(
curPoly
[
1
]
-
curPoly
[
0
]);
VEC3
v2
(
curPoly
[
2
]
-
curPoly
[
1
]);
if
((
v1
^
v2
)[
2
]
<
0
)
{
std
::
cout
<<
"reverse !"
<<
std
::
endl
;
std
::
reverse
(
curPoly
.
begin
(),
curPoly
.
end
());
}
}
}
}
}
...
...
@@ -204,13 +225,15 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
for
(
it
=
allPoly
.
begin
()
;
it
!=
allPoly
.
end
()
;
++
it
)
{
if
(
it
->
size
()
<
3
)
if
(
it
->
size
()
<
4
)
{
it
=
allPoly
.
erase
(
it
);
}
else
{
Dart
d
=
map
.
newFace
(
it
->
size
()
-
1
);
std
::
cout
<<
"newFace "
<<
it
->
size
()
-
1
<<
std
::
endl
;
polygonsFaces
.
mark
(
d
);
for
(
typename
POLYGON
::
iterator
emb
=
it
->
begin
()
;
emb
!=
it
->
end
()
;
emb
++
)
{
position
[
d
]
=
*
emb
;
...
...
@@ -242,19 +265,32 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
DartMarker
close
(
map
);
map
.
closeMap
(
close
);
CellMarker
linked
(
map
,
FACE
)
;
float
maxDistSq
=
40.0
f
*
40.0
f
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
VEC3
p1
=
position
[
d
];
VEC3
p2
=
position
[
map
.
phi1
(
d
)];
if
((
p1
-
p2
).
norm2
()
>
maxDistSq
)
{
VEC3
p3
=
(
p1
+
p2
)
/
2.0
f
;
map
.
cutEdge
(
d
);
position
[
map
.
phi1
(
d
)]
=
p3
;
}
}
CellMarker
linked
(
map
,
VERTEX
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
!
linked
.
isMarked
(
d
)
&&
!
inside
.
isMarked
(
d
))
{
linked
.
mark
(
d
);
Dart
dMin
;
float
distMin
=
(
bb
.
max
()
-
bb
.
min
()).
norm2
()
;
Dart
dMin
=
map
.
end
()
;
float
distMin
=
1.0
f
/
0.0
f
;
for
(
Dart
dd
=
map
.
begin
();
dd
!=
map
.
end
();
map
.
next
(
dd
))
{
if
(
!
map
.
sameFace
(
d
,
dd
))
if
(
!
inside
.
isMarked
(
dd
)
&&
!
map
.
sameFace
(
d
,
dd
))
{
float
dist
=
(
position
[
dd
]
-
position
[
d
]).
norm
2
();
float
dist
=
(
position
[
dd
]
-
position
[
d
]).
norm
();
if
(
dist
<
distMin
)
{
distMin
=
dist
;
...
...
@@ -263,11 +299,23 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP
}
}
// map.splitFace(d,d);
// map.splitFace(dMin,dMin);
if
(
dMin
!=
map
.
end
())
{
Dart
dChoose
=
d
;
Dart
dStart
=
d
;
do
{
float
dist
=
(
position
[
dMin
]
-
position
[
d
]).
norm
();
if
(
dist
<
distMin
)
{
distMin
=
dist
;
dChoose
=
d
;
}
d
=
map
.
phi1
(
d
);
}
while
(
d
!=
dStart
);
//
map.
sewFaces(map.phi_1(d),map.phi_1(dMin)
);
//
map.mergeFaces(map.phi_1(d));
map
.
linkVertices
(
dMin
,
dChoose
);
}
}
}
...
...
include/Topology/generic/embeddedMap2.h
View file @
2c3d4e33
...
...
@@ -107,6 +107,12 @@ public:
*/
virtual
void
splitFace
(
Dart
d
,
Dart
e
)
;
/**
* No attribute is attached to the new edge
* The attributes attached to the face of dart d are kept on the resulting face
*/
virtual
void
linkVertices
(
Dart
d
,
Dart
e
)
;
/**
* The attributes attached to the face of dart d are kept on the resulting face
*/
...
...
include/Topology/generic/embeddedMap2.hpp
View file @
2c3d4e33
...
...
@@ -319,6 +319,25 @@ void EmbeddedMap2<MAP2>::splitFace(Dart d, Dart e)
}
}
template
<
typename
MAP2
>
void
EmbeddedMap2
<
MAP2
>::
linkVertices
(
Dart
d
,
Dart
e
)
{
Dart
dNext
=
MAP2
::
phi1
(
d
)
;
MAP2
::
linkVertices
(
d
,
e
);
if
(
MAP2
::
isOrbitEmbedded
(
VERTEX
))
{
MAP2
::
copyDartEmbedding
(
VERTEX
,
MAP2
::
phi_1
(
e
),
d
)
;
MAP2
::
copyDartEmbedding
(
VERTEX
,
MAP2
::
phi_1
(
d
),
e
)
;
}
if
(
MAP2
::
isOrbitEmbedded
(
FACE
))
{
MAP2
::
embedOrbit
(
FACE
,
dNext
,
MAP2
::
getEmbedding
(
FACE
,
dNext
))
;
}
}
template
<
typename
MAP2
>
bool
EmbeddedMap2
<
MAP2
>::
mergeFaces
(
Dart
d
)
{
...
...
include/Topology/map/map1.h
View file @
2c3d4e33
...
...
@@ -145,6 +145,13 @@ public:
*/
void
splitFace
(
Dart
d
,
Dart
e
);
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
void
linkVertices
(
Dart
d
,
Dart
e
);
//! Merge the two faces of d and e, darts d & e disappear
/*! \pre Dart d and e MUST belong to distinct faces
* \warning Darts d and e no longer exist after the call
...
...
include/Topology/map/map1.hpp
View file @
2c3d4e33
...
...
@@ -157,6 +157,14 @@ inline void Map1::splitFace(Dart d, Dart e)
phi1sew
(
phi_1
(
d
),
phi_1
(
e
))
;
// phi1sew between the 2 new inserted darts
}
inline
void
Map1
::
linkVertices
(
Dart
d
,
Dart
e
)
{
assert
(
d
!=
e
&&
!
sameOrientedFace
(
d
,
e
))
;
Map1
::
cutEdge
(
phi_1
(
d
));
// cut the edge before d (insert a new dart before d)
Map1
::
cutEdge
(
phi_1
(
e
));
// cut the edge before e (insert a new dart before e)
phi1sew
(
phi_1
(
d
),
phi_1
(
e
))
;
// phi1sew between the 2 new inserted darts
}
inline
void
Map1
::
mergeFaces
(
Dart
d
,
Dart
e
)
{
assert
(
!
sameOrientedFace
(
d
,
e
))
;
...
...
include/Topology/map/map2.h
View file @
2c3d4e33
...
...
@@ -190,6 +190,13 @@ public:
*/
virtual
void
splitFace
(
Dart
d
,
Dart
e
);
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
virtual
void
linkVertices
(
Dart
d
,
Dart
e
);
//! Merge the two faces incident to the edge of d.
/*! Works only for non-border edges.
* \warning Darts d & phi2(d) no longer exist after the call
...
...
src/Topology/map/map2.cpp
View file @
2c3d4e33
...
...
@@ -226,6 +226,12 @@ void Map2::splitFace(Dart d, Dart e)
phi2sew
(
phi_1
(
d
),
phi_1
(
e
));
// Sew the two resulting faces along the new edge
}
void
Map2
::
linkVertices
(
Dart
d
,
Dart
e
)
{
Map1
::
linkVertices
(
d
,
e
);
// Split the face
phi2sew
(
phi_1
(
d
),
phi_1
(
e
));
// Sew the two resulting faces along the new edge
}
bool
Map2
::
mergeFaces
(
Dart
d
)
{
Dart
e
=
phi2
(
d
)
;
...
...
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