No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
e578ad3
... +36 ...
b0ca5e6
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
1 | + | /* |
|
2 | + | * Copyright (C) 2020 German Aerospace Center (DLR/SC) |
|
3 | + | * |
|
4 | + | * Created: 2020-09-10 Martin Siggel <Martin.Siggel@dlr.de> |
|
5 | + | * |
|
6 | + | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
7 | + | * you may not use this file except in compliance with the License. |
|
8 | + | * You may obtain a copy of the License at |
|
9 | + | * |
|
10 | + | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | + | * |
|
12 | + | * Unless required by applicable law or agreed to in writing, software |
|
13 | + | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | + | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | + | * See the License for the specific language governing permissions and |
|
16 | + | * limitations under the License. |
|
17 | + | */ |
|
18 | + | ||
19 | + | #include "CTiglConcatSurfaces.h" |
|
20 | + | ||
21 | + | #include <CTiglBSplineAlgorithms.h> |
|
22 | + | #include <CTiglError.h> |
|
23 | + | ||
24 | + | #include <algorithm> |
|
25 | + | ||
26 | + | namespace tigl |
|
27 | + | { |
|
28 | + | ||
29 | + | CTiglConcatSurfaces::CTiglConcatSurfaces(const std::vector<Handle(Geom_BSplineSurface)>& surfaces, |
|
30 | + | const std::vector<double>& surfaceParams, ConcatDir dir) |
|
31 | + | : m_surfaces(surfaces) |
|
32 | + | , m_params(surfaceParams) |
|
33 | + | , m_dir(dir) |
|
34 | + | { |
|
35 | + | ||
36 | + | if (surfaces.size() + 1 != surfaceParams.size()) { |
|
37 | + | throw CTiglError("Surfaces dont match parameters: Number of parameters != number of surfaces + 1"); |
|
38 | + | } |
|
39 | + | ||
40 | + | if (dir ==ConcatDir::v) { |
|
41 | + | throw CTiglError("CTiglConcatSurfaces in v-direction not yet implemented"); |
|
42 | + | } |
|
43 | + | ||
44 | + | std::sort(m_params.begin(), m_params.end()); |
|
45 | + | } |
|
46 | + | ||
47 | + | void CTiglConcatSurfaces::SetMakeKnotsUniformEnabled(unsigned int nUSeg, unsigned int nVSeg) |
|
48 | + | { |
|
49 | + | if (nUSeg > 0 && nVSeg > 0) { |
|
50 | + | m_approxSegments.reset({nUSeg, nVSeg}); |
|
51 | + | } |
|
52 | + | else { |
|
53 | + | m_approxSegments.reset(); |
|
54 | + | } |
|
55 | + | } |
|
56 | + | ||
57 | + | Handle(Geom_BSplineSurface) CTiglConcatSurfaces::Surface() const |
|
58 | + | { |
|
59 | + | // create a copy of all surfaces |
|
60 | + | std::vector<Handle(Geom_BSplineSurface)> surfaces; |
|
61 | + | std::transform(std::begin(m_surfaces), std::end(m_surfaces), std::back_inserter(surfaces), |
|
62 | + | [](const Handle(Geom_BSplineSurface) & surf) { |
|
63 | + | return Handle(Geom_BSplineSurface)::DownCast(surf->Copy()); |
|
64 | + | }); |
|
65 | + | ||
66 | + | if (m_approxSegments) { |
|
67 | + | std::transform( |
|
68 | + | std::begin(surfaces), std::end(surfaces), std::begin(surfaces), [this](Handle(Geom_BSplineSurface) & surf) { |
|
69 | + | return CTiglBSplineAlgorithms::makeKnotsUniform(surf, m_approxSegments->nu, m_approxSegments->nv); |
|
70 | + | }); |
|
71 | + | } |
|
72 | + | ||
73 | + | for (size_t surfIdx = 0; surfIdx < surfaces.size(); ++surfIdx) { |
|
74 | + | CTiglBSplineAlgorithms::reparametrizeBSpline(*surfaces[surfIdx], m_params[surfIdx], m_params[surfIdx + 1], 0., |
|
75 | + | 1., 1e-10); |
|
76 | + | } |
|
77 | + | ||
78 | + | for (size_t surfIdx = 1; surfIdx < surfaces.size(); ++surfIdx) { |
|
79 | + | surfaces[0] = CTiglBSplineAlgorithms::concatSurfacesUDir(surfaces[0], surfaces[surfIdx]); |
|
80 | + | } |
|
81 | + | ||
82 | + | return surfaces[0]; |
|
83 | + | } |
|
84 | + | ||
85 | + | } // namespace tigl |
45 | 45 | #include "tigl_config.h" |
|
46 | 46 | #include "math/tiglmathfunctions.h" |
|
47 | 47 | #include "CNamedShape.h" |
|
48 | + | #include "CTiglWingBuilder.h" |
|
49 | + | #include "CTiglConcatSurfaces.h" |
|
50 | + | #include "GeomConvert.hxx" |
|
48 | 51 | ||
49 | 52 | #include "BRepOffsetAPI_ThruSections.hxx" |
|
50 | 53 | #include "TopExp_Explorer.hxx" |
126 | 129 | return trafo.Transform(point); |
|
127 | 130 | } |
|
128 | 131 | ||
129 | - | // Set the face traits |
|
130 | - | void SetFaceTraits (PNamedShape loft, std::string shapeUID) |
|
131 | - | { |
|
132 | - | // designated names of the faces |
|
133 | - | std::vector<std::string> names(5); |
|
134 | - | names[0]="Bottom"; |
|
135 | - | names[1]="Top"; |
|
136 | - | names[2]="TrailingEdge"; |
|
137 | - | names[3]="Inside"; |
|
138 | - | names[4]="Outside"; |
|
139 | - | ||
140 | - | // map of faces |
|
141 | - | TopTools_IndexedMapOfShape map; |
|
142 | - | TopExp::MapShapes(loft->Shape(), TopAbs_FACE, map); |
|
143 | - | ||
144 | - | for (int iFace = 0; iFace < map.Extent(); ++iFace) { |
|
145 | - | loft->FaceTraits(iFace).SetComponentUID(shapeUID); |
|
146 | - | } |
|
147 | - | ||
148 | - | // check if number of faces is correct (only valid for ruled surfaces lofts) |
|
149 | - | if (map.Extent() != 5 && map.Extent() != 4) { |
|
150 | - | LOG(ERROR) << "CCPACSWingSegment: Unable to determine face names in ruled surface loft"; |
|
151 | - | return; |
|
152 | - | } |
|
153 | - | // remove trailing edge name if there is no trailing edge |
|
154 | - | if (map.Extent() == 4) { |
|
155 | - | names.erase(names.begin()+2); |
|
156 | - | } |
|
157 | - | // set face trait names |
|
158 | - | for (int i = 0; i < map.Extent(); i++) { |
|
159 | - | CFaceTraits traits = loft->GetFaceTraits(i); |
|
160 | - | traits.SetName(names[i].c_str()); |
|
161 | - | loft->SetFaceTraits(i, traits); |
|
162 | - | } |
|
163 | - | } |
|
164 | - | ||
165 | 132 | /** |
|
166 | 133 | * @brief getFaceTrimmingEdge Creates an edge in parameter space to trim a face |
|
167 | 134 | * @return |
486 | 453 | std::string loftName = GetUID(); |
|
487 | 454 | std::string loftShortName = GetShortShapeName(); |
|
488 | 455 | PNamedShape loft (new CNamedShape(loftShape, loftName.c_str(), loftShortName.c_str())); |
|
489 | - | SetFaceTraits(loft, GetUID()); |
|
456 | + | std::vector<double> guideCurveParams = {}; |
|
457 | + | if (GetGuideCurves()) { |
|
458 | + | guideCurveParams = GetGuideCurves()->GetRelativeCircumferenceParameters(); |
|
459 | + | } |
|
460 | + | CTiglWingBuilder::SetFaceTraits(guideCurveParams, GetUID(), loft, innerConnection.GetProfile().HasBluntTE()); |
|
490 | 461 | return loft; |
|
491 | 462 | } |
|
492 | 463 |
974 | 945 | ||
975 | 946 | void CCPACSWingSegment::MakeSurfaces(SurfaceCache& cache) const |
|
976 | 947 | { |
|
977 | - | // make upper and lower surface |
|
978 | - | cache.lowerSurface = BRep_Tool::Surface(TopoDS::Face(GetLowerShape())); |
|
979 | - | cache.upperSurface = BRep_Tool::Surface(TopoDS::Face(GetUpperShape())); |
|
980 | - | cache.lowerSurfaceLocal = BRep_Tool::Surface(TopoDS::Face(GetLowerShape(WING_COORDINATE_SYSTEM))); |
|
981 | - | cache.upperSurfaceLocal = BRep_Tool::Surface(TopoDS::Face(GetUpperShape(WING_COORDINATE_SYSTEM))); |
|
948 | + | auto globalToLocalTrsf = GetParent()->GetParent<CCPACSWing>()->GetTransformationMatrix() |
|
949 | + | .Inverted(); |
|
950 | + | ||
951 | + | auto lowerShape = GetLowerShape(GLOBAL_COORDINATE_SYSTEM); |
|
952 | + | auto upperShape = GetUpperShape(GLOBAL_COORDINATE_SYSTEM); |
|
953 | + | ||
954 | + | if (m_guideCurves) { |
|
955 | + | auto params = m_guideCurves->GetRelativeCircumferenceParameters(); |
|
956 | + | auto it = std::find_if(std::begin(params), std::end(params), [](double val) { |
|
957 | + | // the leading edge is defined at parameter 0, we allow some tolerance |
|
958 | + | return std::abs(val) < 1e-3; |
|
959 | + | }); |
|
960 | + | ||
961 | + | if (it == params.end()) { |
|
962 | + | // could not find leading edge guide curve |
|
963 | + | throw CTiglError ("There is no guide curve defined at the leading edge"); |
|
964 | + | } |
|
965 | + | ||
966 | + | // split into upper and lower parameters |
|
967 | + | std::vector<double> lower_params, upper_params; |
|
968 | + | std::copy(std::begin(params), it+1, std::back_inserter(lower_params)); |
|
969 | + | std::copy(it, std::end(params), std::back_inserter(upper_params)); |
|
970 | + | ||
971 | + | auto concatSurfs = [](const TopoDS_Shape& shape, const std::vector<double>& parms) { |
|
972 | + | if (GetNumberOfFaces(shape) == 1) { |
|
973 | + | return BRep_Tool::Surface(TopoDS::Face(shape)); |
|
974 | + | } |
|
975 | + | else { |
|
976 | + | std::vector<Handle(Geom_BSplineSurface)> surfs; |
|
977 | + | ||
978 | + | for (TopExp_Explorer expl(shape, TopAbs_FACE); expl.More(); expl.Next()) { |
|
979 | + | const TopoDS_Face& face = TopoDS::Face(expl.Current()); |
|
980 | + | auto bspl = GeomConvert::SurfaceToBSplineSurface(BRep_Tool::Surface(face)); |
|
981 | + | surfs.push_back(bspl); |
|
982 | + | } |
|
983 | + | ||
984 | + | CTiglConcatSurfaces concat(surfs, parms, ConcatDir::u); |
|
985 | + | return Handle(Geom_Surface)(concat.Surface()); |
|
986 | + | } |
|
987 | + | }; |
|
988 | + | ||
989 | + | // make upper and lower surface |
|
990 | + | cache.lowerSurface = concatSurfs(lowerShape, lower_params); |
|
991 | + | cache.upperSurface = concatSurfs(upperShape, upper_params); |
|
992 | + | ||
993 | + | } |
|
994 | + | else { |
|
995 | + | // make upper and lower surface |
|
996 | + | cache.lowerSurface = BRep_Tool::Surface(TopoDS::Face(lowerShape)); |
|
997 | + | cache.upperSurface = BRep_Tool::Surface(TopoDS::Face(upperShape)); |
|
998 | + | } |
|
999 | + | ||
1000 | + | cache.lowerSurfaceLocal = globalToLocalTrsf.Transform(cache.lowerSurface); |
|
1001 | + | cache.upperSurfaceLocal = globalToLocalTrsf.Transform(cache.upperSurface); |
|
1002 | + | ||
982 | 1003 | } |
|
983 | 1004 | ||
984 | 1005 | void CCPACSWingSegment::MakeChordSurfaces(ChordSurfaceCache& cache) const |
24 | 24 | #include "tigl.h" |
|
25 | 25 | #include "BRepBuilderAPI_GTransform.hxx" |
|
26 | 26 | #include "BRepBuilderAPI_Transform.hxx" |
|
27 | + | #include "BRepBuilderAPI_MakeFace.hxx" |
|
28 | + | #include "BRep_Tool.hxx" |
|
27 | 29 | #include "gp_XYZ.hxx" |
|
30 | + | #include "TopoDS_Face.hxx" |
|
28 | 31 | #include "Standard_Version.hxx" |
|
29 | 32 | #include "CNamedShape.h" |
|
30 | 33 |
428 | 431 | } |
|
429 | 432 | } |
|
430 | 433 | ||
434 | + | // Transforms a surface with the current transformation matrix and |
|
435 | + | // returns the transformed point |
|
436 | + | TIGL_EXPORT Handle(Geom_Surface) CTiglTransformation::Transform(const Handle(Geom_Surface)& surf) const |
|
437 | + | { |
|
438 | + | auto surfCopy = Handle(Geom_Surface)::DownCast(surf->Copy()); |
|
439 | + | ||
440 | + | TopoDS_Face tmpFace = BRepBuilderAPI_MakeFace(surfCopy, 1e-6); |
|
441 | + | tmpFace = TopoDS::Face(Transform(tmpFace)); |
|
442 | + | TopLoc_Location L; |
|
443 | + | surfCopy = BRep_Tool::Surface(tmpFace, L); |
|
444 | + | surfCopy->Transform(L.Transformation()); |
|
445 | + | ||
446 | + | return surfCopy; |
|
447 | + | } |
|
448 | + | ||
431 | 449 | PNamedShape tigl::CTiglTransformation::Transform(PNamedShape shape) const |
|
432 | 450 | { |
|
433 | 451 | if (!shape) { |
25 | 25 | #include "CTiglPointsToBSplineInterpolation.h" |
|
26 | 26 | #include "to_string.h" |
|
27 | 27 | #include "tiglcommonfunctions.h" |
|
28 | + | #include "Debugging.h" |
|
28 | 29 | ||
29 | 30 | #include <Standard_Version.hxx> |
|
30 | 31 | #include <Geom2d_BSplineCurve.hxx> |
534 | 535 | return std::vector<Handle(Geom_BSplineCurve)>(splines_adapter.begin(), splines_adapter.end()); |
|
535 | 536 | } |
|
536 | 537 | ||
537 | - | std::vector<Handle(Geom_BSplineSurface) > CTiglBSplineAlgorithms::createCommonKnotsVectorSurface(const std::vector<Handle(Geom_BSplineSurface) >& old_surfaces_vector) |
|
538 | + | std::vector<Handle(Geom_BSplineSurface) > CTiglBSplineAlgorithms::createCommonKnotsVectorSurface(const std::vector<Handle(Geom_BSplineSurface) >& old_surfaces_vector, SurfaceDirection dir) |
|
538 | 539 | { |
|
539 | - | // all B-spline surfaces must have the same parameter range in u- and v-direction |
|
540 | - | // TODO: Match parameter range |
|
541 | - | ||
542 | 540 | // Create a copy that we can modify |
|
543 | 541 | std::vector<SurfAdapterView> adapterSplines; |
|
544 | 542 | for (size_t i = 0; i < old_surfaces_vector.size(); ++i) { |
|
545 | 543 | adapterSplines.push_back(SurfAdapterView(Handle(Geom_BSplineSurface)::DownCast(old_surfaces_vector[i]->Copy()), udir)); |
|
546 | 544 | } |
|
547 | 545 | ||
548 | - | // first in u direction |
|
549 | - | makeGeometryCompatibleImpl(adapterSplines, 1e-15); |
|
550 | - | ||
551 | - | for (size_t i = 0; i < old_surfaces_vector.size(); ++i) adapterSplines[i].setDir(vdir); |
|
546 | + | if (dir == SurfaceDirection::u || dir == SurfaceDirection::both) { |
|
547 | + | // first in u direction |
|
548 | + | makeGeometryCompatibleImpl(adapterSplines, 1e-14); |
|
549 | + | } |
|
552 | 550 | ||
553 | - | // now in v direction |
|
554 | - | makeGeometryCompatibleImpl(adapterSplines, 1e-15); |
|
551 | + | if (dir == SurfaceDirection::v || dir == SurfaceDirection::both) { |
|
552 | + | // now in v direction |
|
553 | + | for (size_t i = 0; i < old_surfaces_vector.size(); ++i) adapterSplines[i].setDir(vdir); |
|
554 | + | makeGeometryCompatibleImpl(adapterSplines, 1e-14); |
|
555 | + | } |
|
555 | 556 | ||
556 | 557 | return std::vector<Handle(Geom_BSplineSurface)>(adapterSplines.begin(), adapterSplines.end()); |
|
557 | 558 | } |
818 | 819 | } |
|
819 | 820 | } |
|
820 | 821 | ||
822 | + | void CTiglBSplineAlgorithms::reparametrizeBSpline(Geom_BSplineSurface& spline, double umin, double umax, double vmin, double vmax, double tol) |
|
823 | + | { |
|
824 | + | if (std::abs(spline.UKnot(1) - umin) > tol || std::abs(spline.UKnot(spline.NbUKnots()) - umax) > tol) { |
|
825 | + | TColStd_Array1OfReal aKnots (1, spline.NbUKnots()); |
|
826 | + | spline.UKnots (aKnots); |
|
827 | + | BSplCLib::Reparametrize (umin, umax, aKnots); |
|
828 | + | spline.SetUKnots (aKnots); |
|
829 | + | } |
|
830 | + | ||
831 | + | if (std::abs(spline.VKnot(1) - vmin) > tol || std::abs(spline.VKnot(spline.NbVKnots()) - vmax) > tol) { |
|
832 | + | TColStd_Array1OfReal aKnots (1, spline.NbVKnots()); |
|
833 | + | spline.VKnots (aKnots); |
|
834 | + | BSplCLib::Reparametrize (vmin, vmax, aKnots); |
|
835 | + | spline.SetVKnots (aKnots); |
|
836 | + | } |
|
837 | + | } |
|
838 | + | ||
821 | 839 | CTiglApproxResult CTiglBSplineAlgorithms::reparametrizeBSplineNiceKnots(Handle(Geom_BSplineCurve) spline) |
|
822 | 840 | { |
|
823 | 841 | if (spline.IsNull()) { |
1139 | 1157 | return result; |
|
1140 | 1158 | } |
|
1141 | 1159 | ||
1160 | + | Handle(Geom_BSplineSurface) CTiglBSplineAlgorithms::concatSurfacesUDir(Handle(Geom_BSplineSurface) bspl1, |
|
1161 | + | Handle(Geom_BSplineSurface) bspl2, |
|
1162 | + | double space_tol) |
|
1163 | + | { |
|
1164 | + | ||
1165 | + | DEBUG_SCOPE(debug); |
|
1166 | + | debug.addShape(BRepBuilderAPI_MakeFace(bspl1, 1e-6).Face(), "surf1"); |
|
1167 | + | debug.addShape(BRepBuilderAPI_MakeFace(bspl2, 1e-6).Face(), "surf2"); |
|
1168 | + | ||
1169 | + | // the surfaces must not be periodic in u direction |
|
1170 | + | assert (bspl1->IsUPeriodic() == false); |
|
1171 | + | assert (bspl2->IsUPeriodic() == false); |
|
1172 | + | ||
1173 | + | // we dont have nurbs implemented right now |
|
1174 | + | assert (bspl1->IsURational() == false); |
|
1175 | + | assert (bspl2->IsURational() == false); |
|
1176 | + | assert (bspl1->IsVRational() == false); |
|
1177 | + | assert (bspl2->IsVRational() == false); |
|
1178 | + | ||
1179 | + | double param_tol = 1e-14; |
|
1180 | + | ||
1181 | + | // check that surfaces are following parametrically |
|
1182 | + | double umin1, umax1, vmin1, vmax1; |
|
1183 | + | bspl1->Bounds(umin1, umax1, vmin1, vmax1); |
|
1184 | + | double umin2, umax2, vmin2, vmax2; |
|
1185 | + | bspl2->Bounds(umin2, umax2, vmin2, vmax2); |
|
1186 | + | ||
1187 | + | if (std::abs(umax1 - umin2) > param_tol) { |
|
1188 | + | std::stringstream str; |
|
1189 | + | str << "Surfaces do not follow in u-parametric direction in CTiglBSplineAlgorithms::concatSurfacesUDir. "; |
|
1190 | + | str << "Surface 1 ends at " << umax1 << ", Surface 2 begins at " << umin2 << "!"; |
|
1191 | + | throw CTiglError(str.str(), TIGL_MATH_ERROR); |
|
1192 | + | } |
|
1193 | + | ||
1194 | + | bspl1->SetVNotPeriodic(); |
|
1195 | + | bspl2->SetVNotPeriodic(); |
|
1196 | + | ||
1197 | + | auto u_degree = std::max(bspl1->UDegree(), bspl2->UDegree()); |
|
1198 | + | auto v_degree = std::max(bspl1->VDegree(), bspl2->VDegree()); |
|
1199 | + | ||
1200 | + | bspl1->IncreaseDegree(u_degree, v_degree); |
|
1201 | + | bspl2->IncreaseDegree(u_degree, v_degree); |
|
1202 | + | ||
1203 | + | // check that corner points match |
|
1204 | + | auto leftCornerDist = bspl1->Value(umax1, vmin1).Distance(bspl2->Value(umin2, vmin2)); |
|
1205 | + | auto rightCornerDist = bspl1->Value(umax1, vmax1).Distance(bspl2->Value(umin2, vmax2)) ; |
|
1206 | + | if (leftCornerDist > space_tol || rightCornerDist > space_tol) { |
|
1207 | + | throw CTiglError("Surfaces don't match within tolerances in CTiglBSplineAlgorithms::concatSurfacesUDir.", TIGL_MATH_ERROR); |
|
1208 | + | } |
|
1209 | + | ||
1210 | + | auto spl_vec = CTiglBSplineAlgorithms::createCommonKnotsVectorSurface({bspl1, bspl2}, SurfaceDirection::v); |
|
1211 | + | bspl1 = spl_vec[0]; |
|
1212 | + | bspl2 = spl_vec[1]; |
|
1213 | + | ||
1214 | + | assert(bspl1->NbVPoles() == bspl2->NbVPoles()); |
|
1215 | + | ||
1216 | + | // concat control points |
|
1217 | + | TColgp_Array2OfPnt cpsNew(1, bspl1->NbUPoles() + bspl2->NbUPoles() - 1, 1, bspl1->NbVPoles()); |
|
1218 | + | for (int iv = 0; iv < bspl1->NbVPoles(); ++iv) { |
|
1219 | + | for (int iu = 0; iu < bspl1->NbUPoles() - 1; ++iu) { |
|
1220 | + | cpsNew.SetValue(iu+1, iv+1, bspl1->Pole(iu+1, iv+1)); |
|
1221 | + | } |
|
1222 | + | auto offset = bspl1->NbUPoles(); |
|
1223 | + | for (int iu = 0; iu < bspl2->NbUPoles(); ++iu) { |
|
1224 | + | cpsNew.SetValue(iu + offset, iv+1, bspl2->Pole(iu+1, iv+1)); |
|
1225 | + | } |
|
1226 | + | } |
|
1227 | + | ||
1228 | + | // concat knots and mults |
|
1229 | + | TColStd_Array1OfReal uknots_new(1, bspl1->NbUKnots() + bspl2->NbUKnots() - 1); |
|
1230 | + | TColStd_Array1OfInteger umults_new(1, bspl1->NbUKnots() + bspl2->NbUKnots() - 1); |
|
1231 | + | ||
1232 | + | for (int i = 0; i < bspl1->NbUKnots()-1; ++i) { |
|
1233 | + | uknots_new.SetValue(i+1, bspl1->UKnot(i+1)); |
|
1234 | + | umults_new.SetValue(i+1, bspl1->UMultiplicity(i+1)); |
|
1235 | + | } |
|
1236 | + | ||
1237 | + | int middleIdx = bspl1->NbUKnots(); |
|
1238 | + | uknots_new.SetValue(middleIdx, 0.5 * (bspl1->UKnot(middleIdx) + bspl2->UKnot(1))); |
|
1239 | + | umults_new.SetValue(middleIdx, bspl1->UMultiplicity(middleIdx) - 1); |
|
1240 | + | ||
1241 | + | for (int i = 1; i < bspl2->NbUKnots(); ++i) { |
|
1242 | + | uknots_new.SetValue(i + middleIdx, bspl2->UKnot(i+1)); |
|
1243 | + | umults_new.SetValue(i + middleIdx, bspl2->UMultiplicity(i+1)); |
|
1244 | + | } |
|
1245 | + | ||
1246 | + | // we simply take the v-knots of the first spline |
|
1247 | + | TColStd_Array1OfReal vknots_new(1, bspl1->NbVKnots()); |
|
1248 | + | TColStd_Array1OfInteger vmults_new(1, bspl1->NbVKnots()); |
|
1249 | + | bspl1->VKnots(vknots_new); |
|
1250 | + | bspl1->VMultiplicities(vmults_new); |
|
1251 | + | ||
1252 | + | #ifdef DEBUG |
|
1253 | + | int sum_umults = 0; |
|
1254 | + | for (int i = umults_new.Lower(); i <= umults_new.Upper(); ++i) { |
|
1255 | + | sum_umults += umults_new.Value(i); |
|
1256 | + | } |
|
1257 | + | ||
1258 | + | int sum_vmults = 0; |
|
1259 | + | for (int i = vmults_new.Lower(); i <= vmults_new.Upper(); ++i) { |
|
1260 | + | sum_vmults += vmults_new.Value(i); |
|
1261 | + | } |
|
1262 | + | ||
1263 | + | assert(cpsNew.ColLength() + u_degree + 1 == sum_umults); |
|
1264 | + | assert(cpsNew.RowLength() + v_degree + 1 == sum_vmults); |
|
1265 | + | #endif |
|
1266 | + | ||
1267 | + | return new Geom_BSplineSurface(cpsNew, uknots_new, vknots_new, |
|
1268 | + | umults_new, vmults_new, |
|
1269 | + | u_degree, v_degree, false, false); |
|
1270 | + | } |
|
1271 | + | ||
1272 | + | Handle(Geom_BSplineSurface) CTiglBSplineAlgorithms::makeKnotsUniform(Handle(Geom_BSplineSurface) surf, unsigned int nseg_u, unsigned int nseg_v) |
|
1273 | + | { |
|
1274 | + | double u1, u2, v1, v2; |
|
1275 | + | surf->Bounds(u1, u2, v1, v2); |
|
1276 | + | ||
1277 | + | // we create a degree 3 approximation in all directions |
|
1278 | + | auto ncp_u = std::max(4, static_cast<int>(nseg_u + 1)); |
|
1279 | + | auto ncp_v = std::max(4, static_cast<int>(nseg_v + 1)); |
|
1280 | + | ||
1281 | + | auto u = LinspaceWithBreaks(u1, u2, ncp_u, {}); |
|
1282 | + | auto v = LinspaceWithBreaks(v1, v2, ncp_v, {}); |
|
1283 | + | ||
1284 | + | TColgp_Array2OfPnt points(1, ncp_u, 1, ncp_v); |
|
1285 | + | ||
1286 | + | for (size_t i = 0; i < u.size(); ++i) { |
|
1287 | + | for (size_t j = 0; j < v.size(); ++j) { |
|
1288 | + | auto pnt = surf->Value(u[i], v[j]); |
|
1289 | + | points.SetValue(static_cast<Standard_Integer>(i+1), static_cast<Standard_Integer>(j+1), pnt); |
|
1290 | + | } |
|
1291 | + | } |
|
1292 | + | ||
1293 | + | return CTiglBSplineAlgorithms::pointsToSurface(points, u, v, true, true); |
|
1294 | + | } |
|
1295 | + | ||
1142 | 1296 | } // namespace tigl |
189 | 189 | surfaces_vector_unmod.push_back(tensorProdSurf); |
|
190 | 190 | ||
191 | 191 | // create common knot vector for all three surfaces |
|
192 | - | std::vector<Handle(Geom_BSplineSurface)> surfaces_vector = CTiglBSplineAlgorithms::createCommonKnotsVectorSurface(surfaces_vector_unmod); |
|
192 | + | std::vector<Handle(Geom_BSplineSurface)> surfaces_vector = CTiglBSplineAlgorithms::createCommonKnotsVectorSurface(surfaces_vector_unmod, |
|
193 | + | SurfaceDirection::both); |
|
193 | 194 | ||
194 | 195 | assert(surfaces_vector.size() == 3); |
|
195 | 196 |
Learn more Showing 9 files with coverage changes found.
src/geometry/CTiglConcatSurfaces.h
src/geometry/CTiglConcatSurfaces.cpp
src/geometry/CTiglBSplineAlgorithms.cpp
src/wing/CTiglWingProfilePointList.cpp
src/wing/CCPACSWingProfile.cpp
src/common/tiglcommonfunctions.cpp
src/common/Debugging.cpp
src/guide_curves/CCPACSGuideCurves.cpp
src/guide_curves/CCPACSGuideCurve.cpp
Files | Coverage |
---|---|
src | 0.41% 69.42% |
Project Totals (425 files) | 69.42% |
b0ca5e6
#748
fcd82a3
57bdbf3
845036f
61a00c1
936699a
e73737f
70ddea2
650c689
4c0b203
d799916
42e810c
d11160b
76fb237
7a090aa
0989e7e
9aaebd1
6d8491d
cabb148
30ead36
28e3709
b4a0ee9
ab2974d
f0bd217
814347a
6d3c74c
42330c9
e21a6be
99a9c6b
ed8a4e3
dd1486c
c6ec8d5
48dcdc0
3b7ff53
7a7cf22
6d3c4e1
97317ee
e578ad3