Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented Fuselage Profile Type: Rectangle (Issue #909) #1005

Merged
merged 58 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
0341aff
added skeleton for optional rectangular profile wire
Jan 26, 2024
5585f36
added rectangle testfiles
Jan 31, 2024
c423d12
added test
Jan 31, 2024
6053781
added function buildWireRectangle
Jan 31, 2024
e88bd66
made function build wire with negative cornerradius
Feb 7, 2024
99a504b
added test
Feb 8, 2024
b0aa945
added typecheck
Feb 8, 2024
bb076de
added testsfunctions
Feb 21, 2024
428b688
update function
Feb 26, 2024
2fb50df
added check for valid shapes
Feb 26, 2024
9ebaa60
added constructor that takes parameter of type std::vector<gp_Pnt>
Feb 28, 2024
7b00675
added constructors to take parameters of type std::vector<gp_Pnt>
Feb 28, 2024
98891d4
fixed new constructor
Feb 28, 2024
bb23bba
updated function to build wire from point list
Mar 4, 2024
199d7c7
fixed initialization in new constructor
Mar 4, 2024
79125b5
updated xml-files and added test
Mar 5, 2024
cd41cb2
rewrote function to build wire from one edge
Mar 12, 2024
2b4677d
added testcase
Mar 12, 2024
4d3ca07
added testfiles
Mar 12, 2024
4979829
implemented funktion
Mar 12, 2024
a666615
rectanglewirde built counter-cockwise-> reversed
Mar 20, 2024
f0896d9
adjusted orientation of rectangle wire
Mar 20, 2024
737feef
joined testcases in two xml files
Apr 11, 2024
7632787
moved documentation
Apr 11, 2024
5be8939
removed unnecessary xml file
Apr 11, 2024
9332b8d
modified testfiles
Apr 16, 2024
7f6dd02
updated function to make it work with rectangle profiles
Apr 16, 2024
6a1b595
added boolean expression
Apr 29, 2024
fb99786
Merge branch 'master' into rectangle
Apr 30, 2024
a205ebb
updated values
Apr 30, 2024
bb8e7bd
updated docstring
Apr 30, 2024
2f9882c
updated docstring
Apr 30, 2024
c3b4491
update
May 15, 2024
75c31ca
updated constructors
May 15, 2024
75606c0
updated code regarding pull request suggestions
May 23, 2024
db5bfdb
Merge branch 'updateRectangle' into rectangle
May 23, 2024
f9192ca
added check for curve degree
May 28, 2024
67be429
Update src/fuselage/CCPACSFuselageProfiles.cpp
merakulix Jun 3, 2024
1ac277a
update comment on curve degree
Jun 3, 2024
78a837f
Merge branch 'rectangle' of https://github.com/DLR-SC/tigl into recta…
Jun 3, 2024
49bc34e
added test for CTiglPointsToBSplineInterpolation
Jun 4, 2024
8f32a4c
moved wire tests to tiglCommonFunctions.cpp
Jul 2, 2024
c7bf073
merged master branch
Jul 2, 2024
343c48e
Update src/fuselage/CCPACSFuselageProfile.cpp
merakulix Jul 4, 2024
b8dada1
Update src/common/tiglcommonfunctions.cpp
merakulix Jul 4, 2024
f14c31f
removed redundant check
Jul 11, 2024
a13eea2
added test
Jul 11, 2024
0fe2758
added check vor valid inputs
Jul 11, 2024
4234fba
added test for invalid inputs in cpacs file
Jul 15, 2024
13281fb
fixed file mixup
Jul 15, 2024
8475ecb
added translation to arc circle
Aug 19, 2024
e7db244
update test
Aug 19, 2024
1f7a12a
update test
Aug 19, 2024
bed7bfa
updated rectangle profile to use 'CFunctionToBSpline'
Aug 19, 2024
0fa67b8
update some formatting issues
Aug 20, 2024
0a3f7d8
merge master
Aug 20, 2024
4b29d5e
change function call
Aug 26, 2024
571a2ef
Update src/common/tiglcommonfunctions.cpp
joergbrech Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions src/common/tiglcommonfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "CTiglRelativelyPositionedComponent.h"
#include "CTiglProjectPointOnCurveAtAngle.h"
#include "CTiglBSplineAlgorithms.h"
#include "CTiglPointsToBSplineInterpolation.h"

#include "Standard_Version.hxx"

Expand Down Expand Up @@ -119,13 +120,16 @@
#include <ShapeAnalysis_FreeBounds.hxx>



#include <list>
#include <algorithm>
#include <cassert>
#include <limits>
#include <cmath>

#include "Debugging.h"
#include <GC_MakeArcOfCircle.hxx>


namespace
{
Expand Down Expand Up @@ -1156,6 +1160,125 @@ TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges)
return result;
}

opencascade::handle<Geom_BSplineCurve> ApproximateArcOfCircleToRationalBSpline(double radius, double uMin, double uMax,double y_position, double z_position)
{
std::vector<gp_Pnt> ArcPnts;
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
std::vector<double> alpha = Linspace(uMin, uMax, 64);
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
for (double a : alpha){
ArcPnts.push_back(gp_Pnt(0., y_position + radius * std::cos(a), z_position + radius* std::sin(a)));
}
return tigl::CTiglPointsToBSplineInterpolation(ArcPnts).Curve();
}


//gp_Pnt startUpper(0., (-0.5 + radius), 0.5 * heightToWidthRatio);
//gp_Pnt endUpper(0., (0.5 - radius), 0.5 * heightToWidthRatio);
//gp_Pnt startRight(0., 0.5, 0.5 * heightToWidthRatio - radius);
//gp_Pnt endRight(0., 0.5, -0.5 * heightToWidthRatio + radius);
//gp_Pnt startLower(0., (0.5 - radius), -0.5 * heightToWidthRatio);
//gp_Pnt endLower(0., (-0.5 + radius), -0.5 * heightToWidthRatio);
//gp_Pnt startLeft(0., -0.5, -0.5 * heightToWidthRatio + radius);
//gp_Pnt endLeft(0., -0.5, 0.5 * heightToWidthRatio - radius);
joergbrech marked this conversation as resolved.
Show resolved Hide resolved

TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius)
{
double radius = cornerRadius;
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
if(cornerRadius<0.){
radius*= -1;
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
}
std::vector<Handle(Geom_BSplineCurve)> curves;

// build half upper line from gp_points
std::vector<gp_Pnt> linePntsUpperRightHalf;
std::vector<double> y_UpperRightHalf = Linspace(0.,(0.5-radius),5);
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
for (double y: y_UpperRightHalf){
linePntsUpperRightHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio));
}
opencascade::handle<Geom_BSplineCurve> lowerLineRightHalf = tigl::CTiglPointsToBSplineInterpolation(linePntsUpperRightHalf).Curve();
curves.push_back(lowerLineRightHalf);

if (!(cornerRadius == 0.0)){
//build upper right arc
double y0 = 0.5 - radius;
double z0 = 0.5 * heightToWidthRatio - radius;
auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, 0., M_PI/2., y0, z0);
ArcCurve->Reverse();
curves.push_back(ArcCurve);
}

// build right line from gp_Pnts
std::vector<gp_Pnt> linePnts_right;
std::vector<double> z_right = Linspace( 0.5 * heightToWidthRatio - radius, -0.5 * heightToWidthRatio + radius, 5);
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
for (double z: z_right){
linePnts_right.push_back(gp_Pnt(0., 0.5, z));
}
opencascade::handle<Geom_BSplineCurve> rightLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_right).Curve();
curves.push_back(rightLine);

if (!(cornerRadius == 0.0)){
//build lower right arc
double y0 = 0.5 - radius;
double z0 = - 0.5 * heightToWidthRatio + radius;
auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI*(3./2.), M_PI*2., y0, z0);
ArcCurve->Reverse();
curves.push_back(ArcCurve);
}

// build lower line from gp_points
std::vector<gp_Pnt> linePnts_lower;
std::vector<double> y_upper = Linspace((0.5-radius),(-0.5+radius),5);
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
for (double y: y_upper){
linePnts_lower.push_back(gp_Pnt(0., y, -0.5*heightToWidthRatio));
}
opencascade::handle<Geom_BSplineCurve> lowerLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_lower).Curve();

curves.push_back(lowerLine);

if (!(cornerRadius == 0.)){
// build lower left arc
double y0 = - 0.5 + radius;
double z0 = -0.5 * heightToWidthRatio + radius;
auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI, M_PI*(3./2.), y0, z0);
ArcCurve->Reverse();
curves.push_back(ArcCurve);
}

//build left line from gp_points
std::vector<gp_Pnt> linePnts_left;
std::vector<double> z_left = Linspace(-0.5 * heightToWidthRatio + radius, 0.5 * heightToWidthRatio - radius, 5);
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
for (double z: z_left){
linePnts_left.push_back(gp_Pnt(0., -0.5, z));
}
opencascade::handle<Geom_BSplineCurve> leftLine = tigl::CTiglPointsToBSplineInterpolation(linePnts_left).Curve();
curves.push_back(leftLine);

if (!(cornerRadius == 0.)) {
// build upper left arc
double y0 = - 0.5 + radius;
double z0 = 0.5 * heightToWidthRatio - radius;
auto ArcCurve = ApproximateArcOfCircleToRationalBSpline(radius, M_PI/2., M_PI, y0, z0);
ArcCurve->Reverse();
curves.push_back(ArcCurve);
}

// build half upper line from gp_points
std::vector<gp_Pnt> linePntsUpperLeftHalf;
std::vector<double> y_UpperLeftHalf = Linspace(-(0.5-radius),0.,5);
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
for (double y: y_UpperLeftHalf){
linePntsUpperLeftHalf.push_back(gp_Pnt(0., y, 0.5 * heightToWidthRatio));
}
opencascade::handle<Geom_BSplineCurve> upperLineLeftHalf = tigl::CTiglPointsToBSplineInterpolation(linePntsUpperLeftHalf).Curve();
curves.push_back(upperLineLeftHalf);

opencascade::handle<Geom_BSplineCurve> curve = tigl::CTiglBSplineAlgorithms::concatCurves(curves);
TopoDS_Wire wire;
if(!curve.IsNull())
{
joergbrech marked this conversation as resolved.
Show resolved Hide resolved
wire = BuildWireFromEdges(BRepBuilderAPI_MakeEdge(curve).Edge());
}
return wire;
}

void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList)
{
// get list of edges from passed shape
Expand Down Expand Up @@ -1719,6 +1842,17 @@ bool IsPointAbovePlane(const gp_Pln& pln, gp_Pnt point)
return gp_Vec(pln.Location(), point).Dot(gp_Vec(pln.Axis().Direction())) > 0;
}

std::vector<double> Linspace(double umin, double umax, size_t n_values)
{
double du = (umax - umin) / static_cast<double>(n_values - 1);

std::vector<double> result(n_values);
for (int i = 0; i < n_values; ++i) {
result[i] = i * du + umin;
}
return result;
}

std::vector<double> LinspaceWithBreaks(double umin, double umax, size_t n_values, const std::vector<double>& breaks)
{
double du = (umax - umin) / static_cast<double>(n_values - 1);
Expand Down
27 changes: 27 additions & 0 deletions src/common/tiglcommonfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include <algorithm>
#include "UniquePtr.h"



typedef std::map<std::string, PNamedShape> ShapeMap;

// helper function for std::find
Expand Down Expand Up @@ -269,6 +271,28 @@ TIGL_EXPORT TopoDS_Wire BuildWire(const gp_Pnt& p1, const gp_Pnt& p2);
// Method for building a wire out of the edges from the passed geometry
TIGL_EXPORT TopoDS_Wire BuildWireFromEdges(const TopoDS_Shape& edges);

/**
* @brief ApproximateArcOfCircleToRationalBSpline
* The result of this function is a non-rational B-Spline curve that approximates an arc of circle in the y-z plane. Its center is given by the y- and z-position.
* The angle is given in rad.
* The direction of rotation is counter-clockwise, starting with alpha=0 on the positive y-axis, with z=0.
* @param radius Radius of the circle
* @param uMin Starting parameter in rad. Range: [0,2*Pi]
* @param uMax
* @param y_position
* @param z_position
* @return opencascade::handle<Geom_BSplineCurve>
*/
TIGL_EXPORT opencascade::handle<Geom_BSplineCurve> ApproximateArcOfCircleToRationalBSpline(double cornerRadius, double uMin = 0, double uMax = M_PI/4 ,double y_position = 0., double z_position = 0.);

/**
* @brief BuildWireRectangle Builds a rectangular wire in (y,z) - plane with width 1, center of coordinate system is the center of the rectangle
* @param heightToWidthRatio
* @param cornerRadius
* @return
*/
TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double& heightToWidthRatio, const double& cornerRadius =0.0);
joergbrech marked this conversation as resolved.
Show resolved Hide resolved

// Returns a list of wires built from all connected edges in the passed shape
TIGL_EXPORT void BuildWiresFromConnectedEdges(const TopoDS_Shape& shape, TopTools_ListOfShape& wireList);

Expand Down Expand Up @@ -355,6 +379,9 @@ TIGL_EXPORT double Mix(double x, double y, double a);
// Normalizes the input angle into the range [0, 360)
TIGL_EXPORT double NormalizeAngleDeg(double angleDeg);

// Creates a linear spaces array
TIGL_EXPORT std::vector<double> Linspace(double umin, double umax, size_t n_values);
joergbrech marked this conversation as resolved.
Show resolved Hide resolved

// Creates a linear spaces array but with some additional breaking points
// If the breaking points are very close to a point, the point will be replaced
// Else, the breaking point will be inserted
Expand Down
Loading
Loading