mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0027130: Visualization, Ray tracing - skip structures with transformation persistence flag
Objects with transform persistence are detected as non ray-tracable and redered using the rasterization approach. The renderFiltered() method moved to the OpenGl_Group class. v3d/raytrace/bug27130: test case added
This commit is contained in:
parent
21c7c45701
commit
4552cb8552
@ -108,7 +108,7 @@ namespace
|
|||||||
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_Aspects)());
|
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_Aspects)());
|
||||||
theWorkspace->SetAspects (thePlane->AspectFace());
|
theWorkspace->SetAspects (thePlane->AspectFace());
|
||||||
theWorkspace->SetRenderFilter (aPrevFilter);
|
theWorkspace->SetRenderFilter (aPrevFilter);
|
||||||
if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
|
if (!theWorkspace->ShouldRender (&thePlane->Primitives(), aGroupIter.Value()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -29,29 +29,6 @@
|
|||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group)
|
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group)
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
//! Render element if it passes the filtering procedure. This method should
|
|
||||||
//! be used for elements which can be used in scope of rendering algorithms.
|
|
||||||
//! E.g. elements of groups during recursive rendering.
|
|
||||||
//! If render filter is null, pure rendering is performed.
|
|
||||||
//! @param theWorkspace [in] the rendering workspace.
|
|
||||||
//! @param theFilter [in] the rendering filter to check whether the element
|
|
||||||
//! should be rendered or not.
|
|
||||||
//! @return True if element passes the check and renders,
|
|
||||||
static bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
|
|
||||||
OpenGl_Element* theElement)
|
|
||||||
{
|
|
||||||
if (!theWorkspace->ShouldRender (theElement))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
theElement->Render (theWorkspace);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : OpenGl_Group
|
// function : OpenGl_Group
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -265,7 +242,7 @@ void OpenGl_Group::AddElement (OpenGl_Element* theElem)
|
|||||||
(myLast? myLast->next : myFirst) = aNode;
|
(myLast? myLast->next : myFirst) = aNode;
|
||||||
myLast = aNode;
|
myLast = aNode;
|
||||||
|
|
||||||
if (OpenGl_Raytrace::IsRaytracedElement (aNode))
|
if (OpenGl_Raytrace::IsRaytracedElement (aNode) && !HasPersistence())
|
||||||
{
|
{
|
||||||
myIsRaytracable = Standard_True;
|
myIsRaytracable = Standard_True;
|
||||||
|
|
||||||
@ -277,6 +254,22 @@ void OpenGl_Group::AddElement (OpenGl_Element* theElem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : renderFiltered
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
bool OpenGl_Group::renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||||
|
OpenGl_Element* theElement) const
|
||||||
|
{
|
||||||
|
if (!theWorkspace->ShouldRender (theElement, this))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
theElement->Render (theWorkspace);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : Render
|
// function : Render
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@ -52,6 +52,9 @@ public:
|
|||||||
: Handle(Graphic3d_Aspects)();
|
: Handle(Graphic3d_Aspects)();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Return TRUE if group contains primitives with transform persistence.
|
||||||
|
bool HasPersistence() const { return myStructure != NULL && !myStructure->TransformPersistence().IsNull(); }
|
||||||
|
|
||||||
//! Update aspect.
|
//! Update aspect.
|
||||||
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
|
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
|
||||||
|
|
||||||
@ -106,6 +109,18 @@ protected:
|
|||||||
|
|
||||||
Standard_EXPORT virtual ~OpenGl_Group();
|
Standard_EXPORT virtual ~OpenGl_Group();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! Render element if it passes the filtering procedure.
|
||||||
|
//! This method should be used for elements which can be used in scope of rendering algorithms.
|
||||||
|
//! E.g. elements of groups during recursive rendering.
|
||||||
|
//! If render filter is null, pure rendering is performed.
|
||||||
|
//! @param theWorkspace [in] the rendering workspace
|
||||||
|
//! @param theFilter [in] the rendering filter to check whether the element should be rendered or not
|
||||||
|
//! @return True if element passes the check and renders
|
||||||
|
Standard_EXPORT bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||||
|
OpenGl_Element* theElement) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
OpenGl_Aspects* myAspects;
|
OpenGl_Aspects* myAspects;
|
||||||
|
@ -557,6 +557,11 @@ namespace OpenGl_Raytrace
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup)
|
Standard_Boolean IsRaytracedGroup (const OpenGl_Group* theGroup)
|
||||||
{
|
{
|
||||||
|
if (theGroup->HasPersistence())
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
for (const OpenGl_ElementNode* aNode = theGroup->FirstNode(); aNode != NULL; aNode = aNode->next)
|
for (const OpenGl_ElementNode* aNode = theGroup->FirstNode(); aNode != NULL; aNode = aNode->next)
|
||||||
{
|
{
|
||||||
if (IsRaytracedElement (aNode))
|
if (IsRaytracedElement (aNode))
|
||||||
|
@ -162,6 +162,10 @@ void OpenGl_Structure::SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf)
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
void OpenGl_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||||
{
|
{
|
||||||
|
if ((myTrsfPers.IsNull() || theTrsfPers.IsNull()) && myTrsfPers != theTrsfPers)
|
||||||
|
{
|
||||||
|
++myModificationState;
|
||||||
|
}
|
||||||
myTrsfPers = theTrsfPers;
|
myTrsfPers = theTrsfPers;
|
||||||
updateLayerTransformation();
|
updateLayerTransformation();
|
||||||
}
|
}
|
||||||
@ -226,7 +230,8 @@ void OpenGl_Structure::OnVisibilityChanged()
|
|||||||
Standard_Boolean OpenGl_Structure::IsRaytracable() const
|
Standard_Boolean OpenGl_Structure::IsRaytracable() const
|
||||||
{
|
{
|
||||||
if (!myGroups.IsEmpty()
|
if (!myGroups.IsEmpty()
|
||||||
&& myIsRaytracable)
|
&& myIsRaytracable
|
||||||
|
&& myTrsfPers.IsNull())
|
||||||
{
|
{
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
@ -398,12 +398,13 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
|
|||||||
// function : ShouldRender
|
// function : ShouldRender
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement)
|
bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement,
|
||||||
|
const OpenGl_Group* theGroup)
|
||||||
{
|
{
|
||||||
// render only non-raytracable elements when RayTracing is enabled
|
// render only non-raytracable elements when RayTracing is enabled
|
||||||
if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0)
|
if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0)
|
||||||
{
|
{
|
||||||
if (OpenGl_Raytrace::IsRaytracedElement (theElement))
|
if (!theGroup->HasPersistence() && OpenGl_Raytrace::IsRaytracedElement (theElement))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -176,8 +176,9 @@ public:
|
|||||||
|
|
||||||
//! Checks whether the element can be rendered or not.
|
//! Checks whether the element can be rendered or not.
|
||||||
//! @param theElement [in] the element to check
|
//! @param theElement [in] the element to check
|
||||||
|
//! @param theGroup [in] the group containing the element
|
||||||
//! @return True if element can be rendered
|
//! @return True if element can be rendered
|
||||||
bool ShouldRender (const OpenGl_Element* theElement);
|
bool ShouldRender (const OpenGl_Element* theElement, const OpenGl_Group* theGroup);
|
||||||
|
|
||||||
//! Return the number of skipped transparent elements within active OpenGl_RenderFilter_OpaqueOnly filter.
|
//! Return the number of skipped transparent elements within active OpenGl_RenderFilter_OpaqueOnly filter.
|
||||||
//! @sa OpenGl_LayerList::Render()
|
//! @sa OpenGl_LayerList::Render()
|
||||||
|
18
tests/v3d/raytrace/bug27130
Normal file
18
tests/v3d/raytrace/bug27130
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "0027130: Visualization, Ray tracing - skip structures with transformation persistence flag"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload VISUALIZATION MODELING
|
||||||
|
|
||||||
|
vinit View1
|
||||||
|
vsetdispmode 1
|
||||||
|
|
||||||
|
restore [locate_data_file face1.brep] f
|
||||||
|
vdisplay f
|
||||||
|
box b1 25 25 25
|
||||||
|
vdisplay b1 -trsfPers zoom -trsfPersPos 0 0 0
|
||||||
|
|
||||||
|
vraytrace 1
|
||||||
|
vfit
|
||||||
|
vdump ${imagedir}/${casename}.png
|
Loading…
x
Reference in New Issue
Block a user