/* returns the incenter of the inscribed circle inside the triangle defined by * points a, b, c */ HIDDEN ON_2dPoint incenter(const ON_2dPoint a, const ON_2dPoint b, const ON_2dPoint c) { fastf_t a_b, a_c, b_c, sum; ON_2dPoint incenter; a_b = a.DistanceTo(b); a_c = a.DistanceTo(c); b_c = b.DistanceTo(c); sum = a_b + a_c + b_c; incenter.x = (b_c * a.x + a_c * b.x + a_b * c.x) / sum; incenter.y = (b_c * a.y + a_c * b.y + a_b * c.y) / sum; return incenter; }
ON_BOOL32 ON_HatchExtra::Read(ON_BinaryArchive& archive) { int major_version = 0; int minor_version = 0; bool rc = archive.BeginRead3dmChunk(TCODE_ANONYMOUS_CHUNK,&major_version,&minor_version); if(major_version != 1) rc = false; m_basepoint.Set(0.0,0.0); if(rc) rc = archive.ReadUuid(m_parent_hatch); if(rc) rc = archive.ReadPoint(m_basepoint); if(!archive.EndRead3dmChunk()) rc = false; return rc; }
CRhinoCommand::result CCommandSampleIntepCrvOnSrf::RunCommand( const CRhinoCommandContext& context ) { CRhinoGetObject go; go.SetCommandPrompt( L"Select surface to draw curve on" ); go.SetGeometryFilter( CRhinoObject::surface_object); go.GetObjects( 1, 1 ); if( go.CommandResult() != CRhinoCommand::success ) return go.CommandResult(); const CRhinoObject* obj = go.Object(0).Object(); const ON_BrepFace* face = go.Object(0).Face(); if( 0 == obj || 0 == face ) return CRhinoCommand::failure; ON_SimpleArray<ON_2dPoint> points2d(25); CRhinoGetPoint gp; gp.Constrain( *face, obj->Attributes().m_wire_density ); for(;;) { gp.ClearCommandOptions(); if( points2d.Count() < 1 ) gp.SetCommandPrompt( L"Start of curve" ); else if( points2d.Count() == 1 ) gp.SetCommandPrompt( L"Next point" ); else gp.SetCommandPrompt( L"Next point. Press Enter when done" ); gp.AcceptUndo( points2d.Count() > 0 ); gp.AcceptNothing(); CRhinoGet::result res = gp.GetPoint(); if( res == CRhinoGet::cancel) return CRhinoCommand::cancel; else if ( res == CRhinoGet::undo) { points2d.Remove(); // remove last point continue; } else if( res == CRhinoGet::point) { ON_2dPoint pt; if( gp.PointOnSurface(&pt.x, &pt.y) ) { int count = points2d.Count(); if( count > 0 ) { ON_2dVector v = *points2d.At(count-1) - pt; if ( v.IsTiny()) continue; } points2d.Append( pt ); } continue; } break; } const int count = points2d.Count(); if( count > 1) { // Check for closed curve int is_closed = 0; if( count > 3 ) { ON_2dPoint pt = points2d[0]; if( pt.DistanceTo(points2d[count-1]) < ON_SQRT_EPSILON ) is_closed = 1; } double tol = context.m_doc.AbsoluteTolerance(); ON_Curve* crv = RhinoInterpolatePointsOnSurface( *face, points2d, is_closed, tol, 1 ); if( crv ) { CRhinoCurveObject* crv_obj = new CRhinoCurveObject(); crv_obj->SetCurve( crv ); context.m_doc.AddObject( crv_obj ); context.m_doc.Redraw(); } return CRhinoCommand::success; } return CRhinoCommand::success; }
void ON_HatchExtra::SetBasePoint(ON_2dPoint& point) { if(point.IsValid()) m_basepoint = point; }
void ON_HatchExtra::SetDefaults() { m_parent_hatch = ON_nil_uuid; m_basepoint.Set(0.0,0.0); }