Blender  V2.93
AdvancedFunctions0D.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
22 #include "AdvancedFunctions0D.h"
23 #include "Canvas.h"
24 
25 #include "../view_map/Functions0D.h"
26 #include "../view_map/SteerableViewMap.h"
27 
29 
31 {
32  Canvas *canvas = Canvas::getInstance();
33  int bound = _filter.getBound();
34 
35  if ((iter->getProjectedX() - bound < 0) || (iter->getProjectedX() + bound > canvas->width()) ||
36  (iter->getProjectedY() - bound < 0) || (iter->getProjectedY() + bound > canvas->height())) {
37  result = 0.0;
38  return 0;
39  }
40 
41  RGBImage image;
42  canvas->readColorPixels((int)iter->getProjectedX() - bound,
43  (int)iter->getProjectedY() - bound,
44  _filter.maskSize(),
45  _filter.maskSize(),
46  image);
47  result = _filter.getSmoothedPixel<RGBImage>(
48  &image, (int)iter->getProjectedX(), (int)iter->getProjectedY());
49 
50  return 0;
51 }
52 
54 {
55  Canvas *iViewer = Canvas::getInstance();
56  int bound = _filter.getBound();
57 
58  if ((iter->getProjectedX() - bound < 0) || (iter->getProjectedX() + bound > iViewer->width()) ||
59  (iter->getProjectedY() - bound < 0) || (iter->getProjectedY() + bound > iViewer->height())) {
60  result = 0.0;
61  return 0;
62  }
63 
64  GrayImage image;
65  iViewer->readDepthPixels((int)iter->getProjectedX() - bound,
66  (int)iter->getProjectedY() - bound,
67  _filter.maskSize(),
68  _filter.maskSize(),
69  image);
70  result = _filter.getSmoothedPixel(
71  &image, (int)iter->getProjectedX(), (int)iter->getProjectedY());
72 
73  return 0;
74 }
75 
77 {
78  Canvas *canvas = Canvas::getInstance();
79  result = canvas->readMapPixel(
80  _mapName, _level, (int)iter->getProjectedX(), (int)iter->getProjectedY());
81  return 0;
82 }
83 
85 {
88  _orientation, _level, (int)iter->getProjectedX(), (int)iter->getProjectedY());
89  return 0;
90 }
91 
93 {
96  _level, (int)iter->getProjectedX(), (int)iter->getProjectedY());
97  return 0;
98 }
99 
101 {
103  float pxy = svm->readCompleteViewMapPixel(
104  _level, (int)iter->getProjectedX(), (int)iter->getProjectedY());
105  float gx = svm->readCompleteViewMapPixel(
106  _level, (int)iter->getProjectedX() + _step, (int)iter->getProjectedY()) -
107  pxy;
108  float gy = svm->readCompleteViewMapPixel(
109  _level, (int)iter->getProjectedX(), (int)iter->getProjectedY() + _step) -
110  pxy;
111  result = Vec2f(gx, gy).norm();
112  return 0;
113 }
114 
115 } // namespace Freestyle::Functions0D
Functions taking 0D input.
Class to define a canvas designed to draw style modules.
SteerableViewMap * getSteerableViewMap()
Definition: Canvas.h:177
virtual void readDepthPixels(int x, int y, int w, int h, GrayImage &oImage) const =0
static Canvas * getInstance()
Definition: Canvas.h:69
float readMapPixel(const char *iMapName, int level, int x, int y)
Definition: Canvas.cpp:461
virtual void readColorPixels(int x, int y, int w, int h, RGBImage &oImage) const =0
virtual int height() const =0
virtual int width() const =0
int operator()(Interface0DIterator &iter)
int operator()(Interface0DIterator &iter)
float getSmoothedPixel(Map *map, int x, int y)
virtual real getProjectedX() const
Definition: Interface0D.cpp:55
virtual real getProjectedY() const
Definition: Interface0D.cpp:61
float readSteerableViewMapPixel(unsigned iOrientation, int iLevel, int x, int y)
float readCompleteViewMapPixel(int iLevel, int x, int y)
value_type norm() const
Definition: VecMat.h:109
VecMat::Vec2< float > Vec2f
Definition: Geom.h:34