first release version

This commit is contained in:
Nico Pietroni 2012-10-18 00:42:37 +00:00
parent 01d2f9eae8
commit 154e88ee21
8 changed files with 56029 additions and 0 deletions

View File

@ -0,0 +1,51 @@
include (./predefinitions.pro)
QT += core
QT -= gui
TARGET = miq
TEMPLATE = app
# This is needed by CoMISo
DEFINES += INCLUDE_TEMPLATES
INCLUDEPATH += $$COMISODIR/include
INCLUDEPATH += $$COMISODIR/Solver
INCLUDEPATH += $$COMISODIR/..
# include of vcg library
INCLUDEPATH += $$VCGLIBDIR
# CORE
HEADERS += $$VCGLIBDIR/wrap/miq/core/vertex_indexing.h \
HEADERS += $$VCGLIBDIR/wrap/miq/core/poisson_solver.h
HEADERS += $$VCGLIBDIR/wrap/miq/quadrangulator.h
HEADERS += $$VCGLIBDIR/wrap/miq/core/param_stats.h
HEADERS += $$VCGLIBDIR/wrap/miq/MIQ.h
HEADERS += $$VCGLIBDIR/wrap/miq/core/glUtils.h
HEADERS += $$VCGLIBDIR/wrap/miq/core/seams_initializer.h
HEADERS += $$VCGLIBDIR/wrap/miq/core/stiffening.h
#SOURCES += $$VCGLIBDIR/wrap/miq/MIQ.cpp
# VCG
HEADERS += $$VCGLIBDIR/vcg/complex/algorithms/parametrization/tangent_field_operators.h
HEADERS += $$VCGLIBDIR/vcg/complex/algorithms/parametrization/distortion.h
HEADERS += $$VCGLIBDIR/wrap/io_trimesh/import_field.h
HEADERS += $$VCGLIBDIR/wrap/io_trimesh/export_field.h
SOURCES += $$VCGLIBDIR/wrap/ply/plylib.cpp
SOURCES += main.cpp
# Awful problem with windows..
win32{
DEFINES += NOMINMAX
}
mac{
# Mac specific Config required to avoid to make application bundles
CONFIG += console
CONFIG -= app_bundle
LIBS += -framework OpenGL
LIBS += -L/opt/local/lib -lamd -lcamd -lccolamd -lcholmod -lcolamd -lcxsparse -lblas -framework accelerate
}

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,6 @@
mesh=bunny.ply
field=bunny.ffield
scalegradient=1
gradient=60
directround=0
out=bunny_quad.obj

View File

@ -0,0 +1,142 @@
#include "mesh_type.h"
#include <wrap/miq/MIQ.h>
#include <wrap/miq/quadrangulator.h>
#include <wrap/io_trimesh/import_ply.h>
#include <wrap/io_trimesh/import_off.h>
#include <wrap/io_trimesh/import_obj.h>
using namespace std;
CMesh trimesh;
MyPolyMesh polymesh;
bool OpenTriMesh(std::string PathMesh)
{
int position;
position=PathMesh.find(".ply");
if (position!=-1)
{
int err=vcg::tri::io::ImporterPLY<CMesh>::Open(trimesh,PathMesh.c_str());
return (err==vcg::ply::E_NOERROR);
}
position=PathMesh.find(".obj");
if (position!=-1)
{
int mask;
bool readed=vcg::tri::io::ImporterOBJ<CMesh>::LoadMask(PathMesh.c_str(),mask);
if (!readed)return false;
int err=vcg::tri::io::ImporterOBJ<CMesh>::Open(trimesh,PathMesh.c_str(),mask);
return (err==vcg::tri::io::ImporterOBJ<CMesh>::E_NOERROR);
}
position=PathMesh.find(".off");
assert(position!=-1);
int mask;
bool readed=vcg::tri::io::ImporterOFF<CMesh>::LoadMask(PathMesh.c_str(),mask);
if (!readed)return false;
int err=vcg::tri::io::ImporterOFF<CMesh>::Open(trimesh,PathMesh.c_str(),mask);
return (err==0);
}
int main(int argc, const char * argv[])
{
const char* configfile;
if (argc != 2)
{
cout << "Not enough parameters: ./MIQ configfile" << endl;
exit(EXIT_FAILURE);
}
configfile = argv[1];
printf("configuration file %s",configfile);
fflush(stdout);
// Read Config File
FILE *f= fopen(configfile,"r");
if (f==NULL)
{
printf("Cannot open config file\n");
return -1;
}
char buff[200];
// Mesh name
fscanf(f,"mesh=%s\n",&buff[0]);
std::string filename = std::string(buff);
printf("FILENAME %s",filename.c_str());
fflush(stdout);
bool opened=OpenTriMesh(filename);
if (!opened)
{
printf("error loading mesh file \n");
exit(0);
}
vcg::tri::UpdateBounding<CMesh>::Box(trimesh);
vcg::tri::UpdateNormal<CMesh>::PerVertexNormalizedPerFace(trimesh);
vcg::tri::UpdateNormal<CMesh>::PerFaceNormalized(trimesh);
vcg::tri::UpdateTopology<CMesh>::FaceFace(trimesh);
vcg::tri::UpdateTopology<CMesh>::VertexFace(trimesh);
vcg::tri::UpdateFlags<CMesh>::FaceBorderFromFF(trimesh);
vcg::tri::UpdateFlags<CMesh>::VertexBorderFromFace(trimesh);
// Field name
fscanf(f,"field=%s\n",&buff[0]);
std::string fieldname = std::string(buff);
int position=fieldname.find(".ffield");
if (position==-1)
{
printf("error loading mesh file \n");
exit(0);
}
bool field_loaded=vcg::tri::io::ImporterFIELD<CMesh>::LoadFFIELD(trimesh,fieldname.c_str());
if (!field_loaded)return false;
int scalegradient;
fscanf(f,"scalegradient=%d\n",&scalegradient);
// Gradient Size
float GradientSize;
fscanf(f,"gradient=%f\n",&GradientSize);
if (scalegradient!=0)
GradientSize*=1.0/trimesh.bbox.Diag();
// Stiffness
float Stiffness=4;
// DirectRounding
int DirectRound;
fscanf(f,"directround=%d\n",&DirectRound);
// Number of iterations
int iter=10;
// Number of local iterations
int localIter=5;
// Output name
fscanf(f,"out=%s\n",&buff[0]);
std::string out = std::string(buff);
position=out.find(".obj");
if (position==-1)
{
printf("error output mesh file \n");
exit(0);
}
bool isvalid=MIQ_parametrization<CMesh>::IsValid(trimesh);
if (!isvalid)
{
printf("mesh not valid for parametrization \n");
exit(0);
}
MIQ_parametrization<CMesh>::InitSeamsSing(trimesh,true,true,true);
MIQ_parametrization<CMesh>::Parametrize(trimesh,MIQ_parametrization<CMesh>::ITERATIVE,Stiffness,GradientSize,(bool)DirectRound,iter,localIter,true);
Quadrangulator<CMesh,MyPolyMesh> Quad;
Quad.TestIsProper(trimesh);
Quad.Quadrangulate(trimesh,polymesh);
vcg::tri::io::ExporterOBJ<MyPolyMesh>::Save(polymesh,out.c_str(),0);
fclose(f);
}

View File

@ -0,0 +1,68 @@
#ifndef MESH_TYPE_H
#define MESH_TYPE_H
///vcg imports
#include <vcg/complex/complex.h>
#include <vcg/complex/algorithms/update/bounding.h>
#include <vcg/complex/algorithms/update/normal.h>
#include <vcg/complex/algorithms/update/topology.h>
#include <vcg/simplex/face/topology.h>
#include <vcg/complex/algorithms/parametrization/tangent_field_operators.h>
///wrapper imports
#include <wrap/io_trimesh/import.h>
#include <wrap/io_trimesh/export.h>
#include <wrap/miq/core/param_stats.h>
using namespace vcg;
class CFace;
class CVertex;
struct MyUsedTypes : public UsedTypes< Use<CVertex>::AsVertexType, Use<CFace>::AsFaceType >{};
/// compositing wanted proprieties
class CVertex : public vcg::Vertex< MyUsedTypes,
vcg::vertex::Coord3d, vcg::vertex::Normal3d,
vcg::vertex::BitFlags,vcg::vertex::VFAdj,
vcg::vertex::TexCoord2d,vcg::vertex::Qualityd>{};
class CFace : public vcg::Face< MyUsedTypes, vcg::face::VertexRef,
vcg::face::VFAdj, vcg::face::FFAdj,vcg::face::Normal3d,
vcg::face::WedgeTexCoord2d,vcg::face::BitFlags ,
vcg::face::CurvatureDird,vcg::face::Qualityd,vcg::face::Color4b,
vcg::face::Mark>{};
class CMesh : public vcg::tri::TriMesh< std::vector<CVertex>, std::vector<CFace> >{};
class MyPolyFace;
class MyPolyVertex;
struct PolyUsedTypes: public vcg::UsedTypes<vcg::Use<MyPolyVertex> ::AsVertexType,
vcg::Use<MyPolyFace> ::AsFaceType
>{};
//class DummyEdge: public vcg::Edge<PolyUsedTypes>{};
class MyPolyVertex:public vcg::Vertex< PolyUsedTypes,
vcg::vertex::Coord3f,
vcg::vertex::Normal3f,
vcg::vertex::BitFlags>{} ;
class MyPolyFace:public vcg::Face<
PolyUsedTypes
,vcg::face::PolyInfo // this is necessary if you use component in vcg/simplex/face/component_polygon.h
// It says "this class is a polygon and the memory for its components (e.g. pointer to its vertices
// will be allocated dynamically")
,vcg::face::PFVAdj // Pointer to the vertices (just like FVAdj )
,vcg::face::BitFlags // bit flags
,vcg::face::Normal3f // normal
> {};
class MyPolyMesh: public
vcg::tri::TriMesh<
std::vector<MyPolyVertex>, // the vector of vertices
std::vector<MyPolyFace > // the vector of faces
>{};
#endif

BIN
apps/miq_commandline/miq Executable file

Binary file not shown.

View File

@ -0,0 +1,25 @@
VCGLIBDIR = ../../../vcg/vcglib
GLEWDIR = ../../../code/lib/glew
ANTDIR = ../../../code/lib/AntTweakBar1.14
COMISODIR = ./CoMISo
# Glew settings
DEFINES += GLEW_STATIC
INCLUDEPATH += $$GLEWDIR/include
SOURCES += $$GLEWDIR/src/glew.c
#Anttweakbar stuff
mac{
LIBS +=$$ANTDIR/lib/libAntTweakBar.dylib
}
#Comiso
mac{
LIBS += -L $$COMISODIR/build/Build/lib/CoMISo/ -lCoMISo
}
mac{
QMAKE_POST_LINK +="cp -P ../../../code/lib/AntTweakBar1.14/lib/libAntTweakBar.dylib . ; "
QMAKE_POST_LINK +="install_name_tool -change ../lib/libAntTweakBar.dylib ./libAntTweakBar.dylib $$TARGET ; "
QMAKE_POST_LINK +="cp -P $$COMISODIR/build/Build/lib/CoMISo/libCoMISo.dylib . ; "
}