compiled with new version of spatial hashing
This commit is contained in:
parent
aca3eeec83
commit
f8af64df99
|
|
@ -13,10 +13,11 @@ public:
|
|||
typedef typename ContSimplex::value_type SimplexType;
|
||||
typedef typename ContSimplex::value_type* SimplexPointer;
|
||||
typedef typename ContSimplex::iterator SimplexIterator;
|
||||
typedef typename SimplexType::CoordType Point3x;
|
||||
typedef typename Point3x::ScalarType ScalarType;
|
||||
typedef typename SimplexType::CoordType CoordType;
|
||||
typedef typename CoordType::ScalarType ScalarType;
|
||||
typedef typename vcg::Box3<ScalarType> Box3x;
|
||||
|
||||
typedef SpatialHashTable<SimplexType> HashingTable;
|
||||
typedef DynamicSpatialHashTable<SimplexType,float> HashingTable;
|
||||
|
||||
Collision_Detector(ContSimplex & r_):_simplex(r_){};
|
||||
~Collision_Detector(){};
|
||||
|
|
@ -41,10 +42,14 @@ public:
|
|||
}
|
||||
|
||||
///initialize the box for collision detection and the dimension of a cell
|
||||
void Init(Point3x _min,Point3x _max,ScalarType _l)
|
||||
void Init(CoordType _min,CoordType _max,ScalarType _l)
|
||||
{
|
||||
HTable=new HashingTable();
|
||||
HTable->Init(_min,_max,_l);
|
||||
Box3x bb(_min,_max);
|
||||
CoordType d=((_max-_min)/_l);
|
||||
vcg::Point3i dim;
|
||||
dim.Import<ScalarType>(d);
|
||||
HTable->InitEmpty(bb,dim);
|
||||
}
|
||||
|
||||
//control if two faces share a vertex
|
||||
|
|
@ -66,9 +71,14 @@ public:
|
|||
if ((!f0->IsActive())&&(!f1->IsActive()))
|
||||
return false;
|
||||
//no adiacent faces
|
||||
if ((f0!=f1)&& (!ShareEdge(f0,f1))
|
||||
&& (!ShareVertex(f0,f1)))
|
||||
return (vcg::Intersection<SimplexType>((*f0),(*f1)));
|
||||
assert(f0!=f1);
|
||||
if ((f0!=f1)&& (!ShareEdge(f0,f1))&&!ShareVertex(f0,f1))
|
||||
{
|
||||
//vcg::Segment3<ScalarType> segm;
|
||||
//bool copl=false;
|
||||
return (vcg::Intersection<SimplexType>((*f0),(*f1)));//,copl,segm))
|
||||
//return ((copl)||(segm.Length()>0.001));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -76,44 +86,29 @@ public:
|
|||
void RefreshElements()
|
||||
{
|
||||
HTable->Clear();
|
||||
vactive.clear();///new
|
||||
vactive.clear();
|
||||
|
||||
HTable->tempMark=0;
|
||||
|
||||
for (SimplexIterator si=_simplex.begin();si<_simplex.end();++si)
|
||||
{
|
||||
if (!(*si).IsD())
|
||||
{
|
||||
(*si).Mark()=0;
|
||||
if (!(*si).IsActive())
|
||||
|
||||
HTable->AddElem(&*si);
|
||||
///new now
|
||||
else
|
||||
(*si).HMark()=0;
|
||||
vcg::Box3i cells=HTable->Add(&*si);
|
||||
if ((*si).IsActive())
|
||||
{
|
||||
std::vector<Point3i> cells=HTable->AddElem(&*si);
|
||||
for(std::vector<Point3i>::iterator it=cells.begin();it<cells.end();it++)
|
||||
vactive.insert(*it);
|
||||
vcg::Box3i cells=HTable->Add(&*si);
|
||||
for (int x=cells.min.X(); x<=cells.max.X();x++)
|
||||
for (int y=cells.min.Y(); y<=cells.max.Y();y++)
|
||||
for (int z=cells.min.Z(); z<=cells.max.Z();z++)
|
||||
vactive.insert(vcg::Point3i(x,y,z));
|
||||
}
|
||||
///end new now
|
||||
}
|
||||
|
||||
//UpdateStep(); commented now
|
||||
}
|
||||
}
|
||||
|
||||
/////put active cells on apposite structure
|
||||
//void UpdateStep()
|
||||
//{
|
||||
// vactive.clear();
|
||||
// for (SimplexIterator si=_simplex.begin();si<_simplex.end();++si)
|
||||
// {
|
||||
// if ((((!(*si).IsD()))&&(*si).IsActive()))
|
||||
// {
|
||||
// std::vector<Point3i> cells=HTable->addSimplex(&*si);
|
||||
// for(std::vector<Point3i>::iterator it=cells.begin();it<cells.end();it++)
|
||||
// vactive.insert(*it);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
///put active cells on apposite structure
|
||||
|
|
@ -126,35 +121,16 @@ public:
|
|||
{
|
||||
if ((!(*si).IsD())&&((*si).IsActive()))
|
||||
{
|
||||
std::vector<Point3i> cells=HTable->AddElem(&*si);
|
||||
for(std::vector<Point3i>::iterator it=cells.begin();it<cells.end();it++)
|
||||
vactive.insert(*it);
|
||||
vcg::Box3i cells=HTable->Add(&*si);
|
||||
for (int x=cells.min.X();x<=cells.max.X();x++)
|
||||
for (int y=cells.min.Y();y<=cells.max.Y();y++)
|
||||
for (int z=cells.min.Z();z<=cells.max.Z();z++)
|
||||
vactive.insert(vcg::Point3i(x,y,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////put active cells on apposite structure
|
||||
//void AddElements(typename ContSimplex::iterator newSimplex)
|
||||
//{
|
||||
// while (newSimplex!=_simplex.end())
|
||||
// {
|
||||
// if (!(*newSimplex).IsD())
|
||||
// {
|
||||
// if (!(*newSimplex).IsActive())
|
||||
// HTable->addSimplex(&*newSimplex);
|
||||
// ///new now
|
||||
// else
|
||||
// {
|
||||
// std::vector<Point3i> cells=HTable->addSimplex(&*newSimplex);
|
||||
// for(std::vector<Point3i>::iterator it=cells.begin();it<cells.end();it++)
|
||||
// vactive.insert(*it);
|
||||
// }
|
||||
// ///end new now
|
||||
// }
|
||||
// newSimplex++;
|
||||
// }
|
||||
//}
|
||||
|
||||
///control the real self intersection in the mesh and returns the elements that intersect with someone
|
||||
std::vector<SimplexType*> computeSelfIntersection()
|
||||
|
|
@ -168,7 +144,8 @@ public:
|
|||
if (HTable->numElemCell(p,I)>=2)
|
||||
{
|
||||
std::vector<SimplexType*> inCell;
|
||||
HTable->getAtCell(p,inCell);
|
||||
inCell.clear();
|
||||
HTable->getInCellUpdated(p,inCell);
|
||||
int nelem=inCell.size();
|
||||
if (nelem>=2)
|
||||
{
|
||||
|
|
@ -181,6 +158,7 @@ public:
|
|||
ret.push_back(inCell[j]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ public:
|
|||
{
|
||||
blocked=false;
|
||||
stopped=false;
|
||||
Acc()=Point3f(0,0,0);
|
||||
Vel()=Point3f(0,0,0);
|
||||
Acc()=CoordType(0,0,0);
|
||||
Vel()=CoordType(0,0,0);
|
||||
ClearFlags();
|
||||
//__super::
|
||||
//neeed call of the super class
|
||||
|
|
@ -83,14 +83,14 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
Acc()=Point3f(0,0,0);
|
||||
Vel()=Point3f(0,0,0);
|
||||
Acc()=CoordType(0,0,0);
|
||||
Vel()=CoordType(0,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
IntForce()=Point3f(0.f,0.f,0.f);
|
||||
IntForce()=CoordType(0.f,0.f,0.f);
|
||||
}
|
||||
|
||||
void SetRestPos()
|
||||
|
|
@ -107,7 +107,7 @@ public:
|
|||
bool intersected;
|
||||
float kdihedral;
|
||||
ScalarType AreaRep;
|
||||
int _Mark;
|
||||
int _HMark;
|
||||
|
||||
CoordType old_N;
|
||||
|
||||
|
|
@ -159,13 +159,13 @@ public:
|
|||
return (norm1*norm2);
|
||||
}
|
||||
|
||||
int &Mark()
|
||||
{return (_Mark);}
|
||||
inline int &HMark()
|
||||
{return (_HMark);}
|
||||
|
||||
///return the bounding box of the simplex
|
||||
vcg::Box3<float> BBox()
|
||||
vcg::Box3<ScalarType> BBox()
|
||||
{
|
||||
vcg::Box3<float> bb;
|
||||
vcg::Box3<ScalarType> bb;
|
||||
GetBBox(bb);
|
||||
return (bb);
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ struct MyTriMesh: public vcg::tri::TriMesh<std::vector<MyVertex>,std::vector<MyF
|
|||
|
||||
typedef Partial_Container<std::vector<MyVertex*>,MyVertex> Part_VertexContainer;
|
||||
typedef Partial_Container<std::vector<MyFace*>,MyFace> Part_FaceContainer;
|
||||
typedef PDEIntegrator<Part_FaceContainer,Part_VertexContainer,float> myIntegrator;
|
||||
typedef PDEIntegrator<Part_FaceContainer,Part_VertexContainer,MyVertex::ScalarType> myIntegrator;
|
||||
typedef Collision_Detector<std::vector<MyFace> > Collision;
|
||||
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ public:
|
|||
//Volume_Dataset_Optimized<short> V;
|
||||
Volume_Dataset <short> V;
|
||||
|
||||
vcg::Box3<float> bbox;
|
||||
vcg::Box3<MyTriMesh::ScalarType> bbox;
|
||||
|
||||
char *inDir;
|
||||
char *outDir;
|
||||
|
|
@ -357,6 +357,7 @@ private:
|
|||
double conf=diameter*diameter;
|
||||
///now swap
|
||||
return (fatt2<=conf);
|
||||
//return (!((fabs(p.X())>50)||(fabs(p.Y())>50)||(fabs(p.Z())>50)));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -447,9 +448,9 @@ private:
|
|||
///return true if a coordinate is out of limits
|
||||
bool OutOfLimits(MyTriMesh::CoordType p)
|
||||
{
|
||||
Point3f test=p;
|
||||
Point3f max=BBox().max-Point3f(1.f,1.f,1.f);//last change
|
||||
Point3f min=BBox().min;//+Point3f(1.f,1.f,1.f);//last change
|
||||
MyTriMesh::CoordType test=p;
|
||||
MyTriMesh::CoordType max=BBox().max-MyTriMesh::CoordType(1.f,1.f,1.f);//last change
|
||||
MyTriMesh::CoordType min=BBox().min;//+Point3f(1.f,1.f,1.f);//last change
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
if(((test.V(i)>=max.V(i))||(test.V(i)<=min.V(i))))
|
||||
|
|
@ -944,7 +945,7 @@ void LoadFromDir(char *in, char *out)
|
|||
V.Init(1000,outDir);*/
|
||||
|
||||
V.LoadJpg(inDir);
|
||||
bbox=vcg::Box3<float>(MapToSpace((V.Min())),(MapToSpace(V.Max())));
|
||||
bbox=vcg::Box3<MyTriMesh::ScalarType>(MapToSpace((V.Min())),(MapToSpace(V.Max())));
|
||||
}
|
||||
|
||||
///set the input
|
||||
|
|
@ -972,7 +973,7 @@ void SetSegmentParameters(int tol,float Mass=0.5f,float K_elanst=0.2f,float Dihe
|
|||
time_stamp=Time_stamp;
|
||||
k_dihedral=Dihedral;
|
||||
scale=ScaleFactor;
|
||||
bbox=vcg::Box3<float>(UnScale(MapToSpace(V.Min())),(UnScale(MapToSpace(V.Max()))));//last change!
|
||||
bbox=vcg::Box3<MyTriMesh::ScalarType>(UnScale(MapToSpace(V.Min())),(UnScale(MapToSpace(V.Max()))));//last change!
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -997,7 +998,7 @@ void InitSegmentation(MyTriMesh::CoordType b)
|
|||
}
|
||||
|
||||
///return the bounding box of the mesh
|
||||
vcg::Box3<float>& BBox()
|
||||
vcg::Box3<MyTriMesh::ScalarType>& BBox()
|
||||
{
|
||||
return (bbox);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue