Reputation: 173
Visual studio 2017 became stuck when I compiled a program using VCG in release mode; when i use debug mode, it compliles without problem. To be specific, it became stuck while generating code in release mode.
Can someone tell me why?
Here is the code i used, only the header was attached, I do not know why release became stuck?
#ifndef _DMESH_HEADER_
#define _DMESH_HEADER_
//#include <vcg/complex/complex.h>
//#include <vcg/complex/algorithms/point_sampling.h>
//#include <vcg/complex/algorithms/create/resampler.h>
//#include <wrap/io_trimesh/import.h>
//#include <wrap/io_trimesh/export.h>
// pre-defines data types
typedef float MESH_SCALAR;
typedef vcg::Point2<MESH_SCALAR> Point2m;
typedef vcg::Point3<MESH_SCALAR> Point3m;
typedef vcg::Point4<MESH_SCALAR> Point4m;
typedef vcg::Plane3<MESH_SCALAR> Plane3m;
typedef vcg::Segment2<MESH_SCALAR> Segment2m;
typedef vcg::Segment3<MESH_SCALAR> Segment3m;
typedef vcg::Box3<MESH_SCALAR> Box3m;
typedef vcg::Matrix44<MESH_SCALAR> Matrix44m;
typedef vcg::Matrix33<MESH_SCALAR> Matrix33m;
//typedef vcg::Shot<MESH_SCALAR> Shotm;
//typedef vcg::Similarity<MESH_SCALAR> Similaritym;
namespace vcg
{
namespace vertex
{
template <class T> class Coord3m : public Coord<vcg::Point3<MESH_SCALAR>, T> {
public: static void Name(std::vector<std::string> & name) { name.push_back(std::string("Coord3m")); T::Name(name); }
};
template <class T> class Normal3m : public Normal<vcg::Point3<MESH_SCALAR>, T> {
public: static void Name(std::vector<std::string> & name) { name.push_back(std::string("Normal3m")); T::Name(name); }
};
template <class T> class CurvatureDirmOcf : public CurvatureDirOcf<CurvatureDirTypeOcf<MESH_SCALAR>, T> {
public: static void Name(std::vector<std::string> & name) { name.push_back(std::string("CurvatureDirmOcf")); T::Name(name); }
};
template <class T> class RadiusmOcf : public RadiusOcf<MESH_SCALAR, T> {
public: static void Name(std::vector<std::string> & name) { name.push_back(std::string("RadiusmOcf")); T::Name(name); }
};
}//end namespace vertex
namespace face
{
template <class T> class Normal3m : public NormalAbs<vcg::Point3<MESH_SCALAR>, T> {
public: static void Name(std::vector<std::string> & name) { name.push_back(std::string("Normal3m")); T::Name(name); }
};
template <class T> class CurvatureDirmOcf : public CurvatureDirOcf<CurvatureDirOcfBaseType<MESH_SCALAR>, T> {
public: static void Name(std::vector<std::string> & name) { name.push_back(std::string("CurvatureDirdOcf")); T::Name(name); }
};
}//end namespace face
}//end namespace vcg
// Forward declarations needed for creating the used types
class DVertex;
class DEdge;
class DFace;
// Declaration of the semantic of the used types
class DUsedTypes : public vcg::UsedTypes<vcg::Use<DVertex>::AsVertexType,
vcg::Use<DEdge>::AsEdgeType,
vcg::Use<DFace>::AsFaceType> {};
// The Main Vertex Class
// Most of the attributes are optional and must be enabled before use.
// Each vertex needs 40 byte, on 32bit arch. and 44 byte on 64bit arch.
class DVertex : public vcg::Vertex< DUsedTypes,
vcg::vertex::InfoOcf, /* 4b */
vcg::vertex::Coord3m, /* 12b */
vcg::vertex::BitFlags, /* 4b */
vcg::vertex::Normal3m, /* 12b */
vcg::vertex::Qualityf, /* 4b */
vcg::vertex::Color4b, /* 4b */
vcg::vertex::VFAdjOcf, /* 0b */
vcg::vertex::MarkOcf, /* 0b */
vcg::vertex::TexCoordfOcf, /* 0b */
vcg::vertex::CurvaturefOcf, /* 0b */
vcg::vertex::CurvatureDirmOcf, /* 0b */
vcg::vertex::RadiusmOcf /* 0b */
> {
};
// The Main Edge Class
class DEdge : public vcg::Edge<DUsedTypes,
vcg::edge::BitFlags, /* 4b */
vcg::edge::EVAdj,
vcg::edge::EEAdj
> {
};
// Each face needs 32 byte, on 32bit arch. and 48 byte on 64bit arch.
class DFace : public vcg::Face< DUsedTypes,
vcg::face::InfoOcf, /* 4b */
vcg::face::VertexRef, /*12b */
vcg::face::BitFlags, /* 4b */
vcg::face::Normal3m, /*12b */
vcg::face::QualityfOcf, /* 0b */
vcg::face::MarkOcf, /* 0b */
vcg::face::Color4bOcf, /* 0b */
vcg::face::FFAdjOcf, /* 0b */
vcg::face::VFAdjOcf, /* 0b */
vcg::face::CurvatureDirmOcf, /* 0b */
vcg::face::WedgeTexCoordfOcf /* 0b */
> {};
class DMesh : public vcg::tri::TriMesh< vcg::vertex::vector_ocf<DVertex >, vcg::face::vector_ocf<DFace > >
{
public:
Matrix44m Tr; // Usually it is the identity. It is applied in rendering and filters can or cannot use it. (most of the filter will ignore this)
const Box3m &trBB()
{
static Box3m bb;
bb.SetNull();
bb.Add(Tr, bbox);
return bb;
}
};
/*
Sampler Classes (read carefully the following note).
Sampler Classes and Sampling algorithms are independent.
Sampler classes exploits the sample that are generated with various algorithms.
For example, you can compute Hausdorff distance (that is a sampler) using various
sampling strategies (montecarlo, stratified etc).
For further details see vcg/complex/algorithms/point_sampling.h header file.
*/
class BaseSampler
{
public:
BaseSampler(DMesh* _m) {
m = _m;
uvSpaceFlag = false;
qualitySampling = false;
perFaceNormal = false;
//tex = 0;
}
DMesh *m;
//QImage* tex;
int texSamplingWidth;
int texSamplingHeight;
bool uvSpaceFlag;
bool qualitySampling;
bool perFaceNormal; // default false; if true the sample normal is the face normal, otherwise it is interpolated
void reset()
{
m->Clear();
}
void AddVert(const DMesh::VertexType &p)
{
vcg::tri::Allocator<DMesh>::AddVertices(*m, 1);
m->vert.back().ImportData(p);
}
void AddFace(const DMesh::FaceType &f, DMesh::CoordType p)
{
vcg::tri::Allocator<DMesh>::AddVertices(*m, 1);
m->vert.back().P() = f.cP(0)*p[0] + f.cP(1)*p[1] + f.cP(2)*p[2];
if (perFaceNormal)
m->vert.back().N() = f.cN();
else
m->vert.back().N() = f.cV(0)->N()*p[0] + f.cV(1)->N()*p[1] + f.cV(2)->N()*p[2];
if (qualitySampling)
m->vert.back().Q() = f.cV(0)->Q()*p[0] + f.cV(1)->Q()*p[1] + f.cV(2)->Q()*p[2];
}
void AddTextureSample(const DMesh::FaceType &f, const DMesh::CoordType &p, const vcg::Point2<unsigned int> &tp, float edgeDist)
{
if (edgeDist != .0) return;
vcg::tri::Allocator<DMesh>::AddVertices(*m, 1);
if (uvSpaceFlag) m->vert.back().P() = Point3m(float(tp[0]), float(tp[1]), 0);
else m->vert.back().P() = f.cP(0)*p[0] + f.cP(1)*p[1] + f.cP(2)*p[2];
m->vert.back().N() = f.cV(0)->N()*p[0] + f.cV(1)->N()*p[1] + f.cV(2)->N()*p[2];
/*if (tex)
{
QRgb val;
// Computing normalized texels position
int xpos = (int)(tex->width() * (float(tp[0]) / texSamplingWidth)) % tex->width();
int ypos = (int)(tex->height() * (1.0 - float(tp[1]) / texSamplingHeight)) % tex->height();
if (xpos < 0) xpos += tex->width();
if (ypos < 0) ypos += tex->height();
val = tex->pixel(xpos, ypos);
m->vert.back().C() = Color4b(qRed(val), qGreen(val), qBlue(val), 255);
}*/
}
}; // end class BaseSampler
Upvotes: 0
Views: 101