STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
- SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
+ SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
OPTION(SALOME_BUILD_GUI "Enable GUI" ON)
OPTION(SALOME_SMESH_USE_CGNS "Enable import/export to CGNS format" OFF)
OPTION(SALOME_SMESH_USE_TBB "Enable parallel computation" OFF)
+ OPTION(SALOME_SMESH_DYNLOAD_LOCAL "Load plug-ins' symbols locally (Linux only)" ON)
+
+ IF(SALOME_SMESH_DYNLOAD_LOCAL)
+ ADD_DEFINITIONS(-DDYNLOAD_LOCAL)
+ ENDIF(SALOME_SMESH_DYNLOAD_LOCAL)
#On Linux use Fortran to compile MEFISTO2D
IF(NOT WIN32)
ADD_DEFINITIONS(-DENABLE_MEFISTO)
ENDIF(NOT WIN32)
- MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_SMESH_USE_CGNS SALOME_SMESH_USE_TBB)
+ MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_SMESH_USE_CGNS SALOME_SMESH_USE_TBB SALOME_SMESH_DYNLOAD_LOCAL)
# Prerequisites
# =============
# Find "big" prerequisites first - they reference themselves many others
- # -> this can help finding the smaller prerequisites and detect conficts.
+ # -> this can help finding the smaller prerequisites and detect conflicts.
# In our case KERNEL has already loaded many prereq:
##
# They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
SET(_${PROJECT_NAME}_exposed_targets
SMESHControls MeshDriver MeshDriverDAT MeshDriverGMF MeshDriverMED
- MeshDriverSTL MeshDriverUNV MEDWrapperBase MEDWrapper MEDWrapper_V2_2
+ MeshDriverSTL MeshDriverUNV MEDWrapper
SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS
SMESHUtils StdMeshers StdMeshersEngine MeshJobManagerEngine
SPADDERPluginTesterEngine SalomeIDLSMESH SalomeIDLSPADDER
# - Config file for the @PROJECT_NAME@ package
# It defines the following variables.
- # Specific to the pacakge @PROJECT_NAME@ itself:
+ # Specific to the package @PROJECT_NAME@ itself:
# @PROJECT_NAME_UC@_ROOT_DIR_EXP - the root path of the installation providing this CMake file
#
SET(SMESH_MeshDriverMED MeshDriverMED)
SET(SMESH_MeshDriverSTL MeshDriverSTL)
SET(SMESH_MeshDriverUNV MeshDriverUNV)
-SET(SMESH_MEDWrapperBase MEDWrapperBase)
SET(SMESH_MEDWrapper MEDWrapper)
-SET(SMESH_MEDWrapper_V2_2 MEDWrapper_V2_2)
IF(SALOME_SMESH_ENABLE_MEFISTO)
SET(SMESH_MEFISTO2D MEFISTO2D)
ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-smesh = smeshBuilder.New(theStudy)
+
+ import SMESH, SALOMEDS
+ from salome.smesh import smeshBuilder
+
-print "Number of biquadratic pentahedrons:", infos[SMESH.Entity_BiQuad_Penta]
++smesh = smeshBuilder.New()
+ unPentaBiQuad = smesh.Mesh()
+ nodeID = unPentaBiQuad.AddNode( 0, 0, 0 )
+ nodeID = unPentaBiQuad.AddNode( 10, 0, 0 )
+ nodeID = unPentaBiQuad.AddNode( 0, 10, 0 )
+ nodeID = unPentaBiQuad.AddNode( 0, 0, 10 )
+ nodeID = unPentaBiQuad.AddNode( 10, 0, 10 )
+ nodeID = unPentaBiQuad.AddNode( 0, 10, 10 )
+ nodeID = unPentaBiQuad.AddNode( 5, 0, 0 )
+ nodeID = unPentaBiQuad.AddNode( 7, 7, 0 )
+ nodeID = unPentaBiQuad.AddNode( 0, 5, 0 )
+ nodeID = unPentaBiQuad.AddNode( 5, 0, 10 )
+ nodeID = unPentaBiQuad.AddNode( 7, 7, 10 )
+ nodeID = unPentaBiQuad.AddNode( 0, 5, 10 )
+ nodeID = unPentaBiQuad.AddNode( 0, 0, 5 )
+ nodeID = unPentaBiQuad.AddNode( 10, 0, 5 )
+ nodeID = unPentaBiQuad.AddNode( 0, 10, 5 )
+ nodeID = unPentaBiQuad.AddNode( 5, -1, 5 )
+ nodeID = unPentaBiQuad.AddNode( 8, 8, 5 )
+ nodeID = unPentaBiQuad.AddNode( -1, 5, 5 )
+ volID = unPentaBiQuad.AddVolume( [ 4, 5, 6, 1, 2, 3, 10, 11, 12, 7, 8, 9, 13, 14, 15, 16, 17, 18 ] )
+
+ infos = unPentaBiQuad.GetMeshInfo()
- salome.sg.updateObjBrowser(True)
++print("Number of biquadratic pentahedrons:", infos[SMESH.Entity_BiQuad_Penta])
+ if (infos[SMESH.Entity_BiQuad_Penta] != 1):
+ raise RuntimeError("Bad number of biquadratic pentahedrons: should be 1")
+
+ ## Set names of Mesh objects
+ smesh.SetName(unPentaBiQuad.GetMesh(), 'unPentaBiQuad')
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
--- /dev/null
- salome.sg.updateObjBrowser(True)
+ import salome
+ salome.salome_init()
+
+ ### create geometry
+
+ from salome.geom import geomBuilder
+ geompy = geomBuilder.New(salome.myStudy)
+
+ Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
+ geompy.addToStudy( Box_1, 'Box_1' )
+
+ ### create a mesh
+
+ import SMESH
+ from salome.smesh import smeshBuilder
+ smesh = smeshBuilder.New(salome.myStudy)
+
+ Mesh_1 = smesh.Mesh( Box_1 )
+ Mesh_1.Segment().NumberOfSegments(15)
+ Mesh_1.Triangle()
+ Mesh_1.Compute()
+
+ # define arguments for MakePolyLine
+
+ segments = []
+ # between nodes 20 and 1, default plane
+ segments.append( SMESH.PolySegment( 20, 0, 1, 0, smesh.MakeDirStruct(0,0,0) ))
+ # between nodes 1 and 100, default plane
+ segments.append( SMESH.PolySegment( 1, 0, 200, 0, smesh.MakeDirStruct(0,0,0) ))
+ # between nodes 200 and edge (578, 577), plane includes vector (1,1,1)
+ segments.append( SMESH.PolySegment( 200, 0, 578, 577, smesh.MakeDirStruct(1,1,1) ))
+
+ Mesh_1.MakePolyLine( segments, "1D group")
+
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-geompy = geomBuilder.New(theStudy)
+
+ import GEOM
+ from salome.geom import geomBuilder
+ import math
+ import SALOMEDS
+
-smesh = smeshBuilder.New(theStudy)
++geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+ Divided_Disk_1 = geompy.MakeDividedDisk(100, 1, GEOM.SQUARE)
+ geompy.addToStudy( O, 'O' )
+ geompy.addToStudy( OX, 'OX' )
+ geompy.addToStudy( OY, 'OY' )
+ geompy.addToStudy( OZ, 'OZ' )
+ geompy.addToStudy( Divided_Disk_1, 'Divided Disk_1' )
+
+ import SMESH, SALOMEDS
+ from salome.smesh import smeshBuilder
+
-print "Number of biquadratic pentahedrons:", infos[SMESH.Entity_BiQuad_Penta]
++smesh = smeshBuilder.New()
+ aFilterManager = smesh.CreateFilterManager()
+ Mesh_1 = smesh.Mesh(Divided_Disk_1)
+ Regular_1D = Mesh_1.Segment()
+ Number_of_Segments_1 = Regular_1D.NumberOfSegments(6)
+ Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
+ isDone = Mesh_1.Compute()
+ aMaxElementLength2D0x5d7fdf0 = aFilterManager.CreateMaxElementLength2D()
+ isDone = Mesh_1.QuadToTriObject( Mesh_1, )
+ Mesh_1.ExtrusionSweepObjects( [ Mesh_1 ], [ Mesh_1 ], [ Mesh_1 ], [ 0, 0, 50 ], 3, 1 )
+ Mesh_1.ConvertToQuadratic(0, Mesh_1,True)
+
+ infos = Mesh_1.GetMeshInfo()
- salome.sg.updateObjBrowser(True)
++print("Number of biquadratic pentahedrons:", infos[SMESH.Entity_BiQuad_Penta])
+ if (infos[SMESH.Entity_BiQuad_Penta] != 1080):
+ raise RuntimeError("Bad number of biquadratic pentahedrons: should be 1080")
+
+ ## Set names of Mesh objects
+ smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
+ smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
+ smesh.SetName(Number_of_Segments_1, 'Number of Segments_1')
+ smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
+
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New(salome.myStudy)
+geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(salome.myStudy)
+smesh = smeshBuilder.New()
import salome_notebook
]
filt = smesh.GetFilterFromCriteria( critaria )
filtGroup = mesh.GroupOnFilter( SMESH.FACE, "group on filter", filt )
- print("Group on filter contains %s elemens" % filtGroup.Size())
-print "Group on filter contains %s elements" % filtGroup.Size()
++print("Group on filter contains %s elements" % filtGroup.Size())
# group on filter is updated if the mesh is modified
hyp1D.SetStartLength( 2.5 )
hyp1D.SetEndLength( 2.5 )
mesh.Compute()
- print("After mesh change, group on filter contains %s elemens" % filtGroup.Size())
-print "After mesh change, group on filter contains %s elements" % filtGroup.Size()
++print("After mesh change, group on filter contains %s elements" % filtGroup.Size())
# set a new filter defining the group
filt2 = smesh.GetFilter( SMESH.FACE, SMESH.FT_RangeOfIds, "1-50" )
filtGroup.SetFilter( filt2 )
- print("With a new filter, group on filter contains %s elemens" % filtGroup.Size())
-print "With a new filter, group on filter contains %s elements" % filtGroup.Size()
++print("With a new filter, group on filter contains %s elements" % filtGroup.Size())
# group is updated at modification of the filter
filt2.SetCriteria( [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )])
filtIDs3 = filtGroup.GetIDs()
- print("After filter modification, group on filter contains %s elemens" % filtGroup.Size())
-print "After filter modification, group on filter contains %s elements" % filtGroup.Size()
++print("After filter modification, group on filter contains %s elements" % filtGroup.Size())
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ # Deflection 2D
+
+
+ import salome
+ salome.salome_init()
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ import SMESH
+ from salome.smesh import smeshBuilder
-print "min and max deflection: ", minMax
++smesh = smeshBuilder.New()
+
+ # fuse a box and a sphere
+ Sphere_1 = geompy.MakeSphereR(100)
+ Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
+ Fuse = geompy.MakeFuse( Sphere_1, Box_1, theName="box + sphere" )
+
+ # create a mesh
+ mesh = smesh.Mesh( Fuse, "Deflection_2D")
+ algo = mesh.Segment()
+ algo.LocalLength(35)
+ algo = mesh.Triangle()
+ mesh.Compute()
+
+ # get min and max deflection
+ minMax = mesh.GetMinMax( SMESH.FT_Deflection2D )
-print "deflection of face %s = %s" % ( faceID, defl )
++print("min and max deflection: ", minMax)
+
+ # get deflection of a certain face
+ faceID = mesh.NbEdges() + mesh.NbFaces()
+ defl = mesh.FunctorValue( SMESH.FT_Deflection2D, faceID )
-print "%s faces have deflection less than %s" %( len(anIds), margin )
++print("deflection of face %s = %s" % ( faceID, defl ))
+
+ margin = minMax[1] / 2
+
+ # get all faces with deflection LESS than the margin
+ aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Deflection2D, '<', margin, mesh=mesh)
+ anIds = aFilter.GetIDs()
-aGroup = mesh.MakeGroup("Deflection > " + `margin`, SMESH.FACE, SMESH.FT_Deflection2D,'>',margin)
-print "%s faces have deflection more than %s: %s ..." %( aGroup.Size(), margin, aGroup.GetIDs()[:10] )
++print("%s faces have deflection less than %s" %( len(anIds), margin ))
+
+ # create a group of faces with deflection MORE than the margin
-salome.sg.updateObjBrowser(True)
++aGroup = mesh.MakeGroup("Deflection > " + repr(margin), SMESH.FACE, SMESH.FT_Deflection2D,'>',margin)
++print("%s faces have deflection more than %s: %s ..." %( aGroup.Size(), margin, aGroup.GetIDs()[:10] ))
+
++salome.sg.updateObjBrowser()
\n the old mode (from dump):
\code
import smesh, SMESH, SALOMEDS
-smesh.SetCurrentStudy(salome.myStudy)
+smesh.UpdateStudy()
\endcode
\n the new mode:
\code
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(salome.myStudy)
+smesh = smeshBuilder.New()
\endcode
<b> Of course, <em>from smesh import *</em> is no more possible.</b>
- \n You have to explicitely write <em>smesh.some_method()</em>.
+ \n You have to explicitly write <em>smesh.some_method()</em>.
<b>All algorithms have been transferred from the namespace <em>smesh</em> to the namespace <em>smeshBuilder</em>.</b>
\n For instance:
Compound1 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05)
\endcode
- <b>If you need to import a %SMESH Plugin explicitely, keep in mind that they are now located in separate namespaces.</b>
+ <b>If you need to import a %SMESH Plugin explicitly, keep in mind that they are now located in separate namespaces.</b>
\n For instance:
\code
import StdMeshers
FT_MultiConnection2D,
FT_Length,
FT_Length2D,
+ FT_Deflection2D,
FT_NodeConnectivityNumber,
FT_BelongToMeshGroup,
FT_BelongToGeom,
typedef sequence<Value> Values;
Values GetValues();
};
+ interface Deflection2D : NumericalFunctor{};
interface MultiConnection : NumericalFunctor{};
interface MultiConnection2D : NumericalFunctor
{
/*!
* Filter
*/
- interface Filter: SALOME::GenericObj, SMESH_IDSource
+ interface Filter: SMESH_IDSource
{
/*!
* Structure containing information about one criterion
MaxElementLength3D CreateMaxElementLength3D();
Length CreateLength();
Length2D CreateLength2D();
+ Deflection2D CreateDeflection2D();
MultiConnection CreateMultiConnection();
MultiConnection2D CreateMultiConnection2D();
BallDiameter CreateBallDiameter();
boolean IsEmbeddedMode();
/*!
- Set the current study
+ Update the study
*/
- void SetCurrentStudy( in SALOMEDS::Study theStudy );
-
+ void UpdateStudy();
+
+ /*!
+ Set enable publishing in the study
+ */
+ void SetEnablePublish( in boolean theIsEnablePublish );
+
/*!
- Get the current study
+ Get enable publishing in the study
*/
- SALOMEDS::Study GetCurrentStudy();
+ boolean IsEnablePublish();
/*!
- * Create a hypothesis that can be shared by differents parts of the mesh.
+ * Create a hypothesis that can be shared by different parts of the mesh.
* An hypothesis is either:
* - a method used to generate or modify a part of the mesh (algorithm).
* - a parameter or a law used by an algorithm.
*/
long GetObjectId(in Object theObject);
+ /*!
+ * \brief Get version of MED format being used.
+ */
+ string GetMEDFileVersion();
+
/*!
* \brief Get MED version of the file by its name.
*/
- boolean GetMEDVersion(in string theFileName, out MED_VERSION theVersion);
+ string GetMEDVersion(in string theFileName);
+
+ /*!
+ * \brief Check compatibility of file with MED format being used.
+ */
+ boolean CheckCompatibility(in string theFileName);
/*!
* \brief Get names of meshes defined in file with the specified name.
Entity_TriQuad_Hexa,
Entity_Penta,
Entity_Quad_Penta,
+ Entity_BiQuad_Penta,
Entity_Hexagonal_Prism,
Entity_Polyhedra,
Entity_Quad_Polyhedra,
DRS_FAIL // general failure (exception etc.)
};
- /*!
- * Enumeration for ExportToMED*()
- * MED_V2_1 and MED_V2_2 are here for compatibility and mean respectively obsolete and MED_LATEST.
- * MED_MINOR_0 to MED_MINOR_9 are use to specify the minor version used by MEDfichier
- * to write MED files (major version cannot be changed).
- * This allows backward compatibility from a newer version of SALOME to an older one:
- * for instance, a MESH produced in SALOME 8.4 (med 3.3) can be written in med 3.2 format
- * to be read in SALOME 8.3.
- */
- enum MED_VERSION
- {
- MED_V2_1,
- MED_V2_2,
- MED_LATEST,
- MED_MINOR_0,
- MED_MINOR_1,
- MED_MINOR_2,
- MED_MINOR_3,
- MED_MINOR_4,
- MED_MINOR_5,
- MED_MINOR_6,
- MED_MINOR_7,
- MED_MINOR_8,
- MED_MINOR_9
- };
-
/*!
* \brief A structure containing information about MED file
*/
typedef sequence<SMESH_subMesh> submesh_array;
typedef sequence<submesh_array> submesh_array_array;
- interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource
+ interface SMESH_Mesh : SMESH_IDSource
{
/*!
* Return true if there is a geometry to be meshed
raises (SALOME::SALOME_Exception);
/*!
- * Remove an hypothesis previouly added with AddHypothesis.
+ * Remove an hypothesis previously added with AddHypothesis.
*/
Hypothesis_Status RemoveHypothesis(in GEOM::GEOM_Object aSubObject,
in SMESH_Hypothesis anHyp)
*/
long GetId();
- /*!
- * Get the study Id
- */
- long GetStudyId();
-
/*!
* Obtain instance of SMESH_MeshEditor
*/
boolean HasDuplicatedGroupNamesMED();
/*!
- * Export Mesh to a MED Format file
+ * Export a Mesh to MED file.
* @params
- * - file : name of the MED file
+ * - fileName : name of the MED file
* - auto_groups : boolean parameter for creating/not creating
* the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
* the typical use is auto_groups=false.
- * - version : defines the version of format of MED file, that will be created
* - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists
* - autoDimension : if @c true, a space dimension of a MED mesh can be either
* - 1D if all mesh nodes lie on OX coordinate axis, or
* - 3D in the rest cases.
* If @a autoDimension is @c false, the space dimension is always 3.
*/
- void ExportToMEDX( in string file,
- in boolean auto_groups,
- in MED_VERSION version,
- in boolean overwrite,
- in boolean autoDimension) raises (SALOME::SALOME_Exception);
+ void ExportMED( in string fileName,
+ in boolean auto_groups,
+ in boolean overwrite,
+ in boolean autoDimension) raises (SALOME::SALOME_Exception);
/*!
* Export a [part of] Mesh into a MED file
* @params
* - meshPart : a part of mesh to store
- * - file : name of the MED file
- * - version : define the version of format of MED file, that will be created
+ * - fileName : name of the MED file
* - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists
* - autoDimension : if @c True, a space dimension for export is defined by mesh
* configuration; for example a planar mesh lying on XOY plane
* - 's' stands for _solids_ field.
*/
void ExportPartToMED( in SMESH_IDSource meshPart,
- in string file,
+ in string fileName,
in boolean auto_groups,
- in MED_VERSION version,
in boolean overwrite,
in boolean autoDimension,
in GEOM::ListOfFields fields,
in string geomAssocFields ) raises (SALOME::SALOME_Exception);
- /*!
- * Export Mesh to a MED Format file
- * Works, just the same as ExportToMEDX, with overwrite parameter equal to true.
- * The method is kept in order to support old functionality
- */
- void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion )
- raises (SALOME::SALOME_Exception);
-
- /*!
- * Export Mesh to MED_LATEST MED format
- * Works, just the same as ExportToMEDX with MED_VERSION parameter equal to MED_LATEST
- * and overwrite parameter equal to true
- * The method is kept in order to support old functionality
- */
- void ExportMED( in string file, in boolean auto_groups )
- raises (SALOME::SALOME_Exception);
-
/*!
* Export Mesh to SAUV formatted file
* Write a temporary med file and use med2sauv
void ExportSAUV( in string file, in boolean auto_groups )
raises (SALOME::SALOME_Exception);
- /*!
- * Return string representation of a MED file version comprising nbDigits
- */
- string GetVersionString(in MED_VERSION version, in short nbDigits);
-
/*!
* Export Mesh to different Formats
* (UNV supported version is I-DEAS 10)
in boolean isascii ) raises (SALOME::SALOME_Exception);
void ExportCGNS( in SMESH_IDSource meshPart,
in string file,
- in boolean overwrite ) raises (SALOME::SALOME_Exception);
+ in boolean overwrite,
+ in boolean groupElemsByType) raises (SALOME::SALOME_Exception);
void ExportGMF( in SMESH_IDSource meshPart,
in string file,
in boolean withRequiredGroups) raises (SALOME::SALOME_Exception);
double GetComputeProgress();
/*!
- * Get informations about mesh contents
+ * Get information about mesh contents
*/
long NbNodes()
raises (SALOME::SALOME_Exception);
string_array GetLastParameters();
};
- interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
+ interface SMESH_subMesh : SMESH_IDSource
{
/*!
*
return myType;
}
- const std::set< SMDSAbs_ElementType >&
+ const ElemTypeSet&
DriverMED_Family
::GetTypes() const
{
}
string aValue = aStr.str();
// PAL19785,0019867 - med forbids whitespace to be the last char in the name
- int maxSize;
- //if ( theWrapper->GetVersion() == MED::eV2_1 )
- // maxSize = MED::GetNOMLength<MED::eV2_1>();
- //else
- maxSize = MED::GetNOMLength<MED::eV2_2>();
+ int maxSize = MED::GetNOMLength();
int lastCharPos = min( maxSize, (int) aValue.size() ) - 1;
while ( isspace( aValue[ lastCharPos ] ))
aValue.resize( lastCharPos-- );
#endif
myFamilies.clear();
if(MYDEBUG) MESSAGE("Perform - myFile : "<<myFile);
- PWrapper aMed = CrWrapper(myFile,true);
+ PWrapper aMed = CrWrapperR(myFile);
aResult = DRS_EMPTY;
TInt aNbMeshes = aMed->GetNbMeshes();
case ePYRA13: aNbNodes = 13; break;
case ePENTA6: aNbNodes = 6; break;
case ePENTA15: aNbNodes = 15; break;
+ case ePENTA18: aNbNodes = 18; break;
case eHEXA8: aNbNodes = 8; break;
case eHEXA20: aNbNodes = 20; break;
case eHEXA27: aNbNodes = 27; break;
isRenum = anIsElemNum;
}
break;
+ case ePENTA18:
+ aNbNodes = 18;
+ if(anIsElemNum)
+ anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
+ aNodeIds[2], aNodeIds[3],
+ aNodeIds[4], aNodeIds[5],
+ aNodeIds[6], aNodeIds[7],
+ aNodeIds[8], aNodeIds[9],
+ aNodeIds[10], aNodeIds[11],
+ aNodeIds[12], aNodeIds[13],
+ aNodeIds[14], aNodeIds[15],
+ aNodeIds[16], aNodeIds[17],
+ aCellInfo->GetElemNum(iElem));
+ if (!anElement) {
+ anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+ FindNode(myMesh,aNodeIds[1]),
+ FindNode(myMesh,aNodeIds[2]),
+ FindNode(myMesh,aNodeIds[3]),
+ FindNode(myMesh,aNodeIds[4]),
+ FindNode(myMesh,aNodeIds[5]),
+ FindNode(myMesh,aNodeIds[6]),
+ FindNode(myMesh,aNodeIds[7]),
+ FindNode(myMesh,aNodeIds[8]),
+ FindNode(myMesh,aNodeIds[9]),
+ FindNode(myMesh,aNodeIds[10]),
+ FindNode(myMesh,aNodeIds[11]),
+ FindNode(myMesh,aNodeIds[12]),
+ FindNode(myMesh,aNodeIds[13]),
+ FindNode(myMesh,aNodeIds[14]),
+ FindNode(myMesh,aNodeIds[15]),
+ FindNode(myMesh,aNodeIds[16]),
+ FindNode(myMesh,aNodeIds[17]));
+ isRenum = anIsElemNum;
+ }
+ break;
case eHEXA8:
aNbNodes = 8;
if(anIsElemNum)
try {
if(MYDEBUG) MESSAGE("GetMeshNames - myFile : " << myFile);
theStatus = DRS_OK;
- PWrapper aMed = CrWrapper(myFile);
+ PWrapper aMed = CrWrapperR(myFile);
if (TInt aNbMeshes = aMed->GetNbMeshes()) {
for (int iMesh = 0; iMesh < aNbMeshes; iMesh++) {
set<string>::const_iterator aGrNamesIter = aGroupNames.begin();
for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
{
- const set< SMDSAbs_ElementType >& types = aFamily->GetTypes();
- set< SMDSAbs_ElementType >::const_iterator type = types.begin();
+ const ElemTypeSet& types = aFamily->GetTypes();
+ ElemTypeSet::const_iterator type = types.begin();
for ( ; type != types.end(); ++type )
{
TNameAndType aNameAndType = make_pair( *aGrNamesIter, *type );
void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup)
{
- string aGroupName (theGroup->GetStoreName());
+ TFamilyVec * famVecPtr;
+
+ if ( myGroups2FamiliesMap.IsEmpty() ) // PAL23514
+ {
+ TFamilyVec famVector( 1 );
+ map<int, DriverMED_FamilyPtr>::iterator famIter = myFamilies.begin();
+ for ( ; famIter != myFamilies.end(); famIter++ )
+ {
+ DriverMED_FamilyPtr family = famIter->second;
+ const MED::TStringSet& groups = family->GetGroupNames();
+ famVector[ 0 ] = family;
+ MED::TStringSet::const_iterator grpIter = groups.begin();
+ for ( ; grpIter != groups.end(); ++grpIter )
+ {
+ TCollection_AsciiString groupName = grpIter->c_str();
+ if (( famVecPtr = myGroups2FamiliesMap.ChangeSeek( groupName )))
+ famVecPtr->push_back( family );
+ else
+ myGroups2FamiliesMap.Bind( groupName, famVector );
+ }
+ }
+ }
+
+ const char* aGroupName = theGroup->GetStoreName();
if(MYDEBUG) MESSAGE("Get Group " << aGroupName);
- map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
- for (; aFamsIter != myFamilies.end(); aFamsIter++)
+ if (( famVecPtr = myGroups2FamiliesMap.ChangeSeek( aGroupName )))
{
- DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
- if (aFamily->GetTypes().count( theGroup->GetType() ) && aFamily->MemberOf(aGroupName))
+ for ( size_t i = 0; i < famVecPtr->size(); ++i )
{
- const ElementsSet& anElements = aFamily->GetElements();
- ElementsSet::const_iterator anElemsIter = anElements.begin();
- for (; anElemsIter != anElements.end(); anElemsIter++)
+ DriverMED_FamilyPtr aFamily = (*famVecPtr)[i];
+ if ( aFamily->GetTypes().count( theGroup->GetType() ))
{
- const SMDS_MeshElement * element = *anElemsIter;
- if ( element->GetType() == theGroup->GetType() ) // Issue 0020576
- theGroup->SMDSGroup().Add(element);
+ const ElementsSet& anElements = aFamily->GetElements();
+ ElementsSet::const_iterator anElemsIter = anElements.begin();
+ for (; anElemsIter != anElements.end(); anElemsIter++)
+ {
+ const SMDS_MeshElement * element = *anElemsIter;
+ if ( element->GetType() == theGroup->GetType() ) // Issue 0020576
+ theGroup->SMDSGroup().Add(element);
+ }
+ int aGroupAttrVal = aFamily->GetGroupAttributVal();
+ if( aGroupAttrVal != 0 )
+ theGroup->SetColorGroup(aGroupAttrVal);
}
- int aGroupAttrVal = aFamily->GetGroupAttributVal();
- if( aGroupAttrVal != 0)
- theGroup->SetColorGroup(aGroupAttrVal);
- // if ( element ) -- Issue 0020576
- // theGroup->SetType( theGroup->SMDSGroup().GetType() );
}
}
}
if ( !myMesh )
return addMessage("Supporting mesh not set", /*isFatal=*/true );
- MED::PWrapper medFile = MED::CrWrapper( myFile, MED::eV2_2 );
+ MED::PWrapper medFile = MED::CrWrapperW( myFile );
MED::PMeshInfo meshInfo;
if ( myMeshId > 0 )
{
theVec[ SMDSEntity_TriQuad_Hexa ] = MED::eHEXA27 ;
theVec[ SMDSEntity_Penta ] = MED::ePENTA6 ;
theVec[ SMDSEntity_Quad_Penta ] = MED::ePENTA15 ;
+ theVec[ SMDSEntity_BiQuad_Penta ] = MED::ePENTA18 ;
theVec[ SMDSEntity_Hexagonal_Prism ] = MED::eOCTA12 ;
theVec[ SMDSEntity_Polyhedra ] = MED::ePOLYEDRE;
//theVec[ SMDSEntity_Quad_Polyhedra ] = MED::ePOLYEDRE; // !!
DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh():
- myMedVersion(MED::eV2_2),
myAllSubMeshes (false),
myDoGroupOfNodes (false),
myDoGroupOfEdges (false),
myDoAllInGroups(false)
{}
-void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName,
- MED::EVersion theId)
-{
- Driver_SMESHDS_Mesh::SetFile(theFileName);
- myMedVersion = theId;
- //MESSAGE("myMedVersion:"<<myMedVersion);
-}
-
void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName)
{
Driver_SMESHDS_Mesh::SetFile(theFileName);
}
-/*!
- * MED version is either the latest available, or with an inferior minor,
- * to ensure backward compatibility on writing med files.
- */
-string DriverMED_W_SMESHDS_Mesh::GetVersionString(const MED::EVersion theVersion, int theNbDigits)
-{
- TInt majeur, mineur, release;
- majeur = mineur = release = 0;
- MED::GetVersionRelease<eV2_2>(majeur, mineur, release);
- TInt imposedMineur = mineur;
- switch( theVersion ) {
- case MED::eV2_1 :
- case MED::eV2_2 :
- case MED::eLATEST : break;
- case MED::eMINOR_0 : imposedMineur = 0; break;
- case MED::eMINOR_1 : imposedMineur = 1; break;
- case MED::eMINOR_2 : imposedMineur = 2; break;
- case MED::eMINOR_3 : imposedMineur = 3; break;
- case MED::eMINOR_4 : imposedMineur = 4; break;
- case MED::eMINOR_5 : imposedMineur = 5; break;
- case MED::eMINOR_6 : imposedMineur = 6; break;
- case MED::eMINOR_7 : imposedMineur = 7; break;
- case MED::eMINOR_8 : imposedMineur = 8; break;
- case MED::eMINOR_9 : imposedMineur = 9; break;
- case MED::eVUnknown : imposedMineur = mineur; break;
- }
- if (imposedMineur > mineur)
- imposedMineur = mineur;
- ostringstream name;
- if ( theNbDigits > 0 )
- name << majeur;
- if ( theNbDigits > 1 )
- name << "." << imposedMineur;
- if ( theNbDigits > 2 )
- name << "." << release;
- return name.str();
-}
-
void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_GroupBase* theGroup)
{
myGroups.push_back(theGroup);
break;
}
}
- //MESSAGE("myMedVersion:"<<myMedVersion);
- MED::PWrapper myMed = CrWrapper(myFile,myMedVersion);
+
+ MED::PWrapper myMed = CrWrapperW(myFile);
PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
//MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
myMed->SetMeshInfo(aMeshInfo);
SMDSAbs_Volume));
aTElemTypeDatas.push_back( TElemTypeData(anEntity,
ePENTA15,
- nbElemInfo.NbPrisms( ORDER_QUADRATIC ),
+ nbElemInfo.NbQuadPrisms(),
+ SMDSAbs_Volume));
+ aTElemTypeDatas.push_back( TElemTypeData(anEntity,
+ ePENTA18,
+ nbElemInfo.NbBiQuadPrisms(),
SMDSAbs_Volume));
aTElemTypeDatas.push_back( TElemTypeData(anEntity,
eHEXA8,
continue;
}
+ // build map of family numbers for this type
+ if ( !isElemFamMapBuilt[ aElemTypeData->_smdsType ])
+ {
+ fillElemFamilyMap( anElemFamMap, aFamilies, aElemTypeData->_smdsType );
+ isElemFamMapBuilt[ aElemTypeData->_smdsType ] = true;
+ }
+
// iterator on elements of a current type
SMDS_ElemIteratorPtr elemIterator;
int iElem = 0;
else if (aElemTypeData->_geomType == ePOLYEDRE )
{
elemIterator = myMesh->elementGeomIterator( SMDSGeom_POLYHEDRA );
-
+
if ( nbPolyhedronNodes == 0 ) {
// Count nb of nodes
while ( elemIterator->more() ) {
// allocate data arrays
PBallInfo aBallInfo = myMed->CrBallInfo( aMeshInfo, aElemTypeData->_nbElems );
- // build map of family numbers for this type
- if ( !isElemFamMapBuilt[ aElemTypeData->_smdsType ])
- {
- fillElemFamilyMap( anElemFamMap, aFamilies, aElemTypeData->_smdsType );
- isElemFamMapBuilt[ aElemTypeData->_smdsType ] = true;
- }
-
elemIterator = myMesh->elementsIterator( SMDSAbs_Ball );
while ( elemIterator->more() )
{
{
// Treat standard types
// ---------------------
-
// allocate data arrays
PCellInfo aCellInfo = myMed->CrCellInfo( aMeshInfo,
aElemTypeData->_entity,
theConnMode,
theIsElemNum,
theIsElemNames);
- // build map of family numbers for this type
- if ( !isElemFamMapBuilt[ aElemTypeData->_smdsType ])
- {
- //cout << " fillElemFamilyMap()" << endl;
- fillElemFamilyMap( anElemFamMap, aFamilies, aElemTypeData->_smdsType );
- isElemFamMapBuilt[ aElemTypeData->_smdsType ] = true;
- }
TInt aNbNodes = MED::GetNbNodes(aElemTypeData->_geomType);
elemIterator = myMesh->elementsIterator( aElemTypeData->_smdsType );
// store data in a file
myMed->SetCellInfo(aCellInfo);
}
-
} // loop on geom types
-
-
}
catch(const std::exception& exc) {
INFOS("The following exception was caught:\n\t"<<exc.what());
--- /dev/null
- ePYRA13=313, ePENTA15=315, eHEXA20=320, eHEXA27=327,
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef MED_Common_HeaderFile
+#define MED_Common_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+#include "MED_Vector.hxx"
+#include "MED_SharedPtr.hxx"
+
+#include <string>
+#include <set>
+#include <map>
+
+#include <hdf5.h>
+
+#ifdef WIN32
+#pragma warning(disable:4099)
+#endif
+
+namespace MED
+{
+ typedef enum {eFAUX, eVRAI} EBooleen;
+ typedef double TFloat;
+#if defined(HAVE_F77INT64)
+ typedef long TInt;
+#else
+ typedef int TInt;
+#endif
+ typedef hid_t TIdt;
+ typedef herr_t TErr;
+
+ typedef enum {eFULL_INTERLACE, eNO_INTERLACE} EModeSwitch;
+
+ typedef enum {eFLOAT64=6, eINT=24, eLONG=26} ETypeChamp;
+
+ typedef enum {eNON_STRUCTURE, eSTRUCTURE} EMaillage;
+
+ typedef enum {eCART, eCYL, eSPHER} ERepere;
+
+ typedef enum {eNOD, eDESC} EConnectivite;
+
+ typedef enum {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203,
+ eQUAD4=204, eTRIA6=206, eTRIA7=207, eQUAD8=208, eQUAD9=209, eTETRA4=304,
+ ePYRA5=305, ePENTA6=306, eHEXA8=308, eOCTA12=312, eTETRA10=310,
++ ePYRA13=313, ePENTA15=315, ePENTA18=318, eHEXA20=320, eHEXA27=327,
+ ePOLYGONE=400, ePOLYGON2=420, ePOLYEDRE=500, eNONE=0,
+ eBALL=1101, // no such a type in med.h, it's just a trick
+ eAllGeoType=-1} EGeometrieElement;
+
+ typedef enum {eMAILLE, eFACE, eARETE, eNOEUD, eNOEUD_ELEMENT, eSTRUCT_ELEMENT} EEntiteMaillage;
+
+ typedef enum {eNO_PFLMOD, eGLOBAL, eCOMPACT} EModeProfil;
+
+ typedef enum {eGRILLE_CARTESIENNE, eGRILLE_POLAIRE, eGRILLE_STANDARD} EGrilleType;
+
+ typedef enum {eCOOR, eCONN, eNOM, eNUM, eFAM, eCOOR_IND1, eCOOR_IND2, eCOOR_IND3} ETable;
+
+ typedef TVector<TInt> TIntVector;
+ typedef TVector<TFloat> TFloatVector;
+ typedef TVector<std::string> TStringVector;
+ typedef std::set<std::string> TStringSet;
+
+ typedef std::map<EGeometrieElement,TInt> TGeom2Size;
+ typedef std::map<EEntiteMaillage,TGeom2Size> TEntityInfo;
+
+ typedef std::set<EGeometrieElement> TGeomSet;
+ typedef std::map<EEntiteMaillage,TGeomSet> TEntity2GeomSet;
+
+ struct TNameInfo;
+ typedef SharedPtr<TNameInfo> PNameInfo;
+
+ struct TMeshInfo;
+ typedef SharedPtr<TMeshInfo> PMeshInfo;
+
+ struct TFamilyInfo;
+ typedef SharedPtr<TFamilyInfo> PFamilyInfo;
+
+ struct TElemInfo;
+ typedef SharedPtr<TElemInfo> PElemInfo;
+
+ struct TNodeInfo;
+ typedef SharedPtr<TNodeInfo> PNodeInfo;
+
+ struct TPolygoneInfo;
+ typedef SharedPtr<TPolygoneInfo> PPolygoneInfo;
+
+ struct TPolyedreInfo;
+ typedef SharedPtr<TPolyedreInfo> PPolyedreInfo;
+
+ struct TCellInfo;
+ typedef SharedPtr<TCellInfo> PCellInfo;
+
+ struct TBallInfo;
+ typedef SharedPtr<TBallInfo> PBallInfo;
+
+ struct TFieldInfo;
+ typedef SharedPtr<TFieldInfo> PFieldInfo;
+
+ struct TTimeStampInfo;
+ typedef SharedPtr<TTimeStampInfo> PTimeStampInfo;
+
+ struct TProfileInfo;
+ typedef SharedPtr<TProfileInfo> PProfileInfo;
+
+ struct TGaussInfo;
+ typedef SharedPtr<TGaussInfo> PGaussInfo;
+
+ class TGrilleInfo;
+ typedef SharedPtr<TGrilleInfo> PGrilleInfo;
+
+ struct TTimeStampValueBase;
+ typedef SharedPtr<TTimeStampValueBase> PTimeStampValueBase;
+
+ struct TWrapper;
+ typedef SharedPtr<TWrapper> PWrapper;
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetDESCLength();
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetIDENTLength();
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetNOMLength();
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetLNOMLength();
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetPNOMLength();
+
+ MEDWRAPPER_EXPORT
+ void
+ GetVersionRelease(TInt&, TInt&, TInt&);
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetNbConn(EGeometrieElement, EEntiteMaillage, TInt);
+
+ MEDWRAPPER_EXPORT
+ TInt
+ GetNbNodes(EGeometrieElement typmai);
+
+ MEDWRAPPER_EXPORT
+ const TEntity2GeomSet&
+ GetEntity2GeomSet();
+}
+
+#endif // MED_Common_HeaderFile
--- /dev/null
- //! Define a parent class for all MED entities that describes mesh entites such as nodes and cells.
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef MED_Structures_HeaderFile
+#define MED_Structures_HeaderFile
+
+#include "MED_WrapperDef.hxx"
+#include "MED_Common.hxx"
+#include "MED_Utilities.hxx"
+#include "MED_SliceArray.hxx"
+
+#include <boost/tuple/tuple.hpp>
+
+#ifdef WIN32
+#pragma warning(disable:4251)
+#endif
+
+namespace MED
+{
+ //---------------------------------------------------------------
+ //! Defines a type for managing sequence of strings
+ typedef TVector<char> TString;
+ typedef SharedPtr<TString> PString;
+
+ //---------------------------------------------------------------
+ //! Extract a substring from the sequence of the strings
+ MEDWRAPPER_EXPORT
+ std::string
+ GetString(TInt theId,
+ TInt theStep,
+ const TString& theString);
+
+ //---------------------------------------------------------------
+ //! Set a substring in the sequence of the strings
+ MEDWRAPPER_EXPORT
+ void
+ SetString(TInt theId,
+ TInt theStep,
+ TString& theString,
+ const std::string& theValue);
+
+ //---------------------------------------------------------------
+ //! Set a substring in the sequence of the strings
+ MEDWRAPPER_EXPORT
+ void
+ SetString(TInt theId,
+ TInt theStep,
+ TString& theString,
+ const TString& theValue);
+
+ //---------------------------------------------------------------
+ //! Define a parent class for all MEDWrapper classes
+ struct MEDWRAPPER_EXPORT TBase
+ {
+ virtual ~TBase() {}
+ };
+
+ //---------------------------------------------------------------
+ //! Define a parent class for all named MED entities
+ struct MEDWRAPPER_EXPORT TNameInfo: virtual TBase
+ {
+ TString myName; //!< Keeps its name
+ virtual std::string GetName() const = 0; //!< Gets its name
+ virtual void SetName(const std::string& theValue) = 0; //!< Set a new name
+ virtual void SetName(const TString& theValue) = 0; //!< Set a new name
+ };
+
+ //---------------------------------------------------------------
+ //! Define a parent class for all MED entities that contains a sequence of numbers
+ /*!
+ It defines through corresponding enumeration (EModeSwitch) how the sequence
+ should be interpreted in C or Fortran mode (eFULL_INTERLACE or eNON_INTERLACE).
+ */
+ struct MEDWRAPPER_EXPORT TModeSwitchInfo: virtual TBase
+ {
+ //! To construct instance of the class by default
+ TModeSwitchInfo():
+ myModeSwitch(eFULL_INTERLACE)
+ {}
+
+ //! To construct instance of the class
+ TModeSwitchInfo(EModeSwitch theModeSwitch):
+ myModeSwitch(theModeSwitch)
+ {}
+
+ EModeSwitch myModeSwitch; //!< Keeps the interlace mode
+ EModeSwitch GetModeSwitch() const { return myModeSwitch; }
+ };
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Mesh entity
+ struct MEDWRAPPER_EXPORT TMeshInfo: virtual TNameInfo
+ {
+ TInt myDim; //!< Dimension of the mesh (0, 1, 2 or 3)
+ TInt GetDim() const { return myDim; } //!< Gets dimension of the mesh
+
+ TInt mySpaceDim;
+ TInt GetSpaceDim() const { return mySpaceDim; }
+
+ EMaillage myType; //!< Type of the mesh
+ EMaillage GetType() const { return myType; } //!< Gets type of the mesh
+
+ TString myDesc; //!< Description of the mesh
+ virtual std::string GetDesc() const = 0; //!< Get description for the mesh
+ virtual void SetDesc(const std::string& theValue) = 0; //!< Sets description for the mesh
+ };
+
+ //---------------------------------------------------------------
+ typedef TSlice<TInt> TIntVecSlice;
+ typedef TCSlice<TInt> TCIntVecSlice;
+ typedef TIntVector TFamAttr;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Family entity
+ struct MEDWRAPPER_EXPORT TFamilyInfo: virtual TNameInfo
+ {
+ PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
+ //! Get a reference to corresponding MED Mesh
+ const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
+
+ TInt myId; //!< An unique index of the MED FAMILY
+ TInt GetId() const { return myId; } //!< Gets number of the MED FAMILY
+ void SetId(TInt theId) { myId = theId; } //! Define number of the MED FAMILY
+
+ TInt myNbGroup; //!< Defines number MED Groups connected to
+ //! Gets number of MED GROUPS the MED FAMILY is bound to
+ TInt GetNbGroup() const { return myNbGroup; }
+
+ //! Contains sequence of the names for the MED Groups connected to
+ TString myGroupNames;
+ //! Gets name of a bound MED GROUP by its number
+ virtual std::string GetGroupName(TInt theId) const = 0;
+ //! Sets name of the defined MED GROUP by its number
+ virtual void SetGroupName(TInt theId, const std::string& theValue) = 0;
+
+ TInt myNbAttr; //!< Defines number of the MED Family attributes
+ //! Gets number of attached attributes for the MED FAMILY
+ TInt GetNbAttr() const { return myNbAttr; }
+
+ //! Defines sequence of the indexes of the MED Family attributes
+ TFamAttr myAttrId;
+ //! Get MED FAMILY attribute by its number
+ TInt GetAttrId(TInt theId) const;
+ //! Set MED FAMILY attribute by its number
+ void SetAttrId(TInt theId, TInt theVal);
+
+ //! Defines sequence of the values of the MED Family attributes
+ TFamAttr myAttrVal;
+ //! Get MED FAMILY attribute by its number
+ TInt GetAttrVal(TInt theId) const;
+ //! Set MED FAMILY attribute by its number
+ void SetAttrVal(TInt theId, TInt theVal);
+
+ //! Defines sequence of the names of the MED Family attributes
+ TString myAttrDesc;
+ //! Get value of the MED FAMILY attribute by its number
+ virtual std::string GetAttrDesc(TInt theId) const = 0;
+ //! Set value of the MED FAMILY attribute by its number
+ virtual void SetAttrDesc(TInt theId, const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ typedef TIntVector TElemNum;
+ typedef SharedPtr<TElemNum> PElemNum;
+
+ //---------------------------------------------------------------
- //! Let know if the mesh elements havew names
++ //! Define a parent class for all MED entities that describes mesh entities such as nodes and cells.
+ struct MEDWRAPPER_EXPORT TElemInfo: virtual TBase
+ {
+ PMeshInfo myMeshInfo; //!< A reference to correspondig MED Mesh
+ //! Get a reference to corresponding MED Mesh
+ const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
+
+ TInt myNbElem; //<! Number of corresponding mesh entities
+ TInt GetNbElem() const { return myNbElem; } //! Get number of mesh elements
+
+ //! Defines sequence MED Family indexes for corresponding mesh entites
+ PElemNum myFamNum;
+ //! Get number of a MED FAMILY by order number of the mesh element
+ TInt GetFamNum(TInt theId) const;
+ //! Set number of a MED FAMILY for the mesh element with the order number
+ void SetFamNum(TInt theId, TInt theVal);
+
+ //! Defines if the mesh elements are indexed
+ EBooleen myIsElemNum;
+ //! Let know if the mesh elements are indexed
+ EBooleen IsElemNum() const { return myIsElemNum; }
+
+ //! Defines if the mesh elements family are indexed
+ EBooleen myIsFamNum;
+ //! Let know if the mesh elements family are indexed
+ EBooleen IsFamNum() const { return myIsFamNum; }
+
+ //! Contains sequence of the indexes for the mesh elements
+ PElemNum myElemNum;
+ //! Get a reference number of the mesh element by its order number
+ TInt GetElemNum(TInt theId) const;
+ //! Set a reference number for the mesh element by its order number
+ void SetElemNum(TInt theId, TInt theVal);
+
+ //! Defines if the mesh elements are named
+ EBooleen myIsElemNames;
- *Defines sequence MED Family indexes for corresponding mesh entites
++ //! Let know if the mesh elements have names
+ EBooleen IsElemNames() const { return myIsElemNames; }
+
+ //! Contains sequence of the names for the mesh elements
+ PString myElemNames;
+ //! Get name of the mesh element by its order number
+ virtual std::string GetElemName(TInt theId) const = 0;
+ //! Set name of the mesh element by its order number
+ virtual void SetElemName(TInt theId, const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ typedef TSlice<TFloat> TFloatVecSlice;
+ typedef TCSlice<TFloat> TCFloatVecSlice;
+ typedef TFloatVector TNodeCoord;
+ typedef SharedPtr<TNodeCoord> PNodeCoord;
+ typedef TFloatVecSlice TCoordSlice;
+ typedef TCFloatVecSlice TCCoordSlice;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Nodes entity
+ struct MEDWRAPPER_EXPORT TNodeInfo:
+ virtual TElemInfo,
+ virtual TModeSwitchInfo
+ {
+ PNodeCoord myCoord; //!< Contains all nodal coordinates
+
+ //! Gives coordinates for mesh node by its number (const version)
+ TCCoordSlice GetCoordSlice(TInt theId) const;
+ //! Gives coordinates for mesh node by its number
+ TCoordSlice GetCoordSlice(TInt theId);
+
+ ERepere mySystem; //!< Defines, which coordinate system is used
+ //! Get which coordinate system is used for the node describing
+ ERepere GetSystem() const { return mySystem; }
+ //! Set coordinate system to be used for the node describing
+ void SetSystem(ERepere theSystem) { mySystem = theSystem; }
+
+ TString myCoordNames; //!< Contains names for the coordinate dimensions
+ //! Get name of the coordinate dimension by its order number
+ virtual std::string GetCoordName(TInt theId) const = 0;
+ //! Set name of the coordinate dimension by its order number
+ virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
+
+ TString myCoordUnits; //!< Contains units for the coordinate dimensions
+ //! Get name of unit for the coordinate dimension by its order number
+ virtual std::string GetCoordUnit(TInt theId) const = 0;
+ //! Set name of unit for the coordinate dimension by its order number
+ virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ typedef TIntVecSlice TConnSlice;
+ typedef TCIntVecSlice TCConnSlice;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Cells entity
+ struct MEDWRAPPER_EXPORT TCellInfo:
+ virtual TElemInfo,
+ virtual TModeSwitchInfo
+ {
+ EEntiteMaillage myEntity; //!< Defines the MED Entity where the mesh cells belongs to
+ //! Find out what MED ENTITY the cells belong to
+ EEntiteMaillage GetEntity() const { return myEntity; }
+
+ EGeometrieElement myGeom; //!< Defines the MED Geometric type of the instance
+ //! Find out what MED geometrical type the cells belong to
+ EGeometrieElement GetGeom() const { return myGeom; }
+
+ EConnectivite myConnMode; //!< Defines connectivity mode
+ //! Find out in what connectivity the cells are writen
+ EConnectivite GetConnMode() const { return myConnMode; }
+
+ virtual TInt GetConnDim() const = 0; //!< Gives step in the connectivity sequence
+
+ PElemNum myConn; //!< Defines sequence which describe connectivity for each of mesh cell
+
+ //! Gives connectivities for mesh cell by its number (const version)
+ TCConnSlice GetConnSlice(TInt theElemId) const;
+ //! Gives connectivities for mesh cell by its number
+ TConnSlice GetConnSlice(TInt theElemId);
+ };
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Polygon entity
+ struct MEDWRAPPER_EXPORT TPolygoneInfo:
+ virtual TElemInfo
+ {
+ //! Defines the MED Entity where the polygons belongs to
+ EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
+ //! Find out what MED ENTITY the MED Polygons belong to
+ EEntiteMaillage GetEntity() const { return myEntity; }
+
+ //! Defines the MED Geometric type of the instance
+ EGeometrieElement myGeom; // ePOLYGONE
+ //! Find out what MED geometrical type the MED Polygons belong to
+ EGeometrieElement GetGeom() const { return ePOLYGONE; }
+
+ //! Defines connectivity mode
+ EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
+ //! Find out in what connectivity the cells are writen
+ EConnectivite GetConnMode() const { return myConnMode; }
+
+ PElemNum myConn; //!< Table de connectivities
+ PElemNum myIndex; //!< Table de indexes
+
+ //! Gives number of the connectivities for the defined polygon
+ TInt GetNbConn(TInt theElemId) const;
+
+ //! Gives connectivities for polygon by its number (const version)
+ TCConnSlice GetConnSlice(TInt theElemId) const;
+ //! Gives connectivities for polygon by its number
+ TConnSlice GetConnSlice(TInt theElemId);
+ };
+
+ //---------------------------------------------------------------
+ //! Define a class representing MED_BALL structure element.
+ /*!
+ This could be a generic class for any structure element
+ holding any number of contant and variable attributes
+ but it's too hard to implement
+ */
+ struct MEDWRAPPER_EXPORT TBallInfo:
+ virtual TCellInfo
+ {
+ TFloatVector myDiameters;
+ };
+
+ //---------------------------------------------------------------
+ typedef TVector<TCConnSlice> TCConnSliceArr;
+ typedef TVector<TConnSlice> TConnSliceArr;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Polyedre entity
+ struct MEDWRAPPER_EXPORT TPolyedreInfo:
+ virtual TElemInfo
+ {
+ //! Defines the MED Entity where the polyedres belongs to
+ EEntiteMaillage myEntity; // MED_FACE|MED_MAILLE
+ //! Find out what MED ENTITY the MED Polyedres belong to
+ EEntiteMaillage GetEntity() const { return myEntity; }
+
+ //! Defines the MED Geometric type of the instance
+ EGeometrieElement myGeom; // ePOLYEDRE
+ //! Find out what MED geometrical type the MED Polyedres belong to
+ EGeometrieElement GetGeom() const { return ePOLYEDRE; }
+
+ //! Defines connectivity mode
+ EConnectivite myConnMode; // eNOD|eDESC(eDESC not used)
+ //! Find out in what connectivity the cells are writen
+ EConnectivite GetConnMode() const { return myConnMode; }
+
+ PElemNum myConn; //!< Table de connectivities
+ PElemNum myFaces; //!< Table de faces indexes
+ PElemNum myIndex; //!< Table de indexes
+
+ //! Gives number of the faces for the defined polyedre (const version)
+ TInt GetNbFaces(TInt theElemId) const;
+ //! Gives number of the nodes for the defined polyedre
+ TInt GetNbNodes(TInt theElemId) const;
+
+ //! Gives sequence of the face connectivities for polyedre by its number (const version)
+ TCConnSliceArr GetConnSliceArr(TInt theElemId) const;
+ //! Gives sequence of the face connectivities for polyedre by its number
+ TConnSliceArr GetConnSliceArr(TInt theElemId);
+ };
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Field entity
+ struct MEDWRAPPER_EXPORT TFieldInfo:
+ virtual TNameInfo
+ {
+ PMeshInfo myMeshInfo; //!< A reference to corresponding MED Mesh
+ //! Get a reference to corresponding MED Mesh
+ const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
+
+ ETypeChamp myType; //!< Defines type of MED Field
+ //! Find out what type of MED FIELD is used
+ ETypeChamp GetType() const { return myType; }
+
+ TInt myNbComp; //!< Defines number of components stored in the field
+ //! Get number of components for MED FIELD
+ TInt GetNbComp() const { return myNbComp; }
+
+ EBooleen myIsLocal; //!< Defines if the MED Field is local
+ //! Find out if MED FIELD is local or not
+ EBooleen GetIsLocal() const { return myIsLocal; }
+
+ TInt myNbRef; //!< Defines number of references of the field
+ //! Find out number of references for the MED FIELD
+ TInt GetNbRef() const { return myNbRef; }
+
+ TString myCompNames; //!< Contains names for each of MED Field components
+ //! Get name of the component by its order number
+ virtual std::string GetCompName(TInt theId) const = 0;
+ //! Set name for the component by its order number
+ virtual void SetCompName(TInt theId, const std::string& theValue) = 0;
+
+ TString myUnitNames; //!< Contains units for each of MED Field components
+ //! Get unit of the component by its order number
+ virtual std::string GetUnitName(TInt theId) const = 0;
+ //! Set unit for the component by its order number
+ virtual void SetUnitName(TInt theId, const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ //! Get dimension of the Gauss coordinates for the defined type of mesh cell
+ MEDWRAPPER_EXPORT
+ TInt
+ GetDimGaussCoord(EGeometrieElement theGeom);
+
+ //---------------------------------------------------------------
+ //! Get number of referenced nodes for the defined type of mesh cell
+ MEDWRAPPER_EXPORT
+ TInt
+ GetNbRefCoord(EGeometrieElement theGeom);
+
+ //---------------------------------------------------------------
+ typedef TFloatVector TWeight;
+
+ //---------------------------------------------------------------
+ //! The class represents MED Gauss entity
+ struct MEDWRAPPER_EXPORT TGaussInfo:
+ virtual TNameInfo,
+ virtual TModeSwitchInfo
+ {
+ typedef boost::tuple<EGeometrieElement,std::string> TKey;
+ typedef boost::tuple<TKey,TInt> TInfo;
+ struct MEDWRAPPER_EXPORT TLess
+ {
+ bool
+ operator()(const TKey& theLeft, const TKey& theRight) const;
+
+ bool
+ operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const;
+ };
+
+ //! Defines, which geometrical type the MED Gauss entity belongs to
+ EGeometrieElement myGeom;
+ //! Find out what MED geometrical type the MED GAUSS entity belong to
+ EGeometrieElement GetGeom() const { return myGeom; }
+
+ //! Contains coordinates for the refereced nodes
+ TNodeCoord myRefCoord;
+
+ //! Gives coordinates for the referenced node by its number
+ TCCoordSlice GetRefCoordSlice(TInt theId) const;
+ //! Gives coordinates for the referenced node by its number
+ TCoordSlice GetRefCoordSlice(TInt theId);
+
+ //! Contains coordinates for the Gauss points
+ TNodeCoord myGaussCoord;
+
+ //! Gives coordinates for the Gauss points by its number
+ TCCoordSlice GetGaussCoordSlice(TInt theId) const;
+ //! Gives coordinates for the Gauss points by its number
+ TCoordSlice GetGaussCoordSlice(TInt theId);
+
+ //! Contains wheights for the Gauss points
+ TWeight myWeight;
+
+ //! Gives number of the referenced nodes
+ TInt GetNbRef() const { return GetNbRefCoord(GetGeom()); }
+
+ //! Gives dimension of the referenced nodes
+ TInt GetDim() const { return GetDimGaussCoord(GetGeom()); }
+
+ //! Gives number of the Gauss Points
+ TInt GetNbGauss() const { return (TInt)(myGaussCoord.size() / GetDim()); }
+ };
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometrieElement,PGaussInfo> TGeom2Gauss;
+ typedef std::map<EGeometrieElement,TInt> TGeom2NbGauss;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED TimeStamp
+ struct MEDWRAPPER_EXPORT TTimeStampInfo:
+ virtual TBase
+ {
+ PFieldInfo myFieldInfo; //!< A reference to correspondig MED Field
+ //! Get a reference to corresponding MED Field
+ const PFieldInfo& GetFieldInfo() const { return myFieldInfo; }
+
+ //! Defines the MED Entity where the MED TimeStamp belongs to
+ EEntiteMaillage myEntity;
+ //! Find out to what MED Entity the MED TimeStamp belong to
+ EEntiteMaillage GetEntity() const { return myEntity; }
+
+ //! Keeps map of number of cells per geometric type where the MED TimeStamp belongs to
+ TGeom2Size myGeom2Size;
+ //! Get map of number of cells per geometric type where the MED TimeStamp belongs to
+ const TGeom2Size& GetGeom2Size() const { return myGeom2Size; }
+
+ TGeom2NbGauss myGeom2NbGauss; //!< Keeps number of the Gauss Points for the MED TimeStamp
+ TInt GetNbGauss(EGeometrieElement theGeom) const; //!< Gives number of the Gauss Points for the MED TimeStamp
+
+ TInt myNumDt; //!< Keeps number in time for the MED TimeStamp
+ TInt GetNumDt() const { return myNumDt; } //!< Defines number in time for the MED TimeStamp
+
+ TInt myNumOrd; //!< Keeps number for the MED TimeStamp
+ TInt GetNumOrd() const { return myNumOrd; } //!< Defines number for the MED TimeStamp
+
+ TFloat myDt; //!< Keeps time for the MED TimeStamp
+ TFloat GetDt() const { return myDt; } //!< Defines time for the MED TimeStamp
+
+ //! Keeps map of MED Gauss entityes per geometric type
+ TGeom2Gauss myGeom2Gauss;
+ //! Gets a map of MED Gauss entityes per geometric type
+ const TGeom2Gauss& GetGeom2Gauss() const { return myGeom2Gauss; }
+
+ TString myUnitDt; //!< Defines unit for the time for the MED TimeStamp
+ //! Get unit of time for the MED TimeStamp
+ virtual std::string GetUnitDt() const = 0;
+ //! Set unit of time for the MED TimeStamp
+ virtual void SetUnitDt(const std::string& theValue) = 0;
+ };
+
+ //---------------------------------------------------------------
+ //! The class represents MED Profile entity
+ struct MEDWRAPPER_EXPORT TProfileInfo:
+ virtual TNameInfo
+ {
+ typedef std::string TKey;
+ typedef boost::tuple<TKey,TInt> TInfo;
+
+ EModeProfil myMode; //!< Keeps mode for the MED Profile
+ //! Find out what mode of MED Profile is used
+ EModeProfil GetMode() const { return myMode; }
+ //! Set mode for the MED Profile
+ void SetMode(EModeProfil theMode) { myMode = theMode; }
+
+ PElemNum myElemNum; //!< Keeps sequence of cell by its number which belong to the profile
+ //! Get number of mesh elelemts by its order number
+ TInt GetElemNum(TInt theId) const;
+ //! Set number of mesh elelemts by its order number
+ void SetElemNum(TInt theId, TInt theVal);
+
+ //! Find out if the MED Profile defined
+ bool IsPresent() const { return GetName() != ""; }
+
+ //! Find out size of the MED Profile
+ TInt GetSize() const { return (TInt)myElemNum->size(); }
+ };
+
+ //---------------------------------------------------------------
+ //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
+ struct MEDWRAPPER_EXPORT TMeshValueBase:
+ virtual TModeSwitchInfo
+ {
+ TInt myNbElem;
+ TInt myNbComp;
+ TInt myNbGauss;
+ TInt myStep;
+
+ TMeshValueBase();
+
+ //! Initialize the class
+ void
+ Allocate(TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode = eFULL_INTERLACE);
+
+ //! Returns size of the value container
+ size_t
+ GetSize() const;
+
+ //! Returns MED interpetation of the value size
+ size_t
+ GetNbVal() const;
+
+ //! Returns number of Gauss Points bounded with the value
+ size_t
+ GetNbGauss() const;
+
+ //! Returns step inside of the data array
+ size_t
+ GetStep() const;
+
+ //! Returns bare pointer on the internal value representation
+ virtual
+ unsigned char*
+ GetValuePtr() = 0;
+ };
+
+ //---------------------------------------------------------------
+ //! The class is a helper one. It provide safe and flexible way to get access to values for a MED TimeStamp
+ template<class TValueType>
+ struct TTMeshValue:
+ virtual TMeshValueBase
+ {
+ typedef TValueType TValue;
+ typedef typename TValueType::value_type TElement;
+
+ typedef TSlice<TElement> TValueSlice;
+ typedef TCSlice<TElement> TCValueSlice;
+
+ typedef TVector<TCValueSlice> TCValueSliceArr;
+ typedef TVector<TValueSlice> TValueSliceArr;
+
+ TValue myValue;
+
+ //! Initialize the class
+ void
+ Allocate(TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode = eFULL_INTERLACE)
+ {
+ TMeshValueBase::Allocate(theNbElem, theNbGauss, theNbComp, theMode);
+ myValue.resize(theNbElem * this->GetStep());
+ }
+
+ //! Returns bare pointer on the internal value representation
+ virtual
+ unsigned char*
+ GetValuePtr()
+ {
+ return (unsigned char*)&myValue[0];
+ }
+
+ //! Returns bare pointer on the internal value representation
+ virtual
+ TElement*
+ GetPointer()
+ {
+ return &myValue[0];
+ }
+
+ //! Returns bare pointer on the internal value representation
+ virtual
+ const TElement*
+ GetPointer() const
+ {
+ return &myValue[0];
+ }
+
+ //! Iteration through Gauss Points by their components
+ TCValueSliceArr
+ GetGaussValueSliceArr(TInt theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(myNbGauss);
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TInt anId = theElemId * myStep;
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TCValueSlice(myValue, std::slice(anId, myNbComp, 1));
+ anId += myNbComp;
+ }
+ }
+ else{
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TCValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
+ }
+ }
+ return aValueSliceArr;
+ }
+
+ //! Iteration through Gauss Points by their components
+ TValueSliceArr
+ GetGaussValueSliceArr(TInt theElemId)
+ {
+ TValueSliceArr aValueSliceArr(myNbGauss);
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TInt anId = theElemId*myStep;
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TValueSlice(myValue, std::slice(anId, myNbComp, 1));
+ anId += myNbComp;
+ }
+ }
+ else{
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TValueSlice(myValue, std::slice(theElemId, myNbComp, myStep));
+ }
+ }
+ return aValueSliceArr;
+ }
+
+ //! Iteration through components by corresponding Gauss Points
+ TCValueSliceArr
+ GetCompValueSliceArr(TInt theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(myNbComp);
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TInt anId = theElemId*myStep;
+ for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TCValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
+ anId += 1;
+ }
+ }
+ else{
+ for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TCValueSlice(myValue, std::slice(theElemId, myNbGauss, myStep));
+ }
+ }
+ return aValueSliceArr;
+ }
+
+ //! Iteration through components by corresponding Gauss Points
+ TValueSliceArr
+ GetCompValueSliceArr(TInt theElemId)
+ {
+ if(GetModeSwitch() == eFULL_INTERLACE){
+ TValueSliceArr aValueSliceArr(myNbComp);
+ TInt anId = theElemId*myStep;
+ for(TInt aCompId = 0; aCompId < myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TValueSlice(myValue, std::slice(anId, myNbGauss, myNbComp));
+ anId += 1;
+ }
+ return aValueSliceArr;
+ }
+ else{
+ TValueSliceArr aValueSliceArr(myNbGauss);
+ for(TInt aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TValueSlice(myValue,std::slice(theElemId, myNbComp, myStep));
+ }
+ return aValueSliceArr;
+ }
+ }
+ };
+
+ //---------------------------------------------------------------
+ typedef TTMeshValue<TFloatVector> TFloatMeshValue;
+ typedef TTMeshValue<TIntVector> TIntMeshValue;
+
+ //---------------------------------------------------------------
+ // Backward compatibility declarations
+ typedef TFloatVector TValue;
+ typedef TSlice<TFloat> TValueSlice;
+ typedef TCSlice<TFloat> TCValueSlice;
+
+ typedef TVector<TCValueSlice> TCValueSliceArr;
+ typedef TVector<TValueSlice> TValueSliceArr;
+
+ typedef TFloatMeshValue TMeshValue;
+ typedef std::map<EGeometrieElement,TMeshValue> TGeom2Value;
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometrieElement,PProfileInfo> TGeom2Profile;
+ typedef std::set<EGeometrieElement> TGeom;
+
+ //---------------------------------------------------------------
+ //! The class is a base class for MED TimeStamp values holder
+ struct MEDWRAPPER_EXPORT TTimeStampValueBase:
+ virtual TModeSwitchInfo
+ {
+ //! A reference to correspondig MED TimeStamp
+ PTimeStampInfo myTimeStampInfo;
+ //!< Get a reference to correspondig MED TimeStamp
+ const PTimeStampInfo& GetTimeStampInfo() const { return myTimeStampInfo; }
+
+ //! Keeps set of MED EGeometrieElement which contains values for the timestamp
+ TGeomSet myGeomSet;
+ const TGeomSet& GetGeomSet() const { return myGeomSet; }
+
+ //! Keeps map of MED Profiles per geometric type
+ TGeom2Profile myGeom2Profile;
+ //! Gets a map of MED Profiles per geometric type
+ const TGeom2Profile& GetGeom2Profile() const { return myGeom2Profile; }
+
+ //! Gets type of the champ
+ virtual
+ ETypeChamp
+ GetTypeChamp() const = 0;
+
+ //! Allocates values for the given geometry
+ virtual
+ void
+ AllocateValue(EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode = eFULL_INTERLACE) = 0;
+
+ virtual
+ size_t
+ GetValueSize(EGeometrieElement theGeom) const = 0;
+
+ virtual
+ size_t
+ GetNbVal(EGeometrieElement theGeom) const = 0;
+
+ virtual
+ size_t
+ GetNbGauss(EGeometrieElement theGeom) const = 0;
+
+ virtual
+ unsigned char*
+ GetValuePtr(EGeometrieElement theGeom) = 0;
+ };
+
+ //---------------------------------------------------------------
+ //! The class implements a container for MED TimeStamp values
+ template<class TMeshValueType>
+ struct TTimeStampValue:
+ virtual TTimeStampValueBase
+ {
+ typedef TMeshValueType TTMeshValue;
+ typedef SharedPtr<TMeshValueType> PTMeshValue;
+ typedef typename TMeshValueType::TElement TElement;
+ typedef std::map<EGeometrieElement, PTMeshValue> TTGeom2Value;
+
+ ETypeChamp myTypeChamp; //<! Keeps type of the champ
+
+ //! Gets type of the champ
+ virtual
+ ETypeChamp
+ GetTypeChamp() const
+ {
+ return myTypeChamp;
+ }
+
+ //! Keeps map of MED TimeStamp values per geometric type (const version)
+ TTGeom2Value myGeom2Value;
+
+ const TTGeom2Value&
+ GetGeom2Value() const
+ {
+ return myGeom2Value;
+ }
+
+ //! Gets MED TimeStamp values for the given geometric type (const version)
+ const PTMeshValue&
+ GetMeshValuePtr(EGeometrieElement theGeom) const
+ {
+ typename TTGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
+ if(anIter == myGeom2Value.end())
+ EXCEPTION(std::runtime_error,"TTimeStampValue::GetMeshValuePtr - myGeom2Value.find(theGeom) fails");
+ return anIter->second;
+ }
+
+ //! Gets MED TimeStamp values for the given geometric type
+ PTMeshValue&
+ GetMeshValuePtr(EGeometrieElement theGeom)
+ {
+ myGeomSet.insert(theGeom);
+ if(myGeom2Value.find(theGeom) == myGeom2Value.end()){
+ myGeom2Value[theGeom] = PTMeshValue(new TTMeshValue());
+ return myGeom2Value[theGeom];
+ }
+ return myGeom2Value[theGeom];
+ }
+
+ //! Gets MED TimeStamp values for the given geometric type (const version)
+ const TTMeshValue&
+ GetMeshValue(EGeometrieElement theGeom) const
+ {
+ return *(this->GetMeshValuePtr(theGeom));
+ }
+
+ //! Gets MED TimeStamp values for the given geometric type
+ TTMeshValue&
+ GetMeshValue(EGeometrieElement theGeom)
+ {
+ return *(this->GetMeshValuePtr(theGeom));
+ }
+ };
+
+ //---------------------------------------------------------------
+ typedef TTimeStampValue<TFloatMeshValue> TFloatTimeStampValue;
+ typedef SharedPtr<TFloatTimeStampValue> PFloatTimeStampValue;
+
+ PFloatTimeStampValue MEDWRAPPER_EXPORT
+ CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
+
+ typedef TTimeStampValue<TIntMeshValue> TIntTimeStampValue;
+ typedef SharedPtr<TIntTimeStampValue> PIntTimeStampValue;
+
+ PIntTimeStampValue MEDWRAPPER_EXPORT
+ CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue);
+
+ //---------------------------------------------------------------
+ template<class TMeshValueTypeFrom, class TMeshValueTypeTo>
+ void
+ CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueTypeFrom> > theTimeStampValueFrom,
+ SharedPtr<TTimeStampValue<TMeshValueTypeTo> > theTimeStampValueTo)
+ {
+ typedef TTimeStampValue<TMeshValueTypeFrom> TimeStampValueTypeFrom;
+ typedef TTimeStampValue<TMeshValueTypeTo> TimeStampValueTypeTo;
+ typedef typename TMeshValueTypeTo::TElement TElementTo;
+
+ typename TimeStampValueTypeFrom::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
+ typename TimeStampValueTypeFrom::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
+ for(; anIter != aGeom2Value.end(); anIter++){
+ const EGeometrieElement& aGeom = anIter->first;
+ const typename TimeStampValueTypeFrom::TTMeshValue& aMeshValue = *anIter->second;
+ typename TimeStampValueTypeTo::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
+ aMeshValue2.Allocate(aMeshValue.myNbElem,
+ aMeshValue.myNbGauss,
+ aMeshValue.myNbComp,
+ aMeshValue.myModeSwitch);
+ const typename TimeStampValueTypeFrom::TTMeshValue::TValue& aValue = aMeshValue.myValue;
+ typename TimeStampValueTypeTo::TTMeshValue::TValue& aValue2 = aMeshValue2.myValue;
+ TInt aSize = aValue.size();
+ for(TInt anId = 0; anId < aSize; anId++)
+ aValue2[anId] = TElementTo(aValue[anId]);
+ }
+ }
+
+ //---------------------------------------------------------------
+ template<class TMeshValueType>
+ void
+ CopyTimeStampValue(SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueFrom,
+ SharedPtr<TTimeStampValue<TMeshValueType> > theTimeStampValueTo)
+ {
+ typedef TTimeStampValue<TMeshValueType> TimeStampValueType;
+ typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValueFrom->myGeom2Value;
+ typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
+ for(; anIter != aGeom2Value.end(); anIter++){
+ const EGeometrieElement& aGeom = anIter->first;
+ const typename TimeStampValueType::TTMeshValue& aMeshValue = *anIter->second;
+ typename TimeStampValueType::TTMeshValue& aMeshValue2 = theTimeStampValueTo->GetMeshValue(aGeom);
+ aMeshValue2 = aMeshValue;
+ }
+ }
+
+ //---------------------------------------------------------------
+ inline
+ void
+ CopyTimeStampValueBase(const PTimeStampValueBase& theValueFrom,
+ const PTimeStampValueBase& theValueTo)
+ {
+ if(theValueFrom->GetTypeChamp() == theValueTo->GetTypeChamp()){
+ if(theValueFrom->GetTypeChamp() == eFLOAT64)
+ CopyTimeStampValue<TFloatMeshValue>(theValueFrom, theValueTo);
+ else if(theValueFrom->GetTypeChamp() == eINT)
+ CopyTimeStampValue<TIntMeshValue>(theValueFrom, theValueTo);
+ }else{
+ if(theValueFrom->GetTypeChamp() == eFLOAT64 && theValueTo->GetTypeChamp() == eINT)
+ CopyTimeStampValue<TFloatMeshValue, TIntMeshValue>(theValueFrom, theValueTo);
+ else if(theValueFrom->GetTypeChamp() == eINT && theValueTo->GetTypeChamp() == eFLOAT64)
+ CopyTimeStampValue<TIntMeshValue, TFloatMeshValue>(theValueFrom, theValueTo);
+ }
+ }
+
+ //---------------------------------------------------------------
+ // Backward compatibility declarations
+ typedef TFloatTimeStampValue TTimeStampVal;
+ typedef PFloatTimeStampValue PTimeStampVal;
+
+ //---------------------------------------------------------------
+ typedef std::map<TInt,TFloatVector> TIndexes;
+ typedef std::map<TInt,TString> TNames;
+
+ //---------------------------------------------------------------
+ //! Define a base class which represents MED Grille (structured mesh)
+ struct MEDWRAPPER_EXPORT TGrilleInfo:
+ virtual TModeSwitchInfo
+ {
+ PMeshInfo myMeshInfo;
+ const PMeshInfo& GetMeshInfo() const { return myMeshInfo; }
+
+ TNodeCoord myCoord; //!< Contains all nodal coordinates, now used only for eGRILLE_STANDARD
+ //! Gives coordinates for mesh nodes (const version)
+ const TNodeCoord& GetNodeCoord() const;
+ TNodeCoord& GetNodeCoord();
+ //! Gives coordinates for mesh node by its number, array index from 0
+ TNodeCoord GetCoord(TInt theId);
+ //! Gives ids of nodes for mesh cell or sub-cell by its number, array index from 0
+ TIntVector GetConn(TInt theId, const bool isSub=false);
+
+ EGrilleType myGrilleType; //!< Defines grille type (eGRILLE_CARTESIENNE,eGRILLE_POLAIRE,eGRILLE_STANDARD)
+ //!Gets grille type (const version)
+ const EGrilleType& GetGrilleType() const;
+ //!Gets grille type
+ EGrilleType GetGrilleType();
+ //!Sets grille type
+ void SetGrilleType(EGrilleType theGrilleType);
+
+ TString myCoordNames; //!< Contains names for the coordinate dimensions
+ //! Get name of the coordinate dimension by its order number
+ virtual std::string GetCoordName(TInt theId) const = 0 ;
+ //! Set name of the coordinate dimension by its order number
+ virtual void SetCoordName(TInt theId, const std::string& theValue) = 0;
+
+ TString myCoordUnits; //!< Contains units for the coordinate dimensions
+ //! Get name of unit for the coordinate dimension by its order number
+ virtual std::string GetCoordUnit(TInt theId) const = 0;
+ //! Set name of unit for the coordinate dimension by its order number
+ virtual void SetCoordUnit(TInt theId, const std::string& theValue) = 0;
+
+ //! Map of index of axes and Table of indexes for certain axe, now used for eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
+ TIndexes myIndixes;
+ //!Gets a map of Tables (const version)
+ const TIndexes& GetMapOfIndexes() const ;
+ //!Gets a map of Tables
+ TIndexes& GetMapOfIndexes();
+ //!Gets a Table of indexes for certain axe(const version)
+ const TFloatVector& GetIndexes(TInt theAxisNumber) const;
+ //!Gets a Table of indexes for certain axe
+ TFloatVector& GetIndexes(TInt theAxisNumber);
+ //!Gets a number of indices per axe
+ TInt GetNbIndexes(TInt theAxisNumber);
+
+ TInt GetNbNodes();//! Return count of all points
+ TInt GetNbCells();//! Return count of all cells
+ TInt GetNbSubCells();//! Return count of all entities of <mesh dimension-1>
+ EGeometrieElement GetGeom();//! Return geometry of cells (calculated from mesh dimension)
+ EGeometrieElement GetSubGeom();//! Return geometry of subcells (calculated from mesh dimension)
+ EEntiteMaillage GetEntity();//! Return entity (eMAILLE)
+ EEntiteMaillage GetSubEntity();//! Return sub entity
+
+ /*!
+ *Vector of grille structure (Example: {3,4,5}, 3 nodes in X axe, 4 nodes in Y axe, ...)
+ */
+ TIntVector myGrilleStructure;
+ //!Gets grille structure(const version)
+ const TIntVector& GetGrilleStructure() const;
+ //!Gets grille structure
+ TIntVector GetGrilleStructure();
+ //!Sets the grille structure of theAxis axe to theNb.
+ void SetGrilleStructure(TInt theAxis,TInt theNb);
+
+ /*!
- *Defines sequence MED Family indexes for sub entites
++ *Defines sequence MED Family indexes for corresponding mesh entities
+ */
+ TElemNum myFamNum;
+ //! Get number of a MED FAMILY by order number of the mesh element
+ TInt GetFamNum(TInt theId) const;
+ //! Set number of a MED FAMILY for the mesh element with the order number
+ void SetFamNum(TInt theId, TInt theVal);
+
+ /*!
++ *Defines sequence MED Family indexes for sub entities
+ */
+ TElemNum myFamSubNum;
+ //! Get number of a MED FAMILY by order number of sub element
+ TInt GetFamSubNum(TInt theId) const;
+ //! Set number of a MED FAMILY for theId-th sub element
+ void SetFamSubNum(TInt theId, TInt theVal);
+
+ /*!
+ *Defines sequence MED Family indexes for corresponding mesh nodes
+ */
+ TElemNum myFamNumNode;
+ //! Get number of a MED FAMILY by order number of the mesh node
+ TInt GetFamNumNode(TInt theId) const;
+ //! Set number of a MED FAMILY for the mesh node with the order number
+ void SetFamNumNode(TInt theId, TInt theVal);
+ };
+}
+
+#endif // MED_Structures_HeaderFile
--- /dev/null
-
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef MED_TStructures_HeaderFile
+#define MED_TStructures_HeaderFile
+
+#include "MED_Structures.hxx"
+
+#ifdef WIN32
+#pragma warning(disable:4250)
+#endif
++#include <utilities.h>
+namespace MED
+{
+ //---------------------------------------------------------------
+ //! To provide a common way to handle values of MEDWrapper types as native MED types
+ template<class TValue, class TRepresentation>
+ struct TValueHolder
+ {
+ TValue& myValue;
+ TRepresentation myRepresentation;
+
+ TValueHolder(TValue& theValue):
+ myValue(theValue),
+ myRepresentation(TRepresentation(theValue))
+ {}
+
+ ~TValueHolder()
+ {
+ myValue = TValue(myRepresentation);
+ }
+
+ TRepresentation*
+ operator& ()
+ {
+ return &myRepresentation;
+ }
+
+ operator TRepresentation () const
+ {
+ return myRepresentation;
+ }
+
+ const TValue&
+ operator() () const
+ {
+ return myValue;
+ }
+ };
+
+ //! To customize TValueHolder common template definition for TVector
+ template<class TVal, class TRepresentation>
+ struct TValueHolder<TVector<TVal>, TRepresentation>
+ {
+ typedef TVector<TVal> TValue;
+ TValue& myValue;
+ TRepresentation* myRepresentation;
+
+ TValueHolder(TValue& theValue):
+ myValue(theValue)
+ {
+ if(theValue.empty())
+ myRepresentation = (TRepresentation*)NULL;
+ else
+ myRepresentation = (TRepresentation*)&theValue[0];
+ }
+
+ TRepresentation*
+ operator& ()
+ {
+ return myRepresentation;
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTNameInfo: virtual TNameInfo
+ {
+ TTNameInfo(const std::string& theValue)
+ {
+ myName.resize(GetNOMLength()+1);
+ SetName(theValue);
+ }
+
+ virtual
+ std::string
+ GetName() const
+ {
+ return GetString(0, GetNOMLength(), myName);
+ }
+
+ virtual
+ void
+ SetName(const std::string& theValue)
+ {
+ SetString(0, GetNOMLength(), myName, theValue);
+ }
+
+ virtual
+ void
+ SetName(const TString& theValue)
+ {
+ SetString(0, GetNOMLength(), myName, theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTMeshInfo:
+ virtual TMeshInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTMeshInfo(const PMeshInfo& theInfo):
+ TNameInfoBase(theInfo->GetName())
+ {
+ myDim = theInfo->GetDim();
+ mySpaceDim = theInfo->GetSpaceDim();
+ myType = theInfo->GetType();
+
+ myDesc.resize(GetDESCLength()+1);
+ SetDesc(theInfo->GetDesc());
+ }
+
+ TTMeshInfo(TInt theDim, TInt theSpaceDim,
+ const std::string& theValue,
+ EMaillage theType,
+ const std::string& theDesc):
+ TNameInfoBase(theValue)
+ {
+ myDim = theDim;
+ mySpaceDim = theSpaceDim;
+ myType = theType;
+
+ myDesc.resize(GetDESCLength()+1);
+ SetDesc(theDesc);
+ }
+
+ virtual
+ std::string
+ GetDesc() const
+ {
+ return GetString(0, GetDESCLength(), myDesc);
+ }
+
+ virtual
+ void
+ SetDesc(const std::string& theValue)
+ {
+ SetString(0, GetDESCLength(), myDesc, theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTFamilyInfo:
+ virtual TFamilyInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTFamilyInfo(const PMeshInfo& theMeshInfo, const PFamilyInfo& theInfo):
+ TNameInfoBase(theInfo->GetName())
+ {
+ myMeshInfo = theMeshInfo;
+
+ myId = theInfo->GetId();
+
+ myNbGroup = theInfo->GetNbGroup();
+ myGroupNames.resize(myNbGroup*GetLNOMLength()+1);
+ if(myNbGroup){
+ for(TInt anId = 0; anId < myNbGroup; anId++){
+ SetGroupName(anId,theInfo->GetGroupName(anId));
+ }
+ }
+
+ myNbAttr = theInfo->GetNbAttr();
+ myAttrId.resize(myNbAttr);
+ myAttrVal.resize(myNbAttr);
+ myAttrDesc.resize(myNbAttr*GetDESCLength()+1);
+ if(myNbAttr){
+ for(TInt anId = 0; anId < myNbAttr; anId++){
+ SetAttrDesc(anId,theInfo->GetAttrDesc(anId));
+ myAttrVal[anId] = theInfo->GetAttrVal(anId);
+ myAttrId[anId] = theInfo->GetAttrId(anId);
+ }
+ }
+ }
+
+ TTFamilyInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbGroup,
+ TInt theNbAttr,
+ TInt theId,
+ const std::string& theValue):
+ TNameInfoBase(theValue)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myId = theId;
+
+ myNbGroup = theNbGroup;
+ myGroupNames.resize(theNbGroup*GetLNOMLength()+1);
+
+ myNbAttr = theNbAttr;
+ myAttrId.resize(theNbAttr);
+ myAttrVal.resize(theNbAttr);
+ myAttrDesc.resize(theNbAttr*GetDESCLength()+1);
+ }
+
+ TTFamilyInfo(const PMeshInfo& theMeshInfo,
+ const std::string& theValue,
+ TInt theId,
+ const TStringSet& theGroupNames,
+ const TStringVector& theAttrDescs,
+ const TIntVector& theAttrIds,
+ const TIntVector& theAttrVals):
+ TNameInfoBase(theValue)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myId = theId;
+
+ myNbGroup = (TInt)theGroupNames.size();
+ myGroupNames.resize(myNbGroup*GetLNOMLength()+1);
+ if(myNbGroup){
+ TStringSet::const_iterator anIter = theGroupNames.begin();
+ for(TInt anId = 0; anIter != theGroupNames.end(); anIter++, anId++){
+ const std::string& aVal = *anIter;
+ SetGroupName(anId,aVal);
+ }
+ }
+
+ myNbAttr = (TInt)theAttrDescs.size();
+ myAttrId.resize(myNbAttr);
+ myAttrVal.resize(myNbAttr);
+ myAttrDesc.resize(myNbAttr*GetDESCLength()+1);
+ if(myNbAttr){
+ for(TInt anId = 0, anEnd = (TInt)theAttrDescs.size(); anId < anEnd; anId++){
+ SetAttrDesc(anId,theAttrDescs[anId]);
+ myAttrVal[anId] = theAttrVals[anId];
+ myAttrId[anId] = theAttrIds[anId];
+ }
+ }
+ }
+
+ virtual
+ std::string
+ GetGroupName(TInt theId) const
+ {
+ return GetString(theId, GetLNOMLength(), myGroupNames);
+ }
+
+ virtual
+ void
+ SetGroupName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId, GetLNOMLength(), myGroupNames, theValue);
+ }
+
+ virtual
+ std::string
+ GetAttrDesc(TInt theId) const
+ {
+ return GetString(theId, GetDESCLength(), myAttrDesc);
+ }
+
+ virtual
+ void
+ SetAttrDesc(TInt theId, const std::string& theValue)
+ {
+ SetString(theId, GetDESCLength(), myAttrDesc, theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTElemInfo: virtual TElemInfo
+ {
+ TTElemInfo(const PMeshInfo& theMeshInfo, const PElemInfo& theInfo)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbElem = theInfo->GetNbElem();
+ myFamNum.reset(new TElemNum(myNbElem));
+ myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
+
+ myIsElemNum = theInfo->IsElemNum();
+ if(theInfo->IsElemNum())
+ myElemNum.reset(new TElemNum(myNbElem));
+ else
+ myElemNum.reset(new TElemNum());
+
+ myIsElemNames = theInfo->IsElemNames();
+ if(theInfo->IsElemNames())
+ myElemNames.reset(new TString(myNbElem*GetPNOMLength() + 1));
+ else
+ myElemNames.reset(new TString());
+
+ if(theInfo->GetNbElem()){
+ for(TInt anId = 0; anId < myNbElem; anId++){
+ SetFamNum(anId, theInfo->GetFamNum(anId));
+ }
+ if(theInfo->IsElemNum() == eVRAI){
+ for(TInt anId = 0; anId < myNbElem; anId++){
+ SetElemNum(anId, theInfo->GetElemNum(anId));
+ }
+ }
+ if(theInfo->IsElemNames() == eVRAI){
+ for(TInt anId = 0; anId < myNbElem; anId++){
+ SetElemName(anId,theInfo->GetElemName(anId));
+ }
+ }
+ }
+ }
+
+ TTElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbElem = theNbElem;
+ myFamNum.reset(new TElemNum(theNbElem));
+ myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
+
+ myIsElemNum = theIsElemNum;
+ if(theIsElemNum)
+ myElemNum.reset(new TElemNum(theNbElem));
+ else
+ myElemNum.reset(new TElemNum());
+
+ myIsElemNames = theIsElemNames;
+ if(theIsElemNames)
+ myElemNames.reset(new TString(theNbElem*GetPNOMLength() + 1));
+ else
+ myElemNames.reset(new TString());
+ }
+
+ TTElemInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbElem = theNbElem;
+ myFamNum.reset(new TElemNum(theNbElem));
+ myIsFamNum = eFAUX; // is set to eVRAI in SetFamNum()
+
+ myIsElemNum = theElemNums.size()? eVRAI: eFAUX;
+ if(myIsElemNum)
+ myElemNum.reset(new TElemNum(theNbElem));
+ else
+ myElemNum.reset(new TElemNum());
+
+ myIsElemNames = theElemNames.size()? eVRAI: eFAUX;
+ if(myIsElemNames)
+ myElemNames.reset(new TString(theNbElem*GetPNOMLength() + 1));
+ else
+ myElemNames.reset(new TString());
+
+ if(theNbElem){
+
+ if(theFamilyNums.size())
+ *myFamNum = theFamilyNums;
+
+ if(myIsElemNum)
+ *myElemNum = theElemNums;
+
+ if(myIsElemNames){
+ for(TInt anId = 0; anId < theNbElem; anId++){
+ const std::string& aVal = theElemNames[anId];
+ SetElemName(anId,aVal);
+ }
+ }
+ }
+ }
+
+ virtual
+ std::string
+ GetElemName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(), *myElemNames);
+ }
+
+ virtual
+ void
+ SetElemName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(), *myElemNames, theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTNodeInfo:
+ virtual TNodeInfo,
+ virtual TTElemInfo
+ {
+ typedef TTElemInfo TElemInfoBase;
+
+ TTNodeInfo(const PMeshInfo& theMeshInfo, const PNodeInfo& theInfo):
+ TNodeInfo(theInfo),
+ TElemInfoBase(theMeshInfo, theInfo)
+ {
+ myModeSwitch = theInfo->GetModeSwitch();
+
+ mySystem = theInfo->GetSystem();
+
+ myCoord.reset(new TNodeCoord(*theInfo->myCoord));
+
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ for(TInt anId = 0; anId < aSpaceDim; anId++)
+ SetCoordName(anId,theInfo->GetCoordName(anId));
+
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1);
+ for(TInt anId = 0; anId < aSpaceDim; anId++)
+ SetCoordUnit(anId,theInfo->GetCoordUnit(anId));
+ }
+
+ TTNodeInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EModeSwitch theMode,
+ ERepere theSystem,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames):
+ TModeSwitchInfo(theMode),
+ TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ theIsElemNames)
+ {
+ mySystem = theSystem;
+
+ myCoord.reset(new TNodeCoord(theNbElem * theMeshInfo->mySpaceDim));
+
+ myCoordUnits.resize(theMeshInfo->mySpaceDim*GetPNOMLength()+1);
+
+ myCoordNames.resize(theMeshInfo->mySpaceDim*GetPNOMLength()+1);
+ }
+
+
+ TTNodeInfo(const PMeshInfo& theMeshInfo,
+ const TFloatVector& theNodeCoords,
+ EModeSwitch theMode,
+ ERepere theSystem,
+ const TStringVector& theCoordNames,
+ const TStringVector& theCoordUnits,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames):
+ TModeSwitchInfo(theMode),
+ TElemInfoBase(theMeshInfo,
+ (TInt)theNodeCoords.size()/theMeshInfo->GetDim(),
+ theFamilyNums,
+ theElemNums,
+ theElemNames)
+ {
+ mySystem = theSystem;
+
+ myCoord.reset(new TNodeCoord(theNodeCoords));
+
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ if(!theCoordNames.empty())
+ for(TInt anId = 0; anId < aSpaceDim; anId++)
+ SetCoordName(anId,theCoordNames[anId]);
+
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength() + 1);
+ if(!theCoordUnits.empty())
+ for(TInt anId = 0; anId < aSpaceDim; anId++)
+ SetCoordUnit(anId, theCoordUnits[anId]);
+ }
+
+ virtual
+ std::string
+ GetCoordName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCoordNames);
+ }
+
+ virtual
+ void
+ SetCoordName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCoordNames,theValue);
+ }
+
+ virtual
+ std::string
+ GetCoordUnit(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCoordUnits);
+ }
+
+ virtual
+ void
+ SetCoordUnit(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCoordUnits,theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTPolygoneInfo:
+ virtual TPolygoneInfo,
+ virtual TTElemInfo
+ {
+ typedef TTElemInfo TElemInfoBase;
+
+ TTPolygoneInfo(const PMeshInfo& theMeshInfo, const PPolygoneInfo& theInfo):
+ TElemInfoBase(theMeshInfo,theInfo)
+ {
+ myEntity = theInfo->GetEntity();
+ myGeom = theInfo->GetGeom();
+
+ myIndex.reset(new TElemNum(*theInfo->myIndex));
+ myConn.reset(new TElemNum(*theInfo->myConn));
+
+ myConnMode = theInfo->GetConnMode();
+ }
+
+ TTPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theConnSize,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames):
+ TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ theIsElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myIndex.reset(new TElemNum(theNbElem + 1));
+ myConn.reset(new TElemNum(theConnSize));
+
+ myConnMode = theConnMode;
+ }
+
+ TTPolygoneInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theIndexes,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames):
+ TElemInfoBase(theMeshInfo,
+ (TInt)theIndexes.size() - 1,
+ theFamilyNums,
+ theElemNums,
+ theElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myIndex.reset(new TElemNum(theIndexes));
+ myConn.reset(new TElemNum(theConnectivities));
+
+ myConnMode = theConnMode;
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTPolyedreInfo:
+ virtual TPolyedreInfo,
+ virtual TTElemInfo
+ {
+ typedef TTElemInfo TElemInfoBase;
+
+ TTPolyedreInfo(const PMeshInfo& theMeshInfo, const PPolyedreInfo& theInfo):
+ TElemInfoBase(theMeshInfo,theInfo)
+ {
+ myEntity = theInfo->GetEntity();
+ myGeom = theInfo->GetGeom();
+
+ myIndex.reset(new TElemNum(*theInfo->myIndex));
+ myFaces.reset(new TElemNum(*theInfo->myFaces));
+ myConn.reset(new TElemNum(*theInfo->myConn));
+
+ myConnMode = theInfo->GetConnMode();
+ }
+
+ TTPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theNbFaces,
+ TInt theConnSize,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames):
+ TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ theIsElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myIndex.reset(new TElemNum(theNbElem + 1));
+ myFaces.reset(new TElemNum(theNbFaces));
+ myConn.reset(new TElemNum(theConnSize));
+
+ myConnMode = theConnMode;
+ }
+
+ TTPolyedreInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theIndexes,
+ const TIntVector& theFaces,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames):
+ TElemInfoBase(theMeshInfo,
+ (TInt)theIndexes.size()-1,
+ theFamilyNums,
+ theElemNums,
+ theElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myIndex.reset(new TElemNum(theIndexes));
+ myFaces.reset(new TElemNum(theFaces));
+ myConn.reset(new TElemNum(theConnectivities));
+
+ myConnMode = theConnMode;
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTCellInfo:
+ virtual TCellInfo,
+ virtual TTElemInfo
+ {
+ typedef TTElemInfo TElemInfoBase;
+
+ TTCellInfo(const PMeshInfo& theMeshInfo, const PCellInfo& theInfo):
+ TElemInfoBase(theMeshInfo,theInfo)
+ {
+ myEntity = theInfo->GetEntity();
+ myGeom = theInfo->GetGeom();
+ myConnMode = theInfo->GetConnMode();
+
+ TInt aConnDim = GetNbNodes(myGeom);
+ TInt aNbConn = GetNbConn(myGeom, myEntity, myMeshInfo->myDim);
+ myConn.reset(new TElemNum(myNbElem * aNbConn));
+ for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
+ TConnSlice aConnSlice = GetConnSlice(anElemId);
+ TCConnSlice aConnSlice2 = theInfo->GetConnSlice(anElemId);
+ for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
+ aConnSlice[anConnId] = aConnSlice2[anConnId];
+ }
+ }
+ }
+
+ TTCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ TInt theNbElem,
+ EConnectivite theConnMode,
+ EBooleen theIsElemNum,
+ EBooleen theIsElemNames,
+ EModeSwitch theMode):
+ TModeSwitchInfo(theMode),
+ TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ theIsElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myConnMode = theConnMode;
+ TInt aNbConn = GetNbConn(theGeom, myEntity, theMeshInfo->myDim);
+ myConn.reset(new TElemNum(theNbElem * aNbConn));
+ }
+
+ TTCellInfo(const PMeshInfo& theMeshInfo,
+ EEntiteMaillage theEntity,
+ EGeometrieElement theGeom,
+ const TIntVector& theConnectivities,
+ EConnectivite theConnMode,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums,
+ const TStringVector& theElemNames,
+ EModeSwitch theMode):
+ TModeSwitchInfo(theMode),
+ TElemInfoBase(theMeshInfo,
+ (TInt)theConnectivities.size() / GetNbNodes(theGeom),
+ theFamilyNums,
+ theElemNums,
+ theElemNames)
+ {
+ myEntity = theEntity;
+ myGeom = theGeom;
+
+ myConnMode = theConnMode;
+ TInt aConnDim = GetNbNodes(myGeom);
+ TInt aNbConn = GetNbConn(myGeom, myEntity, myMeshInfo->myDim);
+ myConn.reset(new TElemNum(myNbElem * aNbConn));
+ for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){
+ TConnSlice aConnSlice = GetConnSlice(anElemId);
+ for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){
+ aConnSlice[anConnId] = theConnectivities[anElemId*aConnDim + anConnId];
+ }
+ }
+ }
+
+ virtual
+ TInt
+ GetConnDim() const
+ {
+ return GetNbConn(myGeom, myEntity, myMeshInfo->myDim);
+ }
+
+ };
+
+ //---------------------------------------------------------------
+ struct TTBallInfo:
+ virtual TBallInfo,
+ virtual TTCellInfo
+ {
+ typedef TTCellInfo TCellInfoBase;
+
+ TTBallInfo(const PMeshInfo& theMeshInfo, const PBallInfo& theInfo):
+ TCellInfoBase::TElemInfoBase(theMeshInfo, theInfo),
+ TCellInfoBase(theMeshInfo,theInfo)
+ {
+ myDiameters = theInfo->myDiameters;
+ }
+
+ TTBallInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbElem,
+ EBooleen theIsElemNum ):
+ TCellInfoBase::TElemInfoBase(theMeshInfo,
+ theNbElem,
+ theIsElemNum,
+ /*theIsElemNames=*/eFAUX),
+ TCellInfoBase(theMeshInfo,
+ eSTRUCT_ELEMENT,
+ eBALL,
+ theNbElem,
+ /*EConnectivite=*/eNOD,
+ theIsElemNum,
+ /*theIsElemNames=*/eFAUX,
+ eFULL_INTERLACE)
+ {
+ myDiameters.resize( theNbElem );
+ }
+
+ TTBallInfo(const PMeshInfo& theMeshInfo,
+ const TIntVector& theNodes,
+ TFloatVector& theDiameters,
+ const TIntVector& theFamilyNums,
+ const TIntVector& theElemNums):
+ TCellInfoBase::TElemInfoBase(theMeshInfo,
+ (TInt)std::max(theNodes.size(),theDiameters.size() ),
+ theFamilyNums,
+ theElemNums,
+ TStringVector()),
+ TCellInfoBase(theMeshInfo,
+ eSTRUCT_ELEMENT,
+ eBALL,
+ theNodes,
+ /*EConnectivite=*/eNOD,
+ theFamilyNums,
+ theElemNums,
+ TStringVector(),
+ eFULL_INTERLACE)
+ {
+ myDiameters.swap( theDiameters );
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTFieldInfo:
+ virtual TFieldInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTFieldInfo(const PMeshInfo& theMeshInfo, const PFieldInfo& theInfo):
+ TNameInfoBase(theInfo->GetName())
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbComp = theInfo->GetNbComp();
+ myCompNames.resize(myNbComp*GetPNOMLength()+1);
+ for(TInt anId = 0; anId < myNbComp; anId++){
+ SetCompName(anId,theInfo->GetCompName(anId));
+ }
+
+ myUnitNames.resize(myNbComp*GetPNOMLength()+1);
+ for(TInt anId = 0; anId < myNbComp; anId++){
+ SetUnitName(anId,theInfo->GetUnitName(anId));
+ }
+
+ myType = theInfo->GetType();
+
+ myIsLocal = theInfo->GetIsLocal();
+ myNbRef = theInfo->GetNbRef();
+ }
+
+ TTFieldInfo(const PMeshInfo& theMeshInfo,
+ TInt theNbComp,
+ ETypeChamp theType,
+ const std::string& theValue,
+ EBooleen theIsLocal,
+ TInt theNbRef):
+ TNameInfoBase(theValue)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myNbComp = theNbComp;
+ myCompNames.resize(theNbComp*GetPNOMLength()+1);
+ myUnitNames.resize(theNbComp*GetPNOMLength()+1);
+
+ myType = theType;
+
+ myIsLocal = theIsLocal;
+ myNbRef = theNbRef;
+ }
+
+ virtual
+ std::string
+ GetCompName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCompNames);
+ }
+
+ virtual
+ void
+ SetCompName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCompNames,theValue);
+ }
+
+ virtual
+ std::string
+ GetUnitName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myUnitNames);
+ }
+
+ virtual
+ void
+ SetUnitName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myUnitNames,theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTGaussInfo:
+ virtual TGaussInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTGaussInfo(const TGaussInfo::TInfo& theInfo,
+ EModeSwitch theMode):
+ TModeSwitchInfo(theMode),
+ TNameInfoBase(boost::get<1>(boost::get<0>(theInfo)))
+ {
+ const TGaussInfo::TKey& aKey = boost::get<0>(theInfo);
+
+ myGeom = boost::get<0>(aKey);
+ myRefCoord.resize(GetNbRef()*GetDim());
+
+ TInt aNbGauss = boost::get<1>(theInfo);
+ myGaussCoord.resize(aNbGauss*GetDim());
+ myWeight.resize(aNbGauss);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTTimeStampInfo: virtual TTimeStampInfo
+ {
+ TTTimeStampInfo(const PFieldInfo& theFieldInfo, const PTimeStampInfo& theInfo)
+ {
+ myFieldInfo = theFieldInfo;
+
+ myEntity = theInfo->GetEntity();
+ myGeom2Size = theInfo->GetGeom2Size();
+
+ myNumDt = theInfo->GetNumDt();
+ myNumOrd = theInfo->GetNumOrd();
+ myDt = theInfo->GetDt();
+
+ myUnitDt.resize(GetPNOMLength()+1);
+ SetUnitDt(theInfo->GetUnitDt());
+
+ myGeom2NbGauss = theInfo->myGeom2NbGauss;
+ myGeom2Gauss = theInfo->GetGeom2Gauss();
+ }
+
+ TTTimeStampInfo(const PFieldInfo& theFieldInfo,
+ EEntiteMaillage theEntity,
+ const TGeom2Size& theGeom2Size,
+ const TGeom2NbGauss& theGeom2NbGauss,
+ TInt theNumDt,
+ TInt theNumOrd,
+ TFloat theDt,
+ const std::string& theUnitDt,
+ const TGeom2Gauss& theGeom2Gauss)
+ {
+ myFieldInfo = theFieldInfo;
+
+ myEntity = theEntity;
+ myGeom2Size = theGeom2Size;
+
+ myNumDt = theNumDt;
+ myNumOrd = theNumDt;
+ myDt = theDt;
+
+ myUnitDt.resize(GetPNOMLength()+1);
+ SetUnitDt(theUnitDt);
+
+ myGeom2NbGauss = theGeom2NbGauss;
+ myGeom2Gauss = theGeom2Gauss;
+ }
+
+ virtual
+ std::string
+ GetUnitDt() const
+ {
+ return GetString(0,GetPNOMLength(),myUnitDt);
+ }
+
+ virtual
+ void
+ SetUnitDt(const std::string& theValue)
+ {
+ SetString(0,GetPNOMLength(),myUnitDt,theValue);
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTProfileInfo:
+ virtual TProfileInfo,
+ virtual TTNameInfo
+ {
+ typedef TTNameInfo TNameInfoBase;
+
+ TTProfileInfo(const TProfileInfo::TInfo& theInfo,
+ EModeProfil theMode):
+ TNameInfoBase(boost::get<0>(theInfo))
+ {
+ TInt aSize = boost::get<1>(theInfo);
+ myElemNum.reset(new TElemNum(aSize));
+ myMode = aSize > 0? theMode: eNO_PFLMOD;
+ }
+ };
+
+ //---------------------------------------------------------------
+ template<class TMeshValueType>
+ struct TTTimeStampValue: virtual TTimeStampValue<TMeshValueType>
+ {
+ TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ const PTimeStampValueBase& theInfo,
+ ETypeChamp theTypeChamp)
+ {
+ typedef TTimeStampValue<TMeshValueType> TCompatible;
+ if(TCompatible* aCompatible = dynamic_cast<TCompatible*>(theInfo.get())){
+ this->myTimeStampInfo = theTimeStampInfo;
+ this->myTypeChamp = theTypeChamp;
+ this->myGeom2Profile = aCompatible->GetGeom2Profile();
+ this->myGeom2Value = aCompatible->myGeom2Value;
+ this->myGeomSet = aCompatible->GetGeomSet();
+ }else
+ EXCEPTION(std::runtime_error,"TTTimeStampValue::TTTimeStampValue - use incompatible arguments!");
+ }
+
+ TTTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
+ ETypeChamp theTypeChamp,
+ const TGeom2Profile& theGeom2Profile,
+ EModeSwitch theMode):
+ TModeSwitchInfo(theMode)
+ {
+ this->myTimeStampInfo = theTimeStampInfo;
+
+ this->myTypeChamp = theTypeChamp;
+
+ this->myGeom2Profile = theGeom2Profile;
+
+ TInt aNbComp = theTimeStampInfo->myFieldInfo->myNbComp;
+
+ const TGeom2Size& aGeom2Size = theTimeStampInfo->GetGeom2Size();
+ TGeom2Size::const_iterator anIter = aGeom2Size.begin();
+ for(; anIter != aGeom2Size.end(); anIter++){
+ const EGeometrieElement& aGeom = anIter->first;
+ TInt aNbElem = anIter->second;
+
+ MED::PProfileInfo aProfileInfo;
+ MED::TGeom2Profile::const_iterator anIter = theGeom2Profile.find(aGeom);
+ if(anIter != theGeom2Profile.end())
+ aProfileInfo = anIter->second;
+
+ if(aProfileInfo && aProfileInfo->IsPresent())
+ aNbElem = aProfileInfo->GetSize();
+
+ TInt aNbGauss = theTimeStampInfo->GetNbGauss(aGeom);
+
+ this->GetMeshValue(aGeom).Allocate(aNbElem,aNbGauss,aNbComp);
+ }
+ }
+
+ virtual
+ size_t
+ GetValueSize(EGeometrieElement theGeom) const
+ {
+ return this->GetMeshValue(theGeom).GetSize();
+ }
+
+ virtual
+ size_t
+ GetNbVal(EGeometrieElement theGeom) const
+ {
+ return this->GetMeshValue(theGeom).GetNbVal();
+ }
+
+ virtual
+ size_t
+ GetNbGauss(EGeometrieElement theGeom) const
+ {
+ return this->GetMeshValue(theGeom).GetNbGauss();
+ }
+
+ virtual
+ void
+ AllocateValue(EGeometrieElement theGeom,
+ TInt theNbElem,
+ TInt theNbGauss,
+ TInt theNbComp,
+ EModeSwitch theMode = eFULL_INTERLACE)
+ {
+ this->GetMeshValue(theGeom).Allocate(theNbElem,theNbGauss,theNbComp,theMode);
+ }
+
+ virtual
+ unsigned char*
+ GetValuePtr(EGeometrieElement theGeom)
+ {
+ return this->GetMeshValue(theGeom).GetValuePtr();
+ }
+ };
+
+ //---------------------------------------------------------------
+ struct TTGrilleInfo:
+ virtual TGrilleInfo
+ {
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ const PGrilleInfo& theInfo)
+ {
+ myMeshInfo = theMeshInfo;
+
+ myCoord = theInfo->GetNodeCoord();
+
+ myGrilleType = theInfo->GetGrilleType();
+
+ myCoordNames = theInfo->myCoordNames;
+
+ myCoordUnits = theInfo->myCoordUnits;
+
+ myIndixes = theInfo->GetMapOfIndexes();
+
+ myGrilleStructure = theInfo->GetGrilleStructure();
+
+ myGrilleType = theInfo->GetGrilleType();
+
+ myFamNumNode.resize(theInfo->GetNbNodes());
+ myFamNumNode = theInfo->myFamNumNode;
+
+ myFamNum = theInfo->myFamNum;
+ }
+
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type,
+ const TInt nnoeuds)
+ {
+ myMeshInfo = theMeshInfo;
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+ if(type == eGRILLE_STANDARD){
+ myCoord.resize(aSpaceDim*nnoeuds);
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1);
+ } else { //if(type == eGRILLE_CARTESIENNE){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ }
+ myGrilleStructure.resize(aSpaceDim);
+ myFamNumNode.resize(nnoeuds);
+ }
+
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type)
+ {
+ myMeshInfo = theMeshInfo;
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+ if(type == eGRILLE_STANDARD){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1);
+ } else {// if(type == eGRILLE_CARTESIENNE){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ }
+ myGrilleStructure.resize(aSpaceDim);
+ }
+
+ TTGrilleInfo(const PMeshInfo& theMeshInfo,
+ const EGrilleType& type,
+ const MED::TIntVector& nbNodeVec)
+ {
+ myMeshInfo = theMeshInfo;
+
+ TInt aSpaceDim = theMeshInfo->GetSpaceDim();
+ if(type == eGRILLE_STANDARD){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+1);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+1);
+ } else {// if(type == eGRILLE_CARTESIENNE){
+ myCoordNames.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ myCoordUnits.resize(aSpaceDim*GetPNOMLength()+aSpaceDim);
+ }
+
+ if(type != eGRILLE_STANDARD)
+ for(unsigned int aAxe=0;aAxe<nbNodeVec.size();aAxe++){
+ myIndixes[aAxe].resize(nbNodeVec[aAxe]);
+ }
+ myGrilleStructure.resize(aSpaceDim);
+ }
+
+ virtual
+ std::string
+ GetCoordName(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCoordNames);
+ }
+
+ virtual
+ void
+ SetCoordName(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCoordNames,theValue);
+ }
+
+ virtual
+ std::string
+ GetCoordUnit(TInt theId) const
+ {
+ return GetString(theId,GetPNOMLength(),myCoordUnits);
+ }
+
+ virtual
+ void
+ SetCoordUnit(TInt theId, const std::string& theValue)
+ {
+ SetString(theId,GetPNOMLength(),myCoordUnits,theValue);
+ }
+ };
+}
+
+#endif // MED_TStructures_HeaderFile
#include "SMESH_TypeDefs.hxx"
#include "SMESH_subMesh.hxx"
- #include <Basics_OCCTVersion.hxx>
-
#include <BRepAdaptor_Curve.hxx>
#include <BRepLProp.hxx>
#include <BRep_Tool.hxx>
bool SMESH_Algo::Features::IsCompatible( const SMESH_Algo::Features& algo2 ) const
{
if ( _dim > algo2._dim ) return algo2.IsCompatible( *this );
- // algo2 is of highter dimension
+ // algo2 is of higher dimension
if ( _outElemTypes.empty() || algo2._inElemTypes.empty() )
return false;
bool compatible = true;
*/
//=============================================================================
-SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen)
- : SMESH_Hypothesis(hypId, studyId, gen)
+SMESH_Algo::SMESH_Algo (int hypId, SMESH_Gen * gen)
+ : SMESH_Hypothesis(hypId, gen)
{
_compatibleAllHypFilter = _compatibleNoAuxHypFilter = NULL;
_onlyUnaryInput = _requireDiscreteBoundary = _requireShape = true;
*/
//=============================================================================
-SMESH_0D_Algo::SMESH_0D_Algo(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Algo(hypId, studyId, gen)
+SMESH_0D_Algo::SMESH_0D_Algo(int hypId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, gen)
{
_shapeType = (1 << TopAbs_VERTEX);
_type = ALGO_0D;
}
-SMESH_1D_Algo::SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Algo(hypId, studyId, gen)
+SMESH_1D_Algo::SMESH_1D_Algo(int hypId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, gen)
{
_shapeType = (1 << TopAbs_EDGE);
_type = ALGO_1D;
}
-SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Algo(hypId, studyId, gen)
+SMESH_2D_Algo::SMESH_2D_Algo(int hypId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, gen)
{
_shapeType = (1 << TopAbs_FACE);
_type = ALGO_2D;
}
-SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_Algo(hypId, studyId, gen)
+SMESH_3D_Algo::SMESH_3D_Algo(int hypId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, gen)
{
_shapeType = (1 << TopAbs_SOLID);
_type = ALGO_3D;
//=============================================================================
SMESH_Mesh::SMESH_Mesh(int theLocalId,
- int theStudyId,
SMESH_Gen* theGen,
bool theIsEmbeddedMode,
SMESHDS_Document* theDocument):
{
if(MYDEBUG) MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
_id = theLocalId;
- _studyId = theStudyId;
_gen = theGen;
_myDocument = theDocument;
_myMeshDS = theDocument->NewMesh(theIsEmbeddedMode,theLocalId);
SMESH_Mesh::SMESH_Mesh():
_id(-1),
- _studyId(-1),
_groupId( 0 ),
_nbSubShapes( 0 ),
_isShapeToMesh( false ),
// remove self from studyContext
if ( _gen )
{
- StudyContextStruct * studyContext = _gen->GetStudyContext( _studyId );
+ StudyContextStruct * studyContext = _gen->GetStudyContext();
studyContext->mapMesh.erase( _id );
}
if ( _myDocument )
if ( _id == meshId )
return (SMESH_Mesh*) this;
- if ( StudyContextStruct *aStudyContext = _gen->GetStudyContext( _studyId ))
+ if ( StudyContextStruct *aStudyContext = _gen->GetStudyContext())
{
std::map < int, SMESH_Mesh * >::iterator i_m = aStudyContext->mapMesh.find( meshId );
if ( i_m != aStudyContext->mapMesh.end() )
Unexpect aCatch(SalomeException);
if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
- StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
+ StudyContextStruct *sc = _gen->GetStudyContext();
if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const int anHypId) const
{
- StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
+ StudyContextStruct *sc = _gen->GetStudyContext();
if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
return NULL;
* \param [in] theAutoGroups - boolean parameter for creating/not creating
* the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
* the typical use is auto_groups=false.
- * \param [in] theVersion - defines the version of format of MED file, that will be created
* \param [in] meshPart - mesh data to export
* \param [in] theAutoDimension - if \c true, a space dimension of a MED mesh can be either
* - 1D if all mesh nodes lie on OX coordinate axis, or
void SMESH_Mesh::ExportMED(const char * file,
const char* theMeshName,
bool theAutoGroups,
- int theVersion,
const SMESHDS_Mesh* meshPart,
bool theAutoDimension,
bool theAddODOnVertices,
bool theAllElemsToGroup)
throw(SALOME_Exception)
{
+ //MESSAGE("MED_VERSION:"<< theVersion);
SMESH_TRY;
DriverMED_W_SMESHDS_Mesh myWriter;
- myWriter.SetFile ( file, MED::EVersion(theVersion) );
+ myWriter.SetFile ( file );
myWriter.SetMesh ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
myWriter.SetAutoDimension( theAutoDimension );
myWriter.AddODOnVertices ( theAddODOnVertices );
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
cmd += "\"";
system(cmd.c_str());
- ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, /*theVersion=*/1,
+ ExportMED(medfilename.c_str(), theMeshName, theAutoGroups,
/*meshPart=*/NULL, /*theAutoDimension=*/false, /*theAddODOnVertices=*/false,
/*theAllElemsToGroup=*/true ); // theAllElemsToGroup is for PAL0023413
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import convert ; convert(r'" + medfilename + "', 'MED', 'GIBI', 1, r'" + file + "')";
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
myWriter.SetMeshId(_id);
// myWriter.SetGroups(_mapGroup);
+ // pass group names to SMESHDS
if ( !meshPart )
{
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
void SMESH_Mesh::ExportCGNS(const char * file,
const SMESHDS_Mesh* meshDS,
- const char * meshName)
+ const char * meshName,
+ const bool groupElemsByType)
{
int res = Driver_Mesh::DRS_FAIL;
+
+ // pass group names to SMESHDS
+ for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
+ SMESH_Group* group = it->second;
+ SMESHDS_GroupBase* groupDS = group->GetGroupDS();
+ if ( groupDS ) {
+ string groupName = group->GetName();
+ groupDS->SetStoreName( groupName.c_str() );
+ }
+ }
#ifdef WITH_CGNS
+
DriverCGNS_Write myWriter;
myWriter.SetFile( file );
myWriter.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
myWriter.SetMeshName( SMESH_Comment("Mesh_") << meshDS->GetPersistentId());
if ( meshName && meshName[0] )
myWriter.SetMeshName( meshName );
+ myWriter.SetElementsByType( groupElemsByType );
res = myWriter.Perform();
+ if ( res != Driver_Mesh::DRS_OK )
+ {
+ SMESH_ComputeErrorPtr err = myWriter.GetError();
+ if ( err && !err->IsOK() && !err->myComment.empty() )
+ throw SALOME_Exception(("Export failed: " + err->myComment ).c_str() );
+ }
+
#endif
if ( res != Driver_Mesh::DRS_OK )
throw SALOME_Exception("Export failed");
return _myMeshDS->GetMeshInfo().NbPrisms(order);
}
+ int SMESH_Mesh::NbQuadPrisms() const throw (SALOME_Exception)
+ {
+ Unexpect aCatch(SalomeException);
+ return _myMeshDS->GetMeshInfo().NbQuadPrisms();
+ }
+
+ int SMESH_Mesh::NbBiQuadPrisms() const throw (SALOME_Exception)
+ {
+ Unexpect aCatch(SalomeException);
+ return _myMeshDS->GetMeshInfo().NbBiQuadPrisms();
+ }
+
+
//================================================================================
/*!
* \brief Return number of hexagonal prisms in the mesh
save << clause << ".3) Faces in detail: " << endl;
map <int,int>::iterator itF;
for (itF = myFaceMap.begin(); itF != myFaceMap.end(); itF++)
- save << "--> nb nodes: " << itF->first << " - nb elemens:\t" << itF->second << endl;
+ save << "--> nb nodes: " << itF->first << " - nb elements:\t" << itF->second << endl;
}
}
save << ++clause << ") Total number of " << orderStr << " volumes:\t" << NbVolumes(order) << endl;
save << clause << ".5) Volumes in detail: " << endl;
map <int,int>::iterator itV;
for (itV = myVolumesMap.begin(); itV != myVolumesMap.end(); itV++)
- save << "--> nb nodes: " << itV->first << " - nb elemens:\t" << itV->second << endl;
+ save << "--> nb nodes: " << itV->first << " - nb elements:\t" << itV->second << endl;
}
}
save << endl;
{
public:
SMESH_Mesh(int theLocalId,
- int theStudyId,
SMESH_Gen* theGen,
bool theIsEmbeddedMode,
SMESHDS_Document* theDocument);
void ExportMED(const char * theFile,
const char* theMeshName = NULL,
bool theAutoGroups = true,
- int theVersion = 0,
const SMESHDS_Mesh* theMeshPart = 0,
bool theAutoDimension = false,
bool theAddODOnVertices = false,
const SMESHDS_Mesh* meshPart = 0) throw(SALOME_Exception);
void ExportCGNS(const char * file,
const SMESHDS_Mesh* mesh,
- const char * meshName = 0);
+ const char * meshName = 0,
+ const bool groupElemsByType = false);
void ExportGMF(const char * file,
const SMESHDS_Mesh* mesh,
bool withRequiredGroups = true );
int NbTriQuadraticHexas() const throw(SALOME_Exception);
int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
int NbPrisms(SMDSAbs_ElementOrder order = ORDER_ANY) const throw(SALOME_Exception);
+ int NbQuadPrisms() const throw(SALOME_Exception);
+ int NbBiQuadPrisms() const throw(SALOME_Exception);
int NbHexagonalPrisms() const throw(SALOME_Exception);
int NbPolyhedrons() const throw(SALOME_Exception);
protected:
int _id; // id given by creator (unique within the creator instance)
- int _studyId;
int _groupId; // id generator for group objects
int _nbSubShapes; // initial nb of subshapes in the shape to mesh
bool _isShapeToMesh;// set to true when a shape is given (only once)
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
#include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
#include CORBA_CLIENT_HEADER(SMESH_Measurements)
+ #include CORBA_CLIENT_HEADER(SMESH_Mesh)
// Qt includes
// #define INCLUDE_MENUITEM_DEF // VSR commented ????????
void ExportMeshToFile(int theCommandID);
- void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
+ void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
void SetDisplayEntity(int theCommandID);
}
else if ( theCommandID == SMESHOp::OpImportSAUV ||
theCommandID == SMESHOp::OpPopupImportSAUV ) {
- filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
- filter.append( QObject::tr( "All files (*)" ) );
+ filter.append( QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)" );
+ filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
}
else if ( theCommandID == SMESHOp::OpImportGMF ||
theCommandID == SMESHOp::OpPopupImportGMF ) {
if ( filenames.count() > 0 )
{
SUIT_OverrideCursor wc;
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
QStringList errors;
QStringList anEntryList;
notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
+ notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
"SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
"SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
"SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
+ "SMESH_BIQUADRATIC_PENTAHEDRONS",
"SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
};
// is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
// Get parameters of export operation
- QString aFilename;
- SMESH::MED_VERSION aFormat = SMESH::MED_LATEST;
+ QString aFilename;
// Init the parameters with the default values
bool aIsASCII_STL = true;
bool toCreateGroups = false;
}
else if ( isCGNS )// Export to CGNS
{
- SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
+ const char* theByTypeResource = "cgns_group_elems_by_type";
+ toCreateGroups = SMESHGUI::resourceMgr()->booleanValue( "SMESH", theByTypeResource, false );
+
+ QStringList checkBoxes;
+ checkBoxes << QObject::tr("CGNS_EXPORT_ELEMS_BY_TYPE");
+
+ SalomeApp_CheckFileDlg* fd =
+ new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
fd->setWindowTitle( aTitle );
fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
if ( !anInitialPath.isEmpty() )
fd->selectFile(aMeshName);
SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
fd->setValidator( fv );
+ fd->SetChecked( toCreateGroups, 0 );
if ( fd->exec() )
aFilename = fd->selectedFile();
- toOverwrite = fv->isOverwrite();
+ toOverwrite = fv->isOverwrite();
+ toCreateGroups = fd->IsChecked(0);
+ SMESHGUI::resourceMgr()->setValue("SMESH", theByTypeResource, toCreateGroups );
delete fd;
}
}
else if ( isMED || isSAUV ) // Export to MED or SAUV
{
- QMap<QString, SMESH::MED_VERSION> aFilterMap;
+ QStringList filters;
if ( isMED ) {
- QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
- aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
- int minor = v22.split(".").last().toInt();
- int vv= int(SMESH::MED_MINOR_0); // add all minor from 0 to current
- for (int ii=0; ii<minor; ii++)
- {
- QString vs = aMesh->GetVersionString(SMESH::MED_VERSION(vv), 2);
- aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", SMESH::MED_VERSION(vv));
- vv = vv +1;
- }
+ filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
}
else { // isSAUV
- aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
- aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
- aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
+ filters << QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)";
}
- QStringList filters;
- QString aDefaultFilter;
- QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
- for ( ; it != aFilterMap.end(); ++it ) {
- filters.push_back( it.key() );
- if (it.value() == SMESH::MED_V2_2)
- aDefaultFilter = it.key();
- }
QStringList checkBoxes;
checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
QList< QWidget* > wdgList;
- if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
+ if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
wdgList.append( fieldSelWdg );
SalomeApp_CheckFileDlg* fd =
new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
fd->setWindowTitle( aTitle );
fd->setNameFilters( filters );
- fd->selectNameFilter( aDefaultFilter );
fd->SetChecked( toCreateGroups, 0 );
fd->SetChecked( toFindOutDim, 1 );
if ( !anInitialPath.isEmpty() )
aFilename = QString::null;
break;
}
- aFormat = aFilterMap[fd->selectedNameFilter()];
toOverwrite = fv->isOverwrite();
is_ok = true;
if ( !aFilename.isEmpty() ) {
- // med-2.1 does not support poly elements
- if ( aFormat==SMESH::MED_V2_1 )
- for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
- SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
- SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
- if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
- nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
- {
- int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
- QObject::tr("SMESH_BUT_YES"),
- QObject::tr("SMESH_BUT_NO"), 0, 1);
- if (aRet != 0) {
- is_ok = false;
- break;
- }
- }
- }
if( !toOverwrite ) {
// can't append to an existing using other format
- SMESH::MED_VERSION aVersion = aFormat; //SMESH::MED_V2_1;
- bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
- if( !isVersionOk || aVersion != aFormat ) {
+ bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckCompatibility( aFilename.toUtf8().constData() );
+ if ( !isVersionOk ) {
int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
}
toCreateGroups = fd->IsChecked(0);
toFindOutDim = fd->IsChecked(1);
- fieldSelWdg->GetSelectedFeilds();
+ fieldSelWdg->GetSelectedFields();
if ( !fieldSelWdg->parent() )
delete fieldSelWdg;
delete fd;
const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
- aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
- aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
+ aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups,
+ toOverwrite && aMeshIndex == 0, toFindOutDim );
else
aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
- aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
+ toOverwrite && aMeshIndex == 0, toFindOutDim,
fields, geoAssFields.toLatin1().data() );
}
}
SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
aMeshItem->ExportCGNS( aMeshOrGroup,
aFilename.toUtf8().data(),
- toOverwrite && aMeshIndex == 0 );
+ toOverwrite && aMeshIndex == 0,
+ toCreateGroups );
}
}
else if ( isGMF )
type = QObject::tr( "LENGTH_EDGES" );
else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
type = QObject::tr( "LENGTH2D_EDGES" );
+ else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
+ type = QObject::tr( "DEFLECTION2D_FACES" );
else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
type = QObject::tr( "MULTI_BORDERS" );
else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
if ( selected.Extent() )
{
Handle(SALOME_InteractiveObject) anIObject = selected.First();
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
_PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
if (aSObj) {
if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
}
}
- void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
+ void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
{
SALOME_ListIO selected;
SalomeApp_Application* app =
return;
}
- _PTR(Study) aStudy = appStudy->studyDS();
-
aSel->selectedObjects( selected );
if ( selected.Extent() >= 1 )
break;
}
- SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
+ SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
// nodes: color, marker
dlg.setNodeColor( nodeColor );
if( markerType != VTK::MT_USER )
orientation3d = dlg.orientation3d();
shrinkCoef = dlg.shrinkCoef() / 100.;
- // store point markers map that might be changed by the user
- theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
+ // store point markers that might be changed by the user
+ theMarkerMap = dlg.customMarkers();
// set properties from dialog box to the presentations
SALOME_ListIteratorOfListIO It( selected );
anActor->SetMarkerStd( markerType, markerScale );
}
else {
- const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
- VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
- if ( iter != markerMap.end() )
+ VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
+ if ( iter != theMarkerMap.end() )
anActor->SetMarkerTexture( markerId, iter->second.second );
}
// volumes: normal color, reversed color (delta)
ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
+ ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
void Control( int theCommandID )
{
SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
SALOME_ListIO selected;
if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
if ( !anIDSrc->_is_nil() ) {
SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
if (( !anActor && selected.Extent() == 1 ) &&
- ( anActor = SMESH::CreateActor( aStudy, anIO->getEntry() )))
+ ( anActor = SMESH::CreateActor( anIO->getEntry() )))
{
anActor->SetControlMode( aControl );
SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
{
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
_PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
if (aSObj) {
_PTR(SComponent) aSComp = aSObj->GetFatherComponent();
LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
_PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
_PTR(GenericAttribute) anAttr;
_PTR(AttributeIOR) anIOR;
long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
- info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] +
+ info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
info[SMDSEntity_Polyhedra] +
info[SMDSEntity_Hexagonal_Prism];
long nbBalls = info[SMDSEntity_Ball];
smeshMod = dynamic_cast<SMESHGUI*>( module );
}
- if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
- {
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
- if ( study )
- {
- _PTR(Study) aStudy = study->studyDS();
- if ( aStudy )
- GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
- }
- }
-
return smeshMod;
}
return true;
}
-//=============================================================================
/*!
- *
- */
-//=============================================================================
-static int isStudyLocked(_PTR(Study) theStudy){
- return theStudy->GetProperties()->IsLocked();
-}
-
-static bool checkLock(_PTR(Study) theStudy) {
- if (isStudyLocked(theStudy)) {
- SUIT_MessageBox::warning( SMESHGUI::desktop(),
- QObject::tr("WRN_WARNING"),
- QObject::tr("WRN_STUDY_LOCKED") );
+ * \brief Verifies whether study of operation is locked
+ * \param theMess - specifies whether message box must be shown if study is locked
+ * \return State of study.
+*
+* Verifies whether study of operation is locked. If second parameter is TRUE and study
+* is locked when corresponding message box appears
+*/
+bool SMESHGUI::isStudyLocked( bool theMessage )
+{
+ if ( SMESH::getStudy()->GetProperties()->IsLocked() )
+ {
+ if ( theMessage )
+ SUIT_MessageBox::warning( SMESHGUI::desktop(),
+ QObject::tr( "WRN_WARNING" ),
+ QObject::tr( "WRN_STUDY_LOCKED" ) );
return true;
}
return false;
}
-//=======================================================================
-//function : CheckActiveStudyLocked
-//purpose :
-//=======================================================================
-
-bool SMESHGUI::isActiveStudyLocked()
-{
- _PTR(Study) aStudy = activeStudy()->studyDS();
- return checkLock( aStudy );
-}
-
//=============================================================================
/*!
*
if( !anApp )
return false;
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
SUIT_ResourceMgr* mgr = resourceMgr();
if( !mgr )
return false;
- if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
- GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
- }
-
SUIT_ViewWindow* view = application()->desktop()->activeWindow();
SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
switch (theCommandID) {
case SMESHOp::OpDelete:
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
OnEditDelete();
break;
case SMESHOp::OpImportDAT:
case SMESHOp::OpPopupImportSAUV:
case SMESHOp::OpPopupImportGMF:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
break;
}
case SMESHOp::OpUpdate:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
SUIT_OverrideCursor wc;
try {
- #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
- #endif
SMESH::UpdateView();
}
catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
}
// PAL13338 + PAL15161 -->
- if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !checkLock(aStudy)) {
+ if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
SMESH::UpdateView();
SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
}
case SMESHOp::OpNode:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
break;
case SMESHOp::OpCopyMesh:
{
- if (checkLock(aStudy)) break;
+ if (isStudyLocked()) break;
EmitSignalDeactivateDialog();
( new SMESHGUI_CopyMeshDlg( this ) )->show();
}
break;
case SMESHOp::OpBuildCompoundMesh:
{
- if (checkLock(aStudy)) break;
+ if (isStudyLocked()) break;
EmitSignalDeactivateDialog();
( new SMESHGUI_BuildCompoundDlg( this ) )->show();
}
break;
}
- if ( checkLock( aStudy ) )
+ if ( isStudyLocked() )
break;
/*Standard_Boolean aRes;
break;
}
- if ( checkLock( aStudy ) )
+ if ( isStudyLocked() )
break;
EmitSignalDeactivateDialog();
}
case SMESHOp::OpSmoothing:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_SmoothingDlg( this ) )->show();
}
case SMESHOp::OpExtrusion:
{
- if (checkLock(aStudy)) break;
+ if (isStudyLocked()) break;
if (vtkwnd) {
EmitSignalDeactivateDialog();
( new SMESHGUI_ExtrusionDlg ( this ) )->show();
}
case SMESHOp::OpExtrusionAlongAPath:
{
- if (checkLock(aStudy)) break;
+ if (isStudyLocked()) break;
if (vtkwnd) {
EmitSignalDeactivateDialog();
( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
}
case SMESHOp::OpRevolution:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_RevolutionDlg( this ) )->show();
}
case SMESHOp::OpPatternMapping:
{
- if ( checkLock( aStudy ) )
+ if ( isStudyLocked() )
break;
if ( vtkwnd )
{
break;
}
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
EmitSignalDeactivateDialog();
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
break;
}
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
EmitSignalDeactivateDialog();
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
// check if submesh is selected
Handle(SALOME_InteractiveObject) IObject = selected.First();
if (IObject->hasEntry()) {
- _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
+ _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
if( aSObj ) {
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
if (!aSubMesh->_is_nil()) {
break;
}
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
EmitSignalDeactivateDialog();
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
case SMESHOp::OpAddElemGroupPopup: // Add elements to group
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if (myState == 800) {
SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
if (aDlg) aDlg->onAdd();
case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if (myState == 800) {
SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
if (aDlg) aDlg->onRemove();
break;
}
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
EmitSignalDeactivateDialog();
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
break;
}
- if ( checkLock( aStudy ) )
+ if ( isStudyLocked() )
break;
EmitSignalDeactivateDialog();
case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
{
- if ( checkLock( aStudy ) )
+ if ( isStudyLocked() )
break;
EmitSignalDeactivateDialog();
break;
}
- if ( checkLock( aStudy ) )
+ if ( isStudyLocked() )
break;
EmitSignalDeactivateDialog();
case SMESHOp::OpEditHypothesis:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected;
}
case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
SUIT_OverrideCursor wc;
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
case SMESHOp::OpPyramid:
case SMESHOp::OpHexagonalPrism:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
SMDSAbs_EntityType type = SMDSEntity_Edge;
}
case SMESHOp::OpPolyhedron:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
case SMESHOp::OpQuadraticTetrahedron:
case SMESHOp::OpQuadraticPyramid:
case SMESHOp::OpQuadraticPentahedron:
+ case SMESHOp::OpBiQuadraticPentahedron:
case SMESHOp::OpQuadraticHexahedron:
case SMESHOp::OpTriQuadraticHexahedron:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
SMDSAbs_EntityType type = SMDSEntity_Last;
case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
+ case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
default: break;
}
case SMESHOp::OpRemoveNodes:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_RemoveNodesDlg( this ) )->show();
}
case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_RemoveElementsDlg( this ) )->show();
}
case SMESHOp::OpClearMesh: {
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
SALOME_ListIO selected;
if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
SMESH::ModifiedMesh( aMeshSObj, false, true);
// hide groups and submeshes
_PTR(ChildIterator) anIter =
- SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
+ SMESH::getStudy()->NewChildIterator( aMeshSObj );
for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
{
_PTR(SObject) so = anIter->Value();
}
case SMESHOp::OpRemoveOrphanNodes:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
SALOME_ListIO selected;
if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
aSel->selectedObjects( selected );
}
case SMESHOp::OpRenumberingNodes:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
}
case SMESHOp::OpRenumberingElements:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
}
case SMESHOp::OpTranslation:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_TranslationDlg( this ) )->show();
}
case SMESHOp::OpRotation:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_RotationDlg( this ) )->show();
}
case SMESHOp::OpSymmetry:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if(vtkwnd) {
EmitSignalDeactivateDialog();
( new SMESHGUI_SymmetryDlg( this ) )->show();
}
case SMESHOp::OpScale:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_ScaleDlg( this ) )->show();
case SMESHOp::OpSewing:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if(vtkwnd) {
EmitSignalDeactivateDialog();
( new SMESHGUI_SewingDlg( this ) )->show();
}
case SMESHOp::OpMergeNodes:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if(vtkwnd) {
EmitSignalDeactivateDialog();
( new SMESHGUI_MergeDlg( this, 0 ) )->show();
}
case SMESHOp::OpMergeElements:
{
- if (checkLock(aStudy)) break;
+ if (isStudyLocked()) break;
if (vtkwnd) {
EmitSignalDeactivateDialog();
( new SMESHGUI_MergeDlg( this, 1 ) )->show();
case SMESHOp::OpDuplicateNodes:
{
- if(checkLock(aStudy)) break;
+ if(isStudyLocked()) break;
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
case SMESHOp::OpBareBorderFace:
case SMESHOp::OpOverConstrainedFace:
case SMESHOp::OpLength2D:
+ case SMESHOp::OpDeflection2D:
case SMESHOp::OpConnection2D:
case SMESHOp::OpArea:
case SMESHOp::OpTaper:
createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
+ createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
+ createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
<< SMESHOp::OpNodeConnectivityNb // node controls
<< SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
<< SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
+ << SMESHOp::OpDeflection2D
<< SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
<< SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
<< SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
createMenu( SMESHOp::OpSkew, faceId, -1 );
createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
createMenu( SMESHOp::OpEqualFace, faceId, -1 );
+ createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
createMenu( SMESHOp::OpVolume, volumeId, -1 );
createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
+ createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
createTool( SMESHOp::OpSkew, ctrl2dTb );
createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
createTool( SMESHOp::OpEqualFace, ctrl2dTb );
+ createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
createTool( SMESHOp::OpVolume, ctrl3dTb );
createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
+ createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
+
popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
+ popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
+ popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
+ popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
+
aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
// 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
- GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
- if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study )) {
- if ( _PTR(Study) aStudy = s->studyDS() )
- GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
- }
+ GetSMESHGen()->UpdateStudy();
// get all view currently opened in the study and connect their signals to
// the corresponding slots of the class.
{
if( !s )
return;
- SMESH::RemoveVisuData( s->id() );
+ SMESH::RemoveVisuData();
SalomeApp_Module::studyClosed( s );
}
SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
{
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
if ( CORBA::is_nil( myComponentSMESH ) )
- {
- SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
- if ( aStudy )
- aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
- return aGUI.myComponentSMESH;
- }
- if ( aStudy )
- myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
+ {
+ SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
+ return aGUI.myComponentSMESH;
+ }
return myComponentSMESH;
}
void SMESHGUI::switchToOperation(int id)
{
- if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
- activeStudy()->abortAllOperations();
+ activeStudy()->abortAllOperations();
startOperation( id );
}
savePoint);
_PTR(IParameters) ip = ClientFactory::getIParameters(ap);
- // store map of custom markers
- const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
- if( !aMarkerMap.empty() )
+ // store custom markers
+ if( !myMarkerMap.empty() )
{
- VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
- for( ; anIter != aMarkerMap.end(); anIter++ )
+ VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
+ for( ; anIter != myMarkerMap.end(); anIter++ )
{
int anId = anIter->first;
VTK::MarkerData aMarkerData = anIter->second;
savePoint);
_PTR(IParameters) ip = ClientFactory::getIParameters(ap);
- // restore map of custom markers and map of clipping planes
- VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
+ // restore custom markers and map of clipping planes
TPlaneDataMap aPlaneDataMap;
std::vector<std::string> properties = ip->getProperties();
aMarkerTexture.push_back( aChar.digitValue() );
}
- aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
+ myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
}
else if( aPropertyType == "ClippingPlane" )
{
aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
}
else if( data[0] == "custom" ) {
- VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
- if( markerIt != aMarkerMap.end() ) {
+ VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
+ if( markerIt != myMarkerMap.end() ) {
VTK::MarkerData aMarkerData = markerIt->second;
aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
}
return false;
// check type to prevent renaming of inappropriate objects
- int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
+ int aType = SMESHGUI_Selection::type(qPrintable(entry));
if (aType == SMESH::MESH || aType == SMESH::GROUP ||
aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
if ( obj->FindAttribute(anAttr, "AttributeName") ) {
aName = anAttr;
// check type to prevent renaming of inappropriate objects
- int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
+ int aType = SMESHGUI_Selection::type( qPrintable(entry));
if (aType == SMESH::MESH || aType == SMESH::GROUP ||
aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
case SMDSEntity_Quad_Penta:
anElementName = QString("QUADRATIC_PENTAHEDRON");
break;
+ case SMDSEntity_BiQuad_Penta:
+ anElementName = QString("BIQUADRATIC_PENTAHEDRON");
+ break;
case SMDSEntity_Quad_Hexa:
anElementName = QString("QUADRATIC_HEXAHEDRON");
break;
myNbCorners = 6;
myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_pentahedrons
break;
+ case SMDSEntity_BiQuad_Penta:
+ aNumRows = 9;
+ myNbCorners = 6;
+ myNbMidFaceNodes = 3;
+ myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_pentahedrons
+ break;
case SMDSEntity_Quad_Hexa:
aNumRows = 12;
myNbCorners = 8;
if( !isValid() )
return false;
- if ( mySMESHGUI->isActiveStudyLocked() || myBusy || !IsValid() )
+ if ( SMESHGUI::isStudyLocked() || myBusy || !IsValid() )
return false;
BusyLocker lock( myBusy );
case SMDSEntity_Quad_Tetra:
case SMDSEntity_Quad_Pyramid:
case SMDSEntity_Quad_Penta:
+ case SMDSEntity_BiQuad_Penta:
case SMDSEntity_Quad_Hexa:
case SMDSEntity_TriQuad_Hexa:
for ( int row = 0; row < myNbCorners; row++ )
case SMDSEntity_Quad_Tetra:
case SMDSEntity_Quad_Pyramid:
case SMDSEntity_Quad_Penta:
+ case SMDSEntity_BiQuad_Penta:
case SMDSEntity_Quad_Hexa:
case SMDSEntity_TriQuad_Hexa:
anElementType = SMESH::VOLUME;
case SMDSEntity_Quad_Tetra:
case SMDSEntity_Quad_Pyramid:
case SMDSEntity_Quad_Penta:
+ case SMDSEntity_BiQuad_Penta:
case SMDSEntity_Quad_Hexa:
case SMDSEntity_TriQuad_Hexa:
anElementType = SMESH::VOLUME; break;
aLastColIds = LastPyramidIds;
break;
case SMDSEntity_Quad_Penta:
+ case SMDSEntity_BiQuad_Penta:
aFirstColIds = FirstPentahedronIds;
aLastColIds = LastPentahedronIds;
break;
_PTR(SObject) so = SMESH::FindSObject(aMainShape);
if ( subShapeID == 1 || !so )
return so;
- _PTR(ChildIterator) it;
- if (_PTR(Study) study = SMESH::GetActiveStudyDocument())
- it = study->NewChildIterator(so);
+ _PTR(ChildIterator) it = SMESH::getStudy()->NewChildIterator(so);
_PTR(SObject) subSO;
if ( it ) {
for ( it->InitEx(true); !subSO && it->More(); it->Next() ) {
// NPAL16631: if ( !memoryLack )
{
- _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID(myIObject->getEntry());
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID(myIObject->getEntry());
SMESH::ModifiedMesh( sobj,
!computeFailed && aHypErrors.isEmpty(),
myMesh->NbNodes() == 0);
{
toDisplay = true;
SMESH_Actor *anActor = SMESH::FindActorByObject( aMesh );
- if ( !anActor ) anActor = SMESH::CreateActor( (*anIter).second->GetStudy(),
- (*anIter).second->GetID().c_str(),
+ if ( !anActor ) anActor = SMESH::CreateActor( (*anIter).second->GetID().c_str(),
/*clearLog =*/ true );
if ( anActor ) // actor is not created for an empty mesh
{
currentCellChanged(); // to update buttons
}
}
- // show dialog and wait, becase Compute can be invoked from Preview operation
+ // show dialog and wait, because Compute can be invoked from Preview operation
//aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
aCompDlg->show();
}
void SMESHGUI_BaseComputeOp::onPublishShape()
{
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
- SALOMEDS::Study_var study = SMESHGUI::GetSMESHGen()->GetCurrentStudy();
GEOM::GEOM_Object_var meshShape = myMesh->GetShapeToMesh();
QStringList entryList;
if ( !SMESH::getSubShapeSO( 1, myMainShape )) // the main shape not published
{
QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( myMainShape, "MAIN_SHAPE" ));
- SALOMEDS::SObject_wrap so = geomGen->AddInStudy( study, myMainShape,
+ SALOMEDS::SObject_wrap so = geomGen->AddInStudy( myMainShape,
name.toLatin1().data(),
GEOM::GEOM_Object::_nil());
// look for myMainShape in the table
if ( curSub == 1 ) continue;
}
QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( shape, "ERROR_SHAPE" ));
- SALOMEDS::SObject_wrap so = geomGen->AddInStudy( study, shape,
+ SALOMEDS::SObject_wrap so = geomGen->AddInStudy( shape,
name.toLatin1().data(), myMainShape);
if ( !so->_is_nil() ) {
CORBA::String_var name = so->GetName();
//================================================================================
/*!
- * \brief Desctructor
+ * \brief Destructor
*/
//================================================================================
QList<int> modes;
QMap<int, int> modeMap;
- _PTR(SObject) pMesh = studyDS()->FindObjectID( myIObject->getEntry() );
+ _PTR(SObject) pMesh = SMESH::getStudy()->FindObjectID( myIObject->getEntry() );
getAssignedAlgos( pMesh, modeMap );
if ( modeMap.contains( SMESH::DIM_3D ) )
{
int aPart = SMESH::Tag_RefOnAppliedAlgorithms;
if ( theMesh->FindSubObject( aPart, aHypFolder ))
{
- _PTR(ChildIterator) anIter =
- SMESH::GetActiveStudyDocument()->NewChildIterator( aHypFolder );
+ _PTR(ChildIterator) anIter = SMESH::getStudy()->NewChildIterator( aHypFolder );
for ( ; anIter->More(); anIter->Next() )
{
_PTR(SObject) anObj = anIter->Value();
if ( !theMesh->FindSubObject( aPart, aHypFolder ))
continue;
- _PTR(ChildIterator) anIter =
- SMESH::GetActiveStudyDocument()->NewChildIterator( aHypFolder );
+ _PTR(ChildIterator) anIter = SMESH::getStudy()->NewChildIterator( aHypFolder );
for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
{
_PTR(SObject) anObj = anIter->Value();
SMESH::long_array_var aShapesId = new SMESH::long_array();
try {
- #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
- #endif
SMESH::MeshPreviewStruct_var previewData =
gen->Precompute(myMesh, myMainShape, (SMESH::Dimension)dim, aShapesId);
}
try {
- #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
- #endif
aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
// check if there are memory problems
for ( CORBA::ULong i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
//================================================================================
/*!
- * \brief Desctructor
+ * \brief Destructor
*/
//================================================================================
}
SUIT_OverrideCursor aWaitCursor;
try {
- #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
- #endif
aRes = gen->Evaluate(myMesh, myMainShape);
}
catch(const SALOME::SALOME_Exception & S_ex){
}
try {
- #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
- #endif
aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
}
catch(const SALOME::SALOME_Exception & S_ex){
currentCellChanged(); // to update buttons
}
}
- // show dialog and wait, becase Compute can be invoked from Preview operation
+ // show dialog and wait, because Compute can be invoked from Preview operation
//aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
aCompDlg->show();
}
try
{
QString anObjEntry = myDlg->selectedObject( 0 );
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ _PTR(SObject) pObj = SMESH::getStudy()->FindObjectID( anObjEntry.toLatin1().data() );
if ( !pObj ) return;
SMESH::SMESH_IDSource_var idSource =
QString aMess;
QString anObjEntry = myDlg->selectedObject( 0 );
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ _PTR(SObject) pObj = SMESH::getStudy()->FindObjectID( anObjEntry.toLatin1().data() );
if ( !pObj )
{
dlg()->show();
bool hasBiQuad = ( nbElemOfType[SMDSEntity_BiQuad_Triangle ] ||
nbElemOfType[SMDSEntity_BiQuad_Quadrangle ] ||
+ nbElemOfType[SMDSEntity_BiQuad_Penta ] ||
nbElemOfType[SMDSEntity_TriQuad_Hexa ] );
bool hasLinBiQuad = ( nbElemOfType[SMDSEntity_Triangle ] ||
nbElemOfType[SMDSEntity_Quadrangle ] ||
void SMESHGUI_ConvToQuadOp::ConnectRadioButtons( int id )
{
QString anObjEntry = myDlg->selectedObject( 0 );
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ _PTR(SObject) pObj = SMESH::getStudy()->FindObjectID( anObjEntry.toLatin1().data() );
if ( !pObj ) return;
SMESH::SMESH_IDSource_var idSource =
* \brief Retrieves all fields defined on geometry of given meshes
*/
bool SMESHGUI_FieldSelectorWdg::
- GetAllFeilds(const QList< QPair< SMESH::SMESH_IDSource_var, QString > >& meshes,
+ GetAllFields(const QList< QPair< SMESH::SMESH_IDSource_var, QString > >& meshes,
QList< QPair< GEOM::ListOfFields_var, QString > >& fields)
{
myFields = & fields;
myTree->clear();
- _PTR(Study) study = SMESH::GetActiveStudyDocument();
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
- GEOM::GEOM_IFieldOperations_wrap fieldOp = geomGen->GetIFieldOperations( study->StudyId() );
+ GEOM::GEOM_IFieldOperations_wrap fieldOp = geomGen->GetIFieldOperations();
for ( int iM = 0; iM < meshes.count(); ++iM )
{
/*!
* \brief Filter off not selected fields from myFields
*/
- bool SMESHGUI_FieldSelectorWdg::GetSelectedFeilds()
+ bool SMESHGUI_FieldSelectorWdg::GetSelectedFields()
{
int nbSelected = 0;
if ( myTree->isEnabled() )
//=======================================================================
// name : SMESHGUI_FilterTable::Table::isEditable
- // Purpose : Verify wheter cell is editable
+ // Purpose : Verify whether cell is editable
//=======================================================================
bool SMESHGUI_FilterTable::Table::isEditable (int row, int col) const
{
{
if ( strlen( theCriterion.ThresholdID ) > 0 ) // shape ID -> name
{
- _PTR(SObject) sobj =
- SMESH::GetActiveStudyDocument()->FindObjectID( theCriterion.ThresholdID.in() );
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( theCriterion.ThresholdID.in() );
if ( !sobj )
aTable->item( theRow, 2 )->setText( QString( theCriterion.ThresholdID ) );
else
aCriterion == SMESH::FT_MaxElementLength3D ||
aCriterion == SMESH::FT_Length ||
aCriterion == SMESH::FT_Length2D ||
+ aCriterion == SMESH::FT_Deflection2D ||
aCriterion == SMESH::FT_BallDiameter );
bool toEnable = (( isDbl && ((ComboItem*)aTable->item(aRow, 1))->value() == SMESH::FT_EqualTo) ||
retval = "len_tol_precision"; break;
case SMESH::FT_Length:
case SMESH::FT_Length2D:
+ case SMESH::FT_Deflection2D:
case SMESH::FT_MaxElementLength2D:
case SMESH::FT_MaxElementLength3D:
case SMESH::FT_BallDiameter:
typeIds.append( SMDSEntity_TriQuad_Hexa );
typeIds.append( SMDSEntity_Penta );
typeIds.append( SMDSEntity_Quad_Penta );
+ typeIds.append( SMDSEntity_BiQuad_Penta );
typeIds.append( SMDSEntity_Hexagonal_Prism );
typeIds.append( SMDSEntity_Polyhedra );
//typeIds.append( SMDSEntity_Quad_Polyhedra );
}
// find out a type of item required by a new criterion and other table features
- int aCriterionType = GetCriterionType(row);
+ int aCriterionType = GetCriterionType(row);
bool anIsDoubleCriterion = false;
bool anIsIntCriterion = false;
bool anIsComboCriterion = false;
// other features:
QList<int> comboIDs; // values to show in a combo item
- int nbCompareSigns = 0; // possible values are 0,1,3
+ int nbCompareSigns = 0; // possible values are 0,1,3
bool isThresholdEditable = false; // actual for "simple" item types
switch ( aCriterionType )
{
case SMESH::FT_Area:
case SMESH::FT_Volume3D:
case SMESH::FT_MaxElementLength2D:
- case SMESH::FT_MaxElementLength3D:
- anIsDoubleCriterion = true; break;
+ case SMESH::FT_MaxElementLength3D: anIsDoubleCriterion = true; break;
case SMESH::FT_FreeBorders:
case SMESH::FT_FreeEdges:
case SMESH::FT_MultiConnection2D: anIsIntCriterion = true; nbCompareSigns = 3; break;
case SMESH::FT_Length:
- case SMESH::FT_Length2D: anIsDoubleCriterion = true; break;
+ case SMESH::FT_Length2D:
+ case SMESH::FT_Deflection2D: anIsDoubleCriterion = true; break;
case SMESH::FT_BelongToMeshGroup: break;
aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D");
+ aCriteria[ SMESH::FT_Deflection2D ] = tr("DEFLECTION2D");
aCriteria[ SMESH::FT_MultiConnection2D ] = tr("MULTI2D_BORDERS");
aCriteria[ SMESH::FT_FreeFaces ] = tr("FREE_FACES");
aCriteria[ SMESH::FT_BareBorderFace ] = tr("BARE_BORDER_FACE");
QString aName;
myTable->GetThreshold(i, aName);
- std::vector<_PTR(SObject)> aList =
- SMESH::GetActiveStudyDocument()->FindObjectByName(aName.toLatin1().constData(), "GEOM");
+ std::vector<_PTR(SObject)> aList = SMESH::getStudy()->FindObjectByName(aName.toLatin1().constData(), "GEOM");
if (aList.size() == 0) {
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr("BAD_SHAPE_NAME").arg(aName));
QString aName = "";
// collect all object names of SMESH component
- SalomeApp_Study* appStudy =
- dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
- if ( !appStudy ) return aName;
- _PTR(Study) aStudy = appStudy->studyDS();
+ _PTR(Study) aStudy = SMESH::getStudy();
std::set<std::string> aSet;
_PTR(SComponent) aMeshCompo (aStudy->FindComponent( "SMESH" ));
void SMESHGUI_GroupDlg::setDefaultName() const
{
QString aResName;
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
int i=1;
QString aPrefix ="Group_";
_PTR(SObject) anObj;
do
{
aResName = aPrefix + QString::number( i++ );
- anObj = aStudy->FindObject( SMESH::toUtf8(aResName) );
+ anObj = SMESH::getStudy()->FindObject( SMESH::toUtf8(aResName) );
}
while ( anObj );
myName->setText(aResName);
else if ( grpType == 1 ) // group on geom
{
QString aShapeName( "" );
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
if (!aGroupShape->_is_nil())
{
//=================================================================================
bool SMESHGUI_GroupDlg::onApply()
{
- if (mySMESHGUI->isActiveStudyLocked())
+ if (SMESHGUI::isStudyLocked())
return false;
if (myName->text().trimmed().isEmpty())
if (myMesh->_is_nil() || !myGeomObjects->length())
return false;
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
if (myGeomObjects->length() == 1) {
myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
// create a geometry group
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- if (geomGen->_is_nil() || !aStudy)
+ if (geomGen->_is_nil())
return false;
- GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId());
+ GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations();
if (op->_is_nil())
return false;
QString aNewGeomGroupName ( "Auto_group_for_" );
aNewGeomGroupName += myName->text();
SALOMEDS::SObject_var aNewGroupSO =
- geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar,
+ geomGen->AddInStudy(aGroupVar,
SMESH::toUtf8(aNewGeomGroupName), aMeshShape);
}
{
if ( myFilter->_is_nil() ) return false;
- if (CORBA::is_nil(myGroupOnFilter)) { // creation
+ if (CORBA::is_nil(myGroupOnFilter)) // creation
+ {
if (myMesh->_is_nil())
return false;
myGroupOnFilter = myMesh->CreateGroupFromFilter(aType,
SMESH::toUtf8(myName->text()),
myFilter);
-
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter );
isCreation = true;
}
anIsOk = true;
}
- if( anIsOk )
+ if ( anIsOk )
{
SALOMEDS::Color aColor = getGroupColor();
resultGroup->SetColor(aColor);
continue;
// Check if group constructed on the same shape as a mesh or on its child
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
// The main shape of the group
GEOM::GEOM_Object_var aGroupMainShape;
if (aGeomGroup->GetType() == 37) {
GEOM::GEOM_IGroupOperations_wrap anOp =
- SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
+ SMESH::GetGEOMGen()->GetIGroupOperations();
aGroupMainShape = anOp->GetMainShape(aGeomGroup);
// aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap
}
aGroupMainShape->Register();
}
_PTR(SObject) aGroupMainShapeSO =
- aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
+ SMESH::getStudy()->FindObjectID(aGroupMainShape->GetStudyEntry());
_PTR(SObject) anObj, aRef;
bool isRefOrSubShape = false;
onListSelectionChanged();
} else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) {
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
GEOM::GEOM_IGroupOperations_wrap aGroupOp =
- SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
+ SMESH::GetGEOMGen()->GetIGroupOperations();
SMESH::ElementType aGroupType = SMESH::ALL;
switch(aGroupOp->GetType(myGeomObjects[0])) {
if (aGroupType == aType) {
_PTR(SObject) aGroupSO =
- //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
- aStudy->FindObjectID(myGeomObjects[0]->GetStudyEntry());
+ //SMESH::getStudy()->FindObjectIOR(SMESH::getStudy()->ConvertObjectToIOR(myGeomGroup));
+ SMESH::getStudy()->FindObjectID(myGeomObjects[0]->GetStudyEntry());
// Construct filter
SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
if ( !aGeomVar->_is_nil() )
{
QString ID = aGeomVar->GetStudyEntry();
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- if ( _PTR(SObject) aGeomSO = aStudy->FindObjectID( ID.toLatin1().data() )) {
+ if ( _PTR(SObject) aGeomSO = SMESH::getStudy()->FindObjectID( ID.toLatin1().data() )) {
SALOME_ListIO anIOList;
Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() );
#endif
#ifdef WIN32
- #define LibHandle HMODULE
- #define LoadLib( name ) LoadLibrary( name )
- #define GetProc GetProcAddress
- #define UnLoadLib( handle ) FreeLibrary( handle );
- #else
- #define LibHandle void*
- #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL )
- #define GetProc dlsym
- #define UnLoadLib( handle ) dlclose( handle );
- #endif
+ #define LibHandle HMODULE
+ #define LoadLib( name ) LoadLibrary( name )
+ #define GetProc GetProcAddress
+ #define UnLoadLib( handle ) FreeLibrary( handle );
+ #else // WIN32
+ #define LibHandle void*
+ #ifdef DYNLOAD_LOCAL
+ #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_LOCAL )
+ #else // DYNLOAD_LOCAL
+ #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL )
+ #endif // DYNLOAD_LOCAL
+ #define GetProc dlsym
+ #define UnLoadLib( handle ) dlclose( handle );
+ #endif // WIN32
#ifdef _DEBUG_
static int MYDEBUG = 0;
SUIT_OverrideCursor wc;
try {
- _PTR(Study) aStudy = GetActiveStudyDocument();
+ _PTR(Study) aStudy = getStudy();
_PTR(SObject) aHypObj = aStudy->FindObjectID( IObject->getEntry() );
if( aHypObj )
{
if (!AlgoOrHyp->_is_nil()) {
_PTR(SObject) SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp);
if (SO_Hypothesis) {
- SObjectList listSO =
- SMESHGUI::activeStudy()->studyDS()->FindDependances(SO_Hypothesis);
+ SObjectList listSO = SMESH::getStudy()->FindDependances(SO_Hypothesis);
if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<<listSO.size());
for (unsigned int i = 0; i < listSO.size(); i++) {
QLabel* a2DTriQuad = createField();
a2DTriQuad->setObjectName("nbQuadraticTriangle");
QLabel* a2DTriBiQuad = createField();
- a2DTriBiQuad->setObjectName("nbBiQuadraticTriangle");
+ a2DTriBiQuad->setObjectName("nbBiQuadraticTriangle");
QLabel* a2DQuaLab = new QLabel( tr( "QUADRANGLES_LAB" ), this );
QLabel* a2DQuaTotal = createField();
a2DQuaTotal->setObjectName("nbQuadrangle");
a3DPriLin->setObjectName("nbLinearPrism");
QLabel* a3DPriQuad = createField();
a3DPriQuad->setObjectName("nbQuadraticPrism");
+ QLabel* a3DPriBiQuad = createField();
+ a3DPriBiQuad->setObjectName("nbBiQuadraticPrism");
QLabel* a3DHexPriLab = new QLabel( tr( "HEX_PRISMS_LAB" ), this );
QLabel* a3DHexPriTotal = createField();
a3DHexPriTotal->setObjectName("nbHexagonalPrism");
myWidgets[ index++ ] << a3DTetLab << a3DTetTotal << a3DTetLin << a3DTetQuad;
myWidgets[ index++ ] << a3DHexLab << a3DHexTotal << a3DHexLin << a3DHexQuad << a3DHexBiQuad;
myWidgets[ index++ ] << a3DPyrLab << a3DPyrTotal << a3DPyrLin << a3DPyrQuad;
- myWidgets[ index++ ] << a3DPriLab << a3DPriTotal << a3DPriLin << a3DPriQuad;
+ myWidgets[ index++ ] << a3DPriLab << a3DPriTotal << a3DPriLin << a3DPriQuad << a3DPriBiQuad;
myWidgets[ index++ ] << a3DHexPriLab << a3DHexPriTotal;
myWidgets[ index++ ] << a3DPolLab << a3DPolTotal;
l->addWidget( a3DPriTotal, 24, 1 );
l->addWidget( a3DPriLin, 24, 2 );
l->addWidget( a3DPriQuad, 24, 3 );
+ l->addWidget( a3DPriBiQuad, 24, 4 );
l->addWidget( a3DHexPriLab, 25, 0 );
l->addWidget( a3DHexPriTotal, 25, 1 );
l->addWidget( a3DPolLab, 26, 0 );
long nbTetrahedrons = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra];
long nbHexahedrons = info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa];
long nbPyramids = info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid];
- long nbPrisms = info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta];
+ long nbPrisms = info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta];
long nb3DLinear = info[SMDSEntity_Tetra] + info[SMDSEntity_Hexa] + info[SMDSEntity_Pyramid] + info[SMDSEntity_Penta] + info[SMDSEntity_Polyhedra] + info[SMDSEntity_Hexagonal_Prism];
long nb3DQuadratic = info[SMDSEntity_Quad_Tetra] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_Quad_Pyramid] + info[SMDSEntity_Quad_Penta];
- long nb3DBiQuadratic = info[SMDSEntity_TriQuad_Hexa];
+ long nb3DBiQuadratic = info[SMDSEntity_TriQuad_Hexa] + info[SMDSEntity_BiQuad_Penta];
long nb3DTotal = nb3DLinear + nb3DQuadratic + nb3DBiQuadratic;
myWidgets[i3D][iTotal] ->setProperty( "text", QString::number( nb3DTotal ));
myWidgets[i3D][iLinear] ->setProperty( "text", QString::number( nb3DLinear ));
myWidgets[i3DPrisms][iTotal] ->setProperty( "text", QString::number( nbPrisms ));
myWidgets[i3DPrisms][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Penta] ));
myWidgets[i3DPrisms][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Penta] ));
+ myWidgets[i3DPrisms][iBiQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_BiQuad_Penta] ));
myWidgets[i3DHexaPrisms][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Hexagonal_Prism] ));
myWidgets[i3DPolyhedrons][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Polyhedra] ));
long nbElemTotal = info[SMDSEntity_0D] + info[SMDSEntity_Ball] + nbEdges + nb2DTotal + nb3DTotal;
\param parent parent widget
*/
SMESHGUI_ElemInfo::SMESHGUI_ElemInfo( QWidget* parent )
- : QWidget( parent ), myActor( 0 ), myIsElement( -1 )
+ : QWidget( parent ), myActor( 0 ), myIsElement( -1 )
{
myFrame = new QWidget( this );
myExtra = new ExtraWidget( this );
\brief Set mesh data source (actor)
\param actor mesh object actor
*/
- void SMESHGUI_ElemInfo::setSource( SMESH_Actor* actor )
+ void SMESHGUI_ElemInfo::setSource( SMESH_Actor* actor, SMESH::SMESH_IDSource_var obj )
{
if ( myActor != actor ) {
myActor = actor;
myIsElement = -1;
+ SMESH::SMESH_Mesh_var mesh = obj->GetMesh();
+ myMeshHasShape = ( !mesh->_is_nil() && mesh->HasShapeToMesh() );
clear();
}
}
\param parent parent widget
*/
SMESHGUI_SimpleElemInfo::SMESHGUI_SimpleElemInfo( QWidget* parent )
- : SMESHGUI_ElemInfo( parent )
+ : SMESHGUI_ElemInfo( parent )
{
myInfo = new QTextBrowser( frame() );
QVBoxLayout* l = new QVBoxLayout( frame() );
void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
{
clearInternal();
-
+
if ( actor() ) {
int grp_details = SMESHGUI::resourceMgr()->booleanValue( "SMESH", "elem_info_grp_details", false );
int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
int cprecision = -1;
- if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ))
+ if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ))
cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 );
foreach ( long id, ids ) {
if ( !isElements() ) {
myInfo->append( QString( "<b>%1</b>" ).arg( SMESHGUI_ElemInfo::tr( "FREE_NODE" )).arg( id ));
}
// node position
- SMESH::SMESH_Mesh_ptr aMeshPtr = actor()->GetObject()->GetMeshServer();
+ SMESH::SMESH_Mesh_ptr aMeshPtr = actor()->GetObject()->GetMeshServer();
if ( !CORBA::is_nil( aMeshPtr )) {
SMESH::NodePosition_var pos = aMeshPtr->GetNodePosition( id );
int shapeID = pos->shapeID;
case GEOM::FACE:
shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" );
if ( pos->params.length() == 2 ) {
- u = pos->params[0];
- v = pos->params[1];
+ u = pos->params[0];
+ v = pos->params[1];
}
break;
case GEOM::VERTEX:
SMESH::SMESH_Group_var aStdGroup = SMESH::SMESH_Group::_narrow( aGrp );
SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGrp );
SMESH::SMESH_GroupOnFilter_var aFltGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGrp );
-
+
// type : group on geometry, standalone group, group on filter
if ( !CORBA::is_nil( aStdGroup )) {
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" )).
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" )).
arg( SMESHGUI_AddInfo::tr( "GROUP_ON_FILTER" )) );
}
-
+
// size
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "SIZE" )).
arg( QString::number( aGrp->Size() )) );
-
+
// color
SALOMEDS::Color color = aGrp->GetColor();
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "COLOR" )).
else {
//
// show element info
- //
+ //
const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
SMESH::Controls::NumericalFunctorPtr afunctor;
if ( !e ) return;
-
+
// Element ID && Type
QString stype;
switch( e->GetType() ) {
stype = SMESHGUI_ElemInfo::tr( "FACE" ); break;
case SMDSAbs_Volume:
stype = SMESHGUI_ElemInfo::tr( "VOLUME" ); break;
- default:
+ default:
break;
}
if ( stype.isEmpty() ) return;
gtype = SMESHGUI_ElemInfo::tr( "HEXAHEDRON" ); break;
case SMDSEntity_Penta:
case SMDSEntity_Quad_Penta:
+ case SMDSEntity_BiQuad_Penta:
gtype = SMESHGUI_ElemInfo::tr( "PRISM" ); break;
case SMDSEntity_Hexagonal_Prism:
gtype = SMESHGUI_ElemInfo::tr( "HEX_PRISM" ); break;
case SMDSEntity_Polyhedra:
case SMDSEntity_Quad_Polyhedra:
gtype = SMESHGUI_ElemInfo::tr( "POLYHEDRON" ); break;
- default:
+ default:
break;
}
if ( !gtype.isEmpty() )
afunctor.reset( new SMESH::Controls::Length() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
afunctor->SetPrecision( cprecision );
- myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "LENGTH_EDGES" )).arg( afunctor->GetValue( id )) );
+ myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "LENGTH_EDGES" )).arg( afunctor->GetValue( id )) );
}
if( e->GetType() == SMDSAbs_Face ) {
//Area
afunctor.reset( new SMESH::Controls::Area() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
- afunctor->SetPrecision( cprecision );
+ afunctor->SetPrecision( cprecision );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "AREA_ELEMENTS" )).arg( afunctor->GetValue( id )) );
//Taper
afunctor.reset( new SMESH::Controls::Taper() );
- afunctor->SetMesh( actor()->GetObject()->GetMesh() );
+ afunctor->SetMesh( actor()->GetObject()->GetMesh() );
afunctor->SetPrecision( cprecision );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "TAPER_ELEMENTS" )).arg( afunctor->GetValue( id )) );
//AspectRatio2D
afunctor.reset( new SMESH::Controls::AspectRatio() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "ASPECTRATIO_ELEMENTS" )).arg( afunctor->GetValue( id )) );
- //Minimum angle
+ //Minimum angle
afunctor.reset( new SMESH::Controls::MinimumAngle() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
afunctor->SetPrecision( cprecision );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MINIMUMANGLE_ELEMENTS" )).arg( afunctor->GetValue( id )) );
- //Wraping angle
+ //Warping angle
afunctor.reset( new SMESH::Controls::Warping() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
afunctor->SetPrecision( cprecision );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "WARP_ELEMENTS" )).arg( afunctor->GetValue( id )) );
- //Skew
+ //Skew
afunctor.reset( new SMESH::Controls::Skew() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
afunctor->SetPrecision( cprecision );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "SKEW_ELEMENTS" )).arg( afunctor->GetValue( id )) );
- //ElemDiam2D
+ //ElemDiam2D
afunctor.reset( new SMESH::Controls::MaxElementLength2D() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
+ afunctor->SetPrecision( cprecision );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MAX_ELEMENT_LENGTH_2D" )).arg( afunctor->GetValue( id )) );
+ //min edge length
+ afunctor.reset( new SMESH::Controls::Length2D() );
+ afunctor->SetMesh( actor()->GetObject()->GetMesh() );
+ myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MIN_ELEM_EDGE" )).arg( afunctor->GetValue( id )) );
}
if( e->GetType() == SMDSAbs_Volume ) {
//AspectRatio3D
afunctor.reset( new SMESH::Controls::AspectRatio3D() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "ASPECTRATIO_3D_ELEMENTS" )).arg( afunctor->GetValue( id )) );
- //Volume
+ //Volume
afunctor.reset( new SMESH::Controls::Volume() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUME_3D_ELEMENTS" )).arg( afunctor->GetValue( id )) );
- //ElementDiameter3D
+ //ElementDiameter3D
afunctor.reset( new SMESH::Controls::Volume() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MAX_ELEMENT_LENGTH_3D" )).arg( afunctor->GetValue( id )) );
// Gravity center
XYZ gc = gravityCenter( e );
myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( SMESHGUI_ElemInfo::tr( "GRAVITY_CENTER" )).arg( gc.x() ).arg( gc.y() ).arg( gc.z() ));
-
+
// Normal vector
if( e->GetType() == SMDSAbs_Face ) {
XYZ gc = normal( e );
// Element position
if ( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
- SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
+ SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
if ( !CORBA::is_nil( aMesh )) {
SMESH::ElementPosition pos = aMesh->GetElementPosition( id );
int shapeID = pos.shapeID;
SMESH::SMESH_Group_var aStdGroup = SMESH::SMESH_Group::_narrow( aGrp );
SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGrp );
SMESH::SMESH_GroupOnFilter_var aFltGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGrp );
-
+
// type : group on geometry, standalone group, group on filter
if ( !CORBA::is_nil( aStdGroup )) {
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" )).
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" )).
arg( SMESHGUI_AddInfo::tr( "GROUP_ON_FILTER" )) );
}
-
+
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "SIZE" )).
arg( QString::number( aGrp->Size() )) );
-
+
// color
SALOMEDS::Color color = aGrp->GetColor();
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "COLOR" )).
\param parent parent widget
*/
SMESHGUI_TreeElemInfo::SMESHGUI_TreeElemInfo( QWidget* parent )
- : SMESHGUI_ElemInfo( parent )
+ : SMESHGUI_ElemInfo( parent )
{
myInfo = new QTreeWidget( frame() );
myInfo->setColumnCount( 2 );
gtype = SMESHGUI_ElemInfo::tr( "HEXAHEDRON" ); break;
case SMDSEntity_Penta:
case SMDSEntity_Quad_Penta:
+ case SMDSEntity_BiQuad_Penta:
gtype = SMESHGUI_ElemInfo::tr( "PRISM" ); break;
case SMDSEntity_Hexagonal_Prism:
gtype = SMESHGUI_ElemInfo::tr( "HEX_PRISM" ); break;
QTreeWidgetItem* taperlItem = createItem( cntrItem, Bold );
taperlItem->setText( 0, tr( "TAPER_ELEMENTS" ));
taperlItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id )) );
- //Wraping angle
+ //Warping angle
afunctor.reset( new SMESH::Controls::Warping() );
afunctor->SetMesh( actor()->GetObject()->GetMesh() );
afunctor->SetPrecision( cprecision );
skewItem->setText( 0, tr( "SKEW_ELEMENTS" ));
skewItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id )) );
}
+ //Deflection
+ if ( hasShapeToMesh() )
+ {
+ afunctor.reset( new SMESH::Controls::Deflection2D() );
+ afunctor->SetMesh( actor()->GetObject()->GetMesh() );
+ QTreeWidgetItem* deflItem = createItem( cntrItem, Bold );
+ deflItem->setText( 0, tr( "DEFLECTION_2D" ));
+ deflItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id )) );
+ }
//ElemDiam2D
if ( !e->IsPoly() )
{
diam3Item->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id )) );
}
+ //min edge length
+ afunctor.reset( new SMESH::Controls::Length2D() );
+ afunctor->SetMesh( actor()->GetObject()->GetMesh() );
+ QTreeWidgetItem* minEdgeItem = createItem( cntrItem, Bold );
+ minEdgeItem->setText( 0, tr( "MIN_ELEM_EDGE" ));
+ minEdgeItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id )) );
+
// gravity center
XYZ gc = gravityCenter( e );
QTreeWidgetItem* gcItem = createItem( elemItem, Bold );
\param parent parent widget
*/
SMESHGUI_AddInfo::SMESHGUI_AddInfo( QWidget* parent )
- : QTreeWidget( parent )
+ : QTreeWidget( parent )
{
setColumnCount( 2 );
header()->setStretchLastSection( true );
SMESH::GetNameOfSelectedElements( selector, IO, ID ) :
SMESH::GetNameOfSelectedNodes( selector, IO, ID );
}
- myElemInfo->setSource( myActor ) ;
+ myElemInfo->setSource( myActor, obj ) ;
if ( nb > 0 ) {
myID->setText( ID.trimmed() );
QSet<long> ids;
void SMESHGUI_MeshInfoDlg::dump()
{
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if ( !app ) return;
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study *>( app->activeStudy() );
- if ( !appStudy ) return;
- _PTR( Study ) aStudy = appStudy->studyDS();
-
QStringList aFilters;
aFilters.append( tr( "TEXT_FILES" ));
computeOverConstrainedVolumesInfo();
// aspect Ratio 3D histogram
computeAspectRatio3D();
- }
- else {
- myButtons[7]->setEnabled( true );
- myButtons[8]->setEnabled( true );
- myButtons[9]->setEnabled( true );
- }
+ }
+ else {
+ myButtons[7]->setEnabled( true );
+ myButtons[8]->setEnabled( true );
+ myButtons[9]->setEnabled( true );
+ }
#ifdef DISABLE_PLOT2DVIEWER
myMainLayout->setRowStretch(17,0);
for( int i=35; i<=37; i++)
\param parent parent widget
*/
SMESHGUI_CtrlInfoDlg::SMESHGUI_CtrlInfoDlg( QWidget* parent )
- : QDialog( parent )
+ : QDialog( parent )
{
setAttribute( Qt::WA_DeleteOnClose, true );
setWindowTitle( tr( "CTRL_INFO" ));
*/
void SMESHGUI_CtrlInfoDlg::dump()
{
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if ( !app ) return;
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study *>( app->activeStudy() );
- if ( !appStudy ) return;
- _PTR( Study ) aStudy = appStudy->studyDS();
-
QStringList aFilters;
aFilters.append( tr( "TEXT_FILES" ));
//=======================================================================
// name : SMESHGUI_MultiEditDlg::getIds
- // Purpose : Retrive identifiers from list box or the whole object
+ // Purpose : Retrieve identifiers from list box or the whole object
//=======================================================================
SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds(SMESH::SMESH_IDSource_var& obj)
//=======================================================================
bool SMESHGUI_MultiEditDlg::onApply()
{
- if (mySMESHGUI->isActiveStudyLocked())
+ if (SMESHGUI::isStudyLocked())
return false;
if (!isValid(true))
return false;
#include <SMESH_ScalarBarActor.h>
// SALOME GUI includes
-#include <SalomeApp_Study.h>
+#include <SalomeApp_Application.h>
#include <LightApp_VTKSelector.h>
#include <SVTK_ViewWindow.h>
{
LightApp_Selection::init( client, mgr );
- if( mgr && study() )
+ if( mgr )
{
- SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>(study());
- if (!aSStudy)
- return;
- _PTR(Study) aStudy = aSStudy->studyDS();
-
for( int i=0, n=count(); i<n; i++ ) {
- myTypes.append( typeName( type( entry( i ), aStudy ) ) );
+ myTypes.append( typeName( type( entry( i ) ) ) );
myControls.append( controlMode( i ) );
}
}
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
- _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
- CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
+ CORBA::Object_var obj = SMESH::SObjectToObject( sobj );
SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
if ( !CORBA::is_nil( idSrc ) )
{
bool SMESHGUI_Selection::isQuadratic( int ind ) const
{
- _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
+ _PTR(SObject) so = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
if ( !so )
return false;
SMESH::SMESH_IDSource_var idSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( so );
switch( actor->GetControlMode() ) {
case SMESH_Actor::eLength: mode = "eLength"; break;
case SMESH_Actor::eLength2D: mode = "eLength2D"; break;
+ case SMESH_Actor::eDeflection2D: mode = "eDeflection2D"; break;
case SMESH_Actor::eFreeEdges: mode = "eFreeEdges"; break;
case SMESH_Actor::eFreeNodes: mode = "eFreeNodes"; break;
case SMESH_Actor::eFreeBorders: mode = "eFreeBorders"; break;
return "eNone";
}
+ //=======================================================================
+ //function : isNumFunctor
+ //purpose : return true if a given actor is shown using a numeric functor
+ //=======================================================================
+
bool SMESHGUI_Selection::isNumFunctor( int ind ) const
{
bool result = false;
switch( actor->GetControlMode() ) {
case SMESH_Actor::eLength:
case SMESH_Actor::eLength2D:
+ case SMESH_Actor::eDeflection2D:
case SMESH_Actor::eMultiConnection:
case SMESH_Actor::eMultiConnection2D:
case SMESH_Actor::eArea:
//=======================================================================
//function : facesOrientationMode
- //purpose :
+ //purpose :
//=======================================================================
QString SMESHGUI_Selection::facesOrientationMode( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
- _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
- CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
- SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
- if ( !CORBA::is_nil( mesh ) )
- return mesh->GetAutoColor();
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
+ CORBA::Object_var obj = SMESH::SObjectToObject( sobj );
+
+ if ( !CORBA::is_nil( obj ) ) {
+ SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
+ if ( !CORBA::is_nil( mesh ) )
+ return mesh->GetAutoColor();
+ }
}
return false;
}
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
- _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
- CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
+ CORBA::Object_var obj = SMESH::SObjectToObject( sobj );
if ( !CORBA::is_nil( obj ) ) {
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
int dim = -1;
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
- _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
- CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
+ CORBA::Object_var obj = SMESH::SObjectToObject( sobj );
if ( !CORBA::is_nil( obj ) ) {
SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
myTypes[ind].startsWith("Mesh " )))
{
QMap<int,int> modeMap;
- _PTR(SObject) meshSO = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
+ _PTR(SObject) meshSO = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
_PTR(SComponent) component = meshSO->GetFatherComponent();
if ( meshSO->Depth() - component->Depth() > 1 ) // sub-mesh, get a mesh
if ( maxDim < 2 ) // we can preview 1D or 2D
{
QMap<int,int> modeMap;
- _PTR(SObject) pMesh = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
+ _PTR(SObject) pMesh = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
SMESHGUI_PrecomputeOp::getAssignedAlgos( pMesh, modeMap );
if ( modeMap.size() > 1 )
return (( modeMap.contains( SMESH::DIM_3D )) ||
{
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
{
- _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
+ _PTR(SObject) so = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
return !shape->_is_nil();
}
bool isEditable = true;
if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Hypothesis" )
{
- _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
+ _PTR(SObject) so = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
SMESH::SMESH_Hypothesis_var hyp = SMESH::SObjectToInterface<SMESH::SMESH_Hypothesis>( so );
if ( !hyp->_is_nil() )
{
{
if ( ind >= 0 )
{
- _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().data() );
if ( sobj )
- return SMESH::GetActiveStudyDocument()->GetUseCaseBuilder()->HasChildren( sobj );
+ return SMESH::getStudy()->GetUseCaseBuilder()->HasChildren( sobj );
}
return false;
}
int nb = 0;
if ( ind >= 0 )
{
- _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
- if ( sobj && sobj->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode( sobj ) ) {
- _PTR(UseCaseIterator) it = sobj->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( sobj );
+ _PTR(Study) study = SMESH::getStudy();
+ _PTR(SObject) sobj = study->FindObjectID( entry( ind ).toLatin1().data() );
+ if ( sobj && study->GetUseCaseBuilder()->IsUseCaseNode( sobj ) ) {
+ _PTR(UseCaseIterator) it = study->GetUseCaseBuilder()->GetUseCaseIterator( sobj );
for ( it->Init( false ); it->More(); it->Next() ) nb++;
}
}
//purpose :
//=======================================================================
-int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study )
+int SMESHGUI_Selection::type( const QString& entry )
{
int res = -1;
- _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().data() );
+ _PTR(SObject) obj = SalomeApp_Application::getStudy()->FindObjectID( entry.toLatin1().data() );
if ( obj ) {
_PTR(SObject) ref;
if ( obj->ReferencedObject( ref ) )
bool SMESHGUI_Selection::isImported( const int ind ) const
{
bool res = false;
- _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().constData() );
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().constData() );
if ( sobj )
{
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( sobj ) );
QString SMESHGUI_Selection::groupType( int ind ) const
{
- _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().constData() );
+ _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toLatin1().constData() );
if ( sobj )
{
SMESH::SMESH_Group_var g = SMESH::SObjectToInterface<SMESH::SMESH_Group>( sobj );
// File : SMESHGUI_SingleEditDlg.cxx
// Author : Sergey LITONIN, Open CASCADE S.A.S.
+
+ #include <SVTK_Selector.h>
+
// SMESH includes
//
#include "SMESHGUI_SingleEditDlg.h"
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
- #include <SVTK_Selector.h>
#include <SVTK_ViewWindow.h>
#include <SALOME_ListIO.hxx>
aList.Append(anIO);
mySelectionMgr->setSelectedObjects(aList,false);
- TColStd_IndexedMapOfInteger selectedIndices;
- TColStd_MapOfInteger newIndices;
- mySelector->GetIndex(anIO,selectedIndices);
+ SVTK_IndexedMapOfIds selectedIndices;
+ SVTK_ListOfInteger newIndices;
+ mySelector->GetCompositeIndex(anIO,selectedIndices);
int id1, id2;
if ( !getNodeIds(myEdge->text(), id1, id2) )
if ( findTriangles(aNode1,aNode2,tria1,tria2) )
{
- newIndices.Add(tria1->GetID());
-
- const SMDS_MeshNode* a3Nodes[3];
- SMDS_ElemIteratorPtr it;
- int edgeInd = 2, i;
- for (i = 0, it = tria1->nodesIterator(); it->more(); i++) {
- a3Nodes[ i ] = static_cast<const SMDS_MeshNode*>(it->next());
- if (i > 0 && ( (a3Nodes[ i ] == aNode1 && a3Nodes[ i - 1] == aNode2) ||
- (a3Nodes[ i ] == aNode2 && a3Nodes[ i - 1] == aNode1) ) ) {
- edgeInd = i - 1;
- break;
- }
- }
- newIndices.Add(-edgeInd-1);
+ newIndices.push_back( aNode1->GetID() );
+ newIndices.push_back( aNode2->GetID() );
myOkBtn->setEnabled(true);
myApplyBtn->setEnabled(true);
}
- mySelector->AddOrRemoveIndex(anIO,newIndices, false);
+ mySelector->AddOrRemoveCompositeIndex(anIO, newIndices, false);
SMESH::GetViewWindow(mySMESHGUI)->highlight( anIO, true, true );
}
}
if(SMDS_Mesh* aMesh = aVisualObj->GetMesh())
{
const SMDS_MeshElement* tria[2];
- if( SMESH::GetEdgeNodes( mySelector, aVisualObj, anId1, anId2 ) >= 1 &&
+
+ bool valid = false;
+ SVTK_IndexedMapOfIds anIds;
+ mySelector->GetCompositeIndex(anIO,anIds);
+ if( anIds.Extent() == 1 && anIds(1).size() == 2 ) {
+ anId1 = anIds(1)[0];
+ anId2 = anIds(1)[1];
+ valid = true;
+ }
+
+ if( valid &&
findTriangles( aMesh->FindNode( anId1 ), aMesh->FindNode( anId2 ), tria[0],tria[1] ) )
{
QString aText = QString("%1-%2").arg(anId1).arg(anId2);
//=================================================================================
bool SMESHGUI_SingleEditDlg::onApply()
{
- if (mySMESHGUI->isActiveStudyLocked())
+ if (SMESHGUI::isStudyLocked())
return false;
// verify validity of input data
if (!isValid(true))
// update actor
if (aResult) {
mySelector->ClearIndex();
+ mySelector->ClearCompositeIndex();
mySelectionMgr->setSelectedObjects(aList, false);
onSelectionDone();
SMESH::UpdateView();
namespace SMESH
{
- typedef std::map<TKeyOfVisualObj,TVisualObjPtr> TVisualObjCont;
+ typedef std::map<std::string,TVisualObjPtr> TVisualObjCont;
static TVisualObjCont VISUAL_OBJ_CONT;
//=============================================================================
}
}
- if (aViewManager ) {
- int aStudyId = aViewManager->study()->id();
- TVisualObjCont::key_type aKey(aStudyId,theEntry);
- TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(aKey);
- if(anIter != VISUAL_OBJ_CONT.end()) {
- // for unknown reason, object destructor is not called, so clear object manually
- anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
- anIter->second->GetUnstructuredGrid()->SetPoints(0);
- }
- VISUAL_OBJ_CONT.erase(aKey);
+ TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(theEntry);
+ if(anIter != VISUAL_OBJ_CONT.end()) {
+ // for unknown reason, object destructor is not called, so clear object manually
+ anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
+ anIter->second->GetUnstructuredGrid()->SetPoints(0);
}
+ VISUAL_OBJ_CONT.erase(theEntry);
if(actorRemoved)
aStudy->setVisibilityState(theEntry, Qtx::HiddenState);
*/
//================================================================================
- void RemoveVisuData(int studyID)
+ void RemoveVisuData()
{
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
( SUIT_Session::session()->activeApplication() );
ViewManagerList viewMgrs = app->viewManagers();
for ( int iM = 0; iM < viewMgrs.count(); ++iM ) {
SUIT_ViewManager* aViewManager = viewMgrs.at( iM );
- if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type() &&
- aViewManager->study()->id() == studyID ) {
+ if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type() ) {
QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
for ( int iV = 0; iV < views.count(); ++iV ) {
if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
}
TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin();
for ( ; anIter != VISUAL_OBJ_CONT.end(); ) {
- int curId = anIter->first.first;
- if ( curId == studyID ) {
- // for unknown reason, object destructor is not called, so clear object manually
- anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
- anIter->second->GetUnstructuredGrid()->SetPoints(0);
- VISUAL_OBJ_CONT.erase( anIter++ ); // anIter++ returns a copy of self before incrementing
- }
- else {
- anIter++;
- }
+ // for unknown reason, object destructor is not called, so clear object manually
+ anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
+ anIter->second->GetUnstructuredGrid()->SetPoints(0);
+ VISUAL_OBJ_CONT.erase( anIter++ ); // anIter++ returns a copy of self before incrementing
}
}
*/
//================================================================================
- TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry, bool nulData){
+ TVisualObjPtr GetVisualObj(const char* theEntry, bool nulData){
TVisualObjPtr aVisualObj;
- TVisualObjCont::key_type aKey(theStudyId,theEntry);
try{
OCC_CATCH_SIGNALS;
- TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(aKey);
+ TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(theEntry);
if(anIter != VISUAL_OBJ_CONT.end()){
aVisualObj = anIter->second;
}else{
SalomeApp_Application* app =
dynamic_cast<SalomeApp_Application*>( SMESHGUI::activeStudy()->application() );
- _PTR(Study) aStudy = SMESHGUI::activeStudy()->studyDS();
+ _PTR(Study) aStudy = SMESH::getStudy();
_PTR(SObject) aSObj = aStudy->FindObjectID(theEntry);
if(aSObj){
_PTR(GenericAttribute) anAttr;
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj);
if(!aMesh->_is_nil()){
aVisualObj.reset(new SMESH_MeshObj(aMesh));
- TVisualObjCont::value_type aValue(aKey,aVisualObj);
+ TVisualObjCont::value_type aValue(theEntry,aVisualObj);
VISUAL_OBJ_CONT.insert(aValue);
}
//Try narrow to SMESH_Group interface
aFatherSObj = aFatherSObj->GetFather();
if(!aFatherSObj) return aVisualObj;
CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
- TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in());
+ TVisualObjPtr aVisObj = GetVisualObj(anEntry.in());
if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj));
- TVisualObjCont::value_type aValue(aKey,aVisualObj);
+ TVisualObjCont::value_type aValue(theEntry,aVisualObj);
VISUAL_OBJ_CONT.insert(aValue);
}
}
aFatherSObj = aFatherSObj->GetFather();
if(!aFatherSObj) return aVisualObj;
CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
- TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in());
+ TVisualObjPtr aVisObj = GetVisualObj(anEntry.in());
if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj));
- TVisualObjCont::value_type aValue(aKey,aVisualObj);
+ TVisualObjCont::value_type aValue(theEntry,aVisualObj);
VISUAL_OBJ_CONT.insert(aValue);
}
}
}
if ( objModified ) {
- // PAL16631. Mesurements showed that to show aVisualObj in SHADING(default) mode,
+ // PAL16631. Measurements showed that to show aVisualObj in SHADING(default) mode,
// ~5 times more memory is used than it occupies.
// Warn the user if there is less free memory than 30 sizes of a grid
// TODO: estimate memory usage in other modes and take current mode into account
/*! Return active view window, if it instantiates SVTK_ViewWindow class,
- * overwise find or create corresponding view window, make it active and return it.
+ * otherwise find or create corresponding view window, make it active and return it.
* \note Active VVTK_ViewWindow can be returned, because it inherits SVTK_ViewWindow.
*/
SVTK_ViewWindow* GetViewWindow (const SalomeApp_Module* theModule,
return NULL;
if(!CORBA::is_nil(theObject)){
- _PTR(Study) aStudy = GetActiveStudyDocument();
+ _PTR(Study) aStudy = getStudy();
CORBA::String_var anIOR = app->orb()->object_to_string( theObject );
_PTR(SObject) aSObject = aStudy->FindObjectIOR(anIOR.in());
if(aSObject){
}
- SMESH_Actor* CreateActor(_PTR(Study) theStudy,
- const char* theEntry,
+ SMESH_Actor* CreateActor(const char* theEntry,
int theIsClear)
{
SMESH_Actor *anActor = NULL;
- CORBA::Long anId = theStudy->StudyId();
- if(TVisualObjPtr aVisualObj = GetVisualObj(anId,theEntry)){
- _PTR(SObject) aSObj = theStudy->FindObjectID(theEntry);
+ if(TVisualObjPtr aVisualObj = GetVisualObj(theEntry)){
+ _PTR(SObject) aSObj = getStudy()->FindObjectID(theEntry);
if(aSObj){
_PTR(GenericAttribute) anAttr;
if(aSObj->FindAttribute(anAttr,"AttributeName")){
Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
if(anIO->hasEntry()){
std::string anEntry = anIO->getEntry();
- SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( vtkWnd->getViewManager()->study() );
- int aStudyId = aStudy->id();
- TVisualObjCont::key_type aKey(aStudyId,anEntry);
- VISUAL_OBJ_CONT.erase(aKey);
+ VISUAL_OBJ_CONT.erase(anEntry);
}
}
theActor->Delete();
{
//MESSAGE("---");
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(theWnd->getViewManager()->study());
- _PTR(Study) aDocument = aStudy->studyDS();
- // Pass non-visual objects (hypotheses, etc.), return true in this case
- CORBA::Long anId = aDocument->StudyId();
TVisualObjPtr aVisualObj;
- if ( (aVisualObj = GetVisualObj(anId,theEntry)) && aVisualObj->IsValid())
+ if ( (aVisualObj = GetVisualObj(theEntry)) && aVisualObj->IsValid())
{
- if ((anActor = CreateActor(aDocument,theEntry,true))) {
+ if ((anActor = CreateActor(theEntry,true))) {
bool needFitAll = noSmeshActors(theWnd); // fit for the first object only
DisplayActor(theWnd,anActor);
anActor->SetVisibility(true);
bool Update(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
{
//MESSAGE("Update");
- _PTR(Study) aStudy = GetActiveStudyDocument();
- CORBA::Long anId = aStudy->StudyId();
- if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry())) {
+ if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(theIO->getEntry())) {
if ( theDisplay )
UpdateView(SMESH::eDisplay,theIO->getEntry());
return true;
bool UpdateNulData(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
{
//MESSAGE("UpdateNulData");
- _PTR(Study) aStudy = GetActiveStudyDocument();
- CORBA::Long anId = aStudy->StudyId();
- if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry(), true)) {
+ if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(theIO->getEntry(), true)) {
if ( theDisplay )
UpdateView(SMESH::eDisplay,theIO->getEntry());
return true;
<source>MED_FILES_FILTER</source>
<translation>MED files</translation>
</message>
+ <message>
+ <source>SAUV_FILES_FILTER</source>
+ <translation>SAUV files</translation>
+ </message>
<message>
<source>IDEAS_FILES_FILTER</source>
<translation>IDEAS files</translation>
<source>TEXT_FILES_FILTER</source>
<translation>TXT files</translation>
</message>
- <message>
- <source>MED_VX_FILES_FILTER</source>
- <translation>MED %1 files</translation>
- </message>
<message>
<source>STL_FILES_FILTER</source>
<translation>STL files</translation>
<source>CGNS_FILES_FILTER</source>
<translation>CGNS files</translation>
</message>
+ <message>
+ <source>CGNS_EXPORT_ELEMS_BY_TYPE</source>
+ <translation>Group elements by type</translation>
+ </message>
<message>
<source>GMF_ASCII_FILES_FILTER</source>
<translation>GMF ASCII files</translation>
<source>MIN_DIAG_ELEMENTS</source>
<translation>Minimum diagonal</translation>
</message>
+ <message>
+ <source>MIN_ELEM_EDGE</source>
+ <translation>Minimum Edge Length</translation>
+ </message>
<message>
<source>ASPECTRATIO_3D_ELEMENTS</source>
<translation>Aspect Ratio 3D</translation>
<source>LENGTH2D_EDGES</source>
<translation>Length 2D</translation>
</message>
+ <message>
+ <source>DEFLECTION2D_FACES</source>
+ <translation>Deflection 2D</translation>
+ </message>
<message>
<source>LENGTH_EDGES</source>
<translation>Length</translation>
<source>MAX_ELEMENT_LENGTH_3D</source>
<translation>Element Diameter 3D</translation>
</message>
+ <message>
+ <source>DEFLECTION_2D</source>
+ <translation>Deflection 2D</translation>
+ </message>
<message>
<source>MEN_ADD</source>
<translation>Add</translation>
<source>MEN_LENGTH_2D</source>
<translation>Length 2D</translation>
</message>
+ <message>
+ <source>MEN_DEFLECTION_2D</source>
+ <translation>Deflection 2D</translation>
+ </message>
<message>
<source>MEN_MAP</source>
<translation>Pattern Mapping</translation>
<source>MEN_QUADRATIC_PENTAHEDRON</source>
<translation>Quadratic Pentahedron</translation>
</message>
+ <message>
+ <source>MEN_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>BiQuadratic Pentahedron</translation>
+ </message>
<message>
<source>MEN_QUADRATIC_PYRAMID</source>
<translation>Quadratic Pyramid</translation>
<source>SMESH_ADD_QUADRATIC_PENTAHEDRON_TITLE</source>
<translation>Add Quadratic Pentahedron</translation>
</message>
+ <message>
+ <source>SMESH_ADD_BIQUADRATIC_PENTAHEDRON_TITLE</source>
+ <translation>Add BiQuadratic Pentahedron</translation>
+ </message>
<message>
<source>SMESH_ADD_QUADRATIC_PYRAMID_TITLE</source>
<translation>Add Quadratic Pyramid</translation>
<source>SMESH_EXPORT_ONLY_GPOUP</source>
<translation>You are going to export the group without its mesh.
Do you want to continue?</translation>
- </message>
- <message>
- <source>SMESH_EXPORT_MED_V2_1</source>
- <translation>During export mesh with name - "%1" to MED 2.1
-polygons and polyhedrons elements will be missed
-For correct export use MED 2.2
-Are you sure want to export to MED 2.1?</translation>
</message>
<message>
<source>SMESH_EXPORT_MED_VERSION_COLLISION</source>
</message>
<message>
<source>SMESH_MESHINFO_ALL_TYPES</source>
- <translation>Heterogenous</translation>
+ <translation>Heterogeneous</translation>
</message>
<message>
<source>SMESH_MESHINFO_EDGES</source>
<source>SMESH_QUADRATIC_PENTAHEDRON</source>
<translation>Quadratic Pentahedron</translation>
</message>
+ <message>
+ <source>SMESH_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>BiQuadratic Pentahedron</translation>
+ </message>
<message>
<source>SMESH_QUADRATIC_PENTAHEDRONS</source>
<translation>Quadratic Pentahedrons</translation>
</message>
+ <message>
+ <source>SMESH_BIQUADRATIC_PENTAHEDRONS</source>
+ <translation>BiQuadratic Pentahedrons</translation>
+ </message>
<message>
<source>SMESH_QUADRATIC_PYRAMID</source>
<translation>Quadratic Pyramid</translation>
<source>STB_LENGTH_2D</source>
<translation>Length 2D</translation>
</message>
+ <message>
+ <source>STB_DEFLECTION_2D</source>
+ <translation>Deflection 2D</translation>
+ </message>
<message>
<source>STB_MAP</source>
<translation>Pattern mapping</translation>
<source>STB_QUADRATIC_PENTAHEDRON</source>
<translation>Quadratic Pentahedron</translation>
</message>
+ <message>
+ <source>STB_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>BiQuadratic Pentahedron</translation>
+ </message>
<message>
<source>STB_QUADRATIC_PYRAMID</source>
<translation>Quadratic Pyramid</translation>
<source>TOP_LENGTH_2D</source>
<translation>Length 2D</translation>
</message>
+ <message>
+ <source>TOP_DEFLECTION_2D</source>
+ <translation>Deflection 2D</translation>
+ </message>
<message>
<source>TOP_MAP</source>
<translation>Pattern mapping</translation>
<source>TOP_QUADRATIC_PENTAHEDRON</source>
<translation>Quadratic Pentahedron</translation>
</message>
+ <message>
+ <source>TOP_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>BiQuadratic Pentahedron</translation>
+ </message>
<message>
<source>TOP_QUADRATIC_PYRAMID</source>
<translation>Quadratic Pyramid</translation>
<source>SMESH_ADD_QUADRATIC_PENTAHEDRON</source>
<translation>Add Quadratic Pentahedron</translation>
</message>
+ <message>
+ <source>SMESH_ADD_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>Add BiQuadratic Pentahedron</translation>
+ </message>
<message>
<source>SMESH_ADD_QUADRATIC_PYRAMID</source>
<translation>Add Quadratic Pyramid</translation>
<source>LENGTH2D</source>
<translation>Length 2D</translation>
</message>
+ <message>
+ <source>DEFLECTION2D</source>
+ <translation>Deflection 2D</translation>
+ </message>
<message>
<source>LESS_THAN</source>
<translation>Less than</translation>
</message>
<message>
<source>ENTITY_TYPE_21</source>
- <translation>OCTA12</translation>
+ <translation>PENTA18</translation>
</message>
<message>
<source>ENTITY_TYPE_22</source>
- <translation>POLYEDRE</translation>
+ <translation>OCTA12</translation>
</message>
<message>
<source>ENTITY_TYPE_23</source>
- <translation>QPOLYEDRE</translation>
+ <translation>POLYEDRE</translation>
</message>
<message>
<source>ENTITY_TYPE_24</source>
+ <translation>QPOLYEDRE</translation>
+ </message>
+ <message>
+ <source>ENTITY_TYPE_25</source>
<translation>BALL</translation>
</message>
<message>
<source>MED_FILES_FILTER</source>
<translation>Fichiers MED</translation>
</message>
+ <message>
+ <source>SAUV_FILES_FILTER</source>
+ <translation>Fichiers SAUV</translation>
+ </message>
<message>
<source>IDEAS_FILES_FILTER</source>
<translation>Fichiers IDEAS</translation>
<source>TEXT_FILES_FILTER</source>
<translation>Fichiers TXT</translation>
</message>
- <message>
- <source>MED_VX_FILES_FILTER</source>
- <translation>Fichiers MED %1</translation>
- </message>
<message>
<source>STL_FILES_FILTER</source>
<translation>Fichiers STL</translation>
<source>CGNS_FILES_FILTER</source>
<translation>Fichiers CGNS</translation>
</message>
+ <message>
+ <source>CGNS_EXPORT_ELEMS_BY_TYPE</source>
+ <translation>Groupe les éléments par type</translation>
+ </message>
<message>
<source>GMF_ASCII_FILES_FILTER</source>
<translation>Fichiers GMF ASCII</translation>
<source>MEN_DEL_GROUP</source>
<translation>Supprimer les groupes et leur contenu</translation>
</message>
+ <message>
+ <source>MEN_ADD_TO_GROUP</source>
+ <translation>Ajoute dans le groupe</translation>
+ </message>
+ <message>
+ <source>MEN_REMOVE_FROM_GROUP</source>
+ <translation>Supprime du groupe</translation>
+ </message>
+ <message>
+ <source>STB_ADD_TO_GROUP</source>
+ <translation>Ajoute dans le groupe les éléments sélectionnés</translation>
+ </message>
+ <message>
+ <source>STB_REMOVE_FROM_GROUP</source>
+ <translation>Supprime du groupe les éléments sélectionnés</translation>
+ </message>
<message>
<source>MEN_FACE_ORIENTATION</source>
<translation>Orientation des faces</translation>
<source>MEN_QUADRATIC_PENTAHEDRON</source>
<translation>Pentaèdre quadratique</translation>
</message>
+ <message>
+ <source>MEN_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>Pentaèdre biquadratique</translation>
+ </message>
<message>
<source>MEN_QUADRATIC_PYRAMID</source>
<translation>Pyramide quadratique</translation>
<source>SMESH_ADD_QUADRATIC_PENTAHEDRON_TITLE</source>
<translation>Ajouter un pentaèdre quadratique</translation>
</message>
+ <message>
+ <source>SMESH_ADD_BIQUADRATIC_PENTAHEDRON_TITLE</source>
+ <translation>Ajouter un pentaèdre biquadratique</translation>
+ </message>
<message>
<source>SMESH_ADD_QUADRATIC_PYRAMID_TITLE</source>
<translation>Ajouter une pyramide quadratique</translation>
<source>SMESH_EXPORT_ONLY_GPOUP</source>
<translation>Vous allez export le groupe sans son maillage.
Voulez-vous continuer ?</translation>
- </message>
- <message>
- <source>SMESH_EXPORT_MED_V2_1</source>
- <translation>Les éléments polygonaux et polyèdriques seront omis
-dans le cas d'exportation du maillage "%1" à MED 2.1
-Utilisez MED 2.2 pour l'exportation correcte.
-Voulez-vous effectuer l'exportation à MED 2.1 ?</translation>
</message>
<message>
<source>SMESH_EXPORT_MED_VERSION_COLLISION</source>
<source>SMESH_QUADRATIC_PENTAHEDRON</source>
<translation>Pentaèdre quadratique</translation>
</message>
+ <message>
+ <source>SMESH_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>Pentaèdre biquadratique</translation>
+ </message>
<message>
<source>SMESH_QUADRATIC_PENTAHEDRONS</source>
<translation>Pentaèdres quadratiques</translation>
</message>
+ <message>
+ <source>SMESH_BIQUADRATIC_PENTAHEDRONS</source>
+ <translation>Pentaèdres biquadratiques</translation>
+ </message>
<message>
<source>SMESH_QUADRATIC_PYRAMID</source>
<translation>Pyramide quadratique</translation>
<source>STB_QUADRATIC_PENTAHEDRON</source>
<translation>Pentaèdre quadratique</translation>
</message>
+ <message>
+ <source>STB_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>Pentaèdre biquadratique</translation>
+ </message>
<message>
<source>STB_QUADRATIC_PYRAMID</source>
<translation>Pyramide quadratique</translation>
<source>TOP_QUADRATIC_PENTAHEDRON</source>
<translation>Pentaèdre quadratique</translation>
</message>
+ <message>
+ <source>TOP_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>Pentaèdre biquadratique</translation>
+ </message>
<message>
<source>TOP_QUADRATIC_PYRAMID</source>
<translation>Pyramide quadratique</translation>
<source>SMESH_ADD_QUADRATIC_PENTAHEDRON</source>
<translation>Ajouter un pentaèdre quadratique</translation>
</message>
+ <message>
+ <source>SMESH_ADD_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>Ajouter un pentaèdre biquadratique</translation>
+ </message>
<message>
<source>SMESH_ADD_QUADRATIC_PYRAMID</source>
<translation>Ajouter une pyramide quadratique</translation>
<source>SEPARATE_CORNERS_AND_MEDIUM</source>
<translation>Pas de fusion du coin et des noeuds moyens des cellules quadratiques</translation>
</message>
+ <message>
+ <source>AVOID_MAKING_HOLES</source>
+ <translation>Evite de créer des trous</translation>
+ </message>
<message>
<source>KEEP_NODES</source>
<translation>Les noeuds à conserver pendant la fusion</translation>
</message>
<message>
<source>ENTITY_TYPE_21</source>
- <translation>OCTA12</translation>
+ <translation>PENTA18</translation>
</message>
<message>
<source>ENTITY_TYPE_22</source>
- <translation>POLYEDRE</translation>
+ <translation>OCTA12</translation>
</message>
<message>
<source>ENTITY_TYPE_23</source>
- <translation>QPOLYEDRE</translation>
+ <translation>POLYEDRE</translation>
</message>
<message>
<source>ENTITY_TYPE_24</source>
+ <translation>QPOLYEDRE</translation>
+ </message>
+ <message>
+ <source>ENTITY_TYPE_25</source>
<translation>BALL</translation>
</message>
<message>
<source>SMESH_CREATE_GROUP_FROM_GEOM</source>
<translation>Créer des groupes à partir de la géométrie</translation>
</message>
+ <message>
+ <source>ELEMENTS</source>
+ <translation>Eléments</translation>
+ </message>
+ <message>
+ <source>ELEMENTS_TOOLTIP</source>
+ <translation>Pas d'éléments 0D</translation>
+ </message>
</context>
<context>
<name>SMESHGUI_MeshOrderDlg</name>
<source>ELEM_MODE</source>
<translation>Elément</translation>
</message>
+ <message>
+ <source>SHOW_IDS</source>
+ <translation>Montre les IDs</translation>
+ </message>
<message>
<source>BUT_DUMP_MESH</source>
<translation>&Dump</translation>
<source>MED_FILES_FILTER</source>
<translation>MEDファイル</translation>
</message>
+ <message>
+ <source>SAUV_FILES_FILTER</source>
+ <translation>SAUVファイル</translation>
+ </message>
<message>
<source>IDEAS_FILES_FILTER</source>
<translation>IDEAS ファイル</translation>
<source>TEXT_FILES_FILTER</source>
<translation>TXT ファイル</translation>
</message>
- <message>
- <source>MED_VX_FILES_FILTER</source>
- <translation>ファイル MED %1</translation>
- </message>
<message>
<source>STL_FILES_FILTER</source>
<translation>STL ファイル</translation>
<source>CGNS_FILES_FILTER</source>
<translation>CGNS ファイル</translation>
</message>
+ <message>
+ <source>CGNS_EXPORT_ELEMS_BY_TYPE</source>
+ <translation>タイプで要素をグループ化</translation>
+ </message>
<message>
<source>GMF_ASCII_FILES_FILTER</source>
<translation>GMFアスキーファイル</translation>
<source>MEN_DEL_GROUP</source>
<translation>グループとその内容を削除します。</translation>
</message>
+ <message>
+ <source>MEN_ADD_TO_GROUP</source>
+ <translation>グループに追加</translation>
+ </message>
+ <message>
+ <source>MEN_REMOVE_FROM_GROUP</source>
+ <translation>グループから削除</translation>
+ </message>
+ <message>
+ <source>STB_ADD_TO_GROUP</source>
+ <translation>選択要素をグループに追加</translation>
+ </message>
+ <message>
+ <source>STB_REMOVE_FROM_GROUP</source>
+ <translation>選択要素をグループから削除</translation>
+ </message>
<message>
<source>MEN_FACE_ORIENTATION</source>
<translation>フェースの向き</translation>
<source>MEN_QUADRATIC_PENTAHEDRON</source>
<translation>二次ウェッジ</translation>
</message>
+ <message>
+ <source>MEN_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>4次五面体</translation>
+ </message>
<message>
<source>MEN_QUADRATIC_PYRAMID</source>
<translation>四角錐</translation>
<source>SMESH_ADD_QUADRATIC_PENTAHEDRON_TITLE</source>
<translation>二次くさびを追加します。</translation>
</message>
+ <message>
+ <source>SMESH_ADD_BIQUADRATIC_PENTAHEDRON_TITLE</source>
+ <translation>4次五面体の追加</translation>
+ </message>
<message>
<source>SMESH_ADD_QUADRATIC_PYRAMID_TITLE</source>
<translation>四角錐を追加します。</translation>
<source>SMESH_EXPORT_ONLY_GPOUP</source>
<translation>そのメッシュなしでグループのエクスポートをしようとしています。続行しますか?</translation>
</message>
- <message>
- <source>SMESH_EXPORT_MED_V2_1</source>
- <translation>多角形、多面体要素は正しいエクスポート用 MED 2.1 MED 2.2 にメッシュ '%' のエクスポートの場合省略されます。MED 2.1 をエクスポートしますか。</translation>
- </message>
<message>
<source>SMESH_EXPORT_MED_VERSION_COLLISION</source>
<translation>ファイル「%1」MED バージョンは知られていないか、選択したバージョンと一致しません。ファイルを上書きしますか。</translation>
<source>SMESH_QUADRATIC_PENTAHEDRON</source>
<translation>二次ウェッジ</translation>
</message>
+ <message>
+ <source>SMESH_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>4次五面体</translation>
+ </message>
<message>
<source>SMESH_QUADRATIC_PENTAHEDRONS</source>
<translation>二次ウェッジ</translation>
</message>
+ <message>
+ <source>SMESH_BIQUADRATIC_PENTAHEDRONS</source>
+ <translation>4次五面体</translation>
+ </message>
<message>
<source>SMESH_QUADRATIC_PYRAMID</source>
<translation>四角錐</translation>
<source>STB_QUADRATIC_PENTAHEDRON</source>
<translation>二次ウェッジ</translation>
</message>
+ <message>
+ <source>STB_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>4次五面体</translation>
+ </message>
<message>
<source>STB_QUADRATIC_PYRAMID</source>
<translation>四角錐</translation>
<source>TOP_QUADRATIC_PENTAHEDRON</source>
<translation>二次ウェッジ</translation>
</message>
+ <message>
+ <source>TOP_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>4次五面体</translation>
+ </message>
<message>
<source>TOP_QUADRATIC_PYRAMID</source>
<translation>四角錐</translation>
<source>SMESH_ADD_QUADRATIC_PENTAHEDRON</source>
<translation>二次くさびを追加します。</translation>
</message>
+ <message>
+ <source>SMESH_ADD_BIQUADRATIC_PENTAHEDRON</source>
+ <translation>4次五面体の追加</translation>
+ </message>
<message>
<source>SMESH_ADD_QUADRATIC_PYRAMID</source>
<translation>二次ピラミッドの追加</translation>
<source>SEPARATE_CORNERS_AND_MEDIUM</source>
<translation>2次セルのコーナ節点と中間節点をマージできません</translation>
</message>
+ <message>
+ <source>AVOID_MAKING_HOLES</source>
+ <translation>穴作成の回避</translation>
+ </message>
<message>
<source>KEEP_NODES</source>
<translation>維持節点</translation>
<source>ENTITY_TYPE_24</source>
<translation>ボール</translation>
</message>
+ <message>
+ <source>ENTITY_TYPE_25</source>
+ <translation>ボール</translation>
+ </message>
<message>
<source>GEOM_TYPE</source>
<translation>ジオメトリの種類</translation>
<source>SMESH_CREATE_GROUP_FROM_GEOM</source>
<translation>ジオメトリからグループを作成</translation>
</message>
+ <message>
+ <source>ELEMENTS</source>
+ <translation>要素</translation>
+ </message>
+ <message>
+ <source>ELEMENTS_TOOLTIP</source>
+ <translation>0D要素がない</translation>
+ </message>
</context>
<context>
<name>SMESHGUI_MeshOrderDlg</name>
<source>ELEM_MODE</source>
<translation>要素</translation>
</message>
+ <message>
+ <source>SHOW_IDS</source>
+ <translation>IDの表示</translation>
+ </message>
<message>
<source>BUT_DUMP_MESH</source>
<translation>書き出し(&D)</translation>
#include <unistd.h>
#endif
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyObject ,Standard_Transient);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyCommand ,Standard_Transient);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesisReader,Standard_Transient);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyGen ,_pyObject);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyMesh ,_pyObject);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pySubMesh ,_pyObject);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyMeshEditor ,_pyObject);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesis ,_pyObject);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pySelfEraser ,_pyObject);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyGroup ,_pyObject);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyFilter ,_pyObject);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyAlgorithm ,_pyHypothesis);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyComplexParamHypo,_pyHypothesis);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyNumberOfSegmentsHyp,_pyHypothesis);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pyLayerDistributionHypo,_pyHypothesis);
- OCCT_IMPLEMENT_STANDARD_RTTIEXT(_pySegmentLengthAroundVertexHyp,_pyHypothesis);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyObject ,Standard_Transient);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyCommand ,Standard_Transient);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesisReader,Standard_Transient);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyGen ,_pyObject);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyMesh ,_pyObject);
+ IMPLEMENT_STANDARD_RTTIEXT(_pySubMesh ,_pyObject);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyMeshEditor ,_pyObject);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesis ,_pyObject);
+ IMPLEMENT_STANDARD_RTTIEXT(_pySelfEraser ,_pyObject);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyGroup ,_pyObject);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyFilter ,_pyObject);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyAlgorithm ,_pyHypothesis);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyComplexParamHypo,_pyHypothesis);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyNumberOfSegmentsHyp,_pyHypothesis);
+ IMPLEMENT_STANDARD_RTTIEXT(_pyLayerDistributionHypo,_pyHypothesis);
+ IMPLEMENT_STANDARD_RTTIEXT(_pySegmentLengthAroundVertexHyp,_pyHypothesis);
using namespace std;
using SMESH::TPythonDump;
/*!
* \brief Container of commands into which the initial script is split.
- * It also contains data coresponding to SMESH_Gen contents
+ * It also contains data corresponding to SMESH_Gen contents
*/
static Handle(_pyGen) theGen;
_AString comment;
_pyID obj = cmd->GetObject();
- if ( obj.Search( "print " ) == 1 )
+ if ( obj.Search( "print(" ) == 1 )
return; // print statement
if ( !obj.IsEmpty() && obj.Value( obj.Length() ) == ')' )
// - FT_BelongToMeshGroup = 22
// v 8.1.0: FT_Undefined == 48, new items:
// - FT_NodeConnectivityNumber= 22
+ // v 8.5.0: FT_Undefined == 49, new items:
+ // - FT_Deflection2D = 22
//
// It's necessary to continue recording this history and to fill
// undef2newItems (see below) accordingly.
undef2newItems[ 46 ].push_back( 39 );
undef2newItems[ 47 ].push_back( 22 );
undef2newItems[ 48 ].push_back( 22 );
+ undef2newItems[ 49 ].push_back( 22 );
ASSERT( undef2newItems.rbegin()->first == SMESH::FT_Undefined );
}
}
}
}
+
+ bool _FilterArg( const _AString& theArg )
+ {
+ static std::list<_AString> filteredArgs;
+ static bool initialized = false;
+ if ( !initialized ) {
+ initialized = true;
+ filteredArgs.push_back( "SMESH.MED_V2_1" );
+ filteredArgs.push_back( "SMESH.MED_V2_2" );
+ }
+ return std::find( filteredArgs.begin(), filteredArgs.end(), theArg ) != filteredArgs.end();
+ }
}
//================================================================================
Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
std::set< TCollection_AsciiString >& theRemovedObjIDs,
- SALOMEDS::Study_ptr& theStudy,
const bool theToKeepAllCommands)
{
std::list< TCollection_AsciiString >::iterator lineIt;
theGen = new _pyGen( theEntry2AccessorMethod,
theObjectNames,
theRemovedObjIDs,
- theStudy,
theToKeepAllCommands );
for ( lineIt = theScriptLines.begin(); lineIt != theScriptLines.end(); ++lineIt )
set<_pyID> createdObjects;
createdObjects.insert( "smeshBuilder" );
createdObjects.insert( "smesh" );
- createdObjects.insert( "theStudy" );
for ( cmd = theGen->GetCommands().begin(); cmd != theGen->GetCommands().end(); ++cmd )
{
#ifdef DUMP_CONVERSION
_pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
std::set< TCollection_AsciiString >& theRemovedObjIDs,
- SALOMEDS::Study_ptr& theStudy,
const bool theToKeepAllCommands)
: _pyObject( new _pyCommand( "", 0 )),
myNbCommands( 0 ),
myRemovedObjIDs( theRemovedObjIDs ),
myNbFilters( 0 ),
myToKeepAllCommands( theToKeepAllCommands ),
- myStudy( SALOMEDS::Study::_duplicate( theStudy )),
myGeomIDNb(0), myGeomIDIndex(-1)
{
// make that GetID() to return TPythonDump::SMESHGenName()
GetCreationCmd()->GetString() += "=";
// Find 1st digit of study entry by which a GEOM object differs from a SMESH object
- if ( !theObjectNames.IsEmpty() && !CORBA::is_nil( theStudy ))
+ if ( !theObjectNames.IsEmpty() )
{
// find a GEOM entry
_pyID geomID;
- SALOMEDS::SComponent_wrap geomComp = theStudy->FindComponent("GEOM");
+ SALOMEDS::SComponent_wrap geomComp = SMESH_Gen_i::getStudyServant()->FindComponent("GEOM");
if ( geomComp->_is_nil() ) return;
CORBA::String_var entry = geomComp->GetID();
geomID = entry.in();
//================================================================================
/*!
* \brief Convert a command using a specific converter
- * \param theCommand - the command to convert
+ * \param theCommand - the command to convert
*/
//================================================================================
_AString newCmd = indent + tab + ( aCommand->GetString().ToCString() + indent.Length() );
_AString pasCmd = indent + tab + "pass"; // to keep valid if newCmd is erased
_AString excStr = indent + "except:";
- _AString msgStr = indent + "\tprint '"; msgStr += method + "() failed. Invalid file name?'";
+ _AString msgStr = indent + "\tprint('"; msgStr += method + "() failed. Invalid file name?')";
myCommands.insert( --myCommands.end(), new _pyCommand( tryStr, myNbCommands ));
aCommand->Clear();
aCommand->GetString() += tmpCmd.GetString();
}
// IMP issue 0021014
- // set GetCriterion(elementType,CritType,Compare,Treshold,UnaryOp,BinaryOp,Tolerance)
- // 1 2 3 4 5 6 7
+ // set GetCriterion(elementType,CritType,Compare,Threshold,UnaryOp,BinaryOp,Tolerance)
+ // 1 2 3 4 5 6 7
// instead of "SMESH.Filter.Criterion(
// Type,Compare,Threshold,ThresholdStr,ThresholdID,UnaryOp,BinaryOp,Tolerance,TypeOfElement,Precision)
// 1 2 3 4 5 6 7 8 9 10
"Entity_Polygon", "Entity_Quad_Polygon", "Entity_Tetra", "Entity_Quad_Tetra",
"Entity_Pyramid", "Entity_Quad_Pyramid",
"Entity_Hexa", "Entity_Quad_Hexa", "Entity_TriQuad_Hexa",
- "Entity_Penta", "Entity_Quad_Penta", "Entity_Hexagonal_Prism",
+ "Entity_Penta", "Entity_Quad_Penta", "Entity_BiQuad_Penta", "Entity_Hexagonal_Prism",
"Entity_Polyhedra", "Entity_Quad_Polyhedra", "Entity_Ball" };
if ( -1 < iGeom && iGeom < nbTypes )
Threshold = SMESH + types[ iGeom ];
//================================================================================
/*!
* \brief Convert the command or remember it for later conversion
- * \param theCommand - The python command calling a method of SMESH_Gen
+ * \param theCommand - The python command calling a method of SMESH_Gen
*/
//================================================================================
static TStringSet smeshpyMethods;
if ( smeshpyMethods.empty() ) {
const char * names[] =
- { "SetEmbeddedMode","IsEmbeddedMode","SetCurrentStudy","GetCurrentStudy",
+ { "SetEmbeddedMode","IsEmbeddedMode","UpdateStudy","GetStudy",
"GetPattern","GetSubShapesId",
"" }; // <- mark of array end
smeshpyMethods.Insert( names );
//================================================================================
/*!
* \brief Add access method to mesh that is an argument
- * \param theCmd - command to add access method
- * \retval bool - true if added
+ * \param theCmd - command to add access method
+ * \retval bool - true if added
*/
//================================================================================
//================================================================================
/*!
* \brief Add access method to algo that is an object or an argument
- * \param theCmd - command to add access method
- * \retval bool - true if added
+ * \param theCmd - command to add access method
+ * \retval bool - true if added
*/
//================================================================================
//================================================================================
/*!
* \brief Find hypothesis by ID (entry)
- * \param theHypID - The hypothesis ID
- * \retval Handle(_pyHypothesis) - The found hypothesis
+ * \param theHypID - The hypothesis ID
+ * \retval Handle(_pyHypothesis) - The found hypothesis
*/
//================================================================================
//================================================================================
/*!
* \brief Find algorithm able to create a hypothesis
- * \param theGeom - The shape ID the algorithm was created on
- * \param theMesh - The mesh ID that created the algorithm
- * \param theHypothesis - The hypothesis the algorithm should be able to create
- * \retval Handle(_pyHypothesis) - The found algo
+ * \param theGeom - The shape ID the algorithm was created on
+ * \param theMesh - The mesh ID that created the algorithm
+ * \param theHypothesis - The hypothesis the algorithm should be able to create
+ * \retval Handle(_pyHypothesis) - The found algo
*/
//================================================================================
//================================================================================
/*!
* \brief Find subMesh by ID (entry)
- * \param theSubMeshID - The subMesh ID
- * \retval Handle(_pySubMesh) - The found subMesh
+ * \param theSubMeshID - The subMesh ID
+ * \retval Handle(_pySubMesh) - The found subMesh
*/
//================================================================================
//================================================================================
/*!
* \brief Change order of commands in the script
- * \param theCmd1 - One command
- * \param theCmd2 - Another command
+ * \param theCmd1 - One command
+ * \param theCmd2 - Another command
*/
//================================================================================
int nb1 = theCmd1->GetOrderNb();
theCmd1->SetOrderNb( theCmd2->GetOrderNb() );
theCmd2->SetOrderNb( nb1 );
- // cout << "BECOME " << theCmd1->GetOrderNb() << "\t" << theCmd1->GetString() << endl
- // << "BECOME " << theCmd2->GetOrderNb() << "\t" << theCmd2->GetString() << endl << endl;
+ // cout << "BECOME " << theCmd1->GetOrderNb() << "\t" << theCmd1->GetString() << endl
+ // << "BECOME " << theCmd2->GetOrderNb() << "\t" << theCmd2->GetString() << endl << endl;
}
//================================================================================
/*!
* \brief Set one command after the other
- * \param theCmd - Command to move
- * \param theAfterCmd - Command ater which to insert the first one
+ * \param theCmd - Command to move
+ * \param theAfterCmd - Command ater which to insert the first one
*/
//================================================================================
//================================================================================
/*!
* \brief Set one command before the other
- * \param theCmd - Command to move
- * \param theBeforeCmd - Command before which to insert the first one
+ * \param theCmd - Command to move
+ * \param theBeforeCmd - Command before which to insert the first one
*/
//================================================================================
//================================================================================
/*!
* \brief Set one command before or after the other
- * \param theCmd - Command to move
- * \param theOtherCmd - Command ater or before which to insert the first one
+ * \param theCmd - Command to move
+ * \param theOtherCmd - Command ater or before which to insert the first one
*/
//================================================================================
// void _pyGen::addFilterUser( Handle(_pyCommand)& theCommand, const Handle(_pyObject)& user )
// {
- // No more needed after adding _pyObject::myArgCommands
+ // No more needed after adding _pyObject::myArgCommands
// const char filterPrefix[] = "aFilter0x";
// if ( theCommand->GetString().Search( filterPrefix ) < 1 )
//================================================================================
/*!
* \brief Set command be last in list of commands
- * \param theCmd - Command to be last
+ * \param theCmd - Command to be last
*/
//================================================================================
//================================================================================
/*!
* \brief Set method to access to object wrapped with python class
- * \param theID - The wrapped object entry
- * \param theMethod - The accessor method
+ * \param theID - The wrapped object entry
+ * \param theMethod - The accessor method
*/
//================================================================================
//================================================================================
/*!
* \brief Generated new ID for object and assign with existing name
- * \param theID - ID of existing object
+ * \param theID - ID of existing object
*/
//================================================================================
}
else if ( theObj->IsKind( STANDARD_TYPE( _pyMeshEditor ))) {
add = myMeshEditors.insert( make_pair( theObj->GetID(),
- Handle(_pyMeshEditor)::DownCast( theObj ))).second;
+ Handle(_pyMeshEditor)::DownCast( theObj ))).second;
}
else {
add = myObjects.insert( make_pair( theObj->GetID(), theObj )).second;
// either the SMESH object is not in study or it is a GEOM object
if ( IsGeomObject( theObjID ))
{
- SALOMEDS::SObject_wrap so = myStudy->FindObjectID( theObjID.ToCString() );
+ SALOMEDS::SObject_wrap so = SMESH_Gen_i::getStudyServant()->FindObjectID( theObjID.ToCString() );
if ( so->_is_nil() ) return true;
CORBA::Object_var obj = so->GetObject();
return CORBA::is_nil( obj );
//================================================================================
/*!
* \brief Convert an IDL API command of SMESH::SMESH_Mesh to a method call of python Mesh
- * \param theCommand - Engine method called for this mesh
+ * \param theCommand - Engine method called for this mesh
*/
//================================================================================
// ----------------------------------------------------------------------
else if ( theCommand->MethodStartsFrom( "Export" ))
{
- if ( method == "ExportToMED" || // ExportToMED() --> ExportMED()
- method == "ExportToMEDX" ) // ExportToMEDX() --> ExportMED()
+ if ( method == "ExportToMED" || // ExportToMED() --> ExportMED()
+ method == "ExportToMEDX" || // ExportToMEDX() --> ExportMED()
+ method == "ExportMED" )
{
theCommand->SetMethod( "ExportMED" );
- if ( theCommand->GetNbArgs() == 5 )
+ // filter out deprecated version parameter
+ vector< _AString > args;
+ for ( int i = 1; i <= theCommand->GetNbArgs(); i++ ) {
+ if ( !_FilterArg( theCommand->GetArg( i ) ) )
+ args.push_back( theCommand->GetArg( i ) );
+ }
+ theCommand->RemoveArgs();
+ for ( uint i = 0; i < args.size(); i++ )
+ theCommand->SetArg( i+1, args[i] );
+ if ( theCommand->GetNbArgs() == 4 )
{
// ExportToMEDX(...,autoDimension) -> ExportToMEDX(...,meshPart=None,autoDimension)
- _AString autoDimension = theCommand->GetArg( 5 );
- theCommand->SetArg( 5, "None" );
- theCommand->SetArg( 6, autoDimension );
+ _AString autoDimension = theCommand->GetArg( 4 );
+ theCommand->SetArg( 4, "None" );
+ theCommand->SetArg( 5, autoDimension );
}
}
else if ( method == "ExportCGNS" )
TCollection_AsciiString newMethod = method;
newMethod.Remove( /*where=*/7, /*howmany=*/6 );
theCommand->SetMethod( newMethod );
+ // filter out deprecated version parameter
+ vector< _AString > args;
+ for ( int i = 1; i <= theCommand->GetNbArgs(); i++ ) {
+ if ( !_FilterArg( theCommand->GetArg( i ) ) )
+ args.push_back( theCommand->GetArg( i ) );
+ }
+ theCommand->RemoveArgs();
+ for ( uint i = 0; i < args.size(); i++ )
+ theCommand->SetArg( i+1, args[i] );
// make the 1st arg be the last one (or last but three for ExportMED())
_pyID partID = theCommand->GetArg( 1 );
int nbArgs = theCommand->GetNbArgs() - 3 * (newMethod == "ExportMED");
const char * names[] =
{ "ExportDAT","ExportUNV","ExportSTL","ExportSAUV", "RemoveGroup","RemoveGroupWithContents",
"GetGroups","UnionGroups","IntersectGroups","CutGroups","CreateDimGroup","GetLog","GetId",
- "ClearLog","GetStudyId","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
+ "ClearLog","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
"NbEdges","NbEdgesOfOrder","NbFaces","NbFacesOfOrder","NbTriangles",
"NbTrianglesOfOrder","NbQuadrangles","NbQuadranglesOfOrder","NbPolygons","NbVolumes",
"NbVolumesOfOrder","NbTetras","NbTetrasOfOrder","NbHexas","NbHexasOfOrder",
"ExtrusionAlongPathX","ExtrusionAlongPathObject1D","ExtrusionAlongPathObject2D",
"ExtrusionSweepObjects","RotationSweepObjects","ExtrusionAlongPathObjects",
"Mirror","MirrorObject","Translate","TranslateObject","Rotate","RotateObject",
- "FindCoincidentNodes","MergeNodes","FindEqualElements",
+ "FindCoincidentNodes","MergeNodes","FindEqualElements","FillHole",
"MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders",
"FindCoincidentFreeBorders", "SewCoincidentFreeBorders",
"SewBorderToSide","SewSideElements","ChangeElemNodes","GetLastCreatedNodes",
//================================================================================
/*!
* \brief _pyHypothesis constructor
- * \param theCreationCmd -
+ * \param theCreationCmd -
*/
//================================================================================
//================================================================================
/*!
* \brief Creates algorithm or hypothesis
- * \param theCreationCmd - The engine command creating a hypothesis
- * \retval Handle(_pyHypothesis) - Result _pyHypothesis
+ * \param theCreationCmd - The engine command creating a hypothesis
+ * \retval Handle(_pyHypothesis) - Result _pyHypothesis
*/
//================================================================================
//================================================================================
/*!
* \brief Convert the command adding a hypothesis to mesh into a smesh command
- * \param theCmd - The command like mesh.AddHypothesis( geom, hypo )
- * \param theAlgo - The algo that can create this hypo
- * \retval bool - false if the command can't be converted
+ * \param theCmd - The command like mesh.AddHypothesis( geom, hypo )
+ * \param theAlgo - The algo that can create this hypo
+ * \retval bool - false if the command can't be converted
*/
//================================================================================
//================================================================================
/*!
* \brief Remember hypothesis parameter values
- * \param theCommand - The called hypothesis method
+ * \param theCommand - The called hypothesis method
*/
//================================================================================
//================================================================================
/*!
* \brief Remember hypothesis parameter values
- * \param theCommand - The called hypothesis method
+ * \param theCommand - The called hypothesis method
*/
//================================================================================
{
CreationMethod& crMethod = type2meth->second;
while ( (int) crMethod.myArgs.size() < i+1 )
- crMethod.myArgs.push_back( "[]" );
- crMethod.myArgs[ i ] = theCommand->GetArg( 1 ); // arg value
+ crMethod.myArgs.push_back( "[]" );
+ crMethod.myArgs[ i ] = theCommand->GetArg( 1 ); // arg value
}
myArgCommands.push_back( theCommand );
}
//================================================================================
/*!
* \brief Convert methods of 1D hypotheses to my own methods
- * \param theCommand - The called hypothesis method
+ * \param theCommand - The called hypothesis method
*/
//================================================================================
//================================================================================
/*!
* \brief
- * \param theAdditionCmd - command to be converted
- * \param theMesh - mesh instance
- * \retval bool - status
+ * \param theAdditionCmd - command to be converted
+ * \param theMesh - mesh instance
+ * \retval bool - status
*/
//================================================================================
//================================================================================
/*!
* \brief additionally to Addition2Creation, clears SetDistrType() command
- * \param theCmd - AddHypothesis() command
- * \param theMesh - mesh to which a hypothesis is added
- * \retval bool - conversion result
+ * \param theCmd - AddHypothesis() command
+ * \param theMesh - mesh to which a hypothesis is added
+ * \retval bool - conversion result
*/
//================================================================================
/*!
* \brief Convert the command adding "SegmentLengthAroundVertex" to mesh
* into regular1D.LengthNearVertex( length, vertex )
- * \param theCmd - The command like mesh.AddHypothesis( vertex, SegmentLengthAroundVertex )
- * \param theMesh - The mesh needing this hypo
- * \retval bool - false if the command can't be converted
+ * \param theCmd - The command like mesh.AddHypothesis( vertex, SegmentLengthAroundVertex )
+ * \param theMesh - The mesh needing this hypo
+ * \retval bool - false if the command can't be converted
*/
//================================================================================
//================================================================================
/*!
* \brief _pyAlgorithm constructor
- * \param theCreationCmd - The command like "algo = smeshgen.CreateHypothesis(type,lib)"
+ * \param theCreationCmd - The command like "algo = smeshgen.CreateHypothesis(type,lib)"
*/
//================================================================================
//================================================================================
/*!
* \brief Convert the command adding an algorithm to mesh
- * \param theCmd - The command like mesh.AddHypothesis( geom, algo )
- * \param theMesh - The mesh needing this algo
- * \retval bool - false if the command can't be converted
+ * \param theCmd - The command like mesh.AddHypothesis( geom, algo )
+ * \param theMesh - The mesh needing this algo
+ * \retval bool - false if the command can't be converted
*/
//================================================================================
//================================================================================
/*!
* \brief Return starting position of a part of python command
- * \param thePartIndex - The index of command part
- * \retval int - Part position
+ * \param thePartIndex - The index of command part
+ * \retval int - Part position
*/
//================================================================================
//================================================================================
/*!
* \brief Store starting position of a part of python command
- * \param thePartIndex - The index of command part
- * \param thePosition - Part position
+ * \param thePartIndex - The index of command part
+ * \param thePosition - Part position
*/
//================================================================================
//================================================================================
/*!
* \brief Returns whitespace symbols at the line beginning
- * \retval TCollection_AsciiString - result
+ * \retval TCollection_AsciiString - result
*/
//================================================================================
//================================================================================
/*!
* \brief Return substring of python command looking like ResultValue = Obj.Meth()
- * \retval const TCollection_AsciiString & - ResultValue substring
+ * \retval const TCollection_AsciiString & - ResultValue substring
*/
//================================================================================
//================================================================================
/*!
* \brief Return substring of python command looking like ResVal = Obj.Method()
- * \retval const TCollection_AsciiString & - Method substring
+ * \retval const TCollection_AsciiString & - Method substring
*/
//================================================================================
//================================================================================
/*!
* \brief Return substring of python command looking like ResVal = Obj.Meth(Arg1,...)
- * \retval const TCollection_AsciiString & - Arg<index> substring
+ * \retval const TCollection_AsciiString & - Arg<index> substring
*/
//================================================================================
//================================================================================
/*!
* \brief Check if char is a word part
- * \param c - The character to check
- * \retval bool - The check result
+ * \param c - The character to check
+ * \retval bool - The check result
*/
//================================================================================
//================================================================================
/*!
* \brief Looks for a word in the string and returns word's beginning
- * \param theString - The input string
- * \param theStartPos - The position to start the search, returning word's beginning
- * \param theForward - The search direction
- * \retval TCollection_AsciiString - The found word
+ * \param theString - The input string
+ * \param theStartPos - The position to start the search, returning word's beginning
+ * \param theForward - The search direction
+ * \retval TCollection_AsciiString - The found word
*/
//================================================================================
//================================================================================
/*!
* \brief Look for position where not space char is
- * \param theString - The string
- * \param thePos - The position to search from and which returns result
- * \retval bool - false if there are only space after thePos in theString
+ * \param theString - The string
+ * \param thePos - The position to search from and which returns result
+ * \retval bool - false if there are only space after thePos in theString
*/
//================================================================================
//================================================================================
/*!
* \brief Modify a part of the command
- * \param thePartIndex - The index of the part
- * \param thePart - The new part string
- * \param theOldPart - The old part
+ * \param thePartIndex - The index of the part
+ * \param thePart - The new part string
+ * \param theOldPart - The old part
*/
//================================================================================
void _pyCommand::SetPart(int thePartIndex, const TCollection_AsciiString& thePart,
- TCollection_AsciiString& theOldPart)
+ TCollection_AsciiString& theOldPart)
{
int pos = GetBegPos( thePartIndex );
if ( pos <= Length() && theOldPart != thePart)
//================================================================================
/*!
* \brief Set agrument
- * \param index - The argument index, it counts from 1
- * \param theArg - The argument string
+ * \param index - The argument index, it counts from 1
+ * \param theArg - The argument string
*/
//================================================================================
//================================================================================
/*!
* \brief Insert accessor method after theObjectID
- * \param theObjectID - id of the accessed object
- * \param theAcsMethod - name of the method giving access to the object
- * \retval bool - false if theObjectID is not found in the command string
+ * \param theObjectID - id of the accessed object
+ * \param theAcsMethod - name of the method giving access to the object
+ * \retval bool - false if theObjectID is not found in the command string
*/
//================================================================================
//================================================================================
/*!
* \brief Return method name giving access to an interaface object wrapped by python class
- * \retval const char* - method name
+ * \retval const char* - method name
*/
//================================================================================
bool _pySubMesh::CanBeArgOfMethod(const _AString& theMethodName)
{
return false;
- // // names of all methods where a sub-mesh can be used as argument
- // static TStringSet methods;
- // if ( methods.empty() ) {
- // const char * names[] = {
- // // methods of SMESH_Gen
- // "CopyMesh",
- // // methods of SMESH_Group
- // "AddFrom",
- // // methods of SMESH_Measurements
- // "MinDistance",
- // // methods of SMESH_Mesh
- // "ExportPartToMED","ExportCGNS","ExportPartToDAT","ExportPartToUNV","ExportPartToSTL",
- // "RemoveSubMesh",
- // // methods of SMESH_MeshEditor
- // "ReorientObject","Reorient2D","TriToQuadObject","QuadToTriObject","SplitQuadObject",
- // "SplitVolumesIntoTetra","SmoothObject","SmoothParametricObject","ConvertFromQuadraticObject",
- // "RotationSweepObject","RotationSweepObjectMakeGroups","RotationSweepObject1D",
- // "RotationSweepObject1DMakeGroups","RotationSweepObject2D","RotationSweepObject2DMakeGroups",
- // "ExtrusionSweepObject","ExtrusionSweepObjectMakeGroups","ExtrusionSweepObject0D",
- // "ExtrusionSweepObject0DMakeGroups","ExtrusionSweepObject1D","ExtrusionSweepObject2D",
- // "ExtrusionSweepObject1DMakeGroups","ExtrusionSweepObject2DMakeGroups",
- // "ExtrusionAlongPathObjX","ExtrusionAlongPathObject","ExtrusionAlongPathObjectMakeGroups",
- // "ExtrusionAlongPathObject1D","ExtrusionAlongPathObject1DMakeGroups",
- // "ExtrusionAlongPathObject2D","ExtrusionAlongPathObject2DMakeGroups","MirrorObject",
- // "MirrorObjectMakeGroups","MirrorObjectMakeMesh","TranslateObject","Scale",
- // "TranslateObjectMakeGroups","TranslateObjectMakeMesh","ScaleMakeGroups","ScaleMakeMesh",
- // "RotateObject","RotateObjectMakeGroups","RotateObjectMakeMesh","FindCoincidentNodesOnPart",
- // "FindCoincidentNodesOnPartBut","FindEqualElements","FindAmongElementsByPoint",
- // "MakeBoundaryMesh","Create0DElementsOnAllNodes",
- // "" }; // <- mark of end
- // methods.Insert( names );
- // }
- // return methods.Contains( theMethodName );
+ // names of all methods where a sub-mesh can be used as argument
+ // static TStringSet methods;
+ // if ( methods.empty() ) {
+ // const char * names[] = {
+ // // methods of SMESH_Gen
+ // "CopyMesh",
+ // // methods of SMESH_Group
+ // "AddFrom",
+ // // methods of SMESH_Measurements
+ // "MinDistance",
+ // // methods of SMESH_Mesh
+ // "ExportPartToMED","ExportCGNS","ExportPartToDAT","ExportPartToUNV","ExportPartToSTL",
+ // "RemoveSubMesh",
+ // // methods of SMESH_MeshEditor
+ // "ReorientObject","Reorient2D","TriToQuadObject","QuadToTriObject","SplitQuadObject",
+ // "SplitVolumesIntoTetra","SmoothObject","SmoothParametricObject","ConvertFromQuadraticObject",
+ // "RotationSweepObject","RotationSweepObjectMakeGroups","RotationSweepObject1D",
+ // "RotationSweepObject1DMakeGroups","RotationSweepObject2D","RotationSweepObject2DMakeGroups",
+ // "ExtrusionSweepObject","ExtrusionSweepObjectMakeGroups","ExtrusionSweepObject0D",
+ // "ExtrusionSweepObject0DMakeGroups","ExtrusionSweepObject1D","ExtrusionSweepObject2D",
+ // "ExtrusionSweepObject1DMakeGroups","ExtrusionSweepObject2DMakeGroups",
+ // "ExtrusionAlongPathObjX","ExtrusionAlongPathObject","ExtrusionAlongPathObjectMakeGroups",
+ // "ExtrusionAlongPathObject1D","ExtrusionAlongPathObject1DMakeGroups",
+ // "ExtrusionAlongPathObject2D","ExtrusionAlongPathObject2DMakeGroups","MirrorObject",
+ // "MirrorObjectMakeGroups","MirrorObjectMakeMesh","TranslateObject","Scale",
+ // "TranslateObjectMakeGroups","TranslateObjectMakeMesh","ScaleMakeGroups","ScaleMakeMesh",
+ // "RotateObject","RotateObjectMakeGroups","RotateObjectMakeMesh","FindCoincidentNodesOnPart",
+ // "FindCoincidentNodesOnPartBut","FindEqualElements","FindAmongElementsByPoint",
+ // "MakeBoundaryMesh","Create0DElementsOnAllNodes",
+ // "" }; // <- mark of end
+ // methods.Insert( names );
+ // }
+ // return methods.Contains( theMethodName );
}
//================================================================================
//}
//else {
// ------------------------->>>>> GroupOnGeom( geom, name, typ )
- _pyID type = theCreationCmd->GetArg( 1 );
- _pyID name = theCreationCmd->GetArg( 2 );
- theCreationCmd->SetMethod( "GroupOnGeom" );
- theCreationCmd->RemoveArgs();
- theCreationCmd->SetArg( 1, geom );
- theCreationCmd->SetArg( 2, name );
- theCreationCmd->SetArg( 3, type );
+ _pyID type = theCreationCmd->GetArg( 1 );
+ _pyID name = theCreationCmd->GetArg( 2 );
+ theCreationCmd->SetMethod( "GroupOnGeom" );
+ theCreationCmd->RemoveArgs();
+ theCreationCmd->SetArg( 1, geom );
+ theCreationCmd->SetArg( 2, name );
+ theCreationCmd->SetArg( 3, type );
//}
}
else if ( method == "CreateGroupFromFilter" )
#include <vector>
#include <set>
- #include <Basics_OCCTVersion.hxx>
-
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOMEDS)
bool AddAccessorMethod( _pyID theObjectID, const char* theAcsMethod );
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyCommand,Standard_Transient)
+ DEFINE_STANDARD_RTTIEXT(_pyCommand,Standard_Transient)
};
// -------------------------------------------------------------------------------------
virtual void ClearCommands();
virtual void Free() {}
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyObject,Standard_Transient)
+ DEFINE_STANDARD_RTTIEXT(_pyObject,Standard_Transient)
};
// -------------------------------------------------------------------------------------
_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
std::set< TCollection_AsciiString >& theRemovedObjIDs,
- SALOMEDS::Study_ptr& theStudy,
const bool theToKeepAllCommands);
Handle(_pyCommand) AddCommand( const _AString& theCommand );
void ExchangeCommands( Handle(_pyCommand) theCmd1, Handle(_pyCommand) theCmd2 );
Handle(_pyCommand) myLastCommand;
int myNbFilters;
bool myToKeepAllCommands;
- SALOMEDS::Study_var myStudy;
int myGeomIDNb, myGeomIDIndex;
std::map< _AString, ExportedMeshData > myFile2ExportedMesh;
Handle( _pyHypothesisReader ) myHypReader;
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyGen,_pyObject)
+ DEFINE_STANDARD_RTTIEXT(_pyGen,_pyObject)
};
// -------------------------------------------------------------------------------------
static void AddMeshAccess( const Handle(_pyCommand)& theCommand )
{ theCommand->SetObject( theCommand->GetObject() + "." _pyMesh_ACCESS_METHOD ); }
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyMesh,_pyObject)
+ DEFINE_STANDARD_RTTIEXT(_pyMesh,_pyObject)
};
#undef _pyMesh_ACCESS_METHOD
virtual void Flush() {}
virtual bool CanClear();
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyMesh,_pyObject)
+ DEFINE_STANDARD_RTTIEXT(_pyMeshEditor,_pyObject)
};
// -------------------------------------------------------------------------------------
//void ComputeSaved ( const Handle(_pyCommand)& theComputeCommand );
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyHypothesis,_pyObject)
+ DEFINE_STANDARD_RTTIEXT(_pyHypothesis,_pyObject)
};
// -------------------------------------------------------------------------------------
virtual const char* AccessorMethod() const { return "GetAlgorithm()"; }
virtual bool IsWrappable(const _pyID& theMesh) { return !myIsWrapped; }
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyAlgorithm,_pyHypothesis)
+ DEFINE_STANDARD_RTTIEXT(_pyAlgorithm,_pyHypothesis)
};
// -------------------------------------------------------------------------------------
virtual void Process( const Handle(_pyCommand)& theCommand);
virtual void Flush();
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyComplexParamHypo,_pyHypothesis)
+ DEFINE_STANDARD_RTTIEXT(_pyComplexParamHypo,_pyHypothesis)
};
DEFINE_STANDARD_HANDLE (_pyComplexParamHypo, _pyHypothesis);
const _pyID& theMesh);
virtual void Free() { my1dHyp.Nullify(); }
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyLayerDistributionHypo,_pyHypothesis)
+ DEFINE_STANDARD_RTTIEXT(_pyLayerDistributionHypo,_pyHypothesis)
};
DEFINE_STANDARD_HANDLE (_pyLayerDistributionHypo, _pyHypothesis);
const _pyID& theMesh);
void Flush();
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyNumberOfSegmentsHyp,_pyHypothesis)
+ DEFINE_STANDARD_RTTIEXT(_pyNumberOfSegmentsHyp,_pyHypothesis)
};
DEFINE_STANDARD_HANDLE (_pyNumberOfSegmentsHyp, _pyHypothesis);
_pySegmentLengthAroundVertexHyp(const Handle(_pyCommand)& theCrCmd): _pyHypothesis(theCrCmd) {}
virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
const _pyID& theMesh);
- OCCT_DEFINE_STANDARD_RTTIEXT(_pySegmentLengthAroundVertexHyp,_pyHypothesis)
+ DEFINE_STANDARD_RTTIEXT(_pySegmentLengthAroundVertexHyp,_pyHypothesis)
};
DEFINE_STANDARD_HANDLE (_pySegmentLengthAroundVertexHyp, _pyHypothesis);
virtual bool CanClear();
static bool IsAliveCmd( const Handle(_pyCommand)& theCmd );
- OCCT_DEFINE_STANDARD_RTTIEXT(_pySelfEraser,_pyObject)
+ DEFINE_STANDARD_RTTIEXT(_pySelfEraser,_pyObject)
};
DEFINE_STANDARD_HANDLE (_pySelfEraser, _pyObject);
void SetCreator( const Handle(_pyObject)& theCreator ) { myCreator = theCreator; }
static bool CanBeArgOfMethod(const _AString& theMethodName);
- OCCT_DEFINE_STANDARD_RTTIEXT(_pySubMesh,_pyObject)
+ DEFINE_STANDARD_RTTIEXT(_pySubMesh,_pyObject)
};
// -------------------------------------------------------------------------------------
/*!
//virtual void Free() { myUsers.clear(); }
const _pyID& GetNewID() const { return myNewID; }
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyFilter,_pyObject)
+ DEFINE_STANDARD_RTTIEXT(_pyFilter,_pyObject)
};
DEFINE_STANDARD_HANDLE (_pyFilter, _pyObject);
virtual bool CanClear();
void RemovedWithContents();
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyGroup,_pySubMesh)
+ DEFINE_STANDARD_RTTIEXT(_pyGroup,_pySubMesh)
};
// -------------------------------------------------------------------------------------
_pyHypothesisReader();
Handle(_pyHypothesis) GetHypothesis(const _AString& hypType,
const Handle(_pyCommand)& creationCmd) const;
- OCCT_DEFINE_STANDARD_RTTIEXT(_pyHypothesisReader,Standard_Transient)
+ DEFINE_STANDARD_RTTIEXT(_pyHypothesisReader,Standard_Transient)
};
#endif
#include <SALOMEDS_wrap.hxx>
#include <GEOM_wrap.hxx>
- #include <Basics_OCCTVersion.hxx>
-
#include <BRep_Tool.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_Plane.hxx>
if ( theName != 0 )
{
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
- if ( !aStudy->_is_nil() )
+ SALOMEDS::Study::ListOfSObject_var aList = SMESH_Gen_i::getStudyServant()->FindObjectByName( theName, "GEOM" );
+ if ( aList->length() > 0 )
{
- SALOMEDS::Study::ListOfSObject_var aList = aStudy->FindObjectByName( theName, "GEOM" );
- if ( aList->length() > 0 )
- {
- CORBA::Object_var anObj = aList[ 0 ]->GetObject();
- GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( anObj );
- TopoDS_Shape shape = aSMESHGen->GeomObjectToShape( aGeomObj );
- SALOME::UnRegister( aList ); // UnRegister() objects in aList
- return shape;
- }
+ CORBA::Object_var anObj = aList[ 0 ]->GetObject();
+ GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( anObj );
+ TopoDS_Shape shape = aSMESHGen->GeomObjectToShape( aGeomObj );
+ SALOME::UnRegister( aList ); // UnRegister() objects in aList
+ return shape;
}
}
return TopoDS_Shape();
{
if ( theID && strlen( theID ) > 0 ) {
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
- if ( !aStudy->_is_nil() ) {
- SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
- if ( !aSObj->_is_nil() ) {
- CORBA::Object_var obj = aSObj->GetObject();
- GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
- return aSMESHGen->GeomObjectToShape( aGeomObj );
- }
+ SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID(theID);
+ if ( !aSObj->_is_nil() ) {
+ CORBA::Object_var obj = aSObj->GetObject();
+ GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
+ return aSMESHGen->GeomObjectToShape( aGeomObj );
}
}
return TopoDS_Shape();
// static std::string getShapeNameByID (const char* theID)
// {
// if ( theID && strlen( theID ) > 0 ) {
-// SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
-// SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
-// if ( !aStudy->_is_nil() ) {
-// SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
-// if ( !aSObj->_is_nil() ) {
-// CORBA::String_var name = aSObj->GetName();
-// return name.in();
-// }
+// SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID(theID);
+// if ( !aSObj->_is_nil() ) {
+// CORBA::String_var name = aSObj->GetName();
+// return name.in();
// }
// }
// return "";
return aResult._retn();
}
+ /*
+ Class : Deflection2D_i
+ Description : Functor for calculating distance between a face and geometry
+ */
+ Deflection2D_i::Deflection2D_i()
+ {
+ myNumericalFunctorPtr.reset( new Controls::Deflection2D() );
+ myFunctorPtr = myNumericalFunctorPtr;
+ }
+
+ FunctorType Deflection2D_i::GetFunctorType()
+ {
+ return SMESH::FT_Deflection2D;
+ }
+
/*
Class : MultiConnection_i
Description : Functor for calculating number of faces conneted to the edge
}
else if ( strncmp( "0:", myID.c_str(), 2 ) == 0 ) // transient mode + GUI
{
- SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
- if ( !aStudy->_is_nil() ) {
- SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID( myID.c_str() );
- if ( !aSObj->_is_nil() ) {
- CORBA::Object_var obj = aSObj->GetObject();
- SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
- }
+ SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( myID.c_str() );
+ if ( !aSObj->_is_nil() ) {
+ CORBA::Object_var obj = aSObj->GetObject();
+ SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
}
}
else if ( !myID.empty() ) // persistent mode
{
// search for a group in a current study
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
- if ( StudyContext* sc = aSMESHGen->GetCurrentStudyContext() )
+ if ( StudyContext* sc = aSMESHGen->GetStudyContext() )
{
int id = 1;
std::string ior;
}
case SMESH::ConnectedElements::VERTEX: // get a VERTEX by its entry /////////////////
{
- SALOMEDS::Study_var study = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
- if ( study->_is_nil() )
- THROW_SALOME_CORBA_EXCEPTION
- ( "ConnectedElements_i::SetThreshold(): NULL current study", SALOME::BAD_PARAM );
- SALOMEDS::SObject_wrap sobj = study->FindObjectID( threshold );
+ SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( threshold );
if ( sobj->_is_nil() )
THROW_SALOME_CORBA_EXCEPTION
( "ConnectedElements_i::SetThreshold(): invalid vertex study entry", SALOME::BAD_PARAM );
return anObj._retn();
}
+ Deflection2D_ptr FilterManager_i::CreateDeflection2D()
+ {
+ SMESH::Deflection2D_i* aServant = new SMESH::Deflection2D_i();
+ SMESH::Deflection2D_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateLength2D()";
+ return anObj._retn();
+ }
+
MultiConnection_ptr FilterManager_i::CreateMultiConnection()
{
SMESH::MultiConnection_i* aServant = new SMESH::MultiConnection_i();
case SMESH::FT_Length2D:
aFunctor = aFilterMgr->CreateLength2D();
break;
+ case SMESH::FT_Deflection2D:
+ aFunctor = aFilterMgr->CreateDeflection2D();
+ break;
case SMESH::FT_AspectRatio:
aFunctor = aFilterMgr->CreateAspectRatio();
break;
case FT_EqualFaces : return "Equal faces";
case FT_EqualVolumes : return "Equal volumes";
case FT_MultiConnection : return "Borders at multi-connections";
- case FT_MultiConnection2D :return "Borders at multi-connections 2D";
+ case FT_MultiConnection2D : return "Borders at multi-connections 2D";
case FT_Length : return "Length";
case FT_Length2D : return "Length 2D";
+ case FT_Deflection2D : return "Deflection 2D";
case FT_LessThan : return "Less than";
case FT_MoreThan : return "More than";
case FT_EqualTo : return "Equal to";
case FT_LogicalOR : return "Or";
case FT_GroupColor : return "Color of Group";
case FT_LinearOrQuadratic : return "Linear or Quadratic";
- case FT_ElemGeomType : return "Element geomtry type";
+ case FT_ElemGeomType : return "Element geometry type";
case FT_EntityType : return "Entity type";
case FT_Undefined : return "";
default : return "";
// else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D;
else if ( theStr.equals( "Length" ) ) return FT_Length;
// else if ( theStr.equals( "Length2D" ) ) return FT_Length2D;
+ else if ( theStr.equals( "Deflection" ) ) return FT_Deflection2D;
else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds;
else if ( theStr.equals( "Bad Oriented Volume" ) ) return FT_BadOrientedVolume;
else if ( theStr.equals( "Volumes with bare border" ) ) return FT_BareBorderVolume;
else if ( theStr.equals( "Or" ) ) return FT_LogicalOR;
else if ( theStr.equals( "Color of Group" ) ) return FT_GroupColor;
else if ( theStr.equals( "Linear or Quadratic" ) ) return FT_LinearOrQuadratic;
- else if ( theStr.equals( "Element geomtry type" ) ) return FT_ElemGeomType;
+ else if ( theStr.equals( "Element geometry type" ) ) return FT_ElemGeomType;
else if ( theStr.equals( "Entity type" ) ) return FT_EntityType;
else if ( theStr.equals( "" ) ) return FT_Undefined;
else return FT_Undefined;
if ( myFileName == 0 || strlen( myFileName ) == 0 )
return false;
- #if OCC_VERSION_MAJOR < 7
- FILE* aOutFile = fopen( myFileName, "wt" );
- if ( !aOutFile )
- return false;
-
- LDOM_XmlWriter aWriter( aOutFile );
- aWriter.SetIndentation( 2 );
- aWriter << myDoc;
- fclose( aOutFile );
- #else
std::filebuf fb;
fb.open( myFileName, std::ios::out );
aWriter.SetIndentation( 2 );
aWriter.Write( os, myDoc );
fb.close();
- #endif
TPythonDump()<<this<<".Save()";
return true;
"FT_MultiConnection2D",
"FT_Length",
"FT_Length2D",
+ "FT_Deflection2D",
"FT_NodeConnectivityNumber",
"FT_BelongToMeshGroup",
"FT_BelongToGeom",
"FT_LinearOrQuadratic",
"FT_GroupColor",
"FT_ElemGeomType",
- "FT_EntityType",
+ "FT_EntityType",
"FT_CoplanarFaces",
"FT_BallDiameter",
"FT_ConnectedElements",
// Author : Paul RASCLE, EDF
// Module : SMESH
+ #include <BRepPrimAPI_MakeBox.hxx>
+ #include <BRepPrimAPI_MakeCylinder.hxx>
+ #include <BRepPrimAPI_MakeSphere.hxx>
+ #include <BRep_Tool.hxx>
+ #include <OSD.hxx>
+ #include <TColStd_MapOfAsciiString.hxx>
+ #include <TCollection_AsciiString.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
+ #include <TopTools_IndexedMapOfShape.hxx>
+ #include <TopTools_ListIteratorOfListOfShape.hxx>
+ #include <TopTools_ListOfShape.hxx>
+ #include <TopTools_MapOfShape.hxx>
#include <TopoDS.hxx>
- #include <TopoDS_Iterator.hxx>
- #include <TopoDS_Compound.hxx>
#include <TopoDS_CompSolid.hxx>
- #include <TopoDS_Solid.hxx>
- #include <TopoDS_Shell.hxx>
- #include <TopoDS_Face.hxx>
- #include <TopoDS_Wire.hxx>
+ #include <TopoDS_Compound.hxx>
#include <TopoDS_Edge.hxx>
- #include <TopoDS_Vertex.hxx>
+ #include <TopoDS_Face.hxx>
+ #include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
- #include <TopTools_MapOfShape.hxx>
- #include <TopTools_IndexedMapOfShape.hxx>
- #include <TopTools_ListOfShape.hxx>
- #include <TopTools_ListIteratorOfListOfShape.hxx>
+ #include <TopoDS_Shell.hxx>
+ #include <TopoDS_Solid.hxx>
+ #include <TopoDS_Vertex.hxx>
+ #include <TopoDS_Wire.hxx>
#include <gp_Pnt.hxx>
- #include <BRep_Tool.hxx>
- #include <TCollection_AsciiString.hxx>
- #include <OSD.hxx>
- #include <BRepPrimAPI_MakeSphere.hxx>
- #include <BRepPrimAPI_MakeCylinder.hxx>
- #include <BRepPrimAPI_MakeBox.hxx>
#ifdef WIN32
#define LoadLib( name ) LoadLibrary( name )
#define GetProc GetProcAddress
#define UnLoadLib( handle ) FreeLibrary( handle );
- #else
+ #else // WIN32
#define LibHandle void*
- #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL )
+ #ifdef DYNLOAD_LOCAL
+ #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_LOCAL )
+ #else // DYNLOAD_LOCAL
+ #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL )
+ #endif // DYNLOAD_LOCAL
#define GetProc dlsym
#define UnLoadLib( handle ) dlclose( handle );
- #endif
+ #endif // WIN32
#include "SMESH_Gen_i.hxx"
#include "SMESH_version.h"
#include <map>
#include <fstream>
+#include <sstream>
#include <cstdio>
#include <cstdlib>
_thisObj = this ;
_id = myPoa->activate_object( _thisObj );
+ myStudyContext = new StudyContext;
+
myIsEmbeddedMode = false;
+ myIsEnablePublish = true;
myShapeReader = NULL; // shape reader
mySMESHGen = this;
myIsHistoricalPythonDump = true;
myHypCreatorMap.clear();
// Clear study contexts data
- map<int, StudyContext*>::iterator it;
- for ( it = myStudyContextMap.begin(); it != myStudyContextMap.end(); ++it ) {
- delete it->second;
- }
- myStudyContextMap.clear();
+ delete myStudyContext;
+
// delete shape reader
if ( myShapeReader )
delete myShapeReader;
getHypothesisCreator(theHypName, theLibName, aPlatformLibName);
// create a new hypothesis object, store its ref. in studyContext
- myHypothesis_i = aCreator->Create(myPoa, GetCurrentStudyID(), &myGen);
+ myHypothesis_i = aCreator->Create(myPoa, &myGen);
if (myHypothesis_i)
{
myHypothesis_i->SetLibName( aPlatformLibName.c_str() ); // for persistency assurance
// Get or create the GEOM_Client instance
try {
// create a new mesh object servant, store it in a map in study context
- SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() );
+ SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this );
// create a new mesh object
if(MYDEBUG) MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode);
- meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode ));
+ meshServant->SetImpl( myGen.CreateMesh( myIsEmbeddedMode ));
// activate the CORBA servant of Mesh
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() );
//=============================================================================
/*!
- * SMESH_Gen_i::SetCurrentStudy
+ * SMESH_Gen_i::SetEnablePublish
*
- * Set current study
+ * Set enable publishing in the study
*/
//=============================================================================
-
-void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy )
+void SMESH_Gen_i::SetEnablePublish( CORBA::Boolean theIsEnablePublish )
{
- setCurrentStudy( theStudy );
+ myIsEnablePublish = theIsEnablePublish;
}
-void SMESH_Gen_i::setCurrentStudy( SALOMEDS::Study_ptr theStudy,
- bool theStudyIsBeingClosed)
+//=============================================================================
+/*!
+ * SMESH_Gen_i::IsEnablePublish
+ *
+ * Check enable publishing
+ */
+//=============================================================================
+
+CORBA::Boolean SMESH_Gen_i::IsEnablePublish()
{
- int curStudyId = GetCurrentStudyID();
- myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy );
- // create study context, if it doesn't exist and set current study
- int studyId = GetCurrentStudyID();
- if ( myStudyContextMap.find( studyId ) == myStudyContextMap.end() )
- myStudyContextMap[ studyId ] = new StudyContext;
-
- // myCurrentStudy may be nil
- if ( !theStudyIsBeingClosed && !CORBA::is_nil( myCurrentStudy ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
- SALOMEDS::SComponent_wrap GEOM_var = myCurrentStudy->FindComponent( "GEOM" );
- if( !GEOM_var->_is_nil() )
- aStudyBuilder->LoadWith( GEOM_var, GetGeomEngine() );
- // NPAL16168, issue 0020210
- // Let meshes update their data depending on GEOM groups that could change
- if ( curStudyId != studyId )
- {
- CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SComponent_wrap me = myCurrentStudy->FindComponent( compDataType.in() );
- if ( !me->_is_nil() ) {
- SALOMEDS::ChildIterator_wrap anIter = myCurrentStudy->NewChildIterator( me );
- for ( ; anIter->More(); anIter->Next() ) {
- SALOMEDS::SObject_wrap so = anIter->Value();
- CORBA::Object_var ior = SObjectToObject( so );
- if ( SMESH_Mesh_i* mesh = SMESH::DownCast<SMESH_Mesh_i*>( ior ))
- mesh->CheckGeomModif();
- }
- }
- }
- }
+ return myIsEnablePublish;
}
//=============================================================================
/*!
- * SMESH_Gen_i::GetCurrentStudy
+ * SMESH_Gen_i::UpdateStudy
*
- * Get current study
+ * Update study (needed at switching GEOM->SMESH)
*/
//=============================================================================
-SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy()
+void SMESH_Gen_i::UpdateStudy()
{
- if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetCurrentStudy: study Id = " << GetCurrentStudyID() );
- if ( GetCurrentStudyID() < 0 )
- return SALOMEDS::Study::_nil();
- return SALOMEDS::Study::_duplicate( myCurrentStudy );
+ if ( !myStudyContext )
+ myStudyContext = new StudyContext;
+
+ SALOMEDS::Study_var aStudy = getStudyServant();
+ if ( !CORBA::is_nil( aStudy ) ) {
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::SComponent_wrap GEOM_var = aStudy->FindComponent( "GEOM" );
+ if( !GEOM_var->_is_nil() )
+ aStudyBuilder->LoadWith( GEOM_var, GetGeomEngine() );
+ // NPAL16168, issue 0020210
+ // Let meshes update their data depending on GEOM groups that could change
+ CORBA::String_var compDataType = ComponentDataType();
+ SALOMEDS::SComponent_wrap me = aStudy->FindComponent( compDataType.in() );
+ if ( !me->_is_nil() ) {
+ SALOMEDS::ChildIterator_wrap anIter = aStudy->NewChildIterator( me );
+ for ( ; anIter->More(); anIter->Next() ) {
+ SALOMEDS::SObject_wrap so = anIter->Value();
+ CORBA::Object_var ior = SObjectToObject( so );
+ if ( SMESH_Mesh_i* mesh = SMESH::DownCast<SMESH_Mesh_i*>( ior ))
+ mesh->CheckGeomModif();
+ }
+ }
+ }
}
//=============================================================================
/*!
- * SMESH_Gen_i::GetCurrentStudyContext
+ * SMESH_Gen_i::GetStudyContext
*
- * Get current study context
+ * Get study context
*/
//=============================================================================
-StudyContext* SMESH_Gen_i::GetCurrentStudyContext()
+StudyContext* SMESH_Gen_i::GetStudyContext()
{
- if ( !CORBA::is_nil( myCurrentStudy ) &&
- myStudyContextMap.find( GetCurrentStudyID() ) != myStudyContextMap.end() )
- return myStudyContextMap[ myCurrentStudy->StudyId() ];
- else
- return 0;
+ return myStudyContext;
}
//=============================================================================
// Publish hypothesis/algorithm in the study
if ( CanPublishInStudy( hyp ) ) {
- SALOMEDS::SObject_wrap aSO = PublishHypothesis( myCurrentStudy, hyp );
+ SALOMEDS::SObject_wrap aSO = PublishHypothesis( hyp );
if ( !aSO->_is_nil() ) {
// Update Python script
TPythonDump() << aSO << " = " << this << ".CreateHypothesis('"
SMESH::SMESH_Mesh_out theMesh,
GEOM::GEOM_Object_out theShape)
{
- if ( GetCurrentStudyID() < 0 || CORBA::is_nil( theHyp ))
+ if ( CORBA::is_nil( theHyp ))
return false;
// get Mesh component SO
CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SComponent_wrap comp = myCurrentStudy->FindComponent( compDataType.in() );
+ SALOMEDS::SComponent_wrap comp = getStudyServant()->FindComponent( compDataType.in() );
if ( CORBA::is_nil( comp ))
return false;
SMESH::SMESH_Mesh_var foundMesh;
TopoDS_Shape foundShape;
bool isSole = true;
- SALOMEDS::ChildIterator_wrap meshIter = myCurrentStudy->NewChildIterator( comp );
+ SALOMEDS::ChildIterator_wrap meshIter = getStudyServant()->NewChildIterator( comp );
for ( ; meshIter->More() && isSole; meshIter->Next() )
{
SALOMEDS::SObject_wrap curSO = meshIter->Value();
// publish mesh in the study
if ( CanPublishInStudy( mesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishMesh( myCurrentStudy, mesh.in() );
+ SALOMEDS::SObject_wrap aSO = PublishMesh( mesh.in() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
// publish mesh in the study
if ( CanPublishInStudy( mesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishMesh( myCurrentStudy, mesh.in() );
+ SALOMEDS::SObject_wrap aSO = PublishMesh( mesh.in() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
string aFileName;
// publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishMesh( myCurrentStudy, aMesh.in(), aFileName.c_str() );
+ SALOMEDS::SObject_wrap aSO = PublishMesh( aMesh.in(), aFileName.c_str() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
if (theStatus == SMESH::DRS_OK) {
SALOMEDS::StudyBuilder_var aStudyBuilder;
- if ( GetCurrentStudyID() > -1 )
- {
- aStudyBuilder = myCurrentStudy->NewBuilder();
- aStudyBuilder->NewCommand(); // There is a transaction
- }
+ aStudyBuilder = getStudyServant()->NewBuilder();
+ aStudyBuilder->NewCommand(); // There is a transaction
+
aResult->length( aNames.size() );
int i = 0;
// little trick: for MED file theFileName and theFileNameForPython are the same, but they are different for SAUV
// - as names of meshes are stored in MED file, we use them for data publishing
// - as mesh name is not stored in UNV file, we use file name as name of mesh when publishing data
- aSO = PublishMesh( myCurrentStudy, mesh.in(), ( theFileName == theFileNameForPython ) ? (*it).c_str() : aFileName.c_str() );
+ aSO = PublishMesh( mesh.in(), ( theFileName == theFileNameForPython ) ? (*it).c_str() : aFileName.c_str() );
// Python Dump
if ( !aSO->_is_nil() ) {
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import convert ; convert(r'" + sauvfilename + "', 'GIBI', 'MED', 1, r'" + medfilename + "')";
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
- cmd = "python ";
+ cmd = "python3 ";
#endif
cmd += "-c \"";
cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
#endif
// publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishInStudy
- ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
+ SALOMEDS::SObject_wrap aSO = PublishInStudy( SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
if (theStatus == SMESH::DRS_OK)
{
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
int i = 0;
// publish mesh in the study
SALOMEDS::SObject_wrap aSO;
if ( CanPublishInStudy( mesh ) )
- aSO = PublishMesh( myCurrentStudy, mesh.in(), meshName.c_str() );
+ aSO = PublishMesh( mesh.in(), meshName.c_str() );
// Python Dump
if ( !aSO->_is_nil() ) {
#endif
// publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) {
- SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
- SALOMEDS::SObject_wrap aSO = PublishInStudy
- ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
+ SALOMEDS::SObject_wrap aSO = PublishInStudy( SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) {
// Update Python script
SALOMEDS::SObject_ptr SMESH_Gen_i::GetAlgoSO(const ::SMESH_Algo* algo)
{
if ( algo ) {
- if ( !myCurrentStudy->_is_nil() ) {
+ SALOMEDS::Study_var aStudy = getStudyServant();
+ if ( !aStudy->_is_nil() ) {
// find algo in the study
CORBA::String_var compDataType = ComponentDataType();
- SALOMEDS::SComponent_wrap father = myCurrentStudy->FindComponent( compDataType.in() );
+ SALOMEDS::SComponent_wrap father = aStudy->FindComponent( compDataType.in() );
if ( !father->_is_nil() ) {
- SALOMEDS::ChildIterator_wrap itBig = myCurrentStudy->NewChildIterator( father );
+ SALOMEDS::ChildIterator_wrap itBig = aStudy->NewChildIterator( father );
for ( ; itBig->More(); itBig->Next() ) {
SALOMEDS::SObject_wrap gotBranch = itBig->Value();
if ( gotBranch->Tag() == GetAlgorithmsRootTag() ) {
- SALOMEDS::ChildIterator_wrap algoIt = myCurrentStudy->NewChildIterator( gotBranch );
+ SALOMEDS::ChildIterator_wrap algoIt = aStudy->NewChildIterator( gotBranch );
for ( ; algoIt->More(); algoIt->Next() ) {
SALOMEDS::SObject_wrap algoSO = algoIt->Value();
CORBA::Object_var algoIOR = SObjectToObject( algoSO );
GEOM::GEOM_Gen_ptr geomGen = GetGeomEngine();
// try to find the corresponding SObject
- SALOMEDS::SObject_wrap SObj = ObjectToSObject( myCurrentStudy, geom.in() );
+ SALOMEDS::SObject_wrap SObj = ObjectToSObject( geom.in() );
if ( SObj->_is_nil() ) // submesh can be not found even if published
{
// try to find published submesh
GEOM::ListOfLong_var list = geom->GetSubShapeIndices();
if ( !geom->IsMainShape() && list->length() == 1 ) {
- SALOMEDS::SObject_wrap mainSO = ObjectToSObject( myCurrentStudy, mainShape );
+ SALOMEDS::SObject_wrap mainSO = ObjectToSObject( mainShape );
SALOMEDS::ChildIterator_wrap it;
if ( !mainSO->_is_nil() ) {
- it = myCurrentStudy->NewChildIterator( mainSO );
+ it = getStudyServant()->NewChildIterator( mainSO );
}
if ( !it->_is_nil() ) {
for ( it->InitEx(true); it->More(); it->Next() ) {
}
}
if ( SObj->_is_nil() ) // publish a new subshape
- SObj = geomGen->AddInStudy( myCurrentStudy, geom, theGeomName, mainShape );
+ SObj = geomGen->AddInStudy( geom, theGeomName, mainShape );
// return only published geometry
if ( !SObj->_is_nil() ) {
GEOM::GEOM_Object_var geom = ShapeToGeomObject( meshDS->IndexToShape( shapeID ));
if ( geom->_is_nil() ) {
// try to find a published sub-shape
- SALOMEDS::SObject_wrap mainSO = ObjectToSObject( myCurrentStudy, mainShape );
+ SALOMEDS::SObject_wrap mainSO = ObjectToSObject( mainShape );
SALOMEDS::ChildIterator_wrap it;
if ( !mainSO->_is_nil() ) {
- it = myCurrentStudy->NewChildIterator( mainSO );
+ it = getStudyServant()->NewChildIterator( mainSO );
}
if ( !it->_is_nil() ) {
for ( it->InitEx(true); it->More(); it->Next() ) {
}
if ( geom->_is_nil() ) {
// explode
- GEOM::GEOM_IShapesOperations_wrap op =
- geomGen->GetIShapesOperations( GetCurrentStudyID() );
+ GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
if ( !op->_is_nil() )
geom = op->GetSubShape( mainShape, shapeID );
}
int _assert[( nbNames == SMESH::NB_ELEMENT_TYPES ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
}
string groupName = "Gr";
- SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( myCurrentStudy, theMeshesArray[i] );
+ SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( theMeshesArray[i] );
if ( aMeshSObj ) {
CORBA::String_var name = aMeshSObj->GetName();
groupName += name;
}
// IPAL21468 Change icon of compound because it need not be computed.
- SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( myCurrentStudy, aNewMesh );
+ SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( aNewMesh );
SetPixMap( aMeshSObj, "ICON_SMESH_TREE_MESH" );
if (aNewMeshDS)
SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
if ( !newMesh_i )
THROW_SALOME_CORBA_EXCEPTION( "can't create a mesh", SALOME::INTERNAL_ERROR );
- SALOMEDS::SObject_wrap meshSO = ObjectToSObject(myCurrentStudy, newMesh );
+ SALOMEDS::SObject_wrap meshSO = ObjectToSObject( newMesh );
if ( !meshSO->_is_nil() )
{
SetName( meshSO, meshName, "Mesh" );
return newMesh._retn();
}
+//================================================================================
+/*!
+ * \brief Get version of MED format being used.
+ */
+//================================================================================
+
+char* SMESH_Gen_i::GetMEDFileVersion()
+{
+ MED::TInt majeur, mineur, release;
+ majeur = mineur = release = 0;
+ MED::GetVersionRelease(majeur, mineur, release);
+ std::ostringstream version;
+ version << majeur << "." << mineur << "." << release;
+ return CORBA::string_dup( version.str().c_str() );
+}
+
//================================================================================
/*!
* SMESH_Gen_i::GetMEDVersion
* Get MED version of the file by its name
*/
//================================================================================
-CORBA::Boolean SMESH_Gen_i::GetMEDVersion(const char* theFileName,
- SMESH::MED_VERSION& theVersion)
+char* SMESH_Gen_i::GetMEDVersion(const char* theFileName)
{
- theVersion = SMESH::MED_V2_1;
- MED::EVersion aVersion = MED::GetVersionId( theFileName );
- switch( aVersion ) {
- case MED::eV2_1 : theVersion = SMESH::MED_V2_1; return true;
- case MED::eV2_2 : theVersion = SMESH::MED_V2_2; return true;
- case MED::eLATEST : theVersion = SMESH::MED_LATEST; return true;
- case MED::eMINOR_0 : theVersion = SMESH::MED_MINOR_0; return true;
- case MED::eMINOR_1 : theVersion = SMESH::MED_MINOR_1; return true;
- case MED::eMINOR_2 : theVersion = SMESH::MED_MINOR_2; return true;
- case MED::eMINOR_3 : theVersion = SMESH::MED_MINOR_3; return true;
- case MED::eMINOR_4 : theVersion = SMESH::MED_MINOR_4; return true;
- case MED::eMINOR_5 : theVersion = SMESH::MED_MINOR_5; return true;
- case MED::eMINOR_6 : theVersion = SMESH::MED_MINOR_6; return true;
- case MED::eMINOR_7 : theVersion = SMESH::MED_MINOR_7; return true;
- case MED::eMINOR_8 : theVersion = SMESH::MED_MINOR_8; return true;
- case MED::eMINOR_9 : theVersion = SMESH::MED_MINOR_9; return true;
- case MED::eVUnknown : return false;
- }
- return false;
+ std::string version = MED::GetMEDVersion( theFileName );
+ return CORBA::string_dup( version.c_str() );
+}
+
+//================================================================================
+/*!
+ * SMESH_Gen_i::CheckCompatibility
+ *
+ * Check compatibility of file with MED format being used.
+ */
+//================================================================================
+CORBA::Boolean SMESH_Gen_i::CheckCompatibility(const char* theFileName)
+{
+ return MED::CheckCompatibility( theFileName );
}
//================================================================================
SMESH::string_array* SMESH_Gen_i::GetMeshNames(const char* theFileName)
{
SMESH::string_array_var aResult = new SMESH::string_array();
- MED::PWrapper aMed = MED::CrWrapper( theFileName );
+ MED::PWrapper aMed = MED::CrWrapperR( theFileName );
MED::TErr anErr;
MED::TInt aNbMeshes = aMed->GetNbMeshes( &anErr );
if( anErr >= 0 ) {
const char* theURL,
bool isMultiFile )
{
- // ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() )
- // san -- in case <myCurrentStudy> differs from theComponent's study,
- // use that of the component
- if ( theComponent->GetStudy()->StudyId() != GetCurrentStudyID() )
- SetCurrentStudy( theComponent->GetStudy() );
+ if (!myStudyContext)
+ UpdateStudy();
// Store study contents as a set of python commands
- SavePython(myCurrentStudy);
+ SavePython();
- StudyContext* myStudyContext = GetCurrentStudyContext();
+ SALOMEDS::Study_var aStudy = getStudyServant();
// Declare a byte stream
SALOMEDS::TMPFile_var aStreamFile;
( isMultiFile ) ? TCollection_AsciiString( ( char* )theURL ) : ( char* )SALOMEDS_Tool::GetTmpDir().c_str();
// Create a sequence of files processed
- SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
- aFileSeq->length( NUM_TMP_FILES );
+ SALOMEDS_Tool::ListOfFiles aFileSeq;
+ aFileSeq.reserve( NUM_TMP_FILES );
TCollection_AsciiString aStudyName( "" );
if ( isMultiFile )
- aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( myCurrentStudy->URL() ).c_str() );
+ aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(aStudy->URL()) ).c_str() );
// Set names of temporary files
TCollection_AsciiString filename =
aStudyName + TCollection_AsciiString( "_SMESH.hdf" ); // for SMESH data itself
TCollection_AsciiString meshfile =
aStudyName + TCollection_AsciiString( "_SMESH_Mesh.med" ); // for mesh data to be stored in MED file
- aFileSeq[ 0 ] = CORBA::string_dup( filename.ToCString() );
- aFileSeq[ 1 ] = CORBA::string_dup( meshfile.ToCString() );
+ aFileSeq.push_back(CORBA::string_dup( filename.ToCString() ));
+ aFileSeq.push_back(CORBA::string_dup( meshfile.ToCString() ));
filename = tmpDir + filename;
meshfile = tmpDir + meshfile;
// SetStoreName() to groups before storing hypotheses to let them refer to
// groups using "store name", which is "Group <group_persistent_id>"
{
- SALOMEDS::ChildIterator_wrap itBig = myCurrentStudy->NewChildIterator( theComponent );
+ SALOMEDS::ChildIterator_wrap itBig = aStudy->NewChildIterator( theComponent );
for ( ; itBig->More(); itBig->Next() ) {
SALOMEDS::SObject_wrap gotBranch = itBig->Value();
if ( gotBranch->Tag() > GetAlgorithmsRootTag() ) {
aFile->CreateOnDisk();
// --> iterator for top-level objects
- SALOMEDS::ChildIterator_wrap itBig = myCurrentStudy->NewChildIterator( theComponent );
+ SALOMEDS::ChildIterator_wrap itBig = aStudy->NewChildIterator( theComponent );
for ( ; itBig->More(); itBig->Next() ) {
SALOMEDS::SObject_wrap gotBranch = itBig->Value();
aTopGroup->CreateOnDisk();
// iterator for all hypotheses
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( gotBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( gotBranch );
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
CORBA::Object_var anObject = SObjectToObject( mySObject );
aTopGroup->CreateOnDisk();
// iterator for all algorithms
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( gotBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( gotBranch );
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
CORBA::Object_var anObject = SObjectToObject( mySObject );
SALOMEDS::SObject_wrap myHypBranch;
found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch.inout() );
if ( found && !shapeRefFound && hasShape) { // remove applied hyps
- myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch );
+ aStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch );
}
if ( found && (shapeRefFound || !hasShape) ) {
aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup );
aGroup->CreateOnDisk();
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( myHypBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( myHypBranch );
int hypNb = 0;
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(),
myAlgoBranch.inout() );
if ( found && !shapeRefFound && hasShape) { // remove applied algos
- myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch );
+ aStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch );
}
if ( found && (shapeRefFound || !hasShape)) {
aGroup = new HDFgroup( "Applied Algorithms", aTopGroup );
aGroup->CreateOnDisk();
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( myAlgoBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( myAlgoBranch );
int algoNb = 0;
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
{
bool hasShapeRef = false;
SALOMEDS::ChildIterator_wrap itSM =
- myCurrentStudy->NewChildIterator( mySubmeshBranch );
+ aStudy->NewChildIterator( mySubmeshBranch );
for ( ; itSM->More(); itSM->Next() ) {
SALOMEDS::SObject_wrap mySubRef, myShape, mySObject = itSM->Value();
if ( mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef.inout() ))
}
}
}
- myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( mySObject );
+ aStudy->NewBuilder()->RemoveObjectWithChildren( mySObject );
}
} // loop on submeshes of a type
if ( !shapeRefFound || !hasShapeRef ) { // remove the whole submeshes branch
- myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( mySubmeshBranch );
+ aStudy->NewBuilder()->RemoveObjectWithChildren( mySubmeshBranch );
found = false;
}
} // end check if there is shape reference in submeshes
aGroup->CreateOnDisk();
// iterator for all submeshes of given type
- SALOMEDS::ChildIterator_wrap itSM = myCurrentStudy->NewChildIterator( mySubmeshBranch );
+ SALOMEDS::ChildIterator_wrap itSM = aStudy->NewChildIterator( mySubmeshBranch );
for ( ; itSM->More(); itSM->Next() ) {
SALOMEDS::SObject_wrap mySObject = itSM->Value();
CORBA::Object_var anSubObject = SObjectToObject( mySObject );
aSubSubGroup = new HDFgroup( "Applied Hypotheses", aSubGroup );
aSubSubGroup->CreateOnDisk();
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( mySubHypBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( mySubHypBranch );
int hypNb = 0;
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySubSObject = it->Value();
aSubSubGroup->CreateOnDisk();
SALOMEDS::ChildIterator_wrap it =
- myCurrentStudy->NewChildIterator( mySubAlgoBranch );
+ aStudy->NewChildIterator( mySubAlgoBranch );
int algoNb = 0;
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySubSObject = it->Value();
aGroup = new HDFgroup( name_group, aTopGroup );
aGroup->CreateOnDisk();
- SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( myGroupsBranch );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( myGroupsBranch );
for ( ; it->More(); it->Next() ) {
SALOMEDS::SObject_wrap mySObject = it->Value();
CORBA::Object_var aSubObject = SObjectToObject( mySObject );
// "Face V positions" - V parameter of node on face
// Find out nb of nodes on edges and faces
- // Collect corresponing sub-meshes
+ // Collect corresponding sub-meshes
int nbEdgeNodes = 0, nbFaceNodes = 0;
list<SMESHDS_SubMesh*> aEdgeSM, aFaceSM;
// loop on SMESHDS_SubMesh'es
delete aFile;
// Convert temporary files to stream
- aStreamFile = SALOMEDS_Tool::PutFilesToStream( tmpDir.ToCString(), aFileSeq.in(), isMultiFile );
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream( tmpDir.ToCString(), aFileSeq, isMultiFile );
// Remove temporary files and directory
if ( !isMultiFile )
- SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq.in(), true );
+ SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq, true );
return aStreamFile._retn();
}
if ( theCompRoot->_is_nil() )
return;
- SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( theCompRoot->GetStudy() );
- if ( aStudy->_is_nil() )
- return;
-
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->LoadWith( theCompRoot, GetGeomEngine() );
}
const char* theURL,
bool isMultiFile )
{
- if ( theComponent->GetStudy()->StudyId() != GetCurrentStudyID() )
- SetCurrentStudy( theComponent->GetStudy() );
-
+ if (!myStudyContext)
+ UpdateStudy();
+ SALOMEDS::Study_var aStudy = getStudyServant();
/* if( !theComponent->_is_nil() )
{
- //SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( theComponent->GetStudy() );
- if( !myCurrentStudy->FindComponent( "GEOM" )->_is_nil() )
- loadGeomData( myCurrentStudy->FindComponent( "GEOM" ) );
+ if( !aStudy->FindComponent( "GEOM" )->_is_nil() )
+ loadGeomData( aStudy->FindComponent( "GEOM" ) );
}*/
- StudyContext* myStudyContext = GetCurrentStudyContext();
-
// Get temporary files location
TCollection_AsciiString tmpDir =
( char* )( isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir().c_str() );
// Convert the stream into sequence of files to process
- SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream,
- tmpDir.ToCString(),
- isMultiFile );
+ SALOMEDS_Tool::ListOfFiles aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream,
+ tmpDir.ToCString(),
+ isMultiFile );
TCollection_AsciiString aStudyName( "" );
if ( isMultiFile ) {
- CORBA::String_var url = myCurrentStudy->URL();
- aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( url.in() ).c_str();
+ CORBA::WString_var url = aStudy->URL();
+ aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(url.in()) ).c_str();
}
// Set names of temporary files
TCollection_AsciiString filename = tmpDir + aStudyName + "_SMESH.hdf";
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
if ( strlen( refFromFile ) > 0 ) {
- SALOMEDS::SObject_wrap shapeSO = myCurrentStudy->FindObjectID( refFromFile );
+ SALOMEDS::SObject_wrap shapeSO = aStudy->FindObjectID( refFromFile );
// Make sure GEOM data are loaded first
//loadGeomData( shapeSO->GetFatherComponent() );
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
// san - it is impossible to recover applied algorithms using their entries within Load() method
- //SALOMEDS::SObject_wrap hypSO = myCurrentStudy->FindObjectID( refFromFile );
+ //SALOMEDS::SObject_wrap hypSO = aStudy->FindObjectID( refFromFile );
//CORBA::Object_var hypObject = SObjectToObject( hypSO );
int id = atoi( refFromFile );
delete [] refFromFile;
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
// san - it is impossible to recover applied hypotheses using their entries within Load() method
- //SALOMEDS::SObject_wrap hypSO = myCurrentStudy->FindObjectID( refFromFile );
+ //SALOMEDS::SObject_wrap hypSO = myStudy->FindObjectID( refFromFile );
//CORBA::Object_var hypObject = SObjectToObject( hypSO );
int id = atoi( refFromFile );
delete [] refFromFile;
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
if ( strlen( refFromFile ) > 0 ) {
- SALOMEDS::SObject_wrap subShapeSO = myCurrentStudy->FindObjectID( refFromFile );
+ SALOMEDS::SObject_wrap subShapeSO = aStudy->FindObjectID( refFromFile );
CORBA::Object_var subShapeObject = SObjectToObject( subShapeSO );
if ( !CORBA::is_nil( subShapeObject ) ) {
aSubShapeObject = GEOM::GEOM_Object::_narrow( subShapeObject );
if ( aTopGroup->ExistInternalObject( name_group ) ) {
aGroup = new HDFgroup( name_group, aTopGroup );
aGroup->OpenOnDisk();
- // get number of groups
- int aNbSubObjects = aGroup->nInternalObjects();
- for ( int j = 0; j < aNbSubObjects; j++ ) {
- char name_dataset[ HDF_NAME_MAX_LEN+1 ];
- aGroup->InternalObjectIndentify( j, name_dataset );
- // check if it is an group
- if ( string( name_dataset ).substr( 0, 5 ) == string( "Group" ) ) {
+ // PAL23514: get all names from the HDFgroup to avoid iteration on its contents
+ // within aGroup->ExistInternalObject( name )
+ std::vector< std::string > subNames;
+ TColStd_MapOfAsciiString mapOfNames;
+ aGroup->GetAllObjects( subNames );
+ for ( size_t iN = 0; iN < subNames.size(); ++iN )
+ mapOfNames.Add( subNames[ iN ].c_str() );
+ // loop on groups
+ for ( size_t j = 0; j < subNames.size(); j++ ) {
+ const std::string& name_dataset = subNames[ j ];
+ // check if it is a group
+ if ( name_dataset.substr( 0, 5 ) == "Group" ) {
// --> get group id
- int subid = atoi( string( name_dataset ).substr( 5 ).c_str() );
+ int subid = atoi( name_dataset.substr( 5 ).c_str() );
if ( subid <= 0 )
continue;
- aDataset = new HDFdataset( name_dataset, aGroup );
+ aDataset = new HDFdataset( name_dataset.c_str(), aGroup );
aDataset->OpenOnDisk();
// Retrieve actual group name
TopoDS_Shape aShape;
char aRefName[ 30 ];
sprintf( aRefName, "Ref on shape %d", subid);
- if ( aGroup->ExistInternalObject( aRefName ) ) {
+ if ( mapOfNames.Contains( aRefName ))
+ {
// load mesh "Ref on shape" - it's an entry to SObject
aDataset = new HDFdataset( aRefName, aGroup );
aDataset->OpenOnDisk();
aDataset->ReadFromDisk( refFromFile );
aDataset->CloseOnDisk();
if ( strlen( refFromFile ) > 0 ) {
- SALOMEDS::SObject_wrap shapeSO = myCurrentStudy->FindObjectID( refFromFile );
+ SALOMEDS::SObject_wrap shapeSO = aStudy->FindObjectID( refFromFile );
CORBA::Object_var shapeObject = SObjectToObject( shapeSO );
if ( !CORBA::is_nil( shapeObject ) ) {
aShapeObject = GEOM::GEOM_Object::_narrow( shapeObject );
// Try to read a filter of SMESH_GroupOnFilter
SMESH::Filter_var filter;
SMESH_PredicatePtr predicate;
- std::string hdfGrpName = "Filter " + SMESH_Comment(subid);
- if ( aGroup->ExistInternalObject( hdfGrpName.c_str() ))
+ std::string hdfGrpName = ( SMESH_Comment( "Filter ") << subid );
+ if ( mapOfNames.Contains( hdfGrpName.c_str() ))
{
aDataset = new HDFdataset( hdfGrpName.c_str(), aGroup );
aDataset->OpenOnDisk();
if ( !aGroupBaseDS )
continue;
- aGroupBaseDS->SetStoreName( name_dataset );
+ aGroupBaseDS->SetStoreName( name_dataset.c_str() );
// ouv : NPAL12872
// Read color of the group
char aGroupColorName[ 30 ];
sprintf( aGroupColorName, "ColorGroup %d", subid);
- if ( aGroup->ExistInternalObject( aGroupColorName ) )
+ if ( mapOfNames.Contains( aGroupColorName ))
{
aDataset = new HDFdataset( aGroupColorName, aGroup );
aDataset->OpenOnDisk();
SMESH_File meshFile( meshfile.ToCString() );
if ( !meshFile ) // no meshfile exists
{
- SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq.in(), true );
+ SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq, true );
}
else
{
// creation of tree nodes for all data objects in the study
// to support tree representation customization and drag-n-drop:
- SALOMEDS::Study_var study = theComponent->GetStudy();
- SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = study->GetUseCaseBuilder();
+ SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
if ( !useCaseBuilder->IsUseCaseNode( theComponent ) ) {
useCaseBuilder->SetRootCurrent();
useCaseBuilder->Append( theComponent ); // component object is added as the top level item
- SALOMEDS::ChildIterator_wrap it = study->NewChildIterator( theComponent );
+ SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( theComponent );
for (it->InitEx(true); it->More(); it->Next()) {
useCaseBuilder->AppendTo( it->Value()->GetFather(), it->Value() );
}
{
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Close" );
- // set correct current study
- SALOMEDS::Study_var study = theComponent->GetStudy();
- if ( study->StudyId() != GetCurrentStudyID())
- setCurrentStudy( study, /*IsBeingClosed=*/true );
-
// Clear study contexts data
- int studyId = GetCurrentStudyID();
- if ( myStudyContextMap.find( studyId ) != myStudyContextMap.end() ) {
- delete myStudyContextMap[ studyId ];
- myStudyContextMap.erase( studyId );
- }
+ delete myStudyContext;
+ myStudyContext = 0;
// remove the tmp files meshes are loaded from
SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD( theComponent );
- myCurrentStudy = SALOMEDS::Study::_nil();
return;
}
CORBA::Boolean /*isASCII*/ )
{
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::IORToLocalPersistentID" );
- StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && strcmp( IORString, "" ) != 0 ) {
int anId = myStudyContext->findId( IORString );
CORBA::Boolean /*isASCII*/ )
{
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::LocalPersistentIDToIOR(): id = " << aLocalPersistentID );
- StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && strcmp( aLocalPersistentID, "" ) != 0 ) {
int anId = atoi( aLocalPersistentID );
int SMESH_Gen_i::RegisterObject(CORBA::Object_ptr theObject)
{
- StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && !CORBA::is_nil( theObject )) {
CORBA::String_var iorString = GetORB()->object_to_string( theObject );
return myStudyContext->addObject( string( iorString.in() ) );
CORBA::Long SMESH_Gen_i::GetObjectId(CORBA::Object_ptr theObject)
{
- StudyContext* myStudyContext = GetCurrentStudyContext();
if ( myStudyContext && !CORBA::is_nil( theObject )) {
string iorString = GetORB()->object_to_string( theObject );
return myStudyContext->findId( iorString );
{
if ( theIOR && strcmp( theIOR, "" ) ) {
CORBA::Object_var anObject = GetORB()->string_to_object( theIOR );
- SALOMEDS::SObject_wrap aSO = ObjectToSObject( myCurrentStudy, anObject );
+ SALOMEDS::SObject_wrap aSO = ObjectToSObject( anObject );
if ( !aSO->_is_nil() ) {
SetName( aSO, theName );
}
}
}
-int SMESH_Gen_i::GetCurrentStudyID()
-{
- return myCurrentStudy->_is_nil() || myCurrentStudy->_non_existent() ? -1 : myCurrentStudy->StudyId();
-}
-
// Version information
char* SMESH_Gen_i::getVersion()
{
{
if ( CORBA::is_nil( where ) ) return;
- SALOMEDS::Study_var study = where->GetStudy();
- SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
- SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
+ SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = getStudyServant()->GetUseCaseBuilder();
SALOMEDS::SComponent_var father = where->GetFatherComponent();
std::string dataType = father->ComponentDataType();
if ( dataType != "SMESH" ) return; // not a SMESH component
#include <TCollection_AsciiString.hxx>
#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
+ #include <NCollection_DataMap.hxx>
#include <map>
#include <sstream>
// ==========================================================
class SMESH_I_EXPORT StudyContext
{
+ typedef NCollection_DataMap< int, std::string > TInt2StringMap;
+ typedef NCollection_DataMap< int, int > TInt2IntMap;
public:
// constructor
StudyContext() {}
- // destructor
- ~StudyContext()
- {
- mapIdToIOR.clear();
- mapIdToId.clear();
- }
+
// register object in the internal map and return its id
int addObject( std::string theIOR )
{
int nextId = getNextId();
- mapIdToIOR[ nextId ] = theIOR;
+ mapIdToIOR.Bind( nextId, theIOR );
return nextId;
}
// find the object id in the internal map by the IOR
int findId( std::string theIOR )
{
- std::map<int, std::string>::iterator imap;
+ TInt2StringMap::iterator imap;
for ( imap = mapIdToIOR.begin(); imap != mapIdToIOR.end(); ++imap ) {
- if ( imap->second == theIOR )
- return imap->first;
+ if ( *imap == theIOR )
+ return imap.Iterator().Key();
}
return 0;
}
// get object's IOR by id
std::string getIORbyId( const int theId )
{
- if ( mapIdToIOR.find( theId ) != mapIdToIOR.end() )
- return mapIdToIOR[ theId ];
- return std::string( "" );
+ if ( mapIdToIOR.IsBound( theId ) )
+ return mapIdToIOR( theId );
+ return std::string();
}
// get object's IOR by old id
std::string getIORbyOldId( const int theOldId )
{
- if ( mapIdToId.find( theOldId ) != mapIdToId.end() )
- return getIORbyId( mapIdToId[ theOldId ] );
- return std::string( "" );
+ if ( mapIdToId.IsBound( theOldId ) )
+ return getIORbyId( mapIdToId( theOldId ));
+ return std::string();
}
// maps old object id to the new one (used when restoring data)
void mapOldToNew( const int oldId, const int newId ) {
- mapIdToId[ oldId ] = newId;
+ mapIdToId.Bind( oldId, newId );
}
// get old id by a new one
int getOldId( const int newId ) {
- std::map<int, int>::iterator imap;
+ TInt2IntMap::iterator imap;
for ( imap = mapIdToId.begin(); imap != mapIdToId.end(); ++imap ) {
- if ( imap->second == newId )
- return imap->first;
+ if ( *imap == newId )
+ return imap.Iterator().Key();
}
return 0;
}
int getNextId()
{
int id = 1;
- while( mapIdToIOR.find( id ) != mapIdToIOR.end() )
+ while( mapIdToIOR.IsBound( id ) )
id++;
return id;
}
- std::map<int, std::string> mapIdToIOR; // persistent-to-transient map
- std::map<int, int> mapIdToId; // to translate object from persistent to transient form
+ TInt2StringMap mapIdToIOR; // persistent-to-transient map
+ TInt2IntMap mapIdToId; // to translate object from persistent to transient form
};
// ===========================================================
// Get CORBA object corresponding to the SALOMEDS::SObject
static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject );
// Get the SALOMEDS::SObject corresponding to a CORBA object
- static SALOMEDS::SObject_ptr ObjectToSObject(SALOMEDS::Study_ptr theStudy,
- CORBA::Object_ptr theObject);
+ static SALOMEDS::SObject_ptr ObjectToSObject(CORBA::Object_ptr theObject);
+ // Get the SALOMEDS::Study from naming service
+ static SALOMEDS::Study_ptr getStudyServant();
// Get GEOM Object correspoding to TopoDS_Shape
GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape );
// Get TopoDS_Shape correspoding to GEOM_Object
//GEOM::GEOM_Gen_ptr SetGeomEngine( const char* containerLoc );
void SetGeomEngine( GEOM::GEOM_Gen_ptr geomcompo );
- // Set current study
+ // Set embedded mode
void SetEmbeddedMode( CORBA::Boolean theMode );
- // Get current study
+ // Check embedded mode
CORBA::Boolean IsEmbeddedMode();
- // Set current study
- void SetCurrentStudy( SALOMEDS::Study_ptr theStudy );
- // Get current study
- SALOMEDS::Study_ptr GetCurrentStudy();
+ // Set enable publishing in the study
+ void SetEnablePublish( CORBA::Boolean theIsEnablePublish );
+
+ // Check enable publishing
+ CORBA::Boolean IsEnablePublish();
+
+ // Update study
+ void UpdateStudy();
// Create hypothesis/algorothm of given type
SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const char* theHypType,
CORBA::Double mergeTolerance)
throw ( SALOME::SALOME_Exception );
+ // Get version of MED format being used.
+ char* GetMEDFileVersion();
+
// Get MED version of the file by its name
- CORBA::Boolean GetMEDVersion(const char* theFileName,
- SMESH::MED_VERSION& theVersion);
+ char* GetMEDVersion(const char* theFileName);
+
+ // Check compatibility of file with MED format being used.
+ CORBA::Boolean CheckCompatibility(const char* theFileName);
// Get names of meshes defined in file with the specified name
SMESH::string_array* GetMeshNames(const char* theFileName);
// Returns true if object can be published in the study
bool CanPublishInStudy( CORBA::Object_ptr theIOR );
// Publish object in the study
- SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::Study_ptr theStudy,
- SALOMEDS::SObject_ptr theSObject,
+ SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theObject,
const char* theName )
throw ( SALOME::SALOME_Exception );
// Dump python
// ============
- virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
+ virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript);
- void AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString);
+ void AddToPythonScript (const TCollection_AsciiString& theString);
- void RemoveLastFromPythonScript (int theStudyID);
+ void RemoveLastFromPythonScript();
- void SavePython (SALOMEDS::Study_ptr theStudy);
+ void SavePython();
- TCollection_AsciiString DumpPython_impl (SALOMEDS::Study_ptr theStudy,
- Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
+ TCollection_AsciiString DumpPython_impl (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
Resource_DataMapOfAsciiStringAsciiString& theNames,
bool isPublished,
bool isMultiFile,
bool& aValidScript,
TCollection_AsciiString& theSavedTrace);
- TCollection_AsciiString GetNewPythonLines (int theStudyID);
+ TCollection_AsciiString GetNewPythonLines();
- void CleanPythonTrace (int theStudyID);
+ void CleanPythonTrace();
// *****************************************
// Internal methods
static long GetBallElementsGroupsTag();
// publishing methods
- SALOMEDS::SComponent_ptr PublishComponent(SALOMEDS::Study_ptr theStudy);
- SALOMEDS::SObject_ptr PublishMesh (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ SALOMEDS::SComponent_ptr PublishComponent();
+ SALOMEDS::SObject_ptr PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
const char* theName = 0);
- SALOMEDS::SObject_ptr PublishHypothesis (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Hypothesis_ptr theHyp,
+ SALOMEDS::SObject_ptr PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
const char* theName = 0);
- SALOMEDS::SObject_ptr PublishSubMesh (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ SALOMEDS::SObject_ptr PublishSubMesh (SMESH::SMESH_Mesh_ptr theMesh,
SMESH::SMESH_subMesh_ptr theSubMesh,
GEOM::GEOM_Object_ptr theShapeObject,
const char* theName = 0);
- SALOMEDS::SObject_ptr PublishGroup (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ SALOMEDS::SObject_ptr PublishGroup (SMESH::SMESH_Mesh_ptr theMesh,
SMESH::SMESH_GroupBase_ptr theGroup,
GEOM::GEOM_Object_ptr theShapeObject,
const char* theName = 0);
- bool AddHypothesisToShape(SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject,
SMESH::SMESH_Hypothesis_ptr theHyp);
- bool RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ bool RemoveHypothesisFromShape(SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject,
SMESH::SMESH_Hypothesis_ptr theHyp);
- SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr theStudy,
- SMESH::SMESH_Mesh_ptr theMesh,
+ SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShape);
static void SetName(SALOMEDS::SObject_ptr theSObject,
const char* theName,
const char* thePixMap);
// Get study context
- StudyContext* GetCurrentStudyContext();
+ StudyContext* GetStudyContext();
// Register an object in a StudyContext; return object id
int RegisterObject(CORBA::Object_ptr theObject);
// Return an object that previously had an oldID
template<class TInterface>
- typename TInterface::_var_type GetObjectByOldId( const int oldID )
+ typename TInterface::_var_type GetObjectByOldId( const int oldID )
{
- if ( StudyContext* myStudyContext = GetCurrentStudyContext() ) {
+ if ( myStudyContext ) {
std::string ior = myStudyContext->getIORbyOldId( oldID );
if ( !ior.empty() )
return TInterface::_narrow(GetORB()->string_to_object( ior.c_str() ));
return TInterface::_nil();
}
- // Get current study ID
- int GetCurrentStudyID();
-
/*!
* \brief Find SObject for an algo
*/
const char* theCommandNameForPython,
const char* theFileNameForPython);
- void setCurrentStudy( SALOMEDS::Study_ptr theStudy,
- bool theStudyIsBeingClosed=false);
-
std::vector<long> _GetInside(SMESH::SMESH_IDSource_ptr meshPart,
SMESH::ElementType theElemType,
TopoDS_Shape& aShape,
// hypotheses managing
std::map<std::string, GenericHypothesisCreator_i*> myHypCreatorMap;
- std::map<int, StudyContext*> myStudyContextMap; // Map of study context objects
+ StudyContext* myStudyContext; // study context
GEOM_Client* myShapeReader; // Shape reader
- SALOMEDS::Study_var myCurrentStudy; // Current study
CORBA::Boolean myIsEmbeddedMode; // Current mode
+ CORBA::Boolean myIsEnablePublish; // Enable publishing
// Default color of groups
std::string myDefaultGroupColor;
bool myToForgetMeshDataOnHypModif;
// Dump Python: trace of API methods calls
- std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts;
- bool myIsHistoricalPythonDump;
- std::vector< int > myLastParamIndex;
- std::vector< std::string > myLastParameters;
- std::string myLastObj;
+ Handle(TColStd_HSequenceOfAsciiString) myPythonScript;
+ bool myIsHistoricalPythonDump;
+ std::vector< int > myLastParamIndex;
+ std::vector< std::string > myLastParameters;
+ std::string myLastObj;
};
#include <Utils_CorbaException.hxx>
#include <SALOMEDS_wrap.hxx>
#include <SALOME_GenericObj_i.hh>
- #include <Basics_OCCTVersion.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRep_Tool.hxx>
#include <gp_Ax2.hxx>
#include <gp_Vec.hxx>
- #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- #define NO_CAS_CATCH
- #endif
-
#include <Standard_Failure.hxx>
-
- #ifdef NO_CAS_CATCH
#include <Standard_ErrorHandler.hxx>
- #endif
#include <sstream>
#include <limits>
SMDSAbs_ElementType myPreviewType; // type to show
//!< Constructor
TPreviewMesh(SMDSAbs_ElementType previewElements = SMDSAbs_All) {
- _isShapeToMesh = (_id =_studyId = 0);
+ _isShapeToMesh = (_id = 0);
_myMeshDS = new SMESHDS_Mesh( _id, true );
myPreviewType = previewElements;
}
n[8],n[9],n[10],n[11],n[12],n[13],n[14],
n[15],n[16],n[17],n[18],n[19]);
break;
+ case 18:elem = getMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
+ n[8],n[9],n[10],n[11],n[12],n[13],n[14],
+ n[15],n[16],n[17]);
+ break;
case 27:elem = getMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],
n[8],n[9],n[10],n[11],n[12],n[13],n[14],
n[15],n[16],n[17],n[18],n[19],
::SMESH_MeshEditor::PGroupIDs groupIds =
getEditor().Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
- if ( theCopy && !myIsPreviewMode)
+ if ( !myIsPreviewMode )
{
if ( theTargetMesh )
- {
theTargetMesh->GetMeshDS()->Modified();
- }
else
- {
declareMeshModified( /*isReComputeSafe=*/false );
- }
}
+
return theMakeGroups ? getGroups(groupIds.get()) : 0;
SMESH_CATCH( SMESH::throwCorbaException );
::SMESH_MeshEditor::PGroupIDs groupIds =
getEditor().Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
- if ( theCopy && !myIsPreviewMode )
+ if ( !myIsPreviewMode )
{
if ( theTargetMesh )
- {
theTargetMesh->GetMeshDS()->Modified();
- }
else
- {
declareMeshModified( /*isReComputeSafe=*/false );
- }
}
return theMakeGroups ? getGroups(groupIds.get()) : 0;
::SMESH_MeshEditor::PGroupIDs groupIds =
getEditor().Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
- if ( theCopy && !myIsPreviewMode)
+ if ( !myIsPreviewMode)
{
if ( theTargetMesh ) theTargetMesh->GetMeshDS()->Modified();
else declareMeshModified( /*isReComputeSafe=*/false );
};
gp_Trsf aTrsf;
- #if OCC_VERSION_LARGE > 0x06070100
// fight against orthogonalization
// aTrsf.SetValues( S[0], 0, 0, thePoint.x * (1-S[0]),
// 0, S[1], 0, thePoint.y * (1-S[1]),
thePoint.z * (1-S[2]));
M.SetDiagonal( S[0], S[1], S[2] );
- #else
- double tol = std::numeric_limits<double>::max();
- aTrsf.SetValues( S[0], 0, 0, thePoint.x * (1-S[0]),
- 0, S[1], 0, thePoint.y * (1-S[1]),
- 0, 0, S[2], thePoint.z * (1-S[2]), tol, tol);
- #endif
-
TIDSortedElemSet copyElements;
TIDSortedElemSet* workElements = &elements;
if ( myIsPreviewMode )
::SMESH_MeshEditor::PGroupIDs groupIds =
getEditor().Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
- if ( theCopy && !myIsPreviewMode )
+ if ( !myIsPreviewMode )
{
if ( theTargetMesh ) theTargetMesh->GetMeshDS()->Modified();
else declareMeshModified( /*isReComputeSafe=*/false );
// and then "GetGroups" using SMESH_Mesh::GetGroups()
TPythonDump pydump; // to prevent dump at mesh creation
- mesh = makeMesh( theMeshName );
+ mesh = makeMesh( theMeshName );
mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
if ( mesh_i )
return 0;
}
+ //=======================================================================
+ //function : IsManifold
+ //purpose : Check if a 2D mesh is manifold
+ //=======================================================================
+
+ CORBA::Boolean SMESH_MeshEditor_i::IsManifold()
+ throw (SALOME::SALOME_Exception)
+ {
+ bool isManifold = true;
+
+ SMESH_TRY;
+ SMESH_MeshAlgos::TFreeBorderVec foundFreeBordes;
+ SMESH_MeshAlgos::FindFreeBorders( *getMeshDS(),
+ foundFreeBordes,
+ /*closedOnly=*/true,
+ &isManifold );
+ SMESH_CATCH( SMESH::throwCorbaException );
+
+ return isManifold;
+ }
+
+ //=======================================================================
+ //function : IsCoherentOrientation2D
+ //purpose : Check if orientation of 2D elements is coherent
+ //=======================================================================
+
+ CORBA::Boolean SMESH_MeshEditor_i::IsCoherentOrientation2D()
+ throw (SALOME::SALOME_Exception)
+ {
+ bool isGoodOri = true;
+
+ SMESH_TRY;
+ SMESH_MeshAlgos::TFreeBorderVec foundFreeBordes;
+ SMESH_MeshAlgos::FindFreeBorders( *getMeshDS(),
+ foundFreeBordes,
+ /*closedOnly=*/true,
+ /*isManifold=*/0,
+ &isGoodOri);
+ SMESH_CATCH( SMESH::throwCorbaException );
+
+ return isGoodOri;
+ }
+
+ //=======================================================================
+ //function : FindFreeBorders
+ //purpose : Returns all or only closed FreeBorder's.
+ //=======================================================================
+
+ SMESH::ListOfFreeBorders* SMESH_MeshEditor_i::FindFreeBorders(CORBA::Boolean closedOnly)
+ throw (SALOME::SALOME_Exception)
+ {
+ SMESH::ListOfFreeBorders_var resBorders = new SMESH::ListOfFreeBorders;
+ SMESH_TRY;
+
+ SMESH_MeshAlgos::TFreeBorderVec foundFreeBordes;
+ SMESH_MeshAlgos::FindFreeBorders( *getMeshDS(), foundFreeBordes, closedOnly );
+
+ resBorders->length( foundFreeBordes.size() );
+ for ( size_t i = 0; i < foundFreeBordes.size(); ++i )
+ {
+ const SMESH_MeshAlgos::TFreeBorder& bordNodes = foundFreeBordes[i];
+ SMESH::FreeBorder& bordOut = resBorders[i];
+ bordOut.nodeIDs.length( bordNodes.size() );
+ for ( size_t iN = 0; iN < bordNodes.size(); ++iN )
+ bordOut.nodeIDs[ iN ] = bordNodes[ iN ]->GetID();
+ }
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+
+ return resBorders._retn();
+ }
+
+ //=======================================================================
+ //function : FillHole
+ //purpose : Fill with 2D elements a hole defined by a FreeBorder.
+ //=======================================================================
+
+ void SMESH_MeshEditor_i::FillHole(const SMESH::FreeBorder& theHole)
+ throw (SALOME::SALOME_Exception)
+ {
+ initData();
+
+ if ( theHole.nodeIDs.length() < 4 )
+ THROW_SALOME_CORBA_EXCEPTION("A hole should be bound by at least 3 nodes", SALOME::BAD_PARAM);
+ if ( theHole.nodeIDs[0] != theHole.nodeIDs[ theHole.nodeIDs.length()-1 ] )
+ THROW_SALOME_CORBA_EXCEPTION("Not closed hole boundary. "
+ "First and last nodes must be same", SALOME::BAD_PARAM);
+
+ SMESH_MeshAlgos::TFreeBorder bordNodes;
+ bordNodes.resize( theHole.nodeIDs.length() );
+ for ( size_t iN = 0; iN < theHole.nodeIDs.length(); ++iN )
+ {
+ bordNodes[ iN ] = getMeshDS()->FindNode( theHole.nodeIDs[ iN ]);
+ if ( !bordNodes[ iN ] )
+ THROW_SALOME_CORBA_EXCEPTION(SMESH_Comment("Node #") << theHole.nodeIDs[ iN ]
+ << " does not exist", SALOME::BAD_PARAM);
+ }
+
+ SMESH_TRY;
+
+ MeshEditor_I::TPreviewMesh* previewMesh = 0;
+ SMDS_Mesh* meshDS = getMeshDS();
+ if ( myIsPreviewMode )
+ {
+ // copy faces sharing nodes of theHole
+ TIDSortedElemSet holeFaces;
+ previewMesh = getPreviewMesh( SMDSAbs_Face );
+ for ( size_t i = 0; i < bordNodes.size(); ++i )
+ {
+ SMDS_ElemIteratorPtr fIt = bordNodes[i]->GetInverseElementIterator( SMDSAbs_Face );
+ while ( fIt->more() )
+ {
+ const SMDS_MeshElement* face = fIt->next();
+ if ( holeFaces.insert( face ).second )
+ previewMesh->Copy( face );
+ }
+ bordNodes[i] = previewMesh->GetMeshDS()->FindNode( bordNodes[i]->GetID() );
+ ASSERT( bordNodes[i] );
+ }
+ meshDS = previewMesh->GetMeshDS();
+ }
+
+ std::vector<const SMDS_MeshElement*> newFaces;
+ SMESH_MeshAlgos::FillHole( bordNodes, *meshDS, newFaces );
+
+ if ( myIsPreviewMode )
+ {
+ previewMesh->Clear();
+ for ( size_t i = 0; i < newFaces.size(); ++i )
+ previewMesh->Copy( newFaces[i] );
+ }
+ else
+ {
+ getEditor().ClearLastCreated();
+ SMESH_SequenceOfElemPtr& aSeq =
+ const_cast<SMESH_SequenceOfElemPtr&>( getEditor().GetLastCreatedElems() );
+ for ( size_t i = 0; i < newFaces.size(); ++i )
+ aSeq.Append( newFaces[i] );
+
+ TPythonDump() << this << ".FillHole( SMESH.FreeBorder(" << theHole.nodeIDs << " ))";
+ }
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+ }
+
//=======================================================================
//function : convError
//purpose :
{
SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
SMESH::SMESH_Mesh_var mesh = gen->CreateEmptyMesh();
- SALOMEDS::Study_var study = gen->GetCurrentStudy();
- SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( study, mesh );
+ SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( mesh );
gen->SetName( meshSO, theMeshName, "Mesh" );
gen->SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
SMESH_CATCH( SMESH::throwCorbaException );
return 0;
}
+
+ //================================================================================
+ /*!
+ * \brief Create a polyline consisting of 1D mesh elements each lying on a 2D element of
+ * the initial mesh. Positions of new nodes are found by cutting the mesh by the
+ * plane passing through pairs of points specified by each PolySegment structure.
+ * If there are several paths connecting a pair of points, the shortest path is
+ * selected by the module. Position of the cutting plane is defined by the two
+ * points and an optional vector lying on the plane specified by a PolySegment.
+ * By default the vector is defined by Mesh module as following. A middle point
+ * of the two given points is computed. The middle point is projected to the mesh.
+ * The vector goes from the middle point to the projection point. In case of planar
+ * mesh, the vector is normal to the mesh.
+ * \param [inout] segments - PolySegment's defining positions of cutting planes.
+ * Return the used vector and position of the middle point.
+ * \param [in] groupName - optional name of a group where created mesh segments will
+ * be added.
+ */
+ //================================================================================
+
+ void SMESH_MeshEditor_i::MakePolyLine(SMESH::ListOfPolySegments& theSegments,
+ const char* theGroupName)
+ throw (SALOME::SALOME_Exception)
+ {
+ if ( theSegments.length() == 0 )
+ THROW_SALOME_CORBA_EXCEPTION("No segments given", SALOME::BAD_PARAM );
+ if ( myMesh->NbFaces() == 0 )
+ THROW_SALOME_CORBA_EXCEPTION("No faces in the mesh", SALOME::BAD_PARAM );
+
+ SMESH_TRY;
+ initData(/*deleteSearchers=*/false);
+
+ SMESHDS_Group* groupDS = 0;
+ SMESHDS_Mesh* meshDS = getMeshDS();
+ if ( myIsPreviewMode ) // copy faces to the tmp mesh
+ {
+ TPreviewMesh * tmpMesh = getPreviewMesh( SMDSAbs_Edge );
+ SMDS_ElemIteratorPtr faceIt = getMeshDS()->elementsIterator( SMDSAbs_Face );
+ while ( faceIt->more() )
+ tmpMesh->Copy( faceIt->next() );
+ meshDS = tmpMesh->GetMeshDS();
+ }
+ else if ( theGroupName[0] ) // find/create a group of segments
+ {
+ SMESH_Mesh::GroupIteratorPtr grpIt = myMesh->GetGroups();
+ while ( !groupDS && grpIt->more() )
+ {
+ SMESH_Group* group = grpIt->next();
+ if ( group->GetGroupDS()->GetType() == SMDSAbs_Edge &&
+ strcmp( group->GetName(), theGroupName ) == 0 )
+ {
+ groupDS = dynamic_cast< SMESHDS_Group* >( group->GetGroupDS() );
+ }
+ }
+ if ( !groupDS )
+ {
+ SMESH::SMESH_Group_var groupVar = myMesh_i->CreateGroup( SMESH::EDGE, theGroupName );
+
+ if ( SMESH_Group_i* groupImpl = SMESH::DownCast<SMESH_Group_i*>( groupVar ))
+ groupDS = dynamic_cast< SMESHDS_Group* >( groupImpl->GetGroupDS() );
+ }
+ }
+
+ // convert input polySegments
+ ::SMESH_MeshEditor::TListOfPolySegments segments( theSegments.length() );
+ for ( CORBA::ULong i = 0; i < theSegments.length(); ++i )
+ {
+ SMESH::PolySegment& segIn = theSegments[ i ];
+ ::SMESH_MeshEditor::PolySegment& segOut = segments[ i ];
+ segOut.myNode1[0] = meshDS->FindNode( segIn.node1ID1 );
+ segOut.myNode2[0] = meshDS->FindNode( segIn.node1ID2 );
+ segOut.myNode1[1] = meshDS->FindNode( segIn.node2ID1 );
+ segOut.myNode2[1] = meshDS->FindNode( segIn.node2ID2 );
+ segOut.myVector.SetCoord( segIn.vector.PS.x,
+ segIn.vector.PS.y,
+ segIn.vector.PS.z );
+ if ( !segOut.myNode1[0] )
+ THROW_SALOME_CORBA_EXCEPTION( SMESH_Comment( "Invalid node ID: ") << segIn.node1ID1,
+ SALOME::BAD_PARAM );
+ if ( !segOut.myNode1[1] )
+ THROW_SALOME_CORBA_EXCEPTION( SMESH_Comment( "Invalid node ID: ") << segIn.node2ID1,
+ SALOME::BAD_PARAM );
+ }
+
+ // get a static ElementSearcher
+ SMESH::SMESH_IDSource_var idSource = SMESH::SMESH_IDSource::_narrow( myMesh_i->_this() );
+ theSearchersDeleter.Set( myMesh, getPartIOR( idSource, SMESH::FACE ));
+ if ( !theElementSearcher )
+ theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS() );
+
+ // compute
+ getEditor().MakePolyLine( segments, groupDS, theElementSearcher );
+
+ // return vectors
+ if ( myIsPreviewMode )
+ {
+ for ( CORBA::ULong i = 0; i < theSegments.length(); ++i )
+ {
+ SMESH::PolySegment& segOut = theSegments[ i ];
+ ::SMESH_MeshEditor::PolySegment& segIn = segments[ i ];
+ segOut.vector.PS.x = segIn.myVector.X();
+ segOut.vector.PS.y = segIn.myVector.Y();
+ segOut.vector.PS.z = segIn.myVector.Z();
+ }
+ }
+ else
+ {
+ TPythonDump() << "_segments = []";
+ for ( CORBA::ULong i = 0; i < theSegments.length(); ++i )
+ {
+ SMESH::PolySegment& segIn = theSegments[ i ];
+ TPythonDump() << "_segments.append( SMESH.PolySegment( "
+ << segIn.node1ID1 << ", "
+ << segIn.node1ID2 << ", "
+ << segIn.node2ID1 << ", "
+ << segIn.node2ID2 << ", "
+ << "smeshBuilder.MakeDirStruct( "
+ << segIn.vector.PS.x << ", "
+ << segIn.vector.PS.y << ", "
+ << segIn.vector.PS.z << ")))";
+ }
+ TPythonDump() << this << ".MakePolyLine( _segments, '" << theGroupName << "')";
+ }
+ meshDS->Modified();
+ SMESH_CATCH( SMESH::throwCorbaException );
+ return;
+ }
//=============================================================================
SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
- SMESH_Gen_i* gen_i,
- CORBA::Long studyId )
+ SMESH_Gen_i* gen_i )
: SALOME::GenericObj_i( thePOA )
{
_impl = NULL;
_gen_i = gen_i;
_id = _idGenerator++;
- _studyId = studyId;
_editor = NULL;
_previewEditor = NULL;
_preMeshInfo = NULL;
for ( ; data != _geomGroupData.end(); ++data )
if ( data->_smeshObject->_is_equivalent( _this() ))
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- if ( study->_is_nil() ) break;
- SALOMEDS::SObject_wrap so = study->FindObjectID( data->_groupEntry.c_str() );
+ SALOMEDS::SObject_wrap so = SMESH_Gen_i::getStudyServant()->FindObjectID( data->_groupEntry.c_str() );
CORBA::Object_var obj = _gen_i->SObjectToObject( so );
aShapeObj = GEOM::GEOM_Object::_narrow( obj );
break;
CreateGroupServants();
int major, minor, release;
- if( !MED::getMEDVersion( theFileName, major, minor, release ) )
- major = minor = release = -1;
+ major = minor = release = 0;
+ MED::GetMEDVersion(theFileName, major, minor, release);
_medFileInfo = new SMESH::MedFileInfo();
_medFileInfo->fileName = theFileName;
_medFileInfo->fileSize = 0;
return ConvertDriverMEDReadStatus(status);
}
-//================================================================================
-/*!
- * \brief Return string representation of a MED file version comprising nbDigits
- */
-//================================================================================
-
-char* SMESH_Mesh_i::GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits)
-{
- string ver = DriverMED_W_SMESHDS_Mesh::GetVersionString(MED::EVersion(version),
- nbDigits);
- return CORBA::string_dup( ver.c_str() );
-}
-
//=============================================================================
/*!
* ImportUNVFile
std::string name = _impl->STLToMesh( theFileName );
if ( !name.empty() )
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( study, _this() );
+ SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( _this() );
_gen_i->SetName( meshSO, name.c_str() );
}
SMESH::SMESH_Mesh_var mesh( _this() );
if ( !SMESH_Hypothesis::IsStatusFatal(status) )
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- _gen_i->AddHypothesisToShape( study, mesh, aSubShape, anHyp );
+ _gen_i->AddHypothesisToShape( mesh, aSubShape, anHyp );
}
if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
if ( !SMESH_Hypothesis::IsStatusFatal(status) )
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- _gen_i->RemoveHypothesisFromShape( study, mesh, aSubShape, anHyp );
+ _gen_i->RemoveHypothesisFromShape( mesh, aSubShape, anHyp );
}
// Update Python script
if(_impl->HasShapeToMesh())
subMesh = createSubMesh( aSubShape );
if ( _gen_i->CanPublishInStudy( subMesh ))
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishSubMesh( study, aMesh, subMesh, aSubShape, theName );
+ _gen_i->PublishSubMesh( aMesh, subMesh, aSubShape, theName );
if ( !aSO->_is_nil()) {
// Update Python script
TPythonDump() << aSO << " = " << aMesh << ".GetSubMesh( "
return;
GEOM::GEOM_Object_var aSubShape;
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
- if ( !aStudy->_is_nil() ) {
- // Remove submesh's SObject
- SALOMEDS::SObject_wrap anSO = _gen_i->ObjectToSObject( aStudy, theSubMesh );
- if ( !anSO->_is_nil() ) {
- long aTag = SMESH_Gen_i::GetRefOnShapeTag();
- SALOMEDS::SObject_wrap anObj, aRef;
- if ( anSO->FindSubObject( aTag, anObj.inout() ) &&
- anObj->ReferencedObject( aRef.inout() ))
- {
- CORBA::Object_var obj = aRef->GetObject();
- aSubShape = GEOM::GEOM_Object::_narrow( obj );
- }
- // if ( aSubShape->_is_nil() ) // not published shape (IPAL13617)
- // aSubShape = theSubMesh->GetSubShape();
+ // Remove submesh's SObject
+ SALOMEDS::SObject_wrap anSO = _gen_i->ObjectToSObject( theSubMesh );
+ if ( !anSO->_is_nil() ) {
+ long aTag = SMESH_Gen_i::GetRefOnShapeTag();
+ SALOMEDS::SObject_wrap anObj, aRef;
+ if ( anSO->FindSubObject( aTag, anObj.inout() ) &&
+ anObj->ReferencedObject( aRef.inout() ))
+ {
+ CORBA::Object_var obj = aRef->GetObject();
+ aSubShape = GEOM::GEOM_Object::_narrow( obj );
+ }
+ // if ( aSubShape->_is_nil() ) // not published shape (IPAL13617)
+ // aSubShape = theSubMesh->GetSubShape();
- SALOMEDS::StudyBuilder_var builder = aStudy->NewBuilder();
- builder->RemoveObjectWithChildren( anSO );
+ SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder();
+ builder->RemoveObjectWithChildren( anSO );
- // Update Python script
- TPythonDump() << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )";
- }
+ // Update Python script
+ TPythonDump() << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )";
}
if ( removeSubMesh( theSubMesh, aSubShape.in() ))
if ( _gen_i->CanPublishInStudy( aNewGroup ) )
{
SMESH::SMESH_Mesh_var mesh = _this();
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishGroup( study, mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName);
+ _gen_i->PublishGroup( mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName);
if ( !aSO->_is_nil())
// Update Python script
TPythonDump() << aSO << " = " << mesh << ".CreateGroup( "
if ( _gen_i->CanPublishInStudy( aNewGroup ) )
{
SMESH::SMESH_Mesh_var mesh = _this();
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishGroup( study, mesh, aNewGroup, theGeomObj, theName );
+ _gen_i->PublishGroup( mesh, aNewGroup, theGeomObj, theName );
if ( !aSO->_is_nil())
TPythonDump() << aSO << " = " << mesh << ".CreateGroupFromGEOM( "
<< theElemType << ", '" << theName << "', " << theGeomObj << " )";
if ( _gen_i->CanPublishInStudy( aNewGroup ) )
{
SMESH::SMESH_Mesh_var mesh = _this();
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishGroup( study, mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName );
+ _gen_i->PublishGroup( mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName );
if ( !aSO->_is_nil())
pd << aSO << " = " << mesh << ".CreateGroupFromFilter( "
if ( !aGroup )
return;
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
- if ( !aStudy->_is_nil() )
+ SALOMEDS::SObject_wrap aGroupSO = _gen_i->ObjectToSObject( theGroup );
+ if ( !aGroupSO->_is_nil() )
{
- SALOMEDS::SObject_wrap aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
- if ( !aGroupSO->_is_nil() )
- {
- // Update Python script
- TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
+ // Update Python script
+ TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
- // Remove group's SObject
- SALOMEDS::StudyBuilder_var builder = aStudy->NewBuilder();
- builder->RemoveObjectWithChildren( aGroupSO );
- }
+ // Remove group's SObject
+ SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder();
+ builder->RemoveObjectWithChildren( aGroupSO );
}
aGroup->Modified(/*removed=*/true); // notify dependent Filter with FT_BelongToMeshGroup criterion
if ( CORBA::is_nil( theGeomObj ) || theGeomObj->GetType() != GEOM_GROUP )
return;
// group SO
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( study, theGeomObj );
+ SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( theGeomObj );
if ( groupSO->_is_nil() )
return;
// group indices
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine();
GEOM::GEOM_IGroupOperations_wrap groupOp =
- geomGen->GetIGroupOperations( _gen_i->GetCurrentStudyID() );
+ geomGen->GetIGroupOperations();
GEOM::ListOfLong_var ids = groupOp->GetObjects( theGeomObj );
// store data
TopoDS_Shape newShape;
// get geom group
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- if ( study->_is_nil() ) return newShape; // means "not changed"
- SALOMEDS::SObject_wrap groupSO = study->FindObjectID( groupData._groupEntry.c_str() );
+ SALOMEDS::SObject_wrap groupSO = SMESH_Gen_i::getStudyServant()->FindObjectID( groupData._groupEntry.c_str() );
if ( !groupSO->_is_nil() )
{
CORBA::Object_var groupObj = _gen_i->SObjectToObject( groupSO );
set<int> curIndices;
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine();
GEOM::GEOM_IGroupOperations_wrap groupOp =
- geomGen->GetIGroupOperations( _gen_i->GetCurrentStudyID() );
+ geomGen->GetIGroupOperations();
GEOM::ListOfLong_var ids = groupOp->GetObjects( geomGroup );
for ( CORBA::ULong i = 0; i < ids->length(); ++i )
curIndices.insert( ids[i] );
{
if ( !_impl->HasShapeToMesh() ) return;
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- if ( study->_is_nil() ) return;
-
GEOM::GEOM_Object_var mainGO = _gen_i->ShapeToGeomObject( _impl->GetShapeToMesh() );
//if ( mainGO->_is_nil() ) return;
{
if ( !_impl->HasShapeToMesh() ) return;
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- if ( study->_is_nil() ) return;
-
CORBA::Long nbEntities = NbNodes() + NbElements();
// Check if group contents changed
if ( _mapGroups.find( oldID ) == _mapGroups.end() )
continue;
// get group name
- SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( study,_mapGroups[oldID] );
+ SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( _mapGroups[oldID] );
CORBA::String_var name = groupSO->GetName();
// update
SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>(_mapGroups[oldID] );
if ( newNbEntities != nbEntities )
{
// Add all SObjects with icons to soToUpdateIcons
- soToUpdateIcons.push_back( _gen_i->ObjectToSObject( study, _this() )); // mesh
+ soToUpdateIcons.push_back( _gen_i->ObjectToSObject( _this() )); // mesh
for (map<int, SMESH::SMESH_subMesh_ptr>::iterator i_sm = _mapSubMeshIor.begin();
i_sm != _mapSubMeshIor.end(); ++i_sm ) // submeshes
- soToUpdateIcons.push_back( _gen_i->ObjectToSObject( study, i_sm->second ));
+ soToUpdateIcons.push_back( _gen_i->ObjectToSObject( i_sm->second ));
for ( map<int, SMESH::SMESH_GroupBase_ptr>::iterator i_gr = _mapGroups.begin();
i_gr != _mapGroups.end(); ++i_gr ) // groups
- soToUpdateIcons.push_back( _gen_i->ObjectToSObject( study, i_gr->second ));
+ soToUpdateIcons.push_back( _gen_i->ObjectToSObject( i_gr->second ));
}
list< SALOMEDS::SObject_wrap >::iterator so = soToUpdateIcons.begin();
SALOMEDS::StudyBuilder_var builder;
SALOMEDS::SObject_wrap aGroupSO;
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
+ SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
if ( !aStudy->_is_nil() ) {
builder = aStudy->NewBuilder();
- aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
+ aGroupSO = _gen_i->ObjectToSObject( theGroup );
if ( !aGroupSO->_is_nil() )
{
// remove reference to geometry
return _id;
}
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-CORBA::Long SMESH_Mesh_i::GetStudyId()throw(SALOME::SALOME_Exception)
-{
- return _studyId;
-}
-
//=============================================================================
namespace
{
// Perform Export
PrepareForWriting(file, overwrite);
string aMeshName = "Mesh";
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
+ SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
if ( !aStudy->_is_nil() ) {
- SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( aStudy, _this() );
+ SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( _this() );
if ( !aMeshSO->_is_nil() ) {
CORBA::String_var name = aMeshSO->GetName();
aMeshName = name;
//================================================================================
/*!
- * \brief Export to med file
+ * \brief Export to MED file
*/
//================================================================================
-void SMESH_Mesh_i::ExportToMEDX (const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION theVersion,
- CORBA::Boolean overwrite,
- CORBA::Boolean autoDimension)
+void SMESH_Mesh_i::ExportMED(const char* file,
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean overwrite,
+ CORBA::Boolean autoDimension)
throw(SALOME::SALOME_Exception)
{
+ //MESSAGE("SMESH::MED_VERSION:"<< theVersion);
SMESH_TRY;
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
string aMeshName = prepareMeshNameAndGroups(file, overwrite);
- _impl->ExportMED( file, aMeshName.c_str(), auto_groups, theVersion, 0, autoDimension );
+ _impl->ExportMED( file, aMeshName.c_str(), auto_groups, 0, autoDimension );
- TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportToMEDX( r'"
+ TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
<< file << "', " << auto_groups << ", "
- << theVersion << ", " << overwrite << ", "
+ << overwrite << ", "
<< autoDimension << " )";
SMESH_CATCH( SMESH::throwCorbaException );
}
-//================================================================================
-/*!
- * \brief Export a mesh to a med file
- */
-//================================================================================
-
-void SMESH_Mesh_i::ExportToMED (const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION theVersion)
- throw(SALOME::SALOME_Exception)
-{
- //MESSAGE("SMESH::MED_VERSION:"<< theVersion);
- ExportToMEDX(file,auto_groups,theVersion,true);
-}
-
-//================================================================================
-/*!
- * \brief Export a mesh to a med file
- */
-//================================================================================
-
-void SMESH_Mesh_i::ExportMED (const char* file,
- CORBA::Boolean auto_groups)
- throw(SALOME::SALOME_Exception)
-{
- //MESSAGE("SMESH::MED_VERSION:"<< SMESH::MED_LATEST);
- ExportToMEDX(file,auto_groups,SMESH::MED_LATEST,true);
-}
-
//================================================================================
/*!
* \brief Export a mesh to a SAUV file
<< ".ExportSTL( r'" << file << "', " << isascii << " )";
CORBA::String_var name;
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, _this() );
+ SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( _this() );
if ( !so->_is_nil() )
name = so->GetName();
void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
CORBA::Boolean auto_groups,
- SMESH::MED_VERSION version,
CORBA::Boolean overwrite,
CORBA::Boolean autoDimension,
const GEOM::ListOfFields& fields,
{
aMeshName = prepareMeshNameAndGroups(file, overwrite);
_impl->ExportMED( file, aMeshName.c_str(), auto_groups,
- version, 0, autoDimension, /*addODOnVertices=*/have0dField);
+ 0, autoDimension, /*addODOnVertices=*/have0dField);
meshDS = _impl->GetMeshDS();
}
else
PrepareForWriting(file, overwrite);
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
- if ( !aStudy->_is_nil() ) {
- SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( aStudy, meshPart );
- if ( !SO->_is_nil() ) {
- CORBA::String_var name = SO->GetName();
- aMeshName = name;
- }
+ SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( meshPart );
+ if ( !SO->_is_nil() ) {
+ CORBA::String_var name = SO->GetName();
+ aMeshName = name;
}
+
SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart );
_impl->ExportMED( file, aMeshName.c_str(), auto_groups,
- version, partDS, autoDimension, /*addODOnVertices=*/have0dField);
+ partDS, autoDimension, /*addODOnVertices=*/have0dField);
meshDS = tmpDSDeleter._obj = partDS;
}
}
TPythonDump() << _this() << ".ExportPartToMED( "
<< meshPart << ", r'" << file << "', "
- << auto_groups << ", " << version << ", " << overwrite << ", "
+ << auto_groups << ", " << overwrite << ", "
<< autoDimension << ", " << goList
<< ", '" << ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )";
PrepareForWriting(file);
CORBA::String_var name;
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, meshPart );
+ SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( meshPart );
if ( !so->_is_nil() )
name = so->GetName();
void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
- CORBA::Boolean overwrite)
+ CORBA::Boolean overwrite,
+ CORBA::Boolean groupElemsByType)
throw (SALOME::SALOME_Exception)
{
#ifdef WITH_CGNS
PrepareForWriting(file,overwrite);
std::string meshName("");
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
- SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, meshPart );
+ SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( meshPart );
if ( !so->_is_nil() )
{
CORBA::String_var name = so->GetName();
meshName = name.in();
}
+ SMESH_TRY;
+
SMESH_MeshPartDS partDS( meshPart );
- _impl->ExportCGNS(file, &partDS, meshName.c_str() );
+ _impl->ExportCGNS(file, &partDS, meshName.c_str(), groupElemsByType );
+
+ SMESH_CATCH( SMESH::throwCorbaException );
TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportCGNS( "
<< meshPart<< ", r'" << file << "', " << overwrite << ")";
groups[ ++iG ] = createGroup( SMESH::ElementType(i), theGroupName );
if ( _gen_i->CanPublishInStudy( groups[ iG ] ))
{
- SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
SMESH::SMESH_Mesh_var mesh = _this();
SALOMEDS::SObject_wrap aSO =
- _gen_i->PublishGroup( study, mesh, groups[ iG ],
+ _gen_i->PublishGroup( mesh, groups[ iG ],
GEOM::GEOM_Object::_nil(), theGroupName);
}
SMESH_GroupBase_i* grp_i = SMESH::DownCast< SMESH_GroupBase_i* >( groups[ iG ]);
void SMESH_Mesh_i::CreateGroupServants()
{
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
SMESH::SMESH_Mesh_var aMesh = _this();
set<int> addedIDs;
else { nextId = 0; } // avoid "unused variable" warning in release mode
// publishing the groups in the study
- if ( !aStudy->_is_nil() ) {
- GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape );
- _gen_i->PublishGroup( aStudy, aMesh, groupVar, shapeVar, group->GetName());
- }
+ GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape );
+ _gen_i->PublishGroup( aMesh, groupVar, shapeVar, group->GetName());
}
if ( !addedIDs.empty() )
{
int nbGrp = NbGroups();
if ( !nbGrp )
return;
-
- SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
- if ( aStudy->_is_nil() )
- return; // nothing to do
SMESH::ListOfGroups* grpList = 0;
// avoid dump of "GetGroups"
SMESH::SMESH_GroupBase_ptr aGrp = (*grpList)[ gIndx ];
if ( !aGrp )
continue;
- SALOMEDS::SObject_wrap aGrpSO = _gen_i->ObjectToSObject( aStudy, aGrp );
+ SALOMEDS::SObject_wrap aGrpSO = _gen_i->ObjectToSObject( aGrp );
if ( aGrpSO->_is_nil() )
continue;
// correct name of the mesh group if necessary
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
if(gen) {
CORBA::String_var aParameters = GetParameters();
- SALOMEDS::Study_var aStudy = gen->GetCurrentStudy();
- if ( !aStudy->_is_nil()) {
- SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
- if ( aSections->length() > 0 ) {
- SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ];
- aResult->length( aVars.length() );
- for ( CORBA::ULong i = 0;i < aVars.length(); i++ )
- aResult[i] = CORBA::string_dup( aVars[i] );
- }
+ SALOMEDS::ListOfListOfStrings_var aSections = SMESH_Gen_i::getStudyServant()->ParseVariables(aParameters);
+ if ( aSections->length() > 0 ) {
+ SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ];
+ aResult->length( aVars.length() );
+ for ( CORBA::ULong i = 0;i < aVars.length(); i++ )
+ aResult[i] = CORBA::string_dup( aVars[i] );
}
}
return aResult._retn();
SMESH::SMESH_Mesh_var mesh = meshPart->GetMesh();
SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+ mesh_i->Load();
_meshDS = mesh_i->GetImpl().GetMeshDS();
SetPersistentId( _meshDS->GetPersistentId() );
myInfo = tmpInfo;
}
// -------------------------------------------------------------------------------------
+ const SMDS_MeshElement * SMESH_MeshPartDS::FindElement(int IDelem) const
+ {
+ if ( _meshDS ) return _meshDS->FindElement( IDelem );
+
+ TElemID elem( IDelem );
+ for ( int iType = SMDSAbs_Edge; iType < SMDSAbs_NbElementTypes; ++iType )
+ if ( !_elements[ iType ].empty() )
+ {
+ TIDSortedElemSet::const_iterator it = _elements[ iType ].find( &elem );
+ if ( it != _elements[ iType ].end() )
+ return *it;
+ }
+ return 0;
+ }
+ // -------------------------------------------------------------------------------------
SMDS_ElemIteratorPtr SMESH_MeshPartDS::elementGeomIterator(SMDSAbs_GeometryType geomType) const
{
if ( _meshDS ) return _meshDS->elementGeomIterator( geomType );
SMESH_Mesh_i(const SMESH_Mesh_i&);
public:
SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
- SMESH_Gen_i* myGen_i,
- CORBA::Long studyId );
+ SMESH_Gen_i* myGen_i );
virtual ~SMESH_Mesh_i();
CORBA::Long GetId() throw (SALOME::SALOME_Exception);
- CORBA::Long GetStudyId() throw (SALOME::SALOME_Exception);
-
// --- C++ interface
void SetImpl(::SMESH_Mesh* impl);
* Consider maximum group name length stored in MED file.
*/
CORBA::Boolean HasDuplicatedGroupNamesMED();
- /*!
- * Return string representation of a MED file version comprising nbDigits
- */
- char* GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits);
- void ExportToMEDX( const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION version,
- CORBA::Boolean overwrite,
- CORBA::Boolean autoDimension=true) throw (SALOME::SALOME_Exception);
- void ExportToMED ( const char* file,
- CORBA::Boolean auto_groups,
- SMESH::MED_VERSION version ) throw (SALOME::SALOME_Exception);
- void ExportMED ( const char* file,
- CORBA::Boolean auto_groups ) throw (SALOME::SALOME_Exception);
+ void ExportMED( const char* file,
+ CORBA::Boolean auto_groups,
+ CORBA::Boolean overwrite,
+ CORBA::Boolean autoDimension = true) throw (SALOME::SALOME_Exception);
void ExportSAUV( const char* file, CORBA::Boolean auto_groups ) throw (SALOME::SALOME_Exception);
void ExportSTL( const char* file, bool isascii ) throw (SALOME::SALOME_Exception);
void ExportCGNS(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
- CORBA::Boolean overwrite) throw (SALOME::SALOME_Exception);
+ CORBA::Boolean overwrite,
+ CORBA::Boolean groupElemsByType) throw (SALOME::SALOME_Exception);
void ExportGMF(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
CORBA::Boolean withRequiredGroups) throw (SALOME::SALOME_Exception);
void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
const char* file,
CORBA::Boolean auto_groups,
- SMESH::MED_VERSION version,
CORBA::Boolean overwrite,
CORBA::Boolean autoDim,
const GEOM::ListOfFields& fields,
CORBA::Long NbPolygons()
throw (SALOME::SALOME_Exception);
- CORBA::Long NbPolygonsOfOrder(SMESH::ElementOrder order=SMESH::ORDER_ANY)
+ CORBA::Long NbPolygonsOfOrder(SMESH::ElementOrder order = SMESH::ORDER_ANY)
throw (SALOME::SALOME_Exception);
CORBA::Long NbVolumes()
::SMESH_Mesh* _impl; // :: force no namespace here
SMESH_Gen_i* _gen_i;
int _id; // id given by creator (unique within the creator instance)
- int _studyId;
std::map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
std::map<int, SMESH::SMESH_GroupBase_ptr> _mapGroups;
std::map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;
static void addErrorCode(const char* thePyCommand)
{
TPythonDump() << "if (isDone != 1):";
- TPythonDump() << "\tprint '" << thePyCommand << " :', pattern.GetErrorCode()";
+ TPythonDump() << "\tprint('" << thePyCommand << " :', pattern.GetErrorCode())";
}
//=============================================================================
}
bool ok = false;
try {
- #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
- #endif
ok = myPattern.Apply( aMesh, fset, theNodeIndexOnKeyPoint1, theReverse );
}
catch (Standard_Failure& exc) {
{
enum { GroupOnFilter_OutOfDate = -1 };
- // a map to count not yet loaded meshes
- static std::map< int, int > theStudyIDToMeshCounter;
+ // count not yet loaded meshes
+ static int theMeshCounter = 0;
//================================================================================
/*!
void meshInfoLoaded( SMESH_Mesh_i* mesh )
{
- std::map< int, int >::iterator id2counter =
- theStudyIDToMeshCounter.insert( std::make_pair( (int) mesh->GetStudyId(), 0 )).first;
- id2counter->second++;
+ theMeshCounter++;
}
//================================================================================
/*!
std::string medFile,
std::string hdfFile)
{
- if ( --theStudyIDToMeshCounter[ (int) mesh->GetStudyId() ] == 0 )
+ if ( --theMeshCounter == 0 )
{
std::string tmpDir = SALOMEDS_Tool::GetDirFromPath( hdfFile );
- SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames;
- aFiles->length(2);
+ SALOMEDS_Tool::ListOfFiles aFiles;
+ aFiles.reserve(2);
medFile = SALOMEDS_Tool::GetNameFromPath( medFile ) + ".med";
hdfFile = SALOMEDS_Tool::GetNameFromPath( hdfFile ) + ".hdf";
- aFiles[0] = medFile.c_str();
- aFiles[1] = hdfFile.c_str();
+ aFiles.push_back(medFile.c_str());
+ aFiles.push_back(hdfFile.c_str());
- SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles.in(), true );
+ SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.c_str(), aFiles, true );
}
}
SignalToGUI( SMESH_Mesh_i* mesh )
{
SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var study = gen->GetCurrentStudy();
- if ( !study->_is_nil() && study->StudyId() == mesh->GetStudyId() )
+
+ SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( mesh->_this() );
+ CORBA::Object_var obj = gen->GetNS()->Resolve( "/Kernel/Session" );
+ _session = SALOME::Session::_narrow( obj );
+ if ( !meshSO->_is_nil() && !_session->_is_nil() )
{
- SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject(study, mesh->_this() );
- CORBA::Object_var obj = gen->GetNS()->Resolve( "/Kernel/Session" );
- _session = SALOME::Session::_narrow( obj );
- if ( !meshSO->_is_nil() && !_session->_is_nil() )
- {
- CORBA::String_var meshEntry = meshSO->GetID();
- _messagePrefix = "SMESH/mesh_loading/";
- _messagePrefix += meshEntry.in();
+ CORBA::String_var meshEntry = meshSO->GetID();
+ _messagePrefix = "SMESH/mesh_loading/";
+ _messagePrefix += meshEntry.in();
- std::string msgToGUI = _messagePrefix + "/";
- msgToGUI += SMESH_Comment( mesh->NbNodes() );
- msgToGUI += "/";
- msgToGUI += SMESH_Comment( mesh->NbElements() );
+ std::string msgToGUI = _messagePrefix + "/";
+ msgToGUI += SMESH_Comment( mesh->NbNodes() );
+ msgToGUI += "/";
+ msgToGUI += SMESH_Comment( mesh->NbElements() );
- _session->emitMessageOneWay( msgToGUI.c_str());
- }
+ _session->emitMessageOneWay( msgToGUI.c_str());
}
}
void sendStop()
*/
//================================================================================
- void SMESH_PreMeshInfo::hdf2meshInfo( const std::string& name,
- HDFgroup* hdfGroup)
+ void SMESH_PreMeshInfo::hdf2meshInfo( const std::string& name,
+ HDFgroup* hdfGroup,
+ const TColStd_MapOfAsciiString& allHdfNames)
{
- if ( hdfGroup->ExistInternalObject( name.c_str()) )
+ //if ( hdfGroup->ExistInternalObject( name.c_str()) ) PAL23514
+ if ( allHdfNames.Contains( name.c_str() ))
{
HDFdataset* dataset = new HDFdataset( name.c_str(), hdfGroup );
dataset->OpenOnDisk();
HDFgroup* infoHdfGroup = new HDFgroup( hdfGroupName, aFile );
infoHdfGroup->OpenOnDisk();
- _mesh->changePreMeshInfo()->hdf2meshInfo( "Mesh", infoHdfGroup );
+ // PAL23514: get all names from the HDFgroup to avoid iteration on its contents
+ // within aGroup->ExistInternalObject( name )
+ TColStd_MapOfAsciiString mapOfNames;
+ {
+ std::vector< std::string > subNames;
+ infoHdfGroup->GetAllObjects( subNames );
+ for ( size_t iN = 0; iN < subNames.size(); ++iN )
+ mapOfNames.Add( subNames[ iN ].c_str() );
+ }
+
+ _mesh->changePreMeshInfo()->hdf2meshInfo( "Mesh", infoHdfGroup, mapOfNames );
// read SMESH_PreMeshInfo of groups
map<int, SMESH::SMESH_GroupBase_ptr>::const_iterator i2group = _mesh->_mapGroups.begin();
if ( SMESHDS_GroupBase* group = group_i->GetGroupDS() )
{
const std::string name = group->GetStoreName();
- group_i->changePreMeshInfo()->hdf2meshInfo( name, infoHdfGroup );
+ group_i->changePreMeshInfo()->hdf2meshInfo( name, infoHdfGroup, mapOfNames );
}
}
}
if ( SMESH_subMesh_i* sm = SMESH::DownCast<SMESH_subMesh_i*>( id2sm->second ))
{
sm->changePreMeshInfo() = newInstance();
- sm->changePreMeshInfo()->hdf2meshInfo( SMESH_Comment( sm->GetId()), infoHdfGroup );
+ sm->changePreMeshInfo()->hdf2meshInfo( SMESH_Comment( sm->GetId()),
+ infoHdfGroup,
+ mapOfNames );
}
}
}
{
_isInfoOk = true;
- MED::PWrapper aMed = MED::CrWrapper(_medFileName,true);
- // if ( aMed->GetVersion() != MED::eV2_2 )
- // return false;
-
+ MED::PWrapper aMed = MED::CrWrapperR(_medFileName);
MED::PMeshInfo medMeshInfo = aMed->CrMeshInfo(3,3,SMESH_Comment( _meshID ));
// read nb nodes
map< int, vector< SMESH_PreMeshInfo* > > famId2grInfo;
- MED::PWrapper aMed = MED::CrWrapper(_medFileName,false);
+ MED::PWrapper aMed = MED::CrWrapperR(_medFileName);
MED::PMeshInfo medMeshInfo = aMed->CrMeshInfo(3,3,SMESH_Comment( _meshID ));
// read families to fill in famId2grInfo
void SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD(SALOMEDS::SComponent_ptr smeshComp)
{
- SALOMEDS::Study_var study = smeshComp->GetStudy();
- if ( theStudyIDToMeshCounter[ (int) study->StudyId() ] > 0 )
+ if ( theMeshCounter > 0 )
{
- SALOMEDS::ChildIterator_wrap itBig = study->NewChildIterator( smeshComp );
+ SALOMEDS::ChildIterator_wrap itBig = SMESH_Gen_i::getStudyServant()->NewChildIterator( smeshComp );
for ( ; itBig->More(); itBig->Next() ) {
SALOMEDS::SObject_wrap gotBranch = itBig->Value();
CORBA::Object_var anObject = SMESH_Gen_i::SObjectToObject( gotBranch );
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : SMESH_DumpPython.cxx
+// Created : Thu Mar 24 17:17:59 2005
+// Author : Julia DOROVSKIKH
+// Module : SMESH
+
+#include "SMESH_PythonDump.hxx"
+
+#include "SMESH_2smeshpy.hxx"
+#include "SMESH_Comment.hxx"
+#include "SMESH_Filter_i.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_MeshEditor_i.hxx"
+
+#include <SALOMEDS_wrap.hxx>
+
+#include <LDOMParser.hxx>
+#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+#include "SMESH_TryCatch.hxx"
+
+namespace SMESH
+{
+
+ size_t TPythonDump::myCounter = 0;
+ const char theNotPublishedObjectName[] = "__NOT__Published__Object__";
+
+ TVar::TVar(CORBA::Double value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Long value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(CORBA::Short value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
+ TVar::TVar(const SMESH::double_array& value):myVals(value.length()), myIsList(true)
+ {
+ for ( size_t i = 0; i < value.length(); i++)
+ myVals[i] = SMESH_Comment(value[i]);
+ }
+
+ TPythonDump::
+ TPythonDump():myVarsCounter(0)
+ {
+ ++myCounter;
+ }
+ TPythonDump::
+ ~TPythonDump()
+ {
+ if(--myCounter == 0){
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ std::string aString = myStream.str();
+ TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
+ if(!aCollection.IsEmpty())
+ {
+ const std::string & objEntry = SMESH_Gen_i::GetSMESHGen()->GetLastObjEntry();
+ if ( !objEntry.empty() )
+ aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
+ aSMESHGen->AddToPythonScript(aCollection);
+ if(MYDEBUG) MESSAGE(aString);
+ // prevent misuse of already treated variables
+ aSMESHGen->UpdateParameters(CORBA::Object_var().in(),"");
+ }
+ }
+ }
+
+ TPythonDump& //!< store a variable value. Write either a value or '$varID$'
+ TPythonDump::
+ operator<<(const TVar& theVarValue)
+ {
+ const std::vector< int >& varIDs = SMESH_Gen_i::GetSMESHGen()->GetLastParamIndices();
+ if ( theVarValue.myIsList )
+ {
+ myStream << "[ ";
+ for ( size_t i = 1; i <= theVarValue.myVals.size(); ++i )
+ {
+ if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
+ myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
+ else
+ myStream << theVarValue.myVals[i-1];
+ if ( i < theVarValue.myVals.size() )
+ myStream << ", ";
+ ++myVarsCounter;
+ }
+ myStream << " ]";
+ }
+ else
+ {
+ if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
+ myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
+ else
+ myStream << theVarValue.myVals[0];
+ ++myVarsCounter;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(long int theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(int theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(double theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(float theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const void* theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const char* theArg){
+ if ( theArg )
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const std::string& theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::ElementType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case ALL: myStream<<"ALL"; break;
+ case NODE: myStream<<"NODE"; break;
+ case EDGE: myStream<<"EDGE"; break;
+ case FACE: myStream<<"FACE"; break;
+ case VOLUME: myStream<<"VOLUME"; break;
+ case ELEM0D: myStream<<"ELEM0D"; break;
+ case BALL: myStream<<"BALL"; break;
+ default: myStream<<"__UNKNOWN__ElementType: " << theArg;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::GeometryType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case Geom_POINT: myStream<<"Geom_POINT"; break;
+ case Geom_EDGE: myStream<<"Geom_EDGE"; break;
+ case Geom_TRIANGLE: myStream<<"Geom_TRIANGLE"; break;
+ case Geom_QUADRANGLE: myStream<<"Geom_QUADRANGLE"; break;
+ case Geom_POLYGON: myStream<<"Geom_POLYGON"; break;
+ case Geom_TETRA: myStream<<"Geom_TETRA"; break;
+ case Geom_PYRAMID: myStream<<"Geom_PYRAMID"; break;
+ case Geom_HEXA: myStream<<"Geom_HEXA"; break;
+ case Geom_PENTA: myStream<<"Geom_PENTA"; break;
+ case Geom_POLYHEDRA: myStream<<"Geom_POLYHEDRA"; break;
+ case Geom_BALL: myStream<<"Geom_BALL"; break;
+ default: myStream<<"__UNKNOWN__GeometryType: " << theArg;
+ }
+ return *this;
+ }
+ TPythonDump&
+ TPythonDump::
+ operator<<(const SMESH::EntityType& theArg)
+ {
+ myStream<<"SMESH.";
+ switch(theArg){
+ case Entity_0D: myStream<<"Entity_0D"; break;
+ case Entity_Edge: myStream<<"Entity_Edge"; break;
+ case Entity_Quad_Edge: myStream<<"Entity_Quad_Edge"; break;
+ case Entity_Triangle: myStream<<"Entity_Triangle"; break;
+ case Entity_Quad_Triangle: myStream<<"Entity_Quad_Triangle"; break;
+ case Entity_BiQuad_Triangle: myStream<<"Entity_BiQuad_Triangle"; break;
+ case Entity_Quadrangle: myStream<<"Entity_Quadrangle"; break;
+ case Entity_Quad_Quadrangle: myStream<<"Entity_Quad_Quadrangle"; break;
+ case Entity_BiQuad_Quadrangle: myStream<<"Entity_BiQuad_Quadrangle"; break;
+ case Entity_Polygon: myStream<<"Entity_Polygon"; break;
+ case Entity_Quad_Polygon: myStream<<"Entity_Quad_Polygon"; break;
+ case Entity_Tetra: myStream<<"Entity_Tetra"; break;
+ case Entity_Quad_Tetra: myStream<<"Entity_Quad_Tetra"; break;
+ case Entity_Pyramid: myStream<<"Entity_Pyramid"; break;
+ case Entity_Quad_Pyramid: myStream<<"Entity_Quad_Pyramid"; break;
+ case Entity_Hexa: myStream<<"Entity_Hexa"; break;
+ case Entity_Quad_Hexa: myStream<<"Entity_Quad_Hexa"; break;
+ case Entity_TriQuad_Hexa: myStream<<"Entity_TriQuad_Hexa"; break;
+ case Entity_Penta: myStream<<"Entity_Penta"; break;
+ case Entity_Quad_Penta: myStream<<"Entity_Quad_Penta"; break;
++ case Entity_BiQuad_Penta: myStream<<"Entity_BiQuad_Penta"; break;
+ case Entity_Hexagonal_Prism: myStream<<"Entity_Hexagonal_Prism"; break;
+ case Entity_Polyhedra: myStream<<"Entity_Polyhedra"; break;
+ case Entity_Quad_Polyhedra: myStream<<"Entity_Quad_Polyhedra"; break;
+ case Entity_Ball: myStream<<"Entity_Ball"; break;
+ case Entity_Last: myStream<<"Entity_Last"; break;
+ default: myStream<<"__UNKNOWN__EntityType: " << theArg;
+ }
+ return *this;
+ }
+
+ template<class TArray>
+ void DumpArray(const TArray& theArray, TPythonDump & theStream)
+ {
+ if ( theArray.length() == 0 )
+ {
+ theStream << "[]";
+ }
+ else
+ {
+ theStream << "[ ";
+ for (CORBA::ULong i = 1; i <= theArray.length(); i++) {
+ theStream << theArray[i-1];
+ if ( i < theArray.length() )
+ theStream << ", ";
+ }
+ theStream << " ]";
+ }
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::long_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::double_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::nodes_array& theArg)
+ {
+ DumpArray( theArg, *this );
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::operator<<(const SMESH::string_array& theArray)
+ {
+ myStream << "[ ";
+ for ( CORBA::ULong i = 1; i <= theArray.length(); i++ ) {
+ myStream << "'" << theArray[i-1] << "'";
+ if ( i < theArray.length() )
+ myStream << ", ";
+ }
+ myStream << " ]";
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SALOMEDS::SObject_ptr aSObject)
+ {
+ if ( !aSObject->_is_nil() ) {
+ CORBA::String_var entry = aSObject->GetID();
+ myStream << entry.in();
+ }
+ else {
+ myStream << theNotPublishedObjectName;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(CORBA::Object_ptr theArg)
+ {
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ if(!aSObject->_is_nil()) {
+ CORBA::String_var id = aSObject->GetID();
+ myStream << id;
+ } else if ( !CORBA::is_nil(theArg)) {
+ if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object
+ myStream << "smeshObj_" << size_t(theArg);
+ else
+ myStream << theNotPublishedObjectName;
+ }
+ else
+ myStream << "None";
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
+ {
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
+ myStream << "hyp_" << theArg->GetId();
+ else
+ *this << aSObject;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::SMESH_IDSource_ptr theArg)
+ {
+ if ( CORBA::is_nil( theArg ) )
+ return *this << "None";
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
+ if(!aSObject->_is_nil())
+ {
+ return *this << aSObject;
+ }
+ if ( SMESH::Filter_i* filter = SMESH::DownCast<SMESH::Filter_i*>( theArg ))
+ {
+ return *this << filter;
+ }
+ if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theArg ))
+ {
+ SMESH::SMESH_Mesh_var mesh = theArg->GetMesh();
+ SMESH::long_array_var anElementsId = theArg->GetIDs();
+ SMESH::array_of_ElementType_var types = theArg->GetTypes();
+ SMESH::ElementType type = types->length() ? types[0] : SMESH::ALL;
+ SALOMEDS::SObject_wrap meshSO = SMESH_Gen_i::ObjectToSObject(mesh);
+ if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
+ return *this << mesh << ".GetIDSource([], " << type << ")";
+ else
+ return *this << mesh << ".GetIDSource(" << anElementsId << ", " << type << ")";
+ }
+ return *this << theNotPublishedObjectName;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::FilterLibrary_i* theArg)
+ {
+ myStream<<"aFilterLibrary"<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::FilterManager_i* theArg)
+ {
+ myStream<<"aFilterManager";
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Filter_i* theArg)
+ {
+ myStream<<"aFilter"<<theArg;
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Functor_i* theArg)
+ {
+ if ( theArg ) {
+ FunctorType aFunctorType = theArg->GetFunctorType();
+ switch(aFunctorType) {
+ case FT_AspectRatio: myStream<< "aAspectRatio"; break;
+ case FT_AspectRatio3D: myStream<< "aAspectRatio3D"; break;
+ case FT_Warping: myStream<< "aWarping"; break;
+ case FT_MinimumAngle: myStream<< "aMinimumAngle"; break;
+ case FT_Taper: myStream<< "aTaper"; break;
+ case FT_Skew: myStream<< "aSkew"; break;
+ case FT_Area: myStream<< "aArea"; break;
+ case FT_Volume3D: myStream<< "aVolume3D"; break;
+ case FT_MaxElementLength2D: myStream<< "aMaxElementLength2D"; break;
+ case FT_MaxElementLength3D: myStream<< "aMaxElementLength3D"; break;
+ case FT_FreeBorders: myStream<< "aFreeBorders"; break;
+ case FT_FreeEdges: myStream<< "aFreeEdges"; break;
+ case FT_FreeNodes: myStream<< "aFreeNodes"; break;
+ case FT_FreeFaces: myStream<< "aFreeFaces"; break;
+ case FT_EqualNodes: myStream<< "aEqualNodes"; break;
+ case FT_EqualEdges: myStream<< "aEqualEdges"; break;
+ case FT_EqualFaces: myStream<< "aEqualFaces"; break;
+ case FT_EqualVolumes: myStream<< "aEqualVolumes"; break;
+ case FT_MultiConnection: myStream<< "aMultiConnection"; break;
+ case FT_MultiConnection2D: myStream<< "aMultiConnection2D"; break;
+ case FT_Length: myStream<< "aLength"; break;
+ case FT_Length2D: myStream<< "aLength2D"; break;
++ case FT_Deflection2D: myStream<< "aDeflection2D"; break;
+ case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break;
+ case FT_BelongToMeshGroup: myStream<< "aBelongToMeshGroup"; break;
+ case FT_BelongToGeom: myStream<< "aBelongToGeom"; break;
+ case FT_BelongToPlane: myStream<< "aBelongToPlane"; break;
+ case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break;
+ case FT_BelongToGenSurface: myStream<< "aBelongToGenSurface"; break;
+ case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break;
+ case FT_RangeOfIds: myStream<< "aRangeOfIds"; break;
+ case FT_BadOrientedVolume: myStream<< "aBadOrientedVolume"; break;
+ case FT_BareBorderVolume: myStream<< "aBareBorderVolume"; break;
+ case FT_BareBorderFace: myStream<< "aBareBorderFace"; break;
+ case FT_OverConstrainedVolume: myStream<< "aOverConstrainedVolume"; break;
+ case FT_OverConstrainedFace: myStream<< "aOverConstrainedFace"; break;
+ case FT_LinearOrQuadratic: myStream<< "aLinearOrQuadratic"; break;
+ case FT_GroupColor: myStream<< "aGroupColor"; break;
+ case FT_ElemGeomType: myStream<< "aElemGeomType"; break;
+ case FT_EntityType: myStream<< "aEntityType"; break;
+ case FT_CoplanarFaces: myStream<< "aCoplanarFaces"; break;
+ case FT_BallDiameter: myStream<< "aBallDiameter"; break;
+ case FT_ConnectedElements: myStream<< "aConnectedElements"; break;
+ case FT_LessThan: myStream<< "aLessThan"; break;
+ case FT_MoreThan: myStream<< "aMoreThan"; break;
+ case FT_EqualTo: myStream<< "aEqualTo"; break;
+ case FT_LogicalNOT: myStream<< "aLogicalNOT"; break;
+ case FT_LogicalAND: myStream<< "aLogicalAND"; break;
+ case FT_LogicalOR: myStream<< "aLogicalOR"; break;
+ case FT_Undefined: myStream<< "anUndefined"; break;
+ //default: -- commented to have a compilation warning
+ }
+ myStream<<theArg;
+ }
+ return *this;
+ }
+
+ TPythonDump&
+ TPythonDump::
+ operator<<(SMESH::Measurements_i* theArg)
+ {
+ myStream<<"aMeasurements";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
+ {
+ myStream << SMESHGenName(); return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(SMESH_MeshEditor_i* theArg)
+ {
+ myStream << MeshEditorName() << "_" << ( theArg ? theArg->GetMeshId() : -1 ); return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const TCollection_AsciiString & theStr)
+ {
+ myStream << theStr; return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::AxisStruct & theAxis)
+ {
+ *this << "SMESH.AxisStruct( "
+ << TVar( theAxis.x ) << ", "
+ << TVar( theAxis.y ) << ", "
+ << TVar( theAxis.z ) << ", "
+ << TVar( theAxis.vx ) << ", "
+ << TVar( theAxis.vy ) << ", "
+ << TVar( theAxis.vz ) << " )";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::DirStruct & theDir)
+ {
+ const SMESH::PointStruct & P = theDir.PS;
+ *this << "SMESH.DirStruct( SMESH.PointStruct ( "
+ << TVar( P.x ) << ", "
+ << TVar( P.y ) << ", "
+ << TVar( P.z ) << " ))";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::PointStruct & P)
+ {
+ *this << "SMESH.PointStruct ( "
+ << TVar( P.x ) << ", "
+ << TVar( P.y ) << ", "
+ << TVar( P.z ) << " )";
+ return *this;
+ }
+
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups * theList)
+ {
+ DumpArray( *theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGO& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGBO& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::ListOfIDSources& theList)
+ {
+ DumpArray( theList, *this );
+ return *this;
+ }
+ TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
+ {
+ // dump CoincidentFreeBorders as a list of lists, each enclosed list
+ // contains node IDs of a group of coincident free borders where
+ // each consequent triple of IDs describe a free border: (n1, n2, nLast)
+ // For example [[1, 2, 10, 20, 21, 40], [11, 12, 15, 55, 54, 41]] describes
+ // two groups of coincident free borders, each group including two borders
+
+ myStream << "[";
+ for ( CORBA::ULong i = 0; i < theCFB.coincidentGroups.length(); ++i )
+ {
+ const SMESH::FreeBordersGroup& aGRP = theCFB.coincidentGroups[ i ];
+ if ( i ) myStream << ",";
+ myStream << "[";
+ for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
+ {
+ const SMESH::FreeBorderPart& aPART = aGRP[ iP ];
+ if ( 0 <= aPART.border && aPART.border < (CORBA::Long)theCFB.borders.length() )
+ {
+ if ( iP ) myStream << ", ";
+ const SMESH::FreeBorder& aBRD = theCFB.borders[ aPART.border ];
+ myStream << aBRD.nodeIDs[ aPART.node1 ] << ",";
+ myStream << aBRD.nodeIDs[ aPART.node2 ] << ",";
+ myStream << aBRD.nodeIDs[ aPART.nodeLast ];
+ }
+ }
+ myStream << "]";
+ }
+ myStream << "]";
+
+ return *this;
+ }
+
+ const char* TPythonDump::NotPublishedObjectName()
+ {
+ return theNotPublishedObjectName;
+ }
+
+ TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
+ TCollection_AsciiString myLongStringEnd ( "TPythonDump::LongStringEnd" );
+
+ //================================================================================
+ /*!
+ * \brief Return marker of long string literal beginning
+ * \param type - a name of functionality producing the string literal
+ * \retval TCollection_AsciiString - the marker string to be written into
+ * a raw python script
+ */
+ //================================================================================
+
+ TCollection_AsciiString TPythonDump::LongStringStart(const char* type)
+ {
+ return
+ myLongStringStart +
+ (Standard_Integer) strlen(type) +
+ " " +
+ (char*) type;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Return marker of long string literal end
+ * \retval TCollection_AsciiString - the marker string to be written into
+ * a raw python script
+ */
+ //================================================================================
+
+ TCollection_AsciiString TPythonDump::LongStringEnd()
+ {
+ return myLongStringEnd;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Cut out a long string literal from a string
+ * \param theText - text possibly containing string literals
+ * \param theFrom - position in the text to search from
+ * \param theLongString - the retrieved literal
+ * \param theStringType - a name of functionality produced the literal
+ * \retval bool - true if a string literal found
+ *
+ * The literal is removed from theText; theFrom points position right after
+ * the removed literal
+ */
+ //================================================================================
+
+ bool TPythonDump::CutoutLongString( TCollection_AsciiString & theText,
+ int & theFrom,
+ TCollection_AsciiString & theLongString,
+ TCollection_AsciiString & theStringType)
+ {
+ if ( theFrom < 1 || theFrom > theText.Length() )
+ return false;
+
+ // ...script \ beg marker \ \ type \ literal \ end marker \ script...
+ // "theText myLongStringStart7 Pattern!!! SALOME Mesh Pattern file myLongStringEndtextEnd"
+ // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+ // 0 1 2 3 4 5 6 7 8
+
+ theFrom = theText.Location( myLongStringStart, theFrom, theText.Length() ); // = 09
+ if ( !theFrom )
+ return false;
+
+ // find where literal begins
+ int literalBeg = theFrom + myLongStringStart.Length(); // = 26
+ char* typeLenStr = (char*) theText.ToCString() + literalBeg - 1; // = "7 Pattern!!! SALO...."
+ int typeLen = atoi ( typeLenStr ); // = 7
+ while ( *typeLenStr != ' ' ) { // look for ' ' after typeLen
+ literalBeg++; // 26 -> 27
+ typeLenStr++;
+ }
+ literalBeg += typeLen + 1; // = 35
+ if ( literalBeg > theText.Length() )
+ return false;
+
+ // where literal ends (i.e. end marker begins)
+ int literalEnd = theText.Location( myLongStringEnd, literalBeg, theText.Length() ); // = 64
+ if ( !literalEnd )
+ literalEnd = theText.Length();
+
+ // literal
+ theLongString = theText.SubString( literalBeg, literalEnd - 1); // "!!! SALOME Mesh Pattern file "
+ // type
+ theStringType = theText.SubString( literalBeg - typeLen, literalBeg - 1 ); // "Pattern"
+ // cut off literal
+ literalEnd += myLongStringEnd.Length(); // = 79
+ TCollection_AsciiString textEnd = theText.SubString( literalEnd, theText.Length() ); // "textE..."
+ theText = theText.SubString( 1, theFrom - 1 ) + textEnd;
+
+ return true;
+ }
+
+ void printException( const char* text )
+ {
+#ifdef _DEBUG_
+ cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << endl;
+#endif
+ }
+}
+
+//=======================================================================
+//function : RemoveTabulation
+//purpose :
+//=======================================================================
+void RemoveTabulation( TCollection_AsciiString& theScript )
+{
+ std::string aString( theScript.ToCString() );
+ std::string::size_type aPos = 0;
+ while( aPos < aString.length() )
+ {
+ aPos = aString.find( "\n\t", aPos );
+ if( aPos == std::string::npos )
+ break;
+ aString.replace( aPos, 2, "\n" );
+ aPos++;
+ }
+ theScript = aString.c_str();
+}
+
+//=======================================================================
+//function : DumpPython
+//purpose :
+//=======================================================================
+Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean& isValidScript)
+{
+ SALOMEDS::Study_var aStudy = getStudyServant();
+ if (CORBA::is_nil(aStudy))
+ return new Engines::TMPFile(0);
+
+ CORBA::String_var compDataType = ComponentDataType();
+ SALOMEDS::SObject_wrap aSO = aStudy->FindComponent( compDataType.in() );
+ if (CORBA::is_nil(aSO))
+ return new Engines::TMPFile(0);
+
+ // Map study entries to object names
+ Resource_DataMapOfAsciiStringAsciiString aMap;
+ Resource_DataMapOfAsciiStringAsciiString aMapNames;
+
+ SALOMEDS::ChildIterator_wrap Itr = aStudy->NewChildIterator(aSO);
+ for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
+ SALOMEDS::SObject_wrap aValue = Itr->Value();
+ CORBA::String_var anID = aValue->GetID();
+ CORBA::String_var aName = aValue->GetName();
+ TCollection_AsciiString aGUIName ( (char*) aName.in() );
+ TCollection_AsciiString anEntry ( (char*) anID.in() );
+ if (aGUIName.Length() > 0) {
+ aMapNames.Bind( anEntry, aGUIName );
+ aMap.Bind( anEntry, aGUIName );
+ }
+ }
+
+ // Get trace of restored study
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_wrap anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+ SALOMEDS::AttributePythonObject_var pyAttr =
+ SALOMEDS::AttributePythonObject::_narrow(anAttr);
+ CORBA::String_var oldValue = pyAttr->GetObject();
+ TCollection_AsciiString aSavedTrace (oldValue.in());
+
+ // Add trace of API methods calls and replace study entries by names
+ TCollection_AsciiString aScript;
+ aScript += DumpPython_impl(aMap, aMapNames, isPublished, isMultiFile,
+ myIsHistoricalPythonDump, isValidScript, aSavedTrace);
+
+ int aLen = aScript.Length();
+ unsigned char* aBuffer = new unsigned char[aLen+1];
+ strcpy((char*)aBuffer, aScript.ToCString());
+
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
+ Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
+
+ bool hasNotPublishedObjects = aScript.Location( SMESH::theNotPublishedObjectName, 1, aLen);
+ isValidScript = isValidScript && !hasNotPublishedObjects;
+
+ return aStreamFile._retn();
+}
+
+//=============================================================================
+/*!
+ * AddToPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::AddToPythonScript (const TCollection_AsciiString& theString)
+{
+ if (myPythonScript.IsNull()) {
+ myPythonScript = new TColStd_HSequenceOfAsciiString;
+ }
+ myPythonScript->Append(theString);
+}
+
+//=============================================================================
+/*!
+ * RemoveLastFromPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::RemoveLastFromPythonScript()
+{
+ if (!myPythonScript.IsNull()) {
+ int aLen = myPythonScript->Length();
+ myPythonScript->Remove(aLen);
+ }
+}
+
+//=======================================================================
+//function : SavePython
+//purpose :
+//=======================================================================
+void SMESH_Gen_i::SavePython()
+{
+ // Dump trace of API methods calls
+ TCollection_AsciiString aScript = GetNewPythonLines();
+
+ // Check contents of PythonObject attribute
+ CORBA::String_var compDataType = ComponentDataType();
+ SALOMEDS::SObject_wrap aSO = getStudyServant()->FindComponent( compDataType.in() );
+ SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
+ SALOMEDS::GenericAttribute_wrap anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+ SALOMEDS::AttributePythonObject_var pyAttr =
+ SALOMEDS::AttributePythonObject::_narrow(anAttr);
+ CORBA::String_var oldValue = pyAttr->GetObject();
+ TCollection_AsciiString oldScript (oldValue.in());
+
+ if (oldScript.Length() > 0) {
+ oldScript += "\n";
+ oldScript += aScript;
+ } else {
+ oldScript = aScript;
+ }
+
+ // Store in PythonObject attribute
+ pyAttr->SetObject(oldScript.ToCString(), 1);
+
+ // Clean trace of API methods calls
+ CleanPythonTrace();
+}
+
+
+// impl
+
+
+//=============================================================================
+/*!
+ * FindEntries: Returns a sequence of start/end positions of entries in the string
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
+{
+ Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+ Standard_Integer aLen = theString.Length();
+ Standard_Boolean isFound = Standard_False;
+
+ char* arr = (char*) theString.ToCString();
+ Standard_Integer i = 0, j;
+
+ while(i < aLen) {
+ int c = (int)arr[i];
+ j = i+1;
+ if ( isdigit( c )) { //Is digit?
+
+ isFound = Standard_False;
+ while((j < aLen) && ( isdigit(c) || c == ':' )) { //Check if it is an entry
+ c = (int)arr[j++];
+ if(c == ':') isFound = Standard_True;
+ }
+
+ if (isFound) {
+ int prev = (i < 1) ? 0 : (int)arr[i - 1];
+ // to distinguish from a sketcher command:
+ // last char should be a digit, not ":",
+ // previous char should not be '"'.
+ if (arr[j-2] != ':' && prev != '"') {
+ aSeq->Append(i+1); // +1 because AsciiString starts from 1
+ aSeq->Append(j-1);
+ }
+ }
+ }
+
+ i = j;
+ }
+
+ return aSeq;
+}
+
+namespace {
+
+ //================================================================================
+ /*!
+ * \brief Make a string be a valid python name
+ * \param aName - a string to fix
+ * \retval bool - true if aName was not modified
+ */
+ //================================================================================
+
+ bool fixPythonName(TCollection_AsciiString & aName)
+ {
+ bool isValidName = true;
+ int nbUnderscore = 0;
+ int p;
+ // replace not allowed chars by underscore
+ const char* name = aName.ToCString();
+ for ( p = 0; name[p]; ++p ) {
+ if ( !isalnum( name[p] ) && name[p] != '_' )
+ {
+ if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_')
+ {
+ aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end
+ --p;
+ name = aName.ToCString();
+ }
+ else
+ {
+ aName.SetValue( p+1, '_');
+ nbUnderscore++;
+ }
+ isValidName = false;
+ }
+ }
+ // aName must not start with a digit
+ if ( aName.IsIntegerValue() ) {
+ aName.Insert( 1, 'a' );
+ isValidName = false;
+ }
+ // shorten names like CartesianParameters3D_400_400_400_1000000_1
+ const int nbAllowedUnderscore = 3; /* changed from 2 to 3 by an user request
+ posted to SALOME Forum */
+ if ( aName.Length() > 20 && nbUnderscore > nbAllowedUnderscore )
+ {
+ p = aName.Location( "_", 20, aName.Length());
+ if ( p > 1 )
+ aName.Trunc( p-1 );
+ }
+ return isValidName;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Return Python module names of available plug-ins.
+ */
+ //================================================================================
+
+ std::vector<std::string> getPluginNames()
+ {
+ std::vector<std::string> pluginNames;
+ std::vector< std::string > xmlPaths = SMESH_Gen::GetPluginXMLPaths();
+ LDOMParser xmlParser;
+ for ( size_t i = 0; i < xmlPaths.size(); ++i )
+ {
+ bool error = xmlParser.parse( xmlPaths[i].c_str() );
+ if ( error )
+ {
+ TCollection_AsciiString data;
+ INFOS( xmlParser.GetError(data) );
+ continue;
+ }
+ // <meshers-group name="Standard Meshers"
+ // resources="StdMeshers"
+ // idl-module="StdMeshers"
+ // server-lib="StdMeshersEngine"
+ // gui-lib="StdMeshersGUI">
+ LDOM_Document xmlDoc = xmlParser.getDocument();
+ LDOM_NodeList nodeList = xmlDoc.getElementsByTagName( "meshers-group" );
+ for ( int i = 0; i < nodeList.getLength(); ++i )
+ {
+ LDOM_Node node = nodeList.item( i );
+ LDOM_Element& elem = (LDOM_Element&) node;
+ LDOMString idlModule = elem.getAttribute( "idl-module" );
+ if ( strlen( idlModule.GetString() ) > 0 )
+ pluginNames.push_back( idlModule.GetString() );
+ }
+ }
+ return pluginNames;
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Createa a Dump Python script
+ * \param [in,out] theObjectNames - map of an entry to a study and python name
+ * \param [in] theNames - - map of an entry to a study name
+ * \param [in] isPublished - \c true if dump of object publication in study is needed
+ * \param [in] isMultiFile - \c true if dump of each module goes to a separate file
+ * \param [in] isHistoricalDump - \c true if removed object should be dumped
+ * \param [out] aValidScript - returns \c true if the returned script seems valid
+ * \param [in,out] theSavedTrace - the dump stored in the study. It's cleared to
+ * decrease memory usage.
+ * \return TCollection_AsciiString - the result dump script.
+ */
+//================================================================================
+
+TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
+ (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
+ Resource_DataMapOfAsciiStringAsciiString& theNames,
+ bool isPublished,
+ bool isMultiFile,
+ bool isHistoricalDump,
+ bool& aValidScript,
+ TCollection_AsciiString& theSavedTrace)
+{
+ SMESH_TRY;
+
+ const TCollection_AsciiString aSmeshpy ( SMESH_2smeshpy::SmeshpyName() );
+ const TCollection_AsciiString aSMESHGen( SMESH_2smeshpy::GenName() );
+ const TCollection_AsciiString anOldGen ( SMESH::TPythonDump::SMESHGenName() );
+ const TCollection_AsciiString helper; // to comfortably append C strings to TCollection_AsciiString
+ const TCollection_AsciiString tab( isMultiFile ? "\t" : "" ), nt = helper + "\n" + tab;
+
+ std::list< TCollection_AsciiString > lines; // lines of a script
+ std::list< TCollection_AsciiString >::iterator linesIt;
+
+ if ( isPublished )
+ lines.push_back( aSMESHGen + " = smeshBuilder.New()" );
+ else
+ lines.push_back( aSMESHGen + " = smeshBuilder.New(False)" );
+ lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" );
+ lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );
+
+ // Treat dump trace of restored study
+ if (theSavedTrace.Length() > 0)
+ {
+ linesIt = --lines.end();
+ // Split theSavedTrace into lines
+ int from = 1, end = theSavedTrace.Length(), to;
+ while ( from < end && ( to = theSavedTrace.Location( "\n", from, end )))
+ {
+ if ( theSavedTrace.ToCString()[from-1] == '\t' )
+ ++from;
+ if ( to != from )
+ lines.push_back( theSavedTrace.SubString( from, to - 1 ));
+ from = to + 1;
+ }
+ // For the conversion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen
+ // was replaces with "smeshgen" (==TPythonDump::SMESHGenName()).
+ // Change "smesh" -> "smeshgen" in the trace saved before passage to smeshBuilder.py API
+ bool isNewVersion =
+ theSavedTrace.Location( anOldGen + ".", 1, theSavedTrace.Length() );
+ theSavedTrace.Clear();
+ if ( !isNewVersion )
+ {
+ const TCollection_AsciiString aSmeshCall ( "smesh." ), gen( "gen" );
+ int beg, end, from;
+ for ( ++linesIt; linesIt != lines.end(); ++linesIt )
+ {
+ TCollection_AsciiString& aSavedLine = *linesIt;
+ end = aSavedLine.Length(), from = 1;
+ while ( from < end && ( beg = aSavedLine.Location( aSmeshCall, from, end )))
+ {
+ char charBefore = ( beg == 1 ) ? ' ' : aSavedLine.Value( beg - 1 );
+ if ( isspace( charBefore ) || charBefore == '=' ) { // "smesh." is not a part of a long word
+ aSavedLine.Insert( beg + aSmeshCall.Length() - 1, gen );// "smesh" -> "smeshgen"
+ end += gen.Length();
+ }
+ from = beg + aSmeshCall.Length();
+ }
+ }
+ }
+ }
+
+ // Add new dump trace of API methods calls to script lines
+ if (!myPythonScript.IsNull())
+ {
+ Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
+ Standard_Integer istr, aLen = aPythonScript->Length();
+ for (istr = 1; istr <= aLen; istr++)
+ lines.push_back( aPythonScript->Value( istr ));
+ }
+
+ // Convert IDL API calls into smeshBuilder.py API.
+ // Some objects are wrapped with python classes and
+ // Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects
+ Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
+ std::set< TCollection_AsciiString > aRemovedObjIDs;
+ if ( !getenv("NO_2smeshpy_conversion"))
+ SMESH_2smeshpy::ConvertScript( lines, anEntry2AccessorMethod,
+ theObjectNames, aRemovedObjIDs,
+ isHistoricalDump );
+
+ bool importGeom = false;
+ GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
+ {
+ // Add names of GEOM objects to theObjectNames to exclude same names of SMESH objects
+ GEOM::string_array_var aGeomNames = geom->GetAllDumpNames();
+ int ign = 0, nbgn = aGeomNames->length();
+ for (; ign < nbgn; ign++) {
+ TCollection_AsciiString aName = aGeomNames[ign].in();
+ theObjectNames.Bind(aName, "1");
+ }
+ }
+
+ TCollection_AsciiString anUpdatedScript;
+
+ Resource_DataMapOfAsciiStringAsciiString mapRemoved;
+ Resource_DataMapOfAsciiStringAsciiString mapEntries; // names and entries present in anUpdatedScript
+ Standard_Integer objectCounter = 0;
+ TCollection_AsciiString anEntry, aName, aGUIName, aBaseName("smeshObj_");
+
+ // Treat every script line and add it to anUpdatedScript
+ for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
+ {
+ TCollection_AsciiString& aLine = *linesIt;
+ anUpdatedScript += tab;
+ {
+ //Replace characters used instead of quote marks to quote notebook variables
+ int pos = 1;
+ while (( pos = aLine.Location( 1, SMESH::TVar::Quote(), pos, aLine.Length() )))
+ aLine.SetValue( pos, '"' );
+ }
+ // Find entries to be replaced by names
+ Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aLine);
+ const Standard_Integer aSeqLen = aSeq->Length();
+ Standard_Integer aStart = 1;
+ for (Standard_Integer i = 1; i <= aSeqLen; i += 2)
+ {
+ if ( aStart < aSeq->Value(i) )
+ anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry
+ anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) );
+ // is a GEOM object?
+ CORBA::String_var geomName = geom->GetDumpName( anEntry.ToCString() );
+ if ( !geomName.in() || !geomName.in()[0] ) {
+ // is a SMESH object
+ if ( theObjectNames.IsBound( anEntry )) {
+ // The Object is in Study
+ aName = theObjectNames.Find( anEntry );
+ // check validity of aName
+ bool isValidName = fixPythonName( aName );
+ if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
+ // diff objects have same name - make a new name by appending a digit
+ TCollection_AsciiString aName2;
+ Standard_Integer i = 0;
+ do {
+ aName2 = aName + "_" + ++i;
+ } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
+ aName = aName2;
+ isValidName = false;
+ }
+ if ( !isValidName )
+ theObjectNames(anEntry) = aName;
+
+ if ( aLine.Value(1) != '#' )
+ mapEntries.Bind(anEntry, aName);
+ }
+ else
+ {
+ // Removed Object
+ do {
+ aName = aBaseName + (++objectCounter);
+ } while (theObjectNames.IsBound(aName));
+
+ if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
+ mapRemoved.Bind(anEntry, aName);
+
+ theObjectNames.Bind(anEntry, aName);
+ }
+ theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
+ }
+ else
+ {
+ aName = geomName.in();
+ importGeom = true;
+ }
+ anUpdatedScript += aName;
+ aStart = aSeq->Value(i + 1) + 1;
+
+ } // loop on entries within aLine
+
+ if ( aSeqLen == 0 )
+ anUpdatedScript += aLine;
+ else if ( aSeq->Value( aSeqLen ) < aLine.Length() )
+ anUpdatedScript += aLine.SubString( aSeq->Value(aSeqLen) + 1, aLine.Length() );
+
+ anUpdatedScript += '\n';
+ }
+
+ // Make an initial part of aSript
+
+ TCollection_AsciiString initPart = "import ";
+ if ( isMultiFile )
+ initPart += "salome, ";
+ initPart += " SMESH, SALOMEDS\n";
+ initPart += "from salome.smesh import smeshBuilder\n";
+ if ( importGeom && isMultiFile )
+ {
+ initPart += ("\n## import GEOM dump file ## \n"
+ "import string, os, sys, re, inspect\n"
+ "thisFile = inspect.getfile( inspect.currentframe() )\n"
+ "thisModule = os.path.splitext( os.path.basename( thisFile ))[0]\n"
+ "sys.path.insert( 0, os.path.dirname( thisFile ))\n"
+ "exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",thisModule)+\" import *\")\n\n");
+ }
+ // import python files corresponding to plugins if they are used in anUpdatedScript
+ {
+ TCollection_AsciiString importStr;
+ std::vector<std::string> pluginNames = getPluginNames();
+ for ( size_t i = 0; i < pluginNames.size(); ++i )
+ {
+ // Convert access to plugin members:
+ // e.g. StdMeshers.QUAD_REDUCED -> StdMeshersBuilder.QUAD_REDUCED
+ TCollection_AsciiString pluginAccess = (pluginNames[i] + ".").c_str() ;
+ int iFrom = 1, iPos;
+ while (( iPos = anUpdatedScript.Location( pluginAccess, iFrom, anUpdatedScript.Length() )))
+ {
+ anUpdatedScript.Insert( iPos + pluginNames[i].size(), "Builder" );
+ iFrom = iPos + pluginNames[i].size() + 8;
+ }
+ // if any plugin member is used, import the plugin
+ if ( iFrom > 1 )
+ importStr += ( helper + "\n" "from salome." + pluginNames[i].c_str() +
+ " import " + pluginNames[i].c_str() +"Builder" );
+ }
+ if ( !importStr.IsEmpty() )
+ initPart += importStr + "\n";
+ }
+
+ if ( isMultiFile )
+ initPart += "def RebuildData():";
+ initPart += "\n";
+
+ anUpdatedScript.Prepend( initPart );
+
+ // Make a final part of aScript
+
+ // Dump object removal
+ TCollection_AsciiString removeObjPart;
+ if ( !mapRemoved.IsEmpty() ) {
+ removeObjPart += nt + "## some objects were removed";
+ removeObjPart += nt + "aStudyBuilder = salome.myStudy.NewBuilder()";
+ Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapRemovedIt;
+ for ( mapRemovedIt.Initialize( mapRemoved ); mapRemovedIt.More(); mapRemovedIt.Next() ) {
+ aName = mapRemovedIt.Value(); // python name
+ anEntry = mapRemovedIt.Key();
+ removeObjPart += nt + "SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(";
+ removeObjPart += aName;
+ // for object wrapped by class of smeshBuilder.py
+ if ( anEntry2AccessorMethod.IsBound( anEntry ) )
+ removeObjPart += helper + "." + anEntry2AccessorMethod( anEntry );
+ removeObjPart += helper + "))" + nt + "if SO: aStudyBuilder.RemoveObjectWithChildren(SO)";
+ }
+ }
+
+ // Set object names
+ TCollection_AsciiString setNamePart;
+ Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapEntriesIt;
+ for ( mapEntriesIt.Initialize( mapEntries ); mapEntriesIt.More(); mapEntriesIt.Next() )
+ {
+ anEntry = mapEntriesIt.Key();
+ aName = mapEntriesIt.Value(); // python name
+ if ( theNames.IsBound( anEntry ))
+ {
+ aGUIName = theNames.Find(anEntry);
+ aGUIName.RemoveAll('\''); // remove a quote from a name (issue 22360)
+ setNamePart += nt + aSMESHGen + ".SetName(" + aName;
+ if ( anEntry2AccessorMethod.IsBound( anEntry ) )
+ setNamePart += helper + "." + anEntry2AccessorMethod( anEntry );
+ setNamePart += helper + ", '" + aGUIName + "')";
+ }
+ }
+ if ( !setNamePart.IsEmpty() )
+ {
+ setNamePart.Insert( 1, nt + "## Set names of Mesh objects" );
+ }
+
+ // Store visual properties of displayed objects
+
+ TCollection_AsciiString visualPropertiesPart;
+ if (isPublished)
+ {
+ //Output the script that sets up the visual parameters.
+ CORBA::String_var compDataType = ComponentDataType();
+ CORBA::String_var script = getStudyServant()->GetDefaultScript( compDataType.in(), tab.ToCString() );
+ if ( script.in() && script.in()[0] ) {
+ visualPropertiesPart += nt + "### Store presentation parameters of displayed objects\n";
+ visualPropertiesPart += script.in();
+ }
+ }
+
+ anUpdatedScript += removeObjPart + '\n' + setNamePart + '\n' + visualPropertiesPart;
+
+ if ( isMultiFile )
+ {
+ anUpdatedScript +=
+ "\n\tpass"
+ "\n"
+ "\nif __name__ == '__main__':"
+ "\n\tSMESH_RebuildData = RebuildData"
+ "\n\texec('import '+re.sub('SMESH$','GEOM',thisModule)+' as GEOM_dump')"
+ "\n\tGEOM_dump.RebuildData()"
+ "\n\texec('from '+re.sub('SMESH$','GEOM',thisModule)+' import * ')"
+ "\n\tSMESH_RebuildData()";
+ }
+ anUpdatedScript += "\n";
+
+ // no need now as we use 'tab' and 'nt' variables depending on isMultiFile
+ // if( !isMultiFile ) // remove unnecessary tabulation
+ // RemoveTabulation( anUpdatedScript );
+
+ // -----------------------------------------------------------------
+ // put string literals describing patterns into separate functions
+ // -----------------------------------------------------------------
+
+ TCollection_AsciiString aLongString, aFunctionType;
+ int where = 1;
+ std::set< std::string > functionNameSet;
+ while ( SMESH::TPythonDump::CutoutLongString( anUpdatedScript, where, aLongString, aFunctionType ))
+ {
+ // make a python string literal
+ aLongString.Prepend(":\n\treturn '''\n");
+ aLongString += "\n\t'''\n\tpass\n";
+
+ TCollection_AsciiString functionName;
+
+ // check if the function returning this literal is already defined
+ int posAlready = anUpdatedScript.Location( aLongString, where, anUpdatedScript.Length() );
+ if ( posAlready ) // already defined
+ {
+ // find the function name
+ int functBeg = posAlready;
+ char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def fuction()"
+ while ( *script != ' ' ) {
+ script--;
+ functBeg--;
+ }
+ functBeg++; // do not take ' '
+ posAlready--; // do not take ':'
+ functionName = anUpdatedScript.SubString( functBeg, posAlready );
+ }
+ else // not defined yet
+ {
+ // find a unique function name
+ fixPythonName( aFunctionType );
+ Standard_Integer nb = 0;
+ do functionName = aFunctionType + "_" + ( nb++ ) + "()";
+ while ( !functionNameSet.insert( functionName.ToCString() ).second );
+
+ // define function
+ TCollection_AsciiString funDef = helper + "def " + functionName + aLongString;
+ if ( isMultiFile )
+ {
+ anUpdatedScript += helper + "\n\n" + funDef;
+ }
+ else
+ {
+ funDef += "\n\n";
+ anUpdatedScript.Insert( 1, funDef);
+ where += funDef.Length();
+ }
+ }
+ anUpdatedScript.InsertBefore( where, functionName ); // call function
+ }
+
+ aValidScript = true;
+
+ return anUpdatedScript;
+
+ SMESH_CATCH( SMESH::printException );
+
+ aValidScript = false;
+ return "";
+}
+
+//=============================================================================
+/*!
+ * GetNewPythonLines
+ */
+//=============================================================================
+TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines()
+{
+ TCollection_AsciiString aScript;
+
+ // Dump trace of API methods calls
+ if (!myPythonScript.IsNull()) {
+ Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
+ Standard_Integer istr, aLen = aPythonScript->Length();
+ for (istr = 1; istr <= aLen; istr++) {
+ aScript += "\n";
+ aScript += aPythonScript->Value(istr);
+ }
+ aScript += "\n";
+ }
+
+ return aScript;
+}
+
+//=============================================================================
+/*!
+ * CleanPythonTrace
+ */
+//=============================================================================
+void SMESH_Gen_i::CleanPythonTrace()
+{
+ TCollection_AsciiString aScript;
+
+ // Clean trace of API methods calls
+ if (!myPythonScript.IsNull()) {
+ myPythonScript->Clear();
+ }
+}
def LengthNearVertex(self, length, vertex=0, UseExisting=0):
import types
store_geom = self.geom
- if type(vertex) is types.IntType:
+ if isinstance(vertex, int):
if vertex == 0 or vertex == 1:
from salome.geom import geomBuilder
vertex = self.mesh.geompyD.ExtractShapes(self.geom, geomBuilder.geomBuilder.ShapeType["VERTEX"],True)[vertex]
# 0D algorithm
if self.geom is None:
self.geom = store_geom
- raise RuntimeError, "Attempt to create SegmentAroundVertex_0D algorithm on None shape"
+ raise RuntimeError("Attempt to create SegmentAroundVertex_0D algorithm on None shape")
from salome.smesh.smeshBuilder import AssureGeomPublished, GetName, TreatHypoStatus
AssureGeomPublished( self.mesh, self.geom )
name = GetName(self.geom)
## doc string of the method
# @internal
docHelper = "Creates prism 3D algorithm for volumes"
+ ## flag pointing whether this algorithm should be used by default in dynamic method
+ # of smeshBuilder.Mesh class
+ # @internal
+ isDefault = True
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
## Return 3D hypothesis holding the 1D one
def Get3DHypothesis(self):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
return self.distribHyp
# hypothesis. Returns the created hypothesis
def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
if not self.nbLayers is None:
self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
- study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
- self.mesh.smeshpyD.SetCurrentStudy( None )
+ self.mesh.smeshpyD.SetEnablePublish( False ) # prevents publishing own 1D hypothesis
hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
- self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
+ self.mesh.smeshpyD.SetEnablePublish( True ) # enables publishing
if not self.distribHyp:
self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
self.distribHyp.SetLayerDistribution( hyp )
# the same parameters, else (default) - creates a new one
def NumberOfLayers(self, n, UseExisting=0):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
from salome.smesh.smeshBuilder import IsEqual
# @param p the precision of rounding
def LocalLength(self, l, p=1e-07):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("LocalLength", [l,p])
hyp.SetLength(l)
# @param s the scale factor (optional)
def NumberOfSegments(self, n, s=[]):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
if not s:
hyp = self.OwnHypothesis("NumberOfSegments", [n])
# @param end the length of the last segment
def Arithmetic1D(self, start, end ):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
hyp.SetLength(start, 1)
# @param ratio the common ratio of the geometric progression
def GeometricProgression(self, start, ratio ):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
hyp.SetStartLength( start )
# @param end for the length of the last segment
def StartEndLength(self, start, end):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("StartEndLength", [start, end])
hyp.SetLength(start, 1)
# @param fineness defines the quality of the mesh within the range [0-1]
def AutomaticLength(self, fineness=0):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("AutomaticLength")
hyp.SetFineness( fineness )
self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
else:
self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
- study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
- self.mesh.smeshpyD.SetCurrentStudy( None )
+ self.mesh.smeshpyD.SetEnablePublish( False )
hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
- self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
+ self.mesh.smeshpyD.SetEnablePublish( True )
self.distribHyp.SetLayerDistribution( hyp )
return hyp
self.mesh.AddHypothesis( self.hyp, self.geom )
for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef] ):
- if not gridDef: raise ValueError, "Empty grid definition"
+ if not gridDef: raise ValueError("Empty grid definition")
if isinstance( gridDef, str ):
self.hyp.SetGridSpacing( [gridDef], [], axis )
elif isinstance( gridDef[0], str ):
from salome.geom import geomBuilder
import SMESH # This is necessary for back compatibility
+import omniORB # back compatibility
+SMESH.MED_V2_1 = omniORB.EnumItem("MED_V2_1", 0) # back compatibility
+SMESH.MED_V2_2 = omniORB.EnumItem("MED_V2_2", 1) # back compatibility
+
from SMESH import *
from salome.smesh.smesh_algorithm import Mesh_Algorithm
import SALOME
import SALOMEDS
import os
+import inspect
+
+# In case the omniORBpy EnumItem class does not fully support Python 3
+# (for instance in version 4.2.1-2), the comparison ordering methods must be
+# defined
+#
+try:
+ SMESH.Entity_Triangle < SMESH.Entity_Quadrangle
+except TypeError:
+ def enumitem_eq(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v == other._v
+ else:
+ return self._parent_id == other._parent_id
+ else:
+ return id(self) == id(other)
+ except:
+ return id(self) == id(other)
+
+ def enumitem_lt(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v < other._v
+ else:
+ return self._parent_id < other._parent_id
+ else:
+ return id(self) < id(other)
+ except:
+ return id(self) < id(other)
+
+ def enumitem_le(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v <= other._v
+ else:
+ return self._parent_id <= other._parent_id
+ else:
+ return id(self) <= id(other)
+ except:
+ return id(self) <= id(other)
+
+ def enumitem_gt(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v > other._v
+ else:
+ return self._parent_id > other._parent_id
+ else:
+ return id(self) > id(other)
+ except:
+ return id(self) > id(other)
+
+ def enumitem_ge(self, other):
+ try:
+ if isinstance(other, omniORB.EnumItem):
+ if other._parent_id == self._parent_id:
+ return self._v >= other._v
+ else:
+ return self._parent_id >= other._parent_id
+ else:
+ return id(self) >= id(other)
+ except:
+ return id(self) >= id(other)
+
+ omniORB.EnumItem.__eq__ = enumitem_eq
+ omniORB.EnumItem.__lt__ = enumitem_lt
+ omniORB.EnumItem.__le__ = enumitem_le
+ omniORB.EnumItem.__gt__ = enumitem_gt
+ omniORB.EnumItem.__ge__ = enumitem_ge
+
## Private class used to workaround a problem that sometimes isinstance(m, Mesh) returns False
#
Parameters = ""
hasVariables = False
varModifFun=None
- if args and callable( args[-1] ):
+ if args and callable(args[-1]):
args, varModifFun = args[:-1], args[-1]
for parameter in args:
if isinstance(parameter,str):
# check if there is an inexistent variable name
if not notebook.isVariable(parameter):
- raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
+ raise ValueError("Variable with name '" + parameter + "' doesn't exist!!!")
parameter = notebook.get(parameter)
hasVariables = True
if varModifFun:
# Parameters are stored in AxisStruct.parameters attribute
def __initAxisStruct(ax,*args):
if len( args ) != 6:
- raise RuntimeError,\
- "Bad nb args (%s) passed in SMESH.AxisStruct(x,y,z,dx,dy,dz)"%(len( args ))
+ raise RuntimeError("Bad nb args (%s) passed in SMESH.AxisStruct(x,y,z,dx,dy,dz)"%(len( args )))
ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
pass
SMESH.AxisStruct.__init__ = __initAxisStruct
except:
ior = None
if ior:
- # CORBA object
- studies = salome.myStudyManager.GetOpenStudies()
- for sname in studies:
- s = salome.myStudyManager.GetStudyByName(sname)
- if not s: continue
- sobj = s.FindObjectIOR(ior)
- if not sobj: continue
+ sobj = salome.myStudy.FindObjectIOR(ior)
+ if sobj:
return sobj.GetName()
if hasattr(obj, "GetName"):
# unknown CORBA object, having GetName() method
# unknown non-CORBA object, having GetName() method
return obj.GetName()
pass
- raise RuntimeError, "Null or invalid object"
+ raise RuntimeError("Null or invalid object")
## Print error message if a hypothesis was not assigned.
def TreatHypoStatus(status, hypName, geomName, isAlgo, mesh):
pass
reason = ""
if hasattr( status, "__getitem__" ):
- status,reason = status[0],status[1]
- if status == HYP_UNKNOWN_FATAL :
+ status, reason = status[0], status[1]
+ if status == HYP_UNKNOWN_FATAL:
reason = "for unknown reason"
- elif status == HYP_INCOMPATIBLE :
+ elif status == HYP_INCOMPATIBLE:
reason = "this hypothesis mismatches the algorithm"
- elif status == HYP_NOTCONFORM :
+ elif status == HYP_NOTCONFORM:
reason = "a non-conform mesh would be built"
- elif status == HYP_ALREADY_EXIST :
+ elif status == HYP_ALREADY_EXIST:
if isAlgo: return # it does not influence anything
reason = hypType + " of the same dimension is already assigned to this shape"
- elif status == HYP_BAD_DIM :
+ elif status == HYP_BAD_DIM:
reason = hypType + " mismatches the shape"
- elif status == HYP_CONCURENT :
+ elif status == HYP_CONCURENT:
reason = "there are concurrent hypotheses on sub-shapes"
- elif status == HYP_BAD_SUBSHAPE :
+ elif status == HYP_BAD_SUBSHAPE:
reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
elif status == HYP_BAD_GEOMETRY:
reason = "the algorithm is not applicable to this geometry"
if meshName and meshName != NO_NAME:
where = '"%s" shape in "%s" mesh ' % ( geomName, meshName )
if status < HYP_UNKNOWN_FATAL and where:
- print '"%s" was assigned to %s but %s' %( hypName, where, reason )
+ print('"%s" was assigned to %s but %s' %( hypName, where, reason ))
elif where:
- print '"%s" was not assigned to %s : %s' %( hypName, where, reason )
+ print('"%s" was not assigned to %s : %s' %( hypName, where, reason ))
else:
- print '"%s" was not assigned : %s' %( hypName, reason )
+ print('"%s" was not assigned : %s' %( hypName, reason ))
pass
## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
def AssureGeomPublished(mesh, geom, name=''):
if not isinstance( geom, geomBuilder.GEOM._objref_GEOM_Object ):
return
- if not geom.GetStudyEntry() and \
- mesh.smeshpyD.GetCurrentStudy():
- ## set the study
- studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
- if studyID != mesh.geompyD.myStudyId:
- mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
+ if not geom.GetStudyEntry():
## get a name
if not name and geom.GetShapeType() != geomBuilder.GEOM.COMPOUND:
# for all groups SubShapeName() return "Compound_-1"
def FirstVertexOnCurve(mesh, edge):
vv = mesh.geompyD.SubShapeAll( edge, geomBuilder.geomBuilder.ShapeType["VERTEX"])
if not vv:
- raise TypeError, "Given object has no vertices"
+ raise TypeError("Given object has no vertices")
if len( vv ) == 1: return vv[0]
v0 = mesh.geompyD.MakeVertexOnCurve(edge,0.)
xyz = mesh.geompyD.PointCoordinates( v0 ) # coords of the first vertex
else:
return vv[1]
+## Return a long value from enumeration
+def EnumToLong(theItem):
+ return theItem._v
+
# end of l1_auxiliary
## @}
## This class allows to create, load or manipulate meshes.
# It has a set of methods to create, load or copy meshes, to combine several meshes, etc.
# It also has methods to get infos and measure meshes.
-class smeshBuilder(object, SMESH._objref_SMESH_Gen):
+class smeshBuilder(SMESH._objref_SMESH_Gen):
# MirrorType enumeration
POINT = SMESH_MeshEditor.POINT
PrecisionConfusion = smeshPrecisionConfusion
# TopAbs_State enumeration
- [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
+ [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = list(range(4))
# Methods of splitting a hexahedron into tetrahedra
Hex_5Tet, Hex_6Tet, Hex_24Tet, Hex_2Prisms, Hex_4Prisms = 1, 2, 3, 1, 2
- def __new__(cls):
+ def __new__(cls, *args):
global engine
global smeshInst
global doLcc
#print "====2 ", smeshInst
return smeshInst
- def __init__(self):
+ def __init__(self, *args):
global created
#print "--------------- smeshbuilder __init__ ---", created
if not created:
- created = True
- SMESH._objref_SMESH_Gen.__init__(self)
+ created = True
+ SMESH._objref_SMESH_Gen.__init__(self, *args)
## Dump component to the Python script
# This method overrides IDL function to allow default values for the parameters.
# @ingroup l1_auxiliary
- def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
- return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
+ def DumpPython(self, theIsPublished=True, theIsMultiFile=True):
+ return SMESH._objref_SMESH_Gen.DumpPython(self, theIsPublished, theIsMultiFile)
## Set mode of DumpPython(), \a historical or \a snapshot.
# In the \a historical mode, the Python Dump script includes all commands
else: val = "false"
SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
- ## Set the current study and Geometry component
+ ## Set Geometry component
# @ingroup l1_auxiliary
- def init_smesh(self,theStudy,geompyD = None):
+ def init_smesh(self,isPublished = True,geompyD = None):
#print "init_smesh"
- self.SetCurrentStudy(theStudy,geompyD)
- if theStudy:
+ self.UpdateStudy(geompyD)
+ if isPublished:
global notebook
- notebook.myStudy = theStudy
+ notebook.myStudy = salome.myStudy
## Create a mesh. This can be either an empty mesh, possibly having an underlying geometry,
# or a mesh wrapping a CORBA mesh given as a parameter.
obj,name = name,obj
return Mesh(self,self.geompyD,obj,name)
- ## Return a long value from enumeration
- # @ingroup l1_auxiliary
- def EnumToLong(self,theItem):
- return theItem._v
-
## Return a string representation of the color.
# To be used with filters.
# @param c color value (SALOMEDS.Color)
elif isinstance(c, str):
val = c
else:
- raise ValueError, "Color value should be of string or SALOMEDS.Color type"
+ raise ValueError("Color value should be of string or SALOMEDS.Color type")
return val
## Get PointStruct from vertex
def GetDirStruct(self,theVector):
vertices = self.geompyD.SubShapeAll( theVector, geomBuilder.geomBuilder.ShapeType["VERTEX"] )
if(len(vertices) != 2):
- print "Error: vector object is incorrect."
+ print("Error: vector object is incorrect.")
return None
p1 = self.geompyD.PointCoordinates(vertices[0])
p2 = self.geompyD.PointCoordinates(vertices[1])
# @ingroup l1_auxiliary
def IsEmbeddedMode(self):
return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
-
- ## Set the current study. Calling SetCurrentStudy( None ) allows to
- # switch OFF automatic pubilishing in the Study of mesh objects.
+
+ ## Update the current study. Calling UpdateStudy() allows to
+ # update meshes at switching GEOM->SMESH
# @ingroup l1_auxiliary
- def SetCurrentStudy( self, theStudy, geompyD = None ):
+ def UpdateStudy( self, geompyD = None ):
+ #self.UpdateStudy()
if not geompyD:
from salome.geom import geomBuilder
geompyD = geomBuilder.geom
pass
self.geompyD=geompyD
self.SetGeomEngine(geompyD)
- SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
- global notebook
- if theStudy:
- notebook = salome_notebook.NoteBook( theStudy )
- else:
- notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() )
- if theStudy:
- sb = theStudy.NewBuilder()
- sc = theStudy.FindComponent("SMESH")
- if sc: sb.LoadWith(sc, self)
- pass
+ SMESH._objref_SMESH_Gen.UpdateStudy(self)
+ sb = salome.myStudy.NewBuilder()
+ sc = salome.myStudy.FindComponent("SMESH")
+ if sc: sb.LoadWith(sc, self)
pass
-
- ## Get the current study
+
+ ## Sets enable publishing in the study. Calling SetEnablePublish( false ) allows to
+ # switch OFF publishing in the Study of mesh objects.
# @ingroup l1_auxiliary
- def GetCurrentStudy(self):
- return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
+ def SetEnablePublish( self, theIsEnablePublish ):
+ #self.SetEnablePublish(theIsEnablePublish)
+ SMESH._objref_SMESH_Gen.SetEnablePublish(self,theIsEnablePublish)
+ global notebook
+ notebook = salome_notebook.NoteBook( theIsEnablePublish )
## Create a Mesh object importing data from the given UNV file
# @return an instance of Mesh class
aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self,
theFileName,
True)
- if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment
+ if error.comment: print("*** CreateMeshesFromGMF() errors:\n", error.comment)
return Mesh(self, self.geompyD, aSmeshMesh), error
## Concatenate the given meshes into one mesh. All groups of input meshes will be
def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
- ## Create a pattern mapper.
+ ## Create a pattern mapper.
# @return an instance of SMESH_Pattern
#
# <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
# @return SMESH.Filter.Criterion
# @ingroup l1_controls
def GetEmptyCriterion(self):
- Type = self.EnumToLong(FT_Undefined)
- Compare = self.EnumToLong(FT_Undefined)
+ Type = EnumToLong(FT_Undefined)
+ Compare = EnumToLong(FT_Undefined)
Threshold = 0
ThresholdStr = ""
ThresholdID = ""
- UnaryOp = self.EnumToLong(FT_Undefined)
- BinaryOp = self.EnumToLong(FT_Undefined)
+ UnaryOp = EnumToLong(FT_Undefined)
+ BinaryOp = EnumToLong(FT_Undefined)
Tolerance = 1e-07
TypeOfElement = ALL
Precision = -1 ##@1e-07
BinaryOp=FT_Undefined,
Tolerance=1e-07):
if not CritType in SMESH.FunctorType._items:
- raise TypeError, "CritType should be of SMESH.FunctorType"
+ raise TypeError("CritType should be of SMESH.FunctorType")
aCriterion = self.GetEmptyCriterion()
aCriterion.TypeOfElement = elementType
- aCriterion.Type = self.EnumToLong(CritType)
+ aCriterion.Type = EnumToLong(CritType)
aCriterion.Tolerance = Tolerance
aThreshold = Threshold
if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
- aCriterion.Compare = self.EnumToLong(Compare)
+ aCriterion.Compare = EnumToLong(Compare)
elif Compare == "=" or Compare == "==":
- aCriterion.Compare = self.EnumToLong(FT_EqualTo)
+ aCriterion.Compare = EnumToLong(FT_EqualTo)
elif Compare == "<":
- aCriterion.Compare = self.EnumToLong(FT_LessThan)
+ aCriterion.Compare = EnumToLong(FT_LessThan)
elif Compare == ">":
- aCriterion.Compare = self.EnumToLong(FT_MoreThan)
+ aCriterion.Compare = EnumToLong(FT_MoreThan)
elif Compare != FT_Undefined:
- aCriterion.Compare = self.EnumToLong(FT_EqualTo)
+ aCriterion.Compare = EnumToLong(FT_EqualTo)
aThreshold = Compare
if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
elif isinstance( aThreshold, str ):
aCriterion.ThresholdStr = aThreshold
else:
- raise TypeError, "The Threshold should be a shape."
+ raise TypeError("The Threshold should be a shape.")
if isinstance(UnaryOp,float):
aCriterion.Tolerance = UnaryOp
UnaryOp = FT_Undefined
# Check that Threshold is a group
if isinstance(aThreshold, SMESH._objref_SMESH_GroupBase):
if aThreshold.GetType() != elementType:
- raise ValueError, "Group type mismatches Element type"
+ raise ValueError("Group type mismatches Element type")
aCriterion.ThresholdStr = aThreshold.GetName()
aCriterion.ThresholdID = salome.orb.object_to_string( aThreshold )
- study = self.GetCurrentStudy()
+ study = salome.myStudy
if study:
so = study.FindObjectIOR( aCriterion.ThresholdID )
if so:
if entry:
aCriterion.ThresholdID = entry
else:
- raise TypeError, "The Threshold should be a Mesh Group"
+ raise TypeError("The Threshold should be a Mesh Group")
elif CritType == FT_RangeOfIds:
# Check that Threshold is string
if isinstance(aThreshold, str):
aCriterion.ThresholdStr = aThreshold
else:
- raise TypeError, "The Threshold should be a string."
+ raise TypeError("The Threshold should be a string.")
elif CritType == FT_CoplanarFaces:
# Check the Threshold
if isinstance(aThreshold, int):
elif isinstance(aThreshold, str):
ID = int(aThreshold)
if ID < 1:
- raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
+ raise ValueError("Invalid ID of mesh face: '%s'"%aThreshold)
aCriterion.ThresholdID = aThreshold
else:
- raise TypeError,\
- "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
+ raise TypeError("The Threshold should be an ID of mesh face and not '%s'"%aThreshold)
elif CritType == FT_ConnectedElements:
# Check the Threshold
if isinstance(aThreshold, geomBuilder.GEOM._objref_GEOM_Object): # shape
aCriterion.Threshold = aThreshold
elif isinstance(aThreshold, list): # 3 point coordinates
if len( aThreshold ) < 3:
- raise ValueError, "too few point coordinates, must be 3"
+ raise ValueError("too few point coordinates, must be 3")
aCriterion.ThresholdStr = " ".join( [str(c) for c in aThreshold[:3]] )
elif isinstance(aThreshold, str):
if aThreshold.isdigit():
else:
aCriterion.ThresholdStr = aThreshold # hope that it's point coordinates
else:
- raise TypeError,\
- "The Threshold should either a VERTEX, or a node ID, "\
- "or a list of point coordinates and not '%s'"%aThreshold
+ raise TypeError("The Threshold should either a VERTEX, or a node ID, "\
+ "or a list of point coordinates and not '%s'"%aThreshold)
elif CritType == FT_ElemGeomType:
# Check the Threshold
try:
- aCriterion.Threshold = self.EnumToLong(aThreshold)
+ aCriterion.Threshold = EnumToLong(aThreshold)
assert( aThreshold in SMESH.GeometryType._items )
except:
if isinstance(aThreshold, int):
aCriterion.Threshold = aThreshold
else:
- raise TypeError, "The Threshold should be an integer or SMESH.GeometryType."
+ raise TypeError("The Threshold should be an integer or SMESH.GeometryType.")
pass
pass
elif CritType == FT_EntityType:
# Check the Threshold
try:
- aCriterion.Threshold = self.EnumToLong(aThreshold)
+ aCriterion.Threshold = EnumToLong(aThreshold)
assert( aThreshold in SMESH.EntityType._items )
except:
if isinstance(aThreshold, int):
aCriterion.Threshold = aThreshold
else:
- raise TypeError, "The Threshold should be an integer or SMESH.EntityType."
+ raise TypeError("The Threshold should be an integer or SMESH.EntityType.")
pass
pass
-
+
elif CritType == FT_GroupColor:
# Check the Threshold
try:
aCriterion.ThresholdStr = self.ColorToString(aThreshold)
except:
- raise TypeError, "The threshold value should be of SALOMEDS.Color type"
+ raise TypeError("The threshold value should be of SALOMEDS.Color type")
pass
elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
FT_LinearOrQuadratic, FT_BadOrientedVolume,
FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
# At this point the Threshold is unnecessary
if aThreshold == FT_LogicalNOT:
- aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
+ aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
aCriterion.BinaryOp = aThreshold
else:
aThreshold = float(aThreshold)
aCriterion.Threshold = aThreshold
except:
- raise TypeError, "The Threshold should be a number."
+ raise TypeError("The Threshold should be a number.")
return None
if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
- aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
+ aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
if Threshold in [FT_LogicalAND, FT_LogicalOR]:
- aCriterion.BinaryOp = self.EnumToLong(Threshold)
+ aCriterion.BinaryOp = EnumToLong(Threshold)
if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
- aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
+ aCriterion.BinaryOp = EnumToLong(UnaryOp)
if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
- aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
+ aCriterion.BinaryOp = EnumToLong(BinaryOp)
return aCriterion
# @ingroup l1_controls
def GetFilterFromCriteria(self,criteria, binOp=SMESH.FT_LogicalAND):
for i in range( len( criteria ) - 1 ):
- if criteria[i].BinaryOp == self.EnumToLong( SMESH.FT_Undefined ):
- criteria[i].BinaryOp = self.EnumToLong( binOp )
+ if criteria[i].BinaryOp == EnumToLong( SMESH.FT_Undefined ):
+ criteria[i].BinaryOp = EnumToLong( binOp )
aFilterMgr = self.CreateFilterManager()
aFilter = aFilterMgr.CreateFilter()
aFilter.SetCriteria(criteria)
functor = aFilterMgr.CreateLength()
elif theCriterion == FT_Length2D:
functor = aFilterMgr.CreateLength2D()
+ elif theCriterion == FT_Deflection2D:
+ functor = aFilterMgr.CreateDeflection2D()
elif theCriterion == FT_NodeConnectivityNumber:
functor = aFilterMgr.CreateNodeConnectivityNumber()
elif theCriterion == FT_BallDiameter:
functor = aFilterMgr.CreateBallDiameter()
else:
- print "Error: given parameter is not numerical functor type."
+ print("Error: given parameter is not numerical functor type.")
aFilterMgr.UnRegister()
return functor
d = {}
if hasattr(obj, "GetMeshInfo"):
values = obj.GetMeshInfo()
- for i in range(SMESH.Entity_Last._v):
+ for i in range(EnumToLong(SMESH.Entity_Last)):
if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
pass
return d
# import salome
# salome.salome_init()
# from salome.smesh import smeshBuilder
-# smesh = smeshBuilder.New(salome.myStudy)
+# smesh = smeshBuilder.New()
# \endcode
-# @param study SALOME study, generally obtained by salome.myStudy.
+# @param isPublished If False, the notebool will not be used.
# @param instance CORBA proxy of SMESH Engine. If None, the default Engine is used.
# @return smeshBuilder instance
-def New( study, instance=None):
+def New( isPublished = True, instance=None):
"""
Create a new smeshBuilder instance.The smeshBuilder class provides the Python
interface to create or load meshes.
import salome
salome.salome_init()
from salome.smesh import smeshBuilder
- smesh = smeshBuilder.New(salome.myStudy)
+ smesh = smeshBuilder.New()
Parameters:
- study SALOME study, generally obtained by salome.myStudy.
+ isPublished If False, the notebool will not be used.
instance CORBA proxy of SMESH Engine. If None, the default Engine is used.
Returns:
smeshBuilder instance
global doLcc
engine = instance
if engine is None:
- doLcc = True
+ doLcc = True
smeshInst = smeshBuilder()
assert isinstance(smeshInst,smeshBuilder), "Smesh engine class is %s but should be smeshBuilder.smeshBuilder. Import salome.smesh.smeshBuilder before creating the instance."%smeshInst.__class__
- smeshInst.init_smesh(study)
+ smeshInst.init_smesh(isPublished)
return smeshInst
# It also has methods to define groups of mesh elements, to modify a mesh (by addition of
# new nodes and elements and by changing the existing entities), to get information
# about a mesh and to export a mesh in different formats.
-class Mesh:
- __metaclass__ = MeshMeta
-
+class Mesh(metaclass=MeshMeta):
geom = 0
mesh = 0
editor = 0
# @param name Study name of the mesh
# @ingroup l2_construct
def __init__(self, smeshpyD, geompyD, obj=0, name=0):
- self.smeshpyD=smeshpyD
- self.geompyD=geompyD
+ self.smeshpyD = smeshpyD
+ self.geompyD = geompyD
if obj is None:
obj = 0
objHasName = False
self.geom = obj
objHasName = True
# publish geom of mesh (issue 0021122)
- if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
+ if not self.geom.GetStudyEntry():
objHasName = False
- studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
- if studyID != geompyD.myStudyId:
- geompyD.init_geom( smeshpyD.GetCurrentStudy())
- pass
+ geompyD.init_geom()
if name:
geo_name = name + " shape"
else:
self.geom = self.mesh.GetShapeToMesh()
self.editor = self.mesh.GetMeshEditor()
- self.functors = [None] * SMESH.FT_Undefined._v
+ self.functors = [None] * EnumToLong(SMESH.FT_Undefined)
# set self to algoCreator's
for attrName in dir(self):
#self.mesh.UnRegister()
pass
pass
-
+
## Initialize the Mesh object from an instance of SMESH_Mesh interface
# @param theMesh a SMESH_Mesh object
# @ingroup l2_construct
if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
self.mesh.Clear()
ok = self.smeshpyD.Compute(self.mesh, geom)
- except SALOME.SALOME_Exception, ex:
- print "Mesh computation failed, exception caught:"
- print " ", ex.details.text
+ except SALOME.SALOME_Exception as ex:
+ print("Mesh computation failed, exception caught:")
+ print(" ", ex.details.text)
except:
import traceback
- print "Mesh computation failed, exception caught:"
+ print("Mesh computation failed, exception caught:")
traceback.print_exc()
if True:#not ok:
allReasons = ""
else: msg += " has not been computed"
if allReasons != "": msg += ":"
else: msg += "."
- print msg
- print allReasons
+ print(msg)
+ print(allReasons)
pass
- if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
+ if salome.sg.hasDesktop():
if not isinstance( refresh, list): # not a call from subMesh.Compute()
smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init(self.mesh.GetStudyId())
+ smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
- if refresh: salome.sg.updateObjBrowser(True)
+ if refresh: salome.sg.updateObjBrowser()
return ok
try:
shapeText = ""
mainIOR = salome.orb.object_to_string( self.GetShape() )
- for sname in salome.myStudyManager.GetOpenStudies():
- s = salome.myStudyManager.GetStudyByName(sname)
- if not s: continue
- mainSO = s.FindObjectIOR(mainIOR)
- if not mainSO: continue
+ s = salome.myStudy
+ mainSO = s.FindObjectIOR(mainIOR)
+ if mainSO:
if subShapeID == 1:
shapeText = '"%s"' % mainSO.GetName()
subIt = s.NewChildIterator(mainSO)
continue
if ids == subShapeID:
shapeText = '"%s"' % subSO.GetName()
- break
if not shapeText:
shape = self.geompyD.GetSubShape( self.GetShape(), [subShapeID])
if shape:
pass
groups = []
- for algoName, shapes in algo2shapes.items():
+ for algoName, shapes in list(algo2shapes.items()):
while shapes:
- groupType = self.smeshpyD.EnumToLong( shapes[0].GetShapeType() )
+ groupType = EnumToLong( shapes[0].GetShapeType() )
otherTypeShapes = []
sameTypeShapes = []
group = self.geompyD.CreateGroup( self.geom, groupType )
# @ingroup l2_construct
def Clear(self, refresh=False):
self.mesh.Clear()
- if ( salome.sg.hasDesktop() and
- salome.myStudyManager.GetStudyByID( self.mesh.GetStudyId() ) ):
+ if ( salome.sg.hasDesktop() ):
smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init(self.mesh.GetStudyId())
+ smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
- if refresh: salome.sg.updateObjBrowser(True)
+ if refresh: salome.sg.updateObjBrowser()
## Remove all nodes and elements of indicated shape
# @param refresh if @c True, Object browser is automatically updated (when running in GUI)
self.mesh.ClearSubMesh(geomId)
if salome.sg.hasDesktop():
smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init(self.mesh.GetStudyId())
+ smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
- if refresh: salome.sg.updateObjBrowser(True)
+ if refresh: salome.sg.updateObjBrowser()
## Compute a tetrahedral mesh using AutomaticLength + MEFISTO + Tetrahedron
# @param fineness [0.0,1.0] defines mesh fineness
AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
status = self.mesh.AddHypothesis(geom, hyp)
else:
- status = HYP_BAD_GEOMETRY,""
+ status = HYP_BAD_GEOMETRY, ""
hyp_name = GetName( hyp )
geom_name = ""
if geom:
return self.mesh.RemoveHypothesis( shape, hyp )
hypName = GetName( hyp )
geoName = GetName( shape )
- print "WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName )
+ print("WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName ))
return None
## Get the list of hypotheses added on a geometry
## Export the mesh in a file in MED format
## allowing to overwrite the file if it exists or add the exported data to its contents
- # @param f is the file name
+ # @param fileName is the file name
# @param auto_groups boolean parameter for creating/not creating
# the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
# the typical use is auto_groups=False.
- # @param version MED format version
- # - MED_V2_1 is obsolete.
- # - MED_V2_2 means current version (kept for compatibility reasons)
- # - MED_LATEST means current version.
- # - MED_MINOR_x where x from 0 to 9 indicates the minor version of MED
- # to use for writing MED files, for backward compatibility :
- # for instance, with SALOME 8.4 use MED 3.2 (minor=2) instead of 3.3,
- # to allow the file to be read with SALOME 8.3.
# @param overwrite boolean parameter for overwriting/not overwriting the file
# @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
# @param autoDimension if @c True (default), a space dimension of a MED mesh can be either
# - 3D in the rest cases.<br>
# If @a autoDimension is @c False, the space dimension is always 3.
# @param fields list of GEOM fields defined on the shape to mesh.
- # @param geomAssocFields each character of this string means a need to export a
+ # @param geomAssocFields each character of this string means a need to export a
# corresponding field; correspondence between fields and characters is following:
# - 'v' stands for "_vertices _" field;
# - 'e' stands for "_edges _" field;
# - 'f' stands for "_faces _" field;
# - 's' stands for "_solids _" field.
# @ingroup l2_impexp
- def ExportMED(self, f, auto_groups=0, version=MED_LATEST,
- overwrite=1, meshPart=None, autoDimension=True, fields=[], geomAssocFields=''):
+ def ExportMED(self, *args, **kwargs):
+ # process positional arguments
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+ fileName = args[0]
+ auto_groups = args[1] if len(args) > 1 else False
+ overwrite = args[2] if len(args) > 2 else True
+ meshPart = args[3] if len(args) > 3 else None
+ autoDimension = args[4] if len(args) > 4 else True
+ fields = args[5] if len(args) > 5 else []
+ geomAssocFields = args[6] if len(args) > 6 else ''
+ # process keywords arguments
+ auto_groups = kwargs.get("auto_groups", auto_groups)
+ overwrite = kwargs.get("overwrite", overwrite)
+ meshPart = kwargs.get("meshPart", meshPart)
+ autoDimension = kwargs.get("autoDimension", autoDimension)
+ fields = kwargs.get("fields", fields)
+ geomAssocFields = kwargs.get("geomAssocFields", geomAssocFields)
+ # invoke engine's function
if meshPart or fields or geomAssocFields:
unRegister = genObjUnRegister()
if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart )
- self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite, autoDimension,
+ self.mesh.ExportPartToMED( meshPart, fileName, auto_groups, overwrite, autoDimension,
fields, geomAssocFields)
else:
- self.mesh.ExportToMEDX(f, auto_groups, version, overwrite, autoDimension)
+ self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
## Export the mesh in a file in SAUV format
# @param f is the file name
# @param f is the file name
# @param overwrite boolean parameter for overwriting/not overwriting the file
# @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
+ # @param groupElemsByType if true all elements of same entity type are exported at ones,
+ # else elements are exported in order of their IDs which can cause creation
+ # of multiple cgns sections
# @ingroup l2_impexp
- def ExportCGNS(self, f, overwrite=1, meshPart=None):
+ def ExportCGNS(self, f, overwrite=1, meshPart=None, groupElemsByType=False):
unRegister = genObjUnRegister()
if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL )
meshPart = meshPart.mesh
elif not meshPart:
meshPart = self.mesh
- self.mesh.ExportCGNS(meshPart, f, overwrite)
+ self.mesh.ExportCGNS(meshPart, f, overwrite, groupElemsByType)
## Export the mesh in a file in GMF format.
# GMF files must have .mesh extension for the ASCII format and .meshb for
## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
# Export the mesh in a file in MED format
# allowing to overwrite the file if it exists or add the exported data to its contents
- # @param f the file name
- # @param version MED format version:
- # - MED_V2_1 is obsolete.
- # - MED_V2_2 means current version (kept for compatibility reasons)
- # - MED_LATEST means current version.
- # - MED_MINOR_x where x from 0 to 9 indicates the minor version of MED
- # to use for writing MED files, for backward compatibility :
- # for instance, with SALOME 8.4 use MED 3.2 (minor=2) instead of 3.3,
- # to allow the file to be read with SALOME 8.3.
+ # @param fileName the file name
+ # @param opt boolean parameter for creating/not creating
+ # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
+ # @param overwrite boolean parameter for overwriting/not overwriting the file
+ # @param autoDimension if @c True (default), a space dimension of a MED mesh can be either
+ # - 1D if all mesh nodes lie on OX coordinate axis, or
+ # - 2D if all mesh nodes lie on XOY coordinate plane, or
+ # - 3D in the rest cases.<br>
+ # If @a autoDimension is @c False, the space dimension is always 3.
+ # @ingroup l2_impexp
+ def ExportToMED(self, *args, **kwargs):
+ print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
+ # process positional arguments
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+ fileName = args[0]
+ auto_groups = args[1] if len(args) > 1 else False
+ overwrite = args[2] if len(args) > 2 else True
+ autoDimension = args[3] if len(args) > 3 else True
+ # process keywords arguments
+ auto_groups = kwargs.get("opt", auto_groups) # old keyword name
+ auto_groups = kwargs.get("auto_groups", auto_groups) # new keyword name
+ overwrite = kwargs.get("overwrite", overwrite)
+ autoDimension = kwargs.get("autoDimension", autoDimension)
+ # invoke engine's function
+ self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+
+ ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
+ # Export the mesh in a file in MED format
+ # allowing to overwrite the file if it exists or add the exported data to its contents
+ # @param fileName the file name
# @param opt boolean parameter for creating/not creating
# the groups Group_On_All_Nodes, Group_On_All_Faces, ...
# @param overwrite boolean parameter for overwriting/not overwriting the file
# - 3D in the rest cases.<br>
# If @a autoDimension is @c False, the space dimension is always 3.
# @ingroup l2_impexp
- def ExportToMED(self, f, version=MED_LATEST, opt=0, overwrite=1, autoDimension=True):
- self.mesh.ExportToMEDX(f, opt, version, overwrite, autoDimension)
+ def ExportToMEDX(self, *args, **kwargs):
+ print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
+ # process positional arguments
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+ fileName = args[0]
+ auto_groups = args[1] if len(args) > 1 else False
+ overwrite = args[2] if len(args) > 2 else True
+ autoDimension = args[3] if len(args) > 3 else True
+ # process keywords arguments
+ auto_groups = kwargs.get("auto_groups", auto_groups)
+ overwrite = kwargs.get("overwrite", overwrite)
+ autoDimension = kwargs.get("autoDimension", autoDimension)
+ # invoke engine's function
+ self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
# Operations with groups:
# ----------------------
## Create an empty mesh group
- # @param elementType the type of elements in the group; either of
+ # @param elementType the type of elements in the group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME)
# @param name the name of the mesh group
# @return SMESH_Group
# the name is the same as the geometrical group name
# @param grp a geometrical group, a vertex, an edge, a face or a solid
# @param name the name of the mesh group
- # @param typ the type of elements in the group; either of
+ # @param typ the type of elements in the group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME). If not set, it is
# automatically detected by the type of the geometry
# @return SMESH_GroupOnGeom
elif tgeo == "COMPOUND":
sub = self.geompyD.SubShapeAll( shape, self.geompyD.ShapeType["SHAPE"])
if not sub:
- raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
+ raise ValueError("_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape))
return self._groupTypeFromShape( sub[0] )
else:
- raise ValueError, \
- "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
+ raise ValueError("_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape))
return typ
## Create a mesh group with given \a name based on the \a filter which
## is a special type of group dynamically updating it's contents during
## mesh modification
- # @param typ the type of elements in the group; either of
+ # @param typ the type of elements in the group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME).
# @param name the name of the mesh group
# @param filter the filter defining group contents
## Create a mesh group by the given ids of elements
# @param groupName the name of the mesh group
- # @param elementType the type of elements in the group; either of
+ # @param elementType the type of elements in the group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME).
# @param elemIDs either the list of ids, group, sub-mesh, or filter
# @return SMESH_Group
# @ingroup l2_grps_create
def MakeGroupByIds(self, groupName, elementType, elemIDs):
group = self.mesh.CreateGroup(elementType, groupName)
+ if isinstance( elemIDs, Mesh ):
+ elemIDs = elemIDs.GetMesh()
if hasattr( elemIDs, "GetIDs" ):
if hasattr( elemIDs, "SetMesh" ):
elemIDs.SetMesh( self.GetMesh() )
## Get the list of groups existing in the mesh in the order
# of creation (starting from the oldest one)
- # @param elemType type of elements the groups contain; either of
+ # @param elemType type of elements the groups contain; either of
# (SMESH.ALL, SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME);
# by default groups of elements of all types are returned
# @return a sequence of SMESH_GroupBase
## Find groups by name and type
# @param name name of the group of interest
- # @param elemType type of elements the groups contain; either of
+ # @param elemType type of elements the groups contain; either of
# (SMESH.ALL, SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME);
# by default one group of any type of elements is returned
# if elemType == SMESH.ALL then all groups of any type are returned
if group.GetName() == name:
if elemType is None:
return [group]
- if ( elemType == SMESH.ALL or
+ if ( elemType == SMESH.ALL or
group.GetType() == elemType ):
groups.append( group )
return groups
# @return an instance of SMESH_Group
# @ingroup l2_grps_operon
def UnionListOfGroups(self, groups, name):
- return self.mesh.UnionListOfGroups(groups, name)
+ return self.mesh.UnionListOfGroups(groups, name)
## Prodice an intersection of two groups.
# A new group is created. All mesh elements that are common
# @return an instance of SMESH_Group
# @ingroup l2_grps_operon
def IntersectListOfGroups(self, groups, name):
- return self.mesh.IntersectListOfGroups(groups, name)
+ return self.mesh.IntersectListOfGroups(groups, name)
## Produce a cut of two groups.
# A new group is created. All mesh elements that are present in
##
# Create a standalone group of entities basing on nodes of other groups.
# \param groups - list of reference groups, sub-meshes or filters, of any type.
- # \param elemType - a type of elements to include to the new group; either of
+ # \param elemType - a type of elements to include to the new group; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME).
# \param name - a name of the new group.
# \param nbCommonNodes - a criterion of inclusion of an element to the new group
def GetId(self):
return self.mesh.GetId()
- ## Get the study Id
- # @return integer value, which is the study Id of the mesh
- # @ingroup l1_auxiliary
- def GetStudyId(self):
- return self.mesh.GetStudyId()
-
## Check the group names for duplications.
# Consider the maximum group name length stored in MED file.
# @return True or False
return self.editor.MakeIDSource(ids, elemType)
- # Get informations about mesh contents:
+ # Get information about mesh contents:
# ------------------------------------
- ## Get the mesh stattistic
+ ## Get the mesh statistic
# @return dictionary type element - count of elements
# @ingroup l1_meshinfo
def GetMeshInfo(self, obj = None):
def Add0DElement( self, IDOfNode, DuplicateElements=True ):
return self.editor.Add0DElement( IDOfNode, DuplicateElements )
- ## Create 0D elements on all nodes of the given elements except those
+ ## Create 0D elements on all nodes of the given elements except those
# nodes on which a 0D element already exists.
# @param theObject an object on whose nodes 0D elements will be created.
# It can be mesh, sub-mesh, group, list of element IDs or a holder
# and/or found on nodes of \a theObject.
# @param DuplicateElements to add one more 0D element to a node or not
# @return an object (a new group or a temporary SMESH_IDSource) holding
- # IDs of new and/or found 0D elements. IDs of 0D elements
+ # IDs of new and/or found 0D elements. IDs of 0D elements
# can be retrieved from the returned object by calling GetIDs()
# @ingroup l2_modif_add
def Add0DElementsToAllNodes(self, theObject, theGroupName="", DuplicateElements=False):
VertexID = Vertex
try:
self.editor.SetNodeOnVertex(NodeID, VertexID)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
EdgeID = Edge
try:
self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
## @brief Stores node position on a face
FaceID = Face
try:
self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
## @brief Binds a node to a solid
SolidID = Solid
try:
self.editor.SetNodeInVolume(NodeID, SolidID)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
## @brief Bind an element to a shape
ShapeID = Shape
try:
self.editor.SetMeshElementOnShape(ElementID, ShapeID)
- except SALOME.SALOME_Exception, inst:
- raise ValueError, inst.details.text
+ except SALOME.SALOME_Exception as inst:
+ raise ValueError(inst.details.text)
return True
# @param x the X coordinate of a point
# @param y the Y coordinate of a point
# @param z the Z coordinate of a point
- # @param elementType type of elements to find; either of
+ # @param elementType type of elements to find; either of
# (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME); SMESH.ALL type
# means elements of any type excluding nodes, discrete and 0D elements.
# @param meshPart a part of mesh (group, sub-mesh) to search within
def GetPointState(self, x, y, z):
return self.editor.GetPointState(x, y, z)
+ ## Check if a 2D mesh is manifold
+ # @ingroup l1_controls
+ def IsManifold(self):
+ return self.editor.IsManifold()
+
+ ## Check if orientation of 2D elements is coherent
+ # @ingroup l1_controls
+ def IsCoherentOrientation2D(self):
+ return self.editor.IsCoherentOrientation2D()
+
## Find the node closest to a point and moves it to a point location
# @param x the X coordinate of a point
# @param y the Y coordinate of a point
# Type SMESH.FunctorType._items in the Python Console to see all items.
# Note that not all items correspond to numerical functors.
# @param MaxAngle is the maximum angle between element normals at which the fusion
- # is still performed; theMaxAngle is mesured in radians.
+ # is still performed; theMaxAngle is measured in radians.
# Also it could be a name of variable which defines angle in degrees.
# @return TRUE in case of success, FALSE otherwise.
# @ingroup l2_modif_unitetri
# Type SMESH.FunctorType._items in the Python Console to see all items.
# Note that not all items correspond to numerical functors.
# @param MaxAngle a max angle between element normals at which the fusion
- # is still performed; theMaxAngle is mesured in radians.
+ # is still performed; theMaxAngle is measured in radians.
# @return TRUE in case of success, FALSE otherwise.
# @ingroup l2_modif_unitetri
def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
pattern = self.smeshpyD.GetPattern()
isDone = pattern.LoadFromFile(pattern_tetra)
if not isDone:
- print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
+ print('Pattern.LoadFromFile :', pattern.GetErrorCode())
return isDone
pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
isDone = pattern.MakeMesh(self.mesh, False, False)
- if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
+ if not isDone: print('Pattern.MakeMesh :', pattern.GetErrorCode())
# split quafrangle faces near triangular facets of volumes
self.SplitQuadsNearTriangularFacets()
pattern = self.smeshpyD.GetPattern()
isDone = pattern.LoadFromFile(pattern_prism)
if not isDone:
- print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
+ print('Pattern.LoadFromFile :', pattern.GetErrorCode())
return isDone
pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
isDone = pattern.MakeMesh(self.mesh, False, False)
- if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
+ if not isDone: print('Pattern.MakeMesh :', pattern.GetErrorCode())
# Split quafrangle faces near triangular facets of volumes
self.SplitQuadsNearTriangularFacets()
self.editor.ConvertToQuadratic(theForce3d)
error = self.editor.GetLastError()
if error and error.comment:
- print error.comment
+ print(error.comment)
return error
-
+
## Convert the mesh from quadratic to ordinary,
# deletes old quadratic elements, \n replacing
# them with ordinary mesh elements with the same id.
return mesh, group
##
- # @brief Create missing boundary elements around either the whole mesh or
+ # @brief Create missing boundary elements around either the whole mesh or
# groups of elements
# @param dimension - defines type of boundary elements to create, either of
# { SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D }
# @param groupName - a name of group to store all boundary elements in,
# "" means not to create the group
- # @param meshName - a name of a new mesh, which is a copy of the initial
+ # @param meshName - a name of a new mesh, which is a copy of the initial
# mesh + created boundary elements; "" means not to create the new mesh
# @param toCopyAll - if true, the whole initial mesh will be copied into
# the new mesh else only boundary elements will be copied into the new mesh
if isinstance( basePoint, int):
xyz = self.GetNodeXYZ( basePoint )
if not xyz:
- raise RuntimeError, "Invalid node ID: %s" % basePoint
+ raise RuntimeError("Invalid node ID: %s" % basePoint)
basePoint = xyz
if isinstance( basePoint, geomBuilder.GEOM._objref_GEOM_Object ):
basePoint = self.geompyD.PointCoordinates( basePoint )
Elements = [ Elements.GetMesh() ]
if isinstance( Elements, list ):
if not Elements:
- raise RuntimeError, "Elements empty!"
+ raise RuntimeError("Elements empty!")
if isinstance( Elements[0], int ):
Elements = self.GetIDSource( Elements, SMESH.ALL )
unRegister.set( Elements )
if ( isinstance( thePoint, list )):
thePoint = PointStruct( thePoint[0], thePoint[1], thePoint[2] )
if ( isinstance( theScaleFact, float )):
- theScaleFact = [theScaleFact]
+ theScaleFact = [theScaleFact]
if ( isinstance( theScaleFact, int )):
- theScaleFact = [ float(theScaleFact)]
+ theScaleFact = [ float(theScaleFact)]
self.mesh.SetParameters(thePoint.parameters)
if ( isinstance( thePoint, list )):
thePoint = PointStruct( thePoint[0], thePoint[1], thePoint[2] )
if ( isinstance( theScaleFact, float )):
- theScaleFact = [theScaleFact]
+ theScaleFact = [theScaleFact]
if ( isinstance( theScaleFact, int )):
- theScaleFact = [ float(theScaleFact)]
+ theScaleFact = [ float(theScaleFact)]
self.mesh.SetParameters(thePoint.parameters)
mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
def MergeEqualElements(self):
self.editor.MergeEqualElements()
- raise TypeError, "holeNodes must be either SMESH.FreeBorder or list of integer and not %s" % holeNodes
+ ## Returns all or only closed free borders
+ # @return list of SMESH.FreeBorder's
+ # @ingroup l2_modif_trsf
+ def FindFreeBorders(self, ClosedOnly=True):
+ return self.editor.FindFreeBorders( ClosedOnly )
+
+ ## Fill with 2D elements a hole defined by a SMESH.FreeBorder.
+ # @param FreeBorder either a SMESH.FreeBorder or a list on node IDs. These nodes
+ # must describe all sequential nodes of the hole border. The first and the last
+ # nodes must be the same. Use FindFreeBorders() to get nodes of holes.
+ # @ingroup l2_modif_trsf
+ def FillHole(self, holeNodes):
+ if holeNodes and isinstance( holeNodes, list ) and isinstance( holeNodes[0], int ):
+ holeNodes = SMESH.FreeBorder(nodeIDs=holeNodes)
+ if not isinstance( holeNodes, SMESH.FreeBorder ):
++ raise TypeError("holeNodes must be either SMESH.FreeBorder or list of integer and not %s" % holeNodes)
+ self.editor.FillHole( holeNodes )
+
## Return groups of FreeBorder's coincident within the given tolerance.
# @param tolerance the tolerance. If the tolerance <= 0.0 then one tenth of an average
# size of elements adjacent to free borders being compared is used.
# @ingroup l2_modif_trsf
def FindCoincidentFreeBorders (self, tolerance=0.):
return self.editor.FindCoincidentFreeBorders( tolerance )
-
+
## Sew FreeBorder's of each group
# @param freeBorders either a SMESH.CoincidentFreeBorders structure or a list of lists
# where each enclosed list contains node IDs of a group of coincident free
coincidentGroups = []
for nodeList in freeBorders:
if not nodeList or len( nodeList ) % 3:
- raise ValueError, "Wrong number of nodes in this group: %s" % nodeList
+ raise ValueError("Wrong number of nodes in this group: %s" % nodeList)
group = []
while nodeList:
group.append ( SMESH.FreeBorderPart( len(borders), 0, 1, 2 ))
def ClearLastCreated(self):
self.editor.ClearLastCreated()
- ## Create duplicates of given elements, i.e. create new elements based on the
+ ## Create duplicates of given elements, i.e. create new elements based on the
# same nodes as the given ones.
# @param theElements - container of elements to duplicate. It can be a Mesh,
# sub-mesh, group, filter or a list of element IDs. If \a theElements is
# @param theGroupName - a name of group to contain the generated elements.
# If a group with such a name already exists, the new elements
# are added to the existng group, else a new group is created.
- # If \a theGroupName is empty, new elements are not added
+ # If \a theGroupName is empty, new elements are not added
# in any group.
# @return a group where the new elements are added. None if theGroupName == "".
# @ingroup l2_modif_duplicat
## Identify the elements that will be affected by node duplication (actual duplication is not performed.
# This method is the first step of DoubleNodeElemGroupsInRegion.
- # @param theElems - list of groups of elements (edges or faces) to be replicated
+ # @param theElems - list of groups of nodes or elements (edges or faces) to be replicated
# @param theNodesNot - list of groups of nodes not to replicated
# @param theShape - shape to detect affected elements (element which geometric center
# located on or inside shape).
# The replicated nodes should be associated to affected elements.
- # @return groups of affected elements
+ # @return groups of affected elements in order: volumes, faces, edges
# @ingroup l2_modif_duplicat
def AffectedElemGroupsInRegion(self, theElems, theNodesNot, theShape):
return self.editor.AffectedElemGroupsInRegion(theElems, theNodesNot, theShape)
# @return TRUE if operation has been completed successfully, FALSE otherwise
# @ingroup l2_modif_duplicat
def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems, onAllBoundaries=False ):
- return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems, onAllBoundaries )
+ return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems, onAllBoundaries )
## Double nodes on some external faces and create flat elements.
# Flat elements are mainly used by some types of mechanic calculations.
- #
+ #
# Each group of the list must be constituted of faces.
# Triangles are transformed in prisms, and quadrangles in hexahedrons.
# @param theGroupsOfFaces - list of groups of faces
# @ingroup l2_modif_duplicat
def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
-
+
## identify all the elements around a geom shape, get the faces delimiting the hole
#
def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords):
return self.editor.CreateHoleSkin( radius, theShape, groupName, theNodesCoords )
- def _getFunctor(self, funcType ):
- fn = self.functors[ EnumToLong(funcType) ]
+ ## Create a polyline consisting of 1D mesh elements each lying on a 2D element of
+ # the initial mesh. Positions of new nodes are found by cutting the mesh by the
+ # plane passing through pairs of points specified by each PolySegment structure.
+ # If there are several paths connecting a pair of points, the shortest path is
+ # selected by the module. Position of the cutting plane is defined by the two
+ # points and an optional vector lying on the plane specified by a PolySegment.
+ # By default the vector is defined by Mesh module as following. A middle point
+ # of the two given points is computed. The middle point is projected to the mesh.
+ # The vector goes from the middle point to the projection point. In case of planar
+ # mesh, the vector is normal to the mesh.
+ # @param segments - PolySegment's defining positions of cutting planes.
+ # Return the used vector which goes from the middle point to its projection.
+ # @param groupName - optional name of a group where created mesh segments will
+ # be added.
+ # @ingroup l2_modif_duplicat
+ def MakePolyLine(self, segments, groupName='', isPreview=False ):
+ editor = self.editor
+ if isPreview:
+ editor = self.mesh.GetMeshEditPreviewer()
+ segmentsRes = editor.MakePolyLine( segments, groupName )
+ for i, seg in enumerate( segmentsRes ):
+ segments[i].vector = seg.vector
+ if isPreview:
+ return editor.GetPreviewData()
+ return None
+
+ ## Return a cached numerical functor by its type.
+ # @param theCriterion functor type - an item of SMESH.FunctorType enumeration.
+ # Type SMESH.FunctorType._items in the Python Console to see all items.
+ # Note that not all items correspond to numerical functors.
+ # @return SMESH_NumericalFunctor. The functor is already initialized
+ # with a mesh
+ # @ingroup l1_measurements
+ def GetFunctor(self, funcType ):
+ fn = self.functors[ funcType._v ]
if not fn:
fn = self.smeshpyD.GetFunctor(funcType)
fn.SetMesh(self.mesh)
- self.functors[ funcType._v ] = fn
+ self.functors[ EnumToLong(funcType) ] = fn
return fn
## Return value of a functor for a given element
# @return the functor value or zero in case of invalid arguments
# @ingroup l1_measurements
def FunctorValue(self, funcType, elemId, isElem=True):
- fn = self._getFunctor( funcType )
+ fn = self.GetFunctor( funcType )
if fn.GetElementType() == self.GetElementType(elemId, isElem):
val = fn.GetValue(elemId)
else:
unRegister.set( meshPart )
if isinstance( meshPart, Mesh ):
meshPart = meshPart.mesh
- fun = self._getFunctor( funType )
+ fun = self.GetFunctor( funType )
if fun:
if meshPart:
if hasattr( meshPart, "SetMesh" ):
# with old dump scripts which call SMESH_Mesh directly and not via smeshBuilder.Mesh
#
class meshProxy(SMESH._objref_SMESH_Mesh):
- def __init__(self):
- SMESH._objref_SMESH_Mesh.__init__(self)
+ def __init__(self, *args):
+ SMESH._objref_SMESH_Mesh.__init__(self, *args)
def __deepcopy__(self, memo=None):
- new = self.__class__()
+ new = self.__class__(self)
return new
def CreateDimGroup(self,*args): # 2 args added: nbCommonNodes, underlyingOnly
if len( args ) == 3:
args += SMESH.ALL_NODES, True
- return SMESH._objref_SMESH_Mesh.CreateDimGroup( self, *args )
+ return SMESH._objref_SMESH_Mesh.CreateDimGroup(self, *args)
+ def ExportToMEDX(self, *args): # function removed
+ print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
+ def ExportToMED(self, *args): # function removed
+ print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ while len(args) < 4: # !!!! nb of parameters for ExportToMED IDL's method
+ args.append(True)
+ SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
+ def ExportPartToMED(self, *args): # 'version' parameter removed
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ SMESH._objref_SMESH_Mesh.ExportPartToMED(self, *args)
+ def ExportMED(self, *args): # signature of method changed
+ args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+ while len(args) < 4: # !!!! nb of parameters for ExportToMED IDL's method
+ args.append(True)
+ SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
pass
omniORB.registerObjref(SMESH._objref_SMESH_Mesh._NP_RepositoryId, meshProxy)
## Private class wrapping SMESH.SMESH_SubMesh in order to add Compute()
#
class submeshProxy(SMESH._objref_SMESH_subMesh):
- def __init__(self):
- SMESH._objref_SMESH_subMesh.__init__(self)
+ def __init__(self, *args):
+ SMESH._objref_SMESH_subMesh.__init__(self, *args)
self.mesh = None
def __deepcopy__(self, memo=None):
- new = self.__class__()
+ new = self.__class__(self)
return new
## Compute the sub-mesh and return the status of the computation
ok = self.mesh.Compute( self.GetSubShape(),refresh=[] )
- if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
+ if salome.sg.hasDesktop():
smeshgui = salome.ImportComponentGUI("SMESH")
- smeshgui.Init(self.mesh.GetStudyId())
+ smeshgui.Init()
smeshgui.SetMeshIcon( salome.ObjectToID( self ), ok, (self.GetNumberOfElements()==0) )
- if refresh: salome.sg.updateObjBrowser(True)
+ if refresh: salome.sg.updateObjBrowser()
pass
return ok
# smeshBuilder.Mesh
#
class meshEditor(SMESH._objref_SMESH_MeshEditor):
- def __init__(self):
- SMESH._objref_SMESH_MeshEditor.__init__(self)
+ def __init__(self, *args):
+ SMESH._objref_SMESH_MeshEditor.__init__(self, *args)
self.mesh = None
def __getattr__(self, name ): # method called if an attribute not found
if not self.mesh: # look for name() method in Mesh class
return getattr( self.mesh, name )
if name == "ExtrusionAlongPathObjX":
return getattr( self.mesh, "ExtrusionAlongPathX" ) # other method name
- print "meshEditor: attribute '%s' NOT FOUND" % name
+ print("meshEditor: attribute '%s' NOT FOUND" % name)
return None
def __deepcopy__(self, memo=None):
- new = self.__class__()
+ new = self.__class__(self)
return new
def FindCoincidentNodes(self,*args): # a 2nd arg added (SeparateCornerAndMediumNodes)
if len( args ) == 1: args += False,
# Store a python class of algorithm
def add(self, algoClass):
- if type( algoClass ).__name__ == 'classobj' and \
- hasattr( algoClass, "algoType"):
+ if inspect.isclass(algoClass) and \
+ hasattr(algoClass, "algoType"):
self.algoTypeToClass[ algoClass.algoType ] = algoClass
if not self.defaultAlgoType and \
hasattr( algoClass, "isDefault") and algoClass.isDefault:
algoType = self.defaultAlgoType
if not algoType and self.algoTypeToClass:
algoType = sorted( self.algoTypeToClass.keys() )[0]
- if self.algoTypeToClass.has_key( algoType ):
+ if algoType in self.algoTypeToClass:
#print "Create algo",algoType
+
return self.algoTypeToClass[ algoType ]( self.mesh, shape )
- raise RuntimeError, "No class found for algo type %s" % algoType
+ raise RuntimeError( "No class found for algo type %s" % algoType)
return None
## Private class used to substitute and store variable parameters of hypotheses.
except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
# maybe there is a replaced string arg which is not variable
result = self.method( self.hyp, *args )
- except ValueError, detail: # raised by ParseParameters()
+ except ValueError as detail: # raised by ParseParameters()
try:
result = self.method( self.hyp, *args )
except omniORB.CORBA.BAD_PARAM:
- raise ValueError, detail # wrong variable name
+ raise ValueError(detail) # wrong variable name
return result
pass
pluginBuilderName = pluginName + "Builder"
try:
exec( "from salome.%s.%s import *" % (pluginName, pluginBuilderName))
- except Exception, e:
- from salome_utils import verbose
- if verbose(): print "Exception while loading %s: %s" % ( pluginBuilderName, e )
+ except Exception as e:
+ from salome_utils import verbose
+ if verbose(): print("Exception while loading %s: %s" % ( pluginBuilderName, e ))
continue
exec( "from salome.%s import %s" % (pluginName, pluginBuilderName))
plugin = eval( pluginBuilderName )
if k[0] == '_': continue
algo = getattr( plugin, k )
#print " algo:", str(algo)
- if type( algo ).__name__ == 'classobj' and hasattr( algo, "meshMethod" ):
+ if inspect.isclass(algo) and hasattr(algo, "meshMethod"):
#print " meshMethod:" , str(algo.meshMethod)
if not hasattr( Mesh, algo.meshMethod ):
setattr( Mesh, algo.meshMethod, algoCreator( algo.meshMethod ))
//
#include "libSMESH_Swig.h"
+ #include <SVTK_Selector.h>
#include <SMESHGUI.h>
#include <SMESHGUI_Utils.h>
#include <Utils_ORB_INIT.hxx>
#include <Utils_SINGLETON.hxx>
#include <SALOMEDSClient_ClientFactory.hxx>
+#include <SALOME_KernelServices.hxx>
#include <utilities.h>
void
SetDomain(const char* theMeshOrSubMeshEntry,
const char* theDomainEntry,
- const SALOMEDS::Study_var& theStudy,
const SALOMEDS::StudyBuilder_var& theStudyBuilder,
long theRefOnAppliedDomainTag,
const QString& theAppliedDomainMEN,
const QString& theAppliedDomainICON)
{
- SALOMEDS::SObject_var aMeshOrSubMeshSO = theStudy->FindObjectID(theMeshOrSubMeshEntry);
- SALOMEDS::SObject_var aHypothesisSO = theStudy->FindObjectID(theDomainEntry);
+ SALOMEDS::SObject_var aMeshOrSubMeshSO = KERNEL::getStudyServant()->FindObjectID(theMeshOrSubMeshEntry);
+ SALOMEDS::SObject_var aHypothesisSO = KERNEL::getStudyServant()->FindObjectID(theDomainEntry);
if(!aMeshOrSubMeshSO->_is_nil() && !aHypothesisSO->_is_nil()){
//Find or Create Applied Hypothesis root
void
SetHypothesis(const char* theMeshOrSubMeshEntry,
const char* theDomainEntry,
- const SALOMEDS::Study_var& theStudy,
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
{
SetDomain(theMeshOrSubMeshEntry,
theDomainEntry,
- theStudy,
theStudyBuilder,
SMESH::Tag_RefOnAppliedHypothesis,
QObject::tr("SMESH_MEN_APPLIED_HYPOTHESIS"),
void
SetAlgorithms(const char* theMeshOrSubMeshEntry,
const char* theDomainEntry,
- const SALOMEDS::Study_var& theStudy,
const SALOMEDS::StudyBuilder_var& theStudyBuilder)
{
SetDomain(theMeshOrSubMeshEntry,
theDomainEntry,
- theStudy,
theStudyBuilder,
SMESH::Tag_RefOnAppliedAlgorithms,
QObject::tr("SMESH_MEN_APPLIED_ALGORIHTMS"),
//===============================================================
void
-SMESH_Swig::Init(int theStudyID)
+SMESH_Swig::Init()
{
class TEvent: public SALOME_Event
{
- int myStudyID;
- SALOMEDS::Study_var& myStudy;
SALOMEDS::StudyBuilder_var& myStudyBuilder;
SALOMEDS::SComponent_var& mySComponentMesh;
public:
- TEvent(int theStudyID,
- SALOMEDS::Study_var& theStudy,
- SALOMEDS::StudyBuilder_var& theStudyBuilder,
+ TEvent(SALOMEDS::StudyBuilder_var& theStudyBuilder,
SALOMEDS::SComponent_var& theSComponentMesh):
- myStudyID (theStudyID),
- myStudy (theStudy),
myStudyBuilder (theStudyBuilder),
mySComponentMesh(theSComponentMesh)
{}
SUIT_Application* anApplication = aSession->activeApplication();
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(anApplication);
- SALOME_NamingService* aNamingService = anApp->namingService();
- CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
- myStudy = aStudyMgr->GetStudyByID(myStudyID);
+ SALOMEDS::Study_var aStudy = KERNEL::getStudyServant();
SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
- aSMESHGen->SetCurrentStudy( myStudy.in() );
- myStudyBuilder = myStudy->NewBuilder();
+ myStudyBuilder = aStudy->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributePixMap_var aPixmap;
- SALOMEDS::SComponent_var aSComponent = myStudy->FindComponent("SMESH");
+ SALOMEDS::SComponent_var aSComponent = aStudy->FindComponent("SMESH");
if ( aSComponent->_is_nil() )
{
- bool aLocked = myStudy->GetProperties()->IsLocked();
+ bool aLocked = aStudy->GetProperties()->IsLocked();
if (aLocked)
- myStudy->GetProperties()->SetLocked(false);
+ aStudy->GetProperties()->SetLocked(false);
SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI();
//SRN: BugID IPAL9186, load a SMESH gui if it hasn't been loaded
aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
aPixmap->UnRegister();
- SALOMEDS::UseCaseBuilder_var useCaseBuilder = myStudy->GetUseCaseBuilder();
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = KERNEL::getStudyServant()->GetUseCaseBuilder();
useCaseBuilder->SetRootCurrent();
useCaseBuilder->Append( aSComponent.in() );
myStudyBuilder->DefineComponentInstance(aSComponent,aSMESHGen);
if (aLocked)
- myStudy->GetProperties()->SetLocked(true);
+ KERNEL::getStudyServant()->GetProperties()->SetLocked(true);
}
mySComponentMesh = SALOMEDS::SComponent::_narrow(aSComponent);
//MESSAGE("Init");
- ProcessVoidEvent(new TEvent(theStudyID,
- myStudy,
- myStudyBuilder,
+ ProcessVoidEvent(new TEvent(myStudyBuilder,
mySComponentMesh));
}
{
// VSR: added temporarily - to be removed - objects are published automatically by engine
- SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(theIOR);
+ SALOMEDS::SObject_var aSObject = KERNEL::getStudyServant()->FindObjectIOR(theIOR);
if (aSObject->_is_nil())
{
//Find or Create Hypothesis root
void SMESH_Swig::SetShape(const char* theShapeEntry,
const char* theMeshEntry)
{
- SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID( theShapeEntry );
- SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID( theMeshEntry );
+ SALOMEDS::SObject_var aGeomShapeSO = KERNEL::getStudyServant()->FindObjectID( theShapeEntry );
+ SALOMEDS::SObject_var aMeshSO = KERNEL::getStudyServant()->FindObjectID( theMeshEntry );
if(!aMeshSO->_is_nil() && !aGeomShapeSO->_is_nil()){
SALOMEDS::SObject_var aSObject = myStudyBuilder->NewObjectToTag(aMeshSO, SMESH::Tag_RefOnShape);
{
::SetHypothesis(theMeshOrSubMeshEntry,
theDomainEntry,
- myStudy,
myStudyBuilder);
}
{
::SetAlgorithms(theMeshOrSubMeshEntry,
theDomainEntry,
- myStudy,
myStudyBuilder);
}
void
SMESH_Swig::UnSetHypothesis(const char* theDomainEntry)
{
- SALOMEDS::SObject_var aDomainSO = myStudy->FindObjectID(theDomainEntry);
+ SALOMEDS::SObject_var aDomainSO = KERNEL::getStudyServant()->FindObjectID(theDomainEntry);
if(!aDomainSO->_is_nil())
myStudyBuilder->RemoveObject(aDomainSO);
}
const char* theSubMeshIOR,
int theShapeType)
{
- SALOMEDS::SObject_var aMeshSO = myStudy->FindObjectID(theMeshEntry);
+ SALOMEDS::SObject_var aMeshSO = KERNEL::getStudyServant()->FindObjectID(theMeshEntry);
if(!aMeshSO->_is_nil()) {
long aShapeTag;
QString aSubMeshName;
const char* theSubMeshIOR,
int ShapeType)
{
- SALOMEDS::SObject_var aGeomShapeSO = myStudy->FindObjectID(theGeomShapeEntry);
+ SALOMEDS::SObject_var aGeomShapeSO = KERNEL::getStudyServant()->FindObjectID(theGeomShapeEntry);
if(!aGeomShapeSO->_is_nil())
{
const char * aSubMeshEntry = AddSubMesh(theMeshEntry,theSubMeshIOR,ShapeType);
- SALOMEDS::SObject_var aSubMeshSO = myStudy->FindObjectID(aSubMeshEntry);
+ SALOMEDS::SObject_var aSubMeshSO = KERNEL::getStudyServant()->FindObjectID(aSubMeshEntry);
if ( !aSubMeshSO->_is_nil()) {
SetShape( theGeomShapeEntry, aSubMeshEntry );
CORBA::String_var aString = aSubMeshSO->GetID();
ProcessVoidEvent(new TEvent(Mesh_Entry, allViewers));
}
+ void SMESH_Swig::UpdateActor( const char* Mesh_Entry ) {
+ class TEvent: public SALOME_Event
+ {
+ private:
+ const char* _entry;
+ public:
+ TEvent( const char* Mesh_Entry ) {
+ _entry = Mesh_Entry;
+ }
+ virtual void Execute() {
+ Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
+ ( _entry, "SMESH", "" );
+ SMESH::Update( anIO, true );
+ }
+ };
+
+ ProcessVoidEvent( new TEvent(Mesh_Entry) );
+ }
+
void SMESH_Swig::SetName(const char* theEntry,
const char* theName)
{
- SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(theEntry);
+ SALOMEDS::SObject_var aSObject = KERNEL::getStudyServant()->FindObjectID(theEntry);
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
if(!aSObject->_is_nil()){
{
class TEvent: public SALOME_Event
{
- SALOMEDS::Study_var myStudy;
std::string myMeshEntry;
bool myIsComputed, myIsEmpty;
public:
- TEvent(const SALOMEDS::Study_var& theStudy,
- const std::string& theMeshEntry,
+ TEvent(const std::string& theMeshEntry,
const bool theIsComputed,
const bool isEmpty):
- myStudy (theStudy),
myMeshEntry (theMeshEntry),
myIsComputed(theIsComputed),
myIsEmpty (isEmpty)
void
Execute()
{
- SALOMEDS::SObject_ptr aMeshSO = myStudy->FindObjectID(myMeshEntry.c_str());
+ SALOMEDS::SObject_ptr aMeshSO = KERNEL::getStudyServant()->FindObjectID(myMeshEntry.c_str());
if(_PTR(SObject) aMesh = ClientFactory::SObject(aMeshSO))
SMESH::ModifiedMesh(aMesh,myIsComputed,myIsEmpty);
// aMeshSO->UnRegister(); ~aMesh() already called UnRegister()!
}
};
- ProcessVoidEvent(new TEvent(myStudy,
- theMeshEntry,
+ ProcessVoidEvent(new TEvent(theMeshEntry,
theIsComputed,
isEmpty));
}
ProcessVoidEvent( new TSelectListEvent( id, ids, append ) );
}
+ /*!
+ \brief Helper class for selection edges of cell event
+ */
+ class TSelectListOfPairEvent: public SALOME_Event
+ {
+ const char* myId;
+ std::vector<std::pair<int, int> > myIdsList;
+ bool myIsAppend;
+
+ public:
+ TSelectListOfPairEvent(const char* id, std::vector<std::pair<int, int> > ids, bool append) :
+ myId(id),
+ myIdsList(ids),
+ myIsAppend(append)
+ {}
+ virtual void Execute()
+ {
+
+ LightApp_SelectionMgr* selMgr = 0;
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+ if( anApp )
+ selMgr = dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
+
+ if( !selMgr )
+ return;
+
+ selMgr->clearFilters();
+
+ SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow();
+ if(!aViewWindow)
+ return;
+
+ SMESH_Actor* anActor = SMESH::FindActorByEntry( myId );
+
+ if (!anActor || !anActor->hasIO())
+ return;
+
+ Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+ SALOME_ListIO aList;
+ aList.Append(anIO);
+ selMgr->setSelectedObjects(aList, false);
+
+ if ( aViewWindow->SelectionMode() != EdgeOfCellSelection ) {
+ return;
+ }
+
+ SVTK_IndexedMapOfIds aMap;
+ std::vector<std::pair<int, int> >::const_iterator anIter;
+ for (anIter = myIdsList.begin(); anIter != myIdsList.end(); ++anIter) {
+ std::vector<int> aCompositeId;
+ aCompositeId.push_back((*anIter).first);
+ aCompositeId.push_back((*anIter).second);
+ aMap.Add(aCompositeId);
+ }
+
+ // Set new selection
+ SVTK_Selector* aSelector = aViewWindow->GetSelector();
+ aSelector->AddOrRemoveCompositeIndex(anIO, aMap, myIsAppend);
+ aViewWindow->highlight( anIO, true, true );
+ aViewWindow->GetInteractor()->onEmitSelectionChanged();
+ }
+ };
+
+ /*!
+ \brief Select the elements on the mesh, sub-mesh or group.
+ \param id object entry
+ \param ids list of the element ids
+ \param mode selection mode
+ */
+ void SMESH_Swig::select( const char* id, std::vector<std::pair<int,int> > ids, bool append ) {
+ ProcessVoidEvent( new TSelectListOfPairEvent( id, ids, append ) );
+ }
class TGetSelectionModeEvent : public SALOME_Event
{
std::vector<int> SMESH_Swig::getSelected( const char* Mesh_Entry ) {
return ProcessEvent( new TGetSelectedEvent(Mesh_Entry) );
}
+
+ class TGetSelectedPairEvent : public SALOME_Event
+ {
+ public:
+ typedef std::vector<std::pair<int, int> > TResult;
+ TResult myResult;
+ const char* myId;
+
+ TGetSelectedPairEvent( const char* id) :
+ myResult( std::vector<std::pair<int,int> >() ),
+ myId(id)
+ {}
+
+ virtual void Execute()
+ {
+ SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow();
+ if( !aViewWindow )
+ return;
+
+ if(aViewWindow->SelectionMode() != EdgeOfCellSelection )
+ return;
+
+ SVTK_Selector* aSelector = aViewWindow->GetSelector();
+ if( !aSelector )
+ return;
+
+ SMESH_Actor* anActor = SMESH::FindActorByEntry( myId );
+
+ if ( !anActor || !anActor->hasIO() )
+ return;
+
+ SVTK_IndexedMapOfIds aMapIndex;
+ aSelector->GetCompositeIndex(anActor->getIO(),aMapIndex);
+
+ for( int i = 1; i <= aMapIndex.Extent(); i++ )
+ myResult.push_back( std::make_pair<int,int>( (int)aMapIndex( i )[0], (int)aMapIndex( i )[1]) );
+ }
+ };
+
+ std::vector<std::pair<int,int> > SMESH_Swig::getSelectedEdgeOfCell( const char* Mesh_Entry ) {
+ return ProcessEvent( new TGetSelectedPairEvent(Mesh_Entry) );
+ }
+
//std includes
#include <vector>
+ #include <utility>
#include <SVTK_Selection.h>
SMESH_Swig();
~SMESH_Swig();
- void Init( int );
+ void Init();
const char* AddNewMesh( const char* );
void EraseActor( const char*, const bool allViewers = false );
+ void UpdateActor( const char* Mesh_Entry );
+
/*!
* \brief Set mesh icon according to compute status
* \param Mesh_Entry - entry of a mesh
void setSelectionMode( SelectionMode selectionMode );
std::vector<int> getSelected( const char* Mesh_Entry );
+ std::vector<std::pair<int, int> > getSelectedEdgeOfCell( const char* Mesh_Entry );
// --------------------- for the test purposes -----------------------
SelectionMode getSelectionMode();
void select( const char *id, std::vector<int> ids, bool append = false );
void select( const char *id, int id1, bool append = false );
+ void select( const char *id, std::vector<std::pair<int,int> >, bool apend = false );
private:
- SALOMEDS::Study_var myStudy;
SALOMEDS::StudyBuilder_var myStudyBuilder;
SALOMEDS::SComponent_var mySComponentMesh;
};
%include "typemaps.i"
%include "std_vector.i"
+ %include "std_pair.i"
namespace std {
+
%template(VectorInt) vector<int>;
+ %template() std::pair<int,int>;
+ %template(PairVector) std::vector<std::pair<int,int> >;
};
SMESH_Swig();
~SMESH_Swig();
- void Init(int studyID);
+ void Init();
const char* AddNewMesh(const char* IOR);
const char* AddNewHypothesis(const char* IOR);
void CreateAndDisplayActor( const char* Mesh_Entry );
void EraseActor( const char* Mesh_Entry, const bool allViewers = false );
+ void UpdateActor( const char* Mesh_Entry );
+
+ void setSelectionMode( SelectionMode selectionMode);
+ std::vector<int> getSelected( const char* Mesh_Entry );
+ std::vector<std::pair<int,int> > getSelectedEdgeOfCell( const char* Mesh_Entry );
actorAspect GetActorAspect(const char* Mesh_Entry, int viewId = 0 );
void SetActorAspect( const actorAspect& actorPres, const char* Mesh_Entry, int viewId = 0 );
SelectionMode getSelectionMode();
void select( const char *id, std::vector<int> ids, bool append = false );
void select( const char *id, int id1, bool append = false );
+ void select( const char *id, std::vector<std::pair<int,int> >, bool apend = false );
};
*/
//=============================================================================
-StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, gen)
{
_name = "AutomaticLength";
_param_algo_dim = 1; // is used by SMESH_Regular_1D
theTShapeToLengthMap.insert( make_pair( getTShape( edge ), L ));
}
- // Compute S0 - minimal segement length, is computed by the shortest EDGE
+ // Compute S0 - minimal segment length, is computed by the shortest EDGE
/* image attached to PAL10237
//=======================================================================
StdMeshers_CartesianParameters3D::StdMeshers_CartesianParameters3D(int hypId,
- int studyId,
SMESH_Gen * gen)
- : SMESH_Hypothesis(hypId, studyId, gen),
+ : SMESH_Hypothesis(hypId, gen),
_sizeThreshold( 4.0 ), // default according to the customer specification
_toAddEdges( false )
{
//=======================================================================
//function : LoadFrom
- //purpose : resore my parameters from a stream
+ //purpose : restore my parameters from a stream
//=======================================================================
std::istream & StdMeshers_CartesianParameters3D::LoadFrom(std::istream & load)
#include <utilities.h>
#include <Utils_ExceptHandlers.hxx>
- #include <Basics_OCCTVersion.hxx>
#include <GEOMUtils.hxx>
*/
//=============================================================================
-StdMeshers_Cartesian_3D::StdMeshers_Cartesian_3D(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_Cartesian_3D::StdMeshers_Cartesian_3D(int hypId, SMESH_Gen * gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "Cartesian_3D";
_shapeType = (1 << TopAbs_SOLID); // 1 bit /shape type
}
if ( surf->IsKind( STANDARD_TYPE(Geom_BSplineSurface )) ||
surf->IsKind( STANDARD_TYPE(Geom_BezierSurface )))
- #if OCC_VERSION_MAJOR < 7
- if ( !noSafeTShapes.insert((const Standard_Transient*) _face.TShape() ).second )
- #else
if ( !noSafeTShapes.insert( _face.TShape().get() ).second )
- #endif
isSafe = false;
double f, l;
edgeIsSafe = false;
}
}
- #if OCC_VERSION_MAJOR < 7
- if ( !edgeIsSafe && !noSafeTShapes.insert((const Standard_Transient*) e.TShape() ).second )
- #else
if ( !edgeIsSafe && !noSafeTShapes.insert( e.TShape().get() ).second )
- #endif
isSafe = false;
}
return isSafe;
const SMDS_MeshElement* cornerQuad,
const SMDS_MeshNode* nCorner)
{
- // Find out size of block side mesured in nodes and by the way find two rows
+ // Find out size of block side measured in nodes and by the way find two rows
// of nodes in two directions.
int x, y, nbX, nbY;
//purpose :
//=======================================================================
-StdMeshers_HexaFromSkin_3D::StdMeshers_HexaFromSkin_3D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_HexaFromSkin_3D::StdMeshers_HexaFromSkin_3D(int hypId, SMESH_Gen* gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "HexaFromSkin_3D";
}
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
- #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- #define NO_CAS_CATCH
- #endif
-
#include <Standard_Failure.hxx>
-
- #ifdef NO_CAS_CATCH
#include <Standard_ErrorHandler.hxx>
- #endif
#include <Basics_Utils.hxx>
//=============================================================================
StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId,
- int studyId,
SMESH_Gen * gen)
- : SMESH_Hypothesis(hypId, studyId, gen),
+ : SMESH_Hypothesis(hypId, gen),
_numberOfSegments(15),//issue 19923
_distrType(DT_Regular),
_scaleFactor(1.),
if( _convMode==0 )
{
try {
- #ifdef NO_CAS_CATCH
OCC_CATCH_SIGNALS;
- #endif
val = pow( 10.0, val );
}
catch(Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
throw SALOME_Exception( LOCALIZED( "invalid value"));
return;
}
bool parsed_ok = true;
Handle( ExprIntrp_GenExp ) myExpr;
try {
- #ifdef NO_CAS_CATCH
OCC_CATCH_SIGNALS;
- #endif
myExpr = ExprIntrp_GenExp::Create();
myExpr->Process( str.ToCString() );
} catch(Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
parsed_ok = false;
}
*/
struct TQuadrangleAlgo : public StdMeshers_Quadrangle_2D
{
- TQuadrangleAlgo(int studyId, SMESH_Gen* gen)
- : StdMeshers_Quadrangle_2D( gen->GetANewId(), studyId, gen)
+ TQuadrangleAlgo(SMESH_Gen* gen)
+ : StdMeshers_Quadrangle_2D( gen->GetANewId(), gen)
{
}
static StdMeshers_Quadrangle_2D* instance( SMESH_Algo* fatherAlgo,
SMESH_MesherHelper* helper=0)
{
- static TQuadrangleAlgo* algo = new TQuadrangleAlgo( fatherAlgo->GetStudyId(),
- fatherAlgo->GetGen() );
+ static TQuadrangleAlgo* algo = new TQuadrangleAlgo( fatherAlgo->GetGen() );
if ( helper &&
algo->myProxyMesh &&
algo->myProxyMesh->GetMesh() != helper->GetMesh() )
algo->myProxyMesh.reset( new SMESH_ProxyMesh( *helper->GetMesh() ));
algo->myQuadList.clear();
+ algo->myHelper = 0;
if ( helper )
algo->_quadraticMesh = helper->GetIsQuadratic();
{
StdMeshers_ProjectionSource1D myHyp;
- TProjction1dAlgo(int studyId, SMESH_Gen* gen)
- : StdMeshers_Projection_1D( gen->GetANewId(), studyId, gen),
- myHyp( gen->GetANewId(), studyId, gen)
+ TProjction1dAlgo(SMESH_Gen* gen)
+ : StdMeshers_Projection_1D( gen->GetANewId(), gen),
+ myHyp( gen->GetANewId(), gen)
{
StdMeshers_Projection_1D::_sourceHypo = & myHyp;
}
static TProjction1dAlgo* instance( SMESH_Algo* fatherAlgo )
{
- static TProjction1dAlgo* algo = new TProjction1dAlgo( fatherAlgo->GetStudyId(),
- fatherAlgo->GetGen() );
+ static TProjction1dAlgo* algo = new TProjction1dAlgo( fatherAlgo->GetGen() );
return algo;
}
};
{
StdMeshers_ProjectionSource2D myHyp;
- TProjction2dAlgo(int studyId, SMESH_Gen* gen)
- : StdMeshers_Projection_1D2D( gen->GetANewId(), studyId, gen),
- myHyp( gen->GetANewId(), studyId, gen)
+ TProjction2dAlgo(SMESH_Gen* gen)
+ : StdMeshers_Projection_1D2D( gen->GetANewId(), gen),
+ myHyp( gen->GetANewId(), gen)
{
StdMeshers_Projection_2D::_sourceHypo = & myHyp;
}
static TProjction2dAlgo* instance( SMESH_Algo* fatherAlgo )
{
- static TProjction2dAlgo* algo = new TProjction2dAlgo( fatherAlgo->GetStudyId(),
- fatherAlgo->GetGen() );
+ static TProjction2dAlgo* algo = new TProjction2dAlgo( fatherAlgo->GetGen() );
return algo;
}
const NSProjUtils::TNodeNodeMap& GetNodesMap()
//purpose :
//=======================================================================
-StdMeshers_Prism_3D::StdMeshers_Prism_3D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_Prism_3D::StdMeshers_Prism_3D(int hypId, SMESH_Gen* gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "Prism_3D";
_shapeType = (1 << TopAbs_SOLID); // 1 bit per shape type
//=======================================================================
//function : isSimpleQuad
- //purpose : check if the bottom FACE is meshable with nice qudrangles,
+ //purpose : check if the bottom FACE is meshable with nice quadrangles,
// if so the block aproach can work rather fast.
// This is a temporary mean caused by problems in StdMeshers_Sweeper
//=======================================================================
class StdMeshers_QuadFromMedialAxis_1D2D::Algo1D : public StdMeshers_Regular_1D
{
public:
- Algo1D(int studyId, SMESH_Gen* gen):
- StdMeshers_Regular_1D( gen->GetANewId(), studyId, gen )
+ Algo1D(SMESH_Gen* gen):
+ StdMeshers_Regular_1D( gen->GetANewId(), gen )
{
}
void SetSegmentLength( double len )
//================================================================================
StdMeshers_QuadFromMedialAxis_1D2D::StdMeshers_QuadFromMedialAxis_1D2D(int hypId,
- int studyId,
SMESH_Gen* gen)
- : StdMeshers_Quadrangle_2D(hypId, studyId, gen),
+ : StdMeshers_Quadrangle_2D(hypId, gen),
_regular1D( 0 )
{
_name = "QuadFromMedialAxis_1D2D";
theSinuEdges [0].size() > 0 && theSinuEdges [1].size() > 0 );
// the sinuous EDGEs can be composite and C0 continuous,
- // therefor we use a complex criterion to find TWO short non-sinuous EDGEs
+ // therefore we use a complex criterion to find TWO short non-sinuous EDGEs
// and the rest EDGEs will be treated as sinuous.
// A short edge should have the following features:
// a) straight
}
// cout << "from salome.geom import geomBuilder" << endl;
- // cout << "geompy = geomBuilder.New(salome.myStudy)" << endl;
+ // cout << "geompy = geomBuilder.New()" << endl;
Handle(TColgp_HArray1OfPnt) points = new TColgp_HArray1OfPnt(1, pnt.size());
for ( size_t i = 0; i < pnt.size(); ++i )
{
SMESH_MAT2d::MedialAxis ma( F, sinuFace._sinuEdges, minSegLen, /*ignoreCorners=*/true );
if ( !_regular1D )
- _regular1D = new Algo1D( _studyId, _gen );
+ _regular1D = new Algo1D( _gen );
_regular1D->SetSegmentLength( minSegLen );
vector<double> maParams;
#include "utilities.h"
#include "Utils_ExceptHandlers.hxx"
- #ifndef StdMeshers_Array2OfNode_HeaderFile
- #define StdMeshers_Array2OfNode_HeaderFile
- typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
- typedef NCollection_Array2<SMDS_MeshNodePtr> StdMeshers_Array2OfNode;
- #endif
+ #include <boost/container/flat_set.hpp>
- using namespace std;
+ typedef NCollection_Array2<const SMDS_MeshNode*> StdMeshers_Array2OfNode;
typedef gp_XY gp_UV;
typedef SMESH_Comment TComm;
+ using namespace std;
+
//=============================================================================
/*!
*
*/
//=============================================================================
-StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId,
+StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId,
SMESH_Gen* gen)
- : SMESH_2D_Algo(hypId, studyId, gen),
+ : SMESH_2D_Algo(hypId, gen),
myQuadranglePreference(false),
myTrianglePreference(false),
myTriaVertexID(-1),
continue;
}
- int nbNoDegenEdges = 0;
+ int nbNoDegenEdges = 0, totalNbEdges = 0;
TopExp_Explorer eExp( aFace, TopAbs_EDGE );
- for ( ; eExp.More() && nbNoDegenEdges < 3; eExp.Next() ) {
+ for ( ; eExp.More() && nbNoDegenEdges < 3; eExp.Next(), ++totalNbEdges ) {
if ( !SMESH_Algo::isDegenerated( TopoDS::Edge( eExp.Current() )))
++nbNoDegenEdges;
}
- if ( toCheckAll && nbNoDegenEdges < 3 ) return false;
- if ( !toCheckAll && nbNoDegenEdges >= 3 ) return true;
+ if ( toCheckAll && ( totalNbEdges < 4 && nbNoDegenEdges < 3 )) return false;
+ if ( !toCheckAll && ( totalNbEdges >= 4 || nbNoDegenEdges >= 3 )) return true;
}
return ( toCheckAll && nbFoundFaces != 0 );
}
}
}
}
- else
+ else //if ( !myHelper || !myHelper->IsRealSeam( edge ))
{
sideEdges.push_back( edge );
}
{
// "smooth" by computing node positions using 3D TFI and further projection
- int nbhoriz = quad->iSize;
- int nbvertic = quad->jSize;
+ list< FaceQuadStruct::Ptr >::iterator q = myQuadList.begin();
+ for ( ; q != myQuadList.end() ; ++q )
+ {
+ quad = *q;
+ int nbhoriz = quad->iSize;
+ int nbvertic = quad->jSize;
- SMESH_TNodeXYZ a0( quad->UVPt( 0, 0 ).node );
- SMESH_TNodeXYZ a1( quad->UVPt( nbhoriz-1, 0 ).node );
- SMESH_TNodeXYZ a2( quad->UVPt( nbhoriz-1, nbvertic-1 ).node );
- SMESH_TNodeXYZ a3( quad->UVPt( 0, nbvertic-1 ).node );
+ SMESH_TNodeXYZ a0( quad->UVPt( 0, 0 ).node );
+ SMESH_TNodeXYZ a1( quad->UVPt( nbhoriz-1, 0 ).node );
+ SMESH_TNodeXYZ a2( quad->UVPt( nbhoriz-1, nbvertic-1 ).node );
+ SMESH_TNodeXYZ a3( quad->UVPt( 0, nbvertic-1 ).node );
- for (int i = 1; i < nbhoriz-1; i++)
- {
- SMESH_TNodeXYZ p0( quad->UVPt( i, 0 ).node );
- SMESH_TNodeXYZ p2( quad->UVPt( i, nbvertic-1 ).node );
- for (int j = 1; j < nbvertic-1; j++)
+ for (int i = 1; i < nbhoriz-1; i++)
{
- SMESH_TNodeXYZ p1( quad->UVPt( nbhoriz-1, j ).node );
- SMESH_TNodeXYZ p3( quad->UVPt( 0, j ).node );
+ SMESH_TNodeXYZ p0( quad->UVPt( i, 0 ).node );
+ SMESH_TNodeXYZ p2( quad->UVPt( i, nbvertic-1 ).node );
+ for (int j = 1; j < nbvertic-1; j++)
+ {
+ SMESH_TNodeXYZ p1( quad->UVPt( nbhoriz-1, j ).node );
+ SMESH_TNodeXYZ p3( quad->UVPt( 0, j ).node );
- UVPtStruct& uvp = quad->UVPt( i, j );
+ UVPtStruct& uvp = quad->UVPt( i, j );
- gp_Pnt p = myHelper->calcTFI(uvp.x,uvp.y, a0,a1,a2,a3, p0,p1,p2,p3);
- gp_Pnt2d uv = surface->NextValueOfUV( uvp.UV(), p, 10*tol );
- gp_Pnt pnew = surface->Value( uv );
+ gp_Pnt p = myHelper->calcTFI(uvp.x,uvp.y, a0,a1,a2,a3, p0,p1,p2,p3);
+ gp_Pnt2d uv = surface->NextValueOfUV( uvp.UV(), p, 10*tol );
+ gp_Pnt pnew = surface->Value( uv );
- meshDS->MoveNode( uvp.node, pnew.X(), pnew.Y(), pnew.Z() );
- uvp.u = uv.X();
- uvp.v = uv.Y();
+ meshDS->MoveNode( uvp.node, pnew.X(), pnew.Y(), pnew.Z() );
+ uvp.u = uv.X();
+ uvp.v = uv.Y();
+ }
}
}
- return;
}
+ else
+ {
+ // Get nodes to smooth
- // Get nodes to smooth
-
- typedef map< const SMDS_MeshNode*, TSmoothNode, TIDCompare > TNo2SmooNoMap;
- TNo2SmooNoMap smooNoMap;
+ typedef map< const SMDS_MeshNode*, TSmoothNode, TIDCompare > TNo2SmooNoMap;
+ TNo2SmooNoMap smooNoMap;
- // fixed nodes
- set< const SMDS_MeshNode* > fixedNodes;
- for ( size_t i = 0; i < myForcedPnts.size(); ++i )
- {
- fixedNodes.insert( myForcedPnts[i].node );
- if ( myForcedPnts[i].node->getshapeId() != myHelper->GetSubShapeID() )
+ // fixed nodes
+ boost::container::flat_set< const SMDS_MeshNode* > fixedNodes;
+ for ( size_t i = 0; i < myForcedPnts.size(); ++i )
{
- TSmoothNode & sNode = smooNoMap[ myForcedPnts[i].node ];
- sNode._uv = myForcedPnts[i].uv;
- sNode._xyz = SMESH_TNodeXYZ( myForcedPnts[i].node );
+ fixedNodes.insert( myForcedPnts[i].node );
+ if ( myForcedPnts[i].node->getshapeId() != myHelper->GetSubShapeID() )
+ {
+ TSmoothNode & sNode = smooNoMap[ myForcedPnts[i].node ];
+ sNode._uv = myForcedPnts[i].uv;
+ sNode._xyz = SMESH_TNodeXYZ( myForcedPnts[i].node );
+ }
}
- }
- SMESHDS_SubMesh* fSubMesh = meshDS->MeshElements( quad->face );
- SMDS_NodeIteratorPtr nIt = fSubMesh->GetNodes();
- while ( nIt->more() ) // loop on nodes bound to a FACE
- {
- const SMDS_MeshNode* node = nIt->next();
- TSmoothNode & sNode = smooNoMap[ node ];
- sNode._uv = myHelper->GetNodeUV( quad->face, node );
- sNode._xyz = SMESH_TNodeXYZ( node );
- if ( fixedNodes.count( node ))
- continue; // fixed - no triangles
-
- // set sNode._triangles
- SMDS_ElemIteratorPtr fIt = node->GetInverseElementIterator( SMDSAbs_Face );
- while ( fIt->more() )
+ SMESHDS_SubMesh* fSubMesh = meshDS->MeshElements( quad->face );
+ SMDS_NodeIteratorPtr nIt = fSubMesh->GetNodes();
+ while ( nIt->more() ) // loop on nodes bound to a FACE
{
- const SMDS_MeshElement* face = fIt->next();
- const int nbN = face->NbCornerNodes();
- const int nInd = face->GetNodeIndex( node );
- const int prevInd = myHelper->WrapIndex( nInd - 1, nbN );
- const int nextInd = myHelper->WrapIndex( nInd + 1, nbN );
- const SMDS_MeshNode* prevNode = face->GetNode( prevInd );
- const SMDS_MeshNode* nextNode = face->GetNode( nextInd );
- sNode._triangles.push_back( TTriangle( & smooNoMap[ prevNode ],
- & smooNoMap[ nextNode ]));
- }
- }
- // set _uv of smooth nodes on FACE boundary
- set< StdMeshers_FaceSide* > sidesOnEdge;
- list< FaceQuadStruct::Ptr >::iterator q = myQuadList.begin();
- for ( ; q != myQuadList.end() ; ++q )
- for ( size_t i = 0; i < (*q)->side.size(); ++i )
- if ( ! (*q)->side[i].grid->Edge(0).IsNull() &&
- //(*q)->nbNodeOut( i ) == 0 &&
- sidesOnEdge.insert( (*q)->side[i].grid.get() ).second )
+ const SMDS_MeshNode* node = nIt->next();
+ TSmoothNode & sNode = smooNoMap[ node ];
+ sNode._uv = myHelper->GetNodeUV( quad->face, node );
+ sNode._xyz = SMESH_TNodeXYZ( node );
+ if ( fixedNodes.count( node ))
+ continue; // fixed - no triangles
+
+ // set sNode._triangles
+ SMDS_ElemIteratorPtr fIt = node->GetInverseElementIterator( SMDSAbs_Face );
+ while ( fIt->more() )
{
- const vector<UVPtStruct>& uvVec = (*q)->side[i].grid->GetUVPtStruct();
- for ( unsigned j = 0; j < uvVec.size(); ++j )
+ const SMDS_MeshElement* face = fIt->next();
+ const int nbN = face->NbCornerNodes();
+ const int nInd = face->GetNodeIndex( node );
+ const int prevInd = myHelper->WrapIndex( nInd - 1, nbN );
+ const int nextInd = myHelper->WrapIndex( nInd + 1, nbN );
+ const SMDS_MeshNode* prevNode = face->GetNode( prevInd );
+ const SMDS_MeshNode* nextNode = face->GetNode( nextInd );
+ sNode._triangles.push_back( TTriangle( & smooNoMap[ prevNode ],
+ & smooNoMap[ nextNode ]));
+ }
+ }
+ // set _uv of smooth nodes on FACE boundary
+ set< StdMeshers_FaceSide* > sidesOnEdge;
+ list< FaceQuadStruct::Ptr >::iterator q = myQuadList.begin();
+ for ( ; q != myQuadList.end() ; ++q )
+ for ( size_t i = 0; i < (*q)->side.size(); ++i )
+ if ( ! (*q)->side[i].grid->Edge(0).IsNull() &&
+ //(*q)->nbNodeOut( i ) == 0 &&
+ sidesOnEdge.insert( (*q)->side[i].grid.get() ).second )
{
- TSmoothNode & sNode = smooNoMap[ uvVec[j].node ];
- sNode._uv = uvVec[j].UV();
- sNode._xyz = SMESH_TNodeXYZ( uvVec[j].node );
+ const vector<UVPtStruct>& uvVec = (*q)->side[i].grid->GetUVPtStruct();
+ for ( unsigned j = 0; j < uvVec.size(); ++j )
+ {
+ TSmoothNode & sNode = smooNoMap[ uvVec[j].node ];
+ sNode._uv = uvVec[j].UV();
+ sNode._xyz = SMESH_TNodeXYZ( uvVec[j].node );
+ }
}
- }
- // define reference orientation in 2D
- TNo2SmooNoMap::iterator n2sn = smooNoMap.begin();
- for ( ; n2sn != smooNoMap.end(); ++n2sn )
- if ( !n2sn->second._triangles.empty() )
- break;
- if ( n2sn == smooNoMap.end() ) return;
- const TSmoothNode & sampleNode = n2sn->second;
- const bool refForward = ( sampleNode._triangles[0].IsForward( sampleNode._uv ));
+ // define reference orientation in 2D
+ TNo2SmooNoMap::iterator n2sn = smooNoMap.begin();
+ for ( ; n2sn != smooNoMap.end(); ++n2sn )
+ if ( !n2sn->second._triangles.empty() )
+ break;
+ if ( n2sn == smooNoMap.end() ) return;
+ const TSmoothNode & sampleNode = n2sn->second;
+ const bool refForward = ( sampleNode._triangles[0].IsForward( sampleNode._uv ));
- // Smoothing
+ // Smoothing
- for ( int iLoop = 0; iLoop < 5; ++iLoop )
- {
- for ( n2sn = smooNoMap.begin(); n2sn != smooNoMap.end(); ++n2sn )
+ for ( int iLoop = 0; iLoop < 5; ++iLoop )
{
- TSmoothNode& sNode = n2sn->second;
- if ( sNode._triangles.empty() )
- continue; // not movable node
+ for ( n2sn = smooNoMap.begin(); n2sn != smooNoMap.end(); ++n2sn )
+ {
+ TSmoothNode& sNode = n2sn->second;
+ if ( sNode._triangles.empty() )
+ continue; // not movable node
- gp_XY newUV;
- bool isValid = false;
- bool use3D = ( iLoop > 2 ); // 3 loops in 2D and 2, in 3D
+ gp_XY newUV;
+ bool isValid = false;
+ bool use3D = ( iLoop > 2 ); // 3 loops in 2D and 2, in 3D
- if ( use3D )
- {
- // compute a new XYZ
- gp_XYZ newXYZ (0,0,0);
- for ( size_t i = 0; i < sNode._triangles.size(); ++i )
- newXYZ += sNode._triangles[i]._n1->_xyz;
- newXYZ /= sNode._triangles.size();
-
- // compute a new UV by projection
- newUV = surface->NextValueOfUV( sNode._uv, newXYZ, 10*tol ).XY();
-
- // check validity of the newUV
- for ( size_t i = 0; i < sNode._triangles.size() && isValid; ++i )
- isValid = ( sNode._triangles[i].IsForward( newUV ) == refForward );
- }
- if ( !isValid )
- {
- // compute a new UV by averaging
- newUV.SetCoord(0.,0.);
- for ( unsigned i = 0; i < sNode._triangles.size(); ++i )
- newUV += sNode._triangles[i]._n1->_uv;
- newUV /= sNode._triangles.size();
-
- // check validity of the newUV
- isValid = true;
- for ( unsigned i = 0; i < sNode._triangles.size() && isValid; ++i )
- isValid = ( sNode._triangles[i].IsForward( newUV ) == refForward );
- }
- if ( isValid )
- {
- sNode._uv = newUV;
- sNode._xyz = surface->Value( newUV ).XYZ();
+ if ( use3D )
+ {
+ // compute a new XYZ
+ gp_XYZ newXYZ (0,0,0);
+ for ( size_t i = 0; i < sNode._triangles.size(); ++i )
+ newXYZ += sNode._triangles[i]._n1->_xyz;
+ newXYZ /= sNode._triangles.size();
+
+ // compute a new UV by projection
+ newUV = surface->NextValueOfUV( sNode._uv, newXYZ, 10*tol ).XY();
+
+ // check validity of the newUV
+ for ( size_t i = 0; i < sNode._triangles.size() && isValid; ++i )
+ isValid = ( sNode._triangles[i].IsForward( newUV ) == refForward );
+ }
+ if ( !isValid )
+ {
+ // compute a new UV by averaging
+ newUV.SetCoord(0.,0.);
+ for ( unsigned i = 0; i < sNode._triangles.size(); ++i )
+ newUV += sNode._triangles[i]._n1->_uv;
+ newUV /= sNode._triangles.size();
+
+ // check validity of the newUV
+ isValid = true;
+ for ( unsigned i = 0; i < sNode._triangles.size() && isValid; ++i )
+ isValid = ( sNode._triangles[i].IsForward( newUV ) == refForward );
+ }
+ if ( isValid )
+ {
+ sNode._uv = newUV;
+ sNode._xyz = surface->Value( newUV ).XYZ();
+ }
}
}
- }
- // Set new XYZ to the smoothed nodes
+ // Set new XYZ to the smoothed nodes
- for ( n2sn = smooNoMap.begin(); n2sn != smooNoMap.end(); ++n2sn )
- {
- TSmoothNode& sNode = n2sn->second;
- if ( sNode._triangles.empty() )
- continue; // not movable node
+ for ( n2sn = smooNoMap.begin(); n2sn != smooNoMap.end(); ++n2sn )
+ {
+ TSmoothNode& sNode = n2sn->second;
+ if ( sNode._triangles.empty() )
+ continue; // not movable node
- SMDS_MeshNode* node = const_cast< SMDS_MeshNode*>( n2sn->first );
- gp_Pnt xyz = surface->Value( sNode._uv );
- meshDS->MoveNode( node, xyz.X(), xyz.Y(), xyz.Z() );
+ SMDS_MeshNode* node = const_cast< SMDS_MeshNode*>( n2sn->first );
+ gp_Pnt xyz = surface->Value( sNode._uv );
+ meshDS->MoveNode( node, xyz.X(), xyz.Y(), xyz.Z() );
- // store the new UV
- node->SetPosition( SMDS_PositionPtr( new SMDS_FacePosition( sNode._uv.X(), sNode._uv.Y() )));
+ // store the new UV
+ node->SetPosition( SMDS_PositionPtr( new SMDS_FacePosition( sNode._uv.X(), sNode._uv.Y() )));
+ }
}
// Move medium nodes in quadratic mesh
meshDS->MoveNode( node, xyz.X(), xyz.Y(), xyz.Z() );
}
}
+ return;
}
//================================================================================
if ( myHelper->HasSeam() )
for ( int i = 0; i < nbN && !nInFace; ++i )
if ( !myHelper->IsSeamShape( nn[i]->getshapeId() ))
+ {
nInFace = nn[i];
+ gp_XY uv = myHelper->GetNodeUV( geomFace, nInFace );
+ if ( myHelper->IsOnSeam( uv ))
+ nInFace = NULL;
+ }
toCheckUV = true;
for ( int i = 0; i < nbN; ++i )
uv[ i ] = myHelper->GetNodeUV( geomFace, nn[i], nInFace, &toCheckUV );
+ bool isBad = false;
switch ( nbN ) {
case 4:
{
if ( sign1 * sign2 < 0 )
continue; // this should not happen
}
- if ( sign1 * okSign < 0 )
- badFaces.push_back ( f );
+ isBad = ( sign1 * okSign < 0 );
break;
}
case 3:
{
double sign = getArea( uv[0], uv[1], uv[2] );
- if ( sign * okSign < 0 )
- badFaces.push_back ( f );
+ isBad = ( sign * okSign < 0 );
break;
}
default:;
}
+
+ // if ( isBad && myHelper->HasRealSeam() )
+ // {
+ // // detect a case where a face intersects the seam
+ // for ( int iPar = 1; iPar < 3; ++iPar )
+ // if ( iPar & myHelper->GetPeriodicIndex() )
+ // {
+ // double min = uv[0].Coord( iPar ), max = uv[0].Coord( iPar );
+ // for ( int i = 1; i < nbN; ++i )
+ // {
+ // min = Min( min, uv[i].Coord( iPar ));
+ // max = Max( max, uv[i].Coord( iPar ));
+ // }
+ // }
+ // }
+ if ( isBad )
+ badFaces.push_back ( f );
}
if ( !badFaces.empty() )
if ( SMESH_Algo::isDegenerated( prevE ))
{
list<TopoDS_Edge>::reverse_iterator edge = ++theWire.rbegin();
- while ( SMESH_Algo::isDegenerated( *edge ))
+ while ( SMESH_Algo::isDegenerated( *edge ) /*|| helper.IsRealSeam( *edge )*/)
++edge;
if ( edge == theWire.rend() )
return false;
list<TopoDS_Edge>::iterator edge = theWire.begin();
for ( int iE = 0; edge != theWire.end(); ++edge, ++iE )
{
- if ( SMESH_Algo::isDegenerated( *edge ))
+ if ( SMESH_Algo::isDegenerated( *edge ) /*|| helper.IsRealSeam( *edge )*/)
{
++theNbDegenEdges;
continue;
{
d = Abs( idealLen - accuLength[ iEV ]);
- // take into account presence of a coresponding halfDivider
+ // take into account presence of a corresponding halfDivider
const double cornerWgt = 0.5 / nbSides;
const double vertexWgt = 0.25 / nbSides;
TGeoIndex hd = halfDivider[ evVec[ iEV ]];
#include "StdMeshers_RadialPrism_3D.hxx"
- #include <Basics_OCCTVersion.hxx>
-
#include "StdMeshers_ProjectionUtils.hxx"
#include "StdMeshers_NumberOfLayers.hxx"
#include "StdMeshers_LayerDistribution.hxx"
//purpose :
//=======================================================================
-StdMeshers_RadialPrism_3D::StdMeshers_RadialPrism_3D(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_RadialPrism_3D::StdMeshers_RadialPrism_3D(int hypId, SMESH_Gen* gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "RadialPrism_3D";
_shapeType = (1 << TopAbs_SOLID); // 1 bit per shape type
const int myID = -1000;
TNodeDistributor* myHyp = dynamic_cast<TNodeDistributor*>( aMesh.GetHypothesis( myID ));
if ( !myHyp )
- myHyp = new TNodeDistributor( myID, 0, aMesh.GetGen() );
+ myHyp = new TNodeDistributor( myID, aMesh.GetGen() );
return myHyp;
}
// -----------------------------------------------------------------------------
}
protected:
// -----------------------------------------------------------------------------
- TNodeDistributor( int hypId, int studyId, SMESH_Gen* gen)
- : StdMeshers_Regular_1D( hypId, studyId, gen)
+ TNodeDistributor( int hypId, SMESH_Gen* gen)
+ : StdMeshers_Regular_1D( hypId, gen)
{
}
// -----------------------------------------------------------------------------
//=======================================================================
StdMeshers_RadialQuadrangle_1D2D::StdMeshers_RadialQuadrangle_1D2D(int hypId,
- int studyId,
SMESH_Gen* gen)
- :StdMeshers_Quadrangle_2D( hypId, studyId, gen )
+ :StdMeshers_Quadrangle_2D( hypId, gen )
{
_name = "RadialQuadrangle_1D2D";
_shapeType = (1 << TopAbs_FACE); // 1 bit per shape type
const int myID = -1001;
TNodeDistributor* myHyp = dynamic_cast<TNodeDistributor*>( aMesh.GetHypothesis( myID ));
if ( !myHyp )
- myHyp = new TNodeDistributor( myID, 0, aMesh.GetGen() );
+ myHyp = new TNodeDistributor( myID, aMesh.GetGen() );
return myHyp;
}
// -----------------------------------------------------------------------------
return true;
}
// -----------------------------------------------------------------------------
- //! Make mesh on an adge using assigned 1d hyp or defaut nb of segments
+ //! Make mesh on an adge using assigned 1d hyp or default nb of segments
bool ComputeCircularEdge( SMESH_Mesh& aMesh,
const StdMeshers_FaceSidePtr& aSide )
{
return ok;
}
// -----------------------------------------------------------------------------
- //! Make mesh on an adge using assigned 1d hyp or defaut nb of segments
+ //! Make mesh on an adge using assigned 1d hyp or default nb of segments
bool EvaluateCircularEdge(SMESH_Mesh& aMesh,
const StdMeshers_FaceSidePtr aSide,
MapShapeNbElems& aResMap)
}
protected:
// -----------------------------------------------------------------------------
- TNodeDistributor( int hypId, int studyId, SMESH_Gen* gen)
- : StdMeshers_Regular_1D( hypId, studyId, gen)
+ TNodeDistributor( int hypId, SMESH_Gen* gen)
+ : StdMeshers_Regular_1D( hypId, gen)
{
}
// -----------------------------------------------------------------------------
//=============================================================================
StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId,
- int studyId,
SMESH_Gen * gen)
- :SMESH_1D_Algo( hypId, studyId, gen )
+ :SMESH_1D_Algo( hypId, gen )
{
_name = "Regular_1D";
_shapeType = (1 << TopAbs_EDGE);
double L = GCPnts_AbscissaPoint::Length( theC3d, *itU, l);
static StdMeshers_Regular_1D* auxAlgo = 0;
if ( !auxAlgo ) {
- auxAlgo = new StdMeshers_Regular_1D( _gen->GetANewId(), _studyId, _gen );
+ auxAlgo = new StdMeshers_Regular_1D( _gen->GetANewId(), _gen );
auxAlgo->_hypType = BEG_END_LENGTH;
}
auxAlgo->_value[ BEG_LENGTH_IND ] = Lm;
if ( !nFirst || !nLast )
return error( COMPERR_BAD_INPUT_MESH, "No node on vertex");
- // remove elements created by e.g. patern mapping (PAL21999)
+ // remove elements created by e.g. pattern mapping (PAL21999)
// CLEAN event is incorrectly ptopagated seemingly due to Propagation hyp
// so TEMPORARY solution is to clean the submesh manually
if (SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(theShape))
enum UIndex { U_TGT = 1, U_SRC, LEN_TGT };
const double theMinSmoothCosin = 0.1;
- const double theSmoothThickToElemSizeRatio = 0.3;
+ const double theSmoothThickToElemSizeRatio = 0.6;
const double theMinSmoothTriaAngle = 30;
const double theMinSmoothQuadAngle = 45;
gp_XY LastUV( const TopoDS_Face& F, _EdgesOnShape& eos, int which=-1 ) const;
bool IsOnEdge() const { return _2neibors; }
bool IsOnFace() const { return ( _nodes[0]->GetPosition()->GetDim() == 2 ); }
+ int BaseShapeDim() const { return _nodes[0]->GetPosition()->GetDim(); }
gp_XYZ Copy( _LayerEdge& other, _EdgesOnShape& eos, SMESH_MesherHelper& helper );
void SetCosin( double cosin );
void SetNormal( const gp_XYZ& n ) { _normal = n; }
+ void SetMaxLen( double l ) { _maxLen = l; }
int NbSteps() const { return _pos.size() - 1; } // nb inlation steps
bool IsNeiborOnEdge( const _LayerEdge* edge ) const;
void SetSmooLen( double len ) { // set _len at which smoothing is needed
void Append( const gp_Pnt& center, _LayerEdge* ledge )
{
+ if ( ledge->Is( _LayerEdge::MULTI_NORMAL ))
+ return;
if ( _curvaCenters.size() > 0 )
_segLength2.push_back( center.SquareDistance( _curvaCenters.back() ));
_curvaCenters.push_back( center );
void limitMaxLenByCurvature( _SolidData& data, SMESH_MesherHelper& helper );
void limitMaxLenByCurvature( _LayerEdge* e1, _LayerEdge* e2,
_EdgesOnShape& eos1, _EdgesOnShape& eos2,
- SMESH_MesherHelper& helper );
+ const bool isSmoothable );
bool updateNormals( _SolidData& data, SMESH_MesherHelper& helper, int stepNb, double stepSize );
bool updateNormalsOfConvexFaces( _SolidData& data,
SMESH_MesherHelper& helper,
return _eos._edges[ is2nd ? _eos._edges.size()-1 : 0 ]->_2neibors->_edges[ is2nd ];
}
bool isAnalytic() const { return !_anaCurve.IsNull(); }
+
+ void offPointsToPython() const; // debug
};
//--------------------------------------------------------------------------------
/*!
//================================================================================
// StdMeshers_ViscousLayers hypothesis
//
-StdMeshers_ViscousLayers::StdMeshers_ViscousLayers(int hypId, int studyId, SMESH_Gen* gen)
- :SMESH_Hypothesis(hypId, studyId, gen),
+StdMeshers_ViscousLayers::StdMeshers_ViscousLayers(int hypId, SMESH_Gen* gen)
+ :SMESH_Hypothesis(hypId, gen),
_isToIgnoreShapes(1), _nbLayers(1), _thickness(1), _stretchFactor(1),
_method( SURF_OFFSET_SMOOTH )
{
// look for two neighbor not in-FACE nodes of face
for ( int i = 0; i < 2; ++i )
{
- if ( nNext[i]->GetPosition()->GetDim() != 2 &&
- nNext[i]->GetID() < nodeOnEdge->GetID() )
+ if (( nNext[i]->GetPosition()->GetDim() != 2 ) &&
+ ( nodeOnEdge->GetPosition()->GetDim() == 0 || nNext[i]->GetID() < nodeOnEdge->GetID() ))
{
// look for an in-FACE node
for ( int iN = 0; iN < nbN; ++iN )
py = _pyStream = new ofstream(fname);
*py << "import SMESH" << endl
<< "from salome.smesh import smeshBuilder" << endl
- << "smesh = smeshBuilder.New(salome.myStudy)" << endl
- << "meshSO = smesh.GetCurrentStudy().FindObjectID('0:1:2:" << tag <<"')" << endl
+ << "smesh = smeshBuilder.New()" << endl
+ << "meshSO = salome.myStudy.FindObjectID('0:1:2:" << tag <<"')" << endl
<< "mesh = smesh.Mesh( meshSO.GetObject() )"<<endl;
theNbPyFunc = 0;
}
for ( TopoDS_Iterator vIt( edge ); vIt.More(); vIt.Next() )
{
TGeomID vID = getMeshDS()->ShapeToIndex( vIt.Value() );
- bool noShrinkV = false;
+ bool noShrinkV = false, noShrinkIfAdjMeshed = false;
if ( iSolid < _sdVec.size() )
{
i2S = _sdVec[i ]._shrinkShape2Shape.find( vID );
i2SAdj = _sdVec[iSolid]._shrinkShape2Shape.find( vID );
if ( i2SAdj == _sdVec[iSolid]._shrinkShape2Shape.end() )
- noShrinkV = ( i2S->second.ShapeType() == TopAbs_EDGE || isStructured );
+ noShrinkV = (( isStructured ) ||
+ ( noShrinkIfAdjMeshed = i2S->second.ShapeType() == TopAbs_EDGE ));
else
noShrinkV = ( ! i2S->second.IsSame( i2SAdj->second ));
}
else
{
// the adjacent SOLID has NO layers at all
- noShrinkV = ( isStructured ||
- _sdVec[i]._shrinkShape2Shape[ vID ].ShapeType() == TopAbs_EDGE );
+ if ( isStructured )
+ {
+ noShrinkV = true;
+ }
+ else
+ {
+ noShrinkV = noShrinkIfAdjMeshed =
+ ( _sdVec[i]._shrinkShape2Shape[ vID ].ShapeType() == TopAbs_EDGE );
+ }
+ }
+
+ if ( noShrinkV && noShrinkIfAdjMeshed )
+ {
+ // noShrinkV if FACEs in the adjacent SOLID are meshed
+ PShapeIteratorPtr fIt = helper.GetAncestors( _sdVec[i]._shrinkShape2Shape[ vID ],
+ *_mesh, TopAbs_FACE, &solid );
+ while ( fIt->more() )
+ {
+ const TopoDS_Shape* f = fIt->next();
+ if ( !f->IsSame( fWOL ))
+ {
+ noShrinkV = ! _mesh->GetSubMesh( *f )->IsEmpty();
+ break;
+ }
+ }
}
if ( noShrinkV )
_sdVec[i]._noShrinkShapes.insert( vID );
double curvature = Max( surfProp.MaxCurvature() * oriFactor,
surfProp.MinCurvature() * oriFactor );
if ( curvature > minCurvature )
- ledge->_maxLen = Min( ledge->_maxLen, 1. / curvature );
+ ledge->SetMaxLen( Min( ledge->_maxLen, 1. / curvature ));
}
}
}
for ( size_t j = 0; j < ledge->_simplices.size(); ++j )
if ( ledge->_simplices[j]._nNext->GetPosition()->GetDim() < 2 )
{
- convFace._simplexTestEdges.push_back( ledge );
+ // do not select _LayerEdge's neighboring sharp EDGEs
+ bool sharpNbr = false;
+ for ( size_t iN = 0; iN < ledge->_neibors.size() && !sharpNbr; ++iN )
+ sharpNbr = ( ledge->_neibors[iN]->_cosin > theMinSmoothCosin );
+ if ( !sharpNbr )
+ convFace._simplexTestEdges.push_back( ledge );
break;
}
}
// Find shapes needing smoothing; such a shape has _LayerEdge._normal on it's
// boundary inclined to the shape at a sharp angle
- //list< TGeomID > shapesToSmooth;
TopTools_MapOfShape edgesOfSmooFaces;
-
SMESH_MesherHelper helper( *_mesh );
bool ok = true;
continue;
double tgtThick = eos._hyp.GetTotalThickness();
- TopExp_Explorer eExp( edgesByGeom[iS]._shape, TopAbs_EDGE );
- for ( ; eExp.More() && !eos._toSmooth; eExp.Next() )
+ SMESH_subMeshIteratorPtr subIt = eos._subMesh->getDependsOnIterator(/*includeSelf=*/false );
+ while ( subIt->more() && !eos._toSmooth )
{
- TGeomID iE = getMeshDS()->ShapeToIndex( eExp.Current() );
- vector<_LayerEdge*>& eE = edgesByGeom[ iE ]._edges;
- if ( eE.empty() ) continue;
+ TGeomID iSub = subIt->next()->GetId();
+ const vector<_LayerEdge*>& eSub = edgesByGeom[ iSub ]._edges;
+ if ( eSub.empty() ) continue;
double faceSize;
- for ( size_t i = 0; i < eE.size() && !eos._toSmooth; ++i )
- if ( eE[i]->_cosin > theMinSmoothCosin )
+ for ( size_t i = 0; i < eSub.size() && !eos._toSmooth; ++i )
+ if ( eSub[i]->_cosin > theMinSmoothCosin )
{
- SMDS_ElemIteratorPtr fIt = eE[i]->_nodes[0]->GetInverseElementIterator(SMDSAbs_Face);
+ SMDS_ElemIteratorPtr fIt = eSub[i]->_nodes[0]->GetInverseElementIterator(SMDSAbs_Face);
while ( fIt->more() && !eos._toSmooth )
{
const SMDS_MeshElement* face = fIt->next();
if ( face->getshapeId() == eos._shapeID &&
- getDistFromEdge( face, eE[i]->_nodes[0], faceSize ))
+ getDistFromEdge( face, eSub[i]->_nodes[0], faceSize ))
{
- eos._toSmooth = needSmoothing( eE[i]->_cosin, tgtThick, faceSize );
+ eos._toSmooth = needSmoothing( eSub[i]->_cosin,
+ tgtThick * eSub[i]->_lenFactor,
+ faceSize);
}
}
}
}
if ( eos._toSmooth )
{
- for ( eExp.ReInit(); eExp.More(); eExp.Next() )
+ for ( TopExp_Explorer eExp( edgesByGeom[iS]._shape, TopAbs_EDGE ); eExp.More(); eExp.Next() )
edgesOfSmooFaces.Add( eExp.Current() );
data.PrepareEdgesToSmoothOnFace( &edgesByGeom[iS], /*substituteSrcNodes=*/false );
if ( endSeg->getshapeId() == (int) iS )
{
double segLen =
- SMESH_TNodeXYZ( endSeg->GetNode(0) ).Distance( endSeg->GetNode(1 ));
- eos._toSmooth = needSmoothing( cosinAbs, tgtThick, segLen );
+ SMESH_TNodeXYZ( endSeg->GetNode( 0 )).Distance( endSeg->GetNode( 1 ));
+ eos._toSmooth = needSmoothing( cosinAbs, tgtThick * eV[0]->_lenFactor, segLen );
}
}
if ( eos._toSmooth )
if ( !eos._hyp.ToSmooth() )
for ( size_t i = 0; i < eos._edges.size(); ++i )
- eos._edges[i]->SetCosin( 0 );
+ //eos._edges[i]->SetCosin( 0 ); // keep _cosin to use in limitMaxLenByCurvature()
+ eos._edges[i]->_lenFactor = 1;
}
{
_EdgesOnShape* eof = data.GetShapeEdges( *face );
if ( !eof ) continue; // other solid
- if ( !eos.HasC1( eoe ))
- {
- eos._eosC1.push_back( eoe );
- eoe->_toSmooth = false;
- data.PrepareEdgesToSmoothOnFace( eoe, /*substituteSrcNodes=*/false );
- }
- if ( eos._shapeID != eof->_shapeID && !eos.HasC1( eof ))
+ if ( eos._shapeID == eof->_shapeID ) continue;
+ if ( !eos.HasC1( eof ))
{
+ // check the FACEs
eos._eosC1.push_back( eof );
eof->_toSmooth = false;
data.PrepareEdgesToSmoothOnFace( eof, /*substituteSrcNodes=*/false );
smQueue.push_back( eof->_subMesh );
}
+ if ( !eos.HasC1( eoe ))
+ {
+ eos._eosC1.push_back( eoe );
+ eoe->_toSmooth = false;
+ data.PrepareEdgesToSmoothOnFace( eoe, /*substituteSrcNodes=*/false );
+ }
}
}
}
if ( eos.ShapeType() == TopAbs_FACE ) // get normals to elements on a FACE
{
SMESHDS_SubMesh* smDS = sm->GetSubMeshDS();
+ if ( !smDS ) return;
eos._faceNormals.resize( smDS->NbElements() );
SMDS_ElemIteratorPtr eIt = smDS->GetElements();
getMeshDS()->RemoveFreeNode( edge._nodes.back(), 0, /*fromGroups=*/false );
edge._nodes.resize( 1 );
edge._normal.SetCoord( 0,0,0 );
- edge._maxLen = 0;
+ edge.SetMaxLen( 0 );
}
// Set the rest data
{
if ( eos.ShapeType() != TopAbs_EDGE )
return;
+ if ( _curvature && Is( SMOOTHED_C1 ))
+ return;
gp_XYZ pos = SMESH_TNodeXYZ( _nodes[0] );
gp_XYZ vec1 = pos - SMESH_TNodeXYZ( n1 );
for ( size_t i = 0; i < eos._edges.size(); ++i )
{
if ( eos._edges[i]->Is( _LayerEdge::BLOCKED )) continue;
- eos._edges[i]->_maxLen = thinkness;
+ eos._edges[i]->SetMaxLen( thinkness );
eos._edges[i]->FindIntersection( *searcher, intersecDist, data._epsilon, eos, &face );
if ( intersecDist > 0 && face )
{
data._geomSize = Min( data._geomSize, intersecDist );
if ( !neighborFaces.count( face->getshapeId() ))
- eos._edges[i]->_maxLen = Min( thinkness, intersecDist / ( face->GetID() < 0 ? 3. : 2. ));
+ eos[i]->SetMaxLen( Min( thinkness, intersecDist / ( face->GetID() < 0 ? 3. : 2. )));
}
}
}
const SMDS_MeshElement* intFace = 0;
const SMDS_MeshElement* closestFace = 0;
_LayerEdge* le = 0;
+ bool is1stBlocked = true; // dbg
for ( size_t iS = 0; iS < data._edgesOnShape.size(); ++iS )
{
_EdgesOnShape& eos = data._edgesOnShape[ iS ];
continue;
// ignore intersection with intFace of an adjacent FACE
- if ( dist > 0 )
+ if ( dist > 0.1 * eos._edges[i]->_len )
{
bool toIgnore = false;
if ( eos._toSmooth )
if ( toBlockInfaltion &&
dist < ( eos._edges[i]->_len * theThickToIntersection ))
{
+ if ( is1stBlocked ) { is1stBlocked = false; // debug
+ dumpFunction(SMESH_Comment("blockIntersected") <<data._index<<"_InfStep"<<infStep);
+ }
eos._edges[i]->Set( _LayerEdge::INTERSECTED ); // not to intersect
eos._edges[i]->Block( data ); // not to inflate
} // loop on eos._edges
} // loop on data._edgesOnShape
+ if ( !is1stBlocked )
+ dumpFunctionEnd();
+
if ( closestFace && le )
{
#ifdef __myDEBUG
SMDS_MeshElement::iterator nIt = closestFace->begin_nodes();
- cout << "Shortest distance: _LayerEdge nodes: tgt " << le->_nodes.back()->GetID()
+ cout << "#Shortest distance: _LayerEdge nodes: tgt " << le->_nodes.back()->GetID()
<< " src " << le->_nodes[0]->GetID()<< ", intersection with face ("
<< (*nIt++)->GetID()<<" "<< (*nIt++)->GetID()<<" "<< (*nIt++)->GetID()
<< ") distance = " << distToIntersection<< endl;
try
{
- BRepOffsetAPI_MakeOffsetShape offsetMaker( eos._shape, -offset, Precision::Confusion() );
+ BRepOffsetAPI_MakeOffsetShape offsetMaker;
+ offsetMaker.PerformByJoin( eos._shape, -offset, Precision::Confusion() );
if ( !offsetMaker.IsDone() ) return;
TopExp_Explorer fExp( offsetMaker.Shape(), TopAbs_FACE );
{
if ( !_eos[i]->Is( _LayerEdge::TO_SMOOTH ))
{
- if ( needSmoothing( _leOnV[0]._cosin, _eos[i]->_len, _curveLen * _leParams[i] ) ||
- isToSmooth( i ))
+ if ( needSmoothing( _leOnV[0]._cosin,
+ _eos[i]->_len * leOnV[0]->_lenFactor, _curveLen * _leParams[i] ) ||
+ isToSmooth( i )
+ )
_eos[i]->Set( _LayerEdge::TO_SMOOTH );
else
break;
{
if ( !_eos[i]->Is( _LayerEdge::TO_SMOOTH ))
{
- if ( needSmoothing( _leOnV[1]._cosin, _eos[i]->_len, _curveLen * ( 1.-_leParams[i] )) ||
+ if ( needSmoothing( _leOnV[1]._cosin,
+ _eos[i]->_len * leOnV[1]->_lenFactor, _curveLen * ( 1.-_leParams[i] )) ||
isToSmooth( i ))
_eos[i]->Set( _LayerEdge::TO_SMOOTH );
else
if ( e[1]->Is( updatedOrBlocked )) _iSeg[1] = _offPoints.size()-2;
gp_Pnt pExtreme[2], pProj[2];
+ bool isProjected[2];
for ( int is2nd = 0; is2nd < 2; ++is2nd )
{
pExtreme[ is2nd ] = SMESH_TNodeXYZ( e[is2nd]->_nodes.back() );
int i = _iSeg[ is2nd ];
int di = is2nd ? -1 : +1;
- bool projected = false;
+ bool & projected = isProjected[ is2nd ];
+ projected = false;
double uOnSeg, distMin = Precision::Infinite(), dist, distPrev = 0;
int nbWorse = 0;
do {
gp_Vec vDiv0( pExtreme[0], pProj[0] );
gp_Vec vDiv1( pExtreme[1], pProj[1] );
double d0 = vDiv0.Magnitude();
- double d1 = vDiv1.Magnitude();
+ double d1 = isProjected[1] ? vDiv1.Magnitude() : 0;
if ( e[0]->Is( _LayerEdge::BLOCKED )) {
if ( e[0]->_normal * vDiv0.XYZ() < 0 ) e[0]->_len += d0;
else e[0]->_len -= d0;
// compute normalized length of the offset segments located between the projections
// ---------------------------------------------------------------------------------
+ // temporary replace extreme _offPoints by pExtreme
+ gp_XYZ opXYZ[2] = { _offPoints[ _iSeg[0] ]._xyz,
+ _offPoints[ _iSeg[1]+1 ]._xyz };
+ _offPoints[ _iSeg[0] ]._xyz = pExtreme[0].XYZ();
+ _offPoints[ _iSeg[1]+ 1]._xyz = pExtreme[1].XYZ();
+
size_t iSeg = 0, nbSeg = _iSeg[1] - _iSeg[0] + 1;
vector< double > len( nbSeg + 1 );
len[ iSeg++ ] = 0;
- len[ iSeg++ ] = pProj[ 0 ].Distance( _offPoints[ _iSeg[0]+1 ]._xyz )/* * e[0]->_lenFactor*/;
+ len[ iSeg++ ] = pProj[ 0 ].Distance( _offPoints[ _iSeg[0]+1 ]._xyz );
for ( size_t i = _iSeg[0]+1; i <= _iSeg[1]; ++i, ++iSeg )
{
len[ iSeg ] = len[ iSeg-1 ] + _offPoints[i].Distance( _offPoints[i+1] );
}
- len[ nbSeg ] -= pProj[ 1 ].Distance( _offPoints[ _iSeg[1]+1 ]._xyz )/* * e[1]->_lenFactor*/;
+ // if ( isProjected[ 1 ])
+ // len[ nbSeg ] -= pProj[ 1 ].Distance( _offPoints[ _iSeg[1]+1 ]._xyz );
+ // else
+ // len[ nbSeg ] += pExtreme[ 1 ].Distance( _offPoints[ _iSeg[1]+1 ]._xyz );
- // d0 *= e[0]->_lenFactor;
- // d1 *= e[1]->_lenFactor;
double fullLen = len.back() - d0 - d1;
for ( iSeg = 0; iSeg < len.size(); ++iSeg )
len[iSeg] = ( len[iSeg] - d0 ) / fullLen;
- // temporary replace extreme _offPoints by pExtreme
- gp_XYZ op[2] = { _offPoints[ _iSeg[0] ]._xyz,
- _offPoints[ _iSeg[1]+1 ]._xyz };
- _offPoints[ _iSeg[0] ]._xyz = pExtreme[0].XYZ();
- _offPoints[ _iSeg[1]+ 1]._xyz = pExtreme[1].XYZ();
-
// -------------------------------------------------------------
// distribute tgt nodes of _LayerEdge's between the projections
// -------------------------------------------------------------
dumpMove( tgtNode );
}
- _offPoints[ _iSeg[0] ]._xyz = op[0];
- _offPoints[ _iSeg[1]+1 ]._xyz = op[1];
+ _offPoints[ _iSeg[0] ]._xyz = opXYZ[0];
+ _offPoints[ _iSeg[1]+1 ]._xyz = opXYZ[1];
return true;
}
return norm / size;
}
+ //================================================================================
+ /*!
+ * \brief Writes a script creating a mesh composed of _offPoints
+ */
+ //================================================================================
+
+ void _Smoother1D::offPointsToPython() const
+ {
+ const char* fname = "/tmp/offPoints.py";
+ cout << "execfile('"<<fname<<"')"<<endl;
+ ofstream py(fname);
+ py << "import SMESH" << endl
+ << "from salome.smesh import smeshBuilder" << endl
+ << "smesh = smeshBuilder.New(salome.myStudy)" << endl
+ << "mesh = smesh.Mesh( 'offPoints' )"<<endl;
+ for ( size_t i = 0; i < _offPoints.size(); i++ )
+ {
+ py << "mesh.AddNode( "
+ << _offPoints[i]._xyz.X() << ", "
+ << _offPoints[i]._xyz.Y() << ", "
+ << _offPoints[i]._xyz.Z() << " )" << endl;
+ }
+ }
+
//================================================================================
/*!
* \brief Sort _LayerEdge's by a parameter on a given EDGE
}
// SetSmooLen() to _LayerEdge's on FACE
- for ( size_t i = 0; i < eos->_edges.size(); ++i )
- {
- eos->_edges[i]->SetSmooLen( Precision::Infinite() );
- }
- SMESH_subMeshIteratorPtr smIt = eos->_subMesh->getDependsOnIterator(/*includeSelf=*/false);
- while ( smIt->more() ) // loop on sub-shapes of the FACE
- {
- _EdgesOnShape* eoe = GetShapeEdges( smIt->next()->GetId() );
- if ( !eoe ) continue;
-
- vector<_LayerEdge*>& eE = eoe->_edges;
- for ( size_t iE = 0; iE < eE.size(); ++iE ) // loop on _LayerEdge's on EDGE or VERTEX
- {
- if ( eE[iE]->_cosin <= theMinSmoothCosin )
- continue;
+ // for ( size_t i = 0; i < eos->_edges.size(); ++i )
+ // {
+ // eos->_edges[i]->SetSmooLen( Precision::Infinite() );
+ // }
+ // SMESH_subMeshIteratorPtr smIt = eos->_subMesh->getDependsOnIterator(/*includeSelf=*/false);
+ // while ( smIt->more() ) // loop on sub-shapes of the FACE
+ // {
+ // _EdgesOnShape* eoe = GetShapeEdges( smIt->next()->GetId() );
+ // if ( !eoe ) continue;
- SMDS_ElemIteratorPtr segIt = eE[iE]->_nodes[0]->GetInverseElementIterator(SMDSAbs_Edge);
- while ( segIt->more() )
- {
- const SMDS_MeshElement* seg = segIt->next();
- if ( !eos->_subMesh->DependsOn( seg->getshapeId() ))
- continue;
- if ( seg->GetNode(0) != eE[iE]->_nodes[0] )
- continue; // not to check a seg twice
- for ( size_t iN = 0; iN < eE[iE]->_neibors.size(); ++iN )
- {
- _LayerEdge* eN = eE[iE]->_neibors[iN];
- if ( eN->_nodes[0]->getshapeId() != eos->_shapeID )
- continue;
- double dist = SMESH_MeshAlgos::GetDistance( seg, SMESH_TNodeXYZ( eN->_nodes[0] ));
- double smooLen = getSmoothingThickness( eE[iE]->_cosin, dist );
- eN->SetSmooLen( Min( smooLen, eN->GetSmooLen() ));
- eN->Set( _LayerEdge::NEAR_BOUNDARY );
- }
- }
- }
- }
+ // vector<_LayerEdge*>& eE = eoe->_edges;
+ // for ( size_t iE = 0; iE < eE.size(); ++iE ) // loop on _LayerEdge's on EDGE or VERTEX
+ // {
+ // if ( eE[iE]->_cosin <= theMinSmoothCosin )
+ // continue;
+
+ // SMDS_ElemIteratorPtr segIt = eE[iE]->_nodes[0]->GetInverseElementIterator(SMDSAbs_Edge);
+ // while ( segIt->more() )
+ // {
+ // const SMDS_MeshElement* seg = segIt->next();
+ // if ( !eos->_subMesh->DependsOn( seg->getshapeId() ))
+ // continue;
+ // if ( seg->GetNode(0) != eE[iE]->_nodes[0] )
+ // continue; // not to check a seg twice
+ // for ( size_t iN = 0; iN < eE[iE]->_neibors.size(); ++iN )
+ // {
+ // _LayerEdge* eN = eE[iE]->_neibors[iN];
+ // if ( eN->_nodes[0]->getshapeId() != eos->_shapeID )
+ // continue;
+ // double dist = SMESH_MeshAlgos::GetDistance( seg, SMESH_TNodeXYZ( eN->_nodes[0] ));
+ // double smooLen = getSmoothingThickness( eE[iE]->_cosin, dist );
+ // eN->SetSmooLen( Min( smooLen, eN->GetSmooLen() ));
+ // eN->Set( _LayerEdge::NEAR_BOUNDARY );
+ // }
+ // }
+ // }
+ // }
} // if ( eos->ShapeType() == TopAbs_FACE )
for ( size_t i = 0; i < eos->_edges.size(); ++i )
avgLen /= edge->_simplices.size();
if (( edge->_curvature = _Curvature::New( avgNormProj, avgLen )))
{
+ edge->Set( _LayerEdge::SMOOTHED_C1 );
isCurved = true;
SMDS_FacePosition* fPos = dynamic_cast<SMDS_FacePosition*>( edge->_nodes[0]->GetPosition() );
if ( !fPos )
if ( eI->_nodes[0]->GetID() < eN->_nodes[0]->GetID() ) // treat this pair once
{
_EdgesOnShape* eosN = data.GetShapeEdges( eN );
- limitMaxLenByCurvature( eI, eN, eosI, *eosN, helper );
+ limitMaxLenByCurvature( eI, eN, eosI, *eosN, eosI._hyp.ToSmooth() );
}
}
}
for ( size_t i = 1; i < eosI._edges.size(); ++i )
{
_LayerEdge* eI = eosI._edges[i];
- limitMaxLenByCurvature( eI, e0, eosI, eosI, helper );
+ limitMaxLenByCurvature( eI, e0, eosI, eosI, eosI._hyp.ToSmooth() );
e0 = eI;
}
}
*/
//================================================================================
- void _ViscousBuilder::limitMaxLenByCurvature( _LayerEdge* e1,
- _LayerEdge* e2,
- _EdgesOnShape& eos1,
- _EdgesOnShape& eos2,
- SMESH_MesherHelper& helper )
+ void _ViscousBuilder::limitMaxLenByCurvature( _LayerEdge* e1,
+ _LayerEdge* e2,
+ _EdgesOnShape& eos1,
+ _EdgesOnShape& eos2,
+ const bool isSmoothable )
{
+ if (( e1->_nodes[0]->GetPosition()->GetDim() !=
+ e2->_nodes[0]->GetPosition()->GetDim() ) &&
+ ( e1->_cosin < 0.75 ))
+ return; // angle > 90 deg at e1
+
gp_XYZ plnNorm = e1->_normal ^ e2->_normal;
double norSize = plnNorm.SquareModulus();
if ( norSize < std::numeric_limits<double>::min() )
double ovl = ( u1 * e1->_normal * dir12 -
u2 * e2->_normal * dir12 ) / dir12.SquareModulus();
if ( ovl > theSmoothThickToElemSizeRatio )
- {
- e1->_maxLen = Min( e1->_maxLen, 0.75 * u1 / e1->_lenFactor );
- e2->_maxLen = Min( e2->_maxLen, 0.75 * u2 / e2->_lenFactor );
+ {
+ const double coef = 0.75;
+ e1->SetMaxLen( Min( e1->_maxLen, coef * u1 / e1->_lenFactor ));
+ e2->SetMaxLen( Min( e2->_maxLen, coef * u2 / e2->_lenFactor ));
}
}
}
// else
// {
// double shortLen = 0.75 * ( Min( dist1, dist2 ) / edge->_lenFactor );
- // edge->_maxLen = Min( shortLen, edge->_maxLen );
+ // edge->SetMaxLen( Min( shortLen, edge->_maxLen ));
// }
}
e2neIt = edge2newEdge.insert( make_pair( edge1, zeroEdge )).first;
e2neIt->second._normal += distWgt * newNormal;
e2neIt->second._cosin = newCos;
- e2neIt->second._maxLen = 0.7 * minIntDist / edge1->_lenFactor;
+ e2neIt->second.SetMaxLen( 0.7 * minIntDist / edge1->_lenFactor );
if ( iter > 0 && sgn1 * sgn2 < 0 && edge1->_cosin < 0 )
e2neIt->second._normal += dir2;
if ( Precision::IsInfinite( zeroEdge._maxLen ))
{
e2neIt->second._cosin = edge2->_cosin;
- e2neIt->second._maxLen = 1.3 * minIntDist / edge1->_lenFactor;
+ e2neIt->second.SetMaxLen( 1.3 * minIntDist / edge1->_lenFactor );
}
if ( iter > 0 && sgn1 * sgn2 < 0 && edge2->_cosin < 0 )
e2neIt->second._normal += dir1;
if ( newEdge._maxLen < edge->_len && iter > 0 ) // limit _maxLen
{
edge->InvalidateStep( stepNb + 1, *eos, /*restoreLength=*/true );
- edge->_maxLen = newEdge._maxLen;
+ edge->SetMaxLen( newEdge._maxLen );
edge->SetNewLength( newEdge._maxLen, *eos, helper );
}
continue; // the new _normal is bad
SMESH_Comment msg( "#BLOCK shape=");
msg << data.GetShapeEdges( this )->_shapeID
<< ", nodes " << _nodes[0]->GetID() << ", " << _nodes.back()->GetID();
- dumpCmd( msg + " -- BEGIN")
+ dumpCmd( msg + " -- BEGIN");
- _maxLen = _len;
+ SetMaxLen( _len );
std::queue<_LayerEdge*> queue;
queue.push( this );
double newMaxLen = edge->_maxLen + 0.5 * Sqrt( minDist );
//if ( edge->_nodes[0]->getshapeId() == neibor->_nodes[0]->getshapeId() ) viscous_layers_00/A3
{
- newMaxLen *= edge->_lenFactor / neibor->_lenFactor;
+ //newMaxLen *= edge->_lenFactor / neibor->_lenFactor;
// newMaxLen *= Min( edge->_lenFactor / neibor->_lenFactor,
// neibor->_lenFactor / edge->_lenFactor );
}
if ( neibor->_maxLen > newMaxLen )
{
- neibor->_maxLen = newMaxLen;
+ neibor->SetMaxLen( newMaxLen );
if ( neibor->_maxLen < neibor->_len )
{
_EdgesOnShape* eos = data.GetShapeEdges( neibor );
+ int lastStep = neibor->Is( BLOCKED ) ? 1 : 0;
while ( neibor->_len > neibor->_maxLen &&
- neibor->NbSteps() > 0 )
+ neibor->NbSteps() > lastStep )
neibor->InvalidateStep( neibor->NbSteps(), *eos, /*restoreLength=*/true );
neibor->SetNewLength( neibor->_maxLen, *eos, data.GetHelper() );
//neibor->Block( data );
}
}
}
- dumpCmd( msg + " -- END")
+ dumpCmd( msg + " -- END");
}
//================================================================================
{
if ( NbSteps() == 0 )
_len = 0.;
+ else if ( IsOnFace() && Is( MOVED ))
+ _len = ( nXYZ.XYZ() - SMESH_NodeXYZ( _nodes[0] )) * _normal;
else
_len -= ( nXYZ.XYZ() - curXYZ ).Modulus() / _lenFactor;
}
}
+ return;
}
//================================================================================
int iSmoothed = GetSmoothedPos( tol );
if ( !iSmoothed ) return;
- //if ( 1 || Is( DISTORTED ))
+ gp_XYZ normal = _normal;
+ if ( Is( NORMAL_UPDATED ))
{
- gp_XYZ normal = _normal;
- if ( Is( NORMAL_UPDATED ))
+ double minDot = 1;
+ for ( size_t i = 0; i < _neibors.size(); ++i )
+ {
+ if ( _neibors[i]->IsOnFace() )
+ {
+ double dot = _normal * _neibors[i]->_normal;
+ if ( dot < minDot )
+ {
+ normal = _neibors[i]->_normal;
+ minDot = dot;
+ }
+ }
+ }
+ if ( minDot == 1. )
for ( size_t i = 1; i < _pos.size(); ++i )
{
normal = _pos[i] - _pos[0];
break;
}
}
- const double r = 0.2;
- for ( int iter = 0; iter < 50; ++iter )
- {
- double minDot = 1;
- for ( size_t i = Max( 1, iSmoothed-1-iter ); i < _pos.size()-1; ++i )
- {
- gp_XYZ midPos = 0.5 * ( _pos[i-1] + _pos[i+1] );
- gp_XYZ newPos = ( 1-r ) * midPos + r * _pos[i];
- _pos[i] = newPos;
- double midLen = 0.5 * ( segLen[i-1] + segLen[i+1] );
- double newLen = ( 1-r ) * midLen + r * segLen[i];
- const_cast< double& >( segLen[i] ) = newLen;
- // check angle between normal and (_pos[i+1], _pos[i] )
- gp_XYZ posDir = _pos[i+1] - _pos[i];
- double size = posDir.SquareModulus();
- if ( size > RealSmall() )
- minDot = Min( minDot, ( normal * posDir ) * ( normal * posDir ) / size );
- }
- if ( minDot > 0.5 * 0.5 )
- break;
+ }
+ const double r = 0.2;
+ for ( int iter = 0; iter < 50; ++iter )
+ {
+ double minDot = 1;
+ for ( size_t i = Max( 1, iSmoothed-1-iter ); i < _pos.size()-1; ++i )
+ {
+ gp_XYZ midPos = 0.5 * ( _pos[i-1] + _pos[i+1] );
+ gp_XYZ newPos = ( 1-r ) * midPos + r * _pos[i];
+ _pos[i] = newPos;
+ double midLen = 0.5 * ( segLen[i-1] + segLen[i+1] );
+ double newLen = ( 1-r ) * midLen + r * segLen[i];
+ const_cast< double& >( segLen[i] ) = newLen;
+ // check angle between normal and (_pos[i+1], _pos[i] )
+ gp_XYZ posDir = _pos[i+1] - _pos[i];
+ double size = posDir.SquareModulus();
+ if ( size > RealSmall() )
+ minDot = Min( minDot, ( normal * posDir ) * ( normal * posDir ) / size );
}
+ if ( minDot > 0.5 * 0.5 )
+ break;
}
- // else
- // {
- // for ( size_t i = 1; i < _pos.size()-1; ++i )
- // {
- // if ((int) i < iSmoothed && ( segLen[i] / segLen.back() < 0.5 ))
- // continue;
-
- // double wgt = segLen[i] / segLen.back();
- // gp_XYZ normPos = _pos[0] + _normal * wgt * _len;
- // gp_XYZ tgtPos = ( 1 - wgt ) * _pos[0] + wgt * _pos.back();
- // gp_XYZ newPos = ( 1 - wgt ) * normPos + wgt * tgtPos;
- // _pos[i] = newPos;
- // }
- // }
+ return;
}
//================================================================================
return dump;
}
+
//================================================================================
/*!
- case brief:
- default:
- */
+ * \brief Create layers of prisms
+ */
//================================================================================
bool _ViscousBuilder::refine(_SolidData& data)
surface = helper.GetSurface( geomFace );
// propagate _toSmooth back to _eosC1, which was unset in findShapesToSmooth()
for ( size_t i = 0; i < eos._eosC1.size(); ++i )
- {
eos._eosC1[ i ]->_toSmooth = true;
- for ( size_t j = 0; j < eos._eosC1[i]->_edges.size(); ++j )
- eos._eosC1[i]->_edges[j]->Set( _LayerEdge::SMOOTHED_C1 );
- }
+
isTooConvexFace = false;
if ( _ConvexFace* cf = data.GetConvexFace( eos._shapeID ))
isTooConvexFace = cf->_isTooCurved;
const SMDS_MeshNode* tgtN0 = ledges[0]->_nodes.back();
const SMDS_MeshNode* tgtN1 = ledges[1]->_nodes.back();
int nbSharedPyram = 0;
- SMDS_ElemIteratorPtr vIt = tgtN0->GetInverseElementIterator(SMDSAbs_Volume);
+ SMDS_ElemIteratorPtr vIt = tgtN1->GetInverseElementIterator(SMDSAbs_Volume);
while ( vIt->more() )
{
const SMDS_MeshElement* v = vIt->next();
- nbSharedPyram += int( v->GetNodeIndex( tgtN1 ) >= 0 );
+ nbSharedPyram += int( v->GetNodeIndex( tgtN0 ) >= 0 );
}
if ( nbSharedPyram > 1 )
continue; // not free border of the pyramid
class MacObject:
- """
- This represents a python class definition which contains
- all necessary information about the macro object being created
- in Salome
- """
+ """
+ This represents a python class definition which contains
+ all necessary information about the macro object being created
+ in Salome
+ """
- def __init__( self, ObjectType, GeoParameters, MeshParameters, **args ):
- """
- Initializes the macro object to be created, saves parameters inside of it, checks for neighboring objects,
- determines meshing parameters if necessary and finally launches the generation process.
- """
- import Config,GenFunctions
- if Config.debug : print "Initializing object No. " + str(len(Config.ListObj)+1)
+ def __init__( self, ObjectType, GeoParameters, MeshParameters, **args ):
+ """
+ Initializes the macro object to be created, saves parameters inside of it, checks for neighboring objects,
+ determines meshing parameters if necessary and finally launches the generation process.
+ """
+ import Config,GenFunctions
+ if Config.debug : print("Initializing object No. " + str(len(Config.ListObj)+1))
- if 'publish' in args :
- if args['publish']==0 : Config.publish = 0
- else : Config.publish = 1
- else : Config.publish = 1
-
- if 'groups' in args :
- self.GroupNames = args['groups']
- for group in args['groups'] :
- if not(group in Config.Groups) and group : Config.Groups.append(group)
- else : self.GroupNames = [None, None, None, None]
-
- if ObjectType == 'NonOrtho':
- if not(len(GeoParameters)==4): print "Error: trying to construct a non-ortho object but the 4 constitutive vertices are not given!"
- else :
- Xmin = min([GeoParameters[i][0] for i in range(4)])
- Xmax = max([GeoParameters[i][0] for i in range(4)])
- Ymin = min([GeoParameters[i][1] for i in range(4)])
- Ymax = max([GeoParameters[i][1] for i in range(4)])
- self.GeoPar = [(0.5*(Xmin+Xmax),0.5*(Ymin+Ymax)),(Xmax-Xmin,Ymax-Ymin)]
- self.PtCoor = GenFunctions.SortPoints(GeoParameters)
- else:
- self.GeoPar = GeoParameters
- [Xmin,Ymin,Xmax,Ymax] = [ self.GeoPar[0][0]-0.5*self.GeoPar[1][0], self.GeoPar[0][1]-0.5*self.GeoPar[1][1] ] + [ self.GeoPar[0][0]+0.5*self.GeoPar[1][0], self.GeoPar[0][1]+0.5*self.GeoPar[1][1] ]
- self.PtCoor = [(Xmin,Ymin),(Xmax,Ymin),(Xmax,Ymax),(Xmin,Ymax)]
-
- self.Type = ObjectType
- self.LowBound = [ self.GeoPar[0][0]-0.5*self.GeoPar[1][0], self.GeoPar[0][1]-0.5*self.GeoPar[1][1] ]
- self.UpperBound = [ self.GeoPar[0][0]+0.5*self.GeoPar[1][0], self.GeoPar[0][1]+0.5*self.GeoPar[1][1] ]
- self.MeshPar = MeshParameters
- self.GeoChildren = []
- self.GeoChildrenNames = []
- self.Mesh = []
- self.MeshGroups = []
- self.CheckInterfaces()
- if 'auto' in MeshParameters : self.AutoParam()
- if not(self.MeshPar[0]<0): self.Generate()
- else :
- Config.ListObj.append(self)
- print("Aborting object creation\n ")
+ if 'publish' in args :
+ if args['publish']==0 : Config.publish = 0
+ else : Config.publish = 1
+ else : Config.publish = 1
- def Generate(self) :
- """
- This method generates the geometrical object with the corresponding mesh once all verifications (CheckInterfaces and AutoParam)
- have been accomplished
- """
- import GenFunctions, Alarms, Config
- self = {'Box11' : lambda : GenFunctions.Box11(self),
- 'Box42' : lambda : GenFunctions.Box42(self),
- 'BoxAng32' : lambda : GenFunctions.BoxAng32(self),
- 'CompBox' : lambda : GenFunctions.CompBox(self),
- 'CompBoxF' : lambda : GenFunctions.CompBoxF(self),
- 'NonOrtho' : lambda : GenFunctions.NonOrtho(self),
- 'QuartCyl' : lambda : GenFunctions.QuartCyl(self) }[self.Type]()
+ if 'groups' in args :
+ self.GroupNames = args['groups']
+ for group in args['groups'] :
+ if not(group in Config.Groups) and group : Config.Groups.append(group)
+ else : self.GroupNames = [None, None, None, None]
- if Config.debug : Alarms.Message(self.status) # notification on the result of the generation algorithm
-
+ if ObjectType == 'NonOrtho':
+ if not(len(GeoParameters)==4): print("Error: trying to construct a non-ortho object but the 4 constitutive vertices are not given!")
+ else :
+ Xmin = min([GeoParameters[i][0] for i in range(4)])
+ Xmax = max([GeoParameters[i][0] for i in range(4)])
+ Ymin = min([GeoParameters[i][1] for i in range(4)])
+ Ymax = max([GeoParameters[i][1] for i in range(4)])
+ self.GeoPar = [(0.5*(Xmin+Xmax),0.5*(Ymin+Ymax)),(Xmax-Xmin,Ymax-Ymin)]
+ self.PtCoor = GenFunctions.SortPoints(GeoParameters)
+ else:
+ self.GeoPar = GeoParameters
+ [Xmin,Ymin,Xmax,Ymax] = [ self.GeoPar[0][0]-0.5*self.GeoPar[1][0], self.GeoPar[0][1]-0.5*self.GeoPar[1][1] ] + [ self.GeoPar[0][0]+0.5*self.GeoPar[1][0], self.GeoPar[0][1]+0.5*self.GeoPar[1][1] ]
+ self.PtCoor = [(Xmin,Ymin),(Xmax,Ymin),(Xmax,Ymax),(Xmin,Ymax)]
- def CheckInterfaces(self):
- """
- This method searches for neighbours for the object being created and saves them inside the Config.Connections
- array. This array contains 4 entries per object corresponding to West, East, South, and North neighbours.
- Note that an object may have more than one neighbour for a given direction.
- """
- import Alarms, Config
- from GenFunctions import AddIfDifferent
- from CompositeBox import FindCommonSide
-
- Config.Connections.append([(-1,),(-1,),(-1,),(-1,)])
- itemID = len(Config.ListObj)
- # In all cases except non ortho, PrincipleBoxes is unitary and contains the box in question
- # In the non-ortho case it contains all possible combinations of boxes with 3 vertices
- PrincipleBoxes = self.PrincipleBoxes()
- for i, TestObj in enumerate(Config.ListObj):
- SecondaryBoxes = TestObj.PrincipleBoxes()
- ConnX = 0
- ConnY = 0
- for Box0 in PrincipleBoxes:
- for Box1 in SecondaryBoxes:
- # Along X
- CenterDis = abs(Box1[0][0]-Box0[0][0])
- Extension = 0.5*(Box1[1][0]+Box0[1][0])
- if CenterDis - Extension < -1e-7 :
- ConnX = -1
- elif CenterDis - Extension < 1e-7 :
- if not(FindCommonSide(self.DirBoundaries(2),TestObj.DirBoundaries(3))==[0,0]) and Box1[0][0] < Box0[0][0] : ConnX = 1
- elif not(FindCommonSide(self.DirBoundaries(3),TestObj.DirBoundaries(2))==[0,0]) and Box1[0][0] >= Box0[0][0]: ConnX = 2
- else : ConnX = 0
-
- # Along Y
- CenterDis = abs(Box1[0][1]-Box0[0][1])
- Extension = 0.5*(Box1[1][1]+Box0[1][1])
- if CenterDis - Extension < -1e-7 :
- ConnY = -1
- elif CenterDis - Extension < 1e-7 :
- if not(FindCommonSide(self.DirBoundaries(0),TestObj.DirBoundaries(1))==[0,0]) and Box1[0][1] < Box0[0][1] : ConnY = 1
- elif not(FindCommonSide(self.DirBoundaries(1),TestObj.DirBoundaries(0))==[0,0]) and Box1[0][1] >= Box0[0][1]: ConnY = 2
- else : ConnY = 0
+ self.Type = ObjectType
+ self.LowBound = [ self.GeoPar[0][0]-0.5*self.GeoPar[1][0], self.GeoPar[0][1]-0.5*self.GeoPar[1][1] ]
+ self.UpperBound = [ self.GeoPar[0][0]+0.5*self.GeoPar[1][0], self.GeoPar[0][1]+0.5*self.GeoPar[1][1] ]
+ self.MeshPar = MeshParameters
+ self.GeoChildren = []
+ self.GeoChildrenNames = []
+ self.Mesh = []
+ self.MeshGroups = []
+ self.CheckInterfaces()
+ if 'auto' in MeshParameters : self.AutoParam()
+ if not(self.MeshPar[0]<0): self.Generate()
+ else :
+ Config.ListObj.append(self)
+ print("Aborting object creation\n ")
- if not (ConnX*ConnY == 0) :
- if max(ConnX,ConnY) == -1 and not('NonOrtho' in [self.Type,TestObj.Type]) : Alarms.Message(3)
- else:
- if ConnX == 1 and ConnY == -1:
- if Config.Connections[i][1] == (-1,) : Config.Connections[i][1] = (itemID,)
- else : Config.Connections[i][1] = AddIfDifferent(Config.Connections[i][1],itemID)
- if Config.Connections[itemID][0] == (-1,) : Config.Connections[itemID][0] = (i,)
- else : Config.Connections[itemID][0] = AddIfDifferent(Config.Connections[itemID][0],i)
- elif ConnX == 2 and ConnY == -1:
- if Config.Connections[i][0] == (-1,) : Config.Connections[i][0] = (itemID,)
- else : Config.Connections[i][0] = AddIfDifferent(Config.Connections[i][0],itemID)
- if Config.Connections[itemID][1] == (-1,) : Config.Connections[itemID][1] = (i,)
- else : Config.Connections[itemID][1] = AddIfDifferent(Config.Connections[itemID][1],i)
- elif ConnY == 1 and ConnX == -1:
- if Config.Connections[i][3] == (-1,) : Config.Connections[i][3] = (itemID,)
- else : Config.Connections[i][3] = AddIfDifferent(Config.Connections[i][3],itemID)
- if Config.Connections[itemID][2] == (-1,) : Config.Connections[itemID][2] = (i,)
- else : Config.Connections[itemID][2] = AddIfDifferent(Config.Connections[itemID][2],i)
- elif ConnY ==2 and ConnX == -1:
- if Config.Connections[i][2] == (-1,) : Config.Connections[i][2] = (itemID,)
- else : Config.Connections[i][2] = AddIfDifferent(Config.Connections[i][2],itemID)
- if Config.Connections[itemID][3] == (-1,) : Config.Connections[itemID][3] = (i,)
- else : Config.Connections[itemID][3] = AddIfDifferent(Config.Connections[itemID][3],i)
+ def Generate(self) :
+ """
+ This method generates the geometrical object with the corresponding mesh once all verifications (CheckInterfaces and AutoParam)
+ have been accomplished
+ """
+ import GenFunctions, Alarms, Config
+ self = {'Box11' : lambda : GenFunctions.Box11(self),
+ 'Box42' : lambda : GenFunctions.Box42(self),
+ 'BoxAng32' : lambda : GenFunctions.BoxAng32(self),
+ 'CompBox' : lambda : GenFunctions.CompBox(self),
+ 'CompBoxF' : lambda : GenFunctions.CompBoxF(self),
+ 'NonOrtho' : lambda : GenFunctions.NonOrtho(self),
+ 'QuartCyl' : lambda : GenFunctions.QuartCyl(self) }[self.Type]()
- def AutoParam (self):
- """
- This method is called only if the 'auto' keyword is used inside the meshing algorithm. It is based on the
- connection results per object and tries to find the correct parameters for obtaining a final compatible mesh
- between the objects already present and the one being created. If this is not possible, the method gives an error
- message.
- """
- import Alarms, Config, GenFunctions, CompositeBox
- MeshPar = [0,0,0,0] # initialize the mesh parameter value to be used to -1
- [(X0,Y0),(DX,DY)] = self.GeoPar
- ObjectsInvolved = []
- for i, Conn in enumerate(Config.Connections[-1]):
- if not ( Conn == (-1,) ): # Meaning that there is one or more neighbors on this direction
- for ObjID in Conn :
- ToLook0 = [2,3,0,1][i]
- ToLook1 = [3,2,1,0][i]
- CommonSide = CompositeBox.FindCommonSide(Config.ListObj[ObjID].DirBoundaries(ToLook1),self.DirBoundaries(ToLook0))
- #print "Common Side is:", CommonSide
- ToLook2 = [1,0,3,2][i]
- #print "Full Side is:", CompositeBox.IntLen(Config.ListObj[ObjID].DirBoundaries(ToLook1))
- #print "Full Segments on this direction are:", Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]
- RealSegments = round(Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]*CompositeBox.IntLen(CommonSide)/CompositeBox.IntLen(Config.ListObj[ObjID].DirBoundaries(ToLook1)))
- #print "RealSegments :", RealSegments
-
- MeshPar[i] = MeshPar[i] + RealSegments
- ObjectsInvolved.append(ObjID+1)
- self.DirectionalMeshParams = MeshPar
- self.MeshPar[0] = GenFunctions.CompatibilityTest(self)
+ if Config.debug : Alarms.Message(self.status) # notification on the result of the generation algorithm
- if self.MeshPar[0] < 0 :
- Alarms.Message(4)
- if self.MeshPar[0] == -1 : print ("Problem encountered with object(s) no. "+str(ObjectsInvolved))
- elif self.MeshPar[0] == -2 : print ("This object has no neighbours !!!")
- def Boundaries (self):
- """
- This method returns the global boundaries of the MacObject. [Xmin,Xmax,Ymin,Ymax]
- """
- Xmin = min([self.DirBoundaries(i)[0] for i in [0,1]])
- Xmax = max([self.DirBoundaries(i)[1] for i in [0,1]])
- Ymin = min([self.DirBoundaries(i)[0] for i in [2,3]])
- Ymax = max([self.DirBoundaries(i)[1] for i in [2,3]])
-
- return [Xmin,Xmax,Ymin,Ymax]
-
- def DirBoundaries (self, Direction):
- """
- This method returns a single interval giving [Xmin,Xmax] or [Ymin,Ymax] according to the required direction.
- This works particularly well for nonorthogonal objects.
- Direction : [0,1,2,3] <=> [South, North, West, East]
- """
- PtCoor = self.PtCoor
- PtCoor.append(self.PtCoor[0])
- if type(Direction) is str :
- Dir = { 'South' : lambda : 0,
- 'North' : lambda : 1,
- 'West' : lambda : 2,
- 'East' : lambda : 3,}[Direction]()
- else : Dir = int(Direction)
-
- PtIndex = [0,2,3,1][Dir]
- DirIndex = [0,0,1,1][Dir]
-
- return sorted([PtCoor[PtIndex][DirIndex],PtCoor[PtIndex+1][DirIndex]])
- def DirVectors (self, Direction):
- """
- This method returns for a given object, the real vectors which define a given direction
- The interest in using this method is for non-orthogonal objects where the sides can be
- deviated from the orthogonal basis vectors
- """
- if type(Direction) is str :
- Dir = { 'South' : lambda : 0,
- 'North' : lambda : 1,
- 'West' : lambda : 2,
- 'East' : lambda : 3,}[Direction]()
- else : Dir = int(Direction)
- PtCoor = self.PtCoor
- PtCoor.append(self.PtCoor[0])
- PtIndex = [0,2,3,1][Dir]
- return [PtCoor[PtIndex+1][0]-PtCoor[PtIndex][0],PtCoor[PtIndex+1][1]-PtCoor[PtIndex][1],0.]
-
- def GetBorder (self, Criterion):
- import GenFunctions, Config
+ def CheckInterfaces(self):
+ """
+ This method searches for neighbours for the object being created and saves them inside the Config.Connections
+ array. This array contains 4 entries per object corresponding to West, East, South, and North neighbours.
+ Note that an object may have more than one neighbour for a given direction.
+ """
+ import Alarms, Config
+ from GenFunctions import AddIfDifferent
+ from CompositeBox import FindCommonSide
- from salome.geom import geomBuilder
- geompy = geomBuilder.New( Config.theStudy )
-
- if type(Criterion) is str :
- Crit = {'South' : lambda : 0,
- 'North' : lambda : 1,
- 'West' : lambda : 2,
- 'East' : lambda : 3,}[Criterion]()
- else : Crit = int(Criterion)
-
- AcceptedObj = []
- if Crit < 4 :
- Boundaries = self.Boundaries()
- Research = {0 : lambda : [self.DirVectors(0),1,Boundaries[2]],
- 1 : lambda : [self.DirVectors(1),1,Boundaries[3]],
- 2 : lambda : [self.DirVectors(2),0,Boundaries[0]],
- 3 : lambda : [self.DirVectors(3),0,Boundaries[1]], }[Crit]()
-
- for i,ElemObj in enumerate(self.GeoChildren):
- EdgeIDs = geompy.ExtractShapes(ElemObj,6)# List of Edge IDs belonging to ElemObj
- for Edge in EdgeIDs:
- if GenFunctions.IsParallel(Edge,Research[0]):
- if abs( geompy.PointCoordinates(geompy.GetVertexByIndex(Edge,0))[Research[1]] - Research[2] )< 1e-6 or abs( geompy.PointCoordinates(geompy.GetVertexByIndex(Edge,1))[Research[1]] - Research[2] )< 1e-6 :
- AcceptedObj.append(Edge)
- else :
- CenterSrchPar = {'NE' : lambda : [-1., -1.],
- 'NW' : lambda : [ 1., -1.],
- 'SW' : lambda : [ 1., 1.],
- 'SE' : lambda : [-1., 1.], }[self.MeshPar[1]]()
- Radius = self.GeoPar[1][1]*float(self.MeshPar[2])/(self.MeshPar[2]+1)
- Center = (self.GeoPar[0][0]+CenterSrchPar[0]*self.GeoPar[1][0]/2.,self.GeoPar[0][1]+CenterSrchPar[1]*self.GeoPar[1][1]/2.,0.)
- for i,ElemObj in enumerate(self.GeoChildren):
- EdgeIDs = geompy.ExtractShapes(ElemObj,6)# List of Edge IDs belonging to ElemObj
- for Edge in EdgeIDs:
- if GenFunctions.IsOnCircle(Edge,Center,Radius):
- AcceptedObj.append(Edge)
- return AcceptedObj
+ Config.Connections.append([(-1,),(-1,),(-1,),(-1,)])
+ itemID = len(Config.ListObj)
+ # In all cases except non ortho, PrincipleBoxes is unitary and contains the box in question
+ # In the non-ortho case it contains all possible combinations of boxes with 3 vertices
+ PrincipleBoxes = self.PrincipleBoxes()
+ for i, TestObj in enumerate(Config.ListObj):
+ SecondaryBoxes = TestObj.PrincipleBoxes()
+ ConnX = 0
+ ConnY = 0
+ for Box0 in PrincipleBoxes:
+ for Box1 in SecondaryBoxes:
+ # Along X
+ CenterDis = abs(Box1[0][0]-Box0[0][0])
+ Extension = 0.5*(Box1[1][0]+Box0[1][0])
+ if CenterDis - Extension < -1e-7 :
+ ConnX = -1
+ elif CenterDis - Extension < 1e-7 :
+ if not(FindCommonSide(self.DirBoundaries(2),TestObj.DirBoundaries(3))==[0,0]) and Box1[0][0] < Box0[0][0] : ConnX = 1
+ elif not(FindCommonSide(self.DirBoundaries(3),TestObj.DirBoundaries(2))==[0,0]) and Box1[0][0] >= Box0[0][0]: ConnX = 2
+ else : ConnX = 0
- def PrincipleBoxes (self):
- """
- This function returns all possible combination rectangular shape objects that can contain at least 3 of the principle vertices
- constituting the MacObject. This is indispensable for the Non-ortho types and shall return a number of 24 possible combinations
- """
- from itertools import combinations
- Boxes = []
- if self.Type == 'NonOrtho':
- for combi in combinations(range(4),3):
- Xmin = min([self.PtCoor[i][0] for i in combi])
- Xmax = max([self.PtCoor[i][0] for i in combi])
- Ymin = min([self.PtCoor[i][1] for i in combi])
- Ymax = max([self.PtCoor[i][1] for i in combi])
- Boxes.append([(0.5*(Xmin+Xmax),0.5*(Ymin+Ymax)),(Xmax-Xmin,Ymax-Ymin)])
- else :
- Boxes = [self.GeoPar]
-
- return Boxes
-
-
+ # Along Y
+ CenterDis = abs(Box1[0][1]-Box0[0][1])
+ Extension = 0.5*(Box1[1][1]+Box0[1][1])
+ if CenterDis - Extension < -1e-7 :
+ ConnY = -1
+ elif CenterDis - Extension < 1e-7 :
+ if not(FindCommonSide(self.DirBoundaries(0),TestObj.DirBoundaries(1))==[0,0]) and Box1[0][1] < Box0[0][1] : ConnY = 1
+ elif not(FindCommonSide(self.DirBoundaries(1),TestObj.DirBoundaries(0))==[0,0]) and Box1[0][1] >= Box0[0][1]: ConnY = 2
+ else : ConnY = 0
+
+ if not (ConnX*ConnY == 0) :
+ if max(ConnX,ConnY) == -1 and not('NonOrtho' in [self.Type,TestObj.Type]) : Alarms.Message(3)
+ else:
+ if ConnX == 1 and ConnY == -1:
+ if Config.Connections[i][1] == (-1,) : Config.Connections[i][1] = (itemID,)
+ else : Config.Connections[i][1] = AddIfDifferent(Config.Connections[i][1],itemID)
+ if Config.Connections[itemID][0] == (-1,) : Config.Connections[itemID][0] = (i,)
+ else : Config.Connections[itemID][0] = AddIfDifferent(Config.Connections[itemID][0],i)
+ elif ConnX == 2 and ConnY == -1:
+ if Config.Connections[i][0] == (-1,) : Config.Connections[i][0] = (itemID,)
+ else : Config.Connections[i][0] = AddIfDifferent(Config.Connections[i][0],itemID)
+ if Config.Connections[itemID][1] == (-1,) : Config.Connections[itemID][1] = (i,)
+ else : Config.Connections[itemID][1] = AddIfDifferent(Config.Connections[itemID][1],i)
+ elif ConnY == 1 and ConnX == -1:
+ if Config.Connections[i][3] == (-1,) : Config.Connections[i][3] = (itemID,)
+ else : Config.Connections[i][3] = AddIfDifferent(Config.Connections[i][3],itemID)
+ if Config.Connections[itemID][2] == (-1,) : Config.Connections[itemID][2] = (i,)
+ else : Config.Connections[itemID][2] = AddIfDifferent(Config.Connections[itemID][2],i)
+ elif ConnY ==2 and ConnX == -1:
+ if Config.Connections[i][2] == (-1,) : Config.Connections[i][2] = (itemID,)
+ else : Config.Connections[i][2] = AddIfDifferent(Config.Connections[i][2],itemID)
+ if Config.Connections[itemID][3] == (-1,) : Config.Connections[itemID][3] = (i,)
+ else : Config.Connections[itemID][3] = AddIfDifferent(Config.Connections[itemID][3],i)
+
+ def AutoParam (self):
+ """
+ This method is called only if the 'auto' keyword is used inside the meshing algorithm. It is based on the
+ connection results per object and tries to find the correct parameters for obtaining a final compatible mesh
+ between the objects already present and the one being created. If this is not possible, the method gives an error
+ message.
+ """
+ import Alarms, Config, GenFunctions, CompositeBox
+ MeshPar = [0,0,0,0] # initialize the mesh parameter value to be used to -1
+ [(X0,Y0),(DX,DY)] = self.GeoPar
+ ObjectsInvolved = []
+ for i, Conn in enumerate(Config.Connections[-1]):
+ if not ( Conn == (-1,) ): # Meaning that there is one or more neighbors on this direction
+ for ObjID in Conn :
+ ToLook0 = [2,3,0,1][i]
+ ToLook1 = [3,2,1,0][i]
+ CommonSide = CompositeBox.FindCommonSide(Config.ListObj[ObjID].DirBoundaries(ToLook1),self.DirBoundaries(ToLook0))
+ #print "Common Side is:", CommonSide
+ ToLook2 = [1,0,3,2][i]
+ #print "Full Side is:", CompositeBox.IntLen(Config.ListObj[ObjID].DirBoundaries(ToLook1))
+ #print "Full Segments on this direction are:", Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]
+ RealSegments = round(Config.ListObj[ObjID].DirectionalMeshParams[ToLook2]*CompositeBox.IntLen(CommonSide)/CompositeBox.IntLen(Config.ListObj[ObjID].DirBoundaries(ToLook1)))
+ #print "RealSegments :", RealSegments
+
+ MeshPar[i] = MeshPar[i] + RealSegments
+ ObjectsInvolved.append(ObjID+1)
+ self.DirectionalMeshParams = MeshPar
+ self.MeshPar[0] = GenFunctions.CompatibilityTest(self)
+
+ if self.MeshPar[0] < 0 :
+ Alarms.Message(4)
+ if self.MeshPar[0] == -1 : print(("Problem encountered with object(s) no. "+str(ObjectsInvolved)))
+ elif self.MeshPar[0] == -2 : print ("This object has no neighbours !!!")
+
+ def Boundaries (self):
+ """
+ This method returns the global boundaries of the MacObject. [Xmin,Xmax,Ymin,Ymax]
+ """
+ Xmin = min([self.DirBoundaries(i)[0] for i in [0,1]])
+ Xmax = max([self.DirBoundaries(i)[1] for i in [0,1]])
+ Ymin = min([self.DirBoundaries(i)[0] for i in [2,3]])
+ Ymax = max([self.DirBoundaries(i)[1] for i in [2,3]])
+
+ return [Xmin,Xmax,Ymin,Ymax]
+
+ def DirBoundaries (self, Direction):
+ """
+ This method returns a single interval giving [Xmin,Xmax] or [Ymin,Ymax] according to the required direction.
+ This works particularly well for nonorthogonal objects.
+ Direction : [0,1,2,3] <=> [South, North, West, East]
+ """
+ PtCoor = self.PtCoor
+ PtCoor.append(self.PtCoor[0])
+ if isinstance(Direction, str) :
+ Dir = { 'South' : lambda : 0,
+ 'North' : lambda : 1,
+ 'West' : lambda : 2,
+ 'East' : lambda : 3,}[Direction]()
+ else : Dir = int(Direction)
+
+ PtIndex = [0,2,3,1][Dir]
+ DirIndex = [0,0,1,1][Dir]
+
+ return sorted([PtCoor[PtIndex][DirIndex],PtCoor[PtIndex+1][DirIndex]])
+ def DirVectors (self, Direction):
+ """
+ This method returns for a given object, the real vectors which define a given direction
+ The interest in using this method is for non-orthogonal objects where the sides can be
+ deviated from the orthogonal basis vectors
+ """
+ if isinstance(Direction, str) :
+ Dir = { 'South' : lambda : 0,
+ 'North' : lambda : 1,
+ 'West' : lambda : 2,
+ 'East' : lambda : 3,}[Direction]()
+ else : Dir = int(Direction)
+ PtCoor = self.PtCoor
+ PtCoor.append(self.PtCoor[0])
+ PtIndex = [0,2,3,1][Dir]
+ return [PtCoor[PtIndex+1][0]-PtCoor[PtIndex][0],PtCoor[PtIndex+1][1]-PtCoor[PtIndex][1],0.]
+
+ def GetBorder (self, Criterion):
+ import GenFunctions, Config
+
+ from salome.geom import geomBuilder
- geompy = geomBuilder.New( Config.theStudy )
++ geompy = geomBuilder.New()
+
+ if isinstance(Criterion, str) :
+ Crit = {'South' : lambda : 0,
+ 'North' : lambda : 1,
+ 'West' : lambda : 2,
+ 'East' : lambda : 3,}[Criterion]()
+ else : Crit = int(Criterion)
+
+ AcceptedObj = []
+ if Crit < 4 :
+ Boundaries = self.Boundaries()
+ Research = {0 : lambda : [self.DirVectors(0),1,Boundaries[2]],
+ 1 : lambda : [self.DirVectors(1),1,Boundaries[3]],
+ 2 : lambda : [self.DirVectors(2),0,Boundaries[0]],
+ 3 : lambda : [self.DirVectors(3),0,Boundaries[1]], }[Crit]()
+
+ for i,ElemObj in enumerate(self.GeoChildren):
+ EdgeIDs = geompy.ExtractShapes(ElemObj,6)# List of Edge IDs belonging to ElemObj
+ for Edge in EdgeIDs:
+ if GenFunctions.IsParallel(Edge,Research[0]):
+ if abs( geompy.PointCoordinates(geompy.GetVertexByIndex(Edge,0))[Research[1]] - Research[2] )< 1e-6 or abs( geompy.PointCoordinates(geompy.GetVertexByIndex(Edge,1))[Research[1]] - Research[2] )< 1e-6 :
+ AcceptedObj.append(Edge)
+ else :
+ CenterSrchPar = {'NE' : lambda : [-1., -1.],
+ 'NW' : lambda : [ 1., -1.],
+ 'SW' : lambda : [ 1., 1.],
+ 'SE' : lambda : [-1., 1.], }[self.MeshPar[1]]()
+ Radius = self.GeoPar[1][1]*float(self.MeshPar[2])/(self.MeshPar[2]+1)
+ Center = (self.GeoPar[0][0]+CenterSrchPar[0]*self.GeoPar[1][0]/2.,self.GeoPar[0][1]+CenterSrchPar[1]*self.GeoPar[1][1]/2.,0.)
+ for i,ElemObj in enumerate(self.GeoChildren):
+ EdgeIDs = geompy.ExtractShapes(ElemObj,6)# List of Edge IDs belonging to ElemObj
+ for Edge in EdgeIDs:
+ if GenFunctions.IsOnCircle(Edge,Center,Radius):
+ AcceptedObj.append(Edge)
+ return AcceptedObj
+
+ def PrincipleBoxes (self):
+ """
+ This function returns all possible combination rectangular shape objects that can contain at least 3 of the principle vertices
+ constituting the MacObject. This is indispensable for the Non-ortho types and shall return a number of 24 possible combinations
+ """
+ from itertools import combinations
+ Boxes = []
+ if self.Type == 'NonOrtho':
+ for combi in combinations(list(range(4)),3):
+ Xmin = min([self.PtCoor[i][0] for i in combi])
+ Xmax = max([self.PtCoor[i][0] for i in combi])
+ Ymin = min([self.PtCoor[i][1] for i in combi])
+ Ymax = max([self.PtCoor[i][1] for i in combi])
+ Boxes.append([(0.5*(Xmin+Xmax),0.5*(Ymin+Ymax)),(Xmax-Xmin,Ymax-Ymin)])
+ else :
+ Boxes = [self.GeoPar]
+
+ return Boxes
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-#
+#
import SMESH
import math
import Config
from salome.geom import geomBuilder
-geompy = geomBuilder.New( Config.theStudy )
+geompy = geomBuilder.New()
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New( Config.theStudy )
+smesh = smeshBuilder.New()
##########################################################################################################
def PublishGroups ():
- aFilterManager = smesh.CreateFilterManager()
+ aFilterManager = smesh.CreateFilterManager()
- # Building geometric and mesh compounds and groups ##############################################
- if Config.debug : print "Searching for geometric groups and publishing final compound"
-
+ # Building geometric and mesh compounds and groups ##############################################
+ if Config.debug : print("Searching for geometric groups and publishing final compound")
+
+ TempGEOList = []
+ TempMESHList = []
+
+ for MacroObj in Config.ListObj :
+ TempGEOList += MacroObj.GeoChildren
+ TempMESHList += MacroObj.Mesh
+
+ FinalCompound = geompy.MakeCompound(TempGEOList)
+ geompy.addToStudy (FinalCompound,Config.StudyName)
+ MeshCompound = smesh.Concatenate(TempMESHList, 1, 1, 1e-5)
+ MeshCompound.SetName(Config.StudyName)
+
+ GroupGEO = []
+ for group in Config.Groups :
+
+ # Geometric groups definition
TempGEOList = []
- TempMESHList = []
-
- for MacroObj in Config.ListObj :
- TempGEOList += MacroObj.GeoChildren
- TempMESHList += MacroObj.Mesh
-
- FinalCompound = geompy.MakeCompound(TempGEOList)
- geompy.addToStudy (FinalCompound,Config.StudyName)
- MeshCompound = smesh.Concatenate(TempMESHList, 1, 1, 1e-5)
- MeshCompound.SetName(Config.StudyName)
-
- GroupGEO = []
- for group in Config.Groups :
-
- # Geometric groups definition
- TempGEOList = []
- TempNames = []
- for MacroObj in Config.ListObj :
- if group in MacroObj.GroupNames :
- Occurences = IndexMultiOcc(MacroObj.GroupNames, group)
- for Occ in Occurences :
- TempGEOList += MacroObj.GetBorder(Occ)
- GroupGEO.append(geompy.MakeCompound(TempGEOList))
- geompy.addToStudyInFather(FinalCompound,GroupGEO[-1],'GR_'+group)
-
- # Mesh groups definition
- Criterion = smesh.GetCriterion(SMESH.EDGE, SMESH.FT_BelongToGeom,'=',GroupGEO[-1],Tolerance=1e-06)
- #Criterion = smesh.Filter.Criterion(18,39,0,'GR_'+group,'GR_'+group,39,39,1e-06,smesh.EDGE,7)
- MeshCompound.MakeGroupByCriterion(group,Criterion)
-
- StudyBuilder = Config.theStudy.NewBuilder()
- for MeshObj in TempMESHList:
- SO = Config.theStudy.FindObjectIOR(Config.theStudy.ConvertObjectToIOR(MeshObj))
- if SO is not None: StudyBuilder.RemoveObjectWithChildren(SO)
-
- return MeshCompound
-
+ TempNames = []
+ for MacroObj in Config.ListObj :
+ if group in MacroObj.GroupNames :
+ Occurences = IndexMultiOcc(MacroObj.GroupNames, group)
+ for Occ in Occurences :
+ TempGEOList += MacroObj.GetBorder(Occ)
+ GroupGEO.append(geompy.MakeCompound(TempGEOList))
+ geompy.addToStudyInFather(FinalCompound,GroupGEO[-1],'GR_'+group)
+
+ # Mesh groups definition
+ Criterion = smesh.GetCriterion(SMESH.EDGE, SMESH.FT_BelongToGeom,'=',GroupGEO[-1],Tolerance=1e-06)
+ #Criterion = smesh.Filter.Criterion(18,39,0,'GR_'+group,'GR_'+group,39,39,1e-06,smesh.EDGE,7)
+ MeshCompound.MakeGroupByCriterion(group,Criterion)
+
+ StudyBuilder = Config.theStudy.NewBuilder()
+ for MeshObj in TempMESHList:
+ SO = Config.theStudy.FindObjectIOR(Config.theStudy.ConvertObjectToIOR(MeshObj))
+ if SO is not None: StudyBuilder.RemoveObjectWithChildren(SO)
+
+ return MeshCompound
+
def IndexMultiOcc (Array,Element) :
- """
- This function returns the occurrences indices of Element in Array.
- As opposed to Array.index(Element) method, this allows determining
- multiple entries rather than just the first one!
- """
- Output = []
- try : Array.index(Element)
- except ValueError : print "No more occurrences"
- else : Output.append(Array.index(Element))
-
- if not(Output == [-1]) and len(Array) > 1 :
- for index, ArrElem in enumerate(Array[Output[0]+1:]) :
- if ArrElem is Element : Output.append(index+Output[0]+1)
-
- return Output
-
+ """
+ This function returns the occurrences indices of Element in Array.
+ As opposed to Array.index(Element) method, this allows determining
+ multiple entries rather than just the first one!
+ """
+ Output = []
+ try : Array.index(Element)
+ except ValueError : print("No more occurrences")
+ else : Output.append(Array.index(Element))
+
+ if not(Output == [-1]) and len(Array) > 1 :
+ for index, ArrElem in enumerate(Array[Output[0]+1:]) :
+ if ArrElem is Element : Output.append(index+Output[0]+1)
+
+ return Output
+
def Publish (ObjToPublish):
- for i,GeoObj in enumerate(ObjToPublish) : geompy.addToStudy(GeoObj,"Sub_"+str(i))
-
+ for i,GeoObj in enumerate(ObjToPublish) : geompy.addToStudy(GeoObj,"Sub_"+str(i))
+
def RevolveMesh(MainMesh,**args):
- """
- This function premits to revolute and scale a 2D mesh while transforming the edge
- groups into face groups. Moreover, the function automatically creates the face groups
- corresponding to the symmetry lower and upper faces
- Facultatif arguments are :
- - Center [X,Y,Z], origin being the default
- - Direction [VX,VY,VZ], x-axis being the default
- - AngleDeg or AngleRad : ALPHA, 10 degrees being the default
- - Scale : BETA, no scaling being default
- """
- ################################################################################
- # Reading input arguments and proceeding to defaults if necessary
- ################################################################################
- if 'Center' in args : CenterCoor = [float(Coor) for Coor in args['Center']]
- else :
- print("\nThe coordinates of the center of revolution were not given\nThe origin is used by default.")
- CenterCoor = [0.,0.,0.]
-
- if 'Direction' in args : Direction = [float(Dir) for Dir in args['Direction']]
- else :
- print("\nThe axis vector of revolution was not given\nThe x-axis is used by default.")
- Direction = [1.,0.,0.]
-
- if 'AngleDeg' in args : Angle = float(args['AngleDeg'])*math.pi/180.
- elif 'AngleRad' in args : Angle = float(args['AngleRad'])
- else :
- print("\nThe revolution angle was not given\nAn angle of 10 degrees is used by default.")
- Angle = 10.*math.pi/180.
-
- if 'Scale' in args : Scale = float(args['Scale'])
- else : Scale = 1.
-
-
- # Creating the lower face group LOFAC
- LOFAC = MainMesh.CreateEmptyGroup( SMESH.FACE, 'LOFAC' )
- LOFAC.AddFrom(MainMesh.GetMesh())
-
- GR_Names = MainMesh.GetGroupNames()
- GRs = MainMesh.GetGroups()
- Rev3DMeshGroups = MainMesh.RotationSweepObject2D( MainMesh, SMESH.AxisStruct( CenterCoor[0], CenterCoor[1], CenterCoor[2], Direction[0], Direction[1], Direction[2] ), Angle, 1, 1e-05 ,True)
-
- # Adding an EDGE suffix to the edge groups (to be deleted eventually by the user...)
- for GR in GRs:
- CurrentName = GR.GetName()
- if CurrentName in GR_Names and not(CurrentName=='LOFAC'): # Meaning that this is an old edge group
- GR.SetName(CurrentName+'_EDGE')
-
- # Removing the _rotated prefix from the rotated FACE groups
- for GR in Rev3DMeshGroups:
- CurrentName = GR.GetName()
- if CurrentName.endswith( "_rotated"):
- if CurrentName.startswith( 'LOFAC_' ):
- GR.SetName('VOL')
- else:
- GR.SetName(CurrentName[:-8])
- elif CurrentName == 'LOFAC_top':
- GR.SetName('HIFAC')
- #Index = [ GR_Names[i] in CurrentName for i in range(0,len(GR_Names)) ].index(True)
- #GR.SetName(GR_Names[Index])
-
- # Creating the upper face group HIFAC
- ALLFAC = MainMesh.CreateEmptyGroup( SMESH.FACE, 'ALLFAC' )
- ALLFAC.AddFrom(MainMesh.GetMesh())
-
- #HIFAC = MainMesh.GetMesh().CutListOfGroups( [ ALLFAC ], [LOFAC] + [ MeshGroup for MeshGroup in Rev3DMeshGroups if not(MeshGroup.GetName()=='VOL') ], 'HIFAC' )
- #HIFAC = MainMesh.GetMesh().CutListOfGroups( [ ALLFAC ], [LOFAC] + [ MeshGroup for MeshGroup in Rev3DMeshGroups if ( not(MeshGroup.GetName()=='VOL') and MeshGroup.GetType() == SMESH.FACE )], 'HIFAC' )
-
- # Scaling down the mesh to meter units
- if not(Scale==1.):
- MeshEditor = MainMesh.GetMeshEditor()
- MeshEditor.Scale( MainMesh.GetMesh(), SMESH.PointStruct( 0, 0, 0 ) ,[ Scale, Scale, Scale ], 0 )
-
-
+ """
+ This function permits to revolute and scale a 2D mesh while transforming the edge
+ groups into face groups. Moreover, the function automatically creates the face groups
+ corresponding to the symmetry lower and upper faces
+ Facultatif arguments are :
+ - Center [X,Y,Z], origin being the default
+ - Direction [VX,VY,VZ], x-axis being the default
+ - AngleDeg or AngleRad : ALPHA, 10 degrees being the default
+ - Scale : BETA, no scaling being default
+ """
+ ################################################################################
+ # Reading input arguments and proceeding to defaults if necessary
+ ################################################################################
+ if 'Center' in args : CenterCoor = [float(Coor) for Coor in args['Center']]
+ else :
- print "\nThe coordinates of the center of revolution were not given\nThe origin is used by default."
++ print("\nThe coordinates of the center of revolution were not given\nThe origin is used by default.")
+ CenterCoor = [0.,0.,0.]
+
+ if 'Direction' in args : Direction = [float(Dir) for Dir in args['Direction']]
+ else :
- print "\nThe axis vector of revolution was not given\nThe x-axis is used by default."
++ print("\nThe axis vector of revolution was not given\nThe x-axis is used by default.")
+ Direction = [1.,0.,0.]
+
+ if 'AngleDeg' in args : Angle = float(args['AngleDeg'])*math.pi/180.
+ elif 'AngleRad' in args : Angle = float(args['AngleRad'])
+ else :
- print "\nThe revolution angle was not given\nAn angle of 10 degrees is used by default."
++ print("\nThe revolution angle was not given\nAn angle of 10 degrees is used by default.")
+ Angle = 10.*math.pi/180.
+
+ if 'Scale' in args : Scale = float(args['Scale'])
+ else : Scale = 1.
+
+
+ # Creating the lower face group LOFAC
+ LOFAC = MainMesh.CreateEmptyGroup( SMESH.FACE, 'LOFAC' )
+ LOFAC.AddFrom(MainMesh.GetMesh())
+
+ GR_Names = MainMesh.GetGroupNames()
+ GRs = MainMesh.GetGroups()
+ Rev3DMeshGroups = MainMesh.RotationSweepObject2D( MainMesh, SMESH.AxisStruct( CenterCoor[0], CenterCoor[1], CenterCoor[2], Direction[0], Direction[1], Direction[2] ), Angle, 1, 1e-05 ,True)
+
+ # Adding an EDGE suffix to the edge groups (to be deleted eventually by the user...)
+ for GR in GRs:
+ CurrentName = GR.GetName()
+ if CurrentName in GR_Names and not(CurrentName=='LOFAC'): # Meaning that this is an old edge group
+ GR.SetName(CurrentName+'_EDGE')
+
+ # Removing the _rotated prefix from the rotated FACE groups
+ for GR in Rev3DMeshGroups:
+ CurrentName = GR.GetName()
+ if CurrentName.endswith( "_rotated"):
+ if CurrentName.startswith( 'LOFAC_' ):
+ GR.SetName('VOL')
+ else:
+ GR.SetName(CurrentName[:-8])
+ elif CurrentName == 'LOFAC_top':
+ GR.SetName('HIFAC')
+ #Index = [ GR_Names[i] in CurrentName for i in range(0,len(GR_Names)) ].index(True)
+ #GR.SetName(GR_Names[Index])
+
+ # Creating the upper face group HIFAC
+ ALLFAC = MainMesh.CreateEmptyGroup( SMESH.FACE, 'ALLFAC' )
+ ALLFAC.AddFrom(MainMesh.GetMesh())
+
+ #HIFAC = MainMesh.GetMesh().CutListOfGroups( [ ALLFAC ], [LOFAC] + [ MeshGroup for MeshGroup in Rev3DMeshGroups if not(MeshGroup.GetName()=='VOL') ], 'HIFAC' )
+ #HIFAC = MainMesh.GetMesh().CutListOfGroups( [ ALLFAC ], [LOFAC] + [ MeshGroup for MeshGroup in Rev3DMeshGroups if ( not(MeshGroup.GetName()=='VOL') and MeshGroup.GetType() == SMESH.FACE )], 'HIFAC' )
+
+ # Scaling down the mesh to meter units
+ if not(Scale==1.):
+ MeshEditor = MainMesh.GetMeshEditor()
+ MeshEditor.Scale( MainMesh.GetMesh(), SMESH.PointStruct( 0, 0, 0 ) ,[ Scale, Scale, Scale ], 0 )
+
+
def ExtrudeMesh(MainMesh,**args):
- """
- This function premits to extrude and scale a 2D mesh while transforming the edge
- groups into face groups. Moreover, the function automatically creates the face groups
- corresponding to the symmetry lower and upper faces
- Facultatif arguments are :
- - Direction [VX,VY,VZ], z-axis being default
- - Distance : D, default is 1
- - NSteps : the object will be extruded by NSteps*Distance, default is Nsteps = 1
- - Scale : BETA, no scaling being default
- """
- ################################################################################
- # Reading input arguments and proceeding to defaults if necessary
- ################################################################################
- if 'Distance' in args : Distance = float(args['Distance'])
- else :
- print("\nThe extrusion distance was not given\nA default value of 1 is used.")
- Distance = 1.
-
- if 'Direction' in args : Direction = NormalizeVector([float(Dir) for Dir in args['Direction']],Distance)
- else :
- print("\nThe extrusion vector of revolution was not given\nThe z-axis is used by default.")
- Direction = NormalizeVector([0.,0.,1.],Distance)
-
- if 'Scale' in args : Scale = float(args['Scale'])
- else : Scale = 1.
-
- if 'NSteps' in args : NSteps = int(args['NSteps'])
- else : NSteps = 1
-
- # Creating the lower face group LOFAC
- LOFAC = MainMesh.CreateEmptyGroup( SMESH.FACE, 'LOFAC' )
- LOFAC.AddFrom(MainMesh.GetMesh())
-
- GR_Names = MainMesh.GetGroupNames()
- GRs = MainMesh.GetGroups()
- Ext3DMeshGroups = MainMesh.ExtrusionSweepObject2D(MainMesh,SMESH.DirStruct(SMESH.PointStruct(Direction[0],Direction[1],Direction[2])), NSteps, True)
-
- # Adding an EDGE suffix to the edge groups (to be deleted eventually by the user...)
- for GR in GRs:
- CurrentName = GR.GetName()
- if CurrentName in GR_Names and not(CurrentName=='LOFAC'): # Meaning that this is an old edge group
- GR.SetName(CurrentName+'_EDGE')
-
- # Removing the _extruded suffix from the extruded FACE groups
- for GR in Ext3DMeshGroups:
- CurrentName = GR.GetName()
- if CurrentName.endswith( "_extruded"):
- if CurrentName.startswith( 'LOFAC_' ):
- GR.SetName('VOL')
- else:
- GR.SetName(CurrentName[:-9])
- elif CurrentName == 'LOFAC_top':
- GR.SetName('HIFAC')
-
- # Creating the upper face group HIFAC
- ALLFAC = MainMesh.CreateEmptyGroup( SMESH.FACE, 'ALLFAC' )
- ALLFAC.AddFrom(MainMesh.GetMesh())
-
- #HIFAC = MainMesh.GetMesh().CutListOfGroups( [ ALLFAC ], [LOFAC] + [ MeshGroup for MeshGroup in Ext3DMeshGroups if not(MeshGroup.GetName()=='VOL') ], 'HIFAC' )
-
- # Scaling down the mesh to meter units
- if not(Scale==1.):
- MeshEditor = MainMesh.GetMeshEditor()
- MeshEditor.Scale( MainMesh.GetMesh(), SMESH.PointStruct( 0, 0, 0 ) ,[ Scale, Scale, Scale ], 0 )
-
-
+ """
+ This function permits to extrude and scale a 2D mesh while transforming the edge
+ groups into face groups. Moreover, the function automatically creates the face groups
+ corresponding to the symmetry lower and upper faces
+ Facultatif arguments are :
+ - Direction [VX,VY,VZ], z-axis being default
+ - Distance : D, default is 1
+ - NSteps : the object will be extruded by NSteps*Distance, default is Nsteps = 1
+ - Scale : BETA, no scaling being default
+ """
+ ################################################################################
+ # Reading input arguments and proceeding to defaults if necessary
+ ################################################################################
+ if 'Distance' in args : Distance = float(args['Distance'])
+ else :
- print "\nThe extrusion distance was not given\nA default value of 1 is used."
++ print("\nThe extrusion distance was not given\nA default value of 1 is used.")
+ Distance = 1.
+
+ if 'Direction' in args : Direction = NormalizeVector([float(Dir) for Dir in args['Direction']],Distance)
+ else :
- print "\nThe extrusion vector of revolution was not given\nThe z-axis is used by default."
++ print("\nThe extrusion vector of revolution was not given\nThe z-axis is used by default.")
+ Direction = NormalizeVector([0.,0.,1.],Distance)
+
+ if 'Scale' in args : Scale = float(args['Scale'])
+ else : Scale = 1.
+
+ if 'NSteps' in args : NSteps = int(args['NSteps'])
+ else : NSteps = 1
+
+ # Creating the lower face group LOFAC
+ LOFAC = MainMesh.CreateEmptyGroup( SMESH.FACE, 'LOFAC' )
+ LOFAC.AddFrom(MainMesh.GetMesh())
+
+ GR_Names = MainMesh.GetGroupNames()
+ GRs = MainMesh.GetGroups()
+ Ext3DMeshGroups = MainMesh.ExtrusionSweepObject2D(MainMesh,SMESH.DirStruct(SMESH.PointStruct(Direction[0],Direction[1],Direction[2])), NSteps, True)
+
+ # Adding an EDGE suffix to the edge groups (to be deleted eventually by the user...)
+ for GR in GRs:
+ CurrentName = GR.GetName()
+ if CurrentName in GR_Names and not(CurrentName=='LOFAC'): # Meaning that this is an old edge group
+ GR.SetName(CurrentName+'_EDGE')
+
+ # Removing the _extruded suffix from the extruded FACE groups
+ for GR in Ext3DMeshGroups:
+ CurrentName = GR.GetName()
+ if CurrentName.endswith( "_extruded"):
+ if CurrentName.startswith( 'LOFAC_' ):
+ GR.SetName('VOL')
+ else:
+ GR.SetName(CurrentName[:-9])
+ elif CurrentName == 'LOFAC_top':
+ GR.SetName('HIFAC')
+
+ # Creating the upper face group HIFAC
+ ALLFAC = MainMesh.CreateEmptyGroup( SMESH.FACE, 'ALLFAC' )
+ ALLFAC.AddFrom(MainMesh.GetMesh())
+
+ #HIFAC = MainMesh.GetMesh().CutListOfGroups( [ ALLFAC ], [LOFAC] + [ MeshGroup for MeshGroup in Ext3DMeshGroups if not(MeshGroup.GetName()=='VOL') ], 'HIFAC' )
+
+ # Scaling down the mesh to meter units
+ if not(Scale==1.):
+ MeshEditor = MainMesh.GetMeshEditor()
+ MeshEditor.Scale( MainMesh.GetMesh(), SMESH.PointStruct( 0, 0, 0 ) ,[ Scale, Scale, Scale ], 0 )
+
+
def NormalizeVector (V,Norm):
- """
- This function returns a normalized vector (magnitude = Norm), parallel to the entered one
- """
- V = [float(Coor) for Coor in V]
- Norm = float(Norm)
- MagV = math.sqrt(V[0]*V[0]+V[1]*V[1]+V[2]*V[2])
- return [Coor*Norm/MagV for Coor in V]
-
+ """
+ This function returns a normalized vector (magnitude = Norm), parallel to the entered one
+ """
+ V = [float(Coor) for Coor in V]
+ Norm = float(Norm)
+ MagV = math.sqrt(V[0]*V[0]+V[1]*V[1]+V[2]*V[2])
+ return [Coor*Norm/MagV for Coor in V]
ADD_SUBDIRECTORY(casTests)
- INCLUDE(UsePyQt)
+ IF(SALOME_BUILD_GUI)
+ INCLUDE(UsePyQt)
+ ENDIF(SALOME_BUILD_GUI)
# --- scripts ---
# scripts / static
- SET(plugin_SCRIPTS
+ SET(_plugin_SCRIPTS
__init__.py
ellipse.py
genereCrack.py
- images_rc.py
main.py
output.py
rectangle.py
Zset.py
)
- SET(command_SCRIPTS
+ SET(_command_SCRIPTS
zcracksLaunch.py
)
- # --- resources ---
-
- # uic files / to be processed by pyuic
- SET(_pyuic_files
- zcracks.ui
- )
+ IF(SALOME_BUILD_GUI)
+ # uic files / to be processed by pyuic
+ SET(_pyuic_FILES
+ zcracks.ui
+ )
+
+# qrc files / to be processed by pyrcc
- SET(_pyqrcc_files
++SET(_pyqrc_FILES
+ images.qrc
+)
+
- # scripts / pyuic wrappings
- PYQT_WRAP_UIC(_pyuic_SCRIPTS ${_pyuic_files} OPTIONS "--import-from=Zcracks" "--resource-suffix=_qrc")
- PYQT_WRAP_QRC(_pyqrc_SCRIPTS ${_pyqrcc_files})
+ # scripts / pyuic wrappings
- PYQT_WRAP_UIC(_pyuic_SCRIPTS ${_pyuic_FILES} TARGET_NAME _target_name_pyuic)
++ PYQT_WRAP_UIC(_pyuic_SCRIPTS ${_pyuic_FILES} TARGET_NAME _target_name_pyuic OPTIONS "--import-from=Zcracks" "--resource-suffix=_qrc")
++ PYQT_WRAP_QRC(_pyqrc_SCRIPTS ${_pyqrc_FILES})
+ ENDIF(SALOME_BUILD_GUI)
# --- rules ---
- SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/Zcracks)
- SALOME_INSTALL_SCRIPTS("${_pyuic_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/Zcracks)
- SALOME_INSTALL_SCRIPTS("${_pyqrc_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/Zcracks)
- SALOME_INSTALL_SCRIPTS("${command_SCRIPTS}" ${SALOME_INSTALL_BINS})
+ SALOME_INSTALL_SCRIPTS("${_plugin_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/Zcracks)
+ SALOME_INSTALL_SCRIPTS("${_command_SCRIPTS}" ${SALOME_INSTALL_BINS})
+ IF(SALOME_BUILD_GUI)
+ SALOME_INSTALL_SCRIPTS("${_pyuic_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/Zcracks TARGET_NAME _target_name_pyuic_py)
++ SALOME_INSTALL_SCRIPTS("${_pyqrc_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/Zcracks)
+ # add dependency of compiled py files on uic files in order
+ # to avoid races problems when compiling in parallel
+ ADD_DEPENDENCIES(${_target_name_pyuic_py} ${_target_name_pyuic})
+ ENDIF(SALOME_BUILD_GUI)
+
import salome
salome.salome_init()
--theStudy = salome.myStudy
import salome_notebook
--notebook = salome_notebook.NoteBook(theStudy)
++notebook = salome_notebook.NoteBook()
###
### GEOM component
N=int(N)
from salome.geom import geomBuilder
-- geompy = geomBuilder.New(theStudy)
++ geompy = geomBuilder.New()
eps=L*1.e-6
from salome.smesh import smeshBuilder
import SMESH
-- smesh = smeshBuilder.New(theStudy)
++ smesh = smeshBuilder.New()
Nb_Segments_1 = smesh.CreateHypothesis('NumberOfSegments')
Nb_Segments_1.SetNumberOfSegments( N )
Length_From_Edges_1 = smesh.CreateHypothesis('LengthFromEdges')
aFilter_1.SetMesh(Maillage_1.GetMesh())
FACE_temp = Maillage_1.GroupOnFilter( SMESH.FACE, noms[cont], aFilter_1 )
- Maillage_1.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage_1.ExportMED(outFile)
#if salome.sg.hasDesktop():
- #salome.sg.updateObjBrowser(True)
- #salome.sg.updateObjBrowser(1)
++ #salome.sg.updateObjBrowser()
N=int(N)
from salome.geom import geomBuilder
-- geompy = geomBuilder.New(theStudy)
++ geompy = geomBuilder.New()
eps=L*1.e-6
from salome.smesh import smeshBuilder
import SMESH
-- smesh = smeshBuilder.New(theStudy)
++ smesh = smeshBuilder.New()
Nb_Segments_1 = smesh.CreateHypothesis('NumberOfSegments')
Nb_Segments_1.SetNumberOfSegments( N )
Length_From_Edges_1 = smesh.CreateHypothesis('LengthFromEdges')
aFilter_1.SetMesh(Maillage_1.GetMesh())
EDGE_temp = Maillage_1.GroupOnFilter( SMESH.EDGE, noms[cont], aFilter_1 )
- Maillage_1.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage_1.ExportMED(outFile)
#if salome.sg.hasDesktop():
- #salome.sg.updateObjBrowser(True)
- #salome.sg.updateObjBrowser(1)
++ #salome.sg.updateObjBrowser()
import salome
salome.salome_init()
--theStudy = salome.myStudy
import salome_notebook
--notebook = salome_notebook.NoteBook(theStudy)
++notebook = salome_notebook.NoteBook()
###
### GEOM component
from salome.geom import geomBuilder
import math
import SALOMEDS
-import utilityFunctions as uF
-from output import message
+from . import utilityFunctions as uF
+from .output import message
#ellipse.generate(data_demi_grand_axe, data_centre, data_normale,data_direction, data_demi_petit_axe, data_angle, rayon_entaille,extension, outFile)
#if True:
Vnormale, Vdirection, Vortho = uF.calcCoordVectors(data_normale, data_direction)
Vcentre = numpy.array(data_centre)
-- geompy = geomBuilder.New(theStudy)
++ geompy = geomBuilder.New()
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-- smesh = smeshBuilder.New(theStudy)
++ smesh = smeshBuilder.New()
A=numpy.pi/(30.)
minAxes=numpy.min([data_demi_grand_axe,data_demi_petit_axe])
Maillage=uF.meshCrack(FACE_FISSURE, minSize, maxSize, chordal, dim)
try:
- Maillage.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage.ExportMED(outFile)
smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
except:
- print 'ExportToMEDX() failed. Invalid file name?'
+ print('ExportMED() failed. Invalid file name?')
## Set names of Mesh objects
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(True)
- salome.sg.updateObjBrowser(1)
++ salome.sg.updateObjBrowser()
import os, shutil
-import sphere, ellipse, rectangle
-import utilityFunctions as uF
-from output import message
+from . import sphere, ellipse, rectangle
+from . import utilityFunctions as uF
+from .output import message
def main(data, outFile):
activeCrack=data['crack']['actif']
res=False
demiGrandAxe=crack['Rayon'][0]
- if 'Rayon 2' not in crack.keys(): crack['Rayon 2']=[]
+ if 'Rayon 2' not in list(crack.keys()): crack['Rayon 2']=[]
if len(crack['Rayon 2'])==0:
demiPetitAxe=demiGrandAxe
else:
res=False
normale=crack['Normale']
- if 'Direction' not in crack.keys(): crack['Direction']=[]
+ if 'Direction' not in list(crack.keys()): crack['Direction']=[]
if len(crack['Direction'])==0:
if normale==[1.,0.,0.]:
direction=[0.,1.,0.]
message('E','Normale and Direction are equals',goOn=True)
res=False
- if 'Angle' not in crack.keys(): crack['Angle']=[]
+ if 'Angle' not in list(crack.keys()): crack['Angle']=[]
if len(crack['Angle'])==0:
angle=0.0
else:
res=False
angle=crack['Angle'][0]
- if 'Rayon entaille' not in crack.keys(): crack['Rayon entaille']=[]
+ if 'Rayon entaille' not in list(crack.keys()): crack['Rayon entaille']=[]
if len(crack['Rayon entaille'])==0:
rayon_entaille=0.0
else:
res=False
rayon_entaille=crack['Rayon entaille'][0]
- if 'Extension' not in crack.keys(): crack['Extension']=[]
+ if 'Extension' not in list(crack.keys()): crack['Extension']=[]
if len(crack['Extension'])==0:
extension=0.0
else:
res=False
longueur=crack['Longueur'][0]
- if 'Largeur' not in crack.keys(): crack['Largeur']=[]
+ if 'Largeur' not in list(crack.keys()): crack['Largeur']=[]
if len(crack['Largeur'])==0:
largeur=longueur
else:
res=False
direction=crack['Direction']
- if 'Angle' not in crack.keys(): crack['Angle']=[]
+ if 'Angle' not in list(crack.keys()): crack['Angle']=[]
if len(crack['Angle'])==0:
angle=0.0
else:
res=False
angle=crack['Angle'][0]
- if 'Rayon' not in crack.keys(): crack['Rayon']=[]
+ if 'Rayon' not in list(crack.keys()): crack['Rayon']=[]
if len(crack['Rayon'])==0:
rayon=0.0
else:
res=False
rayon=crack['Rayon'][0]
- if 'Rayon entaille' not in crack.keys(): crack['Rayon entaille']=[]
+ if 'Rayon entaille' not in list(crack.keys()): crack['Rayon entaille']=[]
if len(crack['Rayon entaille'])==0:
rayon_entaille=0.0
else:
import salome
salome.salome_init()
-- theStudy = salome.myStudy
import salome_notebook
-- notebook = salome_notebook.NoteBook(theStudy)
++ notebook = salome_notebook.NoteBook()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-- smesh = smeshBuilder.New(theStudy)
++ smesh = smeshBuilder.New()
([Maillage_1], status) = smesh.CreateMeshesFromMED(crack['med file'])
isCrack=False
for group in Maillage_1.GetGroups():
else:
Group_1 = Maillage_1.CreateEmptyGroup( SMESH.NODE, 'crack' )
nbAdd = Group_1.AddFrom( Maillage_1.GetMesh() )
- Maillage_1.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage_1.ExportMED(outFile)
return(True)
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
-import utilityFunctions as uF
-import genereCrack, Zset, output, zcracks_ui
+from . import utilityFunctions as uF
+from . import genereCrack, Zset, output, zcracks_ui
-from output import message, init
-from zcracks_ui import Ui_Zui
+from .output import message, init
+from .zcracks_ui import Ui_Zui
# ---------------------
if str(string).replace(' ','')=='':
out=[]
else:
- out=map(typ, str(string).split())
+ out=list(map(typ, str(string).split()))
return(out)
def addExtension(string, extension):
else:
obj.setText(self.data[self.lineEditNames[cont]])
- self.ui.CBQuad.setChecked(True if 'quad' in self.data.keys() and self.data['quad'] else False)
- self.ui.CBBarsoum.setChecked(True if 'barsoum' in self.data.keys() and self.data['barsoum'] else False)
- self.ui.CBIs2D.setChecked(True if 'is2D' in self.data.keys() and self.data['is2D'] else False)
- self.ui.CBRefine.setChecked(True if 'refine' in self.data.keys() and self.data['refine'] else False)
+ self.ui.CBQuad.setChecked(True if 'quad' in list(self.data.keys()) and self.data['quad'] else False)
+ self.ui.CBBarsoum.setChecked(True if 'barsoum' in list(self.data.keys()) and self.data['barsoum'] else False)
+ self.ui.CBIs2D.setChecked(True if 'is2D' in list(self.data.keys()) and self.data['is2D'] else False)
+ self.ui.CBRefine.setChecked(True if 'refine' in list(self.data.keys()) and self.data['refine'] else False)
self.setTableParameters()
if not test2:
message('A','No mesh file to visualize')
else:
- print medit+' %s' %meshFile2
+ print(medit+' %s' %meshFile2)
system(medit+' %s' %meshFile2)
else:
- print medit+' %s' %meshFile1
+ print(medit+' %s' %meshFile1)
system(medit+' %s' %meshFile1)
return()
else:
import SMESH, salome
#salome.salome_init()
-- theStudy = salome.myStudy
from salome.smesh import smeshBuilder
-- smesh = smeshBuilder.New(theStudy)
++ smesh = smeshBuilder.New()
([objetSain], status) = smesh.CreateMeshesFromMED(saneFile)
import salome
salome.salome_init()
--theStudy = salome.myStudy
import salome_notebook
--notebook = salome_notebook.NoteBook(theStudy)
++notebook = salome_notebook.NoteBook()
###
### GEOM component
from salome.geom import geomBuilder
import math
import SALOMEDS
-import utilityFunctions as uF
-from output import message
+from . import utilityFunctions as uF
+from .output import message
#import GEOM_Gen.ild
#rectangle.generate(data_longueur,data_largeur,data_centre,data_normale,data_direction,data_angle,data_rayon,rayon_entaille,extension,outFile)
Vnormale, Vdirection, Vortho = uF.calcCoordVectors(data_normale, data_direction)
Vcentre = numpy.array(data_centre)
-- geompy = geomBuilder.New(theStudy)
++ geompy = geomBuilder.New()
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-- smesh = smeshBuilder.New(theStudy)
++ smesh = smeshBuilder.New()
Maillage=uF.meshCrack(FACE_FISSURE, minSize, maxSize, chordal, dim)
try:
- Maillage.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage.ExportMED(outFile)
smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
except:
- print 'ExportToMEDX() failed. Invalid file name?'
+ print('ExportMED() failed. Invalid file name?')
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(True)
- salome.sg.updateObjBrowser(1)
++ salome.sg.updateObjBrowser()
import salome
salome.salome_init()
--theStudy = salome.myStudy
import salome_notebook
--notebook = salome_notebook.NoteBook(theStudy)
++notebook = salome_notebook.NoteBook()
###
### GEOM component
from salome.geom import geomBuilder
import math
import SALOMEDS
-import utilityFunctions as uF
-from output import message
+from . import utilityFunctions as uF
+from .output import message
#import GEOM_Gen.ild
#data_rayon = 0.1
#data_centre = [1., 1., 01.]
-- geompy = geomBuilder.New(theStudy)
++ geompy = geomBuilder.New()
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-- smesh = smeshBuilder.New(theStudy)
++ smesh = smeshBuilder.New()
A=numpy.pi/(20.)
chordal, minSize = uF.calcElemSize(A, data_rayon)
Maillage=uF.meshCrack(FACE_FISSURE, minSize, maxSize, chordal, dim=3)
try:
- Maillage.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ Maillage.ExportMED(outFile)
smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
except:
- print 'ExportToMEDX() failed. Invalid file name?'
+ print('ExportMED() failed. Invalid file name?')
## Set names of Mesh objects
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(True)
- salome.sg.updateObjBrowser(1)
++ salome.sg.updateObjBrowser()
import numpy, subprocess, sys
from os import remove, getpid, path, environ
-from output import message
+from .output import message
def calcCoordVectors(normalIN, directionIN):
V3TEMP=numpy.cross(normalIN,directionIN)
def testStrictRange(x, inf=0.0, sup=False):
test=False
- c1=(type(x)==list)
+ c1=(isinstance(x, list))
if c1:
c2=(len(x)==1)
if c2:
- c3=(type(x[0])==type(inf))
+ c3=(isinstance(x[0], type(inf)))
if c3:
c4=(x[0]>inf)
c5=True
def test3dVector(x):
test=False
- c1=(type(x)==list)
+ c1=(isinstance(x, list))
if c1:
c2=(len(x)==3)
if c2:
- c3=(type(x[0])==float)
- c4=(type(x[1])==float)
- c5=(type(x[2])==float)
+ c3=(isinstance(x[0], float))
+ c4=(isinstance(x[1], float))
+ c5=(isinstance(x[2], float))
if c3 and c4 and c5:
test=True
return(test)
def testRange(x, inf=0.0, sup=False):
test=False
- c1=(type(x)==list)
+ c1=(isinstance(x, list))
if c1:
c2=(len(x)==1)
if c2:
- c3=(type(x[0])==type(inf))
+ c3=(isinstance(x[0], type(inf)))
if c3:
c4=(x[0]>=inf)
c5=True
import salome
salome.salome_init()
-- theStudy = salome.myStudy
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-- smesh = smeshBuilder.New(theStudy)
++ smesh = smeshBuilder.New()
Maillage = smesh.Mesh(geomObject)
if dim==3:
import SMESH, salome
#salome.salome_init()
-- theStudy = salome.myStudy
from salome.smesh import smeshBuilder
-- smesh = smeshBuilder.New(theStudy)
++ smesh = smeshBuilder.New()
([mesh], status) = smesh.CreateMeshesFromMED(meshFile)
if len(front)==0: crackOnly=False
if crackOnly:
- mesh.ExportMED(outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ mesh.ExportMED(outFile)
return('crack')
# Propagates color using elem connectivity
while ifChanged :
ifChanged=False
for elemId in elemList[0]:
- minColor=sys.maxint
- maxColor=-sys.maxint
+ minColor=sys.maxsize
+ maxColor=-sys.maxsize
for elemNodeId in mesh.GetElemNodes(elemId) :
nodeColor=colorList[elemNodeId-1]
if nodeColor<minColor : minColor=nodeColor
mesh.MakeGroupByIds('Extended_side%d' %n ,SMESH.EDGE,grElemList[2][n])
if outFile==None: outFile=meshFile
- mesh.ExportMED(outFile, 0, SMESH.MED_V2_2, 1, None ,1)
+ mesh.ExportMED(outFile)
return(True)
def getMaxAspectRatio(tmpdir):
logFile=path.join(tmpdir,'MESHING_OUTPUT')
- print logFile
+ print(logFile)
if not path.isfile(logFile): return(-1)
import re
def removeFromSessionPath(envVar, patern):
- if type(patern) is not list: patern=[patern]
- if type(envVar) is not list: envVar=[envVar]
+ if not isinstance(patern, list): patern=[patern]
+ if not isinstance(envVar, list): envVar=[envVar]
for env in envVar:
path=environ[env]
# --- scripts ---
# scripts / static
- SET(plugin_SCRIPTS
+ SET(_plugin_SCRIPTS
__init__.py
fissureCoude_ihm.py
fissureCoude_plugin.py
dialogFissureCoude.dic
)
- # --- resources ---
-
# uic files / to be processed by pyuic
- SET(_pyuic_files
+ SET(_pyuic_FILES
fissureCoude.ui
fissureGenerale.ui
)
-
# scripts / pyuic wrappings
- PYQT_WRAP_UIC(_pyuic_SCRIPTS ${_pyuic_files} OPTIONS "--import-from=blocFissure" "--resource-suffix=_qrc")
-PYQT_WRAP_UIC(_pyuic_SCRIPTS ${_pyuic_FILES} TARGET_NAME _target_name_pyuic)
++PYQT_WRAP_UIC(_pyuic_SCRIPTS ${_pyuic_FILES} TARGET_NAME _target_name_pyuic OPTIONS "--import-from=blocFissure" "--resource-suffix=_qrc")
# --- rules ---
- SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/blocFissure/ihm)
+ SALOME_INSTALL_SCRIPTS("${_plugin_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/blocFissure/ihm)
- SALOME_INSTALL_SCRIPTS("${_pyuic_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/blocFissure/ihm)
+ SALOME_INSTALL_SCRIPTS("${_pyuic_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/blocFissure/ihm TARGET_NAME _target_name_pyuic_py)
+ # add dependency of compiled py files on uic files in order
+ # to avoid races problems when compiling in parallel
+ ADD_DEPENDENCIES(${_target_name_pyuic_py} ${_target_name_pyuic})
import salome
salome.salome_init()
--theStudy = salome.myStudy
import salome_notebook
notebook = salome_notebook.notebook
import SALOMEDS
-geompy = geomBuilder.New(theStudy)
+geompy = geomBuilder.New()
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(theStudy)
+smesh = smeshBuilder.New()
from salome.StdMeshers import StdMeshersBuilder
smeshObj_1 = smesh.CreateHypothesis('NumberOfSegments')
smeshObj_1.SetNumberOfSegments( 5 )
Nb_Segments_3.SetDistrType( 0 )
isDone = CylindreSain_1.Compute()
smesh.SetName(CylindreSain_1, 'CylindreSain')
-CylindreSain_1.ExportMED( os.path.join(gmu.pathBloc, "materielCasTests//CylindreSain.med"), 0, SMESH.MED_V2_2, 1 )
+CylindreSain_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests//CylindreSain.med"))
SubMesh_1 = Regular_1D_1.GetSubMesh()
SubMesh_2 = Regular_1D_2.GetSubMesh()
## some objects were removed
--aStudyBuilder = theStudy.NewBuilder()
--SO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(smeshObj_1))
++aStudyBuilder = salome.myStudy.NewBuilder()
++SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(smeshObj_1))
if SO is not None: aStudyBuilder.RemoveObjectWithChildren(SO)
## set object names
smesh.SetName(CylindreSain_1.GetMesh(), 'CylindreSain')
smesh.SetName(SubMesh_2, 'SubMesh_2')
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(True)
+ salome.sg.updateObjBrowser()