1

My aim is to count the number of ADVANCED_FACEs entities that define a solid in a STEP file. To do this I chose to use OpenCascade. I read the documentation about selection of instances, however It is quite difficult for me, and I didn't succeed in understanding how to use predefined operators like step214-placed-items, step214-shape-def-reprand so on.

Then I looked in the comments of XSControl_Reader.hxx file, where they write:

  //! For example, if you wanted to select only the advanced_faces in a STEP
  //! file you would use the following code:
  //! Example
  //! Reader.GiveList("xst-transferrable-roots","step-type(ADVANCED_FACE)");

At the moment, my code looks like the following.

int main(int argc, char* argv[])
{
    //read file
    STEPControl_Reader reader;
    IFSelect_ReturnStatus stat = reader.ReadFile(argv[1]);

    //check entities
    IFSelect_PrintCount mode = IFSelect_ShortByItem;
    reader.PrintCheckLoad(false, mode);

    //count number of roots to transfer
    Standard_Integer numberOfRoots = reader.NbRootsForTransfer();
    cout << "Number of roots = " << numberOfRoots << endl << endl;

    //transfer roots
    Standard_Integer numberOfRootsTransfered = reader.TransferRoots();
    reader.PrintCheckTransfer(false, mode);
    cout << "Number of roots transfered = " << numberOfRootsTransfered << endl << endl;

    //get list of all entities
    Handle(TColStd_HSequenceOfTransient) list = reader.GiveList();
    cout << "Number of entities = " << list->Length() << endl;

    //get list of ADVANCED_FACE entities
    Handle(TColStd_HSequenceOfTransient) listOfFaces = reader.GiveList("xst-transferrable-roots", "step-type(ADVANCED_FACE)");
    cout << "Number of ADVANCED_FACE entities = " << listOfFaces->Length() << endl;

    getchar();

    return 0;
}

The output I obtain is the following:

 Nb Total:0  for 0 items
Number of roots = 1

Check  : W:COMPOSITE_CURVE: Segments are not connected
  - Nb: 3 :   130267  130273  130279
Check  : W:COMPOSITE_CURVE: Segments were disordered; fixed
  - Nb: 1 :   130279
Check  : W:EDGE_LOOP: Edges were intersecting, corrected
  - Nb: 155 :   166207  166215  166222  166238  166276  .. etc
Check  : W:B_SPLINE_CURVE_WITH_KNOTS: Poor result from projection vertex / curve 3d
  - Nb: 4 :   151531  151531  151532  151532
Check  : W:EDGE_CURVE: Edge was self-intersecting, corrected
  - Nb: 3 :   163318  163502  163502
 Nb Total:166  for 5 items
Number of roots transfered = 1

Number of entities = 1
Number of ADVANCED_FACE entities = 1

The problem is that, with the file I pass as argument to main, I expect to obtain a number of ADVANCED_FACE entities much greater than 1. What am I doing wrong?

4

0 回答 0