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;
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);
277 if (_EnableViewMapCache) {
287 for (
int i = 0; i < 4; i++) {
288 for (
int j = 0; j < 4; j++) {
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);
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;
354 if (_SceneNumFaces == 0) {
365 _ListOfModels.clear();
383 if (
nullptr != _RootNode) {
384 int ref = _RootNode->
destroy();
396 _winged_edge =
nullptr;
401 _Scene3dBBox.clear();
404 _minEdgeSize = DBL_MAX;
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;
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++) {
533 cout <<
"\n=== Detecting silhouette edges ===" << endl;
551 printf(
"Feature lines : %lf\n", duration);
574 sTesselator2d.
setNature(_edgeTesselationNature);
575 sTesselator3d.
setNature(_edgeTesselationNature);
579 cout <<
"\n=== Building the view map ===" << endl;
584 *_winged_edge, _VisibilityAlgo, _EPSILON, _Scene3dBBox, _SceneNumFaces);
594 _SilhouetteNode->
addRef();
598 _ProjectedSilhouette->
addRef();
601 duration = _Chrono.
stop();
603 printf(
"ViewMap building : %lf\n", duration);
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]);
681 pm = offscreenBuffer.renderPixmap(_pView->
width(), _pView->
height());
685 cout <<
"BuildViewMap Warning: couldn't render the steerable ViewMap" << endl;
696 img[i]->
setPixel(x, y,
float(qGray(qimg.pixel(x, y))));
701 offscreenBuffer.DetachNode(ng[i]);
706 qimg = QImage(_pView->
width(), _pView->
height(), 32);
709 float v = img[i]->
pixel(x, y);
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;
879 cout <<
"Strokes generation : " << d << endl;
880 cout <<
"Stroke count : " << strokeCount << endl;
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;
989 for (vector<uint>::const_iterator it = vec.begin(); it != vec.end(); it++) {
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
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)
Render * RenderScene(Render *re, bool render)
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
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 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)
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 const BBox< Vec3r > & UpdateBBox()
virtual void accept(SceneVisitor &v)
virtual void AddRep(Rep *iRep)
virtual const BBox< Vec3r > & bbox() const
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
void setScene3dBBox(const BBox< Vec3r > &bbox)
fedges_container & FEdges()
static void setCurrentId(const uint id)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
WingedEdge * getWingedEdge()
local_group_size(16, 16) .push_constant(Type b
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
static const EdgeNature CREASE
static const EdgeNature SILHOUETTE
_W64 unsigned int uintptr_t
static void setPatternsPath(const string &path)
static void setBrushesPath(const string &path)