Exception when trying to create a thicksolid.

Hello,

I am trying to create a thick solid by using BRepOffsetAPI_MakeThickSolid and have been successful with "easy" shapes such as prisms or cubes but when I generate the solid with BRepOffsetAPI_ThruSections, I get an exception.

Please see code below:

I am generating a solid from two faces un face has a arc and the other one one is square.

gp_Pnt p1( 0, 25., 0 );
gp_Pnt p2( 25, 0, 0 );
gp_Pnt p3( 50, 25, 0 );
gp_Pnt p4( 10, 75, 0 );
gp_Pnt p5( 40, 75, 0 );
gp_Pnt p6( 20, 75, 0 );
gp_Pnt p7( 30, 75, 0 );

Handle( Geom_TrimmedCurve ) arc = GC_MakeArcOfCircle( p1, p2, p3 );
Handle( Geom_TrimmedCurve ) seg1 = GC_MakeSegment( p1, p4 );
Handle( Geom_TrimmedCurve ) seg2 = GC_MakeSegment( p4, p6 );
Handle( Geom_TrimmedCurve ) seg4 = GC_MakeSegment( p6, p7 );
Handle( Geom_TrimmedCurve ) seg5 = GC_MakeSegment( p7, p5 );
Handle( Geom_TrimmedCurve ) seg3 = GC_MakeSegment( p5, p3 );

TopoDS_Edge ed1 = BRepBuilderAPI_MakeEdge( arc );
TopoDS_Edge ed2 = BRepBuilderAPI_MakeEdge( seg1 );
TopoDS_Edge ed3 = BRepBuilderAPI_MakeEdge( seg2 );
TopoDS_Edge ed4 = BRepBuilderAPI_MakeEdge( seg3 );
TopoDS_Edge ed5 = BRepBuilderAPI_MakeEdge( seg4 );
TopoDS_Edge ed6 = BRepBuilderAPI_MakeEdge( seg5 );

BRepBuilderAPI_MakeWire wire1 = BRepBuilderAPI_MakeWire( ed1, ed2, ed3, ed4 );
wire1.Add( ed5 );
wire1.Add( ed6 );

gp_Pnt p1_2( 0, 25., 200 );
gp_Pnt p3_2( 50, 25, 200 );
gp_Pnt p4_2( 10, 75, 200 );
gp_Pnt p5_2( 40, 75, 200 );

Handle( Geom_TrimmedCurve ) seg1_2 = GC_MakeSegment( p1_2, p4_2 );
Handle( Geom_TrimmedCurve ) seg2_2 = GC_MakeSegment( p4_2, p5_2 );
Handle( Geom_TrimmedCurve ) seg3_2 = GC_MakeSegment( p1_2, p3_2 );
Handle( Geom_TrimmedCurve ) seg4_2 = GC_MakeSegment( p3_2, p5_2 );

TopoDS_Edge ed1_2 = BRepBuilderAPI_MakeEdge( seg1_2 );
TopoDS_Edge ed2_2 = BRepBuilderAPI_MakeEdge( seg2_2 );
TopoDS_Edge ed3_2 = BRepBuilderAPI_MakeEdge( seg3_2 );
TopoDS_Edge ed4_2 = BRepBuilderAPI_MakeEdge( seg4_2 );

TopoDS_Wire wire2 = BRepBuilderAPI_MakeWire( ed1_2, ed2_2, ed3_2, ed4_2 );

// This is where we generate the solid.
BRepOffsetAPI_ThruSections generatorb(Standard_True,Standard_True);
generatorb.AddWire(wire1);
generatorb.AddWire(wire2);
generatorb.Build();

TopoDS_Shape S2 = generatorb.Shape();

TopoDS_Face faceToRemove;
Standard_Real zMax = -1;
for(TopExp_Explorer aFaceExplorer(S2 , TopAbs_FACE) ; aFaceExplorer.More() ; aFaceExplorer.Next()){
TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current());

Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);

if(aSurface->DynamicType() == STANDARD_TYPE(Geom_Plane)){

Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurface);

gp_Pnt aPnt = aPlane->Location();
Standard_Real aZ = aPnt.Z();

if(aZ > zMax){

zMax = aZ;
faceToRemove = aFace;
}

}
}

TopTools_ListOfShape los;
los.Append( faceToRemove );
TopoDS_Shape newShape = BRepOffsetAPI_MakeThickSolid( S2, los, -0.5 , 1.e-3 );

Thanks.

m-aronsson's picture

What kind of exception ? one listed in the class docs or some other exception ?

Mikael

frsgti's picture

The instruction at ... referenced memory at ... The memory could not be read.