Skip to content

Commit

Permalink
Attempting a holistic fix for the various circle setups
Browse files Browse the repository at this point in the history
  • Loading branch information
Gutza committed Jan 2, 2021
1 parent ef0dce9 commit cd530ae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
12 changes: 7 additions & 5 deletions src/RegionEngineBL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,14 @@ export class RegionEngineBL {
// (5/5)
protected refreshRegions = (cycles: IGraphCycle[]): void => {
this._circles.forEach(circle => {
const isRegion = circle.vertices.length === 0;
if (isRegion && !this._regions.includes(circle.innerContour)) {
this._regions.push(circle.innerContour);
this.emit(EDrawableEventType.add, circle.innerContour);
if (circle.vertices.length === 0) {
circle.isExposed = circle.isEmpty = true;
}
if ((isRegion || circle.isOuterContour) && !this._regions.includes(circle.outerContour)) {
if (circle.isEmpty && !this._regions.includes(circle.innerRegion)) {
this._regions.push(circle.innerRegion);
this.emit(EDrawableEventType.add, circle.innerRegion);
}
if (circle.isExposed && !this._regions.includes(circle.outerContour)) {
this._regions.push(circle.outerContour);
this.emit(EDrawableEventType.add, circle.outerContour);
}
Expand Down
28 changes: 13 additions & 15 deletions src/geometry/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ export class Circle extends PureGeometry implements IRegion, IDrawable {
private _sortedVertices: boolean = true;

/**
* This is a stand-alone circle, and it should be rendered as two
* distinct regions: a complete inner contour, and a complete outer contour.
* This circle is completely empty: none if its points are shared with
* any other circle on the inside.
*/
public isRegion = false;
public isEmpty = false;

/**
* This circle is the outer contour of a region set which contains
* other regions inside (i.e. this is the largest inner tangent circle
* in an otherwise stand-alone configuration). As such, it should only
* be rendered as an outer contour.
* This circle is completely exposed to the universe: none of its points
* are shared with any other circle on the outside.
*/
public isOuterContour: boolean = false;
public isExposed: boolean = false;

public id: any;
private _internalId: number;
Expand Down Expand Up @@ -97,7 +95,7 @@ export class Circle extends PureGeometry implements IRegion, IDrawable {
*/
public setStale = () => {
this.isStale = true;
this.isOuterContour = false;
this.isExposed = false;
}

public onCenterMove = () => {
Expand Down Expand Up @@ -194,7 +192,7 @@ export class Circle extends PureGeometry implements IRegion, IDrawable {
this._bbox = undefined;
this._roundedBbox = undefined;
this._zeroPoint = undefined;
this._innerContour = undefined;
this._innerRegion = undefined;
this._outerContour = undefined;
this._vertices = [];
this.setStale();
Expand Down Expand Up @@ -330,13 +328,13 @@ export class Circle extends PureGeometry implements IRegion, IDrawable {
new CircleArc(this, 0, 0, this.zeroPoint, this.zeroPoint, isClockwise)
);

private _innerContour?: ArcPolygon;
public get innerContour(): ArcPolygon {
if (this._innerContour !== undefined) {
return this._innerContour;
private _innerRegion?: ArcPolygon;
public get innerRegion(): ArcPolygon {
if (this._innerRegion !== undefined) {
return this._innerRegion;
}

return this._innerContour = new ArcPolygon(
return this._innerRegion = new ArcPolygon(
[this._getContour(false)],
ERegionType.region
);
Expand Down
9 changes: 7 additions & 2 deletions src/topology/GraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,13 @@ export default class GraphNode {
throw new Error("Multiple vertex circle with a single edge");
}

if (isTangencyContour && currentDirection === ETraversalDirection.backward) {
currentEdge.circle.isOuterContour = true;
if (isTangencyContour) {
const thisCircle = currentEdge.circle;
if (currentDirection === ETraversalDirection.backward) {
thisCircle.isExposed = true;
} else {
thisCircle.isExposed = true;
}
}
}

Expand Down

0 comments on commit cd530ae

Please sign in to comment.