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

building a hexahedron

Anonymous's picture
Forums: 

Hello all,

I am having quite a bit of difficulty building a valid solid shape having six arbitrarily shaped faces (a hexahedron). I have tried constructing the six faces and then stitching them together using the sewing algorithm, but that doesn't appear to yield a result that works when boolean operations are applied. When a boolean operation is applied to some sides of the newly created hexahedron (e.g. cutting a cylindrical shape out of one side) the wrong portion of the cut is thrown away, while the same operation applied to another side of the hexahedron yields the correct result. This would seem to indicate that a face in my hexahedron is backwards, but I don't know how to determine when a face is pointing the wrong way. Also, I had thought that the sewing algorithm was supposed to fix the orientations of the faces. Is this not so? My algorithm is this:

TopoDS_Vertex vert1 = BRepBuilderAPI_MakeVertex( V1 ); // 8 vertices this way

TopoDS_Edge e12 = BRepBuilderAPI_MakeEdge( vert1, vert2 ); // 12 edges this way

TopoDS_Wire w1234 = BRepBuilderAPI_MakeWire( e12, e23, e34, e41 ); w1234.Closed( true ); // 6 wires

Face f1234 = BRepBuilderAPI_MakeFace( BRepBuilderAPI_FindPlane( w1234, p ).Plane()->Pln(), w1234 ).Face(); // 6 faces

then I sew them all together, construct a shell, and construct a solid from the shell.

This results in shapes with inconsistently oriented faces.

I have also tried another approach: take the common volume bounded by six half spaces as my definition for a hexahedron. The code I tried looks like this (V1-V8 are the eight vertices that define the boundary of the hexahedron, and the point called 'inside' is a reference point on the solid side of each face):

TopoDS_Face f1 = BRepBuilderAPI_MakeFace( gce_MakePln( V1, V2, V3 ).Value() ).Face();

TopoDS_Face f2 = BRepBuilderAPI_MakeFace( gce_MakePln( V5, V6, V7 ).Value() ).Face();

TopoDS_Face f3 = BRepBuilderAPI_MakeFace( gce_MakePln( V1, V4, V8 ).Value() ).Face();

TopoDS_Face f4 = BRepBuilderAPI_MakeFace( gce_MakePln( V2, V3, V7 ).Value() ).Face();

TopoDS_Face f5 = BRepBuilderAPI_MakeFace( gce_MakePln( V1, V2, V6 ).Value() ).Face();

TopoDS_Face f6 = BRepBuilderAPI_MakeFace( gce_MakePln( V3, V4, V8 ).Value() ).Face();

TopoDS_Shape hs1 = BRepPrimAPI_MakeHalfSpace( f1, inside ).Solid();

TopoDS_Shape hs2 = BRepPrimAPI_MakeHalfSpace( f2, inside ).Solid();

TopoDS_Shape hs3 = BRepPrimAPI_MakeHalfSpace( f3, inside ).Solid();

TopoDS_Shape hs4 = BRepPrimAPI_MakeHalfSpace( f4, inside ).Solid();

TopoDS_Shape hs5 = BRepPrimAPI_MakeHalfSpace( f5, inside ).Solid();

TopoDS_Shape hs6 = BRepPrimAPI_MakeHalfSpace( f6, inside ).Solid();

TopoDS_Shape combined1 = BRepAlgoAPI_Common( hs1, hs2 ).Shape();

TopExp_Explorer ex( combined1, TopAbs_FACE );

for ( ; ex.More(); ex.Next() ) {

TopoDS_Face f = TopoDS::Face( ex.Current() );

}

TopoDS_Shape combined2 = BRepAlgoAPI_Common( hs3, hs4 ).Shape();

TopoDS_Shape combined3 = BRepAlgoAPI_Common( hs5, hs6 ).Shape();

TopoDS_Shape combined4 = BRepAlgoAPI_Common( combined1, combined2 ).Shape();

TopoDS_Shape finalShape = BRepAlgoAPI_Common( combined4, combined3 ).Shape();

The way I see it, I should get the volume contained within the six half spaces, but this is not the case. The TopoDS_Explorer finds no faces to iterate over and it appears that I have created a NULL shape. Why???

Neither of the two approaches I used yield a valid hexahedron. Can anyone please help diagnose the problem here?

Thanks,

-- Shaun

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.