Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8547

Emulate Tan and Perp Osnap

$
0
0

@gennaro wrote:

Hi all,

I am trying to emulate the perp and tan osnap in my code. This is pretty much how am I doing it on a curve.

void getPerpOsnap(const ON_Curve* crv, ON_SimpleArray<ON_3dPoint> & osnap){
	if(crv){
		if(const ON_PolyCurve* plycrv =  ON_PolyCurve::Cast( crv )){
			int segcount = plycrv->Count();
			for (int pc = 0 ; pc <segcount; pc++ ){
				ON_Curve* crit = plycrv->SegmentCurve(pc);
				ON_NurbsCurve nrbcrv_pc;
				if (0 != crit && crit->IsValid()){
					if(crit->GetNurbForm(nrbcrv_pc)){
						int sp = 0;
						int nonempty_sp = 0;
						while(nonempty_sp < nrbcrv_pc.SpanCount()){
							ON_BezierCurve bez;
							double tp = 0;
							if(nrbcrv_pc.ConvertSpanToBezier(sp, bez)){
								bez.Reparameterize(1);
								CRhinoSnapContext snap_ctxt;
								if(snap_ctxt.PerpSnapToBezier(bez, p0, 0, &tp)){
									double lengthSquared = (bez.PointAt(tp)-pickPoint).LengthSquared();
										if( lengthSquared < relativePointSquaredDistance){
											osnap.Append(bez.PointAt(tp));
										}
								}
								nonempty_sp++;
							}
							sp++;
						}				
					}
				}
			}
		}
	}
}

I might be wrong but I remember in Rhino5 worked fine. At the moment I cannot get the same points I get in the GUI. Same for Tan. Am I extracting the points in the wrong way?

Thanks,
Gennaro

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 8547

Trending Articles