The specific method is: open an OBJ file and findV X Y ZAnd then the Z string is processed as a symbol:
If it is "-", delete the symbol directly. If it is not "-" And the Z value is not 0, add "-" to the string of Z "-".
Example (original file box. OBJ)
#
# Object box01
#
V-39.306316-32.828358-29.183971
V-39.306316 33.259296-29.183971
V 39.726025 33.259296-29.183971
V 39.726025-32.828358-29.183971
V-39.306316-32.828358 26.914204
V 39.726025-32.828358 26.914204
V 39.726025 33.259296 26.914204
V-39.306316 33.259296 26.914204
-----------------------------------
Converted file (box. obj. Flip ):
#
# Object box01
#
V-39.306316-32.828358 29.183971
V-39.306316 33.259296 29.183971
V 39.726025 33.259296 29.183971
V 39.726025-32.828358 29.183971
V-39.306316-32.828358-26.914204
V 39.726025-32.828358-26.914204
V 39.726025 33.259296-26.914204
V-39.306316 33.259296-26.914204
Code implementation:
1 #include <fstream.h> 2 #include <math.h> 3 4 bool work(const char* path) 5 { 6 char chs[1000]; 7 double x,y,z; 8 CString newPath(path); 9 newPath += ".flip";10 const char* chNewPath = newPath;11 ofstream opf(chNewPath);12 if (!opf.is_open()) return false;13 ifstream pf(path);14 if (!pf.is_open()) {opf.close();return false;}15 16 while (!pf.eof())17 {18 pf.getline(chs, 1000, '\n');19 if (sscanf(chs, "v %lf %lf %lf", &x, &y, &z)==3)20 {21 CString strChs(chs);22 int spacePos=strChs.ReverseFind(' ');23 char c=strChs.GetAt(spacePos+1);24 25 opf<<(LPCTSTR)(strChs.Left(spacePos+1));26 if (c=='-')27 {28 opf<<(LPCTSTR)(strChs.Right(strChs.GetLength()-spacePos-2))<<endl;29 }30 else31 {32 if (fabs(z)>1e-6) opf<<"-";33 opf<<(LPCTSTR)(strChs.Right(strChs.GetLength()-spacePos-1))<<endl;34 }35 }36 else37 {38 opf << chs << endl;39 }40 }41 42 opf.close();43 pf.close();44 return true;45 }