mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-31 03:40:35 +05:00
Mantis issue 0020750: IMP: Naming during STEP import.
This commit is contained in:
parent
3a293c4748
commit
343553810e
@ -65,6 +65,7 @@
|
||||
#define DESCRIPTION_LABEL 3
|
||||
#define HISTORY_LABEL 4
|
||||
#define SUBSHAPES_LABEL 5 // 0020756: GetGroups
|
||||
#define NAMING_LABEL 6 // 002020750: Naming during STEP import
|
||||
|
||||
#define ARGUMENTS _label.FindChild((ARGUMENT_LABEL))
|
||||
#define ARGUMENT(thePosition) _label.FindChild((ARGUMENT_LABEL)).FindChild((thePosition))
|
||||
@ -793,6 +794,16 @@ TDF_Label GEOM_Function::GetArgumentHistoryEntry (const TDF_Label& theArgu
|
||||
return aHistoryCurLabel;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* GetNamingEntry
|
||||
*/
|
||||
//=============================================================================
|
||||
TDF_Label GEOM_Function::GetNamingEntry (const Standard_Boolean create)
|
||||
{
|
||||
return _label.FindChild(NAMING_LABEL, create);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GEOM_Function_Type_
|
||||
//purpose :
|
||||
|
@ -269,6 +269,9 @@ public:
|
||||
Standard_EXPORT TDF_Label GetArgumentHistoryEntry (const TDF_Label& theArgumentRefEntry,
|
||||
const Standard_Boolean create = Standard_True);
|
||||
|
||||
//Returns top label of this function's naming tree
|
||||
Standard_EXPORT TDF_Label GetNamingEntry (const Standard_Boolean create = Standard_True);
|
||||
|
||||
private:
|
||||
|
||||
TDF_Label _label;
|
||||
|
@ -18,7 +18,6 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#include <Standard_Stream.hxx>
|
||||
|
||||
@ -109,7 +108,7 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
|
||||
|
||||
// perform the import
|
||||
TCollection_AsciiString anError;
|
||||
TopoDS_Shape aShape = fp( aFileName, aFormatName, anError, aFunction->GetEntry() );
|
||||
TopoDS_Shape aShape = fp(aFileName, aFormatName, anError, aFunction->GetNamingEntry());
|
||||
|
||||
// unload plugin library
|
||||
// commented by enk:
|
||||
@ -159,7 +158,8 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_ImportDriver_Type_()
|
||||
//function : DownCast
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const Handle(GEOMImpl_ImportDriver) Handle(GEOMImpl_ImportDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
|
||||
const Handle(GEOMImpl_ImportDriver) Handle(GEOMImpl_ImportDriver)::DownCast
|
||||
(const Handle(Standard_Transient)& AnObject)
|
||||
{
|
||||
Handle(GEOMImpl_ImportDriver) _anOtherObject;
|
||||
|
||||
|
@ -265,7 +265,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
|
||||
//if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag());
|
||||
//else aShapeName = TCollection_AsciiString(CORBA::string_dup(theName));
|
||||
|
||||
// try to find existed name for current shape
|
||||
// BEGIN: try to find existed name for current shape
|
||||
bool HasName = false;
|
||||
// recieve current TopoDS shape
|
||||
CORBA::String_var entry = aShape->GetEntry();
|
||||
@ -278,15 +278,17 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
|
||||
}
|
||||
entry = aMainSh->GetEntry();
|
||||
Handle(GEOM_Object) anObj = _impl->GetObject(aMainSh->GetStudyID(), entry);
|
||||
TDF_Label aMainLbl = anObj->GetEntry();
|
||||
TDF_Label aMainLbl = anObj->GetFunction(1)->GetNamingEntry();
|
||||
|
||||
// check all named shapes using iterator
|
||||
TDF_ChildIDIterator anIt (aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
|
||||
for(; anIt.More(); anIt.Next()) {
|
||||
|
||||
for (; anIt.More() && !HasName; anIt.Next()) {
|
||||
Handle(TNaming_NamedShape) anAttr =
|
||||
Handle(TNaming_NamedShape)::DownCast(anIt.Value());
|
||||
if (anAttr.IsNull()) continue;
|
||||
TopoDS_Shape S = anAttr->Get();
|
||||
if( !S.IsEqual(TopoSh) ) continue;
|
||||
if (S.IsEqual(TopoSh)) {
|
||||
TDF_Label L = anAttr->Label();
|
||||
Handle(TDataStd_Name) aName;
|
||||
if (L.FindAttribute(TDataStd_Name::GetID(), aName)) {
|
||||
@ -294,6 +296,8 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
|
||||
HasName = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// END: try to find existed name for current shape
|
||||
|
||||
if (!HasName) {
|
||||
// asv : 11.11.04 Introducing a more sofisticated method of name creation, just as
|
||||
|
@ -22,7 +22,6 @@
|
||||
// File: IGESImport.cxx
|
||||
// Created: Wed May 19 14:36:35 2004
|
||||
// Author: Pavel TELKOV
|
||||
// <ptv@mutex.nnov.opencascade.com>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
@ -31,15 +30,26 @@
|
||||
#include <IFSelect_ReturnStatus.hxx>
|
||||
#include <IGESControl_Reader.hxx>
|
||||
#include <IGESData_IGESModel.hxx>
|
||||
#include <IGESData_IGESEntity.hxx>
|
||||
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
#include <XSControl_TransferReader.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#include <Transfer_TransientProcess.hxx>
|
||||
#include <Transfer_Binder.hxx>
|
||||
#include <TransferBRep.hxx>
|
||||
|
||||
#include <TNaming_Builder.hxx>
|
||||
#include <TDF_TagSource.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
|
||||
#ifdef WNT
|
||||
#if defined IGESIMPORT_EXPORTS || defined IGESImport_EXPORTS
|
||||
@ -71,7 +81,7 @@ IGESIMPORT_EXPORT
|
||||
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& theFormatName,
|
||||
TCollection_AsciiString& theError,
|
||||
const TDF_Label&)
|
||||
const TDF_Label& theShapeLabel)
|
||||
{
|
||||
// Set "C" numeric locale to save numbers correctly
|
||||
Kernel_Utils::Localizer loc;
|
||||
@ -128,6 +138,38 @@ IGESIMPORT_EXPORT
|
||||
MESSAGE("ImportIGES : count of shapes produced = " << aReader.NbShapes());
|
||||
aResShape = aReader.OneShape();
|
||||
|
||||
// BEGIN: Store names of sub-shapes from file
|
||||
Handle(Interface_InterfaceModel) Model = aReader.WS()->Model();
|
||||
Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader();
|
||||
if (!TR.IsNull()) {
|
||||
Handle(Transfer_TransientProcess) TP = /*TransientProcess();*/TR->TransientProcess();
|
||||
Standard_Integer nb = Model->NbEntities();
|
||||
for (Standard_Integer i = 1; i <= nb; i++) {
|
||||
Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(Model->Value(i));
|
||||
if (ent.IsNull() || ! ent->HasName()) continue;
|
||||
|
||||
// find target shape
|
||||
Handle(Transfer_Binder) binder = TP->Find(ent);
|
||||
if (binder.IsNull()) continue;
|
||||
TopoDS_Shape S = TransferBRep::ShapeResult(binder);
|
||||
if (S.IsNull()) continue;
|
||||
|
||||
// create label and set shape
|
||||
TDF_Label L;
|
||||
TDF_TagSource aTag;
|
||||
L = aTag.NewChild(theShapeLabel);
|
||||
TNaming_Builder tnBuild (L);
|
||||
tnBuild.Generated(S);
|
||||
|
||||
// set a name
|
||||
TCollection_AsciiString string = ent->NameValue()->String();
|
||||
string.LeftAdjust();
|
||||
string.RightAdjust();
|
||||
TCollection_ExtendedString str (string);
|
||||
TDataStd_Name::Set(L, str);
|
||||
}
|
||||
}
|
||||
// END: Store names
|
||||
} else {
|
||||
// switch (status) {
|
||||
// case IFSelect_RetVoid:
|
||||
|
@ -16,13 +16,12 @@
|
||||
#
|
||||
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
#
|
||||
|
||||
# File : Makefile.in
|
||||
# Author : Pavel TELKOV
|
||||
# Modified by : Alexander BORODIN (OCN) - autotools usage
|
||||
# Module : GEOM
|
||||
# $Header$
|
||||
#
|
||||
|
||||
include $(top_srcdir)/adm_local/unix/make_common_starter.am
|
||||
|
||||
# Libraries targets
|
||||
@ -39,5 +38,5 @@ libIGESImport_la_CPPFLAGS = \
|
||||
|
||||
libIGESImport_la_LDFLAGS = \
|
||||
$(STDLIB) \
|
||||
$(CAS_LDPATH) -lTKIGES \
|
||||
$(CAS_LDPATH) -lTKIGES -lTKCAF \
|
||||
$(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics
|
||||
|
@ -43,4 +43,4 @@ libSTEPImport_la_CPPFLAGS = \
|
||||
libSTEPImport_la_LDFLAGS = \
|
||||
$(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \
|
||||
$(STDLIB) \
|
||||
$(CAS_LDPATH) -lTKSTEP
|
||||
$(CAS_LDPATH) -lTKSTEP -lTKCAF
|
||||
|
@ -19,12 +19,10 @@
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: STEPImport.cxx
|
||||
// Created: Wed May 19 14:41:10 2004
|
||||
// Author: Pavel TELKOV
|
||||
// <ptv@mutex.nnov.opencascade.com>
|
||||
//
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include <Basics_Utils.hxx>
|
||||
@ -34,13 +32,31 @@
|
||||
#include <IFSelect_ReturnStatus.hxx>
|
||||
|
||||
#include <STEPControl_Reader.hxx>
|
||||
#include <StepBasic_ProductDefinition.hxx>
|
||||
#include <StepBasic_ProductDefinitionFormation.hxx>
|
||||
#include <StepBasic_Product.hxx>
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
#include <XSControl_TransferReader.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
|
||||
#include <Transfer_Binder.hxx>
|
||||
#include <TNaming_Builder.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <Transfer_TransientProcess.hxx>
|
||||
#include <TransferBRep.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
||||
|
||||
@ -74,7 +90,7 @@ STEPIMPORT_EXPORT
|
||||
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
||||
const TCollection_AsciiString& /*theFormatName*/,
|
||||
TCollection_AsciiString& theError,
|
||||
const TDF_Label&)
|
||||
const TDF_Label& theShapeLabel)
|
||||
{
|
||||
MESSAGE("Import STEP model from file " << theFileName.ToCString());
|
||||
// Set "C" numeric locale to save numbers correctly
|
||||
@ -131,7 +147,61 @@ STEPIMPORT_EXPORT
|
||||
if (aResShape.IsNull())
|
||||
aResShape = compound;
|
||||
|
||||
} else {
|
||||
// BEGIN: Store names of sub-shapes from file
|
||||
TopTools_IndexedMapOfShape anIndices;
|
||||
TopExp::MapShapes(aResShape, anIndices);
|
||||
|
||||
Handle(Interface_InterfaceModel) Model = aReader.WS()->Model();
|
||||
Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader();
|
||||
if (!TR.IsNull()) {
|
||||
Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
|
||||
Handle(Standard_Type) tPD = STANDARD_TYPE(StepBasic_ProductDefinition);
|
||||
|
||||
Standard_Integer nb = Model->NbEntities();
|
||||
for (Standard_Integer ie = 1; ie <= nb; ie++) {
|
||||
Handle(Standard_Transient) enti = Model->Value(ie);
|
||||
if (enti->DynamicType() != tPD) continue;
|
||||
|
||||
Handle(StepBasic_ProductDefinition) PD =
|
||||
Handle(StepBasic_ProductDefinition)::DownCast(enti);
|
||||
if (PD.IsNull()) continue;
|
||||
|
||||
Handle(StepBasic_Product) Prod = PD->Formation()->OfProduct();
|
||||
if (Prod->Name()->UsefullLength() <= 0) continue;
|
||||
|
||||
Handle(TCollection_HAsciiString) aName = Prod->Name();
|
||||
TCollection_ExtendedString aNameExt (aName->ToCString());
|
||||
|
||||
// find target shape
|
||||
Handle(Transfer_Binder) binder = TP->Find(enti);
|
||||
if (binder.IsNull()) continue;
|
||||
TopoDS_Shape S = TransferBRep::ShapeResult(binder);
|
||||
if (S.IsNull()) continue;
|
||||
|
||||
// as PRODUCT can be included in the main shape
|
||||
// several times, we look here for all iclusions.
|
||||
Standard_Integer isub, nbSubs = anIndices.Extent();
|
||||
for (isub = 1; isub <= nbSubs; isub++)
|
||||
{
|
||||
TopoDS_Shape aSub = anIndices.FindKey(isub);
|
||||
if (aSub.IsPartner(S)) {
|
||||
// create label and set shape
|
||||
TDF_Label L;
|
||||
TDF_TagSource aTag;
|
||||
L = aTag.NewChild(theShapeLabel);
|
||||
TNaming_Builder tnBuild (L);
|
||||
//tnBuild.Generated(S);
|
||||
tnBuild.Generated(aSub);
|
||||
|
||||
// set a name
|
||||
TDataStd_Name::Set(L, aNameExt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// END: Store names
|
||||
}
|
||||
else {
|
||||
// switch (status) {
|
||||
// case IFSelect_RetVoid:
|
||||
// theError = "Nothing created or No data to process";
|
||||
|
Loading…
Reference in New Issue
Block a user