CCAR: various optimisations : display and GEOM_Client

and timings
This commit is contained in:
caremoli 2010-07-01 08:45:51 +00:00
parent b06a7774c9
commit 3b461374c9
14 changed files with 135 additions and 20 deletions

View File

@ -1745,7 +1745,8 @@ void EntityGUI_SketcherDlg::FindLocalCS()
continue;
if (geomObj->GetType() == GEOM_MARKER) {
ComboBox1->addItem(geomObj->GetName());
TopoDS_Shape aShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
//TopoDS_Shape aShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
TopoDS_Shape aShape = GEOM_Client::ShapeReader.GetShape(GeometryGUI::GetGeomGen(), geomObj);
gp_Ax3 aLCS;
aLCS.Transform(aShape.Location().Transformation());

View File

@ -191,7 +191,7 @@ GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType)
//=============================================================================
GEOM_Object::~GEOM_Object()
{
MESSAGE("GEOM_Object::~GEOM_Object()");
//MESSAGE("GEOM_Object::~GEOM_Object()");
}
//=============================================================================

View File

@ -85,7 +85,8 @@ TopoDS_Shape GEOMBase::GetShapeFromIOR(QString IOR)
if (GeomObject->_is_nil())
return result;
result = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), GeomObject);
//result = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), GeomObject);
result = GEOM_Client::ShapeReader.GetShape(GeometryGUI::GetGeomGen(), GeomObject);
return result;
}
@ -909,7 +910,8 @@ bool GEOMBase::GetShape( const GEOM::GEOM_Object_ptr& theObject, TopoDS_Shape& t
{
if ( !CORBA::is_nil( theObject ) )
{
TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), theObject );
//TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), theObject );
TopoDS_Shape aTopoDSShape = GEOM_Client::ShapeReader.GetShape( GeometryGUI::GetGeomGen(), theObject );
if ( !aTopoDSShape.IsNull() && ( theType == TopAbs_SHAPE || theType == aTopoDSShape.ShapeType() ) )
{
theShape = aTopoDSShape;

View File

@ -53,6 +53,14 @@
#include <TColStd_MapOfInteger.hxx>
#include <TCollection_AsciiString.hxx>
#include <sys/time.h>
static long tcount=0;
static long cumul;
#define START_TIMING long tt0; timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000;
#define END_TIMING(NUMBER) \
tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \
if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; }
//To disable automatic genericobj management, the following line should be commented.
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
#define WITHGENERICOBJ
@ -657,7 +665,8 @@ void GEOMBase_Helper::clearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
TCollection_AsciiString asciiIOR( (char *)IOR.in() );
GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
//GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
GEOM_Client::ShapeReader.RemoveShapeFromBuffer( asciiIOR );
if ( !getStudy() || !getStudy()->studyDS() )
return;
@ -673,7 +682,8 @@ void GEOMBase_Helper::clearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
_PTR(AttributeIOR) anIOR ( anAttr );
TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
//GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
GEOM_Client::ShapeReader.RemoveShapeFromBuffer( asciiIOR );
}
}
}
@ -800,6 +810,7 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
return false;
}
START_TIMING;
erasePreview( false );
bool result = false;
@ -873,6 +884,7 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
}
updateViewer();
END_TIMING(1);
return result;
}

View File

@ -58,6 +58,17 @@
#define HST_CLIENT_LEN 256
#include <vector>
#include <sys/time.h>
static long tcount=0;
static long cumul;
#define START_TIMING long tt0; timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000;
#define END_TIMING(NUMBER) \
tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \
if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; }
GEOM_Client GEOM_Client::ShapeReader;
//=======================================================================
// function : Load()
@ -117,6 +128,19 @@ GEOM_Client::GEOM_Client(Engines::Container_ptr client)
//=======================================================================
Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S )
{
//CCAR
#if 1
if(_myIndexes.count(IOR)==0)
{
return 0;
}
else
{
Standard_Integer i =_myIndexes[IOR];
S = myShapes.Value(i);
return i;
}
#else
for ( Standard_Integer i = 1; i<= myIORs.Length(); i++ ) {
if (myIORs.Value(i).IsEqual(IOR)) {
S = myShapes.Value(i);
@ -124,6 +148,7 @@ Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_S
}
}
return 0;
#endif
}
//=======================================================================
@ -149,6 +174,7 @@ void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape&
{
myIORs.Append(IOR);
myShapes.Append(S);
_myIndexes[IOR]=myIORs.Length();
}
//=======================================================================
@ -165,6 +191,8 @@ void GEOM_Client::RemoveShapeFromBuffer( const TCollection_AsciiString& IOR)
if( anIndex != 0 ) {
myIORs.Remove(anIndex);
myShapes.Remove(anIndex);
_myIndexes.erase(IOR);
_mySubShapes.erase(IOR);
}
return;
}
@ -179,6 +207,8 @@ void GEOM_Client::ClearClientBuffer()
return;
myIORs.Clear();
myShapes.Clear();
_myIndexes.clear();
_mySubShapes.clear();
return;
}
@ -202,7 +232,10 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p
TCollection_AsciiString IOR = (char*)anIOR.in();
Standard_Integer anIndex = Find(IOR, S);
if (anIndex != 0) return S;
if (anIndex != 0)
{
return S;
}
/******* in case of a MAIN GEOM::SHAPE ********/
if (aShape->IsMainShape()) {
@ -216,12 +249,28 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p
TopoDS_Shape aMainShape = GetShape (geom, aShape->GetMainShape());
GEOM::ListOfLong_var list = aShape->GetSubShapeIndices();
START_TIMING;
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aMainShape, anIndices);
anIOR = geom->GetStringFromIOR(aShape->GetMainShape());
IOR = (char*)anIOR.in();
//find subshapes only one time
if(_mySubShapes.count(IOR)==0)
{
std::cerr << "find sub shapes " << std::endl;
TopExp::MapShapes(aMainShape, anIndices);
Standard_Integer ii = 1, nbSubSh = anIndices.Extent();
for (; ii <= nbSubSh; ii++)
{
_mySubShapes[IOR].push_back(anIndices.FindKey(ii));
}
}
/* Case of only one subshape */
if (list->length() == 1 && list[0] > 0) {
S = anIndices.FindKey(list[0]);
//S = anIndices.FindKey(list[0]);
S = _mySubShapes[IOR][list[0]-1];
}
else {
BRep_Builder B;
@ -229,7 +278,8 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p
B.MakeCompound(aCompound);
for (int i = 0; i < list->length(); i++) {
if (0 < list[i] && list[i] <= anIndices.Extent()) {
TopoDS_Shape aSubShape = anIndices.FindKey(list[i]);
TopoDS_Shape aSubShape = _mySubShapes[IOR][list[i]-1];
//TopoDS_Shape aSubShape = anIndices.FindKey(list[i]);
B.Add(aCompound, aSubShape);
}
}
@ -237,5 +287,6 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p
S = aCompound;
}
Bind(IOR, S);
END_TIMING(100);
return S;
}

View File

@ -73,6 +73,10 @@ class TopoDS_Shape;
#define GEOMCLIENT_EXPORT
#endif
#include <TCollection_AsciiString.hxx>
#include <map>
#include <vector>
//=====================================================================
// GEOM_Client : class definition
//=====================================================================
@ -113,12 +117,15 @@ public:
//Standard_EXPORT
unsigned int BufferLength() ;
TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape);
static GEOM_Client ShapeReader;
private:
// Fields PRIVATE
//
TColStd_SequenceOfAsciiString myIORs ;
TopTools_SequenceOfShape myShapes ;
std::map< TCollection_AsciiString , int > _myIndexes;
std::map< TCollection_AsciiString , std::vector<TopoDS_Shape> > _mySubShapes;
long pid_client;
};

View File

@ -139,7 +139,8 @@ bool GEOM_SelectionFilter::getShape (const GEOM::GEOM_Object_ptr& theObject,
}
if ( !CORBA::is_nil( geomGen ) )
{
TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( geomGen, theObject );
//TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( geomGen, theObject );
TopoDS_Shape aTopoDSShape = GEOM_Client::ShapeReader.GetShape( geomGen, theObject );
if ( !aTopoDSShape.IsNull() )
{

View File

@ -92,6 +92,14 @@
#include <GEOMImpl_Types.hxx>
#include <Graphic3d_HArray1OfBytes.hxx>
#include <sys/time.h>
static long tcount=0;
static long cumul;
#define START_TIMING long tt0; timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000;
#define END_TIMING(NUMBER) \
tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \
if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; }
//================================================================
// Function : getActiveStudy
@ -303,9 +311,11 @@ void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO,
if ( prs )
{
START_TIMING;
vf->BeforeDisplay( this );
vf->Display( prs );
vf->AfterDisplay( this );
END_TIMING(100);
if ( updateViewer )
vf->Repaint();
@ -935,7 +945,8 @@ SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
return 0;
internalReset();
setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
setShape( GEOM_Client::ShapeReader.GetShape( GeometryGUI::GetGeomGen(), theObj ) );
//setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
myType = theObj->GetType();
// Update presentation
@ -1016,7 +1027,8 @@ SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
if ( !GeomObject->_is_nil() )
{
// finally set shape
setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
setShape( GEOM_Client::ShapeReader.GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
//setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
myType = GeomObject->GetType();
}
}
@ -1025,6 +1037,7 @@ SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
}
}
UpdatePrs( prs ); // Update presentation by using of the double dispatch
myViewFrame->updateViewer( prs );
}
}
return prs;

View File

@ -87,7 +87,8 @@ public:
static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
GEOM_Client& GetShapeReader() { return myShapeReader; }
GEOM_Client& GetShapeReader() { return GEOM_Client::ShapeReader; }
//GEOM_Client& GetShapeReader() { return myShapeReader; }
// Get active dialog box
QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }

View File

@ -68,6 +68,14 @@
#include <vtkRenderer.h>
#include <sys/time.h>
static long tcount=0;
static long cumul;
#define START_TIMING long tt0; timeval tv; gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000;
#define END_TIMING(NUMBER) \
tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \
if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; }
static GEOM_Client ShapeReader;
inline OCCViewer_Viewer* GetOCCViewer(SUIT_Application* theApp){
@ -154,7 +162,7 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated)
std::string anIORValue = anIOR->Value();
GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(anIORValue.c_str());
TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
TopoDS_Shape Shape = GEOM_Client::ShapeReader.GetShape(Geom,aShape);
if (!Shape.IsNull()) {
if (obj->FindAttribute(anAttr, "AttributeName")) {
_PTR(AttributeName) aName (anAttr);
@ -167,6 +175,7 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated)
aStudyBuilder->Addreference(newObj1, obj);
// commit transaction
op->commit();*/
START_TIMING;
Handle(GEOM_InteractiveObject) anIO =
new GEOM_InteractiveObject (const_cast<char*>(anIORValue.c_str()),
const_cast<char*>(aFatherIOR.c_str()),
@ -174,6 +183,7 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated)
const_cast<char*>( obj->GetID().c_str()));
GEOM_Displayer(ActiveStudy).Display(anIO, myUpdateViewer);
END_TIMING(100);
/*if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
SVTK_View* aView = aViewWindow->getView();
int aMode = aView->GetDisplayMode();

View File

@ -61,6 +61,17 @@
#include "SALOMEDS_Tool.hxx"
#include <sys/time.h>
static long tt0;
static long tcount=0;
static long cumul;
static timeval tv;
#define START_TIMING gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000;
#define END_TIMING(NUMBER) \
tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \
if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; }
//============================================================================
// function : GEOM_Gen_i()
// purpose : constructor to be called for servant creation.
@ -735,6 +746,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
{
SALOMEDS::SObject_var aResultSO;
if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO;
//START_TIMING;
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
CORBA::String_var IOR;
@ -768,6 +780,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
aSubSO->Destroy();
}
//END_TIMING(100);
return aResultSO._retn();
}

View File

@ -65,7 +65,7 @@ GEOM_Object_i::GEOM_Object_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr
GEOM_Object_i::~GEOM_Object_i()
{
MESSAGE("GEOM_Object_i::~GEOM_Object_i");
//MESSAGE("GEOM_Object_i::~GEOM_Object_i");
GEOM_Engine::GetEngine()->RemoveObject(_impl);
}

View File

@ -653,7 +653,8 @@ int GroupGUI_GroupDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMap
if (GEOMBase::GetShape(aGeomObj, aShape)) {
if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == getShapeType()) {
TopTools_IndexedMapOfShape aMainMap;
TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
TopoDS_Shape aMainShape = GEOM_Client::ShapeReader.GetShape(GeometryGUI::GetGeomGen(), myMainObj);
//TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
TopExp::MapShapes(aMainShape, aMainMap);
TopExp_Explorer anExp (aShape, getShapeType());
@ -802,12 +803,14 @@ void GroupGUI_GroupDlg::activateSelection()
SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
if (aView == 0) return;
TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
TopoDS_Shape aMainShape = GEOM_Client::ShapeReader.GetShape(GeometryGUI::GetGeomGen(), myMainObj);
//TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
TopoDS_Shape aRestrictionShape;
if (subSelectionWay() == ALL_SUBSHAPES)
aRestrictionShape = aMainShape;
else if (!myInPlaceObj->_is_nil())
aRestrictionShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myInPlaceObj);
aRestrictionShape = GEOM_Client::ShapeReader.GetShape(GeometryGUI::GetGeomGen(), myInPlaceObj);
//aRestrictionShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myInPlaceObj);
else ;
TopTools_IndexedMapOfShape aSubShapesMap;

View File

@ -213,7 +213,8 @@ void RepairGUI_SuppressFacesDlg::SelectionIntoArgument()
_PTR(Study) aStudy = appStudy->studyDS();
TopTools_IndexedMapOfShape aMainMap;
TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myObject);
TopoDS_Shape aMainShape = GEOM_Client::ShapeReader.GetShape(GeometryGUI::GetGeomGen(), myObject);
//TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myObject);
TopExp::MapShapes(aMainShape, aMainMap);
SALOME_ListIteratorOfListIO anIter (aSelList);