Filletedge using C++


#1

I have a brep with many brepfaces,and want fillet all edges with the same fillet radius using c++ codes.
test.rar(1.9 MB) has the test 3dm file and the codes I write,but it can’t fillet success.
another problem:
if I using filletedge command fillet the test 3dm,will also not success.but if I explode the brep,and them join them
again,this time using filletedge command will success.


(Dale Fugier) #2

How was the Brep in Test.3dm built? If you built it with Rhino, did you change the model’s units or scale the geometry?

Also, instead of doing this:

CRhinoFilletEdge* edge = new CRhinoFilletEdge;
if( edge->FilletEdges(...) )

just do this:

if( CRhinoFilletEdge::FilletEdges(...) )

#3

dale:
I built it with rhino.and does’t change the model’s units or scale the geometry.
my problem I think is how to get the edges which can be filletted.
the function I write to get the edges have problem,because it can’t get any edges.


(Dale Fugier) #4

Can you provide me step-by-step directions on how you created the surface?


#5

next is the main codes created the surface.

on_Brep* CreateZS(ON_SimpleArray<ON_Curve*> &topcs,ON_SimpleArray<ON_Curve*>&botcs,double angle)
{
	ON_SimpleArray<ON_Brep*>breps;
	//放样生成侧面
	for(int i=0;i<botcs.Count();i++)
	{
		ON_SimpleArray<ON_Curve*>curves;
		curves.Append(botcs[i]);			
		curves.Append(topcs[i]);
		ON_SimpleArray<ON_Brep*> tempbreps ;
		g_nurbsAlg.LoftToBrep(curves,false,1,0,tempbreps);
		for(int j=0;j<tempbreps.Count();j++)
		{
			breps.Append(tempbreps[j]);
		}
	}

	
		//加盖生成顶面;
		ON_SimpleArray<const ON_Curve*>plane_crv;
		for(int i=0;i<topcs.Count();i++)
		{
			plane_crv.Append(topcs[i]);
		}
		ON_SimpleArray<ON_Brep*>topBrep;				 
		RhinoPlanarSrf(plane_crv,topBrep);
		for(int i=0;i<topBrep.Count();i++)
		{
			breps.Append(topBrep[i]);
		}
	

	//合成整体;
	ON_Brep* brep=RhinoJoinBreps(breps,0);
	if (brep)
	{
		ON_Brep * outbrep=g_nurbsAlg.BrepFillet(brep,m_angleRadius,0.2);
		if(outbrep)
		{
			delete brep;
			brep=outbrep;
		}
	}

	for(int i=0;i<breps.Count();i++)
	{
		delete breps[i];
	}

	return brep;
}

#6

can anyone give a example how to write this function

on_Brep* FilletBrep(on_Brep* in_brep,double filletRadius);


#7

help me to see my problem please


(Dale Fugier) #8

Instead of this:

ON_Brep* brep = RhinoJoinBreps( breps,0 );

Try this:

ON_Brep* brep = RhinoJoinBreps( breps, 2.1 * doc->AbsoluteTolerance() );

Does this help?


#9

dale:
this still can"t work.
can you give me a full example

on_Brep* FilletBrep(on_Brep* in_brep,double filletRadius);


(Dale Fugier) #10

https://gist.github.com/dalefugier/6553427