Commit 0266b219 authored by Thomas Pitiot 's avatar Thomas Pitiot

ca marche on dirait

parent d611ae24
<!DOCTYPE QGLVIEWER> <!DOCTYPE QGLVIEWER>
<QGLViewer version="2.3.4"> <QGLViewer version="2.6.1">
<State stereo="false" cameraMode="revolve"> <State stereo="false">
<foregroundColor red="180" blue="180" green="180"/> <foregroundColor red="180" blue="180" green="180"/>
<backgroundColor red="51" blue="51" green="51"/> <backgroundColor red="51" blue="51" green="51"/>
</State> </State>
<Display axisIsDrawn="false" gridIsDrawn="false" FPSIsDisplayed="false" cameraIsEdited="false"/> <Display axisIsDrawn="false" gridIsDrawn="false" FPSIsDisplayed="false" cameraIsEdited="false"/>
<Geometry fullScreen="false" width="1800" posX="0" height="1150" posY="25"/> <Geometry fullScreen="false" width="1200" posX="0" height="701" posY="0"/>
<Camera> <Camera>
<Parameters fieldOfView="0.785398" sceneRadius="10000" Type="PERSPECTIVE" zNearCoefficient="0.005" orthoCoef="0.414214" zClippingCoefficient="1.73205"> <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"/> <SceneCenter x="0" y="0" z="0"/>
</Parameters> </Parameters>
<Stereo distToScreen="0.5" focusDistance="24142.1" physScreenWidth="0.4" IODist="0.062"/> <Stereo focusDistance="20.9077" physScreenWidth="0.5" IODist="0.062"/>
<ManipulatedCameraFrame> <ManipulatedCameraFrame>
<position x="0" y="0" z="1673.21"/> <position x="0.147086" y="-1.71221" z="-22.565"/>
<orientation q0="0" q1="0" q2="0" q3="1"/> <orientation q0="0.216344" q1="0.975578" q2="-0.0362554" q3="0.0113711"/>
<ManipulatedParameters transSens="1" rotSens="1" wheelSens="1" spinSens="0.3"/> <ManipulatedParameters transSens="1" zoomSens="1" rotSens="1" wheelSens="1" spinSens="0.3"/>
<ManipulatedCameraParameters flySpeed="100"> <ManipulatedCameraParameters zoomsOnPivotPoint="false" flySpeed="0.0866025" rotatesAroundUpVector="false">
<flyUpVector x="0" y="1" z="0"/> <sceneUpVector x="0" y="1" z="0"/>
</ManipulatedCameraParameters> </ManipulatedCameraParameters>
</ManipulatedCameraFrame> </ManipulatedCameraFrame>
</Camera> </Camera>
......
...@@ -104,6 +104,16 @@ inline float dist3D_Segment_to_Segment( std::pair<VEC3,VEC3> S1, std::pair<VEC3, ...@@ -104,6 +104,16 @@ inline float dist3D_Segment_to_Segment( std::pair<VEC3,VEC3> S1, std::pair<VEC3,
return dP.norm(); // return the closest distance return dP.norm(); // return the closest distance
} }
//=================================================================== //===================================================================
template <typename T>
inline void afficheVector(std::vector<T> vect)
{
CGoGNout<<"[ ";
for( T elem : vect)
{
CGoGNout<<elem<<" ";
}
CGoGNout<<"]";
}
inline VEC3 closestPointInTriangle(VEC3 p1, VEC3 p2, VEC3 p3, VEC3 obj) inline VEC3 closestPointInTriangle(VEC3 p1, VEC3 p2, VEC3 p3, VEC3 obj)
{ {
......
...@@ -326,6 +326,7 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d) ...@@ -326,6 +326,7 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
{ {
if (!map.isBoundaryMarked<3>(volume)) if (!map.isBoundaryMarked<3>(volume))
{ {
volume=map.volumeOldestDart(volume);
pushSegmentInCellAsNeighbor(o, volume); pushSegmentInCellAsNeighbor(o, volume);
mo->neighbor_cells[n].push_back(volume); mo->neighbor_cells[n].push_back(volume);
mo->addGeneralNeighbor ( d); mo->addGeneralNeighbor ( d);
...@@ -548,6 +549,7 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference) ...@@ -548,6 +549,7 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
map.setCurrentLevel(map.getMaxLevel()) ; map.setCurrentLevel(map.getMaxLevel()) ;
unsigned int vLevel = map.volumeLevel(dglobal); unsigned int vLevel = map.volumeLevel(dglobal);
Dart old = map.volumeOldestDart(dglobal); Dart old = map.volumeOldestDart(dglobal);
Dart centerDart=old;
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
int count = 0; int count = 0;
#endif #endif
...@@ -556,8 +558,10 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference) ...@@ -556,8 +558,10 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
// Traversor3WF<typename PFP::MAP> traF(map, old, true); // Traversor3WF<typename PFP::MAP> traF(map, old, true);
// for(Dart dit = traF.begin(); dit != traF.end(); dit = traF.next()) // for(Dart dit = traF.begin(); dit != traF.end(); dit = traF.next())
// { // {
if(OneLevelDifference) if(OneLevelDifference)
{ {
map.setCurrentLevel(vLevel) ;
for ( Face dit : facesIncidentToVolume3(map,old)) for ( Face dit : facesIncidentToVolume3(map,old))
{ {
#ifdef DEBUG_affichage #ifdef DEBUG_affichage
...@@ -577,16 +581,17 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference) ...@@ -577,16 +581,17 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
} }
else if(!map.volumeIsSubdivided(nv)) //check if neighboring volumes have to be subdivided first to avoid one cell surrounded by subdivided ones else if(!map.volumeIsSubdivided(nv)) //check if neighboring volumes have to be subdivided first to avoid one cell surrounded by subdivided ones
{ {
// CGoGNout<<"neighbor not subdivided :"<<nv<<CGoGNendl;
if(map.checkForSurrounded(nv)) if(map.checkForSurrounded(nv))
{ {
// CGoGNout<<"subdiv to avoid"<<CGoGNendl;
subdivideVolume(nv,false); subdivideVolume(nv,false);
} }
} }
} }
} }
// CGoGNout<<"\n";
} }
...@@ -608,8 +613,18 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference) ...@@ -608,8 +613,18 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
{ {
// this->popSegment(o) ; // old version // this->popSegment(o) ; // old version
// removeElementFromVector(RegisteredNeighborEdges[old], o) ; // removeElementFromVector(RegisteredNeighborEdges[old], o) ;
removeElementFromVector(o->nid->neighbor_cells[o->index],old); // CGoGNout<<"tentative de pop voisin "<<o->index<<" : ";
o->nid->removeGeneralNeighbor (old); if(removeElementFromVector(o->nid->neighbor_cells[o->index],old))
{
o->nid->removeGeneralNeighbor (old);
}
else
{
CGoGNout<<"failed to remove... ";
afficheVector(o->nid->neighbor_cells[o->index]);
CGoGNout<<" et old :"<<old<<CGoGNendl;
}
} }
RegisteredNeighborEdges[old].clear(); RegisteredNeighborEdges[old].clear();
...@@ -639,7 +654,8 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference) ...@@ -639,7 +654,8 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
if(!map.isBoundaryMarked(3,dglobal) && map.getDartLevel(dglobal) <= map.getMaxLevel() && !map.volumeIsSubdivided(dglobal) ) if(!map.isBoundaryMarked(3,dglobal) && map.getDartLevel(dglobal) <= map.getMaxLevel() && !map.volumeIsSubdivided(dglobal) )
{ {
Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map, dglobal, position,false); centerDart =Algo::Volume::IHM::subdivideVolumeClassic<PFP>(map, dglobal, position,false);
res=true; res=true;
} }
...@@ -647,25 +663,42 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference) ...@@ -647,25 +663,42 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
duration_subdiv = endSubdiv - startSubdiv; duration_subdiv = endSubdiv - startSubdiv;
if(duration_subdiv.count()>0.035)std::cout << "subdiv duration : " << duration_subdiv.count() << "s\n"; if(duration_subdiv.count()>0.035)std::cout << "subdiv duration : " << duration_subdiv.count() << "s\n";
map.setCurrentLevel(vLevel+1); map.setCurrentLevel(map.getMaxLevel()) ;
CellMarkerMemo<MAP,VOLUME> newVolumes(map); CellMarkerMemo<MAP,VOLUME> newVolumes(map);
Dart start = old; if(res)
do // on marque les nouvelles cellules ! attention TODO cas des volumes qui n'ont aucune arete en commun avec le volume d'origine {
for(Vol vo : VolumesIncidentToVertex3(map,centerDart))
{
newVolumes.mark(map.volumeOldestDart(vo));
}
}
else
{ {
map.setCurrentLevel(vLevel+1); newVolumes.mark(old);
newVolumes.mark(start); }
map.setCurrentLevel(vLevel);
start=map.phi1(start);
}while(start !=old);
map.setCurrentLevel(map.getMaxLevel()) ;
// map.check();
// Dart start = old;
// do // on marque les nouvelles cellules ! attention TODO cas des volumes qui n'ont aucune arete en commun avec le volume d'origine
// {
// map.setCurrentLevel(vLevel+1);
// newVolumes.mark(map.volumeOldestDart(start));
// map.setCurrentLevel(vLevel);
// start=map.phi1(start);
// }while(start !=old);
// map.check();
// CGoGNout<<"nombre de sous cellules markées :"<<newVolumes.get_markedCells().size()<<CGoGNendl;
for (Dart d : newVolumes.get_markedCells()) for (Dart d : newVolumes.get_markedCells())
{ {
// CGoGNout<<"markée :"<<d<<CGoGNendl;
for ( Face f : facesIncidentToVolume3(map,d)) // maj des attributs de face et volume de la carte for ( Face f : facesIncidentToVolume3(map,d)) // maj des attributs de face et volume de la carte
{ {
facecenter[f]=Algo::Surface::Geometry::faceCentroid<PFP, VertexAttribute<VEC3, MAP>>(map,f,position); facecenter[f]=Algo::Surface::Geometry::faceCentroid<PFP, VertexAttribute<VEC3, MAP>>(map,f,position);
...@@ -680,10 +713,13 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference) ...@@ -680,10 +713,13 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
{ {
if(!newVolumes.isMarked(v)) if(!newVolumes.isMarked(v))
{ {
// CGoGNout<<"reenregistrement des voisins de : "<<v<<CGoGNendl;
for(Segment * s : RegisteredEdges[v]) for(Segment * s : RegisteredEdges[v])
{ {
// CGoGNout<<"tentative ajout de : "<<s->index<<CGoGNendl;
if(addElementToVector(RegisteredNeighborEdges[d],s)) if(addElementToVector(RegisteredNeighborEdges[d],s))
{ {
// CGoGNout<<"reussie car non présent"<<CGoGNendl;
s->nid->neighbor_cells[s->index].push_back(d); s->nid->neighbor_cells[s->index].push_back(d);
} }
} }
......
...@@ -236,7 +236,7 @@ void Needle::refine() ...@@ -236,7 +236,7 @@ void Needle::refine()
{ {
if(sim_->envMap_.subdivideVolume(volume)) if(sim_->envMap_.subdivideVolume(volume))
{ {
// refine(); refine();
} }
} }
......
...@@ -27,7 +27,7 @@ void Simulator::init(int argc, char **argv) ...@@ -27,7 +27,7 @@ void Simulator::init(int argc, char **argv)
Needle_or_knife=true; Needle_or_knife=true;
initFixedObjects(); initFixedObjects();
// initSurfaces(); initSurfaces();
initMovingObject(); initMovingObject();
// initEmptyMovingObject(); // initEmptyMovingObject();
......
...@@ -164,12 +164,12 @@ void Surface::initPlane() ...@@ -164,12 +164,12 @@ void Surface::initPlane()
} }
// bool test = false; bool test = false;
// while (!test) while (!test)
// { {
// test = subdiveMap(); test = subdiveMap();
//// CGoGNout<<"subdiv effectuée ? " <<!test<<CGoGNendl; // CGoGNout<<"subdiv effectuée ? " <<!test<<CGoGNendl;
// } }
} }
......
...@@ -41,6 +41,7 @@ Tree::Tree(Simulator* sim, std::vector<std::pair<VEC3, Dart>> startingPoints, st ...@@ -41,6 +41,7 @@ Tree::Tree(Simulator* sim, std::vector<std::pair<VEC3, Dart>> startingPoints, st
sim_->envMap_.FirstRegistrationSegment(o); sim_->envMap_.FirstRegistrationSegment(o);
} }
sim_->objects.push_back(this); sim_->objects.push_back(this);
// CGoGNout<<" segment dans :"<< belonging_cells[0][0]<<CGoGNendl;
} }
void Tree::changeColor(Segment * s, float distance) void Tree::changeColor(Segment * s, float distance)
......
...@@ -551,10 +551,10 @@ void Volusion::displayObj() ...@@ -551,10 +551,10 @@ void Volusion::displayObj()
m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f); m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f);
for (ArticulatedObject * o : simul.objects) for (ArticulatedObject * o : simul.objects)
{ {
CGoGNout<<" size belong :"<< o->belonging_cells.size()<< " || nbseg :"<<o->nbEdges << CGoGNendl; // CGoGNout<<" size belong :"<< o->belonging_cells.size()<< " || nbseg :"<<o->nbEdges << CGoGNendl;
for(auto vect : o->belonging_cells) for(auto vect : o->belonging_cells)
{ {
CGoGNout<<" size vector :"<< vect.size() << CGoGNendl; // CGoGNout<<" size vector :"<< vect.size() << CGoGNendl;
// m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0); // m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
for(Dart it : vect) for(Dart it : vect)
{ {
......
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