random const correctness
This commit is contained in:
parent
4bc6e679d2
commit
de8569a483
|
@ -91,7 +91,7 @@ public:
|
|||
Inertia(MeshType &m) {Compute(m);}
|
||||
|
||||
/* compute various integrations over projection of face */
|
||||
void compProjectionIntegrals(FaceType &f)
|
||||
void compProjectionIntegrals(const FaceType &f)
|
||||
{
|
||||
double a0, a1, da;
|
||||
double b0, b1, db;
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
void CompFaceIntegrals(FaceType &f)
|
||||
void CompFaceIntegrals(const FaceType &f)
|
||||
{
|
||||
Point3<ScalarType> n;
|
||||
ScalarType w;
|
||||
|
@ -196,9 +196,8 @@ void Compute(MeshType &m)
|
|||
T0 = T1[X] = T1[Y] = T1[Z]
|
||||
= T2[X] = T2[Y] = T2[Z]
|
||||
= TP[X] = TP[Y] = TP[Z] = 0;
|
||||
FaceIterator fi;
|
||||
for (fi=m.face.begin(); fi!=m.face.end();++fi) if(!(*fi).IsD() && vcg::DoubleArea(*fi)>std::numeric_limits<float>::min()) {
|
||||
FaceType &f=(*fi);
|
||||
for (auto fi=m.face.begin(); fi!=m.face.end();++fi) if(!(*fi).IsD() && vcg::DoubleArea(*fi)>std::numeric_limits<float>::min()) {
|
||||
const FaceType &f=(*fi);
|
||||
|
||||
nx = fabs(f.N()[0]);
|
||||
ny = fabs(f.N()[1]);
|
||||
|
|
|
@ -192,28 +192,27 @@ public:
|
|||
\short compute the pointcloud barycenter.
|
||||
E.g. it assume each vertex has a mass. If useQualityAsWeight is true, vertex quality is the mass of the vertices
|
||||
*/
|
||||
static Point3<ScalarType> ComputeCloudBarycenter(MeshType & m, bool useQualityAsWeight=false)
|
||||
{
|
||||
if (useQualityAsWeight)
|
||||
tri::RequirePerVertexQuality(m);
|
||||
static Point3<ScalarType> ComputeCloudBarycenter(const MeshType & m, bool useQualityAsWeight=false)
|
||||
{
|
||||
if (useQualityAsWeight)
|
||||
tri::RequirePerVertexQuality(m);
|
||||
|
||||
Point3<ScalarType> barycenter(0, 0, 0);
|
||||
Point3d accumulator(0.0, 0.0, 0.0);
|
||||
double weightSum = 0;
|
||||
VertexIterator vi;
|
||||
for (vi = m.vert.begin(); vi != m.vert.end(); ++vi)
|
||||
if (!(*vi).IsD())
|
||||
{
|
||||
ScalarType weight = useQualityAsWeight ? (*vi).Q() : 1.0f;
|
||||
accumulator[0] += (double)((*vi).P()[0] * weight);
|
||||
accumulator[1] += (double)((*vi).P()[1] * weight);
|
||||
accumulator[2] += (double)((*vi).P()[2] * weight);
|
||||
weightSum += weight;
|
||||
}
|
||||
barycenter[0] = (ScalarType)(accumulator[0] / weightSum);
|
||||
barycenter[1] = (ScalarType)(accumulator[1] / weightSum);
|
||||
barycenter[2] = (ScalarType)(accumulator[2] / weightSum);
|
||||
return barycenter;
|
||||
Point3<ScalarType> barycenter(0, 0, 0);
|
||||
Point3d accumulator(0.0, 0.0, 0.0);
|
||||
double weightSum = 0;
|
||||
for (auto vi = m.vert.begin(); vi != m.vert.end(); ++vi) {
|
||||
if (!(*vi).IsD()) {
|
||||
ScalarType weight = useQualityAsWeight ? (*vi).Q() : 1.0f;
|
||||
accumulator[0] += (double)((*vi).P()[0] * weight);
|
||||
accumulator[1] += (double)((*vi).P()[1] * weight);
|
||||
accumulator[2] += (double)((*vi).P()[2] * weight);
|
||||
weightSum += weight;
|
||||
}
|
||||
}
|
||||
barycenter[0] = (ScalarType)(accumulator[0] / weightSum);
|
||||
barycenter[1] = (ScalarType)(accumulator[1] / weightSum);
|
||||
barycenter[2] = (ScalarType)(accumulator[2] / weightSum);
|
||||
return barycenter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,17 +247,17 @@ public:
|
|||
return V;
|
||||
}
|
||||
|
||||
static ScalarType ComputeMeshVolume(MeshType & m)
|
||||
static ScalarType ComputeMeshVolume(const MeshType & m)
|
||||
{
|
||||
Inertia<MeshType> I(m);
|
||||
return I.Mass();
|
||||
}
|
||||
|
||||
static ScalarType ComputeMeshArea(MeshType & m)
|
||||
static ScalarType ComputeMeshArea(const MeshType & m)
|
||||
{
|
||||
ScalarType area=0;
|
||||
|
||||
for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)
|
||||
for(auto fi = m.face.begin(); fi != m.face.end(); ++fi)
|
||||
if(!(*fi).IsD())
|
||||
area += DoubleArea(*fi);
|
||||
|
||||
|
|
|
@ -174,6 +174,7 @@ public:
|
|||
typedef typename T::VertexType::ScalarType ScalarType;
|
||||
|
||||
inline typename T::VertexType * &V( const int j ) { assert(j>=0 && j<3); return v[j]; } /// \brief The pointer to the i-th vertex
|
||||
inline const typename T::VertexType * V (const int j) const { assert(j>=0 && j<3); return v[j]; }
|
||||
inline typename T::VertexType * cV( const int j ) const { assert(j>=0 && j<3); return v[j]; }
|
||||
|
||||
inline CoordType &P( const int j ) { assert(j>=0 && j<3); return v[j]->P(); } /// \brief Shortcut: the position of the i-th vertex (equivalent to \c V(i)->P() )
|
||||
|
@ -182,6 +183,9 @@ public:
|
|||
inline typename T::VertexType * & V0( const int j ) { return V(j);} /** \brief Return the pointer to the j-th vertex of the face. */
|
||||
inline typename T::VertexType * & V1( const int j ) { return V((j+1)%3);} /** \brief Return the pointer to the ((j+1)%3)-th vertex of the face. */
|
||||
inline typename T::VertexType * & V2( const int j ) { return V((j+2)%3);} /** \brief Return the pointer to the ((j+2)%3)-th vertex of the face. */
|
||||
inline const typename T::VertexType * V0( const int j ) const { return V(j);} /** \brief Return the pointer to the j-th vertex of the face. */
|
||||
inline const typename T::VertexType * V1( const int j ) const { return V((j+1)%3);} /** \brief Return the pointer to the ((j+1)%3)-th vertex of the face. */
|
||||
inline const typename T::VertexType * V2( const int j ) const { return V((j+2)%3);} /** \brief Return the pointer to the ((j+2)%3)-th vertex of the face. */
|
||||
inline typename T::VertexType * cV0( const int j ) const { return cV(j);}
|
||||
inline typename T::VertexType * cV1( const int j ) const { return cV((j+1)%3);}
|
||||
inline typename T::VertexType * cV2( const int j ) const { return cV((j+2)%3);}
|
||||
|
@ -214,6 +218,7 @@ template <class A, class T> class NormalAbs: public T {
|
|||
public:
|
||||
typedef A NormalType;
|
||||
inline NormalType &N() { return _norm; }
|
||||
inline const NormalType &N() const { return _norm; }
|
||||
inline NormalType cN() const { return _norm; }
|
||||
template <class RightValueType>
|
||||
void ImportData(const RightValueType & rightF)
|
||||
|
|
Loading…
Reference in New Issue