Draw Breps in Display conduit

Hello,

When drawing Breps in display conduits, how can I draw both the shaded material and the main isocurves with corresponding occlusion?

In other words, I want to draw something like this:

In my code, using CRhinoDisplayPipeline::DrawShadedBrep and CRhinoDisplayPipeline::DrawBrep I have this:

How do I get the first one?

Many thanks,
Pablo

I’ve moved this to a new topic…

Please post a file with the model, that always helps when answering a question. Also, how did you obtain the first picture?

Actually the first picture is a Rhino sphere, this is my target.

I found the second one with the following piece of code:

class CDrawBrepConduit : public CRhinoDisplayConduit
{
public:
	CDrawBrepConduit();

	bool ExecConduit(CRhinoDisplayPipeline& dp, UINT channel, bool& bTerminate);

	ON_Brep m_brep;
	int m_wireDensity;
	COLORREF m_color;
};


CDrawBrepConduit::CDrawBrepConduit()
	: CRhinoDisplayConduit(CSupportChannels::SC_CALCBOUNDINGBOX | CSupportChannels::SC_DRAWOVERLAY)
{
	m_wireDensity = 1;
	m_color = RGB(0, 0, 0);
}

bool CDrawBrepConduit::ExecConduit(CRhinoDisplayPipeline& dp, UINT channel, bool& bTerminate)
{
	UNREFERENCED_PARAMETER(bTerminate);
	if (channel == CSupportChannels::SC_CALCBOUNDINGBOX) {
		if (m_brep.IsValid()) {
			m_pChannelAttrs->m_BoundingBox.Union(m_brep.BoundingBox());
		}
	}
	else if (channel == CSupportChannels::SC_DRAWOVERLAY) {
		if (m_brep.IsValid()) {
			CDisplayPipelineMaterial mat = dp.DisplayAttrs()->m_pMaterial->m_FrontMaterial;
			dp.DrawBrep(m_brep, m_color, m_wireDensity);
			CRhinoCacheHandle cache;
			dp.DrawShadedBrep(&m_brep, &mat, &cache);
		}
	}
	return true;
}

DrawBrep draws the isocurves and DrawShadedBrep draws the material. As you see, the isocurves are not occluded by the material right now. May this be achieved when drawing in different channels or pipeline steps?

Pablo

Hi @pagarcia,

Is the second image a surface of revolution or a NURBS surface? The Sphere command makes the former.

– Dale

Hi Pablo,

@dale is the man to ask. We use the code from Dale.

Hi @dale,

Here I attach a solution obtaining the second picture:
SampleDrawBrep.zip (36.4 KB)

I get the brep of a Rhino sphere just like this:

ON_Sphere sphere(ON_3dPoint(0, 0, 0), 10.0);
ON_Brep* brep = ON_BrepSphere(sphere);

The question is: how to get isocurve occlusion (the brep material hiding the isocurves in the back with respect to camera point of view)?
I think it’s related to the order of drawing in DrawBrep / DrawShadedBrep and the display conduit channels.

Many thanks,
Pablo

Hi @pagarcia,

This sample seems to draw a sphere (surface of revoluation) like Rhino’s default Shaded display mode would draw the output of the Sphere command.

cmdSampleDrawBrep.cpp

– Dale

Awesome!! Thank you very much.

Pablo