<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10px"><div id="yui_3_16_0_ym19_1_1507634908991_6316"><span></span></div><div id="yui_3_16_0_ym19_1_1507634908991_6446"><font id="yui_3_16_0_ym19_1_1507634908991_7856" size="3">Hello,</font></div><div id="yui_3_16_0_ym19_1_1507634908991_6473"><br></div><div id="yui_3_16_0_ym19_1_1507634908991_6986" dir="ltr"><font id="yui_3_16_0_ym19_1_1507634908991_7968" size="3">Thank you for the answer </font><font id="yui_3_16_0_ym19_1_1507634908991_6559" size="3"><font id="yui_3_16_0_ym19_1_1507634908991_7969" size="3">Francois</font>. Even chaning from raw- to smart-pointer for itkMesh did'nt bring any solution. The number of proints, cells and cell types are the same for vtkUnstructured grid and itkMesh after converting. But I got a new error : "</font><font id="yui_3_16_0_ym19_1_1507634908991_7058" size="3">vnl_error_vector_dimension:vnl_matrix::set_row: Dimensions [3] and [2] donot match" after the calling </font><font id="yui_3_16_0_ym19_1_1507634908991_7079" size="2">m_FemSolver->Update(); function.</font></div><div id="yui_3_16_0_ym19_1_1507634908991_6551" class="qtdSeparateBR"><div id="yui_3_16_0_ym19_1_1507634908991_7114"><font id="yui_3_16_0_ym19_1_1507634908991_7141" size="3">Do you (or someone else) know</font>, <font id="yui_3_16_0_ym19_1_1507634908991_7221" size="3">which matrix dimension is meant hier?  </font></div><div id="yui_3_16_0_ym19_1_1507634908991_7742"><br></div><div id="yui_3_16_0_ym19_1_1507634908991_7479" dir="ltr"><br><font id="yui_3_16_0_ym19_1_1507634908991_7221" size="3">Same quation is also asked here. But unfortunately without answer: <a id="yui_3_16_0_ym19_1_1507634908991_7478" class="" href="https://itk.org/pipermail/insight-users/2009-July/031536.html">https://itk.org/pipermail/insight-users/2009-July/031536.html</a>  <br></font></div><div id="yui_3_16_0_ym19_1_1507634908991_7486"><br></div><div id="yui_3_16_0_ym19_1_1507634908991_7536"><br></div><div id="yui_3_16_0_ym19_1_1507634908991_7369"><font size="3"><br></font></div><div id="yui_3_16_0_ym19_1_1507634908991_7164"><font id="yui_3_16_0_ym19_1_1507634908991_7772" size="3">Best regards</font><br></div><div id="yui_3_16_0_ym19_1_1507634908991_7105"><br></div><div id="yui_3_16_0_ym19_1_1507634908991_7198"><br></div><div id="yui_3_16_0_ym19_1_1507634908991_7244"><br></div></div><div style="display: block;" id="yui_3_16_0_ym19_1_1507634908991_6508" class="yahoo_quoted"> <div id="yui_3_16_0_ym19_1_1507634908991_6507" style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10px;"> <div id="yui_3_16_0_ym19_1_1507634908991_6506" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div id="yui_3_16_0_ym19_1_1507634908991_6544" dir="ltr"><font id="yui_3_16_0_ym19_1_1507634908991_6543" face="Arial" size="2"> Francois Budin <francois.budin@kitware.com> schrieb am 19:35 Montag, 9.Oktober 2017:<br></font></div>  <br><br> <div id="yui_3_16_0_ym19_1_1507634908991_6505" class="y_msg_container"><div id="yiv3537223775"><div id="yui_3_16_0_ym19_1_1507634908991_6504"><div id="yui_3_16_0_ym19_1_1507634908991_6503" dir="ltr"><div id="yui_3_16_0_ym19_1_1507634908991_6502"><div id="yui_3_16_0_ym19_1_1507634908991_6501"><div id="yui_3_16_0_ym19_1_1507634908991_6500"><div id="yui_3_16_0_ym19_1_1507634908991_6499"><div id="yui_3_16_0_ym19_1_1507634908991_6498"><div id="yui_3_16_0_ym19_1_1507634908991_6497">Hello Yusuf,<br clear="none"><br clear="none"></div>I am not sure what the problem is, but here are some ideas you can try to understand it or try to solve it:<br clear="none"></div>1) Use ITK smart pointers instead of raw pointers. The crash seem to indicate that the program was trying to unregister a smart pointer, but your mesh is declared as a raw pointer. The issue could come from this.<br clear="none"></div>2) Have you tried to look at your data, once converted, to make sure that it was converted correctly? Maybe there is a problem during your conversion which leads to an empty mesh or something worst.<br clear="none"><br clear="none"></div>Hope this helps,<br clear="none"></div>Francois<br clear="none"><br clear="none"></div>PS: As a side note, you may want to join the ITK discourse forum to ask your question or help others. The mailing list is still active but more people seem to be using the discourse forum now that it is available (<a rel="nofollow" shape="rect" target="_blank" href="http://discourse.itk.org/">http://discourse.itk.org/</a>)<br clear="none"></div><div id="yui_3_16_0_ym19_1_1507634908991_7024" class="yiv3537223775gmail_extra"><br clear="none"><div class="yiv3537223775yqt2765477433" id="yiv3537223775yqtfd56568"><div id="yui_3_16_0_ym19_1_1507634908991_7023" class="yiv3537223775gmail_quote">On Mon, Oct 9, 2017 at 8:08 AM, Yusuf OEZBEK via Insight-users <span dir="ltr"><<a rel="nofollow" shape="rect" ymailto="mailto:insight-users@itk.org" target="_blank" href="mailto:insight-users@itk.org">insight-users@itk.org</a>></span> wrote:<br clear="none"><blockquote id="yui_3_16_0_ym19_1_1507634908991_7022" class="yiv3537223775gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Dear ITK Users,<br clear="none">
<br clear="none">
According the mail <a rel="nofollow" shape="rect" target="_blank" href="https://public.kitware.com/pipermail/insight-users/2007-November/024272.html">https://public.kitware.com/ pipermail/insight-users/2007- November/024272.html</a> , I have converted my vtkUnstructuredGrid, wich I extracted from a vtkPolyData and contains TRIANGLE_CELL's to the itkMesh and than from itkMesh to itk::Fem::Object to deform my mesh:<br clear="none">
My problem is: If I call "m_FemSolver->Update();" ,I get a segmentation fault, which I really not understand.<br clear="none">
<br clear="none">
Program received signal SIGSEGV, Segmentation fault.<br clear="none">
0x00007fffb1086dd5 in itk::fem::FEMObject<2u>:: DeepCopy (this=0x4cc5ee0,<br clear="none">
    Copy=0x4cc1780)<br clear="none">
    at /home/toolkits/itk-4.7.2/ Modules/Numerics/FEM/include/ itkFEMObject.hxx:157<br clear="none">
157        a->UnRegister();<br clear="none">
<br clear="none">
<br clear="none">
void itkMeshToFemMesh:: updateItkMeshSlot(itk::Mesh< double, 3, MeshTraitsType> *itkMesh)<br clear="none">
{<br clear="none">
  typedef itk::fem::FEMObject<3> FemObjectType;<br clear="none">
  FemObjectType::Pointer m_FemObject= FemObjectType::New();<br clear="none">
<br clear="none">
  typedef itk::fem::Solver<3> SolverType;<br clear="none">
  typedef SolverType::Pointer SolverPointerType;<br clear="none">
  SolverPointerType m_FemSolver= SolverType::New();<br clear="none">
<br clear="none">
  // Define the Element Material properties<br clear="none">
  typedef itk::fem:: MaterialLinearElasticity MaterialType;<br clear="none">
  MaterialType::Pointer material= MaterialType::New();<br clear="none">
  material->SetGlobalNumber(0);<br clear="none">
  material->SetYoungsModulus( 200E6);<br clear="none">
  material-> SetCrossSectionalArea(1.0);<br clear="none">
  material->SetThickness(1.0);<br clear="none">
  material->SetMomentOfInertia( 1.0);<br clear="none">
  material->SetPoissonsRatio(0. 2);<br clear="none">
  material-> SetDensityHeatProduct(1.0);<br clear="none">
  m_FemObject->AddNextMaterial( material);<br clear="none">
<br clear="none">
  // Define the element type<br clear="none">
  typedef itk::fem:: Element2DC0LinearTriangularStr ain TriangularElementType;<br clear="none">
  TriangularElementType::Pointer triangularElement= TriangularElementType::New();<br clear="none">
  triangularElement-> SetMaterial(material. GetPointer());<br clear="none">
<br clear="none">
  // Convert mesh points into nodes<br clear="none">
  VectorType point(3);<br clear="none">
  PointType*ptr;<br clear="none">
  PointType pt;<br clear="none">
  ptr= &pt;<br clear="none">
<br clear="none">
  int numOfPoints= itkMesh->GetNumberOfPoints();<br clear="none">
  cout<<"itkMesh numOfPoints: "<<numOfPoints<<endl;<br clear="none">
<br clear="none">
  int numberOfCells= itkMesh->GetNumberOfCells();<br clear="none">
  cout<<"itkMesh numberOfCells: "<<numberOfCells<<endl;<br clear="none">
<br clear="none">
  CellsContainerPointer cellIterator= itkMesh->GetCells();<br clear="none">
  CellIterator cells= cellIterator->Begin();<br clear="none">
<br clear="none">
  bool flag= true;<br clear="none">
<br clear="none">
  for(int k=0; k< numberOfCells; k++)<br clear="none">
  {<br clear="none">
    CellType *cellPtr= cells.Value();<br clear="none">
    cout<<"Cell Value: "<< cells.Value() << " Cell Type= " << cellPtr->GetType()<<endl;<br clear="none">
<br clear="none">
    switch(cellPtr->GetType())<br clear="none">
    {<br clear="none">
      case CellType::TRIANGLE_CELL:<br clear="none">
      {<br clear="none">
        if(flag== true) // To make sure that the nodes are created just once<br clear="none">
        {<br clear="none">
          for(int j= 0; j< numOfPoints; j++)<br clear="none">
          {<br clear="none">
            itkMesh->GetPoint(j, ptr);<br clear="none">
<br clear="none">
            typedef TriangularElementType::Node TriangularNodeType;<br clear="none">
            TriangularNodeType::Pointer triangularNode= TriangularNodeType::New();<br clear="none">
            point[0]= -1.0;<br clear="none">
            point[1]= 2.0;<br clear="none">
            point[2]= 3.0;<br clear="none">
            triangularNode-> SetCoordinates(point);<br clear="none">
            triangularNode-> SetGlobalNumber(j);<br clear="none">
            m_FemObject->AddNextNode( triangularNode.GetPointer());<br clear="none">
          }<br clear="none">
          flag= false;<br clear="none">
        }<br clear="none">
        PointIdIterator pointIt= cellPtr->PointIdsBegin();<br clear="none">
        int i= 0;<br clear="none">
<br clear="none">
        while(pointIt!= cellPtr->PointIdsEnd())<br clear="none">
        {<br clear="none">
           triangularElement->SetNode(i, m_FemObject->GetNode(*pointIt) );<br clear="none">
          pointIt++;<br clear="none">
          i++;<br clear="none">
        }<br clear="none">
        cells++;<br clear="none">
        triangularElement-> SetGlobalNumber(k);<br clear="none">
        m_FemObject->AddNextElement( triangularElement.GetPointer() );<br clear="none">
        break;<br clear="none">
      }<br clear="none">
    }<br clear="none">
  }<br clear="none">
<br clear="none">
  // Define some Load<br clear="none">
  LoadNodePointerType loadNode =LoadNodeType::New();<br clear="none">
  loadNode->SetElement( triangularElement);<br clear="none">
  loadNode->SetGlobalNumber(3);<br clear="none">
  loadNode->SetNode(1);<br clear="none">
<br clear="none">
  vnl_vector<double> force(2);<br clear="none">
  force[0]= 20.0;<br clear="none">
  force[1]= -20.0;<br clear="none">
  force[2]= 10.0;<br clear="none">
  loadNode->SetForce(force);<br clear="none">
  m_FemObject->AddNextLoad( loadNode);<br clear="none">
<br clear="none">
  //Solve for displacements.<br clear="none">
  m_FemObject->FinalizeMesh();<br clear="none">
  m_FemSolver->SetInput(m_ FemObject);<br clear="none">
  m_FemSolver->Update();     // SEGMENTATION FAULT<br clear="none">
<br clear="none">
  cout<< "Fem Solver Output: "<< m_FemSolver->GetOutput()<< endl;<br clear="none">
<br clear="none">
  const unsigned int invalidId= itk::fem::Element:: InvalidDegreeOfFreedomID;<br clear="none">
  int numberOfNodes= m_FemSolver->GetInput()-> GetNumberOfNodes();<br clear="none">
<br clear="none">
  for(int i= 0; i< numberOfNodes; i++)<br clear="none">
  {<br clear="none">
    itk::fem::Element::Node:: Pointer node= m_FemSolver->GetInput()-> GetNode(i);<br clear="none">
    cout<<"Fem Node : "<< node->GetGlobalNumber()<<endl;<br clear="none">
<br clear="none">
    for(unsigned int j= 0, dof; (dof= node->GetDegreeOfFreedom(j))!= invalidId; j++)<br clear="none">
    {<br clear="none">
      cout <<"Solver GetSolution: "<< m_FemSolver->GetSolution(dof)< <endl;<br clear="none">
    }<br clear="none">
  }<br clear="none">
<br clear="none">
  // Write the deformed mesh<br clear="none">
  typedef itk::FEMObjectSpatialObject<3> FemObjectSpatialObjectType;<br clear="none">
  FemObjectSpatialObjectType:: Pointer m_FemSpatialObject= FemObjectSpatialObjectType:: New();<br clear="none">
  m_FemSpatialObject-> SetFEMObject(m_FemSolver-> GetOutput());<br clear="none">
<br clear="none">
  typedef itk::FEMSpatialObjectWriter<3>                      FemSpatialObjectWriterType;<br clear="none">
  FemSpatialObjectWriterType:: Pointer femSpatialWriter= FemSpatialObjectWriterType:: New();<br clear="none">
  femSpatialWriter->SetInput(m_ FemSpatialObject);<br clear="none">
  femSpatialWriter->SetFileName( "deformedMesh.meta");<br clear="none">
  femSpatialWriter->Update();<br clear="none">
}<br clear="none">
<br clear="none">
Thank you for any help!<br clear="none">
The ITK community is transitioning from this mailing list to <a rel="nofollow" shape="rect" target="_blank" href="http://discourse.itk.org/">discourse.itk.org</a>. Please join us there!<br clear="none">
______________________________ __<br clear="none">
Powered by <a rel="nofollow" shape="rect" target="_blank" href="http://www.kitware.com/">www.kitware.com</a><br clear="none">
<br clear="none">
Visit other Kitware open-source projects at<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/ opensource/opensource.html</a><br clear="none">
<br clear="none">
Kitware offers ITK Training Courses, for more information visit:<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/ products/protraining.php</a><br clear="none">
<br clear="none">
Please keep messages on-topic and check the ITK FAQ at:<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_ FAQ</a><br clear="none">
<br clear="none">
Follow this link to subscribe/unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="http://public.kitware.com/mailman/listinfo/insight-users">http://public.kitware.com/ mailman/listinfo/insight-users</a><br clear="none">
</blockquote></div><br clear="none"></div></div></div></div><br><br></div>  </div> </div>  </div></div></body></html>