For imported step files how is a cylindrical face function ".Location()" calculated ?

Suppose I import the step file in the attached image. You can see I have two cylindrical faces selected. If I call the following code

Handle(Geom_CylindricalSurface) firstCylinder = ...
Handle(Geom_CylindricalSurface) secondCylinder = ...

gp_Ax1 axis1 = firstCylinder->Cylinder().Axis();
gp_Ax1 axis2 = secondCylinder->Cylinder().Axis();

gp_Pnt point1 = axis1.Location();
gp_Pnt point2 = axis2.Location();

Will point 1 always equal point 2 ? When I tested it against the step file (from the attached image) the two points it DID match. The two cylinders also had the same "vMin" and "vMax".

In what situation will the two cylinders "Location()" not match ? I suppose if they have different "vMin" and "vMax" ?? I guess im more wondering how is the .Location() calculated for cylindrical faces that are imported like the step file in the image.

gkv311 n's picture

gp_Cylinder location is not calculated from cylinder, it is how cylinder was defined in the first place.

Whether they match or not will depend on how cylinders were modeled, hence you'll need to take various considerations depending on what you are trying to do with this information.

For instance, the following script defines two cylinders in Draw Harness:

pload MODELING VISUALIZATION
plane p1 0 0 -100 0 0  1
plane p2 0 0  100 0 0 -1
pcylinder c1 p1 50 200
pcylinder c2 p2 50 200
axo
donly c1 c2
fit
explode c1 F
explode c2 F
dumpjson c1_1
dumpjson c2_1

These cylinders geometrically match to each other, but have different definition. You may see from the dump:

    "Surface": {
      "className": "Geom_CylindricalSurface",
      "className": "Geom_ElementarySurface",
      "className": "Geom_Surface",
      "className": "Geom_Geometry",
      "pos": {
        "Location": [0, 0, -100],
        "Direction": [0, 0, 1],
        "XDirection": [1, 0, -0],
        "YDirection": [-0, 1, 0]
      },
      "radius": 50
    },

and for another cylinder:

    "Surface": {
      "className": "Geom_CylindricalSurface",
      "className": "Geom_ElementarySurface",
      "className": "Geom_Surface",
      "className": "Geom_Geometry",
      "pos": {
        "Location": [0, 0, 100],
        "Direction": [0, 0, -1],
        "XDirection": [-1, 0, -0],
        "YDirection": [0, 1, 0]
      },
      "radius": 50
    },

This is only one of the ways to define the same cylinder differently in B-Rep.

Alfredo Gutierrez's picture

Hello Sir,

Yes that makes sense perhaps maybe I did not explain my situation. I am not directly creating a gp_Cylinder with a constructor I am just getting a Geom_CylindricalSurface from a imported step file selected face which then I get the gp_Cylinder. I then call the Axis() on both of the cylinders, I want to call IsCoaxial on them. The method IsCoaxial checks the distance between them using Location()

I am wondering for imported step files how will this Location() be calculated since I am not creating gp_Cylinder() with a constructor. I am just selecting a face and then calling Geom_CylindricalSurface then gp_Cylinder() ... I am assuming however the cylinder was defined in the STEP file is how Location() is calculated ?

In the attached image (original post) if I call IsCoaxial with low tolerances on both of the cylinders it returns true (which is what I expect) but I want to figure out exactly Location() is calculated for imported step files to handle edge cases.

I hope I explained my self correctly

Please let me know if I need to clarify :3

gkv311 n's picture

I am wondering for imported step files how will this Location() be calculated since I am not creating gp_Cylinder() with a constructor.

OCCT will read cylinder definition as it was written into STEP file by originating system. Hence, it could be defined in various ways. Cannot say which kind of input you would like to handle practically speaking, but in general case there might be a lot of deviations.

pload MODELING VISUALIZATION
plane p1 0 0 -100 0 0  1
plane p2 0 0  100 0 0 -1
pcylinder c1 p1 50 200
pcylinder c2 p2 50 200
axo
donly c1 c2
fit
explode c1 F
explode c2 F
dumpjson c1_1
dumpjson c2_1

pload XDE
testwritestep c1_1.step c1_1
testwritestep c2_1.step c2_1
testreadstep c1_1.step cc1
testreadstep c2_1.step cc2
explode cc1 F
explode cc2 F
dumpjson cc1_1
dumpjson cc2_1
Alfredo Gutierrez's picture

Thank you!