From nasil122002 at yahoo.de Thu Nov 9 14:59:10 2017 From: nasil122002 at yahoo.de (Yusuf OEZBEK) Date: Thu, 9 Nov 2017 19:59:10 +0000 (UTC) Subject: [ITK-dev] itk::fem updating displacements References: <587898442.10039537.1510257550772.ref@mail.yahoo.com> Message-ID: <587898442.10039537.1510257550772@mail.yahoo.com> Dear ITK users,I have another question. In order to visualize the deformation, I want to replace the old node coordinates with the new one after generating the solution, like in UpdateDisplacements() function in itkFemSolver.hxx 610-651 The code-block, which generates solution:m_FemSolver->Update(); //m_FemSolver->UpdateDisplacements(); const unsigned int invalidId= itk::fem::Element::InvalidDegreeOfFreedomID; int numberOfNodes= m_FemSolver->GetInput()->GetNumberOfNodes(); for(int i= 0; i< numberOfNodes; i++) { itk::fem::Element::Node::Pointer node= m_FemSolver->GetInput()->GetNode(i); std::cout<<"FEM Mesh Node: "<< node->GetGlobalNumber() << " Coordinates: "<< node->GetCoordinates()<GetDegreeOfFreedom(j))!= invalidId; j++) { cout <<"FEM Mesh Solution: "<< m_FemSolver->GetSolution(dof)<GetInput()->GetNode(i); //itk::fem::Element::Node::Pointer node= m_Fem3dSolver->GetInput()->GetNode(i); for(unsigned int j= 0; j< 3; j++) { std::cout<<"FEM Mesh Solution Vector: "<GetSolution(node->GetDegreeOfFreedom(j))<GetCoordinates()[j] + m_FemSolver->GetSolution(node->GetDegreeOfFreedom(j)); //replacedNodeVector[j] = node->GetCoordinates()[j] + m_ls->GetSolutionValue(node->GetDegreeOfFreedom(j)); } node->SetCoordinates(replacedNodeVector); std::cout<<"FEM Mesh New Node: "<< node->GetGlobalNumber() << " Coordinates: "<< node->GetCoordinates()<GetCoordinates()[j] + m_FemSolver->GetSolution(node->GetDegreeOfFreedom(j)); In my test application, I apply some force at node 1( loadNode->SetNode(1); ) but in generated solution it shows that the force doesn?t act on node 1 and nodes around it but for nodes 68, 69, 82, and 83. All the other solutions are zero. My test mesh contains 86 nodes and 162 elements. If I want to apply the force except node 1,eg at node 20, I get then segmentation fault.typedef itk::fem::LoadNode LoadNodeType; LoadNodeType::Pointer loadNode= LoadNodeType::New(); loadNode->SetElement(tetrahedronElement.GetPointer()); loadNode->SetGlobalNumber(3); loadNode->SetNode(1); vnl_vector force(3); force[0]= 110.0; force[1]= 20.0; force[2]= 31.0; loadNode->SetForce(force); m_FemObject->AddNextLoad(loadNode); For detailed information please see runnable test code:vtkUGridToFemMesh.zip | | | | | | | | | | | vtkUGridToFemMesh.zip Shared with Dropbox | | | | Thank you for any help! -------------- next part -------------- An HTML attachment was scrubbed... URL: From e.a.g.pfaehler at umcg.nl Tue Nov 21 10:12:44 2017 From: e.a.g.pfaehler at umcg.nl (Pfaehler, EAG (ngmb)) Date: Tue, 21 Nov 2017 15:12:44 +0000 Subject: [ITK-dev] Problem calculating oriented bounding box, itk::ShapeLabelObject Message-ID: Dear all, I need the size of the oriented bounding box of a mask. I created a shape label object and extracted already some attributes (like nr. of pixels etc), what works pretty fine. Now I wanted to get the size of the oriented bounding box. But whatever I do and no matter which object I use, I always get the result [0, 0, 0] Is there a trick? Thanks a lot for your answer. Regards Elli My code: typedef itk::CastImageFilter CastFilterType; typedef itk::CastImageFilter uCharCastFilterType; typedef itk::ConnectedComponentImageFilter ConnectedComponentFilterType; typedef itk::LabelImageToShapeLabelMapFilter LabelImageToShapeLabelMapFilterType; typedef int LabelType; typedef itk::ShapeLabelObject ShapeLabelObjectType; typedef itk::LabelMap LabelMapType; typename ConnectedComponentFilterType::Pointer connectedComponentImageFilter = ConnectedComponentFilterType::New(); connectedComponentImageFilter->SetInput(castFilter->GetOutput()); connectedComponentImageFilter->Update(); /*! With the label image to shape label map filter the mask is converted to a labeled image */ typename LabelImageToShapeLabelMapFilterType::Pointer labelImageToShapeLabelMapFilter = LabelImageToShapeLabelMapFilterType::New(); labelImageToShapeLabelMapFilter->SetInput(connectedComponentImageFilter->GetOutput()); labelImageToShapeLabelMapFilter->SetComputePerimeter(true); labelImageToShapeLabelMapFilter->Update(); LabelMapType *labelMap = labelImageToShapeLabelMapFilter->GetOutput(); labelMap->Update(); /*! For every connected component a labelObject is created Because we are only interested in the object with the label one, we check the label number */ for(unsigned int n = 0; n < labelMap->GetNumberOfLabelObjects(); n++){ ShapeLabelObjectType *labelObject = labelMap->GetNthLabelObject(n); int labelNr = labelObject->GetLabel(); if(labelNr ==1){ #ifdef _WIN32 volume = labelObject->GetPhysicalSize(); principalMoments = labelObject->GetPrincipalMoments(); nrPixels = labelObject->GetNumberOfPixels(); surface = labelObject->GetNumberOfPixelsOnBorder()*imageSpacingX*imageSpacingY*imageSpacingZ; std::cout << "nr Pixels border" << labelObject->GetOrientedBoundingBoxOrigin() << std::endl; ________________________________ De inhoud van dit bericht is vertrouwelijk en alleen bestemd voor de geadresseerde(n). Anderen dan de geadresseerde(n) mogen geen gebruik maken van dit bericht, het niet openbaar maken of op enige wijze verspreiden of vermenigvuldigen. Het UMCG kan niet aansprakelijk gesteld worden voor een incomplete aankomst of vertraging van dit verzonden bericht. The contents of this message are confidential and only intended for the eyes of the addressee(s). Others than the addressee(s) are not allowed to use this message, to make it public or to distribute or multiply this message in any way. The UMCG cannot be held responsible for incomplete reception or delay of this transferred message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dzenanz at gmail.com Tue Nov 21 12:46:17 2017 From: dzenanz at gmail.com (=?UTF-8?B?RMW+ZW5hbiBadWtpxIc=?=) Date: Tue, 21 Nov 2017 12:46:17 -0500 Subject: [ITK-dev] Problem calculating oriented bounding box, itk::ShapeLabelObject In-Reply-To: References: Message-ID: Hi Elli, can you repost on discourse ? We have moved there. Regards, D?enan On Tue, Nov 21, 2017 at 10:12 AM, Pfaehler, EAG (ngmb) < e.a.g.pfaehler at umcg.nl> wrote: > Dear all, > > I need the size of the oriented bounding box of a mask. > I created a shape label object and extracted already some attributes (like > nr. of pixels etc), what works pretty fine. > Now I wanted to get the size of the oriented bounding box. But whatever I > do and no matter which object I use, I always get the result [0, 0, 0] > Is there a trick? > > Thanks a lot for your answer. > > Regards > > Elli > > My code: > > > typedef itk::CastImageFilter CastFilterType; > typedef itk::CastImageFilter > uCharCastFilterType; > typedef itk::ConnectedComponentImageFilter > ConnectedComponentFilterType; > typedef itk::LabelImageToShapeLabelMapFilter > LabelImageToShapeLabelMapFilterType; > > typedef int LabelType; > typedef itk::ShapeLabelObject ShapeLabelObjectType; > typedef itk::LabelMap LabelMapType; > typename ConnectedComponentFilterType::Pointer > connectedComponentImageFilter = ConnectedComponentFilterType::New(); > connectedComponentImageFilter->SetInput(castFilter->GetOutput()); > connectedComponentImageFilter->Update(); > /*! > With the label image to shape label map filter the mask is converted > to a labeled image > */ > typename LabelImageToShapeLabelMapFilterType::Pointer > labelImageToShapeLabelMapFilter = LabelImageToShapeLabelMapFilte > rType::New(); > labelImageToShapeLabelMapFilter->SetInput( > connectedComponentImageFilter->GetOutput()); > labelImageToShapeLabelMapFilter->SetComputePerimeter(true); > labelImageToShapeLabelMapFilter->Update(); > > LabelMapType *labelMap = labelImageToShapeLabelMapFilter->GetOutput(); > labelMap->Update(); > /*! > For every connected component a labelObject is created > Because we are only interested in the object with the label one, we > check the label number > */ > for(unsigned int n = 0; n < labelMap->GetNumberOfLabelObjects(); n++){ > ShapeLabelObjectType *labelObject = labelMap->GetNthLabelObject(n) > ; > int labelNr = labelObject->GetLabel(); > if(labelNr ==1){ > #ifdef _WIN32 > volume = labelObject->GetPhysicalSize(); > principalMoments = labelObject->GetPrincipalMoments(); > nrPixels = labelObject->GetNumberOfPixels(); > surface = labelObject->GetNumberOfPixelsOnBorder()* > imageSpacingX*imageSpacingY*imageSpacingZ; > std::cout << "nr Pixels border" << labelObject->GetOrientedBoundingBoxOrigin() > << std::endl; > ------------------------------ > De inhoud van dit bericht is vertrouwelijk en alleen bestemd voor de > geadresseerde(n). Anderen dan de geadresseerde(n) mogen geen gebruik maken > van dit bericht, het niet openbaar maken of op enige wijze verspreiden of > vermenigvuldigen. Het UMCG kan niet aansprakelijk gesteld worden voor een > incomplete aankomst of vertraging van dit verzonden bericht. > > The contents of this message are confidential and only intended for the > eyes of the addressee(s). Others than the addressee(s) are not allowed to > use this message, to make it public or to distribute or multiply this > message in any way. The UMCG cannot be held responsible for incomplete > reception or delay of this transferred message. > > The ITK community is transitioning from this mailing list to > discourse.itk.org. Please join us there! > ______________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Kitware offers ITK Training Courses, for more information visit: > http://kitware.com/products/protraining.php > > Please keep messages on-topic and check the ITK FAQ at: > http://www.itk.org/Wiki/ITK_FAQ > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/insight-developers > > -------------- next part -------------- An HTML attachment was scrubbed... URL: