public static CsgObject CreateFillet(CsgObject objectA, Face faceA, CsgObject objectB, Face faceB, double radius, double extraDimension = defaultExtraDimension) { int centralAxis = 0; // we start defaulted to x switch ((Edge)(faceA | faceB)) { case Edge.LeftTop: case Edge.LeftBottom: case Edge.RightTop: case Edge.RightBottom: centralAxis = 1; // y axis break; case Edge.LeftFront: case Edge.LeftBack: case Edge.RightFront: case Edge.RightBack: centralAxis = 2; // z axis break; } AxisAlignedBoundingBox boundsA = objectA.GetAxisAlignedBoundingBox(); AxisAlignedBoundingBox boundsB = objectB.GetAxisAlignedBoundingBox(); double maxMin = Math.Max(boundsA.minXYZ[centralAxis], boundsB.minXYZ[centralAxis]); double minMax = Math.Min(boundsA.maxXYZ[centralAxis], boundsB.maxXYZ[centralAxis]); if (maxMin >= minMax) { throw new ArgumentException("Your two objects must overlap to have a fillet be created."); } Vector3 size = new Vector3(radius, radius, radius); size[centralAxis] = minMax - maxMin; Round newFilletRound = new Round(size); Face faceToGetBevelFor = CsgObject.GetOposite(faceA) | CsgObject.GetOposite(faceB); newFilletRound.RoundEdge((Edge)faceToGetBevelFor, radius, extraDimension); CsgObject newFillet = new SetCenter(newFilletRound, objectA.GetCenter()); newFillet = new Align(newFillet, CsgObject.GetOposite(faceA), objectA, faceA); newFillet = new Align(newFillet, CsgObject.GetOposite(faceB), objectB, faceB); return(newFillet); }
public static CsgObject CreateFillet(CsgObject objectA, Face faceA, CsgObject objectB, Face faceB, double radius, double extraDimension = defaultExtraDimension) { int centralAxis = 0; // we start defaulted to x switch ((Edge)(faceA | faceB)) { case Edge.LeftTop: case Edge.LeftBottom: case Edge.RightTop: case Edge.RightBottom: centralAxis = 1; // y axis break; case Edge.LeftFront: case Edge.LeftBack: case Edge.RightFront: case Edge.RightBack: centralAxis = 2; // z axis break; } AxisAlignedBoundingBox boundsA = objectA.GetAxisAlignedBoundingBox(); AxisAlignedBoundingBox boundsB = objectB.GetAxisAlignedBoundingBox(); double maxMin = Math.Max(boundsA.minXYZ[centralAxis], boundsB.minXYZ[centralAxis]); double minMax = Math.Min(boundsA.maxXYZ[centralAxis], boundsB.maxXYZ[centralAxis]); if (maxMin >= minMax) { throw new ArgumentException("Your two objects must overlap to have a fillet be created."); } Vector3 size = new Vector3(radius, radius, radius); size[centralAxis] = minMax - maxMin; Round newFilletRound = new Round(size); Face faceToGetBevelFor = CsgObject.GetOposite(faceA) | CsgObject.GetOposite(faceB); newFilletRound.RoundEdge((Edge)faceToGetBevelFor, radius, extraDimension); CsgObject newFillet = new SetCenter(newFilletRound, objectA.GetCenter()); newFillet = new Align(newFillet, CsgObject.GetOposite(faceA), objectA, faceA); newFillet = new Align(newFillet, CsgObject.GetOposite(faceB), objectB, faceB); return newFillet; }
public static CsgObject SimplePartFunction() { double pcbHoldLip = 2; double standYDepth = 8; double pcbYDepth = 2; CsgObject pcbTotal; CsgObject pcbBottom = new Box(23, pcbYDepth, 40); pcbTotal = pcbBottom; CsgObject pcbMid = new Box(30, pcbYDepth, 34.5); pcbMid = new Align(pcbMid, Face.Top, pcbBottom, Face.Top); pcbMid = new SetCenter(pcbMid, pcbBottom.GetCenter(), true, false, false); pcbTotal += pcbMid; CsgObject pcbTop = new Box(64.5, pcbYDepth, 21.5); pcbTop = new Align(pcbTop, Face.Top, pcbBottom, Face.Top); pcbTop = new SetCenter(pcbTop, pcbBottom.GetCenter(), true, false, false); pcbTotal += pcbTop; Box standBaseBox = new Box(pcbTop.XSize + 2 * (standYDepth - pcbHoldLip), 37, standYDepth); //standBaseBox.BevelFace(Face.Top, 3); //standBaseBox.BevelEdge(Face.Left | Face.Front, 3); //standBaseBox.BevelEdge(Face.Left | Face.Back, 3); //standBaseBox.BevelEdge(Face.Right | Face.Front, 3); //standBaseBox.BevelEdge(Face.Right | Face.Back, 3); CsgObject standBase = standBaseBox; CsgObject standTotal = standBase; Box standSideSupportLeftBox = new Box(standYDepth, standYDepth, pcbBottom.ZSize + standBase.ZSize - 10); //standSideSupportLeftBox.BevelEdge(Face.Left | Face.Front, 3); //standSideSupportLeftBox.BevelEdge(Face.Left | Face.Back, 3); //standSideSupportLeftBox.BevelEdge(Face.Left | Face.Top, 3); //standSideSupportLeftBox.BevelEdge(Face.Right | Face.Front, 1); //standSideSupportLeftBox.BevelEdge(Face.Right | Face.Back, 1); CsgObject standSideSupportLeft = standSideSupportLeftBox; standSideSupportLeft = new SetCenter(standSideSupportLeft, standBase.GetCenter(), false, true, false); standSideSupportLeft = new Align(standSideSupportLeft, Face.Bottom | Face.Left, standBase, Face.Bottom | Face.Left); standTotal += standSideSupportLeft; Box insideBevelLeftBox = new Box(standYDepth, standYDepth, standYDepth); insideBevelLeftBox.CutAlongDiagonal(Face.Left | Face.Bottom); CsgObject insideBevelLeft = insideBevelLeftBox; insideBevelLeft = new Align(insideBevelLeft, Face.Left | Face.Front, standSideSupportLeft, Face.Right | Face.Front, -1, 0, -.1); insideBevelLeft = new Align(insideBevelLeft, Face.Bottom, standBase, Face.Top); standTotal += insideBevelLeft; Box standSideSupportRightBox = new Box(standYDepth, standYDepth, pcbBottom.ZSize + standBase.ZSize - 10); //standSideSupportRightBox.BevelEdge(Face.Right | Face.Front, 3); //standSideSupportRightBox.BevelEdge(Face.Right | Face.Back, 3); //standSideSupportRightBox.BevelEdge(Face.Right | Face.Top, 3); //standSideSupportRightBox.BevelEdge(Face.Left | Face.Front, 1); //standSideSupportRightBox.BevelEdge(Face.Left | Face.Back, 1); CsgObject standSideSupportRight = standSideSupportRightBox; standSideSupportRight = new SetCenter(standSideSupportRight, standBase.GetCenter(), false, true, false); standSideSupportRight = new Align(standSideSupportRight, Face.Bottom | Face.Right, standBase, Face.Bottom | Face.Right); standTotal += standSideSupportRight; Box insideBevelRightBox = new Box(standYDepth, standYDepth, standYDepth); insideBevelRightBox.CutAlongDiagonal(Face.Right | Face.Bottom); CsgObject insideBevelRight = insideBevelRightBox; insideBevelRight = new Align(insideBevelRight, Face.Right | Face.Front, standSideSupportRight, Face.Left | Face.Front, 1, 0, -.1); insideBevelRight = new Align(insideBevelRight, Face.Bottom, standBase, Face.Top); standTotal += insideBevelRight; CsgObject ringCutOut = new Cylinder(11, 6, Alignment.y); ringCutOut = new SetCenter(ringCutOut, standBase.GetCenter()); ringCutOut = new Align(ringCutOut, Face.Bottom | Face.Back, standBase, Face.Top | Face.Front, 0, 5.9, -4); standTotal -= ringCutOut; pcbTotal = new SetCenter(pcbTotal, standBase.GetCenter(), true, true, false); pcbTotal = new Align(pcbTotal, Face.Bottom, standBase, Face.Top, offsetZ: -pcbHoldLip); standTotal -= pcbTotal; return(standTotal); }