Skip to content

Commit

Permalink
Use nullptr instead of NULL or 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Jun 14, 2020
1 parent f5f9d33 commit 6c184d1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
22 changes: 11 additions & 11 deletions poly2tri/common/shapes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ std::ostream& operator<<(std::ostream& out, const Point& point) {
Triangle::Triangle(Point& a, Point& b, Point& c)
{
points_[0] = &a; points_[1] = &b; points_[2] = &c;
neighbors_[0] = NULL; neighbors_[1] = NULL; neighbors_[2] = NULL;
neighbors_[0] = nullptr; neighbors_[1] = nullptr; neighbors_[2] = nullptr;
constrained_edge[0] = constrained_edge[1] = constrained_edge[2] = false;
delaunay_edge[0] = delaunay_edge[1] = delaunay_edge[2] = false;
interior_ = false;
Expand Down Expand Up @@ -85,36 +85,36 @@ void Triangle::Clear()
for( int i=0; i<3; i++ )
{
t = neighbors_[i];
if( t != NULL )
if( t != nullptr )
{
t->ClearNeighbor( this );
}
}
ClearNeighbors();
points_[0]=points_[1]=points_[2] = NULL;
points_[0]=points_[1]=points_[2] = nullptr;
}

void Triangle::ClearNeighbor(const Triangle *triangle )
{
if( neighbors_[0] == triangle )
{
neighbors_[0] = NULL;
neighbors_[0] = nullptr;
}
else if( neighbors_[1] == triangle )
{
neighbors_[1] = NULL;
neighbors_[1] = nullptr;
}
else
{
neighbors_[2] = NULL;
neighbors_[2] = nullptr;
}
}

void Triangle::ClearNeighbors()
{
neighbors_[0] = NULL;
neighbors_[1] = NULL;
neighbors_[2] = NULL;
neighbors_[0] = nullptr;
neighbors_[1] = nullptr;
neighbors_[2] = nullptr;
}

void Triangle::ClearDelunayEdges()
Expand Down Expand Up @@ -226,7 +226,7 @@ Point* Triangle::PointCW(const Point& point)
return points_[1];
}
assert(0);
return NULL;
return nullptr;
}

// The point counter-clockwise to given point
Expand All @@ -240,7 +240,7 @@ Point* Triangle::PointCCW(const Point& point)
return points_[0];
}
assert(0);
return NULL;
return nullptr;
}

// The neighbor clockwise to given point
Expand Down
10 changes: 5 additions & 5 deletions poly2tri/sweep/advancing_front.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ Node* AdvancingFront::LocateNode(double x)
Node* node = search_node_;

if (x < node->value) {
while ((node = node->prev) != NULL) {
while ((node = node->prev) != nullptr) {
if (x >= node->value) {
search_node_ = node;
return node;
}
}
} else {
while ((node = node->next) != NULL) {
while ((node = node->next) != nullptr) {
if (x < node->value) {
search_node_ = node->prev;
return node->prev;
}
}
}
return NULL;
return nullptr;
}

Node* AdvancingFront::FindSearchNode(double x)
Expand Down Expand Up @@ -88,13 +88,13 @@ Node* AdvancingFront::LocatePoint(const Point* point)
}
}
} else if (px < nx) {
while ((node = node->prev) != NULL) {
while ((node = node->prev) != nullptr) {
if (point == node->point) {
break;
}
}
} else {
while ((node = node->next) != NULL) {
while ((node = node->next) != nullptr) {
if (point == node->point)
break;
}
Expand Down
4 changes: 2 additions & 2 deletions poly2tri/sweep/sweep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ bool Sweep::LargeHole_DontFill(const Node* node) const {
// Check additional points on front.
const Node* next2Node = nextNode->next;
// "..Plus.." because only want angles on same side as point being added.
if ((next2Node != NULL) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, next2Node->point, prevNode->point))
if ((next2Node != nullptr) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, next2Node->point, prevNode->point))
return false;

const Node* prev2Node = prevNode->prev;
// "..Plus.." because only want angles on same side as point being added.
if ((prev2Node != NULL) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, nextNode->point, prev2Node->point))
if ((prev2Node != nullptr) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, nextNode->point, prev2Node->point))
return false;

return true;
Expand Down
14 changes: 7 additions & 7 deletions poly2tri/sweep/sweep_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
namespace p2t {

SweepContext::SweepContext(const std::vector<Point*>& polyline) : points_(polyline),
front_(0),
head_(0),
tail_(0),
af_head_(0),
af_middle_(0),
af_tail_(0)
front_(nullptr),
head_(nullptr),
tail_(nullptr),
af_head_(nullptr),
af_middle_(nullptr),
af_tail_(nullptr)
{
InitEdges(points_);
}
Expand Down Expand Up @@ -171,7 +171,7 @@ void SweepContext::MeshClean(Triangle& triangle)
Triangle *t = triangles.back();
triangles.pop_back();

if (t != NULL && !t->IsInterior()) {
if (t != nullptr && !t->IsInterior()) {
t->IsInterior(true);
triangles_.push_back(t);
for (int i = 0; i < 3; i++) {
Expand Down

0 comments on commit 6c184d1

Please sign in to comment.