For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Highlighting / step files

Eisenberger Marvin's picture
Forums: 

I'd like to import files (e.g. step - files) and highlight certain parts of the resulting objects.
In an example, I found the following function, which imports step - files and stores the data in myAISContext (type: Handle_AIS_InteractiveContext)

bool OCCViewer::ImportStep(char* filename)
{
Standard_CString aFileName = (Standard_CString) filename;
STEPControl_Reader aReader;
IFSelect_ReturnStatus status = aReader.ReadFile(aFileName);
if ( status == IFSelect_RetDone )
{
bool failsonly = false;
aReader.PrintCheckLoad( failsonly, IFSelect_ItemsByEntity );

int nbr = aReader.NbRootsForTransfer();
aReader.PrintCheckTransfer( failsonly, IFSelect_ItemsByEntity );
for ( Standard_Integer n = 1; n {
Standard_Boolean ok = aReader.TransferRoot( n );
int nbs = aReader.NbShapes();
if ( nbs > 0 )
{
for ( int i = 1; i {
TopoDS_Shape shape = aReader.Shape( i );
myAISContext->Display(new AIS_Shape(shape));
}
}
}
} else
return false;
return true;
}

Unfortunately, the method "MoveTo" (of AIS_InteractiveContext) only highlights the entire object and not the single parts of it (edges,...). Is it possible, to extract the single parts of the whole shape?

Rajesh's picture

I have the same problem!

Eisenberger Marvin's picture

I partly solved my problem, using a "TopoDS_Iterator", but this solution has a rather not beneficial effect on the runtime.... Could someone come up with a more effective solution, please?

void OCCViewer::processShape(const TopoDS_Shape & shape)
{
processShape(shape,0);

myView->Update();
}
void OCCViewer::processShape(const TopoDS_Shape & shape,int tiefe)
{
TopoDS_Iterator it (shape);
while (it.More())
{
TopoDS_Shape subshape = it.Value();
it.Next();
bool rek = false;
TopAbs_ShapeEnum a = subshape.ShapeType();
switch (subshape.ShapeType())
{
case TopAbs_COMPOUND:
case TopAbs_COMPSOLID:
case TopAbs_SOLID:
case TopAbs_SHELL:
rek = true; break;
case TopAbs_VERTEX:
break;
case TopAbs_FACE:
case TopAbs_EDGE:
case TopAbs_WIRE:
rek = true;
default:
AIS_Shape * aisshape = new AIS_Shape(subshape);
aisshape->SetSelectionPriority(tiefe);
aisshape->SetColor(OCCViewer::STD_COLOR);
myAISContext->Display(aisshape,false);
}
if (rek) processShape(subshape,tiefe+1);
}
}

(@Rajesh: Please let me know, as soon as you figured out, how to solve our problem!)

Pawel's picture

Hello Marvin,

you can display a single TopoDS_Shape and then open LocalContext in order to select its components.

Hope this helps,
Pawel

chen's picture

Hello, Marvin:
I met the same problem. In my case, I want to get the sub-shape as solid type in one shape. This shape is obtained from a step file, and I use the TopExp_Explorer Class to get the sub-shapes, and there is only one solid type shape, but in fact, there are a lot of solids in the step file.
I want to ask how to explore the step file to get the sub-shapes as solid type.
Thanks for your answers.
chen

chen's picture

I am sorry,I have solved this problem. The error that I met is dependent on the step file generated by which cad system.
chen

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.