Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-05-31 15:51:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-31 15:55:15 +0300
commitd8dbd49a2f23b7637f05fc058f39bdf6ab706624 (patch)
tree0805b9372c82ae6505d87e879824efe1d3e32f8e /source/blender/freestyle/intern/winged_edge
parent8987f7987d8160e1f6e79e8c85d6ce65b885ab25 (diff)
Cleanup: style, use braces in source/
Automated using clang-tidy.
Diffstat (limited to 'source/blender/freestyle/intern/winged_edge')
-rw-r--r--source/blender/freestyle/intern/winged_edge/Curvature.cpp51
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.cpp75
-rw-r--r--source/blender/freestyle/intern/winged_edge/WEdge.h39
-rw-r--r--source/blender/freestyle/intern/winged_edge/WFillGrid.cpp6
-rw-r--r--source/blender/freestyle/intern/winged_edge/WFillGrid.h6
-rw-r--r--source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp6
-rw-r--r--source/blender/freestyle/intern/winged_edge/WSFillGrid.h6
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.cpp15
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdge.h45
-rw-r--r--source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp3
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp39
-rw-r--r--source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h3
12 files changed, 196 insertions, 98 deletions
diff --git a/source/blender/freestyle/intern/winged_edge/Curvature.cpp b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
index 4fb92e35b40..4f2f2dae9af 100644
--- a/source/blender/freestyle/intern/winged_edge/Curvature.cpp
+++ b/source/blender/freestyle/intern/winged_edge/Curvature.cpp
@@ -62,8 +62,9 @@ static bool angle_obtuse(WVertex *v, WFace *f)
static bool triangle_obtuse(WVertex *, WFace *f)
{
bool b = false;
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
b = b || ((f->getEdgeList()[i]->GetVec() * f->getEdgeList()[(i + 1) % 3]->GetVec()) < 0);
+ }
return b;
}
@@ -80,8 +81,9 @@ static real cotan(WVertex *vo, WVertex *v1, WVertex *v2)
/* denom can be zero if u==v. Returning 0 is acceptable, based on the callers of this function
* below. */
- if (denom == 0.0)
+ if (denom == 0.0) {
return 0.0;
+ }
return (udotv / denom);
}
@@ -127,17 +129,20 @@ bool gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &Kh)
{
real area = 0.0;
- if (!v)
+ if (!v) {
return false;
+ }
/* this operator is not defined for boundary edges */
- if (v->isBoundary())
+ if (v->isBoundary()) {
return false;
+ }
WVertex::incoming_edge_iterator itE;
- for (itE = v->incoming_edges_begin(); itE != v->incoming_edges_end(); itE++)
+ for (itE = v->incoming_edges_begin(); itE != v->incoming_edges_end(); itE++) {
area += (*itE)->GetaFace()->getArea();
+ }
Kh = Vec3r(0.0, 0.0, 0.0);
@@ -190,10 +195,12 @@ bool gts_vertex_gaussian_curvature(WVertex *v, real *Kg)
real area = 0.0;
real angle_sum = 0.0;
- if (!v)
+ if (!v) {
return false;
- if (!Kg)
+ }
+ if (!Kg) {
return false;
+ }
/* this operator is not defined for boundary edges */
if (v->isBoundary()) {
@@ -236,11 +243,13 @@ void gts_vertex_principal_curvatures(real Kh, real Kg, real *K1, real *K2)
{
real temp = Kh * Kh - Kg;
- if (!K1 || !K2)
+ if (!K1 || !K2) {
return;
+ }
- if (temp < 0.0)
+ if (temp < 0.0) {
temp = 0.0;
+ }
temp = sqrt(temp);
*K1 = Kh + temp;
*K2 = Kh - temp;
@@ -313,21 +322,25 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
*/
N[0] = N[1] = N[2] = 0.0;
- for (itE = v->incoming_edges_begin(); itE != v->incoming_edges_end(); itE++)
+ for (itE = v->incoming_edges_begin(); itE != v->incoming_edges_end(); itE++) {
N = Vec3r(N + (*itE)->GetaFace()->GetNormal());
+ }
real normN = N.norm();
- if (normN <= 0.0)
+ if (normN <= 0.0) {
return;
+ }
N.normalize();
}
/* construct a basis from N: */
/* set basis1 to any component not the largest of N */
basis1[0] = basis1[1] = basis1[2] = 0.0;
- if (fabs(N[0]) > fabs(N[1]))
+ if (fabs(N[0]) > fabs(N[1])) {
basis1[1] = 1.0;
- else
+ }
+ else {
basis1[0] = 1.0;
+ }
/* make basis2 orthogonal to N */
basis2 = (N ^ basis1);
@@ -352,8 +365,9 @@ void gts_vertex_principal_directions(WVertex *v, Vec3r Kh, real Kg, Vec3r &e1, V
WFace *f1, *f2;
real weight, kappa, d1, d2;
Vec3r vec_edge;
- if (!*itE)
+ if (!*itE) {
continue;
+ }
e = *itE;
/* since this vertex passed the tests in gts_vertex_mean_curvature_normal(), this should be
@@ -590,8 +604,9 @@ static bool sphere_clip_vector(const Vec3r &O, real r, const Vec3r &P, Vec3r &V)
void compute_curvature_tensor(WVertex *start, real radius, NormalCycle &nc)
{
// in case we have a non-manifold vertex, skip it...
- if (start->isBoundary())
+ if (start->isBoundary()) {
return;
+ }
std::set<WVertex *> vertices;
const Vec3r &O = start->GetVertex();
@@ -601,8 +616,9 @@ void compute_curvature_tensor(WVertex *start, real radius, NormalCycle &nc)
while (!S.empty()) {
WVertex *v = S.top();
S.pop();
- if (v->isBoundary())
+ if (v->isBoundary()) {
continue;
+ }
const Vec3r &P = v->GetVertex();
WVertex::incoming_edge_iterator woeit = v->incoming_edges_begin();
WVertex::incoming_edge_iterator woeitend = v->incoming_edges_end();
@@ -630,8 +646,9 @@ void compute_curvature_tensor(WVertex *start, real radius, NormalCycle &nc)
void compute_curvature_tensor_one_ring(WVertex *start, NormalCycle &nc)
{
// in case we have a non-manifold vertex, skip it...
- if (start->isBoundary())
+ if (start->isBoundary()) {
return;
+ }
WVertex::incoming_edge_iterator woeit = start->incoming_edges_begin();
WVertex::incoming_edge_iterator woeitend = start->incoming_edges_end();
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.cpp b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
index 3dc574515c1..d88f7cf5582 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.cpp
@@ -97,8 +97,9 @@ void WVertex::incoming_edge_iterator::increment()
WFace *WVertex::face_iterator::operator*()
{
WOEdge *woedge = *_edge_it;
- if (!woedge)
+ if (!woedge) {
return NULL;
+ }
return (woedge)->GetbFace();
}
@@ -110,10 +111,12 @@ bool WVertex::isBoundary() const
#endif
bool WVertex::isBoundary()
{
- if (_Border == 1)
+ if (_Border == 1) {
return true;
- else if (_Border == 0)
+ }
+ else if (_Border == 0) {
return false;
+ }
vector<WEdge *>::const_iterator it;
for (it = _EdgeList.begin(); it != _EdgeList.end(); it++) {
@@ -140,10 +143,12 @@ WVertex::incoming_edge_iterator WVertex::incoming_edges_begin()
WOEdge *begin;
WEdge *wedge = _EdgeList.front();
WOEdge *aOEdge = wedge->GetaOEdge();
- if (aOEdge->GetbVertex() == this)
+ if (aOEdge->GetbVertex() == this) {
begin = aOEdge;
- else
+ }
+ else {
begin = _EdgeList.front()->GetbOEdge();
+ }
return incoming_edge_iterator(this, begin, begin);
}
@@ -151,10 +156,12 @@ WVertex::incoming_edge_iterator WVertex::incoming_edges_end()
{
WOEdge *begin;
WOEdge *aOEdge = _EdgeList.front()->GetaOEdge();
- if (aOEdge->GetbVertex() == this)
+ if (aOEdge->GetbVertex() == this) {
begin = aOEdge;
- else
+ }
+ else {
begin = _EdgeList.front()->GetbOEdge();
+ }
return incoming_edge_iterator(this, begin, 0);
}
#if 0
@@ -226,12 +233,14 @@ WEdge::WEdge(WEdge &iBrother)
WOEdge *boedge = iBrother.GetbOEdge();
userdata = NULL;
- if (aoedge)
+ if (aoedge) {
//_paOEdge = new WOEdge(*aoedge);
_paOEdge = aoedge->duplicate();
- if (boedge)
+ }
+ if (boedge) {
//_pbOEdge = new WOEdge(*boedge);
_pbOEdge = boedge->duplicate();
+ }
_nOEdges = iBrother.GetNumberOfOEdges();
_Id = iBrother.GetId();
@@ -361,8 +370,9 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
pOEdge->setbVertex(v2);
// Debug:
- if (v1->GetId() == v2->GetId())
+ if (v1->GetId() == v2->GetId()) {
cerr << "Warning: edge " << this << " null with vertex " << v1->GetId() << endl;
+ }
edge->AddOEdge(pOEdge);
// edge->setNumberOfOEdges(edge->GetNumberOfOEdges() + 1);
@@ -378,26 +388,32 @@ WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
bool WFace::getOppositeEdge(const WVertex *v, WOEdge *&e)
{
- if (_OEdgeList.size() != 3)
+ if (_OEdgeList.size() != 3) {
return false;
+ }
vector<WOEdge *>::iterator it;
e = NULL;
for (it = _OEdgeList.begin(); it != _OEdgeList.end(); it++) {
- if ((*it)->GetaVertex() == v)
+ if ((*it)->GetaVertex() == v) {
e = *it;
+ }
}
- if (!e)
+ if (!e) {
return false;
+ }
e = NULL;
for (it = _OEdgeList.begin(); it != _OEdgeList.end(); it++) {
- if (((*it)->GetaVertex() != v) && ((*it)->GetbVertex() != v))
+ if (((*it)->GetaVertex() != v) && ((*it)->GetbVertex() != v)) {
e = *it;
+ }
}
- if (!e)
+ if (!e) {
return false;
- else
+ }
+ else {
return true;
+ }
}
float WFace::getArea()
@@ -423,13 +439,15 @@ WOEdge *WFace::GetPrevOEdge(WOEdge *iOEdge)
woe = woefirst;
++woe;
for (; woe != woend; woe++) {
- if ((*woe) == iOEdge)
+ if ((*woe) == iOEdge) {
return prev;
+ }
prev = *woe;
}
// We left the loop. That means that the first OEdge was the good one:
- if ((*woefirst) == iOEdge)
+ if ((*woefirst) == iOEdge) {
return prev;
+ }
return NULL;
}
@@ -511,8 +529,9 @@ WShape::WShape(WShape &iBrother)
WOEdge *aoEdge = (*e)->GetaOEdge();
aoEdge->setaVertex(((vertexdata *)(aoEdge->GetaVertex()->userdata))->_copy);
aoEdge->setbVertex(((vertexdata *)(aoEdge->GetbVertex()->userdata))->_copy);
- if (aoEdge->GetaFace())
+ if (aoEdge->GetaFace()) {
aoEdge->setaFace(((facedata *)(aoEdge->GetaFace()->userdata))->_copy);
+ }
aoEdge->setbFace(((facedata *)(aoEdge->GetbFace()->userdata))->_copy);
aoEdge->setOwner(((edgedata *)(aoEdge->GetOwner()->userdata))->_copy);
@@ -521,8 +540,9 @@ WShape::WShape(WShape &iBrother)
if (boEdge) {
boEdge->setaVertex(((vertexdata *)(boEdge->GetaVertex()->userdata))->_copy);
boEdge->setbVertex(((vertexdata *)(boEdge->GetbVertex()->userdata))->_copy);
- if (boEdge->GetaFace())
+ if (boEdge->GetaFace()) {
boEdge->setaFace(((facedata *)(boEdge->GetaFace()->userdata))->_copy);
+ }
boEdge->setbFace(((facedata *)(boEdge->GetbFace()->userdata))->_copy);
boEdge->setOwner(((edgedata *)(boEdge->GetOwner()->userdata))->_copy);
}
@@ -585,8 +605,9 @@ WFace *WShape::MakeFace(vector<WVertex *> &iVertexList,
WFace *face = instanciateFace();
WFace *result = MakeFace(iVertexList, iFaceEdgeMarksList, iMaterial, face);
- if (!result)
+ if (!result) {
delete face;
+ }
return result;
}
@@ -599,8 +620,9 @@ WFace *WShape::MakeFace(vector<WVertex *> &iVertexList,
// allocate the new face
WFace *face = MakeFace(iVertexList, iFaceEdgeMarksList, iMaterial);
- if (!face)
+ if (!face) {
return NULL;
+ }
// set the list of per-vertex normals
face->setNormalList(iNormalsList);
@@ -665,13 +687,16 @@ WFace *WShape::MakeFace(vector<WVertex *> &iVertexList,
// face->AddVertex(*va);
WOEdge *oedge;
- if (*va == iVertexList.back())
+ if (*va == iVertexList.back()) {
oedge = face->MakeEdge(*va, iVertexList.front()); // for the last (closing) edge
- else
+ }
+ else {
oedge = face->MakeEdge(*va, *vb);
+ }
- if (!oedge)
+ if (!oedge) {
return NULL;
+ }
WEdge *edge = oedge->GetOwner();
if (1 == edge->GetNumberOfOEdges()) {
diff --git a/source/blender/freestyle/intern/winged_edge/WEdge.h b/source/blender/freestyle/intern/winged_edge/WEdge.h
index 1a141629c6d..037e21ab4e3 100644
--- a/source/blender/freestyle/intern/winged_edge/WEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WEdge.h
@@ -140,10 +140,12 @@ class WVertex {
inline void setBorder(bool b)
{
- if (b)
+ if (b) {
_Border = 1;
- else
+ }
+ else {
_Border = 0;
+ }
}
/*! Adds an edge to the edges list */
@@ -600,8 +602,9 @@ class WEdge {
*/
static inline WVertex *CommonVertex(WEdge *iEdge1, WEdge *iEdge2)
{
- if (!iEdge1 || !iEdge2)
+ if (!iEdge1 || !iEdge2) {
return NULL;
+ }
WVertex *wv1 = iEdge1->GetaOEdge()->GetaVertex();
WVertex *wv2 = iEdge1->GetaOEdge()->GetbVertex();
@@ -665,10 +668,12 @@ class WEdge {
inline WOEdge *GetOtherOEdge(WOEdge *iOEdge)
{
- if (iOEdge == _paOEdge)
+ if (iOEdge == _paOEdge) {
return _pbOEdge;
- else
+ }
+ else {
return _paOEdge;
+ }
}
/*! modifiers */
@@ -809,8 +814,9 @@ class WFace {
for (vector<WOEdge *>::iterator woe = _OEdgeList.begin(), woend = _OEdgeList.end();
woe != woend;
woe++) {
- if ((*woe)->GetaVertex() == iVertex)
+ if ((*woe)->GetaVertex() == iVertex) {
return index;
+ }
++index;
}
return -1;
@@ -831,8 +837,9 @@ class WFace {
woe != woend;
woe++) {
WFace *af;
- if ((af = (*woe)->GetaFace()))
+ if ((af = (*woe)->GetaFace())) {
oWFaces.push_back(af);
+ }
}
}
@@ -896,8 +903,9 @@ class WFace {
vector<WOEdge *>::iterator woe, woend, woefirst;
woefirst = _OEdgeList.begin();
for (woe = woefirst, woend = _OEdgeList.end(); woe != woend; ++woe) {
- if (found)
+ if (found) {
return (*woe);
+ }
if ((*woe) == iOEdge) {
found = true;
@@ -905,8 +913,9 @@ class WFace {
}
// We left the loop. That means that the first OEdge was the good one:
- if (found)
+ if (found) {
return (*woefirst);
+ }
return NULL;
}
@@ -929,8 +938,9 @@ class WFace {
for (vector<WOEdge *>::const_iterator woe = _OEdgeList.begin(), woeend = _OEdgeList.end();
woe != woeend;
++woe) {
- if ((*woe)->GetOwner()->GetbOEdge() == 0)
+ if ((*woe)->GetOwner()->GetbOEdge() == 0) {
return true;
+ }
}
return false;
}
@@ -1250,11 +1260,13 @@ class WShape {
(*e)->ResetUserData();
// manages WOEdge:
WOEdge *oe = (*e)->GetaOEdge();
- if (oe)
+ if (oe) {
oe->ResetUserData();
+ }
oe = (*e)->GetbOEdge();
- if (oe)
+ if (oe) {
oe->ResetUserData();
+ }
}
for (vector<WFace *>::iterator f = _FaceList.begin(), fend = _FaceList.end(); f != fend; f++) {
@@ -1338,8 +1350,9 @@ class WingedEdge {
void clear()
{
- for (vector<WShape *>::iterator it = _wshapes.begin(); it != _wshapes.end(); it++)
+ for (vector<WShape *>::iterator it = _wshapes.begin(); it != _wshapes.end(); it++) {
delete *it;
+ }
_wshapes.clear();
_numFaces = 0;
}
diff --git a/source/blender/freestyle/intern/winged_edge/WFillGrid.cpp b/source/blender/freestyle/intern/winged_edge/WFillGrid.cpp
index 8106bcedd0c..c6b32e0a89c 100644
--- a/source/blender/freestyle/intern/winged_edge/WFillGrid.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WFillGrid.cpp
@@ -26,8 +26,9 @@ namespace Freestyle {
void WFillGrid::fillGrid()
{
- if (!_winged_edge || !_grid)
+ if (!_winged_edge || !_grid) {
return;
+ }
vector<WShape *> wshapes = _winged_edge->getWShapes();
vector<WVertex *> fvertices;
@@ -40,8 +41,9 @@ void WFillGrid::fillGrid()
for (vector<WFace *>::const_iterator f = faces.begin(); f != faces.end(); ++f) {
(*f)->RetrieveVertexList(fvertices);
- for (vector<WVertex *>::const_iterator wv = fvertices.begin(); wv != fvertices.end(); ++wv)
+ for (vector<WVertex *>::const_iterator wv = fvertices.begin(); wv != fvertices.end(); ++wv) {
vectors.push_back(Vec3r((*wv)->GetVertex()));
+ }
// occluder will be deleted by the grid
Polygon3r *occluder = new Polygon3r(vectors, (*f)->GetNormal());
diff --git a/source/blender/freestyle/intern/winged_edge/WFillGrid.h b/source/blender/freestyle/intern/winged_edge/WFillGrid.h
index f9e63464e30..918c1f154f3 100644
--- a/source/blender/freestyle/intern/winged_edge/WFillGrid.h
+++ b/source/blender/freestyle/intern/winged_edge/WFillGrid.h
@@ -62,14 +62,16 @@ class WFillGrid {
/*! Modifiers */
void setWingedEdge(WingedEdge *winged_edge)
{
- if (winged_edge)
+ if (winged_edge) {
_winged_edge = winged_edge;
+ }
}
void setGrid(Grid *grid)
{
- if (grid)
+ if (grid) {
_grid = grid;
+ }
}
private:
diff --git a/source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp b/source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp
index cd13775239b..404a1ae6181 100644
--- a/source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WSFillGrid.cpp
@@ -26,8 +26,9 @@ namespace Freestyle {
void WSFillGrid::fillGrid()
{
- if (!_winged_edge || !_grid)
+ if (!_winged_edge || !_grid) {
return;
+ }
vector<WShape *> wshapes = _winged_edge->getWShapes();
vector<WVertex *> fvertices;
@@ -40,8 +41,9 @@ void WSFillGrid::fillGrid()
for (vector<WFace *>::const_iterator f = faces.begin(); f != faces.end(); ++f) {
(*f)->RetrieveVertexList(fvertices);
- for (vector<WVertex *>::const_iterator wv = fvertices.begin(); wv != fvertices.end(); ++wv)
+ for (vector<WVertex *>::const_iterator wv = fvertices.begin(); wv != fvertices.end(); ++wv) {
vectors.push_back(Vec3r((*wv)->GetVertex()));
+ }
// occluder will be deleted by the grid
Polygon3r *occluder = new Polygon3r(vectors, (*f)->GetNormal());
diff --git a/source/blender/freestyle/intern/winged_edge/WSFillGrid.h b/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
index 2d8ac77a15d..e3deebcd6c2 100644
--- a/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
+++ b/source/blender/freestyle/intern/winged_edge/WSFillGrid.h
@@ -58,14 +58,16 @@ class WSFillGrid {
/*! Modifiers */
void setWingedEdge(WingedEdge *winged_edge)
{
- if (winged_edge)
+ if (winged_edge) {
_winged_edge = winged_edge;
+ }
}
void setGrid(Grid *grid)
{
- if (grid)
+ if (grid) {
_grid = grid;
+ }
}
private:
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
index 2e36790563e..566b046bb2c 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp
@@ -70,8 +70,9 @@ void WXFaceLayer::RetrieveCuspEdgesIndices(vector<int> &oCuspEdges)
WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
{
// if the smooth edge has already been built: exit
- if (_pSmoothEdge)
+ if (_pSmoothEdge) {
return _pSmoothEdge;
+ }
float ta, tb;
WOEdge *woea(0), *woeb(0);
bool ok = false;
@@ -87,8 +88,9 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
//-----------------------------
// We retrieve the 2 edges for which we have opposite signs for each extremity
RetrieveCuspEdgesIndices(cuspEdgesIndices);
- if (cuspEdgesIndices.size() != 2) // we necessarly have 2 cusp edges
+ if (cuspEdgesIndices.size() != 2) { // we necessarly have 2 cusp edges
return 0;
+ }
// let us determine which cusp edge corresponds to the starting:
// We can do that because we defined that a silhouette edge had the back facing part on its
@@ -179,10 +181,12 @@ WXSmoothEdge *WXFaceLayer::BuildSmoothEdge()
_pSmoothEdge->setTb(tb);
if (_Nature & Nature::SILHOUETTE) {
if (_nNullDotP != 2) {
- if (_DotP[_ClosestPointIndex] + 0.01f > 0.0f)
+ if (_DotP[_ClosestPointIndex] + 0.01f > 0.0f) {
_pSmoothEdge->setFront(true);
- else
+ }
+ else {
_pSmoothEdge->setFront(false);
+ }
}
}
}
@@ -266,8 +270,9 @@ WFace *WXShape::MakeFace(vector<WVertex *> &iVertexList,
unsigned iMaterialIndex)
{
WFace *face = WShape::MakeFace(iVertexList, iFaceEdgeMarksList, iMaterialIndex);
- if (!face)
+ if (!face) {
return NULL;
+ }
Vec3f center;
for (vector<WVertex *>::iterator wv = iVertexList.begin(), wvend = iVertexList.end();
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.h b/source/blender/freestyle/intern/winged_edge/WXEdge.h
index 0f1b8d77c59..0e8ca62fba3 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdge.h
+++ b/source/blender/freestyle/intern/winged_edge/WXEdge.h
@@ -67,14 +67,16 @@ class WXVertex : public WVertex {
virtual ~WXVertex()
{
- if (_curvatures)
+ if (_curvatures) {
delete _curvatures;
+ }
}
virtual void Reset()
{
- if (_curvatures)
+ if (_curvatures) {
_curvatures->Kr = 0.0;
+ }
}
inline void setCurvatures(CurvatureInfo *ci)
@@ -365,8 +367,9 @@ class WXFaceLayer {
virtual ~WXFaceLayer()
{
- if (!_DotP.empty())
+ if (!_DotP.empty()) {
_DotP.clear();
+ }
if (_pSmoothEdge) {
delete _pSmoothEdge;
_pSmoothEdge = NULL;
@@ -400,8 +403,9 @@ class WXFaceLayer {
inline bool hasSmoothEdge() const
{
- if (_pSmoothEdge)
+ if (_pSmoothEdge) {
return true;
+ }
return false;
}
@@ -427,8 +431,9 @@ class WXFaceLayer {
inline void removeSmoothEdge()
{
- if (!_DotP.empty())
+ if (!_DotP.empty()) {
_DotP.clear();
+ }
if (_pSmoothEdge) {
delete _pSmoothEdge;
_pSmoothEdge = NULL;
@@ -458,10 +463,12 @@ class WXFaceLayer {
inline void PushDotP(float iDotP)
{
_DotP.push_back(iDotP);
- if (iDotP > 0.0f)
+ if (iDotP > 0.0f) {
++_nPosDotP;
- if (iDotP == 0.0f) // TODO this comparison is weak, check if it actually works
+ }
+ if (iDotP == 0.0f) { // TODO this comparison is weak, check if it actually works
++_nNullDotP;
+ }
}
inline void ReplaceDotP(unsigned int index, float newDotP)
@@ -475,10 +482,12 @@ class WXFaceLayer {
_nPosDotP = 0;
_nNullDotP = 0;
for (vector<float>::iterator d = _DotP.begin(), dend = _DotP.end(); d != dend; ++d) {
- if ((*d) > 0.0f)
+ if ((*d) > 0.0f) {
++_nPosDotP;
- if ((*d) == 0.0f) // TODO ditto
+ }
+ if ((*d) == 0.0f) { // TODO ditto
++_nNullDotP;
+ }
}
}
@@ -637,10 +646,12 @@ class WXFace : public WFace {
inline void setDotP(float iDotP)
{
_dotp = iDotP;
- if (_dotp > 0.0f)
+ if (_dotp > 0.0f) {
_front = true;
- else
+ }
+ else {
_front = false;
+ }
}
inline void AddSmoothLayer(WXFaceLayer *iLayer)
@@ -654,10 +665,12 @@ class WXFace : public WFace {
for (vector<WXFaceLayer *>::iterator wxf = _SmoothLayers.begin(), wxfend = _SmoothLayers.end();
wxf != wxfend;
++wxf) {
- if ((*wxf)->isViewDependant())
+ if ((*wxf)->isViewDependant()) {
delete (*wxf);
- else
+ }
+ else {
layersToKeep.push_back(*wxf);
+ }
}
_SmoothLayers = layersToKeep;
}
@@ -820,12 +833,14 @@ bool WXVertex::isFeature()
int counter = 0;
vector<WEdge *> &vedges = GetEdges();
for (vector<WEdge *>::iterator ve = vedges.begin(), vend = vedges.end(); ve != vend; ++ve) {
- if (((WXEdge *)(*ve))->nature() != Nature::NO_FEATURE)
+ if (((WXEdge *)(*ve))->nature() != Nature::NO_FEATURE) {
counter++;
+ }
}
- if ((counter == 1) || (counter > 2))
+ if ((counter == 1) || (counter > 2)) {
return true;
+ }
return false;
}
diff --git a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
index a34f2272200..db3719b8d2c 100644
--- a/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WXEdgeBuilder.cpp
@@ -27,8 +27,9 @@ namespace Freestyle {
void WXEdgeBuilder::visitIndexedFaceSet(IndexedFaceSet &ifs)
{
- if (_pRenderMonitor && _pRenderMonitor->testBreak())
+ if (_pRenderMonitor && _pRenderMonitor->testBreak()) {
return;
+ }
WXShape *shape = new WXShape;
if (!buildWShape(*shape, ifs)) {
delete shape;
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
index f190d78014d..97e9ec2bfd2 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.cpp
@@ -34,8 +34,9 @@ namespace Freestyle {
void WingedEdgeBuilder::visitIndexedFaceSet(IndexedFaceSet &ifs)
{
- if (_pRenderMonitor && _pRenderMonitor->testBreak())
+ if (_pRenderMonitor && _pRenderMonitor->testBreak()) {
return;
+ }
WShape *shape = new WShape;
if (!buildWShape(*shape, ifs)) {
delete shape;
@@ -65,8 +66,9 @@ void WingedEdgeBuilder::visitNodeTransform(NodeTransform &tn)
void WingedEdgeBuilder::visitNodeTransformAfter(NodeTransform &)
{
- if (_current_matrix)
+ if (_current_matrix) {
delete _current_matrix;
+ }
if (_matrices_stack.empty()) {
_current_matrix = NULL;
@@ -108,8 +110,9 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs)
vector<FrsMaterial> frs_materials;
if (ifs.msize()) {
const FrsMaterial *const *mats = ifs.frs_materials();
- for (unsigned i = 0; i < ifs.msize(); ++i)
+ for (unsigned i = 0; i < ifs.msize(); ++i) {
frs_materials.push_back(*(mats[i]));
+ }
shape.setFrsMaterials(frs_materials);
}
@@ -136,8 +139,9 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs)
}
const unsigned int *mindices = NULL;
- if (ifs.msize())
+ if (ifs.msize()) {
mindices = ifs.mindices();
+ }
const unsigned int *numVertexPerFace = ifs.numVertexPerFaces();
const unsigned int numfaces = ifs.numFaces();
@@ -182,18 +186,21 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs)
}
vindices += numVertexPerFace[index];
nindices += numVertexPerFace[index];
- if (mindices)
+ if (mindices) {
mindices += numVertexPerFace[index];
- if (tindices)
+ }
+ if (tindices) {
tindices += numVertexPerFace[index];
+ }
faceEdgeMarks++;
}
delete[] new_vertices;
delete[] new_normals;
- if (shape.GetFaceList().size() == 0) // this may happen due to degenerate triangles
+ if (shape.GetFaceList().size() == 0) { // this may happen due to degenerate triangles
return false;
+ }
#if 0
// compute bbox
@@ -207,11 +214,13 @@ bool WingedEdgeBuilder::buildWShape(WShape &shape, IndexedFaceSet &ifs)
vector<WVertex *> &wvertices = shape.getVertexList();
for (vector<WVertex *>::iterator wv = wvertices.begin(), wvend = wvertices.end(); wv != wvend;
++wv) {
- if ((*wv)->isBoundary())
+ if ((*wv)->isBoundary()) {
continue;
+ }
if ((*wv)->GetEdges().size() ==
- 0) // This means that the WVertex has no incoming edges... (12-Sep-2011 T.K.)
+ 0) { // This means that the WVertex has no incoming edges... (12-Sep-2011 T.K.)
continue;
+ }
normalsSet.clear();
WVertex::face_iterator fit = (*wv)->faces_begin();
WVertex::face_iterator fitend = (*wv)->faces_end();
@@ -400,12 +409,14 @@ void WingedEdgeBuilder::buildTriangles(const float * /*vertices*/,
triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[i] & IndexedFaceSet::EDGE_MARK_V2V3) != 0);
triangleFaceEdgeMarks.push_back((iFaceEdgeMarks[i] & IndexedFaceSet::EDGE_MARK_V3V1) != 0);
}
- if (mindices)
+ if (mindices) {
currentShape->MakeFace(
triangleVertices, triangleNormals, triangleTexCoords, triangleFaceEdgeMarks, mindices[0]);
- else
+ }
+ else {
currentShape->MakeFace(
triangleVertices, triangleNormals, triangleTexCoords, triangleFaceEdgeMarks, 0);
+ }
}
void WingedEdgeBuilder::transformVertices(const float *vertices,
@@ -419,8 +430,9 @@ void WingedEdgeBuilder::transformVertices(const float *vertices,
for (unsigned int i = 0; i < vsize / 3; i++) {
HVec3r hv_tmp(v[0], v[1], v[2]);
HVec3r hv(transform * hv_tmp);
- for (unsigned int j = 0; j < 3; j++)
+ for (unsigned int j = 0; j < 3; j++) {
pv[j] = hv[j] / hv[3];
+ }
v += 3;
pv += 3;
}
@@ -437,8 +449,9 @@ void WingedEdgeBuilder::transformNormals(const float *normals,
for (unsigned int i = 0; i < nsize / 3; i++) {
Vec3r hn(n[0], n[1], n[2]);
hn = GeomUtils::rotateVector(transform, hn);
- for (unsigned int j = 0; j < 3; j++)
+ for (unsigned int j = 0; j < 3; j++) {
pn[j] = hn[j];
+ }
n += 3;
pn += 3;
}
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
index a4aa08d50b6..78b1bcf645f 100644
--- a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
+++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h
@@ -48,8 +48,9 @@ class WingedEdgeBuilder : public SceneVisitor {
virtual ~WingedEdgeBuilder()
{
for (vector<Matrix44r *>::iterator it = _matrices_stack.begin(); it != _matrices_stack.end();
- ++it)
+ ++it) {
delete *it;
+ }
_matrices_stack.clear();
}