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

ca marche on dirait

parent d611ae24
<!DOCTYPE QGLVIEWER>
<QGLViewer version="2.3.4">
<State stereo="false" cameraMode="revolve">
<QGLViewer version="2.6.1">
<State stereo="false">
<foregroundColor red="180" blue="180" green="180"/>
<backgroundColor red="51" blue="51" green="51"/>
</State>
<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>
<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"/>
</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>
<position x="0" y="0" z="1673.21"/>
<orientation q0="0" q1="0" q2="0" q3="1"/>
<ManipulatedParameters transSens="1" rotSens="1" wheelSens="1" spinSens="0.3"/>
<ManipulatedCameraParameters flySpeed="100">
<flyUpVector x="0" y="1" z="0"/>
<position x="0.147086" y="-1.71221" z="-22.565"/>
<orientation q0="0.216344" q1="0.975578" q2="-0.0362554" q3="0.0113711"/>
<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"/>
</ManipulatedCameraParameters>
</ManipulatedCameraFrame>
</Camera>
......
......@@ -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
}
//===================================================================
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)
{
......
......@@ -326,6 +326,7 @@ void EnvMap::pushAOneCellSegment(Segment * o, Dart d)
{
if (!map.isBoundaryMarked<3>(volume))
{
volume=map.volumeOldestDart(volume);
pushSegmentInCellAsNeighbor(o, volume);
mo->neighbor_cells[n].push_back(volume);
mo->addGeneralNeighbor ( d);
......@@ -548,6 +549,7 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
map.setCurrentLevel(map.getMaxLevel()) ;
unsigned int vLevel = map.volumeLevel(dglobal);
Dart old = map.volumeOldestDart(dglobal);
Dart centerDart=old;
#ifdef DEBUG_affichage
int count = 0;
#endif
......@@ -556,8 +558,10 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
// Traversor3WF<typename PFP::MAP> traF(map, old, true);
// for(Dart dit = traF.begin(); dit != traF.end(); dit = traF.next())
// {
if(OneLevelDifference)
{
map.setCurrentLevel(vLevel) ;
for ( Face dit : facesIncidentToVolume3(map,old))
{
#ifdef DEBUG_affichage
......@@ -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
{
// CGoGNout<<"neighbor not subdivided :"<<nv<<CGoGNendl;
if(map.checkForSurrounded(nv))
{
// CGoGNout<<"subdiv to avoid"<<CGoGNendl;
subdivideVolume(nv,false);
}
}
}
}
// CGoGNout<<"\n";
}
......@@ -608,8 +613,18 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
{
// this->popSegment(o) ; // old version
// removeElementFromVector(RegisteredNeighborEdges[old], o) ;
removeElementFromVector(o->nid->neighbor_cells[o->index],old);
o->nid->removeGeneralNeighbor (old);
// CGoGNout<<"tentative de pop voisin "<<o->index<<" : ";
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();
......@@ -639,7 +654,8 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
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;
}
......@@ -647,25 +663,42 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
duration_subdiv = endSubdiv - startSubdiv;
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);
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
if(res)
{
for(Vol vo : VolumesIncidentToVertex3(map,centerDart))
{
newVolumes.mark(map.volumeOldestDart(vo));
}
}
else
{
map.setCurrentLevel(vLevel+1);
newVolumes.mark(start);
map.setCurrentLevel(vLevel);
start=map.phi1(start);
}while(start !=old);
newVolumes.mark(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())
{
// CGoGNout<<"markée :"<<d<<CGoGNendl;
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);
......@@ -680,10 +713,13 @@ bool EnvMap::subdivideVolume(Dart dglobal, bool OneLevelDifference)
{
if(!newVolumes.isMarked(v))
{
// CGoGNout<<"reenregistrement des voisins de : "<<v<<CGoGNendl;
for(Segment * s : RegisteredEdges[v])
{
// CGoGNout<<"tentative ajout de : "<<s->index<<CGoGNendl;
if(addElementToVector(RegisteredNeighborEdges[d],s))
{
// CGoGNout<<"reussie car non présent"<<CGoGNendl;
s->nid->neighbor_cells[s->index].push_back(d);
}
}
......
......@@ -236,7 +236,7 @@ void Needle::refine()
{
if(sim_->envMap_.subdivideVolume(volume))
{
// refine();
refine();
}
}
......
......@@ -27,7 +27,7 @@ void Simulator::init(int argc, char **argv)
Needle_or_knife=true;
initFixedObjects();
// initSurfaces();
initSurfaces();
initMovingObject();
// initEmptyMovingObject();
......
......@@ -164,12 +164,12 @@ void Surface::initPlane()
}
// bool test = false;
// while (!test)
// {
// test = subdiveMap();
//// CGoGNout<<"subdiv effectuée ? " <<!test<<CGoGNendl;
// }
bool test = false;
while (!test)
{
test = subdiveMap();
// CGoGNout<<"subdiv effectuée ? " <<!test<<CGoGNendl;
}
}
......
......@@ -41,6 +41,7 @@ Tree::Tree(Simulator* sim, std::vector<std::pair<VEC3, Dart>> startingPoints, st
sim_->envMap_.FirstRegistrationSegment(o);
}
sim_->objects.push_back(this);
// CGoGNout<<" segment dans :"<< belonging_cells[0][0]<<CGoGNendl;
}
void Tree::changeColor(Segment * s, float distance)
......
......@@ -551,10 +551,10 @@ void Volusion::displayObj()
m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, 0.8f, 0.8f);
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)
{
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);
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