[Path] remove unnecessary Boolean comparisons

This commit is contained in:
Uwe
2022-06-19 17:28:08 +02:00
parent 80919201fc
commit d74fdebd11
7 changed files with 57 additions and 43 deletions

View File

@@ -2630,7 +2630,7 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths)
if (!forceInsideOut && FindEntryPointOutside(progressPaths, toolBoundPaths, boundPaths, cleared, entryPoint, toolPos, toolDir))
{
if (Orientation(engageBounds[0]) == false)
if (!Orientation(engageBounds[0]))
ReversePath(engageBounds[0]);
// add initial offset of cleared area to engage paths
Paths outsideEngage;

View File

@@ -780,7 +780,7 @@ bool CCurve::Offset(double leftwards_value)
success = false;
}
if(success == false)
if(!success)
{
if(this->IsClosed())
{

View File

@@ -62,7 +62,7 @@ namespace geoff_geometry {
// *********************************************************************************************************
wostream& operator << (wostream& op, Point& p){
// for debug - print point to file
if(p.ok == false)
if(!p.ok)
op << L" ok=\"false\"";
else
op << L" x=\"" << p.x << L"\" y=\"" << p.y << L"\"";
@@ -71,7 +71,7 @@ namespace geoff_geometry {
wostream& operator <<(wostream& op, CLine& cl){
// for debug - print cline to file
if(cl.ok == false)
if(!cl.ok)
op << L"(CLine UNSET)";
else
op << L"sp=" << cl.p << L" v=" << cl.v;
@@ -80,7 +80,7 @@ namespace geoff_geometry {
wostream& operator <<(wostream& op, Plane& pl){
// for debug - print plane to file stream
if(pl.ok == false)
if(!pl.ok)
op << L"(Plane UNSET)";
else
op << L"d=" << pl.d << L" normal=" << pl.normal;
@@ -89,7 +89,7 @@ namespace geoff_geometry {
ostream& operator << (ostream& op, Point3d& p){
// for debug - print point to file
// if(p.ok == false)
// if(!p.ok)
// op << "ok=\"false\"";
// else
op << "x=\"" << p.x << "\" y=\"" << p.y << "\" z=" << p.z << "\"";
@@ -111,7 +111,7 @@ namespace geoff_geometry {
wostream& operator <<(wostream& op, Circle& c){
// for debug - print circle to file
if(c.ok == false)
if(!c.ok)
op << L"ok=\"false\"";
else
op << L" x=\"" << c.pc.x << L"\" y=\"" << c.pc.y << L"\" radius=\"" << c.radius << L"\"";
@@ -390,7 +390,8 @@ namespace geoff_geometry {
Circle Circle::Transform(Matrix& m) { // transform
Point p0 = this->pc;
double scale;
if(m.GetScale(scale) == false) FAILURE(getMessage(L"Differential Scale not allowed for this method"));
if(!m.GetScale(scale))
FAILURE(getMessage(L"Differential Scale not allowed for this method"));
return Circle(p0.Transform(m), radius * scale);
}
@@ -802,7 +803,8 @@ namespace geoff_geometry {
Plane::Plane(const Point3d& p0, const Vector3d& v, bool normalise) {
// constructor plane from point & vector
normal = v;
if(normalise == true) normal.normalise();
if (normalise)
normal.normalise();
ok = (normal != NULL_VECTOR);
d = -(normal * Vector3d(p0));
}

View File

@@ -18,7 +18,7 @@ namespace geoff_geometry {
int Intof(const Span& sp0, const Span& sp1, Point& p0, Point& p1, double t[4])
{
// returns the number of intersects (lying within spans sp0, sp1)
if(sp0.box.outside(sp1.box) == true)
if(sp0.box.outside(sp1.box))
return 0;
if(!sp0.dir) {
if(!sp1.dir) {
@@ -128,7 +128,7 @@ namespace geoff_geometry {
bool Span::OnSpan(const Point& p, double* t)const {
// FAST OnSpan test - assumes that p lies ON the unbounded span
#if _DEBUG
if(this->returnSpanProperties == false) {
if(!this->returnSpanProperties) {
FAILURE(L"OnSpan - properties no set, incorrect calling code");
}
#endif
@@ -257,13 +257,13 @@ namespace geoff_geometry {
Return FALSE if no solution exists. P Bourke method.
Input this 1st line
Input l2 2nd line
Output lshort shortest line between lines (if lshort.ok == false, the line intersect at a point lshort.p0)
Output lshort shortest line between lines (if !lshort.ok, the line intersect at a point lshort.p0)
Output t1 parameter at intersection on 1st Line
Output t2 parameter at intersection on 2nd Line
*/
Vector3d v13(l2.p0, this->p0);
if(this->ok == false || l2.ok == false)
if(!this->ok || !l2.ok)
return false;
double d1343 = v13 * l2.v; // dot products
@@ -314,7 +314,7 @@ namespace geoff_geometry {
c = Vector3d(l1, l0)
*/
// Vector3d a = l0.v;
if(l0.box.outside(l1.box) == true)
if(l0.box.outside(l1.box))
return 0;
Vector3d b = -l1.v;
Vector3d c = Vector3d(l1.p0, l0.p0);
@@ -526,7 +526,7 @@ namespace geoff_geometry {
// function returns true for intersection, false for no intersection
// method based on Möller & Trumbore(1997) (Barycentric coordinates)
// based on incorrect Pseudo code from "Geometric Tools for Computer Graphics" p.487
if(box.outside(l.box) == true)
if(box.outside(l.box))
return false;
Vector3d line(l.v);
@@ -562,7 +562,7 @@ namespace geoff_geometry {
// box class
bool Box::outside(const Box& b)const {
// returns true if this box is outside b
if(b.ok == false || this->ok == false) // no box set
if(!b.ok || !this->ok) // no box set
return false;
if(this->max.x < b.min.x)
return true;
@@ -593,7 +593,7 @@ namespace geoff_geometry {
bool Box3d::outside(const Box3d& b) const{
// returns true if this box is outside b
if(b.ok == false || this->ok == false) // no box set
if(!b.ok ||! this->ok) // no box set
return false;
if(this->max.x < b.min.x)
return true;

View File

@@ -39,7 +39,7 @@ namespace geoff_geometry {
if(this->m_unit != m.m_unit || this->m_mirrored != m.m_mirrored)
return false;
for(int i = 0; i < 16; i++)
if(FEQ(this->e[i], m.e[i], TIGHT_TOLERANCE) == false)
if(!FEQ(this->e[i], m.e[i], TIGHT_TOLERANCE))
return false;
return true;
}
@@ -527,7 +527,7 @@ namespace geoff_geometry {
void Vector2d::Transform(const Matrix& m) {
// transform vector
if(m.m_unit == false) {
if(!m.m_unit) {
double dxt = dx * m.e[0] + dy * m.e[1];
double dyt = dx * m.e[4] + dy * m.e[5];
dx = dxt;
@@ -538,7 +538,7 @@ namespace geoff_geometry {
void Vector3d::Transform(const Matrix& m) {
// transform vector
if(m.m_unit == false) {
if(!m.m_unit) {
double dxt = dx * m.e[0] + dy * m.e[1] + dz * m.e[2];
double dyt = dx * m.e[4] + dy * m.e[5] + dz * m.e[6];
double dzt = dx * m.e[8] + dy * m.e[9] + dz * m.e[10];
@@ -604,7 +604,8 @@ namespace geoff_geometry {
// calculates a mirror transformation that mirrors 2d about plane
//Point3d p1 = this->Near(Point3d(0.,0.,0.));
if(tmMirrored->m_unit == false) tmMirrored->Unit();
if(!tmMirrored->m_unit)
tmMirrored->Unit();
double nx = this->normal.getx();
double ny = this->normal.gety();

View File

@@ -175,13 +175,15 @@ namespace geoff_geometry {
static int Split(double tolerance, double angle, double radius, int dir);
int Span::Split(double tolerance) {
// returns the number of divisions required to keep in tolerance
if(returnSpanProperties == false) this->SetProperties(true);
if(!returnSpanProperties)
this->SetProperties(true);
return geoff_geometry::Split(tolerance, angle, radius, dir);
}
#if 0
int Span3d::Split(double tolerance) {
// returns the number of divisions required to keep in tolerance
if(returnSpanProperties == false) this->SetProperties(true);
if(!returnSpanProperties)
this->SetProperties(true);
return geoff_geometry::Split(tolerance, angle, radius, dir);
}
#endif
@@ -337,7 +339,7 @@ namespace geoff_geometry {
// returns the near point to span from p - returned point is always on the span
Point pn;
pn = Near(p);
if(this->OnSpan(pn) == true)
if(this->OnSpan(pn))
return pn;
// return nearest endpoint
@@ -352,7 +354,8 @@ namespace geoff_geometry {
if(m.m_mirrored == -1) FAILURE(L"Don't know mirror - use IsMirrored method on object");
if(m.m_mirrored) dir = -dir;
}
if(setprops == true) SetProperties(true);
if(setprops)
SetProperties(true);
}
#if 0
@@ -365,7 +368,8 @@ namespace geoff_geometry {
if(m.m_mirrored == -1) FAILURE(L"Don't know mirror - use IsMirrored method on object");
if(m.m_mirrored) dir = -dir;
}
if(setprops == true) SetProperties(true);
if(setprops)
SetProperties(true);
}
#endif
@@ -560,7 +564,8 @@ return;
bool Kurve::Add(const Span& sp, bool AddNullSpans) {
// add a span, including ID
if(this->m_started == false) this->Start(sp.p0);
if(!this->m_started)
this->Start(sp.p0);
if(this->Add(sp.dir, sp.p1, sp.pc, AddNullSpans)) {
this->AddSpanID(sp.ID);
return true;
@@ -636,7 +641,7 @@ return;
void Kurve::Add(const Kurve* k, bool AddNullSpans) {
Span sp;
Matrix m;
if(this->m_unit == false) {
if(!this->m_unit) {
m = *k;
Matrix im = this->Inverse();
m.Multiply(im);
@@ -647,7 +652,8 @@ return;
#ifndef PEPSDLL
const SpanDataObject* obj = k->GetIndex(i-1);
#endif
if(this->m_unit == false) sp.Transform(m);
if(!this->m_unit)
sp.Transform(m);
if(i == 1) {
// check if this is the same as last point in kurve
@@ -722,7 +728,8 @@ return;
for(int i = 1; i <= nSpans(); i++) {
Span sp;
Get(i, sp, true);
if(igNoreNullSpans == true && sp.NullSpan == true) continue;
if(igNoreNullSpans && sp.NullSpan)
continue;
all->push_back(sp);
}
}
@@ -735,7 +742,7 @@ return;
int Kurve::Get(int vertexnumber, Point& pe, Point& pc) const {
// returns spantype with end / centre by reference
if(vertexnumber < 0 || vertexnumber >= m_nVertices) FAILURE(getMessage(L"Kurve::Get - vertexNumber out of range"));
if(m_isReversed == true) {
if(m_isReversed) {
int revVertexnumber = m_nVertices - 1 - vertexnumber;
SpanVertex* p = (SpanVertex*)m_spans[revVertexnumber / SPANSTORAGE];
int offset = revVertexnumber % SPANSTORAGE;
@@ -757,7 +764,8 @@ return;
int Kurve::GetSpanID(int vertexnumber) const {
// for spanID (wire offset)
if(vertexnumber < 0 || vertexnumber >= m_nVertices) FAILURE(getMessage(L"Kurve::Get - vertexNumber out of range"));
if(m_isReversed == true) vertexnumber = m_nVertices - 1 - vertexnumber;
if(m_isReversed)
vertexnumber = m_nVertices - 1 - vertexnumber;
SpanVertex* p = (SpanVertex*)m_spans[vertexnumber / SPANSTORAGE];
return p->GetSpanID(vertexnumber % SPANSTORAGE);
}
@@ -999,12 +1007,12 @@ return;
for(int nSpans = 0; nSpans <= this->nSpans(); nSpans++)
{
this->Get(spanno, sp, false, true);
if(spanno == startSpanno && wrapped == false) {
if(spanno == startSpanno && !wrapped) {
temp.Start(*pNewStart);
temp.Add(sp.dir, sp.p1, sp.pc, true);
}
else {
if(nSpans == this->nSpans() && this->Closed() == true) {
if(nSpans == this->nSpans() && this->Closed()) {
sp.p1 = *pNewStart;
}
temp.Add(sp, true);
@@ -1013,7 +1021,8 @@ return;
spanno++;
if(spanno > this->nSpans()) {
if(this->Closed() == false) break;
if(!this->Closed())
break;
spanno = 1;
wrapped = true;
}
@@ -1452,7 +1461,7 @@ Kurve Kurve::Part(int fromSpanno, const Point& fromPt, int toSpanno, const Point
Get(i,span,true,true);
kPart.Add(span.dir,span.p1,span.pc);
}
if(Closed() == false)
if(!Closed())
{
Get(1,span,true,true);
kPart.Add(0,span.p0,Point(0.0,0.0)); // Add new span from kend to kstart
@@ -1482,9 +1491,9 @@ Kurve Kurve::Part(int fromSpanno, const Point& fromPt, int toSpanno, const Point
Span sp;
this->Get(i, sp, true, true);
perim += sp.length;
if(fromPerim <= perim && k.m_started == false) {
if(fromPerim <= perim && !k.m_started) {
// start
if(FEQ(fromPerim, perim) == true)
if(FEQ(fromPerim, perim))
k.Start(sp.p0);
else {
double d = fromPerim - perimLast;
@@ -1494,7 +1503,7 @@ Kurve Kurve::Part(int fromSpanno, const Point& fromPt, int toSpanno, const Point
if(perim >= toPerim) {
// end
if(FEQ(toPerim, perim) == true)
if(FEQ(toPerim, perim))
k.Add(sp);
else {
double d = toPerim - perimLast;
@@ -1503,7 +1512,8 @@ Kurve Kurve::Part(int fromSpanno, const Point& fromPt, int toSpanno, const Point
}
break;
}
if(k.m_started == true) k.Add(sp);
if(k.m_started)
k.Add(sp);
perimLast = perim;
}
return k;

View File

@@ -93,7 +93,7 @@ namespace geoff_geometry {
if(spannumber > 1) {
// see if tangent
double d = curSpanOff.p0.Dist(prevSpanOff.p1);
if((d > geoff_geometry::TOLERANCE) && (curSpanOff.NullSpan == false && prevSpanOff.NullSpan == false)) {
if((d > geoff_geometry::TOLERANCE) && (!curSpanOff.NullSpan && !prevSpanOff.NullSpan)) {
// see if offset spans intersect
double cp = prevSpanOff.ve ^ curSpanOff.vs;
@@ -229,7 +229,7 @@ namespace geoff_geometry {
ksaveVertex = ksaveVertex1 ;
clipped = true ; // in a clipped section
if(DoesIntersInterfere(pInt, originalk, offset) == false) {
if(!DoesIntersInterfere(pInt, originalk, offset)) {
sp0.p1 = pInt; // ok so truncate this span to the intersection
clipped = false; // end of clipped section
break;
@@ -240,7 +240,8 @@ namespace geoff_geometry {
ksaveVertex1 = ksaveVertex2 ; // pos AA = BB
ksaveVertex2 = kinVertex; // mark
if((kinVertex > k.nSpans() || fwdCount++ > 25) && clipped == false) break;
if((kinVertex > k.nSpans() || fwdCount++ > 25) && !clipped)
break;
}
}