in string theLibName )
raises ( SALOME::SALOME_Exception );
+ /*!
+ * Return a hypothesis holding parameter values corresponding to the mesh
+ * existing on the given geometry.
+ * The returned hypothesis may be the one existing in a study and used
+ * to compute the mesh, or a temporary one created just to pass parameter
+ * values
+ */
+ SMESH_Hypothesis GetHypothesisParameterValues( in string theHypName,
+ in string theLibName,
+ in SMESH_Mesh theMesh,
+ in GEOM::GEOM_Object theGeom)
+ raises ( SALOME::SALOME_Exception );
+
/*!
* Create a Mesh object, given a geometry shape.
* Mesh is created empty (no points, no elements).
* First, verify list of hypothesis associated with the subShape,
* return NOK if hypothesis are not sufficient
*/
- boolean Compute( in SMESH_Mesh theMesh,
+ boolean Compute( in SMESH_Mesh theMesh,
in GEOM::GEOM_Object theSubObject )
raises ( SALOME::SALOME_Exception );
/*!
- *
+ * Return true if hypotheses are defined well
*/
-
- boolean IsReadyToCompute( in SMESH_Mesh theMesh,
+ boolean IsReadyToCompute( in SMESH_Mesh theMesh,
in GEOM::GEOM_Object theSubObject )
raises ( SALOME::SALOME_Exception );
* Return errors of hypotheses definintion
* algo_error_array is empty if everything is OK
*/
- algo_error_array GetAlgoState( in SMESH_Mesh theMesh,
+ algo_error_array GetAlgoState( in SMESH_Mesh theMesh,
in GEOM::GEOM_Object theSubObject )
raises ( SALOME::SALOME_Exception );
*
*/
long_array GetSubShapesId( in GEOM::GEOM_Object theMainObject,
- in object_array theListOfSubObjects )
+ in object_array theListOfSubObjects )
raises ( SALOME::SALOME_Exception );
-
+
/*!
- *
+ * Return geometrical object the given element is built on.
+ * The returned geometrical object, if not nil, is either found in the
+ * study or is published by this method with the given name
*/
- // long_array GetSubMeshesState( in object_array theListOfSubShape )
- // raises ( SALOME::SALOME_Exception );
-
+ GEOM::GEOM_Object GetGeometryByMeshElement( in SMESH_Mesh theMesh,
+ in long theElementID,
+ in string theGeomName)
+ raises ( SALOME::SALOME_Exception );
+
};
};
<component-comment>Mesh component</component-comment>
<component-multistudy>1</component-multistudy>
<component-icone>ModuleMesh.png</component-icone>
+ <component-impltype>1</component-impltype>
<component-interface-list>
<component-interface-name>SMESH</component-interface-name>
#include "SMESHDS_Group.hxx"
#include "MED_Factory.hxx"
+#include "MED_CoordUtils.hxx"
#include "MED_Utilities.hxx"
#include <stdlib.h>
using namespace MED;
-void DriverMED_R_SMESHDS_Mesh::SetMeshName(string theMeshName)
+void
+DriverMED_R_SMESHDS_Mesh
+::SetMeshName(string theMeshName)
{
myMeshName = theMeshName;
}
}
-enum ECoordName{eX, eY, eZ, eNone};
-typedef TFloat (*TGetCoord)(MED::PNodeInfo&, TInt);
-
-template<ECoordName TheCoordId>
-TFloat GetCoord(MED::PNodeInfo& thePNodeInfo, TInt theElemId){
- return thePNodeInfo->GetNodeCoord(theElemId,TheCoordId);
-}
-
-template<>
-TFloat GetCoord<eNone>(MED::PNodeInfo& thePNodeInfo, TInt theElemId){
- return 0.0;
-}
-
-
-static TGetCoord aXYZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eZ>
-};
-
-
-static TGetCoord aXYGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eNone>
-};
-
-static TGetCoord aYZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eY>
-};
-
-static TGetCoord aXZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eY>
-};
-
-
-static TGetCoord aXGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eNone>
-};
-
-static TGetCoord aYGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eNone>
-};
-
-static TGetCoord aZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eNone>,
- &GetCoord<eX>
-};
-
-
-class TCoordHelper{
- MED::PNodeInfo myPNodeInfo;
- TGetCoord* myGetCoord;
-public:
- TCoordHelper(const MED::PNodeInfo& thePNodeInfo,
- TGetCoord* theGetCoord):
- myPNodeInfo(thePNodeInfo),
- myGetCoord(theGetCoord)
- {}
- virtual ~TCoordHelper(){}
- TFloat GetCoord(TInt theElemId, TInt theCoodId){
- return (*myGetCoord[theCoodId])(myPNodeInfo,theElemId);
- }
-};
-typedef boost::shared_ptr<TCoordHelper> TCoordHelperPtr;
-
-
-Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
+Driver_Mesh::Status
+DriverMED_R_SMESHDS_Mesh
+::Perform()
{
Status aResult = DRS_FAIL;
try{
//------------------------------------------------------
PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
- TCoordHelperPtr aCoordHelperPtr;
- {
- TInt aMeshDimension = aMeshInfo->GetDim();
- bool anIsDimPresent[3] = {false, false, false};
- for(TInt iDim = 0; iDim < aMeshDimension; iDim++){
- string aDimName = aNodeInfo->GetCoordName(iDim);
- if(aDimName == "x" || aDimName == "X")
- anIsDimPresent[eX] = true;
- else if(aDimName == "y" || aDimName == "Y")
- anIsDimPresent[eY] = true;
- else if(aDimName == "z" || aDimName == "Z")
- anIsDimPresent[eZ] = true;
- }
- switch(aMeshDimension){
- case 3:
- aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXYZGetCoord));
- break;
- case 2:
- if(anIsDimPresent[eY] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aYZGetCoord));
- else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXZGetCoord));
- else
- aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXYGetCoord));
- break;
- case 1:
- if(anIsDimPresent[eY])
- aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aYGetCoord));
- else if(anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aZGetCoord));
- else
- aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXGetCoord));
- break;
- }
- }
+ PCoordHelper aCoordHelper = GetCoordHelper(aNodeInfo);
EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
TInt aNbElems = aNodeInfo->GetNbElem();
if(MYDEBUG) MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
DriverMED_FamilyPtr aFamily;
for(TInt iElem = 0; iElem < aNbElems; iElem++){
+ TCCoordSlice aCoordSlice = aNodeInfo->GetCoordSlice(iElem);
double aCoords[3] = {0.0, 0.0, 0.0};
for(TInt iDim = 0; iDim < 3; iDim++)
- aCoords[iDim] = aCoordHelperPtr->GetCoord(iElem,iDim);
+ aCoords[iDim] = aCoordHelper->GetCoord(aCoordSlice,iDim);
const SMDS_MeshNode* aNode;
if(anIsNodeNum) {
aNode = myMesh->AddNodeWithID
// Reading pre information about all MED cells
//--------------------------------------------
+ typedef MED::TVector<int> TNodeIds;
bool takeNumbers = true; // initially we trust the numbers from file
MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin();
if(anEntity == eNOEUD) continue;
// Reading MED cells to the corresponding SMDS structure
//------------------------------------------------------
- const MED::TGeom& aTGeom = anEntityIter->second;
- MED::TGeom::const_iterator anTGeomIter = aTGeom.begin();
- for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
- const EGeometrieElement& aGeom = anTGeomIter->first;
-
- if (aGeom == ePOINT1) {
- continue;
-
- } else if (aGeom == ePOLYGONE) {
+ const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
+ MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
+ for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
+ const EGeometrieElement& aGeom = aGeom2SizeIter->first;
+
+ switch(aGeom){
+ case ePOINT1:
+ break;
+ case ePOLYGONE: {
PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aPolygoneInfo->IsElemNum() : eFAUX;
-
- TElemNum aConn = aPolygoneInfo->GetConnectivite();
- TElemNum aIndex = aPolygoneInfo->GetIndex();
-
- TInt nbPolygons = aPolygoneInfo->GetNbElem();
-
- for (TInt iPG = 0; iPG < nbPolygons; iPG++) {
- // get nodes
- TInt aCurrPG_FirstNodeIndex = aIndex[iPG] - 1;
- int nbNodes = aPolygoneInfo->GetNbConn(iPG);
- std::vector<int> nodes_ids (nbNodes);
- //for (TInt inode = 0; inode < nbNodes; inode++) {
- // nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
- //}
+
+ TInt aNbElem = aPolygoneInfo->GetNbElem();
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
+ TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
+ TNodeIds aNodeIds(aNbConn);
#ifdef _EDF_NODE_IDS_
- if (anIsNodeNum) {
- for (TInt inode = 0; inode < nbNodes; inode++) {
- nodes_ids[inode] = aNodeInfo->GetElemNum(aConn[aCurrPG_FirstNodeIndex + inode] - 1);
- }
- } else {
- for (TInt inode = 0; inode < nbNodes; inode++) {
- nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
- }
- }
+ if(anIsNodeNum)
+ for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ aNodeIds[iConn] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
+ else
+ for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ aNodeIds[iConn] = aConnSlice[iConn];
#else
- for (TInt inode = 0; inode < nbNodes; inode++) {
- nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
- }
+ for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ aNodeIds[iConn] = aConnSlice[iConn];
#endif
-
bool isRenum = false;
SMDS_MeshElement* anElement = NULL;
- TInt aFamNum = aPolygoneInfo->GetFamNum(iPG);
+ TInt aFamNum = aPolygoneInfo->GetFamNum(iElem);
- try {
- if (anIsElemNum) {
- anElement = myMesh->AddPolygonalFaceWithID
- (nodes_ids, aPolygoneInfo->GetElemNum(iPG));
- }
- if (!anElement) {
- std::vector<const SMDS_MeshNode*> nodes (nbNodes);
- for (int inode = 0; inode < nbNodes; inode++) {
- nodes[inode] = FindNode(myMesh, nodes_ids[inode]);
- }
- anElement = myMesh->AddPolygonalFace(nodes);
+ try{
+ if(anIsElemNum){
+ TInt anElemId = aPolygoneInfo->GetElemNum(iElem);
+ anElement = myMesh->AddPolygonalFaceWithID(aNodeIds,anElemId);
+ }
+ if(!anElement){
+ std::vector<const SMDS_MeshNode*> aNodes(aNbConn);
+ for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
+ anElement = myMesh->AddPolygonalFace(aNodes);
isRenum = anIsElemNum;
}
- } catch (const std::exception& exc) {
+ }catch(const std::exception& exc){
aResult = DRS_FAIL;
- } catch (...) {
+ }catch (...){
aResult = DRS_FAIL;
}
- if (!anElement) {
+ if(!anElement){
aResult = DRS_WARN_SKIP_ELEM;
- } else {
- if (isRenum) {
+ }else{
+ if(isRenum){
anIsElemNum = eFAUX;
takeNumbers = false;
- if (aResult < DRS_WARN_RENUMBER)
+ if(aResult < DRS_WARN_RENUMBER)
aResult = DRS_WARN_RENUMBER;
}
if ( checkFamilyID ( aFamily, aFamNum ))
aFamily->SetType(anElement->GetType());
}
}
- } // for (TInt iPG = 0; iPG < nbPolygons; iPG++)
- continue;
-
- } else if (aGeom == ePOLYEDRE) {
+ }
+ break;
+ }
+ case ePOLYEDRE: {
PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aPolyedreInfo->IsElemNum() : eFAUX;
- TElemNum aConn = aPolyedreInfo->GetConnectivite();
- TElemNum aFacesIndex = aPolyedreInfo->GetFacesIndex();
- TElemNum aIndex = aPolyedreInfo->GetIndex();
-
- TInt nbPolyedres = aPolyedreInfo->GetNbElem();
-
- for (int iPE = 0; iPE < nbPolyedres; iPE++) {
- // get faces
- int aCurrPE_FirstFaceIndex = aIndex[iPE] - 1;
- int aNextPE_FirstFaceIndex = aIndex[iPE + 1] - 1;
- int nbFaces = aNextPE_FirstFaceIndex - aCurrPE_FirstFaceIndex;
- std::vector<int> quantities (nbFaces);
- for (int iFa = 0; iFa < nbFaces; iFa++) {
- int aCurrFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa] - 1;
- int aNextFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa + 1] - 1;
-
- int nbNodes = aNextFace_FirstNodeIndex - aCurrFace_FirstNodeIndex;
- quantities[iFa] = nbNodes;
- }
-
- // get nodes
- int aCurrPE_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex] - 1;
- int nbPENodes = aPolyedreInfo->GetNbConn(iPE);
- std::vector<int> nodes_ids (nbPENodes);
- //for (int inode = 0; inode < nbPENodes; inode++) {
- // nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
- //}
+ TInt aNbElem = aPolyedreInfo->GetNbElem();
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
+ TInt aNbFaces = aConnSliceArr.size();
+ typedef MED::TVector<int> TQuantities;
+ TQuantities aQuantities(aNbFaces);
+ TInt aNbNodes = aPolyedreInfo->GetNbNodes(iElem);
+ TNodeIds aNodeIds(aNbNodes);
+ for(TInt iFace = 0, iNode = 0; iFace < aNbFaces; iFace++){
+ MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
+ TInt aNbConn = aConnSlice.size();
+ aQuantities[iFace] = aNbConn;
#ifdef _EDF_NODE_IDS_
- if (anIsNodeNum) {
- for (int inode = 0; inode < nbPENodes; inode++) {
- nodes_ids[inode] = aNodeInfo->GetElemNum(aConn[aCurrPE_FirstNodeIndex + inode] - 1);
- }
- } else {
- for (int inode = 0; inode < nbPENodes; inode++) {
- nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
- }
- }
+ if(anIsNodeNum)
+ for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ aNodeIds[iNode++] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
+ else
+ for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ aNodeIds[iNode++] = aConnSlice[iConn];
#else
- for (int inode = 0; inode < nbPENodes; inode++) {
- nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
+ for(TInt iConn = 0; iConn < aNbConn; iConn++)
+ aNodeIds[iNode++] = aConnSlice[iConn];
+#endif
}
-#endif
-
- bool isRenum = false;
- SMDS_MeshElement* anElement = NULL;
- TInt aFamNum = aPolyedreInfo->GetFamNum(iPE);
- try {
- if (anIsElemNum) {
- anElement = myMesh->AddPolyhedralVolumeWithID
- (nodes_ids, quantities, aPolyedreInfo->GetElemNum(iPE));
- }
- if (!anElement) {
- std::vector<const SMDS_MeshNode*> nodes (nbPENodes);
- for (int inode = 0; inode < nbPENodes; inode++) {
- nodes[inode] = FindNode(myMesh, nodes_ids[inode]);
- }
- anElement = myMesh->AddPolyhedralVolume(nodes, quantities);
- isRenum = anIsElemNum;
- }
- } catch (const std::exception& exc) {
- aResult = DRS_FAIL;
- } catch (...) {
- aResult = DRS_FAIL;
- }
-
- if (!anElement) {
- aResult = DRS_WARN_SKIP_ELEM;
- } else {
- if (isRenum) {
- anIsElemNum = eFAUX;
- takeNumbers = false;
- if (aResult < DRS_WARN_RENUMBER)
- aResult = DRS_WARN_RENUMBER;
- }
- if ( checkFamilyID ( aFamily, aFamNum ))
- {
- // Save reference to this element from its family
- aFamily->AddElement(anElement);
- aFamily->SetType(anElement->GetType());
- }
- }
- } // for (int iPE = 0; iPE < nbPolyedres; iPE++)
- continue;
-
- } else {
- }
-
- PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
- EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
- TInt aNbElems = aCellInfo->GetNbElem();
- if(MYDEBUG) MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
- if(MYDEBUG) MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
-
- for(int iElem = 0; iElem < aNbElems; iElem++){
- TInt aNbNodes = -1;
- switch(aGeom){
- case eSEG2:
- case eSEG3:
- aNbNodes = 2;
- break;
- case eTRIA3:
- case eTRIA6:
- aNbNodes = 3;
- break;
- break;
- case eQUAD4:
- case eQUAD8:
- aNbNodes = 4;
- break;
- case eTETRA4:
- case eTETRA10:
- aNbNodes = 4;
- break;
- case ePYRA5:
- case ePYRA13:
- aNbNodes = 5;
- break;
- case ePENTA6:
- case ePENTA15:
- aNbNodes = 6;
- break;
- case eHEXA8:
- case eHEXA20:
- aNbNodes = 8;
- break;
- }
- vector<TInt> aNodeIds(aNbNodes);
- bool anIsValidConnect = false;
-
- try{
-#ifdef _EDF_NODE_IDS_
- if(anIsNodeNum) {
- for(int i = 0; i < aNbNodes; i++){
- aNodeIds[i] = aNodeInfo->GetElemNum(aCellInfo->GetConn(iElem,i)-1);
+ bool isRenum = false;
+ SMDS_MeshElement* anElement = NULL;
+ TInt aFamNum = aPolyedreInfo->GetFamNum(iElem);
+
+ try{
+ if(anIsElemNum){
+ TInt anElemId = aPolyedreInfo->GetElemNum(iElem);
+ anElement = myMesh->AddPolyhedralVolumeWithID(aNodeIds,aQuantities,anElemId);
}
- }else{
- for(int i = 0; i < aNbNodes; i++){
- aNodeIds[i] = aCellInfo->GetConn(iElem,i);
+ if(!anElement){
+ std::vector<const SMDS_MeshNode*> aNodes(aNbNodes);
+ for(TInt iConn = 0; iConn < aNbNodes; iConn++)
+ aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
+ anElement = myMesh->AddPolyhedralVolume(aNodes,aQuantities);
+ isRenum = anIsElemNum;
}
+ }catch(const std::exception& exc){
+ aResult = DRS_FAIL;
+ }catch(...){
+ aResult = DRS_FAIL;
}
-#else
- for(int i = 0; i < aNbNodes; i++){
- aNodeIds[i] = aCellInfo->GetConn(iElem,i);
+
+ if(!anElement){
+ aResult = DRS_WARN_SKIP_ELEM;
+ }else{
+ if(isRenum){
+ anIsElemNum = eFAUX;
+ takeNumbers = false;
+ if (aResult < DRS_WARN_RENUMBER)
+ aResult = DRS_WARN_RENUMBER;
+ }
+ if ( checkFamilyID ( aFamily, aFamNum )) {
+ // Save reference to this element from its family
+ aFamily->AddElement(anElement);
+ aFamily->SetType(anElement->GetType());
+ }
}
-#endif
- anIsValidConnect = true;
- }catch(const std::exception& exc){
- //INFOS("Follow exception was cought:\n\t"<<exc.what());
- aResult = DRS_FAIL;
- }catch(...){
- //INFOS("Unknown exception was cought !!!");
- aResult = DRS_FAIL;
}
+ break;
+ }
+ default: {
+ PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
+ EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
+ TInt aNbElems = aCellInfo->GetNbElem();
+ if(MYDEBUG) MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
+ if(MYDEBUG) MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
- if(!anIsValidConnect)
- continue;
-
- bool isRenum = false;
- SMDS_MeshElement* anElement = NULL;
- TInt aFamNum = aCellInfo->GetFamNum(iElem);
- try{
- //MESSAGE("Try to create element # " << iElem << " with id = "
- // << aCellInfo->GetElemNum(iElem));
+ for(int iElem = 0; iElem < aNbElems; iElem++){
+ TInt aNbNodes = -1;
switch(aGeom){
case eSEG2:
case eSEG3:
- if(anIsElemNum)
- anElement = myMesh->AddEdgeWithID(aNodeIds[0],
- aNodeIds[1],
- aCellInfo->GetElemNum(iElem));
- if (!anElement) {
- anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
- FindNode(myMesh,aNodeIds[1]));
- isRenum = anIsElemNum;
- }
+ aNbNodes = 2;
break;
case eTRIA3:
case eTRIA6:
aNbNodes = 3;
- if(anIsElemNum)
- anElement = myMesh->AddFaceWithID(aNodeIds[0],
- aNodeIds[1],
- aNodeIds[2],
- aCellInfo->GetElemNum(iElem));
- if (!anElement) {
- anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
- FindNode(myMesh,aNodeIds[1]),
- FindNode(myMesh,aNodeIds[2]));
- isRenum = anIsElemNum;
- }
+ break;
break;
case eQUAD4:
case eQUAD8:
aNbNodes = 4;
- // There is some differnce between SMDS and MED
- if(anIsElemNum)
- anElement = myMesh->AddFaceWithID(aNodeIds[0],
- aNodeIds[1],
- aNodeIds[2],
- aNodeIds[3],
- aCellInfo->GetElemNum(iElem));
- if (!anElement) {
- anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
- FindNode(myMesh,aNodeIds[1]),
- FindNode(myMesh,aNodeIds[2]),
- FindNode(myMesh,aNodeIds[3]));
- isRenum = anIsElemNum;
- }
break;
case eTETRA4:
case eTETRA10:
aNbNodes = 4;
- if(anIsElemNum)
- anElement = myMesh->AddVolumeWithID(aNodeIds[0],
- aNodeIds[1],
- aNodeIds[2],
- aNodeIds[3],
- aCellInfo->GetElemNum(iElem));
- if (!anElement) {
- anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
- FindNode(myMesh,aNodeIds[1]),
- FindNode(myMesh,aNodeIds[2]),
- FindNode(myMesh,aNodeIds[3]));
- isRenum = anIsElemNum;
- }
break;
case ePYRA5:
case ePYRA13:
aNbNodes = 5;
- // There is some differnce between SMDS and MED
- if(anIsElemNum)
- anElement = myMesh->AddVolumeWithID(aNodeIds[0],
- aNodeIds[1],
- aNodeIds[2],
- aNodeIds[3],
- aNodeIds[4],
- 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]));
- isRenum = anIsElemNum;
- }
break;
case ePENTA6:
case ePENTA15:
aNbNodes = 6;
- if(anIsElemNum)
- anElement = myMesh->AddVolumeWithID(aNodeIds[0],
- aNodeIds[1],
- aNodeIds[2],
- aNodeIds[3],
- aNodeIds[4],
- aNodeIds[5],
- 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]));
- isRenum = anIsElemNum;
- }
break;
case eHEXA8:
case eHEXA20:
aNbNodes = 8;
- if(anIsElemNum)
- anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+ break;
+ }
+ TNodeIds aNodeIds(aNbNodes);
+ bool anIsValidConnect = false;
+ TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
+ try{
+#ifdef _EDF_NODE_IDS_
+ if(anIsNodeNum)
+ for(int iNode = 0; iNode < aNbNodes; iNode++)
+ aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iNode] - 1);
+ else
+ for(int iNode = 0; iNode < aNbNodes; iNode++)
+ aNodeIds[iNode] = aConnSlice[iNode];
+#else
+ for(int iNode = 0; iNode < aNbNodes; iNode++)
+ aNodeIds[iNode] = aConnSlice[iNode];
+#endif
+ anIsValidConnect = true;
+ }catch(const std::exception& exc){
+ //INFOS("Follow exception was cought:\n\t"<<exc.what());
+ aResult = DRS_FAIL;
+ }catch(...){
+ //INFOS("Unknown exception was cought !!!");
+ aResult = DRS_FAIL;
+ }
+
+ if(!anIsValidConnect)
+ continue;
+
+ bool isRenum = false;
+ SMDS_MeshElement* anElement = NULL;
+ TInt aFamNum = aCellInfo->GetFamNum(iElem);
+ try{
+ //MESSAGE("Try to create element # " << iElem << " with id = "
+ // << aCellInfo->GetElemNum(iElem));
+ switch(aGeom){
+ case eSEG2:
+ case eSEG3:
+ if(anIsElemNum)
+ anElement = myMesh->AddEdgeWithID(aNodeIds[0],
+ aNodeIds[1],
+ aCellInfo->GetElemNum(iElem));
+ if (!anElement) {
+ anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
+ FindNode(myMesh,aNodeIds[1]));
+ isRenum = anIsElemNum;
+ }
+ break;
+ case eTRIA3:
+ case eTRIA6:
+ aNbNodes = 3;
+ if(anIsElemNum)
+ anElement = myMesh->AddFaceWithID(aNodeIds[0],
+ aNodeIds[1],
+ aNodeIds[2],
+ aCellInfo->GetElemNum(iElem));
+ if (!anElement) {
+ anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
+ FindNode(myMesh,aNodeIds[1]),
+ FindNode(myMesh,aNodeIds[2]));
+ isRenum = anIsElemNum;
+ }
+ break;
+ case eQUAD4:
+ case eQUAD8:
+ aNbNodes = 4;
+ // There is some differnce between SMDS and MED
+ if(anIsElemNum)
+ anElement = myMesh->AddFaceWithID(aNodeIds[0],
aNodeIds[1],
aNodeIds[2],
aNodeIds[3],
- aNodeIds[4],
- aNodeIds[5],
- aNodeIds[6],
- aNodeIds[7],
aCellInfo->GetElemNum(iElem));
- if (!anElement) {
- anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+ if (!anElement) {
+ anElement = myMesh->AddFace(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]));
- isRenum = anIsElemNum;
+ FindNode(myMesh,aNodeIds[3]));
+ isRenum = anIsElemNum;
+ }
+ break;
+ case eTETRA4:
+ case eTETRA10:
+ aNbNodes = 4;
+ if(anIsElemNum)
+ anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+ aNodeIds[1],
+ aNodeIds[2],
+ aNodeIds[3],
+ aCellInfo->GetElemNum(iElem));
+ if (!anElement) {
+ anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+ FindNode(myMesh,aNodeIds[1]),
+ FindNode(myMesh,aNodeIds[2]),
+ FindNode(myMesh,aNodeIds[3]));
+ isRenum = anIsElemNum;
+ }
+ break;
+ case ePYRA5:
+ case ePYRA13:
+ aNbNodes = 5;
+ // There is some differnce between SMDS and MED
+ if(anIsElemNum)
+ anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+ aNodeIds[1],
+ aNodeIds[2],
+ aNodeIds[3],
+ aNodeIds[4],
+ 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]));
+ isRenum = anIsElemNum;
+ }
+ break;
+ case ePENTA6:
+ case ePENTA15:
+ aNbNodes = 6;
+ if(anIsElemNum)
+ anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+ aNodeIds[1],
+ aNodeIds[2],
+ aNodeIds[3],
+ aNodeIds[4],
+ aNodeIds[5],
+ 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]));
+ isRenum = anIsElemNum;
+ }
+ break;
+ case eHEXA8:
+ case eHEXA20:
+ aNbNodes = 8;
+ if(anIsElemNum)
+ anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+ aNodeIds[1],
+ aNodeIds[2],
+ aNodeIds[3],
+ aNodeIds[4],
+ aNodeIds[5],
+ aNodeIds[6],
+ aNodeIds[7],
+ 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]));
+ isRenum = anIsElemNum;
+ }
+ break;
}
- break;
+ }catch(const std::exception& exc){
+ //INFOS("Follow exception was cought:\n\t"<<exc.what());
+ aResult = DRS_FAIL;
+ }catch(...){
+ //INFOS("Unknown exception was cought !!!");
+ aResult = DRS_FAIL;
}
- }catch(const std::exception& exc){
- //INFOS("Follow exception was cought:\n\t"<<exc.what());
- aResult = DRS_FAIL;
- }catch(...){
- //INFOS("Unknown exception was cought !!!");
- aResult = DRS_FAIL;
- }
- if (!anElement) {
- aResult = DRS_WARN_SKIP_ELEM;
- }
- else {
- if (isRenum) {
- anIsElemNum = eFAUX;
- takeNumbers = false;
- if (aResult < DRS_WARN_RENUMBER)
- aResult = DRS_WARN_RENUMBER;
- }
- if ( checkFamilyID ( aFamily, aFamNum ))
- {
- // Save reference to this element from its family
- aFamily->AddElement(anElement);
- aFamily->SetType(anElement->GetType());
- }
- }
- }
+ if (!anElement) {
+ aResult = DRS_WARN_SKIP_ELEM;
+ }
+ else {
+ if (isRenum) {
+ anIsElemNum = eFAUX;
+ takeNumbers = false;
+ if (aResult < DRS_WARN_RENUMBER)
+ aResult = DRS_WARN_RENUMBER;
+ }
+ if ( checkFamilyID ( aFamily, aFamNum )) {
+ // Save reference to this element from its family
+ myFamilies[aFamNum]->AddElement(anElement);
+ myFamilies[aFamNum]->SetType(anElement->GetType());
+ }
+ }
+ }
+ }}
}
}
- break;
}
}
}catch(const std::exception& exc){
int aFamId = (*aFamsIter)->GetId();
const set<const SMDS_MeshElement *>& anElems = (*aFamsIter)->GetElements();
- set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElems.begin();
+ set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElems.begin();
for (; anElemsIter != anElems.end(); anElemsIter++)
{
anElemFamMap[*anElemsIter] = aFamId;
}
-// delete (*aFamsIter);
}
// Storing SMDS nodes to the MED file for the MED mesh
const ERepere SMDS_COORDINATE_SYSTEM = eCART;
PNodeInfo aNodeInfo = myMed->CrNodeInfo(aMeshInfo,
- SMDS_COORDINATE_SYSTEM,
aCoordinates,
+ eFULL_INTERLACE,
+ SMDS_COORDINATE_SYSTEM,
aCoordNames,
aCoordUnits,
aFamilyNums,
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eSEG2,
- SMDS_MED_CONNECTIVITY,
aConnectivity,
+ SMDS_MED_CONNECTIVITY,
aFamilyNums,
anElemNums);
myMed->SetCellInfo(aCellInfo);
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eTRIA3,
- SMDS_MED_CONNECTIVITY,
aTriaConn,
+ SMDS_MED_CONNECTIVITY,
aTriaFamilyNums,
anTriaElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTRIA3<<"; aNbElems = "<<aNbElems);
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eQUAD4,
- SMDS_MED_CONNECTIVITY,
aQuadConn,
+ SMDS_MED_CONNECTIVITY,
aQuadFamilyNums,
aQuadElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems);
PPolygoneInfo aCellInfo = myMed->CrPolygoneInfo(aMeshInfo,
SMDS_MED_ENTITY,
ePOLYGONE,
- SMDS_MED_CONNECTIVITY,
- aPolygoneConn,
aPolygoneInds,
+ aPolygoneConn,
+ SMDS_MED_CONNECTIVITY,
aPolygoneFamilyNums,
aPolygoneElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYGONE<<"; aNbElems = "<<aNbElems);
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eTETRA4,
- SMDS_MED_CONNECTIVITY,
aTetraConn,
+ SMDS_MED_CONNECTIVITY,
aTetraFamilyNums,
anTetraElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTETRA4<<"; aNbElems = "<<aNbElems);
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
ePYRA5,
- SMDS_MED_CONNECTIVITY,
aPyraConn,
+ SMDS_MED_CONNECTIVITY,
aPyraFamilyNums,
anPyraElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePYRA5<<"; aNbElems = "<<aNbElems);
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
ePENTA6,
- SMDS_MED_CONNECTIVITY,
aPentaConn,
+ SMDS_MED_CONNECTIVITY,
aPentaFamilyNums,
anPentaElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePENTA6<<"; aNbElems = "<<aNbElems);
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eHEXA8,
- SMDS_MED_CONNECTIVITY,
aHexaConn,
+ SMDS_MED_CONNECTIVITY,
aHexaFamilyNums,
aHexaElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems);
PPolyedreInfo aCellInfo = myMed->CrPolyedreInfo(aMeshInfo,
SMDS_MED_ENTITY,
ePOLYEDRE,
- SMDS_MED_CONNECTIVITY,
- aPolyedreConn,
- aPolyedreFaces,
aPolyedreInds,
+ aPolyedreFaces,
+ aPolyedreConn,
+ SMDS_MED_CONNECTIVITY,
aPolyedreFamilyNums,
aPolyedreElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYEDRE<<"; aNbElems = "<<aNbElems);
CXXFLAGS += $(OCC_CXXFLAGS) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS += -lMeshDriver -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper
-LDFLAGSFORBIN += -lMeshDriver -lSMDS -lSMESHDS -L${KERNEL_ROOT_DIR}/lib/salome -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lMEDWrapper_V2_2 -lOpUtil -lSALOMELocalTrace -lSALOMEBasics
+LDFLAGSFORBIN += -lMeshDriver -lSMDS -lSMESHDS -L${KERNEL_ROOT_DIR}/lib/salome -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lmed_V2_1 -lMEDWrapper_V2_2 -lOpUtil -lSALOMELocalTrace -lSALOMEBasics
@CONCLUDE@
#include "SMESH_ActorUtils.h"
#include "SMESH_DeviceActor.h"
#include "SMESH_ControlsDef.hxx"
-#include <VTKViewer_ExtractUnstructuredGrid.h>
+#include "VTKViewer_ExtractUnstructuredGrid.h"
#include "SUIT_Session.h"
#include "SUIT_ResourceMgr.h"
#include <qstringlist.h>
+#include <vtkProperty.h>
#include <vtkTimeStamp.h>
#include <vtkObjectFactory.h>
#include <vtkShrinkPolyData.h>
void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
+ Superclass::SetTransform(theTransform);
+
myNodeActor->SetTransform(theTransform);
myBaseActor->SetTransform(theTransform);
#include "SMESH_Mesh.hxx"
#include "SMESH_HypoFilter.hxx"
#include "SMDS_FacePosition.hxx"
+#include "SMDS_EdgePosition.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMESHDS_Mesh.hxx"
double SMESH_Algo::EdgeLength(const TopoDS_Edge & E)
{
- double UMin = 0, UMax = 0;
- TopLoc_Location L;
- if (BRep_Tool::Degenerated(E))
- return 0;
- Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
- GeomAdaptor_Curve AdaptCurve(C);
- GCPnts_AbscissaPoint gabs;
- double length = gabs.Length(AdaptCurve, UMin, UMax);
- return length;
+ double UMin = 0, UMax = 0;
+ if (BRep_Tool::Degenerated(E))
+ return 0;
+ TopLoc_Location L;
+ Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
+ GeomAdaptor_Curve AdaptCurve(C);
+ GCPnts_AbscissaPoint gabs;
+ double length = gabs.Length(AdaptCurve, UMin, UMax);
+ return length;
}
//================================================================================
/*!
* \brief Find out elements orientation on a geometrical face
- * \param theFace - The face correctly oriented in the shape being meshed
- * \param theMeshDS - The mesh data structure
- * \retval bool - true if the face normal and the normal of first element
- * in the correspoding submesh point in different directions
+ * \param theFace - The face correctly oriented in the shape being meshed
+ * \param theMeshDS - The mesh data structure
+ * \retval bool - true if the face normal and the normal of first element
+ * in the correspoding submesh point in different directions
*/
//================================================================================
return Ne * Nf < 0.;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as the algorithm does not hold parameters values
+ */
+//================================================================================
+
+bool SMESH_Algo::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+ const TopoDS_Shape& /*theShape*/)
+{
+ return false;
+}
+
+//================================================================================
+/*!
+ * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
+ * \param theMesh - The mesh containing nodes
+ * \param theEdge - The geometrical edge of interest
+ * \param theParams - The resulting vector of sorted node parameters
+ * \retval bool - false if not all parameters are OK
+ */
+//================================================================================
+
+bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
+ const TopoDS_Edge& theEdge,
+ vector< double > & theParams)
+{
+ theParams.clear();
+
+ if ( !theMesh || theEdge.IsNull() )
+ return false;
+
+ SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
+ if ( !eSubMesh || !eSubMesh->GetElements()->more() )
+ return false; // edge is not meshed
+
+ int nbEdgeNodes = 0;
+ set < double > paramSet;
+ if ( eSubMesh )
+ {
+ // loop on nodes of an edge: sort them by param on edge
+ SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
+ while ( nIt->more() )
+ {
+ const SMDS_MeshNode* node = nIt->next();
+ const SMDS_PositionPtr& pos = node->GetPosition();
+ if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
+ return false;
+ const SMDS_EdgePosition* epos =
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ paramSet.insert( epos->GetUParameter() );
+ ++nbEdgeNodes;
+ }
+ }
+ // add vertex nodes params
+ Standard_Real f, l;
+ BRep_Tool::Range(theEdge, f, l);
+ paramSet.insert( f );
+ paramSet.insert( l );
+ if ( paramSet.size() != nbEdgeNodes + 2 )
+ return false; // there are equal parameters
+
+ // fill the vector
+ theParams.resize( paramSet.size() );
+ set < double >::iterator par = paramSet.begin();
+ vector< double >::iterator vecPar = theParams.begin();
+ for ( ; par != paramSet.end(); ++par, ++vecPar )
+ *vecPar = *par;
+
+ return theParams.size() > 1;
+}
class SMESH_Gen;
class SMESH_Mesh;
class TopoDS_Face;
+class TopoDS_Shape;
class SMESHDS_Mesh;
class SMESH_Algo:public SMESH_Hypothesis
static double EdgeLength(const TopoDS_Edge & E);
+ /*!
+ * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
+ * \param theMesh - The mesh containing nodes
+ * \param theEdge - The geometrical edge of interest
+ * \param theParams - The resulting vector of sorted node parameters
+ * \retval bool - false if not all parameters are OK
+ */
+ static bool GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
+ const TopoDS_Edge& theEdge,
+ std::vector< double > & theParams);
+
+ //static bool GetSegmentLengths();
+
/*!
* \brief Find out elements orientation on a geometrical face
* \param theFace - The face correctly oriented in the shape being meshed
static bool IsReversedSubMesh (const TopoDS_Face& theFace,
SMESHDS_Mesh* theMeshDS);
+ /*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as the algorithm does not hold parameters values
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
public:
// algo features
#include "SMESHDS_Hypothesis.hxx"
class SMESH_Gen;
+class TopoDS_Shape;
+class SMESH_Mesh;
class SMESH_Hypothesis: public SMESHDS_Hypothesis
{
const char* GetLibName() const;
void SetLibName(const char* theLibName);
+ /*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape)=0;
+
protected:
SMESH_Gen* _gen;
int _studyId;
if (_mapGroup.find(theGroupID) == _mapGroup.end())
return;
GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
- _mapGroup.erase (theGroupID);
delete _mapGroup[theGroupID];
+ _mapGroup.erase (theGroupID);
}
//=============================================================================
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) \
-I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
- -I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR}
+ -I${GEOM_ROOT_DIR}/include/salome ${BOOST_CPPFLAGS}
CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR}
LDFLAGS += $(OCC_KERNEL_LIBS) -L${GUI_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeApp -lsuit
SMESHGUI_MeshDlg.cxx \
SMESHGUI_MeshOp.cxx \
SMESHGUI_Displayer.cxx \
- SMESHGUI_Hypotheses.cxx
+ SMESHGUI_Hypotheses.cxx \
+ SMESHGUI_ShapeByMeshDlg.cxx
LIB_MOC = \
SMESHGUI.h \
SMESHGUI_Dialog.h \
SMESHGUI_MeshDlg.h \
SMESHGUI_MeshOp.h \
- SMESHGUI_Hypotheses.h
+ SMESHGUI_Hypotheses.h \
+ SMESHGUI_ShapeByMeshDlg.h
LIB_CLIENT_IDL = SALOME_Exception.idl \
#include "SUIT_ResourceMgr.h"
#include "SUIT_FileDlg.h"
#include "SUIT_Desktop.h"
-#include "SUIT_ResourceMgr.h"
#include "SUIT_OverrideCursor.h"
#include "SUIT_Study.h"
#include "SUIT_Session.h"
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 );
void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
{
- if( sect=="SMESH" )
+ if( sect=="SMESH" ){
+ float sbX1,sbY1,sbW,sbH;
+ std::string aWarning;
+ SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
if( name=="selection_object_color" || name=="selection_element_color" ||
name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
name=="selection_precision_node" || name=="selection_precision_element" )
SMESH::UpdateSelectionProp( this );
+ else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
+ sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
+ sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
+ if(sbX1+sbW > 1.0){
+ aWarning = "Origin and Size Vertical: X+Width > 1\n";
+ sbX1=0.01;
+ sbW=0.05;
+ aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
+ aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
+ }
+ }
+ else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
+ sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
+ sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
+ if(sbY1+sbH > 1.0){
+ aWarning = "Origin and Size Vertical: Y+Height > 1\n";
+ sbY1=0.01;
+ sbH=0.5;
+ aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
+ aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
+ }
+ }
+ else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
+ sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
+ sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
+ if(sbX1+sbW > 1.0){
+ aWarning = "Origin and Size Horizontal: X+Width > 1\n";
+ sbX1=0.2;
+ sbW=0.6;
+ aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
+ aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
+ }
+ }
+ else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
+ sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
+ sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
+ if(sbY1+sbH > 1.0){
+ aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
+ sbY1=0.01;
+ sbH=0.12;
+ aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
+ aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
+ }
+ }
+
+ if(aWarning.size() != 0){
+ aWarning += "The default values are applied instead.";
+ SUIT_MessageBox::warn1(SMESHGUI::desktop(),
+ QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
+ QObject::tr(aWarning.c_str()),
+ QObject::tr("SMESH_BUT_OK"));
+ }
+ }
}
//================================================================================
return op;
}
+//================================================================================
+/*!
+ * \brief Stops current operations and starts a given one
+ * \param id - The id of the operation to start
+ */
+//================================================================================
+
+void SMESHGUI::switchToOperation(int id)
+{
+ if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
+ activeStudy()->abortAllOperations();
+ startOperation( id );
+}
+
LightApp_Displayer* SMESHGUI::displayer()
{
if( !myDisplayer )
void ResetState() ;
void SetState(int aState) ;
bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
+ void switchToOperation(int id) ;
virtual bool OnGUIEvent ( int id );
virtual bool OnMousePress ( QMouseEvent*, SUIT_ViewWindow* );
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
// QT Includes
#include <qbuttongroup.h>
#include <vtkPlaneSource.h>
#include <vtkPolyData.h>
#include <vtkRenderer.h>
+#include <vtkProperty.h>
// STL includes
#include <algorithm>
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
// QT Includes
#include <qapplication.h>
myPreviewActor->PickableOff();
myPreviewActor->VisibilityOff();
myPreviewActor->SetMapper( myMapper );
+ myPreviewActor->SetRepresentation( 3 );
float anRGB[3];
vtkProperty* aProp = vtkProperty::New();
{
if ( myActor ){
myActor->SetPointRepresentation(true);
- myActor->SetEntityMode(SMESH_Actor::eVolumes);
- myActor->SetRepresentation(SMESH_Actor::eSurface);
}
else
SMESH::SetPointRepresentation(true);
{
if( myActor ){
myActor->SetPointRepresentation(false);
- myActor->SetEntityMode(SMESH_Actor::eFaces);
- myActor->SetEntityMode(SMESH_Actor::eVolumes);
- myActor->SetRepresentation(SMESH_Actor::eSurface);
} else {
SMESH::SetPointRepresentation(false);
}
//SALOME_ListIO aList;
//mySelectionMgr->setSelectedObjects( aList );
- mySimulation->SetVisibility(false);
SMESH::UpdateView();
+ if( myActor ){
+ unsigned int anEntityMode = myActor->GetEntityMode();
+ myActor->SetEntityMode(SMESH_Actor::eVolumes | anEntityMode);
+ }
ConstructorsClicked( GetConstructorId() );
busy = false;
}
buttonOk->setEnabled( false );
buttonApply->setEnabled( false );
}
- displaySimulation();
+ if(aListId.count()>1)
+ displaySimulation();
}
}
}
// get selected nodes/faces
QString aString = "";
+ int anbNodes=0,aNbFaces=0;
switch(GetConstructorId()){
case 0:{
- int anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
+ anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
if (anbNodes >= 3)
AddButton->setEnabled(true);
else if (anbNodes < 3){
}
case 1:{
// get selected faces
- int aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
+ aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
if (aNbFaces<=1){
buttonOk->setEnabled( false );
buttonApply->setEnabled( false );
}
default: return;
}
-
- displaySimulation();
+ if(anbNodes>2 || aNbFaces>1)
+ displaySimulation();
}
//=======================================================================
SMESH::TPolySimulation::TVTKIds aVTKIds;
vtkIdType aType = VTK_CONVEX_POINT_SET ;
if (GetConstructorId() == 0){
- if(!Preview->isChecked()) myActor->SetEntityMode(SMESH_Actor::eFaces);
- else myActor->SetEntityMode(SMESH_Actor::eVolumes);
if (!AddButton->isEnabled()){
QListBoxItem* anItem;
mySimulation->ResetGrid(true);
} else {
// add ids from edit line
QStringList anEditIds = QStringList::split( " ", myEditCurrentArgument->text(), false);
- myActor->SetEntityMode(SMESH_Actor::eFaces);
for ( int i = 0; i < anEditIds.count(); i++ )
aVTKIds.push_back( myActor->GetObject()->GetNodeVTKId( anEditIds[ i ].toInt() ));
aType = VTK_POLYGON;
SMDS_Mesh* aMesh = 0;
if ( myActor ){
aMesh = myActor->GetObject()->GetMesh();
- if (Preview->isChecked())
- myActor->SetEntityMode(SMESH_Actor::eVolumes);
- else
- myActor->SetEntityMode(SMESH_Actor::eFaces);
}
if ( aMesh ) {
QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false);
//=======================================================================
void SMESHGUI_FilterDlg::insertFilterInViewer()
{
- if (SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle()) {
+ if (SVTK_Selector* aSelector = SMESH::GetSelector()) {
SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType();
if (myFilter[ myTable->GetType() ]->_is_nil() ||
myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() ||
!mySetInViewer->isChecked()) {
- SMESH::RemoveFilter(getFilterId(anEntType), aStyle);
+ SMESH::RemoveFilter(getFilterId(anEntType), aSelector);
} else {
Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter();
aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate());
- SMESH::SetFilter(aFilter, aStyle);
+ SMESH::SetFilter(aFilter, aSelector);
}
}
}
{
static GEOM::GEOM_Gen_var aGEOMGen;
- if(CORBA::is_nil(aGEOMGen))
- aGEOMGen = GeometryGUI::GetGeomGen();
+ if(CORBA::is_nil(aGEOMGen)) {
+ if ( GeometryGUI::GetGeomGen()->_is_nil() )
+ GeometryGUI::InitGeomGen();
+ aGEOMGen = GeometryGUI::GetGeomGen();
+ }
return aGEOMGen;
}
WStyle_Title | WStyle_SysMenu | WDestructiveClose),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
myIsBusy( false ),
myActor( 0 )
{
myGeomGroupLine->setEnabled(false);
}
- mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
/* Move widget on the botton right corner of main widget */
int x, y ;
WStyle_Title | WStyle_SysMenu | WDestructiveClose),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
myIsBusy( false )
{
if (!name) setName("SMESHGUI_GroupDlg");
- mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
-
initDialog(false);
if (!theGroup->_is_nil())
init(theGroup);
aViewWindow->SetSelectionMode(VolumeSelection);
}
} else {
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(ActorSelection);
if (theMode == 4)
mySelectionMgr->installFilter(mySubMeshFilter);
else if (theMode == 5)
mySelectionMgr->installFilter(myGroupFilter);
else if (theMode == 6)
mySelectionMgr->installFilter(myMeshFilter);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(ActorSelection);
}
mySelectionMode = theMode;
}
SALOME_ListIO aList;
aList.Append(myActor->getIO());
mySelectionMgr->setSelectedObjects(aList,false);
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->highlight( myActor->getIO(), true, true );
}
myIsBusy = false;
}
SMESH::ElementType aType = SMESH::ALL;
switch(myTypeId) {
- case 0: aType = SMESH::NODE; break;
- case 1: aType = SMESH::EDGE; break;
- case 2: aType = SMESH::FACE; break;
- case 3: aType = SMESH::VOLUME; break;
+ case 0:
+ aType = SMESH::NODE;
+ mySelector->SetSelectionMode(NodeSelection);
+ break;
+ case 1:
+ aType = SMESH::EDGE;
+ mySelector->SetSelectionMode(EdgeSelection);
+ break;
+ case 2:
+ aType = SMESH::FACE;
+ mySelector->SetSelectionMode(FaceSelection);
+ break;
+ case 3:
+ aType = SMESH::VOLUME;
+ mySelector->SetSelectionMode(VolumeSelection);
+ break;
+ default:
+ mySelector->SetSelectionMode(ActorSelection);
}
+
if (myCurrentLineEdit == 0) {
//if (aNbSel != 1) { myIsBusy = false; return; }
QString aListStr = "";
{
}
+void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
+ QWidget* parent)
+{
+ MESSAGE( "Creation of hypothesis with initial params" );
+
+ if ( !CORBA::is_nil( initParamsHyp ) && hypType() == initParamsHyp->GetName() )
+ myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( initParamsHyp );
+ create( false, parent );
+}
+
void SMESHGUI_GenericHypothesisCreator::create( const bool isAlgo, QWidget* parent )
{
MESSAGE( "Creation of hypothesis" );
bool res = true;
myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
+
QFrame* fr = buildFrame();
if( fr )
{
dlg->setType( type() );
retrieveParams();
res = dlg->exec()==QDialog::Accepted;
- if( res )
- storeParams();
+ if( res ) {
+ QString paramValues = storeParams();
+ if ( !paramValues.isEmpty() ) {
+ if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
+ SMESH::SetValue( SHyp, paramValues );
+ }
+ }
delete dlg;
}
changeWidgets().clear();
myHypo = SMESH::SMESH_Hypothesis::_nil();
+ myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
return res;
}
QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
GroupC1Layout->addWidget( lab, i, 0 );
- QWidget* w = 0;
- switch( (*anIt).myValue.type() )
- {
- case QVariant::Int:
- {
- QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
- attuneStdWidget( sb, i );
- sb->setValue( (*anIt).myValue.toInt() );
- connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
- w = sb;
- }
- break;
- case QVariant::Double:
- {
- QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
- attuneStdWidget( sb, i );
- sb->setValue( (*anIt).myValue.toDouble() );
- connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
- w = sb;
- }
- break;
- case QVariant::String:
+ QWidget* w = getCustomWidget( *anIt, GroupC1 );
+ if ( !w )
+ switch( (*anIt).myValue.type() )
{
- QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
- attuneStdWidget( le, i );
- le->setText( (*anIt).myValue.toString() );
- connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
- w = le;
+ case QVariant::Int:
+ {
+ QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
+ attuneStdWidget( sb, i );
+ sb->setValue( (*anIt).myValue.toInt() );
+ connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
+ w = sb;
+ }
+ break;
+ case QVariant::Double:
+ {
+ QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
+ attuneStdWidget( sb, i );
+ sb->setValue( (*anIt).myValue.toDouble() );
+ connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
+ w = sb;
+ }
+ break;
+ case QVariant::String:
+ {
+ QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
+ attuneStdWidget( le, i );
+ le->setText( (*anIt).myValue.toString() );
+ connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
+ w = le;
+ }
+ break;
}
- break;
- }
if( w )
{
params.append( item );
}
- else
+ else if ( getParamFromCustomWidget( item, *anIt ))
+ {
+ params.append( item );
+ }
+
+ else
res = false;
}
return res;
}
+QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
+{
+ QString valueStr = "";
+ ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
+ for( int i=0; param!=aLast; param++, i++ )
+ {
+ if ( i > 0 )
+ valueStr += "; ";
+ switch( (*param).myValue.type() )
+ {
+ case QVariant::Int:
+ valueStr += valueStr.number( (*param).myValue.toInt() );
+ break;
+ case QVariant::Double:
+ valueStr += valueStr.number( (*param).myValue.toDouble() );
+ break;
+ case QVariant::String:
+ valueStr += (*param).myValue.toString();
+ break;
+ default:
+ QVariant valCopy = (*param).myValue;
+ valueStr += valCopy.asString();
+ }
+ }
+ return valueStr;
+}
+
SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
{
return myHypo;
}
+SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis() const
+{
+ if ( CORBA::is_nil( myInitParamsHypo ))
+ return myHypo;
+ return myInitParamsHypo;
+}
+
QString SMESHGUI_GenericHypothesisCreator::hypType() const
{
return myHypType;
{
return QString();
}
-
-
-
-
+QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
+ QWidget* /*parent*/) const
+{
+ return 0;
+}
+bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam& , QWidget* ) const
+{
+ return false;
+}
void create( const bool isAlgo, QWidget* );
void edit( SMESH::SMESH_Hypothesis_ptr, QWidget* );
+ void create( SMESH::SMESH_Hypothesis_ptr, QWidget* );
virtual bool checkParams() const = 0;
QString hypType() const;
typedef QPtrList<QWidget> ListOfWidgets;
SMESH::SMESH_Hypothesis_var hypothesis() const;
+ SMESH::SMESH_Hypothesis_var initParamsHypothesis() const;
const ListOfWidgets& widgets() const;
ListOfWidgets& changeWidgets();
virtual QFrame* buildFrame () = 0;
QFrame* buildStdFrame ();
virtual void retrieveParams() const = 0;
- virtual void storeParams () const = 0;
+ virtual QString storeParams () const = 0;
virtual bool stdParams ( ListOfStdParams& ) const;
bool getStdParamFromDlg( ListOfStdParams& ) const;
+ static QString stdParamValues( const ListOfStdParams& );
virtual void attuneStdWidget( QWidget*, const int ) const;
+ virtual QWidget* getCustomWidget( const StdParam &, QWidget* ) const;
+ virtual bool getParamFromCustomWidget( StdParam& , QWidget* ) const;
virtual QString caption() const;
virtual QPixmap icon() const;
virtual QString type() const;
bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, QWidget* );
private:
- SMESH::SMESH_Hypothesis_var myHypo;
+ SMESH::SMESH_Hypothesis_var myHypo, myInitParamsHypo;
QString myHypType;
ListOfWidgets myParamWidgets;
bool myIsCreate;
createObject( tr( "MESH" ), aGrp, Mesh );
// geometry
createObject( tr( "GEOMETRY" ), aGrp, Geom );
+ myGeomPopup = 0;
// Create tab widget
{
myHypoSetPopup->exec( QCursor::pos() );
}
+
+//================================================================================
+/*!
+ * \brief Enable showing of the popup when Geometry selection btn is clicked
+ * \param enable - true to enable
+ */
+//================================================================================
+
+enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
+
+void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
+{
+ if ( QButton* selBtn = dynamic_cast<QButton*>( objectWg( Geom, Btn )))
+ {
+ disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
+ if ( enable ) {
+ if ( ! myGeomPopup ) {
+ myGeomPopup = new QPopupMenu();
+ myGeomPopup->insertItem( tr("DIRECT_GEOM_SELECTION"), DIRECT_GEOM_INDEX );
+ myGeomPopup->insertItem( tr("GEOM_BY_MESH_ELEM_SELECTION"), GEOM_BY_MESH_INDEX );
+ connect( myGeomPopup, SIGNAL( activated( int ) ), SLOT( onGeomPopup( int ) ) );
+ }
+ connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
+ }
+ }
+}
+
+void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
+{
+ if ( myGeomPopup && isBtnOn )
+ myGeomPopup->exec( QCursor::pos() );
+}
+
+void SMESHGUI_MeshDlg::onGeomPopup( int index )
+{
+ emit geomSelectionByMesh( index == GEOM_BY_MESH_INDEX );
+}
void setCurrentTab( const int );
void setMaxHypoDim( const int );
void setHypoSets( const QStringList& );
+ void setGeomPopupEnabled( const bool );
signals:
void hypoSet( const QString& );
+ void geomSelectionByMesh( bool );
private slots:
void onHypoSetPopup( int );
void onHypoSetButton();
+ void onGeomPopup( int );
+ void onGeomSelectionButton( bool );
private:
QMap< int, SMESHGUI_MeshTab* > myTabs;
QTabWidget* myTabWg;
QPopupMenu* myHypoSetPopup;
+ QPopupMenu* myGeomPopup;
};
/*!
#include "SMESHGUI_MeshOp.h"
#include "SMESHGUI_MeshDlg.h"
+#include "SMESHGUI_ShapeByMeshDlg.h"
#include "SMESH_TypeFilter.hxx"
#include "SMESHGUI.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_GEOMGenUtils.h"
+#include "SMESHGUI_VTKUtils.h"
#include "SMESH_TypeFilter.hxx"
#include "SMESH_NumberFilter.hxx"
#include "GEOM_SelectionFilter.h"
+#include "GEOMBase.h"
+#include "GeometryGUI.h"
#include "SalomeApp_Tools.h"
#include "SALOMEDSClient_Study.hxx"
#include "SALOMEDS_SComponent.hxx"
#include "SALOMEDS_SObject.hxx"
-
#include "LightApp_SelectionMgr.h"
#include "LightApp_UpdateFlags.h"
#include "SUIT_MessageBox.h"
#include "SUIT_Desktop.h"
#include "SUIT_OverrideCursor.h"
-
-#include "GEOMBase.h"
+#include "SALOME_InteractiveObject.hxx"
+#include "SALOME_ListIO.hxx"
#include "utilities.h"
#include <TopoDS_Shape.hxx>
#include <TopExp_Explorer.hxx>
+enum { GLOBAL_ALGO_TAG =3,
+ GLOBAL_HYPO_TAG =2,
+ LOCAL_ALGO_TAG =2,
+ LOCAL_HYPO_TAG =1,
+ SUBMESH_ON_EDGE_TAG =5,
+ SUBMESH_ON_WIRE_TAG =6,
+ SUBMESH_ON_FACE_TAG =7,
+ SUBMESH_ON_SHELL_TAG =8,
+ SUBMESH_ON_SOLID_TAG =9,
+ SUBMESH_ON_COMPOUND_TAG=10 };
+
//================================================================================
/*!
* \brief Constructor
: SMESHGUI_SelectionOp(),
myToCreate( theToCreate ),
myIsMesh( theIsMesh ),
- myDlg( 0 )
+ myDlg( 0 ),
+ myShapeByMeshDlg( 0 )
{
+ if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
+ GeometryGUI::InitGeomGen();
}
//================================================================================
//================================================================================
SMESHGUI_MeshOp::~SMESHGUI_MeshOp()
{
- if( myDlg )
+ if ( myDlg )
delete myDlg;
}
this, SLOT( onEditHyp( const int, const int) ) );
}
connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
+ connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));
}
SMESHGUI_SelectionOp::startOperation();
return 0;
}
+//================================================================================
+/*!
+ * \brief check if selected shape is a subshape of the shape to mesh
+ * \retval bool - check result
+ */
+//================================================================================
+
+bool SMESHGUI_MeshOp::isSubshapeOk() const
+{
+ if ( !myToCreate || myIsMesh ) // not submesh creation
+ return false;
+
+ QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+ QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
+ _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
+ if ( pMesh && pGeom ) {
+ SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+ if ( !mesh->_is_nil() ) {
+ GEOM::GEOM_Object_var mainGeom, subGeom;
+ mainGeom = mesh->GetShapeToMesh();
+ subGeom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( pGeom );
+ if ( !mainGeom->_is_nil() && !subGeom->_is_nil() ) {
+ TopoDS_Shape mainShape, subShape;
+ if ( GEOMBase::GetShape( mainGeom, mainShape ) &&
+ GEOMBase::GetShape( subGeom, subShape ) )
+ {
+ int index = GEOMBase::GetIndex( subShape, mainShape, 0 );
+ if ( index > 0 ) {
+ // 1 is index of mainShape itself
+ return index > 1; // it is a subshape
+ }
+ // is it a group?
+ GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ if ( !geomGen->_is_nil() && aStudy ) {
+ GEOM::GEOM_IGroupOperations_var op =
+ geomGen->GetIGroupOperations( aStudy->StudyId() );
+ if ( ! op->_is_nil() ) {
+ GEOM::GEOM_Object_var mainObj = op->GetMainShape( subGeom );
+ if ( !mainObj->_is_nil() )
+ return ( string( mainObj->GetEntry() ) == string( mainGeom->GetEntry() ));
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
+//================================================================================
+/*!
+ * \brief find an existing submesh by the selected shape
+ * \retval _PTR(SObject) - the found submesh SObject
+ */
+//================================================================================
+
+_PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
+{
+ QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+ QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
+ _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
+ if ( pMesh && pGeom ) {
+ GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( pGeom );
+ if ( !geom->_is_nil() ) {
+ int tag = -1;
+ switch ( geom->GetShapeType() ) {
+ case GEOM::EDGE: tag = SUBMESH_ON_EDGE_TAG ; break;
+ case GEOM::WIRE: tag = SUBMESH_ON_WIRE_TAG ; break;
+ case GEOM::FACE: tag = SUBMESH_ON_FACE_TAG ; break;
+ case GEOM::SHELL: tag = SUBMESH_ON_SHELL_TAG ; break;
+ case GEOM::SOLID: tag = SUBMESH_ON_SOLID_TAG ; break;
+ case GEOM::COMPOUND: tag = SUBMESH_ON_COMPOUND_TAG; break;
+ default:;
+ }
+ _PTR(SObject) aSubmeshRoot;
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ if ( pMesh->FindSubObject( tag, aSubmeshRoot ) )
+ {
+ _PTR(ChildIterator) smIter = aStudy->NewChildIterator( aSubmeshRoot );
+ for (; smIter->More(); smIter->Next() )
+ {
+ _PTR(SObject) aSmObj = smIter->Value();
+ _PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSmObj);
+ for (; anIter1->More(); anIter1->Next()) {
+ _PTR(SObject) pGeom2 = anIter1->Value();
+ if ( pGeom2->ReferencedObject( pGeom2 ) &&
+ pGeom2->GetID() == pGeom->GetID() )
+ return aSmObj;
+ }
+ }
+ }
+ }
+ }
+ return _PTR(SObject)();
+}
+
//================================================================================
/*!
* \brief Updates dialog's look and feel
//================================================================================
void SMESHGUI_MeshOp::selectionDone()
{
+ if ( myShapeByMeshDlg && myShapeByMeshDlg->isShown() )
+ return;
+
SMESHGUI_SelectionOp::selectionDone();
- if ( !myToCreate )
+ try
{
- try
- {
- QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
- _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
- if ( pObj != 0 )
- {
- SMESH::SMESH_subMesh_var aVar =
- SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
- myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() );
- myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
- myDlg->updateGeometry();
- myDlg->adjustSize();
- readMesh();
- }
- else
- myDlg->reset();
- }
- catch ( const SALOME::SALOME_Exception& S_ex )
- {
- SalomeApp_Tools::QtCatchCorbaException( S_ex );
- }
- catch ( ... )
- {
- }
- }
+ // Enable tabs according to shape dimension
- // Enable tabs according to shape dimension
+ int shapeDim = 3;
- int shapeDim = 3;
- try
- {
GEOM::GEOM_Object_var aGeomVar;
QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
_PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
}
}
}
+ myDlg->setMaxHypoDim( shapeDim );
+
+ if ( !myToCreate ) // edition: read hypotheses
+ {
+ QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
+ if ( pObj != 0 )
+ {
+ SMESH::SMESH_subMesh_var aVar =
+ SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
+ myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() );
+ myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
+ myDlg->updateGeometry();
+ myDlg->adjustSize();
+ readMesh();
+ }
+ else
+ myDlg->reset();
+
+ }
+ else if ( !myIsMesh ) // submesh creation
+ {
+ // if a submesh on the selected shape already exist, pass to submesh edition mode
+ if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
+ SMESH::SMESH_subMesh_var sm =
+ SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
+ bool editSubmesh = ( !sm->_is_nil() &&
+ SUIT_MessageBox::question2( myDlg, tr( "SMESH_WARNING" ),
+ tr( "EDIT_SUBMESH_QUESTION"),
+ tr( "SMESH_BUT_YES" ),
+ tr( "SMESH_BUT_NO" ), 1, 0, 0 ));
+ if ( editSubmesh )
+ {
+ selectionMgr()->clearFilters();
+ selectObject( pSubmesh );
+ SMESHGUI::GetSMESHGUI()->switchToOperation(704);
+ return;
+ }
+ else
+ {
+ selectObject( _PTR(SObject)() );
+ myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
+ }
+ }
+
+ // enable/disable popup for choice of geom selection way
+ bool enable = false;
+ QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+ if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
+ SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+ if ( !mesh->_is_nil() )
+ enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
+ }
+ myDlg->setGeomPopupEnabled( enable );
+ }
}
catch ( const SALOME::SALOME_Exception& S_ex )
{
catch ( ... )
{
}
- myDlg->setMaxHypoDim( shapeDim );
}
//================================================================================
return false;
}
+ // Imported mesh, if create sub-mesh or edit mesh
+ if ( !myToCreate || ( myToCreate && !myIsMesh ))
+ {
+ QString aMeshEntry = myDlg->selectedObject
+ ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
+ if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
+ SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+ if ( !mesh->_is_nil() && CORBA::is_nil( mesh->GetShapeToMesh() )) {
+ theMess = tr( "IMPORTED_MESH" );
+ return false;
+ }
+ }
+ }
+
// Geom
if ( myToCreate )
{
theMess = tr( "MESH_IS_NULL" );
return false;
}
+ if ( !isSubshapeOk() )
+ {
+ theMess = tr( "INVALID_SUBSHAPE" );
+ return false;
+ }
}
}
+
return true;
}
bool isMesh = !_CAST( SComponent, theFather );
int aPart = -1;
if ( isMesh )
- aPart = theHypType == Algo ? 3 : 2;
+ aPart = theHypType == Algo ? GLOBAL_ALGO_TAG : GLOBAL_HYPO_TAG;
else
- aPart = theHypType == Algo ? 2 : 1;
+ aPart = theHypType == Algo ? LOCAL_ALGO_TAG : LOCAL_HYPO_TAG;
if ( theFather->FindSubObject( aPart, aHypRoot ) )
{
}
}
+//================================================================================
+/*!
+ * \brief If create or edit a submesh, return a hypothesis holding parameters used
+ * to mesh a subshape
+ * \param aHypType - The hypothesis type name
+ * \param aServerLib - Server library name
+ * \param hypData - The structure holding the hypothesis type etc.
+ * \retval SMESH::SMESH_Hypothesis_var - the hypothesis holding parameter values
+ */
+//================================================================================
+
+SMESH::SMESH_Hypothesis_var
+SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
+ const QString& aServerLib ) const
+{
+ if ( aHypType.isEmpty() || aServerLib.isEmpty() )
+ return SMESH::SMESH_Hypothesis::_nil();
+
+ const int nbColonsInMeshEntry = 3;
+ bool isSubMesh = myToCreate ?
+ !myIsMesh :
+ myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).contains(':') > nbColonsInMeshEntry;
+
+ if ( isSubMesh )
+ {
+ // get mesh and geom object
+ SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
+ GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
+
+ QString anEntry = myDlg->selectedObject
+ ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
+ if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.latin1() ))
+ {
+ CORBA::Object_ptr Obj = _CAST( SObject,pObj )->GetObject();
+ if ( myToCreate ) // mesh and geom may be selected
+ {
+ aMeshVar = SMESH::SMESH_Mesh::_narrow( Obj );
+ anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.latin1() ))
+ aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
+ }
+ else // edition: sub-mesh may be selected
+ {
+ SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( Obj );
+ if ( !sm->_is_nil() ) {
+ aMeshVar = sm->GetFather();
+ aGeomVar = sm->GetSubShape();
+ }
+ }
+ }
+
+ if ( !aMeshVar->_is_nil() && !aGeomVar->_is_nil() )
+ return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType,
+ aServerLib,
+ aMeshVar,
+ aGeomVar );
+ }
+ return SMESH::SMESH_Hypothesis::_nil();
+}
+
//================================================================================
/*!
* \brief Calls plugin methods for hypothesis creation
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aHypTypeName );
// Create hypothesis
- if( aCreator )
- aCreator->create( false, myDlg );
+ if ( aCreator )
+ {
+ // When create or edit a submesh, try to initialize a new hypothesis
+ // with values used to mesh a subshape
+ SMESH::SMESH_Hypothesis_var initParamHyp =
+ getInitParamsHypothesis( aHypTypeName, aData->ServerLibName );
+
+ if ( initParamHyp->_is_nil() )
+ aCreator->create( false, myDlg );
+ else
+ aCreator->create( initParamHyp, myDlg );
+ }
+ else
+ {
+ SMESH::CreateHypothesis( aHypTypeName, aData->Label, false );
+ }
}
QStringList aNewHyps;
{
// try to find an existing hypo
QValueList<SMESH::SMESH_Hypothesis_var> & aList = myExistingHyps[ aDim ][ aHypType ];
- int iHyp = 0, nbHyp = aList.count();
- for ( ; iHyp < nbHyp; ++iHyp )
- {
- SMESH::SMESH_Hypothesis_var aHyp = aList[ iHyp ];
- if ( !aHyp->_is_nil() && aHypoTypeName == aHyp->GetName() ) {
- index = iHyp;
- break;
- }
- }
+ int /*iHyp = 0,*/ nbHyp = aList.count();
+// for ( ; iHyp < nbHyp; ++iHyp )
+// {
+// SMESH::SMESH_Hypothesis_var aHyp = aList[ iHyp ];
+// if ( !aHyp->_is_nil() && aHypoTypeName == aHyp->GetName() ) {
+// index = iHyp;
+// break;
+// }
+// }
if ( index >= 0 ) // found
{
- // select an algorithm
+ // select the found hypothesis
setCurrentHyp ( aDim, aHypType, index );
}
else
// Get hypotheses creator client (GUI)
SMESHGUI_GenericHypothesisCreator* aCreator =
SMESH::GetHypothesisCreator( aHypoTypeName );
- aCreator->create( false, myDlg );
+ if ( aCreator )
+ {
+ // When create or edit a submesh, try to initialize a new hypothesis
+ // with values used to mesh a subshape
+ SMESH::SMESH_Hypothesis_var initParamHyp =
+ getInitParamsHypothesis( aHypoTypeName, aHypData->ServerLibName );
+ aCreator->create( initParamHyp, myDlg );
+ }
+ else
+ {
+ SMESH::CreateHypothesis( aHypoTypeName, aHypData->Label, isAlgo );
+ }
}
QStringList aNewHyps;
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
{
return SMESHGUI_Operation::isValid( theOp ) && !theOp->inherits( "SMESHGUI_MeshOp" );
}
+
+//================================================================================
+/*!
+ * \brief SLOT. Is called when the user selects a way of geometry selection
+ * \param theByMesh - true if the user wants to find geometry by mesh element
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
+{
+ if ( theByMesh ) {
+ if ( !myShapeByMeshDlg ) {
+ myShapeByMeshDlg = new SMESHGUI_ShapeByMeshDlg( SMESHGUI::GetSMESHGUI(), "ShapeByMeshDlg");
+ connect(myShapeByMeshDlg, SIGNAL(PublishShape()), SLOT(onPublishShapeByMeshDlg()));
+ connect(myShapeByMeshDlg, SIGNAL(Close()), SLOT(onCloseShapeByMeshDlg()));
+ }
+ // set mesh object to dlg
+ QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+ if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
+ SMESH::SMESH_Mesh_var aMeshVar =
+ SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
+ if ( !aMeshVar->_is_nil() ) {
+ myDlg->hide();
+ myDlg->activateObject( SMESHGUI_MeshDlg::Mesh );
+ myShapeByMeshDlg->Init();
+ myShapeByMeshDlg->SetMesh( aMeshVar );
+ myShapeByMeshDlg->show();
+ }
+ }
+ }
+}
+
+//================================================================================
+/*!
+ * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::onPublishShapeByMeshDlg()
+{
+ if ( myShapeByMeshDlg ) {
+ // Select a found geometry object
+ GEOM::GEOM_Object_var aGeomVar = myShapeByMeshDlg->GetShape();
+ if ( !aGeomVar->_is_nil() )
+ {
+ QString ID = aGeomVar->GetStudyEntry();
+ if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID )) {
+ SMESH::SMESH_Mesh_ptr aMeshPtr = myShapeByMeshDlg->GetMesh();
+ if ( !CORBA::is_nil( aMeshPtr )) {
+ if (_PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshPtr )) {
+ myDlg->activateObject( SMESHGUI_MeshDlg::Mesh );
+ myDlg->selectObject( aMeshSO->GetName(), SMESHGUI_MeshDlg::Mesh, aMeshSO->GetID() );
+ }
+ }
+ myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
+ selectObject( aGeomSO );
+ //selectionDone();
+ }
+ }
+ else {
+ onCloseShapeByMeshDlg();
+ }
+ }
+ myDlg->show();
+}
+
+//================================================================================
+/*!
+ * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::onCloseShapeByMeshDlg()
+{
+ if ( myDlg ) {
+ myDlg->show();
+ myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
+ myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Selects a SObject
+ * \param theSObj - the SObject to select
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::selectObject( _PTR(SObject) theSObj ) const
+{
+ if ( LightApp_SelectionMgr* sm = selectionMgr() ) {
+ SALOME_ListIO anIOList;
+ if ( theSObj ) {
+ Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
+ ( theSObj->GetID().c_str(), "SMESH", theSObj->GetName().c_str() );
+ anIOList.Append( anIO );
+ }
+ sm->setSelectedObjects( anIOList, false );
+ }
+}
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class SMESHGUI_MeshDlg;
-class SMESH_TypeFilter;
-class SMESH_NumberFilter;
-
+class SMESHGUI_ShapeByMeshDlg;
/*!
* \brief Operation for mech creation or editing
void onCreateHyp( const int theHypType, const int theIndex );
void onEditHyp( const int theHypType, const int theIndex );
void onHypoSet( const QString& theSetName );
+ void onGeomSelectionByMesh( bool );
+ void onPublishShapeByMeshDlg();
+ void onCloseShapeByMeshDlg();
private:
bool isValid( QString& ) const;
QString name( _PTR(SObject) ) const;
int find( const SMESH::SMESH_Hypothesis_var&,
const QValueList<SMESH::SMESH_Hypothesis_var>& ) const;
+ SMESH::SMESH_Hypothesis_var getInitParamsHypothesis( const QString& aHypType,
+ const QString& aServerLib ) const;
+ bool isSubshapeOk() const;
+ _PTR(SObject) getSubmeshByGeom() const;
+ void selectObject( _PTR(SObject) ) const;
private:
typedef QMap< int, QValueList<SMESH::SMESH_Hypothesis_var> > IdToHypListMap;
typedef QMap< int, IdToHypListMap > DimToHypMap;
SMESHGUI_MeshDlg* myDlg;
+ SMESHGUI_ShapeByMeshDlg* myShapeByMeshDlg;
bool myToCreate;
bool myIsMesh;
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
#define SPACING 5
#define MARGIN 10
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
// QT includes
#include <qgroupbox.h>
#include "SVTK_Selector.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
-#include "SVTK_InteractorStyle.h"
// OCCT Includes
#include <Precision.hxx>
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
// QT Includes
#include <qframe.h>
myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
if (!myActor)
myActor = SMESH::FindActorByObject(myMesh);
- SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle();
- Handle(VTKViewer_Filter) aFilter = aStyle->GetFilter(myFilterType);
+ SVTK_Selector* aSelector = SMESH::GetSelector();
+ Handle(VTKViewer_Filter) aFilter = aSelector->GetFilter(myFilterType);
if (!aFilter.IsNull())
aFilter->SetActor(myActor);
}
//=======================================================================
bool SMESHGUI_MultiEditDlg::isIdValid (const int theId) const
{
- SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle();
+ SVTK_Selector* aSelector = SMESH::GetSelector();
Handle(SMESHGUI_Filter) aFilter =
- Handle(SMESHGUI_Filter)::DownCast(aStyle->GetFilter(myFilterType));
+ Handle(SMESHGUI_Filter)::DownCast(aSelector->GetFilter(myFilterType));
return (!aFilter.IsNull() && aFilter->IsObjValid(theId));
}
#include <vtkDataSetMapper.h>
#include <vtkActorCollection.h>
#include <vtkRenderer.h>
+#include <vtkProperty.h>
// QT Includes
#include <qbuttongroup.h>
#include "SVTK_ViewWindow.h"
#include "SALOME_ListIO.hxx"
+#include "SalomeApp_Tools.h"
#include "utilities.h"
// OCCT Includes
try {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
aResult = aMeshEditor->RemoveElements(anArrayOfIdeces.inout());
- } catch (...) {
+ } catch (const SALOME::SALOME_Exception& S_ex) {
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
+ myEditCurrentArgument->clear();
+ } catch (...){
+ myEditCurrentArgument->clear();
}
if (aResult) {
myEditCurrentArgument->clear();
+ mySelector->ClearIndex();
SMESH::UpdateView();
}
}
if (aResult) {
myEditCurrentArgument->clear();
+ mySelector->ClearIndex();
SMESH::UpdateView();
}
QString ent = entry( ind );
SMESH_Actor* actor = SMESH::FindActorByEntry( ent.latin1() );
if ( actor && actor->hasIO() ) {
- SVTK_RenderWindowInteractor* renderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
- return QVariant( renderInter->isVisible( actor->getIO() ), 0 );
+ if(SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView())
+ return QVariant( aViewWindow->isVisible( actor->getIO() ), 0 );
}
}
return QVariant( false, 0 );
--- /dev/null
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 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.
+//
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_ShapeByMeshDlg.cxx
+// Author : Edward AGAPOV
+// Module : SMESH
+
+#include "SMESHGUI_ShapeByMeshDlg.h"
+
+#include "SMESHGUI.h"
+#include "SMESHGUI_GEOMGenUtils.h"
+#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_VTKUtils.h"
+
+#include "SMDS_Mesh.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMESH_Actor.h"
+
+#include "GEOMBase.h"
+#include "GeometryGUI.h"
+
+#include "LightApp_DataOwner.h"
+#include "LightApp_SelectionMgr.h"
+#include "SALOMEDSClient_SObject.hxx"
+#include "SALOME_ListIO.hxx"
+#include "SUIT_Desktop.h"
+#include "SVTK_Selector.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_ViewModel.h"
+#include "SalomeApp_Tools.h"
+
+// OCCT Includes
+#include <TColStd_MapOfInteger.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopExp_Explorer.hxx>
+
+// QT Includes
+#include <qframe.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qapplication.h>
+#include <qstringlist.h>
+
+#define SPACING 5
+#define MARGIN 10
+
+enum { EDGE = 0, FACE, VOLUME };
+
+/*!
+ * \brief Dialog to publish a sub-shape of the mesh main shape
+ * by selecting mesh elements
+ */
+SMESHGUI_ShapeByMeshDlg::SMESHGUI_ShapeByMeshDlg( SMESHGUI* theModule,
+ const char* theName)
+ : QDialog( SMESH::GetDesktop( theModule ), theName, false,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+ mySMESHGUI( theModule ),
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+{
+ setCaption(tr("CAPTION"));
+
+ QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING);
+
+ QFrame* aMainFrame = createMainFrame (this);
+ QFrame* aBtnFrame = createButtonFrame(this);
+
+ aDlgLay->addWidget(aMainFrame);
+ aDlgLay->addWidget(aBtnFrame);
+
+ aDlgLay->setStretchFactor(aMainFrame, 1);
+
+ myViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+
+ Init();
+}
+
+//=======================================================================
+// function : createMainFrame()
+// purpose : Create frame containing dialog's input fields
+//=======================================================================
+QFrame* SMESHGUI_ShapeByMeshDlg::createMainFrame (QWidget* theParent)
+{
+ QFrame* aMainGrp = new QFrame(theParent, "main frame");
+ QGridLayout* aLayout = new QGridLayout(aMainGrp, 3, 2);
+ aLayout->setSpacing(6);
+ aLayout->setAutoAdd(false);
+
+ // elem type
+ myElemTypeGroup = new QButtonGroup(1, Qt::Vertical, aMainGrp, "Group types");
+ myElemTypeGroup->setTitle(tr("SMESH_ELEMENT_TYPE"));
+ myElemTypeGroup->setExclusive(true);
+
+ (new QRadioButton( tr("SMESH_EDGE") , myElemTypeGroup))->setChecked(true);
+ new QRadioButton( tr("SMESH_FACE") , myElemTypeGroup);
+ new QRadioButton( tr("SMESH_VOLUME"), myElemTypeGroup);
+
+ // element id
+ QLabel* anIdLabel = new QLabel( aMainGrp, "element id label");
+ anIdLabel->setText( tr("ELEMENT_ID") );
+ myElementId = new QLineEdit( aMainGrp, "element id");
+ myElementId->setValidator( new SMESHGUI_IdValidator( theParent, "id validator", 1 ));
+
+ // shape name
+ QLabel* aNameLabel = new QLabel( aMainGrp, "geom name label");
+ aNameLabel->setText( tr("GEOMETRY_NAME") );
+ myGeomName = new QLineEdit( aMainGrp, "geom name");
+
+ aLayout->addMultiCellWidget(myElemTypeGroup, 0, 0, 0, 1);
+ aLayout->addWidget(anIdLabel, 1, 0);
+ aLayout->addWidget(myElementId, 1, 1);
+ aLayout->addWidget(aNameLabel, 2, 0);
+ aLayout->addWidget(myGeomName, 2, 1);
+
+ connect(myElemTypeGroup, SIGNAL(clicked(int)), SLOT(onTypeChanged(int)));
+ connect(myElementId, SIGNAL(textChanged(const QString&)), SLOT(onElemIdChanged(const QString&)));
+
+ return aMainGrp;
+}
+
+//=======================================================================
+// function : createButtonFrame()
+// purpose : Create frame containing buttons
+//=======================================================================
+QFrame* SMESHGUI_ShapeByMeshDlg::createButtonFrame (QWidget* theParent)
+{
+ QFrame* aFrame = new QFrame(theParent);
+ aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
+
+ myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame);
+ myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
+
+ QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
+
+ QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
+
+ aLay->addWidget(myOkBtn);
+ aLay->addItem(aSpacer);
+ aLay->addWidget(myCloseBtn);
+
+ connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
+ connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
+
+ return aFrame;
+}
+
+//=======================================================================
+// function : ~SMESHGUI_ShapeByMeshDlg()
+// purpose : Destructor
+//=======================================================================
+SMESHGUI_ShapeByMeshDlg::~SMESHGUI_ShapeByMeshDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+//=======================================================================
+// function : Init()
+// purpose : Init dialog fields, connect signals and slots, show dialog
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::Init()
+{
+ SetMesh( SMESH::SMESH_Mesh::_nil() );
+ myIsManualIdEnter = false;
+
+ //erasePreview();
+
+ mySMESHGUI->SetActiveDialogBox((QDialog*)this);
+
+ // selection and SMESHGUI
+ connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
+ connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
+
+ setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+ qApp->processEvents();
+ updateGeometry();
+ adjustSize();
+ resize(minimumSize());
+
+ activateSelection();
+ onSelectionDone();
+
+ int x, y;
+ mySMESHGUI->DefineDlgPosition(this, x, y);
+ this->move(x, y);
+ this->show();
+}
+
+//=======================================================================
+// function : SetMesh()
+// purpose : Set mesh to dialog
+//=======================================================================
+
+void SMESHGUI_ShapeByMeshDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr)
+{
+ myMesh = SMESH::SMESH_Mesh::_duplicate(thePtr);
+ myGeomObj = GEOM::GEOM_Object::_nil();
+ myHasSolids = false;
+
+ vector< bool > hasElement (myElemTypeGroup->count(), false);
+ if (!myMesh->_is_nil() && myViewWindow )
+ {
+ _PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in());
+ SUIT_DataOwnerPtr anIObj (new LightApp_DataOwner(aSobj->GetID().c_str()));
+
+ vector< int > nbShapes( TopAbs_SHAPE, 0 );
+ int shapeDim = 0; // max dim with several shapes
+ if ( mySelectionMgr->isOk(anIObj) ) // check that the mesh has a valid shape
+ {
+ _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
+ GEOM::GEOM_Object_var mainShape = SMESH::GetGeom(aSO);
+ if ( !mainShape->_is_nil() )
+ {
+ if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
+ GeometryGUI::InitGeomGen();
+ TopoDS_Shape aShape;
+ if ( GEOMBase::GetShape(mainShape, aShape))
+ {
+ TopAbs_ShapeEnum types[4] = { TopAbs_EDGE, TopAbs_FACE, TopAbs_SHELL, TopAbs_SOLID };
+ for ( int dim = 4; dim > 0; --dim ) {
+ TopAbs_ShapeEnum type = types[ dim - 1 ];
+ TopAbs_ShapeEnum avoid = ( type == TopAbs_SHELL ) ? TopAbs_SOLID : TopAbs_SHAPE;
+ TopExp_Explorer exp( aShape, type, avoid );
+ for ( ; nbShapes[ type ] < 2 && exp.More(); exp.Next() )
+ ++nbShapes[ type ];
+ if ( nbShapes[ type ] > 1 ) {
+ shapeDim = dim;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (shapeDim > 0)
+ {
+ if ( nbShapes[ TopAbs_SHELL ] + nbShapes[ TopAbs_SOLID ] > 1 )
+ shapeDim = 3;
+ hasElement[ EDGE ] = shapeDim > 0 && myMesh->NbEdges() ;
+ hasElement[ FACE ] = shapeDim > 1 && myMesh->NbFaces() ;
+ hasElement[ VOLUME ] = shapeDim > 2 && myMesh->NbVolumes();
+
+ if ( hasElement[ EDGE ] && myViewWindow->GetSelector() )
+ {
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
+ }
+ }
+ myHasSolids = nbShapes[ TopAbs_SOLID ];
+ }
+
+ // disable inexistant elem types
+ for ( int i = 0; i < myElemTypeGroup->count(); ++i ) {
+ if ( QButton* button = myElemTypeGroup->find( i ) )
+ button->setEnabled( hasElement[ i ] );
+ }
+ myElementId->setEnabled( hasElement[ EDGE ] );
+ myGeomName-> setEnabled( hasElement[ EDGE ] );
+
+ setElementID("");
+}
+
+//=======================================================================
+// function : GetShape()
+// purpose : Get published sub-shape
+//=======================================================================
+GEOM::GEOM_Object_ptr SMESHGUI_ShapeByMeshDlg::GetShape()
+{
+ return myGeomObj.in();
+}
+
+//=======================================================================
+// function : onOk()
+// purpose : SLOT called when "Ok" button pressed.
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::onOk()
+{
+ try {
+ int elemID = myElementId->text().toInt();
+ myGeomObj = SMESHGUI::GetSMESHGen()->GetGeometryByMeshElement
+ ( myMesh.in(), elemID, myGeomName->text().latin1());
+
+ accept();
+ emit PublishShape();
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ SalomeApp_Tools::QtCatchCorbaException(S_ex);
+ }
+ catch (...) {
+ }
+ myViewWindow->SetSelectionMode( ActorSelection );
+ disconnect(mySelectionMgr, 0, this, 0);
+ disconnect(mySMESHGUI, 0, this, 0);
+ mySMESHGUI->ResetState();
+}
+
+//=======================================================================
+// function : onClose()
+// purpose : SLOT called when "Close" button pressed. Close dialog
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::onClose()
+{
+ myViewWindow->SetSelectionMode( ActorSelection );
+ disconnect(mySelectionMgr, 0, this, 0);
+ disconnect(mySMESHGUI, 0, this, 0);
+ mySMESHGUI->ResetState();
+ reject();
+ emit Close();
+}
+
+//=======================================================================
+// function : onSelectionDone()
+// purpose : SLOT called when selection changed
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::onSelectionDone()
+{
+ myOkBtn->setEnabled( false );
+ setElementID("");
+
+ try {
+ SALOME_ListIO aList;
+ mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
+ if (aList.Extent() != 1)
+ return;
+
+ SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First());
+ if (aMesh->_is_nil() || myMesh->_is_nil() || aMesh->GetId() != myMesh->GetId() )
+ return;
+
+ QString aString;
+ int nbElems = SMESH::GetNameOfSelectedElements(myViewWindow->GetSelector(),
+ aList.First(), aString);
+ if ( nbElems == 1 ) {
+ setElementID( aString );
+ myOkBtn->setEnabled( true );
+ }
+ } catch (...) {
+ }
+}
+
+//=======================================================================
+// function : onDeactivate()
+// purpose : SLOT called when dialog must be deativated
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::onDeactivate()
+{
+ if ( isEnabled() ) {
+ //disconnect(mySelectionMgr, 0, this, 0);
+ myViewWindow->SetSelectionMode( ActorSelection );
+ setEnabled(false);
+ }
+}
+
+//=======================================================================
+// function : enterEvent()
+// purpose : Event filter
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::enterEvent (QEvent*)
+{
+ // there is a stange problem that enterEvent() comes after onSave()
+ if ( isVisible () && !isEnabled() ) {
+ mySMESHGUI->EmitSignalDeactivateDialog();
+ setEnabled(true);
+ activateSelection();
+ //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
+ }
+}
+
+//=================================================================================
+// function : closeEvent()
+// purpose : Close dialog box
+//=================================================================================
+void SMESHGUI_ShapeByMeshDlg::closeEvent (QCloseEvent*)
+{
+ onClose();
+}
+
+//=======================================================================
+// function : activateSelection()
+// purpose : Activate selection in accordance with current pattern type
+//=======================================================================
+void SMESHGUI_ShapeByMeshDlg::activateSelection()
+{
+ mySelectionMgr->clearFilters();
+ SMESH::SetPointRepresentation(false);
+
+ myGeomName->setText("");
+
+ if ( myViewWindow )
+ {
+ QString geomName;
+ Selection_Mode mode = EdgeSelection;
+ switch ( myElemTypeGroup->id( myElemTypeGroup->selected() )) {
+ case EDGE :
+ mode = EdgeSelection; geomName = tr("GEOM_EDGE"); break;
+ case FACE :
+ mode = FaceSelection; geomName = tr("GEOM_FACE"); break;
+ case VOLUME:
+ mode = VolumeSelection; geomName = tr(myHasSolids ? "GEOM_SOLID" : "GEOM_SHELL"); break;
+ default: return;
+ }
+ if ( myViewWindow->SelectionMode() != mode )
+ myViewWindow->SetSelectionMode( mode );
+
+ myGeomName->setText( GEOMBase::GetDefaultName( geomName ));
+ }
+}
+
+//=======================================================================
+//function : onTypeChanged
+//purpose : SLOT. Called when element type changed.
+//=======================================================================
+
+void SMESHGUI_ShapeByMeshDlg::onTypeChanged (int theType)
+{
+ setElementID("");
+ activateSelection();
+}
+
+//=======================================================================
+//function : onTypeChanged
+//purpose : SLOT. Called when element id is entered
+// Highlight the element whose Ids the user entered manually
+//=======================================================================
+
+void SMESHGUI_ShapeByMeshDlg::onElemIdChanged(const QString& theNewText)
+{
+ myOkBtn->setEnabled( false );
+
+ if ( myIsManualIdEnter && !myMesh->_is_nil() && myViewWindow )
+ if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) )
+ if ( SMDS_Mesh* aMesh = actor->GetObject()->GetMesh() )
+ {
+ SMDSAbs_ElementType type = SMDSAbs_Edge;
+ switch ( myElemTypeGroup->id( myElemTypeGroup->selected() )) {
+ case EDGE : type = SMDSAbs_Edge; break;
+ case FACE : type = SMDSAbs_Face; break;
+ case VOLUME: type = SMDSAbs_Volume; break;
+ default: return;
+ }
+ TColStd_MapOfInteger newIndices;
+ QStringList aListId = QStringList::split( " ", theNewText, false);
+ for ( int i = 0; i < aListId.count(); i++ ) {
+ if ( const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ))
+ if ( e->GetType() == type )
+ newIndices.Add( e->GetID() );
+ }
+
+ if ( !newIndices.IsEmpty() && newIndices.Extent() == 1 )
+ if ( SVTK_Selector* s = myViewWindow->GetSelector() ) {
+ s->AddOrRemoveIndex( actor->getIO(), newIndices, false );
+ myViewWindow->highlight( actor->getIO(), true, true );
+ myOkBtn->setEnabled( true );
+ }
+ }
+}
+
+//=======================================================================
+//function : setElementID
+//purpose : programmatically set element id
+//=======================================================================
+
+void SMESHGUI_ShapeByMeshDlg::setElementID(const QString& theText)
+{
+ myIsManualIdEnter = false;
+ myElementId->setText(theText);
+ myIsManualIdEnter = true;
+}
--- /dev/null
+// Copyright (C) 2003 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.
+//
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_ShapeByMeshDlg.h
+// Author : Edward AGAPOV
+// Module : SMESH
+
+
+#ifndef SMESHGUI_ShapeByMeshDlg_H
+#define SMESHGUI_ShapeByMeshDlg_H
+
+#include <qdialog.h>
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+class QCloseEvent;
+class QFrame;
+class QLineEdit;
+class QPushButton;
+class LightApp_SelectionMgr;
+class SVTK_ViewWindow;
+class QButtonGroup;
+class SMESHGUI;
+
+/*!
+ * \brief Dialog to publish a sub-shape of the mesh main shape
+ * by selecting mesh elements
+ */
+
+class SMESHGUI_ShapeByMeshDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ SMESHGUI_ShapeByMeshDlg( SMESHGUI* theModule,
+ const char* theName = 0);
+ virtual ~SMESHGUI_ShapeByMeshDlg();
+
+ void Init();
+ void SetMesh (SMESH::SMESH_Mesh_ptr);
+ SMESH::SMESH_Mesh_ptr GetMesh () { return myMesh; }
+ GEOM::GEOM_Object_ptr GetShape();
+
+signals:
+
+ void PublishShape();
+ void Close();
+
+private:
+
+ void closeEvent (QCloseEvent* e);
+ void enterEvent (QEvent*);
+
+private slots:
+
+ void onOk();
+ void onClose();
+
+ void onDeactivate();
+
+ void onSelectionDone();
+ void onTypeChanged (int);
+ void onElemIdChanged (const QString&);
+
+private:
+
+ QFrame* createButtonFrame (QWidget*);
+ QFrame* createMainFrame (QWidget*);
+ //void displayPreview();
+ //void erasePreview();
+ void activateSelection();
+ void setElementID(const QString&);
+
+private:
+
+ QButtonGroup* myElemTypeGroup;
+ QLineEdit* myElementId;
+ QLineEdit* myGeomName;
+
+ QPushButton* myOkBtn;
+ QPushButton* myCloseBtn;
+
+ SMESHGUI* mySMESHGUI;
+ LightApp_SelectionMgr* mySelectionMgr;
+ SVTK_ViewWindow* myViewWindow;
+
+ SMESH::SMESH_Mesh_var myMesh;
+ GEOM::GEOM_Object_var myGeomObj;
+
+ bool myIsManualIdEnter;
+ bool myHasSolids;
+};
+
+#endif
#include "SVTK_Selector.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
-#include "SVTK_RenderWindow.h"
-#include "SVTK_InteractorStyle.h"
-#include "SVTK_RenderWindowInteractor.h"
#include "utilities.h"
double SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ),
SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 );
- for ( int i=0, n=views.count(); i<n; i++ ) {
- SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] );
- if (!aVtkView) continue;
- // update VTK viewer properties
- SVTK_RenderWindowInteractor* anInteractor = aVtkView->getRWInteractor();
- if (anInteractor) {
- // mesh element selection
- anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
- aSelColor.blue()/255., SW );
-
- // tolerances
- anInteractor->SetSelectionTolerance(SP1, SP2);
-
- // pre-selection
- SVTK_InteractorStyle* aStyle =
- dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
- if (aStyle) {
- aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
- aPreColor.blue()/255., PW);
- }
- }
+ for ( int i=0, n=views.count(); i<n; i++ ){
+ // update VTK viewer properties
+ if(SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] )){
+ // mesh element selection
+ aVtkView->SetSelectionProp(aSelColor.red()/255.,
+ aSelColor.green()/255.,
+ aSelColor.blue()/255.,
+ SW );
+ // tolerances
+ aVtkView->SetSelectionTolerance(SP1, SP2);
+
+ // pre-selection
+ aVtkView->SetPreselectionProp(aPreColor.red()/255.,
+ aPreColor.green()/255.,
+ aPreColor.blue()/255.,
+ PW);
// update actors
vtkRenderer* aRenderer = aVtkView->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors();
aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
- anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
+ anActor->SetHighlightColor(aHiColor.red()/255.,
+ aHiColor.green()/255.,
aHiColor.blue()/255.);
- anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
+ anActor->SetPreHighlightColor(aPreColor.red()/255.,
+ aPreColor.green()/255.,
aPreColor.blue()/255.);
}
}
+ }
}
}
//----------------------------------------------------------------------------
- SVTK_InteractorStyle* GetInteractorStyle(SUIT_ViewWindow *theWindow){
- if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow)){
- if(SVTK_RenderWindowInteractor* anInteractor = aWnd->getRWInteractor()){
- return dynamic_cast<SVTK_InteractorStyle*>( anInteractor->GetInteractorStyle() );
- }
- }
+ SVTK_Selector*
+ GetSelector(SUIT_ViewWindow *theWindow)
+ {
+ if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow))
+ return aWnd->GetSelector();
+
return NULL;
}
void SetFilter(const Handle(VTKViewer_Filter)& theFilter,
- SVTK_InteractorStyle* theStyle)
+ SVTK_Selector* theSelector)
{
- if (theStyle)
- theStyle->SetFilter(theFilter);
+ if (theSelector)
+ theSelector->SetFilter(theFilter);
}
- Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_InteractorStyle* theStyle)
+ Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_Selector* theSelector)
{
- return theStyle->GetFilter(theId);
+ return theSelector->GetFilter(theId);
}
- bool IsFilterPresent(int theId, SVTK_InteractorStyle* theStyle)
+ bool IsFilterPresent(int theId, SVTK_Selector* theSelector)
{
- return theStyle->IsFilterPresent(theId);
+ return theSelector->IsFilterPresent(theId);
}
- void RemoveFilter(int theId, SVTK_InteractorStyle* theStyle)
+ void RemoveFilter(int theId, SVTK_Selector* theSelector)
{
- theStyle->RemoveFilter(theId);
+ theSelector->RemoveFilter(theId);
}
- void RemoveFilters(SVTK_InteractorStyle* theStyle)
+ void RemoveFilters(SVTK_Selector* theSelector)
{
- for ( int id = SMESHGUI_NodeFilter; theStyle && id < SMESHGUI_LastFilter; id++ )
- theStyle->RemoveFilter( id );
+ for ( int id = SMESHGUI_NodeFilter; theSelector && id < SMESHGUI_LastFilter; id++ )
+ theSelector->RemoveFilter( id );
}
bool IsValid(SALOME_Actor* theActor, int theCellId,
- SVTK_InteractorStyle* theStyle)
+ SVTK_Selector* theSelector)
{
- return theStyle->IsValid(theActor,theCellId);
+ return theSelector->IsValid(theActor,theCellId);
}
class SUIT_ViewWindow;
class SUIT_ViewManager;
-class SVTK_InteractorStyle;
class SVTK_ViewWindow;
class SVTK_Selector;
//----------------------------------------------------------------------------
- SVTK_InteractorStyle*
- GetInteractorStyle (SUIT_ViewWindow* = GetActiveWindow());
+ SVTK_Selector*
+ GetSelector(SUIT_ViewWindow* = GetActiveWindow());
void SetFilter (const Handle(VTKViewer_Filter)& theFilter,
- SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+ SVTK_Selector* theSelector = GetSelector());
Handle(VTKViewer_Filter)
- GetFilter (int theId, SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+ GetFilter (int theId, SVTK_Selector* theSelector = GetSelector());
bool IsFilterPresent (int theId,
- SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+ SVTK_Selector* theSelector = GetSelector());
void RemoveFilter (int theId,
- SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+ SVTK_Selector* theSelector = GetSelector());
- void RemoveFilters (SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+ void RemoveFilters (SVTK_Selector* theSelector = GetSelector());
bool IsValid (SALOME_Actor* theActor, int theCellId,
- SVTK_InteractorStyle* theStyle = GetInteractorStyle());
+ SVTK_Selector* theSelector = GetSelector());
//----------------------------------------------------------------------------
int GetNameOfSelectedNodes(SVTK_Selector* theSelector,
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Free Software Foundation, Inc.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"PO-Revision-Date: 2006-01-13 13:50+0300\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
# This is a Qt message file in .po format. Each msgid starts with
# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
# would be translated to "Pub", not "Foo::Pub".
msgstr "Update View"
+#Warning incorrect values
+msgid "SMESH_ERR_SCALARBAR_PARAMS"
+msgstr "Warning! The parameters is incorrect"
+
# -------------- Connectivity --------------
#Boundary Edges
#-----------------------------------------------------------
+msgid "SMESHGUI_ShapeByMeshDlg::CAPTION"
+msgstr "Find geometry by mesh element"
+
+msgid "SMESH_ELEMENT_TYPE"
+msgstr "Element Type"
+
+msgid "ELEMENT_ID"
+msgstr "Element ID"
+
+msgid "GEOMETRY_NAME"
+msgstr "Geometry name"
+
+msgid "DIRECT_GEOM_SELECTION"
+msgstr "Direct geometry selection"
+
+msgid "GEOM_BY_MESH_ELEM_SELECTION"
+msgstr "Find geometry by mesh element selection"
+
+#-----------------------------------------------------------
+
msgid "SMESHGUI_MeshTab::ALGORITHM"
msgstr "Algorithm"
msgid "SMESHGUI_MeshOp::THERE_IS_NO_OBJECT_FOR_EDITING"
msgstr "There is no object for editing. Please\nselect mesh or sub-mesh and try again"
+msgid "SMESHGUI_MeshOp::EDIT_SUBMESH_QUESTION"
+msgstr "A submesh on the selected geometry already exists.\n Do you want to edit this submesh?"
+
msgid "SMESHGUI_MeshOp::MESH_IS_NULL"
msgstr "Mesh is null"
+msgid "SMESHGUI_MeshOp::IMPORTED_MESH"
+msgstr "Mesh is not built on geometry"
+
+msgid "SMESHGUI_MeshOp::INVALID_SUBSHAPE"
+msgstr "Geometry object is not a subshape of the shape to mesh"
+
msgid "SMESHGUI_MeshOp::MESH_IS_NOT_DEFINED"
msgstr "Mesh is not defined\nPlease specify it and try again"
-
LDFLAGSFORBIN += -lSMDS -lSMESHDS \
- -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lMEDWrapper_V2_2 \
+ -L${MED_ROOT_DIR}/lib/salome -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lMEDWrapper_V2_2 -lmed_V2_1 \
-lMeshDriver -lMeshDriverMED -lMeshDriverUNV -lMeshDriverDAT -lMeshDriverSTL \
-L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer -lSalomeNS -lRegistry -lSalomeResourcesManager \
-lOpUtil -lSALOMELocalTrace -lSALOMEBasics -lSalomeNotification -lCASCatch \
#include <TopoDS_Shape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <gp_Pnt.hxx>
#include <BRep_Tool.hxx>
#include <TCollection_AsciiString.hxx>
#include "SMESHDS_Document.hxx"
#include "SMESHDS_Group.hxx"
#include "SMESHDS_GroupOnGeom.hxx"
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Hypothesis.hxx"
#include "SMESH_Group.hxx"
+#include "SMESH_MeshEditor.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMDS_FacePosition.hxx"
return hyp._retn();
}
+//================================================================================
+/*!
+ * \brief Return hypothesis of given type holding parameter values of the existing mesh
+ * \param theHypType - hypothesis type name
+ * \param theLibName - plugin library name
+ * \param theMesh - The mesh of interest
+ * \param theGeom - The shape to get parameter values from
+ * \retval SMESH::SMESH_Hypothesis_ptr - The returned hypothesis may be the one existing
+ * in a study and used to compute the mesh, or a temporary one created just to pass
+ * parameter values
+ */
+//================================================================================
+
+SMESH::SMESH_Hypothesis_ptr
+SMESH_Gen_i::GetHypothesisParameterValues (const char* theHypType,
+ const char* theLibName,
+ SMESH::SMESH_Mesh_ptr theMesh,
+ GEOM::GEOM_Object_ptr theGeom)
+ throw ( SALOME::SALOME_Exception )
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ if ( CORBA::is_nil( theMesh ) )
+ THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM );
+ if ( CORBA::is_nil( theGeom ) )
+ THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM );
+
+ // -----------------------------------------------
+ // find hypothesis used to mesh theGeom
+ // -----------------------------------------------
+
+ // get mesh and shape
+ SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
+ TopoDS_Shape shape = GeomObjectToShape( theGeom );
+ if ( !meshServant || shape.IsNull() )
+ return SMESH::SMESH_Hypothesis::_nil();
+ ::SMESH_Mesh& mesh = meshServant->GetImpl();
+
+ if ( mesh.NbNodes() == 0 ) // empty mesh
+ return SMESH::SMESH_Hypothesis::_nil();
+
+ // create a temporary hypothesis to know its dimention
+ SMESH::SMESH_Hypothesis_var tmpHyp = this->createHypothesis( theHypType, theLibName );
+ SMESH_Hypothesis_i* hypServant = SMESH::DownCast<SMESH_Hypothesis_i*>( tmpHyp );
+ if ( !hypServant )
+ return SMESH::SMESH_Hypothesis::_nil();
+ ::SMESH_Hypothesis* hyp = hypServant->GetImpl();
+
+ // look for a hypothesis of theHypType used to mesh the shape
+ if ( myGen.GetShapeDim( shape ) == hyp->GetDim() )
+ {
+ // check local shape
+ SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( theGeom );
+ int nbLocalHyps = aHypList->length();
+ for ( int i = 0; i < nbLocalHyps; i++ )
+ if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND local!
+ return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
+ // check super shapes
+ TopTools_ListIteratorOfListOfShape itShape( mesh.GetAncestors( shape ));
+ while ( nbLocalHyps == 0 && itShape.More() ) {
+ GEOM::GEOM_Object_ptr geomObj = ShapeToGeomObject( itShape.Value() );
+ if ( ! CORBA::is_nil( geomObj )) {
+ SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( geomObj );
+ nbLocalHyps = aHypList->length();
+ for ( int i = 0; i < nbLocalHyps; i++ )
+ if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND global!
+ return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
+ }
+ itShape.Next();
+ }
+ }
+
+ // let the temporary hypothesis find out some how parameter values
+ if ( hyp->SetParametersByMesh( &mesh, shape ))
+ return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
+
+ return SMESH::SMESH_Hypothesis::_nil();
+}
+
//=============================================================================
/*!
* SMESH_Gen_i::CreateMesh
// create mesh
SMESH::SMESH_Mesh_var mesh = this->createMesh();
// set shape
- SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( mesh ).in() );
+ SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
ASSERT( meshServant );
meshServant->SetShape( theShapeObject );
return false;
}
+//================================================================================
+/*!
+ * \brief Return geometrical object the given element is built on
+ * \param theMesh - the mesh the element is in
+ * \param theElementID - the element ID
+ * \param theGeomName - the name of the result geom object if it is not yet published
+ * \retval GEOM::GEOM_Object_ptr - the found or just published geom object
+ */
+//================================================================================
+
+GEOM::GEOM_Object_ptr
+SMESH_Gen_i::GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr theMesh,
+ CORBA::Long theElementID,
+ const char* theGeomName)
+ throw ( SALOME::SALOME_Exception )
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ if ( CORBA::is_nil( theMesh ) )
+ THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM );
+
+ GEOM::GEOM_Object_var mainShape = theMesh->GetShapeToMesh();
+ GEOM::GEOM_Gen_var geomGen = GetGeomEngine();
+
+ // get a core mesh DS
+ SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
+ if ( meshServant && !geomGen->_is_nil() && !mainShape->_is_nil() )
+ {
+ ::SMESH_Mesh & mesh = meshServant->GetImpl();
+ SMESHDS_Mesh* meshDS = mesh.GetMeshDS();
+ // find the element in mesh
+ if ( const SMDS_MeshElement * elem = meshDS->FindElement( theElementID ) )
+ // find a shape id by the element
+ if ( int shapeID = ::SMESH_MeshEditor( &mesh ).FindShape( elem )) {
+ // get a geom object by the shape id
+ GEOM::GEOM_Object_var geom = ShapeToGeomObject( meshDS->IndexToShape( shapeID ));
+ if ( geom->_is_nil() ) {
+ GEOM::GEOM_IShapesOperations_var op =
+ geomGen->GetIShapesOperations( GetCurrentStudyID() );
+ if ( !op->_is_nil() )
+ geom = op->GetSubShape( mainShape, shapeID );
+ }
+ if ( !geom->_is_nil() ) {
+ // try to find the corresponding SObject
+ GeomObjectToShape( geom ); // geom client remembers the found shape
+ SALOMEDS::SObject_var SObj = ObjectToSObject( myCurrentStudy, geom.in() );
+ if ( SObj->_is_nil() )
+ // publish a new subshape
+ SObj = geomGen->AddInStudy( myCurrentStudy, geom, theGeomName, mainShape );
+ // return only published geometry
+ if ( !SObj->_is_nil() )
+ return geom._retn();
+ }
+ }
+ }
+ return GEOM::GEOM_Object::_nil();
+}
+
//=============================================================================
/*!
* SMESH_Gen_i::Save
*/
//=============================================================================
SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
- const char* theURL,
- bool isMultiFile )
+ const char* theURL,
+ bool isMultiFile )
{
INFOS( "SMESH_Gen_i::Save" );
HDFgroup* aSubSubGroup;
hdf_size aSize[ 1 ];
+
+ //Remove the files if they exist: BugID: 11225
+ TCollection_AsciiString cmd("rm -f \"");
+ cmd+=filename;
+ cmd+="\" \"";
+ cmd+=meshfile;
+ cmd+="\"";
+ system(cmd.ToCString());
+
// MED writer to be used by storage process
DriverMED_W_SMESHDS_Mesh myWriter;
myWriter.SetFile( meshfile.ToCString() );
// ---> create HDF file
aFile = new HDFfile( filename.ToCString() );
aFile->CreateOnDisk();
-
+
// --> iterator for top-level objects
SALOMEDS::ChildIterator_var itBig = myCurrentStudy->NewChildIterator( theComponent );
for ( ; itBig->More(); itBig->Next() ) {
const char* theLibName)
throw ( SALOME::SALOME_Exception );
+ // Return hypothesis of given type holding parameter values of the existing mesh
+ SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char* theHypType,
+ const char* theLibName,
+ SMESH::SMESH_Mesh_ptr theMesh,
+ GEOM::GEOM_Object_ptr theGeom)
+ throw ( SALOME::SALOME_Exception );
+
// Create empty mesh on a shape
SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Object_ptr theShapeObject )
throw ( SALOME::SALOME_Exception );
const SMESH::object_array& theListOfSubShape )
throw ( SALOME::SALOME_Exception );
+ // Return geometrical object the given element is built on
+ GEOM::GEOM_Object_ptr GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr theMesh,
+ CORBA::Long theElementID,
+ const char* theGeomName)
+ throw ( SALOME::SALOME_Exception );
// ****************************************************
// Interface inherited methods (from SALOMEDS::Driver)
int hypId = myHyp->GetId();
status = _impl->AddHypothesis(myLocSubShape, hypId);
if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
- _mapHypo[hypId] = myHyp;
+ _mapHypo[hypId] = SMESH::SMESH_Hypothesis::_duplicate( myHyp );
// assure there is a corresponding submesh
if ( !_impl->IsMainShape( myLocSubShape )) {
int shapeId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape );
THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
}
} else {
- // nonexisting file
- TCollection_AsciiString aDirName = aPath.TrekValue(aPath.TrekLength());
- aPath.UpTrek();
- aPath.SetName(aDirName);
- aPath.SetExtension("");
- OSD_Directory aDir (aPath);
- TCollection_AsciiString aFullDirName;
- aPath.SystemName(aFullDirName);
- if (aDir.Exists()) {
- aFile.Reset();
- aFile.Build(OSD_WriteOnly, OSD_Protection());
- if (aFile.Failed()) {
- TCollection_AsciiString msg ("You cannot write to directory ");
- msg += aFullDirName + ".";
- THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
- } else {
- aFile.Close();
- aFile.Remove();
- }
- } else {
- TCollection_AsciiString msg ("Directory ");
- msg += aFullDirName + " does not exist.";
+ // nonexisting file; check if it can be created
+ aFile.Reset();
+ aFile.Build(OSD_WriteOnly, OSD_Protection());
+ if (aFile.Failed()) {
+ TCollection_AsciiString msg ("You cannot create the file ");
+ msg += aFullName + ". Check the directory existance and access rights.";
THROW_SALOME_CORBA_EXCEPTION(msg.ToCString(), SALOME::BAD_PARAM);
+ } else {
+ aFile.Close();
+ aFile.Remove();
}
}
}
// Module : SMESH
// $Header$
-using namespace std;
#include "StdMeshers_Arithmetic1D.hxx"
+#include "SMESH_Algo.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
+using namespace std;
+
//=============================================================================
/*!
*
*/
//=============================================================================
-StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId,
- SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, studyId, gen)
{
_begLength = 1.;
- _endLength = 1.;
+ _endLength = 10.;
_name = "Arithmetic1D";
_param_algo_dim = 1;
}
{
return hyp.LoadFrom( load );
}
+
+//================================================================================
+/*!
+ * \brief Initialize start and end length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_Arithmetic1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ if ( !theMesh || theShape.IsNull() )
+ return false;
+
+ _begLength = _endLength = 0.;
+
+ Standard_Real UMin, UMax;
+ TopLoc_Location L;
+
+ int nbEdges = 0;
+ TopTools_IndexedMapOfShape edgeMap;
+ TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+ for ( int i = 1; i <= edgeMap.Extent(); ++i )
+ {
+ const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( i ));
+ Handle(Geom_Curve) C = BRep_Tool::Curve(edge, L, UMin, UMax);
+ GeomAdaptor_Curve AdaptCurve(C);
+
+ vector< double > params;
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+ if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
+ {
+ nbEdges++;
+ _begLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[0], params[1]);
+ int nb = params.size();
+ _endLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[nb-2], params[nb-1]);
+ }
+ }
+ if ( nbEdges ) {
+ _begLength /= nbEdges;
+ _endLength /= nbEdges;
+ }
+ return nbEdges;
+}
double GetLength(bool isStartLength) const;
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream& operator << (ostream & save, StdMeshers_Arithmetic1D & hyp);
- friend istream& operator >> (istream & load, StdMeshers_Arithmetic1D & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream& operator << (std::ostream & save, StdMeshers_Arithmetic1D & hyp);
+ friend std::istream& operator >> (std::istream & load, StdMeshers_Arithmetic1D & hyp);
+
+ /*!
+ * \brief Initialize start and end length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
double _begLength, _endLength;
#include "SMESH_Mesh.hxx"
#include "SMESHDS_Mesh.hxx"
#include "SMESH_Algo.hxx"
+#include "SMESHDS_SubMesh.hxx"
#include "utilities.h"
*/
//=============================================================================
-StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId,
- SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, studyId, gen)
{
_name = "AutomaticLength";
_param_algo_dim = 1; // is used by SMESH_Regular_1D
*/
//================================================================================
+const double theCoarseConst = 0.5;
+const double theFineConst = 4.5;
+
void StdMeshers_AutomaticLength::SetFineness(double theFineness)
throw(SALOME_Exception)
{
*/
//================================================================================
-static void computeLengths( const SMESH_Mesh* theMesh,
+static void computeLengths( SMESHDS_Mesh* aMesh,
map<const TopoDS_TShape*, double> & theTShapeToLengthMap)
{
theTShapeToLengthMap.clear();
- SMESHDS_Mesh* aMesh = const_cast< SMESH_Mesh* > ( theMesh )->GetMeshDS();
TopoDS_Shape aMainShape = aMesh->ShapeToMesh();
// Find length of longest and shortest edge
if ( anEdge.IsNull() || anEdge.ShapeType() != TopAbs_EDGE )
throw SALOME_Exception(LOCALIZED("Bad edge shape"));
- if ( theMesh != _mesh ) {
- computeLengths( theMesh, _TShapeToLength );
+ if ( theMesh != _mesh )
+ {
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* > ( theMesh )->GetMeshDS();
+ computeLengths( aMeshDS, _TShapeToLength );
_mesh = theMesh;
}
if ( tshape_length == _TShapeToLength.end() )
return 1; // it is a dgenerated edge
- return tshape_length->second / (0.5 + 4.5 * _fineness);
+ return tshape_length->second / (theCoarseConst + theFineConst * _fineness);
}
//=============================================================================
{
return hyp.LoadFrom( load );
}
+
+//================================================================================
+/*!
+ * \brief Initialize Fineness by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_AutomaticLength::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ if ( !theMesh || theShape.IsNull() )
+ return false;
+
+ _fineness = 0;
+
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+
+ int nbEdges = 0;
+ TopTools_IndexedMapOfShape edgeMap;
+ TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+ for ( int i = 1; i <= edgeMap.Extent(); ++i )
+ {
+ const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( i ));
+
+ // assure the base automatic length is stored in _TShapeToLength
+ if ( i == 1 )
+ GetLength( theMesh, edge );
+
+ // get current segment length
+ double L = SMESH_Algo::EdgeLength( edge );
+ if ( L <= DBL_MIN )
+ continue;
+ SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( edge );
+ if ( !eSubMesh )
+ return false;
+ double segLen = L / eSubMesh->NbElements();
+
+ // get segment length from _TShapeToLength
+ map<const TopoDS_TShape*, double>::iterator tshape_length =
+ _TShapeToLength.find( getTShape( edge ));
+ if ( tshape_length == _TShapeToLength.end() )
+ continue;
+ double autoLen = tshape_length->second;
+
+ // segLen = autoLen / (theCoarseConst + theFineConst * _fineness) -->
+ _fineness += ( autoLen / segLen - theCoarseConst ) / theFineConst;
+
+ ++nbEdges;
+ }
+ if ( nbEdges )
+ _fineness /= nbEdges;
+
+ if (_fineness > 1.0)
+ _fineness = 1.0;
+ else if (_fineness < 0.0)
+ _fineness = 0.0;
+
+ return nbEdges;
+}
friend std::ostream & operator <<(std::ostream & save, StdMeshers_AutomaticLength & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_AutomaticLength & hyp);
+ /*!
+ * \brief Initialize Fineness by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
protected:
std::map<const TopoDS_TShape*, double> _TShapeToLength;
const SMESH_Mesh* _mesh;
#include "StdMeshers_Deflection1D.hxx"
#include "utilities.h"
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Algo.hxx"
+
+#include <BRep_Tool.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pnt.hxx>
//=============================================================================
/*!
{
return hyp.LoadFrom( load );
}
+//================================================================================
+/*!
+ * \brief Evaluate curve deflection between two points
+ * \param theCurve - the curve
+ * \param theU1 - the parameter of the first point
+ * \param theU2 - the parameter of the second point
+ * \retval double - deflection value
+ */
+//================================================================================
+
+static double deflection(const GeomAdaptor_Curve & theCurve,
+ double theU1,
+ double theU2)
+{
+ if ( theCurve.GetType() == GeomAbs_Line )
+ return 0;
+ // line between theU1 and theU2
+ gp_Pnt p1 = theCurve.Value( theU1 ), p2 = theCurve.Value( theU2 );
+ gp_Lin segment( p1, gp_Vec( p1, p2 ));
+
+ // evaluate square distance of theCurve from the segment
+ Standard_Real dist2 = 0;
+ const int nbPnt = 7;
+ const double step = ( theU2 - theU1 ) / nbPnt;
+ while (( theU1 += step ) < theU2 )
+ dist2 = Max( dist2, segment.SquareDistance( theCurve.Value( theU1 )));
+
+ return sqrt( dist2 );
+}
+
+//================================================================================
+/*!
+ * \brief Initialize deflection value by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_Deflection1D::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ if ( !theMesh || theShape.IsNull() )
+ return false;
+
+ _value = 0.;
+
+ Standard_Real UMin, UMax;
+ TopLoc_Location L;
+
+ int nbEdges = 0;
+ TopTools_IndexedMapOfShape edgeMap;
+ TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+
+ for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
+ {
+ const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( iE ));
+ Handle(Geom_Curve) C = BRep_Tool::Curve( edge, L, UMin, UMax );
+ GeomAdaptor_Curve AdaptCurve(C);
+ if ( AdaptCurve.GetType() != GeomAbs_Line )
+ {
+ vector< double > params;
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+ if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
+ {
+ nbEdges++;
+ for ( int i = 1; i < params.size(); ++i )
+ _value = Max( _value, deflection( AdaptCurve, params[ i-1 ], params[ i ]));
+ }
+ }
+ else
+ nbEdges++;
+ }
+ return nbEdges;
+}
double GetDeflection() const;
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream & operator <<(ostream & save, StdMeshers_Deflection1D & hyp);
- friend istream & operator >>(istream & load, StdMeshers_Deflection1D & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream & operator <<(std::ostream & save, StdMeshers_Deflection1D & hyp);
+ friend std::istream & operator >>(std::istream & load, StdMeshers_Deflection1D & hyp);
+
+ /*!
+ * \brief Initialize deflection value by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
double _value;
// Module : SMESH
// $Header$
-using namespace std;
#include "StdMeshers_LengthFromEdges.hxx"
+
#include "utilities.h"
+using namespace std;
+
//=============================================================================
/*!
*
{
_mode =1;
_name = "LengthFromEdges";
-// SCRUTE(_name);
-// SCRUTE(&_name);
_param_algo_dim = 2; // is used by SMESH_MEFISTO_2D
}
return hyp.LoadFrom( load );
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+//================================================================================
+
+bool StdMeshers_LengthFromEdges::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+ const TopoDS_Shape& /*theShape*/)
+{
+ return false;
+}
int GetMode();
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream & operator << (ostream & save, StdMeshers_LengthFromEdges & hyp);
- friend istream & operator >> (istream & load, StdMeshers_LengthFromEdges & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream & operator << (std::ostream & save, StdMeshers_LengthFromEdges & hyp);
+ friend std::istream & operator >> (std::istream & load, StdMeshers_LengthFromEdges & hyp);
+
+ /*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
int _mode;
// Module : SMESH
// $Header$
-using namespace std;
#include "StdMeshers_LocalLength.hxx"
+
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Algo.hxx"
+
#include "utilities.h"
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
+using namespace std;
+
//=============================================================================
/*!
*
*/
//=============================================================================
-StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId,
- SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
+StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, studyId, gen)
{
- _length = 1.;
- _name = "LocalLength";
-// SCRUTE(_name);
-// SCRUTE(&_name);
- _param_algo_dim = 1; // is used by SMESH_Regular_1D
+ _length = 1.;
+ _name = "LocalLength";
+ _param_algo_dim = 1; // is used by SMESH_Regular_1D
}
//=============================================================================
{
return hyp.LoadFrom( load );
}
+
+//================================================================================
+/*!
+ * \brief Initialize segment length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_LocalLength::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ if ( !theMesh || theShape.IsNull() )
+ return false;
+
+ _length = 0.;
+
+ Standard_Real UMin, UMax;
+ TopLoc_Location L;
+
+ int nbEdges = 0;
+ TopTools_IndexedMapOfShape edgeMap;
+ TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+ for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
+ {
+ const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( iE ));
+ Handle(Geom_Curve) C = BRep_Tool::Curve( edge, L, UMin, UMax );
+ GeomAdaptor_Curve AdaptCurve(C);
+
+ vector< double > params;
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+ if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
+ {
+ for ( int i = 1; i < params.size(); ++i )
+ _length += GCPnts_AbscissaPoint::Length( AdaptCurve, params[ i-1 ], params[ i ]);
+ nbEdges += params.size() - 1;
+ }
+ }
+ if ( nbEdges )
+ _length /= nbEdges;
+
+ return nbEdges;
+}
class StdMeshers_LocalLength:public SMESH_Hypothesis
{
- public:
- StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen);
- virtual ~ StdMeshers_LocalLength();
+ public:
+ StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen);
+ virtual ~ StdMeshers_LocalLength();
- void SetLength(double length) throw(SALOME_Exception);
+ void SetLength(double length) throw(SALOME_Exception);
- double GetLength() const;
+ double GetLength() const;
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream & operator <<(ostream & save, StdMeshers_LocalLength & hyp);
- friend istream & operator >>(istream & load, StdMeshers_LocalLength & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream & operator <<(std::ostream & save, StdMeshers_LocalLength & hyp);
+ friend std::istream & operator >>(std::istream & load, StdMeshers_LocalLength & hyp);
- protected:
- double _length;
+ /*!
+ * \brief Initialize segment length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+ protected:
+ double _length;
};
#endif
uv0.y -= delta;
else
uv0.y += delta;
-// MESSAGE(" -> " << uv0.x << " " << uv0.y << " ");
+// #ifdef _DEBUG_
+// MESSAGE(" -> " << uv0.x << " " << uv0.y << " ");
// MESSAGE("v1( " << v1.X() << " " << v1.Y() << " ) " <<
// "v2( " << v2.X() << " " << v2.Y() << " ) ");
// MESSAGE("SIN: " << sqrt(1 - dot * dot / (sqMod1 * sqMod2)));
// dot = v1*v2;
// double sin = sqrt(1 - dot * dot / (sqMod1 * sqMod2));
// MESSAGE("NEW SIN: " << sin);
+// #endif
return true;
}
return false;
double scaley,
const TopTools_IndexedDataMapOfShapeListOfShape& VWMap)
{
-// MESSAGE("StdMeshers_MEFISTO_2D::LoadPoints");
-
- //SMDS_Mesh * meshDS = aMesh.GetMeshDS();
+ // MESSAGE("StdMeshers_MEFISTO_2D::LoadPoints");
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
- int mInit = m, mFirst, iEdge;
+ list< int > mOnVertex;
+
gp_XY scale( scalex, scaley );
TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
BRepTools_WireExplorer wexp(W, F);
- for (wexp.Init(W, F), iEdge = 0; wexp.More(); wexp.Next(), iEdge++)
+ for ( wexp.Init(W, F); wexp.More(); wexp.Next() )
{
const TopoDS_Edge & E = wexp.Current();
+ bool isForward = (E.Orientation() == TopAbs_FORWARD);
// --- IDNodes of first and last Vertex
- TopoDS_Vertex VFirst, VLast;
+ TopoDS_Vertex VFirst, VLast, V;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
+ V = isForward ? VFirst : VLast;
- ASSERT(!VFirst.IsNull());
- SMDS_NodeIteratorPtr lid=
- aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
+ ASSERT(!V.IsNull());
+ SMDS_NodeIteratorPtr lid= aMesh.GetSubMesh(V)->GetSubMeshDS()->GetNodes();
if ( !lid->more() ) {
MESSAGE (" NO NODE BUILT ON VERTEX ");
return false;
}
const SMDS_MeshNode* idFirst = lid->next();
- ASSERT(!VLast.IsNull());
- lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
- if ( !lid->more() ) {
- MESSAGE (" NO NODE BUILT ON VERTEX ");
- return false;
- }
- const SMDS_MeshNode* idLast = lid->next();
-
// --- edge internal IDNodes (relies on good order storage, not checked)
- int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
-
- double f, l;
- Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
-
- SMDS_NodeIteratorPtr ite= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
-
- //bool isForward = (E.Orientation() == TopAbs_FORWARD);
map<double, const SMDS_MeshNode*> params;
+ const SMDS_MeshNode * node;
- while(ite->more())
+ SMDS_NodeIteratorPtr nodeIt= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
+ while ( nodeIt->more() )
{
- const SMDS_MeshNode * node = ite->next();
+ node = nodeIt->next();
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
- double param = epos->GetUParameter();
- params[param] = node;
+ params[ epos->GetUParameter() ] = node;
}
+ int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if ( nbPoints != params.size())
{
MESSAGE( "BAD NODE ON EDGE POSITIONS" );
return false;
}
- mFirst = m;
-
// --- load 2D values into MEFISTO structure,
// add IDNodes in mefistoToDS map
- if (E.Orientation() == TopAbs_FORWARD)
+
+ double f, l, uFirst, u;
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+ uFirst = isForward ? f : l;
+
+ // vertex node
+ gp_Pnt2d p = C2d->Value( uFirst ).XY().Multiplied( scale );
+ if ( fixCommonVertexUV( p, V, W, myOuterWire, F, VWMap, aMesh ))
+ myNodesOnCommonV.push_back( idFirst );
+ mOnVertex.push_back( m );
+ uvslf[m].x = p.X();
+ uvslf[m].y = p.Y();
+ mefistoToDS[m + 1] = idFirst;
+ //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+ //MESSAGE("__ f "<<uFirst<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+ m++;
+
+ // internal nodes
+ map<double, const SMDS_MeshNode*>::iterator u_n = params.begin();
+ map<double, const SMDS_MeshNode*>::reverse_iterator u_n_rev = params.rbegin();
+ for ( int i = 0; i < nbPoints; ++i )
{
- gp_Pnt2d p = C2d->Value(f).XY().Multiplied( scale ); // first point = Vertex Forward
- if ( fixCommonVertexUV( p, VFirst, W, myOuterWire, F, VWMap, aMesh ))
- myNodesOnCommonV.push_back( idFirst );
- uvslf[m].x = p.X();
- uvslf[m].y = p.Y();
- mefistoToDS[m + 1] = idFirst;
- //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
- //MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
- m++;
- map<double, const SMDS_MeshNode*>::iterator itp = params.begin();
- for (int i = 1; i <= nbPoints; i++) // nbPoints internal
- {
- double param = (*itp).first;
- gp_Pnt2d p = C2d->Value(param).XY().Multiplied( scale );
- uvslf[m].x = p.X();
- uvslf[m].y = p.Y();
- mefistoToDS[m + 1] = (*itp).second;
- //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
- //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
- m++;
- itp++;
+ if ( isForward ) {
+ u = u_n->first;
+ node = u_n->second;
+ ++u_n;
+ } else {
+ u = u_n_rev->first;
+ node = u_n_rev->second;
+ ++u_n_rev;
}
- }
- else
- {
- gp_Pnt2d p = C2d->Value(l).XY().Multiplied( scale ); // last point = Vertex Reversed
- if ( fixCommonVertexUV( p, VLast, W, myOuterWire, F, VWMap, aMesh ))
- myNodesOnCommonV.push_back( idLast );
+ gp_Pnt2d p = C2d->Value( u ).XY().Multiplied( scale );
uvslf[m].x = p.X();
uvslf[m].y = p.Y();
- mefistoToDS[m + 1] = idLast;
+ mefistoToDS[m + 1] = node;
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
- //MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+ //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
- map<double, const SMDS_MeshNode*>::reverse_iterator itp = params.rbegin();
- for (int i = nbPoints; i >= 1; i--)
- {
- double param = (*itp).first;
- gp_Pnt2d p = C2d->Value(param).XY().Multiplied( scale );
- uvslf[m].x = p.X();
- uvslf[m].y = p.Y();
- mefistoToDS[m + 1] = (*itp).second;
- //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
- //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
- m++;
- itp++;
- }
}
- // prevent failure on overlapped adjacent links
- if ( iEdge > 0 )
- fixOverlappedLinkUV (uvslf[ mFirst - 1],
- uvslf[ mFirst ],
- uvslf[ mFirst + 1 ]);
-
} // for wexp
- fixOverlappedLinkUV (uvslf[ m - 1],
- uvslf[ mInit ],
- uvslf[ mInit + 1 ]);
+ // prevent failure on overlapped adjacent links,
+ // check only links ending in vertex nodes
+ int mFirst = mOnVertex.front(), mLast = m - 1;
+ list< int >::iterator mIt = mOnVertex.begin();
+ for ( ; mIt != mOnVertex.end(); ++mIt ) {
+ int i = *mIt;
+ int iB = i - 1, iA = i + 1; // indices Before and After
+ if ( iB < mFirst ) iB = mLast;
+ if ( iA > mLast ) iA = mFirst;
+ fixOverlappedLinkUV (uvslf[ iB ], uvslf[ i ], uvslf[ iA ]);
+ }
return true;
}
// Module : SMESH
// $Header$
-using namespace std;
#include "StdMeshers_MaxElementArea.hxx"
+
+#include "SMESH_ControlsDef.hxx"
+#include "SMDS_MeshElement.hxx"
+#include "SMESHDS_SubMesh.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
#include "utilities.h"
+using namespace std;
+
//=============================================================================
/*!
*
{
_maxArea =1.;
_name = "MaxElementArea";
-// SCRUTE(_name);
-// SCRUTE(&_name);
_param_algo_dim = 2;
}
return hyp.LoadFrom( load );
}
+//================================================================================
+/*!
+ * \brief Initialize maximal area by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_MaxElementArea::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ if ( !theMesh || theShape.IsNull() )
+ return false;
+
+ _maxArea = 0;
+
+ SMESH::Controls::Area areaControl;
+ SMESH::Controls::TSequenceOfXYZ nodesCoords;
+
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+
+ TopTools_IndexedMapOfShape faceMap;
+ TopExp::MapShapes( theShape, TopAbs_FACE, faceMap );
+ for ( int iF = 1; iF <= faceMap.Extent(); ++iF )
+ {
+ SMESHDS_SubMesh * subMesh = aMeshDS->MeshElements( faceMap( iF ));
+ if ( !subMesh )
+ return false;
+ SMDS_ElemIteratorPtr fIt = subMesh->GetElements();
+ while ( fIt->more() )
+ {
+ const SMDS_MeshElement* elem = fIt->next();
+ if ( elem->GetType() == SMDSAbs_Face ) {
+ areaControl.GetPoints( elem, nodesCoords );
+ _maxArea = max( _maxArea, areaControl.GetValue( nodesCoords ));
+ }
+ }
+ }
+ return _maxArea > 0;
+}
class StdMeshers_MaxElementArea:public SMESH_Hypothesis
{
- public:
- StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
- virtual ~ StdMeshers_MaxElementArea();
+public:
+ StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
+ virtual ~ StdMeshers_MaxElementArea();
- void SetMaxArea(double maxArea) throw(SALOME_Exception);
+ void SetMaxArea(double maxArea) throw(SALOME_Exception);
- double GetMaxArea() const;
+ double GetMaxArea() const;
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream & operator <<(ostream & save, StdMeshers_MaxElementArea & hyp);
- friend istream & operator >>(istream & load, StdMeshers_MaxElementArea & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream & operator <<(std::ostream & save, StdMeshers_MaxElementArea & hyp);
+ friend std::istream & operator >>(std::istream & load, StdMeshers_MaxElementArea & hyp);
- protected:
- double _maxArea;
+ /*!
+ * \brief Initialize maximal area by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+protected:
+ double _maxArea;
};
#endif
using namespace std;
#include "StdMeshers_MaxElementVolume.hxx"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMESHDS_SubMesh.hxx"
+#include "SMESH_ControlsDef.hxx"
+#include "SMESH_Mesh.hxx"
+
#include "utilities.h"
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
//=============================================================================
/*!
*
StdMeshers_MaxElementVolume::StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen)
: SMESH_Hypothesis(hypId, studyId, gen)
{
- _maxVolume =1.;
+ _maxVolume = 1.;
_name = "MaxElementVolume";
-// SCRUTE(_name);
- SCRUTE(&_name);
_param_algo_dim = 3;
}
return hyp.LoadFrom( load );
}
+
+//================================================================================
+/*!
+ * \brief Initialize maximal area by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_MaxElementVolume::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ if ( !theMesh || theShape.IsNull() )
+ return false;
+
+ _maxVolume = 0;
+
+ SMESH::Controls::Volume volumeControl;
+
+ TopTools_IndexedMapOfShape volMap;
+ TopExp::MapShapes( theShape, TopAbs_SOLID, volMap );
+ if ( volMap.IsEmpty() )
+ TopExp::MapShapes( theShape, TopAbs_SHELL, volMap );
+ if ( volMap.IsEmpty() )
+ return false;
+
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+
+ for ( int iV = 1; iV <= volMap.Extent(); ++iV )
+ {
+ const TopoDS_Shape& S = volMap( iV );
+ SMESHDS_SubMesh * subMesh = aMeshDS->MeshElements( S );
+ if ( !subMesh && S.ShapeType() == TopAbs_SOLID ) {
+ TopExp_Explorer shellExp( S, TopAbs_SHELL );
+ if ( shellExp.More() )
+ subMesh = aMeshDS->MeshElements( shellExp.Current() );
+ }
+ if ( !subMesh)
+ return false;
+ SMDS_ElemIteratorPtr vIt = subMesh->GetElements();
+ while ( vIt->more() )
+ {
+ const SMDS_MeshElement* elem = vIt->next();
+ if ( elem->GetType() == SMDSAbs_Volume ) {
+ _maxVolume = max( _maxVolume, volumeControl.GetValue( elem->GetID() ));
+ }
+ }
+ }
+ return _maxVolume > 0;
+}
double GetMaxVolume() const;
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream & operator << (ostream & save, StdMeshers_MaxElementVolume & hyp);
- friend istream & operator >> (istream & load, StdMeshers_MaxElementVolume & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream & operator << (std::ostream & save, StdMeshers_MaxElementVolume & hyp);
+ friend std::istream & operator >> (std::istream & load, StdMeshers_MaxElementVolume & hyp);
+
+ /*!
+ * \brief Initialize maximal volume by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
protected:
double _maxVolume;
{
return load;
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+//================================================================================
+
+bool StdMeshers_NotConformAllowed::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+ const TopoDS_Shape& /*theShape*/)
+{
+ return false;
+}
StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_NotConformAllowed();
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream & operator << (ostream & save, StdMeshers_NotConformAllowed & hyp);
- friend istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream & operator << (std::ostream & save, StdMeshers_NotConformAllowed & hyp);
+ friend std::istream & operator >> (std::istream & load, StdMeshers_NotConformAllowed & hyp);
+
+ /*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
};
#endif
// Module : SMESH
// $Header$
-using namespace std;
#include "StdMeshers_NumberOfSegments.hxx"
+
#include "StdMeshers_Distribution.hxx"
-#include <Standard_ErrorHandler.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <ExprIntrp_GenExp.hxx>
-#include <Expr_NamedUnknown.hxx>
+#include "SMESHDS_SubMesh.hxx"
+#include "SMESH_Mesh.hxx"
+
#include <CASCatch_CatchSignals.hxx>
-#include <CASCatch_Failure.hxx>
#include <CASCatch_ErrorHandler.hxx>
-#include <OSD.hxx>
+#include <CASCatch_Failure.hxx>
+#include <ExprIntrp_GenExp.hxx>
#include <Expr_Array1OfNamedUnknown.hxx>
+#include <Expr_NamedUnknown.hxx>
+#include <OSD.hxx>
#include <TColStd_Array1OfReal.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <Standard_ErrorHandler.hxx>
+
+using namespace std;
const double PRECISION = 1e-7;
{
return hyp.LoadFrom( load );
}
+
+//================================================================================
+/*!
+ * \brief Initialize number of segments by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_NumberOfSegments::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ if ( !theMesh || theShape.IsNull() )
+ return false;
+
+ _numberOfSegments = 0;
+ _distrType = DT_Regular;
+
+ int nbEdges = 0;
+ TopTools_IndexedMapOfShape edgeMap;
+ TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+ for ( int i = 1; i <= edgeMap.Extent(); ++i )
+ {
+ // get current segment length
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+ SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( edgeMap( i ));
+ if ( eSubMesh && eSubMesh->NbElements())
+ _numberOfSegments += eSubMesh->NbElements();
+
+ ++nbEdges;
+ }
+ if ( nbEdges )
+ _numberOfSegments /= nbEdges;
+
+ return nbEdges;
+}
int ConversionMode() const
throw (SALOME_Exception);
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream& operator << (ostream & save, StdMeshers_NumberOfSegments & hyp);
- friend istream& operator >> (istream & load, StdMeshers_NumberOfSegments & hyp);
+
+ /*!
+ * \brief Initialize number of segments by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream& operator << (std::ostream & save, StdMeshers_NumberOfSegments & hyp);
+ friend std::istream& operator >> (std::istream & load, StdMeshers_NumberOfSegments & hyp);
protected:
int _numberOfSegments; //!< an edge will be split on to this number of segments
// Module : SMESH
// $Header$
-using namespace std;
#include "StdMeshers_Propagation.hxx"
+
#include "utilities.h"
+using namespace std;
+
//=============================================================================
/*!
*
{
return "Propagation";
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+//================================================================================
+
+bool StdMeshers_Propagation::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+ const TopoDS_Shape& /*theShape*/)
+{
+ return false;
+}
StdMeshers_Propagation(int hypId, int studyId, SMESH_Gen * gen);
virtual ~ StdMeshers_Propagation();
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream & operator <<(ostream & save, StdMeshers_Propagation & hyp);
- friend istream & operator >>(istream & load, StdMeshers_Propagation & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream & operator <<(std::ostream & save, StdMeshers_Propagation & hyp);
+ friend std::istream & operator >>(std::istream & load, StdMeshers_Propagation & hyp);
static std::string GetName ();
+
+ /*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
};
#endif
{
return hyp.LoadFrom( load );
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+//================================================================================
+
+bool StdMeshers_QuadranglePreference::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
+ const TopoDS_Shape& /*theShape*/)
+{
+ return false;
+}
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream & operator <<(std::ostream & save, StdMeshers_QuadranglePreference & hyp);
friend std::istream & operator >>(std::istream & load, StdMeshers_QuadranglePreference & hyp);
+
+ /*!
+ * \brief Initialize my parameter values by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ *
+ * Just return false as this hypothesis does not have parameters values
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
};
#endif
#include <Precision.hxx>
#include <gp_Pnt2d.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_SequenceOfReal.hxx>
+#include <TColgp_SequenceOfXY.hxx>
#include "utilities.h"
#include "Utils_ExceptHandlers.hxx"
+#ifndef StdMeshers_Array2OfNode_HeaderFile
+#define StdMeshers_Array2OfNode_HeaderFile
+typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
+#include <NCollection_DefineArray2.hxx>
+DEFINE_BASECOLLECTION (StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
+DEFINE_ARRAY2(StdMeshers_Array2OfNode,
+ StdMeshers_BaseCollectionNodePtr, SMDS_MeshNodePtr)
+#endif
+
//=============================================================================
/*!
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
aMesh.GetSubMesh(aShape);
- FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
+ //FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
+ FaceQuadStruct* quad = CheckNbEdges(aMesh, aShape);
+
+ if (!quad)
+ return false;
+
+ if(myQuadranglePreference) {
+ int n1 = quad->nbPts[0];
+ int n2 = quad->nbPts[1];
+ int n3 = quad->nbPts[2];
+ int n4 = quad->nbPts[3];
+ int nfull = n1+n2+n3+n4;
+ int ntmp = nfull/2;
+ ntmp = ntmp*2;
+ if( nfull==ntmp && ( (n1!=n3) || (n2!=n4) ) ) {
+ // special path for using only quandrangle faces
+ return ComputeQuadPref(aMesh, aShape, quad);
+ }
+ }
+
+ // set normalized grid on unit square in parametric domain
+ SetNormalizedGrid(aMesh, aShape, quad);
if (!quad)
return false;
return isOk;
}
+
//=============================================================================
/*!
*
*/
//=============================================================================
-FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
- (SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) throw(SALOME_Exception)
+FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape)
+ throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
// verify 1 wire only, with 4 edges
- if (NumberOfWires(F) != 1)
- {
+ if (NumberOfWires(F) != 1) {
INFOS("only 1 wire by face (quadrangles)");
return 0;
}
const TopoDS_Wire& W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp (W, F);
- FaceQuadStruct *quad = new FaceQuadStruct;
+ FaceQuadStruct* quad = new FaceQuadStruct;
for (int i = 0; i < 4; i++)
quad->uv_edges[i] = 0;
quad->uv_grid = 0;
int nbEdges = 0;
- for (wexp.Init(W, F); wexp.More(); wexp.Next())
- {
+ for (wexp.Init(W, F); wexp.More(); wexp.Next()) {
const TopoDS_Edge& E = wexp.Current();
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
- if (nbEdges < 4)
- {
+ if (nbEdges < 4) {
quad->edge[nbEdges] = E;
quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
}
nbEdges++;
}
- if (nbEdges != 4)
- {
+ if (nbEdges != 4) {
INFOS("face must have 4 edges /quadrangles");
QuadDelete(quad);
return 0;
}
- // set normalized grid on unit square in parametric domain
+ return quad;
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
+ (SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) throw(SALOME_Exception)
+{
+ Unexpect aCatch(SalomeException);
+
+ FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
+
+ if(!quad) return 0;
- SetNormalizedGrid(aMesh, F, quad);
+ // set normalized grid on unit square in parametric domain
+ SetNormalizedGrid(aMesh, aShape, quad);
return quad;
}
}
}
+
+//=======================================================================
+//function : ShiftQuad
+//purpose : auxilary function for ComputeQuadPref
+//=======================================================================
+static void ShiftQuad(FaceQuadStruct* quad, const int num, bool WisF)
+{
+ if(num>3) return;
+ int i;
+ for(i=1; i<=num; i++) {
+ int nbPts3 = quad->nbPts[0];
+ quad->nbPts[0] = quad->nbPts[1];
+ quad->nbPts[1] = quad->nbPts[2];
+ quad->nbPts[2] = quad->nbPts[3];
+ quad->nbPts[3] = nbPts3;
+ TopoDS_Edge edge3 = quad->edge[0];
+ quad->edge[0] = quad->edge[1];
+ quad->edge[1] = quad->edge[2];
+ quad->edge[2] = quad->edge[3];
+ quad->edge[3] = edge3;
+ double first3 = quad->first[0];
+ quad->first[0] = quad->first[1];
+ quad->first[1] = quad->first[2];
+ quad->first[2] = quad->first[3];
+ quad->first[3] = first3;
+ double last3 = quad->last[0];
+ quad->last[0] = quad->last[1];
+ quad->last[1] = quad->last[2];
+ quad->last[2] = quad->last[3];
+ quad->last[3] = last3;
+ bool isEdgeForward3 = quad->isEdgeForward[0];
+ quad->isEdgeForward[0] = quad->isEdgeForward[1];
+ quad->isEdgeForward[1] = quad->isEdgeForward[2];
+ quad->isEdgeForward[2] = quad->isEdgeForward[3];
+ quad->isEdgeForward[3] = isEdgeForward3;
+ bool isEdgeOut3 = quad->isEdgeOut[0];
+ quad->isEdgeOut[0] = quad->isEdgeOut[1];
+ quad->isEdgeOut[1] = quad->isEdgeOut[2];
+ quad->isEdgeOut[2] = quad->isEdgeOut[3];
+ quad->isEdgeOut[3] = isEdgeOut3;
+ UVPtStruct* uv_edges3 = quad->uv_edges[0];
+ quad->uv_edges[0] = quad->uv_edges[1];
+ quad->uv_edges[1] = quad->uv_edges[2];
+ quad->uv_edges[2] = quad->uv_edges[3];
+ quad->uv_edges[3] = uv_edges3;
+ }
+ if(!WisF) {
+ // replacement left and right edges
+ int nbPts3 = quad->nbPts[1];
+ quad->nbPts[1] = quad->nbPts[3];
+ quad->nbPts[3] = nbPts3;
+ TopoDS_Edge edge3 = quad->edge[1];
+ quad->edge[1] = quad->edge[3];
+ quad->edge[3] = edge3;
+ double first3 = quad->first[1];
+ quad->first[1] = quad->first[3];
+ quad->first[3] = first3;
+ double last3 = quad->last[1];
+ quad->last[1] = quad->last[2];
+ quad->last[3] = last3;
+ bool isEdgeForward3 = quad->isEdgeForward[1];
+ quad->isEdgeForward[1] = quad->isEdgeForward[3];
+ quad->isEdgeForward[3] = isEdgeForward3;
+ bool isEdgeOut3 = quad->isEdgeOut[1];
+ quad->isEdgeOut[1] = quad->isEdgeOut[3];
+ quad->isEdgeOut[3] = isEdgeOut3;
+ UVPtStruct* uv_edges3 = quad->uv_edges[1];
+ quad->uv_edges[1] = quad->uv_edges[3];
+ quad->uv_edges[3] = uv_edges3;
+ }
+}
+
+
+//=======================================================================
+//function : CalcUV
+//purpose : auxilary function for ComputeQuadPref
+//=======================================================================
+static gp_XY CalcUV(double x0, double x1, double y0, double y1,
+ FaceQuadStruct* quad,
+ const gp_Pnt2d& a0, const gp_Pnt2d& a1,
+ const gp_Pnt2d& a2, const gp_Pnt2d& a3,
+ const Handle(Geom2d_Curve)& c2db,
+ const Handle(Geom2d_Curve)& c2dr,
+ const Handle(Geom2d_Curve)& c2dt,
+ const Handle(Geom2d_Curve)& c2dl)
+{
+ int nb = quad->nbPts[0];
+ int nr = quad->nbPts[1];
+ int nt = quad->nbPts[2];
+ int nl = quad->nbPts[3];
+
+ UVPtStruct* uv_eb = quad->uv_edges[0];
+ UVPtStruct* uv_er = quad->uv_edges[1];
+ UVPtStruct* uv_et = quad->uv_edges[2];
+ UVPtStruct* uv_el = quad->uv_edges[3];
+
+ double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
+ double y = y0 + x * (y1 - y0);
+
+ double param_b = uv_eb[0].param + x * (uv_eb[nb-1].param - uv_eb[0].param);
+ double param_t = uv_et[0].param + x * (uv_et[nt-1].param - uv_et[0].param);
+ double param_r = uv_er[0].param + y * (uv_er[nr-1].param - uv_er[0].param);
+ double param_l = uv_el[0].param + y * (uv_el[nl-1].param - uv_el[0].param);
+
+ gp_Pnt2d p0 = c2db->Value(param_b);
+ gp_Pnt2d p1 = c2dr->Value(param_r);
+ gp_Pnt2d p2 = c2dt->Value(param_t);
+ gp_Pnt2d p3 = c2dl->Value(param_l);
+
+ double u = (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
+ double v = (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
+
+ u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
+ x * y * a2.X() + (1 - x) * y * a3.X();
+ v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
+ x * y * a2.Y() + (1 - x) * y * a3.Y();
+
+ //cout<<"x0="<<x0<<" x1="<<x1<<" y0="<<y0<<" y1="<<y1<<endl;
+ //cout<<"x="<<x<<" y="<<y<<endl;
+ //cout<<"param_b="<<param_b<<" param_t="<<param_t<<" param_r="<<param_r<<" param_l="<<param_l<<endl;
+ //cout<<"u="<<u<<" v="<<v<<endl;
+
+ return gp_XY(u,v);
+}
+
+
+//=======================================================================
+//function : ComputeQuadPref
+//purpose :
+//=======================================================================
+/*!
+ * Special function for creation only quandrangle faces
+ */
+bool StdMeshers_Quadrangle_2D::ComputeQuadPref
+ (SMESH_Mesh & aMesh,
+ const TopoDS_Shape& aShape,
+ FaceQuadStruct* quad) throw (SALOME_Exception)
+{
+ Unexpect aCatch(SalomeException);
+
+ SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+ const TopoDS_Face& F = TopoDS::Face(aShape);
+ Handle(Geom_Surface) S = BRep_Tool::Surface(F);
+ const TopoDS_Wire& W = BRepTools::OuterWire(F);
+ bool WisF = false;
+ if(W.Orientation()==TopAbs_FORWARD)
+ WisF = true;
+ //if(WisF) cout<<"W is FORWARD"<<endl;
+ //else cout<<"W is REVERSED"<<endl;
+ bool FisF = (F.Orientation()==TopAbs_FORWARD);
+ if(!FisF) WisF = !WisF;
+ int i,j,geomFaceID = meshDS->ShapeToIndex( F );
+
+ int nb = quad->nbPts[0];
+ int nr = quad->nbPts[1];
+ int nt = quad->nbPts[2];
+ int nl = quad->nbPts[3];
+ int dh = abs(nb-nt);
+ int dv = abs(nr-nl);
+
+ if( dh>=dv ) {
+ if( nt>nb ) {
+ // it is a base case => not shift quad but me be replacement is need
+ ShiftQuad(quad,0,WisF);
+ }
+ else {
+ // we have to shift quad on 2
+ ShiftQuad(quad,2,WisF);
+ }
+ }
+ else {
+ if( nr>nl ) {
+ // we have to shift quad on 3
+ ShiftQuad(quad,3,WisF);
+ }
+ else {
+ // we have to shift quad on 1
+ ShiftQuad(quad,1,WisF);
+ }
+ }
+
+ nb = quad->nbPts[0];
+ nr = quad->nbPts[1];
+ nt = quad->nbPts[2];
+ nl = quad->nbPts[3];
+ dh = abs(nb-nt);
+ dv = abs(nr-nl);
+ int nbh = Max(nb,nt);
+ int nbv = Max(nr,nl);
+ int addh = 0;
+ int addv = 0;
+
+ // orientation of face and 3 main domain for future faces
+ // 0 top 1
+ // 1------------1
+ // | | | |
+ // | | | |
+ // | L | | R |
+ // left | | | | rigth
+ // | / \ |
+ // | / C \ |
+ // |/ \|
+ // 0------------0
+ // 0 bottom 1
+
+ if(dh>dv) {
+ addv = (dh-dv)/2;
+ nbv = nbv + addv;
+ }
+ else { // dv>=dh
+ addh = (dv-dh)/2;
+ nbh = nbh + addh;
+ }
+
+ Handle(Geom2d_Curve) c2d[4];
+ for(i=0; i<4; i++) {
+ c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i], F,
+ quad->first[i], quad->last[i]);
+ }
+
+ bool loadOk = true;
+ for(i=0; i<2; i++) {
+ quad->uv_edges[i] = LoadEdgePoints2(aMesh, F, quad->edge[i], false);
+ if(!quad->uv_edges[i]) loadOk = false;
+ }
+ for(i=2; i<4; i++) {
+ quad->uv_edges[i] = LoadEdgePoints2(aMesh, F, quad->edge[i], true);
+ if (!quad->uv_edges[i]) loadOk = false;
+ }
+ if (!loadOk) {
+ INFOS("StdMeshers_Quadrangle_2D::ComputeQuadPref - LoadEdgePoints failed");
+ QuadDelete( quad );
+ quad = 0;
+ return false;
+ }
+
+ UVPtStruct* uv_eb = quad->uv_edges[0];
+ UVPtStruct* uv_er = quad->uv_edges[1];
+ UVPtStruct* uv_et = quad->uv_edges[2];
+ UVPtStruct* uv_el = quad->uv_edges[3];
+
+ // arrays for normalized params
+ //cout<<"Dump B:"<<endl;
+ TColStd_SequenceOfReal npb, npr, npt, npl;
+ for(i=0; i<nb; i++) {
+ npb.Append(uv_eb[i].normParam);
+ //cout<<"i="<<i<<" par="<<uv_eb[i].param<<" npar="<<uv_eb[i].normParam;
+ //const SMDS_MeshNode* N = uv_eb[i].node;
+ //cout<<" node("<<N->X()<<","<<N->Y()<<","<<N->Z()<<")"<<endl;
+ }
+ for(i=0; i<nr; i++) {
+ npr.Append(uv_er[i].normParam);
+ }
+ for(i=0; i<nt; i++) {
+ npt.Append(uv_et[i].normParam);
+ }
+ for(i=0; i<nl; i++) {
+ npl.Append(uv_el[i].normParam);
+ }
+
+ // we have to add few values of params to right and left
+ // insert them after first param
+ // insert to right
+ int dr = nbv - nr;
+ double dpr = (npr.Value(2) - npr.Value(1))/(dr+1);
+ for(i=1; i<=dr; i++) {
+ npr.InsertAfter(1,npr.Value(2)-dpr);
+ }
+ // insert to left
+ int dl = nbv - nl;
+ dpr = (npl.Value(2) - npl.Value(1))/(dl+1);
+ for(i=1; i<=dl; i++) {
+ npl.InsertAfter(1,npl.Value(2)-dpr);
+ }
+ //cout<<"npb:";
+ //for(i=1; i<=npb.Length(); i++) {
+ // cout<<" "<<npb.Value(i);
+ //}
+ //cout<<endl;
+
+ gp_Pnt2d a[4];
+ c2d[0]->D0(uv_eb[0].param,a[0]);
+ c2d[0]->D0(uv_eb[nb-1].param,a[1]);
+ c2d[2]->D0(uv_et[nt-1].param,a[2]);
+ c2d[2]->D0(uv_et[0].param,a[3]);
+ //cout<<" a[0]("<<a[0].X()<<","<<a[0].Y()<<")"<<" a[1]("<<a[1].X()<<","<<a[1].Y()<<")"
+ // <<" a[2]("<<a[2].X()<<","<<a[2].Y()<<")"<<" a[3]("<<a[3].X()<<","<<a[3].Y()<<")"<<endl;
+
+ int nnn = Min(nr,nl);
+ // auxilary sequence of XY for creation nodes
+ // in the bottom part of central domain
+ // it's length must be == nbv-nnn-1
+ TColgp_SequenceOfXY UVL;
+ TColgp_SequenceOfXY UVR;
+
+ // step1: create faces for left domain
+ StdMeshers_Array2OfNode NodesL(1,dl+1,1,nl);
+ // add left nodes
+ for(j=1; j<=nl; j++)
+ NodesL.SetValue(1,j,uv_el[j-1].node);
+ if(dl>0) {
+ // add top nodes
+ for(i=1; i<=dl; i++)
+ NodesL.SetValue(i+1,nl,uv_et[i].node);
+ // create and add needed nodes
+ TColgp_SequenceOfXY UVtmp;
+ for(i=1; i<=dl; i++) {
+ double x0 = npt.Value(i+1);
+ double x1 = x0;
+ // diagonal node
+ double y0 = npl.Value(i+1);
+ double y1 = npr.Value(i+1);
+ gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+ c2d[0], c2d[1], c2d[2], c2d[3]);
+ gp_Pnt P = S->Value(UV.X(),UV.Y());
+ SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+ NodesL.SetValue(i+1,1,N);
+ if(UVL.Length()<nbv-nnn-1) UVL.Append(UV);
+ // internal nodes
+ for(j=2; j<nl; j++) {
+ double y0 = npl.Value(dl+j);
+ double y1 = npr.Value(dl+j);
+ gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+ c2d[0], c2d[1], c2d[2], c2d[3]);
+ gp_Pnt P = S->Value(UV.X(),UV.Y());
+ SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+ NodesL.SetValue(i+1,j,N);
+ if( i==dl ) UVtmp.Append(UV);
+ }
+ }
+ for(i=1; i<=UVtmp.Length() && UVL.Length()<nbv-nnn-1; i++) {
+ UVL.Append(UVtmp.Value(i));
+ }
+ //cout<<"Dump NodesL:"<<endl;
+ //for(i=1; i<=dl+1; i++) {
+ // cout<<"i="<<i;
+ // for(j=1; j<=nl; j++) {
+ // cout<<" ("<<NodesL.Value(i,j)->X()<<","<<NodesL.Value(i,j)->Y()<<","<<NodesL.Value(i,j)->Z()<<")";
+ // }
+ // cout<<endl;
+ //}
+ // create faces
+ for(i=1; i<=dl; i++) {
+ for(j=1; j<nl; j++) {
+ if(WisF) {
+ SMDS_MeshFace* F =
+ meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
+ NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
+ meshDS->SetMeshElementOnShape(F, geomFaceID);
+ }
+ else {
+ SMDS_MeshFace* F =
+ meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i,j+1),
+ NodesL.Value(i+1,j+1), NodesL.Value(i+1,j));
+ meshDS->SetMeshElementOnShape(F, geomFaceID);
+ }
+ }
+ }
+ }
+ else {
+ // fill UVL using c2d
+ for(i=1; i<npl.Length() && UVL.Length()<nbv-nnn-1; i++) {
+ gp_Pnt2d p2d;
+ c2d[3]->D0(uv_el[i].param,p2d);
+ UVL.Append(p2d.XY());
+ }
+ }
+
+ // step2: create faces for right domain
+ StdMeshers_Array2OfNode NodesR(1,dr+1,1,nr);
+ // add right nodes
+ for(j=1; j<=nr; j++)
+ NodesR.SetValue(1,j,uv_er[nr-j].node);
+ if(dr>0) {
+ // add top nodes
+ for(i=1; i<=dr; i++)
+ NodesR.SetValue(i+1,1,uv_et[nt-1-i].node);
+ // create and add needed nodes
+ TColgp_SequenceOfXY UVtmp;
+ for(i=1; i<=dr; i++) {
+ double x0 = npt.Value(nt-i);
+ double x1 = x0;
+ // diagonal node
+ double y0 = npl.Value(i+1);
+ double y1 = npr.Value(i+1);
+ gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+ c2d[0], c2d[1], c2d[2], c2d[3]);
+ gp_Pnt P = S->Value(UV.X(),UV.Y());
+ SMDS_MeshNode * N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+ NodesR.SetValue(i+1,nr,N);
+ if(UVR.Length()<nbv-nnn-1) UVR.Append(UV);
+ // internal nodes
+ for(j=2; j<nr; j++) {
+ double y0 = npl.Value(nbv-j+1);
+ double y1 = npr.Value(nbv-j+1);
+ gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+ c2d[0], c2d[1], c2d[2], c2d[3]);
+ gp_Pnt P = S->Value(UV.X(),UV.Y());
+ SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+ NodesR.SetValue(i+1,j,N);
+ if( i==dr ) UVtmp.Prepend(UV);
+ }
+ }
+ for(i=1; i<=UVtmp.Length() && UVR.Length()<nbv-nnn-1; i++) {
+ UVR.Append(UVtmp.Value(i));
+ }
+ // create faces
+ for(i=1; i<=dr; i++) {
+ for(j=1; j<nr; j++) {
+ if(WisF) {
+ SMDS_MeshFace* F =
+ meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
+ NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
+ meshDS->SetMeshElementOnShape(F, geomFaceID);
+ }
+ else {
+ SMDS_MeshFace* F =
+ meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i,j+1),
+ NodesR.Value(i+1,j+1), NodesR.Value(i+1,j));
+ meshDS->SetMeshElementOnShape(F, geomFaceID);
+ }
+ }
+ }
+ }
+ else {
+ // fill UVR using c2d
+ for(i=1; i<npr.Length() && UVR.Length()<nbv-nnn-1; i++) {
+ gp_Pnt2d p2d;
+ c2d[1]->D0(uv_er[i].param,p2d);
+ UVR.Append(p2d.XY());
+ }
+ }
+
+ // step3: create faces for central domain
+ StdMeshers_Array2OfNode NodesC(1,nb,1,nbv);
+ // add first string using NodesL
+ for(i=1; i<=dl+1; i++)
+ NodesC.SetValue(1,i,NodesL(i,1));
+ for(i=2; i<=nl; i++)
+ NodesC.SetValue(1,dl+i,NodesL(dl+1,i));
+ // add last string using NodesR
+ for(i=1; i<=dr+1; i++)
+ NodesC.SetValue(nb,i,NodesR(i,nr));
+ for(i=1; i<nr; i++)
+ NodesC.SetValue(nb,dr+i+1,NodesR(dr+1,nr-i));
+ // add top nodes (last columns)
+ for(i=dl+2; i<nbh-dr; i++)
+ NodesC.SetValue(i-dl,nbv,uv_et[i-1].node);
+ // add bottom nodes (first columns)
+ for(i=2; i<nb; i++) {
+ NodesC.SetValue(i,1,uv_eb[i-1].node);
+ gp_Pnt2d p2d;
+ c2d[0]->D0(uv_eb[i-1].param,p2d);
+ }
+ // create and add needed nodes
+ // add linear layers
+ for(i=2; i<nb; i++) {
+ double x0 = npt.Value(dl+i);
+ double x1 = x0;
+ for(j=1; j<nnn; j++) {
+ double y0 = npl.Value(nbv-nnn+j);
+ double y1 = npr.Value(nbv-nnn+j);
+ gp_XY UV = CalcUV(x0, x1, y0, y1, quad, a[0], a[1], a[2], a[3],
+ c2d[0], c2d[1], c2d[2], c2d[3]);
+ gp_Pnt P = S->Value(UV.X(),UV.Y());
+ SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ meshDS->SetNodeOnFace(N, geomFaceID, UV.X(), UV.Y());
+ NodesC.SetValue(i,nbv-nnn+j,N);
+ }
+ }
+ // add diagonal layers
+ //cout<<"UVL.Length()="<<UVL.Length()<<" UVR.Length()="<<UVR.Length()<<endl;
+ //cout<<"Dump UVL:"<<endl;
+ //for(i=1; i<=UVL.Length(); i++) {
+ // cout<<" ("<<UVL.Value(i).X()<<","<<UVL.Value(i).Y()<<")";
+ //}
+ //cout<<endl;
+ for(i=1; i<nbv-nnn; i++) {
+ double du = UVR.Value(i).X() - UVL.Value(i).X();
+ double dv = UVR.Value(i).Y() - UVL.Value(i).Y();
+ for(j=2; j<nb; j++) {
+ double u = UVL.Value(i).X() + du*npb.Value(j);
+ double v = UVL.Value(i).Y() + dv*npb.Value(j);
+ gp_Pnt P = S->Value(u,v);
+ SMDS_MeshNode* N = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ meshDS->SetNodeOnFace(N, geomFaceID, u, v);
+ NodesC.SetValue(j,i+1,N);
+ }
+ }
+ // create faces
+ for(i=1; i<nb; i++) {
+ for(j=1; j<nbv; j++) {
+ if(WisF) {
+ SMDS_MeshFace* F =
+ meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
+ NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
+ meshDS->SetMeshElementOnShape(F, geomFaceID);
+ }
+ else {
+ SMDS_MeshFace* F =
+ meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
+ NodesC.Value(i+1,j+1), NodesC.Value(i+1,j));
+ meshDS->SetMeshElementOnShape(F, geomFaceID);
+ }
+ }
+ }
+
+ QuadDelete(quad);
+ bool isOk = true;
+ return isOk;
+}
+
+
+//=============================================================================
+/*!
+ * LoadEdgePoints2
+ */
+//=============================================================================
+UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints2 (SMESH_Mesh & aMesh,
+ const TopoDS_Face& F,
+ const TopoDS_Edge& E,
+ bool IsReverse)
+{
+ //MESSAGE("StdMeshers_Quadrangle_2D::LoadEdgePoints");
+ // --- IDNodes of first and last Vertex
+ TopoDS_Vertex VFirst, VLast;
+ TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
+
+ ASSERT(!VFirst.IsNull());
+ SMDS_NodeIteratorPtr lid = aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
+ if (!lid->more()) {
+ MESSAGE ( "NO NODE BUILT ON VERTEX" );
+ return 0;
+ }
+ const SMDS_MeshNode* idFirst = lid->next();
+
+ ASSERT(!VLast.IsNull());
+ lid = aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
+ if (!lid->more()) {
+ MESSAGE ( "NO NODE BUILT ON VERTEX" );
+ return 0;
+ }
+ const SMDS_MeshNode* idLast = lid->next();
+
+ // --- edge internal IDNodes (relies on good order storage, not checked)
+
+ map<double, const SMDS_MeshNode *> params;
+ SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
+
+ while(ite->more()) {
+ const SMDS_MeshNode* node = ite->next();
+ const SMDS_EdgePosition* epos =
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ double param = epos->GetUParameter();
+ params[param] = node;
+ }
+
+ int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+ if (nbPoints != params.size()) {
+ MESSAGE( "BAD NODE ON EDGE POSITIONS" );
+ return 0;
+ }
+ UVPtStruct* uvslf = new UVPtStruct[nbPoints + 2];
+
+ double f, l;
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+
+ const TopoDS_Wire& W = BRepTools::OuterWire(F);
+ bool FisF = (F.Orientation()==TopAbs_FORWARD);
+ bool WisF = (W.Orientation()==TopAbs_FORWARD);
+ bool isForward = (E.Orientation()==TopAbs_FORWARD);
+ //if(isForward) cout<<"E is FORWARD"<<endl;
+ //else cout<<"E is REVERSED"<<endl;
+ if(!WisF) isForward = !isForward;
+ if(!FisF) isForward = !isForward;
+ //bool isForward = !(E.Orientation()==TopAbs_FORWARD);
+ if(IsReverse) isForward = !isForward;
+ double paramin = 0;
+ double paramax = 0;
+ if (isForward) {
+ paramin = f;
+ paramax = l;
+ gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
+ uvslf[0].x = p.X();
+ uvslf[0].y = p.Y();
+ uvslf[0].param = f;
+ uvslf[0].node = idFirst;
+ //MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
+ map < double, const SMDS_MeshNode* >::iterator itp = params.begin();
+ for (int i = 1; i <= nbPoints; i++) { // nbPoints internal
+ double param = (*itp).first;
+ gp_Pnt2d p = C2d->Value(param);
+ uvslf[i].x = p.X();
+ uvslf[i].y = p.Y();
+ uvslf[i].param = param;
+ uvslf[i].node = (*itp).second;
+ //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
+ itp++;
+ }
+ p = C2d->Value(l); // last point = Vertex Reversed
+ uvslf[nbPoints + 1].x = p.X();
+ uvslf[nbPoints + 1].y = p.Y();
+ uvslf[nbPoints + 1].param = l;
+ uvslf[nbPoints + 1].node = idLast;
+ //MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
+ }
+ else {
+ paramin = l;
+ paramax = f;
+ gp_Pnt2d p = C2d->Value(l); // first point = Vertex Reversed
+ uvslf[0].x = p.X();
+ uvslf[0].y = p.Y();
+ uvslf[0].param = l;
+ uvslf[0].node = idLast;
+ //MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
+ map < double, const SMDS_MeshNode* >::reverse_iterator itp = params.rbegin();
+ for (int j = nbPoints; j >= 1; j--) { // nbPoints internal
+ double param = (*itp).first;
+ int i = nbPoints + 1 - j;
+ gp_Pnt2d p = C2d->Value(param);
+ uvslf[i].x = p.X();
+ uvslf[i].y = p.Y();
+ uvslf[i].param = param;
+ uvslf[i].node = (*itp).second;
+ //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
+ itp++;
+ }
+ p = C2d->Value(f); // last point = Vertex Forward
+ uvslf[nbPoints + 1].x = p.X();
+ uvslf[nbPoints + 1].y = p.Y();
+ uvslf[nbPoints + 1].param = f;
+ uvslf[nbPoints + 1].node = idFirst;
+ //MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
+ }
+
+ ASSERT(paramin != paramax);
+ for (int i = 0; i < nbPoints + 2; i++) {
+ uvslf[i].normParam = (uvslf[i].param - paramin) / (paramax - paramin);
+ }
+
+ return uvslf;
+}
+
+
//=============================================================================
/*!
* LoadEdgePoints
protected:
+ FaceQuadStruct* CheckNbEdges(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+ throw (SALOME_Exception);
+
void SetNormalizedGrid(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
FaceQuadStruct* quad)
throw (SALOME_Exception);
+ /**
+ * Special function for creation only quandrangle faces
+ */
+ bool ComputeQuadPref(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ FaceQuadStruct* quad)
+ throw (SALOME_Exception);
+
+ UVPtStruct* LoadEdgePoints2(SMESH_Mesh& aMesh,
+ const TopoDS_Face& F, const TopoDS_Edge& E,
+ bool IsReverse);
+
UVPtStruct* LoadEdgePoints(SMESH_Mesh& aMesh,
const TopoDS_Face& F, const TopoDS_Edge& E,
double first, double last);
// Module : SMESH
// $Header$
-using namespace std;
-
#include "StdMeshers_Regular_1D.hxx"
#include "StdMeshers_Distribution.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
-#include <OSD.hxx>
-
#include "StdMeshers_LocalLength.hxx"
#include "StdMeshers_NumberOfSegments.hxx"
#include "StdMeshers_Arithmetic1D.hxx"
#include "StdMeshers_StartEndLength.hxx"
#include "StdMeshers_Deflection1D.hxx"
-#include <StdMeshers_AutomaticLength.hxx>
+#include "StdMeshers_AutomaticLength.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include <Expr_Array1OfNamedUnknown.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <ExprIntrp_GenExp.hxx>
+#include <OSD.hxx>
#include <string>
#include <math.h>
+using namespace std;
+
//=============================================================================
/*!
*
// Module : SMESH
// $Header$
-using namespace std;
-
#include "StdMeshers_StartEndLength.hxx"
-#include "utilities.h"
+#include "SMESH_Algo.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
+using namespace std;
//=============================================================================
/*!
:SMESH_Hypothesis(hypId, studyId, gen)
{
_begLength = 1.;
- _endLength = 1.;
+ _endLength = 10.;
_name = "StartEndLength";
_param_algo_dim = 1; // is used by SMESH_Regular_1D
}
{
return hyp.LoadFrom( load );
}
+
+//================================================================================
+/*!
+ * \brief Initialize start and end length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_StartEndLength::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ if ( !theMesh || theShape.IsNull() )
+ return false;
+
+ _begLength = _endLength = 0.;
+
+ Standard_Real UMin, UMax;
+ TopLoc_Location L;
+
+ int nbEdges = 0;
+ TopTools_IndexedMapOfShape edgeMap;
+ TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+ for ( int i = 1; i <= edgeMap.Extent(); ++i )
+ {
+ const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( i ));
+ Handle(Geom_Curve) C = BRep_Tool::Curve(edge, L, UMin, UMax);
+ GeomAdaptor_Curve AdaptCurve(C);
+
+ vector< double > params;
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+ if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
+ {
+ nbEdges++;
+ _begLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[0], params[1]);
+ int nb = params.size();
+ _endLength += GCPnts_AbscissaPoint::Length( AdaptCurve, params[nb-2], params[nb-1]);
+ }
+ }
+ if ( nbEdges ) {
+ _begLength /= nbEdges;
+ _endLength /= nbEdges;
+ }
+ return nbEdges;
+}
double GetLength(bool isStartLength) const;
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend ostream & operator <<(ostream & save, StdMeshers_StartEndLength & hyp);
- friend istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+ friend std::ostream & operator <<(std::ostream & save, StdMeshers_StartEndLength & hyp);
+ friend std::istream & operator >>(std::istream & load, StdMeshers_StartEndLength & hyp);
- protected:
+
+ /*!
+ * \brief Initialize start and end length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+protected:
double _begLength, _endLength;
};
+++ /dev/null
-// SMESH StdMeshersGUI : GUI for StdMeshers plugin
-//
-// Copyright (C) 2003 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.
-//
-// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : StdMeshersGUI_CreateStdHypothesisDlg.cxx
-// Moved here from SMESHGUI_CreateStdHypothesisDlg.cxx
-// Author : Nicolas REJNERI
-// Module : SMESH
-// $Header$
-
-using namespace std;
-#include "StdMeshersGUI_CreateStdHypothesisDlg.h"
-#include "StdMeshersGUI_Parameters.h"
-#include "SMESHGUI.h"
-#include "SMESHGUI_Hypotheses.h"
-
-#include "utilities.h"
-
-#include "SUIT_MessageBox.h"
-#include "SUIT_ResourceMgr.h"
-#include "SUIT_OverrideCursor.h"
-#include "SUIT_Desktop.h"
-
-//=================================================================================
-// class : StdMeshersGUI_CreateStdHypothesisDlg()
-// purpose :
-//=================================================================================
-StdMeshersGUI_CreateStdHypothesisDlg::StdMeshersGUI_CreateStdHypothesisDlg (const QString& hypType,
- QWidget* parent,
- const char* name,
- bool /*modal*/,
- WFlags fl)
- : StdMeshersGUI_CreateHypothesisDlg (hypType, parent, name, true, fl)
-{
- QString hypTypeStr;
- if (hypType.compare("LocalLength") == 0)
- hypTypeStr = "LOCAL_LENGTH";
- else if (hypType.compare("NumberOfSegments") == 0)
- hypTypeStr = "NB_SEGMENTS";
- else if (hypType.compare("MaxElementArea") == 0)
- hypTypeStr = "MAX_ELEMENT_AREA";
- else if (hypType.compare("MaxElementVolume") == 0)
- hypTypeStr = "MAX_ELEMENT_VOLUME";
- else if (hypType.compare("StartEndLength") == 0)
- hypTypeStr = "START_END_LENGTH";
- else if (hypType.compare("Deflection1D") == 0)
- hypTypeStr = "DEFLECTION1D";
- else if (hypType.compare("Arithmetic1D") == 0)
- hypTypeStr = "ARITHMETIC_1D";
- else if (hypType.compare("AutomaticLength") == 0)
- hypTypeStr = "AUTOMATIC_LENGTH";
- else
- return;
-
- QString caption( tr ( QString( "SMESH_%1_TITLE" ).arg( hypTypeStr )));
- QString hypTypeName( tr ( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeStr )));
- QString hypIconName( tr ( QString( "ICON_DLG_%1" ).arg( hypTypeStr )));
-
- CreateDlgLayout(caption,
- SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName ),
- hypTypeName);
-}
-
-//=================================================================================
-// function : ~StdMeshersGUI_CreateStdHypothesisDlg()
-// purpose : Destroys the object and frees any allocated resources
-//=================================================================================
-StdMeshersGUI_CreateStdHypothesisDlg::~StdMeshersGUI_CreateStdHypothesisDlg()
-{
- // no need to delete child widgets, Qt does it all for us
-}
-//=================================================================================
-// function : FillParameters()
-// purpose :
-//=================================================================================
-void StdMeshersGUI_CreateStdHypothesisDlg::GetParameters
- (const QString & hypType,
- std::list<SMESHGUI_aParameterPtr> & params)
-{
- StdMeshersGUI_Parameters::GetParameters( hypType, params );
-}
-
-//=================================================================================
-// function : SetParameters()
-// purpose :
-//=================================================================================
-bool StdMeshersGUI_CreateStdHypothesisDlg::SetParameters
- (SMESH::SMESH_Hypothesis_ptr theHyp, const list<SMESHGUI_aParameterPtr> & params)
-{
- StdMeshersGUI_Parameters::SetParameters( theHyp, params );
- return true;
-}
{
myHypo = StdMeshers::StdMeshers_NumberOfSegments::_duplicate( h );
myVars.ChangeValue( 1 ) = new Expr_NamedUnknown( "t" );
- myCurve1 = insertCurve( QString() );
- myCurve2 = insertCurve( QString() );
+ myDensity = insertCurve( QString() );
+ myDistr = insertCurve( QString() );
myMsg = insertMarker( new QwtPlotMarker( this ) );
setMarkerPos( myMsg, 0.5, 0.5 );
setMarkerLabelPen( myMsg, QPen( Qt::red, 1 ) );
f.setPointSize( 14 );
f.setBold( true );
setMarkerFont( myMsg, f );
- setCurvePen( myCurve1, QPen( Qt::red, 1 ) );
+ setCurvePen( myDensity, QPen( Qt::red, 1 ) );
QColor dc = Qt::blue;
- setCurvePen( myCurve2, QPen( dc, 1 ) );
- setCurveSymbol( myCurve2, QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) );
+ setCurvePen( myDistr, QPen( dc, 1 ) );
+ setCurveSymbol( myDistr, QwtSymbol( QwtSymbol::XCross, QBrush( dc ), QPen( dc ), QSize( 5, 5 ) ) );
+ setAutoLegend( true );
+ enableLegend( true );
+ setLegendPos( Qwt::Bottom );
+ setCurveTitle( myDensity, tr( "SMESH_DENSITY_FUNC" ) );
+ setCurveTitle( myDistr, tr( "SMESH_DISTR" ) );
}
StdMeshersGUI_DistrPreview::~StdMeshersGUI_DistrPreview()
max_x = x[i];
}
- setAxisScale( curveXAxis( myCurve1 ), min_x, max_x );
- setAxisScale( curveYAxis( myCurve1 ), min( 0.0, min_y ), max( 0.0, max_y ) );
- setCurveData( myCurve1, x, y, size );
+ setAxisScale( curveXAxis( myDensity ), min_x, max_x );
+ setAxisScale( curveYAxis( myDensity ), min( 0.0, min_y ), max( 0.0, max_y ) );
+ setCurveData( myDensity, x, y, size );
if( x )
delete[] x;
if( y )
x[i] = distr[i];
y[i] = 0;
}
- setCurveData( myCurve2, x, y, size );
+ setCurveData( myDistr, x, y, size );
delete[] x;
delete[] y;
x = y = 0;
- replot();
+
+ OSD::SetSignal( true );
+ CASCatch_CatchSignals aCatchSignals;
+ aCatchSignals.Activate();
+
+ CASCatch_TRY
+ {
+ replot();
+ }
+ CASCatch_CATCH(CASCatch_Failure)
+ {
+ aCatchSignals.Deactivate();
+ Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
+ }
+ aCatchSignals.Deactivate();
}
void StdMeshersGUI_DistrPreview::showError()
{
- setAxisScale( curveXAxis( myCurve1 ), 0.0, 1.0 );
- setAxisScale( curveYAxis( myCurve1 ), 0.0, 1.0 );
- setCurveData( myCurve1, 0, 0, 0 );
- setCurveData( myCurve2, 0, 0, 0 );
+ setAxisScale( curveXAxis( myDensity ), 0.0, 1.0 );
+ setAxisScale( curveYAxis( myDensity ), 0.0, 1.0 );
+ setCurveData( myDensity, 0, 0, 0 );
+ setCurveData( myDistr, 0, 0, 0 );
setMarkerLabel( myMsg, tr( "SMESH_INVALID_FUNCTION" ) );
replot();
}
bool myIsTable;
Conversion myConv;
SMESH::double_array myTableFunc;
- long myCurve1, myCurve2, myMsg;
+ long myDensity, myDistr, myMsg;
Handle(ExprIntrp_GenExp) myExpr;
Expr_Array1OfNamedUnknown myVars;
TColStd_Array1OfReal myValues;
// $Header$
#include "StdMeshersGUI_DistrTable.h"
+#include <QtxDblValidator.h>
+
#include <qlayout.h>
#include <qpushbutton.h>
-#include <qvalidator.h>
#include <qlineedit.h>
//=================================================================================
{
horizontalHeader()->setLabel( 0, "t" );
horizontalHeader()->setLabel( 1, "f(t)" );
- myArgV = new QDoubleValidator( 0.0, 1.0, 3, this );
- myFuncV = new QDoubleValidator( 0.0, 1E10, 3, this );
+ myArgV = new QtxDblValidator( 0.0, 1.0, 3, this );
+ myFuncV = new QtxDblValidator( 0.0, 1E20, 3, this );
}
StdMeshersGUI_DistrTable::~StdMeshersGUI_DistrTable()
endEdit( currEditRow(), currEditCol(), accept, false );
}
+QWidget* StdMeshersGUI_DistrTable::beginEdit( int row, int col, bool replace )
+{
+ QWidget* w = QTable::beginEdit( row, col, replace );
+ if( w && w->inherits( "QLineEdit" ) )
+ ( ( QLineEdit* )w )->selectAll();
+ return w;
+}
+
void StdMeshersGUI_DistrTable::edit( const int r, const int c )
{
if( isEditing() )
{
stopEditing( false );
setNumRows( d.length()/2 );
+ QString val;
for( int i=0; i<d.length(); i++ )
- setText( i/2, i%2, QString( "%1" ).arg( d[i] ) );
+ {
+ QtxDblValidator* v = i%2==0 ? myArgV : myFuncV;
+ val = QString::number( d[i] );
+ v->fixup( val );
+ setText( i/2, i%2, val );
+ }
+}
+
+QtxDblValidator* StdMeshersGUI_DistrTable::argValidator() const
+{
+ return myArgV;
+}
+
+QtxDblValidator* StdMeshersGUI_DistrTable::funcValidator() const
+{
+ return myFuncV;
}
//=================================================================================
else if( sender()==button( REMOVE_ROW ) )
emit toEdit( REMOVE_ROW, table()->currentRow() );
}
+
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QButton;
-class QDoubleValidator;
+class QtxDblValidator;
/*!
* \brief Values corresponding to buttons for table resize
void data( SMESH::double_array& );
void setData( const SMESH::double_array& );
+ QtxDblValidator* argValidator() const;
+ QtxDblValidator* funcValidator() const;
+
protected:
virtual QWidget* createEditor( int, int, bool ) const;
virtual bool eventFilter( QObject*, QEvent* );
virtual void keyPressEvent( QKeyEvent* );
+ virtual QWidget* beginEdit( int row, int col, bool replace );
virtual void edit( const int, const int );
private slots:
void onEdit( TableButton, int );
private:
- QDoubleValidator *myArgV, *myFuncV;
+ QtxDblValidator *myArgV, *myFuncV;
};
StdMeshersGUI_DistrTable *myTable;
};
-
#endif
#include <QtxIntSpinBox.h>
#include <QtxComboBox.h>
+#include <QtxDblValidator.h>
#include <SMESHGUI_SpinBox.h>
#include <qlabel.h>
myConv->setColumnLayout( 0, Qt::Vertical );
QGridLayout* convLay = new QGridLayout( myConv->layout() );
convLay->addWidget( new QRadioButton( tr( "SMESH_EXP_MODE" ), myConv ), 0, 0 );
- convLay->addWidget( new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
+ convLay->addWidget( myCutNeg = new QRadioButton( tr( "SMESH_CUT_NEG_MODE" ), myConv ), 1, 0 );
myGroupLayout->addWidget( myConv, row, 1 );
row++;
myExpr->setText( data.myExpr );
}
-void StdMeshersGUI_NbSegmentsCreator::storeParams() const
+QString StdMeshersGUI_NbSegmentsCreator::storeParams() const
{
NbSegmentsHypothesisData data;
readParamsFromWidgets( data );
storeParamsToHypo( data );
+
+ QString valStr = QString::number( data.myNbSeg ) += "; ";
+
+ enum DistrType
+ {
+ Regular, //!< equidistant distribution
+ Scale, //!< scale distribution
+ TabFunc, //!< distribution with density function presented by table
+ ExprFunc //!< distribution with density function presented by expression
+ };
+ bool hasConv = false;
+ switch ( data.myDistrType ) {
+ case Regular :
+ valStr += tr("SMESH_DISTR_REGULAR");
+ break;
+ case Scale :
+ valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale );
+ break;
+ case TabFunc : {
+ //valStr += tr("SMESH_TAB_FUNC");
+ bool param = true;
+ for( int i=0; i < data.myTable.length(); i++, param = !param ) {
+ if ( param )
+ valStr += "[";
+ valStr += QString::number( data.myTable[ i ]);
+ valStr += ( param ? "," : "]" );
+ }
+ hasConv = true;
+ break;
+ }
+ case ExprFunc:
+ valStr += data.myExpr;
+ hasConv = true;
+ break;
+ }
+ if ( hasConv )
+ if ( data.myConv )
+ valStr += "; " + tr("SMESH_CUT_NEG_MODE");
+ else
+ valStr += "; " + tr("SMESH_EXP_MODE");
+
+ return valStr;
}
bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisData& h_data ) const
{
StdMeshers::StdMeshers_NumberOfSegments_var h =
- StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
+ StdMeshers::StdMeshers_NumberOfSegments::_narrow( initParamsHypothesis() );
HypothesisData* data = SMESH::GetHypothesisData( hypType() );
h_data.myName = isCreation() && data ? data->Label : "";
{
int distr = myDistr->currentItem();
+/* if( distr==2 ) //table func
+ myCutNeg->setText( tr( "SMESH_NO_CONV" ) );
+ else if( distr==3 )
+ myCutNeg->setText( tr( "SMESH_CUT_NEG_MODE" ) );*/
+
+ if( distr==2 && sender()==myConv ) //table func
+ {
+ myTable->table()->funcValidator()->setBottom( myConv->id( myConv->selected() )==0 ? -1E20 : 0 );
+ SMESH::double_array arr;
+ myTable->table()->data( arr );
+ myTable->table()->setData( arr ); //update data in table
+ }
+
myScale->setShown( distr==1 );
myLScale->setShown( distr==1 );
class QLineEdit;
class QButtonGroup;
class QGridLayout;
+class QRadioButton;
typedef struct
{
protected:
virtual QFrame* buildFrame();
virtual void retrieveParams() const;
- virtual void storeParams() const;
+ virtual QString storeParams() const;
protected slots:
virtual void onValueChanged();
QLabel *myLScale, *myLTable, *myLExpr, *myLConv, *myInfo;
QGridLayout* myGroupLayout;
int myTableRow, myPreviewRow;
+ QRadioButton* myCutNeg;
};
#endif
+++ /dev/null
-// SMESH StdMeshersGUI : GUI for standard meshers
-//
-// Copyright (C) 2003 CEA
-//
-// 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.
-//
-// 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.org
-//
-//
-//
-// File : StdMeshersGUI_Parameters.cxx
-// Module : SMESH
-// $Header$
-
-#include "StdMeshersGUI_Parameters.h"
-
-#include <qobject.h>
-#include <qhbox.h>
-#include <qslider.h>
-#include <qlabel.h>
-
-#include <math.h>
-//#include <float.h>
-
-using namespace std;
-
-#define VALUE_MAX 1.0e+15 // COORD_MAX
-#define VALUE_MAX_2 (VALUE_MAX*VALUE_MAX)
-#define VALUE_MAX_3 (VALUE_MAX*VALUE_MAX*VALUE_MAX)
-
-#define VALUE_SMALL 1.0e-15
-#define VALUE_SMALL_2 (VALUE_SMALL*VALUE_SMALL)
-#define VALUE_SMALL_3 (VALUE_SMALL*VALUE_SMALL*VALUE_SMALL)
-
-//=======================================================================
-//function : HasParameters
-//purpose :
-//=======================================================================
-
-bool StdMeshersGUI_Parameters::HasParameters (const QString& hypType)
-{
- return ((hypType.compare("LocalLength") == 0) ||
- (hypType.compare("NumberOfSegments") == 0) ||
- (hypType.compare("MaxElementArea") == 0) ||
- (hypType.compare("MaxElementVolume") == 0) ||
- (hypType.compare("StartEndLength") == 0) ||
- (hypType.compare("Deflection1D") == 0) ||
- (hypType.compare("AutomaticLength") == 0) ||
- (hypType.compare("Arithmetic1D") == 0));
-}
-
-//=======================================================================
-//function : SetInitValue
-//purpose :
-//=======================================================================
-
-void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
- int initValue)
-{
- SMESHGUI_intParameter* p = dynamic_cast<SMESHGUI_intParameter*>(param.get());
- if ( p )
- {
- p->InitValue() = initValue;
- return;
- }
-
- SMESHGUI_enumParameter* q = dynamic_cast<SMESHGUI_enumParameter*>(param.get());
- if( q )
- {
- q->InitValue() = initValue;
- return;
- }
-
- SMESHGUI_boolParameter* b = dynamic_cast<SMESHGUI_boolParameter*>(param.get());
- if( b )
- {
- b->InitValue() = (bool)initValue;
- return;
- }
-}
-
-//=======================================================================
-//function : SetInitValue
-//purpose :
-//=======================================================================
-
-void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
- double initValue)
-{
- SMESHGUI_doubleParameter* p = dynamic_cast<SMESHGUI_doubleParameter*>(param.get());
- if ( p ) p->InitValue() = initValue;
-}
-
-//=======================================================================
-//function : SetInitValue
-//purpose :
-//=======================================================================
-
-void StdMeshersGUI_Parameters::SetInitValue(SMESHGUI_aParameterPtr param,
- const char* initValue)
-{
- SMESHGUI_strParameter* p = dynamic_cast<SMESHGUI_strParameter*>(param.get());
- if ( p ) p->InitValue() = initValue;
-}
-
-//=======================================================================
-//function : SetInitValue
-//purpose :
-//=======================================================================
-void StdMeshersGUI_Parameters::SetInitValue( SMESHGUI_aParameterPtr param,
- SMESH::double_array& initValue)
-{
- SMESHGUI_tableParameter* p = dynamic_cast<SMESHGUI_tableParameter*>(param.get());
- if( p )
- {
- p->setRowCount( initValue.length()/2 );
- p->setData( initValue );
- }
-}
-
-//================================================================================
-/*!
- * \brief Macros to comfortably create SMESHGUI_aParameterPtr of different types
- */
-//================================================================================
-
-// SMESHGUI_doubleParameter( initValue, label, bottom, top, step, decimals )
-#define DOUBLE_PARAM(v,l,b,t,s,d) SMESHGUI_aParameterPtr(new SMESHGUI_doubleParameter(v,l,b,t,s,d))
-#define INT_PARAM(v,l,b,t) SMESHGUI_aParameterPtr(new SMESHGUI_intParameter(v,l,b,t))
-#define ENUM_PARAM(v,i,l) SMESHGUI_aParameterPtr(new SMESHGUI_enumParameter(v,i,l))
-#define STR_PARAM(i,l,preview) SMESHGUI_aParameterPtr(new SMESHGUI_strParameter(i,l,preview))
-#define BOOL_PARAM(i,l,preview) SMESHGUI_aParameterPtr(new SMESHGUI_boolParameter(i,l,preview))
-
-//================================================================================
-/*!
- * \brief Fill parameter list with default values
- * \param hypType - The name of hypothesis type
- * \param paramList - The list to fill
- */
-//================================================================================
-
-void StdMeshersGUI_Parameters::GetParameters (const QString& hypType,
- list<SMESHGUI_aParameterPtr> & paramList )
-{
- paramList.clear();
-
- if (hypType.compare("LocalLength") == 0)
- {
- paramList.push_back( DOUBLE_PARAM (1.0,
- QObject::tr("SMESH_LOCAL_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1.0, 6));
- }
- else if (hypType.compare("NumberOfSegments") == 0)
- {
- //0-th parameter in list
- paramList.push_back ( INT_PARAM (3,
- QObject::tr("SMESH_NB_SEGMENTS_PARAM"),
- 1, 9999 ));
- QStringList types;
- types.append( QObject::tr( "SMESH_DISTR_REGULAR" ) );
- types.append( QObject::tr( "SMESH_DISTR_SCALE" ) );
- types.append( QObject::tr( "SMESH_DISTR_TAB" ) );
- types.append( QObject::tr( "SMESH_DISTR_EXPR" ) );
- //string description of distribution types
-
- SMESHGUI_enumParameter* type = new SMESHGUI_enumParameter( types, 0, QObject::tr( "SMESH_DISTR_TYPE" ) );
- SMESHGUI_dependParameter::ShownMap& aMap = type->shownMap();
- aMap[0].append( 0 ); // if DistrType=0 (regular), then number of segments and types are shown (0-th and 1-th)
- aMap[0].append( 1 );
- aMap[1].append( 0 ); // if DistrType=1 (scale), then number of segments, types and scale are shown
- aMap[1].append( 1 );
- aMap[1].append( 2 );
- aMap[2].append( 0 ); // if DistrType=2 (table), then number of segments, types, table and exponent are shown
- aMap[2].append( 1 );
- aMap[2].append( 3 );
- aMap[2].append( 5 );
- aMap[3].append( 0 ); // if DistrType=3 (expression), then number of segments, types, expression and exponent are shown
- aMap[3].append( 1 );
- aMap[3].append( 4 );
- aMap[3].append( 5 );
- //1-th parameter in list
- paramList.push_back ( SMESHGUI_aParameterPtr( type ) );
-
- //2-th parameter in list
- paramList.push_back ( DOUBLE_PARAM (1.0,
- QObject::tr("SMESH_NB_SEGMENTS_SCALE_PARAM"),
- VALUE_SMALL, VALUE_MAX, 0.1, 6 ));
- SMESHGUI_tableParameter* tab = new SMESHGUI_tableParameter( 0.0, QObject::tr( "SMESH_TAB_FUNC" ), true );
- tab->setRowCount( 5 );
- tab->setColCount( 2 );
- //default size of table: 5x2
-
- tab->setColName( 0, "t" );
- tab->setColName( 1, "f(t)" );
- tab->setValidator( 0, 0.0, 1.0, 3 );
- tab->setValidator( 1, 1E-7, 1E+300, 3 );
- tab->setEditRows( true );
-
- //3-th parameter in list
- paramList.push_back ( SMESHGUI_aParameterPtr( tab ) );
-
- //4-th parameter in list
- paramList.push_back ( STR_PARAM ( "", QObject::tr( "SMESH_EXPR_FUNC" ), true ) );
-
- //5-th parameter in list
- paramList.push_back ( BOOL_PARAM ( false, QObject::tr( "SMESH_EXP_MODE" ), true ) );
- }
- else if (hypType.compare("Arithmetic1D") == 0)
- {
- paramList.push_back( DOUBLE_PARAM ( 1.0,
- QObject::tr("SMESH_START_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- paramList.push_back( DOUBLE_PARAM ( 10.0,
- QObject::tr("SMESH_END_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- }
- else if (hypType.compare("MaxElementArea") == 0)
- {
- paramList.push_back( DOUBLE_PARAM (1.0,
- QObject::tr("SMESH_MAX_ELEMENT_AREA_PARAM"),
- VALUE_SMALL_2, VALUE_MAX_2, 1.0, 6));
- }
- else if (hypType.compare("MaxElementVolume") == 0)
- {
- paramList.push_back( DOUBLE_PARAM ( 1.0,
- QObject::tr("SMESH_MAX_ELEMENT_VOLUME_PARAM"),
- VALUE_SMALL_3, VALUE_MAX_3, 1.0, 6));
- }
- else if (hypType.compare("StartEndLength") == 0)
- {
- paramList.push_back( DOUBLE_PARAM ( 1.0,
- QObject::tr("SMESH_START_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- paramList.push_back( DOUBLE_PARAM ( 10.0,
- QObject::tr("SMESH_END_LENGTH_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- }
- else if (hypType.compare("Deflection1D") == 0)
- {
- paramList.push_back( DOUBLE_PARAM ( 1.0,
- QObject::tr("SMESH_DEFLECTION1D_PARAM"),
- VALUE_SMALL, VALUE_MAX, 1, 6));
- }
- else if (hypType.compare("AutomaticLength") == 0)
- {
- SMESHGUI_aParameter * param =
- new StdMeshersGUI_doubleSliderParameter ( QObject::tr("SMESH_FINENESS_PARAM"),
- "0 ", " 1",
- 0.0, 0.0, 1.0, 0.05);
- paramList.push_back( SMESHGUI_aParameterPtr( param ));
- }
-}
-
-//================================================================================
-/*!
- * \brief Fill parameter list with real values the hypothesis has
- * \param theHyp - The hypothesis to retrieve parameter values from
- * \param paramList - The list to fill
- */
-//================================================================================
-
-void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr theHyp,
- list<SMESHGUI_aParameterPtr> & paramList )
-{
- paramList.clear();
-
- if (theHyp->_is_nil()) return;
-
- QString hypType = theHyp->GetName();
- GetParameters( hypType, paramList ); // get default parameters
- if ( paramList.empty() )
- return;
-
- // set current values
- if (hypType.compare("LocalLength") == 0)
- {
- StdMeshers::StdMeshers_LocalLength_var LL =
- StdMeshers::StdMeshers_LocalLength::_narrow(theHyp);
- SetInitValue( paramList.front(), LL->GetLength() );
- }
- else if (hypType.compare("NumberOfSegments") == 0)
- {
- StdMeshers::StdMeshers_NumberOfSegments_var NOS =
- StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
-
- list<SMESHGUI_aParameterPtr>::iterator anIt = paramList.begin();
- SetInitValue( *anIt, (int) NOS->GetNumberOfSegments()); anIt++;
- int DType = (int) NOS->GetDistrType();
- SetInitValue( *anIt, DType ); anIt++;
-
- if( DType==1 )
- SetInitValue( *anIt, NOS->GetScaleFactor());
- anIt++;
-
- if( DType==2 )
- {
- SMESH::double_array* tab_func = NOS->GetTableFunction();
- SetInitValue( *anIt, *tab_func );
- delete tab_func;
- }
- anIt++;
-
- if( DType==3 )
- {
- char* expr_func = NOS->GetExpressionFunction();
- SetInitValue( *anIt, expr_func );
- //delete expr_func;
- }
- anIt++;
-
- if( DType==2 || DType==3 )
- SetInitValue( *anIt, (bool)NOS->IsExponentMode());
- }
- else if (hypType.compare("Arithmetic1D") == 0)
- {
- StdMeshers::StdMeshers_Arithmetic1D_var hyp =
- StdMeshers::StdMeshers_Arithmetic1D::_narrow(theHyp);
- SetInitValue( paramList.front(), hyp->GetLength( true )) ;
- SetInitValue( paramList.back(), hyp->GetLength( false )) ;
- }
- else if (hypType.compare("MaxElementArea") == 0)
- {
- StdMeshers::StdMeshers_MaxElementArea_var MEA =
- StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp);
- SetInitValue( paramList.front(), MEA->GetMaxElementArea() );
- }
- else if (hypType.compare("MaxElementVolume") == 0)
- {
- StdMeshers::StdMeshers_MaxElementVolume_var MEV =
- StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp);
- SetInitValue( paramList.front(), MEV->GetMaxElementVolume() );
- }
- else if (hypType.compare("StartEndLength") == 0)
- {
- StdMeshers::StdMeshers_StartEndLength_var hyp =
- StdMeshers::StdMeshers_StartEndLength::_narrow(theHyp);
- SetInitValue( paramList.front(), hyp->GetLength( true ));
- SetInitValue( paramList.back(), hyp->GetLength( false ));
- }
- else if (hypType.compare("Deflection1D") == 0)
- {
- StdMeshers::StdMeshers_Deflection1D_var hyp =
- StdMeshers::StdMeshers_Deflection1D::_narrow(theHyp);
- SetInitValue( paramList.back(), hyp->GetDeflection()) ;
- }
- else if (hypType.compare("AutomaticLength") == 0)
- {
- StdMeshers::StdMeshers_AutomaticLength_var hyp =
- StdMeshers::StdMeshers_AutomaticLength::_narrow(theHyp);
- SetInitValue( paramList.back(), hyp->GetFineness());
- }
-}
-
-//================================================================================
-/*!
- * \brief Return parameter values as a string
- * \param hyp - not used
- * \param paramList - list of parameter values
- * \param params - output string
- */
-//================================================================================
-
-void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr ,
- const list<SMESHGUI_aParameterPtr>& paramList,
- QString& params)
-{
- params = "";
- list<SMESHGUI_aParameterPtr>::const_iterator paramIt = paramList.begin();
- for ( ; paramIt != paramList.end(); paramIt++) {
- if (params.compare("")) params += " ; ";
-
- SMESHGUI_aParameter::Type t = (*paramIt)->GetType();
- if( t==SMESHGUI_aParameter::DOUBLE )
- {
- double aDoubleValue = 0.;
- (*paramIt)->GetNewDouble(aDoubleValue);
- params += QString::number(aDoubleValue);
- }
- else if( t==SMESHGUI_aParameter::STRING || t==SMESHGUI_aParameter::ENUM )
- {
- QString aStrValue( "" );
- (*paramIt)->GetNewText(aStrValue);
- params += aStrValue.simplifyWhiteSpace();
- }
- else if( t==SMESHGUI_aParameter::TABLE )
- {
- params += "TABLE";
- }
- else
- {
- int aIntValue = 0;
- (*paramIt)->GetNewInt(aIntValue);
- params += QString::number(aIntValue);
- }
- }
-}
-
-//=======================================================================
-//function : SetParameters
-//purpose :
-//=======================================================================
-
-//================================================================================
-/*!
- * \brief Set parameter values from the list into a hypothesis
- * \param theHyp - The hypothesis to modify
- * \param paramList - list of parameter values
- * \retval bool - true if any parameter value changed
- */
-//================================================================================
-
-bool StdMeshersGUI_Parameters::SetParameters(SMESH::SMESH_Hypothesis_ptr theHyp,
- const list<SMESHGUI_aParameterPtr> & paramList )
-{
- if (theHyp->_is_nil() || paramList.empty()) return false;
-
- bool modified = false;
-
- QString hypType = theHyp->GetName();
-
- if (hypType.compare("LocalLength") == 0)
- {
- StdMeshers::StdMeshers_LocalLength_var LL =
- StdMeshers::StdMeshers_LocalLength::_narrow(theHyp);
- double length = LL->GetLength();
- modified = paramList.front()->GetNewDouble( length );
- LL->SetLength(length);
- }
- else if (hypType.compare("NumberOfSegments") == 0)
- {
- StdMeshers::StdMeshers_NumberOfSegments_var NOS =
- StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
-
- list<SMESHGUI_aParameterPtr>::const_iterator anIt = paramList.begin();
- int NbSeg, DType;
- double Scale;
- SMESH::double_array TabF;
- QString exprF;
- int expType;
-
- modified = (*anIt)->GetNewInt( NbSeg ); anIt++;
- modified = (*anIt)->GetNewInt( DType ) || modified; anIt++;
- modified = (*anIt)->GetNewDouble( Scale ) || modified; anIt++;
- SMESHGUI_aParameterPtr p = *anIt;
- ((SMESHGUI_tableParameter*)p.get())->data( TabF ); anIt++; modified = true;
- modified = (*anIt)->GetNewText( exprF ) || modified; anIt++;
- modified = (*anIt)->GetNewInt( expType ) || modified;
-
- NOS->SetNumberOfSegments( NbSeg );
- NOS->SetDistrType( DType );
- if( DType==1 )
- NOS->SetScaleFactor( Scale );
- if( DType==2 )
- NOS->SetTableFunction( TabF );
- if( DType==3 )
- NOS->SetExpressionFunction( CORBA::string_dup( exprF.latin1() ) );
- if( DType==2 || DType==3 )
- NOS->SetExponentMode( (bool)expType );
- }
- else if (hypType.compare("Arithmetic1D") == 0)
- {
- if ( paramList.size() != 2 )
- return false;
- StdMeshers::StdMeshers_Arithmetic1D_var hyp =
- StdMeshers::StdMeshers_Arithmetic1D::_narrow(theHyp);
- double begLength = hyp->GetLength( true ) ;
- double endLength = hyp->GetLength( false ) ;
- modified = paramList.front()->GetNewDouble( begLength );
- modified = paramList.back()->GetNewDouble( endLength ) || modified;
- hyp->SetLength( begLength, true );
- hyp->SetLength( endLength, false );
- }
- else if (hypType.compare("MaxElementArea") == 0)
- {
- StdMeshers::StdMeshers_MaxElementArea_var MEA =
- StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp);
- double MaxArea = MEA->GetMaxElementArea();
- modified = paramList.front()->GetNewDouble( MaxArea );
- MEA->SetMaxElementArea(MaxArea);
- }
- else if (hypType.compare("MaxElementVolume") == 0)
- {
- StdMeshers::StdMeshers_MaxElementVolume_var MEV =
- StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp);
- double MaxVolume = MEV->GetMaxElementVolume() ;
- modified = paramList.front()->GetNewDouble( MaxVolume );
- MEV->SetMaxElementVolume(MaxVolume);
- }
- else if (hypType.compare("StartEndLength") == 0)
- {
- if ( paramList.size() != 2 )
- return false;
- StdMeshers::StdMeshers_StartEndLength_var hyp =
- StdMeshers::StdMeshers_StartEndLength::_narrow(theHyp);
- double begLength = hyp->GetLength( true ) ;
- double endLength = hyp->GetLength( false ) ;
- modified = paramList.front()->GetNewDouble( begLength );
- modified = paramList.back()->GetNewDouble( endLength ) || modified;
- hyp->SetLength( begLength, true );
- hyp->SetLength( endLength, false );
- }
- else if (hypType.compare("Deflection1D") == 0)
- {
- StdMeshers::StdMeshers_Deflection1D_var hyp =
- StdMeshers::StdMeshers_Deflection1D::_narrow(theHyp);
- double value = hyp->GetDeflection() ;
- modified = paramList.front()->GetNewDouble( value );
- hyp->SetDeflection( value );
- }
- else if (hypType.compare("AutomaticLength") == 0)
- {
- StdMeshers::StdMeshers_AutomaticLength_var hyp =
- StdMeshers::StdMeshers_AutomaticLength::_narrow(theHyp);
- double value = hyp->GetFineness() ;
- modified = paramList.front()->GetNewDouble( value );
- hyp->SetFineness( value );
- }
- return modified ;
-}
-
-//================================================================================
-/*!
- * \brief Widget: slider with left and right labels
- */
-//================================================================================
-
-class StdMeshersGUI_SliderWith2Lables: public QHBox
-{
-public:
- StdMeshersGUI_SliderWith2Lables( const QString& leftLabel,
- const QString& rightLabel,
- QWidget * parent =0,
- const char * name=0 );
- QSlider * getSlider() const { return _slider; }
-private:
- QSlider * _slider;
-};
-
-StdMeshersGUI_SliderWith2Lables::StdMeshersGUI_SliderWith2Lables( const QString& leftLabel,
- const QString& rightLabel,
- QWidget * parent,
- const char * name )
- :QHBox(parent,name)
-{
- if ( !leftLabel.isEmpty() )
- (new QLabel( this ))->setText( leftLabel );
-
- _slider = new QSlider( Horizontal, this );
-
- if ( !rightLabel.isEmpty() )
- (new QLabel( this ))->setText( rightLabel );
-}
-
-//================================================================================
-/*!
- * \brief Constructor
- * \param label - main label
- * \param leftLabel - label to the left of slider
- * \param rightLabel - label to the right of slider
- * \param initValue - initial slider value
- * \param bottom - least slider value
- * \param top - maximal slider value
- * \param precision - slider value precision
- */
-//================================================================================
-
-StdMeshersGUI_doubleSliderParameter::
-StdMeshersGUI_doubleSliderParameter (const QString& label,
- const QString& leftLabel,
- const QString& rightLabel,
- const double initValue,
- const double bottom,
- const double top ,
- const double precision)
- :SMESHGUI_doubleParameter(initValue,label,bottom,top,precision),
- _leftLabel(leftLabel), _rightLabel(rightLabel)
-{
-}
-
-QWidget* StdMeshersGUI_doubleSliderParameter::CreateWidget( QWidget* parent ) const
-{
- return new StdMeshersGUI_SliderWith2Lables( _leftLabel, _rightLabel, parent );
-}
-
-void StdMeshersGUI_doubleSliderParameter::InitializeWidget( QWidget* aWidget) const
-{
- StdMeshersGUI_SliderWith2Lables * paramWidget =
- dynamic_cast<StdMeshersGUI_SliderWith2Lables*> (aWidget);
- if ( paramWidget && paramWidget->getSlider() )
- {
- QSlider * slider = paramWidget->getSlider();
- slider->setRange( 0, toInt( _top ));
- slider->setValue( toInt( _initValue ));
- }
-}
-
-void StdMeshersGUI_doubleSliderParameter::TakeValue( QWidget* aWidget)
-{
- StdMeshersGUI_SliderWith2Lables * paramWidget =
- dynamic_cast<StdMeshersGUI_SliderWith2Lables*> (aWidget);
- if ( paramWidget && paramWidget->getSlider() )
- {
- int val = paramWidget->getSlider()->value();
- _newValue = Bottom() + val * Step();
- }
-}
-int StdMeshersGUI_doubleSliderParameter::toInt( double val ) const
-{
- return (int) ceil(( val - _bottom ) / _step );
-}
+++ /dev/null
-// SMESH StdMeshersGUI : GUI for standard meshers
-//
-// Copyright (C) 2003 CEA
-//
-// 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.
-//
-// 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.org
-//
-//
-//
-// File : StdMeshersGUI_Parameters.h
-// Module : SMESH
-// $Header$
-
-#ifndef STDMESHERSGUI_PARAMETERS_H
-#define STDMESHERSGUI_PARAMETERS_H
-
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-
-#include "SMESHGUI_aParameter.h"
-
-#include <list>
-#include <vector>
-
-class StdMeshersGUI_Parameters
-{
- public:
- static bool HasParameters (const QString& hypType);
-
- static void GetParameters (const QString& hypType,
- std::list<SMESHGUI_aParameterPtr> & params );
-
- static void GetParameters (SMESH::SMESH_Hypothesis_ptr hyp,
- std::list<SMESHGUI_aParameterPtr> & params );
- static void GetParameters (SMESH::SMESH_Hypothesis_ptr hyp,
- const std::list<SMESHGUI_aParameterPtr> & paramList,
- QString& params);
-
- static bool SetParameters(SMESH::SMESH_Hypothesis_ptr hyp,
- const std::list<SMESHGUI_aParameterPtr> & params );
-
- static void SetInitValue(SMESHGUI_aParameterPtr param,
- int initValue);
- static void SetInitValue(SMESHGUI_aParameterPtr param,
- double initValue);
- static void SetInitValue(SMESHGUI_aParameterPtr param,
- const char* initValue);
- static void SetInitValue(SMESHGUI_aParameterPtr param,
- SMESH::double_array& initValue);
-};
-
-/*!
- * \brief This class provides double parameter with slider control
- */
-class StdMeshersGUI_doubleSliderParameter: public SMESHGUI_doubleParameter
-{
-public:
- StdMeshersGUI_doubleSliderParameter(const QString& label = QString::null,
- const QString& leftLabel = QString::null,
- const QString& rightLabel = QString::null,
- const double initValue = 0.0,
- const double bottom = 0,
- const double top = 1,
- const double precision = 0.1);
- virtual QWidget* CreateWidget( QWidget* ) const;
- virtual void InitializeWidget( QWidget* ) const;
- virtual void TakeValue( QWidget* );
- int toInt( double val ) const;
-private:
- QString _leftLabel, _rightLabel;
-};
-
-#endif
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include <qpixmap.h>
+#include <qhbox.h>
+#include <qslider.h>
+#include <qlabel.h>
const double VALUE_MAX = 1.0e+15, // COORD_MAX
//here this method must be empty because buildStdParam sets values itself
}
-void StdMeshersGUI_StdHypothesisCreator::storeParams() const
+QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
{
ListOfStdParams params;
bool res = getStdParamFromDlg( params );
params.remove( params.begin() );
}
+ QString valueStr = stdParamValues( params );
+
if( res && !params.isEmpty() )
{
if( hypType()=="LocalLength" )
h->SetDeflection( params[0].myValue.toDouble() );
}
+ else if( hypType()=="AutomaticLength" )
+ {
+ StdMeshers::StdMeshers_AutomaticLength_var h =
+ StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
+
+ h->SetFineness( params[0].myValue.toDouble() );
+ }
}
+ return valueStr;
}
bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
p.append( item );
}
+ SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
+
if( hypType()=="LocalLength" )
{
StdMeshers::StdMeshers_LocalLength_var h =
- StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
+ StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
- item.myValue = isCreation() ? 1.0 : h->GetLength();
+ item.myValue = h->GetLength();
p.append( item );
}
else if( hypType()=="Arithmetic1D" )
{
StdMeshers::StdMeshers_Arithmetic1D_var h =
- StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
+ StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
item.myName = tr( "SMESH_START_LENGTH_PARAM" );
- item.myValue = isCreation() ? 1.0 : h->GetLength( true );
+ item.myValue = h->GetLength( true );
p.append( item );
item.myName = tr( "SMESH_END_LENGTH_PARAM" );
- item.myValue = isCreation() ? 10.0 : h->GetLength( false );
+ item.myValue = h->GetLength( false );
p.append( item );
}
else if( hypType()=="MaxElementArea" )
{
StdMeshers::StdMeshers_MaxElementArea_var h =
- StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
+ StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
- item.myValue = isCreation() ? 1.0 : h->GetMaxElementArea();
+ item.myValue = h->GetMaxElementArea();
p.append( item );
}
else if( hypType()=="MaxElementVolume" )
{
StdMeshers::StdMeshers_MaxElementVolume_var h =
- StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
+ StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
- item.myValue = isCreation() ? 1.0 : h->GetMaxElementVolume();
+ item.myValue = h->GetMaxElementVolume();
p.append( item );
}
else if( hypType()=="StartEndLength" )
{
StdMeshers::StdMeshers_StartEndLength_var h =
- StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
+ StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
item.myName = tr( "SMESH_START_LENGTH_PARAM" );
- item.myValue = isCreation() ? 1.0 : h->GetLength( true );
+ item.myValue = h->GetLength( true );
p.append( item );
item.myName = tr( "SMESH_END_LENGTH_PARAM" );
- item.myValue = isCreation() ? 10.0 : h->GetLength( false );
+ item.myValue = h->GetLength( false );
p.append( item );
}
else if( hypType()=="Deflection1D" )
{
StdMeshers::StdMeshers_Deflection1D_var h =
- StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
+ StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
- item.myValue = isCreation() ? 1.0 : h->GetDeflection();
+ item.myValue = h->GetDeflection();
+ p.append( item );
+ }
+ else if( hypType()=="AutomaticLength" )
+ {
+ StdMeshers::StdMeshers_AutomaticLength_var h =
+ StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
+
+ item.myName = tr( "SMESH_FINENESS_PARAM" );
+ item.myValue = h->GetFineness();
p.append( item );
}
else
types.insert( "StartEndLength", "START_END_LENGTH" );
types.insert( "Deflection1D", "DEFLECTION1D" );
types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
+ types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
}
QString res;
return res;
}
+
+//================================================================================
+/*!
+ * \brief Widget: slider with left and right labels
+ */
+//================================================================================
+
+class TDoubleSliderWith2Lables: public QHBox
+{
+public:
+ TDoubleSliderWith2Lables( const QString& leftLabel, const QString& rightLabel,
+ const double initValue, const double bottom,
+ const double top , const double precision,
+ QWidget * parent=0 , const char * name=0 )
+ :QHBox(parent,name), _bottom(bottom), _precision(precision)
+ {
+ if ( !leftLabel.isEmpty() ) (new QLabel( this ))->setText( leftLabel );
+ _slider = new QSlider( Horizontal, this );
+ _slider->setRange( 0, toInt( top ));
+ _slider->setValue( toInt( initValue ));
+ if ( !rightLabel.isEmpty() ) (new QLabel( this ))->setText( rightLabel );
+ }
+ double value() const { return _bottom + _slider->value() * _precision; }
+ QSlider * getSlider() const { return _slider; }
+ int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
+private:
+ double _bottom, _precision;
+ QSlider * _slider;
+};
+
+//=======================================================================
+//function : getCustomWidget
+//purpose :
+//=======================================================================
+
+QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
+ QWidget* parent) const
+{
+ if ( hypType()=="AutomaticLength" && param.myValue.type() == QVariant::Double )
+ return new TDoubleSliderWith2Lables( "0 ", " 1", param.myValue.toDouble(),
+ 0, 1, 0.01, parent );
+
+ return 0;
+}
+
+//=======================================================================
+//function : getParamFromCustomWidget
+//purpose :
+//=======================================================================
+
+bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
+ QWidget* widget) const
+{
+ if ( hypType()=="AutomaticLength" ) {
+ TDoubleSliderWith2Lables* w = dynamic_cast<TDoubleSliderWith2Lables*>( widget );
+ if ( w ) {
+ param.myValue = w->value();
+ return true;
+ }
+ }
+ return false;
+}
protected:
virtual QFrame* buildFrame ();
virtual void retrieveParams() const;
- virtual void storeParams () const;
+ virtual QString storeParams () const;
virtual bool stdParams ( ListOfStdParams& ) const;
virtual void attuneStdWidget( QWidget*, const int ) const;
virtual QString caption() const;
virtual QPixmap icon() const;
virtual QString type() const;
+ virtual QWidget* getCustomWidget( const StdParam&, QWidget* ) const;
+ virtual bool getParamFromCustomWidget( StdParam& , QWidget* ) const;
private:
QString hypTypeName( const QString& ) const;
+++ /dev/null
-# This is a Qt message file in .po format. Each msgid starts with
-# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
-# would be translated to "Pub", not "Foo::Pub".
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n"
-"PO-Revision-Date: YYYY-MM-DD\n"
-"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-
-
-#Select Icon
-msgid "ICON_SELECT"
-msgstr "select1.png"
-
-
-#-----------------------------------------------------------
-# Hypothesis
-#-----------------------------------------------------------
-
-#Hypo Local Length
-msgid "ICON_DLG_LOCAL_LENGTH"
-msgstr "mesh_hypo_length.png"
-
-#Hypo Nb Segments
-msgid "ICON_DLG_NB_SEGMENTS"
-msgstr "mesh_hypo_segment.png"
-
-#Hypo Max Area
-msgid "ICON_DLG_MAX_ELEMENT_AREA"
-msgstr "mesh_hypo_area.png"
-
-#Hypo Max Volume
-msgid "ICON_DLG_MAX_ELEMENT_VOLUME"
-msgstr "mesh_hypo_volume.png"
-
-#Hypo Start End Length
-msgid "ICON_DLG_START_END_LENGTH"
-msgstr "mesh_hypo_length.png"
-
-#Hypo deflection 1D
-msgid "ICON_DLG_DEFLECTION1D"
-msgstr "mesh_hypo_length.png"
-
-#Hypo Geometric 1D
-msgid "ICON_DLG_GEOMETRIC_1D"
-msgstr "mesh_hypo_length.png"
-
-#Hypo Arithmetic 1D
-msgid "ICON_DLG_ARITHMETIC_1D"
-msgstr "mesh_hypo_length.png"
-
-
-#-----------------------------------------------------------
-# ObjectBrowser
-#-----------------------------------------------------------
-
-#mesh_tree_algo_regular
-msgid "ICON_SMESH_TREE_ALGO_Regular_1D"
-msgstr "mesh_tree_algo_regular.png"
-
-#mesh_tree_algo_hexa
-msgid "ICON_SMESH_TREE_ALGO_Hexa_3D"
-msgstr "mesh_tree_algo_hexa.png"
-
-#mesh_tree_algo_mefisto
-msgid "ICON_SMESH_TREE_ALGO_MEFISTO_2D"
-msgstr "mesh_tree_algo_mefisto.png"
-
-#mesh_tree_algo_quad
-msgid "ICON_SMESH_TREE_ALGO_Quadrangle_2D"
-msgstr "mesh_tree_algo_quad.png"
-
-#mesh_tree_hypo_area
-msgid "ICON_SMESH_TREE_HYPO_MaxElementArea"
-msgstr "mesh_tree_hypo_area.png"
-
-#mesh_tree_hypo_length
-msgid "ICON_SMESH_TREE_HYPO_LocalLength"
-msgstr "mesh_tree_hypo_length.png"
-
-#mesh_tree_hypo_segment
-msgid "ICON_SMESH_TREE_HYPO_NumberOfSegments"
-msgstr "mesh_tree_hypo_segment.png"
-
-#mesh_tree_hypo_volume
-msgid "ICON_SMESH_TREE_HYPO_MaxElementVolume"
-msgstr "mesh_tree_hypo_volume.png"
-
-#mesh_tree_hypo_length
-msgid "ICON_SMESH_TREE_HYPO_LengthFromEdges"
-msgstr "mesh_tree_hypo_length.png"
-
-#mesh_tree_hypo_nonconform
-msgid "ICON_SMESH_TREE_HYPO_NotConformAllowed"
-msgstr "mesh_tree_hypo_length.png"
-
-#mesh_tree_hypo_start_end_length
-msgid "ICON_SMESH_TREE_HYPO_StartEndLength"
-msgstr "mesh_tree_hypo_length.png"
-
-#mesh_tree_hypo_deflection1d
-msgid "ICON_SMESH_TREE_HYPO_Deflection1D"
-msgstr "mesh_tree_hypo_length.png"
-
-#mesh_tree_hypo_Arithmetic1d
-msgid "ICON_SMESH_TREE_HYPO_Arithmetic1D"
-msgstr "mesh_tree_hypo_length.png"
-
-#mesh_tree_hypo_propagation
-msgid "ICON_SMESH_TREE_HYPO_Propagation"
-msgstr "mesh_tree_hypo_length.png"
msgid "SMESH_NB_SEGMENTS_SCALE_PARAM"
msgstr "Scale Factor"
+msgid "SMESH_DENSITY_FUNC"
+msgstr "Density function"
+
+msgid "SMESH_DISTR"
+msgstr "Distribution"
+
msgid "SMESH_TAB_FUNC"
msgstr "Table function"
msgid "SMESH_CUT_NEG_MODE"
msgstr "Cut negative"
+msgid "SMESH_NO_CONV"
+msgstr "No conversion"
+
msgid "SMESH_INSERT_ROW"
msgstr "Insert row"