Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
GlidePlaneActor.cpp
Go to the documentation of this file.
1/* This file is part of MODEL, the Mechanics Of Defect Evolution Library.
2 *
3 * Copyright (C) 2011 by Giacomo Po <gpo@ucla.edu>.
4 *
5 * model is distributed without any warranty under the
6 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
7 */
8
9#ifndef model_GlidePlaneActor_cpp_
10#define model_GlidePlaneActor_cpp_
11
12#include <DislocationNetwork.h>
14#include <numbers>
15#include <vtkLine.h>
16#include <vtkPlanes.h>
17#include <vtkStructuredGrid.h>
18#include <vtkUnstructuredGrid.h>
19#include <vtkLookupTable.h>
20#include <vtkStructuredGridAppend.h>
21#include <vtkTableBasedClipDataSet.h>
22#include <vtkTriangle.h>
23#include <vtkCellData.h>
24
25#include <GlidePlaneActor.h>
26#include <Polygon2D.h>
27
28#include <DDqtControls.h>
29
30namespace model
31{
32
33 SingleGlidePlaneActor::SingleGlidePlaneActor(const std::shared_ptr<GlidePlane<3>>& glidePlane_in) :
34 /* init */ glidePlane(glidePlane_in)
35 {
36 if(glidePlane)
37 {
38 for(const auto& pb : glidePlane->grain.planeNormals())
39 {
40 if( (*pb.second+glidePlane->n).base().squaredNorm()==0
41 ||(*pb.second-glidePlane->n).base().squaredNorm()==0)
42 {
43 planeBase=pb.second;
44 break;
45 }
46 }
47 }
48 }
49
50 void SingleGlidePlaneActor::appendClosedPolygon(const std::vector<Eigen::Matrix<double,2,1>>& newPoints)
51 {
52 size_t nextPointID(points.size());
53
54 for(size_t k=0;k<newPoints.size();++k)
55 {
56
57 const auto iterK(uniquePointsIDs.find(newPoints[k]));
58 int kID(nextPointID);
59 if(iterK!=uniquePointsIDs.end())
60 {// newPoints[k] exists
61 kID=iterK->second;
62 }
63 else
64 {// newPoints[k] does not exists
65 points.emplace_back(newPoints[k]);
66 uniquePointsIDs.emplace(newPoints[k],nextPointID);
67 nextPointID++;
68 }
69
70 const size_t k1(k<newPoints.size()-1? k+1 : 0);
71 const auto iterK1(uniquePointsIDs.find(newPoints[k1]));
72 int k1ID(nextPointID);
73 if(iterK1!=uniquePointsIDs.end())
74 {// newPoints[k1] exists
75 k1ID=iterK1->second;
76 }
77 else
78 {// newPoints[k1] does not exists
79 points.emplace_back(newPoints[k1]);
80 uniquePointsIDs.emplace(newPoints[k1],nextPointID);
81 nextPointID++;
82 }
83
84 segments.emplace_back((Eigen::Matrix<int,2,1>()<<kID,k1ID).finished());
85 }
86
87 }
88
89 GlidePlaneActor::GlidePlaneActor(vtkGenericOpenGLRenderWindow* const renWin,vtkRenderer* const ren,DefectiveCrystal<3>& defectiveCrystal_in) :
90 /* init */ renderWindow(renWin)
91 /* init */,renderer(ren)
92 /* init */,defectiveCrystal(defectiveCrystal_in)
93 /* init */,dislocationNetwork(defectiveCrystal.template getUniqueTypedMicrostructure<DislocationNetwork<3>>())
94 /* init */,mainLayout(new QGridLayout(this))
95 /* init */,glidePlanesGroup(new controls::GroupBox(tr("&Planes")))
96 /* init */,lut(vtkSmartPointer<vtkLookupTable>::New())
97 /* init */,glidePlanesNoiseGroup(new controls::GroupBox(tr("&Noise")))
98 /* init */,noiseMeshSizeLabel(new QLabel("mesh size",this))
99 /* init */,noiseMeshSizeEdit(new QLineEdit("2.0"))
100 /* init */,grainNoiseLabel(new QLabel("grain",this))
101 /* init */,grainNoiseBox(new QComboBox(this))
102 /* init */,slipSystemNoiseBox(new QComboBox(this))
103 /* init */,glidePlanesNoiseBox(new QComboBox(this))
104 /* init */,ss1NoiseMin(new QLineEdit("0.0"))
105 /* init */,ss1NoiseMax(new QLineEdit("0.0"))
106 /* init */,ss2NoiseMin(new QLineEdit("0.0"))
107 /* init */,ss2NoiseMax(new QLineEdit("0.0"))
108 /* init */,sfNoiseMin(new QLineEdit("0.0"))
109 /* init */,sfNoiseMax(new QLineEdit("0.0"))
110 /* init */,noisePolydata(vtkSmartPointer<vtkPolyData>::New())
111 /* init */,noiseMapper(vtkSmartPointer<vtkDataSetMapper>::New())
112 /* init */,noiseActor(vtkSmartPointer<vtkActor>::New())
113 /* init */,stackingFaultGroup(new controls::GroupBox(tr("&Stacking Faults")))
114 /* init */,glidePlanePolydata(vtkSmartPointer<vtkPolyData>::New())
115 /* init */,glidePlaneMapper(vtkSmartPointer<vtkPolyDataMapper>::New())
116 /* init */,glidePlaneActor(vtkSmartPointer<vtkActor>::New())
117 /* init */,stackingFaultLut(vtkSmartPointer<vtkLookupTable>::New())
118 /* init */,sfeMinEdit(new QLineEdit("0.0"))
119 /* init */,sfeMaxEdit(new QLineEdit("0.5"))
120 /* init */,stackingFaultPolydata(vtkSmartPointer<vtkPolyData>::New())
121 /* init */,stackingFaultMapper(vtkSmartPointer<vtkPolyDataMapper>::New())
122 /* init */,stackingFaultActor(vtkSmartPointer<vtkActor>::New())
123 {
124
125 lut->SetHueRange(0.66667, 0.0);
126 lut->Build();
127
128 stackingFaultLut->SetHueRange(0.66667, 0.0);
129 stackingFaultLut->Build();
130
131 glidePlanesGroup->setCheckable(true);
132 glidePlanesGroup->setChecked(false);
133 glidePlaneActor->SetVisibility(false);
134
135 glidePlanesNoiseGroup->setCheckable(true);
136 glidePlanesNoiseGroup->setChecked(false);
137
138 stackingFaultGroup->setCheckable(true);
139 stackingFaultGroup->setChecked(false);
140 stackingFaultActor->SetVisibility(false);
141
142 for(const auto& pair : defectiveCrystal.ddBase.poly.grains)
143 {
144 grainNoiseBox->addItem(QString::fromStdString(std::to_string(pair.first)));
145 }
146
147 glidePlanesNoiseBox->addItem("solidSolution_1");
148 glidePlanesNoiseBox->addItem("solidSolution_2");
149 glidePlanesNoiseBox->addItem("stackingFault");
150 const auto& grain(defectiveCrystal.ddBase.poly.grains.begin()->second);
151 for(size_t k=0; k<grain->slipSystems().size();++k)
152 {
153 slipSystemNoiseBox->addItem(QString::fromStdString("slipSystem "+ std::to_string(k)));
154 }
155
156 QGridLayout *noiseLayout = new QGridLayout();
157 glidePlanesNoiseGroup->setLayout(noiseLayout);
158 noiseMeshSizeLabel->hide();
159 grainNoiseLabel->hide();
160 controls::field(noiseLayout, 0, "Mesh area", noiseMeshSizeEdit,
161 "Sampling mesh size for glide-plane noise. Press Enter to recompute.");
162 controls::field(noiseLayout, 1, "Grain", grainNoiseBox,
163 "Grain whose slip planes and noise fields are displayed.");
164 controls::field(noiseLayout, 2, "Slip system", slipSystemNoiseBox, "Slip system for the selected grain.");
165 controls::field(noiseLayout, 3, "Noise field", glidePlanesNoiseBox,
166 "Choose the solid-solution or stacking-fault noise component.");
167 controls::field(noiseLayout, 4, "SS1 minimum", ss1NoiseMin,
168 "Lower color-scale limit for solid-solution noise component 1. Press Enter to apply.");
169 controls::field(noiseLayout, 5, "SS1 maximum", ss1NoiseMax,
170 "Upper color-scale limit for solid-solution noise component 1. Press Enter to apply.");
171 controls::field(noiseLayout, 6, "SS2 minimum", ss2NoiseMin,
172 "Lower color-scale limit for solid-solution noise component 2. Press Enter to apply.");
173 controls::field(noiseLayout, 7, "SS2 maximum", ss2NoiseMax,
174 "Upper color-scale limit for solid-solution noise component 2. Press Enter to apply.");
175 controls::field(noiseLayout, 8, "SF minimum", sfNoiseMin,
176 "Lower color-scale limit for stacking-fault noise. Press Enter to apply.");
177 controls::field(noiseLayout, 9, "SF maximum", sfNoiseMax,
178 "Upper color-scale limit for stacking-fault noise. Press Enter to apply.");
179
180 QGridLayout *stackingFaultLayout = new QGridLayout();
181 controls::field(stackingFaultLayout, 0, "Minimum", sfeMinEdit,
182 "Lower stacking-fault energy color-scale limit. Press Enter to apply.");
183 controls::field(stackingFaultLayout, 1, "Maximum", sfeMaxEdit,
184 "Upper stacking-fault energy color-scale limit. Press Enter to apply.");
185
186 stackingFaultGroup->setLayout(stackingFaultLayout);
187
188
189 mainLayout->addWidget(glidePlanesGroup,0,0,1,1);
190 mainLayout->addWidget(glidePlanesNoiseGroup,1,0,1,1);
191 mainLayout->addWidget(stackingFaultGroup,2,0,1,1);
192
193 glidePlanesGroup->setToolTip(
194 "Show or hide the glide planes associated with the current dislocation configuration.");
195 glidePlanesNoiseGroup->setToolTip("Show or hide sampled noise on the selected grain and slip system.");
196 stackingFaultGroup->setToolTip("Show or hide stacking-fault energy on glide planes.");
197 mainLayout->setRowStretch(3, 1);
198 this->setLayout(mainLayout);
199 connect(glidePlanesGroup,SIGNAL(toggled(bool)), this, SLOT(modify()));
200 connect(glidePlanesNoiseGroup,SIGNAL(toggled(bool)), this, SLOT(modify()));
201 connect(stackingFaultGroup,SIGNAL(toggled(bool)), this, SLOT(modify()));
202
203 connect(glidePlanesNoiseBox,SIGNAL(currentIndexChanged(int)), this, SLOT(modify()));
204 connect(slipSystemNoiseBox,SIGNAL(currentIndexChanged(int)), this, SLOT(computeGlidePlaneNoise()));
205 connect(ss1NoiseMin,SIGNAL(returnPressed()), this, SLOT(modify()));
206 connect(ss1NoiseMax,SIGNAL(returnPressed()), this, SLOT(modify()));
207 connect(ss2NoiseMin,SIGNAL(returnPressed()), this, SLOT(modify()));
208 connect(ss2NoiseMax,SIGNAL(returnPressed()), this, SLOT(modify()));
209 connect(sfNoiseMin,SIGNAL(returnPressed()), this, SLOT(modify()));
210 connect(sfNoiseMax,SIGNAL(returnPressed()), this, SLOT(modify()));
211 connect(noiseMeshSizeEdit,SIGNAL(returnPressed()), this, SLOT(computeGlidePlaneNoise()));
212 connect(sfeMinEdit, &QLineEdit::returnPressed, this, &GlidePlaneActor::computeStackingFaults);
213 connect(sfeMaxEdit, &QLineEdit::returnPressed, this, &GlidePlaneActor::computeStackingFaults);
214
215 // GlidePlane boundaries
216 glidePlaneMapper->SetInputData(glidePlanePolydata);
217 glidePlaneActor->SetMapper(glidePlaneMapper);
218 glidePlaneActor->GetProperty()->SetColor(1.0, 0.0, 1.0); //(R,G,B)
219 renderer->AddActor(glidePlaneActor);
220
221 // GlidePlane noise
222 noisePolydata->Allocate();
223 noiseMapper->SetInputData(noisePolydata);
224 noiseActor->SetMapper ( noiseMapper );
225 noiseActor->GetProperty()->SetOpacity(0.8); //Make the mesh have some transparency.
226 renderer->AddActor(noiseActor);
227
228 // Stacking Faults
229 stackingFaultPolydata->Allocate();
230 stackingFaultMapper->SetInputData(stackingFaultPolydata);
231 stackingFaultActor->SetMapper ( stackingFaultMapper );
232 stackingFaultActor->GetProperty()->SetOpacity(0.8); //Make the mesh have some transparency.
233 renderer->AddActor(stackingFaultActor);
234 }
235
237 {
238 std::cout<<"Updating GlidePlanes..."<<std::flush;
239 const auto t0= std::chrono::system_clock::now();
241 computeGlidePlaneNoise();
243 std::cout<<magentaColor<<" ["<<(std::chrono::duration<double>(std::chrono::system_clock::now()-t0)).count()<<" sec]"<<defaultColor<<std::endl;
244 }
245
246 void GlidePlaneActor::computeGlidePlaneNoise()
247 {
248 if(dislocationNetwork && glidePlanesNoiseGroup->isChecked())
249 {
250 noiseValues.clear();
251 for(int k=0;k<3;++k)
252 {
253 valuesMinMax[k]=std::make_pair(std::numeric_limits<double>::max(),-std::numeric_limits<double>::max());
254 }
255 vtkSmartPointer<vtkPoints> meshPts(vtkSmartPointer<vtkPoints>::New());
256 vtkSmartPointer<vtkCellArray> meshTriangles(vtkSmartPointer<vtkCellArray>::New());
257 vtkSmartPointer<vtkUnsignedCharArray> meshColors(vtkSmartPointer<vtkUnsignedCharArray>::New());
258 meshColors->SetNumberOfComponents(3);
259
260 const size_t selectedGrainID(std::stoi(grainNoiseBox->currentText().toStdString()));
261 const auto& grain(defectiveCrystal.ddBase.poly.grain(selectedGrainID));
262 const size_t selectedSlipSystemID(slipSystemNoiseBox->currentIndex());
263 const auto& slipSystem(grain->slipSystems().at(selectedSlipSystemID));
264 const auto& planeNoise(slipSystem->planeNoise);
265
266 size_t nodeIDoffset(0);
267 double meshSize;
268 std::stringstream ssM(noiseMeshSizeEdit->text().toStdString());
269 if(ssM >> meshSize)
270 {
272 // reference palette colors directly
273 noiseMeshSizeEdit->setStyleSheet("background-color: palette(base)");
274
275 if(planeNoise)
276 {
277 for(const auto& weakGlidePlane : dislocationNetwork->ddBase.dislocationDynamics().glidePlaneFactory.glidePlanes())
278 {
279 if(!weakGlidePlane.second.expired())
280 {
281 const auto glidePlane(weakGlidePlane.second.lock());
282 const auto glidePlaneSlipSystems(glidePlane->slipSystems());
283
284 if(glidePlane->grain.grainID==selectedGrainID && glidePlaneSlipSystems.find(slipSystem)!=glidePlaneSlipSystems.end())
285 {
286 std::deque<Eigen::Matrix<double,2,1>> boundaryPts;
287 std::deque<Eigen::Matrix<double,2,1>> internalPts;
288 for(const auto& bndLine : glidePlane->meshIntersections)
289 {
290 boundaryPts.push_back(glidePlane->localPosition(bndLine->P0));
291 }
292 TriangularMesh triMesh;
293 triMesh.reMesh(boundaryPts,internalPts,meshSize,"pazq");
294
295 for(const auto& point2d : triMesh.vertices())
296 {
297 const auto point3d(glidePlane->globalPosition(point2d));
298 meshPts->InsertNextPoint(point3d(0),point3d(1),point3d(2));
299 noiseValues.push_back(planeNoise->gridInterp(point2d));
300
301 valuesMinMax[0]=std::make_pair(std::min(valuesMinMax[0].first,std::get<0>(noiseValues.back())),std::max(valuesMinMax[0].second,std::get<0>(noiseValues.back())));
302 valuesMinMax[1]=std::make_pair(std::min(valuesMinMax[1].first,std::get<1>(noiseValues.back())),std::max(valuesMinMax[1].second,std::get<1>(noiseValues.back())));
303 valuesMinMax[2]=std::make_pair(std::min(valuesMinMax[2].first,std::get<2>(noiseValues.back())),std::max(valuesMinMax[2].second,std::get<2>(noiseValues.back())));
304 }
305
306 ss1NoiseMin->setText(QString::number((valuesMinMax[0].first)));
307 ss1NoiseMax->setText(QString::number((valuesMinMax[0].second)));
308 ss2NoiseMin->setText(QString::number((valuesMinMax[1].first)));
309 ss2NoiseMax->setText(QString::number((valuesMinMax[1].second)));
310 sfNoiseMin->setText(QString::number((valuesMinMax[2].first)));
311 sfNoiseMax->setText(QString::number((valuesMinMax[2].second)));
312
313 for(const auto& tri : triMesh.triangles())
314 {
315 vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
316 triangle->GetPointIds()->SetId (0,tri(0)+nodeIDoffset);
317 triangle->GetPointIds()->SetId (1,tri(1)+nodeIDoffset);
318 triangle->GetPointIds()->SetId (2,tri(2)+nodeIDoffset);
319 meshTriangles->InsertNextCell ( triangle );
320 const auto triColor(Eigen::Matrix<int,1,3>::Random()*255);
321 meshColors->InsertNextTuple3(triColor(0),triColor(1),triColor(2)); // use this to assig color to each vertex
322 }
323 nodeIDoffset += triMesh.vertices().size();
324 }
325 }
326 }
327 }
328 }
329 else
330 {
331 noiseMeshSizeEdit->setStyleSheet("background-color: red");
332 }
333
334 noisePolydata->SetPoints ( meshPts );
335 noisePolydata->SetPolys ( meshTriangles );
336 noisePolydata->GetCellData()->SetScalars(meshColors);
337 noiseMapper->SetScalarModeToUseCellData();
338 noisePolydata->Modified();
339 modify();
340 }
341 }
342
344{
345 if(dislocationNetwork && stackingFaultGroup->isChecked())
346 {
347 double sfeMin;
348 std::stringstream ssMin(sfeMinEdit->text().toStdString());
349 if(ssMin >> sfeMin)
350 {
351 //sfeMinEdit->setStyleSheet("background-color: white");
352 // reference palette colors directly
353 sfeMinEdit->setStyleSheet("background-color: palette(base)");
354 double sfeMax;
355 std::stringstream ssMax(sfeMaxEdit->text().toStdString());
356 if(ssMax >> sfeMax)
357 {
358 //sfeMaxEdit->setStyleSheet("background-color: white");
359 // reference palette colors directly
360 sfeMaxEdit->setStyleSheet("background-color: palette(base)");
361
362 stackingFaultLut->SetTableRange(sfeMin, sfeMax);
363 double dclr[3];
364 unsigned char cclr[3];
365
366 std::map<LatticePlaneKey<3>,SingleGlidePlaneActor> singleGlidePlaneMap;
367 for(auto& loop : dislocationNetwork->loops())
368 {
369 for(const auto& pair : loop.second.lock()->patches().localPatches())
370 {
371 const auto& glidePlane(pair.first->glidePlane);
372 const auto& key(glidePlane->key);
373 const auto glidePlaneIter(singleGlidePlaneMap.find(key));
374 if(glidePlaneIter!=singleGlidePlaneMap.end())
375 {// glide plane found
376 if(glidePlaneIter->second.planeBase)
377 {
378 if(glidePlaneIter->second.planeBase->gammaSurface)
379 {
380 glidePlaneIter->second.appendClosedPolygon(pair.second);
381 }
382 }
383 }
384 else
385 {// glide plane not found
386 const auto success(singleGlidePlaneMap.emplace(std::piecewise_construct,
387 std::forward_as_tuple(key),
388 std::forward_as_tuple(glidePlane)));
389 if(success.second)
390 {
391 if(success.first->second.planeBase)
392 {
393 if(success.first->second.planeBase->gammaSurface)
394 {
395 success.first->second.appendClosedPolygon(pair.second);
396 }
397 }
398 }
399 else
400 {
401 throw std::runtime_error("Cannot insert glide plane in singleGlidePlaneMap");
402 }
403 }
404 }
405 }
406
407 vtkSmartPointer<vtkPoints> meshPts(vtkSmartPointer<vtkPoints>::New());
408 vtkSmartPointer<vtkCellArray> meshTriangles(vtkSmartPointer<vtkCellArray>::New());
409 vtkSmartPointer<vtkUnsignedCharArray> meshColors(vtkSmartPointer<vtkUnsignedCharArray>::New());
410 meshColors->SetNumberOfComponents(3);
411
412 size_t numVertices(0);
413 for(auto& pair : singleGlidePlaneMap)
414 {
415 if(pair.second.planeBase)
416 {
417 if(pair.second.planeBase->gammaSurface)
418 {
419 TriangularMesh triMesh;
420 triMesh.reMesh(pair.second.points,pair.second.segments,100000.0,"pz");
421
422 for(const auto& point2d : triMesh.vertices())
423 {
424 const auto point3d(pair.second.glidePlane->globalPosition(point2d));
425 meshPts->InsertNextPoint(point3d(0),point3d(1),point3d(2));
426 }
427
428 for(const auto& tri : triMesh.triangles())
429 {
430 vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
431 triangle->GetPointIds()->SetId (0,tri(0)+numVertices);
432 triangle->GetPointIds()->SetId (1,tri(1)+numVertices);
433 triangle->GetPointIds()->SetId (2,tri(2)+numVertices);
434
435 //const Eigen::Vector3d bary3(Eigen::Vector3d())
436
437 const Eigen::Vector2d triCenter((triMesh.vertices()[tri(0)]+triMesh.vertices()[tri(1)]+triMesh.vertices()[tri(2)])/3.0);
438 Eigen::Vector3d slip(Eigen::Vector3d::Zero());
439 for(auto& loop : dislocationNetwork->loops())
440 {
441 slip-=loop.second.lock()->patches().windingNumber(triCenter,pair.second.glidePlane)*loop.second.lock()->burgers();
442 }
443 const double sfe(pair.second.planeBase->misfitEnergy(slip)*defectiveCrystal.ddBase.poly.b_SI*defectiveCrystal.ddBase.poly.mu_SI);
444// std::cout<<"sfe="<<sfe<<std::endl;
445 if(std::fabs(sfe)>FLT_EPSILON)
446 {
447 meshTriangles->InsertNextCell ( triangle );
448
449 stackingFaultLut->GetColor(sfe, dclr);
450 for(unsigned int j = 0; j < 3; j++)
451 {
452 cclr[j] = static_cast<unsigned char>(255.0 * dclr[j]);
453 }
454// noiseColors->InsertNextTypedTuple(cclr);
455 meshColors->InsertNextTuple3(cclr[0],cclr[1],cclr[2]); // use this to assig color to each triangle
456
457
458// const auto triColor(Eigen::Matrix<int,1,3>::Random()*255);
459// meshColors->InsertNextTuple3(cclr[0],cclr[0],triColor(2)); // use this to assig color to each vertex
460 }
461 }
462 numVertices+=triMesh.vertices().size();
463 }
464 }
465
466 }
467
468 stackingFaultPolydata->SetPoints ( meshPts );
469 stackingFaultPolydata->SetPolys ( meshTriangles );
470 stackingFaultPolydata->GetCellData()->SetScalars(meshColors);
471 stackingFaultPolydata->Modified();
472 stackingFaultMapper->SetScalarModeToUseCellData();
473
474 }
475 else
476 {
477 sfeMaxEdit->setStyleSheet("background-color: red");
478 }
479 }
480 else
481 {
482 sfeMinEdit->setStyleSheet("background-color: red");
483 }
484 }
485}
486
488 {
489 if(dislocationNetwork)
490 {
491 vtkSmartPointer<vtkPoints> glidePlanePoints = vtkSmartPointer<vtkPoints>::New();
492 vtkSmartPointer<vtkCellArray> glidePlaneCells(vtkSmartPointer<vtkCellArray>::New());
493 size_t pointIDs(0);
494 for(const auto& weakGlidePlane : dislocationNetwork->ddBase.dislocationDynamics().glidePlaneFactory.glidePlanes())
495 {
496 if(!weakGlidePlane.second.expired())
497 {
498 const auto glidePlane(weakGlidePlane.second.lock());
499 const auto& grain(glidePlane->grain);
500 if(glidePlane->slipSystems().size())
501 {
502
503 // Plot intersections with mesh
504 for(const auto& mshInt : glidePlane->meshIntersections)
505 {
506 glidePlanePoints->InsertNextPoint(mshInt->P0.data());
507
508 glidePlanePoints->InsertNextPoint(mshInt->P1.data());
509
510 vtkSmartPointer<vtkLine> line(vtkSmartPointer<vtkLine>::New());
511 line->GetPointIds()->SetId(0, pointIDs); // the second 0 is the index of the Origin in linesPolyData's points
512 line->GetPointIds()->SetId(1, pointIDs+1);
513 glidePlaneCells->InsertNextCell(line);
514 pointIDs+=2;
515 }
516 }
517 }
518 }
519 glidePlanePolydata->SetPoints(glidePlanePoints);
520 glidePlanePolydata->SetLines(glidePlaneCells);
521 glidePlanePolydata->Modified();
522 }
523 }
524
525 void GlidePlaneActor::modify()
526 {
527 glidePlaneActor->SetVisibility(glidePlanesGroup->isChecked());
528 stackingFaultActor->SetVisibility(stackingFaultGroup->isChecked());
529 noiseActor->SetVisibility(glidePlanesNoiseGroup->isChecked());
530
531 if(glidePlanesNoiseGroup->isChecked())
532 {
533 vtkSmartPointer<vtkUnsignedCharArray> noiseColors(vtkSmartPointer<vtkUnsignedCharArray>::New());
534 noiseColors->SetNumberOfComponents(3);
535 double val(0.0);
536 double dclr[3];
537 unsigned char cclr[3];
538 lut->SetTableRange(valuesMinMax[glidePlanesNoiseBox->currentIndex()].first, valuesMinMax[glidePlanesNoiseBox->currentIndex()].second);
539 //SetScalarRange(ss1NoiseMin->text().toDouble(), ss1NoiseMax->text().toDouble());
540
541 for(const auto& tup : noiseValues)
542 {
543 switch (glidePlanesNoiseBox->currentIndex())
544 {
545 case 0:
546 val=std::get<0>(tup);
547 break;
548 case 1:
549 val=std::get<1>(tup);
550 break;
551 case 2:
552 val=std::get<2>(tup);
553 break;
554 default:
555 break;
556 }
557
558 lut->GetColor(val, dclr);
559 for(unsigned int j = 0; j < 3; j++)
560 {
561 cclr[j] = static_cast<unsigned char>(255.0 * dclr[j]);
562 }
563 noiseColors->InsertNextTypedTuple(cclr);
564 }
565
566 noisePolydata->GetPointData()->SetScalars(noiseColors);
567 noisePolydata->Modified();
568 noiseMapper->SetScalarModeToUsePointData();
569 }
570
571 renderWindow->Render();
572 }
573
574}
575#endif
void reMesh(const std::deque< Eigen::Matrix< double, 2, 1 > > &boundaryPts, const std::deque< Eigen::Matrix< double, 2, 1 > > &internalPts, const double &meshSize, const std::string &flags)
std::deque< Eigen::Vector2d > & vertices()
std::deque< Eigen::Vector3i > & triangles()
void field(QGridLayout *layout, int row, const QString &title, QWidget *input, const QString &description)
size_t InstanceCount< Derived >::count
static std::string magentaColor
static std::string defaultColor
const Polycrystal< dim > & poly
GlidePlaneActor(vtkGenericOpenGLRenderWindow *const, vtkRenderer *const, DefectiveCrystal< 3 > &defectiveCrystal_in)
DefectiveCrystalBase< dim > & ddBase
std::map< Eigen::Matrix< double, 2, 1 >, int, CompareType > uniquePointsIDs
std::vector< Eigen::Matrix< int, 2, 1 > > segments
std::vector< Eigen::Matrix< double, 2, 1 > > points
void appendClosedPolygon(const std::vector< Eigen::Matrix< double, 2, 1 > > &newPoints)
SingleGlidePlaneActor(const std::shared_ptr< GlidePlane< 3 > > &glidePlane_in)
std::shared_ptr< GlidePlaneBase > planeBase
const std::shared_ptr< GlidePlane< 3 > > & glidePlane
newotri tri
int j
REAL ** triangle
Definition triangle.cpp:508
REAL t0
int k
REAL pb
enum insertvertexresult success
newbad key
vertex first