Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LibLaserCut
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Elektronikföreningen Admittansen
LibLaserCut
Commits
890f4dd5
Commit
890f4dd5
authored
11 years ago
by
Thomas Oster
Browse files
Options
Downloads
Patches
Plain Diff
raster mode (inefficient) and improvements
parent
257425fc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/com/t_oster/liblasercut/drivers/IModelaMill.java
+74
-1
74 additions, 1 deletion
src/com/t_oster/liblasercut/drivers/IModelaMill.java
src/com/t_oster/liblasercut/drivers/IModelaProperty.java
+19
-4
19 additions, 4 deletions
src/com/t_oster/liblasercut/drivers/IModelaProperty.java
with
93 additions
and
5 deletions
src/com/t_oster/liblasercut/drivers/IModelaMill.java
+
74
−
1
View file @
890f4dd5
...
...
@@ -25,8 +25,10 @@ import com.t_oster.liblasercut.LaserCutter;
import
com.t_oster.liblasercut.LaserJob
;
import
com.t_oster.liblasercut.LaserProperty
;
import
com.t_oster.liblasercut.ProgressListener
;
import
com.t_oster.liblasercut.RasterPart
;
import
com.t_oster.liblasercut.VectorCommand
;
import
com.t_oster.liblasercut.VectorPart
;
import
com.t_oster.liblasercut.platform.Point
;
import
com.t_oster.liblasercut.platform.Util
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
...
...
@@ -130,6 +132,8 @@ public class IModelaMill extends LaserCutter
private
void
move
(
PrintStream
out
,
double
x
,
double
y
)
{
moveHead
(
out
,
movedepth
);
//TODO: check if last command was also move and lies on the
//same line. If so, replace the last move command
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"G00 X%f Y%f%s\n"
,
x
,
y
,
parameters
));
parameters
=
""
;
}
...
...
@@ -137,6 +141,8 @@ public class IModelaMill extends LaserCutter
private
void
line
(
PrintStream
out
,
double
x
,
double
y
)
{
moveHead
(
out
,
linedepth
);
//TODO: check if last command was also line and lies on the
//same line. If so, replace the last move command
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"G01 X%f Y%f%s\n"
,
x
,
y
,
parameters
));
parameters
=
""
;
}
...
...
@@ -157,11 +163,64 @@ public class IModelaMill extends LaserCutter
if
(
pr
.
getTool
()
!=
tool
)
{
tool
=
pr
.
getTool
();
//TODO: Maybe stop spindle and move to some location?
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"M06T0\n"
));
//return current tool
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"M06T%d\n"
,
tool
));
}
}
/*
* Returns the percentage of black pixels in a square rectangle with
* side length toolDiameter
* arount x/y in the given raster
*/
private
double
getBlackPercent
(
RasterPart
p
,
int
cx
,
int
cy
,
int
toolDiameter
)
{
double
count
=
0
;
double
black
=
0
;
for
(
int
x
=
Math
.
max
(
cx
-
toolDiameter
/
2
,
0
);
x
<
Math
.
min
(
cx
+
toolDiameter
/
2
,
p
.
getRasterWidth
());
x
++)
{
for
(
int
y
=
Math
.
max
(
cy
-
toolDiameter
/
2
,
0
);
y
<
Math
.
min
(
cy
+
toolDiameter
/
2
,
p
.
getRasterHeight
());
y
++)
{
count
++;
if
(
p
.
isBlack
(
x
,
y
))
{
black
++;
}
}
}
return
black
/
count
;
}
private
void
writeRasterCode
(
RasterPart
p
,
PrintStream
out
)
{
double
dpi
=
p
.
getDPI
();
//how many pixels(%) have to be black until we move the head down
double
treshold
=
0.7
;
IModelaProperty
prop
=
(
IModelaProperty
)
p
.
getLaserProperty
();
int
toolDiameterInPx
=
(
int
)
Util
.
mm2px
(
prop
.
getToolDiameter
(),
dpi
);
applyProperty
(
out
,
prop
);
boolean
leftToRight
=
true
;
Point
offset
=
p
.
getRasterStart
();
for
(
int
y
=
0
;
y
<
p
.
getRasterHeight
();
y
+=
toolDiameterInPx
/
2
)
{
for
(
int
x
=
leftToRight
?
0
:
p
.
getRasterWidth
()
-
1
;
(
leftToRight
&&
x
<
p
.
getRasterWidth
())
||
(!
leftToRight
&&
x
>=
0
);
x
+=
leftToRight
?
1
:
-
1
)
{
if
(
getBlackPercent
(
p
,
x
,
y
,
toolDiameterInPx
)<
treshold
)
{
move
(
out
,
Util
.
mm2px
(
offset
.
x
+
x
,
dpi
),
Util
.
mm2px
(
offset
.
y
+
y
,
dpi
));
}
else
{
line
(
out
,
Util
.
mm2px
(
offset
.
x
+
x
,
dpi
),
Util
.
mm2px
(
offset
.
y
+
y
,
dpi
));
}
}
leftToRight
=
!
leftToRight
;
}
}
private
void
writeVectorCode
(
VectorPart
p
,
PrintStream
out
)
{
double
dpi
=
p
.
getDPI
();
...
...
@@ -198,6 +257,12 @@ public class IModelaMill extends LaserCutter
{
return
new
IModelaProperty
();
}
@Override
public
LaserProperty
getLaserPropertyForRasterPart
()
{
return
new
IModelaProperty
();
}
@Override
public
void
sendJob
(
LaserJob
job
,
ProgressListener
pl
,
List
<
String
>
warnings
)
throws
IllegalJobException
,
Exception
...
...
@@ -215,9 +280,17 @@ public class IModelaMill extends LaserCutter
{
if
(
p
instanceof
VectorPart
)
{
pl
.
progressChanged
(
this
,
(
int
)
(
20
+
30
*
i
++/
all
));
writeVectorCode
((
VectorPart
)
p
,
out
);
}
else
if
(
p
instanceof
RasterPart
)
{
writeRasterCode
((
RasterPart
)
p
,
out
);
}
else
{
throw
new
IllegalJobException
(
"Raster3d is not yet supported by iModela driver"
);
}
pl
.
progressChanged
(
this
,
(
int
)
(
20
+
30
*
i
++/
all
));
}
writeFinalizationCode
(
out
);
pl
.
progressChanged
(
this
,
50
);
...
...
This diff is collapsed.
Click to expand it.
src/com/t_oster/liblasercut/drivers/IModelaProperty.java
+
19
−
4
View file @
890f4dd5
...
...
@@ -29,16 +29,23 @@ import com.t_oster.liblasercut.platform.Util;
public
class
IModelaProperty
implements
LaserProperty
{
private
static
String
DEPTH
=
"milling depth"
;
private
static
String
FEED_RATE
=
"feed rate"
;
private
static
String
SPINDLE_SPEED
=
"spindle speed"
;
private
static
String
DEPTH
=
"milling depth
(mm)
"
;
private
static
String
FEED_RATE
=
"feed rate
(mm/min)
"
;
private
static
String
SPINDLE_SPEED
=
"spindle speed
(rpm)
"
;
private
static
String
TOOL
=
"tool"
;
private
static
String
TOOL_DIAMETER
=
"tool diameter (mm)"
;
private
double
depth
=
0
;
private
double
feedRate
=
1
;
private
int
spindleSpeed
=
100
;
private
int
tool
=
1
;
private
double
toolDiameter
=
4
;
public
double
getToolDiameter
()
{
return
toolDiameter
;
}
public
double
getDepth
()
{
return
depth
;
...
...
@@ -102,7 +109,7 @@ public class IModelaProperty implements LaserProperty
@Override
public
String
[]
getPropertyKeys
()
{
return
new
String
[]{
DEPTH
,
SPINDLE_SPEED
,
FEED_RATE
,
TOOL
};
return
new
String
[]{
DEPTH
,
SPINDLE_SPEED
,
FEED_RATE
,
TOOL
,
TOOL_DIAMETER
};
}
@Override
...
...
@@ -124,6 +131,10 @@ public class IModelaProperty implements LaserProperty
{
tool
=
(
Integer
)
value
;
}
else
if
(
TOOL_DIAMETER
.
equals
(
key
))
{
toolDiameter
=
(
Double
)
value
;
}
}
@Override
...
...
@@ -145,6 +156,10 @@ public class IModelaProperty implements LaserProperty
{
return
tool
;
}
else
if
(
TOOL_DIAMETER
.
equals
(
key
))
{
return
toolDiameter
;
}
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment