From 2c2917086a44fc075b0056ae0cffcbe81704c549 Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 12 Jan 2021 13:03:48 +0300 Subject: [PATCH] Provide presentations update after SHAPER objects modification --- src/GEOMClient/GEOM_Client.cxx | 27 ++++++------- src/GEOMClient/GEOM_Client.hxx | 69 ++++++++-------------------------- 2 files changed, 29 insertions(+), 67 deletions(-) diff --git a/src/GEOMClient/GEOM_Client.cxx b/src/GEOMClient/GEOM_Client.cxx index 73558480d..897a47541 100644 --- a/src/GEOMClient/GEOM_Client.cxx +++ b/src/GEOMClient/GEOM_Client.cxx @@ -167,9 +167,10 @@ Standard_Boolean GEOM_Client::Find (const TopoDS_Shape& S, TCollection_AsciiStri // function : Bind() // purpose : //======================================================================= -void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S ) +void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S, int Tick ) { myShapesMap[IOR] = S; + myTicksMap[IOR] = Tick; } //======================================================================= @@ -192,31 +193,31 @@ void GEOM_Client::ClearClientBuffer() myShapesMap.clear(); } -//======================================================================= -// function : BufferLength() -// purpose : -//======================================================================= -unsigned int GEOM_Client::BufferLength() -{ - return myShapesMap.size(); -} - //======================================================================= // function : GetShape() // purpose : //======================================================================= TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape ) { - TopoDS_Shape S; CORBA::String_var anIOR = geom->GetStringFromIOR(aShape); TCollection_AsciiString IOR = anIOR.in(); + int aShapeTick = aShape->GetTick(); + + std::map< TCollection_AsciiString , int >::iterator i2t = myTicksMap.find( IOR ); + if ( i2t != myTicksMap.end() ) { + // The shape was modified, clean the stored one + if (i2t->second != aShapeTick) + RemoveShapeFromBuffer(IOR); + } + + TopoDS_Shape S; if ( Find( IOR, S )) return S; /******* in case of a MAIN GEOM::SHAPE ********/ if ( aShape->IsMainShape() ) { S = Load(geom, aShape); - Bind(IOR, S); + Bind(IOR, S, aShapeTick); return S; } @@ -254,6 +255,6 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p S = aCompound; } - Bind(IOR, S); + Bind(IOR, S, aShapeTick); return S; } diff --git a/src/GEOMClient/GEOM_Client.hxx b/src/GEOMClient/GEOM_Client.hxx index 7feebc689..f18c85d12 100644 --- a/src/GEOMClient/GEOM_Client.hxx +++ b/src/GEOMClient/GEOM_Client.hxx @@ -29,28 +29,12 @@ #include #include CORBA_SERVER_HEADER(GEOM_Gen) -#ifdef HAVE_FINITE -#undef HAVE_FINITE // E.A. fix a warning about redefinition of HAVE_FINITE in re-inclusion of Standard_values.h -#endif -#ifndef _TColStd_SequenceOfAsciiString_HeaderFile -#include -#endif -#ifndef _TopTools_SequenceOfShape_HeaderFile -#include -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif - -class TCollection_AsciiString; -class TopoDS_Shape; +#include +#include +#include -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif +#include +#include #ifdef WIN32 #if defined GEOMCLIENT_EXPORTS || defined GEOMClient_EXPORTS @@ -62,11 +46,6 @@ class TopoDS_Shape; #define GEOMCLIENT_EXPORT #endif -#include -#include -#include -#include - /* * if define SINGLE_CLIENT is not commented, the method get_client always returns the same GEOM_Client object (singleton object) * and the SHAPE_READER macro can be used to define an object that is always this singleton object @@ -81,42 +60,17 @@ class TopoDS_Shape; class GEOMCLIENT_EXPORT GEOM_Client { public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } // Methods PUBLIC // - //Standard_EXPORT GEOM_Client(); - //Standard_EXPORT GEOM_Client(Engines::Container_ptr client); - //Standard_EXPORT GEOM_Client(const GEOM_Client& client); - //Standard_EXPORT - Standard_Boolean Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) ; - //Standard_EXPORT - Standard_Boolean Find( const TopoDS_Shape& S, TCollection_AsciiString& IOR ) ; - //Standard_EXPORT - void Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S ) ; - //Standard_EXPORT + TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape ); - //Standard_EXPORT + Standard_Boolean Find( const TopoDS_Shape& S, TCollection_AsciiString& IOR ) ; void RemoveShapeFromBuffer( const TCollection_AsciiString& IOR ) ; - //Standard_EXPORT void ClearClientBuffer() ; - //Standard_EXPORT - unsigned int BufferLength() ; - TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape); + #ifdef SINGLE_CLIENT static GEOM_Client& get_client(); #else @@ -124,10 +78,17 @@ class GEOMCLIENT_EXPORT GEOM_Client { #endif private: + // Methods PRIVATE + // + Standard_Boolean Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) ; + void Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S, int Tick ) ; + TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape); + // Fields PRIVATE // std::map< TCollection_AsciiString , std::vector > _mySubShapes; std::map< TCollection_AsciiString , TopoDS_Shape > myShapesMap; + std::map< TCollection_AsciiString , int > myTicksMap; long pid_client; }; -- 2.39.2