Skip to content
This repository has been archived by the owner on Jan 29, 2018. It is now read-only.

Commit

Permalink
Fix for dxfs rendering in weird places
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter van der Walt committed Mar 1, 2016
1 parent 1323e85 commit e45e95d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
1 change: 1 addition & 0 deletions i/dxf/gcode/three2gcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ console.log('RapidSpeed', rapidSpeed);
g += " Y" + worldPt.y.toFixed(3);
g += " S" + options.lasersvalue + "\n";


}
}

Expand Down
17 changes: 5 additions & 12 deletions i/dxf/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ THREE.BulgeGeometry.prototype = Object.create( THREE.Geometry.prototype );
* @constructor
*/
function processDXF(data) {
console.log(data);
//console.log(data);

if (typeof(dxfObject) !== 'undefined') {
scene.remove(dxfObject);
Expand Down Expand Up @@ -107,7 +107,7 @@ function processDXF(data) {


function drawEntity(index, entity) {
console.log('inside drawEntity: Entity ', entity, ' Index: ', index)
//console.log('inside drawEntity: Entity ', entity, ' Index: ', index)
if(entity.type === 'CIRCLE' || entity.type === 'ARC') {
drawCircle(entity, index);
} else if(entity.type === 'LWPOLYLINE' || entity.type === 'LINE' || entity.type === 'POLYLINE') {
Expand All @@ -122,7 +122,7 @@ function drawEntity(index, entity) {
}

function drawLine(entity, index) {
console.log('inside drawLine ', entity, ' Index: ', index )
//console.log('inside drawLine ', entity, ' Index: ', index )
var geometry = new THREE.Geometry(),
color = getDXFColor(entity),
material, lineType, vertex, startPoint, endPoint, bulgeGeometry,
Expand Down Expand Up @@ -163,23 +163,16 @@ function drawCircle(entity, index) {

// Laserweb - calc and draw gcode
var radius = entity.radius;
console.log('Radius:'+radius+' and Center '+entity.center.x+','+entity.center.y+','+entity.center.z+',\n'); // Radius:220 and Center 0,0,0,
//console.log('Radius:'+radius+' and Center '+entity.center.x+','+entity.center.y+','+entity.center.z+',\n'); // Radius:220 and Center 0,0,0,
var arcTotalDeg = entity.startAngleDeg - entity.endAngleDeg;
console.log('Start Angle: '+entity.startAngleDeg+', End Angle: '+entity.endAngleDeg+', thus spanning '+arcTotalDeg+'deg' );
//console.log('Start Angle: '+entity.startAngleDeg+', End Angle: '+entity.endAngleDeg+', thus spanning '+arcTotalDeg+'deg' );

// Draw it since its cool to see (note this is a straigh three.js view of it, not via gcode. Can be used in the Cutting Params view by coloring object/layers to change params)
var geometry, material, circle;

geometry = new THREE.CircleGeometry(entity.radius, 128, entity.startAngle, entity.angleLength);
geometry.vertices.shift();

console.log('Passing in:', geometry.vertices);
offsetGeometry = getInflatedPath(geometry.vertices, 3);
console.log('Got Out: ', offsetGeometry);
//offsetMaterial = new THREE.LineBasicMaterial({ color: 0xff0000 });
//offsetCircle = new THREE.Line(offsetGeometry, offsetMaterial);
//scene.add(offsetCircle);

material = new THREE.LineBasicMaterial({ color: getDXFColor(entity) });

//circle = new THREE.Line(geometry, material);
Expand Down
15 changes: 9 additions & 6 deletions i/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1425,18 +1425,21 @@ $(document).ready(function() {
//NEW Dxf -- experimental
parser2 = new window.DxfParser();
dxf2 = parser2.parseSync(r.result);
console.log('DXF Data', dxf2);
//console.log('DXF Data', dxf2);
//cadCanvas = new processDXF(dxf2);

for (i = 0; i < dxf2.entities.length; i++ ) {
console.log('Layer: ', dxf2.entities[i].layer);
//console.log('Layer: ', dxf2.entities[i].layer);
row[i] = dxf2.entities[i].layer
drawEntity(i, dxf2.entities[i]);
};

dxfObject.translateX(laserxmax /2 * -1);
dxfObject.translateY(laserymax /2 * -1);
scene.add(dxfObject);
//dxfObject.translateX(laserxmax /2 * -1);
//dxfObject.translateY(laserymax /2 * -1);
var showDxf = dxfObject.clone();
showDxf.translateX(laserxmax /2 * -1);
showDxf.translateY(laserymax /2 * -1);
scene.add(showDxf);

Array.prototype.unique = function()
{
Expand Down Expand Up @@ -1516,7 +1519,7 @@ $(document).ready(function() {
//document.getElementById('fileInputMILL').value = '';
$('#console').append('<p class="pf" style="color: #000000;"><b>NewDXFLib Complete...</b></p>');
$('#console').scrollTop($("#console")[0].scrollHeight - $("#console").height());
$('#noneg').click();
//$('#noneg').click();

});

Expand Down

0 comments on commit e45e95d

Please sign in to comment.