我的目的是计算在STEP文件中定义实体的ADVANCED_FACEs实体的数量。为此,我选择使用OpenCascade。我读了documentation about selection of instances,但是对我来说却很难,并且我没有成功理解如何使用诸如step214-placed-items
,step214-shape-def-repr
等预定义的运算符。
然后,我查看了 XSControl_Reader.hxx 文件的注释,并在其中写:
//! 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)");
此刻,我的代码如下所示。
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;
}
我获得的输出如下:
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
问题是,使用我作为main参数传递的文件,我希望获得许多大于1的ADVANCED_FACE实体。我在做什么错了?