diff --git a/libsrc/gprim/transform3d.hpp b/libsrc/gprim/transform3d.hpp index e656556f..c61a9a99 100644 --- a/libsrc/gprim/transform3d.hpp +++ b/libsrc/gprim/transform3d.hpp @@ -130,6 +130,9 @@ public: // (*testout) << "Rotation - Transformation:" << (*this) << endl; } + Mat & GetMatrix() { return m; } + Vec & GetVector() { return v; } + /// Transformation CalcInverse () const { diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index 537da6ef..f75c9a67 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -2045,14 +2045,16 @@ namespace netgen if(item.IsNull()) continue; + auto shape_item = item->ItemElementValue(1); + TopoDS_Shape shape = TransferBRep::ShapeResult(transProc->Find(shape_item)); string name = item->Name()->ToCString(); + + if(name == "netgen_geometry_identification") + ReadIdentifications(item, transProc); + if(name != "netgen_geometry_properties") continue; - auto shape_item = item->ItemElementValue(1); - Handle(Transfer_Binder) binder; - binder = transProc->Find(shape_item); - TopoDS_Shape shape = TransferBRep::ShapeResult(binder); auto & prop = OCCGeometry::global_shape_properties[shape.TShape()]; auto nprops = item->NbItemElement(); @@ -2093,14 +2095,75 @@ namespace netgen if(auto hpref = prop.hpref; hpref != default_props.hpref) props.Append( MakeReal(hpref, "hpref") ); - if(props.Size()==1) + if(props.Size()>1) + { + for(auto & item : props.Range(1, props.Size())) + model->AddEntity(item); + + auto compound = MakeCompound(props, "netgen_geometry_properties"); + model->AddEntity(compound); + } + + WriteIdentifications(model, shape, finder); + } + + void WriteIdentifications(const Handle(Interface_InterfaceModel) model, const TopoDS_Shape & shape, const Handle(Transfer_FinderProcess) finder) + { + Handle(StepRepr_RepresentationItem) item = STEPConstruct::FindEntity(finder, shape); + auto & identifications = OCCGeometry::identifications[shape.TShape()]; + if(identifications.size()==0) return; + auto n = identifications.size(); + Array ident_items; + ident_items.Append(item); - for(auto & item : props.Range(1, props.Size())) + for(auto & ident : identifications) + { + Array items; + items.Append(STEPConstruct::FindEntity(finder, ident.other)); + items.Append(MakeInt(static_cast(ident.inverse))); + auto & m = ident.trafo.GetMatrix(); + for(auto i : Range(9)) + items.Append(MakeReal(m(i))); + auto & v = ident.trafo.GetVector(); + for(auto i : Range(3)) + items.Append(MakeReal(v(i))); + for(auto & item : items.Range(1,items.Size())) + model->AddEntity(item); + ident_items.Append(MakeCompound(items, ident.name)); + } + + for(auto & item : ident_items.Range(1,ident_items.Size())) model->AddEntity(item); + auto comp = MakeCompound(ident_items, "netgen_geometry_identification"); + model->AddEntity(comp); + } - auto compound = MakeCompound(props, "netgen_geometry_properties"); - model->AddEntity(compound); + void ReadIdentifications(Handle(StepRepr_RepresentationItem) item, Handle(Transfer_TransientProcess) transProc) + { + auto idents = Handle(StepRepr_CompoundRepresentationItem)::DownCast(item); + auto n = idents->NbItemElement(); + std::vector result; + auto shape_origin = TransferBRep::ShapeResult(transProc->Find(idents->ItemElementValue(1))); + + for(auto i : Range(2,n+1)) + { + auto id_item = Handle(StepRepr_CompoundRepresentationItem)::DownCast(idents->ItemElementValue(i)); + OCCIdentification ident; + ident.name = id_item->Name()->ToCString(); + ident.other = TransferBRep::ShapeResult(transProc->Find(id_item->ItemElementValue(1))); + ident.inverse = static_cast(ReadInt(id_item->ItemElementValue(2))); + + auto & m = ident.trafo.GetMatrix(); + for(auto i : Range(9)) + m(i) = ReadReal(id_item->ItemElementValue(3+i)); + auto & v = ident.trafo.GetVector(); + for(auto i : Range(3)) + v(i) = ReadReal(id_item->ItemElementValue(12+i)); + + result.push_back(ident); + } + OCCGeometry::identifications[shape_origin.TShape()] = result; } void WriteSTEP(const TopoDS_Shape & shape, string filename) diff --git a/libsrc/occ/occgeom.hpp b/libsrc/occ/occgeom.hpp index a7fc3563..aacbbbc5 100644 --- a/libsrc/occ/occgeom.hpp +++ b/libsrc/occ/occgeom.hpp @@ -520,6 +520,11 @@ namespace netgen return int_obj; } + inline int ReadInt (Handle(StepRepr_RepresentationItem) item) + { + return Handle(StepRepr_IntegerRepresentationItem)::DownCast(item)->Value(); + } + inline Handle(StepRepr_RepresentationItem) MakeReal (double val, string name = "") { Handle(StepBasic_MeasureValueMember) value_member = new StepBasic_MeasureValueMember; @@ -529,6 +534,13 @@ namespace netgen return value_repr; } + inline double ReadReal (Handle(StepRepr_RepresentationItem) item) + { + return Handle(StepRepr_ValueRepresentationItem)::DownCast(item) + ->ValueComponentMember()->Real(); + } + + inline Handle(StepRepr_RepresentationItem) MakeCompound( FlatArray items, string name = "" ) { Handle(StepRepr_HArray1OfRepresentationItem) array_repr = new StepRepr_HArray1OfRepresentationItem(1,items.Size()); @@ -541,6 +553,9 @@ namespace netgen return comp; } + void WriteIdentifications(const Handle(Interface_InterfaceModel) model, const TopoDS_Shape & shape, const Handle(Transfer_FinderProcess) finder); + void ReadIdentifications(Handle(StepRepr_RepresentationItem) item, Handle(Transfer_TransientProcess) transProc); + inline Quantity_ColorRGBA MakeColor(const Vec<4> & c) { return Quantity_ColorRGBA (c[0], c[1], c[2], c[3]);