Commit 17a666b7 authored by Sylvain Thery's avatar Sylvain Thery

traversor & foreach macros tutos

parent 29130379
......@@ -29,6 +29,7 @@
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Topology/generic/cells_macros.h"
using namespace CGoGN ;
int main(int argc, char **argv)
......@@ -59,6 +60,17 @@ int main(int argc, char **argv)
return app.exec();
}
void fonct(const Cell<VERTEX>& v)
{
std::cout << v.dart << std::endl;
}
void fonct2(Dart d)
{
std::cout << d << std::endl;
}
void MyQT::traversors(int x)
{
// update all color to grey
......@@ -72,16 +84,31 @@ void MyQT::traversors(int x)
{
case 0:
{
// TRAVERSE2_ADJACENT(VERTEX,EDGE,m_selected, b, MAP, myMap)
// m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
Vertex v(m_selected);
Edge e(m_selected);
fonct(v);
fonct2(e);
fonct(m_selected);
v = m_selected;
/*
Traversor2VVaE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
*/
}
break;
case 1:
{
foreachAdjacent2(VERTEX,FACE,m_selected, b, MAP, myMap)
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
/*
Traversor2VVaF<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
*/
}
break;
case 2:
......@@ -150,9 +177,13 @@ void MyQT::traversors(int x)
break;
case 11:
{
Traversor2VF<MAP> trav(myMap,m_selected);
/* Traversor2VF<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
*/
foreachIncident2(VERTEX,m_selected, FACE, b, MAP, myMap)
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
}
break;
default:
......
cmake_minimum_required(VERSION 2.8)
project(Tuto_Traversals)
SET (CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CGoGN_ROOT_DIR}/include
${CGoGN_EXT_INCLUDES}
)
# define libs path
IF(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/$(ConfigurationName)
${Boost_LIBRARY_DIRS})
ELSE(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/Release ${CGoGN_ROOT_DIR}/lib/Debug)
ENDIF(WIN32)
#define exec to compile
#QT4_WRAP_CPP(tuto1_moc tuto1.h)
#add_executable( tuto1 tuto1.cpp ${tuto1_moc})
#target_link_libraries( tuto1
# ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
#QT4_WRAP_UI( tuto2_ui tuto2.ui )
#QT4_WRAP_CPP(tuto2_moc tuto2.h)
#add_executable( tuto2 tuto2.cpp tuto2.h ${tuto2_ui} ${tuto2_moc})
#target_link_libraries( tuto2
# ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
add_executable( traverse_cells traverse_cells.cpp)
target_link_libraries( traverse_cells ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
add_executable( traverse_neighbours traverse_neighbours.cpp)
target_link_libraries( traverse_neighbours ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
QT4_WRAP_UI( show_traversors_ui show_traversors.ui )
QT4_WRAP_CPP(show_traversors_moc show_traversors.h)
add_executable( show_traversors show_traversors.cpp ${show_traversors_ui} ${show_traversors_moc})
target_link_libraries( show_traversors ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
This diff is collapsed.
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#ifndef __SHOW_TRAVERSORS_
#define __SHOW_TRAVERSORS_
#include <iostream>
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap3.h"
#include "Geometry/vector_gen.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Algo/Render/GL2/topo3Render.h"
#include "Topology/generic/cellmarker.h"
#include "Utils/text3d.h"
#include "Utils/pointSprite.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/cgognStream.h"
#include "Utils/drawer.h"
#include "Utils/Qt/qtSimple.h"
#include "ui_show_traversors.h"
// inclure qtui.h juste après le ui_xxx.h
#include "Utils/Qt/qtui.h"
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition de la carte
typedef EmbeddedMap3 MAP;
};
typedef PFP::MAP MAP ;
typedef PFP::MAP::IMPL MAP_IMPL ;
typedef PFP::VEC3 VEC3 ;
/**
* Utilisation de designer-qt4:
* Faire un DockWiget (laisser le nom par defaut
* dans le Contents ajouter le layout choisi (vertical classiquement)
* Ajouter les widgets necessaires, mettre des noms clairs pour
* les utiliser dans le .cpp (pour les call back principalement)
*/
class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
Algo::Render::GL2::Topo3RenderMap<PFP>* m_render_topo;
bool m_showTopo;
unsigned int m_first3;
unsigned int m_ajd_or_inci3;
unsigned int m_second3;
unsigned int m_first2;
unsigned int m_ajd_or_inci2;
unsigned int m_second2;
float m_expl;
unsigned int m_last;
public:
MyQT():
m_render_topo(NULL),
m_showTopo(true),
m_first3(0),
m_ajd_or_inci3(0),
m_second3(1),
m_first2(0),
m_ajd_or_inci2(0),
m_second2(1),
m_expl(0.8f),
m_last(2),
m_selected(NIL),
m_dm_topo(NULL)
{}
Dart m_selected;
std::vector<Dart> m_affDarts;
Utils::Drawer m_drawer;
DartMarker<MAP>* m_dm_topo;
protected:
void storeVerticesInfo();
void cb_redraw();
void cb_initGL();
void cb_Save();
void cb_mousePress(int button, int x, int y);
template <unsigned int ORBIT>
void colorizeCell(Dart d, float r,float g, float b);
void traverse2();
void traverse3();
void dynamicMarkOrbit(unsigned int orb);
// void dyn_trav3XXaY(unsigned int first, unsigned int second);
// slots locaux
public slots:
void cb_combo1(int x);
void cb_combo2(int x);
void cb_combo3(int x);
void cb_combo4(int x);
void cb_combo5(int x);
void cb_combo6(int x);
void cb_checkTopo(bool b);
void cb_explode(int x);
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DockWidget</class>
<widget class="QDockWidget" name="DockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<height>417</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>250</height>
</size>
</property>
<property name="windowTitle">
<string>Interface</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>200</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>2</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Traversor2</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo4">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<item>
<property name="text">
<string>Vertex</string>
</property>
</item>
<item>
<property name="text">
<string>Edge</string>
</property>
</item>
<item>
<property name="text">
<string>Face</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo5">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<item>
<property name="text">
<string>incident to</string>
</property>
</item>
<item>
<property name="text">
<string>adjacent by</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo6">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Vertex</string>
</property>
</item>
<item>
<property name="text">
<string>Edge</string>
</property>
</item>
<item>
<property name="text">
<string>Face</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Traversor3</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo1">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<item>
<property name="text">
<string>Vertex</string>
</property>
</item>
<item>
<property name="text">
<string>Edge</string>
</property>
</item>
<item>
<property name="text">
<string>Face</string>
</property>
</item>
<item>
<property name="text">
<string>Volume</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo2">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<item>
<property name="text">
<string>incident to</string>
</property>
</item>
<item>
<property name="text">
<string>adjacent by</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo3">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Vertex</string>
</property>
</item>
<item>
<property name="text">
<string>Edge</string>
</property>
</item>
<item>
<property name="text">
<string>Face</string>
</property>
</item>
<item>
<property name="text">
<string>Volume</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="explodeSlider">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="sliderPosition">
<number>80</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkTopo">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>show topo</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
This diff is collapsed.
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#ifndef _TEST_TRAVERSOR2_
#define _TEST_TRAVERSOR2_
//#define USE_GMAP
//#define PRIMAL_TOPO 1
#include "Topology/generic/parameters.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Topology/map/embeddedMap2.h"
#include "Algo/Render/GL2/topoRender.h"
#include "ui_test_traversor2.h"
#include "Utils/Qt/qtui.h"
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
using namespace CGoGN ;
/**
* Struct that contains some informations about the types of the manipulated objects
* Mainly here to be used by the algorithms that are parameterized by it
*/
struct PFP: public PFP_STANDARD
{
// definition of the type of the map
#ifdef USE_GMAP
typedef EmbeddedGMap2 MAP;
#else
typedef EmbeddedMap2 MAP;
#endif
};
typedef PFP::MAP MAP ;
typedef PFP::MAP::IMPL MAP_IMPL ;
typedef PFP::VEC3 VEC3 ;
class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MyQT() :
m_render_topo(NULL),
m_selected(NIL),
m_selected2(NIL),
dm(myMap),
m_shift(0.01f)
{}
void cb_redraw();
void cb_initGL();
void cb_mousePress(int button, int x, int y);
void cb_keyPress(int code);
void cb_Open();
void cb_Save();
Utils::QT::uiDockInterface dock;
protected:
// declaration of the map
MAP myMap;
VertexAttribute<VEC3, MAP_IMPL> position;
DartAttribute<VEC3, MAP_IMPL> colorDarts;
// render (for the topo)
#ifdef USE_GMAP
Algo::Render::GL2::TopoRenderGMap<PFP>* m_render_topo;
#else
Algo::Render::GL2::TopoRenderMap<PFP>* m_render_topo;
#endif
Dart m_selected;
Dart m_selected2;
DartMarker<MAP> dm;
float m_shift;
// just for more compact writing
inline Dart PHI1(Dart d) {return myMap.phi1(d);}
inline Dart PHI_1(Dart d) {return myMap.phi_1(d);}
inline Dart PHI2(Dart d) {return myMap.phi2(d);}
template<int X>
Dart PHI(Dart d) {return myMap.phi<X>(d);}
public:
// example of simple map creation
void createMap(int n);
// void updateMap();
void importMesh(std::string& filename);
public slots:
void traversors(int x);
void svg();
void updateMap();
void width(int w);
};
#endif
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Algo/Tiling/Surface/square.h"
#include "Topology/generic/cells_macros.h"
using namespace CGoGN ;
/**
* Struct that contains some informations about the types of the manipulated objects
* Mainly here to be used by the algorithms that are parameterized by it
*/
struct PFP: public PFP_STANDARD
{
// definition of the type of the map
typedef EmbeddedMap2 MAP;
};
// some typedef shortcuts
typedef PFP::MAP MAP ; // map type
typedef PFP::MAP::IMPL MAP_IMPL ; // map implementation
typedef PFP::VEC3 VEC3 ; // type of R³ vector
int main()
{
// declare a map to handle the mesh
MAP myMap;
// add position attribute on vertices and get handler on it
VertexAttribute<VEC3, MAP_IMPL> position = myMap.addAttribute<VEC3, VERTEX>("position");
// create a topo grid of 2x2 squares
Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, 2, 2, true);
// and embed it using position attribute
grid.embedIntoGrid(position, 1.,1.,0.);
// ALGO:
// foreach vertex of the map
// print position of the vertex
// 4 versions
// low level traversal using pure topo
DartMarker<MAP> dm(myMap);
for (Dart d = myMap.begin(); d != myMap.