20 #include "../image/Image.h"
22 #include "../scene_graph/NodeDrawingStyle.h"
23 #include "../scene_graph/NodeShape.h"
24 #include "../scene_graph/NodeTransform.h"
25 #include "../scene_graph/NodeViewLayer.h"
26 #include "../scene_graph/ScenePrettyPrinter.h"
27 #include "../scene_graph/VertexRep.h"
29 #include "../stroke/PSStrokeRenderer.h"
30 #include "../stroke/StrokeTesselator.h"
31 #include "../stroke/StyleModule.h"
32 #include "../stroke/TextStrokeRenderer.h"
34 #include "../system/PythonInterpreter.h"
35 #include "../system/StringUtils.h"
37 #include "../view_map/SteerableViewMap.h"
38 #include "../view_map/ViewMap.h"
39 #include "../view_map/ViewMapTesselator.h"
41 #include "../winged_edge/Curvature.h"
42 #include "../winged_edge/WEdge.h"
43 #include "../winged_edge/WXEdgeBuilder.h"
44 #include "../winged_edge/WingedEdgeBuilder.h"
46 #include "../blender_interface/BlenderFileLoader.h"
47 #include "../blender_interface/BlenderStrokeRenderer.h"
48 #include "../blender_interface/BlenderStyleModule.h"
73 _SilhouetteNode =
NULL;
74 _ProjectedSilhouette =
NULL;
75 _VisibleProjectedSilhouette =
NULL;
81 _winged_edge =
nullptr;
84 _pRenderMonitor =
nullptr;
91 _minEdgeSize = DBL_MAX;
106 _EnableViewMapCache =
false;
108 _EnableFaceSmoothness =
false;
109 _ComputeRidges =
true;
110 _ComputeSteerableViewMap =
false;
111 _ComputeSuggestive =
true;
112 _ComputeMaterialBoundaries =
true;
114 _creaseAngle = 134.43;
115 prevSceneHash = -1.0;
122 if (
nullptr != _RootNode) {
123 int ref = _RootNode->
destroy();
130 if (
NULL != _SilhouetteNode) {
131 int ref = _SilhouetteNode->
destroy();
133 delete _SilhouetteNode;
137 if (
NULL != _DebugNode) {
138 int ref = _DebugNode->destroy();
147 _winged_edge =
nullptr;
167 _ProgressBar =
nullptr;
175 if (
nullptr == iView) {
185 _pRenderMonitor = iRenderMonitor;
210 if (!_EnableViewMapCache) {
213 if (sceneHashFunc.
match()) {
216 sceneHashFunc.
store();
230 if (blenderScene ==
nullptr) {
232 cout <<
"Cannot load scene" << endl;
239 cout <<
"Empty scene" << endl;
248 cout <<
"Scene loaded" << endl;
249 printf(
"Mesh cleaning : %lf\n", duration);
250 printf(
"View map cache : %s\n", _EnableViewMapCache ?
"enabled" :
"disabled");
255 if (loader.minEdgeSize() < _minEdgeSize) {
256 _minEdgeSize = loader.minEdgeSize();
262 blenderScene->
accept(spp);
275 if (_EnableViewMapCache) {
285 for (
int i = 0; i < 4; i++) {
286 for (
int j = 0; j < 4; j++) {
294 sceneHashFunc.
reset();
296 _RootNode->
accept(sceneHashFunc);
298 cout <<
"Scene hash : " << sceneHashFunc.
toString() << endl;
313 blenderScene->
accept(wx_builder);
316 duration = _Chrono.
stop();
318 printf(
"WEdge building : %lf\n", duration);
325 if (0 != ws_builder) {
330 soc QFileInfo qfi(iFileName);
331 soc
string basename((
const char *)qfi.fileName().toAscii().data());
338 _ListOfModels.emplace_back(
"Blender_models");
340 _Scene3dBBox = _RootNode->
bbox();
342 _bboxDiag = (_RootNode->
bbox().getMax() - _RootNode->
bbox().getMin()).
norm();
344 cout <<
"Triangles nb : " << _SceneNumFaces <<
" imported, " << _winged_edge->
getNumFaces()
345 <<
" retained" << endl;
346 cout <<
"Bounding Box : " << _bboxDiag << endl;
352 if (_SceneNumFaces == 0) {
363 _ListOfModels.clear();
381 if (
nullptr != _RootNode) {
382 int ref = _RootNode->
destroy();
394 _winged_edge =
nullptr;
399 _Scene3dBBox.clear();
402 _minEdgeSize = DBL_MAX;
410 if (
NULL != _SilhouetteNode) {
411 int ref = _SilhouetteNode->destroy();
413 delete _SilhouetteNode;
414 _SilhouetteNode =
NULL;
418 if (
NULL != _ProjectedSilhouette) {
419 int ref = _ProjectedSilhouette->destroy();
421 delete _ProjectedSilhouette;
422 _ProjectedSilhouette =
NULL;
425 if (
NULL != _VisibleProjectedSilhouette) {
426 int ref = _VisibleProjectedSilhouette->destroy();
428 delete _VisibleProjectedSilhouette;
429 _VisibleProjectedSilhouette =
NULL;
434 if (
NULL != _DebugNode) {
435 int ref = _DebugNode->destroy();
437 _DebugNode->addRef();
443 if (freeCache || !_EnableViewMapCache) {
446 prevSceneHash = -1.0;
456 if (_ListOfModels.empty()) {
474 cout <<
"mv" << endl;
478 for (
int i = 0; i < 4; i++) {
479 for (
int j = 0; j < 4; j++) {
483 cout <<
mv[i][j] <<
" ";
496 cout <<
"\nproj" << endl;
500 for (
int i = 0; i < 4; i++) {
501 for (
int j = 0; j < 4; j++) {
505 cout << proj[i][j] <<
" ";
517 for (
int i = 0; i < 4; i++) {
531 cout <<
"\n=== Detecting silhouette edges ===" << endl;
549 printf(
"Feature lines : %lf\n", duration);
572 sTesselator2d.
setNature(_edgeTesselationNature);
573 sTesselator3d.
setNature(_edgeTesselationNature);
577 cout <<
"\n=== Building the view map ===" << endl;
582 *_winged_edge, _VisibilityAlgo, _EPSILON, _Scene3dBBox, _SceneNumFaces);
592 _SilhouetteNode->
addRef();
596 _ProjectedSilhouette->
addRef();
599 duration = _Chrono.
stop();
601 printf(
"ViewMap building : %lf\n", duration);
614 if (_ComputeSteerableViewMap) {
640 completeNS->material().setDiffuse(
c,
c,
c, 1);
648 for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend;
650 if ((*f)->viewedge()->qi() != 0) {
653 fRep =
new LineRep((*f)->vertexA()->point2d(), (*f)->vertexB()->point2d());
655 double *oweights = svm->
AddFEdge(*f);
658 double wc = oweights[i] *
c;
659 if (oweights[i] == 0) {
662 ns->material().setDiffuse(wc, wc, wc, 1);
670 QGLBasicWidget offscreenBuffer(_pView,
"SteerableViewMap", _pView->
width(), _pView->
height());
674 offscreenBuffer.AddNode(ng[i]);
679 pm = offscreenBuffer.renderPixmap(_pView->
width(), _pView->
height());
683 cout <<
"BuildViewMap Warning: couldn't render the steerable ViewMap" << endl;
691 for (
unsigned int y = 0;
y < img[i]->
height(); ++
y) {
692 for (
unsigned int x = 0;
x < img[i]->
width(); ++
x) {
699 offscreenBuffer.DetachNode(ng[i]);
704 qimg = QImage(_pView->
width(), _pView->
height(), 32);
705 for (
unsigned int y = 0;
y < img[i]->
height(); ++
y) {
706 for (
unsigned int x = 0;
x < img[i]->
width(); ++
x) {
708 qimg.setPixel(
x,
y, qRgb(
v,
v,
v));
711 qimg.save(QString(
"newsteerable") + QString::number(i) + QString(
".bmp"),
"BMP");
723 cerr <<
"the Steerable ViewMap has not been computed yet" << endl;
771 switch (_VisibilityAlgo) {
795 _EnableViewMapCache = iBool;
800 return _EnableViewMapCache;
815 _EnableFaceSmoothness = iBool;
820 return _EnableFaceSmoothness;
830 return _ComputeRidges;
835 _ComputeSuggestive =
b;
840 return _ComputeSuggestive;
845 _ComputeMaterialBoundaries =
b;
850 return _ComputeMaterialBoundaries;
855 _ComputeSteerableViewMap = iBool;
860 return _ComputeSteerableViewMap;
870 cout <<
"\n=== Stroke drawing ===" << endl;
877 cout <<
"Strokes generation : " << d << endl;
878 cout <<
"Stroke count : " << strokeCount << endl;
901 cout <<
"Temporary scene generation: " << d << endl;
907 cout <<
"Stroke rendering : " << d << endl;
912 float megs_used_memory = (
mem_in_use) / (1024.0 * 1024.0);
913 float megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
915 printf(
"%d objs, mem %.2fM (peak %.2fM)\n", totmesh, megs_used_memory, megs_peak_memory);
917 delete blenderRenderer;
919 return freestyle_render;
925 cerr <<
"Error: Cannot load \"" << string(iFileName) <<
"\", unknown extension" << endl;
985 vector<unsigned> vec;
987 for (vector<unsigned>::const_iterator it = vec.begin(); it != vec.end(); it++) {
1000 vector<ViewEdge *>::iterator vedges_end)
1007 return (tesselator2D.
Tesselate(vedges_begin, vedges_end));
1012 _edgeTesselationNature ^= (iNature);
1055 using densityCurve = vector<Vec3r>;
1067 for (i = 0; i < nbCurves; ++i) {
1068 for (j = 0; j < nbPoints; ++j) {
1073 for (i = 0; i < nbPoints; ++i) {
1074 for (j = 0; j < nbCurves; ++j) {
1081 for (i = 0; i < nbCurves; ++i) {
1082 _pDensityCurvesWindow->setOrientationCurve(
1085 for (i = 1; i <= 8; ++i) {
1086 _pDensityCurvesWindow->setLevelCurve(
1087 i,
Vec2d(0, 0),
Vec2d(nbCurves, 1), curvesDirection[i],
"orientation",
"density");
1089 _pDensityCurvesWindow->show();
void BLI_path_normalize(const char *relabase, char *path) ATTR_NONNULL(2)
bool BLI_path_extension_check(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
The spinal tap of the system.
struct Depsgraph Depsgraph
@ FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE
@ FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL
@ FREESTYLE_ALGO_VERYFAST
@ FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE
@ FREESTYLE_ALGO_ADAPTIVE_TRADITIONAL
struct FreestyleGlobals g_freestyle
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint i1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
void setViewer(AppView *iViewer)
void setPassZ(float *buf, int width, int height)
void setPassDiffuse(float *buf, int width, int height)
void AddDebug(NodeGroup *iDebug)
void AddSilhouette(NodeGroup *iSilhouette)
void setDebug(NodeGroup *iDebug)
void Add2DSilhouette(NodeGroup *)
void setModel(NodeGroup *iModel)
real GetFovyRadian() const
void Add2DVisibleSilhouette(NodeGroup *)
void DetachModel(Node *iModel)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
unsigned int numFacesRead()
Render * RenderScene(Render *re, bool render)
void setModified(unsigned index, bool iMod)
SteerableViewMap * getSteerableViewMap()
void RemoveStyleModule(unsigned index)
void InsertStyleModule(unsigned index, StyleModule *iStyleModule)
void causalStyleModules(std::vector< unsigned > &vec, unsigned index=0)
virtual void Render(const StrokeRenderer *iRenderer)
void SwapStyleModules(unsigned i1, unsigned i2)
void resetModified(bool iMod=false)
void ReplaceStyleModule(unsigned index, StyleModule *iStyleModule)
static const int NB_STEERABLE_VIEWMAP
void setVisible(unsigned index, bool iVisible)
int getStrokeCount() const
const string & getPatternsPath() const
static Path * getInstance()
const string & getModelsPath() const
const string & getHomeDir() const
Render * RenderStrokes(Render *re, bool render)
string getModelsDir() const
void setComputeSuggestiveContoursFlag(bool b)
void setPassZ(float *buf, int width, int height)
bool getFaceSmoothness() const
void updateCausalStyleModules(unsigned index)
bool getComputeMaterialBoundariesFlag() const
bool getComputeSteerableViewMapFlag() const
void toggleLayer(unsigned index, bool iDisplay)
void setComputeMaterialBoundariesFlag(bool b)
void setVisibilityAlgo(int algo)
void AddStyleModule(const char *iFileName)
void setComputeRidgesAndValleysFlag(bool b)
void setFaceSmoothness(bool iBool)
void setPassDiffuse(float *buf, int width, int height)
void saveSteerableViewMapImages()
void toggleEdgeTesselationNature(Nature::EdgeNature iNature)
void toggleVisibilityAlgo()
void SwapStyleModules(unsigned i1, unsigned i2)
void RemoveStyleModule(unsigned index)
void ReloadStyleModule(unsigned index, const char *iFileName)
bool getQuantitativeInvisibility() const
void setModulesDir(const string &dir)
void DeleteViewMap(bool freeCache=false)
int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
bool getComputeSuggestiveContoursFlag() const
string getModulesDir() const
NodeGroup * BuildRep(vector< ViewEdge * >::iterator vedges_begin, vector< ViewEdge * >::iterator vedges_end)
void setViewMapCache(bool iBool)
void setQuantitativeInvisibility(bool iBool)
void setContext(bContext *C)
void setComputeSteerableViewMapFlag(bool iBool)
void setModified(unsigned index, bool iMod)
void InsertStyleModule(unsigned index, const char *iFileName)
bool getComputeRidgesAndValleysFlag() const
void setView(AppView *iView)
void resetModified(bool iMod=false)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
bool getViewMapCache() const
void displayDensityCurves(int x, int y)
void setModelsDir(const string &dir)
void ComputeSteerableViewMap()
void enableMaterialBoundaries(bool b)
virtual void processShapes(WingedEdge &)
void enableSuggestiveContours(bool b)
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
void setCreaseAngle(float angle)
void setSphereRadius(float r)
void enableFaceSmoothness(bool b)
void enableOrthographicProjection(bool b)
void setViewpoint(const Vec3f &ivp)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
void enableRidgesAndValleysFlag(bool b)
void setDiffuse(float r, float g, float b, float a)
float pixel(unsigned x, unsigned y) const
virtual float * getArray()
void setPixel(unsigned x, unsigned y, float v)
void setProjectionMatrix(double projection_matrix[16])
virtual int numberOfChildren()
virtual void AddChild(Node *iChild)
virtual const BBox< Vec3r > & UpdateBBox()
virtual void accept(SceneVisitor &v)
virtual void AddRep(Rep *iRep)
virtual const BBox< Vec3r > & bbox() const
void setContext(bContext *C)
float readSteerableViewMapPixel(unsigned iOrientation, int iLevel, int x, int y)
double * AddFEdge(FEdge *iFEdge)
unsigned int getNumberOfOrientations() const
void buildImagesPyramids(GrayImage **steerableBases, bool copy=false, unsigned iNbLevels=4, float iSigma=1.0f)
unsigned int getNumberOfPyramidLevels() const
void saveSteerableViewMap() const
void setTransform(const real iModelViewMatrix[4][4], const real iProjectionMatrix[4][4], const int iViewport[4], real iFocalLength, real, real)
void setGrid(Grid *iGrid)
@ ray_casting_adaptive_cumulative
@ ray_casting_adaptive_traditional
@ ray_casting_culled_adaptive_cumulative
@ ray_casting_culled_adaptive_traditional
void setEnableQI(bool iBool)
void setViewpoint(const Vec3r &ivp)
void setFrustum(real iZnear, real iZfar)
ViewMap * BuildViewMap(WingedEdge &we, visibility_algo iAlgo, real epsilon, const BBox< Vec3r > &bbox, unsigned int sceneNumFaces)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
void setFrsMaterial(const FrsMaterial &iMaterial)
void setNature(Nature::EdgeNature iNature)
NodeGroup * Tesselate(ViewMap *iViewMap)
vector< FEdge * > fedges_container
void setScene3dBBox(const BBox< Vec3r > &bbox)
fedges_container & FEdges()
static void setCurrentId(const unsigned id)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
WingedEdge * getWingedEdge()
static char * basename(char *string)
const Depsgraph * depsgraph
size_t(* MEM_get_peak_memory)(void)
size_t(* MEM_get_memory_in_use)(void)
static const string DIR_SEP("/")
static const string OPTIONS_DIR("."+APPLICATION_NAME)
static const string OPTIONS_CURRENT_DIRS_FILE("current_dirs.xml")
static const string APPLICATION_NAME("APPNAME")
VecMat::Vec2< double > Vec2d
VecMat::Vec3< real > Vec3r
static const EdgeNature BORDER
unsigned short EdgeNature
static const EdgeNature CREASE
static const EdgeNature SILHOUETTE
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
_W64 unsigned int uintptr_t
static void setPatternsPath(const string &path)
static void setBrushesPath(const string &path)