Commit 26ed1ddb authored by Thomas Pitiot 's avatar Thomas Pitiot

réparé détection de sortie du maillage

parent 2a8274e6
......@@ -5,15 +5,15 @@
<backgroundColor red="51" blue="51" green="51"/>
</State>
<Display axisIsDrawn="false" gridIsDrawn="false" FPSIsDisplayed="false" cameraIsEdited="false"/>
<Geometry fullScreen="false" width="1200" posX="0" height="701" posY="0"/>
<Geometry fullScreen="false" width="1200" posX="-83" height="701" posY="533"/>
<Camera>
<Parameters fieldOfView="0.785398" sceneRadius="8.66025" Type="PERSPECTIVE" zNearCoefficient="0.005" orthoCoef="0.414214" zClippingCoefficient="1.73205">
<SceneCenter x="0" y="0" z="0"/>
</Parameters>
<Stereo focusDistance="20.9077" physScreenWidth="0.5" IODist="0.062"/>
<ManipulatedCameraFrame>
<position x="0" y="0" z="22.6303"/>
<orientation q0="0" q1="0" q2="0" q3="1"/>
<position x="4.74424" y="-4.86234" z="1.60241"/>
<orientation q0="0.118155" q1="0.590838" q2="0.182477" q3="0.77695"/>
<ManipulatedParameters transSens="1" zoomSens="1" rotSens="1" wheelSens="1" spinSens="0.3"/>
<ManipulatedCameraParameters zoomsOnPivotPoint="false" flySpeed="0.0866025" rotatesAroundUpVector="false">
<sceneUpVector x="0" y="1" z="0"/>
......
......@@ -36,7 +36,18 @@ public :
{
return parts_[index];
}
inline const int& getNeedForSubd(int index) const
{
return partNeedReset[index];
}
inline const int& getNeedForSubd(int index)
{
return partNeedReset[index];
}
inline void setNeedForSubd(int index, int b)
{
partNeedReset[index]=b;
}
const Segment* getSegment(int index) const
{
return Segments_[index];
......@@ -53,13 +64,14 @@ public :
bool removeGeneralCell (Dart d);
void addGeneralNeighbor ( Dart d);
bool removeGeneralNeighbor (Dart d);
void needResetSegment(Segment * o);
unsigned int nbVertices;
unsigned int nbEdges;
std::vector<Particule*> parts_ ;
std::vector<int>partNeedReset;
std::vector<Segment *> Segments_;
std::vector< std::vector<Dart> > belonging_cells;
......@@ -78,7 +90,7 @@ public :
float distanceColorationMaxi;
};
//void resetPart(Segment * o, Dart d1);
......
......@@ -49,6 +49,7 @@ public:
EnvMap() ;
void init(int argc, char **argv) ;
bool checkPointInMap(VEC3 pos,Dart neighborhood);
bool checkPointInCube(VEC3 pos);
bool insideVolume(VEC3 pos, Dart d);
REAL volumeMaxdistance(Vol volume);
VEC3 normaleFromVolume(Dart volume,Dart face);
......@@ -64,10 +65,6 @@ public:
Dart getBelongingCell(const PFP::VEC3& pos);
//
// void resetAgentInFace(Agent* agent) ;
PFP::MAP map ;
VertexAttribute<VEC3, MAP> position ;
......@@ -95,7 +92,7 @@ public:
void pushSegmentInCellAsNeighbor(Segment* o, Dart d);
void popSegmentInCellAsNeighbor(Segment* o, Dart d);
void resetPartSubdiv(Segment* o, int vLevelOld);
void resetPartSubdiv(Segment* o);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Enregistrement Surfaces
......@@ -108,19 +105,11 @@ public:
void popTriangleInCell(Triangle* o, Dart d);
void pushTriangleInCellAsNeighbor(Triangle* cell, Dart d);
void popTriangleInCellAsNeighbor(Triangle* cell, Dart d);
void resetPartSubdiv(Triangle* cell, int vLevelOld);
void resetPartSubdiv(Triangle* cell);
} ;
//void update_registration(Segment * o);
//void register_pop(Segment* o, int n);
//void resetPartSubdiv(Segment* o);
//void resetObstPartInFace(Segment* o, Dart d, unsigned int fLevel);// empeche de viser une dart ayant disparu
//void resetObstPartInFace(Segment* o, Dart d);// empeche de viser une dart ayant disparu
//void resetPart(Segment * mo, Dart d); // empeche de viser une dart ayant disparu pour les voisins
/**************************************
* INLINE FUNCTIONS *
**************************************/
......
......@@ -120,100 +120,14 @@ bool ArticulatedObject::removeGeneralNeighbor (Dart d)
return false;
}
void ArticulatedObject::needResetSegment(Segment * o)
{
partNeedReset[o->indexPart1]=1;
partNeedReset[o->indexPart2]=1;
//-------------------------------------------------------------------------
//////// a implémenter
//void resetPartSubdiv(Segment* o)
//{
// ArticulatedObject * mo = o->mo;
//
// if (mo != NULL)
// {
// unsigned int n =o->index;
// /// ajout Segments lointains
// unsigned int n2;
// switch (n-(mo->nbVertices))
// {
// case 0 : n2=n+1; break;
// case 1 : n2=n-1;break;
// default : n2 =(n+1)%(mo->nbVertices); break;
// }
// ////////
// VEC3 pos = mo->getParticule(n)->getPosition();
// VEC3 pos2 = mo->getParticule(n2)->getPosition();
// mo->getParticule(n]->CGoGN::Algo::MovingObjects::ParticleBase<PFP>::move(Algo::Volume::Geometry::faceCentroid<PFP>(mo->sim_->envMap_.map, mo->parts_[n)->getCell(), mo->sim_->envMap_.position)) ;
//
// mo->getParticule(n)->setState(VOLUME) ;
// mo->getParticule(n)->move(pos) ;
//
// mo->getParticule(n2]->CGoGN::Algo::MovingObjects::ParticleBase<PFP>::move(Algo::Volume::Geometry::faceCentroid<PFP>(mo->sim_->envMap_.map, mo->parts_[n2)->getCell(), mo->sim_->envMap_.position)) ;
//
// mo->getParticule(n2)->setState(VOLUME) ;
// mo->getParticule(n2)->move(pos2) ;
//
// mo->dDir = mo->getParticule(0)->getCell();
// }
//}
//
//void resetObstPartInFace(Segment* o, Dart d1)
//{
// ArticulatedObject * mo = o->mo;
//
// if (mo != NULL)
// {
// unsigned int n =o->index;
// /// ajout Segments lointains
// unsigned int n2;
// switch (n-(mo->nbVertices))
// {
// case 0 : n2=n+1; break;
// case 1 : n2=n-1;break;
// default : n2 =(n+1)%(mo->nbVertices); break;
// }
// ////////
// VEC3 pos1 = mo->getParticule(n)->getPosition();
// VEC3 pos2 = mo->getParticule(n2)->getPosition();
//// if (Algo::Volume::Geometry::isPointInConvexFace2D <PFP> (mo->sim_->envMap_.map, d1, mo->sim_->envMap_.position, pos1, true))
// if ( mo->sim_->envMap_.is_insideConvexCell2D(pos1, d1))
// mo->getParticule(n)->getCell() = d1;
//// if (Algo::Volume::Geometry::isPointInConvexFace2D <PFP> (mo->sim_->envMap_.map, d1, mo->sim_->envMap_.position, pos2, true))
// if ( mo->sim_->envMap_.is_insideConvexCell2D(pos2, d1))
// mo->getParticule(n2)->getCell() = d1;
// if(n==0)
// mo->dDir = mo->getParticule(0)->getCell();
// }
//}
///// a implementer 4 cas
//void resetPart(Segment * o, Dart d1)
//{
// ArticulatedObject * nid = o->nid;
// if(nid!=NULL)
// {
// int n1 = o->indexPart1;
// int n2 = o->indexPart2;
// if (nid->getParticule(n1)->getCell() == nid->sim_->envMap_.map.phi1(d1))
// nid->getParticule(n1)->getCell() = d1;
// if (nid->getParticule(n2)->getCell() == nid->sim_->envMap_.map.phi1(d1))
// nid->getParticule(n2)->getCell() = d1;
// }
//}
}
......
This diff is collapsed.
......@@ -20,7 +20,7 @@ Knife::Knife(Simulator* sim,std::vector<std::pair<VEC3, Dart>> startingPoints)
{
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, (*it).second, (*it).first , sim_->envMap_.position, &(sim_->envMap_.facecenter),&(sim_->envMap_.volumecenter)));
partNeedReset.push_back(0);
}
for (unsigned int i = 0; i < nbEdges; i++)
......
......@@ -23,7 +23,7 @@ Needle::Needle(Simulator* sim,std::pair<VEC3, Dart> startingPoint)
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, startingPoint.second, startingPoint.first , sim_->envMap_.position, &(sim_->envMap_.facecenter),&(sim_->envMap_.volumecenter)));
partNeedReset.push_back(0);
this->color_close();
......@@ -111,7 +111,7 @@ void Needle::unColor_close(Dart volume)
void Needle::createEdge(int index)
{
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, this->getParticule(0)->getCell(), getParticule(0)->getPosition() , sim_->envMap_.position,&(sim_->envMap_.facecenter),&(sim_->envMap_.volumecenter)));
partNeedReset.push_back(0);
Segment* o = new Segment(getParticule(index+1)->getPosition(),
getParticule(0)->getPosition(),
this,index+1,0,index,r,g,b);
......@@ -123,7 +123,6 @@ void Needle::createEdge(int index)
}
nbEdges++;
nbVertices++;
......@@ -133,16 +132,22 @@ void Needle::createEdge(int index)
void Needle::move(VEC3 diff)
{
// VEC3 pos = getPosition(0)+diff;
// getParticule(0)->move(pos);
Dart oldCell = this->getParticule(0)->getCell();
if(diff.norm()>sim_->envMap_.maxCellRay) // on limite la taille du déplacement pour pouvoir vérifier rapidement si l'objectif est dans la carte
{
// CGoGNout<< "déplacement trop grand, on raccourci "<<CGoGNendl;
diff.normalize();
diff*=sim_->envMap_.maxCellRay*0.9;
}
VEC3 pos = getPosition(0)+diff;
if(sim_->envMap_.map.isVolumeIncidentToBoundary(this->getParticule(0)->getCell()))
if(sim_->envMap_.map.isVolumeIncidentToBoundary(oldCell))
{
if(!sim_->envMap_.checkPointInMap(pos,this->getParticule(0)->getCell()))
if(!sim_->envMap_.checkPointInMap(pos,oldCell))
{
CGoGNout<<"pos not in map :"<<pos<< " || d: "<<this->getParticule(0)->getCell()<<CGoGNendl;
pos=pos-diff;
pos=pos-diff;
}
}
......@@ -202,7 +207,7 @@ void Needle::refine()
Dart volume = this->getParticule(0)->getCell();
REAL rayon = sim_->envMap_.volumeMaxdistance(volume) ;
if(rayon > sim_->envMap_.maxCellRay )
if(rayon >2* sim_->envMap_.maxCellRay ) // on subdivise si le rayon est 2 fois le maxCellRay
{
if(sim_->envMap_.subdivideVolume(volume))
{
......
......@@ -131,17 +131,17 @@ void Simulator::initMovingObject()
std::vector<std::pair<VEC3, Dart>> startingPoints ;
std::pair<VEC3, Dart> p;
Dart d=envMap_.map.indexDart(40);
p.first=Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(envMap_.map,d,envMap_.position);
p.first=envMap_.volumecenter[d];
p.second=d;
startingPoints.push_back(p);
std::pair<VEC3, Dart> p2;
Dart d2=envMap_.map.indexDart(120);
p2.first=Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(envMap_.map,d2,envMap_.position);
p2.first=envMap_.volumecenter[d2];
p2.second=d2;
startingPoints.push_back(p2);
std::pair<VEC3, Dart> p3;
Dart d3=envMap_.map.indexDart(240);
p3.first=Algo::Surface::Geometry::volumeCentroid<PFP,VertexAttribute<VEC3,MAP>>(envMap_.map,d3,envMap_.position);
p3.first=envMap_.volumecenter[d3];
p3.second=d3;
startingPoints.push_back(p3);
......
......@@ -189,7 +189,7 @@ bool Surface::subdiveMap()
for(Dart d : toCheck)
{
REAL dist = faceMaxdistance(d);
if(dist > sim_->envMap_.maxCellRay)
if(dist > 2* sim_->envMap_.maxCellRay)
{
// CGoGNout<<"ok pour subdiv face :"<<d<<CGoGNendl;
mapOperator.subdivideFace(d,true,true) ;
......@@ -212,10 +212,10 @@ REAL Surface::faceMaxdistance(Face face)
VEC3 center = Algo::Surface::Geometry::faceCentroid<PFPSurface,VertexAttribute<VEC3,SurfaceMap>>(surfaceMap,face,positionSurface);
REAL res = (positionSurface[d]-center).norm2();
REAL res = (positionSurface[d]-center).norm();
for ( Vertex vert : verticesIncidentToFace2(surfaceMap,face))
{
REAL size=(positionSurface[vert]-center).norm2();
REAL size=(positionSurface[vert]-center).norm();
if(size>res)
{
res=size;
......
......@@ -21,7 +21,7 @@ Tree::Tree(Simulator* sim, std::vector<std::pair<VEC3, Dart>> startingPoints, st
{
parts_.push_back(new CGoGN::Algo::Volume::MovingObjects::ParticleCell3D<PFP>(sim_->envMap_.map, (*it).second, (*it).first , sim_->envMap_.position, &(sim_->envMap_.facecenter),&(sim_->envMap_.volumecenter)));
partNeedReset.push_back(0);
}
for (unsigned int i = 0; i < nbEdges; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment