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
8bfd76d1
Commit
8bfd76d1
authored
Feb 21, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small bug in svg render topo
parent
60b3b83a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
124 additions
and
45 deletions
+124
-45
Apps/Tuto/tuto5.cpp
Apps/Tuto/tuto5.cpp
+1
-0
Apps/Tuto/tuto_oper2.cpp
Apps/Tuto/tuto_oper2.cpp
+98
-7
Apps/Tuto/tuto_oper2.h
Apps/Tuto/tuto_oper2.h
+5
-1
include/Algo/Render/GL2/topoRender.h
include/Algo/Render/GL2/topoRender.h
+8
-0
include/Algo/Render/GL2/topoRender.hpp
include/Algo/Render/GL2/topoRender.hpp
+2
-2
src/Algo/Render/topoRender.cpp
src/Algo/Render/topoRender.cpp
+7
-2
src/Utils/svg.cpp
src/Utils/svg.cpp
+3
-33
No files found.
Apps/Tuto/tuto5.cpp
View file @
8bfd76d1
...
...
@@ -336,6 +336,7 @@ int main(int argc, char **argv)
sqt
.
m_selected
=
myMap
.
begin
();
sqt
.
setGeometry
(
100
,
100
,
1024
,
1024
);
sqt
.
show
();
sqt
.
slider_balls
(
50
);
...
...
Apps/Tuto/tuto_oper2.cpp
View file @
8bfd76d1
...
...
@@ -26,6 +26,9 @@
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Geometry/centroid.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
using
namespace
CGoGN
;
...
...
@@ -164,14 +167,10 @@ void MyQT::createMap(int n)
grid
.
grid_topo
(
n
,
n
);
grid
.
embedGrid
(
1.
,
1.
,
0.
);
// bounding box of scene
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
);
float
lWidthObj
=
std
::
max
<
PFP
::
REAL
>
(
std
::
max
<
PFP
::
REAL
>
(
bb
.
size
(
0
),
bb
.
size
(
1
)),
bb
.
size
(
2
));
Geom
::
Vec3f
lPosObj
=
(
bb
.
min
()
+
bb
.
max
())
/
PFP
::
REAL
(
2
);
// send BB info to interface for centering on GL screen
setParamObject
(
lWidthObj
,
lPosObj
.
data
());
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
setParamObject
(
bb
.
maxSize
(),
bb
.
center
().
data
())
;
m_shift
=
bb
.
maxSize
()
/
200.0
f
;
// first show for be sure that GL context is binded
show
();
...
...
@@ -296,6 +295,30 @@ void MyQT::cb_keyPress(int keycode)
}
}
break
;
case
Qt
::
Key_Up
:
if
(
m_selected
!=
NIL
)
position
[
m_selected
][
1
]
+=
m_shift
;
updateMap
();
updateGL
();
break
;
case
Qt
::
Key_Down
:
if
(
m_selected
!=
NIL
)
position
[
m_selected
][
1
]
-=
m_shift
;
updateMap
();
updateGL
();
break
;
case
Qt
::
Key_Left
:
if
(
m_selected
!=
NIL
)
position
[
m_selected
][
0
]
-=
m_shift
;
updateMap
();
updateGL
();
break
;
case
Qt
::
Key_Right
:
if
(
m_selected
!=
NIL
)
position
[
m_selected
][
0
]
+=
m_shift
;
updateMap
();
updateGL
();
break
;
}
updateGL
();
}
...
...
@@ -306,6 +329,74 @@ void MyQT::svg()
m_render_topo
->
svgout2D
(
filename
,
modelViewMatrix
(),
projectionMatrix
());
}
void
MyQT
::
cb_Open
()
{
std
::
string
filters
(
"all (*.*);; trian (*.trian);; off (*.off);; ply (*.ply);; map (*.map)"
)
;
std
::
string
filename
=
selectFile
(
"Open Mesh"
,
""
,
filters
)
;
if
(
!
filename
.
empty
())
importMesh
(
filename
);
updateGL
();
}
void
MyQT
::
cb_Save
()
{
std
::
string
filename
=
selectFileSave
(
"Export SVG file "
,
"."
,
"(*.off)"
);
Algo
::
Export
::
exportOFF
<
PFP
>
(
myMap
,
position
,
filename
.
c_str
());
}
void
MyQT
::
importMesh
(
std
::
string
&
filename
)
{
myMap
.
clear
(
true
)
;
size_t
pos
=
filename
.
rfind
(
"."
);
// position of "." in filename
std
::
string
extension
=
filename
.
substr
(
pos
);
if
(
extension
==
std
::
string
(
".map"
))
{
myMap
.
loadMapBin
(
filename
);
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
"position"
)
;
}
else
{
std
::
vector
<
std
::
string
>
attrNames
;
if
(
!
Algo
::
Import
::
importMesh
<
PFP
>
(
myMap
,
filename
.
c_str
(),
attrNames
))
{
CGoGNerr
<<
"could not import "
<<
filename
<<
CGoGNendl
;
return
;
}
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
VERTEX
,
attrNames
[
0
])
;
}
colorDarts
=
myMap
.
getAttribute
<
PFP
::
VEC3
>
(
DART
,
"color"
);
if
(
!
colorDarts
.
isValid
())
{
colorDarts
=
myMap
.
addAttribute
<
PFP
::
VEC3
>
(
DART
,
"color"
);
for
(
Dart
d
=
myMap
.
begin
();
d
!=
myMap
.
end
();
myMap
.
next
(
d
))
{
if
(
dm
.
isMarked
(
d
)
&&
(
!
myMap
.
isBoundaryMarked
(
d
)))
{
int
n
=
random
();
float
r
=
float
(
n
&
0x7f
)
/
255.0
f
+
0.25
f
;
float
g
=
float
((
n
>>
8
)
&
0x7f
)
/
255.0
f
+
0.25
f
;
float
b
=
float
((
n
>>
16
)
&
0x7f
)
/
255.0
+
0.25
f
;
colorDarts
[
d
]
=
Geom
::
Vec3f
(
r
,
g
,
b
);
m_render_topo
->
setDartColor
(
d
,
r
,
g
,
b
);
}
}
}
m_selected
=
NIL
;
m_selected2
=
NIL
;
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
setParamObject
(
bb
.
maxSize
(),
bb
.
center
().
data
())
;
m_shift
=
bb
.
maxSize
()
/
200.0
f
;
updateMap
();
updateGLMatrices
()
;
}
void
MyQT
::
width
(
int
w
)
{
m_render_topo
->
setDartWidth
(
w
);
...
...
Apps/Tuto/tuto_oper2.h
View file @
8bfd76d1
...
...
@@ -67,12 +67,14 @@ class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MyQT
()
:
nb
(
myMap
),
m_render_topo
(
NULL
),
m_selected
(
NIL
),
m_selected2
(
NIL
),
dm
(
myMap
)
{}
MyQT
()
:
nb
(
myMap
),
m_render_topo
(
NULL
),
m_selected
(
NIL
),
m_selected2
(
NIL
),
dm
(
myMap
)
,
m_shift
(
0.01
f
)
{}
void
cb_redraw
();
void
cb_initGL
();
void
cb_mousePress
(
int
button
,
int
x
,
int
y
);
void
cb_keyPress
(
int
code
);
void
cb_Open
();
void
cb_Save
();
Utils
::
QT
::
uiDockInterface
dock
;
...
...
@@ -90,6 +92,7 @@ protected:
Dart
m_selected
;
Dart
m_selected2
;
DartMarker
dm
;
float
m_shift
;
// just for more compact writing
inline
Dart
PHI1
(
Dart
d
)
{
return
myMap
.
phi1
(
d
);}
...
...
@@ -102,6 +105,7 @@ public:
// example of simple map creation
void
createMap
(
int
n
);
void
updateMap
();
void
importMesh
(
std
::
string
&
filename
);
public
slots
:
void
operation
(
int
x
);
...
...
include/Algo/Render/GL2/topoRender.h
View file @
8bfd76d1
...
...
@@ -245,6 +245,14 @@ public:
void
updateDataGMap
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
const
FunctorSelect
&
good
=
allDarts
);
/**
* render to svg struct
*/
void
toSVG
(
Utils
::
SVG
::
SVGOut
&
svg
);
/**
* render svg into svg file
*/
void
svgout2D
(
const
std
::
string
&
filename
,
const
glm
::
mat4
&
model
,
const
glm
::
mat4
&
proj
);
};
...
...
include/Algo/Render/GL2/topoRender.hpp
View file @
8bfd76d1
...
...
@@ -189,7 +189,7 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const typename PFP::TVEC
*
positionF1
++
=
fv1
[
d
];
*
positionF1
++
=
fv11
[
e
];
}
m_nbRel1
=
vecDarts
.
size
()
/
2
;
m_nbRel1
=
vecDarts
.
size
();
m_vbo1
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
...
...
@@ -204,7 +204,7 @@ template<typename PFP>
//void TopoRenderGMap::updateData(typename PFP::MAP& map, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good)
void
TopoRender
::
updateDataGMap
(
typename
PFP
::
MAP
&
mapx
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
const
FunctorSelect
&
good
)
{
GMap2
&
map
=
reinterpret
_cast
<
GMap2
&>
(
mapx
);
GMap2
&
map
=
dynamic
_cast
<
GMap2
&>
(
mapx
);
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
src/Algo/Render/topoRender.cpp
View file @
8bfd76d1
...
...
@@ -284,7 +284,11 @@ void TopoRender::popColors()
void
TopoRender
::
svgout2D
(
const
std
::
string
&
filename
,
const
glm
::
mat4
&
model
,
const
glm
::
mat4
&
proj
)
{
Utils
::
SVG
::
SVGOut
svg
(
filename
,
model
,
proj
);
toSVG
(
svg
);
}
void
TopoRender
::
toSVG
(
Utils
::
SVG
::
SVGOut
&
svg
)
{
svg
.
setWidth
(
m_topo_relation_width
);
// PHI2 / beta2
...
...
@@ -293,7 +297,7 @@ void TopoRender::svgout2D(const std::string& filename, const glm::mat4& model, c
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
.
addLine
(
ptr
[
2
*
i
],
ptr
[
2
*
i
+
1
],
Geom
::
Vec3f
(
0.8
f
,
0.0
f
,
0.0
f
));
svg
.
endLines
();
m_vbo2
->
releasePtr
();
...
...
@@ -303,7 +307,7 @@ void TopoRender::svgout2D(const std::string& filename, const glm::mat4& model, c
svg
.
beginLines
();
for
(
unsigned
int
i
=
0
;
i
<
m_nbRel1
;
++
i
)
svg
.
addLine
(
ptr
[
2
*
i
],
ptr
[
2
*
i
+
1
],
Geom
::
Vec3f
(
0.0
f
,
1.0
f
,
1.0
f
));
svg
.
addLine
(
ptr
[
2
*
i
],
ptr
[
2
*
i
+
1
],
Geom
::
Vec3f
(
0.0
f
,
0.7
f
,
0.7
f
));
svg
.
endLines
();
m_vbo1
->
releasePtr
();
...
...
@@ -329,6 +333,7 @@ void TopoRender::svgout2D(const std::string& filename, const glm::mat4& model, c
}
}
//end namespace GL2
}
//end namespace Render
...
...
src/Utils/svg.cpp
View file @
8bfd76d1
...
...
@@ -206,25 +206,7 @@ void SvgLines::save(std::ofstream& out) const
unsigned
int
nb
=
m_vertices
.
size
()
/
2
;
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
saveOne
(
out
,
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
SvgLines
::
saveOne
(
std
::
ofstream
&
out
,
unsigned
int
i
,
unsigned
int
bbl
)
const
...
...
@@ -235,11 +217,11 @@ void SvgLines::saveOne(std::ofstream& out, unsigned int i, unsigned int bbl) con
out
<<
std
::
hex
;
unsigned
int
wp
=
out
.
width
(
2
);
char
prev
=
out
.
fill
(
'0'
);
out
<<
int
(
m_colors
[
i
][
0
]
*
255
);
out
<<
int
(
m_colors
[
2
*
i
][
0
]
*
255
);
out
.
width
(
2
);
out
.
fill
(
'0'
);
out
<<
int
(
m_colors
[
i
][
1
]
*
255
);
out
<<
int
(
m_colors
[
2
*
i
][
1
]
*
255
);
out
.
width
(
2
);
out
.
fill
(
'0'
);
out
<<
int
(
m_colors
[
i
][
2
]
*
255
)
<<
std
::
dec
;
out
<<
int
(
m_colors
[
2
*
i
][
2
]
*
255
)
<<
std
::
dec
;
out
<<
"
\"
stroke-width=
\"
"
<<
m_width
<<
"
\"
points=
\"
"
;
out
.
fill
(
prev
);
out
.
width
(
wp
);
...
...
@@ -525,24 +507,18 @@ 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
(
float
(
Q
[
0
]),
float
(
m_viewport
[
3
])
-
float
(
Q
[
1
]),
float
(
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
->
addVertex
(
Geom
::
Vec3f
(
float
(
Q
[
0
]),
float
(
m_viewport
[
3
])
-
float
(
Q
[
1
]),
float
(
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
);
...
...
@@ -565,9 +541,6 @@ void SVGOut::addLine(const Geom::Vec3f& P, const Geom::Vec3f& P2)
m_current
->
addVertex
(
Geom
::
Vec3f
(
float
(
Q
[
0
]),
float
(
m_viewport
[
3
])
-
float
(
Q
[
1
]),
float
(
Q
[
2
])));
m_current
->
addVertex
(
Geom
::
Vec3f
(
float
(
Q2
[
0
]),
float
(
m_viewport
[
3
])
-
float
(
Q2
[
1
]),
float
(
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]));
}
...
...
@@ -582,9 +555,6 @@ void SVGOut::addLine(const Geom::Vec3f& P, const Geom::Vec3f& P2, const Geom::Ve
m_current
->
addVertex
(
Geom
::
Vec3f
(
float
(
Q
[
0
]),
float
(
m_viewport
[
3
])
-
float
(
Q
[
1
]),
float
(
Q
[
2
])),
C
);
m_current
->
addVertex
(
Geom
::
Vec3f
(
float
(
Q2
[
0
]),
float
(
m_viewport
[
3
])
-
float
(
Q2
[
1
]),
float
(
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);
}
...
...
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