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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KennethVanhoey
CGoGN
Commits
bd3680d8
Commit
bd3680d8
authored
Feb 19, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolve bug in MapBrowserSelector
parent
1f381e91
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
30 deletions
+99
-30
Apps/Tuto/tuto_oper3.cpp
Apps/Tuto/tuto_oper3.cpp
+68
-17
Apps/Tuto/tuto_oper3.h
Apps/Tuto/tuto_oper3.h
+8
-2
include/Algo/Render/GL2/topo3Render.h
include/Algo/Render/GL2/topo3Render.h
+9
-6
include/Topology/generic/mapBrowser.h
include/Topology/generic/mapBrowser.h
+3
-1
include/Topology/generic/mapBrowser.hpp
include/Topology/generic/mapBrowser.hpp
+11
-4
No files found.
Apps/Tuto/tuto_oper3.cpp
View file @
bd3680d8
...
...
@@ -31,6 +31,7 @@
#include "Algo/Geometry/normal.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Topology/generic/mapBrowser.h"
using
namespace
CGoGN
;
...
...
@@ -73,15 +74,15 @@ void MyQT::clipping_onoff(bool x)
Geom
::
Vec3f
pos
=
m_PlanePick
->
getPosition
();
float
pipo
;
Geom
::
Vec3f
normal
=
m_PlanePick
->
getAxisScale
(
2
,
pipo
);
// 2 = Z axis = plane normal
m_
render_topo
->
shader1
()
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_
render_topo
->
shader2
()
->
setClipPlaneParamsAll
(
clip_id2
,
normal
,
pos
);
m_
sh1
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_
sh2
->
setClipPlaneParamsAll
(
clip_id2
,
normal
,
pos
);
}
else
{
m_
render_topo
->
shader1
()
->
setClipPlaneParamsAll
(
clip_id1
,
Geom
::
Vec3f
(
0
,
0
,
1
),
Geom
::
Vec3f
(
0
,
0
,
999999.9
f
));
m_
render_topo
->
shader2
()
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
Geom
::
Vec3f
(
0
,
0
,
999999.9
f
));
m_
render_topo
->
shader1
()
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
m_
render_topo
->
shader2
()
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
m_
sh1
->
setClipPlaneParamsAll
(
clip_id1
,
Geom
::
Vec3f
(
0
,
0
,
1
),
Geom
::
Vec3f
(
0
,
0
,
999999.9
f
));
m_
sh2
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
Geom
::
Vec3f
(
0
,
0
,
999999.9
f
));
m_
sh1
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
m_
sh2
->
setClipColorAttenuationFactorRelative
(
0.0
f
,
0.0
f
);
}
updateMap
();
updateGL
();
...
...
@@ -252,6 +253,8 @@ void MyQT::createMap(int n)
prim
.
hexaGrid_topo
(
n
,
n
,
n
);
prim
.
embedHexaGrid
(
1.0
f
,
1.0
f
,
1.0
f
);
myMap
.
check
();
// bounding box of scene
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
setParamObject
(
bb
.
maxSize
(),
bb
.
center
().
data
())
;
...
...
@@ -265,11 +268,21 @@ void MyQT::createMap(int n)
m_render_topo
->
setDartWidth
(
3.0
f
);
m_render_topo
->
setInitialDartsColor
(
0.0
f
,
0.0
f
,
0.0
f
);
m_render_topo
->
updateData
<
PFP
>
(
myMap
,
position
,
m_ex1
,
m_ex2
,
m_ex3
/*, nb*/
);
// SelectorDartBoundary<PFP::MAP> sdb(myMap);
// MapBrowserSelector mbs(myMap,sdb);
// myMap.setBrowser(&mbs);
// m_render_topo_boundary->updateData<PFP>(myMap,position,m_ex1,m_ex2);
// myMap.setBrowser(NULL);
m_render_topo_boundary
->
updateDataBoundary
<
PFP
>
(
myMap
,
position
,
m_ex1
,
m_ex2
,
m_shift
);
}
void
MyQT
::
updateMap
()
{
std
::
cout
<<
"updateMap"
<<
std
::
endl
;
m_render_topo
->
updateData
<
PFP
>
(
myMap
,
position
,
m_ex1
,
m_ex2
,
m_ex3
/*, nb*/
);
m_render_topo_boundary
->
updateDataBoundary
<
PFP
>
(
myMap
,
position
,
m_ex1
,
m_ex2
,
m_shift
);
}
// initialization GL callback
...
...
@@ -278,18 +291,24 @@ void MyQT::cb_initGL()
glClearColor
(
1.0
f
,
1.0
f
,
1.0
f
,
1.0
f
);
m_render_topo
=
new
Algo
::
Render
::
GL2
::
Topo3Render
()
;
m_render_topo_boundary
=
new
Algo
::
Render
::
GL2
::
TopoRender
();
m_render_topo_boundary
->
setInitialDartsColor
(
0.0
f
,
0.9
f
,
0.0
f
);
m_PlanePick
=
new
Utils
::
Pickable
(
Utils
::
Pickable
::
GRID
,
1
);
m_frame
=
new
Utils
::
FrameManipulator
();
m_frame
->
setSize
(
bb
.
maxSize
());
m_render_topo
->
shader1
()
->
insertClippingCode
();
m_render_topo
->
shader2
()
->
insertClippingCode
();
m_sh1
=
static_cast
<
Utils
::
ClippingShader
*>
(
m_render_topo
->
shader1
());
m_sh2
=
static_cast
<
Utils
::
ClippingShader
*>
(
m_render_topo
->
shader2
());
m_sh1
->
insertClippingCode
();
m_sh2
->
insertClippingCode
();
clip_id1
=
m_
render_topo
->
shader1
()
->
addClipPlane
();
clip_id2
=
m_
render_topo
->
shader2
()
->
addClipPlane
();
clip_id1
=
m_
sh1
->
addClipPlane
();
clip_id2
=
m_
sh2
->
addClipPlane
();
m_
render_topo
->
shader1
()
->
setClipPlaneParamsAll
(
clip_id1
,
Geom
::
Vec3f
(
0
,
0
,
1
),
bb
.
center
());
m_
render_topo
->
shader2
()
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
bb
.
center
());
m_
sh1
->
setClipPlaneParamsAll
(
clip_id1
,
Geom
::
Vec3f
(
0
,
0
,
1
),
bb
.
center
());
m_
sh2
->
setClipPlaneParamsAll
(
clip_id2
,
Geom
::
Vec3f
(
0
,
0
,
1
),
bb
.
center
());
}
...
...
@@ -301,6 +320,8 @@ void MyQT::cb_redraw()
m_render_topo
->
drawTopo
();
m_render_topo_boundary
->
drawTopo
();
glDisable
(
GL_POLYGON_OFFSET_FILL
);
if
(
m_selected
!=
NIL
)
...
...
@@ -330,7 +351,6 @@ void MyQT::cb_mousePress(int button, int x, int y)
{
if
(
d
!=
Dart
::
nil
())
m_selected
=
d
;
std
::
cout
<<
myMap
.
edgeCanCollapse
(
d
)
<<
std
::
endl
;
}
if
(
button
==
Qt
::
RightButton
)
{
...
...
@@ -365,13 +385,37 @@ void MyQT::cb_mousePress(int button, int x, int y)
if
(
Control
())
{
Dart
d
=
m_render_topo
->
picking
<
PFP
>
(
myMap
,
x
,
y
/*, nb*/
);
// Dart d = m_render_topo->picking<PFP>(myMap, x,y/*, nb*/);
// if (button == Qt::LeftButton)
// {
// if (d != Dart::nil())
// m_selecteds.push_back(d);
// }
// updateGL();
if
(
button
==
Qt
::
LeftButton
)
{
Dart
d
=
m_render_topo_boundary
->
picking
<
PFP
>
(
myMap
,
x
,
y
,
true
);
if
(
d
!=
Dart
::
nil
())
{
Dart
e
=
myMap
.
phi2
(
d
);
std
::
cout
<<
"Dart "
<<
d
.
index
<<
" / phi2:"
<<
e
.
index
<<
std
::
endl
;
}
}
if
(
button
==
Qt
::
RightButton
)
{
Dart
d
=
m_render_topo
->
picking
<
PFP
>
(
myMap
,
x
,
y
/*, nb*/
);
if
(
d
!=
Dart
::
nil
())
m_selecteds
.
push_back
(
d
);
{
Dart
e
=
myMap
.
phi2
(
d
);
std
::
cout
<<
"Dart "
<<
d
.
index
<<
" / phi2:"
<<
e
.
index
<<
std
::
endl
;
}
}
updateGL
();
}
}
...
...
@@ -433,8 +477,8 @@ void MyQT::cb_mouseMove(int buttons, int x, int y)
float
pipo
;
Geom
::
Vec3f
normal
=
m_PlanePick
->
getAxisScale
(
2
,
pipo
);
// 2 = Z axis = plane normal
m_
render_topo
->
shader1
()
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_
render_topo
->
shader2
()
->
setClipPlaneParamsAll
(
clip_id2
,
normal
,
pos
);
m_
sh1
->
setClipPlaneParamsAll
(
clip_id1
,
normal
,
pos
);
m_
sh2
->
setClipPlaneParamsAll
(
clip_id2
,
normal
,
pos
);
m_begX
=
x
;
m_begY
=
y
;
...
...
@@ -634,6 +678,13 @@ void MyQT::importMesh(std::string& filename)
m_render_topo
->
updateData
<
PFP
>
(
myMap
,
position
,
m_ex1
,
m_ex2
,
m_ex3
/*, nb*/
);
// SelectorDartBoundary<PFP::MAP> sdb(myMap);
// MapBrowserSelector mbs(myMap,sdb);
// myMap.setBrowser(&mbs);
// m_render_topo_boundary->updateData<PFP>(myMap,position,m_ex1,m_ex2);
// myMap.setBrowser(NULL);
m_render_topo_boundary
->
updateDataBoundary
<
PFP
>
(
myMap
,
position
,
m_ex1
,
m_ex2
,
m_shift
);
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
setParamObject
(
bb
.
maxSize
(),
bb
.
center
().
data
())
;
m_shift
=
bb
.
maxSize
()
/
200.0
f
;
...
...
Apps/Tuto/tuto_oper3.h
View file @
bd3680d8
...
...
@@ -37,6 +37,7 @@
#endif
#include "Algo/Render/GL2/topo3Render.h"
#include "Algo/Render/GL2/topoRender.h"
#include "Algo/Geometry/boundingbox.h"
#include "ui_tuto_oper3.h"
...
...
@@ -70,7 +71,7 @@ class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MyQT
()
:
nb
(
myMap
),
m_render_topo
(
NULL
),
m_selected
(
NIL
),
m_selected2
(
NIL
),
dm
(
myMap
),
m_shift
(
0.01
f
),
m_ex1
(
0.9
f
),
m_ex2
(
0.9
f
),
m_ex3
(
0.9
f
),
clip_volume
(
true
)
,
hide_clipping
(
false
)
{}
MyQT
()
:
m_render_topo
(
NULL
),
m_selected
(
NIL
),
m_selected2
(
NIL
),
dm
(
myMap
),
m_shift
(
0.01
f
),
m_ex1
(
0.9
f
),
m_ex2
(
0.9
f
),
m_ex3
(
0.9
f
),
clip_volume
(
true
)
,
hide_clipping
(
false
)
{}
void
cb_redraw
();
void
cb_initGL
();
...
...
@@ -89,12 +90,13 @@ protected:
VertexAttribute
<
VEC3
>
position
;
SelectorDartNoBoundary
<
PFP
::
MAP
>
nb
;
//
SelectorDartNoBoundary<PFP::MAP> nb;
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
;
// render (for the topo)
Algo
::
Render
::
GL2
::
Topo3Render
*
m_render_topo
;
Algo
::
Render
::
GL2
::
TopoRender
*
m_render_topo_boundary
;
Dart
m_selected
;
Dart
m_selected2
;
std
::
vector
<
Dart
>
m_selecteds
;
...
...
@@ -122,6 +124,10 @@ protected:
template
<
int
X
>
Dart
PHI
(
Dart
d
)
{
return
myMap
.
phi
<
X
>
(
d
);}
Utils
::
ClippingShader
*
m_sh1
;
Utils
::
ClippingShader
*
m_sh2
;
public:
// example of simple map creation
void
createMap
(
int
n
);
...
...
include/Algo/Render/GL2/topo3Render.h
View file @
bd3680d8
...
...
@@ -33,13 +33,16 @@
#include "Topology/generic/functor.h"
#include "Geometry/vector_gen.h"
#include "Utils/GLSLShader.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/vbo_base.h"
#include "Utils/svg.h"
// forward
namespace
CGoGN
{
namespace
Utils
{
class
ShaderSimpleColor
;
}
}
namespace
CGoGN
{
namespace
Utils
{
class
ShaderColorPerVertex
;
}
}
namespace
CGoGN
{
namespace
Utils
{
class
ClippingShader
;
}
}
namespace
CGoGN
{
...
...
@@ -156,8 +159,8 @@ public:
~
Topo3Render
();
Utils
::
ClippingShader
*
shader1
()
{
return
reinterpret_cast
<
Utils
::
Clipping
Shader
*>
(
m_shader1
);}
Utils
::
ClippingShader
*
shader2
()
{
return
reinterpret_cast
<
Utils
::
Clipping
Shader
*>
(
m_shader2
);}
Utils
::
GLSLShader
*
shader1
()
{
return
static_cast
<
Utils
::
GLSL
Shader
*>
(
m_shader1
);}
Utils
::
GLSLShader
*
shader2
()
{
return
static_cast
<
Utils
::
GLSL
Shader
*>
(
m_shader2
);}
/**
* set the with of line use to draw darts (default val is 2)
...
...
include/Topology/generic/mapBrowser.h
View file @
bd3680d8
...
...
@@ -41,11 +41,13 @@ class MapBrowserSelector : public MapBrowser
{
protected:
AttribMap
&
m_map
;
const
FunctorSelect
&
m_selector
;
const
FunctorSelect
*
m_selector
;
public:
MapBrowserSelector
(
AttribMap
&
m
,
const
FunctorSelect
&
fs
);
~
MapBrowserSelector
();
Dart
begin
()
const
;
Dart
end
()
const
;
...
...
include/Topology/generic/mapBrowser.hpp
View file @
bd3680d8
...
...
@@ -27,13 +27,20 @@ namespace CGoGN
inline
MapBrowserSelector
::
MapBrowserSelector
(
AttribMap
&
m
,
const
FunctorSelect
&
fs
)
:
m_map
(
m
),
m_selector
(
fs
)
{}
m_map
(
m
)
{
m_selector
=
fs
.
copy
();
}
inline
MapBrowserSelector
::~
MapBrowserSelector
()
{
delete
m_selector
;
}
inline
Dart
MapBrowserSelector
::
begin
()
const
{
Dart
d
=
m_map
.
realBegin
()
;
while
(
(
d
!=
m_map
.
realEnd
())
&&
!
m_selector
(
d
)
)
while
(
(
d
!=
m_map
.
realEnd
())
&&
!
m_selector
->
operator
()
(
d
)
)
m_map
.
realNext
(
d
);
return
d
;
...
...
@@ -50,7 +57,7 @@ inline void MapBrowserSelector::next(Dart& d) const
{
m_map
.
realNext
(
d
)
;
}
while
(
(
d
!=
m_map
.
realEnd
())
&&
!
m_selector
(
d
)
)
;
while
(
(
d
!=
m_map
.
realEnd
())
&&
!
m_selector
->
operator
()
(
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