ON_Brep* ON_Surface::BrepForm( ON_Brep* brep ) const { ON_Brep* pBrep = NULL; if ( brep ) brep->Destroy(); // 26 August 2008 Dale Lear - fixed bug // When this function was called on an ON_SurfaceProxy //ON_Surface* pSurface = Duplicate(); ON_Surface* pSurface = DuplicateSurface(); if ( pSurface ) { if ( brep ) pBrep = brep; else pBrep = new ON_Brep(); if ( !pBrep->Create(pSurface) ) { if ( pSurface ) { delete pSurface; pSurface = NULL; } if ( !brep ) delete pBrep; pBrep = NULL; } } return pBrep; }
CRhinoCommand::result CCommandTestHistoryExample::RunCommand( const CRhinoCommandContext& context ) { CRhinoCommand::result rc = CRhinoCommand::failure; CRhinoGetObject go; go.SetCommandPrompt(L"Pick two curves"); go.SetGeometryFilter(CRhinoGetObject::curve_object); go.GetObjects(2,2); if( go.Result()== CRhinoGet::object && go.ObjectCount()==2) { CRhinoObjRef CObj0 = go.Object(0); CRhinoObjRef CObj1 = go.Object(1); const ON_Curve* c0 = CObj0.Curve(); const ON_Curve* c1 = CObj1.Curve(); if( c0 && c1) { ON_Surface* pSrf = MakeBilinearSurface( *c0, *c1); ON_Brep brep; if(pSrf && brep.Create(pSrf)) { CRhinoHistory history(*this); WriteHistory(history, CObj0, CObj1); context.m_doc.AddBrepObject(brep,NULL,&history); rc = CRhinoCommand::success; } } } return rc; }
RH_C_FUNCTION ON_Brep* ON_Brep_FromSurface( const ON_Surface* pConstSurface ) { ON_Brep* rc = NULL; if( pConstSurface ) { ON_Brep* pNewBrep = ON_Brep::New(); if( pNewBrep ) { ON_Surface* pNewSurface = pConstSurface->DuplicateSurface(); if( pNewSurface ) { if( pNewBrep->Create(pNewSurface) ) rc = pNewBrep; if( NULL==rc ) delete pNewSurface; } if( NULL==rc ) delete pNewBrep; } } return rc; }