make a compound

hello
i have problem with make a compound shape.
//////the code is////
STEPControl_Reader reader;

reader.ReadFile("ashape.step");//shape is composed of 2 surfaces
....
TopoDS_Shape shape = reader.Shape();
TopTools_Array1OfShape TabShape(1,100);
TopExp_Explorer Ex;
for (Ex.Init(shape,TopAbs_FACE); Ex.More();Ex.Next()) {

TopoDS_Face aFace =TopoDS::Face(Ex.Current());

TabShape.SetValue(i,aFace);
/////i want to make a compound///
BRep_Builder builder;
TopoDS_Compound Comp;
builder.MakeCompound(Comp);
builder.Add(Comp,TabShape(1));
builder.Add(Comp,TabShape(2));

Handle(AIS_Shape) ashape1=new AIS_Shape(Comp);
myAISContext->Display(ashape1,Standard_False);

is compiling without error but is interrupt just on display.

is any one have somme suggestion!!

best regards.

sergey zaritchny's picture

Hi,
Check more carefully your source code.
The provided example has at least not initialized variable "i" and missed closing bracket "}".
Besides you may check each adding face for IsNull and IsValid.
Regards
Sergey

salma's picture

thanks for replay
is not a problem of the variable because it begin by
int i=1;
and the bracket "}" existe .
and when i put only this:
BRep_Builder builder;
TopoDS_Compound Comp;
builder.MakeCompound(Comp);
builder.Add(Comp,TabShape(1));
it is displaying withowt error
but when i add
builder.Add(Comp,TabShape(2));
it doesn't work.
regards

salma's picture

thanks the problem was resolved by:
if (!TabShape(2).IsNull())
{
....
}
now ,i have a problem to make 2 bsplinesurface into 1 bsplinesurface!!!
Handle(Geom_Surface) Surface = BRep_Tool::Surface(aFace);
Handle(Geom_BSplineSurface) aBSplineSurface =GeomConvert::SurfaceToBSplineSurface(Surface);
///how to make 2 BSplineSurfaces into 1 bsplinesurface!!!!
best regards