Go to the documentation of this file.
14 #ifndef _SCL_SECURE_NO_WARNINGS
15 #define _SCL_SECURE_NO_WARNINGS
21 #include <QStringList>
24 #ifndef Q_MOC_RUN // MT : very important to avoid the error : ' Parse error at
28 #include <boost/foreach.hpp>
45 #endif // FEVV_USE_CGAL
46 #ifdef FEVV_USE_OPENMESH
48 #endif // FEVV_USE_OPENMESH
51 #endif // FEVV_USE_AIF
62 #if(FEVV_USE_QT5) // see at the end of .cpp for QT4
63 Q_PLUGIN_METADATA(IID
"JndPlugin")
98 std::cerr <<
"BaseWindow is null or not initialized." << std::endl;
103 template<
typename HalfedgeGraph >
107 typedef boost::graph_traits< HalfedgeGraph > GraphTraits;
122 auto pm =
get(boost::vertex_point, *_m);
125 using VertexColorMap =
127 HalfedgeGraph >::pmap_type;
128 typedef typename boost::property_traits< VertexColorMap >::value_type
Color;
132 std::cout <<
"use existing vertex-color map" << std::endl;
137 std::cout <<
"create vertex-color map" << std::endl;
144 using FaceNormalMap =
146 HalfedgeGraph >::pmap_type;
150 std::cout <<
"use existing face-normal map" << std::endl;
155 std::cout <<
"create face-normal map" << std::endl;
163 using VertexNormalMap =
165 HalfedgeGraph >::pmap_type;
166 VertexNormalMap v_nm;
167 if(
has_map(*pmaps_bag, std::string(
"v:normal")))
169 std::cout <<
"use existing vertex-normal map" << std::endl;
170 v_nm = boost::any_cast< VertexNormalMap >(pmaps_bag->at(
"v:normal"));
174 std::cout <<
"create vertex-normal map" << std::endl;
184 clock_t tStart = clock();
188 std::cout <<
"use existing jnd map" << std::endl;
189 jnd_m = boost::any_cast< JndTypeMap >(pmaps_bag->at(
"v:jnd"));
193 jnd_m = FEVV::make_vertex_property_map< HalfedgeGraph, double >(*_m);
194 std::cout <<
"computing jnd map" << std::endl;
197 (*pmaps_bag)[
"v:jnd"] = jnd_m;
199 clock_t tJND = clock();
201 double min_jnd = 10000.0;
202 double max_jnd = 0.0;
206 auto jnd =
get(jnd_m, vi);
212 clock_t tMM = clock();
216 auto jnd =
get(jnd_m, vi);
219 color = 2.0 * ((std::log((*
log_disp + jnd))) /
220 (std::log((*
log_disp + max_jnd)))) -
223 color = 2.0 * ((jnd - min_jnd) / (max_jnd - min_jnd)) - 1.0;
225 put(v_cm, vi, newcolor);
228 std::cout <<
"Time used to compute JND : "
229 << (double)(tJND - tStart) / CLOCKS_PER_SEC << std::endl;
230 std::cout <<
"Time used to compute minmax : "
231 << (double)(tMM - tJND) / CLOCKS_PER_SEC << std::endl;
232 std::cout <<
"Time used to compute colors : "
233 << (double)(clock() - tMM) / CLOCKS_PER_SEC << std::endl;
234 std::cout <<
"JND min : " << min_jnd << std::endl;
235 std::cout <<
"JND max : " << max_jnd << std::endl;
239 template<
typename HalfedgeGraph >
241 HalfedgeGraph *_mesh,
246 if(dial1.exec() == QDialog::Accepted)
285 #ifdef FEVV_USE_OPENMESH
290 applyHG< MeshOpenMesh >(_adapter, _mesh, pmaps_bag);
295 void apply(BaseAdapterVisu *_adapter,
299 applyHG< MeshLCC >(_adapter, _mesh, pmaps_bag);
302 void apply(BaseAdapterVisu *_adapter,
306 applyHG< MeshSurface >(_adapter, _mesh, pmaps_bag);
309 void apply(BaseAdapterVisu *_adapter,
313 applyHG< MeshPolyhedron >(_adapter, _mesh, pmaps_bag);
318 void apply(BaseAdapterVisu *_adapter,
322 applyHG< MeshAIF >(_adapter, _mesh, pmaps_bag);
329 return QStringList() <<
"JndPlugin";
357 double interpolate(
double val,
double y0,
double x0,
double y1,
double x1)
359 return (val - x0) * (y1 - y0) / (x1 - x0) + y0;
372 double red(
double gray) {
return base(1.0 + gray); }
374 double blue(
double gray) {
return base(1.0 - gray); }
virtual bool isInit() const
std::pair< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_iterator, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_iterator > vertices(const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the iterator range of the vertices of the mesh.
void put_property_map(PropertyT p, const MeshT &, PMapsContainer &pmaps, const typename PMap_traits< PropertyT, MeshT >::pmap_type &pmap)
void applyHG(BaseAdapterVisu *_adapter, HalfedgeGraph *_mesh, FEVV::PMapsContainer *pmaps_bag)
PMap_traits< PropertyT, MeshT >::pmap_type get_property_map(PropertyT p, const MeshT &, const PMapsContainer &pmaps)
double green(double gray)
void getProcess(int &screenH, int &screenW, double &screenS, int &sceneH, double &sceneFov, double &userD, int &nbLights, float &log_disp, bool &use_log, bool &force_jnd)
The parameters of the user.
CGAL::Linear_cell_complex_for_combinatorial_map< 2, 3, CGALLCCTraits, CGALItem > MeshLCC
The parameters of the screen.
bool has_map(const PMapsContainer &pmaps, const std::string &map_name)
(refer to Property Maps API)
This class is intended to provide some standard message boxes to all plugins.
virtual Viewer * getViewer()
void process(HalfedgeGraph *_m, FEVV::PMapsContainer *pmaps_bag)
The parameters of the scene.
CGAL::Surface_mesh< CGALPoint > MeshSurface
SimpleWindow is a specialization of QMainWindow. This class the Main Window.
std::map< std::string, boost::any > PMapsContainer
void draw_or_redraw_mesh(HalfedgeGraph *_g, PMapsContainer *_pmaps, bool _redraw=false, bool _recomputeNT_if_redraw=false, std::string _mesh_filename=std::string(""), bool _recreateOSGobj_if_redraw=true, float _step=0.)
QStringList Generic_plugins() const override
FEVV::PCLPointCloudPointMap::value_type get(const FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key)
Specialization of get(point_map, key) for PCLPointCloud.
SimpleViewer is a specialization of osgViewer::CompositeViewer. This class is a widget where we are a...
void onModificationParam(std::string _pluginName, BasePlugin *_plugin)
Interfaces for plugins These interfaces will be used for different plugins.
void calculate_face_normals(const HalfedgeGraph &g, const PointMap &pm, FaceNormalMap fnm, const GeometryTraits >)
Calculate "some" normal of all the faces of the considered mesh and populate the argument provided Fa...
double interpolate(double val, double y0, double x0, double y1, double x1)
void calculate_vertex_normals(const HalfedgeGraph &g, const PointMap &pm, const FaceNormalMap &fnm, VertexNormalMap vnm, const GeometryTraits >)
Compute the respectice vertex normal for all the vertices of the considered mesh and populate the arg...
bool Generic_plugin(const QString &) override
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
double fabs(const v_Curv< HalfedgeGraph > &input)
OpenMesh::PolyMesh_ArrayKernelT< MyTraits > MeshOpenMesh
void put(FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key, const FEVV::PCLPointCloudPointMap::value_type &value)
Specialization of put(point_map, key, value) for PCLPointCloud.
virtual void apply(BaseAdapterVisu *, void *, FEVV::PMapsContainer *) override
void just_noticeable_distortion_filter(const HalfedgeGraph &halfedge_graph, PointMap &point_map, const VertexNormalMap &vertex_normal_map, const GeometryTraits &geometry_traits, const FaceNormalMap &face_normal_map, JNDMap &jnd_map, const ScreenParam &screen, const UserParam &user, const SceneParam &scene, const int nb_light_sources, bool data_output=false, bool use_random=true)
Computes the Just Noticeable Distortion metric.
CGAL::Polyhedron_3< CGALKernel, CGAL::Polyhedron_items_with_id_3 > MeshPolyhedron
void addParameters(BaseWindow *_window) override
PMap_traits< PropertyT, MeshT >::pmap_type make_property_map(PropertyT, const MeshT &m)
FEVV::DataStructures::AIF::AIFMesh MeshAIF