From 22926772c98c0842965eb915fa87b27cdca21e83 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Sat, 16 Feb 2008 00:12:42 +0000 Subject: [PATCH] first commit, start to work selecting face and check face angle. Problem with face and vertex color paint --- src/fgt/filter_dirt/filter_dirt.cpp | 145 ++++++++++++++++++++++++++++ src/fgt/filter_dirt/filter_dirt.h | 62 ++++++++++++ src/fgt/filter_dirt/filter_dirt.pro | 28 +++++- 3 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 src/fgt/filter_dirt/filter_dirt.cpp create mode 100644 src/fgt/filter_dirt/filter_dirt.h diff --git a/src/fgt/filter_dirt/filter_dirt.cpp b/src/fgt/filter_dirt/filter_dirt.cpp new file mode 100644 index 000000000..b2c1b16c3 --- /dev/null +++ b/src/fgt/filter_dirt/filter_dirt.cpp @@ -0,0 +1,145 @@ +/**************************************************************************** +* MeshLab o o * +* An extendible mesh processor o o * +* _ O _ * +* Copyright(C) 2005, 2006 \/)\/ * +* Visual Computing Lab /\/| * +* ISTI - Italian National Research Council | * +* \ * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program 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 General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ + +#include +#include +#include "filter_dirt.h" + +#include +#include + +#include + +using namespace vcg; + +FilterDirt::FilterDirt(): + defaultDustTon(1) +{ + typeList << FP_DIRT; + + FilterIDType tt; + foreach(tt , types()) + actionList << new QAction(filterName(tt), this); + +} + +FilterDirt::~FilterDirt() { + for (int i = 0; i < actionList.count() ; i++ ) + delete actionList.at(i); +} + +const QString FilterDirt::filterName(FilterIDType filter) +{ + switch(filter) + { + case FP_DIRT : return QString("Simulate dust"); + default: assert(0); + } + return QString("error!"); +} + +const QString FilterDirt::filterInfo(FilterIDType filterId) +{ + switch(filterId) + { + case FP_DIRT: return tr("Simulate dust over mesh."); + default: assert(0); + } + return QString("error!"); +} + + +const PluginInfo &FilterDirt::pluginInfo() +{ + static PluginInfo ai; + ai.Date=tr( __DATE__ ); + ai.Version = tr("0.1"); + ai.Author = ("Luca Bartoletti"); + return ai; +} + +const int FilterDirt::getRequirements(QAction *action) +{ + return MeshModel::MM_FACECOLOR; +} + + +bool FilterDirt::applyFilter(QAction *filter, MeshModel &m, FilterParameterSet & par, vcg::CallBackPos * cb) +{ + /*Select a random face and check only angle between face normal and mesh's -Y axe for now*/ + /* + Problema: Non sono riuscito a capire perchč (*di)->C()=vcg::Color4b::Blue; (come le funzioni vcg::tri::UpdateColor) + non funziona se prima non applico un filtro di tipo Colorize che modifica il colore delle facce + (triangle intersection, triangle qualitity, etc...). Ritorno in getRequest MM_FACECOLOR, per sicurezza ho + provato anche con MM_ALL. + La stessa cosa succede se provo a cambiare il colore dei vertici, + prima devo applicare un filtro che modifica il colore dei vertici (come ad esempio Border). + Ho letto pił volte il plugin meshcolorize senza trovare soluzione, ho provato con il debugger + a guardare cosa succede ma sono solo riuscito a vedere che il colore della faccia viene effettivamente modificato. + + TODO: + *Muovere i ton lungo la superfice per un certo numero di iterazioni + *fornire interfaccia per selezionare numero di ton e numero di iterazioni + *Modificare flag vertici per tenere traccia della quantitą di dust + e per modificarne il colore alla fine delle iterazioni + */ + + //pointer to face where are dust ton + vector dustTon; + + vector::iterator di; + + CMeshO::FaceIterator fi = m.cm.face.begin(); + + int randomFace=0; + + //select random face + for (int cont=0; contC()=vcg::Color4b::Blue; + //get vector direction to move dust over face + dustDirection = ((*di)->N() ^ vcg::Point3f(0,-1,0)) ^ (*di)->N(); + //check if selected face angle between normal and -Y axe + if (!(vcg::Angle((*di)->N(),vcg::Point3f(0,-1,0)) +#include +#include + +#include +#include + + +class FilterDirt : public QObject, public MeshFilterInterface +{ + Q_OBJECT + Q_INTERFACES(MeshFilterInterface) + + public: + enum {FP_DIRT} ; + + FilterDirt(); + ~FilterDirt(); + + virtual const QString filterName(FilterIDType filter); + virtual const QString filterInfo(FilterIDType filter); + virtual const PluginInfo &pluginInfo(); + + virtual const int getRequirements(QAction *); + + virtual bool autoDialog(QAction *) {return false;} + virtual void initParameterSet(QAction *,MeshModel &/*m*/, FilterParameterSet & /*parent*/){}; + virtual bool applyFilter(QAction *filter, MeshModel &m, FilterParameterSet & /*parent*/, vcg::CallBackPos * cb) ; + + + protected: + const int defaultDustTon; +}; + + +#endif diff --git a/src/fgt/filter_dirt/filter_dirt.pro b/src/fgt/filter_dirt/filter_dirt.pro index 0315c415e..bbad36b69 100644 --- a/src/fgt/filter_dirt/filter_dirt.pro +++ b/src/fgt/filter_dirt/filter_dirt.pro @@ -1 +1,27 @@ - MeshLab +TEMPLATE = lib +QT += opengl +CONFIG += plugin +INCLUDEPATH += ../.. ../../../../sf ../../../../code/lib/glew/include +HEADERS = filter_dirt.h + +SOURCES = filter_dirt.cpp \ + ../../meshlab/filterparameter.cpp \ + ../../../../code/lib/glew/src/glew.c + +TARGET = filter_dirt + +DESTDIR = ../../meshlab/plugins + +# the following line is needed to avoid mismatch between +# the awful min/max macros of windows and the limits max +win32:DEFINES += NOMINMAX +# mac:CONFIG += x86 ppc + +DEFINES += GLEW_STATIC + +contains(TEMPLATE,lib) { + CONFIG(debug, debug|release) { + unix:TARGET = $$member(TARGET, 0)_debug + else:TARGET = $$member(TARGET, 0)d + } +}