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
Hurstel
CGoGN
Commits
13e149b1
Commit
13e149b1
authored
Aug 05, 2011
by
Maire Nicolas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rajout de presets dans clippingPresets
parent
fe9839c3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
137 additions
and
8 deletions
+137
-8
Apps/Examples/clipping.cpp
Apps/Examples/clipping.cpp
+48
-0
include/Utils/clippingPresets.h
include/Utils/clippingPresets.h
+22
-2
include/Utils/clippingShader.h
include/Utils/clippingShader.h
+0
-1
src/Utils/clippingPresets.cpp
src/Utils/clippingPresets.cpp
+67
-5
No files found.
Apps/Examples/clipping.cpp
View file @
13e149b1
...
...
@@ -302,6 +302,50 @@ void Clipping::slot_pushButton_applyClippingPreset()
preset
=
Utils
::
ClippingPreset
::
CreateCubePreset
(
Geom
::
Vec3f
((
float
)
centerX
,
(
float
)
centerY
,
(
float
)
centerZ
),
(
float
)
size
,
facing
);
}
break
;
case
2
:
// Tube
{
using
namespace
CGoGN
::
Utils
::
QT
;
double
centerX
=
(
double
)
m_bb
.
center
()[
0
];
double
centerY
=
(
double
)
m_bb
.
center
()[
1
];
double
centerZ
=
(
double
)
m_bb
.
center
()[
2
];
double
size
=
(
double
)
m_bb
.
maxSize
()
*
0.75
;
int
axis
=
0
;
int
precision
=
1
;
bool
facing
=
false
;
if
(
inputValues
(
VarDbl
(
centerX
-
100.0
,
centerX
+
100.0
,
centerX
,
"Center X"
,
VarDbl
(
centerY
-
100.0
,
centerY
+
100.0
,
centerY
,
"Center Y"
,
VarDbl
(
centerZ
-
100.0
,
centerZ
+
100.0
,
centerZ
,
"Center Z"
,
VarDbl
(
size
-
100.0
,
size
+
100.0
,
size
,
"Size"
,
VarSlider
(
0
,
2
,
axis
,
"Axis"
,
VarSlider
(
1
,
30
,
precision
,
"Precision"
,
VarBool
(
facing
,
"Facing"
))))))),
"Preset Setup"
))
preset
=
Utils
::
ClippingPreset
::
CreateTubePreset
(
Geom
::
Vec3f
((
float
)
centerX
,
(
float
)
centerY
,
(
float
)
centerZ
),
(
float
)
size
,
axis
,
precision
,
facing
);
}
break
;
case
3
:
// Molecule
{
using
namespace
CGoGN
::
Utils
::
QT
;
double
centerX
=
(
double
)
m_bb
.
center
()[
0
];
double
centerY
=
(
double
)
m_bb
.
center
()[
1
];
double
centerZ
=
(
double
)
m_bb
.
center
()[
2
];
double
size
=
(
double
)
m_bb
.
maxSize
()
*
0.75
;
double
atomsRadiuses
=
(
double
)
m_bb
.
maxSize
()
*
0.25
;
bool
orClipping
=
true
;
if
(
inputValues
(
VarDbl
(
centerX
-
100.0
,
centerX
+
100.0
,
centerX
,
"Center X"
,
VarDbl
(
centerY
-
100.0
,
centerY
+
100.0
,
centerY
,
"Center Y"
,
VarDbl
(
centerZ
-
100.0
,
centerZ
+
100.0
,
centerZ
,
"Center Z"
,
VarDbl
(
size
-
100.0
,
size
+
100.0
,
size
,
"Size"
,
VarDbl
(
atomsRadiuses
-
100.0
,
atomsRadiuses
+
100.0
,
atomsRadiuses
,
"Atoms radiuses"
,
VarBool
(
orClipping
,
"OR clipping mode"
)))))),
"Preset Setup"
))
preset
=
Utils
::
ClippingPreset
::
CreateMoleculePreset
(
Geom
::
Vec3f
((
float
)
centerX
,
(
float
)
centerY
,
(
float
)
centerZ
),
(
float
)
size
,
atomsRadiuses
,
orClipping
);
}
break
;
}
std
::
vector
<
unsigned
int
>
planesIds
;
std
::
vector
<
unsigned
int
>
spheresIds
;
...
...
@@ -340,6 +384,8 @@ void Clipping::slot_pushButton_applyClippingPreset()
Utils
::
Pickable
*
pickable
=
new
Utils
::
Pickable
(
m_sphereDrawable
,
spheresIds
[
i
]);
pickable
->
translate
(
m_shader
->
getClipSphereParamsCenter
(
spheresIds
[
i
]));
pickable
->
scale
(
m_shader
->
getClipSphereParamsRadius
(
spheresIds
[
i
]));
m_pickableSpheres
.
push_back
(
pickable
);
}
// Update shader sources edits
...
...
@@ -452,6 +498,8 @@ void Clipping::initGUI()
dock
.
comboBox_ClippingPresets
->
addItem
(
"Dual Planes"
);
dock
.
comboBox_ClippingPresets
->
addItem
(
"Cube"
);
dock
.
comboBox_ClippingPresets
->
addItem
(
"Tube"
);
dock
.
comboBox_ClippingPresets
->
addItem
(
"Molecule"
);
}
...
...
include/Utils/clippingPresets.h
View file @
13e149b1
...
...
@@ -28,6 +28,7 @@
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
#include <vector>
#include <cmath>
namespace
CGoGN
{
...
...
@@ -53,7 +54,7 @@ public :
/**
* public static constructor
* @param center center between planes
* @param
distanc
e distance between planes
* @param
siz
e distance between planes
* @param axis axis on which planes are aligned (0 for x, 1 for y, 2 for z)
* @param facing true means having facing planes
*/
...
...
@@ -62,11 +63,30 @@ public :
/**
* public static constructor
* @param center center between planes
* @param
distanc
e distance between planes
* @param
siz
e distance between planes
* @param facing true means having facing planes
*/
static
ClippingPreset
*
CreateCubePreset
(
Geom
::
Vec3f
center
,
float
size
,
bool
facing
);
/**
* public static constructor
* @param center center of the tube
* @param size tube diameter
* @param axis axis of the tube (0 for x, 1 for y, 2 for z)
* @param precision planes count used to build tube
* @param facing true means an outer tube, false an inner tube
*/
static
ClippingPreset
*
CreateTubePreset
(
Geom
::
Vec3f
center
,
float
size
,
int
axis
,
int
precision
,
bool
facing
);
/**
* public static constructor
* @param center center of molecule
* @param size molecule size
* @param atomsRadiuses radiuses of atoms
* @param orClipping set it to true for OR clipping mode
*/
static
ClippingPreset
*
CreateMoleculePreset
(
Geom
::
Vec3f
center
,
float
size
,
float
atomsRadiuses
,
bool
orClipping
);
private
:
/// private constructor (used by public static constructors)
...
...
include/Utils/clippingShader.h
View file @
13e149b1
...
...
@@ -32,7 +32,6 @@
#include <string>
#include <sstream>
#include <vector>
#include <cmath>
namespace
CGoGN
{
...
...
src/Utils/clippingPresets.cpp
View file @
13e149b1
...
...
@@ -49,18 +49,20 @@ ClippingPreset* ClippingPreset::CreateDualPlanesPreset(Geom::Vec3f center, float
{
ClippingPreset
*
preset
=
new
ClippingPreset
;
//
Axis on which planes will be aligned
//
Correct axis if necessary
if
((
axis
<
0
)
||
(
axis
>
2
))
axis
=
0
;
// Axis on which planes will be aligned
Geom
::
Vec3f
positDir
(
0.0
f
,
0.0
f
,
0.0
f
);
positDir
[
axis
]
=
1.0
f
;
Geom
::
Vec3f
negDir
(
0.0
f
,
0.0
f
,
0.0
f
);
negDir
[
axis
]
=
-
1.0
f
;
// Facing of planes
float
side
=
1.0
;
float
side
=
1.0
f
;
if
(
facing
)
side
=
-
1.0
;
side
=
-
1.0
f
;
// Add planes to preset
preset
->
addClipPlane
(
positDir
,
center
+
positDir
*
(
size
/
2.0
f
)
*
(
side
));
...
...
@@ -88,9 +90,9 @@ ClippingPreset* ClippingPreset::CreateCubePreset(Geom::Vec3f center, float size,
Geom
::
Vec3f
zAxisNeg
=
Geom
::
Vec3f
(
0.0
f
,
0.0
f
,
-
1.0
f
);
// Facing of planes
float
side
=
1.0
;
float
side
=
1.0
f
;
if
(
facing
)
side
=
-
1.0
;
side
=
-
1.0
f
;
// Add planes to preset
preset
->
addClipPlane
(
xAxisPos
,
center
+
xAxisPos
*
(
size
/
2.0
f
)
*
(
side
));
...
...
@@ -109,6 +111,66 @@ ClippingPreset* ClippingPreset::CreateCubePreset(Geom::Vec3f center, float size,
return
preset
;
}
ClippingPreset
*
ClippingPreset
::
CreateTubePreset
(
Geom
::
Vec3f
center
,
float
size
,
int
axis
,
int
precision
,
bool
facing
)
{
ClippingPreset
*
preset
=
new
ClippingPreset
;
// Correct axis if necessary
if
((
axis
<
0
)
||
(
axis
>
2
))
axis
=
0
;
// Correct precision if necessary
if
(
precision
<
1
)
precision
=
1
;
// Facing of planes
float
side
=
1.0
f
;
if
(
facing
)
side
=
-
1.0
f
;
// Add planes to preset
Geom
::
Vec3f
direction
(
0.0
,
0.0
,
0.0
);
float
dAngle
=
2.0
f
*
M_PI
/
precision
;
for
(
int
i
=
0
;
i
<
precision
;
i
++
)
{
direction
[(
axis
+
1
)
%
3
]
=
cos
(
i
*
dAngle
);
direction
[(
axis
+
2
)
%
3
]
=
sin
(
i
*
dAngle
);
preset
->
addClipPlane
(
direction
,
center
+
direction
*
(
size
/
2.0
f
)
*
(
side
));
}
// Set clipping mode
ClippingShader
::
clippingMode
clipMode
=
ClippingShader
::
CLIPPING_MODE_AND
;
if
(
facing
)
clipMode
=
ClippingShader
::
CLIPPING_MODE_OR
;
preset
->
setClippingMode
(
clipMode
);
return
preset
;
}
ClippingPreset
*
ClippingPreset
::
CreateMoleculePreset
(
Geom
::
Vec3f
center
,
float
size
,
float
atomsRadiuses
,
bool
orClipping
)
{
ClippingPreset
*
preset
=
new
ClippingPreset
;
// Add spheres to preset on each axis
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
Geom
::
Vec3f
positDir
(
0.0
f
,
0.0
f
,
0.0
f
);
positDir
[
i
]
=
1.0
f
;
Geom
::
Vec3f
negDir
(
0.0
f
,
0.0
f
,
0.0
f
);
negDir
[
i
]
=
-
1.0
f
;
preset
->
addClipSphere
(
center
+
positDir
*
(
size
/
2.0
f
),
atomsRadiuses
);
preset
->
addClipSphere
(
center
+
negDir
*
(
size
/
2.0
f
),
atomsRadiuses
);
}
// Set clipping mode
ClippingShader
::
clippingMode
clipMode
=
ClippingShader
::
CLIPPING_MODE_AND
;
if
(
orClipping
)
clipMode
=
ClippingShader
::
CLIPPING_MODE_OR
;
preset
->
setClippingMode
(
clipMode
);
return
preset
;
}
ClippingPreset
::
ClippingPreset
()
:
m_clipMode
(
ClippingShader
::
CLIPPING_MODE_AND
)
{
...
...
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