//-------------------------------------------------------------------------------------------------- bool _MakeSolid(IShapeOperand sourceShape) { var sourceBRep = GetOperandBRep(0); if (sourceBRep == null) { return(false); } // Calculate Parameters Ax3 axis = _CalculateSolidAxis(); var(interval, offset) = _CalculateParameters(); // Build Transformed Shapes TopoDS_Compound resultShape = new TopoDS_Compound(); var builder = new TopoDS_Builder(); builder.MakeCompound(resultShape); for (var index = 0; index < Quantity; index++) { var angle = (interval * index + offset).ToRad(); var transform = Trsf.Identity; if (_KeepOrientation) { // Translation transform transform.SetTranslation(Pnt.Origin.Rotated(axis.Axis, angle).ToVec()); } else { // Rotation transform transform.SetRotation(axis.Axis, angle); } var makeTransform = new BRepBuilderAPI_Transform(sourceBRep, transform); if (!makeTransform.IsDone()) { Messages.Error("Failed transforming shape."); return(false); } builder.Add(resultShape, makeTransform.Shape()); } // Finalize BRep = resultShape; return(true); }
//-------------------------------------------------------------------------------------------------- bool _MakeSolid(IShapeOperand sourceShape) { var sourceBRep = GetOperandBRep(0); if (sourceBRep == null) { return(false); } // Calculate Offsets Ax3 plane; switch (Plane) { case PlaneType.XY: plane = Ax3.XOY.Rotated(Ax1.OZ, _Rotation.ToRad()); break; case PlaneType.ZX: plane = Ax3.ZOX.Rotated(Ax1.OY, _Rotation.ToRad()); break; case PlaneType.YZ: plane = Ax3.YOZ.Rotated(Ax1.OX, _Rotation.ToRad()); break; default: throw new ArgumentOutOfRangeException(); } var bbTransform = new Trsf(new Ax3(Ax2.XOY), plane); var extents = sourceBRep.BoundingBox().Transformed(bbTransform).Extents(); var offset = Vec.Zero; var interval1 = plane.XDirection.ToVec() * _CalculateOffset(DistanceMode1, Quantity1, Distance1, extents.X); switch (_Alignment1) { case AlignmentMode.Center: offset += interval1 * (Quantity1 - 1) * -0.5; break; case AlignmentMode.Last: interval1 *= -1; break; } var interval2 = plane.YDirection.ToVec() * _CalculateOffset(DistanceMode2, Quantity2, Distance2, extents.Y); switch (_Alignment2) { case AlignmentMode.Center: offset += interval2 * (Quantity2 - 1) * -0.5; break; case AlignmentMode.Last: interval2 *= -1; break; } // Build Transformed Shapes TopoDS_Compound resultShape = new TopoDS_Compound(); var builder = new TopoDS_Builder(); builder.MakeCompound(resultShape); for (var index1 = 0; index1 < Quantity1; index1++) { for (var index2 = 0; index2 < Quantity2; index2++) { if (_Border && index1 != 0 && index1 != Quantity1 - 1 && index2 != 0 && index2 != Quantity2 - 1) { continue; // Skip inner parts } var transform = new Trsf(); transform.SetTranslation(interval1 * index1 + interval2 * index2 + offset); var makeTransform = new BRepBuilderAPI_Transform(sourceBRep, transform); if (!makeTransform.IsDone()) { Messages.Error("Failed transforming shape."); return(false); } builder.Add(resultShape, makeTransform.Shape()); } } // Finalize BRep = resultShape; return(true); }