mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-31 18:30:33 +05:00
For improvements 20019 and 20324.
This commit is contained in:
parent
de4038d0a0
commit
615e23820b
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TDF_Label.hxx>
|
||||||
|
|
||||||
#ifdef WNT
|
#ifdef WNT
|
||||||
#if defined BREPIMPORT_EXPORTS || defined BREPImport_EXPORTS
|
#if defined BREPIMPORT_EXPORTS || defined BREPImport_EXPORTS
|
||||||
@ -61,7 +62,8 @@ extern "C"
|
|||||||
BREPIMPORT_EXPORT
|
BREPIMPORT_EXPORT
|
||||||
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
||||||
const TCollection_AsciiString& /*theFormatName*/,
|
const TCollection_AsciiString& /*theFormatName*/,
|
||||||
TCollection_AsciiString& theError)
|
TCollection_AsciiString& theError,
|
||||||
|
const TDF_Label&)
|
||||||
{
|
{
|
||||||
MESSAGE("Import BREP from file " << theFileName);
|
MESSAGE("Import BREP from file " << theFileName);
|
||||||
TopoDS_Shape aShape;
|
TopoDS_Shape aShape;
|
||||||
|
@ -44,6 +44,11 @@
|
|||||||
|
|
||||||
#include <GEOMImpl_Types.hxx>
|
#include <GEOMImpl_Types.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
#include <Standard_Failure.hxx>
|
#include <Standard_Failure.hxx>
|
||||||
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
||||||
|
|
||||||
@ -206,7 +211,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
|
|||||||
if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result;
|
if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result;
|
||||||
|
|
||||||
Handle(TCollection_HAsciiString) aHLibName;
|
Handle(TCollection_HAsciiString) aHLibName;
|
||||||
if (!IsSupported(Standard_True, theFormatName, aHLibName)) {
|
if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
TCollection_AsciiString aLibName = aHLibName->String();
|
TCollection_AsciiString aLibName = aHLibName->String();
|
||||||
@ -216,6 +221,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
|
|||||||
aCI.SetFileName(theFileName);
|
aCI.SetFileName(theFileName);
|
||||||
aCI.SetFormatName(theFormatName);
|
aCI.SetFormatName(theFormatName);
|
||||||
aCI.SetPluginName(aLibName);
|
aCI.SetPluginName(aLibName);
|
||||||
|
//cout<<"IIO: theFormatName = "<<theFormatName.ToCString()<<endl;
|
||||||
|
|
||||||
//Perform the Import
|
//Perform the Import
|
||||||
try {
|
try {
|
||||||
@ -238,6 +244,21 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
|
|||||||
<< theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
|
<< theFileName.ToCString() << "\", \"" << theFormatName.ToCString() << "\")";
|
||||||
|
|
||||||
SetErrorCode(OK);
|
SetErrorCode(OK);
|
||||||
|
|
||||||
|
if( theFormatName == "IGES_UNIT" ) {
|
||||||
|
TopoDS_Shape S = aFunction->GetValue();
|
||||||
|
TopoDS_Vertex V = TopoDS::Vertex(S);
|
||||||
|
gp_Pnt P = BRep_Tool::Pnt(V);
|
||||||
|
double scale = P.X();
|
||||||
|
TCollection_AsciiString aUnitName = "UNIT_M";
|
||||||
|
if( fabs(scale-0.01) < 1.e-6 )
|
||||||
|
aUnitName = "UNIT_CM";
|
||||||
|
else if( fabs(scale-0.001) < 1.e-6 )
|
||||||
|
aUnitName = "UNIT_MM";
|
||||||
|
//cout<<"IIO: aUnitName = "<<aUnitName.ToCString()<<endl;
|
||||||
|
SetErrorCode(aUnitName);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +432,6 @@ Standard_Boolean GEOMImpl_IInsertOperations::IsSupported
|
|||||||
if (isImport) aMode = "Import";
|
if (isImport) aMode = "Import";
|
||||||
else aMode = "Export";
|
else aMode = "Export";
|
||||||
|
|
||||||
|
|
||||||
// Read supported formats for the certain mode from install directory
|
// Read supported formats for the certain mode from install directory
|
||||||
if (myResMgr->Find(aMode.ToCString())) {
|
if (myResMgr->Find(aMode.ToCString())) {
|
||||||
TCollection_AsciiString aFormats (myResMgr->Value(aMode.ToCString()));
|
TCollection_AsciiString aFormats (myResMgr->Value(aMode.ToCString()));
|
||||||
|
@ -53,7 +53,8 @@
|
|||||||
|
|
||||||
typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&,
|
typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&,
|
||||||
const TCollection_AsciiString&,
|
const TCollection_AsciiString&,
|
||||||
TCollection_AsciiString&);
|
TCollection_AsciiString&,
|
||||||
|
const TDF_Label&);
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetID
|
//function : GetID
|
||||||
@ -100,14 +101,14 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
|
|||||||
fp = (funcPoint)GetProc( anImportLib, "Import" );
|
fp = (funcPoint)GetProc( anImportLib, "Import" );
|
||||||
|
|
||||||
if ( !fp ) {
|
if ( !fp ) {
|
||||||
TCollection_AsciiString aMsg = aFormatName;
|
TCollection_AsciiString aMsg = aFormatName.SubString(1,4);
|
||||||
aMsg += " plugin was not installed";
|
aMsg += " plugin was not installed";
|
||||||
Standard_Failure::Raise(aMsg.ToCString());
|
Standard_Failure::Raise(aMsg.ToCString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// perform the import
|
// perform the import
|
||||||
TCollection_AsciiString anError;
|
TCollection_AsciiString anError;
|
||||||
TopoDS_Shape aShape = fp( aFileName, aFormatName, anError );
|
TopoDS_Shape aShape = fp( aFileName, aFormatName, anError, aFunction->GetEntry() );
|
||||||
|
|
||||||
// unload plugin library
|
// unload plugin library
|
||||||
// commented by enk:
|
// commented by enk:
|
||||||
|
@ -694,6 +694,7 @@ bool GEOMToolsGUI::Import()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GEOM_Operation* anOp = new GEOM_Operation( app, aInsOp.in() );
|
GEOM_Operation* anOp = new GEOM_Operation( app, aInsOp.in() );
|
||||||
try {
|
try {
|
||||||
app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, /*withExten=*/true ) ) );
|
app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, /*withExten=*/true ) ) );
|
||||||
@ -701,6 +702,26 @@ bool GEOMToolsGUI::Import()
|
|||||||
|
|
||||||
CORBA::String_var fileN = fileName.toLatin1().constData();
|
CORBA::String_var fileN = fileName.toLatin1().constData();
|
||||||
CORBA::String_var fileT = aCurrentType.toLatin1().constData();
|
CORBA::String_var fileT = aCurrentType.toLatin1().constData();
|
||||||
|
|
||||||
|
// skl 29.05.2009
|
||||||
|
if( aCurrentType == "IGES" ) {
|
||||||
|
GEOM::GEOM_Object_var anObj = aInsOp->Import( fileN, "IGES_UNIT" );
|
||||||
|
TCollection_AsciiString aUnitName = aInsOp->GetErrorCode();
|
||||||
|
//cout<<"GUI: aUnitName = "<<aUnitName.ToCString()<<endl;
|
||||||
|
if( aUnitName.SubString(1,4) == "UNIT" ) {
|
||||||
|
aUnitName = aUnitName.SubString(6,aUnitName.Length());
|
||||||
|
if( aUnitName != "M" ) {
|
||||||
|
if( SUIT_MessageBox::question( app->desktop(),
|
||||||
|
"Question",//tr("WRN_WARNING"),
|
||||||
|
"Length unit in given file is not a 'meter'. Is it needed to scale a model?",
|
||||||
|
SUIT_MessageBox::Yes | SUIT_MessageBox::No,
|
||||||
|
SUIT_MessageBox::No) == SUIT_MessageBox::Yes ) {
|
||||||
|
fileT = "IGES_SCALE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GEOM::GEOM_Object_var anObj = aInsOp->Import( fileN, fileT );
|
GEOM::GEOM_Object_var anObj = aInsOp->Import( fileN, fileT );
|
||||||
|
|
||||||
if ( !anObj->_is_nil() && aInsOp->IsDone() ) {
|
if ( !anObj->_is_nil() && aInsOp->IsDone() ) {
|
||||||
@ -715,6 +736,16 @@ bool GEOMToolsGUI::Import()
|
|||||||
|
|
||||||
objsForDisplay.append( anObj );
|
objsForDisplay.append( anObj );
|
||||||
|
|
||||||
|
if( aCurrentType == "ACIS" ) {
|
||||||
|
if( SUIT_MessageBox::question( app->desktop(),
|
||||||
|
"Question",//tr("WRN_WARNING"),
|
||||||
|
"Given file contents some names. Is it needed to create groups for named shapes?",
|
||||||
|
SUIT_MessageBox::Yes | SUIT_MessageBox::No,
|
||||||
|
SUIT_MessageBox::No) == SUIT_MessageBox::Yes ) {
|
||||||
|
GeometryGUI::GetGeomGen()->PublishNamedShapesInStudy(aDSStudy, anObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
anOp->commit();
|
anOp->commit();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "GEOM_Object_i.hh"
|
#include "GEOM_Object_i.hh"
|
||||||
#include "GEOM_Object.hxx"
|
#include "GEOM_Object.hxx"
|
||||||
#include "GEOM_Function.hxx"
|
#include "GEOM_Function.hxx"
|
||||||
|
#include "GEOM_ISubShape.hxx"
|
||||||
#include "GEOMImpl_Types.hxx"
|
#include "GEOMImpl_Types.hxx"
|
||||||
#include "GEOMImpl_CopyDriver.hxx"
|
#include "GEOMImpl_CopyDriver.hxx"
|
||||||
|
|
||||||
@ -47,9 +48,14 @@
|
|||||||
#include <BRepTools.hxx>
|
#include <BRepTools.hxx>
|
||||||
#include <TDF_Label.hxx>
|
#include <TDF_Label.hxx>
|
||||||
#include <TDF_Tool.hxx>
|
#include <TDF_Tool.hxx>
|
||||||
|
#include <TDF_ChildIDIterator.hxx>
|
||||||
|
#include <TNaming_NamedShape.hxx>
|
||||||
|
#include <TDataStd_Name.hxx>
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <TColStd_HArray1OfInteger.hxx>
|
#include <TColStd_HArray1OfInteger.hxx>
|
||||||
#include <TopAbs_ShapeEnum.hxx>
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
|
//#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
#include <OSD.hxx>
|
#include <OSD.hxx>
|
||||||
|
|
||||||
#include "SALOMEDS_Tool.hxx"
|
#include "SALOMEDS_Tool.hxx"
|
||||||
@ -249,6 +255,38 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
|
|||||||
//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
|
||||||
|
bool HasName = false;
|
||||||
|
// recieve current TopoDS shape
|
||||||
|
CORBA::String_var entry = aShape->GetEntry();
|
||||||
|
Handle(GEOM_Object) aGShape = _impl->GetObject(aShape->GetStudyID(), entry);
|
||||||
|
TopoDS_Shape TopoSh = aGShape->GetValue();
|
||||||
|
// find label of main shape
|
||||||
|
GEOM::GEOM_Object_var aMainShVar = aShape;
|
||||||
|
GEOM::GEOM_Object_ptr aMainSh = aMainShVar._retn();
|
||||||
|
while( !aMainSh->IsMainShape() ) {
|
||||||
|
aMainSh = aMainSh->GetMainShape();
|
||||||
|
}
|
||||||
|
entry = aMainSh->GetEntry();
|
||||||
|
Handle(GEOM_Object) anObj = _impl->GetObject(aMainSh->GetStudyID(), entry);
|
||||||
|
TDF_Label aMainLbl = anObj->GetEntry();
|
||||||
|
// check all named shapes using iterator
|
||||||
|
TDF_ChildIDIterator anIt(aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
|
||||||
|
for(; anIt.More(); 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;
|
||||||
|
TDF_Label L = anAttr->Label();
|
||||||
|
Handle(TDataStd_Name) aName;
|
||||||
|
if(L.FindAttribute(TDataStd_Name::GetID(),aName)) {
|
||||||
|
aShapeName = aName->Get();
|
||||||
|
HasName = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!HasName) {
|
||||||
// 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
|
||||||
// it is done in GUI in GEOMBase::GetDefaultName() - not just add a Tag() == number
|
// it is done in GUI in GEOMBase::GetDefaultName() - not just add a Tag() == number
|
||||||
// of objects in the study, but compute a number of objects with the same prefix
|
// of objects in the study, but compute a number of objects with the same prefix
|
||||||
@ -266,6 +304,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
|
|||||||
}
|
}
|
||||||
else // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME)
|
else // MOST PROBABLY CALLED FROM GEOM GUI (ALREADY WITH VALID NAME)
|
||||||
aShapeName = TCollection_AsciiString((char*)theName);
|
aShapeName = TCollection_AsciiString((char*)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
|
||||||
aShape->SetStudyEntry(aResultSO->GetID());
|
aShape->SetStudyEntry(aResultSO->GetID());
|
||||||
@ -300,6 +339,126 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// function : CreateAndPublishGroup
|
||||||
|
// purpose : auxilary for PublishNamedShapesInStudy
|
||||||
|
//============================================================================
|
||||||
|
void GEOM_Gen_i::CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
|
||||||
|
GEOM::GEOM_Object_var theMainShape,
|
||||||
|
const TopTools_IndexedMapOfShape& anIndices,
|
||||||
|
const TopTools_SequenceOfShape& SeqS,
|
||||||
|
const TColStd_SequenceOfAsciiString& SeqN,
|
||||||
|
const Standard_CString& GrName,
|
||||||
|
GEOM::ListOfGO_var aResList)
|
||||||
|
{
|
||||||
|
CORBA::String_var entry = theMainShape->GetEntry();
|
||||||
|
Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
|
||||||
|
Handle(TColStd_HArray1OfInteger) anArray;
|
||||||
|
if(SeqS.Length()>0) {
|
||||||
|
// create a group
|
||||||
|
GEOM::GEOM_IGroupOperations_var GOp = GetIGroupOperations(theStudy->StudyId());
|
||||||
|
GEOM::GEOM_Object_ptr GrObj =
|
||||||
|
GOp->CreateGroup( theMainShape, SeqS.Value(1).ShapeType() );
|
||||||
|
AddInStudy(theStudy, GrObj, GrName, theMainShape._retn());
|
||||||
|
// add named objects
|
||||||
|
Handle(GEOM_Object) anObj;
|
||||||
|
for(int i=1; i<=SeqS.Length(); i++) {
|
||||||
|
TopoDS_Shape aValue = SeqS.Value(i);
|
||||||
|
anArray = new TColStd_HArray1OfInteger(1,1);
|
||||||
|
Standard_Integer anIndex = anIndices.FindIndex(aValue);
|
||||||
|
anArray->SetValue(1, anIndex);
|
||||||
|
anObj = GEOM_Engine::GetEngine()->AddObject(aMainShape->GetDocID(), GEOM_SUBSHAPE);
|
||||||
|
if (anObj.IsNull()) continue;
|
||||||
|
Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
|
||||||
|
if (aFunction.IsNull()) continue;
|
||||||
|
GEOM_ISubShape aSSI(aFunction);
|
||||||
|
aSSI.SetMainShape(aMainShape->GetLastFunction());
|
||||||
|
aSSI.SetIndices(anArray);
|
||||||
|
aFunction->SetValue(aValue);
|
||||||
|
GOp->UnionIDs(GrObj, anIndex);
|
||||||
|
SALOMEDS::SObject_var aResultSO;
|
||||||
|
TCollection_AsciiString anEntry;
|
||||||
|
TDF_Tool::Entry(anObj->GetEntry(),anEntry);
|
||||||
|
GEOM::GEOM_Object_var aGObj = GetObject(anObj->GetDocID(), anEntry.ToCString());
|
||||||
|
AddInStudy(theStudy, aGObj._retn(), SeqN.Value(i).ToCString(), GrObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// function : PublishNamedShapesInStudy
|
||||||
|
// purpose :
|
||||||
|
//============================================================================
|
||||||
|
GEOM::ListOfGO* GEOM_Gen_i::
|
||||||
|
PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
|
||||||
|
//SALOMEDS::SObject_ptr theSObject,
|
||||||
|
CORBA::Object_ptr theObject)
|
||||||
|
{
|
||||||
|
//Unexpect aCatch(SALOME_SalomeException);
|
||||||
|
GEOM::ListOfGO_var aResList = new GEOM::ListOfGO;
|
||||||
|
|
||||||
|
//CORBA::Object_var theObject = theSObject->GetObject();
|
||||||
|
GEOM::GEOM_Object_var theMainShape = GEOM::GEOM_Object::_narrow(theObject);
|
||||||
|
if(theMainShape->_is_nil()) return aResList._retn();
|
||||||
|
|
||||||
|
CORBA::String_var entry = theMainShape->GetEntry();
|
||||||
|
Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
|
||||||
|
if (aMainShape.IsNull()) return aResList._retn();
|
||||||
|
TopoDS_Shape MainSh = aMainShape->GetValue();
|
||||||
|
|
||||||
|
TDF_Label aMainLbl = aMainShape->GetEntry();
|
||||||
|
TopTools_SequenceOfShape SolidSeqS, FaceSeqS, EdgeSeqS, VertSeqS;
|
||||||
|
TColStd_SequenceOfAsciiString SolidSeqN, FaceSeqN, EdgeSeqN, VertSeqN;
|
||||||
|
TDF_ChildIDIterator anIt(aMainLbl, TNaming_NamedShape::GetID(), Standard_True);
|
||||||
|
for(; anIt.More(); anIt.Next()) {
|
||||||
|
Handle(TNaming_NamedShape) anAttr =
|
||||||
|
Handle(TNaming_NamedShape)::DownCast(anIt.Value());
|
||||||
|
if(anAttr.IsNull()) continue;
|
||||||
|
TopoDS_Shape S = anAttr->Get();
|
||||||
|
TDF_Label L = anAttr->Label();
|
||||||
|
//if(S.IsEqual(MainSh)) continue;
|
||||||
|
Handle(TDataStd_Name) aName;
|
||||||
|
if(L.FindAttribute(TDataStd_Name::GetID(),aName)) {
|
||||||
|
TCollection_ExtendedString EName = aName->Get();
|
||||||
|
if(S.ShapeType()==TopAbs_SOLID) {
|
||||||
|
SolidSeqS.Append(S);
|
||||||
|
SolidSeqN.Append(aName->Get());
|
||||||
|
}
|
||||||
|
else if(S.ShapeType()==TopAbs_FACE) {
|
||||||
|
FaceSeqS.Append(S);
|
||||||
|
FaceSeqN.Append(aName->Get());
|
||||||
|
}
|
||||||
|
else if(S.ShapeType()==TopAbs_EDGE) {
|
||||||
|
EdgeSeqS.Append(S);
|
||||||
|
EdgeSeqN.Append(aName->Get());
|
||||||
|
}
|
||||||
|
else if(S.ShapeType()==TopAbs_VERTEX) {
|
||||||
|
VertSeqS.Append(S);
|
||||||
|
VertSeqN.Append(aName->Get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TopTools_IndexedMapOfShape anIndices;
|
||||||
|
TopExp::MapShapes(MainSh, anIndices);
|
||||||
|
|
||||||
|
CreateAndPublishGroup(theStudy, theMainShape, anIndices, SolidSeqS, SolidSeqN,
|
||||||
|
"Group_Of_Named_Solids", aResList);
|
||||||
|
|
||||||
|
CreateAndPublishGroup(theStudy, theMainShape, anIndices, FaceSeqS, FaceSeqN,
|
||||||
|
"Group_Of_Named_Faces", aResList);
|
||||||
|
|
||||||
|
CreateAndPublishGroup(theStudy, theMainShape, anIndices, EdgeSeqS, EdgeSeqN,
|
||||||
|
"Group_Of_Named_Edges", aResList);
|
||||||
|
|
||||||
|
CreateAndPublishGroup(theStudy, theMainShape, anIndices, VertSeqS, VertSeqN,
|
||||||
|
"Group_Of_Named_Vertices", aResList);
|
||||||
|
|
||||||
|
return aResList._retn();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
// function : Save()
|
// function : Save()
|
||||||
// purpose : save OCAF/Geom document
|
// purpose : save OCAF/Geom document
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
#include "GEOM_IMeasureOperations_i.hh"
|
#include "GEOM_IMeasureOperations_i.hh"
|
||||||
#include "GEOM_IGroupOperations_i.hh"
|
#include "GEOM_IGroupOperations_i.hh"
|
||||||
|
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
|
||||||
//#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
//#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
||||||
|
|
||||||
|
|
||||||
@ -120,6 +122,9 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
|
|||||||
CORBA::Object_ptr theObject,
|
CORBA::Object_ptr theObject,
|
||||||
const char* theName) throw (SALOME::SALOME_Exception) ;
|
const char* theName) throw (SALOME::SALOME_Exception) ;
|
||||||
|
|
||||||
|
GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
|
||||||
|
CORBA::Object_ptr theObject);
|
||||||
|
|
||||||
CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
|
CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
|
||||||
SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
|
SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
|
||||||
CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
|
CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
|
||||||
@ -257,6 +262,15 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi
|
|||||||
GEOM::find_shape_method theFindMethod,
|
GEOM::find_shape_method theFindMethod,
|
||||||
CORBA::Boolean theInheritFirstArg);
|
CORBA::Boolean theInheritFirstArg);
|
||||||
|
|
||||||
|
// auxilary for PublishNamedShapesInStudy
|
||||||
|
void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
|
||||||
|
GEOM::GEOM_Object_var theMainShape,
|
||||||
|
const TopTools_IndexedMapOfShape& anIndices,
|
||||||
|
const TopTools_SequenceOfShape& SeqS,
|
||||||
|
const TColStd_SequenceOfAsciiString& SeqN,
|
||||||
|
const Standard_CString& GrName,
|
||||||
|
GEOM::ListOfGO_var aResList);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
::GEOMImpl_Gen* _impl;
|
::GEOMImpl_Gen* _impl;
|
||||||
|
@ -129,11 +129,19 @@ GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::Import
|
|||||||
char* aFileName = strdup(theFileName);
|
char* aFileName = strdup(theFileName);
|
||||||
char* aFormatName = strdup(theFormatName);
|
char* aFormatName = strdup(theFormatName);
|
||||||
Handle(GEOM_Object) anObject = GetOperations()->Import(aFileName, aFormatName);
|
Handle(GEOM_Object) anObject = GetOperations()->Import(aFileName, aFormatName);
|
||||||
|
|
||||||
|
if( strcmp(aFormatName,"IGES_UNIT")==0 && !anObject.IsNull() ) {
|
||||||
|
free(aFileName);
|
||||||
|
free(aFormatName);
|
||||||
|
return GetObject(anObject);
|
||||||
|
}
|
||||||
|
|
||||||
free(aFileName);
|
free(aFileName);
|
||||||
free(aFormatName);
|
free(aFormatName);
|
||||||
|
|
||||||
if (!GetOperations()->IsDone() || anObject.IsNull())
|
if (!GetOperations()->IsDone() || anObject.IsNull()) {
|
||||||
return aGEOMObject._retn();
|
return aGEOMObject._retn();
|
||||||
|
}
|
||||||
|
|
||||||
return GetObject(anObject);
|
return GetObject(anObject);
|
||||||
}
|
}
|
||||||
|
@ -473,6 +473,20 @@ SALOMEDS::SObject_ptr GEOM_Superv_i::PublishInStudy(SALOMEDS::Study_ptr theStudy
|
|||||||
return myGeomEngine->PublishInStudy(theStudy, theSObject, theObject, theName);
|
return myGeomEngine->PublishInStudy(theStudy, theSObject, theObject, theName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// function : PublishNamedShapesInStudy
|
||||||
|
// purpose :
|
||||||
|
//============================================================================
|
||||||
|
GEOM::ListOfGO*
|
||||||
|
GEOM_Superv_i::PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
|
||||||
|
//SALOMEDS::SObject_ptr theSObject,
|
||||||
|
CORBA::Object_ptr theObject)
|
||||||
|
{
|
||||||
|
if (CORBA::is_nil(myGeomEngine))
|
||||||
|
setGeomEngine();
|
||||||
|
return myGeomEngine->PublishNamedShapesInStudy(theStudy, theObject);
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
// function : CanCopy()
|
// function : CanCopy()
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@ -125,6 +125,10 @@ public:
|
|||||||
CORBA::Object_ptr theObject,
|
CORBA::Object_ptr theObject,
|
||||||
const char* theName) throw (SALOME::SALOME_Exception) ;
|
const char* theName) throw (SALOME::SALOME_Exception) ;
|
||||||
|
|
||||||
|
GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
|
||||||
|
//SALOMEDS::SObject_ptr theSObject,
|
||||||
|
CORBA::Object_ptr theObject);
|
||||||
|
|
||||||
CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
|
CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
|
||||||
SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
|
SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
|
||||||
CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
|
CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
|
||||||
|
@ -3204,6 +3204,8 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
# @param theFileName The file, containing the shape.
|
# @param theFileName The file, containing the shape.
|
||||||
# @param theFormatName Specify format for the file reading.
|
# @param theFormatName Specify format for the file reading.
|
||||||
# Available formats can be obtained with InsertOp.ImportTranslators() method.
|
# Available formats can be obtained with InsertOp.ImportTranslators() method.
|
||||||
|
# If format 'IGES_SCALE' is used instead 'IGES' length unit will be
|
||||||
|
# set to 'meter' and result model will be scaled.
|
||||||
# @return New GEOM_Object, containing the imported shape.
|
# @return New GEOM_Object, containing the imported shape.
|
||||||
#
|
#
|
||||||
# @ref swig_Import_Export "Example"
|
# @ref swig_Import_Export "Example"
|
||||||
@ -3227,6 +3229,24 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
# Example: see GEOM_TestOthers.py
|
# Example: see GEOM_TestOthers.py
|
||||||
return self.Import(theFileName, "IGES")
|
return self.Import(theFileName, "IGES")
|
||||||
|
|
||||||
|
## Return length unit from given IGES file
|
||||||
|
#
|
||||||
|
# @ref swig_Import_Export "Example"
|
||||||
|
def GetIGESUnit(self,theFileName):
|
||||||
|
# Example: see GEOM_TestOthers.py
|
||||||
|
anObj = self.InsertOp.Import(theFileName, "IGES_UNIT")
|
||||||
|
#RaiseIfFailed("Import", self.InsertOp)
|
||||||
|
# recieve name using returned vertex
|
||||||
|
UnitName = "M"
|
||||||
|
vertices = self.SubShapeAll(anObj,ShapeType["VERTEX"])
|
||||||
|
if len(vertices)>0:
|
||||||
|
p = self.PointCoordinates(vertices[0])
|
||||||
|
if abs(p[0]-0.01) < 1.e-6:
|
||||||
|
UnitName = "CM"
|
||||||
|
elif abs(p[0]-0.001) < 1.e-6:
|
||||||
|
UnitName = "MM"
|
||||||
|
return UnitName
|
||||||
|
|
||||||
## Shortcut to Import() for STEP format
|
## Shortcut to Import() for STEP format
|
||||||
#
|
#
|
||||||
# @ref swig_Import_Export "Example"
|
# @ref swig_Import_Export "Example"
|
||||||
|
@ -28,9 +28,15 @@
|
|||||||
|
|
||||||
#include <IFSelect_ReturnStatus.hxx>
|
#include <IFSelect_ReturnStatus.hxx>
|
||||||
#include <IGESControl_Reader.hxx>
|
#include <IGESControl_Reader.hxx>
|
||||||
|
#include <IGESData_IGESModel.hxx>
|
||||||
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_HAsciiString.hxx>
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TDF_Label.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <gp_Pnt.hxx>
|
||||||
|
|
||||||
#ifdef WNT
|
#ifdef WNT
|
||||||
#if defined IGESIMPORT_EXPORTS || defined IGESImport_EXPORTS
|
#if defined IGESIMPORT_EXPORTS || defined IGESImport_EXPORTS
|
||||||
@ -60,8 +66,9 @@ extern "C"
|
|||||||
{
|
{
|
||||||
IGESIMPORT_EXPORT
|
IGESIMPORT_EXPORT
|
||||||
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
||||||
const TCollection_AsciiString& /*theFormatName*/,
|
const TCollection_AsciiString& theFormatName,
|
||||||
TCollection_AsciiString& theError)
|
TCollection_AsciiString& theError,
|
||||||
|
const TDF_Label&)
|
||||||
{
|
{
|
||||||
IGESControl_Reader aReader;
|
IGESControl_Reader aReader;
|
||||||
TopoDS_Shape aResShape;
|
TopoDS_Shape aResShape;
|
||||||
@ -69,6 +76,41 @@ IGESIMPORT_EXPORT
|
|||||||
IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
|
IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
|
||||||
|
|
||||||
if (status == IFSelect_RetDone) {
|
if (status == IFSelect_RetDone) {
|
||||||
|
|
||||||
|
if( theFormatName == "IGES_UNIT" ) {
|
||||||
|
Handle(IGESData_IGESModel) aModel =
|
||||||
|
Handle(IGESData_IGESModel)::DownCast(aReader.Model());
|
||||||
|
gp_Pnt P(1.0,0.0,0.0);
|
||||||
|
if(!aModel.IsNull()) {
|
||||||
|
Handle(TCollection_HAsciiString) aUnitName =
|
||||||
|
aModel->GlobalSection().UnitName();
|
||||||
|
//cout<<"aUnitName = "<<aUnitName->ToCString()<<endl;
|
||||||
|
//cout<<"aUnitFlag = "<<aModel->GlobalSection().UnitFlag()<<endl;
|
||||||
|
if( aUnitName->String()=="MM" ) {
|
||||||
|
P = gp_Pnt(0.001,0.0,0.0);
|
||||||
|
}
|
||||||
|
else if( aUnitName->String()=="CM" ) {
|
||||||
|
P = gp_Pnt(0.01,0.0,0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BRep_Builder B;
|
||||||
|
TopoDS_Vertex V;
|
||||||
|
B.MakeVertex(V,P,1.e-7);
|
||||||
|
aResShape = V;
|
||||||
|
return aResShape;
|
||||||
|
}
|
||||||
|
if( theFormatName == "IGES_SCALE" ) {
|
||||||
|
//cout<<"need re-scale a model"<<endl;
|
||||||
|
// set UnitFlag to 'meter'
|
||||||
|
Handle(IGESData_IGESModel) aModel =
|
||||||
|
Handle(IGESData_IGESModel)::DownCast(aReader.Model());
|
||||||
|
if(!aModel.IsNull()) {
|
||||||
|
IGESData_GlobalSection aGS = aModel->GlobalSection();
|
||||||
|
aGS.SetUnitFlag(6);
|
||||||
|
aModel->SetGlobalSection(aGS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MESSAGE("ImportIGES : all Geometry Transfer");
|
MESSAGE("ImportIGES : all Geometry Transfer");
|
||||||
//OCC 5.1.2 porting
|
//OCC 5.1.2 porting
|
||||||
// aReader.Clear();
|
// aReader.Clear();
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <TopoDS_Compound.hxx>
|
#include <TopoDS_Compound.hxx>
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TDF_Label.hxx>
|
||||||
|
|
||||||
#include <Standard_Failure.hxx>
|
#include <Standard_Failure.hxx>
|
||||||
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
||||||
@ -68,7 +69,8 @@ extern "C"
|
|||||||
STEPIMPORT_EXPORT
|
STEPIMPORT_EXPORT
|
||||||
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
|
||||||
const TCollection_AsciiString& /*theFormatName*/,
|
const TCollection_AsciiString& /*theFormatName*/,
|
||||||
TCollection_AsciiString& theError)
|
TCollection_AsciiString& theError,
|
||||||
|
const TDF_Label&)
|
||||||
{
|
{
|
||||||
MESSAGE("Import STEP model from file " << theFileName.ToCString());
|
MESSAGE("Import STEP model from file " << theFileName.ToCString());
|
||||||
TopoDS_Shape aResShape;
|
TopoDS_Shape aResShape;
|
||||||
|
Loading…
Reference in New Issue
Block a user