Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
7a0cad68
Commit
7a0cad68
authored
Dec 05, 2012
by
Pierre Kraemer
Browse files
SCHNApps : premiers plugins import et rendu !
parent
81df0944
Changes
26
Hide whitespace changes
Inline
Side-by-side
SCHNApps/Debug/CMakeLists.txt
View file @
7a0cad68
...
...
@@ -39,9 +39,6 @@ file(
)
SET
(
SCHNApps_H_OBJECT_FILES
${
SCHNApps_ROOT_DIR
}
/include/camera.h
${
SCHNApps_ROOT_DIR
}
/include/mapHandler.h
${
SCHNApps_ROOT_DIR
}
/include/plugin.h
${
SCHNApps_ROOT_DIR
}
/include/splitArea.h
${
SCHNApps_ROOT_DIR
}
/include/view.h
${
SCHNApps_ROOT_DIR
}
/include/window.h
...
...
SCHNApps/Plugins/CMakeLists.txt
View file @
7a0cad68
cmake_minimum_required
(
VERSION 2.8
)
ADD_SUBDIRECTORY
(
firstPlugin
)
ADD_SUBDIRECTORY
(
import
)
ADD_SUBDIRECTORY
(
demo
)
SCHNApps/Plugins/firstPlugin/CMakeLists.txt
deleted
100644 → 0
View file @
81df0944
cmake_minimum_required
(
VERSION 2.8
)
INCLUDE_DIRECTORIES
(
${
SCHNApps_ROOT_DIR
}
/include
${
SCHNApps_ROOT_DIR
}
/Plugins/firstPlugin/include
${
CMAKE_CURRENT_BINARY_DIR
}
)
SET
(
FIRSTPLUGIN_PLUGIN_SRC
${
SCHNApps_ROOT_DIR
}
/Plugins/firstPlugin/src/firstPlugin.cpp
)
SET
(
FIRSTPLUGIN_PLUGIN_H
${
SCHNApps_ROOT_DIR
}
/Plugins/firstPlugin/include/firstPlugin.h
)
IF
(
${
CMAKE_BUILD_TYPE
}
STREQUAL Debug
)
ADD_DEFINITIONS
(
-DDEBUG
)
IF
(
WIN32
)
link_directories
(
${
CGoGN_ROOT_DIR
}
/lib/Release
)
ELSE
(
WIN32
)
link_directories
(
${
CGoGN_ROOT_DIR
}
/lib/Debug
${
CGoGN_ROOT_DIR
}
/lib/Release
)
ENDIF
(
WIN32
)
QT4_WRAP_CPP
(
FIRSTPLUGIN_MOC
${
FIRSTPLUGIN_PLUGIN_H
}
)
ADD_LIBRARY
(
FirstPluginD SHARED
${
FIRSTPLUGIN_PLUGIN_SRC
}
${
FIRSTPLUGIN_MOC
}
)
TARGET_LINK_LIBRARIES
(
FirstPluginD
${
CGoGN_LIBS_D
}
${
COMMON_LIBS
}
${
QGLVIEWER_LIBRARIES
}
)
ADD_DEPENDENCIES
(
FirstPluginD SCHNAppsD
)
SET_TARGET_PROPERTIES
(
FirstPluginD PROPERTIES COMPILE_DEFINITIONS
"DEBUG"
)
ELSE
(
${
CMAKE_BUILD_TYPE
}
STREQUAL Debug
)
IF
(
WIN32
)
link_directories
(
${
CGoGN_ROOT_DIR
}
/lib/Release
)
ELSE
(
WIN32
)
link_directories
(
${
CGoGN_ROOT_DIR
}
/lib/Release
)
ENDIF
(
WIN32
)
QT4_WRAP_CPP
(
FIRSTPLUGIN_MOC
${
FIRSTPLUGIN_PLUGIN_H
}
)
ADD_LIBRARY
(
FirstPlugin SHARED
${
FIRSTPLUGIN_PLUGIN_SRC
}
${
FIRSTPLUGIN_MOC
}
)
TARGET_LINK_LIBRARIES
(
FirstPlugin
${
CGoGN_LIBS_R
}
${
COMMON_LIBS
}
${
QGLVIEWER_LIBRARIES
}
)
ADD_DEPENDENCIES
(
FirstPlugin SCHNApps
)
ENDIF
(
${
CMAKE_BUILD_TYPE
}
STREQUAL Debug
)
SCHNApps/Plugins/firstPlugin/include/firstPlugin.h
deleted
100644 → 0
View file @
81df0944
#ifndef _FIRSTPLUGIN_H_
#define _FIRSTPLUGIN_H_
#include
"plugin.h"
/**---CGoGN includes **/
#include
"Topology/generic/parameters.h"
#include
"Topology/map/embeddedMap2.h"
#include
"Algo/Render/GL2/mapRender.h"
#include
"Utils/Shaders/shaderFlat.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 map
typedef
EmbeddedMap2
MAP
;
};
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 Plugin
*/
class
FirstPlugin
:
public
Plugin
{
/**
* Essential Qt macros.
*/
Q_OBJECT
Q_INTERFACES
(
Plugin
)
public:
FirstPlugin
()
{
setProvidesRendering
(
true
);
}
~
FirstPlugin
()
{}
/**
* The plugin's enable 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
enable
();
/**
* The plugin's disable method
* Each time the main application will unload the plugin
* it will call this method.
*/
void
disable
();
virtual
void
redraw
(
View
*
view
);
virtual
void
keyPress
(
View
*
view
,
int
key
)
{}
virtual
void
keyRelease
(
View
*
view
,
int
key
)
{}
virtual
void
mousePress
(
View
*
view
,
int
button
,
int
x
,
int
y
)
{}
virtual
void
mouseRelease
(
View
*
view
,
int
button
,
int
x
,
int
y
)
{}
// virtual void mouseClick(View* view, int button, int x, int y) {}
virtual
void
mouseMove
(
View
*
view
,
int
buttons
,
int
x
,
int
y
)
{}
virtual
void
wheelEvent
(
View
*
view
,
int
delta
,
int
x
,
int
y
)
{}
virtual
void
viewAdded
(
View
*
view
);
virtual
void
viewRemoved
(
View
*
view
)
{}
protected:
MAP
myMap
;
VertexAttribute
<
VEC3
>
position
;
Algo
::
Render
::
GL2
::
MapRender
*
m_render
;
Utils
::
VBO
*
m_positionVBO
;
Utils
::
ShaderFlat
*
m_flatShader
;
};
#endif // _FIRSTPLUGIN_H_
SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp
deleted
100644 → 0
View file @
81df0944
#include
"firstPlugin.h"
#include
"Algo/Geometry/boundingbox.h"
#include
"Algo/Import/import.h"
bool
FirstPlugin
::
enable
()
{
m_render
=
new
Algo
::
Render
::
GL2
::
MapRender
()
;
m_positionVBO
=
new
Utils
::
VBO
()
;
m_flatShader
=
new
Utils
::
ShaderFlat
()
;
m_flatShader
->
setAttributePosition
(
m_positionVBO
)
;
m_flatShader
->
setAmbiant
(
Geom
::
Vec4f
(
0.2
f
,
0.2
f
,
0.2
f
,
0.1
f
))
;
m_flatShader
->
setDiffuse
(
Geom
::
Vec4f
(
0.8
f
,
0.9
f
,
0.7
f
,
1.0
f
))
;
m_flatShader
->
setExplode
(
1.0
f
)
;
CGoGN
::
Utils
::
GLSLShader
::
registerShader
(
NULL
,
m_flatShader
)
;
std
::
vector
<
std
::
string
>
attrNames
;
CGoGN
::
Algo
::
Import
::
importMesh
<
PFP
>
(
myMap
,
"/home/kraemer/Media/Data/surface/lowRes/duck_163.ply"
,
attrNames
);
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
attrNames
[
0
])
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
CGoGN
::
Algo
::
Render
::
GL2
::
POINTS
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
CGoGN
::
Algo
::
Render
::
GL2
::
LINES
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
allDarts
,
CGoGN
::
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
m_positionVBO
->
updateData
(
position
)
;
return
true
;
}
void
FirstPlugin
::
disable
()
{
}
void
FirstPlugin
::
redraw
(
View
*
view
)
{
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
)
;
glEnable
(
GL_LIGHTING
)
;
m_render
->
draw
(
m_flatShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
}
void
FirstPlugin
::
viewAdded
(
View
*
view
)
{
CGoGN
::
Geom
::
BoundingBox
<
PFP
::
VEC3
>
bb
=
Algo
::
Geometry
::
computeBoundingBox
<
PFP
>
(
myMap
,
position
)
;
qglviewer
::
Vec
min
(
bb
.
min
()[
0
],
bb
.
min
()[
1
],
bb
.
min
()[
2
]);
qglviewer
::
Vec
max
(
bb
.
max
()[
0
],
bb
.
max
()[
1
],
bb
.
max
()[
2
]);
view
->
setSceneBoundingBox
(
min
,
max
);
}
/**
* 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
Q_EXPORT_PLUGIN2
(
FirstPlugin
,
FirstPlugin
)
#else
Q_EXPORT_PLUGIN2
(
FirstPluginD
,
FirstPlugin
)
#endif
SCHNApps/Plugins/import/include/importMap.h
deleted
100644 → 0
View file @
81df0944
#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
deleted
100644 → 0
View file @
81df0944
#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
deleted
100644 → 0
View file @
81df0944
#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
deleted
100644 → 0
View file @
81df0944
#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
;