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
2a5e7a78
Commit
2a5e7a78
authored
11 years ago
by
Thomas Oster
Browse files
Options
Downloads
Patches
Plain Diff
Raster3d
parent
cf4e9bac
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/com/t_oster/liblasercut/drivers/IModelaMill.java
+48
-2
48 additions, 2 deletions
src/com/t_oster/liblasercut/drivers/IModelaMill.java
with
48 additions
and
2 deletions
src/com/t_oster/liblasercut/drivers/IModelaMill.java
+
48
−
2
View file @
2a5e7a78
...
...
@@ -25,6 +25,7 @@ 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.Raster3dPart
;
import
com.t_oster.liblasercut.RasterPart
;
import
com.t_oster.liblasercut.VectorCommand
;
import
com.t_oster.liblasercut.VectorPart
;
...
...
@@ -191,6 +192,22 @@ public class IModelaMill extends LaserCutter
return
black
/
count
;
}
private
double
getAverageGrey
(
Raster3dPart
p
,
int
cx
,
int
cy
,
int
toolDiameter
)
{
double
count
=
toolDiameter
*
toolDiameter
;
double
value
=
0
;
for
(
int
y
=
Math
.
max
(
cy
-
toolDiameter
/
2
,
0
);
y
<
Math
.
min
(
cy
+
toolDiameter
/
2
,
p
.
getRasterHeight
());
y
++)
{
List
<
Byte
>
line
=
p
.
getRasterLine
(
y
);
for
(
int
x
=
Math
.
max
(
cx
-
toolDiameter
/
2
,
0
);
x
<
Math
.
min
(
cx
+
toolDiameter
/
2
,
p
.
getRasterWidth
());
x
++)
{
value
+=
line
.
get
(
x
);
}
}
return
(
value
/
count
)/
255
;
}
private
void
writeRasterCode
(
RasterPart
p
,
PrintStream
out
)
{
double
dpi
=
p
.
getDPI
();
...
...
@@ -232,6 +249,35 @@ public class IModelaMill extends LaserCutter
}
}
private
void
writeRaster3dCode
(
Raster3dPart
p
,
PrintStream
out
)
{
double
dpi
=
p
.
getDPI
();
IModelaProperty
prop
=
(
IModelaProperty
)
p
.
getLaserProperty
();
int
toolDiameterInPx
=
(
int
)
Util
.
mm2px
(
prop
.
getToolDiameter
(),
dpi
);
applyProperty
(
out
,
prop
);
boolean
leftToRight
=
true
;
Point
offset
=
p
.
getRasterStart
();
move
(
out
,
Util
.
mm2px
(
offset
.
x
,
dpi
),
Util
.
mm2px
(
offset
.
y
,
dpi
));
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
)
{
//scale the depth according to the average grey value
linedepth
=
getAverageGrey
(
p
,
x
,
y
,
toolDiameterInPx
)*
prop
.
getDepth
();
//skip intermediate line commands
while
((
leftToRight
&&
x
+
1
<
p
.
getRasterWidth
())
||
(!
leftToRight
&&
x
-
1
>=
0
)
&&
getAverageGrey
(
p
,
leftToRight
?
x
+
1
:
x
-
1
,
y
,
toolDiameterInPx
)
==
linedepth
)
{
x
+=
leftToRight
?
1
:
-
1
;
}
line
(
out
,
Util
.
mm2px
(
offset
.
x
+
x
,
dpi
),
Util
.
mm2px
(
offset
.
y
+
y
,
dpi
));
}
//invert direction
leftToRight
=
!
leftToRight
;
}
}
private
void
writeVectorCode
(
VectorPart
p
,
PrintStream
out
)
{
double
dpi
=
p
.
getDPI
();
...
...
@@ -297,9 +343,9 @@ public class IModelaMill extends LaserCutter
{
writeRasterCode
((
RasterPart
)
p
,
out
);
}
else
else
if
(
p
instanceof
Raster3dPart
)
{
throw
new
IllegalJobException
(
"Raster3d is not yet supported by iModela driver"
);
writeRaster3dCode
((
Raster3dPart
)
p
,
out
);
}
pl
.
progressChanged
(
this
,
(
int
)
(
20
+
30
*
i
++/
all
));
}
...
...
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