mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-31 13:40:34 +05:00
CCAR: GEOM_Client modification to optimize the method find
and the method GetShape when a main shape has a lot of subshapes The way of creation of GEOM_Client has also been changed : now, it's a singleton object. It is possible to revert to the old creation way by commenting the #define SINGLE_CLIENT instruction in GEOM_Client.hxx
This commit is contained in:
parent
16f91b82f4
commit
614185e8fd
@ -2309,7 +2309,7 @@ void EntityGUI_SketcherDlg::FindLocalCS()
|
|||||||
continue;
|
continue;
|
||||||
if (geomObj->GetType() == GEOM_MARKER) {
|
if (geomObj->GetType() == GEOM_MARKER) {
|
||||||
ComboBox1->addItem(geomObj->GetName());
|
ComboBox1->addItem(geomObj->GetName());
|
||||||
TopoDS_Shape aShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
|
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
|
||||||
|
|
||||||
gp_Ax3 aLCS;
|
gp_Ax3 aLCS;
|
||||||
aLCS.Transform(aShape.Location().Transformation());
|
aLCS.Transform(aShape.Location().Transformation());
|
||||||
|
@ -85,7 +85,7 @@ TopoDS_Shape GEOMBase::GetShapeFromIOR(QString IOR)
|
|||||||
if (GeomObject->_is_nil())
|
if (GeomObject->_is_nil())
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
result = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), GeomObject);
|
result = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), GeomObject);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,7 +909,7 @@ bool GEOMBase::GetShape( const GEOM::GEOM_Object_ptr& theObject, TopoDS_Shape& t
|
|||||||
{
|
{
|
||||||
if ( !CORBA::is_nil( theObject ) )
|
if ( !CORBA::is_nil( theObject ) )
|
||||||
{
|
{
|
||||||
TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), theObject );
|
TopoDS_Shape aTopoDSShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObject );
|
||||||
if ( !aTopoDSShape.IsNull() && ( theType == TopAbs_SHAPE || theType == aTopoDSShape.ShapeType() ) )
|
if ( !aTopoDSShape.IsNull() && ( theType == TopAbs_SHAPE || theType == aTopoDSShape.ShapeType() ) )
|
||||||
{
|
{
|
||||||
theShape = aTopoDSShape;
|
theShape = aTopoDSShape;
|
||||||
|
@ -656,7 +656,7 @@ void GEOMBase_Helper::clearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
|
|||||||
|
|
||||||
CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
|
CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
|
||||||
TCollection_AsciiString asciiIOR( (char *)IOR.in() );
|
TCollection_AsciiString asciiIOR( (char *)IOR.in() );
|
||||||
GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
|
GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
|
||||||
|
|
||||||
if ( !getStudy() || !getStudy()->studyDS() )
|
if ( !getStudy() || !getStudy()->studyDS() )
|
||||||
return;
|
return;
|
||||||
@ -672,7 +672,7 @@ void GEOMBase_Helper::clearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
|
|||||||
if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
|
if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
|
||||||
_PTR(AttributeIOR) anIOR ( anAttr );
|
_PTR(AttributeIOR) anIOR ( anAttr );
|
||||||
TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
|
TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
|
||||||
GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
|
GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,12 +117,12 @@ GEOM_Client::GEOM_Client(Engines::Container_ptr client)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S )
|
Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S )
|
||||||
{
|
{
|
||||||
for ( Standard_Integer i = 1; i<= myIORs.Length(); i++ ) {
|
if(_myIndexes.count(IOR) != 0)
|
||||||
if (myIORs.Value(i).IsEqual(IOR)) {
|
{
|
||||||
|
Standard_Integer i =_myIndexes[IOR];
|
||||||
S = myShapes.Value(i);
|
S = myShapes.Value(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +149,7 @@ void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape&
|
|||||||
{
|
{
|
||||||
myIORs.Append(IOR);
|
myIORs.Append(IOR);
|
||||||
myShapes.Append(S);
|
myShapes.Append(S);
|
||||||
|
_myIndexes[IOR]=myIORs.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -165,6 +166,8 @@ void GEOM_Client::RemoveShapeFromBuffer( const TCollection_AsciiString& IOR)
|
|||||||
if( anIndex != 0 ) {
|
if( anIndex != 0 ) {
|
||||||
myIORs.Remove(anIndex);
|
myIORs.Remove(anIndex);
|
||||||
myShapes.Remove(anIndex);
|
myShapes.Remove(anIndex);
|
||||||
|
_myIndexes.erase(IOR);
|
||||||
|
_mySubShapes.erase(IOR);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -179,6 +182,8 @@ void GEOM_Client::ClearClientBuffer()
|
|||||||
return;
|
return;
|
||||||
myIORs.Clear();
|
myIORs.Clear();
|
||||||
myShapes.Clear();
|
myShapes.Clear();
|
||||||
|
_myIndexes.clear();
|
||||||
|
_mySubShapes.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,11 +222,23 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p
|
|||||||
GEOM::ListOfLong_var list = aShape->GetSubShapeIndices();
|
GEOM::ListOfLong_var list = aShape->GetSubShapeIndices();
|
||||||
|
|
||||||
TopTools_IndexedMapOfShape anIndices;
|
TopTools_IndexedMapOfShape anIndices;
|
||||||
|
CORBA::String_var aMainIOR = geom->GetStringFromIOR(aShape->GetMainShape());
|
||||||
|
TCollection_AsciiString mainIOR = (char*)aMainIOR.in();
|
||||||
|
|
||||||
|
//find subshapes only one time
|
||||||
|
if(_mySubShapes.count(mainIOR)==0)
|
||||||
|
{
|
||||||
TopExp::MapShapes(aMainShape, anIndices);
|
TopExp::MapShapes(aMainShape, anIndices);
|
||||||
|
Standard_Integer ii = 1, nbSubSh = anIndices.Extent();
|
||||||
|
for (; ii <= nbSubSh; ii++)
|
||||||
|
{
|
||||||
|
_mySubShapes[mainIOR].push_back(anIndices.FindKey(ii));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Case of only one subshape */
|
/* Case of only one subshape */
|
||||||
if (list->length() == 1 && list[0] > 0) {
|
if (list->length() == 1 && list[0] > 0) {
|
||||||
S = anIndices.FindKey(list[0]);
|
S = _mySubShapes[mainIOR][list[0]-1];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BRep_Builder B;
|
BRep_Builder B;
|
||||||
@ -229,7 +246,7 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p
|
|||||||
B.MakeCompound(aCompound);
|
B.MakeCompound(aCompound);
|
||||||
for (int i = 0; i < list->length(); i++) {
|
for (int i = 0; i < list->length(); i++) {
|
||||||
if (0 < list[i] && list[i] <= anIndices.Extent()) {
|
if (0 < list[i] && list[i] <= anIndices.Extent()) {
|
||||||
TopoDS_Shape aSubShape = anIndices.FindKey(list[i]);
|
TopoDS_Shape aSubShape = _mySubShapes[mainIOR][list[i]-1];
|
||||||
B.Add(aCompound, aSubShape);
|
B.Add(aCompound, aSubShape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,18 @@ class TopoDS_Shape;
|
|||||||
#define GEOMCLIENT_EXPORT
|
#define GEOMCLIENT_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
* if define SINGLE_CLIENT is commented, we get the old way to define the GEOM_Client objects : get_client returns a new object
|
||||||
|
* and the SHAPE_READER macro defines also a new object
|
||||||
|
*/
|
||||||
|
#define SINGLE_CLIENT
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
// GEOM_Client : class definition
|
// GEOM_Client : class definition
|
||||||
//=====================================================================
|
//=====================================================================
|
||||||
@ -113,14 +125,26 @@ public:
|
|||||||
//Standard_EXPORT
|
//Standard_EXPORT
|
||||||
unsigned int BufferLength() ;
|
unsigned int BufferLength() ;
|
||||||
TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape);
|
TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape);
|
||||||
|
#ifdef SINGLE_CLIENT
|
||||||
|
static GEOM_Client& get_client() { static GEOM_Client a;return a; }
|
||||||
|
#else
|
||||||
|
static GEOM_Client get_client() { return GEOM_Client(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Fields PRIVATE
|
// Fields PRIVATE
|
||||||
//
|
//
|
||||||
TColStd_SequenceOfAsciiString myIORs ;
|
TColStd_SequenceOfAsciiString myIORs ;
|
||||||
TopTools_SequenceOfShape myShapes ;
|
TopTools_SequenceOfShape myShapes ;
|
||||||
|
std::map< TCollection_AsciiString , int > _myIndexes;
|
||||||
|
std::map< TCollection_AsciiString , std::vector<TopoDS_Shape> > _mySubShapes;
|
||||||
long pid_client;
|
long pid_client;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef SINGLE_CLIENT
|
||||||
|
#define SHAPE_READER(obj) GEOM_Client& obj=GEOM_Client::get_client()
|
||||||
|
#else
|
||||||
|
#define SHAPE_READER(obj) GEOM_Client obj
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -139,7 +139,7 @@ bool GEOM_SelectionFilter::getShape (const GEOM::GEOM_Object_ptr& theObject,
|
|||||||
}
|
}
|
||||||
if ( !CORBA::is_nil( geomGen ) )
|
if ( !CORBA::is_nil( geomGen ) )
|
||||||
{
|
{
|
||||||
TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( geomGen, theObject );
|
TopoDS_Shape aTopoDSShape = GEOM_Client::get_client().GetShape( geomGen, theObject );
|
||||||
|
|
||||||
if ( !aTopoDSShape.IsNull() )
|
if ( !aTopoDSShape.IsNull() )
|
||||||
{
|
{
|
||||||
|
@ -968,7 +968,7 @@ SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj )
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
internalReset();
|
internalReset();
|
||||||
setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
|
setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
|
||||||
myType = theObj->GetType();
|
myType = theObj->GetType();
|
||||||
|
|
||||||
// Update presentation
|
// Update presentation
|
||||||
@ -1049,7 +1049,7 @@ SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry,
|
|||||||
if ( !GeomObject->_is_nil() )
|
if ( !GeomObject->_is_nil() )
|
||||||
{
|
{
|
||||||
// finally set shape
|
// finally set shape
|
||||||
setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
|
setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
|
||||||
myType = GeomObject->GetType();
|
myType = GeomObject->GetType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public:
|
|||||||
|
|
||||||
static void Modified( bool = true );
|
static void Modified( bool = true );
|
||||||
|
|
||||||
GEOM_Client& GetShapeReader() { return myShapeReader; }
|
GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
|
||||||
|
|
||||||
// Get active dialog box
|
// Get active dialog box
|
||||||
QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
|
QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
|
||||||
@ -169,7 +169,6 @@ private:
|
|||||||
|
|
||||||
GUIMap myGUIMap; // GUI libraries map
|
GUIMap myGUIMap; // GUI libraries map
|
||||||
QDialog* myActiveDialogBox; // active dialog box
|
QDialog* myActiveDialogBox; // active dialog box
|
||||||
GEOM_Client myShapeReader; // geom shape reader
|
|
||||||
gp_Ax3 myWorkingPlane;
|
gp_Ax3 myWorkingPlane;
|
||||||
QMap<int,QString> myRules; // popup rules
|
QMap<int,QString> myRules; // popup rules
|
||||||
static StudyTextureMap myTextureMap; // texture map
|
static StudyTextureMap myTextureMap; // texture map
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
#include <vtkRenderer.h>
|
#include <vtkRenderer.h>
|
||||||
|
|
||||||
static GEOM_Client ShapeReader;
|
static SHAPE_READER(ShapeReader);
|
||||||
|
|
||||||
inline OCCViewer_Viewer* GetOCCViewer(SUIT_Application* theApp){
|
inline OCCViewer_Viewer* GetOCCViewer(SUIT_Application* theApp){
|
||||||
SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
|
SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
|
||||||
|
@ -654,7 +654,7 @@ int GroupGUI_GroupDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMap
|
|||||||
if (GEOMBase::GetShape(aGeomObj, aShape)) {
|
if (GEOMBase::GetShape(aGeomObj, aShape)) {
|
||||||
if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == getShapeType()) {
|
if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == getShapeType()) {
|
||||||
TopTools_IndexedMapOfShape aMainMap;
|
TopTools_IndexedMapOfShape aMainMap;
|
||||||
TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
|
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
|
||||||
TopExp::MapShapes(aMainShape, aMainMap);
|
TopExp::MapShapes(aMainShape, aMainMap);
|
||||||
|
|
||||||
TopExp_Explorer anExp (aShape, getShapeType());
|
TopExp_Explorer anExp (aShape, getShapeType());
|
||||||
@ -804,12 +804,12 @@ void GroupGUI_GroupDlg::activateSelection()
|
|||||||
SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
|
SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
|
||||||
if (aView == 0) return;
|
if (aView == 0) return;
|
||||||
|
|
||||||
TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
|
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
|
||||||
TopoDS_Shape aRestrictionShape;
|
TopoDS_Shape aRestrictionShape;
|
||||||
if (subSelectionWay() == ALL_SUBSHAPES)
|
if (subSelectionWay() == ALL_SUBSHAPES)
|
||||||
aRestrictionShape = aMainShape;
|
aRestrictionShape = aMainShape;
|
||||||
else if (!myInPlaceObj->_is_nil())
|
else if (!myInPlaceObj->_is_nil())
|
||||||
aRestrictionShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myInPlaceObj);
|
aRestrictionShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myInPlaceObj);
|
||||||
else ;
|
else ;
|
||||||
|
|
||||||
TopTools_IndexedMapOfShape aSubShapesMap;
|
TopTools_IndexedMapOfShape aSubShapesMap;
|
||||||
|
@ -213,7 +213,7 @@ void RepairGUI_SuppressFacesDlg::SelectionIntoArgument()
|
|||||||
_PTR(Study) aStudy = appStudy->studyDS();
|
_PTR(Study) aStudy = appStudy->studyDS();
|
||||||
|
|
||||||
TopTools_IndexedMapOfShape aMainMap;
|
TopTools_IndexedMapOfShape aMainMap;
|
||||||
TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myObject);
|
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
|
||||||
TopExp::MapShapes(aMainShape, aMainMap);
|
TopExp::MapShapes(aMainShape, aMainMap);
|
||||||
|
|
||||||
SALOME_ListIteratorOfListIO anIter (aSelList);
|
SALOME_ListIteratorOfListIO anIter (aSelList);
|
||||||
|
Loading…
Reference in New Issue
Block a user