mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-06 06:09:54 +01:00
Use nullptr instead of NULL or 0
This commit is contained in:
parent
f5f9d33ea9
commit
6c184d10b4
@ -42,7 +42,7 @@ std::ostream& operator<<(std::ostream& out, const Point& point) {
|
|||||||
Triangle::Triangle(Point& a, Point& b, Point& c)
|
Triangle::Triangle(Point& a, Point& b, Point& c)
|
||||||
{
|
{
|
||||||
points_[0] = &a; points_[1] = &b; points_[2] = &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;
|
constrained_edge[0] = constrained_edge[1] = constrained_edge[2] = false;
|
||||||
delaunay_edge[0] = delaunay_edge[1] = delaunay_edge[2] = false;
|
delaunay_edge[0] = delaunay_edge[1] = delaunay_edge[2] = false;
|
||||||
interior_ = false;
|
interior_ = false;
|
||||||
@ -85,36 +85,36 @@ void Triangle::Clear()
|
|||||||
for( int i=0; i<3; i++ )
|
for( int i=0; i<3; i++ )
|
||||||
{
|
{
|
||||||
t = neighbors_[i];
|
t = neighbors_[i];
|
||||||
if( t != NULL )
|
if( t != nullptr )
|
||||||
{
|
{
|
||||||
t->ClearNeighbor( this );
|
t->ClearNeighbor( this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClearNeighbors();
|
ClearNeighbors();
|
||||||
points_[0]=points_[1]=points_[2] = NULL;
|
points_[0]=points_[1]=points_[2] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Triangle::ClearNeighbor(const Triangle *triangle )
|
void Triangle::ClearNeighbor(const Triangle *triangle )
|
||||||
{
|
{
|
||||||
if( neighbors_[0] == triangle )
|
if( neighbors_[0] == triangle )
|
||||||
{
|
{
|
||||||
neighbors_[0] = NULL;
|
neighbors_[0] = nullptr;
|
||||||
}
|
}
|
||||||
else if( neighbors_[1] == triangle )
|
else if( neighbors_[1] == triangle )
|
||||||
{
|
{
|
||||||
neighbors_[1] = NULL;
|
neighbors_[1] = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
neighbors_[2] = NULL;
|
neighbors_[2] = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Triangle::ClearNeighbors()
|
void Triangle::ClearNeighbors()
|
||||||
{
|
{
|
||||||
neighbors_[0] = NULL;
|
neighbors_[0] = nullptr;
|
||||||
neighbors_[1] = NULL;
|
neighbors_[1] = nullptr;
|
||||||
neighbors_[2] = NULL;
|
neighbors_[2] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Triangle::ClearDelunayEdges()
|
void Triangle::ClearDelunayEdges()
|
||||||
@ -226,7 +226,7 @@ Point* Triangle::PointCW(const Point& point)
|
|||||||
return points_[1];
|
return points_[1];
|
||||||
}
|
}
|
||||||
assert(0);
|
assert(0);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The point counter-clockwise to given point
|
// The point counter-clockwise to given point
|
||||||
@ -240,7 +240,7 @@ Point* Triangle::PointCCW(const Point& point)
|
|||||||
return points_[0];
|
return points_[0];
|
||||||
}
|
}
|
||||||
assert(0);
|
assert(0);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The neighbor clockwise to given point
|
// The neighbor clockwise to given point
|
||||||
|
@ -46,21 +46,21 @@ Node* AdvancingFront::LocateNode(double x)
|
|||||||
Node* node = search_node_;
|
Node* node = search_node_;
|
||||||
|
|
||||||
if (x < node->value) {
|
if (x < node->value) {
|
||||||
while ((node = node->prev) != NULL) {
|
while ((node = node->prev) != nullptr) {
|
||||||
if (x >= node->value) {
|
if (x >= node->value) {
|
||||||
search_node_ = node;
|
search_node_ = node;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ((node = node->next) != NULL) {
|
while ((node = node->next) != nullptr) {
|
||||||
if (x < node->value) {
|
if (x < node->value) {
|
||||||
search_node_ = node->prev;
|
search_node_ = node->prev;
|
||||||
return node->prev;
|
return node->prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* AdvancingFront::FindSearchNode(double x)
|
Node* AdvancingFront::FindSearchNode(double x)
|
||||||
@ -88,13 +88,13 @@ Node* AdvancingFront::LocatePoint(const Point* point)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (px < nx) {
|
} else if (px < nx) {
|
||||||
while ((node = node->prev) != NULL) {
|
while ((node = node->prev) != nullptr) {
|
||||||
if (point == node->point) {
|
if (point == node->point) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ((node = node->next) != NULL) {
|
while ((node = node->next) != nullptr) {
|
||||||
if (point == node->point)
|
if (point == node->point)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -263,12 +263,12 @@ bool Sweep::LargeHole_DontFill(const Node* node) const {
|
|||||||
// Check additional points on front.
|
// Check additional points on front.
|
||||||
const Node* next2Node = nextNode->next;
|
const Node* next2Node = nextNode->next;
|
||||||
// "..Plus.." because only want angles on same side as point being added.
|
// "..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;
|
return false;
|
||||||
|
|
||||||
const Node* prev2Node = prevNode->prev;
|
const Node* prev2Node = prevNode->prev;
|
||||||
// "..Plus.." because only want angles on same side as point being added.
|
// "..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 false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -35,12 +35,12 @@
|
|||||||
namespace p2t {
|
namespace p2t {
|
||||||
|
|
||||||
SweepContext::SweepContext(const std::vector<Point*>& polyline) : points_(polyline),
|
SweepContext::SweepContext(const std::vector<Point*>& polyline) : points_(polyline),
|
||||||
front_(0),
|
front_(nullptr),
|
||||||
head_(0),
|
head_(nullptr),
|
||||||
tail_(0),
|
tail_(nullptr),
|
||||||
af_head_(0),
|
af_head_(nullptr),
|
||||||
af_middle_(0),
|
af_middle_(nullptr),
|
||||||
af_tail_(0)
|
af_tail_(nullptr)
|
||||||
{
|
{
|
||||||
InitEdges(points_);
|
InitEdges(points_);
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ void SweepContext::MeshClean(Triangle& triangle)
|
|||||||
Triangle *t = triangles.back();
|
Triangle *t = triangles.back();
|
||||||
triangles.pop_back();
|
triangles.pop_back();
|
||||||
|
|
||||||
if (t != NULL && !t->IsInterior()) {
|
if (t != nullptr && !t->IsInterior()) {
|
||||||
t->IsInterior(true);
|
t->IsInterior(true);
|
||||||
triangles_.push_back(t);
|
triangles_.push_back(t);
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user