Thank you very much for your reply. But what I want to know is.............
An EDGE can be any type a polyline, a curve, an arc etc. If I have an EDGE, I want to know that type(polyline, curve, arc or any other types) and if that is a curve I want to know the control points and other details.
How can I get those details?
Thank you very much for your reply. But what I want to know is.............
An EDGE can be any type a polyline, a curve, an arc etc. If I have an EDGE, I want to know that type(polyline, curve, arc or any other types) and if that is a curve I want to know the control points and other details.
How can I get those details?
I think first of all an Edge cannot be a polyline because, the Edge always has an underlying geometry of a curve. A polyline could be a Wire in which Edges are connected together - open or closed. In that case each edge would again have underlying geometry of Curve (line).
What you can do is, use the following pseudocode to get the underlying curve of each edge...
Handle(Geom_Curve) crv = BRep_Tool::Curve(edge);
if(crv->DynamicType() == STANDARD_TYPE(Geom_Line))
{
Handle(Geom_Line) lin = Handle(Geom_Line)::DownCast(crv);
... do whatever with line
}
else if (crv->DynamicType() == STANDARD_TYPE(Geom_BezierCurve))
{
Handle(Geom_BezierCurve) bez = Handle(Geom_BezierCurve)::DownCast(crv);
... get the control point array...
}
else
...
Remember, if you have a wire you can use TopExp to explore each edge and find out what each one is.
BRep_Tool has static methods Surface, Curve and Pnt to give Geom_Surface, Geom_Curve and gp_Pnt from TopoDS_Face, TopoDS_Edge and TopoDS_Vertex respectively .
Wed, 01/28/2009 - 09:34
TopExp_Explorer and BRep_Tool::Pnt.
Wed, 01/28/2009 - 09:45
Could you please give me a small example...
Wed, 01/28/2009 - 17:28
// Explore faces...
for (TopExp_Explorer fExpl(aShape, TopAbs_FACE); fExpl.More(); fExpl.Next())
{
const TopoDS_Face &curFace = static_cast(fExpl.Current());
for (TopExp_Explorer wExpl(curFace, TopAbs_WIRE); wExpl.More(); wExpl.Next())
{
// ...
// somewhere deeper
const TopoDS_Vertex &curVertex = static_cast(vExpl.Current());
const gp_Pnt curVertexPos = BRep_Tool::Pnt(curVertex);
// ...
}
}
You may also want to check all methods of TopExp.
Thu, 01/29/2009 - 07:30
Thank you very much for your reply. But what I want to know is.............
An EDGE can be any type a polyline, a curve, an arc etc. If I have an EDGE, I want to know that type(polyline, curve, arc or any other types) and if that is a curve I want to know the control points and other details.
How can I get those details?
Wed, 01/28/2009 - 18:59
A quick look in the documentation could be a good idea, there are a number of examples on how to use TopExp_Explorer.
Thu, 01/29/2009 - 07:30
Thank you very much for your reply. But what I want to know is.............
An EDGE can be any type a polyline, a curve, an arc etc. If I have an EDGE, I want to know that type(polyline, curve, arc or any other types) and if that is a curve I want to know the control points and other details.
How can I get those details?
Thu, 01/29/2009 - 10:31
I think first of all an Edge cannot be a polyline because, the Edge always has an underlying geometry of a curve. A polyline could be a Wire in which Edges are connected together - open or closed. In that case each edge would again have underlying geometry of Curve (line).
What you can do is, use the following pseudocode to get the underlying curve of each edge...
Handle(Geom_Curve) crv = BRep_Tool::Curve(edge);
if(crv->DynamicType() == STANDARD_TYPE(Geom_Line))
{
Handle(Geom_Line) lin = Handle(Geom_Line)::DownCast(crv);
... do whatever with line
}
else if (crv->DynamicType() == STANDARD_TYPE(Geom_BezierCurve))
{
Handle(Geom_BezierCurve) bez = Handle(Geom_BezierCurve)::DownCast(crv);
... get the control point array...
}
else
...
Remember, if you have a wire you can use TopExp to explore each edge and find out what each one is.
BRep_Tool has static methods Surface, Curve and Pnt to give Geom_Surface, Geom_Curve and gp_Pnt from TopoDS_Face, TopoDS_Edge and TopoDS_Vertex respectively .
Hope this solves your problem
Regards
N. Sharjith
Fri, 01/30/2009 - 06:19
Hi,
Thank you very much for you all.
I got it.
Thu, 01/29/2009 - 09:31
for (Ex1.Init(ResultShape,TopAbs_SOLID); Ex1.More(); Ex1.Next())
{
count1++;
TDF_Label L1 = L.FindChild(5);
TDataStd_Name::Set(L1, "Solid");
for (Ex2.Init(Ex1.Current(),TopAbs_SHELL); Ex2.More(); Ex2.Next())
{
TDF_Label L2 = TDF_TagSource::NewChild(L1);
TDataStd_Name::Set(L2, "Shell");
count2++;
for (Ex3.Init(Ex2.Current(),TopAbs_FACE); Ex3.More(); Ex3.Next())
{
TDF_Label L3 = TDF_TagSource::NewChild(L2);
TDataStd_Name::Set(L3, "Face");
count3++;
for (Ex4.Init(Ex3.Current(),TopAbs_WIRE); Ex4.More(); Ex4.Next())
{
TDF_Label L4 = TDF_TagSource::NewChild(L3);
TDataStd_Name::Set(L4, "Wire");
count4++;
for (Ex5.Init(Ex4.Current(),TopAbs_EDGE); Ex5.More(); Ex5.Next())
{
TDF_Label L5 = TDF_TagSource::NewChild(L4);
TDataStd_Name::Set(L5, "Edge");
count5++;
for (Ex6.Init(Ex5.Current(),TopAbs_VERTEX); Ex6.More(); Ex6.Next())
{
TDF_Label L6 = TDF_TagSource::NewChild(L5);
TDataStd_Name::Set(L6, "Point");
TopoDS_Vertex vertex = TopoDS::Vertex(Ex6.Current());
gp_Pnt pt = BRep_Tool::Pnt(vertex);
Standard_Real x1= pt.X();
Standard_Real y1= pt.Y();
Standard_Real z1= pt.Z();
TDataStd_Real::Set(L6.FindChild(1), x1);
TDataStd_Real::Set(L6.FindChild(2), y1);
TDataStd_Real::Set(L6.FindChild(3), z1);
count6++;
}
}
}
}
}
}
This code will help You
Fri, 01/30/2009 - 06:15
Hi,
Thank you very much for you all.
I got it.
Mon, 02/09/2009 - 21:13
Hi,
can u tell me wat function needs to be used to get edge information of a shape.
Mon, 02/09/2009 - 21:19
You have it just in this thread: Vidhyan answer.
You can study all the hierarchical structure of a solid, just copying and pasting.
All the 'Ex#' variables must to be defined as TopExp_Explorer.
This is one of my reference posts!
Regards.