📄 diffshapes.cpp
字号:
// $util\diffShapes.cpp 1.5 milbo$// Compare two shape files and print the differences// Warning: this is raw research code -- expect it to be quite messy.// milbo july 07 petaluma//-----------------------------------------------------------------------------// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// A copy of the GNU General Public License is available at// http://www.r-project.org/Licenses///-----------------------------------------------------------------------------#include "all.hpp"#define INFILE1 "/a/m/shape/84.shape"#define INFILE2 "/a/m/shape/84remarked.shape"//#define INFILE1 "/a/m.extra/shape/old/m2.shape"//#define INFILE2 "/a/m.extra/shape/old/m4.shape"// nDifferent 0 68.shape 84.shape// nDifferent 0 68.shape m2.shape// nDifferent 848 68.shape m3.shape// nDifferent 848 m2.shape m4.shape// nDifferent 0 m2.shape m2vts.shapeint main (void){ int nDifferent = 0; ShapeVec Shapes1, Shapes2; // array[nShapes] of SHAPE StringVec TagStrings1, TagStrings2; // array[nShapes] of string char sImageDirs[SLEN]; // image directories at head of shape file const unsigned Mask1 = 0; const unsigned Mask2 = 0; ReadShapeFile(&Shapes1, TagStrings1, sImageDirs, " mr", Mask1, Mask2, INFILE1, QUIET); DiscardGlobalFaceDetectorShapes(&Shapes1, TagStrings1, AT_DISCARD_UNDERSCORES); printf("%d shapes\n", Shapes1.size()); ReadShapeFile(&Shapes2, TagStrings2, sImageDirs, " mr", Mask1, Mask2, INFILE2, QUIET); DiscardGlobalFaceDetectorShapes(&Shapes2, TagStrings2, AT_DISCARD_UNDERSCORES); printf("%d shapes\n", Shapes2.size()); const int nShapes = min(Shapes1.size(), Shapes2.size()); bool fDiffNbrRows = false; for (int iShape = 0; iShape < nShapes; iShape++) { if (!fDiffNbrRows && Shapes1[iShape].nrows() != Shapes2[iShape].nrows()) { Warn("%s %s iShape %d Shapes1[iShape].nrows() %d != Shapes2[iShape].nrows() %d", TagStrings1[iShape].c_str(), TagStrings2[iShape].c_str(), iShape, Shapes1[iShape].nrows(), Shapes2[iShape].nrows()); fDiffNbrRows = true; } const int nrows = min(Shapes1[iShape].nrows(), Shapes2[iShape].nrows()); Shapes1[iShape].dimKeep(nrows, 2); Shapes2[iShape].dimKeep(nrows, 2); if(Shapes1[iShape].ncols() != Shapes2[iShape].ncols()) Err("%s %s iShape %d Shapes1[iShape].ncols() %d != Shapes2[iShape].ncols() %d", TagStrings1[iShape].c_str(), TagStrings2[iShape].c_str(), iShape, Shapes1[iShape].ncols(), Shapes2[iShape].ncols()); if(Shapes1[iShape].ncols() != 2) Err("%s %s iShape %d Shapes1[iShape].ncols() %d != 2", TagStrings1[iShape].c_str(), TagStrings2[iShape].c_str(), iShape, Shapes1[iShape].ncols()); SHAPE Shape = Shapes1[iShape] - Shapes2[iShape]; bool fFirst = true; for (int iRow = 0; iRow < nrows; iRow++) { if (ABS(Shape(iRow, VX)) > 0.1 || ABS(Shape(iRow, VY)) > 0.5) { if (fFirst) { nDifferent++; fFirst = false; printf("%s %s row ", TagStrings1[iShape].c_str(), TagStrings2[iShape].c_str()); } printf("%d ", iRow); } } if (!fFirst) printf("\n"); } printf("nDifferent %d %s %s\n", nDifferent, INFILE1, INFILE2); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -