Merge branch 'main' into bgbsww-toponaming-makeElementFace
This commit is contained in:
@@ -384,6 +384,9 @@ void TopoShape::mapSubElementTypeForShape(const TopoShape& other,
|
||||
}
|
||||
std::ostringstream ss;
|
||||
char elementType {shapeName(type)[0]};
|
||||
if ( ! elementMap() ) {
|
||||
FC_THROWM(NullShapeException, "No element map");
|
||||
}
|
||||
elementMap()->encodeElementName(elementType, name, ss, &sids, Tag, op, other.Tag);
|
||||
elementMap()->setElementName(element, name, Tag, &sids);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "TopoShapeMapper.h"
|
||||
|
||||
namespace Part
|
||||
|
||||
@@ -15,6 +15,17 @@
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs2871">
|
||||
<linearGradient
|
||||
id="linearGradient4">
|
||||
<stop
|
||||
style="stop-color:#3f6fab;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3" />
|
||||
<stop
|
||||
style="stop-color:#729fcf;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop4" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient62">
|
||||
<stop
|
||||
@@ -417,7 +428,7 @@
|
||||
x2="-22"
|
||||
y2="5" />
|
||||
<linearGradient
|
||||
xlink:href="#linearGradient3836-9-3"
|
||||
xlink:href="#linearGradient4"
|
||||
id="linearGradient97"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
|
||||
@@ -425,6 +436,15 @@
|
||||
y1="18"
|
||||
x2="-22"
|
||||
y2="5" />
|
||||
<linearGradient
|
||||
y2="131.22015"
|
||||
x2="154.4444"
|
||||
y1="161.22015"
|
||||
x1="164.4444"
|
||||
gradientTransform="translate(-188.44439,-101.22016)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient3112"
|
||||
xlink:href="#linearGradient3815" />
|
||||
</defs>
|
||||
<metadata
|
||||
id="metadata2874">
|
||||
@@ -464,7 +484,8 @@
|
||||
transform="matrix(0.1460346,0,0,0.1460346,-220.10298,-55.131225)">
|
||||
<g
|
||||
transform="translate(-451.94762,54.987483)"
|
||||
id="g4428-3-2">
|
||||
id="g4428-3-2"
|
||||
style="display:inline">
|
||||
<path
|
||||
style="fill:none;stroke:#151819;stroke-width:8.27355;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:8.27355, 16.5471;stroke-dashoffset:8.27355;stroke-opacity:1"
|
||||
id="path3044-28"
|
||||
@@ -519,7 +540,7 @@
|
||||
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(5.3322609,0,0,5.33226,1983.4426,601.87102)"
|
||||
transform="matrix(5.3322609,0,0,5.33226,1983.4426,588.17564)"
|
||||
id="g95"
|
||||
style="stroke-width:1.2842">
|
||||
<path
|
||||
@@ -536,11 +557,11 @@
|
||||
id="g97"
|
||||
style="stroke-width:1.2842">
|
||||
<path
|
||||
style="fill:none;stroke:#2e0000;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
style="fill:none;stroke:#0b1521;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path96"
|
||||
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
|
||||
<path
|
||||
style="fill:url(#linearGradient97);fill-opacity:1;stroke:#ef2929;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
style="fill:url(#linearGradient97);fill-opacity:1;stroke:#729fcf;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path97"
|
||||
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
|
||||
</g>
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 19 KiB |
@@ -380,7 +380,7 @@
|
||||
id="path3826" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.77869459,0,0,0.77869445,66.2831,20.597628)"
|
||||
transform="matrix(0.77869459,0,0,0.77869445,63.903318,22.302657)"
|
||||
id="g3"
|
||||
style="display:inline;stroke-width:1.2842">
|
||||
<path
|
||||
@@ -392,5 +392,9 @@
|
||||
id="path3"
|
||||
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
|
||||
</g>
|
||||
<path
|
||||
id="path1"
|
||||
style="fill:none;fill-opacity:1;stroke:#8ae234;stroke-width:2;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
|
||||
d="m 37.956269,30.704899 c 0,-5.743254 4.655691,-10.39908 10.398778,-10.39908 m 10.398777,10.39908 c 0,5.743253 -4.655691,10.399079 -10.398777,10.39908" />
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -261,11 +261,11 @@
|
||||
<linearGradient
|
||||
id="linearGradient2">
|
||||
<stop
|
||||
style="stop-color:#73d216;stop-opacity:1;"
|
||||
style="stop-color:#d3d7cf;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop1" />
|
||||
<stop
|
||||
style="stop-color:#8ae234;stop-opacity:1;"
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop2" />
|
||||
</linearGradient>
|
||||
@@ -316,6 +316,15 @@
|
||||
y1="35.978416"
|
||||
x2="25.988253"
|
||||
y2="29.916241" />
|
||||
<linearGradient
|
||||
xlink:href="#linearGradient2"
|
||||
id="linearGradient3"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
|
||||
x1="-18"
|
||||
y1="18"
|
||||
x2="-22"
|
||||
y2="5" />
|
||||
</defs>
|
||||
<metadata
|
||||
id="metadata2874">
|
||||
@@ -368,7 +377,7 @@
|
||||
</g>
|
||||
<g
|
||||
id="g1068-6"
|
||||
transform="matrix(-1,0,0,1,45.987644,0)">
|
||||
transform="matrix(-1,0,0,1,47.987644,0)">
|
||||
<path
|
||||
style="fill:url(#linearGradient1099);fill-opacity:1;fill-rule:evenodd;stroke:#0b1521;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 13.547502,28.511064 v -7.501616 l -10.4959114,1e-6 V 10.507184 H 13.547502 V 3.005568 l 9.44632,12.752748 z"
|
||||
@@ -395,5 +404,18 @@
|
||||
d="M 138.75945,-0.2767731 C 141.87413,39.053035 101.07195,19.660727 91.353198,47.348227"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.77869459,0,0,0.77869445,39.542061,32.862232)"
|
||||
id="g3"
|
||||
style="display:inline;stroke-width:1.2842">
|
||||
<path
|
||||
style="fill:none;stroke:#151819;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path2"
|
||||
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
|
||||
<path
|
||||
style="fill:url(#linearGradient3);fill-opacity:1;stroke:#ffffff;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path3"
|
||||
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 13 KiB |
@@ -3886,6 +3886,11 @@ void ViewProviderSketch::generateContextMenu()
|
||||
int selectedConics = 0;
|
||||
int selectedPoints = 0;
|
||||
int selectedConstraints = 0;
|
||||
int selectedBsplines = 0;
|
||||
int selectedBsplineKnots = 0;
|
||||
int selectedOrigin = 0;
|
||||
int selectedEndPoints = 0;
|
||||
bool onlyOrigin = false;
|
||||
|
||||
Gui::MenuItem menu;
|
||||
menu.setCommand("Sketcher context");
|
||||
@@ -3896,31 +3901,70 @@ void ViewProviderSketch::generateContextMenu()
|
||||
// if something is selected, count different elements in the current selection
|
||||
if (selection.size() > 0) {
|
||||
const std::vector<std::string> SubNames = selection[0].getSubNames();
|
||||
|
||||
for (auto& name : SubNames) {
|
||||
if (name.substr(0, 4) == "Edge") {
|
||||
++selectedEdges;
|
||||
|
||||
const Sketcher::SketchObject* obj;
|
||||
if (selection[0].getObject()->isDerivedFrom<Sketcher::SketchObject>()) {
|
||||
obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
|
||||
for (auto& name : SubNames) {
|
||||
int geoId = std::atoi(name.substr(4, 4000).c_str()) - 1;
|
||||
if (geoId >= 0) {
|
||||
const Part::Geometry* geo = getSketchObject()->getGeometry(geoId);
|
||||
if (isLineSegment(*geo)) {
|
||||
++selectedLines;
|
||||
}
|
||||
else {
|
||||
++selectedConics;
|
||||
const Part::Geometry* geo = getSketchObject()->getGeometry(geoId);
|
||||
if (name.substr(0, 4) == "Edge") {
|
||||
++selectedEdges;
|
||||
|
||||
if (geoId >= 0) {
|
||||
if (isLineSegment(*geo)) {
|
||||
++selectedLines;
|
||||
}
|
||||
else if (geo->is<Part::GeomBSplineCurve>()) {
|
||||
++selectedBsplines;
|
||||
}
|
||||
else {
|
||||
++selectedConics;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (name.substr(0, 4) == "Vert") {
|
||||
++selectedPoints;
|
||||
}
|
||||
else if (name.substr(0, 4) == "Cons") {
|
||||
++selectedConstraints;
|
||||
else if (name.substr(0, 4) == "Vert") {
|
||||
++selectedPoints;
|
||||
Sketcher::PointPos posId;
|
||||
getIdsFromName(name, obj, geoId, posId);
|
||||
if (isBsplineKnotOrEndPoint(obj, geoId, posId)) {
|
||||
++selectedBsplineKnots;
|
||||
}
|
||||
if (Sketcher::PointPos::start != posId || Sketcher::PointPos::end != posId) {
|
||||
++selectedEndPoints;
|
||||
}
|
||||
}
|
||||
else if (name.substr(0, 4) == "Cons") {
|
||||
++selectedConstraints;
|
||||
}
|
||||
else if (name.substr(2, 5) == "Axis") {
|
||||
++selectedEdges;
|
||||
++selectedLines;
|
||||
++selectedOrigin;
|
||||
}
|
||||
else if (name.substr(0, 4) == "Root") {
|
||||
++selectedPoints;
|
||||
++selectedOrigin;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selectedPoints + selectedEdges == selectedOrigin) {
|
||||
onlyOrigin = true;
|
||||
}
|
||||
// build context menu items depending on the selection
|
||||
if (selectedEdges >= 1 && selectedPoints == 0) {
|
||||
if (selectedBsplines > 0 && selectedBsplines == selectedEdges && selectedPoints == 0
|
||||
&& !onlyOrigin) {
|
||||
menu << "Sketcher_BSplineInsertKnot"
|
||||
<< "Sketcher_BSplineIncreaseDegree"
|
||||
<< "Sketcher_BSplineDecreaseDegree";
|
||||
}
|
||||
else if (selectedBsplineKnots > 0 && selectedBsplineKnots == selectedPoints
|
||||
&& selectedEdges == 0 && !onlyOrigin) {
|
||||
if (selectedBsplineKnots == 1) {
|
||||
menu << "Sketcher_BSplineIncreaseKnotMultiplicity"
|
||||
<< "Sketcher_BSplineDecreaseKnotMultiplicity";
|
||||
}
|
||||
}
|
||||
if (selectedEdges >= 1 && selectedPoints == 0 && selectedBsplines == 0 && !onlyOrigin) {
|
||||
menu << "Sketcher_Dimension";
|
||||
if (selectedConics == 0) {
|
||||
menu << "Sketcher_ConstrainHorVer"
|
||||
@@ -3948,9 +3992,9 @@ void ViewProviderSketch::generateContextMenu()
|
||||
menu << "Sketcher_ConstrainTangent";
|
||||
}
|
||||
}
|
||||
else if (selectedEdges == 1 && selectedPoints >= 1) {
|
||||
else if (selectedEdges == 1 && selectedPoints >= 1 && !onlyOrigin) {
|
||||
menu << "Sketcher_Dimension";
|
||||
if (selectedConics == 0) {
|
||||
if (selectedConics == 0 && selectedBsplines == 0) {
|
||||
menu << "Sketcher_ConstrainCoincidentUnified"
|
||||
<< "Sketcher_ConstrainHorVer"
|
||||
<< "Sketcher_ConstrainVertical"
|
||||
@@ -3958,6 +4002,10 @@ void ViewProviderSketch::generateContextMenu()
|
||||
if (selectedPoints == 2) {
|
||||
menu << "Sketcher_ConstrainSymmetric";
|
||||
}
|
||||
if (selectedPoints == 1) {
|
||||
menu << "Sketcher_ConstrainPerpendicular"
|
||||
<< "Sketcher_ConstrainTangent";
|
||||
}
|
||||
}
|
||||
else {
|
||||
menu << "Sketcher_ConstrainCoincidentUnified"
|
||||
@@ -3965,7 +4013,7 @@ void ViewProviderSketch::generateContextMenu()
|
||||
<< "Sketcher_ConstrainTangent";
|
||||
}
|
||||
}
|
||||
else if (selectedEdges == 0 && selectedPoints >= 1) {
|
||||
else if (selectedEdges == 0 && selectedPoints >= 1 && !onlyOrigin) {
|
||||
menu << "Sketcher_Dimension";
|
||||
|
||||
if (selectedPoints > 1) {
|
||||
@@ -3974,8 +4022,15 @@ void ViewProviderSketch::generateContextMenu()
|
||||
<< "Sketcher_ConstrainVertical"
|
||||
<< "Sketcher_ConstrainHorizontal";
|
||||
}
|
||||
if (selectedPoints == 2) {
|
||||
menu << "Sketcher_ConstrainPerpendicular"
|
||||
<< "Sketcher_ConstrainTangent";
|
||||
if (selectedEndPoints == 2) {
|
||||
menu << "Sketcher_JoinCurves";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (selectedLines >= 1 && selectedPoints >= 1) {
|
||||
else if (selectedLines >= 1 && selectedPoints >= 1 && !onlyOrigin) {
|
||||
menu << "Sketcher_Dimension"
|
||||
<< "Sketcher_ConstrainHorVer"
|
||||
<< "Sketcher_ConstrainVertical"
|
||||
|
||||
@@ -257,6 +257,8 @@ unsigned int CosmeticEdge::getMemSize () const
|
||||
|
||||
void CosmeticEdge::Save(Base::Writer &writer) const
|
||||
{
|
||||
// TODO: this should be using m_format->Save(writer) instead of saving the individual
|
||||
// fields.
|
||||
writer.Stream() << writer.ind() << "<Style value=\"" << m_format.m_style << "\"/>" << endl;
|
||||
writer.Stream() << writer.ind() << "<Weight value=\"" << m_format.m_weight << "\"/>" << endl;
|
||||
writer.Stream() << writer.ind() << "<Color value=\"" << m_format.m_color.asHexString() << "\"/>" << endl;
|
||||
@@ -276,6 +278,9 @@ void CosmeticEdge::Save(Base::Writer &writer) const
|
||||
} else {
|
||||
Base::Console().Warning("CE::Save - unimplemented geomType: %d\n", static_cast<int>(m_geometry->getGeomType()));
|
||||
}
|
||||
|
||||
writer.Stream() << writer.ind() << "<LineNumber value=\"" << m_format.getLineNumber() << "\"/>" << endl;
|
||||
|
||||
}
|
||||
|
||||
void CosmeticEdge::Restore(Base::XMLReader &reader)
|
||||
@@ -293,6 +298,7 @@ void CosmeticEdge::Restore(Base::XMLReader &reader)
|
||||
m_format.m_color.fromHexString(temp);
|
||||
reader.readElement("Visible");
|
||||
m_format.m_visible = reader.getAttributeAsInteger("value") != 0;
|
||||
|
||||
reader.readElement("GeometryType");
|
||||
TechDraw::GeomType gType = static_cast<TechDraw::GeomType>(reader.getAttributeAsInteger("value"));
|
||||
|
||||
@@ -322,6 +328,19 @@ void CosmeticEdge::Restore(Base::XMLReader &reader)
|
||||
} else {
|
||||
Base::Console().Warning("CE::Restore - unimplemented geomType: %d\n", static_cast<int>(gType));
|
||||
}
|
||||
// older documents may not have the LineNumber element, so we need to check the
|
||||
// next entry. if it is a start element, then we check if it is a start element
|
||||
// for LineNumber.
|
||||
if (reader.readNextElement()) {
|
||||
if(strcmp(reader.localName(),"LineNumber") == 0 ) {
|
||||
// this CosmeticEdge has an LineNumber attribute
|
||||
m_format.setLineNumber(reader.getAttributeAsInteger("value"));
|
||||
} else {
|
||||
// LineNumber not found.
|
||||
// TODO: line number should be set to DashedLineGenerator.fromQtStyle(m_format.m_style)
|
||||
m_format.setLineNumber(LineFormat::InvalidLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boost::uuids::uuid CosmeticEdge::getTag() const
|
||||
|
||||
@@ -179,7 +179,7 @@ void CompassWidget::paintEvent(QPaintEvent* event)
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
//general purpose angle update from external source.
|
||||
// set the compass dial and spinbox to a new angle
|
||||
void CompassWidget::setDialAngle(double newAngle)
|
||||
{
|
||||
// Base::Console().Message("CW::setDialAngle(%.3f)\n", newAngle);
|
||||
@@ -212,6 +212,7 @@ void CompassWidget::slotCWAdvance()
|
||||
angle = angle + 360.0;
|
||||
}
|
||||
setDialAngle(angle);
|
||||
Q_EMIT angleChanged(angle);
|
||||
}
|
||||
|
||||
void CompassWidget::slotCCWAdvance()
|
||||
@@ -224,6 +225,7 @@ void CompassWidget::slotCCWAdvance()
|
||||
angle = angle + dsbAngle->minimum();
|
||||
}
|
||||
setDialAngle(angle);
|
||||
Q_EMIT angleChanged(angle);
|
||||
}
|
||||
|
||||
void CompassWidget::setAdvanceIncrement(double newIncrement) { m_advanceIncrement = newIncrement; }
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
// NOLINTBEGIN(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)
|
||||
|
||||
|
||||
class TopoShapeExpansionTest: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
@@ -436,4 +437,151 @@ TEST_F(TopoShapeExpansionTest, splitWires)
|
||||
// splitWires with allfour reorientation values NoReorient, ReOrient, ReorientForward,
|
||||
// ReorientRevesed
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, mapSubElementInvalidParm)
|
||||
{
|
||||
// Arrange
|
||||
auto [cube1, cube2] = CreateTwoCubes();
|
||||
Part::TopoShape cube1TS {cube1};
|
||||
cube1TS.Tag = 1;
|
||||
|
||||
// Act
|
||||
std::vector<Part::TopoShape> subShapes = cube1TS.getSubTopoShapes(TopAbs_FACE);
|
||||
Part::TopoShape face1 = subShapes.front();
|
||||
face1.Tag = 2;
|
||||
|
||||
// Assert
|
||||
EXPECT_THROW(cube1TS.mapSubElement(face1), Part::NullShapeException); // No subshapes
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, mapSubElementFindShapeByNames)
|
||||
{
|
||||
// Arrange
|
||||
auto [cube1, cube2] = CreateTwoCubes();
|
||||
Part::TopoShape cube1TS {cube1};
|
||||
Part::TopoShape cube2TS {cube2};
|
||||
cube1TS.Tag = 1;
|
||||
cube2TS.Tag = 2;
|
||||
Part::TopoShape topoShape, topoShape1;
|
||||
|
||||
// Act
|
||||
int fs1 = topoShape1.findShape(cube1);
|
||||
topoShape.setShape(cube2TS);
|
||||
topoShape1.makeElementCompound({cube1TS, cube2TS});
|
||||
int fs2 = topoShape1.findShape(cube1);
|
||||
|
||||
TopoDS_Shape tds1 = topoShape.findShape("SubShape1");
|
||||
TopoDS_Shape tds2 = topoShape.findShape("SubShape2"); // Nonexistent
|
||||
TopoDS_Shape tds3 = topoShape1.findShape("SubShape1");
|
||||
TopoDS_Shape tds4 = topoShape1.findShape("SubShape2");
|
||||
TopoDS_Shape tds5 = topoShape1.findShape("NonExistentName"); // Invalid Name
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(fs1, 0);
|
||||
EXPECT_EQ(fs2, 1);
|
||||
EXPECT_FALSE(tds1.IsNull());
|
||||
EXPECT_TRUE(tds2.IsNull());
|
||||
EXPECT_FALSE(tds3.IsNull());
|
||||
EXPECT_FALSE(tds4.IsNull());
|
||||
EXPECT_TRUE(tds5.IsNull());
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, mapSubElementFindShapeByType)
|
||||
{
|
||||
// Arrange
|
||||
auto [cube1, cube2] = CreateTwoCubes();
|
||||
Part::TopoShape cube1TS {cube1};
|
||||
Part::TopoShape cube2TS {cube2};
|
||||
cube1TS.Tag = 1;
|
||||
cube2TS.Tag = 2;
|
||||
Part::TopoShape topoShape;
|
||||
topoShape.makeElementCompound({cube1TS, cube2TS});
|
||||
topoShape.mapSubElement(cube2TS, "Name", false);
|
||||
|
||||
// Act, Assert
|
||||
for (int i = 1; i <= 12; i++) {
|
||||
TopoDS_Shape dshape1 = topoShape.findShape(TopAbs_FACE, i);
|
||||
EXPECT_FALSE(dshape1.IsNull()) << "Face num " << i;
|
||||
}
|
||||
TopoDS_Shape dshape1 = topoShape.findShape(TopAbs_FACE, 13);
|
||||
EXPECT_TRUE(dshape1.IsNull());
|
||||
}
|
||||
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, mapSubElementFindAncestor)
|
||||
{
|
||||
// Arrange
|
||||
auto [cube1, cube2] = CreateTwoCubes();
|
||||
Part::TopoShape cube1TS {cube1};
|
||||
Part::TopoShape cube2TS {cube2};
|
||||
cube1TS.Tag = 1;
|
||||
cube2TS.Tag = 2;
|
||||
Part::TopoShape topoShape;
|
||||
topoShape.makeElementCompound({cube1TS, cube2TS});
|
||||
topoShape.mapSubElement(cube2TS, "Name", false);
|
||||
|
||||
// Act
|
||||
int fa1 = topoShape.findAncestor(cube2, TopAbs_COMPOUND);
|
||||
TopoDS_Shape tds1 = topoShape.findAncestorShape(cube1, TopAbs_COMPOUND);
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(fa1, 1);
|
||||
EXPECT_TRUE(tds1.IsEqual(topoShape.getShape()));
|
||||
}
|
||||
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, mapSubElementFindAncestors)
|
||||
{
|
||||
// Arrange
|
||||
auto [cube1, cube2] = CreateTwoCubes();
|
||||
auto [cube3, cube4] = CreateTwoCubes();
|
||||
auto tr {gp_Trsf()};
|
||||
tr.SetTranslation(gp_Vec(gp_XYZ(0, 1, 0)));
|
||||
cube3.Move(TopLoc_Location(tr));
|
||||
cube4.Move(TopLoc_Location(tr));
|
||||
Part::TopoShape cube1TS {cube1};
|
||||
Part::TopoShape cube2TS {cube2};
|
||||
Part::TopoShape cube3TS {cube3};
|
||||
Part::TopoShape cube4TS {cube4};
|
||||
cube1TS.Tag = 1;
|
||||
cube2TS.Tag = 2;
|
||||
cube3TS.Tag = 3;
|
||||
cube4TS.Tag = 4;
|
||||
Part::TopoShape topoShape, topoShape1, topoShape2;
|
||||
Part::TopoShape topoShape3, topoShape4, topoShape5, topoShape6;
|
||||
topoShape.makeElementCompound({cube1TS, cube2TS});
|
||||
topoShape1.makeElementCompound({cube3TS, cube4TS});
|
||||
topoShape2.makeElementCompound({cube1TS, cube3TS});
|
||||
topoShape3.makeElementCompound({cube2TS, cube4TS});
|
||||
topoShape4.makeElementCompound({topoShape, topoShape1});
|
||||
topoShape5.makeElementCompound({topoShape2, topoShape3});
|
||||
topoShape6.makeElementCompound({topoShape4, topoShape5});
|
||||
topoShape6.mapSubElement(cube2TS, nullptr, false);
|
||||
|
||||
// Act
|
||||
auto ancestorList = topoShape6.findAncestors(cube3, TopAbs_COMPOUND);
|
||||
auto ancestorShapeList = topoShape6.findAncestorsShapes(cube3, TopAbs_COMPOUND);
|
||||
|
||||
// FIXME: It seems very strange that both of these ancestors calls return lists of two items
|
||||
// that contain the same thing twice. What I expect is that the ancestors of cube3 would be
|
||||
// topoShape6 topoShape5, topoShape3, topoShape2, and topoShape1.
|
||||
//
|
||||
// This is a very convoluted hierarchy, and the only way I could get more than one result from
|
||||
// findAncestors. I guess it's possible that it's only intended to return a single result in
|
||||
// almost all cases; that would mean that what it returns is the shape at the top of the tree.
|
||||
// But that's exactly the shape we use to call it in the first place, so we already have it.
|
||||
//
|
||||
// Note that in the RT branch, findAncestorsShapes is called by GenericShapeMapper::init,
|
||||
// TopoShape::makEChamfer and MapperPrism
|
||||
// findAncestors is used in a dozen places.
|
||||
//
|
||||
|
||||
// Assert
|
||||
EXPECT_EQ(ancestorList.size(), 2);
|
||||
EXPECT_EQ(ancestorList.front(), 1);
|
||||
EXPECT_EQ(ancestorList.back(), 1);
|
||||
EXPECT_EQ(ancestorShapeList.size(), 2);
|
||||
EXPECT_TRUE(ancestorShapeList.front().IsEqual(topoShape6.getShape()));
|
||||
EXPECT_TRUE(ancestorShapeList.back().IsEqual(topoShape6.getShape()));
|
||||
}
|
||||
|
||||
// NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)
|
||||
|
||||
Reference in New Issue
Block a user