I have a CRhinoObject var name pr,if the object type is brep_object
I can get a ON_Brep var name brep using next codes.
CRhinoObjectpr;
CRhniBrepObject prbrep=(CRhinoBrepObject)pr;
const ON_Brepbrep=prbrep->Brep();
but when the object type is beam_object or extrusion_object,How can I get a ON_Brep var from pr?
menno
(Menno Deij - van Rijswijk)
2
I think the approach below might work to get it from an extrusion
const ON_Brep* brep;
CRhinoObject *pr;
CRhinoBrepObject* pBrep = dynamic_cast<CRhinoBrepObject*>(pr);
CRhinoExtrusionObject* pExtr = dynamic_cast<CRhinoExtrusionObject*>(pr);
if (pBrep)
{
brep = pBrep->Brep();
}
else if (pExtr)
{
brep = pExtr->Extrusion()->Brep();
}
Please note that beam_object
is obsolete and extrusion_object
should be used. Both point to the same object type.
dale
(Dale Fugier)
3
Method 1:
const CRhinoObject* obj = ???;
if (obj)
{
if (obj->ObjectType() == ON::extrusion_object)
{
const ON_Extrusion* extrusion = ON_Extrusion::Cast(obj->Geometry());
if (extrusion)
{
ON_Brep brep;
if (extrusion->BrepForm(&brep, true))
{
// TODO: do something with brep here...
}
}
}
}
Method 2:
const CRhinoObject* obj = ???;
if (obj)
{
if (obj->ObjectType() == ON::extrusion_object)
{
const ON_Extrusion* extrusion = ON_Extrusion::Cast(obj->Geometry());
if (extrusion)
{
ON_Brep* brep = ON_Brep::New();
if (brep == extrusion->BrepForm(brep, true))
{
// TODO: do something with brep here...
}
delete brep; // don't leak...
}
}
}