Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <TopoDS_Shape.hxx>
- #include <TCollection_AsciiString.hxx>
- #include <TCollection_HAsciiString.hxx>
- #include <XSControl_WorkSession.hxx>
- #include <Interface_InterfaceModel.hxx>
- #include <XSControl_TransferReader.hxx>
- #include <Transfer_TransientProcess.hxx>
- #include <StepRepr_Representation.hxx>
- #include <StepRepr_RepresentationItem.hxx>
- #include <TransferBRep.hxx>
- #include <STEPControl_Reader.hxx>
- TopoDS_Shape getShape(STEPControl_Reader &reader, char* shapeName) {
- const TCollection_AsciiString ascShapeName(shapeName);
- const Handle(XSControl_WorkSession)& theSession = reader.WS();
- const Handle(Interface_InterfaceModel)& theModel = theSession->Model();
- const Handle(XSControl_TransferReader)& aReader = theSession->TransferReader();
- const Handle(Transfer_TransientProcess)& tp = aReader->TransientProcess();
- Standard_Integer nb = theModel->NbEntities();
- TopoDS_Shape retShape;
- for(Standard_Integer i=1; i<=nb; i++) {
- Handle(StepRepr_Representation) ent = Handle(StepRepr_Representation)::DownCast(theModel->Value(i));
- if (ent.IsNull()) continue;
- Handle(Transfer_Binder) binder = tp->Find(ent);
- if (binder.IsNull()) continue;
- TopoDS_Shape oneShape = TransferBRep::ShapeResult(binder);
- if (oneShape.IsNull()) continue;
- if (ent->Name().IsNull())
- continue;
- if(ent->Name()->String().IsEqual(ascShapeName))
- {
- retShape = oneShape;
- }
- }
- return retShape;
- }
- //dump all labels
- void dumpLabels(STEPControl_Reader &reader) {
- const Handle(XSControl_WorkSession)& theSession = reader.WS();
- const Handle(Interface_InterfaceModel)& theModel = theSession->Model();
- Standard_Integer nb = theModel->NbEntities();
- std::cout << "number of entities: " << nb << endl;
- for(Standard_Integer i=1; i<=nb; i++) {
- Handle(StepRepr_Representation) ent = Handle(StepRepr_Representation)::DownCast(theModel->Value(i));
- if (ent.IsNull()) {
- cout << "ent is null" << endl;
- continue;
- }
- if (ent->Name().IsNull()) {
- cout << "ent is not null but does not have a name" << endl;
- continue;
- }
- std::cout << "dumpLabels: " << ent->Name()->ToCString() << std::endl;
- }
- }
- int main() {
- STEPControl_Reader reader;
- reader.ReadFile("MJ_3PSA_B2B_AFT_S-PLATE_SOURCE_lan04_2013-06-18.stp");
- dumpLabels(reader);
- //TopoDS_Shape sh = getShape(reader, "CP3");
- }
Advertisement
Add Comment
Please, Sign In to add comment