Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics
 

Single-edge face triangulation fails

Single-edge face triangulation fails
Wayne Christopher 2011/07/27 23:48
I have a TopoDS_Edge which is a circle, and has the same vertex on both ends.

I put this edge into a wire, using BRepBuilderAPI_MakeWire, and then create a face from the wire using BRepBuilderAPI_MakeFace. This succeeds (i.e. MakeFace.IsDone() is true).

When I try to use BRep_Tool::Triangulation however, it fails.

The funny thing is, when I read this same circular face from a STEP file, created externally, the triangulation is fine.

Any thoughts on what's going on? Should I be using a different mechanism to create the face such as GeomPlate_BuildPlateSurface?
spam killer 2011/07/28 07:40
This works for me (OCCT 6.5.1, VS2010, x86):

          // face
          gp_Pnt center(0,0,0);
          gp_Circ circ(gp_Ax2(center, gp::DZ()), 100.0);
          TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circ);
          BRepBuilderAPI_MakeWire mkWire;
          mkWire.Add(edge);
          TopoDS_Face face = BRepBuilderAPI_MakeFace(mkWire.Wire());
          addToView(face);

          // triangulation
          BRep_Builder builder;
          TopoDS_Compound compound;
          builder.MakeCompound(compound);
          TopLoc_Location L; //= TopLoc_Location();
          Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation(face, L);

          // check result
          if (!triangulation.IsNull())
          {
               int nbTriangles = triangulation->NbTriangles();
               const Poly_Array1OfTriangle & triangles = triangulation->Triangles();
               const TColgp_Array1OfPnt & nodes = triangulation->Nodes();
               for (int i = 1; i <= nbTriangles; i++)
               {
                    Poly_Triangle triangle = triangles(i);

                    Standard_Integer node1,node2,node3;
                    triangle.Get(node1, node2, node3);

                    gp_Pnt v1 = nodes(node1);
                    gp_Pnt v2 = nodes(node2);
                    gp_Pnt v3 = nodes(node3);

                    TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(v1,v2);
                    TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(v2,v3);
                    TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(v3,v1);
                    TopoDS_Wire w = BRepBuilderAPI_MakeWire(e1, e2, e3);
                    TopoDS_Face fTriangle = BRepBuilderAPI_MakeFace(w);

                    builder.Add(compound, fTriangle);
               }
               if (nbTriangles > 0)
               {
                    Handle_AIS_Shape aisShape = new AIS_Shape(compound);
                    context->Display(aisShape);
               }
          }
lanhan 2012/07/04 07:28
     TopLoc_Location L1;     
     BRepMesh::Mesh(aFace,0.7);
 
 
Latest news
  • Open CASCADE Technology 6.8.0 is available for download!
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!

  • © OPEN CASCADE 2000 - 2014  |  Search  |  Contacts   |  Site map