cleanup unused code

This commit is contained in:
Val Erastov 2022-08-14 22:14:27 -07:00
parent c2a1207d0e
commit 76ba305571
6 changed files with 3 additions and 190 deletions

View file

@ -1,137 +0,0 @@
export function createOCCBottle(myWidth: number, myHeight: number, myThickness: number, oc: any) {
const aPnt1 = new oc.gp_Pnt_3(-myWidth / 2., 0, 0);
const aPnt2 = new oc.gp_Pnt_3(-myWidth / 2., -myThickness / 4., 0);
const aPnt3 = new oc.gp_Pnt_3(0, -myThickness / 2., 0);
const aPnt4 = new oc.gp_Pnt_3(myWidth / 2., -myThickness / 4., 0);
const aPnt5 = new oc.gp_Pnt_3(myWidth / 2., 0, 0);
// Profile : Define the Geometry
const anArcOfCircle = new oc.GC_MakeArcOfCircle_4(aPnt2, aPnt3, aPnt4);
const aSegment1 = new oc.GC_MakeSegment_1(aPnt1, aPnt2);
const aSegment2 = new oc.GC_MakeSegment_1(aPnt4, aPnt5);
// Profile : Define the Topology
const anEdge1 = new oc.BRepBuilderAPI_MakeEdge_24(new oc.Handle_Geom_Curve_2(aSegment1.Value().get()));
const anEdge2 = new oc.BRepBuilderAPI_MakeEdge_24(new oc.Handle_Geom_Curve_2(anArcOfCircle.Value().get()));
const anEdge3 = new oc.BRepBuilderAPI_MakeEdge_24(new oc.Handle_Geom_Curve_2(aSegment2.Value().get()));
const aWire = new oc.BRepBuilderAPI_MakeWire_4(anEdge1.Edge(), anEdge2.Edge(), anEdge3.Edge());
// Complete Profile
const xAxis = oc.gp.OX();
const aTrsf = new oc.gp_Trsf_1();
aTrsf.SetMirror_2(xAxis);
const aBRepTrsf = new oc.BRepBuilderAPI_Transform_2(aWire.Wire(), aTrsf, false);
const aMirroredShape = aBRepTrsf.Shape();
const mkWire = new oc.BRepBuilderAPI_MakeWire_1();
mkWire.Add_2(aWire.Wire());
mkWire.Add_2(oc.TopoDS.Wire_1(aMirroredShape));
const myWireProfile = mkWire.Wire();
// Body : Prism the Profile
const myFaceProfile = new oc.BRepBuilderAPI_MakeFace_15(myWireProfile, false);
const aPrismVec = new oc.gp_Vec_4(0, 0, myHeight);
let myBody = new oc.BRepPrimAPI_MakePrism_1(myFaceProfile.Face(), aPrismVec, false, true);
// Body : Apply Fillets
const mkFillet = new oc.BRepFilletAPI_MakeFillet(myBody.Shape(), oc.ChFi3d_FilletShape.ChFi3d_Rational);
const anEdgeExplorer = new oc.TopExp_Explorer_2(myBody.Shape(), oc.TopAbs_ShapeEnum.TopAbs_EDGE, oc.TopAbs_ShapeEnum.TopAbs_SHAPE);
while(anEdgeExplorer.More()) {
const anEdge = oc.TopoDS.Edge_1(anEdgeExplorer.Current());
// Add edge to fillet algorithm
mkFillet.Add_2(myThickness / 12., anEdge);
anEdgeExplorer.Next();
}
myBody = mkFillet.Shape();
// Body : Add the Neck
const neckLocation = new oc.gp_Pnt_3(0, 0, myHeight);
const neckAxis = oc.gp.DZ();
const neckAx2 = new oc.gp_Ax2_3(neckLocation, neckAxis);
const myNeckRadius = myThickness / 4.;
const myNeckHeight = myHeight / 10.;
const MKCylinder = new oc.BRepPrimAPI_MakeCylinder_3(neckAx2, myNeckRadius, myNeckHeight);
const myNeck = MKCylinder.Shape();
myBody = new oc.BRepAlgoAPI_Fuse_3(myBody, myNeck);
// Body : Create a Hollowed Solid
let faceToRemove;
let zMax = -1;
const aFaceExplorer = new oc.TopExp_Explorer_2(myBody.Shape(), oc.TopAbs_ShapeEnum.TopAbs_FACE, oc.TopAbs_ShapeEnum.TopAbs_SHAPE);
for(; aFaceExplorer.More(); aFaceExplorer.Next()) {
const aFace = oc.TopoDS.Face_1(aFaceExplorer.Current());
// Check if <aFace> is the top face of the bottle's neck
const aSurface = oc.BRep_Tool.Surface_2(aFace);
if(aSurface.get().$$.ptrType.name === "Geom_Plane*") {
const aPlane = new oc.Handle_Geom_Plane_2(aSurface.get()).get();
const aPnt = aPlane.Location();
const aZ = aPnt.Z();
if(aZ > zMax) {
zMax = aZ;
faceToRemove = new oc.TopExp_Explorer_2(aFace, oc.TopAbs_ShapeEnum.TopAbs_FACE, oc.TopAbs_ShapeEnum.TopAbs_SHAPE).Current();
}
}
}
const facesToRemove = new oc.TopTools_ListOfShape_1();
facesToRemove.Append_1(faceToRemove);
const s = myBody.Shape();
myBody = new oc.BRepOffsetAPI_MakeThickSolid_1();
myBody.MakeThickSolidByJoin(s, facesToRemove, -myThickness / 50, 1.e-3, oc.BRepOffset_Mode.BRepOffset_Skin, false, false, oc.GeomAbs_JoinType.GeomAbs_Arc, false);
// Threading : Create Surfaces
const aCyl1 = new oc.Geom_CylindricalSurface_1(new oc.gp_Ax3_2(neckAx2), myNeckRadius * 0.99);
const aCyl2 = new oc.Geom_CylindricalSurface_1(new oc.gp_Ax3_2(neckAx2), myNeckRadius * 1.05);
// Threading : Define 2D Curves
const aPnt = new oc.gp_Pnt2d_3(2. * Math.PI, myNeckHeight / 2.);
const aDir = new oc.gp_Dir2d_4(2. * Math.PI, myNeckHeight / 4.);
const anAx2d = new oc.gp_Ax2d_2(aPnt, aDir);
const aMajor = 2. * Math.PI;
const aMinor = myNeckHeight / 10;
const anEllipse1 = new oc.Geom2d_Ellipse_2(anAx2d, aMajor, aMinor, true);
const anEllipse2 = new oc.Geom2d_Ellipse_2(anAx2d, aMajor, aMinor / 4, true);
const anArc1 = new oc.Geom2d_TrimmedCurve(new oc.Handle_Geom2d_Curve_2(anEllipse1), 0, Math.PI, true, true);
const anArc2 = new oc.Geom2d_TrimmedCurve(new oc.Handle_Geom2d_Curve_2(anEllipse2), 0, Math.PI, true, true);
const tmp1 = anEllipse1.Value(0);
const anEllipsePnt1 = new oc.gp_Pnt2d_3(tmp1.X(), tmp1.Y());
const tmp2 = anEllipse1.Value(Math.PI);
const anEllipsePnt2 = new oc.gp_Pnt2d_3(tmp2.X(), tmp2.Y());
const aSegment = new oc.GCE2d_MakeSegment_1(anEllipsePnt1, anEllipsePnt2);
// Threading : Build Edges and Wires
const anEdge1OnSurf1 = new oc.BRepBuilderAPI_MakeEdge_30(new oc.Handle_Geom2d_Curve_2(anArc1), new oc.Handle_Geom_Surface_2(aCyl1));
const anEdge2OnSurf1 = new oc.BRepBuilderAPI_MakeEdge_30(new oc.Handle_Geom2d_Curve_2(aSegment.Value().get()), new oc.Handle_Geom_Surface_2(aCyl1));
const anEdge1OnSurf2 = new oc.BRepBuilderAPI_MakeEdge_30(new oc.Handle_Geom2d_Curve_2(anArc2), new oc.Handle_Geom_Surface_2(aCyl2));
const anEdge2OnSurf2 = new oc.BRepBuilderAPI_MakeEdge_30(new oc.Handle_Geom2d_Curve_2(aSegment.Value().get()), new oc.Handle_Geom_Surface_2(aCyl2));
const threadingWire1 = new oc.BRepBuilderAPI_MakeWire_3(anEdge1OnSurf1.Edge(), anEdge2OnSurf1.Edge());
const threadingWire2 = new oc.BRepBuilderAPI_MakeWire_3(anEdge1OnSurf2.Edge(), anEdge2OnSurf2.Edge());
oc.BRepLib.BuildCurves3d_2(threadingWire1.Wire());
oc.BRepLib.BuildCurves3d_2(threadingWire2.Wire());
oc.BRepLib.BuildCurves3d_2(threadingWire1.Wire());
oc.BRepLib.BuildCurves3d_2(threadingWire2.Wire());
// Create Threading
const aTool = new oc.BRepOffsetAPI_ThruSections(true, false, 1.0e-06);
aTool.AddWire(threadingWire1.Wire());
aTool.AddWire(threadingWire2.Wire());
aTool.CheckCompatibility(false);
const myThreading = aTool.Shape();
// Building the Resulting Compound
const aRes = new oc.TopoDS_Compound();
const aBuilder = new oc.BRep_Builder();
aBuilder.MakeCompound(aRes);
aBuilder.Add(aRes, myBody.Shape());
aBuilder.Add(aRes, myThreading);
return aRes;
}

View file

@ -1,10 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 729 B

View file

@ -1,27 +0,0 @@
import {ApplicationContext} from 'cad/context';
import {MBrepShell} from 'cad/model/mshell';
import {roundValueForPresentation as r} from 'cad/craft/operationHelper';
import {createOCCBottle} from './bottle.occ';
import {occ2brep} from 'cad/occ/occ2models';
import icon from './icon.svg';
import {OperationDescriptor} from "cad/craft/operationBundle";
export const OCCBottle:OperationDescriptor<any> = {
id: 'OCC_BOTTLE',
label: 'OCC Bottle',
icon: {
iconType: 'svg',
iconContent: icon
},
info: 'create occ bottle',
paramsInfo: ({width, height, thickness, color}) => `(${r(width)} ${r(height)} ${r(thickness)} ${r(color)})`,
form: [],
run: ({width, height, thickness, color}, ctx: ApplicationContext) => {
const occObj = createOCCBottle(width, height, thickness, ctx.occService.occContext);
const mobject = new MBrepShell(occ2brep(occObj, ctx.occService.occContext));
return {
consumed: [],
created: [mobject]
};
}
}

View file

@ -1,13 +0,0 @@
import OCCBottle from './features/occ_bottle';
import {WorkbenchConfig} from "cad/workbench/workbenchService";
export const ExampleWorkspace: WorkbenchConfig = {
workbenchId: 'examples',
features: [
OCCBottle,
],
actions: [],
ui: {
toolbar: []
}
}

View file

@ -1,8 +1,8 @@
import {ModelerWorkspace} from "workbenches/modeler";
import { sheetMetalWorkspace } from "workbenches/sheetMetal";
import { SheetMetalWorkspace } from "workbenches/sheetMetal";
import {WorkbenchConfig} from "cad/workbench/workbenchService";
export const WorkbenchRegistry: WorkbenchConfig[] = [
ModelerWorkspace, sheetMetalWorkspace
ModelerWorkspace, SheetMetalWorkspace
]

View file

@ -10,7 +10,7 @@ import {GiFoldedPaper} from "react-icons/gi";
export const sheetMetalWorkspace: WorkbenchConfig = {
export const SheetMetalWorkspace: WorkbenchConfig = {
workbenchId: 'SheetMetal',
features: [