Tue, 05/04/2010 - 13:43
Hello,
I'm trying to build an open cascade model from a triangulation. My current approach goes like this:
- for each triangle create a wire with BRepBuilderAPI_MakePolygon
- create a face from the wire with BRepBuilderAPI_MakeFace
- Use BRep_Builder to add the created faces to a shell
Now I'd like to merge neighbored triangles into one face, so I don't have to see the edges from the original triangulation. Is there a way to do that in open cascade? I already tried connecting the faces with BRepBuilderAPI_Sewing or BRepAlgoAPI_Fuse, but the edges still remain after these operations. I also tried BRepAlgoAPI_Fuse, which threw several exceptions.
If it's not possible to merge two adjescent faces and remove the connecting edges, is there a way to build a surface from the triangulation?
Regards
Göran
Fri, 08/20/2010 - 18:33
Hello Göran
I´m facing the same problem. Have you found any solution so far?
Regards
Joachim
Mon, 08/23/2010 - 11:01
Hi Joachim,
I haven't found a really satisfying solution covering all cases so far. If the triangles are planar, I create the wire surrounding all faces and then build the face with BRepBuilderAPI_MakeFace, if they aren't planar I'm currently using BRepFill_Filling, but this doesn't work for all cases.
Regards
Göran
Thu, 02/23/2012 - 13:04
Hi, Göran, I meet the problem too. You said "If the triangles are planar, I create the wire surrounding all faces and then build the face with BRepBuilderAPI_MakeFace", can you get the source code of example? thanks.
Fri, 02/24/2012 - 11:15
BRepBuilderAPI_MakePolygon MP;
//todo: add the points from the edges to MP
//gp_Pnt pnt;
//MP.Add(pnt);
BRepBuilderAPI_MakeFace makeFace(MP.Wire());
if (makeFace.Error() == BRepBuilderAPI_FaceDone)
{
TopoDS_Face faceCurrent = makeFace.Face();
}
Fri, 02/24/2012 - 11:28
Hi, Göran, thank you for your answer. But I think your solution is just for polygon without holes. My case is a polygon with a hole in it, and I have tried to find out all free edges through BRepBuilderAPI_Sewing and then created wires from them, but I could not found a way to check the outer wire. Do you have any idea?
Fri, 02/24/2012 - 11:38
If you know, which points belong to the outer wire and which points belong to the hole, you can first build the outer face and add the hole afterwords:
//faceCurrent contains the polygon without the hole,
//MP contains the points of the Hole
BRepBuilderAPI_MakeFace makeFace(faceCurrent);
makeFace.Add(MP.Wire());
if (makeFace.Error() == BRepBuilderAPI_FaceDone)
{
faceCurrent = makeFace.Face();
}
Fri, 02/24/2012 - 12:33
That is the point, I can get wires belong to the face only, but can not know which wire is the outer wire. I can not find a way to check out the wire is an outer wire or not.
Fri, 02/24/2012 - 12:45
Is it what you are looking for?
TopoDS_Wire outerWire = BRepTools::OuterWire(TopoDS::Face(face));
Fri, 02/24/2012 - 12:51
Hi, Sharad, thank you. But it is not the answer, you know, the face is not constructed yet. we just have some wires, and want to build up the face using those wires.
Fri, 02/24/2012 - 13:04
Try the below code. I m not sure if it will work or not. But try atleast, if you have not tried this.
int nWireCount; // Number of Wires
// Building Wire
ShapeExtend_WireData *pBoundaryWire = new ShapeExtend_WireData();
//Loop all the wires
for(int j=0; j(arr_Wires[j]);
pBoundaryWire->Add(pWire);
}
ShapeFix_Wire fixBoundaryWire;
fixBoundaryWire.Load(pBoundaryWire);
fixBoundaryWire.Perform();
fixBoundaryWire.FixReorder();
fixBoundaryWire.FixConnected();
// Creating OCCT Face
BRepBuilderAPI_MakeFace aFace(fixBoundaryWire.Wire(), Standard_True);
Fri, 02/24/2012 - 13:06
Try the below code. I m not sure if it will work or not. But try atleast, if you have not tried this.
int nWireCount; // Number of Wires
// Building Wire
ShapeExtend_WireData *pBoundaryWire = new ShapeExtend_WireData();
//Loop all the wires
for(int j=0; j(arr_Wires[j]);
pBoundaryWire->Add(pWire);
}
ShapeFix_Wire fixBoundaryWire;
fixBoundaryWire.Load(pBoundaryWire);
fixBoundaryWire.Perform();
fixBoundaryWire.FixReorder();
fixBoundaryWire.FixConnected();
// Creating OCCT Face
BRepBuilderAPI_MakeFace aFace(fixBoundaryWire.Wire(), Standard_True);
Sat, 02/25/2012 - 13:49
Hi,
Did my code work? Or you found out the solution?
Mon, 02/27/2012 - 05:37
Hi, Sharad, Sorry, so late to reply you. I have tried your code, but it could not be compiled, because of the ShapeExtend_WireData instance("error C2661: 'Standard_Transient::operator new': no overloaded function takes 3 arguments"), I am finding the problem.
Mon, 02/27/2012 - 07:47
can not define new to DEBUG_NEW
Mon, 02/27/2012 - 07:46
Hi, Sharad, it is not work. it will remove the big wire, leave the small wire!