Home
Reply
Regular Contributor
Posts: 48

Computing orientation of the COEDGE

Hi,

 

A question about orientation of COEDGEs.

 

Is the following code for computing the tangent to coedge (aligned with its actual orientation so that the face is on the left side) correct?
================================================
REVBIT sens = FORWARD;
COEDGE * coedg0 = (COEDGE *)coedg_List[0];
if(coedg0->sense() == REVERSED)
{
sens = sens ^ 1;
}
if(fac0->sense() == REVERSED)
{
sens = sens ^ 1;
}
EDGE * edg0 = coedg0->edge();
const curve * cur = &(edg0->geometry()->equation());
SPAunit_vector unitTang = cur->eval_direction(curveParam);
unitTang = unitTang * bodyTrans;

if(sens == REVERSED)
{
unitTang = - unitTang;
}
================================================

 

The above code does not seem to work with the attached model (tool.sat).

I tried the above on the attached sat file and plotted the tangent (cotangentOrient.jpg) and it looks like the face is on the right side of the cotangent.

 

Thanks in advance for any help.

 

Jinesh.

Highlighted
Regular Contributor
Posts: 94

Re: Computing orientation of the COEDGE

There are 2 COEDGES on one EDGE. It seems that you give COEDGE for triangular FACE near from your FACE.

 

Also there is no need to consider the FACE/SURFACE relationship in "fac0->sense()" because FACE describes own COEDGES in right direction.

 

COEDGE * coedg0 = (COEDGE *)coedg_List[0];
EDGE * edg0 = coedg0->edge();

const curve * cur = &(edg0->geometry()->equation());
SPAunit_vector unitTang = cur->eval_direction(curveParam);
unitTang = unitTang * bodyTrans;

if(coedg0->sense(edg0->sense()))
{
unitTang = - unitTang;
}

 

Regular Contributor
Posts: 48
0

Re: Computing orientation of the COEDGE

Hello Vi2,

 

I tried your suggestion but that did not solve the problem.  In order to be sure that I am working with the correct FACE, i plotted a point on that FACE.  Here is the code and the attached the image (coedgeOrient2.jpg)

 

api_get_faces(entList.first(), face_List);
FACE * fac0 = (FACE *)face_List[0];

SPApar_box parBox;
int result = sg_get_face_par_box(fac0, parBox);
SPApar_pos facParPos(parBox.u_range().mid_pt(), parBox.v_range().mid_pt());
SPAposition facPos = surf->eval_position(facParPos);
facPos = facPos * bodyTrans;
APOINT * pnt = ACIS_NEW APOINT(facPos);
renderList.add(pnt);

api_get_coedges(fac0, coedg_List);
COEDGE * coedg0 = (COEDGE *)coedg_List[coid];
EDGE * edg0 = coedg0->edge();

const curve * cur = &(edg0->geometry()->equation());
SPAinterval edgIntrvl = edg0->param_range();
double param = edgIntrvl.mid_pt();

SPAunit_vector unitTang = cur->eval_direction(param);	
unitTang = unitTang * bodyTrans;

if(coedg0->sense(edg0->sense()))
{	
	unitTang = - unitTang;
}

 

An associated question is that how are the orientations of the COEDGE and the underlying pcurve (coedge->geometry()->equation()) related?

 

Thanks and kind regards,

Jinesh.

coedgeOrient2.jpg
Regular Contributor
Posts: 94
0

Re: Computing orientation of the COEDGE

I don't see any troubles with your sat file. You should write numerical values of point and vector that you have calculated.

 

It seems that your SC is left-hand oriented. Maybe there is a problem.

Regular Contributor
Posts: 48
0

Re: Computing orientation of the COEDGE

Thats right, the coordinate system was left-handed.  Thanks for pointing that out. 

I feel stupid :-)