-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <TCollection_AsciiString.hxx>
#include <TDF_Label.hxx>
#include <TDF_Tool.hxx>
+#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Iterator.hxx>
#include <typeinfo>
#endif
-#ifdef WNT
+#ifdef WIN32
#pragma warning( disable:4786 )
#endif
//=============================================================================
GEOM_Object_i::GEOM_Object_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine,
- Handle(GEOM_Object) theImpl)
-: SALOME::GenericObj_i( thePOA ), _engine(theEngine), _impl(theImpl)
+ Handle(::GEOM_Object) theImpl) :
+ SALOME::GenericObj_i( thePOA ),
+ GEOM_BaseObject_i( thePOA, theEngine, theImpl ),
+ _impl( theImpl )
{
}
GEOM_Object_i::~GEOM_Object_i()
{
- MESSAGE("GEOM_Object_i::~GEOM_Object_i");
- GEOM_Engine::GetEngine()->RemoveObject(_impl);
-}
-
-
-//=============================================================================
-/*!
- * GetEntry
- */
-//=============================================================================
-char* GEOM_Object_i::GetEntry()
-{
- const TDF_Label& aLabel = _impl->GetEntry();
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(aLabel, anEntry);
- const char* anEntstr = anEntry.ToCString();
- return CORBA::string_dup(anEntstr);
-}
-
-//=============================================================================
-/*!
- * GetStudyID
- */
-//=============================================================================
-CORBA::Long GEOM_Object_i::GetStudyID()
-{
- return _impl->GetDocID();
-}
-
-
-//=============================================================================
-/*!
- * GetType
- */
-//=============================================================================
-CORBA::Long GEOM_Object_i::GetType()
-{
- return _impl->GetType();
+ //MESSAGE("GEOM_Object_i::~GEOM_Object_i");
}
//=============================================================================
return getMinMaxShapeType( _impl->GetValue(), false );
}
-//=============================================================================
+//================================================================================
/*!
- * SetName
+ * GetSubShapeName
*/
-//=============================================================================
-void GEOM_Object_i::SetName(const char* theName)
+//================================================================================
+
+char* GEOM_Object_i::GetSubShapeName(CORBA::Long subID)
{
- _impl->SetName(theName);
-}
+ CORBA::String_var name("");
+ Handle(::GEOM_Function) aMainFun = _impl->GetLastFunction();
+ if ( aMainFun.IsNull() ) return name._retn();
-//=============================================================================
-/*!
- * GetName
- */
-//=============================================================================
-char* GEOM_Object_i::GetName()
-{
- TCollection_AsciiString aName = _impl->GetName();
- return CORBA::string_dup( aName.ToCString() );
+ const TDataStd_ListOfExtendedString& aListEntries = aMainFun->GetSubShapeReferences();
+ TDataStd_ListIteratorOfListOfExtendedString anIt( aListEntries );
+ for (; anIt.More(); anIt.Next())
+ {
+ TCollection_AsciiString anEntry = anIt.Value();
+ Handle(::GEOM_BaseObject) anObj =
+ GEOM_Engine::GetEngine()->GetObject( _impl->GetDocID(), anEntry.ToCString(), false );
+ if ( anObj.IsNull() ) continue;
+
+ TCollection_AsciiString aSubName = anObj->GetName();
+ if ( aSubName.IsEmpty() ) continue;
+
+ Handle(::GEOM_Function) aFun = anObj->GetLastFunction();
+ if ( aFun.IsNull() ) continue;
+
+ GEOM_ISubShape ISS( aFun );
+ Handle(TColStd_HArray1OfInteger) subIDs = ISS.GetIndices();
+ if ( subIDs.IsNull() || subIDs->Length() != 1 ) continue;
+
+ if ( subIDs->Value( subIDs->Lower() ) == subID )
+ {
+ name = aSubName.ToCString();
+ break;
+ }
+ }
+ return name._retn();
}
//=============================================================================
return _impl->GetMarkerTexture();
}
-
-//=============================================================================
-/*!
- * SetStudyEntry
- */
-//=============================================================================
-void GEOM_Object_i::SetStudyEntry(const char* theEntry)
-{
- _impl->SetAuxData(theEntry);
-}
-
-
-//=============================================================================
-/*!
- * GetStudyEntry
- */
-//=============================================================================
-char* GEOM_Object_i::GetStudyEntry()
-{
- TCollection_AsciiString anEntry = _impl->GetAuxData();
- if(!anEntry.IsEmpty()) return CORBA::string_dup(anEntry.ToCString());
- return CORBA::string_dup("");
-}
-
-
-//=============================================================================
-/*!
- * GetDependency
- */
-//=============================================================================
-GEOM::ListOfGO* GEOM_Object_i::GetDependency()
-{
- GEOM::ListOfGO_var aList = new GEOM::ListOfGO();
- aList->length(0);
-
- Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetAllDependency();
- if (aSeq.IsNull()) return aList._retn();
- int aLength = aSeq->Length();
- if (aLength == 0) return aList._retn();
-
- aList->length(aLength);
-
- TCollection_AsciiString anEntry;
-
- for (int i = 1; i<=aLength; i++) {
- Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(aSeq->Value(i));
- if (anObj.IsNull()) continue;
- TDF_Tool::Entry(anObj->GetEntry(), anEntry);
- GEOM::GEOM_Object_var obj = _engine->GetObject(anObj->GetDocID(), anEntry.ToCString());
- aList[i-1] = obj;
- }
-
- return aList._retn();
-}
-
-//=============================================================================
-/*!
- * GetLastDependency
- */
-//=============================================================================
-GEOM::ListOfGO* GEOM_Object_i::GetLastDependency()
-{
- GEOM::ListOfGO_var aList = new GEOM::ListOfGO();
- aList->length(0);
-
- Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetLastDependency();
- if (aSeq.IsNull()) return aList._retn();
- int aLength = aSeq->Length();
- if (aLength == 0) return aList._retn();
-
- aList->length(aLength);
-
- TCollection_AsciiString anEntry;
-
- for (int i = 1; i<=aLength; i++) {
- Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(aSeq->Value(i));
- if (anObj.IsNull()) continue;
- TDF_Tool::Entry(anObj->GetEntry(), anEntry);
- GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_duplicate(_engine->GetObject(anObj->GetDocID(), anEntry.ToCString()));
- aList[i-1] = obj;
- }
-
- return aList._retn();
-}
-
//=================================================================================
// function : GetShapeStream
// Transfer resulting shape to client as sequence of bytes
GEOM::ListOfLong_var anIndices = new GEOM::ListOfLong;
if(!_impl->IsMainShape()) {
- Handle(GEOM_Function) aFunction = _impl->GetLastFunction(); //Get Sub-shape function (always the first (and last) one)
+ Handle(::GEOM_Function) aFunction = _impl->GetLastFunction(); //Get Sub-shape function (always the first (and last) one)
if(aFunction.IsNull()) return anIndices._retn();
GEOM_ISubShape ISS(aFunction);
Handle(TColStd_HArray1OfInteger) anArray = ISS.GetIndices();
{
GEOM::GEOM_Object_var obj;
if(!_impl->IsMainShape()) {
- Handle(GEOM_Function) aFunction = _impl->GetFunction(1); //Get Sub-shape function (always the first (and last) one)
+ Handle(::GEOM_Function) aFunction = _impl->GetFunction(1); //Get Sub-shape function (always the first (and last) one)
if(aFunction.IsNull()) return obj._retn();
GEOM_ISubShape ISS(aFunction);
if(aLabel.IsNull()) return obj._retn();
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aLabel, anEntry);
- return _engine->GetObject(_impl->GetDocID(), anEntry.ToCString());
+ return GEOM::GEOM_Object::_narrow
+ ( _engine->GetObject(_impl->GetDocID(), anEntry.ToCString()) );
}
return obj._retn();
return !_impl->GetValue().IsNull() && _impl->GetType() != GEOM_MARKER;
}
-bool GEOM_Object_i::IsSame(GEOM::GEOM_Object_ptr other)
-{
- TopoDS_Shape thisShape = _impl->GetValue();
- TopoDS_Shape otherShape;
- if ( !CORBA::is_nil( other ) ) {
- Handle(GEOM_Object) otherObject = GEOM_Engine::GetEngine()->GetObject( other->GetStudyID(), other->GetEntry(), false );
- if ( !otherObject.IsNull() )
- otherShape = otherObject->GetValue();
- }
- return thisShape.IsSame( otherShape );
-}
-
-void GEOM_Object_i::SetParameters(const char* theParameters)
-{
- _impl->SetParameters((char*)theParameters);
-}
-
-char* GEOM_Object_i::GetParameters()
-{
- return CORBA::string_dup(_impl->GetParameters().ToCString());
-}
-
-GEOM::CreationInformation* GEOM_Object_i::GetCreationInformation()
+bool GEOM_Object_i::IsSame(GEOM::GEOM_BaseObject_ptr other)
{
- GEOM::CreationInformation_var info = new GEOM::CreationInformation;
+ bool result = false;
- Handle(GEOM_BaseDriver) driver =
- Handle(GEOM_BaseDriver)::DownCast( _impl->GetCreationDriver() );
- if ( !driver.IsNull() )
- {
- std::vector<GEOM_Param> params;
- std::string operationName;
- try
- {
- OCC_CATCH_SIGNALS;
- if ( driver->GetCreationInformation( operationName, params ))
- {
- info->operationName = operationName.c_str();
- info->params.length( params.size() );
- for ( size_t i = 0; i < params.size(); ++i )
- {
- info->params[i].name = params[i].name.c_str();
- info->params[i].value = params[i].value.c_str();
- }
- }
-#ifdef _DEBUG_
- if ( operationName.empty() )
- {
- cout << endl << endl << endl << "Warning: " << endl << "Dear developer!!!" << endl
- << " Consider implementing "
- << typeid(*(driver.operator->())).name() << "::GetCreationInformation() " << endl
- << " for the case of operation which has created '" << GetName() << "' object" << endl
- << "PLEEEEEEEASE" << endl
- << "\tPLEEEEEEEASE" << endl
- << "\t\tPLEEEEEEEASE" << endl
- << "\t\t\tPLEEEEEEEASE" << endl
- << "\t\t\t\tPLEEEEEEEASE" << endl;
- }
-#endif
- }
- catch(...)
- {
-#ifdef _DEBUG_
- cout << "Ecxeption in GEOM_Object_i::GetCreationInformation()" << endl;
-#endif
+ GEOM::GEOM_Object_var shapePtr = GEOM::GEOM_Object::_narrow( other );
+ if ( !CORBA::is_nil( shapePtr ) ) {
+ CORBA::String_var entry = shapePtr->GetEntry();
+ Handle(::GEOM_Object) otherObject = Handle(::GEOM_Object)::DownCast
+ ( GEOM_Engine::GetEngine()->GetObject( shapePtr->GetStudyID(), entry, false ));
+ if ( !otherObject.IsNull() ) {
+ TopoDS_Shape thisShape = _impl->GetValue();
+ TopoDS_Shape otherShape = otherObject->GetValue();
+ result = !thisShape.IsNull() && !otherShape.IsNull() && thisShape.IsSame( otherShape );
}
}
- return info._retn();
+ return result;
}