
Mon, 06/02/2003 - 19:12
Forums:
The following is part of the code I use to convert faces into polygons, I found that parts of the shape appear rotated( 90 degrees I guess )
Can anyone give me a hint?
.
.
.
TopLoc_Location L;
// Get traiangles out of the shape mesh
Handle(Poly_Triangulation) myTriangulation = BRep_Tool::Triangulation(myFace, L);
.
.
.
Handle(Poly_PolygonOnTriangulation) myPolygon = BRep_Tool::PolygonOnTriangulation(myEdge,myTriangulation,L);
.
.
I checked on that both
"Handle(Poly_Triangulation)"
"Handle(Poly_PolygonOnTriangulation)"
are both not null and the code all ran without errors or exceptions.
Tue, 06/03/2003 - 10:00
Hi,
In fact by default the triangulation of a TopoDS_Face is null.
The easiest way to create it is visualize a face in shading mode. After you can retrieve the Poly_Triangulation using BRep_Tool. Or one can create the triangulation BRepMesh_IncrementalMesh class (see how it's done for the shading).
Regards,
Serge
Tue, 06/03/2003 - 10:51
I already apply
BRepMesh_IncrementalMesh on the face before I do the tringulation.
Mabe you misunderstood me, I succeed in converting the face into triangles and they look correct,
BUT
part of the shape appears rotated, for example I have a cylinder placed above a rectangular base, the result I get is correct except that the base is rotated 90
Tue, 06/03/2003 - 11:09
Hi,
Well, it seems I should read more carefully the question :)
Concerning rotation, did you check the TopLoc_Location which
is returned as a second argument to Triangulation method?
If it's not the identity transformation you should apply it to nodes of polygons in the triangulation.
Regards,
Serge
Tue, 06/03/2003 - 11:55
Ok here is part of my code involved in triangulation, can you tell me where should I apply the location?
{
.
.
.
TopLoc_Location L;
// Get traiangles out of the shape mesh
Handle(Poly_Triangulation) myTriangulation = BRep_Tool::Triangulation(myFace, L);
if ( myTriangulation .IsNull())
continue;
// Get nodes out of the shape mesh
Standard_Integer nNodes = myTriangulation->NbNodes();
TColgp_Array1OfPnt pointsArray(1,nNodes);
pointsArray = myTriangulation->Nodes();
// Get triangles indices out of the nodes we already have
Poly_Array1OfTriangle trianglesArray(1,myTriangulation->NbTriangles());
trianglesArray = myTriangulation->Triangles();
.
.
.
}
Tue, 06/03/2003 - 12:44
Hi again,
Something like this:
TopLoc_Location L;
// Get traiangles out of the shape mesh
Handle(Poly_Triangulation) myTriangulation = BRep_Tool::Triangulation(myFace, L);
if ( myTriangulation .IsNull()) continue;
TColgp_Array1OfPnt aNodes=myTriangulation->ChangeNodes();
for(lon i = aNodes.Lower(); i<=aNodes.Upper(); i++)
{
aNodes.SetValue(i, aNodes.Value(i).Transformed(L));
}
....
Regards,
Sergey
Tue, 06/03/2003 - 12:47
Opps,
I've made a mistake, instead of TColgp_Array1OfPnt aNodes
there must be TColgp_Array1OfPnt& aNodes
Tue, 06/03/2003 - 12:44
Hi again,
Something like this:
TopLoc_Location L;
// Get traiangles out of the shape mesh
Handle(Poly_Triangulation) myTriangulation = BRep_Tool::Triangulation(myFace, L);
if ( myTriangulation .IsNull()) continue;
TColgp_Array1OfPnt aNodes=myTriangulation->ChangeNodes();
for(long i = aNodes.Lower(); i<=aNodes.Upper(); i++)
{
aNodes.SetValue(i, aNodes.Value(i).Transformed(L));
}
....
Regards,
Sergey
Tue, 06/03/2003 - 13:31
Thanks alot Sergy it worked fine.
I hope that you can help me 2 in these 2 questios:
1. I use variables of these tyapes, do I have to free them after I finish from them? If I have to, then how should I do so?
Handle(Poly_Triangulation)
Handle(Poly_PolygonOnTriangulation)
TColgp_Array1OfPnt
TColStd_Array1OfInteger
2. I use all the matter of triangulation to be able to read the IGES files that contain surfaces, the result I get is good, but is there a better way? for example ellipses and cylinders don't appear accurate.
Tue, 06/03/2003 - 13:45
Hi,
A1:
You don't need to free the memory allocated by OpenCascade arrays (sequences, lists, maps) and Handle(...) objects as it's freed automatically (destructors, smart pointers)
A2:
Why don't use IGESControl_Reader?
Regards,
Serge
Tue, 06/03/2003 - 13:59
Ok I will make matters more clear:
I have a vector SDK that can draw primitive 3D vector objects: polylines,polygons,ellipses,arcs,polybezier,..
It doesn't support surfaces like cylinder,shpere,..
At the same time I want to be able to view all IGES file which might contain such surfaces.
So, my final goal is to convert IGES surfaces into a form my SDK can understand: ellipses,polygons,..
Can you tell me what is the best way to do this?
Tue, 06/03/2003 - 14:16
In fact this task requires a mesher and I as far as I know there is no mesher in OpenCascade except of the triangulation
tool. So you can try to use external tool to mesh surfaces.
Regards,
Serge