void partition( const uint32_t depthToCreateTo, const uint32_t level ) { uint32_t leftWidth( boundary_.dimensions.w / 2 ); uint32_t rightWidth( boundary_.dimensions.w - leftWidth ); uint32_t bottomHeight( boundary_.dimensions.h / 2 ); uint32_t topHeight( boundary_.dimensions.h - bottomHeight ); uint32_t newLevel( level + 1 ); uint32_t rightStartX( boundary_.ex - rightWidth ); uint32_t topStartY( boundary_.ey - topHeight ); leftBottomNode_ = make_unique<QuadTreeNode>( QuadTreeNode( depthToCreateTo, newLevel, vec4uint32 { boundary_.dimensions.x, boundary_.dimensions.y, leftWidth, bottomHeight } ) ); rightBottomNode_ = make_unique<QuadTreeNode>( QuadTreeNode( depthToCreateTo, newLevel, vec4uint32 { rightStartX, boundary_.dimensions.y, rightWidth, bottomHeight } ) ); leftTopNode_ = make_unique<QuadTreeNode>( QuadTreeNode( depthToCreateTo, newLevel, vec4uint32 { boundary_.dimensions.x, topStartY, leftWidth, topHeight } ) ); rightTopNode_ = make_unique<QuadTreeNode>( QuadTreeNode( depthToCreateTo, newLevel, vec4uint32 { rightStartX, topStartY, rightWidth, topHeight } ) ); }
Component CaseFactory::constructPart(Side whichSide) { // Select parameters depending on which part to build auto innerHeight = (whichSide == BottomSide) ? bottomInnerHeight() : topInnerHeight(); auto outerHeight = (whichSide == BottomSide) ? bottomHeight() : topHeight(); auto forbiddenAreas = (whichSide == BottomSide) ? board.bottomForbiddenAreas : board.topForbiddenAreas; auto ports = (whichSide == BottomSide) ? board.bottomPorts : board.topPorts; auto wallSupports = (whichSide == BottomSide) ? board.bottomWallSupports : board.topWallSupports; auto extension = (whichSide == outerExtensionOnSide) ? ExtensionOutside : ExtensionInside; auto screwHoleRadius =((whichSide == screwHeadsOnSide) ? holesAddRadiusLoose : holesAddRadiusTight) + board.holesRadius; auto screwHeads = (whichSide == screwHeadsOnSide); // We start with the base Component c = constructBase(innerHeight, extension); // Add wall support for (auto wallSupport : wallSupports) { c = addWallSupport(c, outerHeight, wallSupport); } // Screw holes for (auto hole : board.holes) { c = addHoleForScrew(c, outerHeight, hole, screwHoleRadius, screwHeads); } // Added by: Anthony W. Rainer <*****@*****.**> // Modified by: Bogdan Vacaliuc <*****@*****.**> to allow selection of side if(whichSide == board.holeNutsSide) { // Screw holes Nuts for (auto holeNut : board.holeNuts) { c = addCavityForNut(c, outerHeight, board.holes[holeNut.holeIndex], holeNut); } } // Apply rounded corners (if enabled) if (cornerRadius > 0.0) { // Class "RoundedCube" of ooml is buggy as it doesn't respect the "faces" parameter. // So we construct our own rounded cuboid by taking the convex hull of eight spheres. Vec min = {-outset(), -outset(), 0}; Vec max = outerDimensions() + min; Vec cornerOffset = {cornerRadius, cornerRadius, cornerRadius}; min += cornerOffset; max -= cornerOffset; CompositeComponent roundedCorners = Hull::create(); for (int corner = 0; corner < 8; corner++) { double x = (corner & (1 << 0)) ? min.x : max.x; double y = (corner & (1 << 1)) ? min.y : max.y; double z = (corner & (1 << 2)) ? min.z : max.z; roundedCorners.addComponent(Sphere(cornerRadius, cornerFaces).translatedCopy(x, y, z)); } // Intersect the current part with the rounded cuboid c = c * roundedCorners; } // Port holes for (auto port : ports) { c = addHoleForPort(c, outerHeight, port); } // "Forbidden areas" of the board for (auto area : forbiddenAreas) { c = c - Cube(area.sx, area.sy, area.sz + extensionHeight() + eps, false) .translatedCopy(area.x, area.y, outerHeight - area.sz); } // If this is the top, we've just built it mirrored. So we mirror the y axis and move it so it matches the dimensions of the bottom part. if (whichSide == TopSide) { c.scale(1.0, -1.0, 1.0); c.translate(0.0, board.size[1], 0.0); } return c; }