viewer.cpp 29.1 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
/*******************************************************************************
pitiot's avatar
init  
pitiot committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
* Web site: http://cgogn.unistra.fr/                                           *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
24 25

#include "viewer.h"
pitiot's avatar
stats  
pitiot committed
26

pitiot's avatar
pitiot committed
27 28 29 30 31
void Volusion::dart_onoff(bool x)
{
    draw_dart = x;
    updateGL();
}
Pierre Kraemer's avatar
Pierre Kraemer committed
32

pitiot's avatar
pitiot committed
33 34 35 36 37
void Volusion::slot_slide(int i)
    {
        dartSlider = i;
        updateGL();
    }
Pierre Kraemer's avatar
Pierre Kraemer committed
38

pitiot's avatar
init  
pitiot committed
39
void Volusion::volumes_onoff(bool x)
Pierre Kraemer's avatar
Pierre Kraemer committed
40
{
pitiot's avatar
init  
pitiot committed
41 42
	render_volumes = x;
	updateGL();
Pierre Kraemer's avatar
Pierre Kraemer committed
43
}
Pierre Kraemer's avatar
Pierre Kraemer committed
44

pitiot's avatar
init  
pitiot committed
45
void Volusion::edges_onoff(bool x)
Pierre Kraemer's avatar
Pierre Kraemer committed
46
{
pitiot's avatar
init  
pitiot committed
47 48
	render_edges = x;
	updateGL();
Thomas Jund's avatar
Thomas Jund committed
49 50
}

pitiot's avatar
pitiot committed
51
void Volusion::MovingObject_onoff(bool x)
pitiot's avatar
pitiot committed
52
{
pitiot's avatar
pitiot committed
53
    render_MovingObject = x;
pitiot's avatar
pitiot committed
54 55 56 57 58 59 60 61 62 63 64 65 66
    updateGL();
}

void Volusion::belonging_onoff(bool x)
{
    render_belonging = x;
    updateGL();
}
void Volusion::neighbors_onoff(bool x)
{
    render_neighbors= x;
    updateGL();
}
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

void Volusion::obj_onoff(bool x)
{
    display_obj= x;
    updateGL();
}
void Volusion::objBelong_onoff(bool x)
{
    obj_belong= x;
    updateGL();
}
void Volusion::objNeighbors_onoff(bool x)
{
    obj_neighbors= x;
    updateGL();
}
pitiot's avatar
pitiot committed
83 84 85 86 87 88 89
void Volusion::comboEdge(int x)
{
    val_comboEdge = x;
    if(x!=0)  CGoGNout<< "affichage uniquement pour l'arete"<<val_comboEdge<<CGoGNendl;
    updateGL();
}

pitiot's avatar
init  
pitiot committed
90
void Volusion::topo_onoff(bool x)
Thomas Jund's avatar
Thomas Jund committed
91
{
pitiot's avatar
init  
pitiot committed
92 93
	render_topo = x;
	if (render_topo)
Thomas Jund's avatar
Thomas Jund committed
94
	{
pitiot's avatar
pitiot committed
95
//		SelectorDartNoBoundary<MAP> nb(simul.envMap_.map);
pitiot's avatar
init  
pitiot committed
96
		//TODO MapBrowser
pitiot's avatar
pitiot committed
97
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, m_explode_factorf-0.05f, m_explode_factor);
Thomas Jund's avatar
Thomas Jund committed
98 99
	}

pitiot's avatar
init  
pitiot committed
100 101
	updateGL();
}
Thomas Jund's avatar
Thomas Jund committed
102

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
103 104
//void Volusion::clipping_onoff(bool x)
//{
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
//	clip_volume = x;

//	if (clip_volume)
//	{
//		Geom::Vec3f pos = m_PlanePick->getPosition();
//		float pipo;
//		Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
//		float d = -(pos*normal);
//		m_explode_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));
//		m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
//		m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);
//	}
//	else
//	{
//		m_explode_render->setNoClippingPlane();
//		m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
//		m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
//		m_sh1->setClipColorAttenuationFactorRelative(0.0f,0.0f);
//		m_sh2->setClipColorAttenuationFactorRelative(0.0f,0.0f);
//	}
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
125 126
//	updateGL();
//}
Thomas Jund's avatar
Thomas Jund committed
127

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
128 129
//void Volusion::hide_onoff(bool x)
//{
130
//	hide_clipping = x;
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
131 132
//	updateGL();
//}
Thomas Jund's avatar
Thomas Jund committed
133

pitiot's avatar
init  
pitiot committed
134
void Volusion::slider_explode(int x)
Thomas Jund's avatar
Thomas Jund committed
135
{
pitiot's avatar
init  
pitiot committed
136 137 138
	m_explode_factor = 0.01f*(x+1)-0.0001f;
	m_explode_render->setExplodeVolumes(m_explode_factor);
	updateGL();
Thomas Jund's avatar
Thomas Jund committed
139 140
}

pitiot's avatar
init  
pitiot committed
141
void Volusion::slider_explodeF(int x)
Thomas Jund's avatar
Thomas Jund committed
142
{
pitiot's avatar
init  
pitiot committed
143 144 145
	m_explode_factorf = 0.01f*(x+1);
	m_explode_render->setExplodeFaces(m_explode_factorf);
	updateGL();
Thomas Jund's avatar
Thomas Jund committed
146 147
}

pitiot's avatar
init  
pitiot committed
148
void Volusion::slider_pressed()
Thomas Jund's avatar
Thomas Jund committed
149
{
pitiot's avatar
init  
pitiot committed
150 151 152 153
	render_topoTemp = render_topo;
	render_topo = false;
	updateGL();
}
pitiot's avatar
merge  
pitiot committed
154

pitiot's avatar
init  
pitiot committed
155 156 157 158
void Volusion::slider_released()
{
	render_topo = render_topoTemp;
	if (render_topo)
Thomas Jund's avatar
Thomas Jund committed
159
	{
pitiot's avatar
init  
pitiot committed
160 161
//		SelectorDartNoBoundary<MAP> nb(simul.envMap.map);
		//TODO MapBrowser
pitiot's avatar
pitiot committed
162
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, m_explode_factorf-0.05f, m_explode_factor );
Thomas Jund's avatar
Thomas Jund committed
163
	}
pitiot's avatar
init  
pitiot committed
164
	updateGL();
Pierre Kraemer's avatar
Pierre Kraemer committed
165
}
Pierre Kraemer's avatar
Pierre Kraemer committed
166

pitiot's avatar
up  
pitiot committed
167 168 169 170 171 172
void Volusion::cb_keyPress(int code)
{
    switch(code)
    {
    case 'r' :
    {
Thomas Pitiot 's avatar
Thomas Pitiot committed
173 174 175 176 177 178 179 180 181
#ifndef IHMap
//        simul.envMap_.popSegment(simul.objects[0]->Segments_[0]);

//        simul.envMap_.resetPartSubdiv(simul.objects[0]->Segments_[0]);

//        simul.envMap_.FirstRegistrationSegment(simul.objects[0]->Segments_[0]);

#else

pitiot's avatar
up  
pitiot committed
182 183 184 185
        simul.aiguille->refine();
        m_MovingObjectVBO->updateData(simul.envMap_.position);

        updateGL() ;
Thomas Pitiot 's avatar
Thomas Pitiot committed
186
#endif
pitiot's avatar
up  
pitiot committed
187 188 189 190 191 192 193 194

        break;
    }


    }
}

pitiot's avatar
init  
pitiot committed
195
void Volusion::cb_Open()
Thomas Jund's avatar
Thomas Jund committed
196
{
pitiot's avatar
init  
pitiot committed
197 198 199 200
	std::string filters("all (*.*)") ;
	std::string filename = selectFile("Open Mesh", "", filters) ;
	if (filename.empty())
		return ;
pitiot's avatar
pitiot committed
201
    else simul.envMap_.open_file(filename);
Thomas Jund's avatar
Thomas Jund committed
202 203


pitiot's avatar
pitiot committed
204 205 206
//	SelectorDartNoBoundary<MAP> nb(simul.envMap_.map);
    m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
    m_explode_render->updateData<PFP>(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color);
Thomas Jund's avatar
Thomas Jund committed
207

pitiot's avatar
init  
pitiot committed
208
	updateGL() ;
Thomas Jund's avatar
Thomas Jund committed
209 210
}

pitiot's avatar
pitiot committed
211

pitiot's avatar
pitiot committed
212

pitiot's avatar
init  
pitiot committed
213 214
void Volusion::cb_initGL()
{
pitiot's avatar
pitiot committed
215 216


pitiot's avatar
init  
pitiot committed
217 218
	// choose to use GL version 2
	Utils::GLSLShader::setCurrentOGLVersion(2);
pitiot's avatar
pitiot committed
219
    m_ds = new Utils::Drawer();
pitiot's avatar
init  
pitiot committed
220 221 222
	// create the renders
	m_topo_render = new Algo::Render::GL2::Topo3RenderMap<PFP>();
    m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender(true,true,true);
pitiot's avatar
pitiot committed
223

Thomas Pitiot 's avatar
Thomas Pitiot committed
224

pitiot's avatar
pitiot committed
225 226 227
//	SelectorDartNoBoundary<MAP> nb(simul.envMap_.map);
    m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
    m_explode_render->updateData<PFP>(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color);
pitiot's avatar
init  
pitiot committed
228 229 230 231 232
	m_explode_render->setExplodeVolumes(1.0f);
	m_explode_render->setExplodeFaces(1.0f);
	m_explode_render->setAmbiant(Geom::Vec4f(0.2f,0.2f,0.2f,1.0f));
	m_explode_render->setBackColor(Geom::Vec4f(0.9f,0.9f,0.9f,1.0f));
	m_explode_render->setColorLine(Geom::Vec4f(0.8f,0.2f,0.2f,1.0f));
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
233
    m_explode_render->setNoClippingPlane();
pitiot's avatar
pitiot committed
234

235 236
//	m_sh1 = static_cast<Utils::ClippingShader*>(m_topo_render->shader1());
//	m_sh2 = static_cast<Utils::ClippingShader*>(m_topo_render->shader2());
Thomas Jund's avatar
Thomas Jund committed
237

pitiot's avatar
init  
pitiot committed
238 239
	registerShader(m_explode_render->shaderFaces());
	registerShader(m_explode_render->shaderLines());
pitiot's avatar
pitiot committed
240

241 242 243
//    m_PlanePick = new Utils::Pickable(Utils::Pickable::GRID,1);
//    m_frame = new Utils::FrameManipulator();
//    m_frame->setSize(m_WidthObj/2.0f);
Thomas Jund's avatar
Thomas Jund committed
244

245

246 247
//	m_sh1->insertClippingCode();
//	m_sh2->insertClippingCode();
pitiot's avatar
merging  
pitiot committed
248

249 250
//	clip_id1 = m_sh1->addClipPlane();
//	clip_id2 = m_sh2->addClipPlane();
pitiot's avatar
pitiot committed
251

252 253
//	m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), m_PosObj);
//	m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), m_PosObj);
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
254
//    m_explode_render->setClippingPlane(Geom::Vec4f(0,0,1,m_PosObj*Geom::Vec3f(0,0,-1)));
pitiot's avatar
pitiot committed
255

256 257 258 259
//    m_closestVBO = new Utils::VBO();
//    m_closestVBO->setDataSize(3);
//    m_closestVBO->allocate(10000);
//    PFP::VEC3* data = static_cast<PFP::VEC3*>(m_closestVBO->lockPtr());
260

261
//    int j =0;
pitiot's avatar
pitiot committed
262 263 264
    for(Surface * surf : simul.surfaces)
    {
        surf->initGL();
Thomas Pitiot 's avatar
Thomas Pitiot committed
265
        registerShader(surf->m_shader);
Thomas Pitiot 's avatar
Thomas Pitiot committed
266
        registerShader(surf->m_simpleColorShader);
267 268 269 270 271 272
//        for(Triangle * t : surf->triangles_)
//        {
//            data[j]=t->closest_point;
//            data[j+1]=t->p1;
//            j=j+2;
//        }
Thomas Pitiot 's avatar
Thomas Pitiot committed
273

pitiot's avatar
pitiot committed
274 275
    }

276
//    m_closestVBO->releasePtr();
277

278 279 280 281 282
//    m_spriteClosest = new Utils::PointSprite();
//    m_spriteClosest->setAttributePosition(m_closestVBO);
//    m_spriteClosest->setSize(simul.aiguille->width);
//    m_spriteClosest->setColor(Geom::Vec4f(0.0f,1.0f,0.5f,1.0f));
//    registerShader(m_spriteClosest);
283

pitiot's avatar
pitiot committed
284

pitiot's avatar
pitiot committed
285 286
    m_MovingObjectVBO = new Utils::VBO();
    m_MovingObjectVBO->setDataSize(3);
pitiot's avatar
up  
pitiot committed
287
    m_MovingObjectVBO->allocate(10000);
pitiot's avatar
pitiot committed
288 289 290

    //initialisation aiguille

291
   PFP::VEC3* data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr());
292

pitiot's avatar
pitiot committed
293 294 295 296 297
    for (unsigned int i=0; i< simul.aiguille->nbVertices; ++i)
    {
        VEC3 p = simul.aiguille->parts_[i]->getPosition();
        data[i] = p;
    }
Thomas Pitiot 's avatar
Thomas Pitiot committed
298
//    data[simul.aiguille->nbVertices]=simul.aiguille->closest_point;
299

pitiot's avatar
pitiot committed
300
    m_MovingObjectVBO->releasePtr();
pitiot's avatar
pitiot committed
301 302

    m_sprite = new Utils::PointSprite();
pitiot's avatar
pitiot committed
303
    m_sprite->setAttributePosition(m_MovingObjectVBO);
304
    m_sprite->setSize(simul.aiguille->width);
pitiot's avatar
pitiot committed
305 306

    registerShader(m_sprite);
pitiot's avatar
pitiot committed
307 308
    m_frame_MovingObject = new Utils::FrameManipulator();
    m_frame_MovingObject->setSize(5.0f);
pitiot's avatar
pitiot committed
309

pitiot's avatar
init  
pitiot committed
310
}
pitiot's avatar
pitiot committed
311 312


pitiot's avatar
merging  
pitiot committed
313

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
314
void Volusion::displayMO()
pitiot's avatar
init  
pitiot committed
315
{
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
316 317
    m_ds->newList(GL_COMPILE_AND_EXECUTE);
    m_ds->begin(GL_LINE_STRIP);
pitiot's avatar
pitiot committed
318

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
319 320
    m_ds->lineWidth(10.0f);
    if(simul.aiguille->nbEdges>0)
pitiot's avatar
pitiot committed
321
    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
322 323 324 325 326 327 328 329 330 331
        VEC3 origin = simul.aiguille->Segments_[0]->p1;
        m_ds->vertex(origin);
    }
    for(Segment * s : simul.aiguille->Segments_)
    {
        m_ds->color3f(s->r,s->g,s->b);
        VEC3 p = s->p2;
        m_ds->vertex(p);
    }
    m_ds->color3f(0,0.5f,1.0f);
pitiot's avatar
pitiot committed
332

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
333 334
    m_ds->end();
    m_ds->endList();
pitiot's avatar
pitiot committed
335 336 337 338
//        VEC3 pos1 = simul.aiguille->parts_[0]->getPosition();
//        VEC3 pos2 = simul.aiguille->parts_[1]->getPosition();
//        float f;
//        VEC3 cylinder_axis =cylinder->getAxisScale(2,f);
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
339 340 341 342 343
    PFP::VEC3* data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr());
    int i=0;
    for(auto particule : simul.aiguille->parts_)
    {
        VEC3 p = particule->getPosition();
344 345 346 347 348
//            if(i==0)
//            {
//                m_topo_render->overdrawDart(particule->d,15.0f,1.0f,0.5f,1.0f);
//                m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
//            }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
349 350 351
        data[i] = p;
        i++;
    }
Thomas Pitiot 's avatar
Thomas Pitiot committed
352
//        data[simul.aiguille->nbVertices]=simul.aiguille->closest_point;
pitiot's avatar
pitiot committed
353

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
354
    m_MovingObjectVBO->releasePtr();
pitiot's avatar
pitiot committed
355
//        m_frame_MovingObject->draw();
pitiot's avatar
pitiot committed
356 357 358 359 360 361 362
//        CGoGNout<<Geom::angle(pos2-pos1,cylinder_axis)<<CGoGNendl;
//        cylinder->rotate(Geom::angle(pos2-pos1,cylinder_axis),cylinder_axis^(pos2-pos1));

//        cylinder->translate((((pos1+pos2)/2)-cylinder->getPosition())/2);
//        cylinder->draw();


Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
363 364 365 366 367
    m_sprite->enableVertexAttribs();
    glDrawArrays(GL_POINTS, 0, simul.aiguille->nbVertices/*+1*/);
    m_sprite->disableVertexAttribs();
    if(render_belonging) // affichage des cellules qui contiennent l'aiguille
    {
pitiot's avatar
pitiot committed
368

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
369
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
pitiot's avatar
pitiot committed
370

371

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
372 373 374 375 376 377 378 379 380 381 382 383 384
        if ((unsigned int)dock.comboBoxEdge->count()<simul.aiguille->nbEdges)
        {
            dock.comboBoxEdge->clear();
            dock.comboBoxEdge->addItem("Aiguille entiere",2);
            for(unsigned int i = 0; i< simul.aiguille->nbEdges;i++)
            {
                std::ostringstream oss ;
                oss<<"arete "<<i;
                const QString& s=oss.str().c_str();
                dock.comboBoxEdge->addItem(s,2);
            }
        }

385

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
386
        if(val_comboEdge==0)
pitiot's avatar
pitiot committed
387
        {
Thomas Pitiot 's avatar
Thomas Pitiot committed
388

Etienne Schmitt's avatar
const &  
Etienne Schmitt committed
389
            for(const auto& vect : simul.aiguille->belonging_cells)
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
390 391
            {
//                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
Thomas Pitiot 's avatar
Thomas Pitiot committed
392
                for(Dart it : vect)
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
393
                {
Thomas Pitiot 's avatar
Thomas Pitiot committed
394
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,it))
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
395
                    {
396

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
397 398
                        m_topo_render->overdrawDart(d,5.0f,0,1.0f,0);
                    }
pitiot's avatar
pitiot committed
399

400

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
401 402 403 404 405
                }
            }
//             m_topo_render->overdrawDart(simul.aiguille->parts_[simul.aiguille->nbEdges]->d,10.0f,1.0f,0,0);
        }
        else
pitiot's avatar
pitiot committed
406 407
        {

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
408 409 410
//            m_topo_render->overdrawDart(simul.aiguille->parts_[val_comboEdge-1]->d,10.0f,1.0f,0,0);
//            m_topo_render->overdrawDart(simul.aiguille->parts_[val_comboEdge]->d,10.0f,1.0f,0,0);
            int i = val_comboEdge-1;
Thomas Pitiot 's avatar
Thomas Pitiot committed
411
            for(Dart it : simul.aiguille->belonging_cells[i])
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
412
            {
pitiot's avatar
pitiot committed
413

Thomas Pitiot 's avatar
Thomas Pitiot committed
414
                for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it)))
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
415
                {
pitiot's avatar
pitiot committed
416

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
417 418
                    m_topo_render->overdrawDart(d,5.0f,0,1.0f,0);
                }
pitiot's avatar
pitiot committed
419

Thomas Pitiot 's avatar
Thomas Pitiot committed
420

pitiot's avatar
pitiot committed
421
            }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
422
        }
Thomas Pitiot 's avatar
Thomas Pitiot committed
423

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
424
    }
pitiot's avatar
pitiot committed
425

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
426 427 428 429 430
    if(render_neighbors) // affichage des cellules voisines de l'aiguille
    {
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
        if(val_comboEdge==0)
        {
Etienne Schmitt's avatar
const &  
Etienne Schmitt committed
431
            for(const auto& vect : simul.aiguille->neighbor_cells)
Thomas Pitiot 's avatar
Thomas Pitiot committed
432
            {
Thomas Pitiot 's avatar
Thomas Pitiot committed
433 434
//                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
                for(Dart it : vect)
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
435
                {
Thomas Pitiot 's avatar
Thomas Pitiot committed
436
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it)))
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
437
                    {
pitiot's avatar
pitiot committed
438

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
439 440
                        m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f);
                    }
pitiot's avatar
pitiot committed
441 442


Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
443 444 445 446 447 448 449
                }

            }
        }
        else
        {
            int i = val_comboEdge-1;
Thomas Pitiot 's avatar
Thomas Pitiot committed
450
            for(Dart it : simul.aiguille->neighbor_cells[i])
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
451
            {
Thomas Pitiot 's avatar
Thomas Pitiot committed
452
                for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it)))
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
453 454 455
                {
                    m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f);
                }
Thomas Pitiot 's avatar
Thomas Pitiot committed
456

pitiot's avatar
pitiot committed
457

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
458
            }
pitiot's avatar
pitiot committed
459 460

        }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
461 462
    }
}
pitiot's avatar
pitiot committed
463

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
464 465
void Volusion::displayObj()
{
pitiot's avatar
pitiot committed
466

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
467 468 469 470
    //        PFP::VEC3* data2 = static_cast<PFP::VEC3*>(m_closestVBO->lockPtr());

    //        int j =0;
    for(Surface * surf : simul.surfaces)
pitiot's avatar
up  
pitiot committed
471
    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
472 473 474 475 476 477
        surf->draw();
//            for(Triangle * t : surf->triangles_)
//            {
//                data2[j]=t->closest_point;
////                data2[j+1]=t->p1;
//                j++;
pitiot's avatar
pitiot committed
478

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
479
//            }
pitiot's avatar
pitiot committed
480

pitiot's avatar
up  
pitiot committed
481 482
    }

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
483 484 485 486 487 488
//        m_closestVBO->releasePtr();
//        m_spriteClosest->enableVertexAttribs();
//        glDrawArrays(GL_POINTS, 0, j+1);
//        m_spriteClosest->disableVertexAttribs();

    for (ArticulatedObject * art : simul.objects)
pitiot's avatar
up  
pitiot committed
489
    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
490 491 492 493 494 495 496 497 498




        m_ds->newList(GL_COMPILE_AND_EXECUTE);
        m_ds->begin(GL_LINE_STRIP);

        m_ds->lineWidth(10.0f);
        if(art->nbEdges>0)
pitiot's avatar
up  
pitiot committed
499
        {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
500 501 502 503 504 505 506 507 508 509 510
            VEC3 origin = art->Segments_[0]->p1;
            Segment * s=art->Segments_[0];
            m_ds->color3f(s->r,s->g,s->b);
            m_ds->vertex(origin);
        }
        for(Segment * s : art->Segments_)
        {
            m_ds->color3f(s->r,s->g,s->b);
            VEC3 p = s->p2;
            m_ds->vertex(p);
        }
pitiot's avatar
pitiot committed
511

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530

        m_ds->end();
        m_ds->endList();
//        VEC3 pos1 = art->parts_[0]->getPosition();
//        VEC3 pos2 = art->parts_[1]->getPosition();
//        float f;
//        VEC3 cylinder_axis =cylinder->getAxisScale(2,f);
        PFP::VEC3* data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr());
        int i=0;
        for(auto particule : art->parts_)
        {
            VEC3 p = particule->getPosition();
//            if(i==0)
//            {
//                m_topo_render->overdrawDart(particule->d,15.0f,1.0f,0.5f,1.0f);
//                m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
//            }
            data[i] = p;
            i++;
pitiot's avatar
up  
pitiot committed
531
        }
pitiot's avatar
up  
pitiot committed
532

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549

        m_MovingObjectVBO->releasePtr();
//        m_frame_MovingObject->draw();
//        CGoGNout<<Geom::angle(pos2-pos1,cylinder_axis)<<CGoGNendl;
//        cylinder->rotate(Geom::angle(pos2-pos1,cylinder_axis),cylinder_axis^(pos2-pos1));

//        cylinder->translate((((pos1+pos2)/2)-cylinder->getPosition())/2);
//        cylinder->draw();


        m_sprite->enableVertexAttribs();
        glDrawArrays(GL_POINTS, 0, art->nbVertices);
        m_sprite->disableVertexAttribs();


    }
    if(obj_belong)
pitiot's avatar
pitiot committed
550
    {
pitiot's avatar
up  
pitiot committed
551
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
552 553
        for (ArticulatedObject * o : simul.objects)
        {
Thomas Pitiot 's avatar
Thomas Pitiot committed
554
//            CGoGNout<<" size belong :"<< o->belonging_cells.size()<< " || nbseg :"<<o->nbEdges << CGoGNendl;
Etienne Schmitt's avatar
const &  
Etienne Schmitt committed
555
            for(const auto& vect : o->belonging_cells)
556
            {
Thomas Pitiot 's avatar
Thomas Pitiot committed
557
//            CGoGNout<<" size vector :"<< vect.size() << CGoGNendl;
558
    //                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
Thomas Pitiot 's avatar
Thomas Pitiot committed
559
                for(Dart it : vect)
560
                {
Thomas Pitiot 's avatar
Thomas Pitiot committed
561
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it)))
562
                    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
563
                        m_topo_render->overdrawDart(d,5.0f,0.0f,0.6f,0.4f);
564 565 566 567 568 569 570
                    }


                }
            }
        }

571
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
Thomas Pitiot 's avatar
Thomas Pitiot committed
572
        for (Surface * o : simul.surfaces)
573
        {
574 575
            unsigned int i=0;
//            for(unsigned int i =0;i<o->nbTriangles;i++)
576 577
            {
    //                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
Thomas Pitiot 's avatar
Thomas Pitiot committed
578
                for(Dart it : o->belonging_cells[i])
579
                {
Thomas Pitiot 's avatar
Thomas Pitiot committed
580
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it)))
581
                    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
582
                        m_topo_render->overdrawDart(d,5.0f,0.0f,0.6f,0.4f);
583 584
                    }

585

586 587 588
                }
            }
        }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
589 590 591 592 593
    }
    if(obj_neighbors)
    {
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
        for (ArticulatedObject * o : simul.objects)
pitiot's avatar
pitiot committed
594
        {
Etienne Schmitt's avatar
const &  
Etienne Schmitt committed
595
            for(const auto& vect : o->neighbor_cells)
pitiot's avatar
pitiot committed
596
            {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
597
    //                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
Thomas Pitiot 's avatar
Thomas Pitiot committed
598
                for(Dart it : vect)
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
599
                {
Thomas Pitiot 's avatar
Thomas Pitiot committed
600
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it)))
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
601 602 603 604 605 606
                    {
                        m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f);
                    }


                }
pitiot's avatar
pitiot committed
607 608 609
            }
        }

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
610 611
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
        for (Surface * o : simul.surfaces)
pitiot's avatar
pitiot committed
612
        {
613 614
            unsigned int i=0;
//            for(unsigned int i =0;i<o->nbTriangles;i++)
pitiot's avatar
pitiot committed
615
            {
616

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
617
    //                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
Thomas Pitiot 's avatar
Thomas Pitiot committed
618
                for(Dart it : o->neighbor_cells[i])
pitiot's avatar
pitiot committed
619
                {
Thomas Pitiot 's avatar
Thomas Pitiot committed
620
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(it)))
pitiot's avatar
pitiot committed
621
                    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
622
                        m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f);
pitiot's avatar
pitiot committed
623
                    }
pitiot's avatar
pitiot committed
624

pitiot's avatar
pitiot committed
625 626 627 628

                }
            }
        }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
629 630
    }
}
pitiot's avatar
pitiot committed
631

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
632 633
void Volusion::cb_redraw()
{
pitiot's avatar
pitiot committed
634 635


pitiot's avatar
pitiot committed
636

pitiot's avatar
pitiot committed
637

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
638 639
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glEnable(GL_LIGHTING);
pitiot's avatar
pitiot committed
640

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
641 642
	glEnable(GL_POLYGON_OFFSET_FILL);
	glPolygonOffset(1.0f, 1.0f);
pitiot's avatar
pitiot committed
643

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
644 645 646 647 648
    if(render_MovingObject)
    {
        displayMO();
    }
    if(display_obj) // affichage objets fixes
pitiot's avatar
pitiot committed
649
    {
pitiot's avatar
pitiot committed
650

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
651
        displayObj();
pitiot's avatar
pitiot committed
652

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
653 654 655 656 657 658
    }
    if(false) //affichage des normales
    {
        Dart volume=simul.envMap_.map.indexDart(1500);
        for (Face d : facesIncidentToVolume3(simul.envMap_.map,volume))
        {
pitiot's avatar
pitiot committed
659

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
660 661 662 663 664 665 666 667
            m_ds->newList(GL_COMPILE_AND_EXECUTE);
            m_ds->begin(GL_LINE_STRIP);
            m_ds->color3f(0,1.0f,0);
            m_ds->lineWidth(10.0f);
            m_ds->vertex(simul.envMap_.facecenter[d]);
            m_ds->vertex(simul.envMap_.facecenter[d]+simul.envMap_.normaleFromVolume(volume,d));
            m_ds->end();
            m_ds->endList();
pitiot's avatar
pitiot committed
668
        }
pitiot's avatar
pitiot committed
669

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
670
    }
pitiot's avatar
pitiot committed
671

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
672 673 674 675 676 677 678
    if (draw_dart)
    {
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
        dock.spinBox_dart->setRange(0, simul.envMap_.map.end().index) ;
        if( dartSlider < (simul.envMap_.map.end().index))
        {
        m_topo_render->overdrawDart(simul.envMap_.map.indexDart(dartSlider),15.0f,1.0f,0.0f,1.0f);
pitiot's avatar
pitiot committed
679 680 681 682 683

        }
    }


pitiot's avatar
up  
pitiot committed
684

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
685 686


pitiot's avatar
init  
pitiot committed
687
	if (render_topo)
pitiot's avatar
pitiot committed
688
    {
pitiot's avatar
up  
pitiot committed
689
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
pitiot's avatar
pitiot committed
690 691 692
            m_topo_render->drawTopo();

    }
pitiot's avatar
maj  
pitiot committed
693

pitiot's avatar
init  
pitiot committed
694
	if (render_edges)
David Cazier's avatar
David Cazier committed
695
	{
pitiot's avatar
init  
pitiot committed
696
		glLineWidth(2.0f);
Thomas Pitiot 's avatar
Thomas Pitiot committed
697
//        simul.envMap_.map.setCurrentLevel(simul.envMap_.map.getMaxLevel()) ;
pitiot's avatar
up  
pitiot committed
698
        m_explode_render->updateData<PFP>(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color);
pitiot's avatar
init  
pitiot committed
699
		m_explode_render->drawEdges();
pitiot's avatar
pitiot committed
700

Pierre Kraemer's avatar
Pierre Kraemer committed
701
	}
pitiot's avatar
pitiot committed
702

pitiot's avatar
init  
pitiot committed
703
	glDisable(GL_POLYGON_OFFSET_FILL);
Thomas Jund's avatar
Thomas Jund committed
704

pitiot's avatar
init  
pitiot committed
705
	if (render_volumes)
David Cazier's avatar
David Cazier committed
706
	{
Thomas Pitiot 's avatar
Thomas Pitiot committed
707 708
        m_explode_render->updateData<PFP>(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color);
        m_explode_render->drawFaces();
Pierre Kraemer's avatar
Pierre Kraemer committed
709
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
710

711 712 713 714 715
//	if (clip_volume && !hide_clipping)
//	{
//		m_frame->draw();
//		m_PlanePick->draw();
//	}
Pierre Kraemer's avatar
Pierre Kraemer committed
716 717
}

pitiot's avatar
pitiot committed
718

pitiot's avatar
init  
pitiot committed
719
void  Volusion::cb_mousePress(int /*button*/, int x, int y)
Pierre Kraemer's avatar
Pierre Kraemer committed
720
{
721
/*    if (Shift())
pitiot's avatar
pitiot committed
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746
    {

        if (hide_clipping || !clip_volume)
            return;

        m_begX = x;
        m_begY = y;

        // get ray of selection
        Geom::Vec3f rayA,rayB;
        float dist = getOrthoScreenRay(x,y,rayA,rayB);
        Geom::Vec3f AB = rayB-rayA;

        unsigned int fr_picked =0;
        // picking the frame -> axis
        fr_picked = m_frame->pick(rayA,AB,dist);

        if (fr_picked != 0)
        {
            m_pickedAxis=fr_picked;
            m_frame->highlight(m_pickedAxis);
            m_frame->storeProjection(m_pickedAxis);
            updateGL();
        }
    }
747
    else*/ if (Control())
pitiot's avatar
pitiot committed
748 749 750
    {
        startX=x;
        startY=y;
pitiot's avatar
pitiot committed
751 752
        m_frame_MovingObject->storeProjection(0);
        oldPosSprite=m_frame_MovingObject->getPosition();
pitiot's avatar
pitiot committed
753 754
        updateGL();
    }
Pierre Kraemer's avatar
Pierre Kraemer committed
755
}
756

pitiot's avatar
init  
pitiot committed
757
void  Volusion::cb_mouseRelease(int /*button*/, int /*x*/, int /*y*/)
Thomas's avatar
Thomas committed
758 759
{

760 761
//    if (!hide_clipping && clip_volume)
//    {
762

763 764 765 766
//        m_pickedAxis=0;
//        m_frame->highlight(m_pickedAxis);
//        updateGL();
//    }
pitiot's avatar
pitiot committed
767
    if (render_MovingObject)
pitiot's avatar
pitiot committed
768
        updateGL();
769

Thomas's avatar
Thomas committed
770 771
}

pitiot's avatar
init  
pitiot committed
772
void  Volusion::cb_mouseMove(int buttons, int x, int y)
Pierre Kraemer's avatar
Pierre Kraemer committed
773
{
774
/*    if (Shift())
pitiot's avatar
pitiot committed
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828
    {


        if (hide_clipping || !clip_volume)
            return;

        // rotation selected ?
        if (Utils::FrameManipulator::rotationAxis(m_pickedAxis))
        {
            if (buttons&1)
            {
                float angle = m_frame->angleFromMouse(x,y,x-m_begX, y-m_begY);
                m_frame->rotate(m_pickedAxis, angle);
            }
            else if (buttons&2)
                m_frame->rotateInScreen(x-m_begX, y-m_begY);

            m_PlanePick->transfo() = m_frame->transfo();
        }
        // translation selected
        else if (Utils::FrameManipulator::translationAxis(m_pickedAxis))
        {
            if (buttons&1)
            {
                float dist =  m_frame->distanceFromMouse(x-m_begX, y-m_begY);
                m_frame->translate(m_pickedAxis, dist);
            }
            else if (buttons&2)
                m_frame->translateInScreen(x-m_begX, y-m_begY);

            m_PlanePick->transfo() = m_frame->transfo();
        }
        // scale selected
        else if (Utils::FrameManipulator::scaleAxis(m_pickedAxis) )
        {
            float scale = m_frame->scaleFromMouse(x-m_begX, y-m_begY);
            m_frame->scale(m_pickedAxis, scale );
            m_PlanePick->transfo() = m_frame->transfo();
        }

        Geom::Vec3f pos = m_PlanePick->getPosition();
        float pipo;
        Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
        float d = -(pos*normal);
        m_explode_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));

        m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
        m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);

        m_begX = x;
        m_begY = y;
        updateGL();
        return;
    }
829
    else */if(Control())
pitiot's avatar
pitiot committed
830
    {
pitiot's avatar
pitiot committed
831
        m_frame_MovingObject->translateInScreen(x-startX, y-startY);
pitiot's avatar
pitiot committed
832

pitiot's avatar
pitiot committed
833 834 835
//        cylinder->transfo() = m_frame_MovingObject->transfo();
//        simul.aiguille->transfo(m_frame_MovingObject->transfo());
        VEC3 diff = m_frame_MovingObject->getPosition()-oldPosSprite;
pitiot's avatar
pitiot committed
836 837
//        CGoGNout<<"deplacement de : "<<diff<<CGoGNendl;

pitiot's avatar
pitiot committed
838 839
        if(simul.aiguille->nbVertices>0)
            simul.aiguille->move(diff);
pitiot's avatar
pitiot committed
840

pitiot's avatar
pitiot committed
841 842
        startX=x;
        startY=y;
pitiot's avatar
pitiot committed
843
        oldPosSprite=m_frame_MovingObject->getPosition();
pitiot's avatar
pitiot committed
844 845
        updateGL();
    }
846

pitiot's avatar
init  
pitiot committed
847
}
848

Pierre Kraemer's avatar
Pierre Kraemer committed
849

850 851


Etienne Schmitt's avatar
Etienne Schmitt committed
852
void setupQtWidgets(char **argv, int argc,Volusion& sqt)
Pierre Kraemer's avatar
Pierre Kraemer committed
853
{
Etienne Schmitt's avatar
Etienne Schmitt committed
854
    sqt.simul.init(argc,argv);
pitiot's avatar
merging  
pitiot committed
855

Etienne Schmitt's avatar
Etienne Schmitt committed
856
    // interface de tuto5.ui
pitiot's avatar
pitiot committed
857 858

    sqt.setDock(&(sqt.dock));
859

Etienne Schmitt's avatar
Etienne Schmitt committed
860
    //  bounding box
pitiot's avatar
pitiot committed
861
    Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(sqt.simul.envMap_.map, sqt.simul.envMap_.position);
Etienne Schmitt's avatar
Etienne Schmitt committed
862 863
    sqt.m_WidthObj = std::max<REAL>(std::max<REAL>(bb.size(0), bb.size(1)), bb.size(2));
    sqt.m_PosObj = (bb.min() +  bb.max()) / REAL(2);
pitiot's avatar
merging  
pitiot committed
864

pitiot's avatar
init  
pitiot committed
865
    // envoit info BB a l'interface
Etienne Schmitt's avatar
Etienne Schmitt committed
866
    sqt.setParamObject(sqt.m_WidthObj, sqt.m_PosObj.data());
Pierre Kraemer's avatar
Pierre Kraemer committed
867

pitiot's avatar
pitiot committed
868 869 870 871 872 873
    sqt.setCallBack( sqt.dock.checkBox_volumes, SIGNAL(toggled(bool)), SLOT(volumes_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_edges, SIGNAL(toggled(bool)), SLOT(edges_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_topo, SIGNAL(toggled(bool)), SLOT(topo_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_MovingObject, SIGNAL(toggled(bool)), SLOT(MovingObject_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_belonging, SIGNAL(toggled(bool)), SLOT(belonging_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_neighbors, SIGNAL(toggled(bool)), SLOT(neighbors_onoff(bool)) );
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
874 875 876
    sqt.setCallBack( sqt.dock.checkBox_displayobjects, SIGNAL(toggled(bool)), SLOT(obj_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_ObjBelong, SIGNAL(toggled(bool)), SLOT(objBelong_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_ObjNeighbors, SIGNAL(toggled(bool)), SLOT(objNeighbors_onoff(bool)) );
Etienne Schmitt's avatar
Etienne Schmitt committed
877 878 879
    //    sqt.setCallBack( sqt.dock.checkBox_hide, SIGNAL(toggled(bool)), SLOT(hide_onoff(bool)) );
    //    sqt.setCallBack( sqt.dock.checkBox_plane, SIGNAL(toggled(bool)), SLOT(clipping_onoff(bool)) );
    sqt.setCallBack( sqt.dock.comboBoxEdge, SIGNAL(	activated(int)), SLOT(comboEdge(int)) );
pitiot's avatar
pitiot committed
880 881 882 883 884 885 886 887
    sqt.setCallBack( sqt.dock.slider_explode, SIGNAL(sliderPressed()), SLOT(slider_pressed()) );
    sqt.setCallBack( sqt.dock.slider_explode, SIGNAL(sliderReleased()), SLOT(slider_released()) );
    sqt.setCallBack(sqt.dock.spinBox_dart, SIGNAL(valueChanged(int)), SLOT(slot_slide(int))) ;
    sqt.setCallBack(sqt.dock.checkBox_drawDart, SIGNAL(toggled(bool)), SLOT(dart_onoff(bool))) ;
    sqt.setCallBack( sqt.dock.slider_explode_face, SIGNAL(valueChanged(int)), SLOT(slider_explodeF(int)) );

    sqt.setCallBack( sqt.dock.slider_explode_face, SIGNAL(sliderPressed()), SLOT(slider_pressed()) );
    sqt.setCallBack( sqt.dock.slider_explode_face, SIGNAL(sliderReleased()), SLOT(slider_released()) );
888

Etienne Schmitt's avatar
Etienne Schmitt committed
889
    sqt.show();
pitiot's avatar
pitiot committed
890 891
    sqt.dock.slider_explode->setValue(100);
    sqt.dock.slider_explode_face->setValue(100);
Etienne Schmitt's avatar
Etienne Schmitt committed
892 893 894
    //	sqt.clipping_onoff(false);
    sqt.topo_onoff(false);
    sqt.edges_onoff(true);
pitiot's avatar
pitiot committed
895
    sqt.dock.checkBox_MovingObject->setChecked(true);
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
896 897 898
    sqt.dock.checkBox_displayobjects->setChecked(true);
    sqt.dock.checkBox_ObjBelong->setChecked(false);
    sqt.dock.checkBox_ObjNeighbors->setChecked(false);
pitiot's avatar
pitiot committed
899 900 901
    sqt.dock.checkBox_topo->setChecked(false);
    sqt.dock.checkBox_belonging->setChecked(false);
    sqt.dock.checkBox_neighbors->setChecked(false);
Etienne Schmitt's avatar
Etienne Schmitt committed
902 903
    //    sqt.dock.checkBox_plane->setChecked(false);
    //    sqt.dock.checkBox_hide->setChecked(true);
Thomas Pitiot 's avatar
Thomas Pitiot committed
904
    sqt.dock.checkBox_volumes->setChecked(false);
pitiot's avatar
pitiot committed
905 906 907
    sqt.dock.spinBox_dart->setRange(0, sqt.simul.envMap_.map.end().index) ;

    sqt.dock.comboBoxEdge->addItem("Aiguille entiere",2);
pitiot's avatar
pitiot committed
908 909 910 911 912
    for(unsigned int i = 0; i< sqt.simul.aiguille->nbEdges;i++)
    {
        std::ostringstream oss ;
        oss<<"arete "<<i;
        const QString& s=oss.str().c_str();
pitiot's avatar
pitiot committed
913
        sqt.dock.comboBoxEdge->addItem(s,2);
pitiot's avatar
pitiot committed
914
    }
Etienne Schmitt's avatar
Etienne Schmitt committed
915 916 917 918 919 920 921 922
}

int main(int argc, char **argv)
{
    // un peu d'interface
	QApplication app(argc, argv);
	Volusion sqt;
    setupQtWidgets(argv, argc, sqt);
David Cazier's avatar
David Cazier committed
923

pitiot's avatar
init  
pitiot committed
924 925
	// et on attend la fin.
	return app.exec();
pitiot's avatar
merging  
pitiot committed
926

pitiot's avatar
merging  
pitiot committed
927

Arash HABIBI's avatar
Arash HABIBI committed
928 929


pitiot's avatar
merging  
pitiot committed
930

pitiot's avatar
init  
pitiot committed
931
	// exemple utilisation chrono
Pierre Kraemer's avatar
Pierre Kraemer committed
932

pitiot's avatar
merging  
pitiot committed
933

pitiot's avatar
init  
pitiot committed
934
//	Utils::Chrono ch;
pitiot's avatar
pitiot committed
935
//
pitiot's avatar
pitiot committed
936 937
//	Vertex v(simul.envMap_.map.begin());
////	VEC3 p = Algo::Volume::Geometry::vertexNeighborhoodCentroid<PFP>(simul.envMap_.map,v,simul.envMap_.position);
pitiot's avatar
pitiot committed
938
//
pitiot's avatar
pitiot committed
939 940
//	Vol w(simul.envMap_.map.begin());
//	VEC3 q = Algo::Surface::Geometry::volumeCentroid<PFP>(simul.envMap_.map,w,simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
941 942

//	ch.start();
pitiot's avatar
pitiot committed
943 944 945 946
//	float vol = Algo::Geometry::Parallel::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
//	vol += Algo::Geometry::Parallel::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
//	vol += Algo::Geometry::Parallel::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
//	vol += Algo::Geometry::Parallel::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
947 948 949 950
//	std::cout << ch.elapsed()<< " ms //  val="<<vol<< std::endl;
//
//	std::cout << "Compute Volume ->"<< std::endl;
//	ch.start();
pitiot's avatar
pitiot committed
951
//	vol = Algo::Geometry::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
952 953
//	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;
//	ch.start();
pitiot's avatar
pitiot committed
954
//	vol += Algo::Geometry::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
955 956
//	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;
//	ch.start();
pitiot's avatar
pitiot committed
957
//	vol += Algo::Geometry::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
958 959
//	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;
//	ch.start();
pitiot's avatar
pitiot committed
960
//	vol += Algo::Geometry::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
961 962
//	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;

pitiot's avatar
merging  
pitiot committed
963

Pierre Kraemer's avatar
Pierre Kraemer committed
964
}