#include <TopoDS_Edge.hxx>
#include <TDataStd_AsciiString.hxx>
+#include <TDataStd_RealArray.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
QString anObstacleName = GetObjPyName();
- QString aGeomObjectEntry = GetGeomObjectEntry();
+ TCollection_AsciiString aGeomObjectEntry = GetGeomObjectEntry();
QString aFilePath = GetFilePath();
- if ( !aGeomObjectEntry.isEmpty() )
+ if ( !aGeomObjectEntry.IsEmpty() )
{
QString aSalomeObjName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "obstacle_sobj" );
- aResList << QString( "%1 = salome.sg.IDToObject( \"%2\" );" )
- .arg( aSalomeObjName ).arg( aGeomObjectEntry );
+ aResList << QString( "%1 = theStudy.FindObjectID( \"%2\" );" )
+ .arg( aSalomeObjName ).arg( aGeomObjectEntry.ToCString() );
aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() );" )
.arg( anObstacleName ).arg( aSalomeObjName );
+
+ aResList << QString( "%1.SetGeomObjectEntry( \"%2\" );" )
+ .arg( anObstacleName ).arg( aGeomObjectEntry.ToCString() );
+ aResList << QString( "" );
}
else if ( !aFilePath.isEmpty() )
{
aResList << QString( "%1.ImportFromFile( \"%2\" );" )
.arg( anObstacleName ).arg( aFilePath );
+ aResList << QString( "" );
}
- aResList << QString( "" );
+ // Write the translation points
+ double aDx, aDy, aDz;
+ if ( getTranslation( aDx, aDy, aDz ) )
+ {
+ aResList << QString( "%1.Translate( %2, %3, %4 );" )
+ .arg( anObstacleName ).arg( aDx ).arg( aDy ).arg( aDz );
+ aResList << QString( "" );
+ }
aResList << QString( "%1.Update();" ).arg( anObstacleName );
aResList << QString( "" );
return aRes;
}
-bool HYDROData_Obstacle::ImportFromGeomIOR( const QString& theIOR )
-{
- TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( theIOR );
- if ( aShape.IsNull() )
- return false;
-
- SetShape3D( aShape );
- SetGeomObjectEntry( theIOR );
-
- return true;
-}
-
void HYDROData_Obstacle::SetFilePath( const QString& theFilePath )
{
TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() );
return aRes;
}
-void HYDROData_Obstacle::SetGeomObjectEntry( const QString& theEntry )
+bool HYDROData_Obstacle::ImportFromGeomIOR( const TCollection_AsciiString& theIOR )
{
- TCollection_AsciiString anAsciiStr( theEntry.toStdString().c_str() );
- TDataStd_AsciiString::Set( myLab.FindChild( DataTag_GeomObjectEntry ), anAsciiStr );
+ if ( theIOR.IsEmpty() )
+ return false;
+
+ TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( theIOR.ToCString() );
+ if ( aShape.IsNull() )
+ return false;
+
+ SetShape3D( aShape );
+
+ return true;
}
-QString HYDROData_Obstacle::GetGeomObjectEntry() const
+void HYDROData_Obstacle::SetGeomObjectEntry( const TCollection_AsciiString& theEntry )
{
- QString aRes;
+ TDataStd_AsciiString::Set( myLab.FindChild( DataTag_GeomObjectEntry ), theEntry );
+}
+
+TCollection_AsciiString HYDROData_Obstacle::GetGeomObjectEntry() const
+{
+ TCollection_AsciiString aRes;
TDF_Label aLabel = myLab.FindChild( DataTag_GeomObjectEntry, false );
if ( !aLabel.IsNull() )
{
Handle(TDataStd_AsciiString) anAsciiStr;
if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
- aRes = QString( anAsciiStr->Get().ToCString() );
+ aRes = anAsciiStr->Get();
}
return aRes;
}
+void HYDROData_Obstacle::Translate( const double theDx,
+ const double theDy,
+ const double theDz )
+{
+ TopoDS_Shape aShape3D = GetShape3D();
+
+ TopoDS_Shape aTranslatedShape3D = HYDROData_ShapesTool::Translated( aShape3D, theDx, theDy, theDz );
+ if ( aTranslatedShape3D.IsNull() )
+ return;
+
+ SetShape3D( aTranslatedShape3D );
+
+ setTranslation( theDx, theDy, theDz );
+}
+
TopoDS_Shape HYDROData_Obstacle::ImportBREP( const QString& theFilePath ) const
{
TopoDS_Shape aResShape;
return DefaultBorderColor();
}
+ObjectKind HYDROData_Obstacle::getAltitudeObjectType() const
+{
+ return KIND_OBSTACLE_ALTITUDE;
+}
+
void HYDROData_Obstacle::createGroupObjects()
{
TopoDS_Shape anObstacleShape = GetTopShape();
}
}
-ObjectKind HYDROData_Obstacle::getAltitudeObjectType() const
+void HYDROData_Obstacle::setTranslation( const double theDx,
+ const double theDy,
+ const double theDz )
{
- return KIND_OBSTACLE_ALTITUDE;
+ TDF_Label aLabel = myLab.FindChild( DataTag_Translation );
+
+ double aCurDx = theDx;
+ double aCurDy = theDy;
+ double aCurDz = theDz;
+
+ double aPrevDx, aPrevDy, aPrevDz;
+ if ( getTranslation( aPrevDx, aPrevDy, aPrevDz ) )
+ {
+ aCurDx += aPrevDx;
+ aCurDy += aPrevDy;
+ aCurDz += aPrevDz;
+ }
+
+ Handle(TDataStd_RealArray) aCoeffsArray = TDataStd_RealArray::Set( aLabel, 1, 3 );
+ aCoeffsArray->SetValue( 1, aCurDx );
+ aCoeffsArray->SetValue( 2, aCurDy );
+ aCoeffsArray->SetValue( 3, aCurDz );
}
+bool HYDROData_Obstacle::getTranslation( double& theDx, double& theDy, double& theDz ) const
+{
+ theDx = theDy = theDz = 0.0;
+ TDF_Label aLabel = myLab.FindChild( DataTag_Translation, false );
+ if ( aLabel.IsNull() )
+ return false;
+
+ Handle(TDataStd_RealArray) aCoeffsArray;
+ if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), aCoeffsArray ) )
+ return false;
+
+ theDx = aCoeffsArray->Value( 1 );
+ theDy = aCoeffsArray->Value( 2 );
+ theDz = aCoeffsArray->Value( 3 );
+
+ return true;
+}