Removed unused typenames (with latest generation of compilers it become a warning as unused variables)

This commit is contained in:
Paolo Cignoni 2015-09-24 16:41:34 +00:00
parent 5e40d7a734
commit 874346d211
8 changed files with 290 additions and 330 deletions

View File

@ -1693,7 +1693,6 @@ public:
typedef vcg::SpatialHashTable<VertexType, ScalarType> SampleSHT;
SampleSHT sht;
tri::VertTmark<MeshType> markerFunctor;
typedef vcg::vertex::PointDistanceFunctor<ScalarType> VDistFunct;
std::vector<VertexType*> closests;
int mergedCnt=0;
sht.Set(m.vert.begin(), m.vert.end());
@ -1810,63 +1809,63 @@ public:
/**
Select the folded faces using an angle threshold on the face normal.
The face is selected if the dot product between the face normal and the normal of the plane fitted
using the vertices of the one ring faces is below the cosThreshold.
The cosThreshold requires a negative cosine value (a positive value is clamp to zero).
Select the folded faces using an angle threshold on the face normal.
The face is selected if the dot product between the face normal and the normal of the plane fitted
using the vertices of the one ring faces is below the cosThreshold.
The cosThreshold requires a negative cosine value (a positive value is clamp to zero).
*/
static void SelectFoldedFaceFromOneRingFaces(MeshType &m, ScalarType cosThreshold)
{
tri::RequireVFAdjacency(m);
tri::RequirePerFaceNormal(m);
tri::RequirePerVertexNormal(m);
vcg::tri::UpdateSelection<MeshType>::FaceClear(m);
vcg::tri::UpdateNormal<MeshType>::PerFaceNormalized(m);
vcg::tri::UpdateNormal<MeshType>::PerVertexNormalized(m);
vcg::tri::UpdateTopology<MeshType>::VertexFace(m);
if (cosThreshold > 0)
cosThreshold = 0;
tri::RequireVFAdjacency(m);
tri::RequirePerFaceNormal(m);
tri::RequirePerVertexNormal(m);
vcg::tri::UpdateSelection<MeshType>::FaceClear(m);
vcg::tri::UpdateNormal<MeshType>::PerFaceNormalized(m);
vcg::tri::UpdateNormal<MeshType>::PerVertexNormalized(m);
vcg::tri::UpdateTopology<MeshType>::VertexFace(m);
if (cosThreshold > 0)
cosThreshold = 0;
#pragma omp parallel for schedule(dynamic, 10)
for (int i = 0; i < m.face.size(); i++)
{
std::vector<typename MeshType::VertexPointer> nearVertex;
std::vector<typename MeshType::CoordType> point;
typename MeshType::FacePointer f = &m.face[i];
for (int j = 0; j < 3; j++)
{
std::vector<typename MeshType::VertexPointer> temp;
vcg::face::VVStarVF<typename MeshType::FaceType>(f->V(j), temp);
for (int i = 0; i < m.face.size(); i++)
{
std::vector<typename MeshType::VertexPointer> nearVertex;
std::vector<typename MeshType::CoordType> point;
typename MeshType::FacePointer f = &m.face[i];
for (int j = 0; j < 3; j++)
{
std::vector<typename MeshType::VertexPointer> temp;
vcg::face::VVStarVF<typename MeshType::FaceType>(f->V(j), temp);
typename std::vector<typename MeshType::VertexPointer>::iterator iter = temp.begin();
for (; iter != temp.end(); iter++)
{
if ((*iter) != f->V1(j) && (*iter) != f->V2(j))
{
nearVertex.push_back((*iter));
point.push_back((*iter)->P());
}
}
nearVertex.push_back(f->V(j));
point.push_back(f->P(j));
}
for (; iter != temp.end(); iter++)
{
if ((*iter) != f->V1(j) && (*iter) != f->V2(j))
{
nearVertex.push_back((*iter));
point.push_back((*iter)->P());
}
}
nearVertex.push_back(f->V(j));
point.push_back(f->P(j));
}
if (point.size() > 3)
{
vcg::Plane3<typename MeshType::ScalarType> plane;
vcg::FitPlaneToPointSet(point, plane);
float avgDot = 0;
for (int j = 0; j < nearVertex.size(); j++)
avgDot += plane.Direction().dot(nearVertex[j]->N());
avgDot /= nearVertex.size();
typename MeshType::VertexType::NormalType normal;
if (avgDot < 0)
normal = -plane.Direction();
else
normal = plane.Direction();
if (normal.dot(f->N()) < cosThreshold)
f->SetS();
}
}
if (point.size() > 3)
{
vcg::Plane3<typename MeshType::ScalarType> plane;
vcg::FitPlaneToPointSet(point, plane);
float avgDot = 0;
for (int j = 0; j < nearVertex.size(); j++)
avgDot += plane.Direction().dot(nearVertex[j]->N());
avgDot /= nearVertex.size();
typename MeshType::VertexType::NormalType normal;
if (avgDot < 0)
normal = -plane.Direction();
else
normal = plane.Direction();
if (normal.dot(f->N()) < cosThreshold)
f->SetS();
}
}
}
}; // end class

View File

@ -100,7 +100,6 @@ namespace vcg {
typename GRID::CoordType & _ip)
{
typedef typename GRID::ScalarType ScalarType;
typedef Point3<ScalarType> Point3x;
typedef FaceTmark<MESH> MarkerFace;
MarkerFace mf(&mesh);
@ -123,39 +122,38 @@ namespace vcg {
return (0);
}
template <class MESH, class GRID>
typename MESH::FaceType * GetClosestFaceBase( MESH & mesh,GRID & gr,const typename GRID::CoordType & _p,
const typename GRID::ScalarType _maxDist,typename GRID::ScalarType & _minDist,
typename GRID::CoordType &_closestPt)
{
typedef typename GRID::ScalarType ScalarType;
typedef Point3<ScalarType> Point3x;
typedef FaceTmark<MESH> MarkerFace;
MarkerFace mf;
mf.SetMesh(&mesh);
vcg::face::PointDistanceBaseFunctor<ScalarType> PDistFunct;
_minDist=_maxDist;
return (gr.GetClosest(PDistFunct,mf,_p,_maxDist,_minDist,_closestPt));
}
template <class MESH, class GRID>
typename MESH::FaceType * GetClosestFaceBase( MESH & mesh,GRID & gr,const typename GRID::CoordType & _p,
const typename GRID::ScalarType _maxDist,typename GRID::ScalarType & _minDist,
typename GRID::CoordType &_closestPt)
{
typedef typename GRID::ScalarType ScalarType;
typedef FaceTmark<MESH> MarkerFace;
MarkerFace mf;
mf.SetMesh(&mesh);
vcg::face::PointDistanceBaseFunctor<ScalarType> PDistFunct;
_minDist=_maxDist;
return (gr.GetClosest(PDistFunct,mf,_p,_maxDist,_minDist,_closestPt));
}
template <class MESH, class GRID>
typename MESH::FaceType * GetClosestFaceBase( MESH & mesh,GRID & gr,const typename GRID::CoordType & _p,
const typename GRID::ScalarType _maxDist,typename GRID::ScalarType & _minDist,
typename GRID::CoordType &_closestPt, typename GRID::CoordType & _normf,
typename GRID::CoordType & _ip)
{
typedef typename GRID::ScalarType ScalarType;
typename MESH::FaceType * f = GetClosestFaceBase(mesh, gr, _p, _maxDist, _minDist, _closestPt);
if(_maxDist> ScalarType(fabs(_minDist)))
{
// normal computed with trilinear interpolation
InterpolationParameters<typename MESH::FaceType,typename MESH::ScalarType>(*f,f->N(),_closestPt, _ip);
_normf = (f->V(0)->cN())*_ip[0]+
(f->V(1)->cN())*_ip[1]+
(f->V(2)->cN())*_ip[2];
}
return f;
}
template <class MESH, class GRID>
typename MESH::FaceType * GetClosestFaceBase( MESH & mesh,GRID & gr,const typename GRID::CoordType & _p,
const typename GRID::ScalarType _maxDist,typename GRID::ScalarType & _minDist,
typename GRID::CoordType &_closestPt, typename GRID::CoordType & _normf,
typename GRID::CoordType & _ip)
{
typedef typename GRID::ScalarType ScalarType;
typename MESH::FaceType * f = GetClosestFaceBase(mesh, gr, _p, _maxDist, _minDist, _closestPt);
if(_maxDist> ScalarType(fabs(_minDist)))
{
// normal computed with trilinear interpolation
InterpolationParameters<typename MESH::FaceType,typename MESH::ScalarType>(*f,f->N(),_closestPt, _ip);
_normf = (f->V(0)->cN())*_ip[0]+
(f->V(1)->cN())*_ip[1]+
(f->V(2)->cN())*_ip[2];
}
return f;
}
template <class MESH, class GRID>
typename MESH::FaceType * GetClosestFaceEP( MESH & mesh,GRID & gr,const typename GRID::CoordType & _p,
@ -163,7 +161,6 @@ namespace vcg {
typename GRID::CoordType &_closestPt)
{
typedef typename GRID::ScalarType ScalarType;
typedef Point3<ScalarType> Point3x;
typedef FaceTmark<MESH> MarkerFace;
MarkerFace mf;
mf.SetMesh(&mesh);
@ -177,7 +174,6 @@ namespace vcg {
const typename GRID::ScalarType & _maxDist,typename GRID::ScalarType & _minDist,
typename GRID::CoordType &_closestPt)
{
typedef typename GRID::ScalarType ScalarType;
typedef FaceTmark<MESH> MarkerFace;
MarkerFace mf;
mf.SetMesh(&mesh);
@ -341,8 +337,6 @@ namespace vcg {
typename GRID::ObjPtr DoRay(MESH & mesh,GRID & gr, const Ray3<typename GRID::ScalarType> & _ray,
const typename GRID::ScalarType & _maxDist, typename GRID::ScalarType & _t)
{
typedef typename MESH::FaceType FaceType;
typedef typename MESH::ScalarType ScalarType;
typedef FaceTmark<MESH> MarkerFace;
MarkerFace mf;
mf.SetMesh(&mesh);
@ -501,7 +495,6 @@ namespace vcg {
typename GRID::CoordType &_closestPt)
{
typedef typename GRID::ScalarType ScalarType;
typedef Point3<ScalarType> Point3x;
typedef FaceTmark<MESH> MarkerFace;
MarkerFace mf;
mf.SetMesh(&mesh);

View File

@ -50,7 +50,6 @@ namespace tri {
template <class TetraMeshType>
void Tetrahedron(TetraMeshType &in)
{
typedef TetraMeshType MeshType;
typedef typename TetraMeshType::CoordType CoordType;
typedef typename TetraMeshType::VertexPointer VertexPointer;
typedef typename TetraMeshType::VertexIterator VertexIterator;
@ -278,7 +277,6 @@ void Icosahedron(IcoMeshType &in)
template <class MeshType>
void Hexahedron(MeshType &in)
{
typedef typename MeshType::ScalarType ScalarType;
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::VertexPointer VertexPointer;
typedef typename MeshType::VertexIterator VertexIterator;
@ -327,7 +325,6 @@ void Hexahedron(MeshType &in)
template <class MeshType>
void Square(MeshType &in)
{
typedef typename MeshType::ScalarType ScalarType;
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::VertexPointer VertexPointer;
typedef typename MeshType::VertexIterator VertexIterator;
@ -405,9 +402,7 @@ void SphericalCap(MeshType &in, float angleRad, const int subdiv = 3 )
template <class MeshType>
void Sphere(MeshType &in, const int subdiv = 3 )
{
typedef typename MeshType::ScalarType ScalarType;
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::VertexPointer VertexPointer;
typedef typename MeshType::VertexIterator VertexIterator;
typedef typename MeshType::FaceIterator FaceIterator;
if(in.vn==0 && in.fn==0) Icosahedron(in);
@ -445,7 +440,6 @@ void Cone( MeshType& in,
const typename MeshType::ScalarType h,
const int SubDiv = 36 )
{
typedef typename MeshType::ScalarType ScalarType;
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::VertexPointer VertexPointer;
typedef typename MeshType::VertexIterator VertexIterator;
@ -534,7 +528,6 @@ void Cone( MeshType& in,
template <class MeshType >
void Box(MeshType &in, const typename MeshType::BoxType & bb )
{
typedef typename MeshType::ScalarType ScalarType;
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::VertexPointer VertexPointer;
typedef typename MeshType::VertexIterator VertexIterator;
@ -613,11 +606,9 @@ void Torus(MeshType &m, float hRingRadius, float vRingRadius, int hRingDiv=24, i
template <class MeshType,class V, class F >
void Build( MeshType & in, const V & v, const F & f)
{
typedef typename MeshType::ScalarType ScalarType;
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::VertexPointer VertexPointer;
typedef typename MeshType::VertexIterator VertexIterator;
typedef typename MeshType::FaceIterator FaceIterator;
in.Clear();
Allocator<MeshType>::AddVertices(in,v.size());
@ -698,9 +689,6 @@ template <class MeshType>
void Grid(MeshType & in, int w, int h, float wl, float hl, float *data=0)
{
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::VertexPointer VertexPointer;
typedef typename MeshType::VertexIterator VertexIterator;
typedef typename MeshType::FaceIterator FaceIterator;
in.Clear();
Allocator<MeshType>::AddVertices(in,w*h);

View File

@ -38,13 +38,13 @@ inline bool IsEdgeManifold( EdgeType const & e, const int j )
if(EdgeType::HasFFAdjacency())
return ( e.cFFp(j) == &e || &e == e.cFFp(j)->cFFp(e.cFFi(j)) );
else
else
return true;
}
/** Return a boolean that indicate if the j-th edge of the face is a border.
@param j Index of the edge
@return true if j is an edge of border, false otherwise
@param j Index of the edge
@return true if j is an edge of border, false otherwise
*/
template <class EdgeType>
inline bool IsEdgeBorder(EdgeType const & e, const int j )
@ -59,7 +59,6 @@ inline bool IsEdgeBorder(EdgeType const & e, const int j )
template <class EdgeType>
void VVStarVE(typename EdgeType::VertexType* vp, std::vector<typename EdgeType::VertexType *> &starVec)
{
typedef typename EdgeType::VertexType* VertexPointer;
starVec.clear();
edge::VEIterator<EdgeType> vei(vp);
while(!vei.End())

View File

@ -555,7 +555,6 @@ bool CheckFlipEdgeNormal(FaceType &f, const int z, const float angleRad)
{
typedef typename FaceType::VertexType VertexType;
typedef typename VertexType::CoordType CoordType;
typedef typename VertexType::ScalarType ScalarType;
VertexType *OldDiag0 = f.V0(z);
VertexType *OldDiag1 = f.V1(z);
@ -817,7 +816,6 @@ void VFStarVF( typename FaceType::VertexType* vp,
std::vector<FaceType *> &faceVec,
std::vector<int> &indexes)
{
typedef typename FaceType::VertexType* VertexPointer;
faceVec.clear();
indexes.clear();
face::VFIterator<FaceType> vfi(vp);

View File

@ -8,7 +8,7 @@
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
@ -91,219 +91,218 @@ First Version
namespace vcg{
template <class SPATIAL_INDEX, class OBJPOINTDISTFUNCTOR, class OBJMARKER>
typename SPATIAL_INDEX::ObjPtr GridClosest(SPATIAL_INDEX &Si,
OBJPOINTDISTFUNCTOR _getPointDistance,
OBJMARKER & _marker,
const typename OBJPOINTDISTFUNCTOR::QueryType & _p_obj,
const typename SPATIAL_INDEX::ScalarType & _maxDist,
typename SPATIAL_INDEX::ScalarType & _minDist,
typename SPATIAL_INDEX:: CoordType &_closestPt)
{
typedef typename SPATIAL_INDEX::ObjPtr ObjPtr;
typedef SPATIAL_INDEX SpatialIndex;
typedef typename SPATIAL_INDEX::CoordType CoordType;
typedef typename SPATIAL_INDEX::ScalarType ScalarType;
typedef typename SPATIAL_INDEX::Box3x Box3x;
Point3<ScalarType> _p = OBJPOINTDISTFUNCTOR::Pos(_p_obj);
// Initialize min_dist with _maxDist to exploit early rejection test.
_minDist = _maxDist;
template <class SPATIAL_INDEX, class OBJPOINTDISTFUNCTOR, class OBJMARKER>
typename SPATIAL_INDEX::ObjPtr GridClosest(SPATIAL_INDEX &Si,
OBJPOINTDISTFUNCTOR _getPointDistance,
OBJMARKER & _marker,
const typename OBJPOINTDISTFUNCTOR::QueryType & _p_obj,
const typename SPATIAL_INDEX::ScalarType & _maxDist,
typename SPATIAL_INDEX::ScalarType & _minDist,
typename SPATIAL_INDEX:: CoordType &_closestPt)
{
typedef typename SPATIAL_INDEX::ObjPtr ObjPtr;
typedef typename SPATIAL_INDEX::CoordType CoordType;
typedef typename SPATIAL_INDEX::ScalarType ScalarType;
typedef typename SPATIAL_INDEX::Box3x Box3x;
ObjPtr winner=NULL;
_marker.UnMarkAll();
ScalarType newradius = Si.voxel.Norm();
ScalarType radius;
Box3i iboxdone,iboxtodo;
CoordType t_res;
typename SPATIAL_INDEX::CellIterator first,last,l;
if(Si.bbox.IsInEx(_p))
{
Point3i _ip;
Si.PToIP(_p,_ip);
Si.Grid( _ip[0],_ip[1],_ip[2], first, last );
for(l=first;l!=last;++l)
{
ObjPtr elem=&(**l);
if (!elem->IsD())
{
if (_getPointDistance((**l), _p_obj,_minDist, t_res)) // <-- NEW: use of distance functor
{
winner=elem;
_closestPt=t_res;
newradius=_minDist; //
}
_marker.Mark(elem);
}
}
iboxdone=Box3i(_ip,_ip);
}
Point3<ScalarType> _p = OBJPOINTDISTFUNCTOR::Pos(_p_obj);
// Initialize min_dist with _maxDist to exploit early rejection test.
_minDist = _maxDist;
int ix,iy,iz;
Box3i ibox(Point3i(0,0,0),Si.siz-Point3i(1,1,1));
do
{
radius=newradius;
Box3x boxtodo=Box3x(_p,radius);
//boxtodo.Intersect(Si.bbox);
Si.BoxToIBox(boxtodo, iboxtodo);
iboxtodo.Intersect(ibox);
if(!boxtodo.IsNull())
{
for (ix=iboxtodo.min[0]; ix<=iboxtodo.max[0]; ix++)
for (iy=iboxtodo.min[1]; iy<=iboxtodo.max[1]; iy++)
for (iz=iboxtodo.min[2]; iz<=iboxtodo.max[2]; iz++)
if(ix<iboxdone.min[0] || ix>iboxdone.max[0] || // this test is to avoid to re-process already analyzed cells.
iy<iboxdone.min[1] || iy>iboxdone.max[1] ||
iz<iboxdone.min[2] || iz>iboxdone.max[2] )
{
Si.Grid( ix, iy, iz, first, last );
for(l=first;l!=last;++l) if (!(**l).IsD())
{
ObjPtr elem=&(**l);
if (!elem->IsD())
{
if( ! _marker.IsMarked(elem))
{
if (_getPointDistance((**l), _p_obj, _minDist, t_res))
{
winner=elem;
_closestPt=t_res;
};
_marker.Mark(elem);
}
}
}
}
}
if(!winner) newradius=radius+Si.voxel.Norm();
else newradius = _minDist;
iboxdone=iboxtodo;
}
while (_minDist>radius);
ObjPtr winner=NULL;
_marker.UnMarkAll();
ScalarType newradius = Si.voxel.Norm();
ScalarType radius;
Box3i iboxdone,iboxtodo;
CoordType t_res;
typename SPATIAL_INDEX::CellIterator first,last,l;
if(Si.bbox.IsInEx(_p))
{
Point3i _ip;
Si.PToIP(_p,_ip);
Si.Grid( _ip[0],_ip[1],_ip[2], first, last );
for(l=first;l!=last;++l)
{
ObjPtr elem=&(**l);
if (!elem->IsD())
{
if (_getPointDistance((**l), _p_obj,_minDist, t_res)) // <-- NEW: use of distance functor
{
winner=elem;
_closestPt=t_res;
newradius=_minDist; //
}
_marker.Mark(elem);
}
}
iboxdone=Box3i(_ip,_ip);
}
return winner;
}
int ix,iy,iz;
Box3i ibox(Point3i(0,0,0),Si.siz-Point3i(1,1,1));
do
{
radius=newradius;
Box3x boxtodo=Box3x(_p,radius);
//boxtodo.Intersect(Si.bbox);
Si.BoxToIBox(boxtodo, iboxtodo);
iboxtodo.Intersect(ibox);
if(!boxtodo.IsNull())
{
for (ix=iboxtodo.min[0]; ix<=iboxtodo.max[0]; ix++)
for (iy=iboxtodo.min[1]; iy<=iboxtodo.max[1]; iy++)
for (iz=iboxtodo.min[2]; iz<=iboxtodo.max[2]; iz++)
if(ix<iboxdone.min[0] || ix>iboxdone.max[0] || // this test is to avoid to re-process already analyzed cells.
iy<iboxdone.min[1] || iy>iboxdone.max[1] ||
iz<iboxdone.min[2] || iz>iboxdone.max[2] )
{
Si.Grid( ix, iy, iz, first, last );
for(l=first;l!=last;++l) if (!(**l).IsD())
{
ObjPtr elem=&(**l);
if (!elem->IsD())
{
if( ! _marker.IsMarked(elem))
{
if (_getPointDistance((**l), _p_obj, _minDist, t_res))
{
winner=elem;
_closestPt=t_res;
};
_marker.Mark(elem);
}
}
}
}
}
if(!winner) newradius=radius+Si.voxel.Norm();
else newradius = _minDist;
iboxdone=iboxtodo;
}
while (_minDist>radius);
template <class SPATIALINDEXING,class OBJPOINTDISTFUNCTOR, class OBJMARKER,
class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
unsigned int GridGetKClosest(SPATIALINDEXING &_Si,
OBJPOINTDISTFUNCTOR & _getPointDistance,
OBJMARKER & _marker,
const unsigned int _k,
const typename SPATIALINDEXING::CoordType & _p,
const typename SPATIALINDEXING::ScalarType & _maxDist,
OBJPTRCONTAINER & _objectPtrs,
DISTCONTAINER & _distances,
POINTCONTAINER & _points)
{
typedef vcg::ClosestIterator<SPATIALINDEXING,OBJPOINTDISTFUNCTOR,OBJMARKER> ClosestIteratorType;
ClosestIteratorType Cli=ClosestIteratorType(_Si,_getPointDistance);
Cli.SetMarker(_marker);
Cli.Init(_p,_maxDist);
unsigned int i=0;
_objectPtrs.clear();
_distances.clear();
_points.clear();
while ((!Cli.End())&&(i<_k))
{
_objectPtrs.push_back(&(*Cli));
_distances.push_back(Cli.Dist());
_points.push_back(Cli.NearestPoint());
++Cli;
i++;
}
return (i);
}
return winner;
}
template <class SPATIALINDEXING,class OBJRAYISECTFUNCTOR, class OBJMARKER>
typename SPATIALINDEXING::ObjPtr GridDoRay(SPATIALINDEXING &_Si,
OBJRAYISECTFUNCTOR &_rayIntersector,
OBJMARKER &_marker,
const Ray3<typename SPATIALINDEXING::ScalarType> & _ray,
const typename SPATIALINDEXING::ScalarType & _maxDist,
typename SPATIALINDEXING::ScalarType & _t)
{
typedef vcg::RayIterator<SPATIALINDEXING,OBJRAYISECTFUNCTOR,OBJMARKER> RayIteratorType;
RayIteratorType RayIte=RayIteratorType(_Si,_rayIntersector,_maxDist);
RayIte.SetMarker(_marker);
RayIte.Init(_ray);
template <class SPATIALINDEXING,class OBJPOINTDISTFUNCTOR, class OBJMARKER,
class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
unsigned int GridGetKClosest(SPATIALINDEXING &_Si,
OBJPOINTDISTFUNCTOR & _getPointDistance,
OBJMARKER & _marker,
const unsigned int _k,
const typename SPATIALINDEXING::CoordType & _p,
const typename SPATIALINDEXING::ScalarType & _maxDist,
OBJPTRCONTAINER & _objectPtrs,
DISTCONTAINER & _distances,
POINTCONTAINER & _points)
{
typedef vcg::ClosestIterator<SPATIALINDEXING,OBJPOINTDISTFUNCTOR,OBJMARKER> ClosestIteratorType;
ClosestIteratorType Cli=ClosestIteratorType(_Si,_getPointDistance);
Cli.SetMarker(_marker);
Cli.Init(_p,_maxDist);
unsigned int i=0;
_objectPtrs.clear();
_distances.clear();
_points.clear();
while ((!Cli.End())&&(i<_k))
{
_objectPtrs.push_back(&(*Cli));
_distances.push_back(Cli.Dist());
_points.push_back(Cli.NearestPoint());
++Cli;
i++;
}
return (i);
}
if (!RayIte.End())
{
_t=RayIte.Dist();
return(&(*RayIte));
}
return 0;
}
template <class SPATIALINDEXING,class OBJRAYISECTFUNCTOR, class OBJMARKER>
typename SPATIALINDEXING::ObjPtr GridDoRay(SPATIALINDEXING &_Si,
OBJRAYISECTFUNCTOR &_rayIntersector,
OBJMARKER &_marker,
const Ray3<typename SPATIALINDEXING::ScalarType> & _ray,
const typename SPATIALINDEXING::ScalarType & _maxDist,
typename SPATIALINDEXING::ScalarType & _t)
{
typedef vcg::RayIterator<SPATIALINDEXING,OBJRAYISECTFUNCTOR,OBJMARKER> RayIteratorType;
RayIteratorType RayIte=RayIteratorType(_Si,_rayIntersector,_maxDist);
RayIte.SetMarker(_marker);
RayIte.Init(_ray);
template <class SPATIALINDEXING, class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
unsigned int GridGetInSphere(SPATIALINDEXING &_Si,
OBJPOINTDISTFUNCTOR & _getPointDistance,
OBJMARKER & _marker,
const typename SPATIALINDEXING::CoordType & _p,
const typename SPATIALINDEXING::ScalarType & _r,
OBJPTRCONTAINER & _objectPtrs,
DISTCONTAINER & _distances,
POINTCONTAINER & _points)
{
typedef vcg::ClosestIterator<SPATIALINDEXING,OBJPOINTDISTFUNCTOR,OBJMARKER> ClosestIteratorType;
ClosestIteratorType Cli=ClosestIteratorType(_Si,_getPointDistance);
Cli.SetMarker(_marker);
Cli.Init(_p,_r);
_objectPtrs.clear();
_distances.clear();
_points.clear();
while (!Cli.End())
{
_objectPtrs.push_back(&(*Cli));
_distances.push_back(Cli.Dist());
_points.push_back(Cli.NearestPoint());
++Cli;
}
return ((int)_objectPtrs.size());
}
if (!RayIte.End())
{
_t=RayIte.Dist();
return(&(*RayIte));
}
return 0;
}
template <class SPATIALINDEXING,class OBJMARKER, class OBJPTRCONTAINER>
unsigned int GridGetInBox(SPATIALINDEXING &_Si,
OBJMARKER & _marker,
const vcg::Box3<typename SPATIALINDEXING::ScalarType> &_bbox,
OBJPTRCONTAINER & _objectPtrs)
{
typename SPATIALINDEXING::CellIterator first,last,l;
_objectPtrs.clear();
vcg::Box3i ibbox;
Box3i Si_ibox(Point3i(0,0,0),_Si.siz-Point3i(1,1,1));
_Si.BoxToIBox(_bbox, ibbox);
ibbox.Intersect(Si_ibox);
_marker.UnMarkAll();
if (ibbox.IsNull())
return 0;
else
{
int ix,iy,iz;
for (ix=ibbox.min[0]; ix<=ibbox.max[0]; ix++)
for (iy=ibbox.min[1]; iy<=ibbox.max[1]; iy++)
for (iz=ibbox.min[2]; iz<=ibbox.max[2]; iz++)
{
_Si.Grid( ix, iy, iz, first, last );
for(l=first;l!=last;++l)
if (!(**l).IsD())
{
typename SPATIALINDEXING::ObjPtr elem=&(**l);
vcg::Box3<typename SPATIALINDEXING::ScalarType> box_elem;
elem->GetBBox(box_elem);
if(( ! _marker.IsMarked(elem))&&(box_elem.Collide(_bbox))){
_objectPtrs.push_back(elem);
_marker.Mark(elem);
}
}
}
return (static_cast<unsigned int>(_objectPtrs.size()));
}
}
}//end namespace vcg
template <class SPATIALINDEXING, class OBJPOINTDISTFUNCTOR, class OBJMARKER, class OBJPTRCONTAINER, class DISTCONTAINER, class POINTCONTAINER>
unsigned int GridGetInSphere(SPATIALINDEXING &_Si,
OBJPOINTDISTFUNCTOR & _getPointDistance,
OBJMARKER & _marker,
const typename SPATIALINDEXING::CoordType & _p,
const typename SPATIALINDEXING::ScalarType & _r,
OBJPTRCONTAINER & _objectPtrs,
DISTCONTAINER & _distances,
POINTCONTAINER & _points)
{
typedef vcg::ClosestIterator<SPATIALINDEXING,OBJPOINTDISTFUNCTOR,OBJMARKER> ClosestIteratorType;
ClosestIteratorType Cli=ClosestIteratorType(_Si,_getPointDistance);
Cli.SetMarker(_marker);
Cli.Init(_p,_r);
_objectPtrs.clear();
_distances.clear();
_points.clear();
while (!Cli.End())
{
_objectPtrs.push_back(&(*Cli));
_distances.push_back(Cli.Dist());
_points.push_back(Cli.NearestPoint());
++Cli;
}
return ((int)_objectPtrs.size());
}
template <class SPATIALINDEXING,class OBJMARKER, class OBJPTRCONTAINER>
unsigned int GridGetInBox(SPATIALINDEXING &_Si,
OBJMARKER & _marker,
const vcg::Box3<typename SPATIALINDEXING::ScalarType> &_bbox,
OBJPTRCONTAINER & _objectPtrs)
{
typename SPATIALINDEXING::CellIterator first,last,l;
_objectPtrs.clear();
vcg::Box3i ibbox;
Box3i Si_ibox(Point3i(0,0,0),_Si.siz-Point3i(1,1,1));
_Si.BoxToIBox(_bbox, ibbox);
ibbox.Intersect(Si_ibox);
_marker.UnMarkAll();
if (ibbox.IsNull())
return 0;
else
{
int ix,iy,iz;
for (ix=ibbox.min[0]; ix<=ibbox.max[0]; ix++)
for (iy=ibbox.min[1]; iy<=ibbox.max[1]; iy++)
for (iz=ibbox.min[2]; iz<=ibbox.max[2]; iz++)
{
_Si.Grid( ix, iy, iz, first, last );
for(l=first;l!=last;++l)
if (!(**l).IsD())
{
typename SPATIALINDEXING::ObjPtr elem=&(**l);
vcg::Box3<typename SPATIALINDEXING::ScalarType> box_elem;
elem->GetBBox(box_elem);
if(( ! _marker.IsMarked(elem))&&(box_elem.Collide(_bbox))){
_objectPtrs.push_back(elem);
_marker.Mark(elem);
}
}
}
return (static_cast<unsigned int>(_objectPtrs.size()));
}
}
}//end namespace vcg
#endif

View File

@ -141,7 +141,6 @@ namespace vcg {
{
typedef SCALAR_TYPE ScalarType;
typedef typename vcg::Point3< ScalarType > Point3t;
typedef TRIANGLETYPE Triangle3t;
bool penetration_detected = false;

View File

@ -100,10 +100,6 @@ template<class PolygonType>
void PolyNormals(const PolygonType &F,
std::vector<typename PolygonType::CoordType> &Norms)
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
Norms.clear();
if (F.VN()<=2) return;
for (int i=0;i<F.VN();i++)
@ -126,7 +122,6 @@ typename PolygonType::CoordType PolyBarycenter(const PolygonType &F)
template<class PolygonType>
typename PolygonType::ScalarType PolyArea(const PolygonType &F)
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
@ -159,8 +154,6 @@ typename PolygonType::CoordType PolygonNormal(const PolygonType &F)
template<class PolygonType>
typename PolygonType::ScalarType PolyPerimeter(const PolygonType &F)
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
ScalarType SumL=0;
@ -177,11 +170,10 @@ typename PolygonType::ScalarType PolyPerimeter(const PolygonType &F)
template<class PolygonType>
typename PolygonType::ScalarType PolyNormDeviation(const PolygonType &F)
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
std::vector<typename PolygonType::CoordType> Norms;
std::vector<CoordType> Norms;
PolyNormals(F,Norms);
//calculate the Avg Normal
@ -209,7 +201,6 @@ void PolyAngleDeviation(const PolygonType &F,
typename PolygonType::ScalarType &AvgDev,
typename PolygonType::ScalarType &MaxDev)
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
assert(F.VN()>2);
@ -246,7 +237,6 @@ void PolyAngleDeviation(const PolygonType &F,
template<class PolygonType>
vcg::Plane3<typename PolygonType::ScalarType> PolyFittingPlane(const PolygonType &F)
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
vcg::Plane3<ScalarType> BestPL;
@ -263,7 +253,6 @@ vcg::Plane3<typename PolygonType::ScalarType> PolyFittingPlane(const PolygonType
template<class PolygonType>
typename PolygonType::ScalarType PolyFlatness(const PolygonType &F)
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
@ -293,7 +282,6 @@ template<class PolygonType>
void PolyPCA(const PolygonType &F,
typename PolygonType::CoordType PCA[])
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
@ -361,7 +349,6 @@ template<class PolygonType>
void PolyScaledPCA(const PolygonType &F,
typename PolygonType::CoordType PCA[])
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
@ -415,7 +402,6 @@ void GetPolyTemplatePos(const PolygonType &F,
std::vector<typename PolygonType::CoordType> &TemplatePos,
bool force_isotropy=false)
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
std::vector<CoordType> UniformPos,UniformTempl;
@ -528,7 +514,6 @@ template<class PolygonType>
typename PolygonType::ScalarType PolyAspectRatio(const PolygonType &F,
bool isotropic=false)
{
typedef typename PolygonType::FaceType FaceType;
typedef typename PolygonType::CoordType CoordType;
typedef typename PolygonType::ScalarType ScalarType;
std::vector<CoordType> TemplatePos;