1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Denis BOGOLEPOV
1636fd05f6 0027223: Visualization, Ray Tracing - add support of clipping planes 2016-03-03 13:38:45 +03:00
abv
9baa853415 Revert "0026314: Method SetShape working not correctly."
This reverts commit e2df45413e.
2016-02-17 12:33:27 +03:00
18 changed files with 357 additions and 206 deletions

View File

@@ -75,4 +75,8 @@ vbsdf r -kd 0.5 0.9 0.3 -ks 0.0 -kr 0.3 -n
vbsdf r -fresnel Constant 1.0
vsetlocation r 0.5 0.65 0.1
vclipplane create pln
vclipplane change pln equation 0 0 -1 0.1
vclipplane set pln object s
vrenderparams -ray -gi -rayDepth 8

View File

@@ -44,10 +44,6 @@
#include <TColStd_Array1OfInteger.hxx>
#include <TopTrans_CurveTransition.hxx>
#include <BRepAdaptor_HCurve2d.hxx>
#include <Geom_Curve.hxx>
#include <BRep_Tool.hxx>
#define Tolpetit 1.e-10 // pour dist au carre
#define tole 5.e-6
@@ -539,23 +535,6 @@ static void ComputeTangency (const Contap_TheSearch& solrst,
const Handle(Adaptor2d_HCurve2d)& thearc = PStart.Arc();
theparam = PStart.Parameter();
gp_Pnt2d Ptoproj=Contap_HCurve2dTool::Value(thearc,theparam);
//jgv: for the issue 24103 to exclude points that are not same parameter:
//these points can be out of the surface's domain and lead to failure of Walking algorithm.
gp_Pnt PointFromSurf = Surf->Value(Ptoproj.X(), Ptoproj.Y());
Handle(BRepAdaptor_HCurve2d) brhc = Handle(BRepAdaptor_HCurve2d)::DownCast(thearc);
TopoDS_Edge theedge = brhc->ChangeCurve2d().Edge();
Standard_Real fpar, lpar;
Handle(Geom_Curve) thecurve = BRep_Tool::Curve(theedge, fpar, lpar);
if (!thecurve.IsNull())
{
gp_Pnt PointFromEdge = thecurve->Value(theparam);
Standard_Real TolEdge = BRep_Tool::Tolerance(theedge);
if (PointFromSurf.Distance(PointFromEdge) > 2.*TolEdge)
continue;
}
//////////////////////////////////////////////////////////
//-- lbr le 15 mai 97
//-- On elimine les points qui sont egalement present sur une restriction solution
Standard_Boolean SurUneRestrictionSolution = Standard_False;

View File

@@ -54,7 +54,7 @@ public:
}
//! Pass clip planes to the associated graphic driver structure
void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes) { myClipPlanes = thePlanes; }
virtual void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes) { myClipPlanes = thePlanes; }
//! @return bounding box of this presentation
const Graphic3d_BndBox4f& BoundingBox() const

View File

@@ -520,6 +520,18 @@ Standard_Boolean OpenGl_RaytraceGeometry::UpdateTextureHandles (const Handle(Ope
return Standard_True;
}
// =======================================================================
// function : OpenGl_RaytraceClipPlanes
// purpose : Creates new set of clipping planes
// =======================================================================
OpenGl_RaytraceClipPlanes::OpenGl_RaytraceClipPlanes()
{
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < MAX_PLANE_NUMBER; ++aPlaneIdx)
{
myClipPlanes[aPlaneIdx * 2] = BVH_Vec4f (-1.f, -1.f, -1.f, -1.f);
}
}
namespace OpenGl_Raytrace
{
// =======================================================================

View File

@@ -223,6 +223,133 @@ private:
};
//! Set of clipping planes specific for OpenGL primitive array.
class OpenGl_RaytraceClipPlanes
{
public:
//! Maximum number of clipping planes used in ray-tracing for each
//! OpenGL primitive array. This is not implementation restriction,
//! but it is reasonable to limit max number of planes in order to
//! simplify GLSL data representation.
static const Standard_Integer MAX_PLANE_NUMBER = 8;
//! State of clipping plane.
enum ClipPlaneState {
CLIP_PLANE_OFF = -1, //!< plane is deactivated
CLIP_PLANE_VIEW = 0, //!< plane is in view space
CLIP_PLANE_WORLD = 1 //!< plane is in world space
};
//! Wrapper for clipping plane configuration.
class ClipPlane
{
public:
//! Creates new clipping plane wrapper.
ClipPlane (BVH_Vec4f& theSettings,
BVH_Vec4f& theEquation) : mySettings (theSettings),
myEquation (theEquation) {}
//! Sets 4D equation vector for clipping plane.
void SetEquation (const BVH_Vec4d& theEquation, const ClipPlaneState theState = CLIP_PLANE_WORLD)
{
for (Standard_Integer anIndex = 0; anIndex < 4; ++anIndex)
{
myEquation[anIndex] = static_cast<Standard_ShortReal> (theEquation[anIndex]);
}
SetState (theState);
}
//! Returns state of clipping plane.
ClipPlaneState State()
{
return static_cast<ClipPlaneState> (mySettings.x());
}
//! Sets state of clipping plane.
void SetState (const ClipPlaneState theState)
{
mySettings.x() = static_cast<Standard_ShortReal> (theState);
}
private:
//! Settings of clipping plane.
BVH_Vec4f& mySettings;
//! 4D equation vector of clipping plane.
BVH_Vec4f& myEquation;
};
public:
//! Creates new set of clipping planes.
OpenGl_RaytraceClipPlanes();
//! Returns clipping plane for the given index.
ClipPlane operator[] (const Standard_Integer theIndex)
{
return ClipPlane (myClipPlanes[theIndex * 2 + 0],
myClipPlanes[theIndex * 2 + 1]);
}
//! Returns packed (serialized) representation of clipping planes set.
const Standard_ShortReal* Packed()
{
return reinterpret_cast<Standard_ShortReal*> (this);
}
private:
//! Serialized clipping planes storage.
BVH_Vec4f myClipPlanes[MAX_PLANE_NUMBER * 2];
};
//! Stores transform properties of ray-tracing object.
class OpenGl_RaytraceTransform : public BVH_Transform<Standard_ShortReal, 4>
{
public:
//! Value of invalid clipping plane set.
static const Standard_Integer NO_CLIPPING = -1;
public:
//! Creates new identity transformation.
OpenGl_RaytraceTransform() : BVH_Transform<Standard_ShortReal, 4>()
{
myClipSetID = NO_CLIPPING; // no clipping by default
}
//! Creates new transformation with specified matrix.
OpenGl_RaytraceTransform (const BVH_Mat4f& theTransform) : BVH_Transform<Standard_ShortReal, 4> (theTransform)
{
myClipSetID = NO_CLIPPING; // no clipping by default
}
//! Returns ID of associated set of clipping planes.
Standard_Integer ClipSetID() const
{
return myClipSetID;
}
//! Sets ID of associated set of clipping planes.
void SetClipSetID (const Standard_Integer theClipSetID)
{
myClipSetID = theClipSetID;
}
protected:
//! ID of associated set of clipping planes.
Standard_Integer myClipSetID;
};
//! Stores geometry of ray-tracing scene.
class OpenGl_RaytraceGeometry : public BVH_Geometry<Standard_ShortReal, 3>
{
@@ -247,6 +374,10 @@ public:
std::vector<OpenGl_RaytraceMaterial,
NCollection_StdAllocator<OpenGl_RaytraceMaterial> > Materials;
//! Array of sets of clipping plane parameters.
std::vector<OpenGl_RaytraceClipPlanes,
NCollection_StdAllocator<OpenGl_RaytraceClipPlanes> > ClipPlanes;
//! Global ambient from all light sources.
BVH_Vec4f Ambient;

View File

@@ -241,6 +241,20 @@ void OpenGl_Structure::SetAspectText (const CALL_DEF_CONTEXTTEXT &theAspect)
myAspectText->SetAspect (theAspect);
}
// =======================================================================
// function : SetClipPlanes
// purpose :
// =======================================================================
void OpenGl_Structure::SetClipPlanes (const Graphic3d_SequenceOfHClipPlane &thePlanes)
{
Graphic3d_CStructure::SetClipPlanes (thePlanes);
if (IsRaytracable())
{
++myModificationState;
}
}
// =======================================================================
// function : clearHighlightBox
// purpose :

View File

@@ -129,6 +129,9 @@ public:
Standard_EXPORT void Clear (const Handle(OpenGl_Context)& theGlCtx);
//! Pass clip planes to the associated graphic driver structure
void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes);
//! Renders groups of structure without applying any attributes (i.e. transform, material etc).
//! @param theWorkspace current workspace
//! @param theHasClosed flag will be set to TRUE if structure contains at least one group of closed primitives

View File

@@ -702,12 +702,13 @@ protected: //! @name data types related to ray-tracing
OpenGl_RT_RaytraceMaterialTexture = 9,
OpenGl_RT_RaytraceLightSrcTexture = 10,
OpenGl_RT_RaytraceClippingTexture = 11,
OpenGl_RT_FsaaInputTexture = 11,
OpenGl_RT_PrevAccumTexture = 12,
OpenGl_RT_FsaaInputTexture = 12,
OpenGl_RT_PrevAccumTexture = 13,
OpenGl_RT_OpenGlColorTexture = 13,
OpenGl_RT_OpenGlDepthTexture = 14
OpenGl_RT_OpenGlColorTexture = 14,
OpenGl_RT_OpenGlDepthTexture = 15
};
//! Tool class for management of shader sources.
@@ -1032,6 +1033,8 @@ protected: //! @name fields related to ray-tracing
Handle(OpenGl_TextureBufferArb) myRaytraceMaterialTexture;
//! Texture buffer of light source properties.
Handle(OpenGl_TextureBufferArb) myRaytraceLightSrcTexture;
//! Texture buffer of clipping planes parameters.
Handle(OpenGl_TextureBufferArb) myRaytraceClippingTexture;
//! 1st framebuffer (FBO) to perform adaptive FSAA.
Handle(OpenGl_FrameBuffer) myRaytraceFBO1[2];

View File

@@ -403,7 +403,7 @@ Standard_Boolean OpenGl_View::addRaytraceStructure (const OpenGl_Structure*
return Standard_True;
}
// Get structure material
// Get material of the structure
OpenGl_RaytraceMaterial aStructMaterial;
if (theStructure->AspectFace() != NULL)
@@ -435,6 +435,45 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
const Graphic3d_Mat4* theTransform,
const Handle(OpenGl_Context)& theGlContext)
{
// ID of clipping plane set
Standard_Integer aClipSetID = -1;
// Collect clipping planes of structure scope
if (!theStructure->ClipPlanes().IsEmpty())
{
NCollection_Handle<Graphic3d_SequenceOfHClipPlane> aUserPlanes;
for (Graphic3d_SequenceOfHClipPlane::Iterator aClipIter (theStructure->ClipPlanes()); aClipIter.More(); aClipIter.Next())
{
const Handle(Graphic3d_ClipPlane)& aClipPlane = aClipIter.Value();
if (aClipPlane->IsOn())
{
if (aUserPlanes.IsNull())
{
aUserPlanes = new Graphic3d_SequenceOfHClipPlane();
}
aUserPlanes->Append (aClipPlane);
}
}
if (!aUserPlanes.IsNull())
{
myRaytraceGeometry.ClipPlanes.push_back (OpenGl_RaytraceClipPlanes());
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < aUserPlanes->Size(); ++aPlaneIdx)
{
if (aPlaneIdx < OpenGl_RaytraceClipPlanes::MAX_PLANE_NUMBER)
{
myRaytraceGeometry.ClipPlanes.back()[aPlaneIdx].SetEquation (aUserPlanes->operator ()(aPlaneIdx + 1)->GetEquation());
}
}
aClipSetID = static_cast<Standard_Integer> (myRaytraceGeometry.ClipPlanes.size() - 1);
}
}
for (OpenGl_Structure::GroupIterator aGroupIter (theStructure->DrawGroups()); aGroupIter.More(); aGroupIter.Next())
{
// Get group material
@@ -476,13 +515,18 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
{
OpenGl_TriangleSet* aSet = aSetIter->second;
BVH_Transform<Standard_ShortReal, 4>* aTransform = new BVH_Transform<Standard_ShortReal, 4>();
OpenGl_RaytraceTransform* aTransform = new OpenGl_RaytraceTransform;
if (theTransform != NULL)
{
aTransform->SetTransform (*theTransform);
}
if (aClipSetID != OpenGl_RaytraceTransform::NO_CLIPPING)
{
aTransform->SetClipSetID (aClipSetID);
}
aSet->SetProperties (aTransform);
if (aSet->MaterialIndex() != OpenGl_TriangleSet::INVALID_MATERIAL && aSet->MaterialIndex() != aMatID)
@@ -492,18 +536,22 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
}
else
{
NCollection_Handle<BVH_Object<Standard_ShortReal, 3> > aSet =
addRaytracePrimitiveArray (aPrimArray, aMatID, 0);
NCollection_Handle<BVH_Object<Standard_ShortReal, 3> > aSet = addRaytracePrimitiveArray (aPrimArray, aMatID, 0);
if (!aSet.IsNull())
{
BVH_Transform<Standard_ShortReal, 4>* aTransform = new BVH_Transform<Standard_ShortReal, 4>;
OpenGl_RaytraceTransform* aTransform = new OpenGl_RaytraceTransform;
if (theTransform != NULL)
{
aTransform->SetTransform (*theTransform);
}
if (aClipSetID != OpenGl_RaytraceTransform::NO_CLIPPING)
{
aTransform->SetClipSetID (aClipSetID);
}
aSet->SetProperties (aTransform);
myRaytraceGeometry.Objects().Append (aSet);
@@ -1478,6 +1526,8 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
"uRaytraceMaterialTexture", OpenGl_RT_RaytraceMaterialTexture);
aShaderProgram->SetSampler (theGlContext,
"uRaytraceLightSrcTexture", OpenGl_RT_RaytraceLightSrcTexture);
aShaderProgram->SetSampler (theGlContext,
"uRaytraceClippingTexture", OpenGl_RT_RaytraceClippingTexture);
aShaderProgram->SetSampler (theGlContext,
"uOpenGlColorTexture", OpenGl_RT_OpenGlColorTexture);
@@ -1629,6 +1679,7 @@ void OpenGl_View::releaseRaytraceResources (const Handle(OpenGl_Context)& theGlC
nullifyResource (theGlContext, myRaytraceLightSrcTexture);
nullifyResource (theGlContext, myRaytraceMaterialTexture);
nullifyResource (theGlContext, myRaytraceClippingTexture);
myRaytraceGeometry.ReleaseResources (theGlContext);
@@ -1760,7 +1811,7 @@ Standard_Boolean OpenGl_View::uploadRaytraceData (const Handle(OpenGl_Context)&
}
/////////////////////////////////////////////////////////////////////////////
// Create OpenGL BVH buffers
// Create BVH buffers
if (mySceneNodeInfoTexture.IsNull()) // create scene BVH buffers
{
@@ -1800,6 +1851,9 @@ Standard_Boolean OpenGl_View::uploadRaytraceData (const Handle(OpenGl_Context)&
}
}
/////////////////////////////////////////////////////////////////////////////
// Create material buffer
if (myRaytraceMaterialTexture.IsNull()) // create material buffer
{
myRaytraceMaterialTexture = new OpenGl_TextureBufferArb;
@@ -1807,7 +1861,23 @@ Standard_Boolean OpenGl_View::uploadRaytraceData (const Handle(OpenGl_Context)&
if (!myRaytraceMaterialTexture->Create (theGlContext))
{
#ifdef RAY_TRACE_PRINT_INFO
std::cout << "Error: Failed to create buffers for material data" << std::endl;
std::cout << "Error: Failed to create buffer for material data" << std::endl;
#endif
return Standard_False;
}
}
/////////////////////////////////////////////////////////////////////////////
// Create clip planes buffer
if (myRaytraceClippingTexture.IsNull()) // create clipping planes buffer
{
myRaytraceClippingTexture = new OpenGl_TextureBufferArb;
if (!myRaytraceClippingTexture->Create (theGlContext))
{
#ifdef RAY_TRACE_PRINT_INFO
std::cout << "Error: Failed to create buffer for clip plane data" << std::endl;
#endif
return Standard_False;
}
@@ -1825,13 +1895,17 @@ Standard_Boolean OpenGl_View::uploadRaytraceData (const Handle(OpenGl_Context)&
OpenGl_TriangleSet* aTriangleSet = dynamic_cast<OpenGl_TriangleSet*> (
myRaytraceGeometry.Objects().ChangeValue (anElemIndex).operator->());
const BVH_Transform<Standard_ShortReal, 4>* aTransform =
dynamic_cast<const BVH_Transform<Standard_ShortReal, 4>* > (aTriangleSet->Properties().operator->());
const OpenGl_RaytraceTransform* aTransform =
dynamic_cast<const OpenGl_RaytraceTransform*> (aTriangleSet->Properties().operator->());
Standard_ASSERT_RETURN (aTransform != NULL,
"OpenGl_TriangleSet does not contain transform", Standard_False);
aNodeTransforms[anElemIndex] = aTransform->Inversed();
// Note: write clip plane ID in last matrix component, because
// the last matrix row is not used for transformation purposes
aNodeTransforms[anElemIndex].SetValue (3, 3, aTransform->ClipSetID());
}
aResult &= mySceneTransformTexture->Init (theGlContext, 4,
@@ -2006,6 +2080,23 @@ Standard_Boolean OpenGl_View::uploadRaytraceData (const Handle(OpenGl_Context)&
}
}
/////////////////////////////////////////////////////////////////////////////
// Write clip planes buffer
if (myRaytraceGeometry.ClipPlanes.size() != 0)
{
aResult &= myRaytraceClippingTexture->Init (theGlContext, 4,
GLsizei (myRaytraceGeometry.ClipPlanes.size() * 16), myRaytraceGeometry.ClipPlanes.front().Packed());
if (!aResult)
{
#ifdef RAY_TRACE_PRINT_INFO
std::cout << "Error: Failed to upload clipping planes buffer" << std::endl;
#endif
return Standard_False;
}
}
myIsRaytraceDataValid = myRaytraceGeometry.Objects().Size() != 0;
#ifdef RAY_TRACE_PRINT_INFO
@@ -2294,6 +2385,7 @@ void OpenGl_View::bindRaytraceTextures (const Handle(OpenGl_Context)& theGlConte
mySceneTransformTexture->BindTexture (theGlContext, GL_TEXTURE0 + OpenGl_RT_SceneTransformTexture);
myRaytraceMaterialTexture->BindTexture (theGlContext, GL_TEXTURE0 + OpenGl_RT_RaytraceMaterialTexture);
myRaytraceLightSrcTexture->BindTexture (theGlContext, GL_TEXTURE0 + OpenGl_RT_RaytraceLightSrcTexture);
myRaytraceClippingTexture->BindTexture (theGlContext, GL_TEXTURE0 + OpenGl_RT_RaytraceClippingTexture);
if (!myOpenGlFBO.IsNull())
{
@@ -2318,6 +2410,7 @@ void OpenGl_View::unbindRaytraceTextures (const Handle(OpenGl_Context)& theGlCon
mySceneTransformTexture->UnbindTexture (theGlContext, GL_TEXTURE0 + OpenGl_RT_SceneTransformTexture);
myRaytraceMaterialTexture->UnbindTexture (theGlContext, GL_TEXTURE0 + OpenGl_RT_RaytraceMaterialTexture);
myRaytraceLightSrcTexture->UnbindTexture (theGlContext, GL_TEXTURE0 + OpenGl_RT_RaytraceLightSrcTexture);
myRaytraceClippingTexture->UnbindTexture (theGlContext, GL_TEXTURE0 + OpenGl_RT_RaytraceClippingTexture);
if (!myOpenGlFBO.IsNull())
{

View File

@@ -60,6 +60,9 @@ uniform isamplerBuffer uGeometryTriangTexture;
uniform samplerBuffer uRaytraceMaterialTexture;
//! Texture buffer of light source properties.
uniform samplerBuffer uRaytraceLightSrcTexture;
//! Texture buffer of clipping planes properties.
uniform samplerBuffer uRaytraceClippingTexture;
//! Environment map texture.
uniform sampler2D uEnvironmentMapTexture;
@@ -375,12 +378,20 @@ struct SSubTree
ivec4 SubData;
};
#define EMPTY_ROOT ivec4(0)
#define TRS_OFFSET(treelet) treelet.SubData.x
#define BVH_OFFSET(treelet) treelet.SubData.y
#define VRT_OFFSET(treelet) treelet.SubData.z
#define TRG_OFFSET(treelet) treelet.SubData.w
#define EMPTY_ROOT ivec4(0)
#define MAX_CLIP_PLANES 1
#define IS_PLANE_ACTIVE(params) (params.x != -1.F)
#define IS_PLANE_HIDDEN(params) (params.x == -1.F)
#define PLANE_SETTINGS(trsf, index) (16 * int(trsf.w) + 2 * index + 0)
#define PLANE_EQUATION(trsf, index) (16 * int(trsf.w) + 2 * index + 1)
// =======================================================================
// function : SceneNearestHit
@@ -396,6 +407,9 @@ ivec4 SceneNearestHit (in SRay theRay, in vec3 theInverse, inout SIntersect theH
SSubTree aSubTree = SSubTree (theRay, theInverse, EMPTY_ROOT);
float aClipMax = MAXFLOAT;
float aClipMin = -MAXFLOAT;
for (bool toContinue = true; toContinue;)
{
ivec4 aData = texelFetch (uSceneNodeInfoTexture, aNode);
@@ -472,7 +486,7 @@ ivec4 SceneNearestHit (in SRay theRay, in vec3 theInverse, inout SIntersect theH
float aTime = IntersectTriangle (aSubTree.TrsfRay,
aPoint0, aPoint1, aPoint2, aParams, aNormal);
if (aTime < theHit.Time)
if (aTime > aClipMin && aTime < aClipMax && aTime < theHit.Time)
{
aTriIndex = aTriangle;
@@ -493,13 +507,34 @@ ivec4 SceneNearestHit (in SRay theRay, in vec3 theInverse, inout SIntersect theH
}
else if (aData.x > 0) // switch node
{
aSubTree.SubData = ivec4 (4 * aData.x - 4, aData.yzw); // store BVH sub-root
aClipMax = MAXFLOAT;
aClipMin = -MAXFLOAT;
aSubTree.SubData = ivec4 (aData.x * 4 - 4, aData.yzw); // store BVH sub-root
vec4 aInvTransf0 = texelFetch (uSceneTransformTexture, TRS_OFFSET (aSubTree) + 0);
vec4 aInvTransf1 = texelFetch (uSceneTransformTexture, TRS_OFFSET (aSubTree) + 1);
vec4 aInvTransf2 = texelFetch (uSceneTransformTexture, TRS_OFFSET (aSubTree) + 2);
vec4 aInvTransf3 = texelFetch (uSceneTransformTexture, TRS_OFFSET (aSubTree) + 3);
for (int aPlaneIdx = 0; aInvTransf3.w >= 0.0 && aPlaneIdx < MAX_CLIP_PLANES; ++aPlaneIdx)
{
vec4 aSettings = texelFetch (uRaytraceClippingTexture, PLANE_SETTINGS (aInvTransf3, aPlaneIdx));
vec4 aEquation = texelFetch (uRaytraceClippingTexture, PLANE_EQUATION (aInvTransf3, aPlaneIdx));
float aNdotD = -dot (aEquation.xyz, theRay.Direct);
if (IS_PLANE_ACTIVE (aSettings))
{
float aPlaneTime = (dot (aEquation.xyz, theRay.Origin) + aEquation.w) / aNdotD;
if (aNdotD < 0.0)
aClipMin = max (aClipMin, aPlaneTime);
else
aClipMax = min (aClipMax, aPlaneTime);
}
}
aSubTree.TrsfRay.Direct = MatrixColMultiplyDir (theRay.Direct,
aInvTransf0,
aInvTransf1,
@@ -537,6 +572,9 @@ float SceneAnyHit (in SRay theRay, in vec3 theInverse, in float theDistance)
SSubTree aSubTree = SSubTree (theRay, theInverse, EMPTY_ROOT);
float aClipMax = MAXFLOAT;
float aClipMin = -MAXFLOAT;
for (bool toContinue = true; toContinue;)
{
ivec4 aData = texelFetch (uSceneNodeInfoTexture, aNode);
@@ -614,12 +652,12 @@ float SceneAnyHit (in SRay theRay, in vec3 theInverse, in float theDistance)
aPoint0, aPoint1, aPoint2, aParams, aNormal);
#ifdef TRANSPARENT_SHADOWS
if (aTime < theDistance)
if (aTime > aClipMin && aTime < aClipMax && aTime < theDistance)
{
aFactor *= 1.f - texelFetch (uRaytraceMaterialTexture, MATERIAL_TRAN (aTriangle.w)).x;
}
#else
if (aTime < theDistance)
if (aTime > aClipMin && aTime < aClipMax && aTime < theDistance)
{
aFactor = 0.f;
}
@@ -637,6 +675,9 @@ float SceneAnyHit (in SRay theRay, in vec3 theInverse, in float theDistance)
}
else if (aData.x > 0) // switch node
{
aClipMax = MAXFLOAT;
aClipMin = -MAXFLOAT;
aSubTree.SubData = ivec4 (4 * aData.x - 4, aData.yzw); // store BVH sub-root
vec4 aInvTransf0 = texelFetch (uSceneTransformTexture, TRS_OFFSET (aSubTree) + 0);
@@ -644,6 +685,24 @@ float SceneAnyHit (in SRay theRay, in vec3 theInverse, in float theDistance)
vec4 aInvTransf2 = texelFetch (uSceneTransformTexture, TRS_OFFSET (aSubTree) + 2);
vec4 aInvTransf3 = texelFetch (uSceneTransformTexture, TRS_OFFSET (aSubTree) + 3);
for (int aPlaneIdx = 0; aInvTransf3.w >= 0.0 && aPlaneIdx < MAX_CLIP_PLANES; ++aPlaneIdx)
{
vec4 aSettings = texelFetch (uRaytraceClippingTexture, PLANE_SETTINGS (aInvTransf3, aPlaneIdx));
vec4 aEquation = texelFetch (uRaytraceClippingTexture, PLANE_EQUATION (aInvTransf3, aPlaneIdx));
float aNdotD = -dot (aEquation.xyz, theRay.Direct);
if (IS_PLANE_ACTIVE (aSettings))
{
float aPlaneTime = (dot (aEquation.xyz, theRay.Origin) + aEquation.w) / aNdotD;
if (aNdotD < 0.0)
aClipMin = max (aClipMin, aPlaneTime);
else
aClipMax = min (aClipMax, aPlaneTime);
}
}
aSubTree.TrsfRay.Direct = MatrixColMultiplyDir (theRay.Direct,
aInvTransf0,
aInvTransf1,

View File

@@ -402,32 +402,26 @@ TDF_Label XCAFDoc_ShapeTool::NewShape() const
//=======================================================================
void XCAFDoc_ShapeTool::SetShape (const TDF_Label& L, const TopoDS_Shape& S)
{
if(IsReference(L) || !IsTopLevel(L) || /*IsAssembly(L) ||*/ !S.Location().IsIdentity())
return;
TDF_LabelSequence aSubShapes;
GetSubShapes(L, aSubShapes);
{
TNaming_Builder tnBuild(L);
tnBuild.Generated(S);
Handle(XCAFDoc_ShapeMapTool) A = XCAFDoc_ShapeMapTool::Set(L);
// if ( ! L.FindAttribute(XCAFDoc_ShapeMapTool::GetID(), A) ) {
// A = XCAFDoc_ShapeMapTool::Set(L);
// L.AddAttribute(A);
// }
A->SetShape(S);
for(Standard_Integer i = 1; i<=aSubShapes.Length(); i++)
{
TDF_Label aSubLabel = aSubShapes(i);
if (!IsSubShape(L, GetShape(aSubLabel)))
{
aSubLabel.ForgetAllAttributes();
}
}
if(!myShapeLabels.IsBound(S)) {
myShapeLabels.Bind(S,L);
}
UpdateAssociatedAssembly(L);
//:abv 31.10.01: update assemblies that refer a shape
TDF_LabelSequence Labels;
if ( GetUsers ( L, Labels, Standard_True ) ) {
for ( Standard_Integer i=Labels.Length(); i >=1; i-- )
UpdateAssembly ( Labels(i) );
}
}
//=======================================================================
@@ -998,26 +992,6 @@ void XCAFDoc_ShapeTool::RemoveComponent (const TDF_Label& comp) const
}
}
//=======================================================================
//function : UpdateAssociatedAssembly
//purpose :
//=======================================================================
void XCAFDoc_ShapeTool::UpdateAssociatedAssembly (const TDF_Label& L) const
{
TDF_LabelSequence Labels;
if ( GetUsers ( L, Labels ) ) {
for ( Standard_Integer i=Labels.Length(); i >=1; i-- )
{
TDF_Label anAssemblyLabel = Labels(i).Father();
if(!anAssemblyLabel.IsNull())
{
UpdateAssembly(anAssemblyLabel);
}
}
}
}
//=======================================================================
//function : UpdateAssembly
//purpose :
@@ -1027,38 +1001,19 @@ void XCAFDoc_ShapeTool::UpdateAssembly (const TDF_Label& L) const
{
if ( ! IsAssembly(L) ) return;
TopoDS_Compound newassembly;
BRep_Builder b;
TopoDS_Shape aShape = GetShape(L);
Standard_Boolean isFree = aShape.Free();
if (!isFree)
aShape.Free(Standard_True);
TopTools_SequenceOfShape aSubShapeSeq;
TopoDS_Iterator Iterator(aShape);
for (; Iterator.More(); Iterator.Next())
aSubShapeSeq.Append(Iterator.Value());
for (Standard_Integer i = 1; i <= aSubShapeSeq.Length(); i++)
b.Remove(aShape, aSubShapeSeq.Value(i));
b.MakeCompound(newassembly);
TDF_ChildIterator chldLabIt(L);
for (; chldLabIt.More(); chldLabIt.Next() ) {
TDF_Label subLabel = chldLabIt.Value();
if ( IsComponent ( subLabel ) ) {
b.Add(aShape, GetShape(subLabel));
b.Add(newassembly, GetShape(subLabel));
}
}
if (!isFree)
aShape.Free(Standard_False);
TNaming_Builder tnBuild(L);
tnBuild.Generated(aShape);
Handle(XCAFDoc_ShapeMapTool) A = XCAFDoc_ShapeMapTool::Set(L);
A->SetShape(aShape);
UpdateAssociatedAssembly(L);
tnBuild.Generated(newassembly);
}
//=======================================================================
@@ -1951,4 +1906,4 @@ void XCAFDoc_ShapeTool::makeSubShape (const TDF_Label& Part, const TopoDS_Shape&
}
makeSubShape(Part, aChildShape);
}
}
}

View File

@@ -203,11 +203,6 @@ public:
Standard_EXPORT TDF_Label NewShape() const;
//! Sets representation (TopoDS_Shape) for top-level shape.
//! If S has location(location.IsIdentity() is false),
//! command will be skipped. Sub-shapes of S which is
//! subshape of old shape, will be stored ( all atributes will be stored).
//! If a sub-label of L is not a sub-shape of the new shape,
//! it will be removed.
Standard_EXPORT void SetShape (const TDF_Label& L, const TopoDS_Shape& S);
//! Adds a new top-level (creates and returns a new label)
@@ -291,9 +286,6 @@ public:
//! Removes a component from its assembly
Standard_EXPORT void RemoveComponent (const TDF_Label& comp) const;
//! Update labels associated with Label <L>
Standard_EXPORT void UpdateAssociatedAssembly (const TDF_Label& L) const;
//! Update an assembly at label <L>
Standard_EXPORT void UpdateAssembly (const TDF_Label& L) const;

View File

@@ -102,8 +102,7 @@ static Standard_Integer setShape (Draw_Interpretor& di, Standard_Integer argc, c
// XCAFDoc_ShapeTool myAssembly;
// myAssembly.Init(Doc);
Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
if( !myAssembly->IsAssembly(aLabel))
myAssembly->SetShape(aLabel, aShape);
myAssembly->SetShape(aLabel, aShape);
return 0;
}

View File

@@ -1,24 +0,0 @@
puts "============"
puts "OCC24103"
puts "============"
puts ""
######################################################
# Infinite loop in HLR algorithm on the customer's shape
######################################################
pload XDE
smallview
right
stepread [locate_data_file bug24100_REFLECT_CURVE_PART_5_SOL_ohne_Metadaten.stp] a *
explode a_1
donly a_1_1
fit
reflectlines result a_1_1 1 0 0
set length 4217.78
set only_screen_axo 1

View File

@@ -1,24 +0,0 @@
puts "============"
puts "OCC24103"
puts "============"
puts ""
######################################################
# Infinite loop in HLR algorithm on the customer's shape
######################################################
pload XDE
smallview
top
stepread [locate_data_file bug24100_REFLECT_CURVE_PART_5_SOL_ohne_Metadaten.stp] a *
explode a_1
donly a_1_1
fit
reflectlines result a_1_1 0 0 1
set length 6385.96
set only_screen_axo 1

View File

@@ -7,7 +7,7 @@ puts ""
#######################################################################
set BugNumber OCC22962
set check_value 96
set check_value 94
pload DCAF
ReadStep D1 [locate_data_file OCC22962-dm1-oc-214.stp]

View File

@@ -1,22 +0,0 @@
puts "========"
puts "OCC25441"
puts "========"
puts ""
###########################################################################
# XCAFDoc_ShapeTool::UpdateAssembly() does not update the back-references
###########################################################################
pload OCAFKERNEL
box b 0 0 0 1 1 1
psphere b1 10
NewDocument d
compound b c
compound c c1
XAddShape d c1 1
XShow d
XSetShape d 0:1:1:3 b1
XShow d
vfit
checkview -screenshot -3d -path ${imagedir}/${test_image}.png

View File

@@ -1,23 +0,0 @@
puts "========"
puts "OCC26314"
puts "========"
puts ""
############################################################
# Method XCAFDoc_ShapeTool::SetShape() works not correctly
############################################################
pload OCAFKERNEL
box b 0 0 0 1 1 1
box b1 -10 -10 -10 10 10 10
box b2 1 1 1 10 10 10
NewDocument d
compound b1 c1
XAddShape d b 1
XAddShape d c1 1
XShow d
XSetShape d 0:1:1:3 b2
XShow d
vfit
checkview -screenshot -3d -path ${imagedir}/${test_image}.png