Mantis issue 0020908: EDF GEOM: Compound of vertices.

This commit is contained in:
jfa 2010-06-17 10:03:31 +00:00
parent 76715a1dc0
commit 4dfe2cd0b6
4 changed files with 277 additions and 240 deletions

View File

@ -129,7 +129,8 @@ int GEOMGUI_Selection::typeId( const int index ) const
int aType = -1; int aType = -1;
GEOM::GEOM_Object_var anObj = getObject( index ); GEOM::GEOM_Object_var anObj = getObject( index );
if ( !CORBA::is_nil( anObj ) ) if ( !CORBA::is_nil( anObj ) )
aType = anObj->GetType(); //aType = anObj->GetType();
aType = (int)anObj->GetShapeType();
return aType; return aType;
} }

View File

@ -1053,7 +1053,8 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
mgr->setRule( action( GEOMOp::OpDeflection ), "selcount>0 and isVisible and client='OCCViewer'", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpDeflection ), "selcount>0 and isVisible and client='OCCViewer'", QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg( GEOM_POINT ), QtxPopupMgr::VisibleRule ); //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM::VERTEX), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );

View File

@ -3169,6 +3169,11 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
if( min_l < fabs(aYmax - aYmin) ) min_l = fabs(aYmax - aYmin); if( min_l < fabs(aYmax - aYmin) ) min_l = fabs(aYmax - aYmin);
if( min_l < fabs(aZmax - aZmin) ) min_l = fabs(aZmax - aZmin); if( min_l < fabs(aZmax - aZmin) ) min_l = fabs(aZmax - aZmin);
min_l /= dl_l; min_l /= dl_l;
// Mantis issue 0020908 BEGIN
if (!Exp_Edge.More()) {
min_l = Precision::Confusion();
}
// Mantis issue 0020908 END
for ( Standard_Integer nbEdge = 0; Exp_Edge.More(); Exp_Edge.Next(), nbEdge++ ) { for ( Standard_Integer nbEdge = 0; Exp_Edge.More(); Exp_Edge.Next(), nbEdge++ ) {
TopExp_Explorer Exp_Vertex( Exp_Edge.Current(), TopAbs_VERTEX); TopExp_Explorer Exp_Vertex( Exp_Edge.Current(), TopAbs_VERTEX);
for ( Standard_Integer nbVertex = 0; Exp_Vertex.More(); Exp_Vertex.Next(), nbVertex++ ) { for ( Standard_Integer nbVertex = 0; Exp_Vertex.More(); Exp_Vertex.Next(), nbVertex++ ) {

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifdef WNT #ifdef WNT
#pragma warning( disable:4786 ) #pragma warning( disable:4786 )
@ -68,10 +67,10 @@
// purpose : constructor to be called for servant creation. // purpose : constructor to be called for servant creation.
//============================================================================ //============================================================================
GEOM_Gen_i::GEOM_Gen_i(CORBA::ORB_ptr orb, GEOM_Gen_i::GEOM_Gen_i(CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa, PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId, PortableServer::ObjectId* contId,
const char* instanceName, const char* instanceName,
const char* interfaceName) : const char* interfaceName) :
Engines_Component_i(orb, poa, contId, instanceName, interfaceName) Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
{ {
_thisObj = this; _thisObj = this;
@ -114,9 +113,9 @@ GEOM_Gen_i::~GEOM_Gen_i() {
// purpose : // purpose :
//============================================================================ //============================================================================
char* GEOM_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, char* GEOM_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
const char* IORString, const char* IORString,
CORBA::Boolean isMultiFile, CORBA::Boolean isMultiFile,
CORBA::Boolean isASCII) CORBA::Boolean isASCII)
{ {
GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(_orb->string_to_object(IORString)); GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(_orb->string_to_object(IORString));
if (!CORBA::is_nil(anObject)) { if (!CORBA::is_nil(anObject)) {
@ -133,9 +132,9 @@ char* GEOM_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
// : The IOR (IORName) of object created is returned // : The IOR (IORName) of object created is returned
//============================================================================ //============================================================================
char* GEOM_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, char* GEOM_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
const char* aLocalPersistentID, const char* aLocalPersistentID,
CORBA::Boolean isMultiFile, CORBA::Boolean isMultiFile,
CORBA::Boolean isASCII) CORBA::Boolean isASCII)
{ {
SALOMEDS::Study_var aStudy = theSObject->GetStudy(); SALOMEDS::Study_var aStudy = theSObject->GetStudy();
@ -164,9 +163,9 @@ bool GEOM_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
// purpose : // purpose :
//============================================================================ //============================================================================
SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject, SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theObject, CORBA::Object_ptr theObject,
const char* theName) throw (SALOME::SALOME_Exception) const char* theName) throw (SALOME::SALOME_Exception)
{ {
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
SALOMEDS::SObject_var aResultSO; SALOMEDS::SObject_var aResultSO;
@ -266,7 +265,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
aPixmap->Destroy(); aPixmap->Destroy();
//if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag()); //if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag());
//else aShapeName = TCollection_AsciiString(CORBA::string_dup(theName)); //else aShapeName = TCollection_AsciiString(CORBA::string_dup(theName));
// try to find existed name for current shape // try to find existed name for current shape
bool HasName = false; bool HasName = false;
// recieve current TopoDS shape // recieve current TopoDS shape
@ -307,8 +306,8 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_var obj; SALOMEDS::SObject_var obj;
TCollection_AsciiString aNewShapeName; TCollection_AsciiString aNewShapeName;
do { do {
aNewShapeName = aShapeName + TCollection_AsciiString(++i); aNewShapeName = aShapeName + TCollection_AsciiString(++i);
obj = theStudy->FindObject( aNewShapeName.ToCString() ); obj = theStudy->FindObject( aNewShapeName.ToCString() );
} }
while ( !obj->_is_nil() ); while ( !obj->_is_nil() );
aShapeName = aNewShapeName; aShapeName = aNewShapeName;
@ -335,9 +334,9 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
SALOMEDS::ListOfStrings aListOfVars = aSections[i]; SALOMEDS::ListOfStrings aListOfVars = aSections[i];
for(int j = 0, m = aListOfVars.length(); j < m; j++) { for(int j = 0, m = aListOfVars.length(); j < m; j++) {
if(theStudy->IsVariable(aListOfVars[j].in())) if(theStudy->IsVariable(aListOfVars[j].in()))
aVars += TCollection_AsciiString(aListOfVars[j].in()); aVars += TCollection_AsciiString(aListOfVars[j].in());
if(j != m-1) if(j != m-1)
aVars += ":"; aVars += ":";
} }
if(i != n-1) if(i != n-1)
aVars += "|"; aVars += "|";
@ -361,12 +360,12 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
// purpose : auxilary for PublishNamedShapesInStudy // purpose : auxilary for PublishNamedShapesInStudy
//============================================================================ //============================================================================
void GEOM_Gen_i::CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy, void GEOM_Gen_i::CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_var theMainShape, GEOM::GEOM_Object_var theMainShape,
const TopTools_IndexedMapOfShape& anIndices, const TopTools_IndexedMapOfShape& anIndices,
const TopTools_SequenceOfShape& SeqS, const TopTools_SequenceOfShape& SeqS,
const TColStd_SequenceOfAsciiString& SeqN, const TColStd_SequenceOfAsciiString& SeqN,
const Standard_CString& GrName, const Standard_CString& GrName,
GEOM::ListOfGO_var aResList) GEOM::ListOfGO_var aResList)
{ {
CORBA::String_var entry = theMainShape->GetEntry(); CORBA::String_var entry = theMainShape->GetEntry();
Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry); Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
@ -412,8 +411,8 @@ void GEOM_Gen_i::CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
//============================================================================ //============================================================================
GEOM::ListOfGO* GEOM_Gen_i:: GEOM::ListOfGO* GEOM_Gen_i::
PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy, PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
//SALOMEDS::SObject_ptr theSObject, //SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theObject) CORBA::Object_ptr theObject)
{ {
//Unexpect aCatch(SALOME_SalomeException); //Unexpect aCatch(SALOME_SalomeException);
GEOM::ListOfGO_var aResList = new GEOM::ListOfGO; GEOM::ListOfGO_var aResList = new GEOM::ListOfGO;
@ -442,20 +441,20 @@ GEOM::ListOfGO* GEOM_Gen_i::
if(L.FindAttribute(TDataStd_Name::GetID(),aName)) { if(L.FindAttribute(TDataStd_Name::GetID(),aName)) {
TCollection_ExtendedString EName = aName->Get(); TCollection_ExtendedString EName = aName->Get();
if(S.ShapeType()==TopAbs_SOLID) { if(S.ShapeType()==TopAbs_SOLID) {
SolidSeqS.Append(S); SolidSeqS.Append(S);
SolidSeqN.Append(aName->Get()); SolidSeqN.Append(aName->Get());
} }
else if(S.ShapeType()==TopAbs_FACE) { else if(S.ShapeType()==TopAbs_FACE) {
FaceSeqS.Append(S); FaceSeqS.Append(S);
FaceSeqN.Append(aName->Get()); FaceSeqN.Append(aName->Get());
} }
else if(S.ShapeType()==TopAbs_EDGE) { else if(S.ShapeType()==TopAbs_EDGE) {
EdgeSeqS.Append(S); EdgeSeqS.Append(S);
EdgeSeqN.Append(aName->Get()); EdgeSeqN.Append(aName->Get());
} }
else if(S.ShapeType()==TopAbs_VERTEX) { else if(S.ShapeType()==TopAbs_VERTEX) {
VertSeqS.Append(S); VertSeqS.Append(S);
VertSeqN.Append(aName->Get()); VertSeqN.Append(aName->Get());
} }
} }
} }
@ -464,16 +463,16 @@ GEOM::ListOfGO* GEOM_Gen_i::
TopExp::MapShapes(MainSh, anIndices); TopExp::MapShapes(MainSh, anIndices);
CreateAndPublishGroup(theStudy, theMainShape, anIndices, SolidSeqS, SolidSeqN, CreateAndPublishGroup(theStudy, theMainShape, anIndices, SolidSeqS, SolidSeqN,
"Group_Of_Named_Solids", aResList); "Group_Of_Named_Solids", aResList);
CreateAndPublishGroup(theStudy, theMainShape, anIndices, FaceSeqS, FaceSeqN, CreateAndPublishGroup(theStudy, theMainShape, anIndices, FaceSeqS, FaceSeqN,
"Group_Of_Named_Faces", aResList); "Group_Of_Named_Faces", aResList);
CreateAndPublishGroup(theStudy, theMainShape, anIndices, EdgeSeqS, EdgeSeqN, CreateAndPublishGroup(theStudy, theMainShape, anIndices, EdgeSeqS, EdgeSeqN,
"Group_Of_Named_Edges", aResList); "Group_Of_Named_Edges", aResList);
CreateAndPublishGroup(theStudy, theMainShape, anIndices, VertSeqS, VertSeqN, CreateAndPublishGroup(theStudy, theMainShape, anIndices, VertSeqS, VertSeqN,
"Group_Of_Named_Vertices", aResList); "Group_Of_Named_Vertices", aResList);
return aResList._retn(); return aResList._retn();
} }
@ -484,8 +483,8 @@ GEOM::ListOfGO* GEOM_Gen_i::
// purpose : save OCAF/Geom document // purpose : save OCAF/Geom document
//============================================================================ //============================================================================
SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
const char* theURL, const char* theURL,
bool isMultiFile) { bool isMultiFile) {
SALOMEDS::TMPFile_var aStreamFile; SALOMEDS::TMPFile_var aStreamFile;
// Get a temporary directory to store a file // Get a temporary directory to store a file
std::string aTmpDir = (isMultiFile)?theURL:SALOMEDS_Tool::GetTmpDir(); std::string aTmpDir = (isMultiFile)?theURL:SALOMEDS_Tool::GetTmpDir();
@ -529,8 +528,8 @@ SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
// purpose : // purpose :
//============================================================================ //============================================================================
SALOMEDS::TMPFile* GEOM_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, SALOMEDS::TMPFile* GEOM_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
const char* theURL, const char* theURL,
bool isMultiFile) { bool isMultiFile) {
SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile); SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
return aStreamFile._retn(); return aStreamFile._retn();
} }
@ -541,9 +540,9 @@ SALOMEDS::TMPFile* GEOM_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
// purpose : // purpose :
//============================================================================ //============================================================================
CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
const SALOMEDS::TMPFile& theStream, const SALOMEDS::TMPFile& theStream,
const char* theURL, const char* theURL,
bool isMultiFile) { bool isMultiFile) {
if (theStream.length() <= 9) { if (theStream.length() <= 9) {
MESSAGE("The TMPFile is too short : " << theStream.length() << " bytes "); MESSAGE("The TMPFile is too short : " << theStream.length() << " bytes ");
@ -593,9 +592,9 @@ CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
// purpose : // purpose :
//============================================================================ //============================================================================
CORBA::Boolean GEOM_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent, CORBA::Boolean GEOM_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
const SALOMEDS::TMPFile& theStream, const SALOMEDS::TMPFile& theStream,
const char* theURL, const char* theURL,
bool isMultiFile) { bool isMultiFile) {
return Load(theComponent, theStream, theURL, isMultiFile); return Load(theComponent, theStream, theURL, isMultiFile);
} }
@ -671,8 +670,8 @@ CORBA::Boolean GEOM_Gen_i::CanPaste(const char* theComponentName, CORBA::Long th
// purpose : // purpose :
//============================================================================ //============================================================================
SALOMEDS::SObject_ptr GEOM_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream, SALOMEDS::SObject_ptr GEOM_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
CORBA::Long theObjectID, CORBA::Long theObjectID,
SALOMEDS::SObject_ptr theObject) { SALOMEDS::SObject_ptr theObject) {
// Find the current Study and StudyBuilder // Find the current Study and StudyBuilder
SALOMEDS::Study_var aStudy = theObject->GetStudy(); SALOMEDS::Study_var aStudy = theObject->GetStudy();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
@ -731,9 +730,9 @@ char* GEOM_Gen_i::ComponentDataType()
// purpose : // purpose :
//============================================================================ //============================================================================
SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theObject,
const char* theName, const char* theName,
GEOM::GEOM_Object_ptr theFather) GEOM::GEOM_Object_ptr theFather)
{ {
SALOMEDS::SObject_var aResultSO; SALOMEDS::SObject_var aResultSO;
if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO; if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO;
@ -779,7 +778,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
// To be used from python scripts out of geompy.addToStudy (non-default usage) // To be used from python scripts out of geompy.addToStudy (non-default usage)
//============================================================================ //============================================================================
GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy, GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theObject,
const GEOM::ListOfGO& theArgs, const GEOM::ListOfGO& theArgs,
GEOM::find_shape_method theFindMethod, GEOM::find_shape_method theFindMethod,
CORBA::Boolean theInheritFirstArg, CORBA::Boolean theInheritFirstArg,
@ -868,11 +867,11 @@ static void addToListOfGO( const GEOM::ListOfGO& theSrcList,
// are defined, and does not check, if they correspond to each other. // are defined, and does not check, if they correspond to each other.
//============================================================================ //============================================================================
GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy, GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy,
GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theObject,
SALOMEDS::SObject_ptr theSObject, SALOMEDS::SObject_ptr theSObject,
const GEOM::ListOfGO& theArgs, const GEOM::ListOfGO& theArgs,
GEOM::find_shape_method theFindMethod, GEOM::find_shape_method theFindMethod,
CORBA::Boolean theInheritFirstArg, CORBA::Boolean theInheritFirstArg,
CORBA::Boolean theAddPrefix) CORBA::Boolean theAddPrefix)
{ {
GEOM::ListOfGO_var aParts = new GEOM::ListOfGO; GEOM::ListOfGO_var aParts = new GEOM::ListOfGO;
@ -916,6 +915,13 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy,
// set the color of the transformed shape to the color of initial shape // set the color of the transformed shape to the color of initial shape
theObject->SetColor(aList[0]->GetColor()); theObject->SetColor(aList[0]->GetColor());
// set the texture
if (theObject->GetShapeType() == GEOM::VERTEX) {
theObject->SetMarkerStd(aList[0]->GetMarkerType(), aList[0]->GetMarkerSize());
if (aList[0]->GetMarkerType() == GEOM::MT_USER)
theObject->SetMarkerTexture(aList[0]->GetMarkerTexture());
}
anArgSO->Destroy(); anArgSO->Destroy();
} }
else { else {
@ -1005,6 +1011,12 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy,
aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString()); aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
// Restore color // Restore color
aSubO->SetColor(anArgO->GetColor()); aSubO->SetColor(anArgO->GetColor());
// set the texture
if (aSubO->GetShapeType() == GEOM::VERTEX) {
aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
if (anArgO->GetMarkerType() == GEOM::MT_USER)
aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
}
} }
if (!CORBA::is_nil(anArgSO)) { if (!CORBA::is_nil(anArgSO)) {
@ -1056,6 +1068,12 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy,
aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString()); aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString());
// Restore color // Restore color
aSubO->SetColor(anArgO->GetColor()); aSubO->SetColor(anArgO->GetColor());
// set the texture
if (aSubO->GetShapeType() == GEOM::VERTEX) {
aSubO->SetMarkerStd(anArgO->GetMarkerType(), anArgO->GetMarkerSize());
if (anArgO->GetMarkerType() == GEOM::MT_USER)
aSubO->SetMarkerTexture(anArgO->GetMarkerTexture());
}
} }
} }
else if (!CORBA::is_nil(aSubSO)) { else if (!CORBA::is_nil(aSubSO)) {
@ -1138,10 +1156,10 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy,
// purpose : Private method // purpose : Private method
//============================================================================ //============================================================================
GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy, GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theOldSO, SALOMEDS::SObject_ptr theOldSO,
SALOMEDS::SObject_ptr theNewSO, SALOMEDS::SObject_ptr theNewSO,
GEOM::GEOM_Object_ptr theNewO, GEOM::GEOM_Object_ptr theNewO,
GEOM::find_shape_method theFindMethod, GEOM::find_shape_method theFindMethod,
CORBA::Boolean theAddPrefix) CORBA::Boolean theAddPrefix)
{ {
int i = 0; int i = 0;
@ -1175,135 +1193,147 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr th
if (anOldSubSO->FindAttribute(anAttr, "AttributeIOR")) { if (anOldSubSO->FindAttribute(anAttr, "AttributeIOR")) {
SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
GEOM::GEOM_Object_var anOldSubO = GEOM::GEOM_Object_var anOldSubO =
GEOM::GEOM_Object::_narrow(_orb->string_to_object(anAttrIOR->Value())); GEOM::GEOM_Object::_narrow(_orb->string_to_object(anAttrIOR->Value()));
if (!CORBA::is_nil(anOldSubO)) { if (!CORBA::is_nil(anOldSubO)) {
// Find a sub-shape of theNewO in place of anOldSubO // Find a sub-shape of theNewO in place of anOldSubO
GEOM::GEOM_Object_var aNewSubO; GEOM::GEOM_Object_var aNewSubO;
switch (theFindMethod) { switch (theFindMethod) {
case GEOM::FSM_GetInPlace: case GEOM::FSM_GetInPlace:
{ {
// Use GetInPlace // Use GetInPlace
aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO); aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO);
} }
break; break;
case GEOM::FSM_Transformed: case GEOM::FSM_Transformed:
{ {
// transformation, cannot use GetInPlace, operate with indices // transformation, cannot use GetInPlace, operate with indices
GEOM::ListOfLong_var anIDs = anOldSubO->GetSubShapeIndices(); GEOM::ListOfLong_var anIDs = anOldSubO->GetSubShapeIndices();
if (anIDs->length() > 1) { if (anIDs->length() > 1) {
// group // group
aNewSubO = aGroupOp->CreateGroup(theNewO, aGroupOp->GetType(anOldSubO)); aNewSubO = aGroupOp->CreateGroup(theNewO, aGroupOp->GetType(anOldSubO));
if (!CORBA::is_nil(aNewSubO)) if (!CORBA::is_nil(aNewSubO))
aGroupOp->UnionIDs(aNewSubO, anIDs); aGroupOp->UnionIDs(aNewSubO, anIDs);
} }
else { else {
// single sub-shape // single sub-shape
aNewSubO = aShapesOp->GetSubShape(theNewO, anIDs[0]); aNewSubO = aShapesOp->GetSubShape(theNewO, anIDs[0]);
} }
} }
break; break;
case GEOM::FSM_GetSame: case GEOM::FSM_GetSame:
{ {
// Use GetSame // Use GetSame
aNewSubO = aShapesOp->GetSame(theNewO, anOldSubO); aNewSubO = aShapesOp->GetSame(theNewO, anOldSubO);
} }
break; break;
case GEOM::FSM_GetShapesOnShape: case GEOM::FSM_GetShapesOnShape:
{ {
// Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids // Use GetShapesOnShape. Can work only on solids, so it has sense to search only solids
aNewSubO = aShapesOp->GetShapesOnShapeAsCompound(anOldSubO, theNewO, aNewSubO = aShapesOp->GetShapesOnShapeAsCompound(anOldSubO, theNewO,
(short)GEOM::SOLID, GEOM::ST_ONIN); (short)GEOM::SOLID, GEOM::ST_ONIN);
} }
break; break;
case GEOM::FSM_GetInPlaceByHistory: case GEOM::FSM_GetInPlaceByHistory:
{ {
// Use GetInPlaceByHistory // Use GetInPlaceByHistory
aNewSubO = aShapesOp->GetInPlaceByHistory(theNewO, anOldSubO); aNewSubO = aShapesOp->GetInPlaceByHistory(theNewO, anOldSubO);
} }
break; break;
default: default:
{} {}
} }
if (!CORBA::is_nil(aNewSubO)) { if (!CORBA::is_nil(aNewSubO)) {
// add the part to the list // add the part to the list
aParts[i] = aNewSubO; aParts[i] = aNewSubO;
i++; i++;
// add to parts list // add to parts list
addToListOfGO( aNewSubO, aNewParts ); addToListOfGO( aNewSubO, aNewParts );
SALOMEDS::SObject_var aNewSubSO; SALOMEDS::SObject_var aNewSubSO;
if (!CORBA::is_nil(theNewSO)) { if (!CORBA::is_nil(theNewSO)) {
// Publish the sub-shape // Publish the sub-shape
TCollection_AsciiString aSubName; TCollection_AsciiString aSubName;
if (theAddPrefix) { if (theAddPrefix) {
aSubName = "from_"; aSubName = "from_";
} }
aSubName += anArgName; aSubName += anArgName;
aNewSubSO = aStudyBuilder->NewObject(theNewSO); aNewSubSO = aStudyBuilder->NewObject(theNewSO);
aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString()); aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
// Restore color // Restore color
aNewSubO->SetColor(anOldSubO->GetColor()); aNewSubO->SetColor(anOldSubO->GetColor());
// set the texture
if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
}
} }
// Restore published sub-shapes of the argument // Restore published sub-shapes of the argument
GEOM::ListOfGO_var aSubParts; GEOM::ListOfGO_var aSubParts;
if (theFindMethod == GEOM::FSM_GetInPlaceByHistory) if (theFindMethod == GEOM::FSM_GetInPlaceByHistory)
// pass the main shape as Object, because only it has the history // pass the main shape as Object, because only it has the history
aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
theNewO, theFindMethod, theAddPrefix); theNewO, theFindMethod, theAddPrefix);
else else
aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, aSubParts = RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
aNewSubO, theFindMethod, theAddPrefix); aNewSubO, theFindMethod, theAddPrefix);
// add to parts list // add to parts list
addToListOfGO( aSubParts, aNewParts ); addToListOfGO( aSubParts, aNewParts );
} }
else { // GetInPlace failed, try to build from published parts else { // GetInPlace failed, try to build from published parts
SALOMEDS::SObject_var aNewSubSO; SALOMEDS::SObject_var aNewSubSO;
if (!CORBA::is_nil(theNewSO)) if (!CORBA::is_nil(theNewSO))
aNewSubSO = aStudyBuilder->NewObject(theNewSO); aNewSubSO = aStudyBuilder->NewObject(theNewSO);
// Restore published sub-shapes of the argument // Restore published sub-shapes of the argument
GEOM::ListOfGO_var aSubParts = GEOM::ListOfGO_var aSubParts =
RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO,
theNewO, theFindMethod, theAddPrefix); theNewO, theFindMethod, theAddPrefix);
// add to parts list // add to parts list
addToListOfGO( aSubParts, aNewParts ); addToListOfGO( aSubParts, aNewParts );
if (aSubParts->length() > 0) { if (aSubParts->length() > 0) {
// try to build an object from a set of its sub-shapes, // try to build an object from a set of its sub-shapes,
// that published and will be reconstructed // that published and will be reconstructed
if (aSubParts->length() > 1) { if (aSubParts->length() > 1) {
aNewSubO = aShapesOp->MakeCompound(aSubParts); aNewSubO = aShapesOp->MakeCompound(aSubParts);
// add to parts list // add to parts list
addToListOfGO( aNewSubO, aNewParts ); addToListOfGO( aNewSubO, aNewParts );
} }
else { else {
aNewSubO = aSubParts[0]; aNewSubO = aSubParts[0];
} }
if (!CORBA::is_nil(aNewSubO)) { if (!CORBA::is_nil(aNewSubO)) {
// add the part to the list // add the part to the list
aSubParts[i] = aNewSubO; aSubParts[i] = aNewSubO;
i++; i++;
// Publish the sub-shape // Publish the sub-shape
if (!CORBA::is_nil(aNewSubSO)) { if (!CORBA::is_nil(aNewSubSO)) {
TCollection_AsciiString aSubName; TCollection_AsciiString aSubName;
if (theAddPrefix) { if (theAddPrefix) {
aSubName = "from_parts_of_"; aSubName = "from_parts_of_";
} }
aSubName += anArgName; aSubName += anArgName;
aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString()); aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString());
// Restore color // Restore color
aNewSubO->SetColor(anOldSubO->GetColor()); aNewSubO->SetColor(anOldSubO->GetColor());
// set the texture
if (aNewSubO->GetShapeType() == GEOM::VERTEX) {
aNewSubO->SetMarkerStd(anOldSubO->GetMarkerType(), anOldSubO->GetMarkerSize());
if (anOldSubO->GetMarkerType() == GEOM::MT_USER)
aNewSubO->SetMarkerTexture(anOldSubO->GetMarkerTexture());
}
} }
} }
} }
else if (!CORBA::is_nil(aNewSubSO)) { else if (!CORBA::is_nil(aNewSubSO)) {
// remove created aSubSO, because no parts have been found // remove created aSubSO, because no parts have been found
aStudyBuilder->RemoveObject(aNewSubSO); aStudyBuilder->RemoveObject(aNewSubSO);
} }
} // try to build from published parts } // try to build from published parts
} }
} }
} // iterate on published sub-shapes } // iterate on published sub-shapes
@ -1611,7 +1641,7 @@ GEOM::GEOM_IAdvancedOperations_ptr GEOM_Gen_i::GetIAdvancedOperations(CORBA::Lon
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
const GEOM::ListOfLong& theIndices) const GEOM::ListOfLong& theIndices)
{ {
if (CORBA::is_nil(theMainShape) || theIndices.length() < 1) if (CORBA::is_nil(theMainShape) || theIndices.length() < 1)
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
@ -1713,7 +1743,7 @@ bool GEOM_Gen_i::hasObjectInfo()
char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry) char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry)
{ {
GEOM::GEOM_Object_var aGeomObject; GEOM::GEOM_Object_var aGeomObject;
CORBA::Object_var aSMObject = name_service->Resolve( "/myStudyManager" ); CORBA::Object_var aSMObject = name_service->Resolve( "/myStudyManager" );
SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject ); SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId ); SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId );
@ -1732,7 +1762,7 @@ char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry)
} }
if (!aSObj->_is_nil() ) if (!aSObj->_is_nil() )
aSObj->Destroy(); aSObj->Destroy();
const char* aTypeInfo = "Object"; const char* aTypeInfo = "Object";
if ( !aGeomObject->_is_nil() ) { if ( !aGeomObject->_is_nil() ) {
GEOM::GEOM_IKindOfShape::shape_kind aKind; GEOM::GEOM_IKindOfShape::shape_kind aKind;
@ -1745,110 +1775,110 @@ char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry)
if ( anOp->IsDone() ) { if ( anOp->IsDone() ) {
switch ( aKind ) { switch ( aKind ) {
case GEOM::GEOM_IKindOfShape::COMPOUND: case GEOM::GEOM_IKindOfShape::COMPOUND:
aTypeInfo = "Compound"; aTypeInfo = "Compound";
break; break;
case GEOM::GEOM_IKindOfShape::COMPSOLID: case GEOM::GEOM_IKindOfShape::COMPSOLID:
aTypeInfo = "CompSolid"; aTypeInfo = "CompSolid";
break; break;
case GEOM::GEOM_IKindOfShape::SHELL: case GEOM::GEOM_IKindOfShape::SHELL:
aTypeInfo = "Shell"; aTypeInfo = "Shell";
break; break;
case GEOM::GEOM_IKindOfShape::WIRE: case GEOM::GEOM_IKindOfShape::WIRE:
if ( anInts[0] == 1 ) if ( anInts[0] == 1 )
aTypeInfo = "Closed Wire"; aTypeInfo = "Closed Wire";
else if ( anInts[0] == 2 ) else if ( anInts[0] == 2 )
aTypeInfo = "Opened Wire"; aTypeInfo = "Opened Wire";
else else
aTypeInfo = "Wire"; aTypeInfo = "Wire";
break; break;
// SOLIDs // SOLIDs
case GEOM::GEOM_IKindOfShape::SPHERE: case GEOM::GEOM_IKindOfShape::SPHERE:
aTypeInfo = "Sphere"; aTypeInfo = "Sphere";
break; break;
case GEOM::GEOM_IKindOfShape::CYLINDER: case GEOM::GEOM_IKindOfShape::CYLINDER:
aTypeInfo = "Cylinder"; aTypeInfo = "Cylinder";
break; break;
case GEOM::GEOM_IKindOfShape::BOX: case GEOM::GEOM_IKindOfShape::BOX:
case GEOM::GEOM_IKindOfShape::ROTATED_BOX: case GEOM::GEOM_IKindOfShape::ROTATED_BOX:
aTypeInfo = "Box"; aTypeInfo = "Box";
break; break;
case GEOM::GEOM_IKindOfShape::TORUS: case GEOM::GEOM_IKindOfShape::TORUS:
aTypeInfo = "Torus"; aTypeInfo = "Torus";
break; break;
case GEOM::GEOM_IKindOfShape::CONE: case GEOM::GEOM_IKindOfShape::CONE:
aTypeInfo = "Cone"; aTypeInfo = "Cone";
break; break;
case GEOM::GEOM_IKindOfShape::POLYHEDRON: case GEOM::GEOM_IKindOfShape::POLYHEDRON:
aTypeInfo = "Polyhedron"; aTypeInfo = "Polyhedron";
break; break;
case GEOM::GEOM_IKindOfShape::SOLID: case GEOM::GEOM_IKindOfShape::SOLID:
aTypeInfo = "Solid"; aTypeInfo = "Solid";
break; break;
// FACEs // FACEs
case GEOM::GEOM_IKindOfShape::SPHERE2D: case GEOM::GEOM_IKindOfShape::SPHERE2D:
aTypeInfo = "Spherical Face"; aTypeInfo = "Spherical Face";
break; break;
case GEOM::GEOM_IKindOfShape::CYLINDER2D: case GEOM::GEOM_IKindOfShape::CYLINDER2D:
aTypeInfo = "Cylindrical Face"; aTypeInfo = "Cylindrical Face";
break; break;
case GEOM::GEOM_IKindOfShape::TORUS2D: case GEOM::GEOM_IKindOfShape::TORUS2D:
aTypeInfo = "Toroidal Face"; aTypeInfo = "Toroidal Face";
break; break;
case GEOM::GEOM_IKindOfShape::CONE2D: case GEOM::GEOM_IKindOfShape::CONE2D:
aTypeInfo = "Conical Face"; aTypeInfo = "Conical Face";
break; break;
case GEOM::GEOM_IKindOfShape::DISK_CIRCLE: case GEOM::GEOM_IKindOfShape::DISK_CIRCLE:
aTypeInfo = "Disk"; aTypeInfo = "Disk";
break; break;
case GEOM::GEOM_IKindOfShape::DISK_ELLIPSE: case GEOM::GEOM_IKindOfShape::DISK_ELLIPSE:
aTypeInfo = "Elliptical Face"; aTypeInfo = "Elliptical Face";
break; break;
case GEOM::GEOM_IKindOfShape::POLYGON: case GEOM::GEOM_IKindOfShape::POLYGON:
aTypeInfo = "Polygon"; aTypeInfo = "Polygon";
break; break;
case GEOM::GEOM_IKindOfShape::PLANE: case GEOM::GEOM_IKindOfShape::PLANE:
aTypeInfo = "Plane"; aTypeInfo = "Plane";
break; break;
case GEOM::GEOM_IKindOfShape::PLANAR: case GEOM::GEOM_IKindOfShape::PLANAR:
aTypeInfo = "Planar Face"; aTypeInfo = "Planar Face";
break; break;
case GEOM::GEOM_IKindOfShape::FACE: case GEOM::GEOM_IKindOfShape::FACE:
aTypeInfo = "Face"; aTypeInfo = "Face";
break; break;
// EDGEs // EDGEs
case GEOM::GEOM_IKindOfShape::CIRCLE: case GEOM::GEOM_IKindOfShape::CIRCLE:
aTypeInfo = "Circle"; aTypeInfo = "Circle";
break; break;
case GEOM::GEOM_IKindOfShape::ARC_CIRCLE: case GEOM::GEOM_IKindOfShape::ARC_CIRCLE:
aTypeInfo = "Arc Circle"; aTypeInfo = "Arc Circle";
break; break;
case GEOM::GEOM_IKindOfShape::ELLIPSE: case GEOM::GEOM_IKindOfShape::ELLIPSE:
aTypeInfo = "Ellipse"; aTypeInfo = "Ellipse";
break; break;
case GEOM::GEOM_IKindOfShape::ARC_ELLIPSE: case GEOM::GEOM_IKindOfShape::ARC_ELLIPSE:
aTypeInfo = "Arc Ellipse"; aTypeInfo = "Arc Ellipse";
break; break;
case GEOM::GEOM_IKindOfShape::LINE: case GEOM::GEOM_IKindOfShape::LINE:
aTypeInfo = "Line"; aTypeInfo = "Line";
break; break;
case GEOM::GEOM_IKindOfShape::SEGMENT: case GEOM::GEOM_IKindOfShape::SEGMENT:
aTypeInfo = "Segment"; aTypeInfo = "Segment";
break; break;
case GEOM::GEOM_IKindOfShape::EDGE: case GEOM::GEOM_IKindOfShape::EDGE:
aTypeInfo = "Edge"; aTypeInfo = "Edge";
break; break;
case GEOM::GEOM_IKindOfShape::VERTEX: case GEOM::GEOM_IKindOfShape::VERTEX:
aTypeInfo = "Vertex"; aTypeInfo = "Vertex";
break; break;
default: default:
break; break;
} }
} }
} }
char* anInfo = new char[strlen("Module ") + strlen(ComponentDataType()) + strlen(", ") + strlen(aTypeInfo) + 3]; char* anInfo = new char[strlen("Module ") + strlen(ComponentDataType()) + strlen(", ") + strlen(aTypeInfo) + 3];
sprintf(anInfo, "Module %s, %s", ComponentDataType(), aTypeInfo); sprintf(anInfo, "Module %s, %s", ComponentDataType(), aTypeInfo);
char* ret = CORBA::string_dup(anInfo); char* ret = CORBA::string_dup(anInfo);
delete [] anInfo; delete [] anInfo;
return ret; return ret;
@ -1863,13 +1893,13 @@ extern "C"
GEOM_I_EXPORT GEOM_I_EXPORT
PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB*, PortableServer::POA*, PortableServer::ObjectId*, const char*, const char*); PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB*, PortableServer::POA*, PortableServer::ObjectId*, const char*, const char*);
*/ */
GEOM_I_EXPORT GEOM_I_EXPORT
PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB_ptr orb, PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa, PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId, PortableServer::ObjectId* contId,
const char* instanceName, const char* instanceName,
const char* interfaceName) const char* interfaceName)
{ {
GEOM_Gen_i* myGEOM_Gen_i = new GEOM_Gen_i(orb, poa, contId, instanceName, interfaceName); GEOM_Gen_i* myGEOM_Gen_i = new GEOM_Gen_i(orb, poa, contId, instanceName, interfaceName);
return myGEOM_Gen_i->getId(); return myGEOM_Gen_i->getId();