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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
CGoGN
Commits
c0b35bc7
Commit
c0b35bc7
authored
Nov 30, 2012
by
Jund Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
importSVG for closed polygons
parent
edd64adf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
53 deletions
+58
-53
include/Algo/Import/importSvg.hpp
include/Algo/Import/importSvg.hpp
+58
-53
No files found.
include/Algo/Import/importSvg.hpp
View file @
c0b35bc7
...
...
@@ -111,6 +111,7 @@ void getPolygonFromSVG(std::string allcoords, std::vector<VEC3>& curPoly, bool&
else
if
(
coord
[
0
]
==
'z'
)
//end of path
{
closedPoly
=
true
;
}
else
//coordinates
{
...
...
@@ -336,13 +337,14 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, VertexAttrib
map
.
sewFaces
(
d1
,
d_1
,
false
)
;
edgeWidth
[
d1
]
=
*
itW
;
if
(
*
itW
==
0
)
std
::
cout
<<
"importSVG : null path width"
<<
std
::
endl
;
if
(
*
itW
==
0
)
std
::
cout
<<
"importSVG : null path width"
<<
std
::
endl
;
d1
=
map
.
phi1
(
d1
);
d_1
=
map
.
phi_1
(
d_1
);
}
polygonsFaces
.
mark
(
d
);
//
polygonsFaces.mark(d);
//embed the line
d1
=
d
;
...
...
@@ -359,67 +361,70 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, VertexAttrib
std
::
cout
<<
"importSVG : broken lines created : "
<<
nbVertices
<<
" vertices"
<<
std
::
endl
;
/////////////////////////////////////////////////////////////////////////////////////////////
//create polygons
// typename std::vector<POLYGON >::iterator it;
// for(it = allPoly.begin() ; it != allPoly.end() ; ++it)
// {
//
// if(it->size()<4)
// {
// it = allPoly.erase(it);
// }
// else
// {
// Dart d = map.newFace(it->size()-1);
//// std::cout << "newFace1 " << it->size()-1 << std::endl;
// polygonsFaces.mark(d);
//
// Dart dd = d;
// typename POLYGON::iterator emb = it->begin();
// do
// {
// bb->addPoint(*emb);
// position[dd] = *emb;
// emb++;
// dd = map.phi1(dd);
// } while(dd!=d);
// }
// }
//
// for(Dart d = map.begin();d != map.end(); map.next(d))
// {
// if(position[d][0] == position[map.phi1(d)][0] && position[d][1] == position[map.phi1(d)][1])
// std::cout << "prob d " << d << std::endl;
// }
//
// DartMarker inside(map);
//
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// polygons.mark(d);
// inside.mark(d);
// }
//
// std::cout << "importSVG : Polygons generated." << std::endl;
/////////////////////////////////////////////////////////////////////////////////////////////
Algo
::
BooleanOperator
::
mergeVertices
<
PFP
>
(
map
,
position
);
std
::
cout
<<
"importSVG : Merging of vertices."
<<
std
::
endl
;
/////////////////////////////////////////////////////////////////////////////////////////////
//create polygons
typename
std
::
vector
<
POLYGON
>::
iterator
it
;
for
(
it
=
allPoly
.
begin
()
;
it
!=
allPoly
.
end
()
;
++
it
)
{
if
(
it
->
size
()
<
4
)
{
it
=
allPoly
.
erase
(
it
);
}
else
{
Dart
d
=
map
.
newFace
(
it
->
size
());
// std::cout << "newFace1 " << it->size()-1 << std::endl;
polygonsFaces
.
mark
(
d
);
Dart
dd
=
d
;
typename
POLYGON
::
iterator
emb
=
it
->
begin
();
do
{
bb
->
addPoint
(
*
emb
);
position
[
dd
]
=
*
emb
;
emb
++
;
dd
=
map
.
phi1
(
dd
);
}
while
(
dd
!=
d
);
}
}
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
position
[
d
][
0
]
==
position
[
map
.
phi1
(
d
)][
0
]
&&
position
[
d
][
1
]
==
position
[
map
.
phi1
(
d
)][
1
])
std
::
cout
<<
"prob d "
<<
d
<<
std
::
endl
;
}
DartMarker
inside
(
map
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
polygons
.
mark
(
d
);
inside
.
mark
(
d
);
}
std
::
cout
<<
"importSVG : Polygons generated."
<<
std
::
endl
;
/////////////////////////////////////////////////////////////////////////////////////////////
//simplify the edges to have a more regular sampling
float
minDist
=
20.0
f
;
for
(
Dart
d
=
map
.
begin
()
;
d
!=
map
.
end
()
;
map
.
next
(
d
))
{
bool
canSimplify
=
true
;
while
(
canSimplify
&&
((
position
[
map
.
phi1
(
d
)]
-
position
[
d
]).
norm
()
<
minDist
)
)
if
(
!
polygons
.
isMarked
(
d
))
{
if
(
map
.
vertexDegree
(
map
.
phi1
(
d
))
==
2
)
{
map
.
uncutEdge
(
d
)
;
bool
canSimplify
=
true
;
while
(
canSimplify
&&
((
position
[
map
.
phi1
(
d
)]
-
position
[
d
]).
norm
()
<
minDist
)
)
{
if
(
map
.
vertexDegree
(
map
.
phi1
(
d
))
==
2
)
{
map
.
uncutEdge
(
d
)
;
}
else
canSimplify
=
false
;
}
else
canSimplify
=
false
;
}
}
std
::
cout
<<
"importSVG : Downsampling of vertices."
<<
std
::
endl
;
...
...
@@ -430,7 +435,7 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, VertexAttrib
CellMarker
<
EDGE
>
treated
(
map
)
;
for
(
Dart
d
=
map
.
begin
()
;
d
!=
map
.
end
()
;
map
.
next
(
d
))
{
if
(
!
treated
.
isMarked
(
d
))
if
(
!
polygons
.
isMarked
(
d
)
&&
!
treated
.
isMarked
(
d
))
{
treated
.
mark
(
d
)
;
VEC3
p1
=
position
[
d
]
;
...
...
@@ -591,7 +596,7 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, VertexAttrib
// }
//
// }
//
// CellMarker connected(map,VERTEX);
// unsigned int i=0;
// for(Dart d = map.begin();d != map.end(); map.next(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