Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
iMSTK
iMSTK
Commits
2a84d7c1
Commit
2a84d7c1
authored
Jan 15, 2016
by
Ricardo Ortiz
Browse files
ENH: Refactoring StaticObject interface.
Use the model from SceneObject to laod meshes.
parent
6aefe4a3
Pipeline
#4818
passed with stage
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
SceneModels/DeformableSceneObject.cpp
View file @
2a84d7c1
...
...
@@ -77,12 +77,6 @@ void DeformableSceneObject::initialize()
}
}
//---------------------------------------------------------------------------
bool
DeformableSceneObject
::
configure
(
const
std
::
string
&
)
{
return
false
;
}
//---------------------------------------------------------------------------
void
DeformableSceneObject
::
update
(
const
double
dt
)
{
...
...
SceneModels/DeformableSceneObject.h
View file @
2a84d7c1
...
...
@@ -61,12 +61,10 @@ public:
///
void
initialize
()
override
;
virtual
bool
configure
(
const
std
::
string
&
);
///
/// \brief Update states
///
void
update
(
const
double
dt
);
void
update
(
const
double
dt
)
override
;
///
/// \brief Update states
...
...
@@ -88,6 +86,7 @@ public:
///
std
::
shared_ptr
<
OdeSystemState
>
getPreviousState
();
private:
///////////////////////////////////////////////////////////////////////////////
//////////// TODO: These are pure virtual methods from superclass. ////////////
//////////// They should be removed in the future. ////////////
...
...
SceneModels/SceneObject.h
View file @
2a84d7c1
...
...
@@ -68,7 +68,10 @@ public:
/// \brief Abstract object initialization
virtual
void
initialize
()
=
0
;
virtual
bool
configure
(
const
std
::
string
&
ConfigFile
)
=
0
;
virtual
bool
configure
(
const
std
::
string
&
/*ConfigFile*/
)
{
return
false
;
};
/// \brief Load the initial posiitons, velocities etc.,
virtual
void
loadInitialStates
()
=
0
;
...
...
@@ -213,8 +216,6 @@ public:
protected:
bool
isActive
;
private:
std
::
shared_ptr
<
ObjectSimulator
>
objectSim
;
//!< object simulator that will simulate the object
std
::
shared_ptr
<
CustomRenderer
>
customRender
;
std
::
vector
<
core
::
Vec3d
>
localVertices
;
//!< local copy of vertices
...
...
SceneModels/StaticSceneObject.cpp
View file @
2a84d7c1
...
...
@@ -24,6 +24,7 @@
#include "SceneModels/StaticSceneObject.h"
#include "Core/Factory.h"
#include "Core/RenderDelegate.h"
#include "Geometry/MeshModel.h"
StaticSceneObject
::
StaticSceneObject
(
std
::
shared_ptr
<
ErrorLog
>
/*p_log*/
)
:
SceneObject
()
{
...
...
@@ -36,39 +37,33 @@ StaticSceneObject::StaticSceneObject(std::shared_ptr<ErrorLog> /*p_log*/) : Scen
"StaticSceneObjectRenderDelegate"
,
RenderDelegate
::
RendererType
::
VTK
));
}
StaticSceneObject
::~
StaticSceneObject
()
{
}
void
StaticSceneObject
::
unSerialize
(
void
*
/*p_memoryBlock*/
)
{
}
void
StaticSceneObject
::
serialize
(
void
*
/*p_memoryBlock*/
)
//---------------------------------------------------------------------------
void
StaticSceneObject
::
initialize
()
{
this
->
objectSim
=
nullptr
;
this
->
flags
.
isSimulatorInit
=
false
;
}
void
StaticSceneObject
::
initialize
()
//---------------------------------------------------------------------------
void
StaticSceneObject
::
printInfo
()
const
{
std
::
cout
<<
"
\t
-------------------------------------
\n
"
;
std
::
cout
<<
"
\t
Name : "
<<
this
->
getName
()
<<
std
::
endl
;
std
::
cout
<<
"
\t
-------------------------------------
\n
"
;
}
//---------------------------------------------------------------------------
void
StaticSceneObject
::
loadInitialStates
()
{
}
if
(
fileName
.
empty
())
{
// TODO: log this
return
;
}
bool
StaticSceneObject
::
configure
(
const
std
::
string
&
/*ConfigFile*/
)
{
return
false
;
}
auto
model
=
std
::
make_shared
<
MeshModel
>
();
std
::
shared_ptr
<
SceneObject
>
StaticSceneObject
::
clone
()
{
return
safeDownCast
<
SceneObject
>
();
}
model
->
load
(
fileName
);
void
StaticSceneObject
::
printInfo
()
const
{
std
::
cout
<<
"
\t
-------------------------------------
\n
"
;
std
::
cout
<<
"
\t
Name : "
<<
this
->
getName
()
<<
std
::
endl
;
std
::
cout
<<
"
\t
-------------------------------------
\n
"
;
this
->
setModel
(
model
);
}
SceneModels/StaticSceneObject.h
View file @
2a84d7c1
...
...
@@ -38,41 +38,83 @@ namespace core {
class
Event
;
}
/// \brief static scene object
class
StaticSceneObject
:
public
SceneObject
///
/// \brief This type of models are meant to be static in the sense that dynamics do not
/// apply to them. They can be used to model objects that do not move in the scene or
/// or objects that are controlled by external hardware, i.e. haptics devices.
///
class
StaticSceneObject
:
public
SceneObject
{
public:
/// \brief constructor
///
/// \brief Constructor
///
StaticSceneObject
(
std
::
shared_ptr
<
ErrorLog
>
p_log
=
nullptr
);
/// \brief destructor
~
StaticSceneObject
();
///
/// \brief Destructor
///
~
StaticSceneObject
()
=
default
;
//not implemented yet..tansel
virtual
void
serialize
(
void
*
p_memoryBlock
)
override
;
///
/// \brief Initialize this model.
///
void
initialize
()
override
;
//not implemented yet..tansel
virtual
void
unSerialize
(
void
*
p_memoryBlock
)
override
;
///
///
///
void
printInfo
()
const
override
;
///not implemented yet.
virtual
std
::
shared_ptr
<
SceneObject
>
clone
()
override
;
///
///
///
virtual
void
handleEvent
(
std
::
shared_ptr
<
core
::
Event
>
)
override
{}
/// \brief Initialize the parameters and properties of the simulation object
void
initialize
()
override
;
///
///
///
void
update
(
const
double
/*dt*/
)
override
{}
/// \brief load initial displacements and velocities of the nodes
///
/// \brief Initialize mesh for this model
///
void
loadMesh
(
const
std
::
string
&
file
)
{
this
->
fileName
=
file
;
this
->
loadInitialStates
();
}
private:
///
/// \brief Initialize the model for this scene model.
///
void
loadInitialStates
()
override
;
/// \brief configure the static scene object using external config file (optional)
bool
configure
(
const
std
::
string
&
ConfigFile
)
override
;
///////////////////////////////////////////////////////////////////////////////
/////////// DO NOT USE THIS API ///////////
///////////////////////////////////////////////////////////////////////////////
//////////// TODO: These are pure virtual methods from superclass. ////////////
//////////// They should be removed in the future. ////////////
///////////////////////////////////////////////////////////////////////////////
///
///not implemented yet.
///
virtual
std
::
shared_ptr
<
SceneObject
>
clone
()
override
{
return
nullptr
;
}
void
printInfo
()
const
override
;
///
//not implemented yet..tansel
///
virtual
void
serialize
(
void
*/
*
p_memoryBlock
*/
)
override
{}
virtual
void
handleEvent
(
std
::
shared_ptr
<
core
::
Event
>
)
override
{}
///
//not implemented yet..tansel
///
virtual
void
unSerialize
(
void
*/
*
p_memoryBlock
*/
)
override
{}
void
update
(
const
double
/*dt*/
)
{}
private:
std
::
string
fileName
;
};
#endif
SceneModels/VegaFEMDeformableSceneObject.cpp
View file @
2a84d7c1
...
...
@@ -27,6 +27,7 @@
#include "Mesh/VegaVolumetricMesh.h"
#include "Core/MakeUnique.h"
#include "IO/IOMesh.h"
#include "Geometry/MeshModel.h"
// Vega includes
#include "configFile.h"
...
...
@@ -65,16 +66,20 @@
/// fixedDOFFilename List of fixed degrees of freedom
/// [path to file containing indices]
/// dampingMassCoefficient Mass matrix scaling factor for damping matrix computation
/// [default = 0.1; C = dampingMassCoefficient*M + dampingStiffnessCoefficient*K]
/// dampingStiffnessCoefficient Stiffness matrix factor for damping matrix computation
/// [default = 0.01; C = dampingMassCoefficient*M + dampingStiffnessCoefficient*K]
/// [default = 0.1; C = dampingMassCoefficient*M +
/// dampingStiffnessCoefficient*K]
/// dampingStiffnessCoefficient Stiffness matrix factor for damping matrix
/// computation
/// [default = 0.01; C = dampingMassCoefficient*M +
/// dampingStiffnessCoefficient*K]
/// dampingLaplacianCoefficient Laplacian damping matrix factor.
/// [default = 0.0]
/// deformationCompliance Compliance factor.
/// [default = 1.0]
/// gravity Gravity constant.
/// [default = -9.81]
/// compressionResistance Compression resistance parameter for the invertible methods
/// compressionResistance Compression resistance parameter for the invertible
/// methods
/// [default = 500.0]
/// inversionThreshold Inversion threshold parameter for the invertible methods
/// [default = -infinity]
...
...
@@ -110,12 +115,15 @@ public:
std
::
string
vegaConfigFile
;
///> Store configuration file.
std
::
map
<
std
::
string
,
double
>
floatsOptionMap
;
///> Map for floating point configuration variables.
std
::
map
<
std
::
string
,
int
>
intsOptionMap
;
///> Map for int configuration variables.
std
::
map
<
std
::
string
,
std
::
string
>
stringsOptionMap
;
///> Map for string configuration variables.
std
::
map
<
std
::
string
,
double
>
floatsOptionMap
;
///> Map for floating point
///> configuration variables.
std
::
map
<
std
::
string
,
int
>
intsOptionMap
;
///> Map for int configuration variables.
std
::
map
<
std
::
string
,
std
::
string
>
stringsOptionMap
;
///> Map for string
///> configuration variables.
MethodType
forceModelType
;
///> Force model type used.
InvertibleMaterialType
isotropicMaterialType
;
///> Constitutive law for nonlinear materials.
InvertibleMaterialType
isotropicMaterialType
;
///> Constitutive law for nonlinear
///> materials.
};
//---------------------------------------------------------------------------
...
...
@@ -260,7 +268,9 @@ VegaConfiguration::VegaConfiguration(const std::string &configurationFile, bool
}
//---------------------------------------------------------------------------
VegaFEMDeformableSceneObject
::
VegaFEMDeformableSceneObject
(
const
std
::
string
&
meshFilename
,
const
std
::
string
&
vegaConfigFileName
)
VegaFEMDeformableSceneObject
::
VegaFEMDeformableSceneObject
(
const
std
::
string
&
meshFilename
,
const
std
::
string
&
vegaConfigFileName
)
{
this
->
loadVolumeMesh
(
meshFilename
);
if
(
!
this
->
volumetricMesh
)
...
...
@@ -279,15 +289,17 @@ VegaFEMDeformableSceneObject::~VegaFEMDeformableSceneObject() {}
//---------------------------------------------------------------------------
void
VegaFEMDeformableSceneObject
::
loadVolumeMesh
(
const
std
::
string
&
fileName
)
{
auto
ioMesh
=
std
::
make_shared
<
IOMesh
>
();
ioMesh
->
read
(
fileName
);
auto
model
=
std
::
make_shared
<
MeshModel
>
();
this
->
volumetricMesh
=
std
::
static_pointer_cast
<
VegaVolumetricMesh
>
(
ioMesh
->
getMesh
());
model
->
load
(
fileName
);
if
(
!
this
->
volumetricMesh
)
this
->
setModel
(
model
);
this
->
volumetricMesh
=
std
::
static_pointer_cast
<
VegaVolumetricMesh
>
(
model
->
getMesh
());
if
(
!
model
->
getMesh
())
{
// TODO: Print error message
// TODO: Print error message
and log
return
;
}
}
...
...
@@ -420,14 +432,11 @@ void VegaFEMDeformableSceneObject::initTangentStiffnessMatrix()
matrix
->
BuildSubMatrixIndices
(
*
this
->
vegaMassMatrix
.
get
());
if
(
!
this
->
dampingMatrix
)
if
(
this
->
dampingMatrix
)
{
// TODO: log this
return
;
matrix
->
BuildSubMatrixIndices
(
*
this
->
dampingMatrix
.
get
(),
1
);
}
matrix
->
BuildSubMatrixIndices
(
*
this
->
dampingMatrix
.
get
(),
1
);
auto
rowLengths
=
matrix
->
GetRowLengths
();
auto
columnIndices
=
matrix
->
GetColumnIndices
();
...
...
@@ -771,8 +780,8 @@ std::vector< std::size_t > VegaFEMDeformableSceneObject::loadBoundaryConditions(
}
//---------------------------------------------------------------------------
void
VegaFEMDeformableSceneObject
::
updateValuesFromMatrix
(
std
::
shared_ptr
<
SparseMatrix
>
matrix
,
double
*
values
)
void
VegaFEMDeformableSceneObject
::
updateValuesFromMatrix
(
std
::
shared_ptr
<
SparseMatrix
>
matrix
,
double
*
values
)
{
auto
rowLengths
=
matrix
->
GetRowLengths
();
auto
nonZeroValues
=
matrix
->
GetEntries
();
...
...
@@ -830,7 +839,8 @@ void VegaFEMDeformableSceneObject::setOdeRHS()
//---------------------------------------------------------------------------
void
VegaFEMDeformableSceneObject
::
setTangentStiffnessMatrix
()
{
auto
tangentStiffness
=
[
this
](
const
OdeSystemState
&
s
)
->
const
core
::
SparseMatrixd
&
auto
tangentStiffness
=
[
this
](
const
OdeSystemState
&
s
)
->
const
core
::
SparseMatrixd
&
{
double
*
data
=
const_cast
<
double
*>
(
s
.
getPositions
().
data
());
...
...
@@ -847,7 +857,8 @@ void VegaFEMDeformableSceneObject::setTangentStiffnessMatrix()
//---------------------------------------------------------------------------
void
VegaFEMDeformableSceneObject
::
setMassMatrix
()
{
auto
massMatrix
=
[
this
](
const
OdeSystemState
&
/*s*/
)
->
const
core
::
SparseMatrixd
&
auto
massMatrix
=
[
this
](
const
OdeSystemState
&
/*s*/
)
->
const
core
::
SparseMatrixd
&
{
return
this
->
M
;
};
...
...
@@ -863,7 +874,8 @@ void VegaFEMDeformableSceneObject::setDampingMatrices()
const
auto
&
dampingMassCoefficient
=
this
->
vegaFemConfig
->
floatsOptionMap
.
at
(
"dampingMassCoefficient"
);
auto
raleighDamping
=
[
&
,
this
](
const
OdeSystemState
&
/*s*/
)
->
const
core
::
SparseMatrixd
&
auto
raleighDamping
=
[
&
,
this
](
const
OdeSystemState
&
/*s*/
)
->
const
core
::
SparseMatrixd
&
{
if
(
dampingMassCoefficient
>
0
)
{
...
...
@@ -883,7 +895,8 @@ void VegaFEMDeformableSceneObject::setDampingMatrices()
if
(
this
->
dampingMatrix
)
{
auto
lagrangianDamping
=
[
this
](
const
OdeSystemState
&
/*s*/
)
->
const
core
::
SparseMatrixd
&
auto
lagrangianDamping
=
[
this
](
const
OdeSystemState
&
/*s*/
)
->
const
core
::
SparseMatrixd
&
{
return
this
->
D
;
};
...
...
SceneModels/VegaFEMDeformableSceneObject.h
View file @
2a84d7c1
...
...
@@ -68,7 +68,7 @@ public:
/// \brief Set the initial state of the system. It assumes there is a valid mesh and
/// that numOfDOF is greater than zero.
///
void
loadInitialStates
();
void
loadInitialStates
()
override
;
///
/// \brief Initialize the ode solver.
...
...
@@ -149,7 +149,7 @@ public:
void
updateMesh
()
override
;
private:
// Volumetric mesh
// Volumetric mesh
, local copy of the actual mesh (stored in the model).
std
::
shared_ptr
<
VegaVolumetricMesh
>
volumetricMesh
;
// Vega force model
...
...
Write
Preview
Supports
Markdown
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