Fri, 10/10/2008 - 12:21
I have a problem making a face out of grid data: I have a regular 2D-grid with height values at every point. I want to transform that into a face in order to be able to extrude it afterwards. In the end I want to get a solid.
In my implementation first of all I define four gp_Pnt for every grid cell. With the help of these points I create four TopoDS_Edge by using the BRepBuilderAPI_MakeEdge(...). Afterward I define a BRepBuilderAPI_MakeWire and use the Method Add(...) to add all edges. And now my problems start. I tried to use BRepBuilderAPI_MakeFace(conructedWire) to build a face out of the construced wire. Afterwards I wanted to use BRepPrimAPI_MakePrism(...) to extrude the face. The extrusion is not the problem, I tested it with simpler faces and shapes. But the construction of the face out of the complex wire fails. Does anyone knows why?
Thanks a lot!
Fri, 10/10/2008 - 15:55
Just use BRepBuilderAPI_MakePolygon. Create an instance of it, and for each new point call the Add method. Close it, ask for the Wire, create the face with BRepBuilderAPI_MakeFace and then create the solid with BRepPrimAPI_MakePrism.
You can also check your wire is OK with BRepCheck_Wire (method SelfIntersect). Do that after having the face.
Fri, 10/10/2008 - 19:36
Thanks for that information. I tried it, but for a grid looking like this (numbers stand for points)
9 10 11 12 etc.
5 6 7 8
1 2 3 4
I have the problem that the points I add to BRepBuilderAPI_MakePolygon do not form ony one connected line. The wire could be created, but I got the status BRepCheck_SelfIntersectingWire. The face creation with that wire failed.
Then I tried to create a face for every small grid cell (e.g. 1-2-6-5) and fuse the faces with BRepAlgo_Fuse(...). But that did not work, because for some small grid cells no face could be created - I have no idea why.
Do you see any fault I made or have another idea?
Mon, 10/13/2008 - 09:54
I don't understand those numbers as coordinates. Could you please write them in the form (x, y, z), and a sequence that is not working for you?
The method I described to you is something I'm using, and it works perfectly.
Mon, 10/13/2008 - 12:05
Thanks for your reply. Here I have four coordinates for which I cannot create a face (x, y, z):
(450.0, 0.0, 34.90), (475.0, 0.0, 34.90), (450.0, 25.0, 35.0), (475.0, 25.0, 34.90)
For these points I used your algorithm: Add Points to a BRepBuilderAPI_MakePolygon and use the resulting wire as input for a BRepBuilderAPI_MakeFace. E.g. for the listed points IsDone() of the BRepBuilderAPI_MakeFace returns false.
Tue, 10/14/2008 - 10:29
The third point has Z = 35.0, all others 34.90. Are you sure about that?
Did you close the wire using BRepBuilderAPI_MakePolygon::Close() before creating the face?
Tue, 10/14/2008 - 11:20
Your points set has two problems:
1. The points form a 8-like twisted polygon. Swap points 3 and 4.
2. the points do not lie in the same plane. To avoid it, you should change Z of the point 3 or you should somehow create a b-spline surface passing through all edges, and use it in MakeFace.
Wed, 10/15/2008 - 17:15
Thank you very much. I tried using GeomAPI_PointsToBSplineSurface(...) as input for BRepBuilderAPI_MakeFace(...). After that I used BRepPrimAPI_MakePrism(...) as before to create a solid. It seems to work well, but another problem arises now: I use BRepAlgoAPI_Cut(...) to cut out objects from the created solid. But that did not work all the time (e.g. it return errorstatus = 101). When using a planar face instead of a bspline it seems to work.
Wed, 10/15/2008 - 17:28
It is probably a bug in BOP. You can attach here a draw script or a fragment of code leading to the error, may be OCC team will find a time to fix it.