22416: GEOM Regression: Names in STEP files are not imported anymore

This commit is contained in:
eap 2013-12-05 10:45:51 +00:00
parent 48b981c7a8
commit 57164ba740

View File

@ -240,10 +240,9 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
CORBA::String_var aGeomObjIOR = _orb->object_to_string(theObject); CORBA::String_var aGeomObjIOR = _orb->object_to_string(theObject);
aResultSO->SetAttrString("AttributeIOR",aGeomObjIOR); aResultSO->SetAttrString("AttributeIOR",aGeomObjIOR);
TCollection_AsciiString anObjectName("Shape_"); TCollection_AsciiString anObjectName, aNamePrefix("Shape_");
// BEGIN: try to find existed name for current shape // BEGIN: try to find existed name for current shape
bool HasName = false;
if ( !aShape->_is_nil() ) if ( !aShape->_is_nil() )
{ {
// recieve current TopoDS shape // recieve current TopoDS shape
@ -263,7 +262,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
// check all named shapes using iterator // check all named shapes using iterator
TDF_ChildIDIterator anIt (aMainLbl, TNaming_NamedShape::GetID(), Standard_True); TDF_ChildIDIterator anIt (aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
for (; anIt.More() && !HasName; anIt.Next()) { for (; anIt.More() && anObjectName.IsEmpty(); anIt.Next()) {
Handle(TNaming_NamedShape) anAttr = Handle(TNaming_NamedShape) anAttr =
Handle(TNaming_NamedShape)::DownCast(anIt.Value()); Handle(TNaming_NamedShape)::DownCast(anIt.Value());
if (anAttr.IsNull()) continue; if (anAttr.IsNull()) continue;
@ -271,10 +270,8 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
if (S.IsEqual(TopoSh)) { if (S.IsEqual(TopoSh)) {
TDF_Label L = anAttr->Label(); TDF_Label L = anAttr->Label();
Handle(TDataStd_Name) aName; Handle(TDataStd_Name) aName;
if (L.FindAttribute(TDataStd_Name::GetID(), aName)) { if (L.FindAttribute(TDataStd_Name::GetID(), aName))
anObjectName = aName->Get(); anObjectName = aName->Get();
HasName = true;
}
} }
} }
} }
@ -286,32 +283,32 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
switch ( (TopAbs_ShapeEnum)anOp->GetType( aShape )) { switch ( (TopAbs_ShapeEnum)anOp->GetType( aShape )) {
case TopAbs_VERTEX: case TopAbs_VERTEX:
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_PNT" ); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_PNT" );
anObjectName = "Group_Of_Vertices_"; aNamePrefix = "Group_Of_Vertices_";
break; break;
case TopAbs_EDGE: case TopAbs_EDGE:
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_EDGE"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_EDGE");
anObjectName = "Group_Of_Edges_"; aNamePrefix = "Group_Of_Edges_";
break; break;
case TopAbs_FACE: case TopAbs_FACE:
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_FACE"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_FACE");
anObjectName = "Group_Of_Faces_"; aNamePrefix = "Group_Of_Faces_";
break; break;
case TopAbs_SOLID: case TopAbs_SOLID:
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_SOLID"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_GROUP_SOLID");
anObjectName = "Group_Of_Solids_"; aNamePrefix = "Group_Of_Solids_";
break; break;
} }
} else if ( mytype == GEOM_MARKER ) { } else if ( mytype == GEOM_MARKER ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_LCS"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_LCS");
anObjectName = "LocalCS_"; aNamePrefix = "LocalCS_";
} else if ( mytype > ADVANCED_BASE ) { } else if ( mytype > ADVANCED_BASE ) {
char buf[20]; char buf[20];
sprintf( buf, "%d", aBaseObj->GetType() ); sprintf( buf, "%d", aBaseObj->GetType() );
std::string advId = "ICON_OBJBROWSER_ADVANCED_"; advId += buf; std::string advId = "ICON_OBJBROWSER_ADVANCED_"; advId += buf;
aResultSO->SetAttrString("AttributePixMap",advId.c_str()); aResultSO->SetAttrString("AttributePixMap",advId.c_str());
anObjectName = "Advanced_"; aNamePrefix = "Advanced_";
} else if ( mytype == GEOM_FIELD ) { } else if ( mytype == GEOM_FIELD ) {
anObjectName = "Field_"; aNamePrefix = "Field_";
GEOM::GEOM_Field_var aField = GEOM::GEOM_Field::_narrow(theObject); GEOM::GEOM_Field_var aField = GEOM::GEOM_Field::_narrow(theObject);
if ( !aField->_is_nil() ) if ( !aField->_is_nil() )
switch( aField->GetDimension() ) { switch( aField->GetDimension() ) {
@ -327,38 +324,38 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FIELD_SOLID"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FIELD_SOLID");
} }
} else if ( mytype == GEOM_FIELD_STEP ) { } else if ( mytype == GEOM_FIELD_STEP ) {
anObjectName = "Step_"; aNamePrefix = "Step_";
} else if ( !aShape->_is_nil() ) { } else if ( !aShape->_is_nil() ) {
GEOM::shape_type myshapetype=aShape->GetShapeType(); GEOM::shape_type myshapetype=aShape->GetShapeType();
if ( myshapetype == GEOM::COMPOUND ) { if ( myshapetype == GEOM::COMPOUND ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPOUND" ); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPOUND" );
anObjectName = "Compound_"; aNamePrefix = "Compound_";
} else if ( myshapetype == GEOM::COMPSOLID ) { } else if ( myshapetype == GEOM::COMPSOLID ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPSOLID"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_COMPSOLID");
anObjectName = "Compsolid_"; aNamePrefix = "Compsolid_";
} else if ( myshapetype == GEOM::SOLID ) { } else if ( myshapetype == GEOM::SOLID ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SOLID"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SOLID");
anObjectName = "Solid_"; aNamePrefix = "Solid_";
} else if ( myshapetype == GEOM::SHELL ) { } else if ( myshapetype == GEOM::SHELL ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SHELL"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_SHELL");
anObjectName = "Shell_"; aNamePrefix = "Shell_";
} else if ( myshapetype == GEOM::FACE ) { } else if ( myshapetype == GEOM::FACE ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FACE"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_FACE");
anObjectName = "Face_"; aNamePrefix = "Face_";
} else if ( myshapetype == GEOM::WIRE ) { } else if ( myshapetype == GEOM::WIRE ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_WIRE"); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_WIRE");
anObjectName = "Wire_"; aNamePrefix = "Wire_";
} else if ( myshapetype == GEOM::EDGE ) { } else if ( myshapetype == GEOM::EDGE ) {
aResultSO->SetAttrString("AttributePixMap", "ICON_OBJBROWSER_EDGE"); aResultSO->SetAttrString("AttributePixMap", "ICON_OBJBROWSER_EDGE");
anObjectName = "Edge_"; aNamePrefix = "Edge_";
} else if ( myshapetype == GEOM::VERTEX ) { } else if ( myshapetype == GEOM::VERTEX ) {
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_VERTEX" ); aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_VERTEX" );
anObjectName = "Vertex_"; aNamePrefix = "Vertex_";
} }
} }
if (!HasName) if ( anObjectName.IsEmpty() )
{ {
//if (strlen(theName) == 0) anObjectName += TCollection_AsciiString(aResultSO->Tag()); //if (strlen(theName) == 0) aNamePrefix += TCollection_AsciiString(aResultSO->Tag());
//else anObjectName = TCollection_AsciiString(CORBA::string_dup(theName)); //else anObjectName = TCollection_AsciiString(CORBA::string_dup(theName));
// asv : 11.11.04 Introducing a more sofisticated method of name creation, just as // asv : 11.11.04 Introducing a more sofisticated method of name creation, just as
@ -368,17 +365,16 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
if ( strlen( theName ) == 0 ) { // MOST PROBABLY CALLED FROM BATCHMODE OR SUPERVISOR if ( strlen( theName ) == 0 ) { // MOST PROBABLY CALLED FROM BATCHMODE OR SUPERVISOR
int i = 0; // (WITH EMPTY NEW NAME) int i = 0; // (WITH EMPTY NEW NAME)
SALOMEDS::SObject_var obj; SALOMEDS::SObject_var obj;
TCollection_AsciiString aNewObjectName;
do { do {
aNewObjectName = anObjectName + TCollection_AsciiString(++i); anObjectName = aNamePrefix + TCollection_AsciiString(++i);
obj = theStudy->FindObject( aNewObjectName.ToCString() ); obj = theStudy->FindObject( anObjectName.ToCString() );
} }
while ( !obj->_is_nil() ); while ( !obj->_is_nil() );
anObjectName = aNewObjectName;
} }
else // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME) else { // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME)
anObjectName = theName; anObjectName = theName;
} }
}
//Set the study entry as a name of the published GEOM_Object //Set the study entry as a name of the published GEOM_Object
CORBA::String_var anID = aResultSO->GetID(); CORBA::String_var anID = aResultSO->GetID();