|
@@ -14,6 +14,8 @@
|
|
|
#include <igl/viewer/Viewer.h>
|
|
|
#include <sstream>
|
|
|
|
|
|
+#include <igl/serialize.h>
|
|
|
+#include <igl/xml/serialize_xml.h>
|
|
|
// Input mesh
|
|
|
Eigen::MatrixXd V;
|
|
|
Eigen::MatrixXi F;
|
|
@@ -55,6 +57,49 @@ Eigen::MatrixXi FUV_seams;
|
|
|
Eigen::MatrixXd UV;
|
|
|
Eigen::MatrixXi FUV;
|
|
|
|
|
|
+// Serialization state
|
|
|
+struct MIQState : public igl::Serializable
|
|
|
+{
|
|
|
+ Eigen::MatrixXd UV;
|
|
|
+ Eigen::MatrixXi FUV;
|
|
|
+
|
|
|
+ // You have to define this function to
|
|
|
+ // register the fields you want to serialize
|
|
|
+ void InitSerialization()
|
|
|
+ {
|
|
|
+ this->Add(UV , "UV");
|
|
|
+ this->Add(FUV , "FUV");
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual ~MIQState(){}
|
|
|
+
|
|
|
+ void printDiff(const MIQState &other, std::ostream& out = std::cout){
|
|
|
+ std::cout << "Start Diff..\n";
|
|
|
+ out << "Checking UV..\n";
|
|
|
+ int nErrorsUV = 0;
|
|
|
+ for(int i = 0; i < UV.rows(); i++){
|
|
|
+ if(UV.row(i) != other.UV.row(i)){
|
|
|
+ if(nErrorsUV == 0)
|
|
|
+ out << "Index\tthisUV\totherUV\n";
|
|
|
+ out << i << UV(i,0) << "\t" << UV(i,1) << "\t" << other.UV(i,0) << "\t" << other.UV(i,1) << std::endl;
|
|
|
+ nErrorsUV++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ out << "Checking FUV..\n";
|
|
|
+ int nErrorsFUV = 0;
|
|
|
+ for(int i = 0; i < FUV.rows(); i++){
|
|
|
+ if(FUV.row(i) != other.FUV.row(i)){
|
|
|
+ if(nErrorsFUV == 0)
|
|
|
+ out << "Index\tthisFUV\totherFUV\n";
|
|
|
+ out << i << FUV(i,0) << "\t" << FUV(i,1) << "\t" << other.FUV(i,0) << "\t" << other.FUV(i,1) << std::endl;
|
|
|
+ nErrorsFUV++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ std::cout << "Finished.\n" << nErrorsUV << " errors in UV.\n" << nErrorsFUV << " errors in FUV.\n";
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
// Create a texture that hides the integer translation in the parametrization
|
|
|
void line_texture(Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> &texture_R,
|
|
@@ -397,6 +442,34 @@ igl::comiso::miq(V,
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ viewer.ngui->addNewGroup("Check results");
|
|
|
+ viewer.ngui->addButton("Serialize results", [&](){
|
|
|
+ auto path = nanogui::file_dialog({}, true);
|
|
|
+
|
|
|
+ if(path != ""){
|
|
|
+ MIQState miqstate;
|
|
|
+ miqstate.UV = UV;
|
|
|
+ miqstate.FUV = FUV;
|
|
|
+ // Serialize the state of the application
|
|
|
+ igl::serialize(miqstate,"MIQState",path,true);
|
|
|
+ std::cout << "Serialized UV(" << UV.rows() << " rows) and FUV(" << FUV.rows() << " rows)\n";
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ viewer.ngui->addButton("Check results with reference", [&](){
|
|
|
+ auto path = nanogui::file_dialog({ {"*", "Any file"}, }, true);
|
|
|
+
|
|
|
+ if(path != ""){
|
|
|
+ MIQState miqstate_ref, miqstate;
|
|
|
+ miqstate.UV = UV;
|
|
|
+ miqstate.FUV = FUV;
|
|
|
+ // Serialize the state of the application
|
|
|
+ igl::deserialize(miqstate_ref,"MIQState",path);
|
|
|
+ std::cout << "this = reference\n";
|
|
|
+ miqstate_ref.printDiff(miqstate);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
viewer.ngui->layout();
|
|
|
return false;
|