CODE: std::vector<std::pair<Orientation, Orientation>> quadrants{
{Orientation::NORTH, Orientation::EAST},
{Orientation::EAST, Orientation::SOUTH},
{Orientation::SOUTH, Orientation::WEST},
{Orientation::WEST, Orientation::NORTH}
};
auto getTangentFromOrientation = [](Orientation dir) -> gp_Vec {
switch (dir) {
case Orientation::NORTH: return gp_Vec(0, 1, 0);
case Orientation::EAST: return gp_Vec(0, 0, 1);
case Orientation::SOUTH: return gp_Vec(0, -1, 0);
case Orientation::WEST: return gp_Vec(0, 0, -1);
default: return gp_Vec(0, 0, 0);
}
};
int index{ 0 };
for (const auto& quadrant : quadrants)
{
ProfileData startProfile = this->profiles[quadrant.first];
ProfileData endProfile = this->profiles[quadrant.second];
gp_Trsf startTrsf, endTrsf;
startTrsf.SetRotation(rotationAxis, rotationMap[quadrant.first]);
endTrsf.SetRotation(rotationAxis, rotationMap[quadrant.second]);
TopoDS_Wire sWire = TopoDS::Wire(BRepBuilderAPI_Transform(startProfile.profile, startTrsf).Shape());
TopoDS_Wire eWire = TopoDS::Wire(BRepBuilderAPI_Transform(endProfile.profile, endTrsf).Shape());
gp_Pnt P1(startProfile.reflector.end.x, startProfile.reflector.end.y, 0.0);
P1.Transform(startTrsf);
gp_Pnt P2(endProfile.reflector.end.x, endProfile.reflector.end.y, 0.0);
P2.Transform(endTrsf);
Handle(TColgp_HArray1OfPnt) points = new TColgp_HArray1OfPnt(1, 2);
points->SetValue(1, P2);
points->SetValue(2, P1);
GeomAPI_Interpolate interpolator(points, Standard_False, Precision::Confusion());
interpolator.Load(getTangentFromOrientation(quadrant.second), getTangentFromOrientation(quadrant.first), Standard_True);
interpolator.Perform();
Handle(Geom_BSplineCurve) spline = interpolator.Curve();
TopoDS_Edge arcEdge = BRepBuilderAPI_MakeEdge(spline);
TopoDS_Wire arcWire = BRepBuilderAPI_MakeWire(arcEdge);
builder.Add(collimator, arcWire);
builder.Add(collimator, sWire);
builder.Add(collimator, eWire);
builder.Add(collimator , spineWires[index]);
index++;
}