fixes for identifications not using maps, python maps also don't use hash

This commit is contained in:
Christopher Lackner 2022-12-09 13:10:17 +01:00
parent 6b846eeec2
commit d3a393a727
2 changed files with 11 additions and 7 deletions

View File

@ -439,7 +439,7 @@ namespace netgen
void PropagateIdentifications (TBuilder & builder, TopoDS_Shape shape, std::optional<Transformation<3>> trafo = nullopt) void PropagateIdentifications (TBuilder & builder, TopoDS_Shape shape, std::optional<Transformation<3>> trafo = nullopt)
{ {
TopTools_IndexedMapOfShape mod_indices; TopTools_IndexedMapOfShape mod_indices;
std::vector<TopTools_IndexedMapOfShape> modifications; Array<TopTools_IndexedMapOfShape> modifications;
TopTools_MapOfShape shape_handled; TopTools_MapOfShape shape_handled;
Transformation<3> trafo_inv; Transformation<3> trafo_inv;
@ -451,8 +451,8 @@ namespace netgen
{ {
auto s = e.Current(); auto s = e.Current();
mod_indices.Add(s); mod_indices.Add(s);
modifications.push_back({}); modifications.Append(TopTools_IndexedMapOfShape());
modifications.back().Add(s); modifications.Last().Add(s);
} }
for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX }) for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX })
@ -483,9 +483,12 @@ namespace netgen
for(auto ident : identifications) for(auto ident : identifications)
{ {
// nothing happened auto i1 = mod_indices.FindIndex(ident.to);
auto& mods_to = modifications[mod_indices.FindIndex(ident.to)-1]; auto i2 = mod_indices.FindIndex(ident.from);
auto& mods_from = modifications[mod_indices.FindIndex(ident.from)-1]; if(i1 == 0 || i2 == 0) // not in geometry
continue;
auto& mods_to = modifications[i1-1];
auto& mods_from = modifications[i2-1];
if(mods_to.Extent()==1 && mods_from.Extent() ==1) if(mods_to.Extent()==1 && mods_from.Extent() ==1)
continue; continue;

View File

@ -1000,7 +1000,8 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
return shape1.IsSame(shape2); return shape1.IsSame(shape2);
}) })
.def("__hash__", [] (const TopoDS_Shape& shape) { .def("__hash__", [] (const TopoDS_Shape& shape) {
return shape.HashCode(std::numeric_limits<Standard_Integer>::max()); OCCGeometry::GetProperties(shape); // make sure it is in global properties
return OCCGeometry::global_shape_property_indices.FindIndex(shape);
}) })
.def("Reversed", [](const TopoDS_Shape & shape) { .def("Reversed", [](const TopoDS_Shape & shape) {