66 const string sep(Config::DIR_SEP);
68 sep + Config::OPTIONS_CURRENT_DIRS_FILE;
69 _current_dirs =
new ConfigIO(filename, Config::APPLICATION_NAME +
"CurrentDirs",
true);
76 _SilhouetteNode =
nullptr;
77 _ProjectedSilhouette =
nullptr;
78 _VisibleProjectedSilhouette =
nullptr;
84 _winged_edge =
nullptr;
87 _pRenderMonitor =
nullptr;
89 _edgeTesselationNature = (Nature::SILHOUETTE | Nature::BORDER | Nature::CREASE);
94 _minEdgeSize = DBL_MAX;
109 _EnableViewMapCache =
false;
111 _EnableFaceSmoothness =
false;
112 _ComputeRidges =
true;
113 _ComputeSteerableViewMap =
false;
114 _ComputeSuggestive =
true;
115 _ComputeMaterialBoundaries =
true;
117 _creaseAngle = 134.43;
118 prevSceneHash = -1.0;
125 if (
nullptr != _RootNode) {
126 int ref = _RootNode->destroy();
133 if (
nullptr != _SilhouetteNode) {
134 int ref = _SilhouetteNode->destroy();
136 delete _SilhouetteNode;
140 if (
nullptr != _DebugNode) {
141 int ref = _DebugNode->destroy();
150 _winged_edge =
nullptr;
170 _ProgressBar =
nullptr;
178 if (
nullptr == iView) {
188 _pRenderMonitor = iRenderMonitor;
202 app_canvas->
setPassZ(buf, width, height);
213 if (!_EnableViewMapCache) {
216 if (sceneHashFunc.match()) {
219 sceneHashFunc.store();
225 blender::Depsgraph *depsgraph)
235 if (blenderScene ==
nullptr) {
237 cout <<
"Cannot load scene" << endl;
244 cout <<
"Empty scene" << endl;
251 real duration = _Chrono.stop();
253 cout <<
"Scene loaded" << endl;
254 printf(
"Mesh cleaning : %lf\n", duration);
255 printf(
"View map cache : %s\n", _EnableViewMapCache ?
"enabled" :
"disabled");
260 if (loader.minEdgeSize() < _minEdgeSize) {
261 _minEdgeSize = loader.minEdgeSize();
267 blenderScene->
accept(spp);
270 _RootNode->AddChild(blenderScene);
271 _RootNode->UpdateBBox();
273 _pView->setModel(_RootNode);
276 if (_pRenderMonitor->testBreak()) {
280 if (_EnableViewMapCache) {
290 for (
int i = 0; i < 4; i++) {
291 for (
int j = 0; j < 4; j++) {
296 _RootNode->AddChild(cam);
299 sceneHashFunc.reset();
301 _RootNode->accept(sceneHashFunc);
303 cout <<
"Scene hash : " << sceneHashFunc.toString() << endl;
318 blenderScene->
accept(wx_builder);
321 duration = _Chrono.stop();
323 printf(
"WEdge building : %lf\n", duration);
327 _pView->setDebug(_DebugNode);
330 if (0 != ws_builder) {
335 soc QFileInfo qfi(iFileName);
336 soc
string basename((
const char *)qfi.fileName().toAscii().data());
338 BLI_strncpy(cleaned, iFileName,
FILE_MAX);
339 BLI_path_normalize(cleaned);
340 string basename = string(cleaned);
343 _ListOfModels.emplace_back(
"Blender_models");
345 _Scene3dBBox = _RootNode->bbox();
347 _bboxDiag = (_RootNode->bbox().getMax() - _RootNode->bbox().getMin()).norm();
349 cout <<
"Triangles nb : " << _SceneNumFaces <<
" imported, " << _winged_edge->getNumFaces()
350 <<
" retained" << endl;
351 cout <<
"Bounding Box : " << _bboxDiag << endl;
356 _SceneNumFaces = _winged_edge->getNumFaces();
357 if (_SceneNumFaces == 0) {
368 _ListOfModels.clear();
385 _pView->DetachModel();
386 if (
nullptr != _RootNode) {
387 int ref = _RootNode->destroy();
391 _RootNode->clearBBox();
399 _winged_edge =
nullptr;
404 _Scene3dBBox.clear();
407 _minEdgeSize = DBL_MAX;
414 _pView->DetachSilhouette();
415 if (
nullptr != _SilhouetteNode) {
416 int ref = _SilhouetteNode->destroy();
418 delete _SilhouetteNode;
419 _SilhouetteNode =
nullptr;
423 if (
nullptr != _ProjectedSilhouette) {
424 int ref = _ProjectedSilhouette->destroy();
426 delete _ProjectedSilhouette;
427 _ProjectedSilhouette =
nullptr;
430 if (
nullptr != _VisibleProjectedSilhouette) {
431 int ref = _VisibleProjectedSilhouette->destroy();
433 delete _VisibleProjectedSilhouette;
434 _VisibleProjectedSilhouette =
nullptr;
438 _pView->DetachDebug();
439 if (
nullptr != _DebugNode) {
440 int ref = _DebugNode->destroy();
442 _DebugNode->addRef();
448 if (freeCache || !_EnableViewMapCache) {
451 prevSceneHash = -1.0;
461 if (_ListOfModels.empty()) {
479 cout <<
"mv" << endl;
483 for (
int i = 0; i < 4; i++) {
484 for (
int j = 0; j < 4; j++) {
488 cout <<
mv[i][j] <<
" ";
501 cout <<
"\nproj" << endl;
505 for (
int i = 0; i < 4; i++) {
506 for (
int j = 0; j < 4; j++) {
510 cout << proj[i][j] <<
" ";
522 for (
int i = 0; i < 4; i++) {
528 cout <<
"\nfocal:" << _pView->GetFocalLength() << endl << endl;
536 cout <<
"\n=== Detecting silhouette edges ===" << endl;
540 edgeDetector.setViewpoint(vp);
541 edgeDetector.enableOrthographicProjection(proj[3][3] != 0.0);
542 edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges);
543 edgeDetector.enableSuggestiveContours(_ComputeSuggestive);
544 edgeDetector.enableMaterialBoundaries(_ComputeMaterialBoundaries);
545 edgeDetector.enableFaceSmoothness(_EnableFaceSmoothness);
546 edgeDetector.setCreaseAngle(_creaseAngle);
547 edgeDetector.setSphereRadius(_sphereRadius);
548 edgeDetector.setSuggestiveContourKrDerivativeEpsilon(_suggestiveContourKrDerivativeEpsilon);
549 edgeDetector.setRenderMonitor(_pRenderMonitor);
550 edgeDetector.processShapes(*_winged_edge);
552 real duration = _Chrono.stop();
554 printf(
"Feature lines : %lf\n", duration);
557 if (_pRenderMonitor->testBreak()) {
567 mv, proj, viewport, _pView->GetFocalLength(), _pView->GetAspect(), _pView->GetFovyRadian());
568 vmBuilder.
setFrustum(_pView->znear(), _pView->zfar());
577 sTesselator2d.
setNature(_edgeTesselationNature);
578 sTesselator3d.
setNature(_edgeTesselationNature);
582 cout <<
"\n=== Building the view map ===" << endl;
587 *_winged_edge, _VisibilityAlgo, _EPSILON, _Scene3dBBox, _SceneNumFaces);
597 _SilhouetteNode->
addRef();
601 _ProjectedSilhouette->
addRef();
604 duration = _Chrono.stop();
606 printf(
"ViewMap building : %lf\n", duration);
610 _pView->AddSilhouette(_SilhouetteNode);
611 _pView->AddSilhouette(_WRoot);
612 _pView->Add2DSilhouette(_ProjectedSilhouette);
613 _pView->Add2DVisibleSilhouette(_VisibleProjectedSilhouette);
614 _pView->AddDebug(_DebugNode);
619 if (_ComputeSteerableViewMap) {
645 completeNS->material().setDiffuse(c, c, c, 1);
653 for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend; ++f)
655 if ((*f)->viewedge()->qi() != 0) {
658 fRep =
new LineRep((*f)->vertexA()->point2d(), (*f)->vertexB()->point2d());
660 double *oweights = svm->
AddFEdge(*f);
663 double wc = oweights[i] * c;
664 if (oweights[i] == 0) {
667 ns->material().setDiffuse(wc, wc, wc, 1);
675 QGLBasicWidget offscreenBuffer(_pView,
"SteerableViewMap", _pView->width(), _pView->height());
679 offscreenBuffer.AddNode(ng[i]);
681 img[i] =
new GrayImage(_pView->width(), _pView->height());
682 offscreenBuffer.readPixels(0, 0, _pView->width(), _pView->height(), img[i]->
getArray());
684 pm = offscreenBuffer.renderPixmap(_pView->width(), _pView->height());
688 cout <<
"BuildViewMap Warning: couldn't render the steerable ViewMap" << endl;
695 img[i] =
new GrayImage(_pView->width(), _pView->height());
696 for (uint
y = 0;
y < img[i]->
height(); ++
y) {
697 for (uint
x = 0;
x < img[i]->
width(); ++
x) {
704 offscreenBuffer.DetachNode(ng[i]);
709 qimg = QImage(_pView->width(), _pView->height(), 32);
710 for (uint
y = 0;
y < img[i]->
height(); ++
y) {
711 for (uint
x = 0;
x < img[i]->
width(); ++
x) {
713 qimg.setPixel(
x,
y, qRgb(v, v, v));
716 qimg.save(QString(
"newsteerable") + QString::number(i) + QString(
".bmp"),
"BMP");
728 cerr <<
"the Steerable ViewMap has not been computed yet" << endl;
776 switch (_VisibilityAlgo) {
800 _EnableViewMapCache = iBool;
805 return _EnableViewMapCache;
820 _EnableFaceSmoothness = iBool;
825 return _EnableFaceSmoothness;
835 return _ComputeRidges;
840 _ComputeSuggestive =
b;
845 return _ComputeSuggestive;
850 _ComputeMaterialBoundaries =
b;
855 return _ComputeMaterialBoundaries;
860 _ComputeSteerableViewMap = iBool;
865 return _ComputeSteerableViewMap;
875 cout <<
"\n=== Stroke drawing ===" << endl;
879 real d = _Chrono.stop();
882 cout <<
"Strokes generation : " << d << endl;
883 cout <<
"Stroke count : " << strokeCount << endl;
904 real d = _Chrono.stop();
906 cout <<
"Temporary scene generation: " << d << endl;
912 cout <<
"Stroke rendering : " << d << endl;
917 float megs_used_memory = (mem_in_use) / (1024.0 * 1024.0);
918 float megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
920 printf(
"%d objs, mem %.2fM (peak %.2fM)\n", totmesh, megs_used_memory, megs_peak_memory);
922 delete blenderRenderer;
924 return freestyle_render;
930 cerr <<
"Error: Cannot load \"" << string(iFileName) <<
"\", unknown extension" << endl;
992 for (vector<uint>::const_iterator it = vec.begin(); it != vec.end(); it++) {
1005 vector<ViewEdge *>::iterator vedges_end)
1012 return tesselator2D.
Tesselate(vedges_begin, vedges_end);
1017 _edgeTesselationNature ^= (iNature);
1060 using densityCurve = vector<Vec3r>;
1072 for (i = 0; i < nbCurves; ++i) {
1073 for (j = 0; j < nbPoints; ++j) {
1078 for (i = 0; i < nbPoints; ++i) {
1079 for (j = 0; j < nbCurves; ++j) {
1086 for (i = 0; i < nbCurves; ++i) {
1087 _pDensityCurvesWindow->setOrientationCurve(
1090 for (i = 1; i <= 8; ++i) {
1091 _pDensityCurvesWindow->setLevelCurve(
1092 i,
Vec2d(0, 0),
Vec2d(nbCurves, 1), curvesDirection[i],
"orientation",
"density");
1094 _pDensityCurvesWindow->show();
The spinal tap of the system.
GTS - Library for the manipulation of triangulated surfaces.
Class to encapsulate an array of RGB or Gray level values.
Class to define a Drawing Style to be applied to the underlying children. Inherits from NodeGroup.
Class to build a shape node. It contains a Rep, which is the shape geometry.
Class to represent a view layer in Blender.
Class to define the Postscript rendering of a stroke.
Class to display textual information about a scene graph.
Convenient access to the steerable ViewMap to which any element of the ViewMap belongs to.
Class to build a Node Tree designed to be displayed from a set of strokes structure.
Class representing a style module.
Class to define the representation of a vertex for displaying purpose.
Class to build a Node Tree designed to be displayed from a Silhouette View Map structure.
Classes to define a View Map (ViewVertex, ViewEdge, etc.).
Classes to define a Winged Edge data structure.
Class inherited from WingedEdgeBuilder and designed to build a WX (WingedEdge + extended info (silhou...
Class to render a WingedEdge data structure from a polyhedral data structure organized in nodes of a ...
void setViewer(AppView *iViewer)
void setPassZ(float *buf, int width, int height)
void setPassDiffuse(float *buf, int width, int height)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
BlenderStrokeRenderer(blender::Render *re, int render_count)
blender::Render * RenderScene(blender::Render *re, bool render)
BlenderStyleModule(blender::Text *text, const string &name, Interpreter *inter)
BufferedStyleModule(const string &buffer, const string &file_name, Interpreter *inter)
void setVisible(uint index, bool iVisible)
void setModified(uint index, bool iMod)
void causalStyleModules(std::vector< uint > &vec, uint index=0)
void RemoveStyleModule(uint index)
void InsertStyleModule(uint index, StyleModule *iStyleModule)
void SwapStyleModules(uint i1, uint i2)
virtual void Render(const StrokeRenderer *iRenderer)
void resetModified(bool iMod=false)
void ReplaceStyleModule(uint index, StyleModule *iStyleModule)
static const int NB_STEERABLE_VIEWMAP
SteerableViewMap * getSteerableViewMap()
int getStrokeCount() const
const string & getPatternsPath() const
static Path * getInstance()
const string & getHomeDir() const
const string & getModelsPath() const
int LoadMesh(blender::Render *re, blender::ViewLayer *view_layer, blender::Depsgraph *depsgraph)
string getModelsDir() const
void setComputeSuggestiveContoursFlag(bool b)
void setPassZ(float *buf, int width, int height)
bool getFaceSmoothness() const
bool getComputeMaterialBoundariesFlag() const
bool getComputeSteerableViewMapFlag() const
void setComputeMaterialBoundariesFlag(bool b)
void setVisibilityAlgo(int algo)
void AddStyleModule(const char *iFileName)
void setComputeRidgesAndValleysFlag(bool b)
void ReloadStyleModule(uint index, const char *iFileName)
void setFaceSmoothness(bool iBool)
void setPassDiffuse(float *buf, int width, int height)
void setModified(uint index, bool iMod)
void saveSteerableViewMapImages()
void toggleEdgeTesselationNature(Nature::EdgeNature iNature)
void toggleVisibilityAlgo()
void updateCausalStyleModules(uint index)
void setContext(blender::bContext *C)
bool getQuantitativeInvisibility() const
blender::Render * RenderStrokes(blender::Render *re, bool render)
void setModulesDir(const string &dir)
void DeleteViewMap(bool freeCache=false)
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 toggleLayer(uint index, bool iDisplay)
void RemoveStyleModule(uint index)
void setComputeSteerableViewMapFlag(bool iBool)
void SwapStyleModules(uint i1, uint i2)
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 InsertStyleModule(uint index, const char *iFileName)
void setModelsDir(const string &dir)
void ComputeSteerableViewMap()
void setDiffuse(float r, float g, float b, float a)
virtual float * getArray()
void setPixel(uint x, uint y, float v)
float pixel(uint x, uint y) const
void setProjectionMatrix(const double projection_matrix[16])
virtual int numberOfChildren()
virtual void AddChild(Node *iChild)
virtual void accept(SceneVisitor &v)
virtual void AddRep(Rep *iRep)
NodeViewLayer(blender::Scene &scene, blender::ViewLayer &view_layer)
void setContext(blender::bContext *C)
double * AddFEdge(FEdge *iFEdge)
uint getNumberOfPyramidLevels() const
uint getNumberOfOrientations() const
void saveSteerableViewMap() const
float readSteerableViewMapPixel(uint iOrientation, int iLevel, int x, int y)
void buildImagesPyramids(GrayImage **steerableBases, bool copy=false, uint iNbLevels=4, float iSigma=1.0f)
StyleModule(const string &file_name, Interpreter *inter)
void setTransform(const real iModelViewMatrix[4][4], const real iProjectionMatrix[4][4], const int iViewport[4], real iFocalLength, real, real)
void setGrid(Grid *iGrid)
ViewMap * BuildViewMap(WingedEdge &we, visibility_algo iAlgo, real epsilon, const BBox< Vec3r > &bbox, uint sceneNumFaces)
@ 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)
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 uint id)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
WingedEdge * getWingedEdge()
size_t(*) MEM_get_memory_in_use(void)
size_t(*) MEM_get_peak_memory(void)
VecMat::Vec2< double > Vec2d
VecMat::Vec3< float > Vec3f
struct FreestyleGlobals g_freestyle
bool BLI_path_extension_check(const char *path, const char *ext) ATTR_NONNULL(1
@ FREESTYLE_ALGO_VERYFAST
@ FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE
@ FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE
@ FREESTYLE_ALGO_ADAPTIVE_TRADITIONAL
@ FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL
static void setPatternsPath(const string &path)
static void setBrushesPath(const string &path)