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
f491ef48
Commit
f491ef48
authored
Mar 14, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better partial rendering on topo3
add svg rendering
parent
e2fc1ed9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
173 additions
and
52 deletions
+173
-52
include/Algo/Render/GL2/topo3Render.h
include/Algo/Render/GL2/topo3Render.h
+27
-4
include/Algo/Render/GL2/topo3Render.hpp
include/Algo/Render/GL2/topo3Render.hpp
+67
-46
src/Algo/Render/topo3Render.cpp
src/Algo/Render/topo3Render.cpp
+79
-2
No files found.
include/Algo/Render/GL2/topo3Render.h
View file @
f491ef48
...
...
@@ -36,6 +36,7 @@
#include "Geometry/vector_gen.h"
#include "Utils/vbo.h"
#include "Utils/svg.h"
// forward
namespace
CGoGN
{
namespace
Utils
{
class
ShaderSimpleColor
;
}
}
...
...
@@ -83,6 +84,11 @@ protected:
*/
GLuint
m_nbDarts
;
/**
* number of relations 2 to draw
*/
GLuint
m_nbRel1
;
/**
* number of relations 2 to draw
*/
...
...
@@ -266,8 +272,6 @@ public:
void
dartToCol
(
Dart
d
,
float
&
r
,
float
&
g
,
float
&
b
);
/**
* update all drawing buffers to render a dual map
* @param map the map
...
...
@@ -280,6 +284,14 @@ public:
template
<
typename
PFP
>
void
updateData
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
float
kv
,
const
FunctorSelect
&
good
=
allDarts
);
/**
* update color buffer with color attributte handler
* @param map the map
* @param good selector
* @param colors attribute of dart's colors
*/
template
<
typename
PFP
>
void
updateColors
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
colors
,
const
FunctorSelect
&
good
=
allDarts
);
/**
* Get back middle position of drawed darts
...
...
@@ -290,6 +302,17 @@ public:
template
<
typename
PFP
>
void
computeDartMiddlePositions
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
posExpl
,
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
);
protected:
/**
* update all drawing buffers to render a dual map
...
...
@@ -301,7 +324,7 @@ protected:
* @param good selector
*/
template
<
typename
PFP
>
void
updateDataMap3
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
float
kv
,
const
FunctorSelect
&
good
=
allDarts
);
void
updateDataMap3
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
float
kv
,
const
FunctorSelect
&
good
);
/**
* update all drawing buffers to render a gmap
...
...
@@ -313,7 +336,7 @@ protected:
* @param good selector
*/
template
<
typename
PFP
>
void
updateDataGMap3
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
float
kv
,
const
FunctorSelect
&
good
=
allDarts
);
void
updateDataGMap3
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
float
kv
,
const
FunctorSelect
&
good
);
};
...
...
include/Algo/Render/GL2/topo3Render.hpp
View file @
f491ef48
...
...
@@ -63,10 +63,6 @@ void Topo3Render::updateData(typename PFP::MAP& map, const typename PFP::TVEC3&
template
<
typename
PFP
>
void
Topo3Render
::
updateDataMap3
(
typename
PFP
::
MAP
&
mapx
,
const
typename
PFP
::
TVEC3
&
positions
,
float
ke
,
float
kf
,
float
kv
,
const
FunctorSelect
&
good
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
// Map3& map = dynamic_cast<Map3&>(mapx);
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -90,8 +86,7 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV
CellMarker
cmv
(
mapx
,
VOLUME
);
AutoAttributeHandler
<
VEC3
>
centerVolumes
(
mapx
,
VOLUME
,
"centerVolumes"
);
Algo
::
Geometry
::
computeCentroidVolumes
<
PFP
>
(
mapx
,
positions
,
centerVolumes
,
good
);
Algo
::
Geometry
::
computeCentroidVolumes
<
PFP
>
(
mapx
,
positions
,
centerVolumes
,
allDarts
);
// debut phi1
AutoAttributeHandler
<
VEC3
>
fv1
(
mapx
,
DART
);
...
...
@@ -118,7 +113,7 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV
unsigned
int
posDBI
=
0
;
// traverse each face of each volume
TraversorCell
<
typename
PFP
::
MAP
>
traFace
(
mapx
,
PFP
::
MAP
::
ORBIT_IN_PARENT
(
FACE
),
good
);
TraversorCell
<
typename
PFP
::
MAP
>
traFace
(
mapx
,
PFP
::
MAP
::
ORBIT_IN_PARENT
(
FACE
),
allDarts
);
for
(
Dart
d
=
traFace
.
begin
();
d
!=
traFace
.
end
();
d
=
traFace
.
next
())
{
vecDartFaces
.
push_back
(
d
);
...
...
@@ -157,22 +152,25 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV
float
oke
=
1.0
f
-
ke
;
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
VEC3
P
=
vecPos
[
i
]
*
ke
+
vecPos
[
i
+
1
]
*
oke
;
VEC3
Q
=
vecPos
[
i
+
1
]
*
ke
+
vecPos
[
i
]
*
oke
;
if
(
good
(
d
))
{
VEC3
P
=
vecPos
[
i
]
*
ke
+
vecPos
[
i
+
1
]
*
oke
;
VEC3
Q
=
vecPos
[
i
+
1
]
*
ke
+
vecPos
[
i
]
*
oke
;
m_attIndex
[
d
]
=
posDBI
;
posDBI
+=
2
;
m_attIndex
[
d
]
=
posDBI
;
posDBI
+=
2
;
*
positionDartBuf
++
=
P
;
*
positionDartBuf
++
=
Q
;
*
colorDartBuf
++
=
m_dartsColor
;
*
colorDartBuf
++
=
m_dartsColor
;
*
positionDartBuf
++
=
P
;
*
positionDartBuf
++
=
Q
;
*
colorDartBuf
++
=
m_dartsColor
;
*
colorDartBuf
++
=
m_dartsColor
;
fv1
[
d
]
=
P
*
0.1
f
+
Q
*
0.9
f
;
fv11
[
d
]
=
P
*
0.9
f
+
Q
*
0.1
f
;
fv1
[
d
]
=
P
*
0.1
f
+
Q
*
0.9
f
;
fv11
[
d
]
=
P
*
0.9
f
+
Q
*
0.1
f
;
fv2
[
d
]
=
P
*
0.52
f
+
Q
*
0.48
f
;
fv2x
[
d
]
=
P
*
0.48
f
+
Q
*
0.52
f
;
fv2
[
d
]
=
P
*
0.52
f
+
Q
*
0.48
f
;
fv2x
[
d
]
=
P
*
0.48
f
+
Q
*
0.52
f
;
}
d
=
mapx
.
phi1
(
d
);
}
...
...
@@ -184,25 +182,16 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV
m_vbo4
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
// phi1
m_vbo1
->
bind
();
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
m_nbDarts
*
sizeof
(
typename
PFP
::
VEC3
),
0
,
GL_STREAM_DRAW
);
GLvoid
*
PositionBuffer1
=
glMapBufferARB
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
//phi2
m_vbo2
->
bind
();
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
m_nbDarts
*
sizeof
(
typename
PFP
::
VEC3
),
0
,
GL_STREAM_DRAW
);
GLvoid
*
PositionBuffer2
=
glMapBufferARB
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
//phi3
m_vbo3
->
bind
();
glBufferData
(
GL_ARRAY_BUFFER
,
2
*
m_nbDarts
*
sizeof
(
typename
PFP
::
VEC3
),
0
,
GL_STREAM_DRAW
);
GLvoid
*
PositionBuffer3
=
glMapBufferARB
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
);
VEC3
*
positioniF1
=
new
VEC3
[
2
*
m_nbDarts
];
VEC3
*
positioniF2
=
new
VEC3
[
2
*
m_nbDarts
];
VEC3
*
positioniF3
=
new
VEC3
[
2
*
m_nbDarts
];
VEC3
*
positionF1
=
reinterpret_cast
<
VEC3
*>
(
PositionBuffer1
)
;
VEC3
*
positionF2
=
reinterpret_cast
<
VEC3
*>
(
PositionBuffer2
)
;
VEC3
*
positionF3
=
reinterpret_cast
<
VEC3
*>
(
PositionBuffer3
)
;
VEC3
*
positionF1
=
positioniF1
;
VEC3
*
positionF2
=
positioniF2
;
VEC3
*
positionF3
=
positioniF3
;
m_nbRel1
=
0
;
m_nbRel2
=
0
;
m_nbRel3
=
0
;
...
...
@@ -212,7 +201,7 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV
do
{
Dart
e
=
mapx
.
phi2
(
d
);
if
(
d
<
e
)
if
(
(
d
<
e
)
&&
good
(
d
)
&&
good
(
e
))
{
*
positionF2
++
=
fv2
[
d
];
*
positionF2
++
=
fv2x
[
e
];
...
...
@@ -221,7 +210,7 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV
m_nbRel2
++
;
}
e
=
mapx
.
phi3
(
d
);
if
(
!
mapx
.
isBoundaryMarked
(
e
)
&&
(
d
<
e
))
if
(
!
mapx
.
isBoundaryMarked
(
e
)
&&
(
d
<
e
)
&&
good
(
d
)
&&
good
(
e
)
)
{
*
positionF3
++
=
fv2
[
d
];
*
positionF3
++
=
fv2x
[
e
];
...
...
@@ -230,24 +219,28 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV
m_nbRel3
++
;
}
e
=
mapx
.
phi1
(
d
);
*
positionF1
++
=
fv1
[
d
];
*
positionF1
++
=
fv11
[
e
];
if
(
good
(
d
)
&&
good
(
e
))
{
*
positionF1
++
=
fv1
[
d
];
*
positionF1
++
=
fv11
[
e
];
m_nbRel1
++
;
}
d
=
mapx
.
phi1
(
d
);
}
while
(
d
!=
*
face
);
}
m_vbo3
->
bind
();
gl
Unmap
Buffer
ARB
(
GL_ARRAY_BUFFER
);
glBuffer
Data
(
GL_ARRAY_BUFFER
,
4
*
m_nbRel3
*
sizeof
(
typename
PFP
::
VEC3
),
positioniF3
,
GL_STREAM_DRAW
);
m_vbo2
->
bind
();
gl
Unmap
Buffer
ARB
(
GL_ARRAY_BUFFER
);
glBuffer
Data
(
GL_ARRAY_BUFFER
,
4
*
m_nbRel2
*
sizeof
(
typename
PFP
::
VEC3
),
positioniF2
,
GL_STREAM_DRAW
);
m_vbo1
->
bind
();
gl
Unmap
Buffer
(
GL_ARRAY_BUFFER
);
glBuffer
Data
(
GL_ARRAY_BUFFER
,
2
*
m_nbRel1
*
sizeof
(
typename
PFP
::
VEC3
),
positioniF1
,
GL_STREAM_DRAW
);
m_vbo4
->
bind
();
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
delete
[]
positioniF1
;
delete
[]
positioniF2
;
delete
[]
positioniF3
;
}
...
...
@@ -280,7 +273,7 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& g
}
else
{
CGoGNerr
<<
"Error buffer too small for color picking (change the
good
parameter ?)"
<<
CGoGNendl
;
CGoGNerr
<<
"Error buffer too small for color picking (change the
selector
parameter ?)"
<<
CGoGNendl
;
break
;
}
}
...
...
@@ -288,6 +281,34 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& g
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
}
template
<
typename
PFP
>
void
Topo3Render
::
updateColors
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
colors
,
const
FunctorSelect
&
good
)
{
m_vbo4
->
bind
();
Geom
::
Vec3f
*
colorBuffer
=
reinterpret_cast
<
Geom
::
Vec3f
*>
(
glMapBuffer
(
GL_ARRAY_BUFFER
,
GL_READ_WRITE
));
unsigned
int
nb
=
0
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
good
(
d
))
{
if
(
nb
<
m_nbDarts
)
{
colorBuffer
[
m_attIndex
[
d
]]
=
colors
[
d
];
nb
++
;
}
else
{
CGoGNerr
<<
"Error buffer too small for color picking (change the selector parameter ?)"
<<
CGoGNendl
;
break
;
}
}
}
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
}
template
<
typename
PFP
>
Dart
Topo3Render
::
picking
(
typename
PFP
::
MAP
&
map
,
int
x
,
int
y
,
const
FunctorSelect
&
good
)
{
...
...
src/Algo/Render/topo3Render.cpp
View file @
f491ef48
...
...
@@ -43,7 +43,7 @@ namespace GL2
{
Topo3Render
::
Topo3Render
()
:
m_nbDarts
(
0
),
m_nbRel2
(
0
),
m_nbRel3
(
0
),
m_nbDarts
(
0
),
m_
nbRel1
(
0
),
m_
nbRel2
(
0
),
m_nbRel3
(
0
),
m_topo_dart_width
(
2.0
f
),
m_topo_relation_width
(
3.0
f
),
m_color_save
(
NULL
),
m_dartsColor
(
1.0
f
,
1.0
f
,
1.0
f
)
{
...
...
@@ -192,7 +192,7 @@ void Topo3Render::drawRelation1()
m_shader1
->
setColor
(
Geom
::
Vec4f
(
0.0
f
,
1.0
f
,
1.0
f
,
0.0
f
));
m_shader1
->
enableVertexAttribs
();
glDrawArrays
(
GL_LINES
,
0
,
m_nb
Darts
*
2
);
glDrawArrays
(
GL_LINES
,
0
,
m_nb
Rel1
*
2
);
m_shader1
->
disableVertexAttribs
();
...
...
@@ -370,6 +370,83 @@ Dart Topo3Render::pickColor(unsigned int x, unsigned int y)
return
colToDart
(
color
);
}
void
Topo3Render
::
svgout2D
(
const
std
::
string
&
filename
,
const
glm
::
mat4
&
model
,
const
glm
::
mat4
&
proj
)
{
Utils
::
SVG
::
SVGOut
svg
(
filename
,
model
,
proj
);
toSVG
(
svg
);
}
void
Topo3Render
::
toSVG
(
Utils
::
SVG
::
SVGOut
&
svg
)
{
svg
.
setWidth
(
m_topo_relation_width
);
// PHI3 / beta3
const
Geom
::
Vec3f
*
ptr
=
reinterpret_cast
<
Geom
::
Vec3f
*>
(
m_vbo3
->
lockPtr
());
svg
.
beginLines
();
for
(
unsigned
int
i
=
0
;
i
<
m_nbRel3
;
++
i
)
{
Geom
::
Vec3f
P
=
(
ptr
[
4
*
i
]
+
ptr
[
4
*
i
+
3
])
/
2.0
f
;
Geom
::
Vec3f
Q
=
(
ptr
[
4
*
i
+
1
]
+
ptr
[
4
*
i
+
2
])
/
2.0
f
;
svg
.
addLine
(
P
,
Q
,
Geom
::
Vec3f
(
0.8
f
,
0.8
f
,
0.0
f
));
}
svg
.
endLines
();
m_vbo3
->
releasePtr
();
// PHI2 / beta2
ptr
=
reinterpret_cast
<
Geom
::
Vec3f
*>
(
m_vbo2
->
lockPtr
());
svg
.
beginLines
();
for
(
unsigned
int
i
=
0
;
i
<
m_nbRel2
;
++
i
)
{
Geom
::
Vec3f
P
=
(
ptr
[
4
*
i
]
+
ptr
[
4
*
i
+
3
])
/
2.0
f
;
Geom
::
Vec3f
Q
=
(
ptr
[
4
*
i
+
1
]
+
ptr
[
4
*
i
+
2
])
/
2.0
f
;
svg
.
addLine
(
P
,
Q
,
Geom
::
Vec3f
(
0.8
f
,
0.0
f
,
0.0
f
));
}
svg
.
endLines
();
m_vbo2
->
releasePtr
();
//PHI1 /beta1
ptr
=
reinterpret_cast
<
Geom
::
Vec3f
*>
(
m_vbo1
->
lockPtr
());
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
,
0.7
f
,
0.7
f
));
svg
.
endLines
();
m_vbo1
->
releasePtr
();
const
Geom
::
Vec3f
*
colorsPtr
=
reinterpret_cast
<
const
Geom
::
Vec3f
*>
(
m_vbo4
->
lockPtr
());
ptr
=
reinterpret_cast
<
Geom
::
Vec3f
*>
(
m_vbo0
->
lockPtr
());
svg
.
setWidth
(
m_topo_dart_width
);
svg
.
beginLines
();
for
(
unsigned
int
i
=
0
;
i
<
m_nbDarts
;
++
i
)
{
Geom
::
Vec3f
col
=
colorsPtr
[
2
*
i
];
if
(
col
.
norm2
()
>
2.9
f
)
col
=
Geom
::
Vec3f
(
1.0
f
,
1.0
f
,
1.0
f
)
-
col
;
svg
.
addLine
(
ptr
[
2
*
i
],
ptr
[
2
*
i
+
1
],
col
);
}
svg
.
endLines
();
svg
.
beginPoints
();
for
(
unsigned
int
i
=
0
;
i
<
m_nbDarts
;
++
i
)
{
Geom
::
Vec3f
col
=
colorsPtr
[
2
*
i
];
if
(
col
.
norm2
()
>
2.9
f
)
col
=
Geom
::
Vec3f
(
1.0
f
,
1.0
f
,
1.0
f
)
-
col
;
svg
.
addPoint
(
ptr
[
2
*
i
],
col
);
}
svg
.
endPoints
();
m_vbo0
->
releasePtr
();
m_vbo4
->
releasePtr
();
}
...
...
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