Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
iMSTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ruiliang Gao
iMSTK
Commits
0950c34d
Commit
0950c34d
authored
9 years ago
by
Sreekanth Arikatla
Committed by
Ricardo Ortiz
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Refactors the code!
parent
95dcdc9c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Examples/LaparoscopicCamera/main.cpp
+44
-35
44 additions, 35 deletions
Examples/LaparoscopicCamera/main.cpp
with
44 additions
and
35 deletions
Examples/LaparoscopicCamera/main.cpp
+
44
−
35
View file @
0950c34d
...
...
@@ -32,45 +32,54 @@
#include
"Core/StaticSceneObject.h"
#include
"Mesh/VegaVolumetricMesh.h"
#include
"Devices/VRPNForceDevice.h"
#include
"VirtualTools/ToolCoupler.h"
#include
"VirtualTools/LaparoscopicCameraCoupler.h"
// Include required simulators
#include
"Simulators/VegaFemSimulator.h"
#include
"Simulators/DefaultSimulator.h"
#include
"Core/CollisionPair.h"
#include
"Collision/PlaneCollisionModel.h"
#include
"Collision/MeshCollisionModel.h"
#include
"Collision/PlaneToMeshCollision.h"
#include
"ContactHandling/PenaltyContactFemToStatic.h"
#include
"IO/initIO.h"
// VTK includes
#include
"VTKRendering/initVTKRendering.h"
#include
"VTKRendering/VTKViewer.h"
std
::
shared_ptr
<
MeshCollisionModel
>
createStaticSceneObject
(
std
::
shared_ptr
<
SDK
>
sdk
,
char
*
meshFile
,
std
::
shared_ptr
<
RenderDetail
>
renderProp
)
bool
createCameraNavigationScene
(
std
::
shared_ptr
<
SDK
>
sdk
,
char
*
fileName
)
{
auto
staticSimulator2
=
std
::
make_shared
<
DefaultSimulator
>
(
sdk
->
getErrorLog
());
auto
meshRenderDetail
=
std
::
make_shared
<
RenderDetail
>
(
SIMMEDTK_RENDER_NORMALS
);
meshRenderDetail
->
setAmbientColor
(
Color
(
0.2
,
0.2
,
0.2
,
1.0
));
meshRenderDetail
->
setDiffuseColor
(
Color
(
0.8
,
0.0
,
0.0
,
1.0
));
meshRenderDetail
->
setSpecularColor
(
Color
(
0.4
,
0.4
,
0.4
,
1.0
));
meshRenderDetail
->
setShininess
(
100.0
);
double
radius
=
2.0
;
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
auto
staticSimulator2
=
std
::
make_shared
<
DefaultSimulator
>
(
sdk
->
getErrorLog
());
auto
staticTarget
=
std
::
make_shared
<
StaticSceneObject
>
();
auto
staticDragon
=
std
::
make_shared
<
StaticSceneObject
>
();
auto
targetModel
=
std
::
make_shared
<
MeshCollisionModel
>
();
targetModel
->
loadTriangleMesh
(
fileName
);
targetModel
->
getMesh
()
->
scale
(
Eigen
::
UniformScaling
<
double
>
(
0.15
));
//0.2
staticTarget
->
setModel
(
targetModel
);
auto
dragenModel
=
std
::
make_shared
<
MeshCollisionModel
>
();
dragenModel
->
loadTriangleMesh
(
meshFile
);
dragenModel
->
getMesh
()
->
scale
(
Eigen
::
UniformScaling
<
double
>
(
0.15
));
//0.2
staticDragon
->
setModel
(
dragenModel
);
targetModel
->
setRenderDetail
(
meshRenderDetail
);
dragenModel
->
setRenderDetail
(
renderProp
);
sdk
->
addSceneActor
(
staticTarget
,
staticSimulator2
);
sdk
->
addSceneActor
(
staticDragon
,
staticSimulator2
);
targetModel
->
getMesh
()
->
translate
(
Eigen
::
Translation3d
(
0
,
0
,
-
radius
)
);
return
dragenModel
;
Eigen
::
Quaterniond
q
(
cos
(
i
*
22.0
/
42
),
0
,
sin
(
i
*
22.0
/
42
),
0
);
targetModel
->
getMesh
()
->
rotate
(
q
);
}
return
true
;
}
int
main
(
int
ac
,
char
**
av
)
...
...
@@ -90,35 +99,31 @@ int main(int ac, char** av)
auto
staticObject
=
std
::
make_shared
<
StaticSceneObject
>
();
auto
plane
=
std
::
make_shared
<
PlaneCollisionModel
>
(
core
::
Vec3d
(
0.0
,
-
0
.01
,
0.0
),
core
::
Vec3d
(
0.0
,
-
3
.01
,
0.0
),
core
::
Vec3d
(
0.0
,
1.0
,
0.0
));
plane
->
getPlaneModel
()
->
setWidth
(
5
);
if
(
ac
>
2
)
plane
->
getPlaneModel
()
->
setWidth
(
atof
(
av
[
2
]));
staticObject
->
setModel
(
plane
);
sdk
->
addSceneActor
(
staticObject
,
staticSimulator
);
auto
planeRendDetail
=
std
::
make_shared
<
RenderDetail
>
(
SIMMEDTK_RENDER_FACES
);
//-------------------------------------------------------
// Create scene actor 2: dragon
//-------------------------------------------------------
auto
dragonRenderDetail
=
std
::
make_shared
<
RenderDetail
>
(
SIMMEDTK_RENDER_FACES
);
Color
grey
(
0.32
,
0.32
,
0.32
,
1.
);
dragon
Rend
er
Detail
->
setAmbientColor
(
Color
(
0.2
,
0.2
,
0.2
,
1.0
)
);
dragon
Rend
er
Detail
->
setDiffuseColor
(
Color
(
0.8
,
0.0
,
0.0
,
1.0
)
);
dragon
Rend
er
Detail
->
setSpecularColor
(
Color
(
0.4
,
0.4
,
0.4
,
1.0
)
);
dragon
Rend
er
Detail
->
setShininess
(
10
0.0
);
plane
RendDetail
->
setAmbientColor
(
grey
);
plane
RendDetail
->
setDiffuseColor
(
grey
);
plane
RendDetail
->
setSpecularColor
(
grey
);
plane
RendDetail
->
setShininess
(
5
0.0
);
double
radius
=
3.0
;
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
auto
meshModel
=
createStaticSceneObject
(
sdk
,
"./Target.vtk"
,
dragonRenderDetail
);
plane
->
getPlaneModel
()
->
setRenderDetail
(
planeRendDetail
);
meshModel
->
getMesh
()
->
translate
(
Eigen
::
Translation3d
(
0
,
0
,
-
radius
)
);
sdk
->
addSceneActor
(
staticObject
,
staticSimulator
);
Eigen
::
Quaterniond
q
(
cos
(
i
*
22.0
/
42
),
0
,
sin
(
i
*
22.0
/
42
),
0
);
meshModel
->
getMesh
()
->
rotate
(
q
);
}
//-------------------------------------------------------
// Create camera navigation scene
//-------------------------------------------------------
createCameraNavigationScene
(
sdk
,
"./asianDragon.vtk"
);
//-------------------------------------------------------
// Customize the viewer
...
...
@@ -145,6 +150,10 @@ int main(int ac, char** av)
light2
->
lightPos
.
setPosition
(
core
::
Vec3d
(
25.0
,
10.0
,
10.0
));
scene
->
addLight
(
light2
);
auto
light3
=
Light
::
getDefaultLighting
();
light3
->
lightPos
.
setPosition
(
core
::
Vec3d
(
0.0
,
25.0
,
0.0
));
scene
->
addLight
(
light3
);
//-------------------------------------------------------
// Create a Laparoscopic camera controller
//-------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment