I have have a cylinder of diameter 80 with axis vector (200,-200,170) starting at origin and intersecting a plane offset by -200 from ZX(along y). Picture attached. Intersection is an ellipse and I was testing if I am getting correct distances to other two planes, one offset from YX by -70 (along z) and the other by 350 (along z). Creo2 (Pro/Engineer) gives distances to planes 127.50238101 and 187.50238101, but the code bellow gives

NofSol = 1
Ellipse center @: 200 -200 170
distance to front plane = 282.745 distance to back plane = 137.255

Ellipse center is correct, but the distances are not. Furthermore, for vector of the cylinder axis (0,-200,0) which is just a cylinder along y axis so the intersection is a circle. One point is correct only giving distance 30, the other distance should be 310.

NofSol = 1
Circle center @: 0 -200 0
distance to front plane = 30 distance to back plane = 390

This is all using 6.7.1. I want to think that I am doing something wrong, but I don't see what that might be. Would anybody be willing to run the function bellow and investigate? Thank you in advance.

calls made are

to the function

void getStngPts(double top,double front,double back,double stZbdyAx1, double stZbdyAx2,double stZbdyAx3, double stDia){
gp_Vec xUnit(1,0,0);
gp_Vec yUnit(0,1,0);
gp_Vec zUnit(0,0,1);

gp_Pnt top_pt(0,-top,0);
gp_Pnt front_pt(0,0,-front);
gp_Pnt back_pt(0,0,back);

gp_Pln top_pln(top_pt,gp_Dir(yUnit));
gp_Pln front_pln(front_pt,gp_Dir(zUnit));
gp_Pln back_pln(back_pt,gp_Dir(zUnit));

gp_Pnt orig(0,0,0);
gp_Dir stAxDir(gp_XYZ(stZbdyAx1,stZbdyAx2,stZbdyAx3));
gp_Ax3 stAxis(orig,stAxDir);

gp_Cylinder stCyl(stAxis,stDia/2.0);
IntAna_QuadQuadGeo Intrc(top_pln,stCyl,0.0001,0.001);
std::cout IntAna_ResultType tp=Intrc.TypeInter();

gp_Circ elC;
gp_Elips elE;
TopoDS_Edge elEdge;

if(IntAna_Circle == tp){
std::cout elEdge=BRepBuilderAPI_MakeEdge(elC);
std::cout elEdge=BRepBuilderAPI_MakeEdge(elE);

TopoDS_Face frontFace=BRepBuilderAPI_MakeFace(front_pln);
TopoDS_Face backFace=BRepBuilderAPI_MakeFace(back_pln);

BRepExtrema_DistShapeShape dist2front(elEdge, frontFace);
BRepExtrema_DistShapeShape dist2back(elEdge, backFace);

double dist2f,dist2b;

if (dist2front.IsDone()) {
dist2f = dist2front.Value();
if (dist2back.IsDone()){
dist2b = dist2back.Value();

std::cout }

Vin Yovanovich's picture

And it appears that some calculation in BRepExtrema_DistShapeShape is wrong in this case. Distance is to (I guess) a starting and ending point of the ellipse curve (different than what C++ code gave above). Here is the input to drawexe and the front view attached.

Draw[2]> cylinder c 0 0 0 200 -200 170 40
Draw[3]> plane p 0 -200 0 0 1 0
Draw[4]> intersect e c p
Draw[5]> plane pf 0 0 -70 0 0 1
Draw[6]> plane pb 0 0 350 0 0 1
Draw[8]> mkedge ed e
Draw[9]> mkface pfa pf
Draw[10]> distmini d1 ed pfa
d1_val d1
Draw[11]> mkface pba pb
Draw[13]> distmini d2 ed pba
d2_val d2
Draw[19]> dval d1_val
Draw[20]> dval d2_val