diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 36dc7a0..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-freerouting.freerouting
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index e206d70..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/.idea/libraries/java_help.xml b/.idea/libraries/java_help.xml
deleted file mode 100644
index 7e583ce..0000000
--- a/.idea/libraries/java_help.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/javaws.xml b/.idea/libraries/javaws.xml
deleted file mode 100644
index 35528bd..0000000
--- a/.idea/libraries/javaws.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
deleted file mode 100644
index 922003b..0000000
--- a/.idea/scopes/scope_settings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index f6cd5ef..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,487 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- localhost
- 5050
-
-
-
-
-
-
-
-
-
- 1403984491365
- 1403984491365
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No facets are configured
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1.7
-
-
-
-
-
-
-
-
-
-
-
- freerouting.freerouting
-
-
-
-
-
-
-
-
-
-
-
- javaws
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/LICENSE b/LICENSE
index 70566f2..7d75849 100644
--- a/LICENSE
+++ b/LICENSE
@@ -100,7 +100,7 @@ public, and in some countries other activities as well.
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
- An interactive user interface displays "Appropriate Legal Notices"
+ An eu.mihosoft.freerouting.interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
@@ -227,8 +227,8 @@ terms of section 4, provided that you also meet all of these conditions:
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
+ d) If the work has eu.mihosoft.freerouting.interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has eu.mihosoft.freerouting.interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
@@ -331,7 +331,7 @@ requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
+adversely affects the operation of the network or violates the eu.mihosoft.freerouting.rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
@@ -650,7 +650,7 @@ the "copyright" line and a pointer to where the full notice is found.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
+notice like this when it starts in an eu.mihosoft.freerouting.interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
@@ -667,8 +667,8 @@ For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
+into proprietary programs. If your program is a subroutine eu.mihosoft.freerouting.library, you
may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
+the eu.mihosoft.freerouting.library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
\ No newline at end of file
diff --git a/README.md b/README.md
index 8364010..d28c1c2 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ Java Based Printed Circuit Board Routing Software from FreeRouting.net written b
http://www.freerouting.net/fen/viewtopic.php?f=4&t=255
-by alfons » Sat Mar 08, 2014 12:07 pm
+by alfons � Sat Mar 08, 2014 12:07 pm
Because I am no more maintaining the Freerouting project since 4 years and future Java versions may block my Freerouting Java Web Start application completely, I finally decided to open the source of the Freerouting project under the GNU public license version 3.
@@ -37,21 +37,21 @@ Introduction:
This software can be used together with all host PCB design software systems containing a standard Specctra or Electra DSN interface. It imports .dsn-files generated by the Specctra interface of the host system and exports Specctra session files.(There exists also an interface to Cadsoft-Eagle.)
-There are three modes for routing traces: 90 degree, 45 degree and free angle. The interactive router is production stable and unsurpassed in its free angle capabilities. An autorouter is currently under development and already stable in the conventional 45 degree mode.
+There are three modes for routing traces: 90 degree, 45 degree and free angle. The eu.mihosoft.freerouting.interactive router is production stable and unsurpassed in its free angle capabilities. An autorouter is currently under development and already stable in the conventional 45 degree mode.
After launching the router a window appears with buttons to display some router demonstrations, to open a sample design, or to open a design of your own.
-After opening a design you can start the autorouter with the button in the toolbar on top of the board window.
+After opening a design you can start the autorouter with the button in the toolbar on top of the eu.mihosoft.freerouting.board window.
-The board editor has three different interactive states. You can switch between this states with the buttons Select, Route and Drag on the left of the toolbar.
+The eu.mihosoft.freerouting.board editor has three different eu.mihosoft.freerouting.interactive states. You can switch between this states with the buttons Select, Route and Drag on the left of the toolbar.
-In the beginning the board editor is in the select state. In this state you can select single board items by picking them with the left mouse button or select items in a rectangle by dragging the left mouse button. Only item types switched on in the select parameter sheet will be selected. After selecting some items the toolbar displays options for showing and manipulating these items. If you push the info button for example a window with text information about the selected items is displayed. After clicking a blue word in this text a new window with further information pops up. To return to the select state push the cancel button or click somewhere in the empty space of the board window.
+In the beginning the eu.mihosoft.freerouting.board editor is in the select state. In this state you can select single eu.mihosoft.freerouting.board items by picking them with the left mouse button or select items in a rectangle by dragging the left mouse button. Only item types switched on in the select parameter sheet will be selected. After selecting some items the toolbar displays options for showing and manipulating these items. If you push the info button for example a window with text information about the selected items is displayed. After clicking a blue word in this text a new window with further information pops up. To return to the select state push the cancel button or click somewhere in the empty space of the eu.mihosoft.freerouting.board window.
-By pushing the Route button you get into the state for interactive routing. In this state you can start a new trace by picking an item belonging to a net, for example a pin. Then you can follow the displayed airline with the mouse until you have reached the target item at the other end of the airline. The trace will be connected automatically to the target, if it is on the same layer. If you want to change to a different layer during interactive routing, select "change layer" and then the name of the new layer in the popup menu under the right mouse button. Then a via will be inserted, if that is possible, and a new trace starts on the new layer. You can also change the layer by pressing a number key.
+By pushing the Route button you get into the state for eu.mihosoft.freerouting.interactive routing. In this state you can start a new trace by picking an item belonging to a net, for example a pin. Then you can follow the displayed airline with the mouse until you have reached the target item at the other end of the airline. The trace will be connected automatically to the target, if it is on the same layer. If you want to change to a different layer during eu.mihosoft.freerouting.interactive routing, select "change layer" and then the name of the new layer in the popup menu under the right mouse button. Then a via will be inserted, if that is possible, and a new trace starts on the new layer. You can also change the layer by pressing a number key.
After pushing the Drag button you get into the state for changing the location of vias, components or traces. In this state you can select vias or components and drag them with the left mouse button to a different location. The connected route is updated automatically. You can also move traces by pushing them from behind out of the empty space with the left mouse button pressed. That works on the current layer, which can be changed in the select parameter sheet. In this way you can make space for example to insert a new component.
-For more information please use the online help in the board editor. From here you can download also a printable version of the online help.
+For more information please use the online help in the eu.mihosoft.freerouting.board editor. From here you can download also a printable version of the online help.
If you have further questions or want some feedback, please sent an Email to support@ FreeRouting.net or visit our forum.
@@ -84,7 +84,7 @@ Here are some instructions how to run the Freerouting project in the NetBeans ID
5) Build your new project in NetBeans.
-6) To get rid of the undefined's download and unzip the attached library jh.jar. It is the system library of the Java Help system.
+6) To get rid of the undefined's download and unzip the attached eu.mihosoft.freerouting.library jh.jar. It is the system eu.mihosoft.freerouting.library of the Java Help system.
7) Right click on the name of your new project on the left of NetBeans and select Properties.
@@ -94,6 +94,6 @@ Here are some instructions how to run the Freerouting project in the NetBeans ID
10) Build the project again. The router should run now.
-For optional parameters of the Freerouting outfile check the usage of the variable p_args in the source file gui/MainApplication.java.
+For optional parameters of the Freerouting outfile check the usage of the variable p_args in the source file eu.mihosoft.freerouting.gui/MainApplication.java.
diff --git a/launch4j.xml b/launch4j.xml
index 9cd7d47..24c5a71 100644
--- a/launch4j.xml
+++ b/launch4j.xml
@@ -1,7 +1,7 @@
false
- gui
+ eu.mihosoft.freerouting.gui
F:\stuff\freerouting.freerouting\build\FreeRouting.jar
FreeRouting.exe
diff --git a/lib/jh.jar b/lib/jh.jar
deleted file mode 100644
index 185d942..0000000
Binary files a/lib/jh.jar and /dev/null differ
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/AutorouteSettings.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/AutorouteSettings.java
deleted file mode 100644
index cb79e0b..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/AutorouteSettings.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * AutorouteSettings.java
- *
- * Created on 1. Maerz 2007, 07:10
- *
- */
-package designformats.specctra;
-
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-/**
- *
- * @author Alfons Wirtz
- */
-public class AutorouteSettings
-{
-
- static interactive.AutorouteSettings read_scope(Scanner p_scanner, LayerStructure p_layer_structure)
- {
- interactive.AutorouteSettings result = new interactive.AutorouteSettings(p_layer_structure.arr.length);
- boolean with_fanout = false;
- boolean with_autoroute = true;
- boolean with_postroute = true;
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_scanner.next_token();
- } catch (java.io.IOException e)
- {
- System.out.println("AutorouteSettings.read_scope: IO error scanning file");
- return null;
- }
- if (next_token == null)
- {
- System.out.println("AutorouteSettings.read_scope: unexpected end of file");
- return null;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.FANOUT)
- {
- with_fanout = DsnFile.read_on_off_scope(p_scanner);
- }
- else if (next_token == Keyword.AUTOROUTE)
- {
- with_autoroute = DsnFile.read_on_off_scope(p_scanner);
- }
- else if (next_token == Keyword.POSTROUTE)
- {
- with_postroute = DsnFile.read_on_off_scope(p_scanner);
- }
- else if (next_token == Keyword.VIAS)
- {
- result.set_vias_allowed(DsnFile.read_on_off_scope(p_scanner));
- }
- else if (next_token == Keyword.VIA_COSTS)
- {
- result.set_via_costs(DsnFile.read_integer_scope(p_scanner));
- }
- else if (next_token == Keyword.PLANE_VIA_COSTS)
- {
- result.set_plane_via_costs(DsnFile.read_integer_scope(p_scanner));
- }
- else if (next_token == Keyword.START_RIPUP_COSTS)
- {
- result.set_start_ripup_costs(DsnFile.read_integer_scope(p_scanner));
- }
- else if (next_token == Keyword.START_PASS_NO)
- {
- result.set_pass_no(DsnFile.read_integer_scope(p_scanner));
- }
- else if (next_token == Keyword.LAYER_RULE)
- {
- result = read_layer_rule(p_scanner, p_layer_structure, result);
- if (result == null)
- {
- return null;
- }
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- }
- }
- result.set_with_fanout(with_fanout);
- result.set_with_autoroute(with_autoroute);
- result.set_with_postroute(with_postroute);
- return result;
- }
-
- static interactive.AutorouteSettings read_layer_rule(Scanner p_scanner, LayerStructure p_layer_structure,
- interactive.AutorouteSettings p_settings)
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- Object next_token;
- try
- {
- next_token = p_scanner.next_token();
- } catch (java.io.IOException e)
- {
- System.out.println("AutorouteSettings.read_layer_rule: IO error scanning file");
- return null;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("AutorouteSettings.read_layer_rule: String expected");
- return null;
- }
- int layer_no = p_layer_structure.get_no((String) next_token);
- if (layer_no < 0)
- {
- System.out.println("AutorouteSettings.read_layer_rule: layer not found");
- return null;
- }
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_scanner.next_token();
- } catch (java.io.IOException e)
- {
- System.out.println("AutorouteSettings.read_layer_rule: IO error scanning file");
- return null;
- }
- if (next_token == null)
- {
- System.out.println("AutorouteSettings.read_layer_rule: unexpected end of file");
- return null;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.ACTIVE)
- {
- p_settings.set_layer_active(layer_no, DsnFile.read_on_off_scope(p_scanner));
- }
- else if (next_token == Keyword.PREFERRED_DIRECTION)
- {
- try
- {
- boolean pref_dir_is_horizontal = true;
- next_token = p_scanner.next_token();
- if (next_token == Keyword.VERTICAL)
- {
- pref_dir_is_horizontal = false;
- }
- else if (next_token != Keyword.HORIZONTAL)
- {
- System.out.println("AutorouteSettings.read_layer_rule: unexpected key word");
- return null;
- }
- p_settings.set_preferred_direction_is_horizontal(layer_no, pref_dir_is_horizontal);
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("AutorouteSettings.read_layer_rule: uclosing bracket expected");
- return null;
- }
- } catch (java.io.IOException e)
- {
- System.out.println("AutorouteSettings.read_layer_rule: IO error scanning file");
- return null;
- }
- }
- else if (next_token == Keyword.PREFERRED_DIRECTION_TRACE_COSTS)
- {
- p_settings.set_preferred_direction_trace_costs(layer_no, DsnFile.read_float_scope(p_scanner));
- }
- else if (next_token == Keyword.AGAINST_PREFERRED_DIRECTION_TRACE_COSTS)
- {
- p_settings.set_against_preferred_direction_trace_costs(layer_no, DsnFile.read_float_scope(p_scanner));
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- }
- }
- return p_settings;
- }
-
- static void write_scope(IndentFileWriter p_file, interactive.AutorouteSettings p_settings,
- board.LayerStructure p_layer_structure, IdentifierType p_identifier_type) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("autoroute_settings");
- p_file.new_line();
- p_file.write("(fanout ");
- if (p_settings.get_with_fanout())
- {
- p_file.write("on)");
- }
- else
- {
- p_file.write("off)");
- }
- p_file.new_line();
- p_file.write("(autoroute ");
- if (p_settings.get_with_autoroute())
- {
- p_file.write("on)");
- }
- else
- {
- p_file.write("off)");
- }
- p_file.new_line();
- p_file.write("(postroute ");
- if (p_settings.get_with_postroute())
- {
- p_file.write("on)");
- }
- else
- {
- p_file.write("off)");
- }
- p_file.new_line();
- p_file.write("(vias ");
- if (p_settings.get_vias_allowed())
- {
- p_file.write("on)");
- }
- else
- {
- p_file.write("off)");
- }
- p_file.new_line();
- p_file.write("(via_costs ");
- {
- Integer via_costs = p_settings.get_via_costs();
- p_file.write(via_costs.toString());
- }
- p_file.write(")");
- p_file.new_line();
- p_file.write("(plane_via_costs ");
- {
- Integer via_costs = p_settings.get_plane_via_costs();
- p_file.write(via_costs.toString());
- }
- p_file.write(")");
- p_file.new_line();
- p_file.write("(start_ripup_costs ");
- {
- Integer ripup_costs = p_settings.get_start_ripup_costs();
- p_file.write(ripup_costs.toString());
- }
- p_file.write(")");
- p_file.new_line();
- p_file.write("(start_pass_no ");
- {
- Integer pass_no = p_settings.get_pass_no();
- p_file.write(pass_no.toString());
- }
- p_file.write(")");
- for (int i = 0; i < p_layer_structure.arr.length; ++i)
- {
- board.Layer curr_layer = p_layer_structure.arr[i];
- p_file.start_scope();
- p_file.write("layer_rule ");
- p_identifier_type.write(curr_layer.name, p_file);
- p_file.new_line();
- p_file.write("(active ");
- if (p_settings.get_layer_active(i))
- {
- p_file.write("on)");
- }
- else
- {
- p_file.write("off)");
- }
- p_file.new_line();
- p_file.write("(preferred_direction ");
- if (p_settings.get_preferred_direction_is_horizontal(i))
- {
- p_file.write("horizontal)");
- }
- else
- {
- p_file.write("vertical)");
- }
- p_file.new_line();
- p_file.write("(preferred_direction_trace_costs ");
- Float trace_costs = (float) p_settings.get_preferred_direction_trace_costs(i);
- p_file.write(trace_costs.toString());
- p_file.write(")");
- p_file.new_line();
- p_file.write("(against_preferred_direction_trace_costs ");
- trace_costs = (float) p_settings.get_against_preferred_direction_trace_costs(i);
- p_file.write(trace_costs.toString());
- p_file.write(")");
- p_file.end_scope();
- }
- p_file.end_scope();
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Circle.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Circle.java
deleted file mode 100644
index 81c08e8..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Circle.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Circle.java
- *
- * Created on 20. Mai 2004, 09:22
- */
-
-package designformats.specctra;
-
-import geometry.planar.IntPoint;
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-/**
- * Class for reading and writing circle scopes from dsn-files.
- *
- * @author alfons
- */
-public class Circle extends Shape
-{
- /**
- * Creates a new circle from the input parameters.
- * p_coor is an array of dimension 3.
- * p_coor [0] is the radius of the circle,
- * p_coor [1] is the x coordinate of the circle,
- * p_coor [2] is the y coordinate of the circle.
- */
- public Circle(Layer p_layer, double [] p_coor)
- {
- super(p_layer);
- coor = p_coor;
- }
-
- public Circle(Layer p_layer, double p_radius, double p_center_x, double p_center_y)
- {
- super(p_layer);
- coor = new double[3];
- coor[0] = p_radius;
- coor[1] = p_center_x;
- coor[2] = p_center_y;
- }
-
- public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform)
- {
- double [] location = new double[2];
- location[0] = coor[1];
- location[1] = coor[2];
- IntPoint center = p_coordinate_transform.dsn_to_board(location).round();
- int radius = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[0]) / 2);
- return new geometry.planar.Circle(center, radius);
- }
-
- public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform)
- {
- int [] new_coor = new int[3];
- new_coor[0] = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[0]) / 2);
- for (int i = 1; i < 3; ++i)
- {
- new_coor[i] = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[i]));
- }
- return new geometry.planar.Circle(new IntPoint(new_coor[1], new_coor[2]), new_coor[0]);
- }
-
- public Rectangle bounding_box()
- {
- double[] bounds = new double[4];
- bounds[0] = coor[1] - coor[0];
- bounds[1] = coor[2] - coor[0];
- bounds[2] = coor[1] + coor[0];
- bounds[3] = coor[2] + coor[0];
- return new Rectangle(layer, bounds);
- }
-
- public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException
- {
- p_file.new_line();
- p_file.write("(circle ");
- p_identifier_type.write(this.layer.name, p_file);
- for (int i = 0; i < coor.length; ++i)
- {
- p_file.write(" ");
- p_file.write(new Double(coor[i]).toString());
- }
- p_file.write(")");
- }
-
- public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException
- {
- p_file.new_line();
- p_file.write("(circle ");
- p_identifier_type.write(this.layer.name, p_file);
- for (int i = 0; i < coor.length; ++i)
- {
- p_file.write(" ");
- Integer curr_coor = (int) Math.round(coor[i]);
- p_file.write(curr_coor.toString());
- }
- p_file.write(")");
- }
-
- public final double[] coor;
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Circuit.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Circuit.java
deleted file mode 100644
index f2c126b..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Circuit.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Circuit.java
- *
- * Created on 30. Mai 2005, 06:30
- *
- */
-
-package designformats.specctra;
-
-/**
- *
- * @author Alfons Wirtz
- */
-public class Circuit
-{
- /**
- * Currently only the length matching rule is read from a circuit scope.
- * If the scope does not contain a length matching rule, nulll is returned.
- */
- public static ReadScopeResult read_scope( Scanner p_scanner)
- {
- Object next_token = null;
- double min_trace_length = 0;
- double max_trace_length = 0;
- java.util.Collection use_via = new java.util.LinkedList();
- java.util.Collection use_layer = new java.util.LinkedList();
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("Circuit.read_scope: IO error scanning file");
- return null;
- }
- if (next_token == null)
- {
- System.out.println("Circuit.read_scope: unexpected end of file");
- return null;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.LENGTH)
- {
- LengthMatchingRule length_rule = read_length_scope(p_scanner);
- if (length_rule != null)
- {
- min_trace_length = length_rule.min_length;
- max_trace_length = length_rule.max_length;
- }
- }
- else if (next_token == Keyword.USE_VIA)
- {
- use_via.addAll(Structure.read_via_padstacks(p_scanner));
- }
- else if (next_token == Keyword.USE_LAYER)
- {
- use_layer.addAll(DsnFile.read_string_list_scope(p_scanner));
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- }
- }
- return new ReadScopeResult(max_trace_length, min_trace_length, use_via, use_layer);
- }
-
- static LengthMatchingRule read_length_scope( Scanner p_scanner)
- {
- LengthMatchingRule result = null;
- double[] length_arr = new double[2];
- Object next_token = null;
- for (int i = 0; i < 2; ++i)
- {
- try
- {
- next_token = p_scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("Circuit.read_length_scope: IO error scanning file");
- return null;
- }
- if (next_token instanceof Double)
- {
- length_arr[i] = ((Double) next_token).doubleValue();
- }
- else if (next_token instanceof Integer)
- {
- length_arr[i] = ((Integer) next_token).intValue();
- }
- else
- {
- System.out.println("Circuit.read_length_scope: number expected");
- return null;
- }
- }
- result = new LengthMatchingRule(length_arr[0], length_arr[1]);
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("Circuit.read_length_scope: IO error scanning file");
- return null;
- }
- if (next_token == null)
- {
- System.out.println("Circuit.read_length_scope: unexpected end of file");
- return null;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- }
- return result;
- }
-
- /** A max_length of -1 indicates, tha no maximum length is defined. */
- public static class ReadScopeResult
- {
- public ReadScopeResult(double p_max_length, double p_min_length, java.util.Collection p_use_via, java.util.Collection p_use_layer)
- {
- max_length = p_max_length;
- min_length = p_min_length;
- use_via = p_use_via;
- use_layer = p_use_layer;
- }
-
- public final double max_length;
- public final double min_length;
- public final java.util.Collection use_via;
- public final java.util.Collection use_layer;
- }
-
- /** A max_length of -1 indicates, tha no maximum length is defined. */
- private static class LengthMatchingRule
- {
- public LengthMatchingRule(double p_max_length, double p_min_length)
- {
- max_length = p_max_length;
- min_length = p_min_length;
- }
-
- public final double max_length;
- public final double min_length;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Component.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Component.java
deleted file mode 100644
index 7e35641..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Component.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Component.java
- *
- * Created on 20. Mai 2004, 07:32
- */
-
-package designformats.specctra;
-
-
-/**
- * Handels the placement bata of a library component.
- *
- * @author alfons
- */
-public class Component extends ScopeKeyword
-{
-
- /** Creates a new instance of Component */
- public Component()
- {
- super("component");
- }
-
- /**
- * Overwrites the function read_scope in ScopeKeyword
- */
- public boolean read_scope(ReadScopeParameter p_par)
- {
- try
- {
- ComponentPlacement component_placement = read_scope(p_par.scanner);
- if(component_placement == null)
- {
- return false;
- }
- p_par.placement_list.add(component_placement);
- }
- catch (java.io.IOException e)
- {
- System.out.println("Component.read_scope: IO error scanning file");
- return false;
- }
- return true;
- }
-
- /**
- * Used also when reading a session file.
- */
- public static ComponentPlacement read_scope(Scanner p_scanner) throws java.io.IOException
- {
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Component.read_scope: component name expected");
- return null;
- }
- String name = (String) next_token;
- ComponentPlacement component_placement = new ComponentPlacement(name);
- Object prev_token = next_token;
- next_token = p_scanner.next_token();
- while ( next_token != Keyword.CLOSED_BRACKET)
- {
- if (prev_token == Keyword.OPEN_BRACKET && next_token == Keyword.PLACE)
- {
- ComponentPlacement.ComponentLocation next_location = read_place_scope(p_scanner);
- if (next_location != null)
- {
- component_placement.locations.add(next_location);
- }
- }
- prev_token = next_token;
- next_token = p_scanner.next_token();
- }
- return component_placement;
- }
-
- public static void write_scope(WriteScopeParameter p_par, board.Component p_component)
- throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("place ");
- p_par.file.new_line();
- p_par.identifier_type.write(p_component.name, p_par.file);
- if (p_component.is_placed())
- {
- double [] coor = p_par.coordinate_transform.board_to_dsn(p_component.get_location().to_float());
- for (int i = 0; i < coor.length; ++i)
- {
- p_par.file.write(" ");
- p_par.file.write((new Double(coor[i])).toString());
- }
- if (p_component.placed_on_front())
- {
- p_par.file.write(" front ");
- }
- else
- {
- p_par.file.write(" back ");
- }
- int rotation = (int) Math.round(p_component.get_rotation_in_degree());
- p_par.file.write((new Integer(rotation).toString()));
- }
- if (p_component.position_fixed)
- {
- p_par.file.new_line();
- p_par.file.write(" (lock_type position)");
- }
- int pin_count = p_component.get_package().pin_count();
- for (int i = 0; i < pin_count; ++i)
- {
- write_pin_info(p_par, p_component, i);
- }
- write_keepout_infos(p_par, p_component);
- p_par.file.end_scope();
- }
-
- private static void write_pin_info(WriteScopeParameter p_par, board.Component p_component, int p_pin_no)
- throws java.io.IOException
- {
- if (!p_component.is_placed())
- {
- return;
- }
- library.Package.Pin package_pin = p_component.get_package().get_pin(p_pin_no);
- if (package_pin == null)
- {
- System.out.println("Component.write_pin_info: package pin not found");
- return;
- }
- board.Pin component_pin = p_par.board.get_pin(p_component.no, p_pin_no);
- if (component_pin == null)
- {
- System.out.println("Component.write_pin_info: component pin not found");
- return;
- }
- String cl_class_name = p_par.board.rules.clearance_matrix.get_name(component_pin.clearance_class_no());
- if (cl_class_name == null)
- {
- System.out.println("Component.write_pin_info: clearance class name not found");
- return;
- }
- p_par.file.new_line();
- p_par.file.write("(pin ");
- p_par.identifier_type.write(package_pin.name, p_par.file);
- p_par.file.write(" (clearance_class ");
- p_par.identifier_type.write(cl_class_name, p_par.file);
- p_par.file.write("))");
- }
-
- private static void write_keepout_infos(WriteScopeParameter p_par, board.Component p_component)
- throws java.io.IOException
- {
- if (!p_component.is_placed())
- {
- return;
- }
- library.Package.Keepout[] curr_keepout_arr;
- String keepout_type;
- for (int j = 0; j < 3; ++j)
- {
- if (j == 0)
- {
- curr_keepout_arr = p_component.get_package().keepout_arr;
- keepout_type = "(keepout ";
- }
- else if (j == 1)
- {
- curr_keepout_arr = p_component.get_package().via_keepout_arr;
- keepout_type = "(via_keepout ";
- }
- else
- {
- curr_keepout_arr = p_component.get_package().place_keepout_arr;
- keepout_type = "(place_keepout ";
- }
- for (int i = 0; i < curr_keepout_arr.length; ++i)
- {
- library.Package.Keepout curr_keepout = curr_keepout_arr[i];
- board.ObstacleArea curr_obstacle_area = get_keepout(p_par.board, p_component.no, curr_keepout.name);
- if (curr_obstacle_area == null || curr_obstacle_area.clearance_class_no() == 0)
- {
- continue;
- }
- String cl_class_name = p_par.board.rules.clearance_matrix.get_name(curr_obstacle_area.clearance_class_no());
- if (cl_class_name == null)
- {
- System.out.println("Component.write_keepout_infos: clearance class name not found");
- return;
- }
- p_par.file.new_line();
- p_par.file.write(keepout_type);
- p_par.identifier_type.write(curr_keepout.name, p_par.file);
- p_par.file.write(" (clearance_class ");
- p_par.identifier_type.write(cl_class_name, p_par.file);
- p_par.file.write("))");
- }
- }
- }
-
- private static board.ObstacleArea get_keepout(board.BasicBoard p_board, int p_component_no, String p_name)
- {
- java.util.Iterator it = p_board.item_list.start_read_object();
- for(;;)
- {
- board.Item curr_item = (board.Item)p_board.item_list.read_object(it);
- if (curr_item == null)
- {
- break;
- }
- if (curr_item.get_component_no() == p_component_no && curr_item instanceof board.ObstacleArea)
- {
- board.ObstacleArea curr_area = (board.ObstacleArea) curr_item;
- if (curr_area.name != null && curr_area.name.equals(p_name))
- {
- return curr_area;
- }
- }
- }
- return null;
- }
-
-
-
- private static ComponentPlacement.ComponentLocation read_place_scope(Scanner p_scanner)
- {
- try
- {
- java.util.Map pin_infos =
- new java.util.TreeMap();
- java.util.Map keepout_infos =
- new java.util.TreeMap();
- java.util.Map via_keepout_infos =
- new java.util.TreeMap();
- java.util.Map place_keepout_infos =
- new java.util.TreeMap();
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Component.read_place_scope: String expected");
- return null;
- }
- String name = (String) next_token;
- double[] location = new double[2];
- for (int i = 0; i < 2; ++i)
- {
- next_token = p_scanner.next_token();
- if (next_token instanceof Double)
- {
- location[i] = ((Double) next_token).doubleValue();
- }
- else if (next_token instanceof Integer)
- {
- location[i] = ((Integer) next_token).intValue();
- }
- else if (next_token == Keyword.CLOSED_BRACKET)
- {
- // component is not yet placed
- return new ComponentPlacement.ComponentLocation(name, null, true, 0, false, pin_infos,
- keepout_infos, via_keepout_infos, place_keepout_infos);
- }
- else
- {
- System.out.println("Component.read_place_scope: number expected");
- return null;
- }
- }
- next_token = p_scanner.next_token();
- boolean is_front = true;
- if (next_token == Keyword.BACK)
- {
- is_front = false;
- }
- else if (next_token != Keyword.FRONT)
- {
- System.out.println("Component.read_place_scope: Keyword.FRONT expected");
- }
- double rotation;
- next_token = p_scanner.next_token();
- if (next_token instanceof Double)
- {
- rotation = ((Double) next_token).doubleValue();
- }
- else if (next_token instanceof Integer)
- {
- rotation = ((Integer) next_token).intValue();
- }
- else
- {
- System.out.println("Component.read_place_scope: number expected");
- return null;
- }
- boolean position_fixed = false;
- next_token = p_scanner.next_token();
- while (next_token == Keyword.OPEN_BRACKET)
- {
- next_token = p_scanner.next_token();
- if (next_token == Keyword.LOCK_TYPE)
- {
- position_fixed = read_lock_type(p_scanner);
- }
- else if (next_token == Keyword.PIN)
- {
- ComponentPlacement.ItemClearanceInfo curr_pin_info = read_item_clearance_info(p_scanner);
- if (curr_pin_info == null)
- {
- return null;
- }
- pin_infos.put(curr_pin_info.name, curr_pin_info);
- }
- else if (next_token == Keyword.KEEPOUT)
- {
- ComponentPlacement.ItemClearanceInfo curr_keepout_info = read_item_clearance_info(p_scanner);
- if (curr_keepout_info == null)
- {
- return null;
- }
- keepout_infos.put(curr_keepout_info.name, curr_keepout_info);
- }
- else if (next_token == Keyword.VIA_KEEPOUT)
- {
- ComponentPlacement.ItemClearanceInfo curr_keepout_info = read_item_clearance_info(p_scanner);
- if (curr_keepout_info == null)
- {
- return null;
- }
- via_keepout_infos.put(curr_keepout_info.name, curr_keepout_info);
- }
- else if (next_token == Keyword.PLACE_KEEPOUT)
- {
- ComponentPlacement.ItemClearanceInfo curr_keepout_info = read_item_clearance_info(p_scanner);
- if (curr_keepout_info == null)
- {
- return null;
- }
- place_keepout_infos.put(curr_keepout_info.name, curr_keepout_info);
- }
- else
- {
- skip_scope(p_scanner);
- }
- next_token = p_scanner.next_token();
- }
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Component.read_place_scope: ) expected");
- return null;
- }
- ComponentPlacement.ComponentLocation result =
- new ComponentPlacement.ComponentLocation(name, location, is_front, rotation, position_fixed, pin_infos,
- keepout_infos, via_keepout_infos, place_keepout_infos);
- return result;
- }
- catch (java.io.IOException e)
- {
- System.out.println("Component.read_scope: IO error scanning file");
- System.out.println(e);
- return null;
- }
- }
-
- private static ComponentPlacement.ItemClearanceInfo read_item_clearance_info(Scanner p_scanner) throws java.io.IOException
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Component.read_item_clearance_info: String expected");
- return null;
- }
- String name = (String) next_token;
- String cl_class_name = null;
- next_token = p_scanner.next_token();
- while (next_token == Keyword.OPEN_BRACKET)
- {
- next_token = p_scanner.next_token();
- if (next_token == Keyword.CLEARANCE_CLASS)
- {
- cl_class_name = DsnFile.read_string_scope(p_scanner);
- }
- else
- {
- skip_scope(p_scanner);
- }
- next_token = p_scanner.next_token();
- }
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Component.read_item_clearance_info: ) expected");
- return null;
- }
- if (cl_class_name == null)
- {
- System.out.println("Component.read_item_clearance_info: clearance class name not found");
- return null;
- }
- return new ComponentPlacement.ItemClearanceInfo(name, cl_class_name);
- }
-
- private static boolean read_lock_type(Scanner p_scanner) throws java.io.IOException
- {
- boolean result = false;
- for (;;)
- {
- Object next_token = p_scanner.next_token();
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- break;
- }
- if (next_token == Keyword.POSITION)
- {
- result = true;
- }
- }
- return result;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/ComponentPlacement.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/ComponentPlacement.java
deleted file mode 100644
index 3633c2e..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/ComponentPlacement.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * ComponentPlacement.java
- *
- * Created on 20. Mai 2004, 07:43
- */
-
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Map;
-
-/**
- * Describes the placement data of a library component
- *
- * @author alfons
- */
-public class ComponentPlacement
-{
-
- /** Creates a new instance of ComponentPlacement */
- public ComponentPlacement(String p_lib_name)
- {
- lib_name = p_lib_name;
- locations = new LinkedList();
- }
-
- /** The name of the corresponding library component */
- public final String lib_name;
-
- /** The list of ComponentLocations of the library component on the board. */
- public final Collection locations;
-
- /** The structure of an entry in the list locations. */
- public static class ComponentLocation
- {
- ComponentLocation(String p_name, double[] p_coor, boolean p_is_front, double p_rotation, boolean p_position_fixed,
- Map p_pin_infos, Map p_keepout_infos,
- Map p_via_keepout_infos, Map p_place_keepout_infos)
- {
- name = p_name;
- coor = p_coor;
- is_front = p_is_front;
- rotation = p_rotation;
- position_fixed = p_position_fixed;
- pin_infos = p_pin_infos;
- keepout_infos = p_keepout_infos;
- via_keepout_infos = p_via_keepout_infos;
- place_keepout_infos = p_place_keepout_infos;
-
- }
-
- public final String name;
-
- /** the x- and the y-coordinate of the location. */
- public final double [] coor;
-
- /**
- * True, if the component is placed at the component side.
- * Else the component is placed at the solder side.
- */
- public final boolean is_front;
-
- /** The rotation of the component in degree. */
- public final double rotation;
-
- /** If true, the component cannot be moved. */
- public final boolean position_fixed;
-
- /**
- * The entries of this map are of type ItemClearanceInfo, the keys are the pin names.
- */
- public final Map pin_infos;
-
- public final Map keepout_infos;
-
- public final Map via_keepout_infos;
-
- public final Map place_keepout_infos;
- }
-
- public static class ItemClearanceInfo
- {
- ItemClearanceInfo( String p_name, String p_clearance_class)
- {
- name = p_name;
- clearance_class = p_clearance_class;
- }
- public final String name;
- public final String clearance_class;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/CoordinateTransform.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/CoordinateTransform.java
deleted file mode 100644
index 1c291e5..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/CoordinateTransform.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * CoordinateTransform.java
- *
- * Created on 14. Mai 2004, 09:09
- */
-
-package designformats.specctra;
-
-import geometry.planar.FloatPoint;
-import geometry.planar.Vector;
-import geometry.planar.Line;
-import geometry.planar.IntBox;
-import geometry.planar.PolylineShape;
-
-/**
- * Computes transformations between a specctra dsn-file coordinates and board coordinates.
- *
- * @author Alfons Wirtz
- */
-public class CoordinateTransform implements java.io.Serializable
-{
-
- /**
- * Creates a new instance of CoordinateTransform.
- * The base point of the dsn coordinate system will be translated to zero in the board
- * coordinate system.
- */
- public CoordinateTransform(double p_scale_factor, double p_base_x, double p_base_y)
- {
- scale_factor = p_scale_factor;
- base_x = p_base_x;
- base_y = p_base_y;
- }
-
- /**
- * Scale a value from the board to the dsn coordinate system
- */
- public double board_to_dsn(double p_val)
- {
- return p_val / scale_factor;
- }
-
- /**
- * Scale a value from the dsn to the board coordinate system
- */
- public double dsn_to_board(double p_val)
- {
- return p_val * scale_factor;
- }
-
- /**
- * Transforms a geometry.planar.FloatPoint to a tuple of doubles
- * in the dsn coordinate system.
- */
- public double[] board_to_dsn(FloatPoint p_point)
- {
- double [] result = new double[2];
- result [0] = board_to_dsn(p_point.x) + base_x;
- result [1] = board_to_dsn(p_point.y) + base_y;
- return result;
- }
-
- /**
- * Transforms a geometry.planar.FloatPoint to a tuple of doubles
- * in the dsn coordinate system in relative (vector) coordinates.
- */
- public double[] board_to_dsn_rel(FloatPoint p_point)
- {
- double [] result = new double[2];
- result [0] = board_to_dsn(p_point.x);
- result [1] = board_to_dsn(p_point.y);
- return result;
- }
-
- /**
- * Transforms an array of n geometry.planar.FloatPoints to
- * an array of 2*n doubles in the dsn coordinate system.
- */
- public double [] board_to_dsn(FloatPoint [] p_points)
- {
- double [] result = new double[2 * p_points.length];
- for (int i = 0; i < p_points.length; ++ i)
- {
- result[2 * i] = board_to_dsn(p_points[i].x) + base_x;
- result[2 * i + 1] = board_to_dsn(p_points[i].y) + base_y;
- }
- return result;
- }
-
- /**
- * Transforms an array of n geometry.planar.Lines to
- * an array of 4*n doubles in the dsn coordinate system.
- */
- public double [] board_to_dsn(Line [] p_lines)
- {
- double [] result = new double[4 * p_lines.length];
- for (int i = 0; i < p_lines.length; ++ i)
- {
- FloatPoint a = p_lines[i].a.to_float();
- FloatPoint b = p_lines[i].b.to_float();
- result[4 * i] = board_to_dsn(a.x) + base_x;
- result[4 * i + 1] = board_to_dsn(a.y) + base_y;
- result[4 * i + 2] = board_to_dsn(b.x) + base_x;
- result[4 * i + 3] = board_to_dsn(b.y) + base_y;
- }
- return result;
- }
-
- /**
- * Transforms an array of n geometry.planar.FloatPoints to
- * an array of 2*n doubles in the dsn coordinate system in relative (vector) coordinates.
- */
- public double [] board_to_dsn_rel(FloatPoint [] p_points)
- {
- double [] result = new double[2 * p_points.length];
- for (int i = 0; i < p_points.length; ++ i)
- {
- result[2 * i] = board_to_dsn(p_points[i].x);
- result[2 * i + 1] = board_to_dsn(p_points[i].y);
- }
- return result;
- }
-
- /**
- * Transforms a geometry.planar.Vector to a tuple of doubles
- * in the dsn coordinate system.
- */
- public double[] board_to_dsn(Vector p_vector)
- {
- double [] result = new double[2];
- FloatPoint v = p_vector.to_float();
- result [0] = board_to_dsn(v.x);
- result [1] = board_to_dsn(v.y);
- return result;
- }
-
- /**
- * Transforms a dsn tuple to a geometry.planar.FloatPoint
- */
- public FloatPoint dsn_to_board(double [] p_tuple)
- {
- double x = dsn_to_board(p_tuple[0] - base_x);
- double y = dsn_to_board(p_tuple[1] - base_y);
- return new FloatPoint(x, y);
- }
-
- /**
- * Transforms a dsn tuple to a geometry.planar.FloatPoint in relative (vector) coordinates.
- */
- public FloatPoint dsn_to_board_rel(double [] p_tuple)
- {
- double x = dsn_to_board(p_tuple[0]);
- double y = dsn_to_board(p_tuple[1]);
- return new FloatPoint(x, y);
- }
-
- /**
- * Transforms a geometry.planar.Intbox to the coordinates of a Rectangle.
- */
- public double [] board_to_dsn(IntBox p_box)
- {
- double [] result = new double[4];
- result[0] = p_box.ll.x / scale_factor + base_x;
- result[1] = p_box.ll.y / scale_factor + base_y;
- result[2] = p_box.ur.x / scale_factor + base_x;
- result[3] = p_box.ur.y / scale_factor + base_y;
- return result;
- }
-
- /**
- * Transforms a geometry.planar.Intbox to a Rectangle in relative (vector) coordinates.
- */
- public double [] board_to_dsn_rel(IntBox p_box)
- {
- double [] result = new double[4];
- result[0] = p_box.ll.x / scale_factor;
- result[1] = p_box.ll.y / scale_factor ;
- result[2] = p_box.ur.x / scale_factor;
- result[3] = p_box.ur.y / scale_factor;
- return result;
- }
-
- /**
- * Transforms a board shape to a dsn shape.
- */
- public Shape board_to_dsn(geometry.planar.Shape p_board_shape, Layer p_layer)
- {
- Shape result;
- if (p_board_shape instanceof IntBox)
- {
- result = new Rectangle(p_layer, board_to_dsn((IntBox) p_board_shape));
- }
- else if (p_board_shape instanceof PolylineShape)
- {
- FloatPoint [] corners = ((PolylineShape)p_board_shape).corner_approx_arr();
- double [] coors = board_to_dsn(corners);
- result = new Polygon(p_layer, coors);
- }
- else if (p_board_shape instanceof geometry.planar.Circle)
- {
- geometry.planar.Circle board_circle = (geometry.planar.Circle) p_board_shape;
- double diameter = 2 * board_to_dsn(board_circle.radius);
- double [] center_coor = board_to_dsn(board_circle.center.to_float());
- result = new Circle(p_layer, diameter, center_coor[0], center_coor[1]);
- }
- else
- {
- System.out.println("CoordinateTransform.board_to_dsn not yet implemented for p_board_shape");
- result = null;
- }
- return result;
- }
-
- /**
- * Transforms the relative (vector) coordinates of a geometry.planar.Shape to a specctra dsn shape.
- */
- public Shape board_to_dsn_rel(geometry.planar.Shape p_board_shape, Layer p_layer)
- {
- Shape result;
- if (p_board_shape instanceof IntBox)
- {
- result = new Rectangle(p_layer, board_to_dsn_rel((IntBox) p_board_shape));
- }
- else if (p_board_shape instanceof PolylineShape)
- {
- FloatPoint [] corners = ((PolylineShape)p_board_shape).corner_approx_arr();
- double [] coors = board_to_dsn_rel(corners);
- result = new Polygon(p_layer, coors);
- }
- else if (p_board_shape instanceof geometry.planar.Circle)
- {
- geometry.planar.Circle board_circle = (geometry.planar.Circle) p_board_shape;
- double diameter = 2 * board_to_dsn(board_circle.radius);
- double [] center_coor = board_to_dsn_rel(board_circle.center.to_float());
- result = new Circle(p_layer, diameter, center_coor[0], center_coor[1]);
- }
- else
- {
- System.out.println("CoordinateTransform.board_to_dsn not yet implemented for p_board_shape");
- result = null;
- }
- return result;
- }
-
- private final double scale_factor;
- private final double base_x;
- private final double base_y;
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/DsnFile.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/DsnFile.java
deleted file mode 100644
index 77a3388..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/DsnFile.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * InputDsnFile.java
- *
- * Created on 10. Mai 2004, 07:43
- */
-package designformats.specctra;
-
-import datastructures.IndentFileWriter;
-
-import board.BasicBoard;
-import board.TestLevel;
-
-/**
- * Class for reading and writing dsn-files.
- *
- * @author alfons
- */
-public class DsnFile
-{
-
- public enum ReadResult
- {
-
- OK, OUTLINE_MISSING, ERROR
- }
-
- private DsnFile() {
- }
-
- /**
- * Creates a routing board from a Specctra dns file.
- * The parameters p_item_observers and p_item_id_no_generator are used,
- * in case the board is embedded into a host system.
- * Returns false, if an error occured.
- */
- public static ReadResult read(java.io.InputStream p_input_stream, interactive.IBoardHandling p_board_handling,
- board.BoardObservers p_observers, datastructures.IdNoGenerator p_item_id_no_generator, TestLevel p_test_level)
- {
- Scanner scanner = new SpecctraFileScanner(p_input_stream);
- Object curr_token = null;
- for (int i = 0; i < 3; ++i)
- {
- try
- {
- curr_token = scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("DsnFile.read: IO error scanning file");
- System.out.println(e);
- return ReadResult.ERROR;
- }
- boolean keyword_ok = true;
- if (i == 0)
- {
- keyword_ok = (curr_token == Keyword.OPEN_BRACKET);
- }
- else if (i == 1)
- {
- keyword_ok = (curr_token == Keyword.PCB_SCOPE);
- scanner.yybegin(SpecctraFileScanner.NAME); // to overread the name of the pcb for i = 2
- }
- if (!keyword_ok)
- {
- System.out.println("DsnFile.read: specctra dsn file format expected");
- return ReadResult.ERROR;
- }
- }
- ReadScopeParameter read_scope_par =
- new ReadScopeParameter(scanner, p_board_handling, p_observers, p_item_id_no_generator, p_test_level);
- boolean read_ok = Keyword.PCB_SCOPE.read_scope(read_scope_par);
- ReadResult result;
- if (read_ok)
- {
- result = ReadResult.OK;
- if (read_scope_par.autoroute_settings == null)
- {
- // look for power planes with incorrect layer type and adjust autoroute parameters
- adjust_plane_autoroute_settings(p_board_handling);
- }
- }
- else if (!read_scope_par.board_outline_ok)
- {
- result = ReadResult.OUTLINE_MISSING;
- }
- else
- {
- result = ReadResult.ERROR;
- }
- //tests.Validate.check("after reading dsn", read_scope_par.board_handling.get_routing_board());
- return result;
- }
-
- /**
- * Sets contains_plane to true for nets with a conduction_area covering a
- * large part of a signal layer, if that layer does not contain any traces
- * This is useful in case the layer type was not set correctly to plane in the dsn-file.
- * Returns true, if something was changed.
- */
- private static boolean adjust_plane_autoroute_settings(interactive.IBoardHandling p_board_handling)
- {
- BasicBoard routing_board = p_board_handling.get_routing_board();
- board.LayerStructure board_layer_structure = routing_board.layer_structure;
- if (board_layer_structure.arr.length <= 2)
- {
- return false;
- }
- for (board.Layer curr_layer : board_layer_structure.arr)
- {
- if (!curr_layer.is_signal)
- {
- return false;
- }
- }
- boolean[] layer_contains_wires_arr = new boolean[board_layer_structure.arr.length];
- boolean[] changed_layer_arr = new boolean[board_layer_structure.arr.length];
- for (int i = 0; i < layer_contains_wires_arr.length; ++i)
- {
- layer_contains_wires_arr[i] = false;
- changed_layer_arr[i] = false;
- }
- java.util.Collection conduction_area_list = new java.util.LinkedList();
- java.util.Collection item_list = routing_board.get_items();
- for (board.Item curr_item : item_list)
- {
- if (curr_item instanceof board.Trace)
- {
- int curr_layer = ((board.Trace) curr_item).get_layer();
- layer_contains_wires_arr[curr_layer] = true;
- }
- else if (curr_item instanceof board.ConductionArea)
- {
- conduction_area_list.add((board.ConductionArea) curr_item);
- }
- }
- boolean nothing_changed = true;
-
- board.BoardOutline board_outline = routing_board.get_outline();
- double board_area = 0;
- for (int i = 0; i < board_outline.shape_count(); ++i)
- {
- geometry.planar.TileShape[] curr_piece_arr = board_outline.get_shape(i).split_to_convex();
- if (curr_piece_arr != null)
- {
- for (geometry.planar.TileShape curr_piece : curr_piece_arr)
- {
- board_area += curr_piece.area();
- }
- }
- }
- for (board.ConductionArea curr_conduction_area : conduction_area_list)
- {
- int layer_no = curr_conduction_area.get_layer();
- if (layer_contains_wires_arr[layer_no])
- {
- continue;
- }
- board.Layer curr_layer = routing_board.layer_structure.arr[layer_no];
- if (!curr_layer.is_signal || layer_no == 0 || layer_no == board_layer_structure.arr.length - 1)
- {
- continue;
- }
- geometry.planar.TileShape[] convex_pieces = curr_conduction_area.get_area().split_to_convex();
- double curr_area = 0;
- for (geometry.planar.TileShape curr_piece : convex_pieces)
- {
- curr_area += curr_piece.area();
- }
- if (curr_area < 0.5 * board_area)
- {
- // skip conduction areas not covering most of the board
- continue;
- }
-
- for (int i = 0; i < curr_conduction_area.net_count(); ++i)
- {
- rules.Net curr_net = routing_board.rules.nets.get(curr_conduction_area.get_net_no(i));
- curr_net.set_contains_plane(true);
- nothing_changed = false;
- }
-
- changed_layer_arr[layer_no] = true;
- if (curr_conduction_area.get_fixed_state().ordinal() < board.FixedState.USER_FIXED.ordinal())
- {
- curr_conduction_area.set_fixed_state(board.FixedState.USER_FIXED);
- }
- }
- if (nothing_changed)
- {
- return false;
- }
- // Adjust the layer prefered directions in the autoroute settings.
- // and deactivate the changed layers.
- interactive.AutorouteSettings autoroute_settings = p_board_handling.get_settings().autoroute_settings;
- int layer_count = routing_board.get_layer_count();
- boolean curr_preferred_direction_is_horizontal =
- autoroute_settings.get_preferred_direction_is_horizontal(0);
- for (int i = 0; i < layer_count; ++i)
- {
- if (changed_layer_arr[i])
- {
- autoroute_settings.set_layer_active(i, false);
- }
- else if (autoroute_settings.get_layer_active(i))
- {
- autoroute_settings.set_preferred_direction_is_horizontal(i, curr_preferred_direction_is_horizontal);
- curr_preferred_direction_is_horizontal = !curr_preferred_direction_is_horizontal;
- }
- }
- return true;
- }
-
- /**
- * Writes p_board to a text file in the Specctra dsn format.
- * Returns false, if the write failed.
- * If p_compat_mode is true, only standard speecctra dsn scopes are written, so that any
- * host system with an specctra interface can read them.
- */
- public static boolean write(interactive.BoardHandling p_board_handling, java.io.OutputStream p_file, String p_design_name, boolean p_compat_mode)
- {
- //tests.Validate.check("before writing dsn", p_board);
- IndentFileWriter output_file = new IndentFileWriter(p_file);
- if (output_file == null)
- {
- System.out.println("unable to write dsn file");
- return false;
- }
-
- try
- {
- write_pcb_scope(p_board_handling, output_file, p_design_name, p_compat_mode);
- }
- catch (java.io.IOException e)
- {
- System.out.println("unable to write dsn file");
- return false;
- }
- try
- {
- output_file.close();
- }
- catch (java.io.IOException e)
- {
- System.out.println("unable to close dsn file");
- return false;
- }
- return true;
- }
-
- private static void write_pcb_scope(interactive.BoardHandling p_board_handling, IndentFileWriter p_file, String p_design_name, boolean p_compat_mode)
- throws java.io.IOException
- {
- BasicBoard routing_board = p_board_handling.get_routing_board();
- WriteScopeParameter write_scope_parameter =
- new WriteScopeParameter(routing_board, p_board_handling.settings.autoroute_settings, p_file,
- routing_board.communication.specctra_parser_info.string_quote,
- routing_board.communication.coordinate_transform, p_compat_mode);
-
- p_file.start_scope();
- p_file.write("PCB ");
- write_scope_parameter.identifier_type.write(p_design_name, p_file);
- Parser.write_scope(write_scope_parameter.file,
- write_scope_parameter.board.communication.specctra_parser_info, write_scope_parameter.identifier_type, false);
- Resolution.write_scope(p_file, routing_board.communication);
- Structure.write_scope(write_scope_parameter);
- Placement.write_scope(write_scope_parameter);
- Library.write_scope(write_scope_parameter);
- PartLibrary.write_scope(write_scope_parameter);
- Network.write_scope(write_scope_parameter);
- Wiring.write_scope(write_scope_parameter);
- p_file.end_scope();
- }
-
- static boolean read_on_off_scope(Scanner p_scanner)
- {
- try
- {
- Object next_token = p_scanner.next_token();
- boolean result = false;
- if (next_token == Keyword.ON)
- {
- result = true;
- }
- else if (next_token != Keyword.OFF)
- {
- System.out.println("DsnFile.read_boolean: Keyword.OFF expected");
- }
- ScopeKeyword.skip_scope(p_scanner);
- return result;
- }
- catch (java.io.IOException e)
- {
- System.out.println("DsnFile.read_boolean: IO error scanning file");
- return false;
- }
- }
-
- static int read_integer_scope(Scanner p_scanner)
- {
- try
- {
- int value;
- Object next_token = p_scanner.next_token();
- if (next_token instanceof Integer)
- {
- value = ((Integer) next_token).intValue();
- }
- else
- {
- System.out.println("DsnFile.read_integer_scope: number expected");
- return 0;
- }
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("DsnFile.read_integer_scope: closing bracket expected");
- return 0;
- }
- return value;
- }
- catch (java.io.IOException e)
- {
- System.out.println("DsnFile.read_integer_scope: IO error scanning file");
- return 0;
- }
- }
-
- static double read_float_scope(Scanner p_scanner)
- {
- try
- {
- double value;
- Object next_token = p_scanner.next_token();
- if (next_token instanceof Double)
- {
- value = ((Double) next_token).doubleValue();
- }
- else if (next_token instanceof Integer)
- {
- value = ((Integer) next_token).intValue();
- }
- else
- {
- System.out.println("DsnFile.read_float_scope: number expected");
- return 0;
- }
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("DsnFile.read_float_scope: closing bracket expected");
- return 0;
- }
- return value;
- }
- catch (java.io.IOException e)
- {
- System.out.println("DsnFile.read_float_scope: IO error scanning file");
- return 0;
- }
- }
-
- public static String read_string_scope(Scanner p_scanner)
- {
- try
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("DsnFile:read_string_scope: String expected");
- return null;
- }
- String result = (String) next_token;
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("DsnFile.read_string_scope: closing bracket expected");
- }
- return result;
- }
- catch (java.io.IOException e)
- {
- System.out.println("DsnFile.read_string_scope: IO error scanning file");
- return null;
- }
- }
-
- public static java.util.Collection read_string_list_scope(Scanner p_scanner)
- {
- java.util.Collection result = new java.util.LinkedList();
- try
- {
- for (;;)
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- Object next_token = p_scanner.next_token();
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- break;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("DsnFileread_string_list_scope: string expected");
- return null;
- }
- result.add((String) next_token);
- }
- }
- catch (java.io.IOException e)
- {
- System.out.println("DsnFile.read_string_list_scope: IO error scanning file");
- }
- return result;
- }
- static final String CLASS_CLEARANCE_SEPARATOR = "-";
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Keyword.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Keyword.java
deleted file mode 100644
index 52da218..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Keyword.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Keyword.java
- *
- * Created on 8. Mai 2004, 10:23
- */
-package designformats.specctra;
-
-/**
- * Enumeration class for keywords of the specctra dsn file format
- *
- * @author alfons
- */
-public class Keyword
-{
-
- /**
- * The only instances of the internal classes:
- *
- * ScopeKeywords with an inividual read_scope method are defined in an extra class,
- */
- public static final Keyword ABSOLUTE = new Keyword("absolute");
- public static final Keyword ACTIVE = new Keyword("active");
- public static final Keyword AGAINST_PREFERRED_DIRECTION_TRACE_COSTS = new Keyword("against_preferred_direction_trace_costs");
- public static final Keyword ATTACH = new Keyword("attach");
- public static final Keyword AUTOROUTE = new Keyword("autoroute");
- public static final Keyword AUTOROUTE_SETTINGS = new Keyword("autoroute_settings");
- public static final Keyword BACK = new Keyword("back");
- public static final Keyword BOUNDARY = new Keyword("boundary");
- public static final Keyword CIRCUIT = new Keyword("circuit");
- public static final Keyword CIRCLE = new Keyword("circle");
- public static final Keyword CLASS = new Keyword("class");
- public static final Keyword CLASS_CLASS = new Keyword("class_class");
- public static final Keyword CLASSES = new Keyword("classes");
- public static final ScopeKeyword COMPONENT_SCOPE = new Component();
- public static final Keyword CONSTANT = new Keyword("constant");
- public static final Keyword CONTROL = new Keyword("control");
- public static final Keyword CLEARANCE = new Keyword("clearance");
- public static final Keyword CLEARANCE_CLASS = new Keyword("clearance_class");
- public static final Keyword CLOSED_BRACKET = new Keyword(")");
- public static final Keyword FANOUT = new Keyword("fanout");
- public static final Keyword FLIP_STYLE = new Keyword("flip_style");
- public static final Keyword FIX = new Keyword("fix");
- public static final Keyword FORTYFIVE_DEGREE = new Keyword("fortyfive_degree");
- public static final Keyword FROMTO = new Keyword("fromto");
- public static final Keyword FRONT = new Keyword("front");
- public static final Keyword GENERATED_BY_FREEROUTE = new Keyword("generated_by_freeroute");
- public static final Keyword HORIZONTAL = new Keyword("horizontal");
- public static final Keyword HOST_CAD = new Keyword("host_cad");
- public static final Keyword HOST_VERSION = new Keyword("host_version");
- public static final Keyword IMAGE = new Keyword("image");
- public static final Keyword KEEPOUT = new Keyword("keepout");
- public static final Keyword LAYER = new Keyword("layer");
- public static final Keyword LAYER_RULE = new Keyword("layer_rule");
- public static final Keyword LENGTH = new Keyword("length");
- public static final ScopeKeyword LIBRARY_SCOPE = new Library();
- public static final Keyword LOCK_TYPE = new Keyword("lock_type");
- public static final Keyword LOGICAL_PART = new Keyword("logical_part");
- public static final Keyword LOGICAL_PART_MAPPING = new Keyword("logical_part_mapping");
- public static final Keyword NET = new Keyword("net");
- public static final Keyword NETWORK_OUT = new Keyword("network_out");
- public static final ScopeKeyword NETWORK_SCOPE = new Network();
- public static final Keyword NINETY_DEGREE = new Keyword("ninety_degree");
- public static final Keyword NONE = new Keyword("none");
- public static final Keyword NORMAL = new Keyword("normal");
- public static final Keyword OFF = new Keyword("off");
- public static final Keyword ON = new Keyword("on");
- public static final Keyword OPEN_BRACKET = new Keyword("(");
- public static final Keyword ORDER = new Keyword("order");
- public static final Keyword OUTLINE = new Keyword("outline");
- public static final Keyword PADSTACK = new Keyword("padstack");
- public static final ScopeKeyword PART_LIBRARY_SCOPE = new PartLibrary();
- public static final ScopeKeyword PARSER_SCOPE = new Parser();
- public static final ScopeKeyword PCB_SCOPE = new ScopeKeyword("pcb");
- public static final Keyword PIN = new Keyword("pin");
- public static final Keyword PINS = new Keyword("pins");
- public static final Keyword PLACE = new Keyword("place");
- public static final ScopeKeyword PLACE_CONTROL = new PlaceControl();
- public static final Keyword PLACE_KEEPOUT = new Keyword("place_keepout");
- public static final ScopeKeyword PLACEMENT_SCOPE = new Placement();
- public static final ScopeKeyword PLANE_SCOPE = new Plane();
- public static final Keyword PLANE_VIA_COSTS = new Keyword("plane_via_costs");
- public static final Keyword PREFERRED_DIRECTION = new Keyword("preferred_direction");
- public static final Keyword PREFERRED_DIRECTION_TRACE_COSTS = new Keyword("preferred_direction_trace_costs");
- public static final Keyword SNAP_ANGLE = new Keyword("snap_angle");
- public static final Keyword POLYGON = new Keyword("polygon");
- public static final Keyword POLYGON_PATH = new Keyword("polygon_path");
- public static final Keyword POLYLINE_PATH = new Keyword("polyline_path");
- public static final Keyword POSITION = new Keyword("position");
- public static final Keyword POSTROUTE = new Keyword("postroute");
- public static final Keyword POWER = new Keyword("power");
- public static final Keyword PULL_TIGHT = new Keyword("pull_tight");
- public static final Keyword RECTANGLE = new Keyword("rectangle");
- public static final Keyword RESOLUTION_SCOPE = new Resolution();
- public static final Keyword ROTATE = new Keyword("rotate");
- public static final Keyword ROTATE_FIRST = new Keyword("rotate_first");
- public static final Keyword ROUTES = new Keyword("routes");
- public static final Keyword RULE = new Keyword("rule");
- public static final Keyword RULES = new Keyword("rules");
- public static final Keyword SESSION = new Keyword("session");
- public static final Keyword SHAPE = new Keyword("shape");
- public static final Keyword SHOVE_FIXED = new Keyword("shove_fixed");
- public static final Keyword SIDE = new Keyword("side");
- public static final Keyword SIGNAL = new Keyword("signal");
- public static final Keyword SPARE = new Keyword("spare");
- public static final Keyword START_PASS_NO = new Keyword("start_pass_no");
- public static final Keyword START_RIPUP_COSTS = new Keyword("start_ripup_costs");
- public static final Keyword STRING_QUOTE = new Keyword("string_quote");
- public static final ScopeKeyword STRUCTURE_SCOPE = new Structure();
- public static final Keyword TYPE = new Keyword("type");
- public static final Keyword USE_LAYER = new Keyword("use_layer");
- public static final Keyword USE_NET = new Keyword("use_net");
- public static final Keyword USE_VIA = new Keyword("use_via");
- public static final Keyword VERTICAL = new Keyword("vertical");
- public static final Keyword VIA = new Keyword("via");
- public static final Keyword VIAS = new Keyword("vias");
- public static final Keyword VIA_AT_SMD = new Keyword("via_at_smd");
- public static final Keyword VIA_COSTS = new Keyword("via_costs");
- public static final Keyword VIA_KEEPOUT = new Keyword("via_keepout");
- public static final Keyword VIA_RULE = new Keyword("via_rule");
- public static final Keyword WIDTH = new Keyword("width");
- public static final Keyword WINDOW = new Keyword("window");
- public static final Keyword WIRE = new Keyword("wire");
- public static final ScopeKeyword WIRING_SCOPE = new Wiring();
- public static final Keyword WRITE_RESOLUTION = new Keyword("write_resolution");
-
- /**
- * Returns the name string of this Keyword.
- * The name is used for debugging purposes.
- */
- public String get_name()
- {
- return name;
- }
- private final String name;
-
- /** prevents creating more instances */
- protected Keyword(String p_name)
- {
- name = p_name;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Layer.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Layer.java
deleted file mode 100644
index 45658f2..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Layer.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Layer.java
- *
- * Created on 15. Mai 2004, 08:29
- */
-
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-
-/**
- * Describes a layer in a Specctra dsn file.
- *
- * @author alfons
- */
-public class Layer
-{
- /** all layers of the board */
- public static final Layer PCB = new Layer("pcb", -1, false);
- /** the signal layers */
- public static final Layer SIGNAL = new Layer("signal", -1, true);
-
- /**
- * Creates a new instance of Layer.
- * p_no is the physical layer number starting with 0 at the component side
- * and ending at the solder side.
- * If p_is_signal, the layer is a signal layer, otherwise it is a powerground layer.
- * For Layer objects describing more than 1 layer the number is -1.
- * p_net_names is a list of nets for this layer, if the layer is a power plane.
- */
- public Layer(String p_name, int p_no, boolean p_is_signal, Collection p_net_names)
- {
- name = p_name;
- no = p_no;
- is_signal = p_is_signal;
- net_names = p_net_names;
- }
-
- /**
- * Creates a new instance of Layer.
- * p_no is the physical layer number starting with 0 at the component side
- * and ending at the solder side.
- * If p_is_signal, the layer is a signal layer, otherwise it is a powerground layer.
- * For Layer objects describing more than 1 layer the number is -1.
- */
- public Layer(String p_name, int p_no, boolean p_is_signal)
- {
- name = p_name;
- no = p_no;
- is_signal = p_is_signal;
- net_names = new LinkedList();
- }
-
- /**
- * Writes a layer scope in the stucture scope.
- */
- public static void write_scope(WriteScopeParameter p_par, int p_layer_no,
- boolean p_write_rule) throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("layer ");
- board.Layer board_layer = p_par.board.layer_structure.arr[p_layer_no];
- p_par.identifier_type.write(board_layer.name, p_par.file);
- p_par.file.new_line();
- p_par.file.write("(type ");
- if (board_layer.is_signal)
- {
- p_par.file.write("signal)");
- }
- else
- {
- p_par.file.write("power)");
- }
- if (p_write_rule)
- {
- Rule.write_default_rule(p_par, p_layer_no);
- }
- p_par.file.end_scope();
- }
- public final String name;
- public final int no;
- public final boolean is_signal;
- public final java.util.Collection net_names;
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/LayerStructure.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/LayerStructure.java
deleted file mode 100644
index 202bb81..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/LayerStructure.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * LayerStructure.java
- *
- * Created on 16. Mai 2004, 08:08
- */
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * Describes a layer structure read from a dsn file.
- *
- * @author alfons
- */
-public class LayerStructure
-{
-
- /** Creates a new instance of LayerStructure from a list of layers*/
- public LayerStructure(Collection p_layer_list)
- {
- arr = new Layer[p_layer_list.size()];
- Iterator it = p_layer_list.iterator();
- for (int i = 0; i < arr.length; ++i)
- {
- arr[i] = it.next();
- }
- }
-
- /**
- * Creates a dsn-LayerStructure from a board LayerStructure.
- */
- public LayerStructure(board.LayerStructure p_board_layer_structure)
- {
- arr = new Layer[p_board_layer_structure.arr.length];
- for (int i = 0; i < arr.length; ++i)
- {
- board.Layer board_layer = p_board_layer_structure.arr[i];
- arr[i] = new Layer(board_layer.name, i, board_layer.is_signal);
- }
- }
-
- /**
- * returns the number of the layer with the name p_name,
- * -1, if no layer with name p_name exists.
- */
- public int get_no(String p_name)
- {
- for (int i = 0; i < arr.length; ++i)
- {
- if (p_name.equals(arr[i].name))
- {
- return i;
- }
- }
- // check for special layers of the Electra autorouter used for the outline
- if (p_name.contains("Top"))
- {
- return 0;
- }
- if (p_name.contains("Bottom"))
- {
- return arr.length - 1;
- }
- return -1;
- }
-
- public int signal_layer_count()
- {
- int result = 0;
- for (Layer curr_layer : arr)
- {
- if (curr_layer.is_signal)
- {
- ++result;
- }
- }
- return result;
- }
-
- /**
- * Returns, if the net with name p_net_name contains a powwer plane.
- */
- public boolean contains_plane(String p_net_name)
- {
-
- for (Layer curr_layer : arr)
- {
- if (!curr_layer.is_signal)
- {
- if (curr_layer.net_names.contains(p_net_name))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- public final Layer[] arr;
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Library.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Library.java
deleted file mode 100644
index 5ad97c5..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Library.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Library.java
- *
- * Created on 21. Mai 2004, 08:09
- */
-
-package designformats.specctra;
-
-import geometry.planar.IntVector;
-import geometry.planar.Vector;
-import geometry.planar.PolygonShape;
-import geometry.planar.Simplex;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-
-/**
- * Class for reading and writing library scopes from dsn-files.
- *
- * @author Alfons Wirtz
- */
-public class Library extends ScopeKeyword
-{
-
- /** Creates a new instance of Library */
- public Library()
- {
- super("library");
- }
-
- public boolean read_scope(ReadScopeParameter p_par)
- {
- board.RoutingBoard board = p_par.board_handling.get_routing_board();
- board.library.padstacks = new library.Padstacks(p_par.board_handling.get_routing_board().layer_structure);
- Collection package_list = new LinkedList();
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_par.scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("Library.read_scope: IO error scanning file");
- System.out.println(e);
- return false;
- }
- if (next_token == null)
- {
- System.out.println("Library.read_scope: unexpected end of file");
- return false;
- }
- if (next_token == CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == OPEN_BRACKET)
- {
- if (next_token == Keyword.PADSTACK)
- {
- if (!read_padstack_scope(p_par.scanner, p_par.layer_structure,
- p_par.coordinate_transform, board.library.padstacks))
- {
- return false;
- }
- }
- else if (next_token == Keyword.IMAGE)
- {
- Package curr_package = Package.read_scope(p_par.scanner, p_par.layer_structure);
- if (curr_package == null)
- {
- return false;
- }
- package_list.add(curr_package);
- }
- else
- {
- skip_scope(p_par.scanner);
- }
- }
- }
-
- // Set the via padstacks.
- if (p_par.via_padstack_names != null)
- {
- library.Padstack[] via_padstacks = new library.Padstack[p_par.via_padstack_names.size()];
- Iterator it = p_par.via_padstack_names.iterator();
- int found_padstack_count = 0;
- for (int i = 0; i < via_padstacks.length; ++i)
- {
- String curr_padstack_name = it.next();
- library.Padstack curr_padstack = board.library.padstacks.get(curr_padstack_name);
- if (curr_padstack != null)
- {
- via_padstacks[found_padstack_count] = curr_padstack;
- ++found_padstack_count;
- }
- else
- {
- System.out.print("Library.read_scope: via padstack with name ");
- System.out.print(curr_padstack_name);
- System.out.println(" not found");
- }
- }
- if (found_padstack_count != via_padstacks.length)
- {
- // Some via padstacks were not found in the padstacks scope of the dsn-file.
- library.Padstack[] corrected_padstacks = new library.Padstack[found_padstack_count];
- System.arraycopy(via_padstacks, 0, corrected_padstacks, 0, found_padstack_count);
- via_padstacks = corrected_padstacks;
- }
- board.library.set_via_padstacks(via_padstacks);
- }
-
- // Create the library packages on the board
- board.library.packages = new library.Packages(board.library.padstacks);
- Iterator it = package_list.iterator();
- while (it.hasNext())
- {
- Package curr_package = it.next();
- library.Package.Pin[] pin_arr = new library.Package.Pin[curr_package.pin_info_arr.length];
- for (int i = 0; i < pin_arr.length; ++i)
- {
- Package.PinInfo pin_info = curr_package.pin_info_arr[i];
- int rel_x = (int) Math.round(p_par.coordinate_transform.dsn_to_board(pin_info.rel_coor[0]));
- int rel_y = (int) Math.round(p_par.coordinate_transform.dsn_to_board(pin_info.rel_coor[1]));
- Vector rel_coor = new IntVector(rel_x, rel_y);
- library.Padstack board_padstack = board.library.padstacks.get(pin_info.padstack_name);
- if (board_padstack == null)
- {
- System.out.println("Library.read_scope: board padstack not found");
- return false;
- }
- pin_arr[i] = new library.Package.Pin(pin_info.pin_name, board_padstack.no, rel_coor, pin_info.rotation);
- }
- geometry.planar.Shape[] outline_arr = new geometry.planar.Shape[curr_package.outline.size()];
-
- Iterator it3 = curr_package.outline.iterator();
- for (int i = 0; i < outline_arr.length; ++i)
- {
- Shape curr_shape = it3.next();
- if (curr_shape != null)
- {
- outline_arr[i] = curr_shape.transform_to_board_rel(p_par.coordinate_transform);
- }
- else
- {
- System.out.println("Library.read_scope: outline shape is null");
- }
- }
- generate_missing_keepout_names("keepout_", curr_package.keepouts);
- generate_missing_keepout_names("via_keepout_", curr_package.via_keepouts);
- generate_missing_keepout_names("place_keepout_", curr_package.place_keepouts);
- library.Package.Keepout [] keepout_arr = new library.Package.Keepout [curr_package.keepouts.size()];
- Iterator it2 = curr_package.keepouts.iterator();
- for (int i = 0; i < keepout_arr.length; ++i)
- {
- Shape.ReadAreaScopeResult curr_keepout = it2.next();
- Layer curr_layer = curr_keepout.shape_list.iterator().next().layer;
- geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform);
- keepout_arr[i] = new library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no);
- }
- library.Package.Keepout [] via_keepout_arr = new library.Package.Keepout [curr_package.via_keepouts.size()];
- it2 = curr_package.via_keepouts.iterator();
- for (int i = 0; i < via_keepout_arr.length; ++i)
- {
- Shape.ReadAreaScopeResult curr_keepout = it2.next();
- Layer curr_layer = (curr_keepout.shape_list.iterator().next()).layer;
- geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform);
- via_keepout_arr[i] = new library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no);
- }
- library.Package.Keepout [] place_keepout_arr = new library.Package.Keepout [curr_package.place_keepouts.size()];
- it2 = curr_package.place_keepouts.iterator();
- for (int i = 0; i < place_keepout_arr.length; ++i)
- {
- Shape.ReadAreaScopeResult curr_keepout = it2.next();
- Layer curr_layer = (curr_keepout.shape_list.iterator().next()).layer;
- geometry.planar.Area curr_area = Shape.transform_area_to_board_rel(curr_keepout.shape_list, p_par.coordinate_transform);
- place_keepout_arr[i] = new library.Package.Keepout(curr_keepout.area_name, curr_area, curr_layer.no);
- }
- board.library.packages.add(curr_package.name, pin_arr, outline_arr,
- keepout_arr, via_keepout_arr, place_keepout_arr, curr_package.is_front);
- }
- return true;
- }
-
- public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("library");
- for (int i = 1; i <= p_par.board.library.packages.count(); ++i)
- {
- Package.write_scope(p_par, p_par.board.library.packages.get(i));
- }
- for (int i = 1; i <= p_par.board.library.padstacks.count(); ++i)
- {
- write_padstack_scope(p_par, p_par.board.library.padstacks.get(i));
- }
- p_par.file.end_scope();
- }
-
- public static void write_padstack_scope(WriteScopeParameter p_par, library.Padstack p_padstack) throws java.io.IOException
- {
- // search the layer range of the padstack
- int first_layer_no = 0;
- while (first_layer_no < p_par.board.get_layer_count())
- {
- if (p_padstack.get_shape(first_layer_no) != null)
- {
- break;
- }
- ++first_layer_no;
- }
- int last_layer_no = p_par.board.get_layer_count() - 1;
- while (last_layer_no >= 0 )
- {
- if (p_padstack.get_shape(last_layer_no) != null)
- {
- break;
- }
- --last_layer_no;
- }
- if (first_layer_no >= p_par.board.get_layer_count() || last_layer_no < 0)
- {
- System.out.println("Library.write_padstack_scope: padstack shape not found");
- return;
- }
-
- p_par.file.start_scope();
- p_par.file.write("padstack ");
- p_par.identifier_type.write(p_padstack.name, p_par.file);
- for (int i = first_layer_no; i <= last_layer_no; ++i)
- {
- geometry.planar.Shape curr_board_shape = p_padstack.get_shape(i);
- if (curr_board_shape == null)
- {
- continue;
- }
- board.Layer board_layer = p_par.board.layer_structure.arr[i];
- Layer curr_layer = new Layer(board_layer.name, i, board_layer.is_signal);
- Shape curr_shape = p_par.coordinate_transform.board_to_dsn_rel(curr_board_shape, curr_layer);
- p_par.file.start_scope();
- p_par.file.write("shape");
- curr_shape.write_scope(p_par.file, p_par.identifier_type);
- p_par.file.end_scope();
- }
- if (!p_padstack.attach_allowed)
- {
- p_par.file.new_line();
- p_par.file.write("(attach off)");
- }
- if (p_padstack.placed_absolute)
- {
- p_par.file.new_line();
- p_par.file.write("(absolute on)");
- }
- p_par.file.end_scope();
- }
-
- static boolean read_padstack_scope(Scanner p_scanner, LayerStructure p_layer_structure,
- CoordinateTransform p_coordinate_transform, library.Padstacks p_board_padstacks)
- {
- String padstack_name = null;
- boolean is_drilllable = true;
- boolean placed_absolute = false;
- Collection shape_list = new LinkedList();
- try
- {
- Object next_token = p_scanner.next_token();
- if (next_token instanceof String)
- {
- padstack_name = (String) next_token;
- }
- else
- {
- System.out.println("Library.read_padstack_scope: unexpected padstack identifier");
- return false;
- }
-
- while (next_token != Keyword.CLOSED_BRACKET)
- {
- Object prev_token = next_token;
- next_token = p_scanner.next_token();
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.SHAPE)
- {
- Shape curr_shape = Shape.read_scope(p_scanner, p_layer_structure);
- if (curr_shape != null)
- {
- shape_list.add(curr_shape);
- }
- // overread the closing bracket and unknown scopes.
- Object curr_next_token = p_scanner.next_token();
- while (curr_next_token == Keyword.OPEN_BRACKET)
- {
- ScopeKeyword.skip_scope(p_scanner);
- curr_next_token = p_scanner.next_token();
- }
- if (curr_next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Library.read_padstack_scope: closing bracket expected");
- return false;
- }
- }
- else if (next_token == Keyword.ATTACH)
- {
- is_drilllable = DsnFile.read_on_off_scope(p_scanner);
- }
- else if (next_token == Keyword.ABSOLUTE)
- {
- placed_absolute = DsnFile.read_on_off_scope(p_scanner);
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- }
-
- }
- }
- catch (java.io.IOException e)
- {
- System.out.println("Library.read_padstack_scope: IO error scanning file");
- System.out.println(e);
- return false;
- }
- if (p_board_padstacks.get(padstack_name) != null)
- {
- // Padstack exists already
- return true;
- }
- if (shape_list.isEmpty())
- {
- System.out.print("Library.read_padstack_scope: shape not found for padstack with name ");
- System.out.println(padstack_name);
- return true;
- }
- geometry.planar.ConvexShape[] padstack_shapes = new geometry.planar.ConvexShape[p_layer_structure.arr.length];
- Iterator it = shape_list.iterator();
- while (it.hasNext())
- {
- Shape pad_shape = it.next();
- geometry.planar.Shape curr_shape = pad_shape.transform_to_board_rel(p_coordinate_transform);
- geometry.planar.ConvexShape convex_shape;
- if (curr_shape instanceof geometry.planar.ConvexShape)
- {
- convex_shape = (geometry.planar.ConvexShape) curr_shape;
- }
- else
- {
- if (curr_shape instanceof PolygonShape)
- {
- curr_shape = ((PolygonShape)curr_shape).convex_hull();
- }
- geometry.planar.TileShape[] convex_shapes = curr_shape.split_to_convex();
- if (convex_shapes.length != 1)
- {
- System.out.println("Library.read_padstack_scope: convex shape expected");
- }
- convex_shape = convex_shapes[0];
- if (convex_shape instanceof Simplex)
- {
- convex_shape = ((Simplex) convex_shape).simplify();
- }
- }
- geometry.planar.ConvexShape padstack_shape = convex_shape;
- if (padstack_shape != null)
- {
- if (padstack_shape.dimension() < 2)
- {
- System.out.print("Library.read_padstack_scope: shape is not an area ");
- // enllarge the shape a little bit, so that it is an area
- padstack_shape = padstack_shape.offset(1);
- if (padstack_shape.dimension() < 2)
- {
- padstack_shape = null;
- }
- }
- }
-
- if (pad_shape.layer == Layer.PCB || pad_shape.layer == Layer.SIGNAL)
- {
- for (int i = 0; i < padstack_shapes.length; ++i)
- {
- padstack_shapes[i] = padstack_shape;
- }
- }
- else
- {
- int shape_layer = p_layer_structure.get_no(pad_shape.layer.name);
- if (shape_layer < 0 || shape_layer >= padstack_shapes.length)
- {
- System.out.println("Library.read_padstack_scope: layer number found");
- return false;
- }
- padstack_shapes[shape_layer] = padstack_shape;
- }
- }
- p_board_padstacks.add(padstack_name, padstack_shapes, is_drilllable, placed_absolute);
- return true;
- }
-
- private void generate_missing_keepout_names(String p_keepout_type, Collection p_keepout_list)
- {
- boolean all_names_existing = true;
- for (Shape.ReadAreaScopeResult curr_keepout : p_keepout_list)
- {
- if (curr_keepout.area_name == null)
- {
- all_names_existing = false;
- break;
- }
- }
- if (all_names_existing)
- {
- return;
- }
- // generate names
- Integer curr_name_index = 1;
- for (Shape.ReadAreaScopeResult curr_keepout : p_keepout_list)
- {
- curr_keepout.area_name = p_keepout_type + curr_name_index.toString();
- ++curr_name_index;
- }
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Net.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Net.java
deleted file mode 100644
index 8ea45af..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Net.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Net.java
- *
- * Created on 19. Mai 2004, 08:58
- */
-
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.Iterator;
-
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-
-/**
- * Class for reading and writing net scopes from dsn-files.
- *
- * @author alfons
- */
-public class Net
-{
-
- /** Creates a new instance of Net */
- public Net(Id p_net_id)
- {
- id = p_net_id;
- }
-
- public static void write_scope(WriteScopeParameter p_par, rules.Net p_net, Collection p_pin_list) throws java.io.IOException
- {
- p_par.file.start_scope();
- write_net_id(p_net, p_par.file, p_par.identifier_type);
- // write the pins scope
- p_par.file.start_scope();
- p_par.file.write("pins");
- Iterator it = p_pin_list.iterator();
- while (it.hasNext())
- {
- board.Pin curr_pin = it.next();
- if (curr_pin.contains_net(p_net.net_number))
- {
- write_pin(p_par, curr_pin);
- }
- }
- p_par.file.end_scope();
- p_par.file.end_scope();
- }
-
- public static void write_net_id( rules.Net p_net, IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException
- {
- p_file.write("net ");
- p_identifier_type.write(p_net.name, p_file);
- p_file.write(" ");
- Integer subnet_number = p_net.subnet_number;
- p_file.write(subnet_number.toString());
- }
-
- public static void write_pin(WriteScopeParameter p_par, board.Pin p_pin) throws java.io.IOException
- {
- board.Component curr_component = p_par.board.components.get(p_pin.get_component_no());
- if (curr_component == null)
- {
- System.out.println("Net.write_scope: component not found");
- return;
- }
- library.Package.Pin lib_pin = curr_component.get_package().get_pin(p_pin.get_index_in_package());
- if (lib_pin == null)
- {
- System.out.println("Net.write_scope: pin number out of range");
- return;
- }
- p_par.file.new_line();
- p_par.identifier_type.write(curr_component.name, p_par.file);
- p_par.file.write("-");
- p_par.identifier_type.write(lib_pin.name, p_par.file);
-
- }
-
- public void set_pins(Collection p_pin_list)
- {
- pin_list = new TreeSet();
- for (Pin curr_pin : p_pin_list)
- {
- pin_list.add(curr_pin);
- }
- }
-
- public Set get_pins()
- {
- return pin_list;
- }
-
- public final Id id;
-
- /** List of elements of type Pin. */
- private Set pin_list = null;
-
- public static class Id implements Comparable
- {
- public Id(String p_name, int p_subnet_number)
- {
- name = p_name;
- subnet_number = p_subnet_number;
- }
-
- public int compareTo(Id p_other)
- {
- int result = this.name.compareTo(p_other.name);
- if (result == 0)
- {
- result = this.subnet_number - p_other.subnet_number;
- }
- return result;
- }
-
- public final String name;
- public final int subnet_number;
- }
-
-
- /**
- * Sorted tuple of component name and pin name.
- */
- public static class Pin implements Comparable
- {
- public Pin(String p_component_name, String p_pin_name)
- {
- component_name = p_component_name;
- pin_name = p_pin_name;
- }
-
- public int compareTo(Pin p_other)
- {
- int result = this.component_name.compareTo(p_other.component_name);
- if (result == 0)
- {
- result = this.pin_name.compareTo(p_other.pin_name);
- }
- return result;
- }
-
- public final String component_name;
- public final String pin_name;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/NetClass.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/NetClass.java
deleted file mode 100644
index 2f58819..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/NetClass.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * NetClass.java
- *
- * Created on 13. April 2005, 06:55
- */
-
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-/**
- * Contains the information of a Specctra Class scope.
- *
- * @author alfons
- */
-public class NetClass
-{
-
- public static NetClass read_scope(Scanner p_scanner)
- {
-
- try
- {
- // read the class name
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("NetClass.read_scope: String expected");
- return null;
- }
- String class_name = (String) next_token;
- Collection net_list = new LinkedList();
- boolean rules_missing = false;
- // read the nets belonging to the class
- for (;;)
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- next_token = p_scanner.next_token();
- if (next_token == Keyword.OPEN_BRACKET)
- {
- break;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- rules_missing = true;
- break;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("NetClass.read_scope: String expected");
- return null;
- }
- net_list.add((String) next_token);
- }
- Collection rules = new LinkedList();
- Collection layer_rules = new LinkedList();
- Collection use_via = new LinkedList();
- Collection use_layer = new LinkedList();
- String via_rule = null;
- String trace_clearance_class = null;
- boolean pull_tight = true;
- boolean shove_fixed = false;
- double min_trace_length = 0;
- double max_trace_length = 0;
- if (!rules_missing)
- {
- Object prev_token = next_token;
- for (;;)
- {
- next_token = p_scanner.next_token();
- if (next_token == null)
- {
- System.out.println("NetClass.read_scope: unexpected end of file");
- return null;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.RULE)
- {
- rules.addAll(Rule.read_scope(p_scanner));
- }
- else if (next_token == Keyword.LAYER_RULE)
- {
- layer_rules.add(Rule.read_layer_rule_scope(p_scanner));
- }
- else if (next_token == Keyword.VIA_RULE)
- {
- via_rule = DsnFile.read_string_scope(p_scanner);
- }
- else if (next_token == Keyword.CIRCUIT)
- {
- Circuit.ReadScopeResult curr_rule = Circuit.read_scope(p_scanner);
- if (curr_rule != null)
- {
- max_trace_length = curr_rule.max_length;
- min_trace_length = curr_rule.min_length;
- use_via.addAll(curr_rule.use_via);
- use_layer.addAll(curr_rule.use_layer);
- }
- }
- else if (next_token == Keyword.CLEARANCE_CLASS)
- {
- trace_clearance_class = DsnFile.read_string_scope(p_scanner);
- if (trace_clearance_class == null)
- {
- return null;
- }
- }
- else if (next_token == Keyword.SHOVE_FIXED)
- {
- shove_fixed = DsnFile.read_on_off_scope(p_scanner);
- }
- else if (next_token == Keyword.PULL_TIGHT)
- {
- pull_tight = DsnFile.read_on_off_scope(p_scanner);
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- }
- prev_token = next_token;
- }
- }
- return new NetClass(class_name, trace_clearance_class, net_list, rules, layer_rules,
- use_via, use_layer, via_rule, shove_fixed, pull_tight, min_trace_length, max_trace_length);
- }
- catch (java.io.IOException e)
- {
- System.out.println("NetClass.read_scope: IO error while scanning file");
- return null;
- }
- }
-
- public static ClassClass read_class_class_scope(Scanner p_scanner)
- {
- try
- {
- Collection classes = new LinkedList();
- Collection rules = new LinkedList();
- Collection layer_rules = new LinkedList();
- Object prev_token = null;
- for (;;)
- {
- Object next_token = p_scanner.next_token();
- if (next_token == null)
- {
- System.out.println("ClassClass.read_scope: unexpected end of file");
- return null;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.CLASSES)
- {
- classes.addAll(DsnFile.read_string_list_scope(p_scanner));
- }
- else if (next_token == Keyword.RULE)
- {
- rules.addAll(Rule.read_scope(p_scanner));
- }
- else if (next_token == Keyword.LAYER_RULE)
- {
- layer_rules.add(Rule.read_layer_rule_scope(p_scanner));
- }
- }
- prev_token = next_token;
- }
- return new ClassClass(classes, rules, layer_rules);
- }
- catch (java.io.IOException e)
- {
- System.out.println("NetClass.read_scope: IO error while scanning file");
- return null;
- }
- }
-
- /** Creates a new instance of NetClass */
- public NetClass(String p_name, String p_trace_clearance_class, Collection p_net_list,
- Collection p_rules, Collection p_layer_rules, Collection p_use_via,
- Collection p_use_layer, String p_via_rule, boolean p_shove_fixed, boolean p_pull_tight,
- double p_min_trace_length, double p_max_trace_length)
- {
- name = p_name;
- trace_clearance_class = p_trace_clearance_class;
- net_list = p_net_list;
- rules = p_rules;
- layer_rules = p_layer_rules;
- use_via = p_use_via;
- use_layer = p_use_layer;
- via_rule = p_via_rule;
- shove_fixed = p_shove_fixed;
- pull_tight = p_pull_tight;
- min_trace_length = p_min_trace_length;
- max_trace_length = p_max_trace_length;
- }
-
- public final String name;
- public final String trace_clearance_class;
- public final Collection net_list;
- public final Collection rules;
- public final Collection layer_rules;
- public final Collection use_via;
- public final Collection use_layer;
- public final String via_rule;
- public final boolean shove_fixed;
- public final boolean pull_tight;
- public final double min_trace_length;
- public final double max_trace_length;
-
- public static class ClassClass
- {
- public ClassClass( Collection p_class_names, Collection p_rules,
- Collection p_layer_rules)
- {
- class_names = p_class_names;
- rules = p_rules;
- layer_rules = p_layer_rules;
- }
- public final Collection class_names;
- public final Collection rules;
- public final Collection layer_rules;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/NetList.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/NetList.java
deleted file mode 100644
index 7da2471..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/NetList.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * NetList.java
- *
- * Created on 19. Mai 2004, 09:05
- */
-
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.Set;
-
-/**
- * Describes a list of nets sorted by its names.
- * The net number is generated internally.
- *
- * @author alfons
- */
-public class NetList
-{
-
- /**
- * Returns true, if the netlist contains a net with the input name.
- */
- public boolean contains(Net.Id p_net_id)
- {
- return nets.containsKey(p_net_id);
- }
-
- /**
- * Adds a new net mit the input name to the net list.
- * Returns null, if a net with p_name already exists in the net list.
- * In this case no new net is added.
- */
- public Net add_net(Net.Id p_net_id)
- {
- Net result;
- if (nets.containsKey(p_net_id))
- {
- result = null;
- }
- else
- {
- result = new Net(p_net_id);
- nets.put(p_net_id, result);
- }
- return result;
- }
-
- /**
- * Returns the net with the input name, or null,
- * if the netlist does not contain a net with the input name.
- */
- public Net get_net(Net.Id p_net_id)
- {
- Object value = nets.get(p_net_id);
- return ((Net) value);
- }
-
- /**
- * Returns all nets in this net list containing the input pin.
- */
- public Collection get_nets(String p_component_name, String p_pin_name)
- {
- Collection result = new java.util.LinkedList();
- Net.Pin search_pin = new Net.Pin(p_component_name, p_pin_name);
- Collection net_list = nets.values();
- Iterator it = net_list.iterator();
- while (it.hasNext())
- {
- Net curr_net = it.next();
- Set net_pins = curr_net.get_pins();
- if (net_pins != null && net_pins.contains(search_pin))
- {
- result.add(curr_net);
- }
- }
- return result;
- }
-
- /** The entries of this map are of type Net, the keys are the net_ids. */
- private final Map nets = new TreeMap();
-
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Network.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Network.java
deleted file mode 100644
index 042c6b1..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Network.java
+++ /dev/null
@@ -1,1536 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Network.java
- *
- * Created on 22. Mai 2004, 07:44
- */
-package designformats.specctra;
-
-import geometry.planar.IntPoint;
-import geometry.planar.Point;
-import geometry.planar.Vector;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.Iterator;
-
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-import rules.BoardRules;
-import rules.DefaultItemClearanceClasses.ItemClass;
-import board.RoutingBoard;
-
-/**
- * Class for reading and writing net network from dsn-files.
- *
- * @author Alfons Wirtz
- */
-public class Network extends ScopeKeyword
-{
-
- /** Creates a new instance of Network */
- public Network()
- {
- super("network");
- }
-
- public boolean read_scope(ReadScopeParameter p_par)
- {
- Collection classes = new LinkedList();
- Collection class_class_list = new LinkedList();
- Collection via_infos = new LinkedList();
- Collection> via_rules = new LinkedList>();
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_par.scanner.next_token();
- } catch (java.io.IOException e)
- {
- System.out.println("Network.read_scope: IO error scanning file");
- System.out.println(e);
- return false;
- }
- if (next_token == null)
- {
- System.out.println("Network.read_scope: unexpected end of file");
- return false;
- }
- if (next_token == CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == OPEN_BRACKET)
- {
- if (next_token == Keyword.NET)
- {
- read_net_scope(p_par.scanner, p_par.netlist, p_par.board_handling.get_routing_board(),
- p_par.coordinate_transform, p_par.layer_structure, p_par.board_handling.get_locale());
- }
- else if (next_token == Keyword.VIA)
- {
- rules.ViaInfo curr_via_info = read_via_info(p_par.scanner, p_par.board_handling.get_routing_board());
- if (curr_via_info == null)
- {
- return false;
- }
- via_infos.add(curr_via_info);
- }
- else if (next_token == Keyword.VIA_RULE)
- {
- Collection curr_via_rule = read_via_rule(p_par.scanner, p_par.board_handling.get_routing_board());
- if (curr_via_rule == null)
- {
- return false;
- }
- via_rules.add(curr_via_rule);
- }
- else if (next_token == Keyword.CLASS)
- {
- NetClass curr_class = NetClass.read_scope(p_par.scanner);
- if (curr_class == null)
- {
- return false;
- }
- classes.add(curr_class);
- }
- else if (next_token == Keyword.CLASS_CLASS)
- {
- NetClass.ClassClass curr_class_class = NetClass.read_class_class_scope(p_par.scanner);
- if (curr_class_class == null)
- {
- return false;
- }
- class_class_list.add(curr_class_class);
- }
- else
- {
- skip_scope(p_par.scanner);
- }
- }
- }
- insert_via_infos(via_infos, p_par.board_handling.get_routing_board(), p_par.via_at_smd_allowed);
- insert_via_rules(via_rules, p_par.board_handling.get_routing_board());
- insert_net_classes(classes, p_par);
- insert_class_pairs(class_class_list, p_par);
- insert_compoments(p_par);
- insert_logical_parts(p_par);
- return true;
- }
-
- public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("network");
- Collection board_pins = p_par.board.get_pins();
- for (int i = 1; i <= p_par.board.rules.nets.max_net_no(); ++i)
- {
- Net.write_scope(p_par, p_par.board.rules.nets.get(i), board_pins);
- }
- write_via_infos(p_par.board.rules, p_par.file, p_par.identifier_type);
- write_via_rules(p_par.board.rules, p_par.file, p_par.identifier_type);
- write_net_classes(p_par);
- p_par.file.end_scope();
- }
-
- public static void write_via_infos(rules.BoardRules p_rules, IndentFileWriter p_file, IdentifierType p_identifier_type)
- throws java.io.IOException
- {
- for (int i = 0; i < p_rules.via_infos.count(); ++i)
- {
- rules.ViaInfo curr_via = p_rules.via_infos.get(i);
- p_file.start_scope();
- p_file.write("via ");
- p_file.new_line();
- p_identifier_type.write(curr_via.get_name(), p_file);
- p_file.write(" ");
- p_identifier_type.write(curr_via.get_padstack().name, p_file);
- p_file.write(" ");
- p_identifier_type.write(p_rules.clearance_matrix.get_name(curr_via.get_clearance_class()), p_file);
- if (curr_via.attach_smd_allowed())
- {
- p_file.write(" attach");
- }
- p_file.end_scope();
- }
- }
-
- public static void write_via_rules(rules.BoardRules p_rules, IndentFileWriter p_file, IdentifierType p_identifier_type)
- throws java.io.IOException
- {
- for (rules.ViaRule curr_rule : p_rules.via_rules)
- {
- p_file.start_scope();
- p_file.write("via_rule");
- p_file.new_line();
- p_identifier_type.write(curr_rule.name, p_file);
- for (int i = 0; i < curr_rule.via_count(); ++i)
- {
- p_file.write(" ");
- p_identifier_type.write(curr_rule.get_via(i).get_name(), p_file);
- }
- p_file.end_scope();
- }
- }
-
- public static void write_net_classes(WriteScopeParameter p_par)
- throws java.io.IOException
- {
- for (int i = 0; i < p_par.board.rules.net_classes.count(); ++i)
- {
- write_net_class(p_par.board.rules.net_classes.get(i), p_par);
- }
- }
-
- public static void write_net_class(rules.NetClass p_net_class, WriteScopeParameter p_par)
- throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("class ");
- p_par.identifier_type.write(p_net_class.get_name(), p_par.file);
- final int nets_per_row = 8;
- int net_counter = 0;
- for (int i = 1; i <= p_par.board.rules.nets.max_net_no(); ++i)
- {
- if (p_par.board.rules.nets.get(i).get_class() == p_net_class)
- {
- if (net_counter % nets_per_row == 0)
- {
- p_par.file.new_line();
- }
- else
- {
- p_par.file.write(" ");
- }
- p_par.identifier_type.write(p_par.board.rules.nets.get(i).name, p_par.file);
- ++net_counter;
- }
- }
-
- // write the trace clearance class
- Rule.write_item_clearance_class(p_par.board.rules.clearance_matrix.get_name(p_net_class.get_trace_clearance_class()),
- p_par.file, p_par.identifier_type);
-
- // write the via rule
- p_par.file.new_line();
- p_par.file.write("(via_rule ");
- p_par.file.write(p_net_class.get_via_rule().name);
- p_par.file.write(")");
-
- // write the rules, if they are different from the default rule.
- Rule.write_scope(p_net_class, p_par);
-
- write_circuit(p_net_class, p_par);
-
- if (!p_net_class.get_pull_tight())
- {
- p_par.file.new_line();
- p_par.file.write("(pull_tight off)");
- }
-
- if (p_net_class.is_shove_fixed())
- {
- p_par.file.new_line();
- p_par.file.write("(shove_fixed on)");
- }
-
- p_par.file.end_scope();
- }
-
- private static void write_circuit(rules.NetClass p_net_class, WriteScopeParameter p_par)
- throws java.io.IOException
- {
- double min_trace_length = p_net_class.get_minimum_trace_length();
- double max_trace_length = p_net_class.get_maximum_trace_length();
- p_par.file.start_scope();
- p_par.file.write("circuit ");
- p_par.file.new_line();
- p_par.file.write("(use_layer");
- int layer_count = p_net_class.layer_count();
- for (int i = 0; i < layer_count; ++i)
- {
- if (p_net_class.is_active_routing_layer(i))
- {
- p_par.file.write(" ");
- p_par.file.write(p_par.board.layer_structure.arr[i].name);
- }
- }
- p_par.file.write(")");
- if (min_trace_length > 0 || max_trace_length > 0)
- {
- p_par.file.new_line();
- p_par.file.write("(length ");
- Double transformed_max_length;
- if (max_trace_length <= 0)
- {
- transformed_max_length = (double) -1;
- }
- else
- {
- transformed_max_length = p_par.coordinate_transform.board_to_dsn(max_trace_length);
- }
- p_par.file.write(transformed_max_length.toString());
- p_par.file.write(" ");
- Double transformed_min_length;
- if (min_trace_length <= 0)
- {
- transformed_min_length = (double) 0;
- }
- else
- {
- transformed_min_length = p_par.coordinate_transform.board_to_dsn(min_trace_length);
- }
- p_par.file.write(transformed_min_length.toString());
- p_par.file.write(")");
- }
- p_par.file.end_scope();
- }
-
- private boolean read_net_scope(Scanner p_scanner, NetList p_net_list, RoutingBoard p_board,
- CoordinateTransform p_coordinate_transform, LayerStructure p_layer_structure, java.util.Locale p_locale)
- {
- // read the net name
- Object next_token;
- try
- {
- next_token = p_scanner.next_token();
- } catch (java.io.IOException e)
- {
- System.out.println("Network.read_net_scope: IO error while scanning file");
- return false;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("Network.read_net_scope: String expected");
- return false;
- }
- String net_name = (String) next_token;
- int subnet_number = 1;
- try
- {
- next_token = p_scanner.next_token();
- } catch (java.io.IOException e)
- {
- System.out.println("Network.read_net_scope: IO error while scanning file");
- return false;
- }
- boolean scope_is_empty = (next_token == CLOSED_BRACKET);
- if (next_token instanceof Integer)
- {
- subnet_number = ((Integer) next_token).intValue();
- }
- boolean pin_order_found = false;
- Collection pin_list = new LinkedList();
- Collection net_rules = new LinkedList();
- Collection> subnet_pin_lists = new LinkedList>();
- if (!scope_is_empty)
- {
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_scanner.next_token();
- } catch (java.io.IOException e)
- {
- System.out.println("Network.read_net_scope: IO error scanning file");
- return false;
- }
- if (next_token == null)
- {
- System.out.println("Network.read_net_scope: unexpected end of file");
- return false;
- }
- if (next_token == CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == OPEN_BRACKET)
- {
- if (next_token == Keyword.PINS)
- {
- if (!read_net_pins(p_scanner, pin_list))
- {
- return false;
- }
- }
- else if (next_token == Keyword.ORDER)
- {
- pin_order_found = true;
- if (!read_net_pins(p_scanner, pin_list))
- {
- return false;
- }
- }
- else if (next_token == Keyword.FROMTO)
- {
- Set curr_subnet_pin_list = new java.util.TreeSet();
- if (!read_net_pins(p_scanner, curr_subnet_pin_list))
- {
- return false;
- }
- subnet_pin_lists.add(curr_subnet_pin_list);
- }
- else if (next_token == Keyword.RULE)
- {
- net_rules.addAll(Rule.read_scope(p_scanner));
- }
- else if (next_token == Keyword.LAYER_RULE)
- {
- System.out.println("Netwark.read_net_scope: layer_rule not yet implemented");
- skip_scope(p_scanner);
- }
- else
- {
- skip_scope(p_scanner);
- }
- }
- }
- }
- if (subnet_pin_lists.isEmpty())
- {
- if (pin_order_found)
- {
- subnet_pin_lists = create_ordered_subnets(pin_list);
- }
- else
- {
- subnet_pin_lists.add(pin_list);
- }
- }
- for (Collection curr_pin_list : subnet_pin_lists)
- {
- Net.Id net_id = new Net.Id(net_name, subnet_number);
- if (!p_net_list.contains(net_id))
- {
- Net new_net = p_net_list.add_net(net_id);
- boolean contains_plane = p_layer_structure.contains_plane(net_name);
- if (new_net != null)
- {
- p_board.rules.nets.add(new_net.id.name, new_net.id.subnet_number, contains_plane);
- }
- }
- Net curr_subnet = p_net_list.get_net(net_id);
- if (curr_subnet == null)
- {
- System.out.println("Network.read_net_scope: net not found in netlist");
- return false;
- }
- curr_subnet.set_pins(curr_pin_list);
- if (!net_rules.isEmpty())
- {
- // Evaluate the net rules.
- rules.Net board_net = p_board.rules.nets.get(curr_subnet.id.name, curr_subnet.id.subnet_number);
- if (board_net == null)
- {
- System.out.println("Network.read_net_scope: board net not found");
- return false;
- }
- Iterator it = net_rules.iterator();
- while (it.hasNext())
- {
- Rule curr_ob = it.next();
- if (curr_ob instanceof Rule.WidthRule)
- {
- rules.NetClass default_net_rule = p_board.rules.get_default_net_class();
- double wire_width = ((Rule.WidthRule) curr_ob).value;
- int trace_halfwidth = (int) Math.round(p_coordinate_transform.dsn_to_board(wire_width) / 2);
- rules.NetClass net_rule =
- p_board.rules.net_classes.find(trace_halfwidth, default_net_rule.get_trace_clearance_class(),
- default_net_rule.get_via_rule());
- if (net_rule == null)
- {
- // create a new net rule
- net_rule = p_board.rules.get_new_net_class(p_locale);
- }
- net_rule.set_trace_half_width(trace_halfwidth);
- board_net.set_class(net_rule);
- }
- else
- {
- System.out.println("Network.read_net_scope: Rule not yet implemented");
- }
- }
- }
- ++subnet_number;
- }
- return true;
- }
-
- /**
- * Creates a sequence of subnets with 2 pins from p_pin_list
- */
- private static Collection> create_ordered_subnets(Collection p_pin_list)
- {
- Collection> result = new LinkedList>();
- if (p_pin_list.isEmpty())
- {
- return result;
- }
-
- Iterator it = p_pin_list.iterator();
- Net.Pin prev_pin = it.next();
- while (it.hasNext())
- {
- Net.Pin next_pin = it.next();
- Set curr_subnet_pin_list = new java.util.TreeSet();
- curr_subnet_pin_list.add(prev_pin);
- curr_subnet_pin_list.add(next_pin);
- result.add(curr_subnet_pin_list);
- prev_pin = next_pin;
- }
- return result;
- }
-
- private static boolean read_net_pins(Scanner p_scanner, Collection p_pin_list)
- {
- Object next_token;
- for (;;)
- {
- try
- {
- p_scanner.yybegin(SpecctraFileScanner.COMPONENT_NAME);
- next_token = p_scanner.next_token();
- } catch (java.io.IOException e)
- {
- System.out.println("Network.read_net_pins: IO error while scanning file");
- return false;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- break;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("Network.read_net_pins: String expected");
- return false;
- }
- String component_name = (String) next_token;
- try
- {
- p_scanner.yybegin(SpecctraFileScanner.SPEC_CHAR);
- next_token = p_scanner.next_token(); // overread the hyphen
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- next_token = p_scanner.next_token();
- } catch (java.io.IOException e)
- {
- System.out.println("Network.read_net_pins: IO error while scanning file");
- return false;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("Network.read_net_pins: String expected");
- return false;
- }
- String pin_name = (String) next_token;
- Net.Pin curr_entry = new Net.Pin(component_name, pin_name);
- p_pin_list.add(curr_entry);
- }
- return true;
- }
-
- static rules.ViaInfo read_via_info(Scanner p_scanner, board.BasicBoard p_board)
- {
- try
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Network.read_via_info: string expected");
- return null;
- }
- String name = (String) next_token;
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Network.read_via_info: string expected");
- return null;
- }
- String padstack_name = (String) next_token;
- library.Padstack via_padstack = p_board.library.get_via_padstack(padstack_name);
- if (via_padstack == null)
- {
- // The padstack may not yet be inserted into the list of via padstacks
- via_padstack = p_board.library.padstacks.get(padstack_name);
- if (via_padstack == null)
- {
- System.out.println("Network.read_via_info: padstack not found");
- return null;
- }
- p_board.library.add_via_padstack(via_padstack);
- }
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Network.read_via_info: string expected");
- return null;
- }
- int clearance_class = p_board.rules.clearance_matrix.get_no((String) next_token);
- if (clearance_class < 0)
- {
- // Clearance class not stored, because it is identical to the default clearance class.
- clearance_class = BoardRules.default_clearance_class();
- }
- boolean attach_allowed = false;
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- if (next_token != Keyword.ATTACH)
- {
- System.out.println("Network.read_via_info: Keyword.ATTACH expected");
- return null;
- }
- attach_allowed = true;
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Network.read_via_info: closing bracket expected");
- return null;
- }
- }
- return new rules.ViaInfo(name, via_padstack, clearance_class, attach_allowed, p_board.rules);
- } catch (java.io.IOException e)
- {
- System.out.println("Network.read_via_info: IO error while scanning file");
- return null;
- }
- }
-
- static Collection read_via_rule(Scanner p_scanner, board.BasicBoard p_board)
- {
- try
- {
- Collection result = new LinkedList();
- for (;;)
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- Object next_token = p_scanner.next_token();
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- break;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("Network.read_via_rule: string expected");
- return null;
- }
- result.add((String) next_token);
- }
- return result;
- } catch (java.io.IOException e)
- {
- System.out.println("Network.read_via_rule: IO error while scanning file");
- return null;
- }
- }
-
- private static void insert_via_infos(Collection p_via_infos, RoutingBoard p_board, boolean p_attach_allowed)
- {
- if (p_via_infos.size() > 0)
- {
- for (rules.ViaInfo curr_info : p_via_infos)
- {
- p_board.rules.via_infos.add(curr_info);
- }
- }
- else // no via infos found, create default via infos from the via padstacks.
- {
- create_default_via_infos(p_board, p_board.rules.get_default_net_class(), p_attach_allowed);
- }
- }
-
- private static void create_default_via_infos(board.BasicBoard p_board, rules.NetClass p_net_class, boolean p_attach_allowed)
- {
- int cl_class = p_net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.VIA);
- boolean is_default_class = (p_net_class == p_board.rules.get_default_net_class());
- for (int i = 0; i < p_board.library.via_padstack_count(); ++i)
- {
- library.Padstack curr_padstack = p_board.library.get_via_padstack(i);
- boolean attach_allowed = p_attach_allowed && curr_padstack.attach_allowed;
- String via_name;
- if (is_default_class)
- {
- via_name = curr_padstack.name;
- }
- else
- {
- via_name = curr_padstack.name + DsnFile.CLASS_CLEARANCE_SEPARATOR + p_net_class.get_name();
- }
- rules.ViaInfo found_via_info =
- new rules.ViaInfo(via_name, curr_padstack, cl_class, attach_allowed, p_board.rules);
- p_board.rules.via_infos.add(found_via_info);
- }
- }
-
- private static void insert_via_rules(Collection> p_via_rules, board.BasicBoard p_board)
- {
- boolean rule_found = false;
- for (Collection curr_list : p_via_rules)
- {
- if (curr_list.size() < 2)
- {
- continue;
- }
- if (add_via_rule(curr_list, p_board))
- {
- rule_found = true;
- }
- }
- if (!rule_found)
- {
- p_board.rules.create_default_via_rule(p_board.rules.get_default_net_class(), "default");
- }
- for (int i = 0; i < p_board.rules.net_classes.count(); ++i)
- {
- p_board.rules.net_classes.get(i).set_via_rule(p_board.rules.get_default_via_rule());
- }
- }
-
- /**
- * Inserts a via rule into the board.
- * Replaces an already existing via rule with the same
- */
- static boolean add_via_rule(Collection p_name_list, board.BasicBoard p_board)
- {
- Iterator it = p_name_list.iterator();
- String rule_name = it.next();
- rules.ViaRule existing_rule = p_board.rules.get_via_rule(rule_name);
- rules.ViaRule curr_rule = new rules.ViaRule(rule_name);
- boolean rule_ok = true;
- while (it.hasNext())
- {
- rules.ViaInfo curr_via = p_board.rules.via_infos.get(it.next());
- if (curr_via != null)
- {
- curr_rule.append_via(curr_via);
- }
- else
- {
- System.out.println("Network.insert_via_rules: via_info not found");
- rule_ok = false;
- }
- }
- if (rule_ok)
- {
- if (existing_rule != null)
- {
- // Replace already existing rule.
- p_board.rules.via_rules.remove(existing_rule);
- }
- p_board.rules.via_rules.add(curr_rule);
- }
- return rule_ok;
- }
-
- private static void insert_net_classes(Collection p_net_classes, ReadScopeParameter p_par)
- {
- board.BasicBoard routing_board = p_par.board_handling.get_routing_board();
- for (NetClass curr_class : p_net_classes)
- {
- insert_net_class(curr_class, p_par.layer_structure, routing_board, p_par.coordinate_transform, p_par.via_at_smd_allowed);
- }
- }
-
- static void insert_net_class(NetClass p_class, LayerStructure p_layer_structure, board.BasicBoard p_board, CoordinateTransform p_coordinate_transform,
- boolean p_via_at_smd_allowed)
- {
- rules.NetClass board_net_class = p_board.rules.append_net_class(p_class.name);
- if (p_class.trace_clearance_class != null)
- {
- int trace_clearance_class = p_board.rules.clearance_matrix.get_no(p_class.trace_clearance_class);
- if (trace_clearance_class >= 0)
- {
- board_net_class.set_trace_clearance_class(trace_clearance_class);
- }
- else
- {
- System.out.println("Network.insert_net_class: clearance class not found");
- }
- }
- if (p_class.via_rule != null)
- {
- rules.ViaRule via_rule = p_board.rules.get_via_rule(p_class.via_rule);
- if (via_rule != null)
- {
- board_net_class.set_via_rule(via_rule);
- }
- else
- {
- System.out.println("Network.insert_net_class: via rule not found");
- }
- }
- if (p_class.max_trace_length > 0)
- {
- board_net_class.set_maximum_trace_length(p_coordinate_transform.dsn_to_board(p_class.max_trace_length));
- }
- if (p_class.min_trace_length > 0)
- {
- board_net_class.set_minimum_trace_length(p_coordinate_transform.dsn_to_board(p_class.min_trace_length));
- }
- for (String curr_net_name : p_class.net_list)
- {
- Collection curr_net_list = p_board.rules.nets.get(curr_net_name);
- for (rules.Net curr_net : curr_net_list)
- {
- curr_net.set_class(board_net_class);
- }
- }
-
- // read the trace width and clearance rules.
-
- boolean clearance_rule_found = false;
-
- for (Rule curr_rule : p_class.rules)
- {
- if (curr_rule instanceof Rule.WidthRule)
- {
- int trace_halfwidth = (int) Math.round(p_coordinate_transform.dsn_to_board(((Rule.WidthRule) curr_rule).value / 2));
- board_net_class.set_trace_half_width(trace_halfwidth);
- }
- else if (curr_rule instanceof Rule.ClearanceRule)
- {
- add_clearance_rule(p_board.rules.clearance_matrix, board_net_class,
- (Rule.ClearanceRule) curr_rule, -1, p_coordinate_transform);
- clearance_rule_found = true;
- }
- else
- {
-
- System.out.println("Network.insert_net_class: rule type not yet implemented");
- }
- }
-
- // read the layer dependent rules.
-
- for (Rule.LayerRule curr_layer_rule : p_class.layer_rules)
- {
- for (String curr_layer_name : curr_layer_rule.layer_names)
- {
- int layer_no = p_board.layer_structure.get_no(curr_layer_name);
- if (layer_no < 0)
- {
- System.out.println("Network.insert_net_class: layer not found");
- continue;
- }
- for (Rule curr_rule : curr_layer_rule.rules)
- {
- if (curr_rule instanceof Rule.WidthRule)
- {
- int trace_halfwidth = (int) Math.round(p_coordinate_transform.dsn_to_board(((Rule.WidthRule) curr_rule).value / 2));
- board_net_class.set_trace_half_width(layer_no, trace_halfwidth);
- }
- else if (curr_rule instanceof Rule.ClearanceRule)
- {
- add_clearance_rule(p_board.rules.clearance_matrix, board_net_class, (Rule.ClearanceRule) curr_rule, layer_no, p_coordinate_transform);
- clearance_rule_found = true;
- }
- else
- {
- System.out.println("Network.insert_net_class: layer rule type not yet implemented");
- }
- }
- }
- }
-
- board_net_class.set_pull_tight(p_class.pull_tight);
- board_net_class.set_shove_fixed(p_class.shove_fixed);
- boolean via_infos_created = false;
-
- if (clearance_rule_found && board_net_class != p_board.rules.get_default_net_class())
- {
- create_default_via_infos(p_board, board_net_class, p_via_at_smd_allowed);
- via_infos_created = true;
- }
-
- if (!p_class.use_via.isEmpty())
- {
- create_via_rule(p_class.use_via, board_net_class, p_board, p_via_at_smd_allowed);
- }
- else if (via_infos_created)
- {
- p_board.rules.create_default_via_rule(board_net_class, board_net_class.get_name());
- }
- if (!p_class.use_layer.isEmpty())
- {
- create_active_trace_layers(p_class.use_layer, p_layer_structure, board_net_class);
- }
- }
-
- static private void insert_class_pairs(Collection p_class_classes, ReadScopeParameter p_par)
- {
- for (NetClass.ClassClass curr_class_class : p_class_classes)
- {
- java.util.Iterator it1 = curr_class_class.class_names.iterator();
- board.BasicBoard routing_board = p_par.board_handling.get_routing_board();
- while (it1.hasNext())
- {
- String first_name = it1.next();
- rules.NetClass first_class = routing_board.rules.net_classes.get(first_name);
- if (first_class == null)
- {
- System.out.println("Network.insert_class_pairs: first class not found");
- }
- else
- {
- java.util.Iterator it2 = it1;
- while (it2.hasNext())
- {
- String second_name = it2.next();
- rules.NetClass second_class = routing_board.rules.net_classes.get(second_name);
- if (second_class == null)
- {
- System.out.println("Network.insert_class_pairs: second class not found");
- }
- else
- {
- insert_class_pair_info(curr_class_class, first_class, second_class, routing_board,
- p_par.coordinate_transform);
- }
- }
- }
- }
- }
- }
-
- static private void insert_class_pair_info(NetClass.ClassClass p_class_class, rules.NetClass p_first_class, rules.NetClass p_second_class,
- board.BasicBoard p_board, CoordinateTransform p_coordinate_transform)
- {
- for (Rule curr_rule : p_class_class.rules)
- {
- if (curr_rule instanceof Rule.ClearanceRule)
- {
- Rule.ClearanceRule curr_clearance_rule = (Rule.ClearanceRule) curr_rule;
- add_mixed_clearance_rule(p_board.rules.clearance_matrix, p_first_class, p_second_class,
- curr_clearance_rule, -1, p_coordinate_transform);
- }
- else
- {
- System.out.println("Network.insert_class_pair_info: unexpected rule");
- }
- }
- for (Rule.LayerRule curr_layer_rule : p_class_class.layer_rules)
- {
- for (String curr_layer_name : curr_layer_rule.layer_names)
- {
- int layer_no = p_board.layer_structure.get_no(curr_layer_name);
- if (layer_no < 0)
- {
- System.out.println("Network.insert_class_pair_info: layer not found");
- continue;
- }
- for (Rule curr_rule : curr_layer_rule.rules)
- {
- if (curr_rule instanceof Rule.ClearanceRule)
- {
- add_mixed_clearance_rule(p_board.rules.clearance_matrix,
- p_first_class, p_second_class, (Rule.ClearanceRule) curr_rule,
- layer_no, p_coordinate_transform);
- }
- else
- {
- System.out.println("Network.insert_class_pair_info: unexpected layer rule type");
- }
- }
- }
- }
- }
-
- static private void add_mixed_clearance_rule(rules.ClearanceMatrix p_clearance_matrix, rules.NetClass p_first_class,
- rules.NetClass p_second_class, Rule.ClearanceRule p_clearance_rule, int p_layer_no,
- CoordinateTransform p_coordinate_transform)
- {
- int curr_clearance = (int) Math.round(p_coordinate_transform.dsn_to_board(p_clearance_rule.value));
- final String first_class_name = p_first_class.get_name();
- int first_class_no = p_clearance_matrix.get_no(first_class_name);
- if (first_class_no < 0)
- {
- p_clearance_matrix.append_class(first_class_name);
- first_class_no = p_clearance_matrix.get_no(first_class_name);
- }
- final String second_class_name = p_second_class.get_name();
- int second_class_no = p_clearance_matrix.get_no(second_class_name);
- if (second_class_no < 0)
- {
- p_clearance_matrix.append_class(second_class_name);
- second_class_no = p_clearance_matrix.get_no(second_class_name);
- }
- if (p_clearance_rule.clearance_class_pairs.isEmpty())
- {
- if (p_layer_no < 0)
- {
- p_clearance_matrix.set_value(first_class_no, second_class_no, curr_clearance);
- p_clearance_matrix.set_value(second_class_no, first_class_no, curr_clearance);
- }
- else
- {
- p_clearance_matrix.set_value(first_class_no, second_class_no, p_layer_no, curr_clearance);
- p_clearance_matrix.set_value(second_class_no, first_class_no, p_layer_no, curr_clearance);
- }
- }
- else
- {
- Iterator it = p_clearance_rule.clearance_class_pairs.iterator();
- while (it.hasNext())
- {
- String curr_string = it.next();
- String[] curr_pair = curr_string.split("_");
- if (curr_pair.length != 2)
- {
- continue;
- }
-
- int curr_first_class_no;
- int curr_second_class_no;
- for (int i = 0; i < 2; ++i)
- {
- if (i == 0)
- {
- curr_first_class_no = get_clearance_class(p_clearance_matrix, p_first_class, curr_pair[0]);
- curr_second_class_no = get_clearance_class(p_clearance_matrix, p_second_class, curr_pair[1]);
- }
- else
- {
- curr_first_class_no = get_clearance_class(p_clearance_matrix, p_second_class, curr_pair[0]);
- curr_second_class_no = get_clearance_class(p_clearance_matrix, p_first_class, curr_pair[1]);
- }
- if (p_layer_no < 0)
- {
- p_clearance_matrix.set_value(curr_first_class_no, curr_second_class_no, curr_clearance);
- p_clearance_matrix.set_value(curr_second_class_no, curr_first_class_no, curr_clearance);
- }
- else
- {
- p_clearance_matrix.set_value(curr_first_class_no, curr_second_class_no, p_layer_no, curr_clearance);
- p_clearance_matrix.set_value(curr_second_class_no, curr_first_class_no, p_layer_no, curr_clearance);
- }
- }
- }
- }
- }
-
- static private void create_default_clearance_classes(rules.NetClass p_net_class,
- rules.ClearanceMatrix p_clearance_matrix)
- {
- get_clearance_class(p_clearance_matrix, p_net_class, "via");
- get_clearance_class(p_clearance_matrix, p_net_class, "smd");
- get_clearance_class(p_clearance_matrix, p_net_class, "pin");
- get_clearance_class(p_clearance_matrix, p_net_class, "area");
- }
-
- private static void create_via_rule(Collection p_use_via, rules.NetClass p_net_class, board.BasicBoard p_board, boolean p_attach_allowed)
- {
- rules.ViaRule new_via_rule = new rules.ViaRule(p_net_class.get_name());
- int default_via_cl_class = p_net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.VIA);
- for (String curr_via_name : p_use_via)
- {
- for (int i = 0; i < p_board.rules.via_infos.count(); ++i)
- {
- rules.ViaInfo curr_via_info = p_board.rules.via_infos.get(i);
- if (curr_via_info.get_clearance_class() == default_via_cl_class)
- {
- if (curr_via_info.get_padstack().name.equals(curr_via_name))
- {
- new_via_rule.append_via(curr_via_info);
- }
- }
- }
- }
- p_board.rules.via_rules.add(new_via_rule);
- p_net_class.set_via_rule(new_via_rule);
- }
-
- private static void create_active_trace_layers(Collection p_use_layer, LayerStructure p_layer_structure, rules.NetClass p_net_class)
- {
- for (int i = 0; i < p_layer_structure.arr.length; ++i)
- {
- p_net_class.set_active_routing_layer(i, false);
- }
- for (String cur_layer_name : p_use_layer)
- {
- int curr_no = p_layer_structure.get_no(cur_layer_name);
- p_net_class.set_active_routing_layer(curr_no, true);
- }
- // currently all inactive layers have tracewidth 0.
- for (int i = 0; i < p_layer_structure.arr.length; ++i)
- {
- if (!p_net_class.is_active_routing_layer(i))
- {
- p_net_class.set_trace_half_width(i, 0);
- }
- }
- }
-
- private static void add_clearance_rule(rules.ClearanceMatrix p_clearance_matrix, rules.NetClass p_net_class,
- Rule.ClearanceRule p_rule, int p_layer_no, CoordinateTransform p_coordinate_transform)
- {
- int curr_clearance = (int) Math.round(p_coordinate_transform.dsn_to_board(p_rule.value));
- final String class_name = p_net_class.get_name();
- int class_no = p_clearance_matrix.get_no(class_name);
- if (class_no < 0)
- {
- // class not yet existing, create a new class
- p_clearance_matrix.append_class(class_name);
- class_no = p_clearance_matrix.get_no(class_name);
- // set the clearance values of the new class to the maximum of curr_clearance and the
- // the existing values.
- for (int i = 1; i < p_clearance_matrix.get_class_count(); ++i)
- {
- for (int j = 0; j < p_clearance_matrix.get_layer_count(); ++j)
- {
- int curr_value = Math.max(p_clearance_matrix.value(class_no, i, j), curr_clearance);
- p_clearance_matrix.set_value(class_no, i, j, curr_value);
- p_clearance_matrix.set_value(i, class_no, j, curr_value);
- }
- }
- p_net_class.default_item_clearance_classes.set_all(class_no);
- }
- p_net_class.set_trace_clearance_class(class_no);
- if (p_rule.clearance_class_pairs.isEmpty())
- {
- if (p_layer_no < 0)
- {
- p_clearance_matrix.set_value(class_no, class_no, curr_clearance);
- }
- else
- {
- p_clearance_matrix.set_value(class_no, class_no, p_layer_no, curr_clearance);
- }
- return;
- }
- if (Structure.contains_wire_clearance_pair(p_rule.clearance_class_pairs))
- {
- create_default_clearance_classes(p_net_class, p_clearance_matrix);
- }
- Iterator it = p_rule.clearance_class_pairs.iterator();
- while (it.hasNext())
- {
- String curr_string = it.next();
- String[] curr_pair = curr_string.split("_");
- if (curr_pair.length != 2)
- {
- continue;
- }
-
- int first_class_no = get_clearance_class(p_clearance_matrix, p_net_class, curr_pair[0]);
- int second_class_no = get_clearance_class(p_clearance_matrix, p_net_class, curr_pair[1]);
-
- if (p_layer_no < 0)
- {
- p_clearance_matrix.set_value(first_class_no, second_class_no, curr_clearance);
- p_clearance_matrix.set_value(second_class_no, first_class_no, curr_clearance);
- }
- else
- {
- p_clearance_matrix.set_value(first_class_no, second_class_no, p_layer_no, curr_clearance);
- p_clearance_matrix.set_value(second_class_no, first_class_no, p_layer_no, curr_clearance);
- }
- }
- }
-
- /**
- * Gets the number of the clearance class with name combined of p_net_class_name and p_item_class_name.
- * Creates a new class, if that class is not yet existing.
- */
- static private int get_clearance_class(rules.ClearanceMatrix p_clearance_matrix,
- rules.NetClass p_net_class, String p_item_class_name)
- {
- String net_class_name = p_net_class.get_name();
- String new_class_name = net_class_name;
- if (!p_item_class_name.equals("wire"))
- {
- new_class_name = new_class_name + DsnFile.CLASS_CLEARANCE_SEPARATOR + p_item_class_name;
- }
- int found_class_no = p_clearance_matrix.get_no(new_class_name);
- if (found_class_no >= 0)
- {
- return found_class_no;
- }
- p_clearance_matrix.append_class(new_class_name);
- int result = p_clearance_matrix.get_no(new_class_name);
- int net_class_no = p_clearance_matrix.get_no(net_class_name);
- if (net_class_no < 0 || result < 0)
- {
- System.out.println("Network.get_clearance_class: clearance class not found");
- return result;
- }
- // initalise the clearance values of p_new_class_name from p_net_class_name
- for (int i = 1; i < p_clearance_matrix.get_class_count(); ++i)
- {
-
- for (int j = 0; j < p_clearance_matrix.get_layer_count(); ++j)
- {
- int curr_value = p_clearance_matrix.value(net_class_no, i, j);
- p_clearance_matrix.set_value(result, i, j, curr_value);
- p_clearance_matrix.set_value(i, result, j, curr_value);
- }
- }
- if (p_item_class_name.equals("via"))
- {
- p_net_class.default_item_clearance_classes.set(ItemClass.VIA, result);
- }
- else if (p_item_class_name.equals("pin"))
- {
- p_net_class.default_item_clearance_classes.set(ItemClass.PIN, result);
- }
- else if (p_item_class_name.equals("smd"))
- {
- p_net_class.default_item_clearance_classes.set(ItemClass.SMD, result);
- }
- else if (p_item_class_name.equals("area"))
- {
- p_net_class.default_item_clearance_classes.set(ItemClass.AREA, result);
- }
- return result;
- }
-
- private static void insert_compoments(ReadScopeParameter p_par)
- {
- Iterator it = p_par.placement_list.iterator();
- while (it.hasNext())
- {
- ComponentPlacement next_lib_component = it.next();
- Iterator it2 = next_lib_component.locations.iterator();
- while (it2.hasNext())
- {
- ComponentPlacement.ComponentLocation next_component = it2.next();
- insert_component(next_component, next_lib_component.lib_name, p_par);
- }
-
- }
- }
-
- /**
- * Create the part library on the board. Can be called after the components are inserted.
- * Returns false, if an error occured.
- */
- private static boolean insert_logical_parts(ReadScopeParameter p_par)
- {
- board.BasicBoard routing_board = p_par.board_handling.get_routing_board();
- for (PartLibrary.LogicalPart next_part : p_par.logical_parts)
- {
- library.Package lib_package = search_lib_package(next_part.name, p_par.logical_part_mappings, routing_board);
- if (lib_package == null)
- {
- return false;
- }
- library.LogicalPart.PartPin[] board_part_pins =
- new library.LogicalPart.PartPin[next_part.part_pins.size()];
- int curr_index = 0;
- for (PartLibrary.PartPin curr_part_pin : next_part.part_pins)
- {
- int pin_no = lib_package.get_pin_no(curr_part_pin.pin_name);
- if (pin_no < 0)
- {
- System.out.println("Network.insert_logical_parts: package pin not found");
- return false;
- }
- board_part_pins[curr_index] =
- new library.LogicalPart.PartPin(pin_no, curr_part_pin.pin_name,
- curr_part_pin.gate_name, curr_part_pin.gate_swap_code,
- curr_part_pin.gate_pin_name, curr_part_pin.gate_pin_swap_code);
- ++curr_index;
- }
- routing_board.library.logical_parts.add(next_part.name, board_part_pins);
- }
-
- for (PartLibrary.LogicalPartMapping next_mapping : p_par.logical_part_mappings)
- {
- library.LogicalPart curr_logical_part = routing_board.library.logical_parts.get(next_mapping.name);
- {
- if (curr_logical_part == null)
- {
- System.out.println("Network.insert_logical_parts: logical part not found");
- }
- }
- for (String curr_cmp_name : next_mapping.components)
- {
- board.Component curr_component = routing_board.components.get(curr_cmp_name);
- if (curr_component != null)
- {
- curr_component.set_logical_part(curr_logical_part);
- }
- else
- {
- System.out.println("Network.insert_logical_parts: board component not found");
- }
- }
- }
- return true;
- }
-
- /**
- * Calculates the library package belonging to the logical part with name p_part_name.
- * Returns null, if the package was not found.
- */
- private static library.Package search_lib_package(String p_part_name,
- java.util.Collection p_logical_part_mappings, board.BasicBoard p_board)
- {
- for (PartLibrary.LogicalPartMapping curr_mapping : p_logical_part_mappings)
- {
- if (curr_mapping.name.equals(p_part_name))
- {
- if (curr_mapping.components.isEmpty())
- {
- System.out.println("Network.search_lib_package: component list empty");
- return null;
- }
- String component_name = curr_mapping.components.first();
- if (component_name == null)
- {
- System.out.println("Network.search_lib_package: component list empty");
- return null;
- }
- board.Component curr_component = p_board.components.get(component_name);
- if (curr_component == null)
- {
- System.out.println("Network.search_lib_package: component not found");
- return null;
- }
- return curr_component.get_package();
- }
- }
- System.out.print("Network.search_lib_package: library package ");
- System.out.print(p_part_name);
- System.out.println(" not found");
- return null;
- }
-
- /**
- * Inserts all board components belonging to the input library component.
- */
- private static void insert_component(ComponentPlacement.ComponentLocation p_location, String p_lib_key,
- ReadScopeParameter p_par)
- {
- board.RoutingBoard routing_board = p_par.board_handling.get_routing_board();
- library.Package curr_front_package = routing_board.library.packages.get(p_lib_key, true);
- library.Package curr_back_package = routing_board.library.packages.get(p_lib_key, false);
- if (curr_front_package == null || curr_back_package == null)
- {
- System.out.println("Network.insert_component: component package not found");
- return;
- }
-
- IntPoint component_location;
- if (p_location.coor != null)
- {
- component_location = p_par.coordinate_transform.dsn_to_board(p_location.coor).round();
- }
- else
- {
- component_location = null;
- }
- double rotation_in_degree = p_location.rotation;
-
- board.Component new_component = routing_board.components.add(p_location.name, component_location,
- rotation_in_degree, p_location.is_front, curr_front_package, curr_back_package, p_location.position_fixed);
-
- if (component_location == null)
- {
- return; // component is not yet placed.
- }
- Vector component_translation = component_location.difference_by(Point.ZERO);
- board.FixedState fixed_state;
- if (p_location.position_fixed)
- {
- fixed_state = board.FixedState.SYSTEM_FIXED;
- }
- else
- {
- fixed_state = board.FixedState.UNFIXED;
- }
- library.Package curr_package = new_component.get_package();
- for (int i = 0; i < curr_package.pin_count(); ++i)
- {
- library.Package.Pin curr_pin = curr_package.get_pin(i);
- library.Padstack curr_padstack = routing_board.library.padstacks.get(curr_pin.padstack_no);
- if (curr_padstack == null)
- {
- System.out.println("Network.insert_component: pin padstack not found");
- return;
- }
- Collection pin_nets = p_par.netlist.get_nets(p_location.name, curr_pin.name);
- Collection net_numbers = new LinkedList();
- for (Net curr_pin_net : pin_nets)
- {
- rules.Net curr_board_net = routing_board.rules.nets.get(curr_pin_net.id.name, curr_pin_net.id.subnet_number);
- if (curr_board_net == null)
- {
- System.out.println("Network.insert_component: board net not found");
-
- }
- else
- {
- net_numbers.add(curr_board_net.net_number);
- }
- }
- int[] net_no_arr = new int[net_numbers.size()];
- int net_index = 0;
- for (Integer curr_net_no : net_numbers)
- {
- net_no_arr[net_index] = curr_net_no;
- ++net_index;
- }
- rules.NetClass net_class;
- rules.Net board_net;
- if (net_no_arr.length > 0)
- {
- board_net = routing_board.rules.nets.get(net_no_arr[0]);
- }
- else
- {
- board_net = null;
- }
- if (board_net != null)
- {
- net_class = board_net.get_class();
- }
- else
- {
- net_class = routing_board.rules.get_default_net_class();
- }
- int clearance_class = -1;
- ComponentPlacement.ItemClearanceInfo pin_info = p_location.pin_infos.get(curr_pin.name);
- if (pin_info != null)
- {
- clearance_class = routing_board.rules.clearance_matrix.get_no(pin_info.clearance_class);
- }
- if (clearance_class < 0)
- {
- if (curr_padstack.from_layer() == curr_padstack.to_layer())
- {
- clearance_class = net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.SMD);
- }
- else
- {
- clearance_class = net_class.default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.PIN);
- }
- }
- routing_board.insert_pin(new_component.no, i, net_no_arr, clearance_class, fixed_state);
- }
-
- // insert the keepouts belonging to the package (k = 1 for via keepouts)
- for (int k = 0; k <= 2; ++k)
- {
- library.Package.Keepout[] keepout_arr;
- java.util.Map curr_keepout_infos;
- if (k == 0)
- {
- keepout_arr = curr_package.keepout_arr;
- curr_keepout_infos = p_location.keepout_infos;
- }
- else if (k == 1)
- {
- keepout_arr = curr_package.via_keepout_arr;
- curr_keepout_infos = p_location.via_keepout_infos;
- }
- else
- {
- keepout_arr = curr_package.place_keepout_arr;
- curr_keepout_infos = p_location.place_keepout_infos;
- }
- for (int i = 0; i < keepout_arr.length; ++i)
- {
- library.Package.Keepout curr_keepout = keepout_arr[i];
- int layer = curr_keepout.layer;
- if (layer >= routing_board.get_layer_count())
- {
- System.out.println("Network.insert_component: keepout layer is to big");
- continue;
- }
- if (layer >= 0 && !p_location.is_front)
- {
- layer = routing_board.get_layer_count() - curr_keepout.layer - 1;
- }
- int clearance_class =
- routing_board.rules.get_default_net_class().default_item_clearance_classes.get(rules.DefaultItemClearanceClasses.ItemClass.AREA);
- ComponentPlacement.ItemClearanceInfo keepout_info = curr_keepout_infos.get(curr_keepout.name);
- if (keepout_info != null)
- {
- int curr_clearance_class = routing_board.rules.clearance_matrix.get_no(keepout_info.clearance_class);
- if (curr_clearance_class > 0)
- {
- clearance_class = curr_clearance_class;
- }
- }
- if (layer >= 0)
- {
- if (k == 0)
- {
- routing_board.insert_obstacle(curr_keepout.area, layer, component_translation,
- rotation_in_degree, !p_location.is_front, clearance_class, new_component.no,
- curr_keepout.name, fixed_state);
- }
- else if (k == 1)
- {
- routing_board.insert_via_obstacle(curr_keepout.area, layer, component_translation,
- rotation_in_degree, !p_location.is_front, clearance_class, new_component.no,
- curr_keepout.name, fixed_state);
- }
- else
- {
- routing_board.insert_component_obstacle(curr_keepout.area, layer, component_translation,
- rotation_in_degree, !p_location.is_front, clearance_class, new_component.no,
- curr_keepout.name, fixed_state);
- }
- }
- else
- {
- // insert the obstacle on all signal layers
- for (int j = 0; j < routing_board.layer_structure.arr.length; ++j)
- {
- if (routing_board.layer_structure.arr[j].is_signal)
- {
- if (k == 0)
- {
- routing_board.insert_obstacle(curr_keepout.area, j, component_translation,
- rotation_in_degree, !p_location.is_front, clearance_class, new_component.no,
- curr_keepout.name, fixed_state);
- }
- else if (k == 1)
- {
- routing_board.insert_via_obstacle(curr_keepout.area, j, component_translation,
- rotation_in_degree, !p_location.is_front, clearance_class, new_component.no,
- curr_keepout.name, fixed_state);
- }
- else
- {
- routing_board.insert_component_obstacle(curr_keepout.area, j, component_translation,
- rotation_in_degree, !p_location.is_front, clearance_class, new_component.no,
- curr_keepout.name, fixed_state);
- }
- }
- }
- }
- }
- }
- // insert the outline as component keepout
- for (int i = 0; i < curr_package.outline.length; ++i)
- {
-
- routing_board.insert_component_outline(curr_package.outline[i], p_location.is_front, component_translation,
- rotation_in_degree, new_component.no, fixed_state);
- }
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Package.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Package.java
deleted file mode 100644
index 6347cac..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Package.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Package.java
- *
- * Created on 21. Mai 2004, 09:31
- */
-
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import board.Item;
-
-/**
- * Class for reading and writing package scopes from dsn-files.
- *
- * @author alfons
- */
-public class Package
-{
-
- /** Creates a new instance of Package */
- public Package(String p_name, PinInfo[] p_pin_info_arr, Collection p_outline, Collection p_keepouts,
- Collection p_via_keepouts, Collection p_place_keepouts, boolean p_is_front)
- {
- name = p_name;
- pin_info_arr = p_pin_info_arr;
- outline = p_outline;
- keepouts = p_keepouts;
- via_keepouts = p_via_keepouts;
- place_keepouts = p_place_keepouts;
- is_front = p_is_front;
- }
-
- public static Package read_scope(Scanner p_scanner, LayerStructure p_layer_structure)
- {
- try
- {
- boolean is_front = true;
- Collection outline = new LinkedList();
- Collection keepouts = new LinkedList();
- Collection via_keepouts = new LinkedList();
- Collection place_keepouts = new LinkedList();
- Object next_token = p_scanner.next_token();
- if ( !(next_token instanceof String))
- {
- System.out.println("Package.read_scope: String expected");
- return null;
- }
- String package_name = (String) next_token;
- Collection pin_info_list = new LinkedList();
- for (;;)
- {
- Object prev_token = next_token;
- next_token = p_scanner.next_token();
-
- if (next_token == null)
- {
- System.out.println("Package.read_scope: unexpected end of file");
- return null;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.PIN)
- {
- PinInfo next_pin = read_pin_info(p_scanner);
- if (next_pin == null)
- {
- return null;
- }
- pin_info_list.add(next_pin);
- }
- else if (next_token == Keyword.SIDE)
- {
- is_front = read_placement_side(p_scanner);
- }
- else if (next_token == Keyword.OUTLINE)
- {
- Shape curr_shape = Shape.read_scope(p_scanner, p_layer_structure);
- if (curr_shape != null)
- {
- outline.add(curr_shape);
- }
- // overread closing bracket
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Package.read_scope: closed bracket expected");
- return null;
- }
- }
- else if (next_token == Keyword.KEEPOUT)
- {
- Shape.ReadAreaScopeResult keepout_area = Shape.read_area_scope(p_scanner, p_layer_structure, false);
- if (keepout_area != null)
- {
- keepouts.add(keepout_area);
- }
- }
- else if (next_token == Keyword.VIA_KEEPOUT)
- {
- Shape.ReadAreaScopeResult keepout_area = Shape.read_area_scope(p_scanner, p_layer_structure, false);
- if (keepout_area != null)
- {
- via_keepouts.add(keepout_area);
- }
- }
- else if (next_token == Keyword.PLACE_KEEPOUT)
- {
- Shape.ReadAreaScopeResult keepout_area = Shape.read_area_scope(p_scanner, p_layer_structure, false);
- if (keepout_area != null)
- {
- place_keepouts.add(keepout_area);
- }
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- }
- }
- PinInfo [] pin_info_arr = new PinInfo[pin_info_list.size()];
- Iterator it = pin_info_list.iterator();
- for (int i = 0; i < pin_info_arr.length; ++i)
- {
- pin_info_arr[i] = it.next();
- }
- return new Package(package_name, pin_info_arr, outline, keepouts, via_keepouts, place_keepouts, is_front);
- }
- catch (java.io.IOException e)
- {
- System.out.println("Package.read_scope: IO error scanning file");
- System.out.println(e);
- return null;
- }
- }
-
- public static void write_scope(WriteScopeParameter p_par, library.Package p_package) throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("image ");
- p_par.identifier_type.write(p_package.name, p_par.file);
- // write the placement side of the package
- p_par.file.new_line();
- p_par.file.write("(side ");
- if (p_package.is_front)
- {
- p_par.file.write("front)");
- }
- else
- {
- p_par.file.write("back)");
- }
- // write the pins of the package
- for (int i = 0; i < p_package.pin_count(); ++i)
- {
- library.Package.Pin curr_pin = p_package.get_pin(i);
- p_par.file.new_line();
- p_par.file.write("(pin ");
- library.Padstack curr_padstack = p_par.board.library.padstacks.get(curr_pin.padstack_no);
- p_par.identifier_type.write(curr_padstack.name, p_par.file);
- p_par.file.write(" ");
- p_par.identifier_type.write(curr_pin.name, p_par.file);
- double [] rel_coor = p_par.coordinate_transform.board_to_dsn(curr_pin.relative_location);
- for(int j = 0; j < rel_coor.length; ++j)
- {
- p_par.file.write(" ");
- p_par.file.write((new Double(rel_coor[j])).toString());
- }
- int rotation = (int) Math.round(curr_pin.rotation_in_degree);
- if (rotation != 0)
- {
- p_par.file.write("(rotate ");
- p_par.file.write((new Integer(rotation)).toString());
- p_par.file.write(")");
- }
- p_par.file.write(")");
- }
- // write the keepouts belonging to the package.
- for (int i = 0; i < p_package.keepout_arr.length; ++i)
- {
- write_package_keepout(p_package.keepout_arr[i], p_par, false);
- }
- for (int i = 0; i < p_package.via_keepout_arr.length; ++i)
- {
- write_package_keepout(p_package.via_keepout_arr[i], p_par, true);
- }
- // write the package outline.
- for (int i = 0; i < p_package.outline.length; ++i)
- {
- p_par.file.start_scope();
- p_par.file.write("outline");
- Shape curr_outline = p_par.coordinate_transform.board_to_dsn_rel(p_package.outline[i], Layer.SIGNAL);
- curr_outline.write_scope(p_par.file, p_par.identifier_type);
- p_par.file.end_scope();
- }
- p_par.file.end_scope();
- }
-
- private static void write_package_keepout(library.Package.Keepout p_keepout, WriteScopeParameter p_par,
- boolean p_is_via_keepout) throws java.io.IOException
- {
- Layer keepout_layer;
- if (p_keepout.layer >= 0)
- {
- board.Layer board_layer = p_par.board.layer_structure.arr[p_keepout.layer];
- keepout_layer = new Layer(board_layer.name, p_keepout.layer, board_layer.is_signal);
- }
- else
- {
- keepout_layer = Layer.SIGNAL;
- }
- geometry.planar.Shape boundary_shape;
- geometry.planar.Shape [] holes;
- if (p_keepout.area instanceof geometry.planar.Shape)
- {
- boundary_shape = (geometry.planar.Shape) p_keepout.area ;
- holes = new geometry.planar.Shape [0];
- }
- else
- {
- boundary_shape = p_keepout.area .get_border();
- holes = p_keepout.area .get_holes();
- }
- p_par.file.start_scope();
- if (p_is_via_keepout)
- {
- p_par.file.write("via_keepout");
- }
- else
- {
- p_par.file.write("keepout");
- }
- Shape dsn_shape = p_par.coordinate_transform.board_to_dsn(boundary_shape, keepout_layer);
- if (dsn_shape != null)
- {
- dsn_shape.write_scope(p_par.file, p_par.identifier_type);
- }
- for (int j = 0; j < holes.length; ++j)
- {
- Shape dsn_hole = p_par.coordinate_transform.board_to_dsn(holes[j], keepout_layer);
- dsn_hole.write_hole_scope(p_par.file, p_par.identifier_type);
- }
- p_par.file.end_scope();
- }
-
- /** Reads the information of a single pin in a package. */
- private static PinInfo read_pin_info(Scanner p_scanner)
- {
- try
- {
- // Read the padstack name.
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- String padstack_name = null;
- Object next_token = p_scanner.next_token();
- if ( next_token instanceof String)
- {
- padstack_name = (String) next_token;
- }
- else if ( next_token instanceof Integer)
- {
- padstack_name = ((Integer) next_token).toString();
- }
- else
- {
- System.out.println("Package.read_pin_info: String or Integer expected");
- return null;
- }
- double rotation = 0;
-
- p_scanner.yybegin(SpecctraFileScanner.NAME); // to be able to handle pin names starting with a digit.
- next_token = p_scanner.next_token();
- if (next_token == Keyword.OPEN_BRACKET)
- {
- // read the padstack rotation
- next_token = p_scanner.next_token();
- if (next_token == Keyword.ROTATE)
- {
- rotation = read_rotation(p_scanner);
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- next_token = p_scanner.next_token();
- }
- // Read the pin name.
- String pin_name = null;
- if ( next_token instanceof String)
- {
- pin_name = (String) next_token;
- }
- else if ( next_token instanceof Integer)
- {
- pin_name = ((Integer) next_token).toString();
- }
- else
- {
- System.out.println("Package.read_pin_info: String or Integer expected");
- return null;
- }
-
- double [] pin_coor = new double [2];
- for (int i = 0; i < 2; ++i)
- {
- next_token = p_scanner.next_token();
- if (next_token instanceof Double)
- {
- pin_coor[i] = ((Double) next_token).doubleValue();
- }
- else if (next_token instanceof Integer)
- {
- pin_coor[i] = ((Integer) next_token).intValue();
- }
- else
- {
- System.out.println("Package.read_pin_info: number expected");
- return null;
- }
- }
- // Handle scopes at the end of the pin scope.
- for (;;)
- {
- Object prev_token = next_token;
- next_token = p_scanner.next_token();
-
- if (next_token == null)
- {
- System.out.println("Package.read_pin_info: unexpected end of file");
- return null;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.ROTATE)
- {
- rotation = read_rotation(p_scanner);
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- }
- }
- return new PinInfo(padstack_name, pin_name, pin_coor, rotation);
- }
- catch (java.io.IOException e)
- {
- System.out.println("Package.read_pin_info: IO error while scanning file");
- return null;
- }
- }
-
- private static double read_rotation(Scanner p_scanner)
- {
- double result = 0;
- try
- {
- Object next_token = p_scanner.next_token();
- if (next_token instanceof Integer)
- {
- result = ((Integer)next_token).intValue();
- }
- else if (next_token instanceof Double)
- {
- result = ((Double)next_token).doubleValue();
- }
- else
- {
- System.out.println("Package.read_rotation: number expected");
- }
- // Overread The closing bracket.
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Package.read_rotation: closing bracket expected");
- }
- }
- catch (java.io.IOException e)
- {
- System.out.println("Package.read_rotation: IO error while scanning file");
- }
- return result;
- }
-
- /**
- * Writes the placements of p_package to a Specctra dsn-file.
- */
- public static void write_placement_scope(WriteScopeParameter p_par, library.Package p_package)
- throws java.io.IOException
- {
- Collection- board_items = p_par.board.get_items();
- boolean component_found = false;
- for (int i = 1; i <= p_par.board.components.count(); ++i)
- {
- board.Component curr_component = p_par.board.components.get(i);
- if (curr_component.get_package() == p_package)
- {
- // check, if not all items of the component are deleted
- boolean undeleted_item_found = false;
- Iterator
- it = board_items.iterator();
- while (it.hasNext())
- {
- Item curr_item = it.next();
- if (curr_item.get_component_no() == curr_component.no)
- {
- undeleted_item_found = true;
- break;
- }
- }
- if (undeleted_item_found || !curr_component.is_placed())
- {
- if (!component_found)
- {
- // write the scope header
- p_par.file.start_scope();
- p_par.file.write("component ");
- p_par.identifier_type.write(p_package.name, p_par.file);
- component_found = true;
- }
- Component.write_scope(p_par, curr_component);
- }
- }
- }
- if (component_found)
- {
- p_par.file.end_scope();
- }
- }
-
- private static boolean read_placement_side(Scanner p_scanner) throws java.io.IOException
- {
- Object next_token = p_scanner.next_token();
- boolean result = (next_token != Keyword.BACK);
-
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Package.read_placement_side: closing bracket expected");
- }
- return result;
- }
-
-
- public final String name;
- /** List of objects of type PinInfo. */
- public final PinInfo[] pin_info_arr;
- /** The outline of the package. */
- public final Collection outline;
- /** Collection of keepoouts belonging to this package */
- public final Collection keepouts;
- /** Collection of via keepoouts belonging to this package */
- public final Collection via_keepouts;
- /** Collection of place keepoouts belonging to this package */
- public final Collection place_keepouts;
- /** If false, the package is placed on the back side of the board */
- public final boolean is_front;
-
-
- /** Describes the Iinformation of a pin in a package. */
- static public class PinInfo
- {
- PinInfo(String p_padstack_name, String p_pin_name, double [] p_rel_coor, double p_rotation)
- {
- padstack_name = p_padstack_name;
- pin_name = p_pin_name;
- rel_coor = p_rel_coor;
- rotation = p_rotation;
- }
- /** Phe name of the pastack of this pin. */
- public final String padstack_name;
- /** Phe name of this pin. */
- public final String pin_name;
- /** The x- and y-coordinates relative to the package location. */
- public final double [] rel_coor;
- /** The rotation of the pin relative to the package. */
- public final double rotation;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Parser.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Parser.java
deleted file mode 100644
index dffc2dc..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Parser.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Parser.java
- *
- * Created on 24. Januar 2005, 08:29
- */
-package designformats.specctra;
-
-import board.Communication.SpecctraParserInfo;
-
-/**
- * Class for reading and writing parser scopes from dsn-files.
- *
- * @author Alfons Wirtz
- */
-public class Parser extends ScopeKeyword
-{
-
- /** Creates a new instance of Parser */
- public Parser()
- {
- super("parser");
- }
-
- public boolean read_scope(ReadScopeParameter p_par)
- {
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_par.scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("Parser.read_scope: IO error scanning file");
- return false;
- }
- if (next_token == null)
- {
- System.out.println("Parser.read_scope: unexpected end of file");
- return false;
- }
- if (next_token == CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- boolean read_ok = true;
- if (prev_token == OPEN_BRACKET)
- {
- if (next_token == Keyword.STRING_QUOTE)
- {
- String quote_char = read_quote_char(p_par.scanner);
- if (quote_char == null)
- {
- return false;
- }
- p_par.string_quote = quote_char;
- }
- else if (next_token == Keyword.HOST_CAD)
- {
- p_par.host_cad = DsnFile.read_string_scope(p_par.scanner);
- }
- else if (next_token == Keyword.HOST_VERSION)
- {
- p_par.host_version = DsnFile.read_string_scope(p_par.scanner);
- }
- else if (next_token == Keyword.CONSTANT)
- {
- String[] curr_constant = read_constant(p_par);
- if (curr_constant != null)
- {
- p_par.constants.add(curr_constant);
- }
- }
- else if (next_token == Keyword.WRITE_RESOLUTION)
- {
- p_par.write_resolution = read_write_solution(p_par);
- }
- else if (next_token == Keyword.GENERATED_BY_FREEROUTE)
- {
- p_par.dsn_file_generated_by_host = false;
- // skip the closing bracket
- skip_scope(p_par.scanner);
- }
- else
- {
- skip_scope(p_par.scanner);
- }
- }
- if (!read_ok)
- {
- return false;
- }
- }
- return true;
- }
-
- private static SpecctraParserInfo.WriteResolution read_write_solution(ReadScopeParameter p_par)
- {
- try
- {
- Object next_token = p_par.scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Parser.read_write_solution: string expected");
- return null;
- }
- String resolution_string = (String) next_token;
- next_token = p_par.scanner.next_token();
- if (!(next_token instanceof Integer))
- {
- System.out.println("Parser.read_write_solution: integer expected expected");
- return null;
- }
- int resolution_value = (Integer) next_token;
- next_token = p_par.scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Parser.read_write_solution: closing_bracket expected");
- return null;
- }
- return new SpecctraParserInfo.WriteResolution(resolution_string, resolution_value);
- }
- catch (java.io.IOException e)
- {
- System.out.println("Parser.read_write_solution: IO error scanning file");
- return null;
- }
- }
-
- private static String[] read_constant(ReadScopeParameter p_par)
- {
- try
- {
- String[] result = new String[2];
- p_par.scanner.yybegin(SpecctraFileScanner.NAME);
- Object next_token = p_par.scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Parser.read_constant: string expected");
- return null;
- }
- result[0] = (String) next_token;
- p_par.scanner.yybegin(SpecctraFileScanner.NAME);
- next_token = p_par.scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Parser.read_constant: string expected");
- return null;
- }
- result[1] = (String) next_token;
- next_token = p_par.scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Parser.read_constant: closing_bracket expected");
- return null;
- }
- return result;
- }
- catch (java.io.IOException e)
- {
- System.out.println("Parser.read_constant: IO error scanning file");
- return null;
- }
- }
-
- /**
- * p_reduced is true if the scope is written to a session file.
- */
- public static void write_scope(datastructures.IndentFileWriter p_file, SpecctraParserInfo p_parser_info,
- datastructures.IdentifierType p_identifier_type, boolean p_reduced) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("parser");
- if (!p_reduced)
- {
- p_file.new_line();
- p_file.write("(string_quote ");
- p_file.write(p_parser_info.string_quote);
- p_file.write(")");
- p_file.new_line();
- p_file.write("(space_in_quoted_tokens on)");
- }
- if (p_parser_info.host_cad != null)
- {
- p_file.new_line();
- p_file.write("(host_cad ");
- p_identifier_type.write(p_parser_info.host_cad, p_file);
- p_file.write(")");
- }
- if (p_parser_info.host_version != null)
- {
- p_file.new_line();
- p_file.write("(host_version ");
- p_identifier_type.write(p_parser_info.host_version, p_file);
- p_file.write(")");
- }
- if (p_parser_info.constants != null)
- {
- for (String[] curr_constant : p_parser_info.constants)
- {
- p_file.new_line();
- p_file.write("(constant ");
- for (int i = 0; i < curr_constant.length; ++i)
- {
- p_identifier_type.write(curr_constant[i], p_file);
- p_file.write(" ");
- }
- p_file.write(")");
- }
- }
- if (p_parser_info.write_resolution != null)
- {
- p_file.new_line();
- p_file.write("(write_resolution ");
- p_file.write(p_parser_info.write_resolution.char_name.substring(0, 1));
- p_file.write(" ");
- Integer positive_int = p_parser_info.write_resolution.positive_int;
- p_file.write(positive_int.toString());
- p_file.write(")");
- }
- if (!p_reduced)
- {
- p_file.new_line();
- p_file.write("(generated_by_freeroute)");
- }
- p_file.end_scope();
- }
-
- private static String read_quote_char(Scanner p_scanner)
- {
- try
- {
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Parser.read_quote_char: string expected");
- return null;
- }
- String result = (String) next_token;
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Parser.read_quote_char: closing bracket expected");
- return null;
- }
- return result;
- }
- catch (java.io.IOException e)
- {
- System.out.println("Parser.read_quote_char: IO error scanning file");
- return null;
- }
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PartLibrary.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PartLibrary.java
deleted file mode 100644
index c0ebb4f..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PartLibrary.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * PartLibrary.java
- *
- * Created on 23. Maerz 2005, 08:36
- */
-
-package designformats.specctra;
-
-/**
- *
- * @author Alfons Wirtz
- */
-public class PartLibrary extends ScopeKeyword
-{
-
- /** Creates a new instance of PartLibrary */
- public PartLibrary()
- {
- super("part_library");
- }
-
- public boolean read_scope(ReadScopeParameter p_par)
- {
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_par.scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("PartLibrary.read_scope: IO error scanning file");
- System.out.println(e);
- return false;
- }
- if (next_token == null)
- {
- System.out.println("PartLibrary.read_scope: unexpected end of file");
- return false;
- }
- if (next_token == CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == OPEN_BRACKET)
- {
- if (next_token == Keyword.LOGICAL_PART_MAPPING)
- {
- LogicalPartMapping next_mapping = read_logical_part_mapping(p_par.scanner);
- if (next_mapping == null)
- {
- return false;
- }
- p_par.logical_part_mappings.add(next_mapping);
- }
- else if (next_token == Keyword.LOGICAL_PART)
- {
- LogicalPart next_part = read_logical_part(p_par.scanner);
- if (next_part == null)
- {
- return false;
- }
- p_par.logical_parts.add(next_part);
- }
- else
- {
- skip_scope(p_par.scanner);
- }
- }
- }
- return true;
- }
-
- public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException
- {
- library.LogicalParts logical_parts = p_par.board.library.logical_parts;
- if (logical_parts.count() <= 0)
- {
- return;
- }
- p_par.file.start_scope();
- p_par.file.write("part_library");
-
- // write the logical part mappings
-
- for (int i = 1; i <= logical_parts.count(); ++i)
- {
- library.LogicalPart curr_part = logical_parts.get(i);
- p_par.file.start_scope();
- p_par.file.write("logical_part_mapping ");
- p_par.identifier_type.write(curr_part.name, p_par.file);
- p_par.file.new_line();
- p_par.file.write("(comp");
- for (int j = 1; j <= p_par.board.components.count(); ++j)
- {
- board.Component curr_compomnent = p_par.board.components.get(j);
- if (curr_compomnent.get_logical_part() == curr_part)
- {
- p_par.file.write(" ");
- p_par.file.write(curr_compomnent.name);
- }
- }
- p_par.file.write(")");
- p_par.file.end_scope();
- }
-
- // write the logical parts.
-
- for (int i = 1; i <= logical_parts.count(); ++i)
- {
- library.LogicalPart curr_part = logical_parts.get(i);
-
- p_par.file.start_scope();
- p_par.file.write("logical_part ");
- p_par.identifier_type.write(curr_part.name, p_par.file);
- p_par.file.new_line();
- for (int j = 0; j < curr_part.pin_count(); ++j)
- {
- p_par.file.new_line();
- library.LogicalPart.PartPin curr_pin = curr_part.get_pin(j);
- p_par.file.write("(pin ");
- p_par.identifier_type.write(curr_pin.pin_name, p_par.file);
- p_par.file.write(" 0 ");
- p_par.identifier_type.write(curr_pin.gate_name, p_par.file);
- p_par.file.write(" ");
- Integer gate_swap_code = curr_pin.gate_swap_code;
- p_par.file.write(gate_swap_code.toString());
- p_par.file.write(" ");
- p_par.identifier_type.write(curr_pin.gate_pin_name, p_par.file);
- p_par.file.write(" ");
- Integer gate_pin_swap_code = curr_pin.gate_pin_swap_code;
- p_par.file.write(gate_pin_swap_code.toString());
- p_par.file.write(")");
- }
- p_par.file.end_scope();
- }
- p_par.file.end_scope();
- }
-
- /**
- * Reads the component list of a logical part mapping.
- * Returns null, if an error occured.
- */
- private LogicalPartMapping read_logical_part_mapping(Scanner p_scanner)
- {
- try
- {
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("PartLibrary.read_logical_part_mapping: string expected");
- return null;
- }
- String name = (String) next_token;
- next_token = p_scanner.next_token();
- if (next_token != Keyword.OPEN_BRACKET)
- {
- System.out.println("PartLibrary.read_logical_part_mapping: open bracket expected");
- return null;
- }
- next_token = p_scanner.next_token();
- if (next_token != Keyword.COMPONENT_SCOPE)
- {
- System.out.println("PartLibrary.read_logical_part_mapping: Keyword.COMPONENT_SCOPE expected");
- return null;
- }
- java.util.SortedSet result = new java.util.TreeSet();
- for(;;)
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- next_token = p_scanner.next_token();
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- break;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("PartLibrary.read_logical_part_mapping: string expected");
- return null;
- }
- result.add((String) next_token);
- }
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("PartLibrary.read_logical_part_mapping: closing bracket expected");
- return null;
- }
- return new LogicalPartMapping(name, result);
- }
- catch (java.io.IOException e)
- {
- System.out.println("PartLibrary.read_logical_part_mapping: IO error scanning file");
- return null;
- }
- }
-
- private LogicalPart read_logical_part(Scanner p_scanner)
- {
- java.util.Collection part_pins = new java.util.LinkedList();
- Object next_token = null;
- try
- {
- next_token = p_scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("PartLibrary.read_logical_part: IO error scanning file");
- return null;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("PartLibrary.read_logical_part: string expected");
- return null;
- }
- String part_name = (String) next_token;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("PartLibrary.read_logical_part: IO error scanning file");
- return null;
- }
- if (next_token == null)
- {
- System.out.println("PartLibrary.read_logical_part: unexpected end of file");
- return null;
- }
- if (next_token == CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- boolean read_ok = true;
- if (prev_token == OPEN_BRACKET)
- {
- if (next_token == Keyword.PIN)
- {
- PartPin curr_part_pin = read_part_pin(p_scanner);
- if (curr_part_pin == null)
- {
- return null;
- }
- part_pins.add(curr_part_pin);
- }
- else
- {
- skip_scope(p_scanner);
- }
- }
- if (!read_ok)
- {
- return null;
- }
- }
- return new LogicalPart(part_name, part_pins);
- }
-
- private PartPin read_part_pin(Scanner p_scanner)
- {
- try
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("PartLibrary.read_part_pin: string expected");
- return null;
- }
- String pin_name = (String) next_token;
- next_token = p_scanner.next_token();
- if (!(next_token instanceof Integer))
- {
- System.out.println("PartLibrary.read_part_pin: integer expected");
- return null;
- }
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("PartLibrary.read_part_pin: string expected");
- return null;
- }
- String gate_name = (String) next_token;
- next_token = p_scanner.next_token();
- if (!(next_token instanceof Integer))
- {
- System.out.println("PartLibrary.read_part_pin: integer expected");
- return null;
- }
- int gate_swap_code = (Integer) next_token;
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("PartLibrary.read_part_pin: string expected");
- return null;
- }
- String gate_pin_name = (String) next_token;
- next_token = p_scanner.next_token();
- if (!(next_token instanceof Integer))
- {
- System.out.println("PartLibrary.read_part_pin: integer expected");
- return null;
- }
- int gate_pin_swap_code = (Integer) next_token;
- // overread subgates
- for (;;)
- {
- next_token = p_scanner.next_token();
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- break;
- }
- }
- return new PartPin(pin_name, gate_name, gate_swap_code, gate_pin_name, gate_pin_swap_code);
- }
- catch (java.io.IOException e)
- {
- System.out.println("PartLibrary.read_part_pin: IO error scanning file");
- return null;
- }
- }
-
- public static class LogicalPartMapping
- {
- private LogicalPartMapping(String p_name, java.util.SortedSet p_components)
- {
- name = p_name;
- components = p_components;
- }
- /** The name of the maopping. */
- public final String name;
-
- /** The conponents belonging to the mapping. */
- public final java.util.SortedSet components;
- }
-
- public static class PartPin
- {
- private PartPin(String p_pin_name, String p_gate_name, int p_gate_swap_code,
- String p_gate_pin_name, int p_gate_pin_swap_code)
- {
- pin_name = p_pin_name;
- gate_name = p_gate_name;
- gate_swap_code = p_gate_swap_code;
- gate_pin_name = p_gate_pin_name;
- gate_pin_swap_code = p_gate_pin_swap_code;
- }
-
- public final String pin_name;
- public final String gate_name;
- public final int gate_swap_code;
- public final String gate_pin_name;
- public final int gate_pin_swap_code;
- }
-
- public static class LogicalPart
- {
- private LogicalPart(String p_name, java.util.Collection p_part_pins)
- {
- name = p_name;
- part_pins = p_part_pins;
- }
- /** The name of the maopping. */
- public final String name;
-
- /** The pins of this logical part */
- public final java.util.Collection part_pins;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Path.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Path.java
deleted file mode 100644
index 2cad403..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Path.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Path.java
- *
- * Created on 30. Juni 2004, 09:28
- */
-
-package designformats.specctra;
-
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-/**
- * Class for writing path scopes from dsn-files.
- *
- * @author alfons
- */
-public abstract class Path extends Shape
-{
-
- /** Creates a new instance of Path */
- Path(Layer p_layer, double p_width, double[] p_coordinate_arr)
- {
- super (p_layer);
- width = p_width;
- coordinate_arr = p_coordinate_arr;
- }
-
- /**
- * Writes this path as a scope to an output dsn-file.
- */
- public abstract void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException;
-
- public final double width;
- public final double [] coordinate_arr;
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PlaceControl.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PlaceControl.java
deleted file mode 100644
index e71ab91..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PlaceControl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * PlaceControl.java
- *
- * Created on 25. November 2004, 13:21
- */
-
-package designformats.specctra;
-
-/**
- * Class for reading place_control scopes from dsn-files.
- *
- * @author Alfons Wirtz
- */
-public class PlaceControl extends ScopeKeyword
-{
-
- /** Creates a new instance of PlaceControl */
- public PlaceControl()
- {
- super("place_control");
- }
-
- /** Reads the flip_style */
- public boolean read_scope(ReadScopeParameter p_par)
- {
- boolean flip_style_rotate_first = false;
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_par.scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("PlaceControl.read_scope: IO error scanning file");
- return false;
- }
- if (next_token == null)
- {
- System.out.println("PlaceControl.read_scope: unexpected end of file");
- return false;
- }
- if (next_token == CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == OPEN_BRACKET)
- {
- if (next_token == Keyword.FLIP_STYLE)
- {
- flip_style_rotate_first = read_flip_style_rotate_first(p_par.scanner);
- }
- }
- }
- if (flip_style_rotate_first)
- {
- p_par.board_handling.get_routing_board().components.set_flip_style_rotate_first(true);
- }
- return true;
- }
-
- /**
- * Returns true, if rotate_first is read, else false.
- */
- static boolean read_flip_style_rotate_first(Scanner p_scanner)
- {
- try
- {
- boolean result = false;
- Object next_token = p_scanner.next_token();
- if (next_token == Keyword.ROTATE_FIRST)
- {
- if (next_token == Keyword.ROTATE_FIRST)
- {
- result = true;
- }
- }
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Structure.read_flip_style: closing bracket expected");
- return false;
- }
- return result;
- }
- catch (java.io.IOException e)
- {
- System.out.println("Structure.read_flip_style: IO error scanning file");
- return false;
- }
- }
-
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Placement.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Placement.java
deleted file mode 100644
index d03f9cd..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Placement.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Placement.java
- *
- * Created on 5. Juli 2004, 08:53
- */
-
-package designformats.specctra;
-
-/**
- * Class for writing placement scopes from dsn-files.
- *
- * @author Alfons Wirtz
- */
-public class Placement extends ScopeKeyword
-{
-
- /** Creates a new instance of Placemet */
- public Placement()
- {
- super("placement");
- }
-
- public static void write_scope(WriteScopeParameter p_par) throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("placement");
- if (p_par.board.components.get_flip_style_rotate_first())
- {
- p_par.file.new_line();
- p_par.file.write("(place_control (flip_style rotate_first))");
- }
- for (int i = 1; i <= p_par.board.library.packages.count(); ++i)
- {
- Package.write_placement_scope(p_par, p_par.board.library.packages.get(i));
- }
- p_par.file.end_scope();
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Plane.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Plane.java
deleted file mode 100644
index f58fab0..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Plane.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Plane.java
- *
- * Created on 19. Mai 2004, 08:39
- */
-
-package designformats.specctra;
-
-
-
-/**
- * Class for reading and writing plane scopes from dsn-files.
- *
- * @author alfons
- */
-public class Plane extends ScopeKeyword
-{
-
- /** Creates a new instance of Plane */
- public Plane()
- {
- super("plane");
- }
-
- public boolean read_scope(ReadScopeParameter p_par)
- {
- // read the net name
- String net_name = null;
- boolean skip_window_scopes = p_par.host_cad != null && p_par.host_cad.equalsIgnoreCase("allegro");
- // Cadence Allegro cutouts the pins on power planes, which leads to performance problems
- // when dividing a conduction area into convex pieces.
- Shape.ReadAreaScopeResult conduction_area = null;
- try
- {
- Object next_token = p_par.scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Plane.read_scope: String expected");
- return false;
- }
- net_name = (String) next_token;
- conduction_area = Shape.read_area_scope(p_par.scanner, p_par.layer_structure, skip_window_scopes);
- }
- catch (java.io.IOException e)
- {
- System.out.println("Plane.read_scope: IO error scanning file");
- System.out.println(e);
- return false;
- }
- ReadScopeParameter.PlaneInfo plane_info = new ReadScopeParameter.PlaneInfo(conduction_area, net_name);
- p_par.plane_list.add(plane_info);
- return true;
- }
-
- public static void write_scope(WriteScopeParameter p_par, board.ConductionArea p_conduction) throws java.io.IOException
- {
- int net_count = p_conduction.net_count();
- if (net_count <= 0 || net_count > 1)
- {
- System.out.println("Plane.write_scope: unexpected net count");
- return;
- }
- String net_name = p_par.board.rules.nets.get(p_conduction.get_net_no(0)).name;
- geometry.planar.Area curr_area = p_conduction.get_area();
- int layer_no = p_conduction.get_layer();
- board.Layer board_layer = p_par.board.layer_structure.arr[ layer_no];
- Layer plane_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal);
- geometry.planar.Shape boundary_shape;
- geometry.planar.Shape [] holes;
- if (curr_area instanceof geometry.planar.Shape)
- {
- boundary_shape = (geometry.planar.Shape) curr_area;
- holes = new geometry.planar.Shape [0];
- }
- else
- {
- boundary_shape = curr_area.get_border();
- holes = curr_area.get_holes();
- }
- p_par.file.start_scope();
- p_par.file.write("plane ");
- p_par.identifier_type.write(net_name, p_par.file);
- Shape dsn_shape = p_par.coordinate_transform.board_to_dsn(boundary_shape, plane_layer);
- if (dsn_shape != null)
- {
- dsn_shape.write_scope(p_par.file, p_par.identifier_type);
- }
- for (int i = 0; i < holes.length; ++i)
- {
- Shape dsn_hole = p_par.coordinate_transform.board_to_dsn(holes[i], plane_layer);
- dsn_hole.write_hole_scope(p_par.file, p_par.identifier_type);
- }
- p_par.file.end_scope();
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Polygon.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Polygon.java
deleted file mode 100644
index 3231e54..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Polygon.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Polygon.java
- *
- * Created on 15. Mai 2004, 08:39
- */
-
-package designformats.specctra;
-import geometry.planar.IntPoint;
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-/**
- * Describes a polygon in a Specctra dsn file.
- *
- * @author alfons
- */
-public class Polygon extends Shape
-{
- /**
- * Creates a new instance of Polygon
- * p_coor is an array of dimension of dimension 2 * point_count and contains x0, y0, x1, y1, ...
- * If the polygon is used as rectangle,
- */
- public Polygon(Layer p_layer, double[] p_coor)
- {
- super(p_layer);
- coor = p_coor;
- }
-
- public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform)
- {
- IntPoint [] corner_arr = new IntPoint[coor.length / 2];
- double [] curr_point = new double [2];
- for (int i = 0; i < corner_arr.length; ++i)
- {
- curr_point[0] = coor[2 * i];
- curr_point[1] = coor[2 * i + 1];
- corner_arr[i] = p_coordinate_transform.dsn_to_board(curr_point).round();
- }
- return new geometry.planar.PolygonShape(corner_arr);
- }
-
- public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform)
- {
- if (coor.length < 2)
- {
- return geometry.planar.Simplex.EMPTY;
- }
- IntPoint [] corner_arr = new IntPoint[coor.length / 2];
- for (int i = 0; i < corner_arr.length; ++i)
- {
- int curr_x = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[2 * i]));
- int curr_y = (int) Math.round(p_coordinate_transform.dsn_to_board(coor[2 * i + 1]));
- corner_arr[i] = new IntPoint(curr_x, curr_y);
- }
- return new geometry.planar.PolygonShape(corner_arr);
- }
-
- public Rectangle bounding_box()
- {
- double[] bounds = new double[4];
- bounds[0] = Integer.MAX_VALUE;
- bounds[1] = Integer.MAX_VALUE;
- bounds[2] = Integer.MIN_VALUE;
- bounds[3] = Integer.MIN_VALUE;
- for (int i = 0; i < coor.length; ++i)
- {
- if (i % 2 == 0)
- {
- // x coordinate
- bounds[0] = Math.min(bounds[0], coor[i]);
- bounds[2] = Math.max(bounds[2], coor[i]);
- }
- else
- {
- // x coordinate
- bounds[1] = Math.min(bounds[1], coor[i]);
- bounds[3] = Math.max(bounds[3], coor[i]);
- }
- }
- return new Rectangle(layer, bounds);
- }
-
- /**
- * Writes this polygon as a scope to an output dsn-file.
- */
- public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("polygon ");
- p_identifier_type.write(this.layer.name, p_file);
- p_file.write(" ");
- p_file.write((new Integer(0)).toString());
- int corner_count = coor.length/ 2;
- for (int i = 0; i < corner_count; ++i)
- {
- p_file.new_line();
- p_file.write(new Double(coor[2 * i]).toString());
- p_file.write(" ");
- p_file.write(new Double(coor[2 * i + 1]).toString());
- }
- p_file.end_scope();
- }
-
- public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("polygon ");
- p_identifier_type.write(this.layer.name, p_file);
- p_file.write(" ");
- p_file.write((new Integer(0)).toString());
- int corner_count = coor.length/ 2;
- for (int i = 0; i < corner_count; ++i)
- {
- p_file.new_line();
- Integer curr_coor = (int) Math.round(coor[2* i ]);
- p_file.write(curr_coor.toString());
- p_file.write(" ");
- curr_coor = (int) Math.round(coor[2* i + 1]);
- p_file.write(curr_coor.toString());
- }
- p_file.end_scope();
- }
-
- public final double [] coor;
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PolygonPath.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PolygonPath.java
deleted file mode 100644
index 298b013..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PolygonPath.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Path.java
- *
- * Created on 24. Mai 2004, 08:10
- */
-
-package designformats.specctra;
-
-import geometry.planar.FloatPoint;
-import geometry.planar.IntPoint;
-import geometry.planar.IntOctagon;
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-
-/**
- * Class for reading and writing path scopes consisting of a polygon from dsn-files.
- *
- * @author Alfons Wirtz
- */
-public class PolygonPath extends Path
-{
-
- /** Creates a new instance of PolygonPath */
- public PolygonPath(Layer p_layer, double p_width, double[] p_coordinate_arr)
- {
- super(p_layer, p_width, p_coordinate_arr);
- }
-
-
- /**
- * Writes this path as a scope to an output dsn-file.
- */
- public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("path ");
- p_identifier_type.write(this.layer.name, p_file);
- p_file.write(" ");
- p_file.write((new Double(this.width)).toString());
- int corner_count = coordinate_arr.length/ 2;
- for (int i = 0; i < corner_count; ++i)
- {
- p_file.new_line();
- p_file.write(new Double(coordinate_arr[2 * i]).toString());
- p_file.write(" ");
- p_file.write(new Double(coordinate_arr[2 * i + 1]).toString());
- }
- p_file.end_scope();
- }
-
- public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier_type) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("path ");
- p_identifier_type.write(this.layer.name, p_file);
- p_file.write(" ");
- p_file.write((new Double(this.width)).toString());
- int corner_count = coordinate_arr.length/ 2;
- for (int i = 0; i < corner_count; ++i)
- {
- p_file.new_line();
- Integer curr_coor = (int) Math.round(coordinate_arr[2* i ]);
- p_file.write(curr_coor.toString());
- p_file.write(" ");
- curr_coor = (int) Math.round(coordinate_arr[2* i + 1]);
- p_file.write(curr_coor.toString());
- }
- p_file.end_scope();
- }
-
- public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform)
- {
- FloatPoint [] corner_arr = new FloatPoint[this.coordinate_arr.length / 2];
- double [] curr_point = new double [2];
- for (int i = 0; i < corner_arr.length; ++i)
- {
- curr_point[0] = this.coordinate_arr[2 * i];
- curr_point[1] = this.coordinate_arr[2 * i + 1];
- corner_arr[i] = p_coordinate_transform.dsn_to_board(curr_point);
- }
- double offset = p_coordinate_transform.dsn_to_board(this.width) / 2;
- if (corner_arr.length <= 2)
- {
- IntOctagon bounding_oct = FloatPoint.bounding_octagon(corner_arr);
- return bounding_oct.enlarge(offset);
- }
- IntPoint [] rounded_corner_arr = new IntPoint[corner_arr.length];
- for (int i = 0; i < corner_arr.length; ++i)
- {
- rounded_corner_arr[i] = corner_arr[i].round();
- }
- geometry.planar.Shape result = new geometry.planar.PolygonShape(rounded_corner_arr);
- if (offset > 0)
- {
- result = result.bounding_tile().enlarge(offset);
- }
- return result;
- }
-
- public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform)
- {
- FloatPoint [] corner_arr = new FloatPoint[this.coordinate_arr.length / 2];
- double [] curr_point = new double [2];
- for (int i = 0; i < corner_arr.length; ++i)
- {
- curr_point[0] = this.coordinate_arr[2 * i];
- curr_point[1] = this.coordinate_arr[2 * i + 1];
- corner_arr[i] = p_coordinate_transform.dsn_to_board_rel(curr_point);
- }
- double offset = p_coordinate_transform.dsn_to_board(this.width) / 2;
- if (corner_arr.length <= 2)
- {
- IntOctagon bounding_oct = FloatPoint.bounding_octagon(corner_arr);
- return bounding_oct.enlarge(offset);
- }
- IntPoint [] rounded_corner_arr = new IntPoint[corner_arr.length];
- for (int i = 0; i < corner_arr.length; ++i)
- {
- rounded_corner_arr[i] = corner_arr[i].round();
- }
- geometry.planar.Shape result = new geometry.planar.PolygonShape(rounded_corner_arr);
- if (offset > 0)
- {
- result = result.bounding_tile().enlarge(offset);
- }
- return result;
- }
-
- public Rectangle bounding_box()
- {
- double offset = this.width/2;
- double[] bounds = new double[4];
- bounds[0] = Integer.MAX_VALUE;
- bounds[1] = Integer.MAX_VALUE;
- bounds[2] = Integer.MIN_VALUE;
- bounds[3] = Integer.MIN_VALUE;
- for (int i = 0; i < coordinate_arr.length; ++i)
- {
- if (i % 2 == 0)
- {
- // x coordinate
- bounds[0] = Math.min(bounds[0], coordinate_arr[i] - offset);
- bounds[2] = Math.max(bounds[2], coordinate_arr[i]) + offset;
- }
- else
- {
- // x coordinate
- bounds[1] = Math.min(bounds[1], coordinate_arr[i] - offset);
- bounds[3] = Math.max(bounds[3], coordinate_arr[i] + offset);
- }
- }
- return new Rectangle(layer, bounds);
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PolylinePath.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PolylinePath.java
deleted file mode 100644
index 2add800..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/PolylinePath.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * PolylinePath.java
- *
- * Created on 30. Juni 2004, 08:24
- */
-
-package designformats.specctra;
-
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-
-/**
- * Describes a path defined by a sequence of lines (instead of a sequence of corners.
- *
- * @author alfons
- */
-public class PolylinePath extends Path
-{
-
- /** Creates a new instance of PolylinePath */
- public PolylinePath(Layer p_layer, double p_width, double[] p_corner_arr)
- {
- super(p_layer, p_width, p_corner_arr);
- }
-
- /**
- * Writes this path as a scope to an output dsn-file.
- */
- public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("polyline_path ");
- p_identifier.write(this.layer.name, p_file);
- p_file.write(" ");
- p_file.write((new Double(this.width)).toString());
- int line_count = coordinate_arr.length/ 4;
- for (int i = 0; i < line_count; ++i)
- {
- p_file.new_line();
- for (int j = 0; j < 4; ++j)
- {
- p_file.write(new Double(coordinate_arr[4 * i + j]).toString());
- p_file.write(" ");
- }
- }
- p_file.end_scope();
- }
-
- public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("polyline_path ");
- p_identifier.write(this.layer.name, p_file);
- p_file.write(" ");
- p_file.write((new Double(this.width)).toString());
- int line_count = coordinate_arr.length/ 4;
- for (int i = 0; i < line_count; ++i)
- {
- p_file.new_line();
- for (int j = 0; j < 4; ++j)
- {
- Integer curr_coor = (int) Math.round(coordinate_arr[4 * i + j]);
- p_file.write(curr_coor.toString());
- p_file.write(" ");
- }
- }
- p_file.end_scope();
- }
-
- public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform)
- {
- System.out.println("PolylinePath.transform_to_board_rel not implemented");
- return null;
- }
-
- public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform)
- {
- System.out.println("PolylinePath.transform_to_board_rel not implemented");
- return null;
- }
-
-
- public Rectangle bounding_box()
- {
- System.out.println("PolylinePath.boundingbox not implemented");
- return null;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/ReadScopeParameter.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/ReadScopeParameter.java
deleted file mode 100644
index 0e6d14c..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/ReadScopeParameter.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * ReadScopeParameter.java
- *
- * Created on 21. Juni 2004, 08:28
- */
-
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-/**
- * Default parameter type used while reading a Specctra dsn-file.
- *
- * @author alfons
- */
-public class ReadScopeParameter
-{
-
- /** Creates a new instance of ReadScopeParameter */
- ReadScopeParameter(Scanner p_scanner, interactive.IBoardHandling p_board_handling,
- board.BoardObservers p_observers,
- datastructures.IdNoGenerator p_item_id_no_generator,board.TestLevel p_test_level)
- {
- scanner = p_scanner;
- board_handling = p_board_handling;
- observers = p_observers;
- item_id_no_generator = p_item_id_no_generator;
- test_level = p_test_level;
- }
-
- final Scanner scanner;
- final interactive.IBoardHandling board_handling;
- final NetList netlist = new NetList();
-
- final board.BoardObservers observers;
- final datastructures.IdNoGenerator item_id_no_generator;
- final board.TestLevel test_level;
-
- /** Collection of elements of class PlaneInfo.
- * The plane cannot be inserted directly into the boards, because the layers may not be read completely.
- */
- final Collection plane_list = new LinkedList();
-
- /**
- * Component placement information.
- * It is filled while reading the placement scope and can be
- * evaluated after reading the library and network scope.
- */
- final Collection placement_list = new LinkedList();
-
-
- /**
- * The names of the via padstacks filled while reading the structure scope
- * and evaluated after reading the library scope.
- */
- Collection via_padstack_names = null;
-
- boolean via_at_smd_allowed = false;
- board.AngleRestriction snap_angle = board.AngleRestriction.FORTYFIVE_DEGREE;
-
- /** The logical parts are used for pin and gate swaw */
- java.util.Collection logical_part_mappings
- = new java.util.LinkedList();
- java.util.Collection logical_parts = new java.util.LinkedList();
-
- /** The following objects are from the parser scope. */
- String string_quote = "\"";
- String host_cad = null;
- String host_version = null;
-
- boolean dsn_file_generated_by_host = true;
-
- boolean board_outline_ok = true;
-
- final Collection constants = new LinkedList();
- board.Communication.SpecctraParserInfo.WriteResolution write_resolution = null;
-
-
- /** The following objects will be initialised when the structure scope is read. */
- CoordinateTransform coordinate_transform = null;
- LayerStructure layer_structure = null;
- interactive.AutorouteSettings autoroute_settings = null;
-
- board.Unit unit = board.Unit.MIL;
- int resolution = 100; // default resulution
-
- /** Information for inserting a plane */
- static class PlaneInfo
- {
- PlaneInfo(Shape.ReadAreaScopeResult p_area, String p_net_name)
- {
- area = p_area;
- net_name = p_net_name;
- }
-
- final Shape.ReadAreaScopeResult area;
- final String net_name;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Rectangle.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Rectangle.java
deleted file mode 100644
index 474d4c5..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Rectangle.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Rectangle.java
- *
- * Created on 15. Mai 2004, 08:39
- */
-
-package designformats.specctra;
-
-import geometry.planar.FloatPoint;
-import geometry.planar.IntBox;
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-/**
- * Describes a rectangle in a Specctra dsn file.
- *
- * @author alfons
- */
-public class Rectangle extends Shape
-{
- /**
- * Creates a new instance of Rectangle
- * p_coor is an array of dimension 4 and contains the rectangle coordinates
- * in the following order: lower left x, lower left y, upper right x, uppper right y.
- */
- public Rectangle(Layer p_layer, double[] p_coor)
- {
- super(p_layer);
- coor = p_coor;
- }
-
- public Rectangle bounding_box()
- {
- return this;
- }
-
- /**
- * Creates the smallest rectangle containing this rectangle and p_other
- */
- public Rectangle union (Rectangle p_other)
- {
- double[] result_coor = new double[4];
- result_coor[0] = Math.min(this.coor[0], p_other.coor[0]);
- result_coor[1] = Math.min(this.coor[1], p_other.coor[1]);
- result_coor[2] = Math.max(this.coor[2], p_other.coor[2]);
- result_coor[3] = Math.max(this.coor[3], p_other.coor[3]);
- return new Rectangle(this.layer, result_coor);
- }
-
- public geometry.planar.Shape transform_to_board_rel(CoordinateTransform p_coordinate_transform)
- {
- int box_coor[] = new int[4];
- for (int i = 0; i < 4; ++i)
- {
- box_coor[i] = (int) Math.round(p_coordinate_transform.dsn_to_board(this.coor[i]));
- }
-
- IntBox result;
- if (box_coor[1] <= box_coor[3])
- {
- // box_coor describe lower left and upper right corner
- result = new IntBox(box_coor[0], box_coor[1], box_coor[2], box_coor[3]);
- }
- else
- {
- // box_coor describe upper left and lower right corner
- result = new IntBox(box_coor[0], box_coor[3], box_coor[2], box_coor[1]);
- }
- return result;
- }
-
- public geometry.planar.Shape transform_to_board(CoordinateTransform p_coordinate_transform)
- {
- double [] curr_point = new double [2];
- curr_point[0] = Math.min(coor[0], coor[2]);
- curr_point[1] = Math.min(coor[1], coor[3]);
- FloatPoint lower_left = p_coordinate_transform.dsn_to_board(curr_point);
- curr_point[0] = Math.max(coor[0], coor[2]);
- curr_point[1] = Math.max(coor[1], coor[3]);
- FloatPoint upper_right= p_coordinate_transform.dsn_to_board(curr_point);
- return new IntBox(lower_left.round(), upper_right.round());
- }
-
- /**
- * Writes this rectangle as a scope to an output dsn-file.
- */
- public void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException
- {
- p_file.new_line();
- p_file.write("(rect ");
- p_identifier.write(this.layer.name, p_file);
- for (int i = 0; i < coor.length; ++i)
- {
- p_file.write(" ");
- p_file.write(new Double(coor[i]).toString());
- }
- p_file.write(")");
- }
-
- public void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException
- {
- p_file.new_line();
- p_file.write("(rect ");
- p_identifier.write(this.layer.name, p_file);
- for (int i = 0; i < coor.length; ++i)
- {
- p_file.write(" ");
- Integer curr_coor = (int) Math.round(coor[i]);
- p_file.write(curr_coor.toString());
- }
- p_file.write(")");
- }
-
- public final double [] coor;
-}
\ No newline at end of file
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Resolution.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Resolution.java
deleted file mode 100644
index 833c84a..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Resolution.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Resolution.java
- *
- * Created on 30. Oktober 2004, 08:00
- */
-
-package designformats.specctra;
-
-/**
- * Class for reading resolution scopes from dsn-files.
- *
- * @author alfons
- */
-public class Resolution extends ScopeKeyword
-{
-
- /** Creates a new instance of Resolution */
- public Resolution()
- {
- super("resolution");
- }
-
- public boolean read_scope(ReadScopeParameter p_par)
- {
- try
- {
- // read the unit
- Object next_token = p_par.scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("Resolution.read_scope: string expected");
- return false;
- }
- p_par.unit = board.Unit.from_string((String) next_token);
- if (p_par.unit == null)
- {
- System.out.println("Resolution.read_scope: unit mil, inch or mm expected");
- return false;
- }
- // read the scale factor
- next_token = p_par.scanner.next_token();
- if (!(next_token instanceof Integer))
- {
- System.out.println("Resolution.read_scope: integer expected");
- return false;
- }
- p_par.resolution = ((Integer)next_token).intValue();
- // overread the closing bracket
- next_token = p_par.scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Resolution.read_scope: closing bracket expected");
- return false;
- }
- return true;
- }
- catch (java.io.IOException e)
- {
- System.out.println("Resolution.read_scope: IO error scanning file");
- return false;
- }
- }
-
- public static void write_scope(datastructures.IndentFileWriter p_file, board.Communication p_board_communication) throws java.io.IOException
- {
- p_file.new_line();
- p_file.write("(resolution ");
- p_file.write(p_board_communication.unit.toString());
- p_file.write(" ");
- p_file.write((new Integer(p_board_communication.resolution)).toString());
- p_file.write(")");
- }
-
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Rule.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Rule.java
deleted file mode 100644
index 0b90f3f..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Rule.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Rule.java
- *
- * Created on 1. Juni 2004, 09:27
- */
-
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-
-/**
- * Class for reading and writing rule scopes from dsn-files.
- *
- * @author Alfons Wirtz
- */
-public abstract class Rule
-{
- /**
- * Returns a collection of objects of class Rule.
- */
- public static Collection read_scope( Scanner p_scanner)
- {
- Collection result = new LinkedList();
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("Rule.read_scope: IO error scanning file");
- System.out.println(e);
- return null;
- }
- if (next_token == null)
- {
- System.out.println("Rule.read_scope: unexpected end of file");
- return null;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- Rule curr_rule = null;
- if (next_token == Keyword.WIDTH)
- {
- curr_rule = read_width_rule(p_scanner);
- }
- else if (next_token == Keyword.CLEARANCE)
- {
- curr_rule = read_clearance_rule(p_scanner);
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- if (curr_rule != null)
- {
- result.add(curr_rule);
- }
-
- }
- }
- return result;
- }
-
- /**
- * Reads a LayerRule from dsn-file.
- */
- public static LayerRule read_layer_rule_scope( Scanner p_scanner)
- {
- try
- {
- Collection layer_names = new LinkedList();
- Collection rule_list = new LinkedList();
- for (;;)
- {
- p_scanner.yybegin(SpecctraFileScanner.LAYER_NAME);
- Object next_token = p_scanner.next_token();
- if (next_token == Keyword.OPEN_BRACKET)
- {
- break;
- }
- if (!(next_token instanceof String))
- {
-
- System.out.println("Rule.read_layer_rule_scope: string expected");
- return null;
- }
- layer_names.add((String) next_token);
- }
- for (;;)
- {
- Object next_token = p_scanner.next_token();
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- break;
- }
- if (next_token != Keyword.RULE)
- {
-
- System.out.println("Rule.read_layer_rule_scope: rule expected");
- return null;
- }
- rule_list.addAll(read_scope(p_scanner));
- }
- return new LayerRule(layer_names, rule_list);
- }
- catch (java.io.IOException e)
- {
- System.out.println("Rule.read_layer_rule_scope: IO error scanning file");
- return null;
- }
- }
-
- public static WidthRule read_width_rule(Scanner p_scanner)
- {
- try
- {
- double value;
- Object next_token = p_scanner.next_token();
- if (next_token instanceof Double)
- {
- value = ((Double) next_token).doubleValue();
- }
- else if (next_token instanceof Integer)
- {
- value = ((Integer) next_token).intValue();
- }
- else
- {
- System.out.println("Rule.read_width_rule: number expected");
- return null;
- }
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Rule.read_width_rule: closing bracket expected");
- return null;
- }
- return new WidthRule(value);
- }
- catch (java.io.IOException e)
- {
- System.out.println("Rule.read_width_rule: IO error scanning file");
- return null;
- }
- }
-
- public static void write_scope(rules.NetClass p_net_class, WriteScopeParameter p_par) throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("rule");
-
- // write the trace width
- int default_trace_half_width = p_net_class.get_trace_half_width(0);
- double trace_width = 2 * p_par.coordinate_transform.board_to_dsn(default_trace_half_width);
- p_par.file.new_line();
- p_par.file.write("(width ");
- p_par.file.write((new Double(trace_width)).toString());
- p_par.file.write(")");
- p_par.file.end_scope();
- for (int i = 1; i < p_par.board.layer_structure.arr.length; ++i)
- {
- if (p_net_class.get_trace_half_width(i) != default_trace_half_width)
- {
- write_layer_rule(p_net_class, i, p_par);
- }
- }
- }
-
- private static void write_layer_rule(rules.NetClass p_net_class, int p_layer_no, WriteScopeParameter p_par) throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("layer_rule ");
-
- board.Layer curr_board_layer = p_par.board.layer_structure.arr[p_layer_no];
-
- p_par.file.write(curr_board_layer.name);
- p_par.file.start_scope();
- p_par.file.write("rule ");
-
- int curr_trace_half_width = p_net_class.get_trace_half_width(p_layer_no);
-
- // write the trace width
- double trace_width = 2 * p_par.coordinate_transform.board_to_dsn(curr_trace_half_width);
- p_par.file.new_line();
- p_par.file.write("(width ");
- p_par.file.write((new Double(trace_width)).toString());
- p_par.file.write(") ");
- p_par.file.end_scope();
- p_par.file.end_scope();
- }
-
- /**
- * Writes the default rule as a scope to an output dsn-file.
- */
- public static void write_default_rule(WriteScopeParameter p_par, int p_layer) throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("rule");
- // write the trace width
- double trace_width = 2 * p_par.coordinate_transform.board_to_dsn(p_par.board.rules.get_default_net_class().get_trace_half_width(0));
- p_par.file.new_line();
- p_par.file.write("(width ");
- p_par.file.write((new Double(trace_width)).toString());
- p_par.file.write(")");
- // write the default clearance rule
- int default_cl_no = rules.BoardRules.default_clearance_class();
- int default_board_clearance = p_par.board.rules.clearance_matrix.value(default_cl_no, default_cl_no, p_layer);
- double default_clearance = p_par.coordinate_transform.board_to_dsn(default_board_clearance);
- p_par.file.new_line();
- p_par.file.write("(clear ");
- p_par.file.write((new Double(default_clearance)).toString());
- p_par.file.write(")");
- // write the Smd_to_turn_gap
- Double smd_to_turn_dist = p_par.coordinate_transform.board_to_dsn(p_par.board.rules.get_pin_edge_to_turn_dist());
- p_par.file.new_line();
- p_par.file.write("(clear ");
- p_par.file.write(smd_to_turn_dist.toString());
- p_par.file.write(" (type smd_to_turn_gap))");
- int cl_count = p_par.board.rules.clearance_matrix.get_class_count();
- for (int i = 1; i <= cl_count; ++i)
- {
- write_clearance_rules(p_par, p_layer, i, cl_count, default_board_clearance);
- }
- p_par.file.end_scope();
- }
-
- /**
- * Write the clearance rules, which are different from the default clearance.
- */
- private static void write_clearance_rules(WriteScopeParameter p_par,
- int p_layer, int p_cl_class, int p_max_cl_class, int p_default_clearance) throws java.io.IOException
- {
- rules.ClearanceMatrix cl_matrix = p_par.board.rules.clearance_matrix;
- for (int i = p_cl_class; i < p_max_cl_class; ++i)
- {
- int curr_board_clearance = cl_matrix.value(p_cl_class, i, p_layer);
- if (curr_board_clearance == p_default_clearance)
- {
- continue;
- }
- double curr_clearance = p_par.coordinate_transform.board_to_dsn(curr_board_clearance);
- p_par.file.new_line();
- p_par.file.write("(clear ");
- p_par.file.write((new Double(curr_clearance)).toString());
- p_par.file.write(" (type ");
- p_par.identifier_type.write(cl_matrix.get_name(p_cl_class), p_par.file);
- p_par.file.write("_");
- p_par.identifier_type.write(cl_matrix.get_name(i), p_par.file);
- p_par.file.write("))");
- }
- }
-
- public static ClearanceRule read_clearance_rule(Scanner p_scanner)
- {
- try
- {
- double value;
- Object next_token = p_scanner.next_token();
- if (next_token instanceof Double)
- {
- value = ((Double) next_token).doubleValue();
- }
- else if (next_token instanceof Integer)
- {
- value = ((Integer) next_token).intValue();
- }
- else
- {
- System.out.println("Rule.read_clearance_rule: number expected");
- return null;
- }
- Collection class_pairs = new LinkedList ();
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- if (next_token != Keyword.OPEN_BRACKET)
- {
- System.out.println("Rule.read_clearance_rule: ( expected");
- return null;
- }
- next_token = p_scanner.next_token();
- if (next_token != Keyword.TYPE)
- {
- System.out.println("Rule.read_clearance_rule: type expected");
- return null;
- }
- for (;;)
- {
- p_scanner.yybegin(SpecctraFileScanner.IGNORE_QUOTE);
- next_token = p_scanner.next_token();
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- break;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("Rule.read_clearance_rule: string expected");
- return null;
- }
- class_pairs.add((String)next_token);
- }
- next_token = p_scanner.next_token();
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("Rule.read_clearance_rule: closing bracket expected");
- return null;
- }
- }
- return new ClearanceRule(value, class_pairs);
- }
- catch (java.io.IOException e)
- {
- System.out.println("Rule.read_clearance_rule: IO error scanning file");
- return null;
- }
-
- }
-
- static public void write_item_clearance_class( String p_name, datastructures.IndentFileWriter p_file,
- datastructures.IdentifierType p_identifier_type) throws java.io.IOException
- {
- p_file.new_line();
- p_file.write("(clearance_class ");
- p_identifier_type.write(p_name, p_file);
- p_file.write(")");
- }
-
- public static class WidthRule extends Rule
- {
- public WidthRule(double p_value)
- {
- value = p_value;
- }
- final double value;
- }
-
- public static class ClearanceRule extends Rule
- {
- public ClearanceRule(double p_value, Collection p_class_pairs)
- {
- value = p_value;
- clearance_class_pairs = p_class_pairs;
- }
- final double value;
- final Collection clearance_class_pairs;
- }
-
- public static class LayerRule
- {
- LayerRule(Collection p_layer_names, Collection p_rules)
- {
- layer_names = p_layer_names;
- rules = p_rules;
- }
- final Collection layer_names;
- final Collection rules;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/RulesFile.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/RulesFile.java
deleted file mode 100644
index 23dc7d6..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/RulesFile.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * RulesFile.java
- *
- * Created on 18. Juli 2005, 07:07
- *
- */
-
-package designformats.specctra;
-
-import datastructures.IndentFileWriter;
-
-import board.BasicBoard;
-
-/**
- * File for saving the board rules, so that they can be restored after the Board
- * is creates anew from the host system.
- *
- * @author Alfons Wirtz
- */
-public class RulesFile
-{
-
- public static void write(interactive.BoardHandling p_board_handling, java.io.OutputStream p_output_stream, String p_design_name)
- {
- IndentFileWriter output_file = new IndentFileWriter(p_output_stream);
- BasicBoard routing_board = p_board_handling.get_routing_board();
- WriteScopeParameter write_scope_parameter =
- new WriteScopeParameter(routing_board, p_board_handling.settings.autoroute_settings,
- output_file, routing_board.communication.specctra_parser_info.string_quote,
- routing_board.communication.coordinate_transform, false);
- try
- {
- write_rules(write_scope_parameter, p_design_name);
- }
- catch (java.io.IOException e)
- {
- System.out.println("unable to write rules to file");
- }
- try
- {
- output_file.close();
- }
- catch (java.io.IOException e)
- {
- System.out.println("unable to close rules file");
- }
- }
-
- public static boolean read(java.io.InputStream p_input_stream, String p_design_name,
- interactive.BoardHandling p_board_handling)
- {
- BasicBoard routing_board = p_board_handling.get_routing_board();
- Scanner scanner = new SpecctraFileScanner(p_input_stream);
- try
- {
- Object curr_token = scanner.next_token();
- if (curr_token != Keyword.OPEN_BRACKET)
- {
- System.out.println("RulesFile.read: open bracket expected");
- return false;
- }
- curr_token = scanner.next_token();
- if (curr_token != Keyword.RULES)
- {
- System.out.println("RulesFile.read: keyword rules expected");
- return false;
- }
- curr_token = scanner.next_token();
- if (curr_token != Keyword.PCB_SCOPE)
- {
- System.out.println("RulesFile.read: keyword pcb expected");
- return false;
- }
- scanner.yybegin(SpecctraFileScanner.NAME);
- curr_token = scanner.next_token();
- if (!(curr_token instanceof String) || !((String) curr_token).equals(p_design_name))
- {
- System.out.println("RulesFile.read: design_name not matching");
- return false;
- }
- }
- catch (java.io.IOException e)
- {
- System.out.println("RulesFile.read: IO error scanning file");
- return false;
- }
- LayerStructure layer_structure = new LayerStructure(routing_board.layer_structure);
- CoordinateTransform coordinate_transform = routing_board.communication.coordinate_transform;
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("RulesFile.read: IO error scanning file");
- return false;
- }
- if (next_token == null)
- {
- System.out.println("Structure.read_scope: unexpected end of file");
- return false;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- boolean read_ok = true;
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.RULE)
- {
- add_rules(Rule.read_scope(scanner), routing_board, null);
- }
- else if (next_token == Keyword.LAYER)
- {
- add_layer_rules(scanner, routing_board);
- }
- else if (next_token == Keyword.PADSTACK)
- {
- Library.read_padstack_scope(scanner, layer_structure, coordinate_transform, routing_board.library.padstacks);
- }
- else if (next_token == Keyword.VIA)
- {
- read_via_info(scanner, routing_board);
- }
- else if (next_token == Keyword.VIA_RULE)
- {
- read_via_rule(scanner, routing_board);
- }
- else if (next_token == Keyword.CLASS)
- {
- read_net_class(scanner, layer_structure, routing_board);
- }
- else if (next_token == Keyword.SNAP_ANGLE)
- {
-
- board.AngleRestriction snap_angle = Structure.read_snap_angle(scanner);
- if (snap_angle != null)
- {
- routing_board.rules.set_trace_angle_restriction(snap_angle);
- }
- }
- else if (next_token == Keyword.AUTOROUTE_SETTINGS)
- {
- interactive.AutorouteSettings autoroute_settings
- = AutorouteSettings.read_scope(scanner, layer_structure);
- if (autoroute_settings != null)
- {
- p_board_handling.settings.autoroute_settings = autoroute_settings;
- }
- }
- else
- {
- ScopeKeyword.skip_scope(scanner);
- }
- }
- if (!read_ok)
- {
- return false;
- }
- }
- return true;
- }
-
- private static void write_rules( WriteScopeParameter p_par, String p_design_name) throws java.io.IOException
- {
- p_par.file.start_scope();
- p_par.file.write("rules PCB ");
- p_par.file.write(p_design_name);
- Structure.write_snap_angle(p_par.file, p_par.board.rules.get_trace_angle_restriction());
- AutorouteSettings.write_scope(p_par.file, p_par.autoroute_settings,
- p_par.board.layer_structure, p_par.identifier_type);
- // write the default rule using 0 as default layer.
- Rule.write_default_rule(p_par, 0);
- // write the via padstacks
- for (int i = 1; i <= p_par.board.library.padstacks.count(); ++i)
- {
- library.Padstack curr_padstack = p_par.board.library.padstacks.get(i);
- if (p_par.board.library.get_via_padstack(curr_padstack.name )!= null)
- {
- Library.write_padstack_scope(p_par, curr_padstack);
- }
- }
- Network.write_via_infos(p_par.board.rules, p_par.file, p_par.identifier_type);
- Network.write_via_rules(p_par.board.rules, p_par.file, p_par.identifier_type);
- Network.write_net_classes(p_par);
- p_par.file.end_scope();
- }
-
- private static void add_rules(java.util.Collection p_rules, BasicBoard p_board, String p_layer_name)
- {
- int layer_no = -1;
- if (p_layer_name != null)
- {
- layer_no = p_board.layer_structure.get_no(p_layer_name);
- if (layer_no < 0)
- {
- System.out.println("RulesFile.add_rules: layer not found");
- }
- }
- CoordinateTransform coordinate_transform = p_board.communication.coordinate_transform;
- String string_quote = p_board.communication.specctra_parser_info.string_quote;
- for (Rule curr_rule : p_rules)
- {
- if (curr_rule instanceof Rule.WidthRule)
- {
- double wire_width = ((Rule.WidthRule)curr_rule).value;
- int trace_halfwidth = (int) Math.round(coordinate_transform.dsn_to_board(wire_width) / 2);
- if (layer_no < 0)
- {
- p_board.rules.set_default_trace_half_widths(trace_halfwidth);
- }
- else
- {
- p_board.rules.set_default_trace_half_width(layer_no, trace_halfwidth);
- }
- }
- else if (curr_rule instanceof Rule.ClearanceRule)
- {
- Structure.set_clearance_rule(( Rule.ClearanceRule)curr_rule, layer_no, coordinate_transform, p_board.rules, string_quote);
- }
- }
- }
-
- private static boolean add_layer_rules(Scanner p_scanner, BasicBoard p_board)
- {
- try
- {
- Object next_token = p_scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("RulesFile.add_layer_rules: String expected");
- return false;
- }
- String layer_string = (String) next_token;
- next_token = p_scanner.next_token();
- while (next_token != Keyword.CLOSED_BRACKET)
- {
- if (next_token != Keyword.OPEN_BRACKET)
- {
- System.out.println("RulesFile.add_layer_rules: ( expected");
- return false;
- }
- next_token = p_scanner.next_token();
- if (next_token == Keyword.RULE)
- {
- java.util.Collection curr_rules = Rule.read_scope(p_scanner);
- add_rules(curr_rules, p_board, layer_string);
- }
- else
- {
- ScopeKeyword.skip_scope(p_scanner);
- }
- next_token = p_scanner.next_token();
- }
- return true;
- }
- catch (java.io.IOException e)
- {
- System.out.println("RulesFile.add_layer_rules: IO error scanning file");
- return false;
- }
- }
- private static boolean read_via_info(Scanner p_scanner, BasicBoard p_board)
- {
- rules.ViaInfo curr_via_info = Network.read_via_info(p_scanner, p_board);
- if (curr_via_info == null)
- {
- return false;
- }
- rules.ViaInfo existing_via = p_board.rules.via_infos.get(curr_via_info.get_name());
- if (existing_via != null)
- {
- // replace existing via info
- p_board.rules.via_infos.remove(existing_via);
- }
- p_board.rules.via_infos.add(curr_via_info);
- return true;
- }
-
- private static boolean read_via_rule(Scanner p_scanner, BasicBoard p_board)
- {
- java.util.Collection via_rule = Network.read_via_rule(p_scanner, p_board);
- if (via_rule == null)
- {
- return false;
- }
- Network.add_via_rule(via_rule, p_board);
- return true;
- }
-
- private static boolean read_net_class(Scanner p_scanner, LayerStructure p_layer_structure, BasicBoard p_board)
- {
- NetClass curr_class = NetClass.read_scope(p_scanner);
- if (curr_class == null)
- {
- return false;
- }
- Network.insert_net_class(curr_class, p_layer_structure, p_board, p_board.communication.coordinate_transform, false);
- return true;
- }
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Scanner.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Scanner.java
deleted file mode 100644
index 70c924b..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Scanner.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Scanner.java
- *
- * Created on 4. Juli 2004, 19:13
- */
-
-package designformats.specctra;
-
-/**
- * Interface for scanner generated by jflex.
- *
- * @author alfons
- */
-public interface Scanner
-{
- /**
- * Reads the next token from the input file.
- */
- Object next_token() throws java.io.IOException;
-
- /**
- * Starts a new state.
- */
- void yybegin(int p_new_state);
-}
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/ScopeKeyword.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/ScopeKeyword.java
deleted file mode 100644
index f64b2bf..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/ScopeKeyword.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * ScopeKeyword.java
- *
- * Created on 12. Mai 2004, 08:47
- */
-
-package designformats.specctra;
-
-/**
- *
- * @author alfons
- */
-
-/** Keywords defining a scope object*/
-public class ScopeKeyword extends Keyword
-{
- public ScopeKeyword(String p_name)
- {
- super(p_name);
- }
-
- /**
- * Scips the current scope while reading a dsn file.
- * Returns false, if no legal scope was found.
- */
- public static boolean skip_scope(Scanner p_scanner)
- {
- int open_bracked_count = 1;
- while (open_bracked_count > 0)
- {
- p_scanner.yybegin(SpecctraFileScanner.NAME);
- Object curr_token = null;
- try
- {
- curr_token = p_scanner.next_token();
- }
- catch (Exception e)
- {
- System.out.println("ScopeKeyword.skip_scope: Error while scanning file");
- System.out.println(e);
- return false;
- }
- if (curr_token == null)
- {
- return false; // end of file
- }
- if (curr_token == Keyword.OPEN_BRACKET)
- {
- ++open_bracked_count;
- }
- else if (curr_token == Keyword.CLOSED_BRACKET)
- {
- --open_bracked_count;
- }
- }
- return true;
- }
-
- /**
- * Reads the next scope of this keyword from dsn file.
- */
- public boolean read_scope(ReadScopeParameter p_par)
- {
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- try
- {
- next_token = p_par.scanner.next_token();
- }
- catch (java.io.IOException e)
- {
- System.out.println("ScopeKeyword.read_scope: IO error scanning file");
- System.out.println(e);
- return false;
- }
- if (next_token == null)
- {
- // end of file
- return true;
- }
- if (next_token == CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
-
- if (prev_token == OPEN_BRACKET)
- {
- ScopeKeyword next_scope;
- // a new scope is expected
- if (next_token instanceof ScopeKeyword)
- {
- next_scope = (ScopeKeyword) next_token;
- if (!next_scope.read_scope(p_par))
- {
- return false;
- }
-
- }
- else
- {
- // skip unknown scope
- skip_scope(p_par.scanner);
- }
-
- }
- }
- return true;
- }
-}
-
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/SessionFile.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/SessionFile.java
deleted file mode 100644
index cc739b2..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/SessionFile.java
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * SessionFile.java
- *
- * Created on 29. Oktober 2004, 08:01
- */
-
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import geometry.planar.FloatPoint;
-import geometry.planar.Point;
-
-import board.BasicBoard;
-import board.PolylineTrace;
-import board.Via;
-import board.ConductionArea;
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-/**
- * Methods to handle a Specctra session file.
- *
- * @author alfons
- */
-public class SessionFile
-{
- /**
- * Creates a Specctra session file to update the host system from the RoutingBooard
- */
- public static boolean write( BasicBoard p_board, java.io.OutputStream p_output_stream, String p_design_name)
- {
- if (p_output_stream == null)
- {
- return false;
- }
- IndentFileWriter output_file = null;
- try
- {
- output_file = new IndentFileWriter(p_output_stream);
- }
- catch (Exception e)
- {
- System.out.println("unable to create session file");
- return false;
- }
- String session_name = p_design_name.replace(".dsn", ".ses");
- try
- {
- String [] reserved_chars = {"(", ")", " ", "-"};
- IdentifierType identifier_type = new IdentifierType(reserved_chars, p_board.communication.specctra_parser_info.string_quote);
- write_session_scope(p_board, identifier_type, output_file, session_name, p_design_name);
- }
- catch (java.io.IOException e)
- {
- System.out.println("unable to write session file");
- return false;
- }
- try
- {
- output_file.close();
- }
- catch (java.io.IOException e)
- {
- System.out.println("unable to close session file");
- return false;
- }
- return true;
- }
-
- private static void write_session_scope(BasicBoard p_board, IdentifierType p_identifier_type,
- IndentFileWriter p_file, String p_session_name, String p_design_name) throws java.io.IOException
- {
- double scale_factor = p_board.communication.coordinate_transform.dsn_to_board(1)/p_board.communication.resolution;
- CoordinateTransform coordinate_transform = new CoordinateTransform(scale_factor, 0, 0);
- p_file.start_scope();
- p_file.write("session ");
- p_identifier_type.write(p_session_name, p_file);
- p_file.new_line();
- p_file.write("(base_design ");
- p_identifier_type.write(p_design_name, p_file);
- p_file.write(")");
- write_placement(p_board, p_identifier_type, coordinate_transform, p_file);
- write_was_is(p_board, p_identifier_type, p_file);
- write_routes(p_board, p_identifier_type, coordinate_transform, p_file);
- p_file.end_scope();
- }
-
- public static void write_placement(BasicBoard p_board, IdentifierType p_identifier_type,
- CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("placement");
- Resolution.write_scope(p_file, p_board.communication);
-
- for (int i = 1; i <= p_board.library.packages.count(); ++i)
- {
- write_components(p_board, p_identifier_type, p_coordinate_transform, p_file, p_board.library.packages.get(i));
- }
- p_file.end_scope();
- }
-
- /**
- * Writes all components with the package p_package to the session file.
- */
- public static void write_components(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform,
- IndentFileWriter p_file, library.Package p_package) throws java.io.IOException
- {
- Collection board_items = p_board.get_items();
- boolean component_found = false;
- for (int i = 1; i <= p_board.components.count(); ++i)
- {
- board.Component curr_component = p_board.components.get(i);
- if (curr_component.get_package() == p_package)
- {
- // check, if not all items of the component are deleted
- boolean undeleted_item_found = false;
- Iterator it = board_items.iterator();
- while (it.hasNext())
- {
- board.Item curr_item = it.next();
- if (curr_item.get_component_no() == curr_component.no)
- {
- undeleted_item_found = true;
- break;
- }
- }
- if (undeleted_item_found)
- {
- if (!component_found)
- {
- // write the scope header
- p_file.start_scope();
- p_file.write("component ");
- p_identifier_type.write(p_package.name, p_file);
- component_found = true;
- }
- write_component(p_board, p_identifier_type, p_coordinate_transform, p_file, curr_component);
- }
- }
- }
- if (component_found)
- {
- p_file.end_scope();
- }
- }
-
- public static void write_component(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform,
- IndentFileWriter p_file, board.Component p_component) throws java.io.IOException
- {
- p_file.new_line();
- p_file.write("(place ");
- p_identifier_type.write(p_component.name, p_file);
- double[] location = p_coordinate_transform.board_to_dsn(p_component.get_location().to_float());
- Integer x_coor = (int) Math.round(location[0]);
- Integer y_coor = (int) Math.round(location[1]);
- p_file.write(" ");
- p_file.write(x_coor.toString());
- p_file.write(" ");
- p_file.write(y_coor.toString());
- if (p_component.placed_on_front())
- {
- p_file.write(" front ");
- }
- else
- {
- p_file.write(" back ");
- }
- int rotation = (int) Math.round(p_component.get_rotation_in_degree());
- p_file.write((new Integer(rotation).toString()));
- if (p_component.position_fixed)
- {
- p_file.new_line();
- p_file.write(" (lock_type position)");
- }
- p_file.write(")");
- }
-
- public static void write_was_is(BasicBoard p_board, IdentifierType p_identifier_type,
- IndentFileWriter p_file) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("was_is");
- Collection board_pins = p_board.get_pins();
- for (board.Pin curr_pin : board_pins)
- {
- board.Pin swapped_with = curr_pin.get_changed_to();
- if (curr_pin.get_changed_to() != curr_pin)
- {
- p_file.new_line();
- p_file.write("(pins ");
- board.Component curr_cmp = p_board.components.get(curr_pin.get_component_no());
- if (curr_cmp != null)
- {
- p_identifier_type.write(curr_cmp.name, p_file);
- p_file.write("-");
- library.Package.Pin package_pin = curr_cmp.get_package().get_pin(curr_pin.get_index_in_package());
- p_identifier_type.write(package_pin.name, p_file);
- }
- else
- {
- System.out.println("SessionFile.write_was_is: component not found");
- }
- p_file.write(" ");
- board.Component swap_cmp = p_board.components.get(swapped_with.get_component_no());
- if (swap_cmp != null)
- {
- p_identifier_type.write(swap_cmp.name, p_file);
- p_file.write("-");
- library.Package.Pin package_pin = swap_cmp.get_package().get_pin(swapped_with.get_index_in_package());
- p_identifier_type.write(package_pin.name, p_file);
- }
- else
- {
- System.out.println("SessionFile.write_was_is: component not found");
- }
- p_file.write(")");
- }
- }
- p_file.end_scope();
- }
-
- private static void write_routes(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform,
- IndentFileWriter p_file) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("routes ");
- Resolution.write_scope(p_file, p_board.communication);
- Parser.write_scope(p_file,p_board.communication.specctra_parser_info, p_identifier_type, true);
- write_library(p_board, p_identifier_type, p_coordinate_transform, p_file);
- write_network(p_board, p_identifier_type, p_coordinate_transform, p_file);
- p_file.end_scope();
- }
-
- private static void write_library(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform,
- IndentFileWriter p_file) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("library_out ");
- for (int i = 0; i < p_board.library.via_padstack_count(); ++i)
- {
- write_padstack(p_board.library.get_via_padstack(i), p_board, p_identifier_type, p_coordinate_transform, p_file);
- }
- p_file.end_scope();
- }
-
- private static void write_padstack(library.Padstack p_padstack, BasicBoard p_board, IdentifierType p_identifier_type,
- CoordinateTransform p_coordinate_transform, IndentFileWriter p_file)
- throws java.io.IOException
- {
- // search the layer range of the padstack
- int first_layer_no = 0;
- while (first_layer_no < p_board.get_layer_count())
- {
- if (p_padstack.get_shape(first_layer_no) != null)
- {
- break;
- }
- ++first_layer_no;
- }
- int last_layer_no = p_board.get_layer_count() - 1;
- while (last_layer_no >= 0 )
- {
- if (p_padstack.get_shape(last_layer_no) != null)
- {
- break;
- }
- --last_layer_no;
- }
- if (first_layer_no >= p_board.get_layer_count() || last_layer_no < 0)
- {
- System.out.println("SessionFile.write_padstack: padstack shape not found");
- return;
- }
-
- p_file.start_scope();
- p_file.write("padstack ");
- p_identifier_type.write(p_padstack.name, p_file);
- for (int i = first_layer_no; i <= last_layer_no; ++i)
- {
- geometry.planar.Shape curr_board_shape = p_padstack.get_shape(i);
- if (curr_board_shape == null)
- {
- continue;
- }
- board.Layer board_layer = p_board.layer_structure.arr[i];
- Layer curr_layer = new Layer(board_layer.name, i, board_layer.is_signal);
- Shape curr_shape = p_coordinate_transform.board_to_dsn_rel(curr_board_shape, curr_layer);
- p_file.start_scope();
- p_file.write("shape");
- curr_shape.write_scope_int(p_file, p_identifier_type);
- p_file.end_scope();
- }
- if (!p_padstack.attach_allowed)
- {
- p_file.new_line();
- p_file.write("(attach off)");
- }
- p_file.end_scope();
- }
-
-
-
- private static void write_network(BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform,
- IndentFileWriter p_file) throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("network_out ");
- for (int i = 1; i <= p_board.rules.nets.max_net_no(); ++i)
- {
- write_net(i, p_board, p_identifier_type, p_coordinate_transform, p_file);
- }
- p_file.end_scope();
- }
-
- private static void write_net(int p_net_no, BasicBoard p_board, IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform,
- IndentFileWriter p_file) throws java.io.IOException
- {
- Collection net_items = p_board.get_connectable_items(p_net_no);
- boolean header_written = false;
- Iterator it = net_items.iterator();
- while (it.hasNext())
- {
- board.Item curr_item = it.next();
- if (curr_item.get_fixed_state() == board.FixedState.SYSTEM_FIXED)
- {
- continue;
- }
- boolean is_wire = curr_item instanceof PolylineTrace;
- boolean is_via = curr_item instanceof Via;
- boolean is_conduction_area = curr_item instanceof ConductionArea
- && p_board.layer_structure.arr [curr_item.first_layer()].is_signal;
- if (!header_written && (is_wire || is_via || is_conduction_area))
- {
- p_file.start_scope();
- p_file.write("net ");
- rules.Net curr_net = p_board.rules.nets.get(p_net_no);
- if (curr_net == null)
- {
- System.out.println("SessionFile.write_net: net not found");
- }
- else
- {
- p_identifier_type.write(curr_net.name, p_file);
- }
- header_written = true;
- }
- if (is_wire)
- {
- write_wire((PolylineTrace)curr_item, p_board, p_identifier_type, p_coordinate_transform, p_file);
- }
- else if (is_via)
- {
- write_via((Via) curr_item, p_board, p_identifier_type, p_coordinate_transform, p_file);
- }
- else if (is_conduction_area)
- {
- write_conduction_area( (ConductionArea) curr_item, p_board, p_identifier_type,
- p_coordinate_transform, p_file);
- }
- }
- if (header_written)
- {
- p_file.end_scope();
- }
- }
-
- private static void write_wire(PolylineTrace p_wire, BasicBoard p_board, IdentifierType p_identifier_type,
- CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException
- {
- int layer_no = p_wire.get_layer();
- board.Layer board_layer = p_board.layer_structure.arr[layer_no];
- int wire_width = (int) Math.round(p_coordinate_transform.board_to_dsn(2 * p_wire.get_half_width()));
- p_file.start_scope();
- p_file.write("wire");
- Point[] corner_arr = p_wire.polyline().corner_arr();
- int [] coors = new int [2 * corner_arr.length];
- int corner_index = 0;
- int [] prev_coors = null;
- for (int i = 0; i < corner_arr.length; ++i)
- {
- double[] curr_float_coors = p_coordinate_transform.board_to_dsn(corner_arr[i].to_float());
- int [] curr_coors = new int[2];
- curr_coors[0] = (int) Math.round(curr_float_coors[0]);
- curr_coors[1] = (int) Math.round(curr_float_coors[1]);
- if (i == 0 || ( curr_coors[0] != prev_coors[0] || curr_coors[1] != prev_coors[1]))
- {
- coors[corner_index] = curr_coors[0];
- ++corner_index;
- coors[corner_index] = curr_coors[1];
- ++corner_index;
- prev_coors = curr_coors;
-
- }
- }
- if (corner_index < coors.length)
- {
- int [] adjusted_coors = new int[corner_index];
- for (int i = 0; i < adjusted_coors.length; ++i)
- {
- adjusted_coors[i] = coors[i];
- }
- coors = adjusted_coors;
- }
- write_path(board_layer.name, wire_width, coors, p_identifier_type, p_file);
- write_fixed_state(p_file, p_wire.get_fixed_state());
- p_file.end_scope();
- }
-
- private static void write_via(Via p_via, BasicBoard p_board, IdentifierType p_identifier_type,
- CoordinateTransform p_coordinate_transform, IndentFileWriter p_file) throws java.io.IOException
- {
- library.Padstack via_padstack = p_via.get_padstack();
- FloatPoint via_location = p_via.get_center().to_float();
- p_file.start_scope();
- p_file.write("via ");
- p_identifier_type.write(via_padstack.name, p_file);
- p_file.write(" ");
- double[] location = p_coordinate_transform.board_to_dsn(via_location);
- Integer x_coor = (int) Math.round(location[0]);
- p_file.write(x_coor.toString());
- p_file.write(" ");
- Integer y_coor = (int) Math.round(location[1]);
- p_file.write(y_coor.toString());
- write_fixed_state(p_file, p_via.get_fixed_state());
- p_file.end_scope();
- }
-
- static private void write_fixed_state(IndentFileWriter p_file, board.FixedState p_fixed_state) throws java.io.IOException
- {
- if (p_fixed_state.ordinal() <= board.FixedState.SHOVE_FIXED.ordinal())
- {
- return;
- }
- p_file.new_line();
- p_file.write("(type ");
- if (p_fixed_state == board.FixedState.SYSTEM_FIXED)
- {
- p_file.write("fix)");
- }
- else
- {
- p_file.write("protect)");
- }
- }
-
- private static void write_path(String p_layer_name, int p_width, int[] p_coors, IdentifierType p_identifier_type,
- IndentFileWriter p_file)
- throws java.io.IOException
- {
- p_file.start_scope();
- p_file.write("path ");
- p_identifier_type.write(p_layer_name, p_file);
- p_file.write(" ");
- p_file.write((new Integer(p_width)).toString());
- int corner_count = p_coors.length/ 2;
- for (int i = 0; i < corner_count; ++i)
- {
- p_file.new_line();
- p_file.write(new Integer(p_coors[2 * i]).toString());
- p_file.write(" ");
- p_file.write(new Integer(p_coors[2 * i + 1]).toString());
- }
- p_file.end_scope();
- }
-
- private static void write_conduction_area( ConductionArea p_conduction_area, BasicBoard p_board,
- IdentifierType p_identifier_type, CoordinateTransform p_coordinate_transform,
- IndentFileWriter p_file) throws java.io.IOException
- {
- int net_count = p_conduction_area.net_count();
- if (net_count <= 0 || net_count > 1)
- {
- System.out.println("SessionFile.write_conduction_area: unexpected net count");
- return;
- }
- geometry.planar.Area curr_area = p_conduction_area.get_area();
- int layer_no = p_conduction_area.get_layer();
- board.Layer board_layer = p_board.layer_structure.arr[ layer_no];
- Layer conduction_layer = new Layer(board_layer.name, layer_no, board_layer.is_signal);
- geometry.planar.Shape boundary_shape;
- geometry.planar.Shape [] holes;
- if (curr_area instanceof geometry.planar.Shape)
- {
- boundary_shape = (geometry.planar.Shape) curr_area;
- holes = new geometry.planar.Shape [0];
- }
- else
- {
- boundary_shape = curr_area.get_border();
- holes = curr_area.get_holes();
- }
- p_file.start_scope();
- p_file.write("wire ");
- Shape dsn_shape = p_coordinate_transform.board_to_dsn(boundary_shape, conduction_layer);
- if (dsn_shape != null)
- {
- dsn_shape.write_scope_int(p_file, p_identifier_type);
- }
- for (int i = 0; i < holes.length; ++i)
- {
- Shape dsn_hole = p_coordinate_transform.board_to_dsn(holes[i], conduction_layer);
- dsn_hole.write_hole_scope(p_file, p_identifier_type);
- }
- p_file.end_scope();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/SessionToEagle.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/SessionToEagle.java
deleted file mode 100644
index d1180ad..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/SessionToEagle.java
+++ /dev/null
@@ -1,738 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * SessionToEagle.java
- *
- * Created on 8. Dezember 2004, 07:42
- */
-
-package designformats.specctra;
-
-
-/**
- * Transformes a Specctra session file into an Eagle script file.
- *
- * @author Alfons Wirtz
- */
-public class SessionToEagle extends javax.swing.JFrame
-{
-
- public static boolean get_instance(java.io.InputStream p_session, java.io.OutputStream p_output_stream,
- board.BasicBoard p_board)
- {
- if (p_output_stream == null)
- {
- return false;
- }
-
- // create a scanner for reading the session_file.
-
- Scanner scanner = new SpecctraFileScanner(p_session);
-
- // create a file_writer for the eagle script file.
- java.io.OutputStreamWriter file_writer = new java.io.OutputStreamWriter(p_output_stream);
-
- boolean result = true;
-
- double board_scale_factor = p_board.communication.coordinate_transform.board_to_dsn(1);
- SessionToEagle new_instance = new SessionToEagle(scanner, file_writer, p_board,
- p_board.communication.unit, p_board.communication.resolution, board_scale_factor);
-
- try
- {
- result = new_instance.process_session_scope();
- }
- catch (java.io.IOException e)
- {
- System.out.println("unable to process session scope");
- result = false;
- }
-
- // close files
- try
- {
- p_session.close();
- file_writer.close();
- }
- catch (java.io.IOException e)
- {
- System.out.println("unable to close files");
- }
- return result;
- }
-
- SessionToEagle(Scanner p_scanner, java.io.OutputStreamWriter p_out_file, board.BasicBoard p_board,
- board.Unit p_unit, double p_session_file_scale_dominator, double p_board_scale_factor)
- {
- scanner = p_scanner;
- out_file = p_out_file;
- board = p_board;
- this.specctra_layer_structure = new LayerStructure(p_board.layer_structure);
- unit = p_unit;
- session_file_scale_denominator = p_session_file_scale_dominator;
- board_scale_factor = p_board_scale_factor;
- }
-
- /**
- * Processes the outmost scope of the session file.
- * Returns false, if an error occured.
- */
- private boolean process_session_scope() throws java.io.IOException
- {
-
- // read the first line of the session file
- Object next_token = null;
- for (int i = 0; i < 3; ++i)
- {
- next_token = this.scanner.next_token();
- boolean keyword_ok = true;
- if (i == 0)
- {
- keyword_ok = (next_token == Keyword.OPEN_BRACKET);
- }
- else if (i == 1)
- {
- keyword_ok = (next_token == Keyword.SESSION);
- this.scanner.yybegin(SpecctraFileScanner.NAME); // to overread the name of the pcb for i = 2
- }
- if (!keyword_ok)
- {
- System.out.println("SessionToEagle.process_session_scope specctra session file format expected");
- return false;
- }
- }
-
- // Write the header of the eagle script file.
-
- this.out_file.write("GRID ");
- this.out_file.write(this.unit.toString());
- this.out_file.write("\n");
- this.out_file.write("SET WIRE_BEND 2\n");
- this.out_file.write("SET OPTIMIZING OFF\n");
-
- // Activate all layers in Eagle.
-
- for (int i = 0; i < this.board.layer_structure.arr.length; ++i)
- {
- this.out_file.write("LAYER " + this.get_eagle_layer_string(i) + ";\n");
- }
-
- this.out_file.write("LAYER 17;\n");
- this.out_file.write("LAYER 18;\n");
- this.out_file.write("LAYER 19;\n");
- this.out_file.write("LAYER 20;\n");
- this.out_file.write("LAYER 23;\n");
- this.out_file.write("LAYER 24;\n");
-
- // Generate Code to remove the complete route.
- // Write a bounding rectangle with GROUP (Min_X-1 Min_Y-1) (Max_X+1 Max_Y+1);
-
- geometry.planar.IntBox board_bounding_box = this.board.get_bounding_box();
-
- Float min_x = (float) this.board_scale_factor * (board_bounding_box.ll.x - 1);
- Float min_y = (float) this.board_scale_factor * (board_bounding_box.ll.y - 1);
- Float max_x = (float) this.board_scale_factor * (board_bounding_box.ur.x + 1);
- Float max_y = (float) this.board_scale_factor * (board_bounding_box.ur.y + 1);
-
- this.out_file.write("GROUP (");
- this.out_file.write(min_x.toString());
- this.out_file.write(" ");
- this.out_file.write(min_y.toString());
- this.out_file.write(") (");
- this.out_file.write(max_x.toString());
- this.out_file.write(" ");
- this.out_file.write(max_y.toString());
- this.out_file.write(");\n");
- this.out_file.write("RIPUP;\n");
-
- // read the direct subscopes of the session scope
- for (;;)
- {
- Object prev_token = next_token;
- next_token = this.scanner.next_token();
- if (next_token == null)
- {
- // end of file
- return true;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
-
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.ROUTES)
- {
- if (!process_routes_scope())
- {
- return false;
- }
- }
- else if (next_token == Keyword.PLACEMENT_SCOPE)
- {
- if (!process_placement_scope())
- {
- return false;
- }
- }
- else
- {
- // overread all scopes except the routes scope for the time being
- ScopeKeyword.skip_scope(this.scanner);
- }
- }
- }
- // Wird nur einmal am Ende benoetigt!
- this.out_file.write("RATSNEST\n");
- return true;
- }
-
- private boolean process_placement_scope() throws java.io.IOException
- {
- // read the component scopes
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- next_token = this.scanner.next_token();
- if (next_token == null)
- {
- // unexpected end of file
- return false;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
-
- if (prev_token == Keyword.OPEN_BRACKET)
- {
-
- if (next_token == Keyword.COMPONENT_SCOPE)
- {
- if (!process_component_placement())
- {
- return false;
- }
- }
- else
- {
- // skip unknown scope
- ScopeKeyword.skip_scope(this.scanner);
- }
-
- }
- }
- process_swapped_pins();
- return true;
- }
-
- private boolean process_component_placement() throws java.io.IOException
- {
- ComponentPlacement component_placement = Component.read_scope(this.scanner);
- if (component_placement == null)
- {
- return false;
- }
- for (ComponentPlacement.ComponentLocation curr_location : component_placement.locations)
- {
- this.out_file.write("ROTATE =");
- Integer rotation = (int) Math.round(curr_location.rotation);
- String rotation_string;
- if (curr_location.is_front)
- {
- rotation_string = "R" + rotation.toString();
- }
- else
- {
- rotation_string = "MR" + rotation.toString();
- }
- this.out_file.write(rotation_string);
- this.out_file.write(" '");
- this.out_file.write(curr_location.name);
- this.out_file.write("';\n");
- this.out_file.write("move '");
- this.out_file.write(curr_location.name);
- this.out_file.write("' (");
- Double x_coor = curr_location.coor[0] / this.session_file_scale_denominator;
- this.out_file.write(x_coor.toString());
- this.out_file.write(" ");
- Double y_coor = curr_location.coor[1] / this.session_file_scale_denominator;
- this.out_file.write(y_coor.toString());
- this.out_file.write(");\n");
- }
- return true;
- }
-
- private boolean process_routes_scope() throws java.io.IOException
- {
- // read the direct subscopes of the routes scope
- boolean result = true;
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- next_token = this.scanner.next_token();
- if (next_token == null)
- {
- // unexpected end of file
- return false;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
-
- if (prev_token == Keyword.OPEN_BRACKET)
- {
-
- if (next_token == Keyword.NETWORK_OUT)
- {
- result = process_network_scope();
- }
- else
- {
- // skip unknown scope
- ScopeKeyword.skip_scope(this.scanner);
- }
-
- }
- }
- return result;
- }
-
- private boolean process_network_scope() throws java.io.IOException
- {
- boolean result = true;
- Object next_token = null;
- // read the net scopes
- for (;;)
- {
- Object prev_token = next_token;
- next_token = this.scanner.next_token();
- if (next_token == null)
- {
- // unexpected end of file
- return false;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
-
- if (prev_token == Keyword.OPEN_BRACKET)
- {
-
- if (next_token == Keyword.NET)
- {
- result = process_net_scope();
- }
- else
- {
- // skip unknown scope
- ScopeKeyword.skip_scope(this.scanner);
- }
-
- }
- }
- return result;
- }
-
- private boolean process_net_scope() throws java.io.IOException
- {
- // read the net name
- Object next_token = this.scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("SessionToEagle.processnet_scope: String expected");
- return false;
- }
- String net_name = (String) next_token;
-
- // Hier alle nicht gefixten Traces und Vias des Netz mit Namen net_name
- // in der Eagle Datenhaltung loeschen.
-
- // read the wires and vias of this net
- for (;;)
- {
- Object prev_token = next_token;
- next_token = this.scanner.next_token();
- if (next_token == null)
- {
- // end of file
- return true;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
-
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.WIRE)
- {
- if (!process_wire_scope(net_name))
- {
- return false;
- }
- }
- else if (next_token == Keyword.VIA)
- {
- if (!process_via_scope(net_name))
- {
- return false;
- }
- }
- else
- {
- ScopeKeyword.skip_scope(this.scanner);
- }
- }
- }
- return true;
- }
-
- private boolean process_wire_scope(String p_net_name) throws java.io.IOException
- {
- PolygonPath wire_path = null;
- Object next_token = null;
- for (;;)
- {
- Object prev_token = next_token;
- next_token = this.scanner.next_token();
- if (next_token == null)
- {
- System.out.println("SessionToEagle.process_wire_scope: unexpected end of file");
- return false;
- }
- if (next_token == Keyword.CLOSED_BRACKET)
- {
- // end of scope
- break;
- }
- if (prev_token == Keyword.OPEN_BRACKET)
- {
- if (next_token == Keyword.POLYGON_PATH)
- {
- wire_path = Shape.read_polygon_path_scope(this.scanner, this.specctra_layer_structure);
- }
- else
- {
- ScopeKeyword.skip_scope(this.scanner);
- }
- }
- }
- if (wire_path == null)
- {
- // conduction areas are skipped
- return true;
- }
-
- this.out_file.write("CHANGE LAYER ");
-
- this.out_file.write(wire_path.layer.name);
- this.out_file.write(";\n");
-
- //WIRE ['signal_name'] [width] [ROUND | FLAT] [curve | @radius]
-
- this.out_file.write("WIRE '");
-
- this.out_file.write(p_net_name);
- this.out_file.write("' ");
- Double wire_width = wire_path.width / this.session_file_scale_denominator;
- this.out_file.write(wire_width.toString());
- this.out_file.write(" (");
- for (int i = 0; i < wire_path.coordinate_arr.length; ++i)
- {
- Double wire_coor = wire_path.coordinate_arr[i] / this.session_file_scale_denominator;
- this.out_file.write(wire_coor.toString());
- if (i % 2 == 0)
- {
- this.out_file.write(" ");
- }
- else
- {
- if (i == wire_path.coordinate_arr.length - 1)
- {
- this.out_file.write(")");
- }
- else
- {
- this.out_file.write(") (");
- }
- }
- }
- this.out_file.write(";\n");
-
- return true;
- }
-
- private boolean process_via_scope(String p_net_name) throws java.io.IOException
- {
- // read the padstack name
- Object next_token = this.scanner.next_token();
- if (!(next_token instanceof String))
- {
- System.out.println("SessionToEagle.process_via_scope: padstack name expected");
- return false;
- }
- String padstack_name = (String) next_token;
- // read the location
- double []location = new double [2];
- for (int i = 0; i < 2; ++i)
- {
- next_token = this.scanner.next_token();
- if (next_token instanceof Double)
- {
- location[i] = ((Double) next_token).doubleValue();
- }
- else if (next_token instanceof Integer)
- {
- location[i] = ((Integer) next_token).intValue();
- }
- else
- {
- System.out.println("SessionToEagle.process_via_scope: number expected");
- return false;
- }
- }
- next_token = this.scanner.next_token();
- while (next_token == Keyword.OPEN_BRACKET)
- {
- // skip unknown scopes
- ScopeKeyword.skip_scope(this.scanner);
- next_token = this.scanner.next_token();
- }
- if (next_token != Keyword.CLOSED_BRACKET)
- {
- System.out.println("SessionToEagle.process_via_scope: closing bracket expected");
- return false;
- }
-
- if (padstack_name == null)
- {
- System.out.println("SessionToEagle.process_via_scope: padstack_name missing");
- return false;
- }
-
- library.Padstack via_padstack = this.board.library.padstacks.get(padstack_name);
-
- if (via_padstack == null)
- {
- System.out.println("SessionToEagle.process_via_scope: via padstack not found");
- return false;
- }
-
- geometry.planar.ConvexShape via_shape = via_padstack.get_shape(via_padstack.from_layer());
-
- Double via_diameter = via_shape.max_width() * this.board_scale_factor;
-
- // The Padstack name is of the form Name$drill_diameter$from_layer-to_layer
-
- String [] name_parts = via_padstack.name.split("\\$", 3);
-
- // example CHANGE DRILL 0.2
-
- this.out_file.write("CHANGE DRILL ");
- if (name_parts.length > 1)
- {
- this.out_file.write(name_parts[1]);
- }
- else
- {
- // create a default drill, because it is needed in Eagle
- this.out_file.write("0.1");
- }
- this.out_file.write(";\n");
-
-
- //VIA ['signal_name'] [diameter] [shape] [layers] [flags]
- // Via Net2 0.6 round 1-4 (20.0, 222.0);
- this.out_file.write("VIA '");
-
- this.out_file.write(p_net_name);
- this.out_file.write("' ");
-
- //Durchmesser aus Padstack
- this.out_file.write(via_diameter.toString());
-
- //Shape lesen und einsetzen Square / Round / Octagon
- if (via_shape instanceof geometry.planar.Circle)
- {
- this.out_file.write(" round ");
- }
- else if (via_shape instanceof geometry.planar.IntOctagon)
- {
- this.out_file.write(" octagon ");
- }
- else
- {
- this.out_file.write(" square ");
- }
- this.out_file.write(get_eagle_layer_string(via_padstack.from_layer()));
- this.out_file.write("-");
- this.out_file.write(get_eagle_layer_string(via_padstack.to_layer()));
- this.out_file.write(" (");
- Double x_coor = location[0] / this.session_file_scale_denominator;
- this.out_file.write(x_coor.toString());
- this.out_file.write(" ");
- Double y_coor = location[1] / this.session_file_scale_denominator;
- this.out_file.write(y_coor.toString());
- this.out_file.write(");\n");
-
- return true;
- }
-
- private String get_eagle_layer_string(int p_layer_no)
- {
- if (p_layer_no < 0 || p_layer_no >= specctra_layer_structure.arr.length)
- {
- return "0";
- }
- String [] name_pieces = this.specctra_layer_structure.arr[p_layer_no].name.split("#", 2);
- return name_pieces[0];
- }
-
- private boolean process_swapped_pins() throws java.io.IOException
- {
- for (int i = 1; i <= this.board.components.count(); ++i)
- {
- if (!process_swapped_pins(i))
- {
- return false;
- }
- }
- return true;
- }
-
- private boolean process_swapped_pins(int p_component_no) throws java.io.IOException
- {
- java.util.Collection component_pins = this.board.get_component_pins(p_component_no);
- boolean component_has_swapped_pins = false;
- for (board.Pin curr_pin : component_pins)
- {
- if (curr_pin.get_changed_to() != curr_pin)
- {
- component_has_swapped_pins = true;
- break;
- }
- }
- if (!component_has_swapped_pins)
- {
- return true;
- }
- PinInfo[] pin_info_arr = new PinInfo[component_pins.size()];
- int i = 0;
- for (board.Pin curr_pin : component_pins)
- {
- pin_info_arr[i] = new PinInfo(curr_pin);
- ++i;
- }
- for (i = 0; i < pin_info_arr.length; ++i)
- {
- PinInfo curr_pin_info = pin_info_arr[i];
- if (curr_pin_info.curr_changed_to != curr_pin_info.pin.get_changed_to())
- {
- PinInfo other_pin_info = null;
- for (int j = i + 1; j < pin_info_arr.length; ++j)
- {
- if (pin_info_arr[j].pin.get_changed_to() == curr_pin_info.pin)
- {
- other_pin_info = pin_info_arr[j];
- }
- }
- if (other_pin_info == null)
- {
- System.out.println("SessuinToEagle.process_swapped_pins: other_pin_info not found");
- return false;
- }
- write_pin_swap(curr_pin_info.pin, other_pin_info.pin);
- curr_pin_info.curr_changed_to = other_pin_info.pin;
- other_pin_info.curr_changed_to = curr_pin_info.pin;
- }
- }
- return true;
- }
-
- private void write_pin_swap( board.Pin p_pin_1, board.Pin p_pin_2) throws java.io.IOException
- {
- int layer_no = Math.max(p_pin_1.first_layer(), p_pin_2.first_layer());
- String layer_name = board.layer_structure.arr[layer_no].name;
-
- this.out_file.write("CHANGE LAYER ");
- this.out_file.write(layer_name);
- this.out_file.write(";\n");
-
- double [] location_1 =
- this.board.communication.coordinate_transform.board_to_dsn(p_pin_1.get_center().to_float());
- double [] location_2 =
- this.board.communication.coordinate_transform.board_to_dsn(p_pin_2.get_center().to_float());
-
- this.out_file.write("PINSWAP ");
- this.out_file.write(" (");
- Double curr_coor = location_1[0];
- this.out_file.write(curr_coor.toString());
- this.out_file.write(" ");
- curr_coor = location_1[1];
- this.out_file.write(curr_coor.toString());
- this.out_file.write(") (");
- curr_coor = location_2[0];
- this.out_file.write(curr_coor.toString());
- this.out_file.write(" ");
- curr_coor = location_2[1];
- this.out_file.write(curr_coor.toString());
- this.out_file.write(");\n");
- }
-
-
-
- /** The function for scanning the session file */
- private final Scanner scanner;
-
- /** The generated Eagle script file. */
- private final java.io.OutputStreamWriter out_file;
-
- /** Some information is read from the board, because it is not contained in the speccctra session file. */
- private final board.BasicBoard board;
-
- /** The layer structure in specctra format */
- private final LayerStructure specctra_layer_structure;
-
- private final board.Unit unit;
-
- /** The scale factor for transforming coordinates from the session file to Eagle */
- private final double session_file_scale_denominator;
-
- /** The scale factor for transforming coordinates from the board to Eagle */
- private final double board_scale_factor;
-
- private static class PinInfo
- {
- PinInfo(board.Pin p_pin)
- {
- pin = p_pin;
- curr_changed_to = p_pin;
- }
- final board.Pin pin;
- board.Pin curr_changed_to;
- }
-}
-
diff --git a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Shape.java b/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Shape.java
deleted file mode 100644
index e1da944..0000000
--- a/src/main/java/eu/mihosoft/freerouting/designformats/specctra/Shape.java
+++ /dev/null
@@ -1,831 +0,0 @@
-/*
- * Copyright (C) 2014 Alfons Wirtz
- * website www.freerouting.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License at
- * for more details.
- *
- * Shape.java
- *
- * Created on 16. Mai 2004, 11:09
- */
-package designformats.specctra;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import geometry.planar.PolylineShape;
-import datastructures.IndentFileWriter;
-import datastructures.IdentifierType;
-
-/**
- * Describes a shape in a Specctra dsn file.
- *
- * @author alfons
- */
-public abstract class Shape
-{
-
- /**
- * Writes a shape scope to a Specctra dsn file.
- */
- public abstract void write_scope(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException;
-
- /**
- * Writes a shape scope to a Specctra session file.
- * In a session file all coordinates must be integer.
- */
- public abstract void write_scope_int(IndentFileWriter p_file, IdentifierType p_identifier) throws java.io.IOException;
-
- /**
- * Reads shape scope from a Specctra dsn file.
- * If p_layer_structure == null, only Layer.PCB and Layer.Signal are expected, no induvidual layers.
- */
- public static final Shape read_scope(Scanner p_scanner, LayerStructure p_layer_structure)
- {
- Shape result = null;
- try
- {
- Object next_token = p_scanner.next_token();
- if (next_token == Keyword.OPEN_BRACKET)
- {
- // overread the open bracket
- next_token = p_scanner.next_token();
- }
-
- if (next_token == Keyword.RECTANGLE)
- {
-
- result = Shape.read_rectangle_scope(p_scanner, p_layer_structure);
- }
- else if (next_token == Keyword.POLYGON)
- {
-
- result = Shape.read_polygon_scope(p_scanner, p_layer_structure);
- }
- else if (next_token == Keyword.CIRCLE)
- {
-
- result = Shape.read_circle_scope(p_scanner, p_layer_structure);
- }
- else if (next_token == Keyword.POLYGON_PATH)
- {
- result = Shape.read_polygon_path_scope(p_scanner, p_layer_structure);
- }
- else
- {
- // not a shape scope, skip it.
- ScopeKeyword.skip_scope(p_scanner);
- }
- }
- catch (java.io.IOException e)
- {
- System.out.println("Shape.read_scope: IO error scanning file");
- System.out.println(e);
- return result;
- }
- return result;
- }
-
- /**
- * Reads an object of type PolylinePath from the dsn-file.
- */
- public static PolylinePath read_polyline_path_scope(Scanner p_scanner, LayerStructure p_layer_structure)
- {
- try
- {
- Layer layer = null;
- Object next_token = p_scanner.next_token();
- if (next_token == Keyword.PCB_SCOPE)
- {
- layer = Layer.PCB;
- }
- else if (next_token == Keyword.SIGNAL)
- {
- layer = Layer.SIGNAL;
- }
- else
- {
- if (p_layer_structure == null)
- {
- System.out.println("PolylinePath.read_scope: only layer types pcb or signal expected");
- return null;
- }
- if (!(next_token instanceof String))
- {
- System.out.println("PolylinePath.read_scope: layer name string expected");
- return null;
- }
- int layer_no = p_layer_structure.get_no((String) next_token);
- if (layer_no < 0 || layer_no >= p_layer_structure.arr.length)
- {
- System.out.print("Shape.read_polyline_path_scope: layer name ");
- System.out.print((String) next_token);
- System.out.println(" not found in layer structure ");
- return null;
- }
- layer = p_layer_structure.arr[layer_no];
- }
- Collection