Merge branch 'identifications_in_step' into 'master'

fix identifications write and load to step

See merge request ngsolve/netgen!638
This commit is contained in:
Hochsteger, Matthias 2024-03-05 08:37:56 +01:00
commit 70abacaf82

View File

@ -2338,21 +2338,25 @@ namespace netgen
for(auto & ident : identifications) for(auto & ident : identifications)
{ {
const auto& to = STEPConstruct::FindEntity(finder, ident.from == shape ? ident.to : ident.from);
if(to.IsNull())
continue;
Array<Handle(StepRepr_RepresentationItem)> items; Array<Handle(StepRepr_RepresentationItem)> items;
// items.Append(STEPConstruct::FindEntity(finder, ident.other)); // TODO! items.Append(MakeReal(ident.from == shape ? 1 : 0));
items.Append(to);
auto & m = ident.trafo.GetMatrix(); auto & m = ident.trafo.GetMatrix();
for(auto i : Range(9)) for(auto i : Range(9))
items.Append(MakeReal(m(i))); items.Append(MakeReal(m(i)));
auto & v = ident.trafo.GetVector(); auto & v = ident.trafo.GetVector();
for(auto i : Range(3)) for(auto i : Range(3))
items.Append(MakeReal(v(i))); items.Append(MakeReal(v(i)));
for(auto & item : items.Range(1,items.Size())) items.Append(MakeInt(ident.type));
for(auto & item : items.Range(0, items.Size()))
model->AddEntity(item); model->AddEntity(item);
ident_items.Append(MakeCompound(items, ident.name)); ident_items.Append(MakeCompound(items, ident.name));
} }
for(auto & item : ident_items.Range(1, ident_items.Size()))
for(auto & item : ident_items.Range(1,ident_items.Size())) model->AddEntity(item);
model->AddEntity(item);
auto comp = MakeCompound(ident_items, "netgen_geometry_identification"); auto comp = MakeCompound(ident_items, "netgen_geometry_identification");
model->AddEntity(comp); model->AddEntity(comp);
} }
@ -2369,7 +2373,18 @@ namespace netgen
auto id_item = Handle(StepRepr_CompoundRepresentationItem)::DownCast(idents->ItemElementValue(i)); auto id_item = Handle(StepRepr_CompoundRepresentationItem)::DownCast(idents->ItemElementValue(i));
OCCIdentification ident; OCCIdentification ident;
ident.name = id_item->Name()->ToCString(); ident.name = id_item->Name()->ToCString();
// ident.other = TransferBRep::ShapeResult(transProc->Find(id_item->ItemElementValue(1))); /TODO! auto is_from = ReadReal(id_item->ItemElementValue(1));
if(is_from)
{
ident.from = shape_origin;
ident.to = TransferBRep::ShapeResult(transProc->Find(id_item->ItemElementValue(2)));
}
else
{
ident.from = TransferBRep::ShapeResult(
transProc->Find(id_item->ItemElementValue(2)));
ident.to = shape_origin;
}
auto & m = ident.trafo.GetMatrix(); auto & m = ident.trafo.GetMatrix();
for(auto i : Range(9)) for(auto i : Range(9))
@ -2377,7 +2392,7 @@ namespace netgen
auto & v = ident.trafo.GetVector(); auto & v = ident.trafo.GetVector();
for(auto i : Range(3)) for(auto i : Range(3))
v(i) = ReadReal(id_item->ItemElementValue(12+i)); v(i) = ReadReal(id_item->ItemElementValue(12+i));
ident.type = Identifications::ID_TYPE(ReadInt(id_item->ItemElementValue(15)));
result.push_back(ident); result.push_back(ident);
} }
OCCGeometry::GetIdentifications(shape_origin) = result; OCCGeometry::GetIdentifications(shape_origin) = result;