"justify"> (! feof (fp)) {cd; (fp, % d , amp; cd.x); (fp, % d , amp; cd.y ); (fp, % d , amp; cd.z); _ coords.append (cd);
} (fp); () lt; lt; QString ( Read% 1 lines. ). arg (m_coords.size ());
}
//-------------------------------------------------------------------------------------------
void Thinner :: start () {() lt; lt; QString ( Thinner start processing );=0;=0; (m_coords.size ()!=sz) {= m_coords.size (); :: comparison=i% 3; ++; (); (); (coords :: comparison == 2) ( tmp.prn ); () lt; lt; QString ( I'm working% 1 coords. ). arg (m_coords.size ());
} () lt; lt; QString ( Thinner finish% 1. ). arg (m_coords.size ());
} Thinner :: toFile (constQString amp; filename) {(filename); (file.open (QIODevice :: WriteOnly)) { lt; coords gt; :: Iterator it=m_coords.begin (); (it!=m_coords.end ()) {cd=* it;=QString (% 1% 2% 3 n ). arg (cd.x) .arg (cd.y) .arg (cd. z) ;. write (sd.toLocal8Bit ());
++ it;
}. close (); () lt; lt; QString ( Save to file% 1. ). arg (filename);
}
}
//-------------------------------------------------------------------------------------------Thinner::fill(){lt;coordsgt;::Iterator it=m_coords.begin (); cd1=* it;
++ it; (it!=m_coords.end ()) {cd2=* it;
//обробка x (cd1.z == cd2.z amp; amp; cd1.y == cd2.y) {; .z=cd1.z; .y=cd1.y; (cd1.x gt; cd2.x + 1) {.x=cd1.x - 1;
} if (cd2.x gt; cd1.x + 1) {.x=cd2.x - 1;
} {
++ it;=cd2 ;;
}=cdnew;=m_coords.insert (it, cdnew) ;;
}
//обробка y (cd1.z == cd2.z amp; amp; cd1.x == cd2.x) {; .z=cd1.z; .x=cd1.x; (cd1.y gt; cd2.y + 1) {.y=cd1.y - 1;
} if (cd2.y gt; cd1.y + 1) {.y=cd2.y - 1;
} {
++ it;=cd2 ;;
}=cdnew;=m_coords.insert (it, cdnew) ;;
}
//обробка Z (cd.x == cd2.x amp; amp; cd1.y == cd2.y) {; .x=cd1.x; .y=cd1.y; (cd1.z gt; cd2.z + 1) {.z=cd1.z - 1;
} if (cd2.z gt; cd1.z + 1) {.z=cd2.z - 1;
} {
++ it;=cd2 ;;
}=cdnew;=m_coords.insert (it, cdnew) ;;
}=cd2;
++ it;
}}
//-------------------------------------------------------------------------------------------Thinner::sort(){lt;coordsgt;newList;(m_coords.size() gt; 0) { lt; coords gt; :: Iterator it=m_coords.begin (); lt; coords gt; :: Iterator smaller=it; (it!=M_coords.end ()) {(* smaller gt; * it) {= it;
}
++ it;
}. append (* smaller); _ coords.erase (smaller);
} _ coords=newList;
}
ФайлThinner.h
# ifndefThinner_h
# define Thinner_h
# include lt; QList gt;
{x; y; z; comparison;
: operator gt; (constcoords amp; rv) const {(comparison == 0) {(x gt; rv.x) {true;
} (x == rv.x) {(y gt; rv.y) {true;
} (y == rv.y) {(z gt;=rv.z) {true;
}
} false;
} false;
} if (comparison == 1) {(y gt; rv.y) {true;
} (y == rv.y) {(z gt; rv.z) {true;
} (z == rv.z) {(x gt;=rv.x) {true;
}
} false;
} false;
} if (comparison == 2) {(z gt; rv.z) {true;
} (z == rv.z) {(x gt; rv.x) {true;
} (x == rv.x) {(y gt;=rv.y) {true;
}
} false;
} false;
} false;
}
};
Thinner {
: ();
~ Thinner ();
load (constQString amp; filename); start (); (constQString amp; filename);
: sort (); fill ();
lt; coords gt; m_coords;
};
# endif//Thinner_h
Додаток 2
Лістинг програми розрахунк...