
Tue, 04/17/2018 - 15:39
Hello All,
I need to get the id of step entities, as this is used to reference information outside the STEP file,
e.g. the BW_123 from #33=OPEN_SHELL('BW_123',(#79)) ;
The lookup of this information takes ages compared with all other operation.
Loading my reference file containing ~10.000 faces into a document takes about 2 minutes,
creating a map containing the name and the shape about 45 minutes, doing the aktual work another 2 minutes.
The loop over the shapes itself takes less than a second, the code to access the id is taken from examples found in the forum.
Are there ideas how to speed this up a bit ?
Thank you, Carsten
for (TopExp_Explorer shellExplorer(shape, TopAbs_SHELL); shellExplorer.More(); shellExplorer.Next()) {
const TopoDS_Shell& shell = TopoDS::Shell(shellExplorer.Current());
// Get the name of the STEP Entity
Standard_CString shapeName = "";
Handle(Standard_Transient) anEntity = aTransferReader->EntityFromShapeResult(shell, 1);
if (anEntity.IsNull()) {
// as just mapped
anEntity = aTransferReader->EntityFromShapeResult(shell, -1);
}
if (anEntity.IsNull()) {
// as anything
anEntity = aTransferReader->EntityFromShapeResult(shell, 4);
}
if (anEntity.IsNull()) {
GLOG(INFO) << "Warning: XSControl_TransferReader::EntityFromShapeResult(shapeResult) entity not found (NULL)";
} else {
// use StepRepr_RepresentationItem for solids, faces and compound (geometric_set)
Handle(StepRepr_RepresentationItem) aReprItem;
aReprItem = Handle(StepRepr_RepresentationItem)::DownCast(anEntity);
if (aReprItem.IsNull()) {
GLOG(INFO) << "Warning: XSControl_TransferReader::EntityFromShapeResult(shapeResult) : "
<< "StepRepr_RepresentationItem Is NULL, entity type was: " << anEntity->DynamicType() << endl;
// use StepRepr_Representation for some compounds like e.g. ManifoldSurfaceShapeRepresentation, StepShape_AdvancedBrepShapeRepresentation
Handle(StepRepr_Representation) ent;
ent = Handle(StepRepr_Representation)::DownCast(anEntity);
if (ent.IsNull()) {
GLOG(INFO) << "Error: XSControl_TransferReader::EntityFromShapeResult(shapeResult) : "
<< "StepRepr_Representation also is NULL, entity type was: " << anEntity->DynamicType() << endl;
} else {
shapeName = ent->Name()->ToCString();
id = ent->GetRefCount();
}
} else {
shapeName = aReprItem->Name()->ToCString();
id = aReprItem->GetRefCount();
}
}
Mon, 04/23/2018 - 12:37
Hello All,
just out of curiosity I tried it the other way round (from STEP Entity to TopoDS_Shape) and the speed up is tremendously.
I still have no idea, why shape -> entity is that slow, but with the code below the overall time is ok.
Bey, Carsten
const Handle(XSControl_WorkSession) workSession = stepReader.Reader().WS();
const Handle(Interface_InterfaceModel) model = workSession->Model();
const Handle(XSControl_TransferReader) transferReader =
workSession->TransferReader();
Handle(Transfer_TransientProcess) transProc = transferReader->TransientProcess();
Standard_Integer nb = model->NbEntities();
for (Standard_Integer i = 1; i < nb; i++) {
Handle(Standard_Transient) entity = model->Value(i);
if (!entity->DynamicType()->SubType("StepShape_OpenShell")) continue;
Handle(StepRepr_RepresentationItem) SRRI =
Handle(StepRepr_RepresentationItem)::DownCast(entity);
if (SRRI.IsNull()) {
GLOG(WARNING) << "no StepRepr_RepresentationItem found in " << entity->DynamicType()->Name();
continue;
}
Handle(TCollection_HAsciiString) hName = SRRI->Name();
string shapeName = hName->ToCString();
GLOG(INFO) << "STEP " << i << " " << entity->DynamicType()->Name() << " " << shapeName;
Handle(Transfer_Binder) binder;
if (!transProc->IsBound(SRRI)) {
GLOG(WARNING) << "found unbound entity " << shapeName;
continue;
}
binder = transProc->Find(SRRI);
TopoDS_Shape shape = TransferBRep::ShapeResult(binder);
Tue, 04/24/2018 - 09:44
I guess that EntityFromShapeResult() searches the whole model until it finds the shape. Doing that in a for loop for every shape means really a lot of effort.
Benjamin