Edge points are different when evaluated from curves using params

I am using the following code -

BRep_ListIteratorOfListOfCurveRepresentation itcr;
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) & edge.TShape());
const TopLoc_Location& Eloc = edge.Location();

const BRep_ListOfCurveRepresentation& aLCR = TE->Curves();

TopoDS_Vertex v1a, v1b;
TopExp::Vertices(edge, v1a, v1b);

gp_Pnt pnt1a = BRep_Tool::Pnt(v1a);
gp_Pnt pnt2a = BRep_Tool::Pnt(v1b);
//
itcr.Initialize(aLCR);
gp_Pnt2d aPC2D1, aPC2D2;
gp_Pnt aPC3D1, aPC3D2;
for (; itcr.More(); itcr.Next())
{
	const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
	const TopLoc_Location& loc = cr->Location();
	TopLoc_Location L = (Eloc * loc);

	if (cr->IsCurve3D())
	{
		const Handle(Geom_Curve)& aC3D = cr->Curve3D();
		//
		if (aC3D.IsNull())
		{
			continue;
		}
		
		Standard_Real aParam1, aParam2;
		aParam1 = BRep_Tool::Parameter(v1a, edge);
		aPC3D1 = aC3D->Value(aParam1);

		aParam2 = BRep_Tool::Parameter(v1b, edge);
		aPC3D2 = aC3D->Value(aParam2);
	}

	else if (cr->IsCurveOnSurface())
	{
		const Handle(Geom2d_Curve)& aC2D = cr->PCurve();
		if (aC2D.IsNull())
		{
			continue;
		}

		const Handle(Geom_Surface)& aS = cr->Surface();

		Standard_Real aParam1, aParam2;
		aParam1 = BRep_Tool::Parameter(v1a, edge, aS, L);
		aPC2D1 = aC2D->Value(aParam1);

		aParam2 = BRep_Tool::Parameter(v1b, edge, aS, L);
		aPC2D2 = aC2D->Value(aParam2);
	}
}

Here are the values that I get -

aPC2D1 : { x = 0.014740, y = 16.048112 } [gp_Pnt2d]
aPC2D2 : { x = 0.412034, y = 16.459913 } [gp_Pnt2d]

aPC3D1 : { x = 0.014740, y = 16.048112, z = 0.000000 } [gp_Pnt]
aPC3D2 : { x = 0.412034, y = 16.459913, z = 0.000000 } [gp_Pnt]

pnt1a : { x = 0.013663, y = 16.049987, z = 0.000000 } [gp_Pnt]
pnt2a : { x = 0.411037, y = 16.461870, z = 0.000000 } [gp_Pnt]

As you can see, when points are calculated from edge, they are slightly different than the ones calculated from curves. (x = 0.013663 vs x = 0.014740) Is this expected? I am getting wrong results in my algorithm due to this difference.

Dmitrii Pasukhin's picture

Hello. It is no really the same values to compare without tolerances. You compare the topology based values, which must be in the range [curve  UV +- tolerance]. And just curve UV space. So, topology is not always have the same values as geometry.

In some cases they can be the same, but it is not obligated.

Also one remark to your code, they can be reversed, based on orientation.

Best regards, Dmitrii.

Roman Lygin's picture

Hi Rajendra,
That's the essence of the local tolerances in a B-Rep model (Open CASCADE or any other B-Rep kernel). The gap between different geoemtric representations must be within a tolerance.

You should likely find the description in the documentation. If curious, here's a brief blog-post I wrote 16 years ago - https://opencascade.blogspot.com/2009/02/topology-and-geometry-in-open-c...

Best regards,
Roman

Le Pharaon's picture

You should likely find the description in the documentation. If curious, here's a brief blog-post I wrote 16 years ago - https://opencascade.blogspot.com/2009/02/topology-and-geometry-in-open-c...

How many years have passed, and the information is still relevant