75 _SilhouetteNode =
nullptr;
76 _ProjectedSilhouette =
nullptr;
77 _VisibleProjectedSilhouette =
nullptr;
83 _winged_edge =
nullptr;
86 _pRenderMonitor =
nullptr;
93 _minEdgeSize = DBL_MAX;
108 _EnableViewMapCache =
false;
110 _EnableFaceSmoothness =
false;
111 _ComputeRidges =
true;
112 _ComputeSteerableViewMap =
false;
113 _ComputeSuggestive =
true;
114 _ComputeMaterialBoundaries =
true;
116 _creaseAngle = 134.43;
117 prevSceneHash = -1.0;
124 if (
nullptr != _RootNode) {
125 int ref = _RootNode->destroy();
132 if (
nullptr != _SilhouetteNode) {
133 int ref = _SilhouetteNode->destroy();
135 delete _SilhouetteNode;
139 if (
nullptr != _DebugNode) {
140 int ref = _DebugNode->destroy();
149 _winged_edge =
nullptr;
169 _ProgressBar =
nullptr;
177 if (
nullptr == iView) {
187 _pRenderMonitor = iRenderMonitor;
201 app_canvas->
setPassZ(buf, width, height);
212 if (!_EnableViewMapCache) {
215 if (sceneHashFunc.match()) {
218 sceneHashFunc.store();
232 if (blenderScene ==
nullptr) {
234 cout <<
"Cannot load scene" << endl;
241 cout <<
"Empty scene" << endl;
248 real duration = _Chrono.stop();
250 cout <<
"Scene loaded" << endl;
251 printf(
"Mesh cleaning : %lf\n", duration);
252 printf(
"View map cache : %s\n", _EnableViewMapCache ?
"enabled" :
"disabled");
257 if (loader.minEdgeSize() < _minEdgeSize) {
258 _minEdgeSize = loader.minEdgeSize();
264 blenderScene->
accept(spp);
267 _RootNode->AddChild(blenderScene);
268 _RootNode->UpdateBBox();
270 _pView->setModel(_RootNode);
273 if (_pRenderMonitor->testBreak()) {
277 if (_EnableViewMapCache) {
287 for (
int i = 0;
i < 4;
i++) {
288 for (
int j = 0; j < 4; j++) {
293 _RootNode->AddChild(cam);
296 sceneHashFunc.reset();
298 _RootNode->accept(sceneHashFunc);
300 cout <<
"Scene hash : " << sceneHashFunc.toString() << endl;
315 blenderScene->
accept(wx_builder);
318 duration = _Chrono.stop();
320 printf(
"WEdge building : %lf\n", duration);
324 _pView->setDebug(_DebugNode);
327 if (0 != ws_builder) {
332 soc QFileInfo qfi(iFileName);
333 soc
string basename((
const char *)qfi.fileName().toAscii().data());
337 string basename = string(cleaned);
340 _ListOfModels.emplace_back(
"Blender_models");
342 _Scene3dBBox = _RootNode->bbox();
344 _bboxDiag = (_RootNode->bbox().getMax() - _RootNode->bbox().getMin()).norm();
346 cout <<
"Triangles nb : " << _SceneNumFaces <<
" imported, " << _winged_edge->getNumFaces()
347 <<
" retained" << endl;
348 cout <<
"Bounding Box : " << _bboxDiag << endl;
353 _SceneNumFaces = _winged_edge->getNumFaces();
354 if (_SceneNumFaces == 0) {
365 _ListOfModels.clear();
382 _pView->DetachModel();
383 if (
nullptr != _RootNode) {
384 int ref = _RootNode->destroy();
388 _RootNode->clearBBox();
396 _winged_edge =
nullptr;
401 _Scene3dBBox.clear();
404 _minEdgeSize = DBL_MAX;
411 _pView->DetachSilhouette();
412 if (
nullptr != _SilhouetteNode) {
413 int ref = _SilhouetteNode->destroy();
415 delete _SilhouetteNode;
416 _SilhouetteNode =
nullptr;
420 if (
nullptr != _ProjectedSilhouette) {
421 int ref = _ProjectedSilhouette->destroy();
423 delete _ProjectedSilhouette;
424 _ProjectedSilhouette =
nullptr;
427 if (
nullptr != _VisibleProjectedSilhouette) {
428 int ref = _VisibleProjectedSilhouette->destroy();
430 delete _VisibleProjectedSilhouette;
431 _VisibleProjectedSilhouette =
nullptr;
435 _pView->DetachDebug();
436 if (
nullptr != _DebugNode) {
437 int ref = _DebugNode->destroy();
439 _DebugNode->addRef();
445 if (freeCache || !_EnableViewMapCache) {
448 prevSceneHash = -1.0;
458 if (_ListOfModels.empty()) {
476 cout <<
"mv" << endl;
480 for (
int i = 0;
i < 4;
i++) {
481 for (
int j = 0; j < 4; j++) {
485 cout <<
mv[
i][j] <<
" ";
498 cout <<
"\nproj" << endl;
502 for (
int i = 0;
i < 4;
i++) {
503 for (
int j = 0; j < 4; j++) {
507 cout << proj[
i][j] <<
" ";
519 for (
int i = 0;
i < 4;
i++) {
525 cout <<
"\nfocal:" << _pView->GetFocalLength() << endl << endl;
533 cout <<
"\n=== Detecting silhouette edges ===" << endl;
537 edgeDetector.setViewpoint(vp);
538 edgeDetector.enableOrthographicProjection(proj[3][3] != 0.0);
539 edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges);
540 edgeDetector.enableSuggestiveContours(_ComputeSuggestive);
541 edgeDetector.enableMaterialBoundaries(_ComputeMaterialBoundaries);
542 edgeDetector.enableFaceSmoothness(_EnableFaceSmoothness);
543 edgeDetector.setCreaseAngle(_creaseAngle);
544 edgeDetector.setSphereRadius(_sphereRadius);
545 edgeDetector.setSuggestiveContourKrDerivativeEpsilon(_suggestiveContourKrDerivativeEpsilon);
546 edgeDetector.setRenderMonitor(_pRenderMonitor);
547 edgeDetector.processShapes(*_winged_edge);
549 real duration = _Chrono.stop();
551 printf(
"Feature lines : %lf\n", duration);
554 if (_pRenderMonitor->testBreak()) {
564 mv, proj, viewport, _pView->GetFocalLength(), _pView->GetAspect(), _pView->GetFovyRadian());
565 vmBuilder.
setFrustum(_pView->znear(), _pView->zfar());
574 sTesselator2d.
setNature(_edgeTesselationNature);
575 sTesselator3d.
setNature(_edgeTesselationNature);
579 cout <<
"\n=== Building the view map ===" << endl;
584 *_winged_edge, _VisibilityAlgo, _EPSILON, _Scene3dBBox, _SceneNumFaces);
585 _ViewMap->setScene3dBBox(_Scene3dBBox);
594 _SilhouetteNode->
addRef();
598 _ProjectedSilhouette->
addRef();
601 duration = _Chrono.stop();
603 printf(
"ViewMap building : %lf\n", duration);
607 _pView->AddSilhouette(_SilhouetteNode);
608 _pView->AddSilhouette(_WRoot);
609 _pView->Add2DSilhouette(_ProjectedSilhouette);
610 _pView->Add2DVisibleSilhouette(_VisibleProjectedSilhouette);
611 _pView->AddDebug(_DebugNode);
616 if (_ComputeSteerableViewMap) {
642 completeNS->material().setDiffuse(
c,
c,
c, 1);
650 for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend; ++f)
652 if ((*f)->viewedge()->qi() != 0) {
655 fRep =
new LineRep((*f)->vertexA()->point2d(), (*f)->vertexB()->point2d());
657 double *oweights = svm->
AddFEdge(*f);
660 double wc = oweights[
i] *
c;
661 if (oweights[
i] == 0) {
664 ns->material().setDiffuse(wc, wc, wc, 1);
672 QGLBasicWidget offscreenBuffer(_pView,
"SteerableViewMap", _pView->width(), _pView->height());
676 offscreenBuffer.AddNode(ng[
i]);
678 img[
i] =
new GrayImage(_pView->width(), _pView->height());
679 offscreenBuffer.readPixels(0, 0, _pView->width(), _pView->height(), img[
i]->
getArray());
681 pm = offscreenBuffer.renderPixmap(_pView->width(), _pView->height());
685 cout <<
"BuildViewMap Warning: couldn't render the steerable ViewMap" << endl;
692 img[
i] =
new GrayImage(_pView->width(), _pView->height());
701 offscreenBuffer.DetachNode(ng[
i]);
706 qimg = QImage(_pView->width(), _pView->height(), 32);
710 qimg.setPixel(
x,
y, qRgb(
v,
v,
v));
713 qimg.save(QString(
"newsteerable") + QString::number(
i) + QString(
".bmp"),
"BMP");
725 cerr <<
"the Steerable ViewMap has not been computed yet" << endl;
773 switch (_VisibilityAlgo) {
797 _EnableViewMapCache = iBool;
802 return _EnableViewMapCache;
817 _EnableFaceSmoothness = iBool;
822 return _EnableFaceSmoothness;
832 return _ComputeRidges;
837 _ComputeSuggestive =
b;
842 return _ComputeSuggestive;
847 _ComputeMaterialBoundaries =
b;
852 return _ComputeMaterialBoundaries;
857 _ComputeSteerableViewMap = iBool;
862 return _ComputeSteerableViewMap;
872 cout <<
"\n=== Stroke drawing ===" << endl;
876 real d = _Chrono.stop();
877 int strokeCount =
_Canvas->getStrokeCount();
879 cout <<
"Strokes generation : " << d << endl;
880 cout <<
"Stroke count : " << strokeCount << endl;
898 _Canvas->Render(blenderRenderer);
901 real d = _Chrono.stop();
903 cout <<
"Temporary scene generation: " << d << endl;
909 cout <<
"Stroke rendering : " << d << endl;
914 float megs_used_memory = (
mem_in_use) / (1024.0 * 1024.0);
915 float megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
917 printf(
"%d objs, mem %.2fM (peak %.2fM)\n", totmesh, megs_used_memory, megs_peak_memory);
919 delete blenderRenderer;
921 return freestyle_render;
927 cerr <<
"Error: Cannot load \"" << string(iFileName) <<
"\", unknown extension" << endl;
932 _Canvas->InsertStyleModule(index, sm);
938 _Canvas->InsertStyleModule(index, sm);
944 _Canvas->InsertStyleModule(index, sm);
954 _Canvas->RemoveStyleModule(index);
965 _Canvas->ReplaceStyleModule(index, sm);
970 _Canvas->SwapStyleModules(i1, i2);
975 _Canvas->setVisible(index, iDisplay);
981 _Canvas->setModified(index, iMod);
988 _Canvas->causalStyleModules(vec, index);
989 for (vector<uint>::const_iterator it = vec.begin(); it != vec.end(); it++) {
991 _Canvas->setModified(*it,
true);
1002 vector<ViewEdge *>::iterator vedges_end)
1009 return tesselator2D.
Tesselate(vedges_begin, vedges_end);
1014 _edgeTesselationNature ^= (iNature);
1057 using densityCurve = vector<Vec3r>;
1069 for (
i = 0;
i < nbCurves; ++
i) {
1070 for (j = 0; j < nbPoints; ++j) {
1075 for (
i = 0;
i < nbPoints; ++
i) {
1076 for (j = 0; j < nbCurves; ++j) {
1083 for (
i = 0;
i < nbCurves; ++
i) {
1084 _pDensityCurvesWindow->setOrientationCurve(
1085 i,
Vec2d(0, 0),
Vec2d(nbPoints, 1), curves[
i],
"scale",
"density");
1087 for (
i = 1;
i <= 8; ++
i) {
1088 _pDensityCurvesWindow->setLevelCurve(
1089 i,
Vec2d(0, 0),
Vec2d(nbCurves, 1), curvesDirection[
i],
"orientation",
"density");
1091 _pDensityCurvesWindow->show();
int BLI_path_normalize(char *path) ATTR_NONNULL(1)
bool BLI_path_extension_check(const char *path, const char *ext) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
The spinal tap of the system.
GTS - Library for the manipulation of triangulated surfaces.
@ 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
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 ...
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
void setPassZ(float *buf, int width, int height)
void setPassDiffuse(float *buf, int width, int height)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
Render * RenderScene(Render *re, bool render)
static const int NB_STEERABLE_VIEWMAP
const string & getPatternsPath() const
static Path * getInstance()
const string & getHomeDir() const
const string & getModelsPath() 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
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)
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 toggleLayer(uint index, bool iDisplay)
void setContext(bContext *C)
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)
void setContext(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)
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
static void setCurrentId(const uint id)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
WingedEdge * getWingedEdge()
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< float > Vec3f
VecMat::Vec3< real > Vec3r
static const EdgeNature BORDER
static const EdgeNature CREASE
static const EdgeNature SILHOUETTE
static void setPatternsPath(const string &path)
static void setBrushesPath(const string &path)