Wed, 06/12/2019 - 15:34
Forums:
Hello,
I'm generating a cylinder with this:
BRepPrimAPI_MakeCylinder aMakeCylinder = new BRepPrimAPI_MakeCylinder(new gp_Ax2(new gp_Pnt(0, 0, 0), new gp_Dir(0, 0, 1)), 1, 1, 0);
TopoDS_Shape myBody = aMakeCylinder.Shape();
and then i'm extracting the vertices:
public static List<List<gp_Pnt>> toVertices(TopoDS_Shape myBody)
{
List<List<gp_Pnt>> myPoints = new List<List<gp_Pnt>>();
// we explore each face
for (TopExp_Explorer aFaceExplorer = new TopExp_Explorer(myBody, TopAbs_ShapeEnum.TopAbs_FACE); aFaceExplorer.More(); aFaceExplorer.Next())
{
TopoDS_Face face = TopoDS.TopoDS.ToFace(aFaceExplorer.Current());
// in each face we get all the vertex
List<gp_Pnt> tempList = new List<gp_Pnt>();
for (TopExp_Explorer exp = new TopExp_Explorer(face.Oriented(TopAbs_Orientation.TopAbs_FORWARD), TopAbs_ShapeEnum.TopAbs_VERTEX); exp.More(); exp.Next())
{
TopoDS_Vertex vertex = TopoDS.TopoDS.ToVertex(exp.Current());
gp_Pnt pt = BRep_Tool.Pnt(vertex);
tempList.Add(pt);
}
myPoints.Add(tempList);
}
return myPoints;
}
if i print the vertices of one face, i get for example:
[0.5; 0; 0.5]
[0.5; 0; 0.5]
[0.5; 0; 0.5]
[0.5; 0; 0]
[0.5; 0; 0]
[0.5; 0; 0]
[0.5; 0; 0.5]
[0.5; 0; 0]
only two differents points...what happens ??
Attachments:
Tue, 06/18/2019 - 11:08
Note that it works perfectly with a cube
Fri, 06/21/2019 - 09:50
Here is my solution:
so i'm still building my cylinder the same way as previously
and i'm using FinishShape on myBody
it retrieves two faces ( top and bottom )
now it's your job to create the lateral faces (small hint, with my code you simply need to iterate through the faces and put together the vertices List1[i], List1[i+1], List2[i+1], List2[i]
it will create rectangular faces all around your cylinder
simply create triangles from those rectangles and ggwp =)
Fri, 06/21/2019 - 09:57
I'm on a good mood
this is the function to add the lateral faces, apply it on myPoints, the output of FinishShape
Thu, 06/27/2019 - 12:21
Edit: the way i'm buidling a cylinder is wrong, the parameter angle is set to 0, remove it