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
f7ea2700
Commit
f7ea2700
authored
Feb 09, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor change in toprender svg & tuto_oper2
parent
a2f2f8b9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
272 additions
and
119 deletions
+272
-119
Apps/Tuto/tuto_oper2.cpp
Apps/Tuto/tuto_oper2.cpp
+4
-0
include/Algo/Render/GL2/topoRender.h
include/Algo/Render/GL2/topoRender.h
+5
-0
include/Algo/Render/GL2/topoRender.hpp
include/Algo/Render/GL2/topoRender.hpp
+75
-0
include/Algo/Render/SVG/mapSVGRender.h
include/Algo/Render/SVG/mapSVGRender.h
+33
-0
include/Algo/Render/SVG/mapSVGRender.hpp
include/Algo/Render/SVG/mapSVGRender.hpp
+21
-113
src/Algo/Render/mapSVGRender.cpp
src/Algo/Render/mapSVGRender.cpp
+134
-6
No files found.
Apps/Tuto/tuto_oper2.cpp
View file @
f7ea2700
...
...
@@ -282,6 +282,10 @@ void MyQT::cb_keyPress(int keycode)
}
}
break
;
case
's'
:
m_render_topo
->
svgout
<
PFP
>
(
myMap
,
"/tmp/toto.svg"
,
modelViewMatrix
(),
projectionMatrix
(),
nb
);
break
;
}
updateGL
();
...
...
include/Algo/Render/GL2/topoRender.h
View file @
f7ea2700
...
...
@@ -36,6 +36,7 @@
#include "Geometry/vector_gen.h"
#include "Utils/vbo.h"
#include "Algo/Render/SVG/mapSVGRender.h"
// forward
namespace
CGoGN
{
namespace
Utils
{
class
ShaderSimpleColor
;
}
}
...
...
@@ -217,6 +218,10 @@ public:
template
<
typename
PFP
>
void
updateDataGMap
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
const
FunctorSelect
&
good
=
allDarts
);
template
<
typename
PFP
>
void
svgout
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
const
glm
::
mat4
&
model
,
const
glm
::
mat4
&
proj
,
const
FunctorSelect
&
good
=
allDarts
);
};
// just for compatibility with old code
...
...
include/Algo/Render/GL2/topoRender.hpp
View file @
f7ea2700
...
...
@@ -422,6 +422,81 @@ Dart TopoRender::picking(typename PFP::MAP& map,int x, int y, const FunctorSelec
}
template
<
typename
PFP
>
void
TopoRender
::
svgout
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
const
glm
::
mat4
&
model
,
const
glm
::
mat4
&
proj
,
const
FunctorSelect
&
good
)
{
Algo
::
Render
::
SVG
::
SVGOut
svg
(
filename
,
model
,
proj
);
svg
.
setWidth
(
3.0
f
);
// PHI2
m_vbo2
->
bind
();
Geom
::
Vec3f
*
ptr
=
reinterpret_cast
<
typename
PFP
::
VEC3
*>
(
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_ONLY
));
svg
.
beginLines
();
for
(
unsigned
int
i
=
0
;
i
<
m_nbRel2
;
++
i
)
svg
.
addLine
(
ptr
[
2
*
i
],
ptr
[
2
*
i
+
1
],
Geom
::
Vec3f
(
1.0
f
,
0.0
f
,
0.0
f
));
svg
.
endLines
();
m_vbo2
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
//PHI1
m_vbo1
->
bind
();
ptr
=
reinterpret_cast
<
typename
PFP
::
VEC3
*>
(
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_ONLY
));
svg
.
beginLines
();
for
(
unsigned
int
i
=
0
;
i
<
m_nbDarts
;
++
i
)
svg
.
addLine
(
ptr
[
2
*
i
],
ptr
[
2
*
i
+
1
],
Geom
::
Vec3f
(
0.0
f
,
1.0
f
,
1.0
f
));
svg
.
endLines
();
m_vbo1
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
m_vbo0
->
bind
();
ptr
=
reinterpret_cast
<
typename
PFP
::
VEC3
*>
(
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_ONLY
));
m_vbo3
->
bind
();
Geom
::
Vec3f
*
colorsPtr
=
reinterpret_cast
<
typename
PFP
::
VEC3
*>
(
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_ONLY
));
svg
.
setWidth
(
5.0
f
);
svg
.
beginLines
();
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
good
(
d
))
{
unsigned
int
id
=
m_attIndex
[
d
];
// svg.addLine(ptr[id], ptr[id+1], colorsPtr[id]);
svg
.
addLine
(
ptr
[
id
],
ptr
[
id
+
1
],
Geom
::
Vec3f
(
0.0
f
,
0.0
f
,
0.0
f
));
}
}
svg
.
endLines
();
svg
.
beginPoints
();
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
good
(
d
))
{
unsigned
int
id
=
m_attIndex
[
d
];
// svg.addPoint(ptr[id], colorsPtr[id]);
svg
.
addPoint
(
ptr
[
id
],
Geom
::
Vec3f
(
0.0
f
,
0.0
f
,
0.0
f
));
}
}
svg
.
endPoints
();
m_vbo0
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
m_vbo3
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
// relations:
}
}
//end namespace GL2
...
...
include/Algo/Render/SVG/mapSVGRender.h
View file @
f7ea2700
...
...
@@ -63,6 +63,7 @@ class SvgObj
{
protected:
std
::
vector
<
Geom
::
Vec3f
>
m_vertices
;
std
::
vector
<
Geom
::
Vec3f
>
m_colors
;
std
::
vector
<
Geom
::
Vec3f
>
m_vertices3D
;
Geom
::
Vec3f
m_color
;
float
m_width
;
...
...
@@ -71,6 +72,13 @@ public:
void
addVertex3D
(
const
Geom
::
Vec3f
&
v
);
void
addVertex
(
const
Geom
::
Vec3f
&
v
,
const
Geom
::
Vec3f
&
C
);
void
addVertex3D
(
const
Geom
::
Vec3f
&
v
,
const
Geom
::
Vec3f
&
C
);
// void addColor(const Geom::Vec3f& c);
void
setColor
(
const
Geom
::
Vec3f
&
c
);
void
setWidth
(
float
w
)
{
m_width
=
w
;}
...
...
@@ -100,6 +108,12 @@ public:
void
save
(
std
::
ofstream
&
out
);
};
class
SvgLines
:
public
SvgObj
{
public:
void
save
(
std
::
ofstream
&
out
);
};
class
SvgPolygon
:
public
SvgObj
{
...
...
@@ -127,6 +141,8 @@ protected:
std
::
vector
<
SvgObj
*>
m_objs
;
SvgObj
*
m_current
;
public:
/**
...
...
@@ -160,6 +176,23 @@ public:
void
orderPrimitives
(
std
::
list
<
SvgObj
*>&
primitives
);
void
beginPoints
();
void
endPoints
();
void
addPoint
(
const
Geom
::
Vec3f
&
P
);
void
addPoint
(
const
Geom
::
Vec3f
&
P
,
const
Geom
::
Vec3f
&
C
);
void
beginLines
();
void
endLines
();
void
addLine
(
const
Geom
::
Vec3f
&
P
,
const
Geom
::
Vec3f
&
P2
);
void
addLine
(
const
Geom
::
Vec3f
&
P
,
const
Geom
::
Vec3f
&
P2
,
const
Geom
::
Vec3f
&
C
);
};
...
...
include/Algo/Render/SVG/mapSVGRender.hpp
View file @
f7ea2700
...
...
@@ -42,90 +42,47 @@ namespace SVG
template
<
typename
PFP
>
void
SVGOut
::
renderPointsToSVG
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
good
,
unsigned
int
thread
)
{
glm
::
i32vec4
viewport
;
glGetIntegerv
(
GL_VIEWPORT
,
&
(
viewport
[
0
]));
SvgPoints
*
points
=
new
SvgPoints
();
points
->
setColor
(
global_color
);
points
->
setWidth
(
global_width
);
// DartMarker m(map, thread);
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if(!m.isMarked(d) && good(d))
// {
// const Geom::Vec3f& P = position[d];
// glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
// glm::vec3 R = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,glm::mat4(1.0),viewport);
// points->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
// m.markOrbit(VERTEX, d);
// }
// }
// m_objs.push_back(points);
TraversorV
<
typename
PFP
::
MAP
>
trav
(
map
,
good
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
const
Geom
::
Vec3f
&
P
=
position
[
d
];
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
viewport
);
points
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
viewport
[
3
])
-
Q
[
1
],
Q
[
2
]));
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
m_
viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_
viewport
);
points
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
m_
viewport
[
3
])
-
Q
[
1
],
Q
[
2
]));
}
m_objs
.
push_back
(
points
);
}
template
<
typename
PFP
>
void
SVGOut
::
renderLinesToSVG
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
good
,
unsigned
int
thread
)
{
glm
::
i32vec4
viewport
;
glGetIntegerv
(
GL_VIEWPORT
,
&
(
viewport
[
0
]));
// DartMarker m(map, thread);
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if(!m.isMarked(d) && good(d))
// {
//
// const Geom::Vec3f& P = position[d];
// glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
// glm::vec3 R = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,glm::mat4(1.0),viewport);
//
// const Geom::Vec3f& P2 = position[map.phi1(d)];
// glm::vec3 Q2 = glm::project(glm::vec3(P2[0],P2[1],P2[2]),m_model,m_proj,viewport);
// glm::vec3 R2 = glm::project(glm::vec3(P2[0],P2[1],P2[2]),m_model,glm::mat4(1.0),viewport);
//
// SvgPolyline* pol = new SvgPolyline();
// pol->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
// pol->addVertex(Geom::Vec3f(Q2[0],float(viewport[3])-Q2[1],Q2[2]));
//
// pol->addVertex3D(Geom::Vec3f(R[0],float(viewport[3])-R[1],R[2]));
// pol->addVertex3D(Geom::Vec3f(R2[0],float(viewport[3])-R2[1],R2[2]));
//
// pol->setColor(global_color);
// pol->setWidth(global_width);
// m_objs.push_back(pol);
// m.markOrbit(EDGE, d);
// }
// }
TraversorE
<
typename
PFP
::
MAP
>
trav
(
map
,
good
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
{
const
Geom
::
Vec3f
&
P
=
position
[
d
];
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
viewport
);
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
m_
viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_
viewport
);
const
Geom
::
Vec3f
&
P2
=
position
[
map
.
phi1
(
d
)];
glm
::
vec3
Q2
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
m_proj
,
viewport
);
glm
::
vec3
R2
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
viewport
);
glm
::
vec3
Q2
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
m_proj
,
m_
viewport
);
glm
::
vec3
R2
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_
viewport
);
SvgPolyline
*
pol
=
new
SvgPolyline
();
pol
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
viewport
[
3
])
-
Q
[
1
],
Q
[
2
]));
pol
->
addVertex
(
Geom
::
Vec3f
(
Q2
[
0
],
float
(
viewport
[
3
])
-
Q2
[
1
],
Q2
[
2
]));
pol
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
m_
viewport
[
3
])
-
Q
[
1
],
Q
[
2
]));
pol
->
addVertex
(
Geom
::
Vec3f
(
Q2
[
0
],
float
(
m_
viewport
[
3
])
-
Q2
[
1
],
Q2
[
2
]));
pol
->
addVertex3D
(
Geom
::
Vec3f
(
R
[
0
],
float
(
viewport
[
3
])
-
R
[
1
],
R
[
2
]));
pol
->
addVertex3D
(
Geom
::
Vec3f
(
R2
[
0
],
float
(
viewport
[
3
])
-
R2
[
1
],
R2
[
2
]));
pol
->
addVertex3D
(
Geom
::
Vec3f
(
R
[
0
],
float
(
m_
viewport
[
3
])
-
R
[
1
],
R
[
2
]));
pol
->
addVertex3D
(
Geom
::
Vec3f
(
R2
[
0
],
float
(
m_
viewport
[
3
])
-
R2
[
1
],
R2
[
2
]));
pol
->
setColor
(
global_color
);
pol
->
setWidth
(
global_width
);
...
...
@@ -137,55 +94,6 @@ void SVGOut::renderLinesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3&
template
<
typename
PFP
>
void
SVGOut
::
renderFacesToSVG
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
float
shrink
,
bool
cull
,
const
FunctorSelect
&
good
,
unsigned
int
thread
)
{
glm
::
i32vec4
viewport
;
glGetIntegerv
(
GL_VIEWPORT
,
&
(
viewport
[
0
]));
// DartMarker m(map, thread);
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if(!m.isMarked(d) && good(d))
// {
// bool cullFace=false;
// if (cull)
// {
// const Geom::Vec3f& P = position[d];
//
// glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
// const Geom::Vec3f& P2 = position[map.phi1(d)];
// glm::vec3 R = glm::project(glm::vec3(P2[0],P2[1],P2[2]),m_model,m_proj,viewport);
// const Geom::Vec3f& P3 = position[map.phi1(map.phi1(d))];
// glm::vec3 S = glm::project(glm::vec3(P3[0],P3[1],P3[2]),m_model,m_proj,viewport);
// glm::vec3 N = glm::cross(S-R,Q-R);
// if (N[2]<0.0f)
// cullFace=true;
// }
//
// if (!cullFace)
// {
// typename PFP::VEC3 center = Algo::Geometry::faceCentroid<PFP>(map,d,position);
// SvgPolygon* pol = new SvgPolygon();
// Dart dd = d;
// do
// {
// Geom::Vec3f P = position[d];
// P = P*shrink + center*(1.0f-shrink);
// glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
// glm::vec3 R = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,glm::mat4(1.0),viewport);
// pol->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
// pol->addVertex3D(Geom::Vec3f(R[0],R[1],R[2]));
// d = map.phi1(d);
// }while (d!=dd);
//
// pol->close();
// pol->setColor(global_color);
// pol->setWidth(global_width);
// m_objs.push_back(pol);
// }
// m.markOrbit(FACE, d);
// }
// }
TraversorF
<
typename
PFP
::
MAP
>
trav
(
map
,
good
,
thread
);
for
(
Dart
d
=
trav
.
begin
();
d
!=
trav
.
end
();
d
=
trav
.
next
())
...
...
@@ -195,11 +103,11 @@ void SVGOut::renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3&
{
const
Geom
::
Vec3f
&
P
=
position
[
d
];
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
viewport
);
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
m_
viewport
);
const
Geom
::
Vec3f
&
P2
=
position
[
map
.
phi1
(
d
)];
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
m_proj
,
viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
m_proj
,
m_
viewport
);
const
Geom
::
Vec3f
&
P3
=
position
[
map
.
phi1
(
map
.
phi1
(
d
))];
glm
::
vec3
S
=
glm
::
project
(
glm
::
vec3
(
P3
[
0
],
P3
[
1
],
P3
[
2
]),
m_model
,
m_proj
,
viewport
);
glm
::
vec3
S
=
glm
::
project
(
glm
::
vec3
(
P3
[
0
],
P3
[
1
],
P3
[
2
]),
m_model
,
m_proj
,
m_
viewport
);
glm
::
vec3
N
=
glm
::
cross
(
S
-
R
,
Q
-
R
);
if
(
N
[
2
]
<
0.0
f
)
cullFace
=
true
;
...
...
@@ -214,9 +122,9 @@ void SVGOut::renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3&
{
Geom
::
Vec3f
P
=
position
[
d
];
P
=
P
*
shrink
+
center
*
(
1.0
f
-
shrink
);
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
viewport
);
pol
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
viewport
[
3
])
-
Q
[
1
],
Q
[
2
]));
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
m_
viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_
viewport
);
pol
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
m_
viewport
[
3
])
-
Q
[
1
],
Q
[
2
]));
pol
->
addVertex3D
(
Geom
::
Vec3f
(
R
[
0
],
R
[
1
],
R
[
2
]));
d
=
map
.
phi1
(
d
);
}
while
(
d
!=
dd
);
...
...
src/Algo/Render/mapSVGRender.cpp
View file @
f7ea2700
...
...
@@ -43,14 +43,31 @@ namespace Render
namespace
SVG
{
void
SvgObj
::
addVertex
(
const
Geom
::
Vec3f
&
v
)
{
m_vertices
.
push_back
(
v
);
m_colors
.
push_back
(
m_color
);
}
void
SvgObj
::
addVertex3D
(
const
Geom
::
Vec3f
&
v
)
{
m_vertices3D
.
push_back
(
v
);
m_colors
.
push_back
(
m_color
);
}
void
SvgObj
::
addVertex
(
const
Geom
::
Vec3f
&
v
,
const
Geom
::
Vec3f
&
c
)
{
m_vertices
.
push_back
(
v
);
m_colors
.
push_back
(
c
);
}
void
SvgObj
::
addVertex3D
(
const
Geom
::
Vec3f
&
v
,
const
Geom
::
Vec3f
&
c
)
{
m_vertices3D
.
push_back
(
v
);
m_colors
.
push_back
(
c
);
}
...
...
@@ -90,21 +107,23 @@ void SvgPoints::save(std::ofstream& out)
{
std
::
stringstream
ss
;
for
(
std
::
vector
<
Geom
::
Vec3f
>::
iterator
it
=
m_vertices
.
begin
();
it
!=
m_vertices
.
end
();
++
it
)
// for (std::vector<Geom::Vec3f>::iterator it =m_vertices.begin(); it != m_vertices.end(); ++it)
unsigned
int
nb
=
m_vertices
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
out
<<
"<circle cx=
\"
"
<<
(
*
it
)
[
0
];
out
<<
"
\"
cy=
\"
"
<<
(
*
it
)
[
1
];
out
<<
"<circle cx=
\"
"
<<
m_vertices
[
i
]
[
0
];
out
<<
"
\"
cy=
\"
"
<<
m_vertices
[
i
]
[
1
];
out
<<
"
\"
r=
\"
"
<<
m_width
;
out
<<
"
\"
style=
\"
stroke: none; fill: #"
;
out
<<
std
::
hex
;
unsigned
int
wp
=
out
.
width
(
2
);
char
prev
=
out
.
fill
(
'0'
);
out
<<
int
(
m_color
[
0
]
*
255
);
out
<<
int
(
m_color
s
[
i
]
[
0
]
*
255
);
out
.
width
(
2
);
out
.
fill
(
'0'
);
out
<<
int
(
m_color
[
1
]
*
255
);
out
<<
int
(
m_color
s
[
i
]
[
1
]
*
255
);
out
.
width
(
2
);
out
.
fill
(
'0'
);
out
<<
int
(
m_color
[
2
]
*
255
)
<<
std
::
dec
;
out
<<
int
(
m_color
s
[
i
]
[
2
]
*
255
)
<<
std
::
dec
;
out
.
fill
(
prev
);
out
.
width
(
wp
);
...
...
@@ -135,9 +154,36 @@ void SvgPolyline::save(std::ofstream& out)
out
<<
(
*
it
)[
0
]
<<
","
<<
(
*
it
)[
1
]
<<
" "
;
}
out
<<
"
\"
/>"
<<
std
::
endl
;
}
void
SvgLines
::
save
(
std
::
ofstream
&
out
)
{
std
::
stringstream
ss
;
// for (std::vector<Geom::Vec3f>::iterator it =m_vertices.begin(); it != m_vertices.end(); ++it)
unsigned
int
nb
=
m_vertices
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
out
<<
"<polyline fill=
\"
none
\"
stroke=
\"
#"
;
out
<<
std
::
hex
;
unsigned
int
wp
=
out
.
width
(
2
);
char
prev
=
out
.
fill
(
'0'
);
out
<<
int
(
m_colors
[
i
][
0
]
*
255
);
out
.
width
(
2
);
out
.
fill
(
'0'
);
out
<<
int
(
m_colors
[
i
][
1
]
*
255
);
out
.
width
(
2
);
out
.
fill
(
'0'
);
out
<<
int
(
m_colors
[
i
][
2
]
*
255
)
<<
std
::
dec
;
out
<<
"
\"
stroke-width=
\"
"
<<
m_width
<<
"
\"
points=
\"
"
;
out
.
fill
(
prev
);
out
.
width
(
wp
);
out
<<
m_vertices
[
i
][
0
]
<<
","
<<
m_vertices
[
i
][
1
]
<<
" "
;
i
++
;
out
<<
m_vertices
[
i
][
0
]
<<
","
<<
m_vertices
[
i
][
1
];
out
<<
"
\"
/>"
<<
std
::
endl
;
}
}
void
SvgPolygon
::
setColorFill
(
const
Geom
::
Vec3f
&
c
)
{
m_colorFill
=
c
;
...
...
@@ -370,6 +416,88 @@ bool compNormObj::operator() (SvgObj* a, SvgObj*b)
void
SVGOut
::
beginPoints
()
{
glm
::
i32vec4
viewport
;
glGetIntegerv
(
GL_VIEWPORT
,
&
(
viewport
[
0
]));
m_current
=
new
SvgPoints
();
m_current
->
setColor
(
global_color
);
m_current
->
setWidth
(
global_width
);
}
void
SVGOut
::
endPoints
()
{
m_objs
.
push_back
(
m_current
);
}
void
SVGOut
::
addPoint
(
const
Geom
::
Vec3f
&
P
)
{
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
m_viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_viewport
);
m_current
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
m_viewport
[
3
])
-
Q
[
1
],
Q
[
2
]));
m_current
->
addVertex3D
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
m_viewport
[
3
])
-
Q
[
1
],
Q
[
2
]));
}
void
SVGOut
::
addPoint
(
const
Geom
::
Vec3f
&
P
,
const
Geom
::
Vec3f
&
C
)
{
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
m_viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_viewport
);
m_current
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
m_viewport
[
3
])
-
Q
[
1
],
Q
[
2
]),
C
);
m_current
->
addVertex3D
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
m_viewport
[
3
])
-
Q
[
1
],
Q
[
2
]),
C
);
}
void
SVGOut
::
beginLines
()
{
glm
::
i32vec4
viewport
;
glGetIntegerv
(
GL_VIEWPORT
,
&
(
viewport
[
0
]));
m_current
=
new
SvgLines
();
m_current
->
setColor
(
global_color
);
m_current
->
setWidth
(
global_width
);
}
void
SVGOut
::
endLines
()
{
m_objs
.
push_back
(
m_current
);
}
void
SVGOut
::
addLine
(
const
Geom
::
Vec3f
&
P
,
const
Geom
::
Vec3f
&
P2
)
{
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
m_viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_viewport
);
glm
::
vec3
Q2
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
m_proj
,
m_viewport
);
glm
::
vec3
R2
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_viewport
);
m_current
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
m_viewport
[
3
])
-
Q
[
1
],
Q
[
2
]));
m_current
->
addVertex
(
Geom
::
Vec3f
(
Q2
[
0
],
float
(
m_viewport
[
3
])
-
Q2
[
1
],
Q2
[
2
]));
m_current
->
addVertex3D
(
Geom
::
Vec3f
(
R
[
0
],
float
(
m_viewport
[
3
])
-
R
[
1
],
R
[
2
]));
m_current
->
addVertex3D
(
Geom
::
Vec3f
(
R2
[
0
],
float
(
m_viewport
[
3
])
-
R2
[
1
],
R2
[
2
]));
}
void
SVGOut
::
addLine
(
const
Geom
::
Vec3f
&
P
,
const
Geom
::
Vec3f
&
P2
,
const
Geom
::
Vec3f
&
C
)
{
glm
::
vec3
Q
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
m_proj
,
m_viewport
);
glm
::
vec3
R
=
glm
::
project
(
glm
::
vec3
(
P
[
0
],
P
[
1
],
P
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_viewport
);
glm
::
vec3
Q2
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
m_proj
,
m_viewport
);
glm
::
vec3
R2
=
glm
::
project
(
glm
::
vec3
(
P2
[
0
],
P2
[
1
],
P2
[
2
]),
m_model
,
glm
::
mat4
(
1.0
),
m_viewport
);
m_current
->
addVertex
(
Geom
::
Vec3f
(
Q
[
0
],
float
(
m_viewport
[
3
])
-
Q
[
1
],
Q
[
2
]),
C
);
m_current
->
addVertex
(
Geom
::
Vec3f
(
Q2
[
0
],
float
(
m_viewport
[
3
])
-
Q2
[
1
],
Q2
[
2
]),
C
);
m_current
->
addVertex3D
(
Geom
::
Vec3f
(
R
[
0
],
float
(
m_viewport
[
3
])
-
R
[
1
],
R
[
2
]),
C
);
m_current
->
addVertex3D
(
Geom
::
Vec3f
(
R2
[
0
],
float
(
m_viewport
[
3
])
-
R2
[
1
],
R2
[
2
]),
C
);
}
}
// namespace SVG
}
// namespace Render
...
...
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