GetIsoCurves

I write 2 functions to get a brepface or a surface iso curves
most time these functions work fine,but sometimes will get a lot confused curves.
test.rar (1.3 MB) is the test 3dm file which has a brepface and a surface.

The test code like that:

void Test(ON_Brep*in_b,int uNum,int vNum)
{
if(in_b->m_S.Count()>1)
{
return ;
}

ON_SimpleArray<ON_Curve*>ucs;
ON_SimpleArray<ON_Curve*>vcs;
if(in_b->IsSurface())
{
	GetIsoCs(in_b->m_S[0],uNum,ucs,0);
	GetIsoCs(in_b->m_S[0],vNum,vcs,1);
}
else
{
	GetBrepFaceIsoCs(in_b->Face(0),uNum,ucs,0);
	GetBrepFaceIsoCs(in_b->Face(0),vNum,vcs,1);
}

}

void GetIsoCs(ON_Surface* face,int Count,ON_SimpleArray<ON_Curve*>&out_cs,int dir)
{
ON_Interval udomain= face->Domain(dir);
double uAdd=(udomain.Max()-udomain.Min())/Count;
double c=udomain.Min();
for(int i=0;i<Count;i++)
{
ON_Curve*cc=face->IsoCurve(dir,c);
if(cc)
{
out_cs.Append(cc);
}
c+=uAdd;
if(i==Count-2)
{
c=udomain.Max();
}
}
}

void GetBrepFaceIsoCs(ON_BrepFace* face,int Count,ON_SimpleArray<ON_Curve*>&out_cs,int dir)
{
ON_Interval udomain= face->Domain(dir);
double uAdd=(udomain.Max()-udomain.Min())/Count;
double c=udomain.Min();
for(int i=0;i<Count;i++)
{
ON_SimpleArray<ON_Curve*>cs;
face->GetIsoCurves(dir,c,cs);
for(int j=0;j<cs.Count();j++)
{
out_cs.Append(cs[j]);
}
c+=uAdd;
if(i==Count-2)
{
c=udomain.Max();
}
}
}

test.rar also has the test codes.

Have you tried using RhinoGetBrepFaceIsoCurves(). See rhinoSdkUtilities.h for details.

RhinoGetBrepFaceIsoCurves can get the brepface isocurves,but I also need get the surface isocurves,and
i want know why GetIsoCs function I writed can’t work fine

A brep face is just a proxy to the underlying surface, Here is a diagram you might find helpful.

Trust me, use RhinoGetBrepFaceIsoCurves().

@dale, @NiceDay replied RhinoGetBrepFaceIsoCurves() can get good isocurves from brepface. He would like to know why GetIsoCs() works for most cases, but not for the two surfaces in the 3dm that he has attached. The on_surface isocurves extracted from the two surfaces by GetIsoCs() are pretty messed up, too long and not even on the surface. Implementing RhinoGetBrepFaceIsoCurves() in GetIsoCs() doesn’t make it work. Can you please test GetIsoCs() with the two surfaces and see what is wrong?

The following sample command seems to work just fine on the shoe shaped surface. But it will not work on the trimmed surface as ON_Surface::IsoCurve only works on the underlying surface, not the trimmed ON_BrepFace, which is why I suggested using RhinoGetBrepFaceIsoCurves()

Anyway, here is a link to my sample command.

I should note that I didn’t run his sample code because it is incomplete. In the future, he should provide a full working command sample (.CPP).

Also, I don’t know what “pretty messed up” means. You might have to elaborabe for me to be any more helpful.

dale:
Thanks very much.
you sample comand is work fine
and I know what problem in my code after see you sample.
the problem is next two line codes used the same dir params.
in fact ,they should use the opposite params.
when Domain using 0,then GetIsoCurves should using 1.
ON_Interval udomain= face->Domain(dir);
face->GetIsoCurves(dir,c,cs);