Commit 4b1315a5 authored by saubatn's avatar saubatn
Browse files

FIXED : bug #47 : initial particules where not updated since a biomechanical simulation starts.

This bug occured for structural components only composed by atoms (no cells). 
When creating a 3D Vtk representation of a structural component, each of its vtk 3d point represents an atom. When updating atoms position (during biomechanichal simulation), the vtk Point was not updated since it has no way to find which atom it was representing !
This mapping was done using an indexation point <--> atom.

This indexation was correctly done for Structural Components composed of CELLS. Now it has been also added for these only composed of ATOMS.


git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@194 ec899d31-69d1-42ba-9299-647d76f65fb3
parent f19719de
......@@ -145,7 +145,6 @@ QObject * StructuralComponentDC::getPropertyObject() {
// --------------- updateAtoms -------------------
void StructuralComponentDC::updateAtoms() {
if ( getSC()->composedBy() == StructuralComponent::CELLS ) {
CellDC *cdc;
unsigned int atomIndex;
......@@ -177,8 +176,30 @@ void StructuralComponentDC::updateAtoms() {
// update the nr of atoms
nrOfAtoms = atomDCs.size();
} else
} else // ComposedBy ATOMS
/// Nicolas : correct bug #47
if (getSC()->composedBy() == StructuralComponent::ATOMS)
{
// For structural component NOT featuring CELLS, i.e. only ATOMS
unsigned int atomIndex = 0;
AtomDC *adc;
// loop over the atoms of the SC
foreach ( camitk::Component *dc, childrenComponent ) {
// add an atom index each time a vtkPoint representing an atom is updated
// for instance when position changes during mechanical deformation
// NOTE : without index, when running MMLDisplay::updateDisplay()
// there is no way to get the correspondance between a 3D vtkPoint and the atom in the
// physical model (the method 'getOrderNumberInSCDC' called in 'this->UpdatePosition()'
// systematically returns -1 for SC only composed of ATOMS.
adc = dynamic_cast<AtomDC *> ( dc );
adc->registerIndexInSCDC ( std::IndexInParentItemPair ( this, atomIndex++ ) );
}
nrOfParts = nrOfAtoms = childrenComponent.size();
}
else // ComposedBy NOTHING
nrOfParts = nrOfAtoms = childrenComponent.size();
}
// --------------- initRepresentation -------------------
......@@ -200,6 +221,7 @@ void StructuralComponentDC::initRepresentation() {
}
// --------------- cellsToGeometry -------------------
Geometry * StructuralComponentDC::cellsToGeometry() {
Geometry *o;
......@@ -295,7 +317,6 @@ Geometry * StructuralComponentDC::cellsToGeometry() {
thePoints->SetNumberOfPoints ( nrOfAtoms );
// insert only the atoms that are in the vector (the one needed by the cells) (see updateAtoms() method)
for ( i = 0;i < nrOfAtoms;i++ ) {
atomDCs[i]->getAtom()->getPosition ( pos );
thePoints->SetPoint ( i, pos[0], pos[1], pos[2] );
......@@ -379,6 +400,7 @@ QMenu * StructuralComponentDC::getPopupMenu ( QWidget* parent ) {
// -------------------- updatePosition --------------------
void StructuralComponentDC::updatePosition ( AtomDC *modifiedAtomDC, int atomOrderNumber ) {
// update the 3D representation
if ( myGeometry ) {
// the order nr was not given, find it then !
if ( atomOrderNumber == -1 ) {
......@@ -386,6 +408,7 @@ void StructuralComponentDC::updatePosition ( AtomDC *modifiedAtomDC, int atomOrd
if ( getSC()->composedBy() == StructuralComponent::ATOMS ) {
// get the index of the modified atom in the list
atomOrderNumber = modifiedAtomDC->getOrderNumberInSCDC ( this );
std::cout << "atomOrderNumber : " << atomOrderNumber << std::endl;
} else
// I'm a SC whose cell has an atom that has changed
if ( isInstanceOf ( "StructuralComponentDC" ) ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment