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

Search the Forums
See All Topics
Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forums
Open Source community
Training and e-learning
A-la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
News
Home / Developer Corner / Forums / Usage issues / Triangulation of simple face.

Triangulation of simple face.

Triangulation of simple face.
Niko Lehikoinen 2012/10/23 11:56
Hello,

I have a problem triangulating a simple quad polygon/face. The following code produces IMO false result:

//--------------------------------------------------

gp_Pnt p0(0.0, 0.0, 0.0);
gp_Pnt p1(1.0, 0.0, 0.0);
gp_Pnt p2(1.0, 1.0, 0.0);
gp_Pnt p3(0.0, 1.0, 0.0);

Handle(Geom_TrimmedCurve) seg0 = GC_MakeSegment(p0, p1);
Handle(Geom_TrimmedCurve) seg1 = GC_MakeSegment(p3, p2);
TopoDS_Edge edge0 = BRepBuilderAPI_MakeEdge(seg0);
TopoDS_Edge edge1 = BRepBuilderAPI_MakeEdge(seg1);
const TopoDS_Face face = BRepFill::Face(edge0, edge1);
TopLoc_Location loc;
double accuracy = 0.01;
BRepMesh::Mesh(face, accuracy);

TopExp_Explorer expl;
for (expl.Init(face, TopAbs_FACE); expl.More(); expl.Next())
{
TopoDS_Face f = TopoDS::Face(expl.Current());
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation(f, loc);
const Poly_Array1OfTriangle &triangles = triangulation->Triangles();
for (int i=1; i {
int n1,n2,n3;
if (f.Orientation() == TopAbs_REVERSED )
     triangles(i).Get(n3,n2,n1);
else
     triangles(i).Get(n1,n2,n3);

std::cout << "triface " << n1 << " " << n2 << " " << n3 << std::endl;
}

}

//--------------------------------------------------

I think triangulating polygon with four vertices should produce two triangles. Running the above program tells me:

triface 4 1 2

where as expected results would be:

triface 4 1 2
triface 4 2 3

There must be something simple I forgot to do, I really would appreciate if you could point the err of my ways.

Best regards,

Niko
Niko Lehikoinen 2012/10/29 14:33
I forgot to mention that I am using the pre-built developer libraries on Ubuntu 12.10, could there be some clue why this do not work for me?

Best regards,

Niko
 
 
Latest news
  • Open CASCADE Technology 6.7.0 is available for download!
  • Open CASCADE Technology 6.6.0 is available for download!
  • Open CASCADE Technology 6.5.5 is available for download!

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