Part/Toponaming: Tests for flushElementMap and resetElementMap (#12471)
* Part/Toponaming: tests for flushElementMap and resetElementMap * Added test for resetElementMap() * Added test for flushElementMap() * restored ComplexGeoData::resetElementMap to RT fork * modified TopoShape::resetElementMap to match the restored signature of ComplexGeoData::resetElementMap * added checks in TopoShape::makeShapeWithElementMap to avoid segfaults * added check in TopoShape::setElementComboName to avoid segfaults * restored testFindSubShapesForSourceWithTypeAndIndex * modified test saveDocFileWithNoElementMap to match the restored signature of ComplexGeoData::resetElementMap * Part/Toponaming: tests for flushElementMap and resetElementMap * Removed comments in ComplexGeoData::resetElementMap() * Changed TopoShape::resetElementMap():: from virtual to override * Removed comment in TopoShape::resetElementMap() * Added comments about differences between main and RT fork * Removed comment in test saveDocFileWithNoElementMap * Updated expected test result in makeElementCompoundTwoShapesGeneratesMap * Updated expected test result in resetElementMapTest * Fixed typo in test flushElementMapTest * Part/Toponaming: tests for flushElementMap and resetElementMap * updated expected tests results after previous methods modifications --------- Signed-off-by: CalligaroV <vincenzo.calligaro@gmail.com>
This commit is contained in:
committed by
GitHub
parent
cbc39e989f
commit
0e7aa5f7bc
@@ -270,12 +270,8 @@ public:
|
||||
*
|
||||
* @return Returns the existing element map.
|
||||
*/
|
||||
virtual ElementMapPtr resetElementMap(ElementMapPtr elementMap = ElementMapPtr(),
|
||||
ElementMapResetPolicy forceEmpty = ForceEmptyMap)
|
||||
virtual ElementMapPtr resetElementMap(ElementMapPtr elementMap = ElementMapPtr())
|
||||
{
|
||||
if (!elementMap && forceEmpty == ForceEmptyMap) {
|
||||
elementMap = std::make_shared<Data::ElementMap>();
|
||||
}
|
||||
_elementMap.swap(elementMap);
|
||||
return elementMap;
|
||||
}
|
||||
|
||||
@@ -562,6 +562,13 @@ MappedName ElementMap::setElementName(const IndexedName& element, const MappedNa
|
||||
}
|
||||
}
|
||||
|
||||
// Originally in ComplexGeoData::setElementName
|
||||
// LinkStable/src/App/ComplexGeoData.cpp#L1631
|
||||
// No longer possible after map separated in ElementMap.cpp
|
||||
|
||||
// if(!_ElementMap)
|
||||
// resetElementMap(std::make_shared<ElementMap>());
|
||||
|
||||
ElementIDRefs _sid;
|
||||
if (!sid) {
|
||||
sid = &_sid;
|
||||
|
||||
@@ -1247,8 +1247,8 @@ public:
|
||||
|
||||
void flushElementMap() const override;
|
||||
|
||||
virtual Data::ElementMapPtr resetElementMap(
|
||||
Data::ElementMapPtr elementMap=Data::ElementMapPtr());
|
||||
Data::ElementMapPtr resetElementMap(
|
||||
Data::ElementMapPtr elementMap=Data::ElementMapPtr()) override;
|
||||
|
||||
/** Helper class to return the generated and modified shape given an input shape
|
||||
*
|
||||
|
||||
@@ -766,9 +766,15 @@ void TopoShape::mapSubElementTypeForShape(const TopoShape& other,
|
||||
}
|
||||
}
|
||||
char elementType {shapeName(type)[0]};
|
||||
|
||||
// Originally in ComplexGeoData::setElementName
|
||||
// LinkStable/src/App/ComplexGeoData.cpp#L1631
|
||||
// No longer possible after map separated in ElementMap.cpp
|
||||
|
||||
if (!elementMap()) {
|
||||
resetElementMap(); // TODO: Should never happen, but does while code is in transit
|
||||
resetElementMap(std::make_shared<Data::ElementMap>());
|
||||
}
|
||||
|
||||
std::ostringstream ss;
|
||||
elementMap()->encodeElementName(elementType, name, ss, &sids, Tag, op, other.Tag);
|
||||
elementMap()->setElementName(element, name, Tag, &sids);
|
||||
@@ -1503,6 +1509,15 @@ TopoShape& TopoShape::makeShapeWithElementMap(const TopoDS_Shape& shape,
|
||||
}
|
||||
}
|
||||
Data::MappedName other_name = other_key.name;
|
||||
|
||||
// Originally in ComplexGeoData::setElementName
|
||||
// LinkStable/src/App/ComplexGeoData.cpp#L1631
|
||||
// No longer possible after map separated in ElementMap.cpp
|
||||
|
||||
if (!elementMap()) {
|
||||
resetElementMap(std::make_shared<Data::ElementMap>());
|
||||
}
|
||||
|
||||
elementMap()->encodeElementName(*other_info.shapetype,
|
||||
other_name,
|
||||
ss2,
|
||||
@@ -1555,6 +1570,15 @@ TopoShape& TopoShape::makeShapeWithElementMap(const TopoDS_Shape& shape,
|
||||
ss << abs(first_info.index);
|
||||
}
|
||||
ss << postfix;
|
||||
|
||||
// Originally in ComplexGeoData::setElementName
|
||||
// LinkStable/src/App/ComplexGeoData.cpp#L1631
|
||||
// No longer possible after map separated in ElementMap.cpp
|
||||
|
||||
if (!elementMap()) {
|
||||
resetElementMap(std::make_shared<Data::ElementMap>());
|
||||
}
|
||||
|
||||
elementMap()
|
||||
->encodeElementName(element[0], first_name, ss, &sids, Tag, op, first_key.tag);
|
||||
elementMap()->setElementName(element, first_name, Tag, &sids);
|
||||
@@ -1645,6 +1669,15 @@ TopoShape& TopoShape::makeShapeWithElementMap(const TopoDS_Shape& shape,
|
||||
if (nameInfo.index > 1) {
|
||||
ss << nameInfo.index;
|
||||
}
|
||||
|
||||
// Originally in ComplexGeoData::setElementName
|
||||
// LinkStable/src/App/ComplexGeoData.cpp#L1631
|
||||
// No longer possible after map separated in ElementMap.cpp
|
||||
|
||||
if (!elementMap()) {
|
||||
resetElementMap(std::make_shared<Data::ElementMap>());
|
||||
}
|
||||
|
||||
elementMap()->encodeElementName(indexedName[0], newName, ss, &sids, Tag, op);
|
||||
elementMap()->setElementName(indexedName, newName, Tag, &sids);
|
||||
}
|
||||
@@ -1742,6 +1775,15 @@ TopoShape& TopoShape::makeShapeWithElementMap(const TopoDS_Shape& shape,
|
||||
ss << lowerPostfix() << sids.back().toString();
|
||||
}
|
||||
}
|
||||
|
||||
// Originally in ComplexGeoData::setElementName
|
||||
// LinkStable/src/App/ComplexGeoData.cpp#L1631
|
||||
// No longer possible after map separated in ElementMap.cpp
|
||||
|
||||
if (!elementMap()) {
|
||||
resetElementMap(std::make_shared<Data::ElementMap>());
|
||||
}
|
||||
|
||||
elementMap()->encodeElementName(element[0], newName, ss, &sids, Tag, op);
|
||||
elementMap()->setElementName(element, newName, Tag, &sids);
|
||||
}
|
||||
@@ -4177,6 +4219,15 @@ Data::MappedName TopoShape::setElementComboName(const Data::IndexedName& element
|
||||
ss << marker << sids.back().toString();
|
||||
}
|
||||
}
|
||||
|
||||
// Originally in ComplexGeoData::setElementName
|
||||
// LinkStable/src/App/ComplexGeoData.cpp#L1631
|
||||
// No longer possible after map separated in ElementMap.cpp
|
||||
|
||||
if (!elementMap()) {
|
||||
resetElementMap(std::make_shared<Data::ElementMap>());
|
||||
}
|
||||
|
||||
elementMap()->encodeElementName(element[0], newName, ss, &sids, Tag, op);
|
||||
return elementMap()->setElementName(element, newName, Tag, &sids);
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ TEST_F(ComplexGeoDataTest, saveDocFileWithNoElementMap)
|
||||
{
|
||||
// Arrange
|
||||
Base::StringWriter writer;
|
||||
cgd().resetElementMap(nullptr, Data::AllowNoMap); // Force undefined map
|
||||
cgd().resetElementMap(nullptr); // Force undefined map
|
||||
|
||||
// Act
|
||||
cgd().SaveDocFile(writer);
|
||||
|
||||
@@ -142,7 +142,7 @@ TEST_F(TopoShapeExpansionTest, makeElementCompoundTwoShapesGeneratesMap)
|
||||
EXPECT_FLOAT_EQ(getLength(topoShape.getShape()), 2);
|
||||
EXPECT_TRUE(PartTestHelpers::boxesMatch(bb, Base::BoundBox3d(0, 0, 0, 2, 0, 0)));
|
||||
// Assert map is correct
|
||||
EXPECT_TRUE(topoShape.getMappedChildElements().empty());
|
||||
EXPECT_FALSE(topoShape.getMappedChildElements().empty());
|
||||
EXPECT_EQ(elements.size(), 6);
|
||||
EXPECT_EQ(elements[IndexedName("Edge", 1)], MappedName("Edge1;:H2,E"));
|
||||
EXPECT_EQ(elements[IndexedName("Edge", 2)], MappedName("Edge1;:H3,E"));
|
||||
@@ -161,7 +161,10 @@ TEST_F(TopoShapeExpansionTest, makeElementCompoundTwoCubes)
|
||||
auto elementMap = cube1TS.getElementMap();
|
||||
Base::BoundBox3d bb = topoShape.getBoundBox();
|
||||
// Assert shape is correct
|
||||
EXPECT_EQ(6, topoShape.getMappedChildElements().size());
|
||||
EXPECT_EQ(22,
|
||||
topoShape.getMappedChildElements()
|
||||
.size()); // Changed with PR#12471. Probably will change again after importing
|
||||
// other TopoNaming logics
|
||||
EXPECT_FLOAT_EQ(getVolume(topoShape.getShape()), 2);
|
||||
EXPECT_TRUE(PartTestHelpers::boxesMatch(bb, Base::BoundBox3d(0, 0, 0, 2, 1, 1)));
|
||||
// Assert map is correct
|
||||
@@ -171,28 +174,29 @@ TEST_F(TopoShapeExpansionTest, makeElementCompoundTwoCubes)
|
||||
// 6 Faces
|
||||
// ----------
|
||||
// 26 subshapes each
|
||||
EXPECT_TRUE(
|
||||
allElementsMatch(topoShape,
|
||||
{
|
||||
"Vertex1;:H1,V;:H7,V", "Vertex2;:H1,V;:H7,V", "Vertex3;:H1,V;:H7,V",
|
||||
"Vertex4;:H1,V;:H7,V", "Vertex1;:H2,V;:H7,V", "Vertex2;:H2,V;:H7,V",
|
||||
"Vertex3;:H2,V;:H7,V", "Vertex4;:H2,V;:H7,V", "Face1;:H8,F;:He,F",
|
||||
"Face1;:H9,F;:He,F", "Face1;:Ha,F;:He,F", "Face1;:Hb,F;:He,F",
|
||||
"Face1;:Hc,F;:He,F", "Face1;:Hd,F;:He,F", "Edge1;:H8,E;:He,E",
|
||||
"Edge2;:H8,E;:He,E", "Edge3;:H8,E;:He,E", "Edge4;:H8,E;:He,E",
|
||||
"Edge1;:H9,E;:He,E", "Edge2;:H9,E;:He,E", "Edge3;:H9,E;:He,E",
|
||||
"Edge4;:H9,E;:He,E", "Edge1;:Ha,E;:He,E", "Edge2;:Ha,E;:He,E",
|
||||
"Edge3;:Ha,E;:He,E", "Edge4;:Ha,E;:He,E", "Vertex1;:H8,V;:He,V",
|
||||
"Vertex2;:H8,V;:He,V", "Vertex3;:H8,V;:He,V", "Vertex4;:H8,V;:He,V",
|
||||
"Vertex1;:H9,V;:He,V", "Vertex2;:H9,V;:He,V", "Vertex3;:H9,V;:He,V",
|
||||
"Vertex4;:H9,V;:He,V", "Edge1;:H1,E;:H7,E", "Edge2;:H1,E;:H7,E",
|
||||
"Edge3;:H1,E;:H7,E", "Edge4;:H1,E;:H7,E", "Edge1;:H2,E;:H7,E",
|
||||
"Edge2;:H2,E;:H7,E", "Edge3;:H2,E;:H7,E", "Edge4;:H2,E;:H7,E",
|
||||
"Edge1;:H3,E;:H7,E", "Edge2;:H3,E;:H7,E", "Edge3;:H3,E;:H7,E",
|
||||
"Edge4;:H3,E;:H7,E", "Face1;:H1,F;:H7,F", "Face1;:H2,F;:H7,F",
|
||||
"Face1;:H3,F;:H7,F", "Face1;:H4,F;:H7,F", "Face1;:H5,F;:H7,F",
|
||||
"Face1;:H6,F;:H7,F",
|
||||
}));
|
||||
EXPECT_TRUE(allElementsMatch(
|
||||
topoShape,
|
||||
{
|
||||
"Vertex1;:H1,V;:H7:6,V", "Vertex2;:H1,V;:H7:6,V", "Vertex3;:H1,V;:H7:6,V",
|
||||
"Vertex4;:H1,V;:H7:6,V", "Vertex1;:H2,V;:H7:6,V", "Vertex2;:H2,V;:H7:6,V",
|
||||
"Vertex3;:H2,V;:H7:6,V", "Vertex4;:H2,V;:H7:6,V", "Face1;:H8,F;:He:6,F",
|
||||
"Face1;:H9,F;:He:6,F", "Face1;:Ha,F;:He:6,F", "Face1;:Hb,F;:He:6,F",
|
||||
"Face1;:Hc,F;:He:6,F", "Face1;:Hd,F;:He:6,F", "Edge1;:H8,E;:He:6,E",
|
||||
"Edge2;:H8,E;:He:6,E", "Edge3;:H8,E;:He:6,E", "Edge4;:H8,E;:He:6,E",
|
||||
"Edge1;:H9,E;:He:6,E", "Edge2;:H9,E;:He:6,E", "Edge3;:H9,E;:He:6,E",
|
||||
"Edge4;:H9,E;:He:6,E", "Edge1;:Ha,E;:He:6,E", "Edge2;:Ha,E;:He:6,E",
|
||||
"Edge3;:Ha,E;:He:6,E", "Edge4;:Ha,E;:He:6,E", "Vertex1;:H8,V;:He:6,V",
|
||||
"Vertex2;:H8,V;:He:6,V", "Vertex3;:H8,V;:He:6,V", "Vertex4;:H8,V;:He:6,V",
|
||||
"Vertex1;:H9,V;:He:6,V", "Vertex2;:H9,V;:He:6,V", "Vertex3;:H9,V;:He:6,V",
|
||||
"Vertex4;:H9,V;:He:6,V", "Edge1;:H1,E;:H7:6,E", "Edge2;:H1,E;:H7:6,E",
|
||||
"Edge3;:H1,E;:H7:6,E", "Edge4;:H1,E;:H7:6,E", "Edge1;:H2,E;:H7:6,E",
|
||||
"Edge2;:H2,E;:H7:6,E", "Edge3;:H2,E;:H7:6,E", "Edge4;:H2,E;:H7:6,E",
|
||||
"Edge1;:H3,E;:H7:6,E", "Edge2;:H3,E;:H7:6,E", "Edge3;:H3,E;:H7:6,E",
|
||||
"Edge4;:H3,E;:H7:6,E", "Face1;:H1,F;:H7:6,F", "Face1;:H2,F;:H7:6,F",
|
||||
"Face1;:H3,F;:H7:6,F", "Face1;:H4,F;:H7:6,F", "Face1;:H5,F;:H7:6,F",
|
||||
"Face1;:H6,F;:H7:6,F",
|
||||
})); // Changed with PR#12471. Probably will change again after importing
|
||||
// other TopoNaming logics
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, MapperMakerModified)
|
||||
@@ -390,6 +394,120 @@ TEST_F(TopoShapeExpansionTest, MapperHistoryGenerated)
|
||||
EXPECT_EQ(fuse2MprHst.generated(edge3).size(), 1); // fuse2 has a new vertex generated by edge3
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, resetElementMapTest)
|
||||
{
|
||||
// Arrange
|
||||
// Creating various TopoShapes to check different conditions
|
||||
|
||||
// A TopoShape without a map
|
||||
auto shapeWithoutMap {
|
||||
TopoShape(BRepBuilderAPI_MakeEdge(gp_Pnt(-1.0, 0.0, 0.0), gp_Pnt(1.0, 0.0, 0.0)).Edge(),
|
||||
1)};
|
||||
|
||||
// A TopoShape without a map that will be replaced by another map
|
||||
auto shapeWithoutMapAfterReset {TopoShape(shapeWithoutMap)};
|
||||
|
||||
// A TopoShape with a map
|
||||
auto shapeWithMap {
|
||||
TopoShape(BRepBuilderAPI_MakeEdge(gp_Pnt(0.0, -1.0, 0.0), gp_Pnt(0.0, 1.0, 0.0)).Edge(),
|
||||
3)};
|
||||
shapeWithMap.makeShapeWithElementMap(shapeWithMap.getShape(),
|
||||
TopoShape::Mapper(),
|
||||
{shapeWithMap});
|
||||
|
||||
// A TopoShape with a map that will be replaced by another map
|
||||
auto shapeWithMapAfterReset {TopoShape(shapeWithMap)};
|
||||
shapeWithMapAfterReset.makeShapeWithElementMap(shapeWithMapAfterReset.getShape(),
|
||||
TopoShape::Mapper(),
|
||||
{shapeWithMapAfterReset});
|
||||
|
||||
// A TopoShape with a map that will be replaced by an empty map
|
||||
auto shapeWithMapAfterEmptyReset {TopoShape(shapeWithMap)};
|
||||
shapeWithMapAfterEmptyReset.makeShapeWithElementMap(shapeWithMapAfterEmptyReset.getShape(),
|
||||
TopoShape::Mapper(),
|
||||
{shapeWithMapAfterEmptyReset});
|
||||
|
||||
// A new map
|
||||
auto newElementMapPtr {std::make_shared<Data::ElementMap>()};
|
||||
newElementMapPtr->setElementName(IndexedName("Edge", 2),
|
||||
MappedName("Edge2;:H,E"),
|
||||
3,
|
||||
nullptr,
|
||||
true);
|
||||
|
||||
// Act
|
||||
shapeWithoutMapAfterReset.resetElementMap(newElementMapPtr);
|
||||
shapeWithMapAfterReset.resetElementMap(newElementMapPtr);
|
||||
shapeWithMapAfterEmptyReset.resetElementMap(nullptr);
|
||||
|
||||
// Assert
|
||||
// Check that the original maps haven't been modified
|
||||
EXPECT_EQ(shapeWithoutMap.getElementMapSize(false), 0);
|
||||
EXPECT_EQ(shapeWithMap.getElementMapSize(false), 3);
|
||||
|
||||
// Check that the two shapes have the same map
|
||||
EXPECT_EQ(shapeWithoutMapAfterReset.getElementMap(), shapeWithMapAfterReset.getElementMap());
|
||||
// Check that inside the shape's map there's the element of the new map (same result if
|
||||
// checking with the other shape)
|
||||
EXPECT_NE(shapeWithoutMapAfterReset.getElementMap()[0].name.find("Edge2"), -1);
|
||||
// Check that there aren't leftovers from the previous map
|
||||
EXPECT_EQ(shapeWithMapAfterReset.getElementMap()[0].name.find("Edge1"), -1);
|
||||
|
||||
// Check that the map has been emptied
|
||||
EXPECT_EQ(shapeWithMapAfterEmptyReset.getElementMapSize(false), 0);
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, flushElementMapTest)
|
||||
{
|
||||
// Arrange
|
||||
// Creating various TopoShapes to check different conditions
|
||||
|
||||
// A TopoShape with a map that won't be flushed
|
||||
auto shapeWithMapNotFlushed {
|
||||
TopoShape(BRepBuilderAPI_MakeEdge(gp_Pnt(-1.0, 0.0, 0.0), gp_Pnt(1.0, 0.0, 0.0)).Edge(),
|
||||
1)};
|
||||
shapeWithMapNotFlushed.makeShapeWithElementMap(shapeWithMapNotFlushed.getShape(),
|
||||
TopoShape::Mapper(),
|
||||
{shapeWithMapNotFlushed});
|
||||
|
||||
// A TopoShape with a map that will be reset and then flushed
|
||||
auto shapeWithMapFlushed {
|
||||
TopoShape(BRepBuilderAPI_MakeEdge(gp_Pnt(0.0, -1.0, 0.0), gp_Pnt(0.0, 1.0, 0.0)).Edge(),
|
||||
2)};
|
||||
shapeWithMapFlushed.makeShapeWithElementMap(shapeWithMapFlushed.getShape(),
|
||||
TopoShape::Mapper(),
|
||||
{shapeWithMapFlushed});
|
||||
|
||||
// A child TopoShape that will be flushed
|
||||
auto childshapeWithMapFlushed {shapeWithMapFlushed.getSubTopoShape(TopAbs_VERTEX, 1)};
|
||||
childshapeWithMapFlushed.Tag = 3;
|
||||
|
||||
// A new map
|
||||
auto newElementMapPtr {std::make_shared<Data::ElementMap>()};
|
||||
newElementMapPtr->setElementName(IndexedName("Edge", 2),
|
||||
MappedName("Edge2;:H,E"),
|
||||
3,
|
||||
nullptr,
|
||||
true);
|
||||
|
||||
// Setting a different element map and then resetting otherwise flush won't have effect
|
||||
shapeWithMapFlushed.resetElementMap(newElementMapPtr);
|
||||
shapeWithMapFlushed.resetElementMap(nullptr);
|
||||
|
||||
// Act
|
||||
shapeWithMapNotFlushed.flushElementMap();
|
||||
shapeWithMapFlushed.flushElementMap();
|
||||
childshapeWithMapFlushed.flushElementMap();
|
||||
|
||||
// Assert
|
||||
// Check that the original map haven't been modified
|
||||
EXPECT_EQ(shapeWithMapNotFlushed.getElementMapSize(false), 3);
|
||||
|
||||
// Check that the two maps have been flushed
|
||||
EXPECT_NE(shapeWithMapFlushed.getElementMap()[0].name.find("Edge2"), -1);
|
||||
EXPECT_NE(childshapeWithMapFlushed.getElementMap()[0].name.find("Vertex1"), -1);
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, makeElementWiresCombinesAdjacent)
|
||||
{
|
||||
// Arrange
|
||||
@@ -426,16 +544,19 @@ TEST_F(TopoShapeExpansionTest, makeElementWiresCombinesWires)
|
||||
EXPECT_TRUE(PartTestHelpers::boxesMatch(bb, Base::BoundBox3d(0, 0, 0, 3, 2, 0)));
|
||||
// Assert map is correct
|
||||
EXPECT_TRUE(allElementsMatch(topoShape,
|
||||
{"Edge1;WIR",
|
||||
"Edge1;WIR;D1",
|
||||
"Edge1;WIR;D2",
|
||||
"Edge1;WIR;D1;D1",
|
||||
"Vertex1;WIR",
|
||||
"Vertex2;WIR",
|
||||
"Vertex2;WIR;D1",
|
||||
"Vertex1;WIR;D1",
|
||||
"Vertex2;WIR;D2",
|
||||
"Vertex2;WIR;D1;D1"}));
|
||||
{
|
||||
"Edge1;:C1;:H4:4,E;WIR;:H4:4,E;WIR;:H4:4,E",
|
||||
"Edge1;:H1,E;WIR;:H1:4,E;WIR;:H1:4,E",
|
||||
"Edge1;:H2,E;WIR;:H2:4,E;WIR;:H2:4,E",
|
||||
"Edge1;:H4,E;WIR;:H4:4,E;WIR;:H4:4,E",
|
||||
"Vertex1;:H1,V;WIR;:H1:4,V;WIR;:H1:4,V",
|
||||
"Vertex1;:H4,V;WIR;:H4:4,V;WIR;:H4:4,V",
|
||||
"Vertex2;:C1;:H4:4,V;WIR;:H4:4,V;WIR;:H4:4,V",
|
||||
"Vertex2;:H1,V;WIR;:H1:4,V;WIR;:H1:4,V",
|
||||
"Vertex2;:H2,V;WIR;:H2:4,V;WIR;:H2:4,V",
|
||||
"Vertex2;:H4,V;WIR;:H4:4,V;WIR;:H4:4,V",
|
||||
})); // Changed with PR#12471. Probably will change again after
|
||||
// importing other TopoNaming logics
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, makeElementFaceNull)
|
||||
@@ -659,7 +780,10 @@ TEST_F(TopoShapeExpansionTest, setElementComboNameCompound)
|
||||
OpCodes::Common,
|
||||
op);
|
||||
// ASSERT
|
||||
EXPECT_STREQ(result.toString().c_str(), "Edge1;CMN(Face7|Face8);Copy");
|
||||
EXPECT_STREQ(
|
||||
result.toString().c_str(),
|
||||
"Edge1;:H,E;CMN(Face7|Face8);Copy"); // Changed with PR#12471. Probably will change again
|
||||
// after importing other TopoNaming logics
|
||||
// The detailed forms of names are covered in encodeElementName tests
|
||||
}
|
||||
|
||||
@@ -1864,19 +1988,19 @@ TEST_F(TopoShapeExpansionTest, makeElementSlice)
|
||||
EXPECT_EQ(TopAbs_ShapeEnum::TopAbs_WIRE, result.getShape().ShapeType());
|
||||
// Assert that we're creating a correct element map
|
||||
EXPECT_TRUE(result.getMappedChildElements().empty());
|
||||
EXPECT_TRUE(elementsMatch(result,
|
||||
{
|
||||
"Edge1;SLC;D1;MAK",
|
||||
"Edge1;SLC;D2;MAK",
|
||||
"Edge1;SLC;D3;MAK",
|
||||
"Edge1;SLC;MAK",
|
||||
"Vertex1;SLC;D1;MAK",
|
||||
"Vertex1;SLC;D2;MAK",
|
||||
"Vertex1;SLC;MAK",
|
||||
"Vertex2;SLC;D1;MAK",
|
||||
"Vertex2;SLC;D2;MAK",
|
||||
"Vertex2;SLC;MAK",
|
||||
}));
|
||||
EXPECT_TRUE(
|
||||
elementsMatch(result,
|
||||
{
|
||||
"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",
|
||||
"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
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, makeElementSlices)
|
||||
@@ -1900,31 +2024,40 @@ TEST_F(TopoShapeExpansionTest, makeElementSlices)
|
||||
EXPECT_EQ(TopAbs_ShapeEnum::TopAbs_WIRE, subTopoShapes[2].getShape().ShapeType());
|
||||
// Assert that we're creating a correct element map
|
||||
EXPECT_TRUE(result.getMappedChildElements().empty());
|
||||
EXPECT_TRUE(elementsMatch(result, {"Edge1;SLC;:H1:4,E;D1;:H1:3,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC;:H1:4,E;D2;:H1:3,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC;:H1:4,E;D3;:H1:3,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC;:H1:4,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC_2;:H1:6,E;D1;:H1:3,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC_2;:H1:6,E;D2;:H1:3,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC_2;:H1:6,E;D3;:H1:3,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC_2;:H1:6,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC_3;:H1:6,E;D1;:H1:3,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC_3;:H1:6,E;D2;:H1:3,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC_3;:H1:6,E;D3;:H1:3,E;MAK;:H1:4,E",
|
||||
"Edge1;SLC_3;:H1:6,E;MAK;:H1:4,E",
|
||||
"Vertex1;SLC;:H1:4,V;D2;:H1:3,V;MAK;:H1:4,V",
|
||||
"Vertex1;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
"Vertex1;SLC_2;:H1:6,V;D2;:H1:3,V;MAK;:H1:4,V",
|
||||
"Vertex1;SLC_2;:H1:6,V;MAK;:H1:4,V",
|
||||
"Vertex1;SLC_3;:H1:6,V;D2;:H1:3,V;MAK;:H1:4,V",
|
||||
"Vertex1;SLC_3;:H1:6,V;MAK;:H1:4,V",
|
||||
"Vertex2;SLC;:H1:4,V;D1;:H1:3,V;MAK;:H1:4,V",
|
||||
"Vertex2;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
"Vertex2;SLC_2;:H1:6,V;D1;:H1:3,V;MAK;:H1:4,V",
|
||||
"Vertex2;SLC_2;:H1:6,V;MAK;:H1:4,V",
|
||||
"Vertex2;SLC_3;:H1:6,V;D1;:H1:3,V;MAK;:H1:4,V",
|
||||
"Vertex2;SLC_3;:H1:6,V;MAK;:H1:4,V"}));
|
||||
EXPECT_TRUE(subTopoShapes[0].getElementMap().empty());
|
||||
EXPECT_TRUE(elementsMatch(
|
||||
result,
|
||||
{
|
||||
"Edge10;:G(Face1;SLC;:H1:4,F;K-2;:H1:4,F);SLC;:H1:26,V;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
"Edge10;:G(Face1;SLC_2;:H2:6,F;K-2;:H2:4,F);SLC_2;:H1:2a,V;SLC_2;:H1:6,V;MAK;:H1:4,V",
|
||||
"Edge10;:G(Face1;SLC_3;:H3:6,F;K-2;:H3:4,F);SLC_3;:H1:2a,V;SLC_3;:H1:6,V;MAK;:H1:4,V",
|
||||
"Edge11;:G(Face1;SLC;:H1:4,F;K-3;:H1:4,F);SLC;:H1:26,V;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
"Edge11;:G(Face1;SLC_2;:H2:6,F;K-3;:H2:4,F);SLC_2;:H1:2a,V;SLC_2;:H1:6,V;MAK;:H1:4,V",
|
||||
"Edge11;:G(Face1;SLC_3;:H3:6,F;K-3;:H3:4,F);SLC_3;:H1:2a,V;SLC_3;:H1:6,V;MAK;:H1:4,V",
|
||||
"Edge12;:G(Face1;SLC;:H1:4,F;K-4;:H1:4,F);SLC;:H1:26,V;D1;:H1:3,V;SLC;:H1:4,V;MAK;:H1:"
|
||||
"4,V",
|
||||
"Edge12;:G(Face1;SLC;:H1:4,F;K-4;:H1:4,F);SLC;:H1:26,V;SLC;:H1:4,V;MAK;:H1:4,V",
|
||||
"Edge12;:G(Face1;SLC_2;:H2:6,F;K-4;:H2:4,F);SLC_2;:H1:2a,V;D1;:H1:3,V;SLC_2;:H1:6,V;"
|
||||
"MAK;:H1:4,V",
|
||||
"Edge12;:G(Face1;SLC_2;:H2:6,F;K-4;:H2:4,F);SLC_2;:H1:2a,V;SLC_2;:H1:6,V;MAK;:H1:4,V",
|
||||
"Edge12;:G(Face1;SLC_3;:H3:6,F;K-4;:H3:4,F);SLC_3;:H1:2a,V;D1;:H1:3,V;SLC_3;:H1:6,V;"
|
||||
"MAK;:H1:4,V",
|
||||
"Edge12;:G(Face1;SLC_3;:H3:6,F;K-4;:H3:4,F);SLC_3;:H1:2a,V;SLC_3;:H1:6,V;MAK;:H1:4,V",
|
||||
"Face1;SLC;:H1:4,F;:G5(Face3;K-1;:H1:4,F);SLC;:H1:1b,E;SLC;:H1:4,E;MAK;:H1:4,E",
|
||||
"Face1;SLC;:H1:4,F;:G6(Face4;K-1;:H1:4,F);SLC;:H1:1b,E;SLC;:H1:4,E;MAK;:H1:4,E",
|
||||
"Face1;SLC;:H1:4,F;:G7(Face5;K-1;:H1:4,F);SLC;:H1:1b,E;SLC;:H1:4,E;MAK;:H1:4,E",
|
||||
"Face1;SLC;:H1:4,F;:G8(Face6;K-1;:H1:4,F);SLC;:H1:1b,E;SLC;:H1:4,E;MAK;:H1:4,E",
|
||||
"Face3;:G(Face1;SLC_2;:H2:6,F;K-5;:H2:4,F);SLC_2;:H1:2a,E;SLC_2;:H1:6,E;MAK;:H1:4,E",
|
||||
"Face3;:G(Face1;SLC_3;:H3:6,F;K-5;:H3:4,F);SLC_3;:H1:2a,E;SLC_3;:H1:6,E;MAK;:H1:4,E",
|
||||
"Face4;:G(Face1;SLC_2;:H2:6,F;K-6;:H2:4,F);SLC_2;:H1:2a,E;SLC_2;:H1:6,E;MAK;:H1:4,E",
|
||||
"Face4;:G(Face1;SLC_3;:H3:6,F;K-6;:H3:4,F);SLC_3;:H1:2a,E;SLC_3;:H1:6,E;MAK;:H1:4,E",
|
||||
"Face5;:G(Face1;SLC_2;:H2:6,F;K-7;:H2:4,F);SLC_2;:H1:2a,E;SLC_2;:H1:6,E;MAK;:H1:4,E",
|
||||
"Face5;:G(Face1;SLC_3;:H3:6,F;K-7;:H3:4,F);SLC_3;:H1:2a,E;SLC_3;:H1:6,E;MAK;:H1:4,E",
|
||||
"Face6;:G(Face1;SLC_2;:H2:6,F;K-8;:H2:4,F);SLC_2;:H1:2a,E;SLC_2;:H1:6,E;MAK;:H1:4,E",
|
||||
"Face6;:G(Face1;SLC_3;:H3:6,F;K-8;:H3:4,F);SLC_3;:H1:2a,E;SLC_3;:H1:6,E;MAK;:H1:4,E",
|
||||
}));
|
||||
EXPECT_FALSE(
|
||||
subTopoShapes[0].getElementMap().empty()); // Changed with PR#12471. Probably will change
|
||||
// again after importing other TopoNaming logics
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, makeElementMirror)
|
||||
@@ -2077,7 +2210,10 @@ TEST_F(TopoShapeExpansionTest, makeElementSolid)
|
||||
// Assert elementMap is correct
|
||||
EXPECT_EQ(elements.size(), 52);
|
||||
EXPECT_EQ(elements.count(IndexedName("Face", 1)), 1);
|
||||
EXPECT_EQ(elements[IndexedName("Face", 1)], MappedName("Face1;SLD;:H1:4,F"));
|
||||
EXPECT_EQ(
|
||||
elements[IndexedName("Face", 1)],
|
||||
MappedName("Face1;:H,F;SLD;:H1:4,F")); // Changed with PR#12471. Probably will change again
|
||||
// after importing other TopoNaming logics
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeExpansionTest, makeElementRevolve)
|
||||
|
||||
@@ -71,7 +71,8 @@ TEST_F(TopoShapeMakeShapeTests, shapeVertex)
|
||||
// Act
|
||||
TopoShape& result = topoShape.makeElementShape(vertexMaker, topoShape);
|
||||
// Assert
|
||||
EXPECT_EQ(result.getElementMap().size(), 0);
|
||||
EXPECT_EQ(result.getElementMap().size(), 1); // Changed with PR#12471. Probably will change
|
||||
// again after importing other TopoNaming logics
|
||||
EXPECT_EQ(result.countSubElements("Vertex"), 1);
|
||||
EXPECT_EQ(result.countSubShapes("Vertex"), 1);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,10 @@ TEST_F(TopoShapeMakeShapeWithElementMapTests, mapCompoundCount)
|
||||
EXPECT_STREQ(sources[0].shapeName().c_str(), "Compound");
|
||||
EXPECT_STREQ(sources[1].shapeName().c_str(), "Compound");
|
||||
EXPECT_STREQ(compound.shapeName().c_str(), "Compound");
|
||||
EXPECT_EQ(6, compound.getMappedChildElements().size());
|
||||
EXPECT_EQ(
|
||||
22,
|
||||
compound.getMappedChildElements().size()); // Changed with PR#12471. Probably will change
|
||||
// again after importing other TopoNaming logics
|
||||
}
|
||||
|
||||
TEST_F(TopoShapeMakeShapeWithElementMapTests, emptySourceShapes)
|
||||
@@ -232,9 +235,9 @@ void testFindSubShapesForSourceWithTypeAndIndex(const std::string& shapeTypeStr,
|
||||
|
||||
EXPECT_NO_THROW(elementStdMap.at(indexedName)); // We check that the IndexedName
|
||||
// is one of the keys...
|
||||
EXPECT_EQ(mappedName.find(shapeName.c_str()),
|
||||
EXPECT_NE(mappedName.find(shapeName.c_str()),
|
||||
-1); // ... that the element name is in the MappedName...
|
||||
EXPECT_NE(mappedName.toString().back(), shapeTypePrefix);
|
||||
EXPECT_EQ(mappedName.toString().back(), shapeTypePrefix);
|
||||
}
|
||||
|
||||
void testFindSubShapesForSourceWithType(const TopoShape& source,
|
||||
|
||||
Reference in New Issue
Block a user