Ejemplo n.º 1
0
/**
 *  Method in charge of the load of the triangular mesh data from F4S in the
 *  mesh object from SOFA
 *  @param pMesh : pointer to the triangular mesh
 */
void MeshF4S::loadMesh(::fwData::Mesh::sptr pMesh)
{
    // Copy points to Sofa
    const size_t nbPoints = pMesh->getNumberOfPoints();
    ::fwComEd::helper::Mesh meshHelper(pMesh);
    ::fwData::Mesh::PointsMultiArrayType points = meshHelper.getPoints();
    vertices.resize(nbPoints);
    for (int p=0;p<nbPoints;p++)
    {
        vertices[p][0] = (SReal)points[p][0];
        vertices[p][1] = (SReal)points[p][1];
        vertices[p][2] = (SReal)points[p][2];
    }

    // Copy cells to Sofa
    const size_t nbCells = pMesh->getNumberOfCells();
    ::fwData::Mesh::CellDataMultiArrayType cells = meshHelper.getCellData();
    facets.resize(nbCells);
    for (int i=0, f=0; f<nbCells; f++,i+=3)
    {
        facets[f].resize(3);
        facets[f][0].resize(3);
        facets[f][1].resize(3);
        facets[f][2].resize(3);
        facets[f][0][0] = cells[i];
        facets[f][0][1] = cells[i+1];
        facets[f][0][2] = cells[i+2];
    }
}
Ejemplo n.º 2
0
void AlgoMeshDeformation::setParam(
    ::fwData::Mesh::sptr _mesh,
    const unsigned int _nbStep,
    const unsigned int _amplitude)
{
    m_mesh      = _mesh;
    m_nbStep    = _nbStep;
    m_amplitude = _amplitude;
    m_direction = 1;

    m_nbPoints = _mesh->getNumberOfPoints();
    m_nbCells  = _mesh->getNumberOfCells();
}
Ejemplo n.º 3
0
void AlgoMeshDeformation::computeDeformation( ::fwData::Mesh::sptr _mesh,
                                              const unsigned int _nbStep,
                                              const unsigned int _amplitude )
{
    if (    m_mesh.expired() ||
            m_nbPoints != _mesh->getNumberOfPoints() ||
            m_nbCells != _mesh->getNumberOfCells()  ||
            !_mesh->getPointColorsArray())
    {
        this->setParam( _mesh, _nbStep, _amplitude );
        this->initSimu();
    }
    else
    {
        this->computeSimu();
    }
}