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
a1495866
Commit
a1495866
authored
Nov 09, 2012
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first add of some plugins
parent
67658c78
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
959 additions
and
0 deletions
+959
-0
SCHNApps/Plugins/firstPlugin/include/firstPlugin.h
SCHNApps/Plugins/firstPlugin/include/firstPlugin.h
+122
-0
SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp
SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp
+74
-0
SCHNApps/Plugins/import/include/importMap.h
SCHNApps/Plugins/import/include/importMap.h
+70
-0
SCHNApps/Plugins/import/src/importMap.cpp
SCHNApps/Plugins/import/src/importMap.cpp
+94
-0
SCHNApps/Plugins/visuSurface/include/simpleVisu.h
SCHNApps/Plugins/visuSurface/include/simpleVisu.h
+156
-0
SCHNApps/Plugins/visuSurface/src/simpleVisu.cpp
SCHNApps/Plugins/visuSurface/src/simpleVisu.cpp
+443
-0
No files found.
SCHNApps/Plugins/firstPlugin/include/firstPlugin.h
0 → 100644
View file @
a1495866
#ifndef FIRSTPLUGIN_H_
#define FIRSTPLUGIN_H_
#include "visualPlugin.h"
/**---CGoGN includes **/
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
#include "Topology/generic/parameters.h"
#ifdef USE_GMAP
#include "Topology/gmap/embeddedGMap2.h"
#else
#include "Topology/map/embeddedMap2.h"
#endif
#include "Algo/Render/GL2/topoRender.h"
/**---CGoGN includes **/
/**---Definitions specific to CGoGN ---*/
using
namespace
CGoGN
;
/**
* Struct that contains some informations about the types of the manipulated objects
* Mainly here to be used by the algorithms that are parameterized by it
*/
struct
PFP
:
public
PFP_STANDARD
{
// definition of the type of the map
#ifdef USE_GMAP
typedef
EmbeddedGMap2
MAP
;
#else
typedef
EmbeddedMap2
MAP
;
#endif
};
typedef
PFP
::
MAP
MAP
;
typedef
PFP
::
VEC3
VEC3
;
/**---Definitions specific to CGoGN ---*/
/**
* This class is a basic minimal plugin.
* All the methods in this class are overloaded methods.
* In order to create a valid plugin, all the method in this
* needs to be declared (they are actually overloaded methods
* from VisualPlugin), even if your plugin doesn't make any
* drawing.
*/
/**
* Our plugin must inherit from VisualPlugin,
* that is a class that itself is an implementation
* of the Plugin interface (virtual class). It contains
* many useful and essantial methods.
*/
class
FirstPlugin
:
public
VisualPlugin
{
/**
* Essential Qt macros.
*/
Q_OBJECT
Q_INTERFACES
(
Plugin
)
public:
FirstPlugin
(){}
~
FirstPlugin
(){}
/**
* The classical call back for the initGL method
* When a scene will be link to this plugin, it will call
* back this method with itself as a parameter.
*/
void
cb_initGL
(
Scene
*
scene
);
/**
* The drawing method that needs to be overloaded.
* Each time a scene (that is to say, at least one of the
* views that is contains) needs to be refresh, it calls back
* this method with itself as a parameter
*/
void
cb_redraw
(
Scene
*
scene
);
/**
* The plugin's activation method
* Each time the main application loads this plugin,
* it call this method. Writing this method is
* the occasion to initialize the plugin and check certain
* conditions.
* If this methods return 'false', the plugin load will be aborted.
*/
bool
activate
();
/**
* The plugin's disabling method
* Each time the main application will unload the plugin
* it will call this method.
*/
void
disable
();
protected:
/** Attributes that are specific to this plugin **/
MAP
myMap
;
// attribute for vertices positions
VertexAttribute
<
VEC3
>
position
;
// render (for the topo)
Algo
::
Render
::
GL2
::
TopoRender
*
m_render_topo
;
// just for more compact writing
inline
Dart
PHI1
(
Dart
d
)
{
return
myMap
.
phi1
(
d
);
}
inline
Dart
PHI_1
(
Dart
d
)
{
return
myMap
.
phi_1
(
d
);
}
inline
Dart
PHI2
(
Dart
d
)
{
return
myMap
.
phi2
(
d
);
}
template
<
int
X
>
Dart
PHI
(
Dart
d
)
{
return
myMap
.
phi
<
X
>
(
d
);
}
/** Attributes that are specific to this plugin **/
};
#endif
/* FIRSTPLUGIN_H_ */
SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp
0 → 100644
View file @
a1495866
#include "firstPlugin.h"
#include "Algo/Geometry/boundingbox.h"
bool
FirstPlugin
::
activate
(){
// creation of 2 new faces: 1 triangle and 1 square
Dart
d1
=
myMap
.
newFace
(
3
);
Dart
d2
=
myMap
.
newFace
(
4
);
// sew these faces along one of their edge
myMap
.
sewFaces
(
d1
,
d2
);
// creation of a new attribute on vertices of type 3D vector for position.
// a handler to this attribute is returned
position
=
myMap
.
addAttribute
<
VEC3
,
VERTEX
>
(
"position"
);
// affect position by moving in the map
position
[
d1
]
=
VEC3
(
0
,
0
,
0
);
position
[
PHI1
(
d1
)]
=
VEC3
(
2
,
0
,
0
);
position
[
PHI_1
(
d1
)]
=
VEC3
(
1
,
2
,
0
);
position
[
PHI
<
11
>
(
d2
)]
=
VEC3
(
0
,
-
2
,
0
);
position
[
PHI_1
(
d2
)]
=
VEC3
(
2
,
-
2
,
0
);
m_render_topo
=
NULL
;
return
true
;
}
void
FirstPlugin
::
disable
(){
if
(
m_render_topo
){
delete
m_render_topo
;
}
}
void
FirstPlugin
::
cb_redraw
(
Scene
*
scene
){
m_render_topo
->
drawTopo
();
}
void
FirstPlugin
::
cb_initGL
(
Scene
*
scene
){
if
(
scene
){
//we fit the first (possibly the only) view of the newly liked
//scene to the content of our map
// bounding box of scene
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
);
scene
->
firstViewFitSphere
(
bb
.
center
()[
0
],
bb
.
center
()[
1
],
bb
.
center
()[
2
],
bb
.
maxSize
());
m_render_topo
=
new
Algo
::
Render
::
GL2
::
TopoRender
()
;
// render the topo of the map without boundary darts
SelectorDartNoBoundary
<
PFP
::
MAP
>
nb
(
myMap
);
m_render_topo
->
updateData
<
PFP
>
(
myMap
,
position
,
0.9
f
,
0.9
f
,
nb
);
}
}
/**
* If we want to compile this plugin in debug mode,
* we also define a DEBUG macro at the compilation
*/
#ifndef DEBUG
//essential Qt function:
//arguments are
// - the complied name of the plugin
// - the main class of our plugin (that extends VisualPlugin)
Q_EXPORT_PLUGIN2
(
FirstPlugin
,
FirstPlugin
)
#else
Q_EXPORT_PLUGIN2
(
FirstPluginD
,
FirstPlugin
)
#endif
SCHNApps/Plugins/import/include/importMap.h
0 → 100644
View file @
a1495866
#ifndef _IMPORTMAP_H_
#define _IMPORTMAP_H_
#include "visualPlugin.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Render/GL2/topoRender.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Utils/vboRender.h"
#include "Utils/Qt/qtInputs.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
using
namespace
CGoGN
;
struct
PFP
:
public
PFP_STANDARD
{
// definition of the map
typedef
EmbeddedMap2
MAP
;
};
class
ImportMap
:
public
VisualPlugin
{
Q_OBJECT
Q_INTERFACES
(
Plugin
)
public:
ImportMap
();
~
ImportMap
();
void
cb_updateMatrix
(
View
*
view
){}
void
cb_redraw
(
Scene
*
scene
){}
void
cb_initGL
(
Scene
*
scene
){}
bool
activate
();
void
disable
();
protected:
bool
importMap
(
QString
filename
);
protected
slots
:
void
saveMap
();
};
#endif
SCHNApps/Plugins/import/src/importMap.cpp
0 → 100644
View file @
a1495866
#include "import.h"
#include <QMessageBox>
ImportMap
::
ImportMap
(){}
ImportMap
::~
ImportMap
(){}
bool
ImportMap
::
activate
(){
QAction
*
action
=
new
QAction
(
m_window
);
action
->
setIcon
(
QIcon
(
":icon/map.png"
));
QObject
::
connect
(
action
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
saveMap
()));
addMenuAction
(
"Visu;Imorter une Map"
,
action
);
addToolbarAction
(
action
);
waitingForScene
(
0
);
return
true
;
}
void
ImportMap
::
disable
(){}
bool
ImportMap
::
importMap
(
QString
filename
){
QFileInfo
fileInfo
(
filename
);
QString
extension
=
fileInfo
.
suffix
();
PFP
::
MAP
*
myMap
=
new
PFP
::
MAP
();
VertexAttribute
<
PFP
::
VEC3
>
position
;
VertexAttribute
<
PFP
::
VEC3
>
normal
;
if
(
extension
==
"map"
)
{
myMap
->
loadMapBin
(
filename
.
toStdString
());
position
=
myMap
->
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
"position"
)
;
}
else
{
std
::
vector
<
std
::
string
>
attrNames
;
if
(
!
Algo
::
Import
::
importMesh
<
PFP
>
(
*
myMap
,
filename
.
toStdString
().
c_str
(),
attrNames
))
{
return
false
;
}
position
=
myMap
->
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
attrNames
[
0
])
;
std
::
cout
<<
"import map position ok? "
<<
((
myMap
->
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
attrNames
[
0
]).
isValid
())
?
"yes"
:
"no"
)
<<
std
::
endl
;
std
::
cout
<<
"import map position ok? "
<<
((
myMap
->
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
"position"
).
isValid
())
?
"yes"
:
"no"
)
<<
std
::
endl
;
}
normal
=
myMap
->
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
"normal"
)
;
if
(
!
normal
.
isValid
())
normal
=
myMap
->
addAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
"normal"
)
;
Algo
::
Geometry
::
computeNormalVertices
<
PFP
>
(
*
myMap
,
position
,
normal
)
;
std
::
cout
<<
"import map normal ok? "
<<
((
myMap
->
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
"normal"
).
isValid
())
?
"yes"
:
"no"
)
<<
std
::
endl
;
MapHandler
*
vizuHandler
=
new
MapHandler
(
myMap
);
if
(
!
addReferencedMap
(
fileInfo
.
baseName
()
+
"_map"
,
vizuHandler
)){
System
::
Error
::
showError
();
delete
vizuHandler
;
return
false
;
}
// myMap->check();
return
true
;
}
void
ImportMap
::
saveMap
(){
QString
fileName
=
QFileDialog
::
getOpenFileName
(
m_window
,
System
::
app_path
+
"../files"
,
tr
(
"3D files (*)"
));
if
(
!
fileName
.
isEmpty
()){
if
(
!
importMap
(
fileName
)){
QMessageBox
msg
;
msg
.
setText
(
QString
::
fromUtf8
(
"Une erreur est survenue lors de la création de la carte"
));
if
(
System
::
Error
::
code
!=
System
::
Error
::
SUCCESS
){
System
::
Error
::
showError
();
}
}
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2
(
ImportMap
,
ImportMap
)
#else
Q_EXPORT_PLUGIN2
(
ImportMapD
,
ImportMap
)
#endif
SCHNApps/Plugins/visuSurface/include/simpleVisu.h
0 → 100644
View file @
a1495866
#ifndef _SIMPLEVISU_H_
#define _SIMPLEVISU_H_
#include "visualPlugin.h"
#include "ui_simpleVisu.h"
#include <iostream>
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Render/GL2/topoRender.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Utils/vboRender.h"
#include "Utils/Qt/qtInputs.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
#include <QHash>
#include <QPair>
using
namespace
CGoGN
;
struct
PFP
:
public
PFP_STANDARD
{
// definition of the map
typedef
EmbeddedMap2
MAP
;
};
typedef
PFP
::
MAP
MAP
;
typedef
PFP
::
VEC3
VEC3
;
struct
MyContainer
{
MAP
*
map
;
QPair
<
VBOHandler
*
,
VBOHandler
*>
vbos
;
QPair
<
VertexAttribute
<
VEC3
>
,
VertexAttribute
<
VEC3
>
>
attributes
;
Algo
::
Render
::
GL2
::
MapRender
*
render
;
bool
valid
;
MyContainer
(
MAP
*
myMap
,
VBOHandler
*
vbo1
,
VBOHandler
*
vbo2
,
VertexAttribute
<
VEC3
>
a1
,
VertexAttribute
<
VEC3
>
a2
,
Algo
::
Render
::
GL2
::
MapRender
*
r
)
:
map
(
myMap
),
vbos
(
vbo1
,
vbo2
),
attributes
(
a1
,
a2
),
render
(
r
),
valid
(
true
)
{}
};
class
MyWidget
:
public
QWidget
,
public
Ui
::
Form
{
Q_OBJECT
public:
MyWidget
(
QWidget
*
parent
=
0
)
:
QWidget
(
parent
)
{
this
->
setupUi
(
this
);}
};
class
SimpleVisu
:
public
VisualPlugin
{
Q_OBJECT
Q_INTERFACES
(
Plugin
)
public:
SimpleVisu
();
~
SimpleVisu
(){}
// void cb_updateMatrix(View* view);
void
cb_redraw
(
Scene
*
scene
);
void
cb_initGL
(
Scene
*
scene
);
bool
activate
();
void
disable
();
void
cb_recievedMap
(
MapHandler
*
map
);
void
cb_removingMap
(
MapHandler
*
map
);
void
cb_removingScene
(
Scene
*
scene
);
protected:
enum
renderMode
{
FLAT
,
PHONG
}
;
Geom
::
Vec4f
colDif
;
Geom
::
Vec4f
colSpec
;
Geom
::
Vec4f
colClear
;
Geom
::
Vec4f
colNormal
;
float
shininess
;
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
;
float
normalBaseSize
;
float
normalScaleFactor
;
float
vertexBaseSize
;
float
vertexScaleFactor
;
float
faceShrinkage
;
int
m_renderStyle
;
bool
m_drawVertices
;
bool
m_drawEdges
;
bool
m_drawFaces
;
bool
m_drawNormals
;
bool
m_drawTopo
;
VertexAttribute
<
VEC3
>
m_position
;
VertexAttribute
<
VEC3
>
m_normal
;
// Algo::Render::GL2::MapRender* m_render ;
VBOHandler
*
m_positionVBO
;
VBOHandler
*
m_normalVBO
;
bool
initOK
;
Utils
::
ShaderPhong
*
m_phongShader
;
Utils
::
ShaderFlat
*
m_flatShader
;
Utils
::
ShaderVectorPerVertex
*
m_vectorShader
;
Utils
::
ShaderSimpleColor
*
m_simpleColorShader
;
Utils
::
PointSprite
*
m_pointSprite
;
MyWidget
*
m_widget
;
QHash
<
Scene
*
,
MyContainer
>
h_info
;
QList
<
QPair
<
Scene
*
,
MapHandler
*>
>
l_waitingAssoc
;
// void initVBOs(Scene* scene);
public
slots
:
void
slot_drawVertices
(
bool
b
)
;
void
slot_verticesSize
(
int
i
)
;
void
slot_drawEdges
(
bool
b
)
;
void
slot_drawFaces
(
bool
b
)
;
void
slot_faceLighting
(
int
i
)
;
void
slot_drawTopo
(
bool
b
)
;
void
slot_drawNormals
(
bool
b
)
;
void
slot_normalsSize
(
int
i
)
;
};
#endif
SCHNApps/Plugins/visuSurface/src/simpleVisu.cpp
0 → 100644
View file @
a1495866
#include "simpleVisu.h"
bool
init
=
false
;
SimpleVisu
::
SimpleVisu
()
:
m_renderStyle
(
FLAT
),
m_drawVertices
(
false
),
m_drawEdges
(
false
),
m_drawFaces
(
true
),
m_drawNormals
(
false
),
m_drawTopo
(
false
),
initOK
(
false
),
m_phongShader
(
NULL
),
m_flatShader
(
NULL
),
m_vectorShader
(
NULL
),
m_simpleColorShader
(
NULL
),
m_pointSprite
(
NULL
)
{
normalScaleFactor
=
1.0
f
;
vertexScaleFactor
=
0.1
f
;
faceShrinkage
=
1.0
f
;
colClear
=
Geom
::
Vec4f
(
0.2
f
,
0.2
f
,
0.2
f
,
0.1
f
)
;
colDif
=
Geom
::
Vec4f
(
0.8
f
,
0.9
f
,
0.7
f
,
1.0
f
)
;
colSpec
=
Geom
::
Vec4f
(
0.9
f
,
0.9
f
,
0.9
f
,
1.0
f
)
;
colNormal
=
Geom
::
Vec4f
(
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
)
;
shininess
=
80.0
f
;
}
void
SimpleVisu
::
cb_recievedMap
(
MapHandler
*
map
){
std
::
cout
<<
"recived MAP"
<<
std
::
endl
;
int
t
;
if
((
t
=
l_map
.
size
())
<=
l_recievedScene
.
size
()){
std
::
cout
<<
"t="
<<
t
<<
std
::
endl
;
Scene
*
s
=
l_recievedScene
[
t
-
1
];
std
::
cout
<<
"scene "
<<
s
->
getName
().
toStdString
()
<<
std
::
endl
;
l_waitingAssoc
.
push_back
(
QPair
<
Scene
*
,
MapHandler
*>
(
s
,
map
));
}
if
(
l_scene
.
size
()
!=
0
){
updateGL
();
}
}
void
SimpleVisu
::
cb_removingMap
(
MapHandler
*
map
){
int
i
=
l_map
.
indexOf
(
map
);
if
(
i
>=
0
&&
i
<
l_recievedScene
.
size
()){
Scene
*
s
;
l_recievedScene
.
push_back
((
s
=
l_recievedScene
.
takeAt
(
i
)));
h_info
.
remove
(
s
);
}
}
void
SimpleVisu
::
cb_removingScene
(
Scene
*
scene
){
int
i
=
l_recievedScene
.
indexOf
(
scene
);
if
(
i
>=
0
&&
i
<
l_map
.
size
()){
MapHandler
*
vh
;
l_map
.
push_back
((
vh
=
l_map
.
takeAt
(
i
)));
}
}
void
SimpleVisu
::
cb_redraw
(
Scene
*
scene
){
while
(
!
l_waitingAssoc
.
isEmpty
()){
QPair
<
Scene
*
,
MapHandler
*>
p
=
l_waitingAssoc
.
takeFirst
();
Scene
*
s
=
p
.
first
;
if
(
h_info
.
find
(
s
)
==
h_info
.
end
()){
MapHandler
*
vh
=
p
.
second
;
VBOHandler
*
vboPosition
,
*
vboNormal
;
if
(
!
(
vboPosition
=
vh
->
findVBO
(
"positionVBO"
))){
vboPosition
=
vh
->
addNewVBO
(
"positionVBO"
);
}
if
(
!
(
vboNormal
=
vh
->
findVBO
(
"normalVBO"
))){
vboNormal
=
vh
->
addNewVBO
(
"normalVBO"
);
}
PFP
::
MAP
*
map
=
(
PFP
::
MAP
*
)
vh
->
map
();
VertexAttribute
<
VEC3
>
position
=
map
->
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
"position"
);
VertexAttribute
<
VEC3
>
normal
=
map
->
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
"normal"
)
;
if
(
!
normal
.
isValid
()){