mirror of https://github.com/CGAL/cgal
Change and Add some functionality: we can see words corresponding to translations
This commit is contained in:
parent
bb43abe344
commit
3ea080c409
|
|
@ -28,6 +28,7 @@
|
|||
// experiment
|
||||
#include "GroupOfIndex2.h"
|
||||
#include "OriginalDomainNeighbors.h"
|
||||
#include "OriginalDomainNeighborsCommon.h"
|
||||
//
|
||||
|
||||
// GraphicsView items and event filters (input classes)
|
||||
|
|
@ -37,7 +38,7 @@
|
|||
#include "TriangulationConflictZone.h"
|
||||
#include "TriangulationRemoveVertex.h"
|
||||
#include "TriangulationPointInputAndConflictZone.h"
|
||||
#include <CGAL/Qt/TriangulationGraphicsItem.h>
|
||||
#include <CGAL/Qt/TriangulationGraphicsItemWithColorInfo.h>
|
||||
#include <CGAL/Qt/VoronoiGraphicsItem.h>
|
||||
|
||||
// for viewportsBbox
|
||||
|
|
@ -99,6 +100,17 @@ private:
|
|||
typedef CGAL::Qt::OriginalDomainNeighbors<Delaunay, Hyperbolic_isometry> OriginalDomainNeighbors;
|
||||
typedef Group_of_index_2<Hyperbolic_isometry> Group_of_index_2;
|
||||
|
||||
|
||||
// Oct 2012
|
||||
typedef IsometryWithInfo<Gt, TranslationInfo<std::wstring> > TranslationWithInfo;
|
||||
typedef CGAL::Qt::OriginalDomainNeighborsCommon<Delaunay, TranslationWithInfo> OriginalDomainNeighborsWithInfo;
|
||||
|
||||
std::vector<TranslationWithInfo> cloud_of_translations;
|
||||
|
||||
OriginalDomainNeighborsWithInfo *odnwi;
|
||||
OriginalDomainNeighborsWithInfo *odnwi2;
|
||||
//
|
||||
|
||||
// delete later, for some experiments
|
||||
Group_of_index_2::List words;
|
||||
//
|
||||
|
|
@ -221,6 +233,44 @@ void GenerateWordsOfLengthLessThan4(const TList& input, TList& output)
|
|||
|
||||
}
|
||||
|
||||
|
||||
template<class TList>
|
||||
void GenerateWordsOfLengthLessThan4_2(const TList& input, TList& output)
|
||||
{
|
||||
typedef typename TList::value_type Val_type;
|
||||
|
||||
std::copy(input.begin(), input.end(), std::insert_iterator<TList>(output, output.end()));
|
||||
|
||||
typename TList::const_iterator gi, gj, gk, gl;
|
||||
gi = input.begin();
|
||||
int i, j, k;
|
||||
for(i = 0, gi = input.begin(); gi != input.end(); i++, gi++) {
|
||||
for(j = 0, gj = input.begin(); gj != input.end(); j++, gj++) {
|
||||
if(inverses(i, j)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Val_type el = (*gi) * (*gj);
|
||||
output.push_back(el);
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0, gi = input.begin(); gi != input.end(); i++, gi++) {
|
||||
for(j = 0, gj = input.begin(); gj != input.end(); j++, gj++) {
|
||||
for(k = 0, gk = input.begin(); gk != input.end(); k++, gk++) {
|
||||
if(inverses(i, j) || inverses(j, k)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Val_type el = (*gi) * (*gj) * (*gk);
|
||||
output.push_back(el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: DemosMainWindow(), dt(K(1))
|
||||
{
|
||||
|
|
@ -295,6 +345,35 @@ MainWindow::MainWindow()
|
|||
trs_c->info().setString(L"c");
|
||||
trs_d->info().setString(L"d");
|
||||
|
||||
// temp things
|
||||
TranslationWithInfo tr_a(Translations::a(), TranslationInfo<std::wstring>(L"a") );
|
||||
TranslationWithInfo tr_b(Translations::b(), TranslationInfo<std::wstring>(L"b") );
|
||||
TranslationWithInfo tr_c(Translations::c(), TranslationInfo<std::wstring>(L"c") );
|
||||
TranslationWithInfo tr_d(Translations::d(), TranslationInfo<std::wstring>(L"d") );
|
||||
|
||||
TranslationWithInfo tr_inv_a(Translations::a().inverse(), TranslationInfo<std::wstring>(L"a̅") );
|
||||
TranslationWithInfo tr_inv_b(Translations::b().inverse(), TranslationInfo<std::wstring>(L"b̅") );
|
||||
TranslationWithInfo tr_inv_c(Translations::c().inverse(), TranslationInfo<std::wstring>(L"c̅") );
|
||||
TranslationWithInfo tr_inv_d(Translations::d().inverse(), TranslationInfo<std::wstring>(L"d̅") );
|
||||
|
||||
std::vector<TranslationWithInfo> translations_with_info;
|
||||
translations_with_info.push_back(tr_a);
|
||||
translations_with_info.push_back(tr_b);
|
||||
translations_with_info.push_back(tr_inv_a);
|
||||
translations_with_info.push_back(tr_inv_b);
|
||||
translations_with_info.push_back(tr_c);
|
||||
translations_with_info.push_back(tr_d);
|
||||
translations_with_info.push_back(tr_inv_c);
|
||||
translations_with_info.push_back(tr_inv_d);
|
||||
|
||||
GenerateWordsOfLengthLessThan4_2(translations_with_info, cloud_of_translations);
|
||||
std::cout << "size of cloud " << cloud_of_translations.size() << std::endl;
|
||||
|
||||
odnwi = new OriginalDomainNeighborsWithInfo(scene, &dt, this);
|
||||
QObject::connect(odnwi, SIGNAL(modelChanged()),
|
||||
this, SIGNAL(changed()));
|
||||
//
|
||||
|
||||
QObject::connect(trs_a, SIGNAL(modelChanged()),
|
||||
this, SIGNAL(changed()));
|
||||
QObject::connect(trs_b, SIGNAL(modelChanged()),
|
||||
|
|
@ -405,13 +484,25 @@ MainWindow::processInput(CGAL::Object o)
|
|||
//}
|
||||
|
||||
//delete
|
||||
if(disk->contains(qp)){
|
||||
/*if(disk->contains(qp)){
|
||||
std::cout << "inserted point " << p << std::endl;
|
||||
odn2 = new OriginalDomainNeighbors(scene, &dt, this, p, 1);
|
||||
QObject::connect(odn2, SIGNAL(modelChanged()), this, SIGNAL(changed()));
|
||||
|
||||
odn2->assign(g4.begin(), g4.end());
|
||||
odn2->assign(words.begin(), words.end());
|
||||
}*/
|
||||
|
||||
// Oct 2012
|
||||
|
||||
if(disk->contains(qp)){
|
||||
std::cout << "inserted point " << p << std::endl;
|
||||
odnwi2 = new OriginalDomainNeighborsWithInfo(scene, &dt, this, p, 1);
|
||||
QObject::connect(odnwi2, SIGNAL(modelChanged()),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
//odnwi2->assign(g4.begin(), g4.end());
|
||||
odnwi2->assign(cloud_of_translations.begin(), cloud_of_translations.end());
|
||||
}
|
||||
}
|
||||
emit(changed());
|
||||
|
|
@ -524,8 +615,11 @@ MainWindow::on_actionG16_toggled(bool checked)
|
|||
// odn->assign(g16.begin(), g16.end());
|
||||
|
||||
// Delete! Add all the words of length less than 4 + some words of length 4.
|
||||
odn->assign(g4.begin(), g4.end());
|
||||
odn->assign(words.begin(), words.end());
|
||||
//odn->assign(g4.begin(), g4.end());
|
||||
//odn->assign(words.begin(), words.end());
|
||||
|
||||
// Oct 2012
|
||||
odnwi->assign(cloud_of_translations.begin(), cloud_of_translations.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
|
||||
#ifndef CGAL_QT_ORIGINAL_DOMAIN_NEIGHBORS_COMMON
|
||||
#define CGAL_QT_ORIGINAL_DOMAIN_NEIGHBORS_COMMON
|
||||
|
||||
#include <CGAL/circulator.h>
|
||||
|
||||
#include <CGAL/Qt/GraphicsViewInput.h>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QEvent>
|
||||
|
||||
#include <PointGraphicsItem.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Qt {
|
||||
|
||||
template <typename DT, typename Translation>
|
||||
class OriginalDomainNeighborsCommon : public GraphicsViewInput
|
||||
{
|
||||
public:
|
||||
typedef typename DT::Face_handle Face_handle;
|
||||
typedef typename DT::Vertex_handle Vertex_handle;
|
||||
typedef typename DT::Point Point;
|
||||
|
||||
OriginalDomainNeighborsCommon(QGraphicsScene& scene_, DT * dt_, QObject* parent, Point p_, int color);
|
||||
|
||||
template <typename InputIterator>
|
||||
void assign(InputIterator begin, InputIterator end)
|
||||
{
|
||||
insert(begin, end);
|
||||
}
|
||||
|
||||
protected:
|
||||
template <typename InputIterator>
|
||||
void insert(InputIterator begin, InputIterator end);
|
||||
|
||||
Point do_point_translation(const Translation& translation) const;
|
||||
virtual Vertex_handle insert_point(const Point& p);
|
||||
|
||||
// extra - not common
|
||||
template<typename Info>
|
||||
void add_info(Vertex_handle v, Info new_info);
|
||||
void add_color(Vertex_handle v);
|
||||
|
||||
private:
|
||||
DT * dt;
|
||||
|
||||
// center of original domain
|
||||
Point p;
|
||||
int color;
|
||||
};
|
||||
|
||||
|
||||
template <typename DT, typename Translation>
|
||||
OriginalDomainNeighborsCommon<DT, Translation>::OriginalDomainNeighborsCommon(QGraphicsScene& ,
|
||||
DT * dt_,
|
||||
QObject* parent,
|
||||
Point p_ = Point(0, 0),
|
||||
int color_ = 0)
|
||||
: GraphicsViewInput(parent), dt(dt_), p(p_), color(color_)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template <typename DT, typename Translation>
|
||||
template <typename InputIterator>
|
||||
void
|
||||
OriginalDomainNeighborsCommon<DT, Translation>::insert(InputIterator begin, InputIterator end)
|
||||
{
|
||||
insert_point(p);
|
||||
|
||||
for(InputIterator it = begin; it != end; ++it) {
|
||||
Translation t = *it;
|
||||
Point neighbor = do_point_translation(*it);
|
||||
|
||||
Vertex_handle v = insert_point(neighbor);
|
||||
|
||||
add_info(v, it->info());
|
||||
add_color(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename DT, typename Translation>
|
||||
typename OriginalDomainNeighborsCommon<DT, Translation>::Point
|
||||
OriginalDomainNeighborsCommon<DT, Translation>::do_point_translation(const Translation& translation) const
|
||||
{
|
||||
return translation.DoAction(p);
|
||||
}
|
||||
|
||||
|
||||
template <typename DT, typename Translation>
|
||||
typename OriginalDomainNeighborsCommon<DT, Translation>::Vertex_handle
|
||||
OriginalDomainNeighborsCommon<DT, Translation>::insert_point(const Point& p)
|
||||
{
|
||||
Vertex_handle v = dt->insert(p);
|
||||
emit(modelChanged());
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
template <typename DT, typename Translation>
|
||||
template <typename Info>
|
||||
void
|
||||
OriginalDomainNeighborsCommon<DT, Translation>::add_info(Vertex_handle v, Info new_info)
|
||||
{
|
||||
v->info() = new_info;
|
||||
}
|
||||
|
||||
|
||||
template <typename DT, typename Translation>
|
||||
void
|
||||
OriginalDomainNeighborsCommon<DT, Translation>::add_color(Vertex_handle v)
|
||||
{
|
||||
v->info().setColor(color);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Qt
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_QT_ORIGINAL_DOMAIN_NEIGHBORS_COMMON
|
||||
|
|
@ -74,7 +74,7 @@ template <typename T>
|
|||
PointGraphicsItem<T>::PointGraphicsItem(Point p)
|
||||
: m_painter(0), m_p(p), bb(0,0,0,0), bb_initialized(false)
|
||||
{
|
||||
setVertexPen(QPen(::Qt::green, 3.));
|
||||
setVertexPen(QPen(::Qt::black, 4.));
|
||||
|
||||
updateBoundingBox();
|
||||
setZValue(3);
|
||||
|
|
|
|||
|
|
@ -108,10 +108,11 @@ PointTranslation<DT, Translation>::mousePressEvent(QGraphicsSceneMouseEvent *eve
|
|||
return;
|
||||
}
|
||||
|
||||
// Oct 2012. Commented for a while
|
||||
// translate chosen point
|
||||
Point translated_point = do_point_translation();
|
||||
//Point translated_point = do_point_translation();
|
||||
// insert to the triangulation
|
||||
insert_point(translated_point);
|
||||
//insert_point(translated_point);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
#ifndef TRANSLATION_INFO
|
||||
#define TRANSLATION_INFO
|
||||
|
||||
#include <CGAL/Hyperbolic_isometry_2.h>
|
||||
|
||||
template<typename String>
|
||||
class TranslationInfo
|
||||
{
|
||||
|
|
@ -7,8 +12,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
TranslationInfo(const String& name)
|
||||
: name_of_translation(name), color(0)
|
||||
TranslationInfo(const String& name, int new_color = 0)
|
||||
: name_of_translation(name), color(new_color)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -46,3 +51,31 @@ TranslationInfo<String> operator + (const TranslationInfo<String>& l, const Tran
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Gt, typename Info>
|
||||
class IsometryWithInfo : public CGAL::Hyperbolic_isometry_2<Gt>
|
||||
{
|
||||
public:
|
||||
typedef CGAL::Hyperbolic_isometry_2<Gt> Base;
|
||||
//typedef Base::Point Point;
|
||||
|
||||
IsometryWithInfo(const Base& base, const Info& new_info = Info()) : Base(base), _info(new_info)
|
||||
{
|
||||
}
|
||||
|
||||
IsometryWithInfo operator * (const IsometryWithInfo& other) const
|
||||
{
|
||||
Base base = this->Base::operator *(other);
|
||||
Info new_info = info() + other.info();
|
||||
|
||||
return IsometryWithInfo(base, new_info);
|
||||
}
|
||||
|
||||
const Info& info() const { return _info; }
|
||||
Info& info() { return _info; }
|
||||
|
||||
private:
|
||||
Info _info;
|
||||
};
|
||||
|
||||
#endif // TRANSLATION_INFO
|
||||
|
|
|
|||
|
|
@ -48,13 +48,13 @@ public:
|
|||
static Hyperbolic_isometry& c()
|
||||
{
|
||||
compute();
|
||||
return g[2].first;
|
||||
return g[5].first;
|
||||
}
|
||||
|
||||
static Hyperbolic_isometry& d()
|
||||
{
|
||||
compute();
|
||||
return g[3].first;
|
||||
return g[6].first;
|
||||
}
|
||||
|
||||
static const Vector& get_vector_of_translations()
|
||||
|
|
|
|||
Loading…
Reference in New Issue