Skip to content

Commit

Permalink
Reformat with WebStorm formatter, see phetsims/chipper#814
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Mar 16, 2021
1 parent f3f28bb commit 0728ce2
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 61 deletions.
100 changes: 50 additions & 50 deletions js/ops/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,44 +419,44 @@ class Graph {
needsLoop = false;

for ( let i = 0; i < this.vertices.length; i++ ) {
const vertex = this.vertices[ i ];
if ( vertex.incidentHalfEdges.length === 2 ) {
const aEdge = vertex.incidentHalfEdges[ 0 ].edge;
const bEdge = vertex.incidentHalfEdges[ 1 ].edge;
let aSegment = aEdge.segment;
let bSegment = bEdge.segment;
const aVertex = aEdge.getOtherVertex( vertex );
const bVertex = bEdge.getOtherVertex( vertex );

assert && assert( this.loops.length === 0 );

// TODO: Can we avoid this in the inner loop?
if ( aEdge.startVertex === vertex ) {
aSegment = aSegment.reversed();
}
if ( bEdge.endVertex === vertex ) {
bSegment = bSegment.reversed();
}
const vertex = this.vertices[ i ];
if ( vertex.incidentHalfEdges.length === 2 ) {
const aEdge = vertex.incidentHalfEdges[ 0 ].edge;
const bEdge = vertex.incidentHalfEdges[ 1 ].edge;
let aSegment = aEdge.segment;
let bSegment = bEdge.segment;
const aVertex = aEdge.getOtherVertex( vertex );
const bVertex = bEdge.getOtherVertex( vertex );

assert && assert( this.loops.length === 0 );

// TODO: Can we avoid this in the inner loop?
if ( aEdge.startVertex === vertex ) {
aSegment = aSegment.reversed();
}
if ( bEdge.endVertex === vertex ) {
bSegment = bSegment.reversed();
}

if ( aSegment instanceof Line && bSegment instanceof Line ) {
// See if the lines are collinear, so that we can combine them into one edge
if ( aSegment.tangentAt( 0 ).normalized().distance( bSegment.tangentAt( 0 ).normalized() ) < 1e-6 ) {
this.removeEdge( aEdge );
this.removeEdge( bEdge );
aEdge.dispose();
bEdge.dispose();
arrayRemove( this.vertices, vertex );
vertex.dispose();

const newSegment = new Line( aVertex.point, bVertex.point );
this.addEdge( new Edge( newSegment, aVertex, bVertex ) );

needsLoop = true;
break;
}
if ( aSegment instanceof Line && bSegment instanceof Line ) {
// See if the lines are collinear, so that we can combine them into one edge
if ( aSegment.tangentAt( 0 ).normalized().distance( bSegment.tangentAt( 0 ).normalized() ) < 1e-6 ) {
this.removeEdge( aEdge );
this.removeEdge( bEdge );
aEdge.dispose();
bEdge.dispose();
arrayRemove( this.vertices, vertex );
vertex.dispose();

const newSegment = new Line( aVertex.point, bVertex.point );
this.addEdge( new Edge( newSegment, aVertex, bVertex ) );

needsLoop = true;
break;
}
}
}
}
}
}

Expand Down Expand Up @@ -935,25 +935,25 @@ class Graph {
needsLoop = false;

for ( let i = this.vertices.length - 1; i >= 0; i-- ) {
const vertex = this.vertices[ i ];

if ( vertex.incidentHalfEdges.length < 2 ) {
// Disconnect any existing edges
for ( let j = 0; j < vertex.incidentHalfEdges.length; j++ ) {
const edge = vertex.incidentHalfEdges[ j ].edge;
this.removeEdge( edge );
this.replaceEdgeInLoops( edge, [] ); // remove the edge from the loops
edge.dispose();
}
const vertex = this.vertices[ i ];

if ( vertex.incidentHalfEdges.length < 2 ) {
// Disconnect any existing edges
for ( let j = 0; j < vertex.incidentHalfEdges.length; j++ ) {
const edge = vertex.incidentHalfEdges[ j ].edge;
this.removeEdge( edge );
this.replaceEdgeInLoops( edge, [] ); // remove the edge from the loops
edge.dispose();
}

// Remove the vertex
this.vertices.splice( i, 1 );
vertex.dispose();
// Remove the vertex
this.vertices.splice( i, 1 );
vertex.dispose();

needsLoop = true;
break;
}
needsLoop = true;
break;
}
}
}
assert && assert( _.every( this.edges, edge => _.includes( this.vertices, edge.startVertex ) ) );
assert && assert( _.every( this.edges, edge => _.includes( this.vertices, edge.endVertex ) ) );
Expand Down
6 changes: 3 additions & 3 deletions js/segments/Arc.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ class Arc extends Segment {
if ( this.angleDifference < Math.PI * 2 - epsilon ) {
largeArcFlag = this.angleDifference < Math.PI ? '0' : '1';
this._svgPathFragment = `A ${kite.svgNumber( this._radius )} ${kite.svgNumber( this._radius )} 0 ${largeArcFlag
} ${sweepFlag} ${kite.svgNumber( this.end.x )} ${kite.svgNumber( this.end.y )}`;
} ${sweepFlag} ${kite.svgNumber( this.end.x )} ${kite.svgNumber( this.end.y )}`;
}
else {
// circle (or almost-circle) case needs to be handled differently
Expand All @@ -638,9 +638,9 @@ class Arc extends Segment {
largeArcFlag = '0'; // since we split it in 2, it's always the small arc

const firstArc = `A ${kite.svgNumber( this._radius )} ${kite.svgNumber( this._radius )} 0 ${
largeArcFlag} ${sweepFlag} ${kite.svgNumber( splitPoint.x )} ${kite.svgNumber( splitPoint.y )}`;
largeArcFlag} ${sweepFlag} ${kite.svgNumber( splitPoint.x )} ${kite.svgNumber( splitPoint.y )}`;
const secondArc = `A ${kite.svgNumber( this._radius )} ${kite.svgNumber( this._radius )} 0 ${
largeArcFlag} ${sweepFlag} ${kite.svgNumber( this.end.x )} ${kite.svgNumber( this.end.y )}`;
largeArcFlag} ${sweepFlag} ${kite.svgNumber( this.end.x )} ${kite.svgNumber( this.end.y )}`;

this._svgPathFragment = `${firstArc} ${secondArc}`;
}
Expand Down
4 changes: 2 additions & 2 deletions js/segments/Cubic.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,8 @@ class Cubic extends Segment {
}
if ( !this._svgPathFragment ) {
this._svgPathFragment = `C ${kite.svgNumber( this._control1.x )} ${kite.svgNumber( this._control1.y )} ${
kite.svgNumber( this._control2.x )} ${kite.svgNumber( this._control2.y )} ${
kite.svgNumber( this._end.x )} ${kite.svgNumber( this._end.y )}`;
kite.svgNumber( this._control2.x )} ${kite.svgNumber( this._control2.y )} ${
kite.svgNumber( this._end.x )} ${kite.svgNumber( this._end.y )}`;
}
if ( assert ) {
if ( oldPathFragment ) {
Expand Down
10 changes: 5 additions & 5 deletions js/segments/EllipticalArc.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ class EllipticalArc extends Segment {
if ( this.getAngleDifference() < Math.PI * 2 - epsilon ) {
largeArcFlag = this.getAngleDifference() < Math.PI ? '0' : '1';
this._svgPathFragment = `A ${kite.svgNumber( this._radiusX )} ${kite.svgNumber( this._radiusY )} ${degreesRotation
} ${largeArcFlag} ${sweepFlag} ${kite.svgNumber( this.getEnd().x )} ${kite.svgNumber( this.getEnd().y )}`;
} ${largeArcFlag} ${sweepFlag} ${kite.svgNumber( this.getEnd().x )} ${kite.svgNumber( this.getEnd().y )}`;
}
else {
// ellipse (or almost-ellipse) case needs to be handled differently
Expand All @@ -807,11 +807,11 @@ class EllipticalArc extends Segment {
largeArcFlag = '0'; // since we split it in 2, it's always the small arc

const firstArc = `A ${kite.svgNumber( this._radiusX )} ${kite.svgNumber( this._radiusY )} ${
degreesRotation} ${largeArcFlag} ${sweepFlag} ${
kite.svgNumber( splitPoint.x )} ${kite.svgNumber( splitPoint.y )}`;
degreesRotation} ${largeArcFlag} ${sweepFlag} ${
kite.svgNumber( splitPoint.x )} ${kite.svgNumber( splitPoint.y )}`;
const secondArc = `A ${kite.svgNumber( this._radiusX )} ${kite.svgNumber( this._radiusY )} ${
degreesRotation} ${largeArcFlag} ${sweepFlag} ${
kite.svgNumber( this.getEnd().x )} ${kite.svgNumber( this.getEnd().y )}`;
degreesRotation} ${largeArcFlag} ${sweepFlag} ${
kite.svgNumber( this.getEnd().x )} ${kite.svgNumber( this.getEnd().y )}`;

this._svgPathFragment = `${firstArc} ${secondArc}`;
}
Expand Down
2 changes: 1 addition & 1 deletion js/segments/Quadratic.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class Quadratic extends Segment {
}
if ( !this._svgPathFragment ) {
this._svgPathFragment = `Q ${kite.svgNumber( this._control.x )} ${kite.svgNumber( this._control.y )} ${
kite.svgNumber( this._end.x )} ${kite.svgNumber( this._end.y )}`;
kite.svgNumber( this._end.x )} ${kite.svgNumber( this._end.y )}`;
}
if ( assert ) {
if ( oldPathFragment ) {
Expand Down

0 comments on commit 0728ce2

Please sign in to comment.