RhinoSweep2 C++

Hi,

I tried to find a bit of information about how to generate Sweep2 and didnt really solve the problem. I know it is a bit of a hassle working with Argument classes and that everything has to fit perfectly, but I hope you will be able to tell me why my Sweep2 Function doesn`t work, and if there is a quick fix…thanks!

bool Sweep2( ON_Curve* rail1, ON_Curve* rail2, ON_SimpleArray<ON_Curve*> sectioncrvs, ON_SimpleArray<ON_Brep*> brep_arr)
{
    CArgsRhinoSweep2 args;
	int i,j;

	 CRhinoPolyEdge edge1,edge2;
	 
	 edge1.Create( rail1 );
	 edge2.Create( rail2 );

		args.m_rail_curves[0] = &edge1;
		args.m_rail_curves[1] = &edge2;

		for( i = 0; i < sectioncrvs.Count(); i++ )
		{				
			args.m_shape_curves.Append( const_cast<ON_Curve*>(sectioncrvs[i]));
		
				//find the parameters
					ON_3dPointArray respts1, respts2;

					IntersectCurveCurve(sectioncrvs[i], rail1, respts1); //THIS IS MY FUNCTION THAT WORKS PROPERLY - I CHECKED
					IntersectCurveCurve(sectioncrvs[i], rail2, respts2); //THIS IS MY FUNCTION THAT WORKS PROPERLY - I CHECKED

					if(respts1.Count() >0 )
					{						
						double t;
						sectioncrvs[i]->GetClosestPoint( respts1[0], &t );
						args.m_rail_params[0].Append( t );
					}

					if(respts2.Count() >0 )
					{						
						double t;
						sectioncrvs[i]->GetClosestPoint( respts2[0], &t );
						args.m_rail_params[1].Append( t );
					}										
		}

			args.m_bClosed = false; 
			args.m_bSimpleSweep = true;
			args.m_simplify = 0; // Simplify method for shape curves
			args.m_rebuild_count = -1; // Sample point count for rebuilding shapes
			args.m_refit_tolerance = 0.01;
			args.m_sweep_tolerance =0.01;
			args.m_angle_tolerance =0.01;// RhinoApp().ActiveDoc()->AngleToleranceRadians();

		RhinoSweep2(args, brep_arr );


	return true;
}

Hi Milos,

Does this sample help you?

cmdSampleSweep2Point.cpp

– Dale

Thanks Dale,

I will try it out and let you know. Can you tell me what the start_pt and end_pt represent in this function? They confused me from the start when I saw them in the argument list…

If I select the two rails left and right and the line bellow as the cross section…I get to select one “end point”…this is the result: (I tried changing the code to select two points above , start_pt and end_pt, but then nothing gets generated)

Sweep2 allows for optional starting and end point as cross sections (for lack of better term). See the Sweep2 command help for details. Note, these points are not required…

Thanks. It did work at the end. The end points should be avoided (if you do not specifically want to have a point instead of a cross section) and you have to check your directions…for example rail curves have to have the same orientation apparently…

Hi all,
I am having the same problem but I cannot find a way to get the sweep 2 in my plug-in. The example simply gives me nothing, while with the same curves the command Sweep2 in Rhino generates the surface I need.
If I use the end point I have the same @dimcic got in his picture. By the way I really need to sweep curved curves and defining the curve with points does not seem to be a suitable option.
Anybody has a suggestion?
Thanks!!

Hi @gennaro,

Can you provide the source code and the geometry that you’re unable to make work?

Thanks,

– Dale

Hi Dale!
I have tried these two:


The first works only with points and I just cannot make the second work with any geometry… Am I doing something wrong?
Thanks for your reply

Can you also provide some sample geometry - thanks.

– Dale

Dale,
this is a simple case for example…
Sweep2.3dm (15.1 KB)

Hi @gennaro,

Keep on mind that RhinoSweep2 does not do any curve ordering or sorting. So you’ll need to do this on your own.

For example, the starting points of the two rails curves are not on or near the shape curve. So, you will want to reverse the order of these.

– Dale

Dale,

I changed the geometry as you said but still I get nothing… am I mistaken?
Sweep2.3dm (15.1 KB)

G.

Hi @gennaro,

See if Rhino2RailSweep isn’t any easier for you.

– Dale

Brilliant! it works!!
Thank you very much!