/************************************************************************ Yutaka Ohtake CMeshEditorDoc.cpp Main class Copyright (c) 1999-2001 The University of Aizu. All Rights Reserved. ************************************************************************/ #include "stdafx.h" #include "MeshEditor.h" #include "MeshEditorDoc.h" #include "MeshEditorView.h" #include "ProgressViewer.h" #include //#define PI 3.14159265 #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMeshEditorDoc IMPLEMENT_DYNCREATE(CMeshEditorDoc, CDocument) BEGIN_MESSAGE_MAP(CMeshEditorDoc, CDocument) //{{AFX_MSG_MAP(CMeshEditorDoc) ON_COMMAND(ID_FILE_OPEN, OnFileOpen) ON_COMMAND(ID_WIRE, OnWire) ON_COMMAND(ID_VISUAL, OnVisual) ON_COMMAND(ID_AD_SMOOTH, OnAdSmooth) ON_COMMAND(ID_ANGLE, OnAngle) ON_COMMAND(ID_EDGE, OnEdge) ON_COMMAND(ID_ENHANCE, OnEnhance) ON_COMMAND(ID_FILE_SAVE, OnFileSave) ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs) ON_COMMAND(ID_FLAT, OnFlat) ON_COMMAND(ID_RIDGE, OnRidge) ON_COMMAND(ID_SIMPLIFY, OnSimplify) ON_COMMAND(ID_SMOOTH, OnSmooth) ON_COMMAND(ID_SUBDIVIDE, OnSubdivide) ON_COMMAND(ID_SMOOTH_SHADE, OnSmoothShade) ON_COMMAND(ID_PRINCIPAL, OnPrincipal) ON_COMMAND(ID_CURVATURE, OnCurvature) ON_COMMAND(ID_TENSOR_SMOOTH, OnTensorSmooth) ON_COMMAND(ID_CURVATURE2, OnCurvature2) ON_COMMAND(ID_NOISE, OnNoise) ON_COMMAND(ID_GAUSS, OnGauss) ON_COMMAND(ID_MAX_TENSOR, OnMaxTensor) ON_COMMAND(ID_MEAN, OnMean) ON_COMMAND(ID_MIN_TENSOR, OnMinTensor) ON_COMMAND(ID_PRINCIPAL2, OnPrincipal2) ON_COMMAND(ID_TOTAL, OnTotal) ON_COMMAND(ID_UNDO, OnUndo) ON_COMMAND(ID_VIEW_DIRE, OnViewDire) ON_COMMAND(ID_NON_MANI, OnNonMani) ON_COMMAND(ID_EDGE_CURVATURE, OnEdgeCurvature) ON_COMMAND(ID_SIL, OnSil) ON_COMMAND(ID_MIN_STROKE, OnMinStroke) ON_COMMAND(ID_MAX_STROKE, OnMaxStroke) ON_COMMAND(ID_GREEN, OnGreen) ON_COMMAND(ID_RED, OnRed) ON_COMMAND(ID_BLUE, OnBlue) ON_COMMAND(ID_RGB, OnRgb) ON_COMMAND(ID_POINTS, OnPoints) ON_COMMAND(ID_ERROR, OnError) ON_COMMAND(ID_FACE_ERROR, OnFaceError) ON_COMMAND(ID_VERTEX_ERROR, OnVertexError) ON_COMMAND(ID_FLIP, OnFlip) ON_COMMAND(ID_AD_GAUSS, OnAdGauss) ON_COMMAND(ID_DUAL, OnDual) ON_COMMAND(ID_WHITE, OnWhite) ON_COMMAND(ID_SAVE_POINT, OnSavePoint) ON_COMMAND(ID_RBF_FIT, OnRbfFit) ON_COMMAND(ID_BELYAEV_CGI98, OnBelyaevCgi98) ON_COMMAND(ID_SAVE_DUAL, OnSaveDual) ON_COMMAND(ID_SAVE_RR, OnSaveRr) //}}AFX_MSG_MAP END_MESSAGE_MAP() static char file_ex[] = "All files(*.*)|*.*||"; ///////////////////////////////////////////////////////////////////////////// // CMeshEditorDoc クラスの構築/消滅 CMeshEditorDoc::CMeshEditorDoc() { file_manager = new FileManager; feature_detector = new FeatureDetector; smoother = new Smoother; simplifier = new Simplifier; subdivider = new Subdivider; mesh = NULL; last_mesh = NULL; rbf = NULL; ridge_dialog = new RidgeDialog(NULL); smooth_dialog = new SmoothDialog(NULL); visual_dialog = new Visualization(NULL); ad_smooth_dialog = new AdSmoothDialog(NULL); noise_dialog = new NoiseDialog(NULL); angle_dia = new AngleDialog(NULL); tensor_dia = new TensorDialog(NULL); decimation_dia = new DecimationDialog(NULL); view_angle_dia = new ViewAngleDialog(NULL); subdiv_dia = new SubdivisionDialog; sample_dia = new SamplingDialog; gauss_dia = new AdaptiveGaussianDialog; err_est = new ErrorEstimator; ridge_B_dia = new RidgeBelyaevDialog; graph_win = new GraphWindow; p_error = NULL; pro_dia = new ProgressViewer(NULL); POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); pro_dia->Create(IDD_DIALOG6, pView); graph_win->Create(NULL, "Graph"); //, WS_OVERLAPPEDWINDOW, rectDefault, //NULL, WS_EX_TOPMOST, NULL); } CMeshEditorDoc::~CMeshEditorDoc() { delete file_manager; delete smoother; delete feature_detector; delete simplifier; delete subdivider; delete tensor_dia; delete ridge_dialog; delete smooth_dialog; delete visual_dialog; delete ad_smooth_dialog; delete noise_dialog; delete pro_dia; delete decimation_dia; delete angle_dia; delete view_angle_dia; delete subdiv_dia; delete sample_dia; delete gauss_dia; delete err_est; delete graph_win; if(mesh != NULL) delete mesh; if(rbf != NULL) delete rbf; if(p_error != NULL) delete[] p_error; } BOOL CMeshEditorDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CMeshEditorDoc シリアライゼーション void CMeshEditorDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { } else { } } ///////////////////////////////////////////////////////////////////////////// // CMeshEditorDoc クラスの診断 #ifdef _DEBUG void CMeshEditorDoc::AssertValid() const { CDocument::AssertValid(); } void CMeshEditorDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMeshEditorDoc コマンド void CMeshEditorDoc::OnFileOpen() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください CFileDialog* dia = new CFileDialog(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, file_ex, NULL); if(dia->DoModal() == IDOK){ POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); if(pView == NULL) OnNewDocument(); if(mesh != NULL){ delete simplifier; simplifier = new Simplifier; delete mesh; } mesh = new MeshData; CString file_name = dia->GetPathName(); CString file_ext = dia->GetFileExt(); FILE* file = fopen(file_name,"r"); //Read mesh data from file //and create adjacent data for the mesh file_manager->setFile(file, file_name, file_ext); file_manager->open(mesh); fclose(file); TRACE("File Open is Finished.\n"); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); //err_est->setMeshData(mesh); //smoother->computeNRingMeanCurvature(3); mesh->computeFaceNormal(); if(mesh->normal == NULL) mesh->computeNormal(); //smoother->GaussianNoise(0.05); //mesh->computeFaceNormal(); //mesh->computeNormal(); //return; /***************************** feature_detector->ridge(); //bunny 0.8, 0.6 feature_detector->automaticThresholding(0.6f, 0.3f); simplifier->setTagEdges(); //simplifier->setTagEdgesAngle(0.95f); //bunny = 0.75; simplifier->halfEdgeCollapse(2.5, true); simplifier->deleteSmallCycle(1.0); simplifier->deleteShortFeature(1.0); feature_detector->generatePairVertexRidge(simplifier->ridge_edge); delete mesh; //TRACE("RIDEG\n"); /*******************************/ /************************************** mesh = new MeshData; file = fopen(file_name,"r"); file_manager->setFile(file, file_name, file_ext); file_manager->open(mesh); fclose(file); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); mesh->computeFaceNormal(); mesh->computeNormal(); feature_detector->ridge(); feature_detector->automaticThresholding(0.8f, 0.6f); simplifier->setTagEdges(); //simplifier->setTagEdgesAngle(0.95f); simplifier->halfEdgeCollapse(0.3, false); simplifier->deleteSmallCycle(1.0); simplifier->deleteShortFeature(0.5); //feature_detector->generatePairVertexRidge(simplifier->ridge_edge); feature_detector->generatePairVertexRavine(simplifier->ravine_edge); delete mesh; //TRACE("RAVINE\n"); /***********************************/ /*************************** //simplifier->setTagEdgesAngle(0.95f); //simplifier->deleteShortFeature(0.5); feature_detector->ridge(); feature_detector->automaticThresholding(0.8f, 0.6f); //feature_detector->constantThresholding(2.0f); simplifier->setTagEdges(); simplifier->deleteSmallCycle(2.0); simplifier->deleteShortFeature(0.1); /* for(int i=0; i<8; i++){ //simplifier->deleteSmallCycle(2.0); simplifier->DK2(2.0f, -0.5f); mesh->computeFaceNormal(); mesh->computeNormal(); } simplifier->deleteSmallCycle(5.0); //simplifier->deleteShortFeature(0.5); /* do{ mesh->computeFaceNormal(); mesh->computeNormal(); simplifier->deleteSmallCycle(2.0); }while(simplifier->DK2(0, -1.0f)); mesh->computeFaceNormal();*/ /* feature_detector->generatePairVertex(simplifier->ridge_edge, simplifier->ravine_edge); delete mesh; */ /* for(int i=0; i<10; i++){ simplifier->DK2(2.0f, -0.5f); mesh->computeFaceNormal(); mesh->computeNormal(); } feature_detector->generatePairVertex(simplifier->ridge_edge, simplifier->ravine_edge); */ //delete mesh; /* do{ mesh->computeFaceNormal(); mesh->computeNormal(); }while(simplifier->DK2(2.0f, -0.5f)); mesh->computeFaceNormal(); feature_detector->generatePairVertex(simplifier->ridge_edge, simplifier->ravine_edge); delete mesh; */ /***************************/ /************************ feature_detector->ridge(); feature_detector->constantThresholding(1.0f); simplifier->setTagEdges(); do{ TRACE("DK\n"); mesh->computeNormal(); }while(simplifier->DK2(2.0f, 0.5f)); mesh->computeFaceNormal(); feature_detector->generatePairVertex(simplifier->ridge_edge, simplifier->ravine_edge); delete mesh; **************************/ /********** ridge path ******************** feature_detector->ridge(); feature_detector->constantThresholding(2.0f); TRACE("Ridge computation is Finished.\n"); simplifier->setRidgeAsTag(); do{ TRACE("DK\n"); mesh->computeNormal(); }while(simplifier->DK(0)); feature_detector->generateRidgePairVertex(); TRACE("Generate Ridge Pair\n"); delete mesh; *******************************************/ /************** ravine path **************** mesh = new MeshData; file = fopen(file_name,"r"); file_manager->setFile(file, file_name, file_ext); file_manager->open(mesh); fclose(file); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); feature_detector->ridge(); feature_detector->constantThresholding(2.0f); TRACE("Ridge computation is Finished.\n"); simplifier->setRavineAsTag(); do{ TRACE("DK\n"); mesh->computeNormal(); }while(simplifier->DK(0)); feature_detector->generateRavinePairVertex(); TRACE("Generate Ravine Pair\n"); delete mesh; ************************************************/ /*************** path computed *************** mesh = new MeshData; //file_name = "C:\\d8011101\\experiment\\Data\\o_bunny.ply2"; file = fopen(file_name,"r"); file_manager->setFile(file, file_name, file_ext); file_manager->open(mesh); fclose(file); mesh->computeFaceNormal(); mesh->computeNormal(); /************************************** smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); mesh->computePrincipal(); //feature_detector->connectPairVertex(); feature_detector->connectPairVertex(simplifier->ridge_cluster, simplifier->ravine_cluster); TRACE("PATH\n"); /**********************************************/ //this->drawMesh(VERTEX_CLUSTER); //this->drawMesh(TAG_EDGE); //this->drawMesh(RIDGE_PATH); //this->drawMesh(RIDGE_EDGE); vis_mode = FLAT_SHADING; //is_deformed = true; is_deformed = false; //this->drawMesh(); //this->drawMesh(COLOR); draw(); //mesh->computeVarienceAndHistogram(); } delete dia; } void CMeshEditorDoc::drawMesh() { float L[] = {20,20,40}; POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); if(mesh != NULL){ pView->vertex_count = mesh->countValidVertex(); pView->face_count = mesh->countValidFace(); } else{ pView->vertex_count = 0; pView->face_count = 0; return; } int i; float (*T)[3]; switch(vis_mode){ case FLAT_SHADING: if(is_deformed){ //mesh->computeNormal(); mesh->computeFaceNormal(); } pView->flatShade(mesh); break; case SMOOTH_SHADING: if(is_deformed){ mesh->computeNormal(); } pView->smoothShade(mesh); break; case WIRE_FRAME: if(is_deformed){ mesh->computeNormal(); } pView->wireFrame(mesh); break; case CURVATURE_COLOR: pView->flatShade(mesh); break; case PRINCIPAL_DIRECTION_MAX: if(is_deformed){ mesh->computeNormal(); mesh->computePrincipal(); } /* if(mesh->ridge_dir == NULL) mesh->computeRidgeDirection(); */ //pView->drawDisconT(mesh, false, tensor_dia->m_dire_T); pView->drawPrincipalDir(mesh, true, false, false, visual_dialog->m_gray_scale); break; case PRINCIPAL_DIRECTION_MIN: if(is_deformed){ mesh->computeNormal(); mesh->computePrincipal(); } pView->drawPrincipalDir(mesh, false, true, false, visual_dialog->m_gray_scale); break; case RIDGE_PRINCIPAL: pView->drawRidgeVertexAsSegmet(mesh, false, visual_dialog->m_gray_scale, true); //pView->wireFrame(mesh); //pView->drawRidgeTriangle(mesh); break; case RIDGE_RIDGE: pView->drawRidgeVertexAsSegmet(mesh, false, visual_dialog->m_gray_scale, false); break; case RIDGE_EDGE: pView->drawRidgeEdge(mesh, false, visual_dialog->m_gray_scale); break; case RIDGE_FACE: //pView->drawRidgeFace(mesh, true, false); break; case COLOR_MAX: if(is_deformed){ mesh->computeNormal(); mesh->computePrincipal(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) /* data[i] = 2.0*atan((mesh->k_min[i]+mesh->k_max[i])/ (mesh->k_min[i]-mesh->k_max[i]))/PI; if(data[i] > 0.25) data[i] = 1; else if(data[i] < -0.25) data[i] = -1; */ data[i] = mesh->k_max[i]; graph_win->setData(data, mesh->vertex_N); } T= new float[mesh->vertex_N][3]; for(i=0; ivertex_N; i++){ /* T[i][0] = 2.0*atan((mesh->k_min[i]+mesh->k_max[i])/ (mesh->k_min[i]-mesh->k_max[i]))/PI; if(T[i][0] > 0.25 && T[i][0] < 0.9) T[i][0] = 1; else if(T[i][0] < -0.25 && T[i][0] > -0.9) T[i][0] = -1; else T[i][0] = 0;*/ T[i][0] = (float)(mesh->k_max[i]);// mesh->k_min[i]; T[i][1] = 0; T[i][2] = 0; } //pView->drawDisconK(mesh, false, 10.0f); pView->drawColoredVertex(mesh, T, visual_dialog->m_gray_scale); delete[] T; break; case COLOR_MIN: if(is_deformed){ mesh->computeNormal(); mesh->computePrincipal(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) data[i] = mesh->k_min[i]; graph_win->setData(data, mesh->vertex_N); } T= new float[mesh->vertex_N][3]; for(i=0; ivertex_N; i++){ T[i][0] = (float)(mesh->k_min[i]);// + mesh->k_max[i]; T[i][1] = 0; T[i][2] = 0; } pView->drawColoredVertex(mesh, T, visual_dialog->m_gray_scale); delete[] T; break; case RIDGE_PATH: pView->drawRidgePath(mesh, feature_detector->normal_path, feature_detector->normal_path_N, feature_detector->ridge_path, feature_detector->ridge_path_N, feature_detector->ravine_path, feature_detector->ravine_path_N, false); break; case TAG_EDGE: if(is_deformed){ mesh->computeNormal(); mesh->computeFaceNormal(); if(angle_dia->m_threshold == 0) simplifier->setTagEdgesAngle((float)(-cos(PI*angle_dia->m_angle/180))); else //feature_detector->detectShapEdge((float)angle_dia->m_hi/100.0f, (float)angle_dia->m_row/100.0f); feature_detector->detectAngleMax((float)angle_dia->m_hi/100.0f, (float)angle_dia->m_row/100.0f); //simplifier->setTagEdgesAngle(-cos(PI*angle_dia->m_angle/180)); } pView->drawTagEdges(mesh, mesh->ridge_edge, mesh->ravine_edge, false, visual_dialog->m_gray_scale, angle_dia->m_shade); break; case VERTEX_CLUSTER: pView->drawVertexCluster(mesh, simplifier->ridge_cluster, false); break; case MAX_TENSOR: if(is_deformed){ mesh->computeNormal(); mesh->computePrincipal(); } pView->drawTensor(mesh, true, false, false, visual_dialog->m_gray_scale); break; case MIN_TENSOR: if(is_deformed){ mesh->computeNormal(); mesh->computePrincipal(); } pView->drawTensor(mesh, false, true, false, false); break; case TOTAL: if(is_deformed){ mesh->computeNormal(); mesh->computePrincipal(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) data[i] = fabs(mesh->k_min[i]) + fabs(mesh->k_max[i]); graph_win->setData(data, mesh->vertex_N); } T= new float[mesh->vertex_N][3]; for(i=0; ivertex_N; i++){ T[i][0] = (float)(fabs(mesh->k_min[i]) + fabs(mesh->k_max[i])); T[i][1] = 0; T[i][2] = 0; } pView->drawColoredVertex(mesh, T, visual_dialog->m_gray_scale); delete[] T; break; case MEAN: if(is_deformed){ mesh->computeNormal(); mesh->computePrincipal(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) data[i] = 0.5*(mesh->k_min[i] + mesh->k_max[i]); graph_win->setData(data, mesh->vertex_N); } T= new float[mesh->vertex_N][3]; for(i=0; ivertex_N; i++){ T[i][0] = 0.5f*(float)(mesh->k_min[i] + mesh->k_max[i]); /* if(T[i][0] > 0) T[i][0] = 100; else T[i][0] = -1;*/ T[i][1] = 0; T[i][2] = 0; } pView->drawColoredVertex(mesh, T, visual_dialog->m_gray_scale); delete[] T; break; case GAUSS: if(is_deformed){ mesh->computeNormal(); mesh->computePrincipal(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) data[i] = mesh->k_min[i]*mesh->k_max[i]; graph_win->setData(data, mesh->vertex_N); } T= new float[mesh->vertex_N][3]; for(i=0; ivertex_N; i++){ T[i][0] = (float)(mesh->k_min[i]*mesh->k_max[i]); T[i][1] = 0; T[i][2] = 0; } pView->drawColoredVertex(mesh, T, visual_dialog->m_gray_scale); delete[] T; break; case NON_MANI_VIEW: pView->drawNonManifold(mesh); break; case EDGE_COLOR: if(is_deformed){ mesh->computeFaceNormal(); mesh->computeEdgeCurvature(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->face_N*3]; for(int i=0; iface_N; i++) for(int j=0; j<3; j++) data[3*i+j] = mesh->k_edge[i][j]; graph_win->setData(data, 3*mesh->face_N); } pView->drawKEdge(mesh); break; case SILHOUETTE: if(is_deformed){ mesh->computeNormal(); } //pView->drawSilhouette(mesh); pView->drawHatch2(mesh, L, -0.5, 0); break; case MAX_STROKE: pView->drawTmaxAsLong(mesh); break; case MIN_STROKE: pView->drawTminAsLong(mesh); break; case POINTS: pView->drawPoints(mesh); break; /* case P_ERROR: BOOL *isBad = new BOOL[mesh->face_N]; smoother->badTriangles(isBad); T= new float[mesh->face_N][3]; for(i=0; iface_N; i++){ //if(p_error[i] > 0.1) if(isBad[i]) T[i][0] = 1; else T[i][0] = 0; } pView->drawColoredTriangle(mesh, T, visual_dialog->m_gray_scale); delete[] T; break; */ case VERTEX_ERROR: if(is_deformed){ double max; err_est->estimateVertexError(max); if(graph_win != NULL){ graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) data[i] = err_est->v_error[i]; graph_win->setData(data, mesh->vertex_N); } } T= new float[mesh->vertex_N][3]; for(i=0; ivertex_N; i++){ T[i][0] = err_est->v_error[i]; T[i][1] = 0; T[i][2] = 0; } pView->drawColoredVertex(mesh, T, visual_dialog->m_gray_scale); delete[] T; break; case FACE_ERROR: if(is_deformed){ double max; err_est->estimateFaceError(max); if(graph_win != NULL){ graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->face_N]; for(int i=0; iface_N; i++) data[i] = err_est->f_error[i]; graph_win->setData(data, mesh->face_N); } } T= new float[mesh->face_N][3]; for(i=0; iface_N; i++){ T[i][0] = err_est->f_error[i]; T[i][1] = 0; T[i][2] = 0; } pView->drawColoredTriangle(mesh, T, visual_dialog->m_gray_scale); delete[] T; break; case GAUSSIAN: pView->drawGaussianSupport(mesh); break; case SIGMA: pView->drawScaleMap(mesh, smoother->sigma); break; case DUAL: if(is_deformed){ mesh->computeNormal(); mesh->computeCenter(); } pView->drawDualGraph(mesh); break; case SOL: T= new float[mesh->face_N][3]; for(i=0; iface_N; i++){ T[i][0] = (float)rbf->sol[i+1]; T[i][1] = 0; T[i][2] = 0; } pView->drawColoredTriangle(mesh, T, visual_dialog->m_gray_scale); delete[] T; break; case RIDGEL: pView->drawRidgeL(mesh, false, visual_dialog->m_gray_scale); break; case RIDGES: pView->drawRidgeS(mesh, false, visual_dialog->m_gray_scale, ridge_B_dia->m_ridge_T, ridge_B_dia->m_ravine_T, ridge_B_dia->m_width); break; } is_deformed = false; //pView->Invalidate(TRUE); //pView->UpdateWindow(); } void CMeshEditorDoc::OnWire() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->normal_f == NULL) mesh->computeFaceNormal(); if(mesh->normal == NULL) mesh->computeNormal(); vis_mode = WIRE_FRAME; draw(); } } void CMeshEditorDoc::OnVisual() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(visual_dialog->DoModal() == IDOK){ POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); pView->setSize(visual_dialog->m_line, visual_dialog->m_point); draw(); } } void CMeshEditorDoc::OnAdSmooth() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(ad_smooth_dialog->DoModal() == IDOK){ if(last_mesh != NULL) delete last_mesh; last_mesh = new MeshData; last_mesh->copyMesh(mesh); if(mesh->face_link_V == NULL) mesh->generateFaceLinkV(); int iteration = ad_smooth_dialog->m_iteration; BOOL animate = ad_smooth_dialog->m_animate; int out_iter, in_iter, mod_iter; if(animate) in_iter = ad_smooth_dialog->m_interval; else{ if(iteration > 9) in_iter = iteration/10; else in_iter = 1; } out_iter = iteration/in_iter; mod_iter = iteration - out_iter*in_iter; pro_dia->m_progress.SetRange(0, iteration); pro_dia->m_progress.SetStep(in_iter); pro_dia->m_progress.SetPos(0); pro_dia->ShowWindow(SW_SHOW); int inner_iter = ad_smooth_dialog->m_inner_iter; float int_step = ad_smooth_dialog->m_int_step; int int_type = ad_smooth_dialog->m_integration; int d_type = ad_smooth_dialog->m_diff; int ave_iter = ad_smooth_dialog->m_ave_iter; int f_type = ad_smooth_dialog->m_func_type; int L_deg = ad_smooth_dialog->m_degree; int filter = ad_smooth_dialog->m_filter; if(filter == 0){ for(int i=0; iadaptiveSmoothing(in_iter, ad_smooth_dialog->m_threshold, ad_smooth_dialog->m_rate, int_type, inner_iter, int_step, d_type, ave_iter, f_type, L_deg); pro_dia->m_progress.StepIt(); if(animate){ is_deformed = true; draw(); } } pro_dia->ShowWindow(SW_HIDE); smoother->adaptiveSmoothing(mod_iter, ad_smooth_dialog->m_threshold, ad_smooth_dialog->m_rate, int_type, inner_iter, int_step, d_type, ave_iter, f_type, L_deg); } else{ for(int i=0; iadaptiveSmoothingM(in_iter, ad_smooth_dialog->m_isWeighted, int_type, inner_iter, int_step, d_type, ave_iter, L_deg); pro_dia->m_progress.StepIt(); if(animate){ is_deformed = true; draw(); } } pro_dia->ShowWindow(SW_HIDE); smoother->adaptiveSmoothingM(in_iter, ad_smooth_dialog->m_isWeighted, int_type, inner_iter, int_step, d_type, ave_iter, L_deg); } is_deformed = true; //vis_mode = SIGMA; draw(); } } void CMeshEditorDoc::OnAngle() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh == NULL) return; if(angle_dia->DoModal() == IDOK){ if(angle_dia->m_presmooth){ MeshData* current_mesh = new MeshData; current_mesh->copyMesh(mesh); vis_mode = TAG_EDGE; OnAdSmooth(); mesh->computeNormal(); mesh->computeFaceNormal(); if(angle_dia->m_threshold == 0) simplifier->setTagEdgesAngle((float)(-cos(PI*angle_dia->m_angle/180))); else //feature_detector->detectShapEdge((float)angle_dia->m_hi/100.0f, (float)angle_dia->m_row/100.0f); feature_detector->detectAngleMax((float)angle_dia->m_hi/100.0f, (float)angle_dia->m_row/100.0f); for(int i=0; ivertex_N; i++){ mesh->vertex[i][0] = current_mesh->vertex[i][0]; mesh->vertex[i][1] = current_mesh->vertex[i][1]; mesh->vertex[i][2] = current_mesh->vertex[i][2]; } mesh->computeNormal(); mesh->computeFaceNormal(); delete current_mesh; } else{ //simplifier->setTagEdgesAngle(0.9845f); /* mesh->generateFaceLinkV(); for(int i=0; i<100; i++); smoother->smoothNormalV(10, 1); */ //draw(); //return; if(angle_dia->m_threshold == 0) simplifier->setTagEdgesAngle((float)(-cos(PI*angle_dia->m_angle/180))); else //feature_detector->detectShapEdge((float)angle_dia->m_hi/100.0f, (float)angle_dia->m_row/100.0f); feature_detector->detectAngleMax((float)angle_dia->m_hi/100.0f, (float)angle_dia->m_row/100.0f); //simplifier->deleteShortFeature(0.5); //simplifier->deleteSmallCycle(1.5); //simplifier->deleteShortFeature(0.5); } vis_mode = TAG_EDGE; this->draw(); } } void CMeshEditorDoc::OnEdge() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ vis_mode = RIDGE_PRINCIPAL; draw(); } } void CMeshEditorDoc::OnEnhance() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください } void CMeshEditorDoc::OnFileSave() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください this->OnFileSaveAs() ; } void CMeshEditorDoc::OnFileSaveAs() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください CFileDialog* dia = new CFileDialog(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, NULL); if(dia->DoModal() == IDOK){ CString file_name = dia->GetPathName(); CString file_ext = dia->GetFileExt(); if(file_ext == ""){ file_ext = "ply2"; file_name += "." + file_ext; } FILE* file = fopen(file_name,"w"); //mesh->undoNormalizeScale(); file_manager->setFile(file, file_name, file_ext); file_manager->save(mesh); //mesh->normalizeScale(); fclose(file); } delete dia; } void CMeshEditorDoc::OnFlat() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ mesh->computeFaceNormal(); vis_mode = FLAT_SHADING; this->draw(); } } void CMeshEditorDoc::OnRidge() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh == NULL) return; if(ridge_dialog->DoModal() == IDOK){ //pre-smoothing MeshData* current_mesh = NULL; switch(ridge_dialog->m_pre_smoothing){ case 0: break; case 1: current_mesh = new MeshData; current_mesh->copyMesh(mesh); OnSmooth(); break; case 2: current_mesh = new MeshData; current_mesh->copyMesh(mesh); OnAdSmooth(); break; } if(mesh->k_max == NULL){ mesh->computeNormal(); mesh->computePrincipal(); } if(ridge_dialog->m_tensor) OnTensorSmooth(); //feature_detector->ridgeT(); feature_detector->ridge(); //Thresholding double T1, T2; switch(ridge_dialog->m_thresholding){ case 0: feature_detector->constantThresholding(0); T1 = T2 = 0; break; case 1: feature_detector->automaticThresholding(ridge_dialog->m_hi,ridge_dialog->m_low); //feature_detector->automaticThresholding(ridge_dialog->m_hi,ridge_dialog->m_low, T1, T2); break; case 2: feature_detector->constantThresholding(ridge_dialog->m_constant); T1 = T2 = ridge_dialog->m_constant; break; } if(ridge_dialog->m_cross) feature_detector->crossThresholding(); //feature_detector->addBridgeRR(0, 0); //feature_detector->ridgeTriangle(); /* if(ridge_dialog->m_connect){ if(ridge_dialog->m_thresholding == 1) feature_detector->connectRR(ridge_dialog->m_search, T1, T2, ridge_dialog->m_cross); else feature_detector->connectRR(ridge_dialog->m_search); }*/ //Visualization switch(ridge_dialog->m_data_type){ case 0: if(ridge_dialog->m_ridge_dir){ mesh->computeRidgeDirection(); vis_mode = RIDGE_RIDGE; if(current_mesh != NULL){ for(int i=0; ivertex_N; i++){ mesh->vertex[i][0] = current_mesh->vertex[i][0]; mesh->vertex[i][1] = current_mesh->vertex[i][1]; mesh->vertex[i][2] = current_mesh->vertex[i][2]; } mesh->computeNormal(); mesh->computeFaceNormal(); delete current_mesh; } draw(); } else{ vis_mode = RIDGE_PRINCIPAL; if(current_mesh != NULL){ for(int i=0; ivertex_N; i++){ mesh->vertex[i][0] = current_mesh->vertex[i][0]; mesh->vertex[i][1] = current_mesh->vertex[i][1]; mesh->vertex[i][2] = current_mesh->vertex[i][2]; } mesh->computeNormal(); mesh->computeFaceNormal(); delete current_mesh; } draw(); } break; case 1: feature_detector->setRidgeEdges(); //simplifier->setTagEdges(); if(ridge_dialog->m_connect){ //feature_detector->setRREdge2(0.6, 0.3, 10); //simplifier->deleteSmallCycle(1.0); //mesh->computeRidgeDirection(); //simplifier->deleteShortFeature(0.5); //feature_detector->connectRRE2(ridge_dialog->m_search); //simplifier->deleteShortFeature(ridge_dialog->m_search*0.5); //smoother->smoothTagEdges(5,0.3); //draw(TAG_EDGE); feature_detector->connectRRedge(ridge_dialog->m_search, T1, T2); } vis_mode = TAG_EDGE; //RIDGE_PRINCIPAL; if(current_mesh != NULL){ for(int i=0; ivertex_N; i++){ mesh->vertex[i][0] = current_mesh->vertex[i][0]; mesh->vertex[i][1] = current_mesh->vertex[i][1]; mesh->vertex[i][2] = current_mesh->vertex[i][2]; } mesh->computeNormal(); mesh->computeFaceNormal(); delete current_mesh; } if(ridge_dialog->m_edge_smooth){ smoother->smoothTagEdges(ridge_dialog->m_edge_iter,0.1f); } draw(); break; case 2: if(ridge_dialog->m_extraction){ // // } //draw(RIDGE_FACE); break; } } } void CMeshEditorDoc::OnSimplify() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください //simplifier->DK2(2.0f, -0.5f); if(decimation_dia->DoModal() == IDOK){ if(mesh->isRidge == NULL){ mesh->allocateTagEdges(); } //simplifier->setTagEdges(); if(last_mesh != NULL) delete last_mesh; last_mesh = new MeshData; last_mesh->copyMesh(mesh); //simplifier->halfEdgeCollapse((int)((1.0 - decimation_dia->m_rate)*mesh->countValidVertex())); simplifier->Garland(decimation_dia->m_rate, false); //simplifier->GralandWithCluster(decimation_dia->m_rate); MeshData* new_mesh = new MeshData; new_mesh->copyMesh2(mesh); delete mesh; mesh = new_mesh; //mesh = last_mesh; mesh->generateVertexLink(); mesh->generateFaceLink(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); mesh->computeFaceNormal(); mesh->computeNormal(); vis_mode = FLAT_SHADING; //vis_mode = VERTEX_CLUSTER; this->draw(); } } void CMeshEditorDoc::OnSmooth() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh == NULL) return; if(smooth_dialog->DoModal() == IDOK){ if(last_mesh != NULL) delete last_mesh; last_mesh = new MeshData; last_mesh->copyMesh(mesh); CString method = smooth_dialog->m_method; int iteration = smooth_dialog->m_iteration; BOOL animate = smooth_dialog->m_animate; int out_iter, in_iter, mod_iter; if(animate) in_iter = smooth_dialog->m_interval; else{ if(iteration > 9) in_iter = iteration/10; else in_iter = 1; } out_iter = iteration/in_iter; mod_iter = iteration - out_iter*in_iter; pro_dia->m_progress.SetRange(0, iteration); pro_dia->m_progress.SetStep(in_iter); pro_dia->m_progress.SetPos(0); pro_dia->ShowWindow(SW_SHOW); double init_vol = mesh->getVolume(); if(method == "Laplacian Flow"){ for(int i=0; iLaplacianFlowImplicit(smooth_dialog->m_step); smoother->LaplacianFlow(in_iter, smooth_dialog->m_step); //smoother->LaplacianWithRidge(in_iter, smooth_dialog->m_step); //smoother->BilaplacianWithRidge2(in_iter, smooth_dialog->m_step); pro_dia->m_progress.StepIt(); if(animate){ if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } //smoother->LaplacianLocalControl(iteration, smooth_dialog->m_step); smoother->LaplacianFlow(mod_iter, smooth_dialog->m_step); //smoother->LaplacianWithRidge(mod_iter, smooth_dialog->m_step); //smoother->BilaplacianWithRidge2(mod_iter, smooth_dialog->m_step); } else if(method == "Laplacian Flow (implicit)"){ float min_edge = mesh->minEdge(); float dt = smooth_dialog->m_step; //*min_edge*min_edge; for(int i=0; iMeanCurvatureFlowImplicit(dt); //smoother->meanCurvatureFlow(in_iter, dt); smoother->LaplacianFlowImplicit(dt); pro_dia->m_progress.StepIt(); if(animate){ if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } } else if(method == "Mean Curvature Flow (Desbrun)"){ float min_edge = mesh->minEdge(); float dt = smooth_dialog->m_step; //*min_edge*min_edge; for(int i=0; iMeanCurvatureFlowImplicit(dt); smoother->meanCurvatureFlow(in_iter, dt); pro_dia->m_progress.StepIt(); if(animate){ if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } smoother->meanCurvatureFlow(mod_iter, smooth_dialog->m_step); } else if(method == "Mean Curvature Flow (Desbrun, implicit)"){ float min_edge = mesh->minEdge(); float dt = smooth_dialog->m_step; //*min_edge*min_edge; for(int i=0; iMeanCurvatureFlowImplicit(dt); //smoother->meanCurvatureFlow(in_iter, dt); pro_dia->m_progress.StepIt(); if(animate){ if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } //smoother->MeanCurvatureFlowImplicit(smooth_dialog->m_step); //smoother->meanCurvatureFlow(mod_iter, smooth_dialog->m_step); } else if(method == "Modified Mean Curvature Flow (Curvature along Median)"){ float min_edge = mesh->minEdge(); float dt = smooth_dialog->m_step; //*min_edge*min_edge; for(int i=0; icurvatureAlongMedian(in_iter, dt); pro_dia->m_progress.StepIt(); if(animate){ if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } smoother->curvatureAlongMedian(mod_iter, smooth_dialog->m_step); } else if(method == "Taubin Smoothing (k=0.1)"){ float min_edge = mesh->minEdge(); float dt = smooth_dialog->m_step; //*min_edge*min_edge; for(int i=0; iTaubinMethod(in_iter, dt, 0.1f, 0); pro_dia->m_progress.StepIt(); if(animate){ if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } smoother->TaubinMethod(mod_iter, dt, 0.1f, 0); } else if(method == "Taubin Smoothing (k=0.1, w = 1/d)"){ float min_edge = mesh->minEdge(); float dt = smooth_dialog->m_step; //*min_edge*min_edge; for(int i=0; iTaubinMethod(in_iter, dt, 0.1f, 1); pro_dia->m_progress.StepIt(); if(animate){ if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } smoother->TaubinMethod(mod_iter, dt, 0.1f, 1); } else if(method == "Taubin Smoothing (k=0.1, w = Desbrun)"){ float min_edge = mesh->minEdge(); float dt = smooth_dialog->m_step; //*min_edge*min_edge; for(int i=0; iTaubinMethod(in_iter, dt, 0.1f, 2); pro_dia->m_progress.StepIt(); if(animate){ if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } smoother->TaubinMethod(mod_iter, dt, 0.1f, 2); } else if(method == "Bilaplacian (Kobbelt)"){ float min_edge = mesh->minEdge(); float dt = smooth_dialog->m_step; //*min_edge*min_edge; for(int i=0; iBilaplacian(in_iter, dt); pro_dia->m_progress.StepIt(); if(animate){ if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } smoother->Bilaplacian(mod_iter, dt); } //smoother->LaplacianWithRidge(smooth_dialog->m_iteration, smooth_dialog->m_step); //smoother->meanCurvatureFlow12Ring(smooth_dialog->m_iteration, smooth_dialog->m_step, 0.2f); pro_dia->ShowWindow(SW_HIDE); if(smooth_dialog->m_volume){ double vol = mesh->getVolume(); mesh->rescale(pow(init_vol/vol, 1.0/3.0)); } is_deformed = true; draw(); } } void CMeshEditorDoc::OnSubdivide() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh == NULL) return; if(subdiv_dia->DoModal() == IDOK){ if(last_mesh != NULL) delete last_mesh; last_mesh = new MeshData; last_mesh->copyMesh(mesh); CString method = subdiv_dia->m_method; if(method == "Loop"){ subdivider->LOOP(); } else if(method == "Modified butterfly"){ subdivider->butterfly(); } else if(method == "Normal averaging(angle)"){ //mesh->computeCenter(); //subdivider->subdivideTopologyBary(); subdivider->subdivideTopologySqrt3(); //subdivider->normalAverage(); } else{ subdivider->linear(); } is_deformed = true; draw(); } } void CMeshEditorDoc::OnSmoothShade() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->normal == NULL) mesh->computeNormal(); vis_mode = SMOOTH_SHADING; draw(); } } void CMeshEditorDoc::OnPrincipal() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->k_max == NULL){ mesh->computePrincipal(); //mesh->computePrincipalHeckbert(); } vis_mode = PRINCIPAL_DIRECTION_MAX; draw(); } } void CMeshEditorDoc::OnCurvature() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->k_max == NULL) mesh->computePrincipal(); //mesh->computePrincipalHeckbert(); //mesh->computeEdgeCurvature(); //mesh->computePrincipal2(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) //data[i] = 2.0*atan((mesh->k_min[i]+mesh->k_max[i])/ // (mesh->k_min[i]-mesh->k_max[i]))/PI; data[i] = mesh->k_max[i]; graph_win->setData(data, mesh->vertex_N); vis_mode = COLOR_MAX; draw(); } } void CMeshEditorDoc::OnTensorSmooth() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh == NULL) return; if(tensor_dia->DoModal() == IDOK){ if(mesh->k_max == NULL) mesh->computePrincipal(); int iteration = tensor_dia->m_cur_iteration; BOOL animate = tensor_dia->m_animate; int out_iter, in_iter, mod_iter; if(animate) in_iter = tensor_dia->m_interval; else{ if(iteration > 9) in_iter = iteration/10; else in_iter = 1; } out_iter = iteration/in_iter; mod_iter = iteration - out_iter*in_iter; pro_dia->m_progress.SetRange(0, iteration); pro_dia->m_progress.SetStep(in_iter); pro_dia->m_progress.SetPos(0); pro_dia->ShowWindow(SW_SHOW); if(tensor_dia->m_visual == 0) vis_mode = COLOR_MAX; else vis_mode = COLOR_MIN; for(int i=0; ismoothKmaxKmin2(in_iter, tensor_dia->m_cur_T); pro_dia->m_progress.StepIt(); if(animate){ draw(); } } smoother->smoothKmaxKmin2(mod_iter, tensor_dia->m_cur_T); draw(); iteration = tensor_dia->m_dire_iteration; animate = tensor_dia->m_animate; if(animate) in_iter = tensor_dia->m_interval; else{ if(iteration > 9) in_iter = iteration/10; else in_iter = 1; } out_iter = iteration/in_iter; mod_iter = iteration - out_iter*in_iter; pro_dia->m_progress.SetRange(0, iteration); pro_dia->m_progress.SetStep(in_iter); pro_dia->m_progress.SetPos(0); pro_dia->ShowWindow(SW_SHOW); if(tensor_dia->m_visual == 0) vis_mode = PRINCIPAL_DIRECTION_MAX; else vis_mode = PRINCIPAL_DIRECTION_MIN; for(i=0; ismoothTmaxTminSIG1(in_iter, tensor_dia->m_dire_T); smoother->smoothTmaxTmin3(in_iter, tensor_dia->m_dire_T); pro_dia->m_progress.StepIt(); if(animate){ draw(); } } //smoother->smoothTmaxTminSIG2(); //smoother->smoothTmaxTminSIG1(mod_iter, tensor_dia->m_dire_T); smoother->smoothTmaxTmin3(in_iter, tensor_dia->m_dire_T); draw(); pro_dia->ShowWindow(SW_HIDE); if(tensor_dia->m_visual == 0) vis_mode = MAX_TENSOR; else vis_mode = MIN_TENSOR; draw(); } } void CMeshEditorDoc::OnCurvature2() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->k_max == NULL) mesh->computePrincipal(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) data[i] = mesh->k_min[i]; graph_win->setData(data, mesh->vertex_N); vis_mode = COLOR_MIN; draw(); } } void CMeshEditorDoc::OnNoise() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(noise_dialog->DoModal() == IDOK){ if(last_mesh != NULL) delete last_mesh; last_mesh = new MeshData; last_mesh->copyMesh(mesh); //smoother->GaussianNoise(noise_dialog->m_size); smoother->addEdgeLengthNoise(noise_dialog->m_size); mesh->computeFaceNormal(); mesh->computeNormal(); vis_mode = FLAT_SHADING; this->draw(); } } void CMeshEditorDoc::OnGauss() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->k_max == NULL) mesh->computePrincipal(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) data[i] = mesh->k_max[i]*mesh->k_min[i]; graph_win->setData(data, mesh->vertex_N); vis_mode = GAUSS; draw(); } } void CMeshEditorDoc::OnMaxTensor() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->k_max == NULL) mesh->computePrincipal(); vis_mode = MAX_TENSOR; draw(); } } void CMeshEditorDoc::OnMean() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->k_max == NULL) mesh->computePrincipal(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) data[i] = 0.5*(mesh->k_max[i] + mesh->k_min[i]); graph_win->setData(data, mesh->vertex_N); vis_mode = MEAN; draw(); } } void CMeshEditorDoc::OnMinTensor() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->k_max == NULL) mesh->computePrincipal(); vis_mode = MIN_TENSOR; draw(); } } void CMeshEditorDoc::OnPrincipal2() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->k_max == NULL) mesh->computePrincipal(); vis_mode = PRINCIPAL_DIRECTION_MIN; draw(); } } void CMeshEditorDoc::OnTotal() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ if(mesh->k_max == NULL) mesh->computePrincipal(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->vertex_N]; for(int i=0; ivertex_N; i++) data[i] = fabs(mesh->k_max[i]) + fabs(mesh->k_min[i]); graph_win->setData(data, mesh->vertex_N); vis_mode = TOTAL; draw(); } } void CMeshEditorDoc::OnUndo() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(last_mesh != NULL){ delete mesh; mesh = last_mesh; last_mesh = NULL; mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); err_est->mesh = mesh; is_deformed = true; if(vis_mode == TAG_EDGE) vis_mode = FLAT_SHADING; draw(); } } void CMeshEditorDoc::OnViewDire() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); if(mesh != NULL){ pView->vertex_count = mesh->countValidVertex(); pView->face_count = mesh->countValidFace(); } view_angle_dia->m_Rx = pView->Rx; view_angle_dia->m_Ry = pView->Ry; view_angle_dia->m_Rz = pView->Rz; if(view_angle_dia->DoModal() == IDOK){ pView->Rx = view_angle_dia->m_Rx; pView->Ry = view_angle_dia->m_Ry; pView->Rz = view_angle_dia->m_Rz; draw(); } } void CMeshEditorDoc::draw() { POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); pView->draw(); } void CMeshEditorDoc::OnNonMani() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください vis_mode = NON_MANI_VIEW; draw(); } void CMeshEditorDoc::OnEdgeCurvature() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ mesh->computeFaceNormal(); mesh->computeEdgeCurvature(); graph_win->ShowWindow(SW_SHOW); double* data = new double[mesh->face_N*3]; for(int i=0; iface_N; i++) for(int j=0; j<3; j++) data[3*i+j] = mesh->k_edge[i][j]; graph_win->setData(data, 3*mesh->face_N); vis_mode = EDGE_COLOR; draw(); } } void CMeshEditorDoc::OnSil() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください vis_mode = SILHOUETTE; //hatch data mesh->generateSamplePointRandamly2(3000); mesh->computeHatchTriangle(tensor_dia->m_dire_T); //ridge and ravine data feature_detector->ridge(); double T1, T2; feature_detector->automaticThresholding(0.8f, 0.3f, T1, T2); feature_detector->crossThresholding(); feature_detector->subPixel(); mesh->computeRidgeDirection(); smoother->smoothRidgeDir3(20,20); feature_detector->generateRidgeLine2(2.0f, 0.01f, T1, T2); mesh->computeHatchTriangle(tensor_dia->m_dire_T); draw(); } void CMeshEditorDoc::OnMinStroke() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください vis_mode = MIN_STROKE; if(mesh->k_max == NULL) mesh->computePrincipal(); if(sample_dia->DoModal() == IDOK){ mesh->generateSamplePointRandamly2(sample_dia->m_amount); draw(); } } void CMeshEditorDoc::OnMaxStroke() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください vis_mode = MAX_STROKE; if(mesh->k_max == NULL) mesh->computePrincipal(); if(sample_dia->DoModal() == IDOK){ mesh->generateSamplePointRandamly2(sample_dia->m_amount); draw(); } } void CMeshEditorDoc::OnGreen() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); pView->color_type = 2; pView->initGL(); draw(); } void CMeshEditorDoc::OnRed() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); pView->color_type = 1; pView->initGL(); draw(); } void CMeshEditorDoc::OnBlue() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); pView->color_type = 3; pView->initGL(); draw(); } void CMeshEditorDoc::OnRgb() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); pView->color_type = 0; pView->initGL(); draw(); } void CMeshEditorDoc::OnPoints() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ vis_mode = POINTS; this->draw(); } } void CMeshEditorDoc::mesureError(FILE *v_err_file, FILE *n_err_file, FILE *k_err_file, FILE *v_max_file, FILE *n_max_file, FILE *k_max_file, int type) { if(type == 0){ func->setNormalAsGrd(mesh); double max; fprintf(v_err_file, "%f\n", func->EvaluateVertexError(mesh, max)); fprintf(v_max_file, "%f\n", max); fprintf(n_err_file, "%f\n", func->EvaluateNormalError(mesh, max)); fprintf(n_max_file, "%f\n", max); } else{ double max; fprintf(v_err_file, "%f\n", err_est->estimateVertexError(max)); fprintf(v_max_file, "%f\n", max); fprintf(n_err_file, "%f\n", err_est->estimateFaceError(max)); fprintf(n_max_file, "%f\n", max); } /* //func->setNormalAsGrd(mesh); double max; //double err = func->EvaluateVertexError(mesh, max); //fprintf(v_err_file, "%f\n", err); fprintf(v_err_file, "%f\n", err_est->estimateVertexError(max)); fprintf(v_max_file, "%f\n", max); //err = func->EvaluateNormalError(mesh, max); //fprintf(n_err_file, "%f\n", err); fprintf(n_err_file, "%f\n", err_est->estimateFaceError(max)); fprintf(n_max_file, "%f\n", max); //fprintf(k_err_file, "%f\n", err_est->estimateHnError(max)); //fprintf(k_max_file, "%f\n", max); //fprintf(n_err_file, "%f\n", err_est->estimateCorelationVertex()); //fprintf(v_max_file, "%f\n", max); */ /* err = func->EvaluateNormalError(mesh, max); fprintf(n_err_file, "%f\n", err); fprintf(n_max_file, "%f\n", max); err = func->EvaluateCurvatureError(mesh, max); fprintf(k_err_file, "%f\n", err); fprintf(k_max_file, "%f\n", max); */ } void CMeshEditorDoc::OnError() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください MeshData* original = new MeshData; original->copyMesh(mesh); FILE *v_f, *n_f, *k_f, *v_m, *n_m, *k_m; CString dire = "D:\\d8011101\\paper_data\\vmv02\\bunny05\\"; //CString dire = "H:\\WINDOWS\\pg02\\bunnyM\\"; CString name; func = new ImplicitFunction; err_est->setNoisy(); int type = 1; int N = 30; //400; //float T = 10; float T = 0; float dt = 0.6307f; //float dt2 = 0.0005; //float dt2 = 0.0001; //float dt2 = 0.0005; float dt2 = 0.0005f; int i; double init_vol = mesh->getVolume(); /* name = "Laplacian100"; //"Our_deri0"; //"torus_analy"; //"Curvature_NO_1";//"tmp1"; "Laplacian100"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->meanCurvatureFlow(1, dt2); //smoother->curvatureAlongMedian(1, dt2); smoother->LaplacianFlow(1, 0.05); mesh->rescale(pow(init_vol/mesh->getVolume(), 1.0/3.0)); //smoother->TaubinMethod(1, dt, 0.1, 0); //smoother->adaptiveSmoothing(1, T, 0.5, 1, 10, 0.1, 0, 1, 1, 1); //smoother->adaptiveSmoothing(1, 5, 0.5, 0, 1, 1.0, 1, 1, 1, 1); //smoother->meanCurvatureFlow(1, 0.00005); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); //////////////////////////////// mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "Taubin100"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->LaplacianFlow(1, 0.5); smoother->TaubinMethod(1, dt, 0.1, 0); //smoother->adaptiveSmoothing(1, 5, 0.5, 1, 10, 0.1, 1, 1, 1, 1); //smoother->adaptiveSmoothing(1, 5, 0.5, 0, 1, 1.0, 1, 1, 1, 1); //smoother->meanCurvatureFlow(1, 0.00005); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); ///////////////////////////////// /* mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "TaubinW100"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->LaplacianFlow(1, 0.5); smoother->TaubinMethod(3, dt, 0.1, 1); //smoother->adaptiveSmoothing(1, 5, 0.5, 1, 10, 0.1, 1, 1, 1, 1); //smoother->adaptiveSmoothing(1, 5, 0.5, 0, 1, 1.0, 1, 1, 1, 1); //smoother->meanCurvatureFlow(1, 0.00005); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); ////////////////////////////////////// /* mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "TaubinD100"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->LaplacianFlow(1, 0.5); smoother->TaubinMethod(12, dt, 0.1, 2); //smoother->adaptiveSmoothing(1, 5, 0.5, 1, 10, 0.1, 1, 1, 1, 1); //smoother->adaptiveSmoothing(1, 5, 0.5, 0, 1, 1.0, 1, 1, 1, 1); //smoother->meanCurvatureFlow(1, 0.00005); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); //////////////////////////////////// mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "Bilaplacian100"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->LaplacianFlow(1, 0.5); smoother->Bilaplacian(1, 0.5); //smoother->adaptiveSmoothing(1, 5, 0.5, 1, 10, 0.1, 1, 1, 1, 1); //smoother->adaptiveSmoothing(1, 5, 0.5, 0, 1, 1.0, 1, 1, 1, 1); //smoother->meanCurvatureFlow(1, 0.00005); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); ////////////////////////////////////// mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "Our_deri100"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->LaplacianFlow(1, 0.5); //smoother->TaubinMethod(1, 0.5, 0.1); //smoother->adaptiveSmoothing(1, T, 0.5, 1, 10, 0.1, 1, 1, 1, 1); smoother->adaptiveSmoothing(20, 0.1f, 0.5f, 1, 10, 0.1f, 0, 1, 1, 1); //smoother->meanCurvatureFlow(1, 0.00005); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); //////////////////////////////////////// mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "Our_dist100"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->LaplacianFlow(1, 0.5); //smoother->TaubinMethod(1, 0.5, 0.1); //smoother->adaptiveSmoothing(1, 5, 0.5, 1, 10, 0.1, 1, 1, 1, 1); smoother->adaptiveSmoothing(1, T, 0.5, 0, 1, 1.0, 1, 1, 1, 1); //smoother->meanCurvatureFlow(1, 0.00005); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); /////////////////////////////////////////// */ mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "Curvature100_2"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->LaplacianFlow(1, 0.5); //smoother->TaubinMethod(1, 0.5, 0.1); //smoother->adaptiveSmoothing(1, 5, 0.5, 1, 10, 0.1, 1, 1, 1, 1); //smoother->adaptiveSmoothing(1, 5, 0.5, 0, 1, 1.0, 1, 1, 1, 1); //for(int j=0; j<6; j++) smoother->MeanCurvatureFlowImplicit(dt2); mesh->rescale(pow(init_vol/mesh->getVolume(), 1.0/3.0)); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); /////////////////////////////////////// /* mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "Curvature_m100"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->LaplacianFlow(1, 0.5); //smoother->TaubinMethod(1, 0.5, 0.1); //smoother->adaptiveSmoothing(1, 5, 0.5, 1, 10, 0.1, 1, 1, 1, 1); //smoother->adaptiveSmoothing(1, 5, 0.5, 0, 1, 1.0, 1, 1, 1, 1); //smoother->meanCurvatureFlow(1, dt2); smoother->curvatureAlongMedian(1, dt2); mesh->rescale(pow(init_vol/mesh->getVolume(), 1.0/3.0)); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); */ //////////////////////////////////////// /* mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "Our_linear100"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); for(i=0; icomputeFaceNormal(); //smoother->LaplacianFlow(1, 0.5); //smoother->TaubinMethod(1, 0.5, 0.1); smoother->adaptiveSmoothing(1, T, 0.5, 1, 10, 0.1, 0, 1, 1, 1); //smoother->adaptiveSmoothing(1, 5, 0.5, 0, 1, 1.0, 1, 1, 1, 1); //smoother->meanCurvatureFlow(1, 0.00005); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); } fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); mesh->copyMesh(original); mesh->generateVertexLink(); mesh->generateFaceLink(); mesh->computeFaceNormal(); mesh->computeNormal(); smoother->setMeshData(mesh); feature_detector->setMeshData(mesh); simplifier->setMeshData(mesh); subdivider->setMeshData(mesh); is_deformed = true; name = "Gaussian_Iso"; v_f = fopen(dire + name + "_ev", "w"); n_f = fopen(dire + name + "_en", "w"); k_f = fopen(dire + name + "_ek", "w"); v_m = fopen(dire + name + "_mv", "w"); n_m = fopen(dire + name + "_mn", "w"); k_m = fopen(dire + name + "_mk", "w"); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); mesh->computeFaceNormal(); float c = 0.002f; smoother->adaptiveGaussianSmoothing(c, gauss_dia->m_anistropic, 10.0f); mesureError(v_f, n_f, k_f, v_m, n_m, k_m, type); fclose(v_f); fclose(n_f); fclose(k_f); fclose(v_m); fclose(n_m); fclose(k_m); */ } void CMeshEditorDoc::OnFaceError() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください /* func = new ImplicitFunction; func->setNormalAsGrd(mesh); if(p_error == NULL) p_error = new float[mesh->face_N]; func->EvaluateNormalError(mesh, p_error); */ /* double max; err_est->estimateFaceError(max); */ is_deformed = true; vis_mode = FACE_ERROR; draw(); } void CMeshEditorDoc::OnVertexError() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください /* double max; err_est->estimateVertexError(max); */ is_deformed = true; vis_mode = VERTEX_ERROR; draw(); } void CMeshEditorDoc::selectTriangle(float s[], float d[]) { if(mesh != NULL){ int f = mesh->selectTriangle(s, d); if(f < 0) return; float e = mesh->averageOfEdgeLength(); //smoother->checkGaussianSupport(f, 5.0f*e, 5.0f/e);//0.5*smoother->computeSigma1(f, 10)); smoother->checkGauusianSupportDikstra(f, 8.0f*e, 20.0f); //smoother->checkGaussianSupportDikstra2(f, 4.0f*e, 10.0f*e*e); vis_mode = GAUSSIAN; draw(); } } void CMeshEditorDoc::OnFlip() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh != NULL){ smoother->antialiasingEdgeFlip(); is_deformed = true; draw(); } } void CMeshEditorDoc::OnAdGauss() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh == NULL) return; if(gauss_dia->DoModal() == IDOK){ float c; if(gauss_dia->m_effect == 0) c = 0.0002f; else if(gauss_dia->m_effect == 1) c = 0.002f; else c = 0.02f; smoother->adaptiveGaussianSmoothing(c, gauss_dia->m_anistropic, 10.0); is_deformed = true; vis_mode = SIGMA; draw(); } } void CMeshEditorDoc::OnDual() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(mesh == NULL) return; if(mesh->center == NULL) mesh->computeCenter(); if(mesh->normal == NULL) mesh->computeNormal(); vis_mode = DUAL; draw(); } void CMeshEditorDoc::OnWhite() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください POSITION pos = GetFirstViewPosition(); CMeshEditorView* pView = (CMeshEditorView*)GetNextView(pos); pView->color_type = 5; pView->initGL(); draw(); } void CMeshEditorDoc::OnSavePoint() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください CFileDialog* dia = new CFileDialog(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, NULL); if(dia->DoModal() == IDOK){ CString file_name = dia->GetPathName(); CString file_ext = dia->GetFileExt(); if(file_ext == ""){ file_ext = "pwn"; file_name += "." + file_ext; } FILE* file = fopen(file_name,"w"); //mesh->undoNormalizeScale(); //for(int i=0; i< 10; i++) //smoother->smoothNormalL(); file_manager->setFile(file, file_name, file_ext); file_manager->save(mesh); //mesh->normalizeScale(); fclose(file); } delete dia; } void CMeshEditorDoc::OnRbfFit() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください if(rbf != NULL) delete rbf; rbf = new RBF; rbf->mesh = mesh; rbf->fittingDual(2); //rbf->setNormalAsGradient(); vis_mode = SOL; draw(); } void CMeshEditorDoc::OnBelyaevCgi98() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください //feature_detector->ridgeBelyaevCGI98(); if(ridge_B_dia->DoModal() == IDOK){ feature_detector->ridgeBelyaevCGI98S(); vis_mode = RIDGES; draw(); } } void CMeshEditorDoc::OnSaveDual() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください CFileDialog* dia = new CFileDialog(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, NULL); if(dia->DoModal() == IDOK){ CString file_name = dia->GetPathName(); CString file_ext = dia->GetFileExt(); FILE* file = fopen(file_name,"w"); //mesh->undoNormalizeScale(); //for(int i=0; i< 10; i++) //smoother->smoothNormalL(); file_manager->setFile(file, file_name, file_ext); file_manager->saveDualMesh(mesh); //mesh->normalizeScale(); fclose(file); } delete dia; } void CMeshEditorDoc::OnSaveRr() { // TODO: この位置にコマンド ハンドラ用のコードを追加してください CFileDialog* dia = new CFileDialog(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, NULL); if(dia->DoModal() == IDOK){ CString file_name = dia->GetPathName(); CString file_ext = dia->GetFileExt(); FILE* file = fopen(file_name,"w"); file_manager->setFile(file, file_name, file_ext); file_manager->saveRR(mesh); fclose(file); } delete dia; }