Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
EllipsoidalInclusionPolyData.h
Go to the documentation of this file.
1/* This file is part of MoDELib, distributed under GNU GPL v2. */
2#ifndef model_EllipsoidalInclusionPolyData_H_
3#define model_EllipsoidalInclusionPolyData_H_
4
5#include <Eigen/Dense>
6#include <vtkAlgorithm.h>
7#include <vtkMatrix4x4.h>
8#include <vtkNew.h>
9#include <vtkPolyData.h>
10#include <vtkSmartPointer.h>
11#include <vtkSphereSource.h>
12#include <vtkTransform.h>
13#include <vtkTransformPolyDataFilter.h>
14
15namespace model
16{
17 inline vtkSmartPointer<vtkPolyData> ellipsoidalInclusionPolyData(
18 const Eigen::Vector3d& center, const Eigen::Matrix3d& axes)
19 {
20 vtkNew<vtkSphereSource> sphere;
21 sphere->SetRadius(1.0);
22 sphere->SetThetaResolution(32);
23 sphere->SetPhiResolution(33);
24 sphere->SetOutputPointsPrecision(vtkAlgorithm::DOUBLE_PRECISION);
25
26 // Columns of axes are the semiaxis vectors, including their lengths.
27 // Transforming a unit sphere directly avoids Euler-angle conventions.
28 vtkNew<vtkMatrix4x4> matrix;
29 matrix->Identity();
30 for(int i=0; i<3; ++i)
31 {
32 for(int j=0; j<3; ++j)
33 {
34 matrix->SetElement(i,j,axes(i,j));
35 }
36 matrix->SetElement(i,3,center(i));
37 }
38 vtkNew<vtkTransform> transform;
39 transform->SetMatrix(matrix);
40 vtkNew<vtkTransformPolyDataFilter> filter;
41 filter->SetTransform(transform);
42 filter->SetInputConnection(sphere->GetOutputPort());
43 filter->SetOutputPointsPrecision(vtkAlgorithm::DOUBLE_PRECISION);
44 filter->Update();
45 auto result=vtkSmartPointer<vtkPolyData>::New();
46 result->ShallowCopy(filter->GetOutput());
47 return result;
48 }
49}
50#endif
vtkSmartPointer< vtkPolyData > ellipsoidalInclusionPolyData(const Eigen::Vector3d &center, const Eigen::Matrix3d &axes)
M sphere(const V &r, double a, const M &e, double n=nu, double m=mu)
Eigen::MatrixXd matrix(const Form &form)
int j
int i
result