From: kgv Date: Thu, 21 Nov 2013 09:29:08 +0000 (+0400) Subject: 0024353: TKOpenGl - crash in IsRaytracedStructure when clearing mutli-connected prese... X-Git-Tag: V6_7_0~68 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=d5af86261d890fcacfff08db4fb4ecba81ec59e3 0024353: TKOpenGl - crash in IsRaytracedStructure when clearing mutli-connected presentation Correction of test cases for issue CR24353 --- diff --git a/src/OpenGl/OpenGl_SceneGeometry.cxx b/src/OpenGl/OpenGl_SceneGeometry.cxx index 472687e155..be2f3509d2 100644 --- a/src/OpenGl/OpenGl_SceneGeometry.cxx +++ b/src/OpenGl/OpenGl_SceneGeometry.cxx @@ -146,7 +146,8 @@ OpenGl_RaytraceLight::OpenGl_RaytraceLight (const OpenGl_RTVec4f& theDiffuse, // ======================================================================= OpenGl_RTVec4f OpenGl_RaytraceScene::Center (const int theTriangle) const { - const OpenGl_RTVec4i anIndex (Triangles [theTriangle]); + const OpenGl_RTVec4i& anIndex = Triangles [theTriangle]; + return ( Vertices[anIndex.x()] + Vertices[anIndex.y()] + Vertices[anIndex.z()] ) * ( 1.f / 3.f ); @@ -159,7 +160,8 @@ OpenGl_RTVec4f OpenGl_RaytraceScene::Center (const int theTriangle) const float OpenGl_RaytraceScene::CenterAxis (const int theTriangle, const int theAxis) const { - const OpenGl_RTVec4i anIndex (Triangles [theTriangle]); + const OpenGl_RTVec4i& anIndex = Triangles [theTriangle]; + return ( Vertices[anIndex.x()][theAxis] + Vertices[anIndex.y()][theAxis] + Vertices[anIndex.z()][theAxis] ) * ( 1.f / 3.f ); @@ -171,11 +173,11 @@ float OpenGl_RaytraceScene::CenterAxis (const int theTriangle, // ======================================================================= OpenGl_AABB OpenGl_RaytraceScene::Box (const int theTriangle) const { - const OpenGl_RTVec4i anIndex (Triangles[theTriangle]); + const OpenGl_RTVec4i& anIndex = Triangles[theTriangle]; - const OpenGl_RTVec4f pA = Vertices[anIndex.x()]; - const OpenGl_RTVec4f pB = Vertices[anIndex.y()]; - const OpenGl_RTVec4f pC = Vertices[anIndex.z()]; + const OpenGl_RTVec4f& pA = Vertices[anIndex.x()]; + const OpenGl_RTVec4f& pB = Vertices[anIndex.y()]; + const OpenGl_RTVec4f& pC = Vertices[anIndex.z()]; OpenGl_AABB aBox (pA); diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 42ade61c9e..f7a89cc7f9 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -385,6 +385,27 @@ void OpenGl_Structure::UnregisterAncestorStructure (const OpenGl_Structure* theS } } +// ======================================================================= +// function : UnregisterFromAncestorStructure +// purpose : +// ======================================================================= +void OpenGl_Structure::UnregisterFromAncestorStructure() const +{ + for (OpenGl_ListOfStructure::Iterator anIta (myAncestorStructures); anIta.More(); anIta.Next()) + { + OpenGl_Structure* anAncestor = const_cast (anIta.ChangeValue()); + + for (OpenGl_ListOfStructure::Iterator anIts (anAncestor->myConnected); anIts.More(); anIts.Next()) + { + if (anIts.Value() == this) + { + anAncestor->myConnected.Remove (anIts); + return; + } + } + } +} + // ======================================================================= // function : UpdateStateWithAncestorStructures // purpose : @@ -778,6 +799,11 @@ void OpenGl_Structure::Release (const Handle(OpenGl_Context)& theGlCtx) OpenGl_Element::Destroy (theGlCtx, myAspectMarker); OpenGl_Element::Destroy (theGlCtx, myAspectText); ClearHighlightColor (theGlCtx); + +#ifdef HAVE_OPENCL + // Remove from connected list of ancestor + UnregisterFromAncestorStructure(); +#endif } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Structure.hxx b/src/OpenGl/OpenGl_Structure.hxx index 994e6ad13e..4a4fe17480 100644 --- a/src/OpenGl/OpenGl_Structure.hxx +++ b/src/OpenGl/OpenGl_Structure.hxx @@ -138,6 +138,9 @@ protected: //! Unregisters ancestor connected structure (for updating ray-tracing state). void UnregisterAncestorStructure (const OpenGl_Structure* theStructure) const; + //! Unregisters structure from ancestor structure (for updating ray-tracing state). + void UnregisterFromAncestorStructure() const; + //! Updates modification state for structure and its parents. void UpdateStateWithAncestorStructures() const; diff --git a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx index 192b21e341..eee0428fac 100644 --- a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx +++ b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx @@ -47,7 +47,7 @@ using namespace OpenGl_Raytrace; //! Use this macro to output ray-tracing debug info -// #define RAY_TRACE_PRINT_INFO +//#define RAY_TRACE_PRINT_INFO #ifdef RAY_TRACE_PRINT_INFO #include diff --git a/tests/v3d/raytrace/connected b/tests/v3d/raytrace/connected new file mode 100644 index 0000000000..a2f84676ca --- /dev/null +++ b/tests/v3d/raytrace/connected @@ -0,0 +1,32 @@ +puts "TODO ?OCC24130 Windows: TKOpenGl | Type\: Error | ID\: 0 | Severity\: High | Message\:" + +puts "========" +puts "Ray Tracing - check rendering of multi-connected structures" +puts "========" + +# create boxes +box b1 0 0 0 1 2 3 +box b2 3 0 0 3 2 1 + +# draw box +vinit View1 +vclear +vsetdispmode 1 +vraytrace 0 +vaxo +vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2 +vfit +vrotate 0.2 0.0 0.0 +vclear +vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2 + +# take snapshot with fixed pipeline +vdump $::imagedir/${::casename}_OFF.png + +# turn on ray tracing +vraytrace 1 +vclinfo +vdump $::imagedir/${::casename}_rt1.png + +vclear +vconnectsh b1c -3 0 0 1 0 0 0 0 1 b1 b2