From c626fecd77d4ada5e099cc8c85bbf7eadc215319 Mon Sep 17 00:00:00 2001 From: Mike Taverne Date: Tue, 28 Apr 2009 17:21:08 +0200 Subject: [PATCH] =?utf8?q?=C2=C2renamed=20createspecialmapping=20to=20surf?= =?utf8?q?acesmoother?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- createspecialmapping.cpp | 1171 ---------------------------------------------- createspecialmapping.h | 289 ------------ engrid.pro | 16 +- guismoothsurface.cpp | 10 +- smoothingutilities.h | 2 +- vertexdelegate.cpp | 2 +- 6 files changed, 17 insertions(+), 1473 deletions(-) delete mode 100644 createspecialmapping.cpp delete mode 100644 createspecialmapping.h diff --git a/createspecialmapping.cpp b/createspecialmapping.cpp deleted file mode 100644 index d591987..0000000 --- a/createspecialmapping.cpp +++ /dev/null @@ -1,1171 +0,0 @@ -#include "createspecialmapping.h" - -#include -#include -#include - -#include "smoothingutilities.h" - -#include "swaptriangles.h" -#include "laplacesmoother.h" -#include "guimainwindow.h" - -#include -using namespace std; - -CreateSpecialMapping::CreateSpecialMapping() -{ - DebugLevel=0; -} - -int CreateSpecialMapping::Process() -{ - int i_iter=0; - for(i_iter=0;i_iterGetValue(node)); - int idx=VMDvector.indexOf(nodeVMD); - if(DebugLevel>3) cout<<"idx="<SetValue(node, VMDvector[idx].density); - } - else//unspecified - { - double L=CurrentVertexAvgDist(node,n2n,m_grid); - double D=1./L; - node_meshdensity->SetValue(node, D); - } - }*/ - - double diff=Convergence_meshdensity+1; - if(DebugLevel>3) cout<<"before loop: diff="<2) cout<<"--->diff="<2) cout<<"======>"<GetValue(node)); - int idx=VMDvector.indexOf(nodeVMD); - node_specified_density->SetValue(node, idx); - if(DebugLevel>2) cout<<"------>idx="<SetValue(node, VMDvector[idx].density); - } - else//unspecified - { - double D=DesiredMeshDensity(node,n2n,m_grid); - if(first) { - if(DebugLevel>2) { - cout<<"------>FIRST:"<D="<node_meshdensity->GetValue("<GetValue(node)<D-node_meshdensity->GetValue("<GetValue(node)<diff=abs(D-node_meshdensity->GetValue("<GetValue(node))<GetValue(node)); - first=false; - } - else { - if(DebugLevel>2) { - cout<<"------>NOT FIRST:"<D="<node_meshdensity->GetValue("<GetValue(node)<D-node_meshdensity->GetValue("<GetValue(node)<diff=abs(D-node_meshdensity->GetValue("<GetValue(node))<diff="<max(abs(D-node_meshdensity->GetValue("<GetValue(node)),diff)<GetValue(node)),diff); - } - node_meshdensity->SetValue(node, D); - } - if(DebugLevel>2) cout<<"======>"<Convergence_meshdensity && !first && iter bcs_complement=complementary_bcs(m_bcs,m_grid,cells); - cout<<"m_bcs="< bc; - foreach(vtkIdType C, n2c[node]) - { - bc.insert(cell_code->GetValue(C)); - VMD.BCmap[cell_code->GetValue(C)]=2; - } - VMD.BClist.resize(bc.size()); - qCopy(bc.begin(),bc.end(),VMD.BClist.begin()); - qSort(VMD.BClist.begin(),VMD.BClist.end()); - return(VMD); -} - -int CreateSpecialMapping::insert_FP_counter() -{ - cout<<"===insert_FP_counter() START==="<0) cout<<"inserting a field point "<(" << node1 << "," << node2 << ")" << ": " << edge_map_iter.value() << endl; - QSet stencil_cells_set; - QVector stencil_cells_vector; - stencil_cells_set=n2c[node1]; - stencil_cells_set.intersect(n2c[node2]); - if(DebugLevel>10) cout<<"stencil_cells_set="<10) cout<<"stencil_cells_vector="<10) cout<<"SideToSplit="<10) cout<<"c2c[id_cell][SideToSplit]="<10) for(int i=0;i<3;i++) cout<<"c2c[id_cell]["<10) cout<<"stencil_marked="<10) cout<<"insert_edgepoint(node1,node2)="<1) cout<<"inserting an edge point "<< "(" << node1 << "," << node2 << ")" << ": " << edge_map_iter.value() << endl; - N_inserted_EP++; - foreach(vtkIdType C,stencil_cells_vector) marked_cells[C]=true; - StencilVector.push_back(S); - - if(stencil_cells_vector.size()==2)//2 cells around the edge - { - N_newcells+=2; - N_newpoints+=1; - } - else//1 cell around the edge - { - N_newcells+=1; - N_newpoints+=1; - } - } - if(DebugLevel>10) cout <<"--->end of edge processing"<GetValue(node)==VTK_SIMPLE_VERTEX) - { - bool marked=false; - foreach(vtkIdType C,n2c[node]) - { - if(marked_cells[C]) marked=true; - } - - QSet DeadCells; - QSet MutatedCells; - QSet MutilatedCells; - if( !marked && remove_fieldpoint(node) && FindSnapPoint(m_grid,node,DeadCells,MutatedCells,MutilatedCells, N_newpoints, N_newcells)!=-1) - { - if(DebugLevel>1) cout<<"removing field point "<GetValue(node)==VTK_BOUNDARY_EDGE_VERTEX) - { - bool marked=false; - foreach(vtkIdType C,n2c[node]) - { - if(marked_cells[C]) marked=true; - } - QSet DeadCells; - QSet MutatedCells; - QSet MutilatedCells; - if( !marked && remove_edgepoint(node) && FindSnapPoint(m_grid,node,DeadCells,MutatedCells,MutilatedCells, N_newpoints, N_newcells)!=-1) - { - cout<<"removing edge point "<marked_cells["<marked_cells["<0) cout<<"inserting a field point "<GetValue(id_cell); - if(DebugLevel>42) cout<<"id_cell="<10) cout<<"S="<GetPoint(S.p[1],A.data()); - grid_tmp->GetPoint(S.p[3],B.data()); - vec3_t M=0.5*(A+B); - addPoint(grid_tmp,m_newNodeId,M.data()); - if(DebugLevel>0) cout<<"NEW EDGE POINT: "<10) cout<<"marked_cells["<10) cout<<"marked_cells["<GetValue(S.id_cell1); - int bc2=cell_code_tmp->GetValue(S.id_cell2); - - grid_tmp->ReplaceCell(S.id_cell1 , 3, pts_triangle[0]); - cell_code_tmp->SetValue(S.id_cell1, bc1); - - grid_tmp->ReplaceCell(S.id_cell2 , 3, pts_triangle[1]); - cell_code_tmp->SetValue(S.id_cell2, bc2); - - vtkIdType newCellId; - newCellId = grid_tmp->InsertNextCell(VTK_TRIANGLE,3,pts_triangle[2]); - cell_code_tmp->SetValue(newCellId, bc2); - newCellId = grid_tmp->InsertNextCell(VTK_TRIANGLE,3,pts_triangle[3]); - cell_code_tmp->SetValue(newCellId, bc1); - } - else{//there is no neighbour cell - if(DebugLevel>10) cout<<"marked_cells["<GetValue(S.id_cell1); - - grid_tmp->ReplaceCell(S.id_cell1 , 3, pts_triangle[0]); - cell_code_tmp->SetValue(S.id_cell1, bc1); - - vtkIdType newCellId; - newCellId = grid_tmp->InsertNextCell(VTK_TRIANGLE,3,pts_triangle[3]); - cell_code_tmp->SetValue(newCellId, bc1); - } - - m_newNodeId++; - } - cout<<"===insert_EP_actor END==="<1) cout<<"removing field point "<1) cout<<"removing edge point "<GetNumberOfPoints(); - N_cells=m_grid->GetNumberOfCells(); - N_newpoints=0; - N_newcells=0; - - hitlist.resize(N_points); - offset.resize(N_points); - - marked_cells.clear(); - marked_nodes.clear(); - - if(insert_FP) insert_FP_counter(); - if(insert_EP) insert_EP_counter(); - if(remove_FP) remove_FP_counter(); - if(remove_EP) remove_EP_counter(); - - cout<<"================="<GetNumberOfPoints(); - N_cells=m_grid->GetNumberOfCells(); - cout<<"N_points="<47) cout<<"Deleting point "<QuickSave("pre-deleting_"+num1+"_"+num2+".vtu"); - - bool DelResult=DeletePoint_2(m_grid,i-kills,N_newpoints,N_newcells); - m_total_N_newpoints+=N_newpoints; m_total_N_newcells+=N_newcells; - - if(DelResult) - { - kills++; - if(DebugLevel>47) cout<<"Kill successful"<47) cout<<"Kill failed"<QuickSave("post-deleting_"+num1+"_"+num2+".vtu"); - - } - } - cout<<"Killed: "<47) cout<<"Deleting point "<QuickSave("pre-deleting_"+num1+"_"+num2+".vtu"); - - bool DelResult=DeletePoint_2(m_grid,i-kills,N_newpoints,N_newcells); - m_total_N_newpoints+=N_newpoints; m_total_N_newcells+=N_newcells; - - if(DelResult) - { - kills++; - if(DebugLevel>47) cout<<"Kill successful"<47) cout<<"Kill failed"<QuickSave("post-deleting_"+num1+"_"+num2+".vtu"); - - } - } - cout<<"Killed: "< DeadNodes; - for(vtkIdType i=0;i DeadNodes; - for(vtkIdType i=0;i -#include -#include -#include -#include "egvtkobject.h" -#include "operation.h" -#include "vertexmeshdensity.h" - -#include "geometrytools.h" -using namespace GeometryTools; - -#include -using namespace std; - -class CreateSpecialMapping : public Operation { - public: - CreateSpecialMapping(); - int Process(); - void operate(){}; - - int N_SmoothIterations; - int maxiter_density; - - double Convergence_meshdensity; - - bool insert_FP; - bool insert_EP; - bool remove_FP; - bool remove_EP; - - bool DoSwap; - bool DoLaplaceSmoothing; - - int N_inserted_FP; - int N_inserted_EP; - int N_removed_FP; - int N_removed_EP; - - int N_points; - int N_cells; - int N_newpoints; - int N_newcells; - int m_total_N_newpoints; - int m_total_N_newcells; - - QSet m_bcs; - QVector m_AllCells; - QVector m_SelectedCells; - vtkUnstructuredGrid* m_grid; - vtkIdType m_newNodeId; - - QMap< pair, vtkIdType> edge_map; - QVector StencilVector; - QSet m_SelectedNodes; - QVector m_AllNodes; - - QVector hitlist;//Elements to be terminated (0=keep alive, 1=field agent to eliminate, 2=border agent to eliminate) - QVector offset;//offset caused by terminated elements - -/* double SV_value; - double FV_value; - double FEV_value; - double BEV_value;*/ - - QVector VMDvector;//Vertices of Mass destruction - - QMap marked_cells; - QMap marked_nodes; - - void SetInput(QSet a_bcs,vtkUnstructuredGrid* a_grid) - { - m_bcs=a_bcs; - m_grid=a_grid; - }; - - void SetVertexMeshDensityVector(QVector a_VMDvector){VMDvector=a_VMDvector;}; - -/* void Set_SV_value(double V){SV_value=V;}; - void Set_FV_value(double V){FV_value=V;}; - void Set_FEV_value(double V){FEV_value=V;}; - void Set_BEV_value(double V){BEV_value=V;};*/ - - void SetConvergence_meshdensity(double C){Convergence_meshdensity=C;}; - void Set_insert_FP(bool B){insert_FP=B;}; - void Set_insert_EP(bool B){insert_EP=B;}; - void Set_remove_FP(bool B){remove_FP=B;}; - void Set_remove_EP(bool B){remove_EP=B;}; - - VertexMeshDensity getVMD(vtkIdType node, char VertexType); - - //utilities - public: - double Um(vtkIdType D) { - double ret=0; - vtkIdType N_pts, *pts; - m_grid->GetCellPoints(D, N_pts, pts); - for(int i=0;iGetPoints()->GetPoint(pts[i], A.data()); - m_grid->GetPoints()->GetPoint(pts[(i+1)%N_pts], B.data()); - ret+=(B-A).abs(); - } - return(ret); - } - double A_U(vtkIdType D) { // area of the circumscribed circle of the triangle - vtkIdType N_pts, *pts; - m_grid->GetCellPoints(D, N_pts, pts); - vec3_t A,B,C; - m_grid->GetPoints()->GetPoint(pts[0], A.data()); - m_grid->GetPoints()->GetPoint(pts[1], B.data()); - m_grid->GetPoints()->GetPoint(pts[2], C.data()); - double a=(C-B).abs(); - double alpha=angle((B-A),(C-A)); - double R=a/(2*sin(alpha)); - return(M_PI*R*R); - } - double A_D(vtkIdType D) { // triangle area - return(cellVA(m_grid,D)); - } - double DN(int i,vtkIdType D) { //triangle neighbours - return(c2c[D][i]); - } - double nk(vtkIdType P) { - return(n2n[P].size()); - } - double G_k(vtkIdType node) { - EG_VTKDCN(vtkDoubleArray, node_meshdensity, m_grid, "node_meshdensity"); - return(1.0/node_meshdensity->GetValue(node)); - }; - double DK(int i,vtkIdType D) { // triangle nodes - vtkIdType N_pts, *pts; - m_grid->GetCellPoints(D, N_pts, pts); - return(pts[i]); - } - vtkIdType KK(int i,vtkIdType j,vtkIdType K) {//i=1 or 2, j=node2, K=node1 - if(i==1) return(K); - else return(j); - } - double L_k(vtkIdType j,vtkIdType K)// node1 K, node2 j - { - vec3_t A; - vec3_t B; - m_grid->GetPoints()->GetPoint(K, A.data()); - m_grid->GetPoints()->GetPoint(j, B.data()); - return((B-A).abs()); - } - double Q_L(vtkIdType D) - { - // Um(D)/sum(G_k(DK(i,D)),i,1,3) - double denom_sum=0; - for(int i=0;i<3;i++) - { - denom_sum += G_k(DK(i,D)); - } - /*if(DebugLevel>0) cout<<"D="<1.0/Fred1="<"<<1.0/Fred1<3*Qmin="<"<<3*Qmin<1.0/Fred1 && total>3*Qmin ); - } - bool insert_edgepoint(vtkIdType j,vtkIdType K)// node1 K, node2 j - { -/* cout<<"j="<0.5*(G_k(j)+G_k(K)); - if(DebugLevel>0 && result){ - cout<<"j="< & DeadCells,QSet & MutatedCells,QSet & MutilatedCells); - - int remove_EP_all_2(); - int remove_FP_all_2(); - - int remove_EP_all_3(); - int remove_FP_all_3(); - - int SwapFunction(); - int SmoothFunction(); - -}; -//end of CreateSpecialMapping class - -// #define VTK_SIMPLE_VERTEX 0 -// #define VTK_FIXED_VERTEX 1 -// #define VTK_FEATURE_EDGE_VERTEX 2 -// #define VTK_BOUNDARY_EDGE_VERTEX 3 - -#endif diff --git a/engrid.pro b/engrid.pro index 30eddfe..f586da2 100644 --- a/engrid.pro +++ b/engrid.pro @@ -47,7 +47,7 @@ LIBS += -lvtkWidgets #netgen lib LIBS += -lng -!win32 { +!win32 { LIBS += -L./netgen_svn LIBS += -L$(VTKLIBDIR) LIBS += -Wl,-rpath @@ -56,7 +56,7 @@ LIBS += -lng INCLUDEPATH += ./netgen_svn/netgen-mesher/netgen/nglib INCLUDEPATH += ./netgen_svn/netgen-mesher/netgen/libsrc/general } -win32 { +win32 { VTK_DIR = C:\VTK VTK_SRCDIR = C:\VTK\5.0.4 LIBS += -L$$VTK_DIR\bin\release @@ -156,7 +156,6 @@ guisettingsviewer.h \ \ guitransform.h \ vtksmoothpolydatafilter2.h \ - createspecialmapping.h \ vertexdelegate.h \ vertexmeshdensity.h \ smoothingutilities.h \ @@ -168,7 +167,8 @@ guisettingsviewer.h \ deletepickedpoint.h \ text3d.h \ guipick.h \ - egvtkinteractorstyle.h + egvtkinteractorstyle.h \ + surfacesmoother.h SOURCES = \ main.cpp \ @@ -232,7 +232,6 @@ guisettingsviewer.cpp \ \ guitransform.cpp \ vtksmoothpolydatafilter2.cpp \ - createspecialmapping.cpp \ vertexdelegate.cpp \ vertexmeshdensity.cpp \ smoothingutilities.cpp \ @@ -244,7 +243,8 @@ guisettingsviewer.cpp \ deletepickedpoint.cpp \ text3d.cpp \ guipick.cpp \ - egvtkinteractorstyle.cpp + egvtkinteractorstyle.cpp \ + surfacesmoother.cpp FORMS = \ guicreateboundarylayer.ui \ @@ -259,3 +259,7 @@ guisetboundarycode.ui \ guismoothsurface.ui \ guitransform.ui \ guipick.ui +SOURCES -= createspecialmapping.cpp + +HEADERS -= createspecialmapping.h + diff --git a/guismoothsurface.cpp b/guismoothsurface.cpp index 24c3c89..8ace44e 100644 --- a/guismoothsurface.cpp +++ b/guismoothsurface.cpp @@ -22,7 +22,7 @@ // #include "guismoothsurface.h" #include "swaptriangles.h" -#include "createspecialmapping.h" +#include "surfacesmoother.h" #include "vertexdelegate.h" #include "settingssheet.h" #include "laplacesmoother.h" @@ -1201,7 +1201,7 @@ void GuiSmoothSurface::operate() QVector VMDvector=GetSet(); - CreateSpecialMapping toto; + SurfaceSmoother toto; toto.SetInput(bcs,grid); toto.SetVertexMeshDensityVector(VMDvector); @@ -1242,7 +1242,7 @@ void GuiSmoothSurface::operate() { QSet bcs; getSelectedItems(ui.listWidget, bcs); - CreateSpecialMapping toto; + SurfaceSmoother toto; toto.SetInput(bcs,grid); setDebugLevel(ui.spinBox_DebugLevel->value()); @@ -1261,7 +1261,7 @@ void GuiSmoothSurface::operate() { QSet bcs; getSelectedItems(ui.listWidget, bcs); - CreateSpecialMapping toto; + SurfaceSmoother toto; SetConvergence(ui.doubleSpinBox_Convergence->value()); SetFeatureEdgeSmoothing(ui.checkBox_FeatureEdgeSmoothing->checkState()); @@ -1298,7 +1298,7 @@ void GuiSmoothSurface::operate() { QSet bcs; getSelectedItems(ui.listWidget, bcs); - CreateSpecialMapping toto; + SurfaceSmoother toto; setDebugLevel(ui.spinBox_DebugLevel->value()); diff --git a/smoothingutilities.h b/smoothingutilities.h index 2692886..ac9e7b9 100644 --- a/smoothingutilities.h +++ b/smoothingutilities.h @@ -1,7 +1,7 @@ #ifndef SMOOTHINGUTILITIES_H #define SMOOTHINGUTILITIES_H -// class CreateSpecialMapping : public Operation { +// class SurfaceSmoother : public Operation { #endif diff --git a/vertexdelegate.cpp b/vertexdelegate.cpp index adec3f9..436963e 100644 --- a/vertexdelegate.cpp +++ b/vertexdelegate.cpp @@ -1,7 +1,7 @@ #include #include "vertexdelegate.h" -#include "createspecialmapping.h" +#include "surfacesmoother.h" #include using namespace std; -- 2.11.4.GIT