Skip to content

Commit

Permalink
Helper functions for slat creation are now returing geometry rather t…
Browse files Browse the repository at this point in the history
…han accepting it through parameters.
  • Loading branch information
vidanovic committed May 29, 2024
1 parent c84ed29 commit 7e34482
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/SingleLayerOptics/src/VenetianSlat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ namespace SingleLayerOptics
{
namespace Helper
{
void createPolarSegments(Viewer::CGeometry2D & aGeometry,
const VenetianGeometry & venetian,
size_t t_NumOfSegments,
SegmentsDirection t_Direction,
double radius)
Viewer::CGeometry2D createPolarSegments(const VenetianGeometry & venetian,
size_t t_NumOfSegments,
SegmentsDirection t_Direction,
double radius)
{
using ConstantsData::WCE_PI;

Expand All @@ -41,29 +40,33 @@ namespace SingleLayerOptics
double startTheta = t_Direction == SegmentsDirection::Positive ? theta2 : theta1;

auto startPoint{CPoint2D::createPointFromPolarCoordinates(startTheta, radius)};

CGeometry2D aGeometry;
for(size_t i = 1; i <= t_NumOfSegments; ++i)
{
double nextTheta = t_Direction == SegmentsDirection::Positive
? startTheta - dTheta * i
: startTheta + dTheta * i;
const auto endPoint{CPoint2D::createPointFromPolarCoordinates(nextTheta, radius)};
CViewSegment2D aSegment{startPoint, endPoint};
aGeometry.appendSegment(aSegment);
aGeometry.appendSegment({startPoint, endPoint});
startPoint = endPoint;
}

return aGeometry;
}

void createCartesianSegments(Viewer::CGeometry2D & aGeometry,
const VenetianGeometry & venetian,
size_t t_NumOfSegments,
SegmentsDirection t_Direction)
Viewer::CGeometry2D createCartesianSegments(const VenetianGeometry & venetian,
size_t t_NumOfSegments,
SegmentsDirection t_Direction)
{
double dWidth = venetian.SlatWidth / t_NumOfSegments;
double startRadius =
t_Direction == SegmentsDirection::Positive ? 0 : dWidth * t_NumOfSegments;

auto startPoint{
CPoint2D::createPointFromPolarCoordinates(venetian.SlatTiltAngle, startRadius)};

CGeometry2D aGeometry;
for(size_t i = 1; i <= t_NumOfSegments; ++i)
{
double nextRadius = t_Direction == SegmentsDirection::Positive
Expand All @@ -75,6 +78,8 @@ namespace SingleLayerOptics
aGeometry.appendSegment(aSegment);
startPoint = endPoint;
}

return aGeometry;
}

std::pair<double, double> calculateTranslation(const Viewer::CGeometry2D & aGeometry,
Expand All @@ -87,21 +92,20 @@ namespace SingleLayerOptics
}
} // namespace Helper

Viewer::CGeometry2D buildViewerSlat(const VenetianGeometry & t_Geometry,
Viewer::CGeometry2D buildViewerSlat(const VenetianGeometry & venetian,
size_t t_NumOfSegments,
SegmentsDirection t_Direction)
{
Viewer::CGeometry2D aGeometry;
auto venetian{adjustSlatTiltAngle(t_Geometry)};
double radius = std::abs(venetian.CurvatureRadius);

Viewer::CGeometry2D aGeometry;
if(radius > (venetian.SlatWidth / 2))
{
Helper::createPolarSegments(aGeometry, venetian, t_NumOfSegments, t_Direction, radius);
aGeometry = Helper::createPolarSegments(venetian, t_NumOfSegments, t_Direction, radius);
}
else if(radius == 0)
{
Helper::createCartesianSegments(aGeometry, venetian, t_NumOfSegments, t_Direction);
aGeometry = Helper::createCartesianSegments(venetian, t_NumOfSegments, t_Direction);
}
else
{
Expand Down

0 comments on commit 7e34482

Please sign in to comment.