1 #include "createspecialmapping.h"
5 #include <vtkCharArray.h>
7 #include "smoothingutilities.h"
9 #include "swaptriangles.h"
10 #include "laplacesmoother.h"
11 #include "guimainwindow.h"
16 CreateSpecialMapping::CreateSpecialMapping()
21 int CreateSpecialMapping::Process()
24 for(i_iter
=0;i_iter
<NumberOfIterations
;i_iter
++)//TODO:Optimize this loop
26 cout
<<"===ITERATION NB "<<i_iter
<<"/"<<NumberOfIterations
<<"==="<<endl
;
28 m_total_N_newpoints
=0;
31 getAllSurfaceCells(m_AllCells
,m_grid
);
32 getSurfaceCells(m_bcs
, m_SelectedCells
, m_grid
);
33 cout
<<"m_AllCells.size()="<<m_AllCells
.size()<<endl
;
35 EG_VTKDCC(vtkIntArray
, cell_code
, m_grid
, "cell_code");
36 EG_VTKDCN(vtkDoubleArray
, node_meshdensity
, m_grid
, "node_meshdensity");
38 m_SelectedNodes
.clear();
39 getSurfaceNodes(m_bcs
,m_SelectedNodes
,m_grid
);
40 getNodesFromCells(m_AllCells
, nodes
, m_grid
);
44 cout
<<"m_AllCells.size()="<<m_AllCells
.size()<<endl
;
47 EG_VTKDCN(vtkCharArray
, node_type
, m_grid
, "node_type");
49 //Phase A : Calculate current mesh density
50 cout
<<"===Phase A==="<<endl
;
52 foreach(vtkIdType node
,m_SelectedNodes
)
54 VertexMeshDensity nodeVMD
= getVMD(node
,node_type
->GetValue(node
));
55 int idx
=VMDvector
.indexOf(nodeVMD
);
56 if(DebugLevel
>3) cout
<<"idx="<<idx
<<endl
;
57 if(idx
!=-1)//specified
59 node_meshdensity
->SetValue(node
, VMDvector
[idx
].density
);
63 double L
=CurrentVertexAvgDist(node
,n2n
,m_grid
);
65 node_meshdensity
->SetValue(node
, D
);
69 //Phase B : define desired mesh density
70 cout
<<"===Phase B==="<<endl
;
71 double diff
=Convergence_meshdensity
+1;
72 if(DebugLevel
>3) cout
<<"before loop: diff="<<diff
<<endl
;
77 if(DebugLevel
>2) cout
<<"--->diff="<<diff
<<endl
;
79 foreach(vtkIdType node
,m_SelectedNodes
)
81 if(DebugLevel
>2) cout
<<"======>"<<endl
;
82 VertexMeshDensity nodeVMD
= getVMD(node
,node_type
->GetValue(node
));
83 int idx
=VMDvector
.indexOf(nodeVMD
);
84 if(DebugLevel
>2) cout
<<"------>idx="<<idx
<<endl
;
85 if(idx
!=-1)//specified
87 node_meshdensity
->SetValue(node
, VMDvector
[idx
].density
);
91 double D
=DesiredMeshDensity(node
,n2n
,m_grid
);
94 cout
<<"------>FIRST:"<<endl
;
95 cout
<<"------>D="<<D
<<endl
;
96 cout
<<"------>node_meshdensity->GetValue("<<node
<<")="<<node_meshdensity
->GetValue(node
)<<endl
;
97 cout
<<"------>D-node_meshdensity->GetValue("<<node
<<")="<<D
-node_meshdensity
->GetValue(node
)<<endl
;
98 cout
<<"------>diff=abs(D-node_meshdensity->GetValue("<<node
<<"))="<<abs(D
-node_meshdensity
->GetValue(node
))<<endl
;
100 diff
=abs(D
-node_meshdensity
->GetValue(node
));
105 cout
<<"------>NOT FIRST:"<<endl
;
106 cout
<<"------>D="<<D
<<endl
;
107 cout
<<"------>node_meshdensity->GetValue("<<node
<<")="<<node_meshdensity
->GetValue(node
)<<endl
;
108 cout
<<"------>D-node_meshdensity->GetValue("<<node
<<")="<<D
-node_meshdensity
->GetValue(node
)<<endl
;
109 cout
<<"------>diff=abs(D-node_meshdensity->GetValue("<<node
<<"))="<<abs(D
-node_meshdensity
->GetValue(node
))<<endl
;
110 cout
<<"------>diff="<<diff
<<endl
;
111 cout
<<"------>max(abs(D-node_meshdensity->GetValue("<<node
<<")),diff)="<<max(abs(D
-node_meshdensity
->GetValue(node
)),diff
)<<endl
;
113 diff
=max(abs(D
-node_meshdensity
->GetValue(node
)),diff
);
115 node_meshdensity
->SetValue(node
, D
);
117 if(DebugLevel
>2) cout
<<"======>"<<endl
;
120 } while(diff
>Convergence_meshdensity
&& !first
&& iter
<maxiter
);// if first=true, it means no new mesh density has been defined (all densities specified)
121 cout
<<"iter="<<iter
<<endl
;
122 if(iter
>=maxiter
) cout
<<"WARNING: Desired convergence factor has not been reached!"<<endl
;
124 //Phase C: Prepare edge_map
125 cout
<<"===Phase C==="<<endl
;
128 foreach(vtkIdType node1
,m_SelectedNodes
)
130 // cout<<"node1="<<node1<<endl;
131 foreach(vtkIdType node2
,n2n
[node1
])
133 if(edge_map
[OrderedPair(node1
,node2
)]==0) { //this edge hasn't been numbered yet
134 edge_map
[OrderedPair(node1
,node2
)]=edgeId
;edgeId
++;
138 cout
<<"edge_map.size()="<<edge_map
.size()<<endl
;
140 //Phase D: edit points
141 cout
<<"===Phase D==="<<endl
;
151 /* if(insert_FP) insert_FP_all();
152 if(insert_EP) insert_EP_all();
153 if(remove_FP) remove_FP_all();
154 if(remove_EP) remove_EP_all();*/
156 ofstream file1
,file2
,file3
,file4
;
161 /* file1.open ("file1.txt");
162 cout_grid(file1,m_grid,true,true,true,true);
168 /* file2.open ("file2.txt");
169 cout_grid(file2,m_grid,true,true,true,true);
175 /* file3.open ("file3.txt");
176 cout_grid(file3,m_grid,true,true,true,true);
182 /* file4.open ("file4.txt");
183 cout_grid(file4,m_grid,true,true,true,true);
187 //Phase E : Delaunay swap
189 QSet
<int> bcs_complement
=complementary_bcs(m_bcs
,m_grid
,cells
);
190 cout
<<"m_bcs="<<m_bcs
<<endl
;
191 cout
<<"bcs_complement="<<bcs_complement
<<endl
;
194 swap
.setGrid(m_grid
);
195 swap
.setBoundaryCodes(bcs_complement
);
199 //Phase F : translate points to smooth grid
203 //laplacian smoothing with projection
204 //Roland smoothing with projection
206 //laplacian smoothing with projection
207 if(DoLaplaceSmoothing
) {
209 Lap
.SetInput(m_bcs
,m_grid
);
210 Lap
.SetNumberOfIterations(N_SmoothIterations
);
214 cout
<<"===Summary==="<<endl
;
215 cout
<<"N_inserted_FP="<<N_inserted_FP
<<endl
;
216 cout
<<"N_inserted_EP="<<N_inserted_EP
<<endl
;
217 cout
<<"N_removed_FP="<<N_removed_FP
<<endl
;
218 cout
<<"N_removed_EP="<<N_removed_EP
<<endl
;
220 cout
<<"N_points="<<N_points
<<endl
;
221 cout
<<"N_cells="<<N_cells
<<endl
;
222 cout
<<"m_total_N_newpoints="<<m_total_N_newpoints
<<endl
;
223 cout
<<"m_total_N_newcells="<<m_total_N_newcells
<<endl
;
224 cout
<<"============"<<endl
;
226 if(m_total_N_newpoints
==0 && m_total_N_newcells
==0) break;
230 cout
<<"i_iter/NumberOfIterations="<<i_iter
<<"/"<<NumberOfIterations
<<endl
;
236 VertexMeshDensity
CreateSpecialMapping::getVMD(vtkIdType node
, char VertexType
)
238 VertexMeshDensity VMD
;
241 VMD
.CurrentNode
=node
;
242 EG_VTKDCC(vtkIntArray
, cell_code
, m_grid
, "cell_code");
243 /* createNodeMapping(nodes, _nodes, m_grid);
244 createNodeToCell(m_AllCells, nodes, _nodes, n2c, m_grid);*/
247 foreach(vtkIdType C
, n2c
[node
])
249 bc
.insert(cell_code
->GetValue(C
));
251 VMD
.BClist
.resize(bc
.size());
252 qCopy(bc
.begin(),bc
.end(),VMD
.BClist
.begin());
253 qSort(VMD
.BClist
.begin(),VMD
.BClist
.end());
257 int CreateSpecialMapping::insert_FP_counter()
259 cout
<<"===insert_FP_counter() START==="<<endl
;
260 foreach(vtkIdType id_cell
, m_SelectedCells
)
262 if( !marked_cells
[id_cell
] && insert_fieldpoint(id_cell
) )
264 cout
<<"inserting a field point "<<id_cell
<<endl
;
266 marked_cells
[id_cell
]=true;
271 cout
<<"===insert_FP_counter() END==="<<endl
;
275 int CreateSpecialMapping::insert_EP_counter()
277 cout
<<"===insert_EP_counter() START==="<<endl
;
278 StencilVector
.clear();
279 QMapIterator
< pair
<vtkIdType
,vtkIdType
>, vtkIdType
> edge_map_iter(edge_map
);
280 //rewind the iterator
281 edge_map_iter
.toFront ();
283 while (edge_map_iter
.hasNext()) {
284 edge_map_iter
.next();
285 vtkIdType node1
=edge_map_iter
.key().first
;
286 vtkIdType node2
=edge_map_iter
.key().second
;
287 if(DebugLevel
>10) cout
<< "--->(" << node1
<< "," << node2
<< ")" << ": " << edge_map_iter
.value() << endl
;
288 QSet
<int> stencil_cells_set
;
289 QVector
<int> stencil_cells_vector
;
290 stencil_cells_set
=n2c
[node1
];
291 stencil_cells_set
.intersect(n2c
[node2
]);
292 if(DebugLevel
>10) cout
<<"stencil_cells_set="<<stencil_cells_set
<<endl
;
294 stencil_cells_vector
.resize(stencil_cells_set
.size());
295 qCopy(stencil_cells_set
.begin(),stencil_cells_set
.end(),stencil_cells_vector
.begin());
296 if(DebugLevel
>10) cout
<<"stencil_cells_vector="<<stencil_cells_vector
<<endl
;
298 vtkIdType id_cell
=stencil_cells_vector
[0];
299 int SideToSplit
= getSide(id_cell
,m_grid
,node1
,node2
);
300 if(DebugLevel
>10) cout
<<"SideToSplit="<<SideToSplit
<<endl
;
301 if(DebugLevel
>10) cout
<<"c2c[id_cell][SideToSplit]="<<c2c
[id_cell
][SideToSplit
]<<endl
;
302 if(DebugLevel
>10) for(int i
=0;i
<3;i
++) cout
<<"c2c[id_cell]["<<i
<<"]="<<c2c
[id_cell
][i
]<<endl
;
303 stencil_t S
=getStencil(id_cell
,SideToSplit
);
305 bool stencil_marked
=false;
306 foreach(vtkIdType C
,stencil_cells_vector
)
308 if(marked_cells
[C
]) stencil_marked
=true;
310 if(DebugLevel
>10) cout
<<"stencil_marked="<<stencil_marked
<<endl
;
311 if(DebugLevel
>10) cout
<<"insert_edgepoint(node1,node2)="<<insert_edgepoint(node1
,node2
)<<endl
;
313 if( !stencil_marked
&& insert_edgepoint(node1
,node2
) )
315 if(DebugLevel
>1) cout
<<"inserting an edge point "<< "(" << node1
<< "," << node2
<< ")" << ": " << edge_map_iter
.value() << endl
;
317 foreach(vtkIdType C
,stencil_cells_vector
) marked_cells
[C
]=true;
318 StencilVector
.push_back(S
);
320 if(stencil_cells_vector
.size()==2)//2 cells around the edge
325 else//1 cell around the edge
331 if(DebugLevel
>10) cout
<<"--->end of edge processing"<<endl
;
333 cout
<<"===insert_EP_counter() END==="<<endl
;
337 int CreateSpecialMapping::remove_FP_counter()
339 cout
<<"===remove_FP_counter() START==="<<endl
;
341 EG_VTKDCN(vtkCharArray
, node_type
, m_grid
, "node_type");
342 foreach(vtkIdType node
,m_SelectedNodes
)
344 if(node_type
->GetValue(node
)==VTK_SIMPLE_VERTEX
)
347 foreach(vtkIdType C
,n2c
[node
])
349 if(marked_cells
[C
]) marked
=true;
352 QSet
<vtkIdType
> DeadCells
;
353 QSet
<vtkIdType
> MutatedCells
;
354 QSet
<vtkIdType
> MutilatedCells
;
355 if( !marked
&& remove_fieldpoint(node
) && FindSnapPoint(m_grid
,node
,DeadCells
,MutatedCells
,MutilatedCells
)!=-1)
357 if(DebugLevel
>1) cout
<<"removing field point "<<node
<<endl
;
360 foreach(vtkIdType C
,n2c
[node
]) marked_cells
[C
]=true;
366 cout
<<"===remove_FP_counter() END==="<<endl
;
370 int CreateSpecialMapping::remove_EP_counter()
372 cout
<<"===remove_EP_counter() START==="<<endl
;
374 EG_VTKDCN(vtkCharArray
, node_type
, m_grid
, "node_type");
375 foreach(vtkIdType node
,m_SelectedNodes
)
377 if(node_type
->GetValue(node
)==VTK_BOUNDARY_EDGE_VERTEX
)
380 foreach(vtkIdType C
,n2c
[node
])
382 if(marked_cells
[C
]) marked
=true;
384 QSet
<vtkIdType
> DeadCells
;
385 QSet
<vtkIdType
> MutatedCells
;
386 QSet
<vtkIdType
> MutilatedCells
;
387 if( !marked
&& remove_edgepoint(node
) && FindSnapPoint(m_grid
,node
,DeadCells
,MutatedCells
,MutilatedCells
)!=-1)
389 cout
<<"removing edge point "<<node
<<endl
;
392 foreach(vtkIdType C
,n2c
[node
]) marked_cells
[C
]=true;
393 if(n2n
[node
].size()==4)//4 cells around the edge
398 else//2 cells around the edge
406 cout
<<"===remove_EP_counter() END==="<<endl
;
410 int CreateSpecialMapping::insert_FP_actor(vtkUnstructuredGrid
* grid_tmp
)
412 cout
<<"===insert_FP_actor START==="<<endl
;
414 EG_VTKDCC(vtkIntArray
, cell_code_tmp
, grid_tmp
, "cell_code");
415 foreach(vtkIdType id_cell
, m_SelectedCells
)
417 /* if(marked_cells[id_cell]) cout<<"--->marked_cells["<<id_cell<<"]=TRUE"<<endl;
418 else cout<<"--->marked_cells["<<id_cell<<"]=FALSE"<<endl;*/
420 if( !marked_cells
[id_cell
] && insert_fieldpoint(id_cell
) )
422 cout
<<"inserting a field point "<<id_cell
<<endl
;
423 vtkIdType newBC
=cell_code_tmp
->GetValue(id_cell
);
424 cout
<<"id_cell="<<id_cell
<<" newBC="<<newBC
<<endl
;
426 vtkIdType N_pts
, *pts
;
427 m_grid
->GetCellPoints(id_cell
, N_pts
, pts
);
430 int N_neighbours
=N_pts
;
431 cout
<<"N_neighbours="<<N_neighbours
<<endl
;
433 vtkIdType pts_triangle
[4][3];
434 for(int i
=0;i
<N_neighbours
;i
++)
436 m_grid
->GetPoints()->GetPoint(pts
[i
], corner
[i
].data());
439 C
=(1/(double)N_neighbours
)*C
;
440 addPoint(grid_tmp
,m_newNodeId
,C
.data());
441 vtkIdType intmidpoint
=m_newNodeId
;
444 for(int i
=0;i
<N_neighbours
;i
++)
446 pts_triangle
[i
][0]=pts
[i
];
447 pts_triangle
[i
][1]=pts
[(i
+1)%N_neighbours
];
448 pts_triangle
[i
][2]=intmidpoint
;
451 grid_tmp
->ReplaceCell(id_cell
, 3, pts_triangle
[0]);
452 cell_code_tmp
->SetValue(id_cell
, newBC
);
456 vtkIdType newCellId
= grid_tmp
->InsertNextCell(VTK_TRIANGLE
,3,pts_triangle
[i
]);
457 cell_code_tmp
->SetValue(newCellId
, newBC
);
463 cout
<<"===insert_FP_actor END==="<<endl
;
467 int CreateSpecialMapping::insert_EP_actor(vtkUnstructuredGrid
* grid_tmp
)
469 cout
<<"===insert_EP_actor START==="<<endl
;
471 EG_VTKDCC(vtkIntArray
, cell_code_tmp
, grid_tmp
, "cell_code");
472 foreach(stencil_t S
,StencilVector
)
474 if(DebugLevel
>10) cout
<<"S="<<S
<<endl
;
476 grid_tmp
->GetPoint(S
.p
[1],A
.data());
477 grid_tmp
->GetPoint(S
.p
[3],B
.data());
479 addPoint(grid_tmp
,m_newNodeId
,M
.data());
481 vtkIdType pts_triangle
[4][3];
483 if(S
.valid
){//there is a neighbour cell
484 if(DebugLevel
>10) cout
<<"marked_cells["<<S
.id_cell1
<<"]=true;"<<endl
;
485 if(DebugLevel
>10) cout
<<"marked_cells["<<S
.id_cell2
<<"]=true;"<<endl
;
486 marked_cells
[S
.id_cell1
]=true;
487 marked_cells
[S
.id_cell2
]=true;
491 pts_triangle
[i
][0]=S
.p
[i
];
492 pts_triangle
[i
][1]=S
.p
[(i
+1)%4];
493 pts_triangle
[i
][2]=m_newNodeId
;
496 int bc1
=cell_code_tmp
->GetValue(S
.id_cell1
);
497 int bc2
=cell_code_tmp
->GetValue(S
.id_cell2
);
499 grid_tmp
->ReplaceCell(S
.id_cell1
, 3, pts_triangle
[0]);
500 cell_code_tmp
->SetValue(S
.id_cell1
, bc1
);
502 grid_tmp
->ReplaceCell(S
.id_cell2
, 3, pts_triangle
[1]);
503 cell_code_tmp
->SetValue(S
.id_cell2
, bc2
);
506 newCellId
= grid_tmp
->InsertNextCell(VTK_TRIANGLE
,3,pts_triangle
[2]);
507 cell_code_tmp
->SetValue(newCellId
, bc2
);
508 newCellId
= grid_tmp
->InsertNextCell(VTK_TRIANGLE
,3,pts_triangle
[3]);
509 cell_code_tmp
->SetValue(newCellId
, bc1
);
511 else{//there is no neighbour cell
512 if(DebugLevel
>10) cout
<<"marked_cells["<<S
.id_cell1
<<"]=true;"<<endl
;
513 marked_cells
[S
.id_cell1
]=true;
515 pts_triangle
[0][0]=S
.p
[0];
516 pts_triangle
[0][1]=S
.p
[1];
517 pts_triangle
[0][2]=m_newNodeId
;
518 pts_triangle
[3][0]=S
.p
[3];
519 pts_triangle
[3][1]=S
.p
[0];
520 pts_triangle
[3][2]=m_newNodeId
;
522 int bc1
=cell_code_tmp
->GetValue(S
.id_cell1
);
524 grid_tmp
->ReplaceCell(S
.id_cell1
, 3, pts_triangle
[0]);
525 cell_code_tmp
->SetValue(S
.id_cell1
, bc1
);
528 newCellId
= grid_tmp
->InsertNextCell(VTK_TRIANGLE
,3,pts_triangle
[3]);
529 cell_code_tmp
->SetValue(newCellId
, bc1
);
534 cout
<<"===insert_EP_actor END==="<<endl
;
538 int CreateSpecialMapping::remove_FP_actor(vtkUnstructuredGrid
* grid_tmp
)
540 cout
<<"===remove_FP_actor START==="<<endl
;
542 foreach(vtkIdType node
,m_SelectedNodes
)
549 foreach(vtkIdType C
,n2c
[node
])
551 if(marked_cells
[C
]) marked
=true;
553 if( !marked
&& remove_fieldpoint(node
) )
555 if(DebugLevel
>1) cout
<<"removing field point "<<node
<<endl
;
556 foreach(vtkIdType C
,n2c
[node
]) marked_cells
[C
]=true;
557 //TODO: Special copy function, leaving out nodes to remove
560 cout
<<"===remove_FP_actor END==="<<endl
;
564 int CreateSpecialMapping::remove_EP_actor(vtkUnstructuredGrid
* grid_tmp
)
566 cout
<<"===remove_EP_actor START==="<<endl
;
568 foreach(vtkIdType node
,m_SelectedNodes
)
571 foreach(vtkIdType C
,n2c
[node
])
573 if(marked_cells
[C
]) marked
=true;
575 if( !marked
&& remove_edgepoint(node
) )
577 cout
<<"removing edge point "<<node
<<endl
;
578 foreach(vtkIdType C
,n2c
[node
]) marked_cells
[C
]=true;
579 if(n2n
[node
].size()==4)//4 cells around the edge
583 else//2 cells around the edge
589 cout
<<"===remove_EP_actor END==="<<endl
;
593 int CreateSpecialMapping::insert_FP_all()
595 cout
<<"===insert_FP_all START==="<<endl
;
597 getAllSurfaceCells(m_AllCells
,m_grid
);
598 getSurfaceCells(m_bcs
, m_SelectedCells
, m_grid
);
599 EG_VTKDCC(vtkIntArray
, cell_code
, m_grid
, "cell_code");
600 EG_VTKDCN(vtkDoubleArray
, node_meshdensity
, m_grid
, "node_meshdensity");
601 m_SelectedNodes
.clear();
602 getSurfaceNodes(m_bcs
,m_SelectedNodes
,m_grid
);
603 getNodesFromCells(m_AllCells
, nodes
, m_grid
);
605 setCells(m_AllCells
);
606 cout
<<"m_AllCells.size()="<<m_AllCells
.size()<<endl
;
610 N_points
=m_grid
->GetNumberOfPoints();
611 N_cells
=m_grid
->GetNumberOfCells();
615 marked_cells
.clear();
616 marked_nodes
.clear();
620 //unmark cells (TODO: optimize)
621 marked_cells
.clear();
623 N_points
=m_grid
->GetNumberOfPoints();
624 N_cells
=m_grid
->GetNumberOfCells();
625 cout
<<"N_points="<<N_points
<<endl
;
626 cout
<<"N_cells="<<N_cells
<<endl
;
627 cout
<<"N_newpoints="<<N_newpoints
<<endl
;
628 cout
<<"N_newcells="<<N_newcells
<<endl
;
629 EG_VTKSP(vtkUnstructuredGrid
,grid_tmp
);
630 allocateGrid(grid_tmp
,N_cells
+N_newcells
,N_points
+N_newpoints
);
631 m_total_N_newpoints
+=N_newpoints
; m_total_N_newcells
+=N_newcells
;
633 makeCopyNoAlloc(m_grid
, grid_tmp
);
634 //initialize new node counter
635 m_newNodeId
=N_points
;
637 insert_FP_actor(grid_tmp
);
639 makeCopy(grid_tmp
,m_grid
);
640 cout
<<"===insert_FP_all END==="<<endl
;
644 int CreateSpecialMapping::insert_EP_all()
646 cout
<<"===insert_EP_all START==="<<endl
;
648 getAllSurfaceCells(m_AllCells
,m_grid
);
649 getSurfaceCells(m_bcs
, m_SelectedCells
, m_grid
);
650 EG_VTKDCC(vtkIntArray
, cell_code
, m_grid
, "cell_code");
651 EG_VTKDCN(vtkDoubleArray
, node_meshdensity
, m_grid
, "node_meshdensity");
652 m_SelectedNodes
.clear();
653 getSurfaceNodes(m_bcs
,m_SelectedNodes
,m_grid
);
654 getNodesFromCells(m_AllCells
, nodes
, m_grid
);
656 setCells(m_AllCells
);
657 cout
<<"m_AllCells.size()="<<m_AllCells
.size()<<endl
;
661 N_points
=m_grid
->GetNumberOfPoints();
662 N_cells
=m_grid
->GetNumberOfCells();
666 marked_cells
.clear();
667 marked_nodes
.clear();
671 //unmark cells (TODO: optimize)
672 marked_cells
.clear();
674 N_points
=m_grid
->GetNumberOfPoints();
675 N_cells
=m_grid
->GetNumberOfCells();
676 cout
<<"N_points="<<N_points
<<endl
;
677 cout
<<"N_cells="<<N_cells
<<endl
;
678 cout
<<"N_newpoints="<<N_newpoints
<<endl
;
679 cout
<<"N_newcells="<<N_newcells
<<endl
;
680 EG_VTKSP(vtkUnstructuredGrid
,grid_tmp
);
681 allocateGrid(grid_tmp
,N_cells
+N_newcells
,N_points
+N_newpoints
);
682 m_total_N_newpoints
+=N_newpoints
; m_total_N_newcells
+=N_newcells
;
684 makeCopyNoAlloc(m_grid
, grid_tmp
);
685 //initialize new node counter
686 m_newNodeId
=N_points
;
688 insert_EP_actor(grid_tmp
);
690 makeCopy(grid_tmp
,m_grid
);
692 cout
<<"===insert_EP_all END==="<<endl
;
696 int CreateSpecialMapping::remove_FP_all()
698 cout
<<"===remove_FP_all START==="<<endl
;
700 getAllSurfaceCells(m_AllCells
,m_grid
);
701 getSurfaceCells(m_bcs
, m_SelectedCells
, m_grid
);
702 EG_VTKDCC(vtkIntArray
, cell_code
, m_grid
, "cell_code");
703 EG_VTKDCN(vtkDoubleArray
, node_meshdensity
, m_grid
, "node_meshdensity");
704 m_SelectedNodes
.clear();
705 getSurfaceNodes(m_bcs
,m_SelectedNodes
,m_grid
);
706 getNodesFromCells(m_AllCells
, nodes
, m_grid
);
708 setCells(m_AllCells
);
709 cout
<<"m_AllCells.size()="<<m_AllCells
.size()<<endl
;
713 N_points
=m_grid
->GetNumberOfPoints();
714 N_cells
=m_grid
->GetNumberOfCells();
718 hitlist
.resize(N_points
);
719 offset
.resize(N_points
);
721 marked_cells
.clear();
722 marked_nodes
.clear();
726 //unmark cells (TODO: optimize)
727 marked_cells
.clear();
729 N_points
=m_grid
->GetNumberOfPoints();
730 N_cells
=m_grid
->GetNumberOfCells();
731 cout
<<"N_points="<<N_points
<<endl
;
732 cout
<<"N_cells="<<N_cells
<<endl
;
733 cout
<<"N_newpoints="<<N_newpoints
<<endl
;
734 cout
<<"N_newcells="<<N_newcells
<<endl
;
735 EG_VTKSP(vtkUnstructuredGrid
,grid_tmp
);
736 allocateGrid(grid_tmp
,N_cells
+N_newcells
,N_points
+N_newpoints
);
737 m_total_N_newpoints
+=N_newpoints
; m_total_N_newcells
+=N_newcells
;
739 makeCopyNoAlloc(m_grid
, grid_tmp
);
740 //initialize new node counter
741 m_newNodeId
=N_points
;
743 remove_FP_actor(grid_tmp
);
745 makeCopy(grid_tmp
,m_grid
);
747 cout
<<"===remove_FP_all END==="<<endl
;
751 int CreateSpecialMapping::remove_EP_all()
753 cout
<<"===remove_EP_all START==="<<endl
;
755 getAllSurfaceCells(m_AllCells
,m_grid
);
756 getSurfaceCells(m_bcs
, m_SelectedCells
, m_grid
);
757 EG_VTKDCC(vtkIntArray
, cell_code
, m_grid
, "cell_code");
758 EG_VTKDCN(vtkDoubleArray
, node_meshdensity
, m_grid
, "node_meshdensity");
759 m_SelectedNodes
.clear();
760 getSurfaceNodes(m_bcs
,m_SelectedNodes
,m_grid
);
761 getNodesFromCells(m_AllCells
, nodes
, m_grid
);
763 setCells(m_AllCells
);
764 cout
<<"m_AllCells.size()="<<m_AllCells
.size()<<endl
;
768 N_points
=m_grid
->GetNumberOfPoints();
769 N_cells
=m_grid
->GetNumberOfCells();
773 hitlist
.resize(N_points
);
774 offset
.resize(N_points
);
776 marked_cells
.clear();
777 marked_nodes
.clear();
781 //unmark cells (TODO: optimize)
782 marked_cells
.clear();
784 N_points
=m_grid
->GetNumberOfPoints();
785 N_cells
=m_grid
->GetNumberOfCells();
786 cout
<<"N_points="<<N_points
<<endl
;
787 cout
<<"N_cells="<<N_cells
<<endl
;
788 cout
<<"N_newpoints="<<N_newpoints
<<endl
;
789 cout
<<"N_newcells="<<N_newcells
<<endl
;
790 EG_VTKSP(vtkUnstructuredGrid
,grid_tmp
);
791 allocateGrid(grid_tmp
,N_cells
+N_newcells
,N_points
+N_newpoints
);
792 m_total_N_newpoints
+=N_newpoints
; m_total_N_newcells
+=N_newcells
;
794 makeCopyNoAlloc(m_grid
, grid_tmp
);
795 //initialize new node counter
796 m_newNodeId
=N_points
;
798 remove_EP_actor(grid_tmp
);
800 makeCopy(grid_tmp
,m_grid
);
802 cout
<<"===remove_EP_all END==="<<endl
;
806 int CreateSpecialMapping::FullEdit()
808 cout
<<"===FullEdit START==="<<endl
;
815 N_points
=m_grid
->GetNumberOfPoints();
816 N_cells
=m_grid
->GetNumberOfCells();
820 hitlist
.resize(N_points
);
821 offset
.resize(N_points
);
823 marked_cells
.clear();
824 marked_nodes
.clear();
826 if(insert_FP
) insert_FP_counter();
827 if(insert_EP
) insert_EP_counter();
828 if(remove_FP
) remove_FP_counter();
829 if(remove_EP
) remove_EP_counter();
831 cout
<<"================="<<endl
;
832 cout
<<"hitlist="<<hitlist
<<endl
;
833 cout
<<"================="<<endl
;
835 //unmark cells (TODO: optimize)
836 marked_cells
.clear();
838 N_points
=m_grid
->GetNumberOfPoints();
839 N_cells
=m_grid
->GetNumberOfCells();
840 cout
<<"N_points="<<N_points
<<endl
;
841 cout
<<"N_cells="<<N_cells
<<endl
;
842 cout
<<"N_newpoints="<<N_newpoints
<<endl
;
843 cout
<<"N_newcells="<<N_newcells
<<endl
;
844 EG_VTKSP(vtkUnstructuredGrid
,grid_tmp
);
845 allocateGrid(grid_tmp
,N_cells
+N_newcells
,N_points
+N_newpoints
);
846 m_total_N_newpoints
+=N_newpoints
; m_total_N_newcells
+=N_newcells
;
848 makeCopyNoAlloc(m_grid
, grid_tmp
);//TODO: This will not work if the size of the grid is reduced!
849 //initialize new node counter
850 m_newNodeId
=N_points
;
852 if(insert_FP
) insert_FP_actor(grid_tmp
);
853 if(insert_EP
) insert_EP_actor(grid_tmp
);
855 cout
<<"================="<<endl
;
856 cout
<<"hitlist="<<hitlist
<<endl
;
857 cout
<<"================="<<endl
;
858 if(remove_FP
) remove_FP_actor(grid_tmp
);
859 if(remove_EP
) remove_EP_actor(grid_tmp
);
861 makeCopy(grid_tmp
,m_grid
);
863 cout
<<"===FullEdit END==="<<endl
;
867 // vtkIdType CreateSpecialMapping::FindSnapPoint(vtkUnstructuredGrid *src, vtkIdType DeadNode)
868 vtkIdType
CreateSpecialMapping::FindSnapPoint(vtkUnstructuredGrid
*src
, vtkIdType DeadNode
,QSet
<vtkIdType
> & DeadCells
,QSet
<vtkIdType
> & MutatedCells
,QSet
<vtkIdType
> & MutilatedCells
)
870 getAllSurfaceCells(m_AllCells
,src
);
871 getSurfaceCells(m_bcs
, m_SelectedCells
, src
);
872 m_SelectedNodes
.clear();
873 getSurfaceNodes(m_bcs
,m_SelectedNodes
,src
);
874 getNodesFromCells(m_AllCells
, nodes
, src
);
876 setCells(m_AllCells
);
880 EG_VTKDCN(vtkCharArray
, node_type
, src
, "node_type");
881 if(node_type
->GetValue(DeadNode
)==VTK_FIXED_VERTEX
)
883 cout
<<"Sorry, unable to remove fixed vertex."<<endl
;
888 N_points
=src
->GetNumberOfPoints();
889 N_cells
=src
->GetNumberOfCells();
893 vtkIdType SnapPoint
=-1;
895 foreach(vtkIdType PSP
, n2n
[DeadNode
])
897 bool IsValidSnapPoint
=true;
899 if(DebugLevel
>10) cout
<<"====>PSP="<<PSP
<<endl
;
901 if(NumberOfCommonPoints(DeadNode
,PSP
,IsTetra
)>2)//common point check
903 if(DebugLevel
>10) cout
<<"Sorry, but you are not allowed to move point "<<DeadNode
<<" to point "<<PSP
<<"."<<endl
;
904 IsValidSnapPoint
=false;
906 if(IsTetra
)//tetra check
908 if(DebugLevel
>10) cout
<<"Sorry, but you are not allowed to move point "<<DeadNode
<<" to point "<<PSP
<<"."<<endl
;
909 IsValidSnapPoint
=false;
912 //count number of points and cells to remove + analyse cell transformations
916 MutatedCells
.clear();
917 MutilatedCells
.clear();
918 foreach(vtkIdType C
, n2c
[DeadNode
])//loop through potentially dead cells
920 //get points around cell
921 vtkIdType N_pts
, *pts
;
922 src
->GetCellPoints(C
, N_pts
, pts
);
924 bool ContainsSnapPoint
=false;
925 bool invincible
=false;
926 for(int i
=0;i
<N_pts
;i
++)
928 if(DebugLevel
>10) cout
<<"pts["<<i
<<"]="<<pts
[i
]<<" and PSP="<<PSP
<<endl
;
929 if(pts
[i
]==PSP
) {ContainsSnapPoint
=true;}
930 if(pts
[i
]!=DeadNode
&& pts
[i
]!=PSP
&& n2c
[pts
[i
]].size()<=1) invincible
=true;
932 if(ContainsSnapPoint
)
934 if(N_pts
==3)//dead cell
936 if(invincible
)//Check that empty lines aren't left behind when a cell is killed
938 if(DebugLevel
>10) cout
<<"Sorry, but you are not allowed to move point "<<DeadNode
<<" to point "<<PSP
<<"."<<endl
;
939 IsValidSnapPoint
=false;
945 if(DebugLevel
>10) cout
<<"cell "<<C
<<" has been pwned!"<<endl
;
950 cout
<<"RED ALERT: Xenomorph detected!"<<endl
;
956 vtkIdType src_N_pts
, *src_pts
;
957 src
->GetCellPoints(C
, src_N_pts
, src_pts
);
961 cout
<<"RED ALERT: Xenomorph detected!"<<endl
;
965 vtkIdType OldTriangle
[3];
966 vtkIdType NewTriangle
[3];
968 for(int i
=0;i
<src_N_pts
;i
++)
970 OldTriangle
[i
]=src_pts
[i
];
971 NewTriangle
[i
]=( (src_pts
[i
]==DeadNode
) ? PSP
: src_pts
[i
] );
973 vec3_t Old_N
= triNormal(src
, OldTriangle
[0], OldTriangle
[1], OldTriangle
[2]);
974 vec3_t New_N
= triNormal(src
, NewTriangle
[0], NewTriangle
[1], NewTriangle
[2]);
975 double OldArea
=Old_N
.abs();
976 double NewArea
=New_N
.abs();
977 double scal
=Old_N
*New_N
;
978 double cross
=(Old_N
.cross(New_N
)).abs();//double-cross on Nar Shadaa B-)
981 cout
<<"OldArea="<<OldArea
<<endl
;
982 cout
<<"NewArea="<<NewArea
<<endl
;
983 cout
<<"scal="<<scal
<<endl
;
984 cout
<<"cross="<<cross
<<endl
;
987 if(Old_N
*New_N
<Old_N
*Old_N
*1./100.)//area + inversion check
989 if(DebugLevel
>10) cout
<<"Sorry, but you are not allowed to move point "<<DeadNode
<<" to point "<<PSP
<<"."<<endl
;
990 IsValidSnapPoint
=false;
994 MutatedCells
.insert(C
);
995 if(DebugLevel
>10) cout
<<"cell "<<C
<<" has been infected!"<<endl
;
999 if(N_cells
+N_newcells
<=0)//survivor check
1001 if(DebugLevel
>10) cout
<<"Sorry, but you are not allowed to move point "<<DeadNode
<<" to point "<<PSP
<<"."<<endl
;
1002 IsValidSnapPoint
=false;
1004 if(node_type
->GetValue(DeadNode
)==VTK_BOUNDARY_EDGE_VERTEX
&& node_type
->GetValue(PSP
)==VTK_SIMPLE_VERTEX
)
1006 if(DebugLevel
>10) cout
<<"Sorry, but you are not allowed to move point "<<DeadNode
<<" to point "<<PSP
<<"."<<endl
;
1007 IsValidSnapPoint
=false;
1010 if(IsValidSnapPoint
) {SnapPoint
=PSP
; break;}
1011 }//end of loop through potential SnapPoints
1015 cout
<<"AT FINDSNAPPOINT EXIT"<<endl
;
1016 cout
<<"N_points="<<N_points
<<endl
;
1017 cout
<<"N_cells="<<N_cells
<<endl
;
1018 cout
<<"N_newpoints="<<N_newpoints
<<endl
;
1019 cout
<<"N_newcells="<<N_newcells
<<endl
;
1024 bool CreateSpecialMapping::DeletePoint_2(vtkUnstructuredGrid
*src
, vtkIdType DeadNode
)
1026 getAllSurfaceCells(m_AllCells
,src
);
1027 getSurfaceCells(m_bcs
, m_SelectedCells
, src
);
1028 m_SelectedNodes
.clear();
1029 getSurfaceNodes(m_bcs
,m_SelectedNodes
,src
);
1030 getNodesFromCells(m_AllCells
, nodes
, src
);
1032 setCells(m_AllCells
);
1035 N_points
=src
->GetNumberOfPoints();
1036 N_cells
=src
->GetNumberOfCells();
1040 if(DeadNode
<0 || DeadNode
>=N_points
)
1042 cout
<<"Warning: Point out of range: DeadNode="<<DeadNode
<<" N_points="<<N_points
<<endl
;
1046 QSet
<vtkIdType
> DeadCells
;
1047 QSet
<vtkIdType
> MutatedCells
;
1048 QSet
<vtkIdType
> MutilatedCells
;
1051 cout
<<"BEFORE FINDSNAPPOINT"<<endl
;
1052 cout
<<"N_points="<<N_points
<<endl
;
1053 cout
<<"N_cells="<<N_cells
<<endl
;
1054 cout
<<"N_newpoints="<<N_newpoints
<<endl
;
1055 cout
<<"N_newcells="<<N_newcells
<<endl
;
1057 vtkIdType SnapPoint
=FindSnapPoint(src
,DeadNode
,DeadCells
,MutatedCells
,MutilatedCells
);
1059 if(DebugLevel
>0) cout
<<"===>DeadNode="<<DeadNode
<<" moving to SNAPPOINT="<<SnapPoint
<<" DebugLevel="<<DebugLevel
<<endl
;
1060 if(SnapPoint
<0) {cout
<<"Sorry no possible SnapPoint found."<<endl
; return(false);}
1064 cout
<<"BEFORE ALLOCATION"<<endl
;
1065 cout
<<"N_points="<<N_points
<<endl
;
1066 cout
<<"N_cells="<<N_cells
<<endl
;
1067 cout
<<"N_newpoints="<<N_newpoints
<<endl
;
1068 cout
<<"N_newcells="<<N_newcells
<<endl
;
1070 N_points
=src
->GetNumberOfPoints();
1071 N_cells
=src
->GetNumberOfCells();
1072 cout
<<"N_points="<<N_points
<<endl
;
1073 cout
<<"N_cells="<<N_cells
<<endl
;
1074 cout
<<"N_newpoints="<<N_newpoints
<<endl
;
1075 cout
<<"N_newcells="<<N_newcells
<<endl
;
1076 EG_VTKSP(vtkUnstructuredGrid
,dst
);
1077 allocateGrid(dst
,N_cells
+N_newcells
,N_points
+N_newpoints
);
1078 m_total_N_newpoints
+=N_newpoints
; m_total_N_newcells
+=N_newcells
;
1080 //vector used to redefine the new point IDs
1081 QVector
<vtkIdType
> OffSet(N_points
);
1083 //copy undead points
1084 vtkIdType dst_id_node
=0;
1085 for (vtkIdType src_id_node
= 0; src_id_node
< N_points
; src_id_node
++) {//loop through src points
1086 if(src_id_node
!=DeadNode
)//if the node isn't dead, copy it
1089 src
->GetPoints()->GetPoint(src_id_node
, x
.data());
1090 dst
->GetPoints()->SetPoint(dst_id_node
, x
.data());
1091 copyNodeData(src
, src_id_node
, dst
, dst_id_node
);
1092 OffSet
[src_id_node
]=src_id_node
-dst_id_node
;
1097 if(DebugLevel
>0) cout
<<"src_id_node="<<src_id_node
<<" dst_id_node="<<dst_id_node
<<endl
;
1101 cout
<<"DeadCells="<<DeadCells
<<endl
;
1102 cout
<<"MutatedCells="<<MutatedCells
<<endl
;
1103 cout
<<"MutilatedCells="<<MutilatedCells
<<endl
;
1106 for (vtkIdType id_cell
= 0; id_cell
< src
->GetNumberOfCells(); ++id_cell
) {//loop through src cells
1107 if(!DeadCells
.contains(id_cell
))//if the cell isn't dead
1109 vtkIdType src_N_pts
, *src_pts
;
1110 vtkIdType dst_N_pts
, *dst_pts
;
1111 src
->GetCellPoints(id_cell
, src_N_pts
, src_pts
);
1113 vtkIdType type_cell
= src
->GetCellType(id_cell
);
1114 if(DebugLevel
>10) cout
<<"-->id_cell="<<id_cell
<<endl
;
1115 if(DebugLevel
>10) for(int i
=0;i
<src_N_pts
;i
++) cout
<<"src_pts["<<i
<<"]="<<src_pts
[i
]<<endl
;
1116 // src->GetCellPoints(id_cell, dst_N_pts, dst_pts);
1117 dst_N_pts
=src_N_pts
;
1118 dst_pts
=new vtkIdType
[dst_N_pts
];
1119 if(MutatedCells
.contains(id_cell
))//mutated cell
1121 if(DebugLevel
>10) cout
<<"processing mutated cell "<<id_cell
<<endl
;
1122 for(int i
=0;i
<src_N_pts
;i
++)
1124 if(src_pts
[i
]==DeadNode
) {
1126 cout
<<"SnapPoint="<<SnapPoint
<<endl
;
1127 cout
<<"OffSet[SnapPoint]="<<OffSet
[SnapPoint
]<<endl
;
1128 cout
<<"src_pts["<<i
<<"]="<<src_pts
[i
]<<endl
;
1130 dst_pts
[i
]=SnapPoint
-OffSet
[SnapPoint
];
1132 else dst_pts
[i
]=src_pts
[i
]-OffSet
[src_pts
[i
]];
1134 if(DebugLevel
>10) cout
<<"--->dst_pts:"<<endl
;
1135 if(DebugLevel
>10) for(int i
=0;i
<dst_N_pts
;i
++) cout
<<"dst_pts["<<i
<<"]="<<dst_pts
[i
]<<endl
;
1138 else if(MutilatedCells
.contains(id_cell
))//mutilated cell
1140 if(DebugLevel
>10) cout
<<"processing mutilated cell "<<id_cell
<<endl
;
1142 if(type_cell
==VTK_QUAD
) {
1143 type_cell
=VTK_TRIANGLE
;
1146 else {cout
<<"FATAL ERROR: Unknown mutilated cell detected! It is not a quad! Potential xenomorph infestation!"<<endl
;EG_BUG
;}
1149 for(int i
=0;i
<src_N_pts
;i
++)
1151 if(src_pts
[i
]==SnapPoint
) { dst_pts
[j
]=SnapPoint
-OffSet
[SnapPoint
];j
++; }//SnapPoint
1152 else if(src_pts
[i
]!=DeadNode
) { dst_pts
[j
]=src_pts
[i
]-OffSet
[src_pts
[i
]];j
++; }//pre-snap/dead + post-snap/dead
1153 //do nothing in case of DeadNode
1158 if(DebugLevel
>10) cout
<<"processing normal cell "<<id_cell
<<endl
;
1159 for(int i
=0;i
<src_N_pts
;i
++)
1161 dst_pts
[i
]=src_pts
[i
]-OffSet
[src_pts
[i
]];
1165 vtkIdType id_new_cell
= dst
->InsertNextCell(type_cell
, dst_N_pts
, dst_pts
);
1166 copyCellData(src
, id_cell
, dst
, id_new_cell
);
1168 cout
<<"===Copying cell "<<id_cell
<<" to "<<id_new_cell
<<"==="<<endl
;
1169 cout
<<"src_pts:"<<endl
;
1170 for(int i
=0;i
<src_N_pts
;i
++) cout
<<"src_pts["<<i
<<"]="<<src_pts
[i
]<<endl
;
1171 cout
<<"dst_pts:"<<endl
;
1172 for(int i
=0;i
<dst_N_pts
;i
++) cout
<<"dst_pts["<<i
<<"]="<<dst_pts
[i
]<<endl
;
1173 cout
<<"OffSet="<<OffSet
<<endl
;
1174 cout
<<"===Copying cell end==="<<endl
;
1179 // cout_grid(cout,dst,true,true,true,true);
1184 int CreateSpecialMapping::remove_EP_all_2()
1186 cout
<<"===remove_EP_all_2 START==="<<endl
;
1187 getAllSurfaceCells(m_AllCells
,m_grid
);
1188 getSurfaceCells(m_bcs
, m_SelectedCells
, m_grid
);
1189 EG_VTKDCC(vtkIntArray
, cell_code
, m_grid
, "cell_code");
1190 EG_VTKDCN(vtkDoubleArray
, node_meshdensity
, m_grid
, "node_meshdensity");
1191 m_SelectedNodes
.clear();
1192 getSurfaceNodes(m_bcs
,m_SelectedNodes
,m_grid
);
1193 getNodesFromCells(m_AllCells
, nodes
, m_grid
);
1195 setCells(m_AllCells
);
1196 cout
<<"m_AllCells.size()="<<m_AllCells
.size()<<endl
;
1200 N_points
=m_grid
->GetNumberOfPoints();
1201 N_cells
=m_grid
->GetNumberOfCells();
1207 hitlist
.resize(N_points
);
1208 offset
.resize(N_points
);
1210 marked_cells
.clear();
1211 marked_nodes
.clear();
1213 remove_EP_counter();
1214 cout
<<"================="<<endl
;
1215 cout
<<"hitlist="<<hitlist
<<endl
;
1216 cout
<<"================="<<endl
;
1220 for(int i
=0;i
<hitlist
.size();i
++)
1224 cout
<<"Deleting point "<<i
<<" currently known as "<<i
-kills
<<endl
;
1226 QString num1
;num1
.setNum(i
);
1227 QString num2
;num2
.setNum(i
-kills
);
1228 GuiMainWindow::pointer()->QuickSave("pre-deleting_"+num1
+"_"+num2
+".vtu");
1230 if(DeletePoint_2(m_grid
,i
-kills
))
1233 cout
<<"Kill successful"<<endl
;
1237 cout
<<"Kill failed"<<endl
;
1241 GuiMainWindow::pointer()->QuickSave("post-deleting_"+num1
+"_"+num2
+".vtu");
1245 cout
<<"Killed: "<<kills
<<"/"<<contracts
<<endl
;
1246 if(kills
!=contracts
) {cout
<<"MISSION FAILED"<<endl
;EG_BUG
;}
1247 cout
<<"===remove_EP_all_2 END==="<<endl
;
1251 int CreateSpecialMapping::remove_FP_all_2()
1253 cout
<<"===remove_FP_all_2 START==="<<endl
;
1254 cout
<<"+++++++"<<endl
;
1255 cout_grid(cout
,m_grid
,true,true,true,true);
1256 cout
<<"+++++++"<<endl
;
1258 getAllSurfaceCells(m_AllCells
,m_grid
);
1259 getSurfaceCells(m_bcs
, m_SelectedCells
, m_grid
);
1260 EG_VTKDCC(vtkIntArray
, cell_code
, m_grid
, "cell_code");
1261 EG_VTKDCN(vtkDoubleArray
, node_meshdensity
, m_grid
, "node_meshdensity");
1262 m_SelectedNodes
.clear();
1263 getSurfaceNodes(m_bcs
,m_SelectedNodes
,m_grid
);
1264 getNodesFromCells(m_AllCells
, nodes
, m_grid
);
1266 setCells(m_AllCells
);
1267 cout
<<"m_AllCells.size()="<<m_AllCells
.size()<<endl
;
1271 N_points
=m_grid
->GetNumberOfPoints();
1272 N_cells
=m_grid
->GetNumberOfCells();
1278 hitlist
.resize(N_points
);
1279 offset
.resize(N_points
);
1281 marked_cells
.clear();
1282 marked_nodes
.clear();
1284 remove_FP_counter();
1285 cout_grid(cout
,m_grid
);
1286 cout
<<"================="<<endl
;
1287 cout
<<"hitlist="<<hitlist
<<endl
;
1288 cout
<<"================="<<endl
;
1292 for(int i
=0;i
<hitlist
.size();i
++)
1296 cout
<<"Deleting point "<<i
<<" currently known as "<<i
-kills
<<endl
;
1298 QString num1
;num1
.setNum(i
);
1299 QString num2
;num2
.setNum(i
-kills
);
1300 GuiMainWindow::pointer()->QuickSave("pre-deleting_"+num1
+"_"+num2
+".vtu");
1302 if(DeletePoint_2(m_grid
,i
-kills
))
1305 cout
<<"Kill successful"<<endl
;
1309 cout
<<"Kill failed"<<endl
;
1313 GuiMainWindow::pointer()->QuickSave("post-deleting_"+num1
+"_"+num2
+".vtu");
1317 cout
<<"Killed: "<<kills
<<"/"<<contracts
<<endl
;
1318 if(kills
!=contracts
) {cout
<<"MISSION FAILED"<<endl
;EG_BUG
;}
1319 cout
<<"===remove_FP_all_2 END==="<<endl
;