Null TopoDS_Face triangulation

Hi all,
I am trying to obtain a triangulation from a TopoDS_Face. According to what I've seen in the documentation and on the forum, it should be a pretty straightforward operation. Yet, the triangulation I obtain is just an empty object. I found several threads in which it is pointed out that this usually occurs when the triangulation hasn't been initialized, so I added an initialization via the BRepMesh::Mesh method. This isn't solving the problem though, and I really have no clue of what I'm missing here...
This is the code I'm using.

TopLoc_Location loc;
loc.Identity();
Handle(Poly_Triangulation) tri = BRep_Tool::Triangulation(trimmed_approx_face, loc);
if (tri.IsNull())
{
cout BRepMesh::Mesh(trimmed_approx_face, 0.7);
}

if (tri.IsNull())
{
cout }

I really hope that I made some stupid mistake here, but just in case... I might mention that my face is obtained in a peculiar way. I initially use GeomPlate_Surface to obtain the surface bounded by closed wire. I then approximate such plate surface with a Geom_BSplineSurface. Finally, I obtain my trimmed_approx_face by cutting the bspline surface with the original wire through BRepBuilderAPI_MakeFace. All these operations are successful and I can also export the face into an IGES file.

Ben Cain's picture

I'm new to OpenCascade so this might not help. I have gotten the curve of a face and discretized it into arcs. In the code below I save them out as a CSV file to render in another program.

See the attached image of the face when rendered in a Qt based application.

QString workingDirPath;
if(!variant.isNull())
{
workingDirPath = variant.toString();
}
// Get the pathname for the projected wireframe file to save.
QString pathname = QFileDialog::getSaveFileName(
0, // parent
"Export wireframe file", // caption
workingDirPath, // start directory (selects file if contains file name)
"Wireframe files (*.csv)"); // file type filter
if(!pathname.isEmpty())
{
QFile outFile(pathname);
outFile.open(QIODevice::WriteOnly | QIODevice::Text);
if(outFile.isOpen())
{
QTextStream outStream(&outFile);
{
cout << "Edges of projected shape:\n";
TopExp_Explorer edgeExpl;
int ii;
for(ii=0, edgeExpl.Init(mShapeFace, TopAbs_EDGE); edgeExpl.More(); ++ii, edgeExpl.Next())
{
TopoDS_Edge edge = TopoDS::Edge(edgeExpl.Current());
cout << ii << " ";
cout << (BRep_Tool::IsGeometric(edge) ? "curve " : "!curve ");
Handle_Geom2d_Curve curve2d;
Handle_Geom_Surface surface;
TopLoc_Location location;
Standard_Real first, last;
BRep_Tool::CurveOnSurface(edge, curve2d, surface, location, first, last);
#if 1
if(!curve2d.IsNull())
{
//double deflection(0.1);
double deflection(0.5);
Geom2dAdaptor_Curve curveAdapter(curve2d);
GCPnts_UniformDeflection discretizer;
discretizer.Initialize(curveAdapter, deflection, first, last);
// Did the algorithm converge?
if(discretizer.IsDone())
{
outStream << discretizer.NbPoints() << endl;
cout << "#pnts=" << discretizer.NbPoints() << " ";
for(int jj=0; jj

Attachments: 
Ben Cain's picture

Just ignore the Qt QVariant stuff. It's a way of retrieving the last working directory. I probably shouldn't have included that since it's not necessary. Hopefully, the OpenCascade stuff is clear though.

QSettings settings(qApp->applicationName());
QVariant variant = settings.value("working-directory");