Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Open CASCADEShowroomGet Open CASCADEDeveloper CornerSupportAbout us
Technical overview
Areas of use
Advantages
Public license
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
System requirements
What's new
Download Center
CD-ROM
Documentation
Getting started
Forum
Open Source community
Training and e-learning
A la Carte Support
Value-added software
Client Area
Company Profile
Contacts and Locations
Customers
News
Home / Developer Corner / Forum / query topods shape by name

Forum

query topods shape by name
Matthias Weber 2008-05-15 15:02
Hi,

I want to query a TopoDS_Shape by its name. First, an IGES file is loaded with the IGESControl_Reader. As far as I have seen in the sourcecode, the sections containing the names are directory sections. Unfortunately, I can't see where I could query these directory entries or, that would be the best, how to get a shape by the name referenced in the IGES file.

So, is there a possible solution? What could I do?

Best,
Matthias
Matthias Teich 2008-05-16 10:22
You should search the forum for IGESCAFControl_Reader, there you can use layers, colors and names
Matthias Weber 2008-05-16 18:01
Thank you very much! I did and from the sourcecode I programmed the following.
It is included in a class that is derived from IGESControl_Reader.

     //get shape for label
     TopoDS_Shape getShape(char* shapeName)
     {
          const TCollection_AsciiString ascShapeName(shapeName);
          
          const Handle(XSControl_WorkSession)& theSession = 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(IGESData_IGESEntity) ent =
               Handle(IGESData_IGESEntity)::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->HasName() && ent->NameValue()->String().IsEqual(ascShapeName))
           {
               retShape = oneShape;
           }
          }
          
          return retShape;
     }

     //dump all labels
     void dumpLabels()
     {
          const Handle(XSControl_WorkSession)& theSession = WS();
          const Handle(Interface_InterfaceModel)& theModel = theSession->Model();
          
          Standard_Integer nb = theModel->NbEntities();
          for(Standard_Integer i=1; i<=nb; i++)
          {
           Handle(IGESData_IGESEntity) ent =
               Handle(IGESData_IGESEntity)::DownCast
               (theModel->Value(i));
           if (ent.IsNull()) continue;
          
           if (ent->HasName())
           {
               std::cout << ent->NameValue()->String().ToCString() << std::endl;
           }
          }
     }

This seems to work quite well and just want to share this if anybody else looks for a similar solution.
 
 
Latest news
  • Open CASCADE Technology 6.3
  • SolidWorks Import by Datakit
  • UG NX Import by Datakit

  • © Open CASCADE 2000 - 2008  |  Search  |  Contacts