mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-24 01:15:25 +01:00
fix extrude operation
This commit is contained in:
parent
dbc17908a3
commit
37bce68fa2
1 changed files with 30 additions and 27 deletions
|
|
@ -143,26 +143,26 @@ TCAD.craft.getSketchedPolygons3D = function(app, face) {
|
|||
};
|
||||
|
||||
TCAD.craft.extrude = function(app, face, faces, height) {
|
||||
|
||||
var sketchedPolygons = TCAD.craft.getSketchedPolygons3D(app, face);
|
||||
if (sketchedPolygons == null) return null;
|
||||
|
||||
var newSolidFaces = [];
|
||||
var normal = face.polygon.normal;
|
||||
|
||||
var toMeldWith = [];
|
||||
for (var i = 0; i < sketchedPolygons.length; i++) {
|
||||
var extruded = TCAD.geom.extrude(sketchedPolygons[i], normal.multiply(height));
|
||||
newSolidFaces = newSolidFaces.concat(extruded);
|
||||
toMeldWith = toMeldWith.concat(TCAD.craft._makeFromPolygons(extruded));
|
||||
}
|
||||
var work = TCAD.craft._makeFromPolygons(faces.map(function(f){ return f.polygon }));
|
||||
|
||||
var meld = CSG.fromPolygons(work).union(CSG.fromPolygons(toMeldWith));
|
||||
|
||||
face.polygon.__face = undefined;
|
||||
|
||||
for (var i = 0; i < faces.length; i++) {
|
||||
newSolidFaces.push(faces[i].polygon);
|
||||
}
|
||||
return newSolidFaces;
|
||||
return TCAD.craft.reconstruct(meld);
|
||||
};
|
||||
|
||||
|
||||
TCAD.craft.pkey = function(point) {
|
||||
return point.x + ":" + point.y + ":" + point.z;
|
||||
}
|
||||
|
|
@ -588,25 +588,7 @@ TCAD.craft.recoverySketchInfo = function(polygons) {
|
|||
}
|
||||
};
|
||||
|
||||
TCAD.craft.cut = function(app, face, faces, height) {
|
||||
|
||||
var sketchedPolygons = TCAD.craft.getSketchedPolygons3D(app, face);
|
||||
if (sketchedPolygons == null) return null;
|
||||
|
||||
var newSolidFaces = [];
|
||||
var normal = face.polygon.normal;
|
||||
|
||||
var cutter = [];
|
||||
for (var i = 0; i < sketchedPolygons.length; i++) {
|
||||
var extruded = TCAD.geom.extrude(sketchedPolygons[i], normal.multiply( - height));
|
||||
cutter = cutter.concat(TCAD.craft._makeFromPolygons(extruded));
|
||||
}
|
||||
var work = TCAD.craft._makeFromPolygons(faces.map(function(f){ return f.polygon }));
|
||||
|
||||
var cut = CSG.fromPolygons(work).subtract(CSG.fromPolygons(cutter));
|
||||
|
||||
face.polygon.__face = undefined;
|
||||
|
||||
TCAD.craft.reconstruct = function (cut) {
|
||||
function pInP(p1, p2) {
|
||||
var notEqPoints = [];
|
||||
|
||||
|
|
@ -743,10 +725,31 @@ TCAD.craft.cut = function(app, face, faces, height) {
|
|||
);
|
||||
}
|
||||
TCAD.craft.recoverySketchInfo(result);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
TCAD.craft.cut = function(app, face, faces, height) {
|
||||
|
||||
var sketchedPolygons = TCAD.craft.getSketchedPolygons3D(app, face);
|
||||
if (sketchedPolygons == null) return null;
|
||||
|
||||
var newSolidFaces = [];
|
||||
var normal = face.polygon.normal;
|
||||
|
||||
var cutter = [];
|
||||
for (var i = 0; i < sketchedPolygons.length; i++) {
|
||||
var extruded = TCAD.geom.extrude(sketchedPolygons[i], normal.multiply( - height));
|
||||
cutter = cutter.concat(TCAD.craft._makeFromPolygons(extruded));
|
||||
}
|
||||
var work = TCAD.craft._makeFromPolygons(faces.map(function(f){ return f.polygon }));
|
||||
|
||||
var cut = CSG.fromPolygons(work).subtract(CSG.fromPolygons(cutter));
|
||||
|
||||
face.polygon.__face = undefined;
|
||||
|
||||
return TCAD.craft.reconstruct(cut);
|
||||
};
|
||||
|
||||
TCAD.Craft = function(app) {
|
||||
this.app = app;
|
||||
this.history = [];
|
||||
|
|
|
|||
Loading…
Reference in a new issue