mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
Playing with face creating in test feature
This commit is contained in:
parent
a4b82dce14
commit
87666bacbd
5 changed files with 273 additions and 0 deletions
62
modules/workbenches/modeler/features/testFeature/CHAMFER.svg
Normal file
62
modules/workbenches/modeler/features/testFeature/CHAMFER.svg
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
<svg
|
||||||
|
version="1.1"
|
||||||
|
viewBox="0.0 0.0 96.0 96.0"
|
||||||
|
fill="none"
|
||||||
|
stroke="none"
|
||||||
|
stroke-linecap="square"
|
||||||
|
stroke-miterlimit="10"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
><clipPath id="g14470d71bf0_0_353.0"><path
|
||||||
|
d="m0 0l96.0 0l0 96.0l-96.0 0l0 -96.0z"
|
||||||
|
clip-rule="nonzero"
|
||||||
|
/></clipPath><g clip-path="url(#g14470d71bf0_0_353.0)"><path
|
||||||
|
fill="#000000"
|
||||||
|
fill-opacity="0.0"
|
||||||
|
d="m0 0l96.0 0l0 96.0l-96.0 0z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
fill="#999999"
|
||||||
|
d="m13.372704 43.574802l37.414307 21.838055l-0.14963913 25.93435l-37.264668 -21.687027z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-width="4.0"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-linecap="butt"
|
||||||
|
d="m13.372704 43.574802l37.414307 21.838055l-0.14963913 25.93435l-37.264668 -21.687027z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
fill="#ffff00"
|
||||||
|
d="m50.93061 65.80887l14.41851 -26.288708l-36.652504 -21.483416l-15.473518 25.839937z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-width="4.0"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-linecap="butt"
|
||||||
|
d="m50.93061 65.80887l14.41851 -26.288708l-36.652504 -21.483416l-15.473518 25.839937z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
fill="#999999"
|
||||||
|
d="m29.0 17.736256l21.779976 -12.767752l36.954308 21.630383l-22.38359 12.91997z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-width="4.0"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-linecap="butt"
|
||||||
|
d="m29.0 17.736256l21.779976 -12.767752l36.954308 21.630383l-22.38359 12.91997z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
fill="#999999"
|
||||||
|
d="m88.18786 26.750656l0 43.1138l-37.40571 21.3312l0 -25.385918l14.421135 -26.139114z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-width="4.0"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-linecap="butt"
|
||||||
|
d="m88.18786 26.750656l0 43.1138l-37.40571 21.3312l0 -25.385918l14.421135 -26.139114z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/></g></svg>
|
||||||
|
After Width: | Height: | Size: 2 KiB |
64
modules/workbenches/modeler/features/testFeature/FILLET.svg
Normal file
64
modules/workbenches/modeler/features/testFeature/FILLET.svg
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
<svg
|
||||||
|
version="1.1"
|
||||||
|
viewBox="0.0 0.0 96.0 96.0"
|
||||||
|
fill="none"
|
||||||
|
stroke="none"
|
||||||
|
stroke-linecap="square"
|
||||||
|
stroke-miterlimit="10"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
><clipPath id="g14470d71bf0_0_149.0"><path
|
||||||
|
d="m0 0l96.0 0l0 96.0l-96.0 0l0 -96.0z"
|
||||||
|
clip-rule="nonzero"
|
||||||
|
/></clipPath><g clip-path="url(#g14470d71bf0_0_149.0)"><path
|
||||||
|
fill="#000000"
|
||||||
|
fill-opacity="0.0"
|
||||||
|
d="m0 0l96.0 0l0 96.0l-96.0 0z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
fill="#999999"
|
||||||
|
d="m50.628822 91.18427l37.40571 -21.782593l0 -43.1138l-37.40571 -21.480791l-22.38359 12.61816l37.40571 21.782597l-2.4039574 1.8029709l-2.703144 2.1021538l-1.6533775 2.10215l-2.2517433 2.8553581l-1.9551849 3.154541l-1.650753 3.154541l-1.3515701 4.2069283l-0.45140076 3.0023232l-0.2991829 3.605938l-37.555298 -21.480793l0 25.986904z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-width="4.0"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-linecap="butt"
|
||||||
|
d="m50.628822 91.18427l37.40571 -21.782593l0 -43.1138l-37.40571 -21.480791l-22.38359 12.61816l37.40571 21.782597l-2.4039574 1.8029709l-2.703144 2.1021538l-1.6533775 2.10215l-2.2517433 2.8553581l-1.9551849 3.154541l-1.650753 3.154541l-1.3515701 4.2069283l-0.45140076 3.0023232l-0.2991829 3.605938l-37.555298 -21.480793l0 25.986904z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
fill="#ffff00"
|
||||||
|
d="m43.117744 25.840397l22.53318 13.219151l-1.8029709 1.3515701l-1.8029671 1.3515701l-1.9525604 1.6533775l-1.8029709 1.650753l-1.8029671 2.1047783l-1.5011635 2.5535507l-1.9525604 3.154541l-1.0523872 3.3041306l-0.6009903 2.8527336l-0.44877625 2.5535507l-0.15221405 3.7555313l-37.555298 -21.480793l0 -3.0049515l0.45139885 -3.9051208l0.60098934 -2.4039574l1.3515711 -3.453724l1.802969 -3.605938l2.2543678 -2.5535507l1.650753 -1.9525604l2.1047764 -1.9525604l2.5535507 -1.802969l2.2517433 -1.5011635z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-width="4.0"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-linecap="butt"
|
||||||
|
d="m43.117744 25.840397l22.53318 13.219151l-1.8029709 1.3515701l-1.8029671 1.3515701l-1.9525604 1.6533775l-1.8029709 1.650753l-1.8029671 2.1047783l-1.5011635 2.5535507l-1.9525604 3.154541l-1.0523872 3.3041306l-0.6009903 2.8527336l-0.44877625 2.5535507l-0.15221405 3.7555313l-37.555298 -21.480793l0 -3.0049515l0.45139885 -3.9051208l0.60098934 -2.4039574l1.3515711 -3.453724l1.802969 -3.605938l2.2543678 -2.5535507l1.650753 -1.9525604l2.1047764 -1.9525604l2.5535507 -1.802969l2.2517433 -1.5011635z"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
fill="#000000"
|
||||||
|
fill-opacity="0.0"
|
||||||
|
d="m65.50656 39.211285l22.58268 -12.755905"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-width="4.0"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-linecap="butt"
|
||||||
|
d="m65.50656 39.211285l22.58268 -12.755905"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
fill="#000000"
|
||||||
|
fill-opacity="0.0"
|
||||||
|
d="m50.78215 65.350395l-0.18897629 25.228348"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/><path
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-width="4.0"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-linecap="butt"
|
||||||
|
d="m50.78215 65.350395l-0.18897629 25.228348"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
/></g></svg>
|
||||||
|
After Width: | Height: | Size: 3.2 KiB |
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Teast feature
|
||||||
|
|
||||||
|
This feature is used to test functionlity prior to building a complete real feature
|
||||||
21
modules/workbenches/modeler/features/testFeature/icon.svg
Normal file
21
modules/workbenches/modeler/features/testFeature/icon.svg
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version='1.0' encoding='utf-8' ?>
|
||||||
|
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN'
|
||||||
|
'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
|
||||||
|
<svg
|
||||||
|
version="1.1"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 512 512"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
enable-background="new 0 0 512 512"
|
||||||
|
>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path
|
||||||
|
d="m409.1,150.1h-306.2c-11.3,0-20.4,9.1-20.4,20.4v310.1c0,11.3 9.1,20.4 20.4,20.4h306.3c11.3,0 20.4-9.1 20.4-20.4v-310.1c-0.1-11.3-9.2-20.4-20.5-20.4zm-20.4,310.1h-265.4v-269.3h265.4v269.3z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="m170,135.9h175c11.3,0 20.4-9.1 20.4-20.4v-84.1c0-11.3-9.1-20.4-20.4-20.4h-175c-11.3,0-20.4,9.1-20.4,20.4v84.1c-0.1,11.3 9.1,20.4 20.4,20.4zm20.4-84.1h134.2v43.3h-134.2v-43.3z"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 773 B |
|
|
@ -0,0 +1,123 @@
|
||||||
|
import {ApplicationContext} from 'cad/context';
|
||||||
|
import {roundValueForPresentation as r} from 'cad/craft/operationHelper';
|
||||||
|
import {EntityKind} from "cad/model/entities";
|
||||||
|
import {OperationDescriptor} from "cad/craft/operationBundle";
|
||||||
|
import {FromMObjectProductionAnalyzer} from "cad/craft/production/productionAnalyzer";
|
||||||
|
import {MEdge} from "cad/model/medge";
|
||||||
|
import {MObject} from "cad/model/mobject";
|
||||||
|
import {MShell} from "cad/model/mshell";
|
||||||
|
import { MBrepFace, MFace } from 'cad/model/mface';
|
||||||
|
import icon from "./icon.svg";
|
||||||
|
|
||||||
|
interface TestFeatureParams {
|
||||||
|
face: MFace,
|
||||||
|
R: number,
|
||||||
|
H: number,
|
||||||
|
Q: number,
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TestFeatureOperation: OperationDescriptor<any> = {
|
||||||
|
id: 'TestFeature_TOOL',
|
||||||
|
label: 'TestFeature/Chamfer',
|
||||||
|
icon,
|
||||||
|
info: 'TestFeature/Chamfer',
|
||||||
|
path:__dirname,
|
||||||
|
paramsInfo: ({size, opperationType,}) => `(${r(size)} ${r(opperationType)}})`,
|
||||||
|
run: (params: TestFeatureParams, ctx: ApplicationContext) => {
|
||||||
|
|
||||||
|
const occ = ctx.occService;
|
||||||
|
const oci = occ.commandInterface;
|
||||||
|
let edgeList = [];
|
||||||
|
|
||||||
|
|
||||||
|
// oci.cylinder("aCylinder", params.R);
|
||||||
|
|
||||||
|
// oci.line("aLine2d", "0", "0", "1", params.H);
|
||||||
|
// console.log("before trim");
|
||||||
|
// oci.trim("aSegment", "aLine2d", "0", 5* Math.PI);
|
||||||
|
// console.log("After");
|
||||||
|
|
||||||
|
// oci.mkedge("aHelixEdge", "aSegment", "aCylinder", "0", params.Q* Math.PI);
|
||||||
|
|
||||||
|
// //# there is no curve 3d in the pcurve edge.
|
||||||
|
// oci.mkedgecurve("aHelixEdge", "0.001");
|
||||||
|
|
||||||
|
// oci.wire("aHelixWire", "aHelixEdge");
|
||||||
|
|
||||||
|
// oci.circle("profile", params.R, "0", "0", "0", "4", "1", "1");
|
||||||
|
// oci.mkedge("profile", "profile");
|
||||||
|
// oci.wire("profile", "profile");
|
||||||
|
// oci.mkplane("profile", "profile");
|
||||||
|
// oci.mkshell("profile", "profile");
|
||||||
|
|
||||||
|
// console.log("my face", params.face)
|
||||||
|
|
||||||
|
|
||||||
|
const sketch = ctx.sketchStorageService.readSketch(params.face.id);
|
||||||
|
|
||||||
|
const sweepSources = occ.utils.sketchToFaces(sketch, params.face.csys)
|
||||||
|
|
||||||
|
// console.log(sweepSources[0].face);
|
||||||
|
|
||||||
|
// oci.mkshell("shell", sweepSources[0].face);
|
||||||
|
|
||||||
|
|
||||||
|
const created = sweepSources.map((faceRef, i) => {
|
||||||
|
//alert(i)
|
||||||
|
const faceName = faceRef.face;
|
||||||
|
const shapeName = "[f]" + i;
|
||||||
|
oci.mkshell(shapeName, faceName);
|
||||||
|
return occ.io.getShell(shapeName,null);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
console.log(created);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return {created,
|
||||||
|
consumed:[]}
|
||||||
|
|
||||||
|
oci.pipe("aSpring", "aHelixWire", "profile");
|
||||||
|
|
||||||
|
//holeSolids.push(occ.io.getShell("aSpring"));
|
||||||
|
|
||||||
|
return {created:[occ.io.getShell("aSpring")],
|
||||||
|
consumed:[]}
|
||||||
|
|
||||||
|
},
|
||||||
|
form: [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
name: 'face',
|
||||||
|
capture: [EntityKind.FACE],
|
||||||
|
label: 'Face',
|
||||||
|
multi: false,
|
||||||
|
defaultValue: {
|
||||||
|
usePreselection: true,
|
||||||
|
preselectionIndex: 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'number',
|
||||||
|
label: 'R',
|
||||||
|
name: 'R',
|
||||||
|
defaultValue: 5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'number',
|
||||||
|
label: 'H',
|
||||||
|
name: 'H',
|
||||||
|
defaultValue: 5,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'number',
|
||||||
|
label: 'Q',
|
||||||
|
name: 'Q',
|
||||||
|
defaultValue: 5,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue