53 std::cout<<
"Updating inclusions..."<<std::flush;
54 const auto t0= std::chrono::system_clock::now();
57 vtkNew<vtkPolyData> emptyEllipsoids;
58 ellipsoidalMapper->SetInputData(emptyEllipsoids);
59 vtkNew<vtkAppendPolyData> ellipsoids;
65 vtkSmartPointer<vtkPoints> points(vtkSmartPointer<vtkPoints>::New());
66 vtkSmartPointer<vtkFloatArray> diameters(vtkSmartPointer<vtkFloatArray>::New());
67 vtkSmartPointer<vtkFloatArray> colors(vtkSmartPointer<vtkFloatArray>::New());
68 diameters->SetName(
"diameters");
69 colors->SetName(
"colors");
71 vtkNew<vtkUnstructuredGrid> ugrid;
72 vtkNew<vtkPoints> polyhedronPoints;
74 std::vector<vtkIdType> polyhedronPointsIDs(
inclusions->polyhedronInclusionNodes().size());
76 for(
const auto& node :
inclusions->polyhedronInclusionNodes())
78 polyhedronPoints->InsertNextPoint(node.second.P.data());
79 polyhedronPointsIDs[
k]=
k;
82 ugrid->SetPoints(polyhedronPoints);
85 for(
const auto& inclusion :
inclusions->eshelbyInclusions())
91 points->InsertNextPoint(sphericalDerived->C(0), sphericalDerived->C(1), sphericalDerived->C(2));
92 diameters->InsertNextValue(2.0*sphericalDerived->a);
93 colors->InsertNextValue(sphericalDerived->phaseID);
97 if(ellipsoidalDerived)
100 ellipsoidalDerived->C,ellipsoidalDerived->axes));
104 if (polyhedronDerived)
108 vtkNew<vtkIdList> faces;
119 for(
const auto& facePair : polyhedronDerived->faces)
121 faces->InsertNextId(facePair.second.size());
123 for(
const auto& vertexPair : facePair.second)
125 faces->InsertNextId(vertexPair.first);
128 ugrid->InsertNextCell(VTK_POLYHEDRON,
inclusions->polyhedronInclusionNodes().size(), polyhedronPointsIDs.data(), polyhedronDerived->faces.size(), faces->GetPointer(0));
140 grid->SetPoints(points);
141 grid->GetPointData()->AddArray(diameters);
142 grid->GetPointData()->SetActiveScalars(
"diameters");
143 grid->GetPointData()->AddArray(colors);
181 polyhedronMapper->SetInputData(ugrid);
182 if(ellipsoids->GetNumberOfInputConnections(0)>0)
184 ellipsoids->Update();
185 ellipsoidalMapper->SetInputData(ellipsoids->GetOutput());
194 ,mainLayout(new QGridLayout(this))
195 ,showInclusions(new QCheckBox(this))
196 ,sliderInclusionOpacity(new QSlider(this))
197 ,grid(vtkSmartPointer<vtkUnstructuredGrid>::New())
198 ,sphereSource(vtkSmartPointer<vtkSphereSource>::New())
199 ,glyph3D(vtkSmartPointer<vtkGlyph3D>::New())
200 ,mapper(vtkSmartPointer<vtkPolyDataMapper>::New())
201 ,actor(vtkSmartPointer<vtkActor>::New())
202 ,lookUpColors(vtkSmartPointer<vtkLookupTable>::New())
203 ,ellipsoidalMapper(vtkSmartPointer<vtkPolyDataMapper>::New())
204 ,ellipsoidalActor(vtkSmartPointer<vtkActor>::New())
205 ,polyhedronMapper(vtkSmartPointer<vtkDataSetMapper>::New())
206 ,polyhedronActor(vtkSmartPointer<vtkActor>::New())
210 showInclusions->setChecked(
true);
211 showInclusions->setText(
"show inclusions");
213 controls::box(
"Inclusions",
this,
"Show spherical, ellipsoidal and polyhedral inclusions.", showInclusions);
214 mainLayout->addWidget(inclusionBox, 0, 0);
215 mainLayout->setRowStretch(1, 1);
216 this->setLayout(mainLayout);
217 connect(showInclusions,SIGNAL(stateChanged(
int)),
this, SLOT(modify()));
219 sliderInclusionOpacity->setMinimum(0);
220 sliderInclusionOpacity->setMaximum(10);
221 sliderInclusionOpacity->setValue(5);
222 sliderInclusionOpacity->setOrientation(Qt::Horizontal);
223 connect(sliderInclusionOpacity,SIGNAL(valueChanged(
int)),
this, SLOT(modify()));
225 "Set inclusion opacity from transparent (0) to opaque (10).");
227 sphereSource->SetPhiResolution(20);
228 sphereSource->SetThetaResolution(20);
229 glyph3D->SetInputData(grid);
230 glyph3D->SetSourceConnection(sphereSource->GetOutputPort());
231 mapper->SetInputConnection(glyph3D->GetOutputPort());
232 mapper->ScalarVisibilityOff();
233 actor->GetProperty()->SetColor(0.5,0.5,0.5);
234 actor->GetProperty()->SetOpacity(0.4);
235 actor->SetMapper(mapper);
237 ellipsoidalMapper->ScalarVisibilityOff();
238 vtkNew<vtkPolyData> emptyEllipsoids;
239 ellipsoidalMapper->SetInputData(emptyEllipsoids);
240 ellipsoidalActor->SetMapper(ellipsoidalMapper);
241 ellipsoidalActor->GetProperty()->SetColor(0.5,0.5,0.5);
242 ellipsoidalActor->GetProperty()->SetOpacity(0.4);
246 vtkNew<vtkUnstructuredGrid> emptyPolyhedra;
247 polyhedronMapper->SetInputData(emptyPolyhedra);
248 polyhedronActor->SetMapper(polyhedronMapper);
249 polyhedronActor->GetProperty()->SetColor(0.5,0.5,0.5);
250 polyhedronActor->GetProperty()->SetOpacity(0.4);
252 renderer->AddActor(actor);
253 renderer->AddActor(ellipsoidalActor);
254 renderer->AddActor(polyhedronActor);