mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Improve performance of netlist calculations
This commit is contained in:
@@ -556,7 +556,7 @@ public class DrawingManager {
|
|||||||
return areas;
|
return areas;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expandConnections(Set<Connection> connections) {
|
public void expandConnections(Set<Connection> connections) {
|
||||||
Set<Connection> toAdd = new HashSet<Connection>();
|
Set<Connection> toAdd = new HashSet<Connection>();
|
||||||
for (Connection c1 : connections)
|
for (Connection c1 : connections)
|
||||||
for (Connection c2 : connections) {
|
for (Connection c2 : connections) {
|
||||||
@@ -596,15 +596,19 @@ public class DrawingManager {
|
|||||||
continue;
|
continue;
|
||||||
Area a1 = areas.get(i);
|
Area a1 = areas.get(i);
|
||||||
Area a2 = areas.get(j);
|
Area a2 = areas.get(j);
|
||||||
Area intersection = new Area(a1);
|
Area intersection = null;
|
||||||
intersection.intersect(a2);
|
if (a1.getBounds2D().intersects(a2.getBounds())) {
|
||||||
|
intersection = new Area(a1);
|
||||||
|
intersection.intersect(a2);
|
||||||
|
}
|
||||||
// if the two areas intersect, make a union and consume the second area
|
// if the two areas intersect, make a union and consume the second area
|
||||||
if (!intersection.isEmpty()) {
|
if (intersection != null && !intersection.isEmpty()) {
|
||||||
a1.add(a2);
|
a1.add(a2);
|
||||||
consumed.set(j, true);
|
consumed.set(j, true);
|
||||||
} else { // maybe there's a connection between them
|
} else { // maybe there's a connection between them
|
||||||
for (Connection p : connections) {
|
for (Connection p : connections) { // use getBounds to optimize the computation, don't get into complex math if not needed
|
||||||
if ((a1.contains(p.getP1()) && a2.contains(p.getP2())) || (a1.contains(p.getP2()) && a2.contains(p.getP1()))) {
|
if ((a1.getBounds().contains(p.getP1()) && a2.getBounds().contains(p.getP2()) && a1.contains(p.getP1()) && a2.contains(p.getP2())) ||
|
||||||
|
(a1.getBounds().contains(p.getP2()) && a2.getBounds().contains(p.getP1())) && a1.contains(p.getP2()) && a2.contains(p.getP1())) {
|
||||||
a1.add(a2);
|
a1.add(a2);
|
||||||
consumed.set(j, true);
|
consumed.set(j, true);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2910,7 +2910,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private List<Connection> getConnections(Map<ISwitch, Integer> switchPositions) {
|
private List<Connection> getConnections(Map<ISwitch, Integer> switchPositions) {
|
||||||
List<Connection> connections = new ArrayList<Connection>();
|
Set<Connection> connections = new HashSet<Connection>();
|
||||||
for (IDIYComponent<?> c : currentProject.getComponents()) {
|
for (IDIYComponent<?> c : currentProject.getComponents()) {
|
||||||
ComponentType type =
|
ComponentType type =
|
||||||
ComponentProcessor.getInstance().extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) c.getClass());
|
ComponentProcessor.getInstance().extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) c.getClass());
|
||||||
@@ -2932,7 +2932,9 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return connections;
|
drawingManager.expandConnections(connections);
|
||||||
|
|
||||||
|
return new ArrayList<Connection>(connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Binary file not shown.
@@ -27,7 +27,6 @@ import org.diylc.common.SimpleComponentTransformer;
|
|||||||
import org.diylc.components.AbstractLeadedComponent;
|
import org.diylc.components.AbstractLeadedComponent;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.CreationMethod;
|
import org.diylc.core.CreationMethod;
|
||||||
import org.diylc.core.IContinuity;
|
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.BomPolicy;
|
import org.diylc.core.annotations.BomPolicy;
|
||||||
@@ -42,7 +41,7 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
description = "Straight copper trace", zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW,
|
description = "Straight copper trace", zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW,
|
||||||
autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB",
|
autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB",
|
||||||
transformer = SimpleComponentTransformer.class)
|
transformer = SimpleComponentTransformer.class)
|
||||||
public class CopperTrace extends AbstractLeadedComponent<Void> implements IContinuity {
|
public class CopperTrace extends AbstractLeadedComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -168,9 +167,4 @@ public class CopperTrace extends AbstractLeadedComponent<Void> implements IConti
|
|||||||
public String getControlPointNodeName(int index) {
|
public String getControlPointNodeName(int index) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean arePointsConnected(int index1, int index2) {
|
|
||||||
return Math.abs(index1 - index2) == getControlPointCount() - 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import org.diylc.common.PCBLayer;
|
|||||||
import org.diylc.common.SimpleComponentTransformer;
|
import org.diylc.common.SimpleComponentTransformer;
|
||||||
import org.diylc.components.AbstractCurvedComponent;
|
import org.diylc.components.AbstractCurvedComponent;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IContinuity;
|
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.annotations.BomPolicy;
|
import org.diylc.core.annotations.BomPolicy;
|
||||||
@@ -41,7 +40,7 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
instanceNamePrefix = "Trace", description = "Curved copper trace with two control points",
|
instanceNamePrefix = "Trace", description = "Curved copper trace with two control points",
|
||||||
zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
|
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
|
||||||
public class CurvedTrace extends AbstractCurvedComponent<Void> implements IContinuity {
|
public class CurvedTrace extends AbstractCurvedComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -117,9 +116,4 @@ public class CurvedTrace extends AbstractCurvedComponent<Void> implements IConti
|
|||||||
public String getControlPointNodeName(int index) {
|
public String getControlPointNodeName(int index) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean arePointsConnected(int index1, int index2) {
|
|
||||||
return Math.abs(index1 - index2) == getControlPointCount() - 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -2634,6 +2634,10 @@
|
|||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Output SPICE node names in the "Nxxx" format</description>
|
<description>Output SPICE node names in the "Nxxx" format</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Improve performance of netlist calculations</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Honor "Terminal Strip" connectivity when creating a netlist</description>
|
<description>Honor "Terminal Strip" connectivity when creating a netlist</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user