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

Search the Forums
See All Topics
 

Output PCurves of a cylindrical face in order

Output PCurves of a cylindrical face in order
George Feng 2012/11/06 13:05
Two cylinders are fused together with BRepAlgoAPI_Fuse. The code is as follows.



     // first Shape = Cylinder
     gp_Pnt middlePoint = gp_Pnt(1000, 0, 1000);//1000,0,1000
     gp_Dir direction = gp_Dir(0, 1, 0);
     gp_Ax2 Ax2 = gp_Ax2(middlePoint, direction);
     aCylinderShape1 = BRepPrimAPI_MakeCylinder(Ax2, 500,2000);
     // second Shape = Cone
     middlePoint = gp_Pnt(1000, 1000, 1000);
     direction = gp_Dir(0, 1, 0);
     Ax2 = gp_Ax2(middlePoint, direction);
     //Shape2 = BRepPrimAPI_MakeCone(Ax2, 0.0635114, 0, 0.309304);
     aCylinderShape2 = BRepPrimAPI_MakeCylinder(Ax2, 500,2000);

     TopoDS_Shape aFuseShape = BRepAlgoAPI_Fuse(aCylinderShape1, aCylinderShape2);

After that the cylindrical wire of the first section is dumped out as follows.

Shape : 6, FORWARD

Dump of 6 TShapes

-----------------

Flags : Free, Modified, Checked, Orientable, Closed, Infinite, Convex

TShape # 1 : WIRE 0101000 04A8B6F8
-5 +3 +2 -3

TShape # 2 : EDGE 0101100 04A83684
+4 -4
Tolerance : 1e-007
same parametrisation of curves
same range on curves
- Curve 3D : 3, range : 0 6.28319
- PCurve : 6 on surface 3, range : 0 6.28319
UV Points : 0, 0 6.28319, 0
- PCurve : 7 on surface 4, range : 0 6.28319
UV Points : 500, -1.22465e-013 500, -1.22465e-013

TShape # 3 : EDGE 0101000 04A877C4
+4 -6
Tolerance : 1e-007
same parametrisation of curves
same range on curves
- Curve 3D : 2, range : 0 1000
- PCurve : 4, 5 (CN) on surface 3, range : 0 1000
UV Points : 6.28319, 0 6.28319, 1000
UV Points : 0, 0 0, 1000

TShape # 4 : VERTEX 0101101 04A83594

Tolerance : 1e-007
- Point 3D : 1000, 0, 1500

TShape # 5 : EDGE 0101100 04A84260
+6 -6
Tolerance : 1e-007
same parametrisation of curves
same range on curves
- Curve 3D : 1, range : 0 6.28319
- PCurve : 1 on surface 1, range : 0 6.28319
UV Points : 0, 0 6.28319, 0
- PCurve : 2 on surface 2, range : 0 6.28319
UV Points : 500, 0 500, 0
- PCurve : 3 on surface 3, range : 0 6.28319
UV Points : 0, 1000 6.28319, 1000

TShape # 6 : VERTEX 0101101 04A84170

Tolerance : 1e-007
- Point 3D : 1000, 1000, 1500


-------
Dump of 7 Curve2ds
-------

1 : Line
Origin :0, 0
Axis :1, 0

2 : Circle
Center :0, 0
XAxis :1, 0
YAxis :-0, 1
Radius :500

3 : Line
Origin :0, 1000
Axis :1, 0

4 : Line
Origin :6.28319, -0
Axis :0, 1

5 : Line
Origin :0, -0
Axis :0, 1

6 : Line
Origin :0, 0
Axis :1, 0

7 : Circle
Center :0, 0
XAxis :1, 0
YAxis :-0, 1
Radius :500


-------
Dump of 3 Curves
-------

1 : Circle
Center :1000, 1000, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0
Radius :500

2 : Line
Origin :1000, 0, 1500
Axis :0, 1, 0

3 : Circle
Center :1000, 0, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0
Radius :500

-------
Dump of 0 Polygon3Ds
-------
-------
Dump of 0 PolygonOnTriangulations
-------

-------
Dump of 4 surfaces
-------

1 : CylindricalSurface
Origin :1000, 1000, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0
Radius :500

2 : Plane
Origin :1000, 1000, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0

3 : CylindricalSurface
Origin :1000, 0, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0
Radius :500

4 : Plane
Origin :1000, 0, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0

-------
Dump of 0 Triangulations
-------



-------
Dump of 0 Locations
-------


I want to know how to output the pcurves of the wire in order. Here is the codes I am using and the output is wrong.



for(Ex.Init(W,aFace); Ex.More(); Ex.Next())
{
     aEdge1 = Ex.Current();

     aEdgeList.AddTail(aEdge1);

     Standard_Boolean Eisreversed = (aEdge1.Orientation() == TopAbs_REVERSED);
     BRep_ListIteratorOfListOfCurveRepresentation itrc((*((Handle(BRep_TEdge)*)&aEdge1.TShape()))->ChangeCurves());

     while(itrc.More())
     {
          const Handle(BRep_CurveRepresentation)& cr = itrc.Value();
          const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
          GC->Range(First,Last);

          if (cr->IsCurveOnSurface(tSurface, loc))
          {
               Handle(Geom_Surface) S = GC->Surface();
               L = aEdge1.Location() * GC->Location();

               if (GC->IsCurveOnClosedSurface() && Eisreversed)
               {
                    theCurve2d_2 = GC->PCurve2();
                    //output theCurve2d_2
                    break;
               }
               else
               {
                    theCurve2d_1 = GC->PCurve();
                    //output theCurve2d_1
                    break;
               }
          }

          itrc.Next();
     }
}
You have to be logged in to download the attached file
George Feng 2012/11/06 14:28
      WIRE: -5 +3 +2 -3
Here, '-5' represents edge 5 with reversed direction. But next edge '+3' is a seam edge, and I don't know which pcurve should be used, since there are two pcurves, as shown in the following.

- PCurve : 4, 5 (CN) on surface 3, range : 0 1000
UV Points : 6.28319, 0 6.28319, 1000
UV Points : 0, 0 0, 1000

I don't know which pcurve should be selected to be as the next one.
Forum supervisor 2012/11/07 12:10
Dear George,
You can use DRAW command <pcurve ..> to get pcurves of the face.
Also you can inspect the command implementation.
I do hope it will help you.
Regards
George Feng 2012/11/11 16:43
     Does anybody know whether WIRE: -5 +3 +2 -3 is equal to WIRE:-3 +2 +3 -5?
After inspect carefully I think, WIRE:-3 +2 +3 -5 should be a normal representaion with edge numbers from right to left, while WIRE: -5 +3 +2 -3 is an abnormal representation with edge numbers from left to right.
Am I right? Need help.
George Feng 2012/11/09 18:22
      After almost two weeks thought, I think I can resolve this problem now.
DRAW command <pcurve ..> get a wrong result after I resort the result brep file into the draw system, which should be a bug in DRAW.
As shown in the figure, PCurve2 is u=0, and PCurve1 is u=6.28. And walking along edges of the wire counterclockwisely, we can get 5, 3, 2, 3. And according to the direction of each curve, we can get -5 +3 +2 -3, where -5 means the direction of the pcurve of edge 5 is reverse with the direction of walking, +3 means the direction of the pucrve of edge 3 is accordant with the direction of wlking.
In most cases, PCurve2 is u=6.28, and PCurve1 is u=0, and DRAW command <pcurve> can work perfectly, but here PCurve2 is u=0, and PCurve1 is u=6.28.
Hope this will help others who have encountered the same problem.
You have to be logged in to download the attached file
George Feng 2012/11/09 18:32
     Sorry, ‘And walking along edges of the wire counterclockwisely, we can get 5, 3, 2, 3.’ is wrong, where counterclockwisely should be clockwisely.
If the above law is right, then the wire can also be described by another way to be +5 +3 -2 -3. And W: -5 +3 +2 -3 and W: +5 +3 -2 -3 should be the same wire with different representations, one representation is obtained by walking along the wire clockwisely and another counterclockwisely.
George Feng 2012/11/10 08:45
      I have made a mistake, still need help. I changed the position of edge 5 and edge 2 in the above picture. I post my brep file here.
You have to be logged in to download the attached file
George Feng 2012/11/10 08:48
I post the right picture here. The above law I have posted should be wrong somewhere.
You have to be logged in to download the attached file
George Feng 2012/11/10 08:50
      It should be this picture.
You have to be logged in to download the attached file
George Feng 2012/11/10 18:29
      DRAW commands are listed as follows:
Draw[1]> pload ALL
Draw[5]> restore My_cylinder_box_fused_10_2.brep s
s
Draw[7]> explo s f
s_1 s_2 s_3 s_4 s_5

Draw[8]> pcurve s_2

rouge FORWARD
bleu REVERSED
rose EXTERNAL
orange INTERNAL

Draw[10]> av2d
Draw[11]> 2dfit

After that, I only get two lines drawn in the 2d window.
Forum supervisor 2012/11/12 12:06
Dear George,
For sure there are 4 curves.
Check it more carefully.
You may use Draw command <wzoom > for this
or just try to list possible 2d curves by command
<directory s_2*>
==> s_2 s_2_1 s_2_2 s_2_3 s_2_4

Regards
Ear MongHeng 2013/01/04 18:48
Hi George Feng
After i saw your post, i want to know how can i get value of Shape like(point,origin,....).The same you:
Dump of 7 Curve2ds
-------

1 : Line
Origin :0, 0
Axis :1, 0

2 : Circle
Center :0, 0
XAxis :1, 0
YAxis :-0, 1
Radius :500

3 : Line
Origin :0, 1000
Axis :1, 0

4 : Line
Origin :6.28319, -0
Axis :0, 1

5 : Line
Origin :0, -0
Axis :0, 1

6 : Line
Origin :0, 0
Axis :1, 0

7 : Circle
Center :0, 0
XAxis :1, 0
YAxis :-0, 1
Radius :500


-------
Dump of 3 Curves
-------

1 : Circle
Center :1000, 1000, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0
Radius :500

2 : Line
Origin :1000, 0, 1500
Axis :0, 1, 0

3 : Circle
Center :1000, 0, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0
Radius :500

-------
Dump of 0 Polygon3Ds
-------
-------
Dump of 0 PolygonOnTriangulations
-------

-------
Dump of 4 surfaces
-------

1 : CylindricalSurface
Origin :1000, 1000, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0
Radius :500

2 : Plane
Origin :1000, 1000, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0

3 : CylindricalSurface
Origin :1000, 0, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0
Radius :500

4 : Plane
Origin :1000, 0, 1000
Axis :0, 1, 0
XAxis :0, -0, 1
YAxis :1, 0, -0
///////////////////////////////////

i try to write the code like these and i don't know it right or wrong:

for(ExpFace.Init(shape,TopAbs_FACE); ExpFace.More(); ExpFace.Next()) {
          TopoDS_Face face = TopoDS::Face(ExpFace.Current());
          const TopoDS_Shape& shape1 = ExpFace.Current();
          const Handle(TopoDS_TShape)& Tshape = shape1.TShape();
          if (ShapeAnalysis::IsOuterBound(face)) {
               Handle(Geom_Surface) surface = BRep_Tool::Surface(face,location);
               if(surface->IsKind(STANDARD_TYPE(Geom_Plane))) {
                    for(ExpEdge.Init(face,TopAbs_EDGE); ExpEdge.More(); ExpEdge.Next()) {
                         TopoDS_Edge edge = TopoDS::Edge(ExpEdge.Current());
                         if (!edge.IsNull()) {
                              Handle(Geom_Curve) curve = BRep_Tool::Curve(edge,first,last);
                              if (curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
print(point,origin,corrdinate...)                                   
                              }
                         }
                    }
               }
          }

     }

////////////////////////////////////////
my goal, i read a cylinder.step file and then express to xml file.

if possible,could you please explain or give me a code?

i look forward to hearing from you soon.

thank in advance
from cambodian student.(ear.mongheng@gmail.com)
 
 
Latest news
  • OCCT Applications
  • Open CASCADE Technology 6.8.0 is available for download!
  • New features to enhance the development process

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