Merge pull request #12804 from bgbsww/bgbsww-toponamingPartFeature
Toponaming/Part: methods in part feature and dependencies for correct elementMaps
This commit is contained in:
@@ -218,6 +218,6 @@ TEST_F(FeaturePartCommonTest, testMapping)
|
||||
#ifndef FC_USE_TNP_FIX
|
||||
EXPECT_EQ(ts1.getElementMap().size(), 0);
|
||||
#else
|
||||
EXPECT_EQ(ts1.getElementMap().size(), 26); // TODO: This should be 26.
|
||||
EXPECT_EQ(ts1.getElementMap().size(), 26);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <src/App/InitApplication.h>
|
||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
#include "PartTestHelpers.h"
|
||||
#include "App/MappedElement.h"
|
||||
|
||||
using namespace Part;
|
||||
using namespace PartTestHelpers;
|
||||
@@ -54,7 +55,7 @@ TEST_F(FeaturePartTest, testGetElementName)
|
||||
#ifndef FC_USE_TNP_FIX
|
||||
EXPECT_EQ(ts.getElementMap().size(), 0);
|
||||
#else
|
||||
EXPECT_EQ(ts.getElementMap().size(), 0); // TODO: Value and code TBD
|
||||
EXPECT_EQ(ts.getElementMap().size(), 26);
|
||||
#endif
|
||||
// TBD
|
||||
}
|
||||
@@ -127,3 +128,88 @@ TEST_F(FeaturePartTest, create)
|
||||
// will have only 1 feature
|
||||
EXPECT_EQ(otherDoc->getObjects().size(), 1);
|
||||
}
|
||||
|
||||
TEST_F(FeaturePartTest, getElementHistory)
|
||||
{
|
||||
// Arrange
|
||||
const char* name = "Part__Box";
|
||||
const char* name2 = "Edge2"; // Edge, Vertex, or Face. will work here.
|
||||
// Act
|
||||
auto result = Feature::getElementHistory(_boxes[0], name2, true, false);
|
||||
Data::HistoryItem histItem = result.front();
|
||||
// Assert
|
||||
EXPECT_EQ(result.size(), 1);
|
||||
EXPECT_NE(histItem.tag, 0); // Make sure we have one. It will vary.
|
||||
EXPECT_EQ(histItem.index.getIndex(), 2);
|
||||
EXPECT_STREQ(histItem.index.getType(), "Edge");
|
||||
EXPECT_STREQ(histItem.element.toString().c_str(), name2);
|
||||
EXPECT_EQ(histItem.obj, _boxes[0]);
|
||||
}
|
||||
|
||||
TEST_F(FeaturePartTest, getRelatedElements)
|
||||
{
|
||||
// Arrange
|
||||
_common->Base.setValue(_boxes[0]);
|
||||
_common->Tool.setValue(_boxes[1]);
|
||||
// Act
|
||||
_common->execute();
|
||||
auto label1 = _common->Label.getValue();
|
||||
auto label2 = _boxes[1]->Label.getValue();
|
||||
const TopoShape& ts = _common->Shape.getShape();
|
||||
auto result = Feature::getRelatedElements(_doc->getObject(label1),
|
||||
"Edge2",
|
||||
HistoryTraceType::followTypeChange,
|
||||
true);
|
||||
auto result2 = Feature::getRelatedElements(_doc->getObject(label2),
|
||||
"Edge1",
|
||||
HistoryTraceType::followTypeChange,
|
||||
true);
|
||||
// Assert
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
EXPECT_EQ(result.size(), 1); // Found the one.
|
||||
EXPECT_EQ(result2.size(), 0); // No element map, so no related elements
|
||||
// The results are always going to vary, so we can't test for specific values:
|
||||
// EXPECT_STREQ(result.front().name.toString().c_str(),"Edge3;:M;CMN;:H38d:7,E");
|
||||
#else
|
||||
EXPECT_EQ(result.size(), 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Note that this test is pretty trivial and useless .. but the method in question is never
|
||||
// called in the codebase.
|
||||
TEST_F(FeaturePartTest, getElementFromSource)
|
||||
{
|
||||
// Arrange
|
||||
_common->Base.setValue(_boxes[0]);
|
||||
_common->Tool.setValue(_boxes[1]);
|
||||
App::DocumentObject sourceObject;
|
||||
// const char *sourceSubElement;
|
||||
// Act
|
||||
_common->execute();
|
||||
auto label1 = _common->Label.getValue();
|
||||
auto label2 = _boxes[1]->Label.getValue();
|
||||
const TopoShape& ts = _common->Shape.getShape();
|
||||
auto element = Feature::getElementFromSource(_common,
|
||||
"Part__Box001", // "Edge1",
|
||||
_boxes[0],
|
||||
"Face1", // "Edge1",
|
||||
false);
|
||||
// Assert
|
||||
EXPECT_EQ(element.size(), 0);
|
||||
}
|
||||
|
||||
TEST_F(FeaturePartTest, getSubObject)
|
||||
{
|
||||
// Arrange
|
||||
_common->Base.setValue(_boxes[0]);
|
||||
_common->Tool.setValue(_boxes[1]);
|
||||
App::DocumentObject sourceObject;
|
||||
const char* sourceSubElement;
|
||||
PyObject* pyObj;
|
||||
// Act
|
||||
_common->execute();
|
||||
auto result = _boxes[1]->getSubObject("Face5", &pyObj, nullptr, false, 10);
|
||||
// Assert
|
||||
ASSERT_NE(result, nullptr);
|
||||
EXPECT_STREQ(result->getNameInDocument(), "Part__Box001");
|
||||
}
|
||||
|
||||
@@ -2028,17 +2028,16 @@ TEST_F(TopoShapeExpansionTest, makeElementSlice)
|
||||
{
|
||||
"Face1;SLC;:H1:4,F;:G2;SLC;:H1:8,V;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
"Face1;SLC;:H1:4,F;:G3;SLC;:H1:8,V;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
// TODO: Prove that this difference is not a problem.
|
||||
// The next element varies according to platform / OCCT version and thus can't be
|
||||
// absolutely tested.
|
||||
// "Face1;SLC;:H1:4,F;:G4;SLC;:H1:8,V;D1;:H1:3,V;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
// MacOSX difference:
|
||||
// "Face1;SLC;:H1:4,F;:G4;SLC;:H1:8,V;D25fd;:H1:6,V;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
// "Face1;SLC;:H1:4,F;:G4;SLC;:H1:8,V;D1;:H1:3,V;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
"Face1;SLC;:H1:4,F;:G4;SLC;:H1:8,V;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
"Face1;SLC;:H1:4,F;:G5;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
|
||||
"Face1;SLC;:H1:4,F;:G6;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
|
||||
"Face1;SLC;:H1:4,F;:G7;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
|
||||
"Face1;SLC;:H1:4,F;:G8;SLC;:H1:8,E;SLC;:H1:4,E;MAK;:H1:4,E",
|
||||
})); // Changed with PR#12471. Probably will change again after importing
|
||||
// other TopoNaming logics
|
||||
})); // Changed with PR#12471. Probably will change again after
|
||||
// importing other TopoNaming logics
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, makeElementSlices)
|
||||
|
||||
Reference in New Issue
Block a user