From 9c9f270183b15ec0f3af45a313ef557302bc9186 Mon Sep 17 00:00:00 2001 From: Mike Taverne Date: Fri, 24 Apr 2009 15:45:22 +0200 Subject: [PATCH] -Added Set2Vector + Vector2Set functions to egvtkobject -Create DeleteSetOfPoints() function in class Operation --- egvtkobject.h | 19 ++++++ guismoothsurface.cpp | 54 +++++++++++++++- operation.cpp | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++ operation.h | 3 +- 4 files changed, 247 insertions(+), 2 deletions(-) diff --git a/egvtkobject.h b/egvtkobject.h index 8b5cdcd..7346777 100644 --- a/egvtkobject.h +++ b/egvtkobject.h @@ -696,6 +696,25 @@ ostream &operator<<(ostream &out, QVector < pair > & vector) out<<"]"; return(out); } + +template +QVector Set2Vector(QSet a_set, bool a_sort) +{ + QVector l_vector(a_set.size()); + qCopy(a_set.begin(),a_set.end(),l_vector.begin()); + if(a_sort) qSort(l_vector.begin(),l_vector.end()); + return(l_vector); +} + +template +QSet Vector2Set(QVector a_vector, bool a_sort) +{ + QSet l_set(a_vector.size()); + qCopy(a_vector.begin(),a_vector.end(),l_set.begin()); + if(a_sort) qSort(l_set.begin(),l_set.end()); + return(l_set); +} + /////////////////////////////////////////// // /////////////////////////////////////////// // /* Here is how we we get QTextStreams that look like iostreams */ diff --git a/guismoothsurface.cpp b/guismoothsurface.cpp index 28d84ae..1975549 100644 --- a/guismoothsurface.cpp +++ b/guismoothsurface.cpp @@ -210,7 +210,7 @@ void GuiSmoothSurface::before() ui.SmoothMethod->addItem("Method 10: Super smoothing :)"); ui.SmoothMethod->addItem("Method 11: Update current mesh density + node types"); ui.SmoothMethod->addItem("Method 12: Delete all possible points :)"); - ui.SmoothMethod->addItem("Method 13"); + ui.SmoothMethod->addItem("Method 13: Delete selected points"); ui.SmoothMethod->addItem("Method 14"); ui.SmoothMethod->addItem("Method 15"); ui.SmoothMethod->addItem("Method 16"); @@ -1286,6 +1286,58 @@ void GuiSmoothSurface::operate() } ////////////////////////////////////////////////////////////////////////////////////////////// + else if(ui.SmoothMethod->currentIndex()==13)// Delete selected points + { + QSet bcs; + getSelectedItems(ui.listWidget, bcs); + CreateSpecialMapping toto; + + SetConvergence(ui.doubleSpinBox_Convergence->value()); + SetFeatureEdgeSmoothing(ui.checkBox_FeatureEdgeSmoothing->checkState()); + SetFeatureAngle(ui.doubleSpinBox_FeatureAngle->value()); + SetEdgeAngle(ui.doubleSpinBox_EdgeAngle->value()); + SetBoundarySmoothing(ui.checkBox_BoundarySmoothing->checkState()); + + int N_newpoints; + int N_newcells; + + vtkIdType N_points=grid->GetNumberOfPoints(); + vtkIdType N_cells=grid->GetNumberOfCells(); + + QVector VMDvector=GetSet(); +// cout<<"VMDvector="< +#include "egvtkobject.h" #include "geometrytools.h" using namespace GeometryTools; @@ -1994,6 +1995,178 @@ bool Operation::DeletePoint_2(vtkUnstructuredGrid *src, vtkIdType DeadNode, int& } //End of DeletePoint_2 +bool Operation::DeleteSetOfPoints(vtkUnstructuredGrid *src, QSet DeadNodes, int& N_newpoints, int& N_newcells) +{ + QVector DeadNode_vector=Set2Vector(DeadNodes,false); + + getAllSurfaceCells(cells,src); +// getNodesFromCells(cells, nodes, src); + setGrid(src); + setCells(cells); + UpdateNodeType(); + + //src grid info + int N_points=src->GetNumberOfPoints(); + int N_cells=src->GetNumberOfCells(); + + QSet DeadCells; + QSet MutatedCells; + QSet MutilatedCells; + QVector SnapPoint(DeadNode_vector.size()); + + for(int i=0;i=N_points) + { + cout<<"Warning: Point out of range: DeadNode_vector[i]="<DeadNode_vector[i]="<10) { + cout<<"BEFORE ALLOCATION"<id_cell="<10) for(int i=0;i10) { + cout<<"SnapPoint="<dst_pts:"<10) for(int i=0;i10) cout<<"processing mutilated cell "<10) cout<<"processing normal cell "<InsertNextCell(type_cell, dst_N_pts, dst_pts); + copyCellData(src, id_cell, dst, id_new_cell); + if(DebugLevel>10) { + cout<<"===Copying cell "< & DeadCells,QSet & MutatedCells,QSet & MutilatedCells, int& N_newpoints, int& N_newcells); bool DeletePoint_2(vtkUnstructuredGrid *src, vtkIdType DeadNode, int& N_newpoints, int& N_newcells); - + bool DeleteSetOfPoints(vtkUnstructuredGrid *src, QSet DeadNodes, int& N_newpoints, int& N_newcells); + void TxtSave(QString a_filename); void DualSave(QString a_filename); -- 2.11.4.GIT