From d9ce7a48c18bb6cddc877a8a02ff8e0efda13748 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 21 Jan 2005 14:03:54 +0000 Subject: [PATCH 01/16] Comment annoing trace --- src/SMESH/SMESH_subMesh.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index 238bd22d9..9e4bc28b1 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -1550,7 +1550,7 @@ static void removeSubMesh( SMESHDS_Mesh * meshDS, const TopoDS_Shape& subShape) void SMESH_subMesh::RemoveSubMeshElementsAndNodes() { - SCRUTE(_subShape.ShapeType()); + //SCRUTE(_subShape.ShapeType()); removeSubMesh( _meshDS, _subShape ); -- 2.30.2 From dcab7b2d24224d2d956107e0b8e5a8d8ecdcbea1 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 21 Jan 2005 14:11:17 +0000 Subject: [PATCH 02/16] PAL7722. Add IsReversedInChain(). In BuildPropagationChain(), chains of edges with propagated hypothesis are filled taking into account edges orientation --- src/SMESH/SMESH_Mesh.cxx | 32 +++++++++++++++++++++++++++----- src/SMESH/SMESH_Mesh.hxx | 5 +++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index a778699e1..ef500ac8e 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -964,6 +964,26 @@ bool SMESH_Mesh::IsPropagatedHypothesis (const TopoDS_Shape& theEdge, return false; } +//============================================================================= +/*! + * IsReversedInChain + */ +//============================================================================= + +bool SMESH_Mesh::IsReversedInChain (const TopoDS_Shape& theEdge, + const TopoDS_Shape& theMainEdge) +{ + if ( !theMainEdge.IsNull() && !theEdge.IsNull() && + _mapPropagationChains.Contains( theMainEdge )) + { + const TopTools_IndexedMapOfShape& aChain = + _mapPropagationChains.FindFromKey( theMainEdge ); + int index = aChain.FindIndex( theEdge ); + if ( index ) + return aChain(index).Orientation() == TopAbs_REVERSED; + } + return false; +} //============================================================================= /*! @@ -1075,7 +1095,7 @@ bool SMESH_Mesh::BuildPropagationChain (const TopoDS_Shape& theMainEdge) // List of edges, added to chain on the previous cycle pass TopTools_ListOfShape listPrevEdges; - listPrevEdges.Append(theMainEdge); + listPrevEdges.Append(theMainEdge.Oriented( TopAbs_FORWARD )); // 5____4____3____4____5____6 // | | | | | | @@ -1122,9 +1142,6 @@ bool SMESH_Mesh::BuildPropagationChain (const TopoDS_Shape& theMainEdge) if (!_mapAncestors.Contains(anEdges(nb))) { MESSAGE("WIRE EXPLORER HAVE GIVEN AN INVALID EDGE !!!"); break; - } else { - int ind = _mapAncestors.FindIndex(anEdges(nb)); - anEdges(nb) = _mapAncestors.FindKey(ind); } if (anEdges(nb).IsSame(anE)) found = nb; } @@ -1145,7 +1162,12 @@ bool SMESH_Mesh::BuildPropagationChain (const TopoDS_Shape& theMainEdge) aChain.Clear(); return false; } else { - // Add found edge to the chain + // Add found edge to the chain oriented so that to + // have it in aChain co-directed with theMainEdge + TopAbs_Orientation ori = anE.Orientation(); + if ( anEdges(opp).Orientation() == anEdges(found).Orientation() ) + ori = TopAbs::Reverse( ori ); + anOppE.Orientation( ori ); aChain.Add(anOppE); listCurEdges.Append(anOppE); } diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 0ddd8398b..a28a67ea5 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -196,6 +196,11 @@ public: // Returns through the edge, from // which the 1D hypothesis is propagated on + bool IsReversedInChain (const TopoDS_Shape& theEdge, + const TopoDS_Shape& theMainEdge); + // Returns true if theEdge should be reversed to be + // co-directed with theMainEdge + bool RebuildPropagationChains(); bool RemovePropagationChain (const TopoDS_Shape& theMainEdge); bool BuildPropagationChain (const TopoDS_Shape& theMainEdge); -- 2.30.2 From d8e7d0d7d955c625b4a5a89d22b141375db22c96 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 21 Jan 2005 14:15:45 +0000 Subject: [PATCH 03/16] PAL7722. Take into account edge orientation when Compute() uses a propagated hypothesis --- src/StdMeshers/StdMeshers_Regular_1D.cxx | 151 +++++++++++++---------- src/StdMeshers/StdMeshers_Regular_1D.hxx | 10 +- 2 files changed, 91 insertions(+), 70 deletions(-) diff --git a/src/StdMeshers/StdMeshers_Regular_1D.cxx b/src/StdMeshers/StdMeshers_Regular_1D.cxx index 86831c6b5..bca9e634c 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.cxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.cxx @@ -178,13 +178,55 @@ bool StdMeshers_Regular_1D::CheckHypothesis return ( _hypType != NONE ); } +//======================================================================= +//function : compensateError +//purpose : adjust theParams so that the last segment length == an +//======================================================================= + +static void compensateError(double a1, double an, + double U1, double Un, + double length, + GeomAdaptor_Curve& C3d, + list & theParams) +{ + int i, nPar = theParams.size(); + if ( a1 + an < length && nPar > 1 ) + { + list::reverse_iterator itU = theParams.rbegin(); + double Ul = *itU++; + // dist from the last point to the edge end , it should be equal + double Ln = GCPnts_AbscissaPoint::Length( C3d, Ul, Un ); + double dLn = an - Ln; // error of + if ( Abs( dLn ) <= Precision::Confusion() ) + return; + double dU = Ul - *itU; // parametric length of the last but one segment + double dUn = dLn * ( Un - U1 ) / length; // modificator of the last parameter + if ( dUn < 0.5 * dU ) { // last segment is a bit shorter than dU + dUn = -dUn; // move the last parameter to the edge beginning + } + else { // last segment is much shorter than dU -> remove the last param and + theParams.pop_back(); // move the rest points toward the edge end + Ln = GCPnts_AbscissaPoint::Length( C3d, theParams.back(), Un ); + dUn = ( an - Ln ) * ( Un - U1 ) / length; + if ( dUn < 0.5 * dU ) + dUn = -dUn; + } + double q = dUn / ( nPar - 1 ); + for ( itU = theParams.rbegin(), i = 1; i < nPar; itU++, i++ ) { + (*itU) += dUn; + dUn -= q; + } + } +} + //============================================================================= /*! * */ //============================================================================= bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge, - list & theParams) const + list & theParams, + const bool theReverse) const { theParams.clear(); @@ -193,7 +235,6 @@ bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge GeomAdaptor_Curve C3d(Curve); double length = EdgeLength(theEdge); - //SCRUTE(length); switch( _hypType ) { @@ -213,10 +254,11 @@ bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge double epsilon = 0.001; if (fabs(_value[ SCALE_FACTOR_IND ] - 1.0) > epsilon) { - double alpha = - pow( _value[ SCALE_FACTOR_IND ], 1.0 / (_value[ NB_SEGMENTS_IND ] - 1)); - double factor = - length / (1 - pow( alpha,_value[ NB_SEGMENTS_IND ])); + double scale = _value[ SCALE_FACTOR_IND ]; + if ( theReverse ) + scale = 1. / scale; + double alpha = pow( scale , 1.0 / (_value[ NB_SEGMENTS_IND ] - 1)); + double factor = (l - f) / (1 - pow( alpha,_value[ NB_SEGMENTS_IND ])); int i, NbPoints = 1 + (int) _value[ NB_SEGMENTS_IND ]; for ( i = 2; i < NbPoints; i++ ) @@ -249,8 +291,8 @@ bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge // geometric progression: SUM(n) = ( a1 - an * q ) / ( 1 - q ) = length - double a1 = _value[ BEG_LENGTH_IND ]; - double an = _value[ END_LENGTH_IND ]; + double a1 = theReverse ? _value[ END_LENGTH_IND ] : _value[ BEG_LENGTH_IND ]; + double an = theReverse ? _value[ BEG_LENGTH_IND ] : _value[ END_LENGTH_IND ]; double q = ( length - a1 ) / ( length - an ); double U1 = Min ( f, l ); @@ -269,84 +311,56 @@ bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge break; eltSize *= q; } - if ( a1 + an < length ) { - // compensate error - double Ln = GCPnts_AbscissaPoint::Length( C3d, theParams.back(), Un ); - double dLn = an - Ln; - if ( dLn < 0.5 * an ) - dLn = -dLn; - else { - theParams.pop_back(); - Ln = GCPnts_AbscissaPoint::Length( C3d, theParams.back(), Un ); - dLn = an - Ln; - if ( dLn < 0.5 * an ) - dLn = -dLn; - } - double dUn = dLn * ( Un - U1 ) / length; -// SCRUTE( Ln ); -// SCRUTE( dLn ); -// SCRUTE( dUn ); - list::reverse_iterator itU = theParams.rbegin(); - int i, n = theParams.size(); - for ( i = 1 ; i < n; itU++, i++ ) { - (*itU) += dUn; - dUn /= q; - } - } - - return true; - } - - case DEFLECTION: { - - GCPnts_UniformDeflection Discret(C3d, _value[ DEFLECTION_IND ], true); - if ( !Discret.IsDone() ) - return false; - - int NbPoints = Discret.NbPoints(); - for ( int i = 2; i < NbPoints; i++ ) - { - double param = Discret.Parameter(i); - theParams.push_back( param ); - } + compensateError( a1, an, U1, Un, length, C3d, theParams ); return true; - } case ARITHMETIC_1D: { - // arithmetic progression: SUM(n) = ( an - a1 + q ) * ( a1 + an ) / ( 2 * q ) = length - double a1 = _value[ BEG_LENGTH_IND ]; - double an = _value[ END_LENGTH_IND ]; + // arithmetic progression: SUM(n) = ( an - a1 + q ) * ( a1 + an ) / ( 2 * q ) = length + + double a1 = theReverse ? _value[ END_LENGTH_IND ] : _value[ BEG_LENGTH_IND ]; + double an = theReverse ? _value[ BEG_LENGTH_IND ] : _value[ END_LENGTH_IND ]; - double nd = (2 * length) / (an + a1) - 1; - int n = int(nd); - if(n != nd) - n++; + double q = ( an - a1 ) / ( 2 *length/( a1 + an ) - 1 ); + int n = int( 1 + ( an - a1 ) / q ); - double q = ((2 * length) / (n + 1) - 2 * a1) / n; double U1 = Min ( f, l ); double Un = Max ( f, l ); double param = U1; double eltSize = a1; - double L=0; - while ( 1 ) { - L+=eltSize; + while ( eltSize > 0. && n-- > 0) { // computes a point on a curve at the distance // from the point of parameter . GCPnts_AbscissaPoint Discret( C3d, eltSize, param ); if ( !Discret.IsDone() ) break; param = Discret.Parameter(); - if ( fabs(param - Un) > Precision::Confusion() && param < Un) { + if ( param < Un ) theParams.push_back( param ); - } else break; - eltSize += q; + eltSize += q; // eltSize may become negative here } + compensateError( a1, an, U1, Un, length, C3d, theParams ); + + return true; + } + + case DEFLECTION: { + + GCPnts_UniformDeflection Discret(C3d, _value[ DEFLECTION_IND ], true); + if ( !Discret.IsDone() ) + return false; + int NbPoints = Discret.NbPoints(); + for ( int i = 2; i < NbPoints; i++ ) + { + double param = Discret.Parameter(i); + theParams.push_back( param ); + } return true; + } default:; @@ -401,8 +415,11 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh if (!Curve.IsNull()) { list< double > params; + bool reversed = false; + if ( !_mainEdge.IsNull() ) + reversed = aMesh.IsReversedInChain( EE, _mainEdge ); try { - if ( ! computeInternalParameters( E, params )) + if ( ! computeInternalParameters( E, params, reversed )) return false; } catch ( Standard_Failure ) { @@ -480,15 +497,15 @@ const list & StdMeshers_Regular_1D::GetUsedHypothes _usedHypList.clear(); _usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy int nbHyp = _usedHypList.size(); + _mainEdge.Nullify(); if (nbHyp == 0) { // Check, if propagated from some other edge - TopoDS_Shape aMainEdge; if (aShape.ShapeType() == TopAbs_EDGE && - aMesh.IsPropagatedHypothesis(aShape, aMainEdge)) + aMesh.IsPropagatedHypothesis(aShape, _mainEdge)) { // Propagation of 1D hypothesis from on this edge - _usedHypList = GetAppliedHypothesis(aMesh, aMainEdge); // copy + _usedHypList = GetAppliedHypothesis(aMesh, _mainEdge); // copy nbHyp = _usedHypList.size(); } } diff --git a/src/StdMeshers/StdMeshers_Regular_1D.hxx b/src/StdMeshers/StdMeshers_Regular_1D.hxx index 548d59802..96128d984 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.hxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.hxx @@ -59,7 +59,8 @@ public: protected: bool computeInternalParameters (const TopoDS_Edge& theEdge, - std::list< double > & theParameters ) const; + std::list< double > & theParameters, + const bool theReverse) const; enum HypothesisType { LOCAL_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, NONE }; @@ -70,11 +71,14 @@ protected: END_LENGTH_IND = 1, DEFLECTION_IND = 0 }; - + HypothesisType _hypType; double _value[2]; - + + // a source of propagated hypothesis, is set by CheckHypothesis() + // always called before Compute() + TopoDS_Shape _mainEdge; }; #endif -- 2.30.2 From 298f5a9bb302fffccb6af7ac6e624dfd28d6e08a Mon Sep 17 00:00:00 2001 From: mzn Date: Mon, 24 Jan 2005 06:46:13 +0000 Subject: [PATCH 04/16] Bug PAL7222( DEVELOPMENT : Info on mesh and export MED File ). Comment for auto_groups parameter of ExportToMED(...) method added. --- idl/SMESH_Mesh.idl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index 094b66583..f34baa99b 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -325,6 +325,10 @@ module SMESH /*! * Export Mesh to MED Formats + * @params + * - auto_groups : boolean parameter for creating/not creating + * the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; + * the typical use is auto_groups=false. */ void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion ) raises (SALOME::SALOME_Exception); -- 2.30.2 From 776e25bc46048a970a8492f432a4e8ce01dada79 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 24 Jan 2005 13:37:56 +0000 Subject: [PATCH 05/16] [Bug PAL7784] REGR: wrong Export-Import Mesh in med --- src/DriverMED/DriverMED_Family.cxx | 8 ++-- src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx | 43 +++++++++++++--------- src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx | 18 ++++----- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/DriverMED/DriverMED_Family.cxx b/src/DriverMED/DriverMED_Family.cxx index 778c282a5..34ff2c20b 100644 --- a/src/DriverMED/DriverMED_Family.cxx +++ b/src/DriverMED/DriverMED_Family.cxx @@ -193,10 +193,10 @@ list DriverMED_Family::MakeFamilies aFamilies.push_back(aFreeVolumesFam); } - DriverMED_FamilyPtr aNullFam (new DriverMED_Family); - aNullFam->SetId(0); - aNullFam->myType = SMDSAbs_All; - aFamilies.push_back(aNullFam); + //DriverMED_FamilyPtr aNullFam (new DriverMED_Family); + //aNullFam->SetId(0); + //aNullFam->myType = SMDSAbs_All; + //aFamilies.push_back(aNullFam); return aFamilies; } diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index 25e517cf4..fe5100d4f 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -38,6 +38,12 @@ #include +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + #define _EDF_NODE_IDS_ using namespace MED; @@ -136,7 +142,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() Status aResult = DRS_FAIL; try{ myFamilies.clear(); - MESSAGE("Perform - myFile : "<GetName()); + if(MYDEBUG) MESSAGE("Perform - aMeshName : "<GetName()); if(aMeshName != aMeshInfo->GetName()) continue; aResult = DRS_OK; //TInt aMeshDim = aMeshInfo->GetDim(); // Reading MED families to the temporary structure //------------------------------------------------ - TInt aNbFams = aMed->GetNbFamilies(aMeshInfo); - MESSAGE("Read " << aNbFams << " families"); + TErr anErr; + TInt aNbFams = aMed->GetNbFamilies(aMeshInfo); + if(MYDEBUG) MESSAGE("Read " << aNbFams << " families"); for (TInt iFam = 0; iFam < aNbFams; iFam++) { - PFamilyInfo aFamilyInfo = aMed->GetPFamilyInfo(aMeshInfo, iFam+1); - TInt aFamId = aFamilyInfo->GetId(); - MESSAGE("Family " << aFamId << " :"); - + PFamilyInfo aFamilyInfo = aMed->GetPFamilyInfo(aMeshInfo,iFam+1,&anErr); + if(anErr >= 0){ + TInt aFamId = aFamilyInfo->GetId(); + if(MYDEBUG) MESSAGE("Family " << aFamId << " :"); + DriverMED_FamilyPtr aFamily (new DriverMED_Family); - + TInt aNbGrp = aFamilyInfo->GetNbGroup(); - MESSAGE("belong to " << aNbGrp << " groups"); + if(MYDEBUG) MESSAGE("belong to " << aNbGrp << " groups"); for (TInt iGr = 0; iGr < aNbGrp; iGr++) { string aGroupName = aFamilyInfo->GetGroupName(iGr); - MESSAGE(aGroupName); + if(MYDEBUG) MESSAGE(aGroupName); aFamily->AddGroupName(aGroupName); } myFamilies[aFamId] = aFamily; + } } // Reading MED nodes to the corresponding SMDS structure @@ -221,7 +230,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() EBooleen anIsNodeNum = aNodeInfo->IsElemNum(); TInt aNbElems = aNodeInfo->GetNbElem(); - MESSAGE("Perform - aNodeInfo->GetNbElem() = "<GetNbElem() = "< DriverMED_R_SMESHDS_Mesh::GetGroupNames() void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup) { string aGroupName (theGroup->GetStoreName()); - MESSAGE("Get Group " << aGroupName); + if(MYDEBUG) MESSAGE("Get Group " << aGroupName); map::iterator aFamsIter = myFamilies.begin(); for (; aFamsIter != myFamilies.end(); aFamsIter++) diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index cf7d9a819..74490377a 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -35,7 +35,6 @@ #include "SMDS_MeshNode.hxx" #include "utilities.h" -#include "MED_Factory.hxx" #include "MED_Utilities.hxx" #define _EDF_NODE_IDS_ @@ -53,7 +52,8 @@ DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh(): myDoGroupOfVolumes (false) {} -void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, MED::EVersion theId) +void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, + MED::EVersion theId) { myMed = CrWrapper(theFileName,theId); Driver_SMESHDS_Mesh::SetFile(theFileName); @@ -384,7 +384,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() SMDS_MED_ENTITY = eARETE; #endif SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); - TInt aNbConnectivity = MED::GetNbConn(SMDS_MED_ENTITY,eSEG2,aMeshDimension); + TInt aNbConnectivity = MED::GetNbConnectivities(eSEG2); MED::TIntVector anElemNums(aNbElems); MED::TIntVector aFamilyNums(aNbElems); MED::TIntVector aConnectivity(aNbElems*aNbConnectivity); @@ -424,7 +424,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() #ifdef _ELEMENTS_BY_DIM_ SMDS_MED_ENTITY = eFACE; #endif - TInt aNbTriaConn = MED::GetNbConn(SMDS_MED_ENTITY,eTRIA3,aMeshDimension); + TInt aNbTriaConn = MED::GetNbConnectivities(eTRIA3); MED::TIntVector anTriaElemNums; anTriaElemNums.reserve(aNbElems); MED::TIntVector aTriaFamilyNums; @@ -432,7 +432,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector aTriaConn; aTriaConn.reserve(aNbElems*aNbTriaConn); - TInt aNbQuadConn = MED::GetNbConn(SMDS_MED_ENTITY,eQUAD4,aMeshDimension); + TInt aNbQuadConn = MED::GetNbConnectivities(eQUAD4); MED::TIntVector aQuadElemNums; aQuadElemNums.reserve(aNbElems); MED::TIntVector aQuadFamilyNums; @@ -531,7 +531,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() #ifdef _ELEMENTS_BY_DIM_ SMDS_MED_ENTITY = eMAILLE; #endif - TInt aNbTetraConn = MED::GetNbConn(SMDS_MED_ENTITY,eTETRA4,aMeshDimension); + TInt aNbTetraConn = MED::GetNbConnectivities(eTETRA4); MED::TIntVector anTetraElemNums; anTetraElemNums.reserve(aNbElems); MED::TIntVector aTetraFamilyNums; @@ -539,7 +539,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector aTetraConn; aTetraConn.reserve(aNbElems*aNbTetraConn); - TInt aNbPyraConn = MED::GetNbConn(SMDS_MED_ENTITY,ePYRA5,aMeshDimension); + TInt aNbPyraConn = MED::GetNbConnectivities(ePYRA5); MED::TIntVector anPyraElemNums; anPyraElemNums.reserve(aNbElems); MED::TIntVector aPyraFamilyNums; @@ -547,7 +547,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector aPyraConn; aPyraConn.reserve(aNbElems*aNbPyraConn); - TInt aNbPentaConn = MED::GetNbConn(SMDS_MED_ENTITY,ePENTA6,aMeshDimension); + TInt aNbPentaConn = MED::GetNbConnectivities(ePENTA6); MED::TIntVector anPentaElemNums; anPentaElemNums.reserve(aNbElems); MED::TIntVector aPentaFamilyNums; @@ -555,7 +555,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector aPentaConn; aPentaConn.reserve(aNbElems*aNbPentaConn); - TInt aNbHexaConn = MED::GetNbConn(SMDS_MED_ENTITY,eHEXA8,aMeshDimension); + TInt aNbHexaConn = MED::GetNbConnectivities(eHEXA8); MED::TIntVector aHexaElemNums; aHexaElemNums.reserve(aNbElems); MED::TIntVector aHexaFamilyNums; -- 2.30.2 From 55a0f35a26a2199ccd575fa145f76bf01a4e97d4 Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 25 Jan 2005 05:21:30 +0000 Subject: [PATCH 06/16] Fix wrong comments indentation --- src/SMESH_SWIG/meshpy.py | 133 ++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 66 deletions(-) diff --git a/src/SMESH_SWIG/meshpy.py b/src/SMESH_SWIG/meshpy.py index 528e4fe21..86c0fde04 100644 --- a/src/SMESH_SWIG/meshpy.py +++ b/src/SMESH_SWIG/meshpy.py @@ -24,28 +24,28 @@ smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(salome.myStudyId) class MeshHexaImpl: -""" - Class MeshHexaImpl for Hexahedrical meshing + """ + Class MeshHexaImpl for Hexahedrical meshing - Examples: cube2pyGibi.py, lines 270-295 - cube2partition.py, lines 72-83 -""" + Examples: cube2pyGibi.py, lines 270-295 + cube2partition.py, lines 72-83 + """ piece = 0 name = 0 mesh = 0 cpt = 0 def Mesh1D(self, shape, n, propagate=0): - """ - Define Wires discretization. - Sets algorithm and hypothesis for 1D discretization of \a shape: - - algorithm "Regular_1D" - - hypothesis "NumberOfSegments" with number of segments \a n - \param shape Main shape or sub-shape to define wire discretization of - \param n Number of segments to split eash wire of the \a shape on - \param propagate Boolean flag. If propagate = 1, - "Propagation" hypothesis will be applied also to the \a shape - """ + """ + Define Wires discretization. + Sets algorithm and hypothesis for 1D discretization of \a shape: + - algorithm "Regular_1D" + - hypothesis "NumberOfSegments" with number of segments \a n + \param shape Main shape or sub-shape to define wire discretization of + \param n Number of segments to split eash wire of the \a shape on + \param propagate Boolean flag. If propagate = 1, + "Propagation" hypothesis will be applied also to the \a shape + """ hyp1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(hyp1D), self.name+"/WireDiscretisation/"+str(self.cpt)) self.mesh.AddHypothesis(shape, hyp1D) @@ -63,23 +63,23 @@ class MeshHexaImpl: self.cpt=self.cpt+1 def __init__(self, piece, n, name): - """ - Constructor - - Creates mesh on the shape \a piece, - sets GUI name of this mesh to \a name. \n - Sets the following global algorithms and hypotheses: - - for 1D discretization: - - algorithm "Regular_1D" - - hypothesis "NumberOfSegments" with number of segments \a n - - for 2D discretization: - - algorithm "Quadrangle_2D" - - for 3D discretization: - - algorithm "Hexa_3D" - \param piece Shape to be meshed - \param n Global number of segments for wires discretization - \param name Name for mesh to be created - """ + """ + Constructor + + Creates mesh on the shape \a piece, + sets GUI name of this mesh to \a name. \n + Sets the following global algorithms and hypotheses: + - for 1D discretization: + - algorithm "Regular_1D" + - hypothesis "NumberOfSegments" with number of segments \a n + - for 2D discretization: + - algorithm "Quadrangle_2D" + - for 3D discretization: + - algorithm "Hexa_3D" + \param piece Shape to be meshed + \param n Global number of segments for wires discretization + \param name Name for mesh to be created + """ self.piece = piece self.name = name @@ -97,49 +97,50 @@ class MeshHexaImpl: self.mesh.AddHypothesis(piece, hyp3D) def local(self, edge, n): - """ - Creates sub-mesh of the mesh, created by constructor. - This sub-mesh will be created on edge \a edge. - Set algorithm and hypothesis for 1D discretization of the \a edge: - - algorithm "Regular_1D" - - hypothesis "NumberOfSegments" with number of segments \a n - \param edge Sub-edge of the main shape - \param n Number of segments to split the \a edge on - \note: \a edge will be automatically published in study under the shape, given in constructor. - """ + """ + Creates sub-mesh of the mesh, created by constructor. + This sub-mesh will be created on edge \a edge. + Set algorithm and hypothesis for 1D discretization of the \a edge: + - algorithm "Regular_1D" + - hypothesis "NumberOfSegments" with number of segments \a n + \param edge Sub-edge of the main shape + \param n Number of segments to split the \a edge on + \note: \a edge will be automatically published in study under the shape, given in constructor. + """ geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece)) submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt)) self.Mesh1D(edge, n) def Propagate(self, edge, n): - """ - Creates sub-mesh of the mesh, created by constructor. - This sub-mesh will be created on edge \a edge and propagate the hypothesis on all correspondant edges. - Set algorithm and hypothesis for 1D discretization of the \a edge and all other propagate edges: - - algorithm "Regular_1D" - - hypothesis "NumberOfSegments" with number of segments \a n - - hypothesis "Propagation" - \param edge Sub-edge of the main shape - \param n Number of segments to split the \a edge and all other propagate edges on - \note: \a edge will be automatically published in study under the shape, given in constructor. - """ + """ + Creates sub-mesh of the mesh, created by constructor. + This sub-mesh will be created on edge \a edge and + propagate the hypothesis on all correspondant edges. + Set algorithm and hypothesis for 1D discretization of the \a edge and all other propagate edges: + - algorithm "Regular_1D" + - hypothesis "NumberOfSegments" with number of segments \a n + - hypothesis "Propagation" + \param edge Sub-edge of the main shape + \param n Number of segments to split the \a edge and all other propagate edges on + \note: \a edge will be automatically published in study under the shape, given in constructor. + """ geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece)) submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt)) self.Mesh1D(edge, n, 1) def Compute(self): - """ - Computes mesh, created by constructor. - """ + """ + Computes mesh, created by constructor. + """ smesh.Compute(self.mesh, self.piece) salome.sg.updateObjBrowser(1) def Group(self, grp, name=""): - """ - Creates mesh group based on a geometric group - \param grp Geometric group - \param name Name for mesh group to be created - """ + """ + Creates mesh group based on a geometric group + \param grp Geometric group + \param name Name for mesh group to be created + """ if name == "": name = grp.GetName() tgeo = geompy.GroupOp.GetType(grp) @@ -154,11 +155,11 @@ class MeshHexaImpl: return self.mesh.CreateGroupFromGEOM(type, name, grp) def ExportMED(self, filename, groups=1): - """ - Export mesh in a MED file - \param filename Name for MED file to be created - \param groups Boolean flag. If groups = 1, mesh groups will be also stored in file - """ + """ + Export mesh in a MED file + \param filename Name for MED file to be created + \param groups Boolean flag. If groups = 1, mesh groups will be also stored in file + """ self.mesh.ExportMED(filename, groups) MeshHexa = MeshHexaImpl -- 2.30.2 From be0f45394e6273c01769d2825369779322f39485 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 25 Jan 2005 13:43:14 +0000 Subject: [PATCH 07/16] Apply patch from Paul Rascle (correction of make procedure) --- configure.in.base | 2 +- src/DriverMED/Makefile.in | 2 +- src/SMESH_I/Makefile.in | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/configure.in.base b/configure.in.base index 38caec219..2e65ed140 100644 --- a/configure.in.base +++ b/configure.in.base @@ -351,7 +351,7 @@ do case "$local_bin" in *.in | *~) ;; ./bin/CVS | ./bin/salome) ;; - *) /usr/bin/install -C $i .; echo $local_bin ;; + *) /usr/bin/install $i .; echo $local_bin ;; esac done cd $ROOT_BUILDDIR diff --git a/src/DriverMED/Makefile.in b/src/DriverMED/Makefile.in index 19d97d9ac..47997c6d7 100644 --- a/src/DriverMED/Makefile.in +++ b/src/DriverMED/Makefile.in @@ -63,7 +63,7 @@ CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS CXXFLAGS += $(OCC_CXXFLAGS) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS += -lMeshDriver -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper -LDFLAGSFORBIN += -lMeshDriver -lSMDS -lSMESHDS -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper -lOpUtil -lSALOMELocalTrace +LDFLAGSFORBIN += -lMeshDriver -lSMDS -lSMESHDS -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lMEDWrapper_V2_2 -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/SMESH_I/Makefile.in b/src/SMESH_I/Makefile.in index 5a5457f9e..700a10d33 100644 --- a/src/SMESH_I/Makefile.in +++ b/src/SMESH_I/Makefile.in @@ -92,11 +92,12 @@ LDFLAGS+= -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer -lSalomeNS -lRegistr -L${CASROOT}/lin/lib -lTKCDF -lTKBO -LDFLAGSFORBIN += -lSMDS -lSMESHDS -lMEDWrapper -lMeshDriver -lMeshDriverMED -lMeshDriverUNV -lMeshDriverDAT -lMeshDriverSTL \ - -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer -lSalomeNS -lRegistry \ - -lOpUtil -lSALOMELocalTrace -lSalomeNotification \ +LDFLAGSFORBIN += -lSMDS -lSMESHDS -lMEDWrapper -lMEDWrapperBase -lMEDWrapper_V2_1 -lMEDWrapper_V2_2 \ + -lMeshDriver -lMeshDriverMED -lMeshDriverUNV -lMeshDriverDAT -lMeshDriverSTL \ + -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer -lSalomeNS -lRegistry -lSalomeResourcesManager \ + -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector -lSalomeNotification -lCASCatch \ -lSalomeHDFPersist -lSalomeLifeCycleCORBA -lTOOLSDS -lSalomeGenericObj \ - -L${GEOM_ROOT_DIR}/lib/salome -lGEOMClient -lSMESHimpl -lSMESHControls \ + -L${GEOM_ROOT_DIR}/lib/salome -lGEOMClient -lSMESHimpl -lSMESHControls -lNMTTools -lNMTDS \ -L${CASROOT}/lin/lib -lTKCDF -lTKBO @CONCLUDE@ -- 2.30.2 From fa076b4364194654265db89166ecd7e4daa4792f Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 25 Jan 2005 15:51:15 +0000 Subject: [PATCH 08/16] Modify 'Modification of orientation' dialog box: implement processing of 'Bad oriented volume' filter. --- src/SMESHGUI/SMESHGUI_FilterDlg.cxx | 7 +- src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx | 107 +++++++++++++++++++++---- src/SMESHGUI/SMESHGUI_MultiEditDlg.h | 8 +- src/SMESHGUI/SMESH_msg_en.po | 3 + 4 files changed, 105 insertions(+), 20 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index 0f8a79779..5eda1bc93 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -973,7 +973,8 @@ void SMESHGUI_FilterTable::updateAdditionalWidget() GetCriterionType( aRow ) != FT_BelongToGeom && GetCriterionType( aRow ) != FT_LyingOnGeom && GetCriterionType( aRow ) != FT_RangeOfIds && - GetCriterionType( aRow ) != FT_FreeEdges; + GetCriterionType( aRow ) != FT_FreeEdges && + GetCriterionType( aRow ) != FT_BadOrientedVolume; if ( !myAddWidgets.contains( anItem ) ) { myAddWidgets[ anItem ] = new AdditionalWidget( myWgStack ); @@ -1045,7 +1046,8 @@ void SMESHGUI_FilterTable::onCriterionChanged( const int row, const int col, con int aCriterionType = GetCriterionType( row ); if ( aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders || - aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges ) + aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges || + aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume ) { if ( aCompareItem->count() > 0 ) aCompareItem->setStringList( QStringList() ); @@ -1298,6 +1300,7 @@ const QMap& SMESHGUI_FilterTable::getCriteria( const int theType ) aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" ); aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" ); aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" ); + aCriteria[ SMESH::FT_BadOrientedVolume ] = tr( "BAD_ORIENTED_VOLUME" ); } return aCriteria; } diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index b1662d8e6..1e01c6881 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -47,7 +47,9 @@ #include "SALOME_ListIteratorOfListIO.hxx" #include "VTKViewer_InteractorStyleSALOME.h" -#include +#include +#include +#include #include #include #include @@ -69,6 +71,8 @@ #include #include #include +#include +#include // IDL Headers #include "SALOMEconfig.h" @@ -90,6 +94,7 @@ SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg( QWidget* theParent, SALOME_Selection* theSelection, const int theMode, + const bool the3d2d, const char* theName ) : QDialog( theParent, theName, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) @@ -98,10 +103,12 @@ SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg( QWidget* theParent, mySubmeshFilter = new SMESH_TypeFilter( SUBMESH ); myGroupFilter = new SMESH_TypeFilter( GROUP ); + myEntityType = 0; + myFilterType = theMode; QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); - QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aMainFrame = createMainFrame ( this, the3d2d ); QFrame* aBtnFrame = createButtonFrame( this ); aDlgLay->addWidget( aMainFrame ); @@ -116,7 +123,7 @@ SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg( QWidget* theParent, // name : SMESHGUI_MultiEditDlg::createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent ) +QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent, const bool the3d2d ) { QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); aMainGrp->setFrameStyle( QFrame::NoFrame ); @@ -126,6 +133,15 @@ QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent ) // "Selected cells" group mySelGrp = new QGroupBox( 1, Qt::Horizontal, aMainGrp ); + + myEntityTypeGrp = 0; + if ( the3d2d ) { + myEntityTypeGrp = new QHButtonGroup( tr("SMESH_ELEMENTS_TYPE"), mySelGrp ); + (new QRadioButton( tr("SMESH_FACE"), myEntityTypeGrp ))->setChecked( true ); + (new QRadioButton( tr("SMESH_VOLUME"), myEntityTypeGrp )); + myEntityType = myEntityTypeGrp->id( myEntityTypeGrp->selected() ); + } + QFrame* aFrame = new QFrame( mySelGrp ); myListBox = new QListBox( aFrame ); @@ -251,6 +267,9 @@ void SMESHGUI_MultiEditDlg::Init( SALOME_Selection* theSelection ) connect( myGroupChk , SIGNAL( stateChanged( int ) ), SLOT( onGroupChk() ) ); connect( myToAllChk , SIGNAL( stateChanged( int ) ), SLOT( onToAllChk() ) ); + if ( myEntityTypeGrp ) + connect( myEntityTypeGrp, SIGNAL( clicked(int) ), SLOT( on3d2dChanged(int) ) ); + connect( myListBox, SIGNAL( selectionChanged() ), SLOT( onListSelectionChanged() ) ); onSelectionDone(); @@ -293,10 +312,14 @@ SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds() vtkCell* aCell = aGrid->GetCell( i ); if ( aCell != 0 ) { - int nbNodes = aCell->GetNumberOfPoints(); - if ( nbNodes == 3 && myFilterType == SMESHGUI_TriaFilter || - nbNodes == 4 && myFilterType == SMESHGUI_QuadFilter || - ( nbNodes == 4 || nbNodes == 3 ) && myFilterType == SMESHGUI_UnknownFilter ) + vtkTriangle* aTri = vtkTriangle::SafeDownCast(aCell); + vtkQuad* aQua = vtkQuad::SafeDownCast(aCell); + vtkCell3D* a3d = vtkCell3D::SafeDownCast(aCell); + + if ( aTri && myFilterType == SMESHGUI_TriaFilter || + aQua && myFilterType == SMESHGUI_QuadFilter || + ( aTri || aQua ) && myFilterType == SMESHGUI_FaceFilter || + a3d && myFilterType == SMESHGUI_VolumeFilter ) { int anObjId = aVisualObj->GetElemObjId( i ); myIds.Add( anObjId ); @@ -329,6 +352,7 @@ void SMESHGUI_MultiEditDlg::onClose() SMESH::RemoveFilter(SMESHGUI_EdgeFilter); SMESH::RemoveFilter(SMESHGUI_FaceFilter); + SMESH::RemoveFilter(SMESHGUI_VolumeFilter); SMESH::RemoveFilter(SMESHGUI_QuadFilter); SMESH::RemoveFilter(SMESHGUI_TriaFilter); SMESH::SetPickable(); @@ -472,11 +496,11 @@ void SMESHGUI_MultiEditDlg::onFilterBtn() { if ( myFilterDlg == 0 ) { - myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), SMESH::FACE ); + myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), entityType() ? SMESH::VOLUME : SMESH::FACE ); connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) ); } else - myFilterDlg->Init( SMESH::FACE ); + myFilterDlg->Init( entityType() ? SMESH::VOLUME : SMESH::FACE ); myFilterDlg->SetSelection( mySelection ); myFilterDlg->SetMesh( myMesh ); @@ -810,6 +834,13 @@ void SMESHGUI_MultiEditDlg::onToAllChk() //======================================================================= void SMESHGUI_MultiEditDlg::setSelectionMode() { + SMESH::RemoveFilter(SMESHGUI_EdgeFilter); + SMESH::RemoveFilter(SMESHGUI_FaceFilter); + SMESH::RemoveFilter(SMESHGUI_VolumeFilter); + SMESH::RemoveFilter(SMESHGUI_QuadFilter); + SMESH::RemoveFilter(SMESHGUI_TriaFilter); + SMESH::SetPickable(); + mySelection->ClearIObjects(); mySelection->ClearFilters(); @@ -825,11 +856,16 @@ void SMESHGUI_MultiEditDlg::setSelectionMode() } else { - QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); - if ( myFilterType == SMESHGUI_TriaFilter ) - SMESH::SetFilter( new SMESHGUI_TriangleFilter() ); - else if ( myFilterType == SMESHGUI_QuadFilter ) - SMESH::SetFilter( new SMESHGUI_QuadrangleFilter() ); + if ( myFilterType == SMESHGUI_VolumeFilter ) { + QAD_Application::getDesktop()->SetSelectionMode( VolumeSelection, true ); + } + else { + QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); + if ( myFilterType == SMESHGUI_TriaFilter ) + SMESH::SetFilter( new SMESHGUI_TriangleFilter() ); + else if ( myFilterType == SMESHGUI_QuadFilter ) + SMESH::SetFilter( new SMESHGUI_QuadrangleFilter() ); + } } } @@ -870,6 +906,43 @@ bool SMESHGUI_MultiEditDlg::onApply() return aResult; } +//======================================================================= +// name : SMESHGUI_MultiEditDlg::on3d2dChanged +// Purpose : +//======================================================================= +void SMESHGUI_MultiEditDlg::on3d2dChanged(int type) +{ + if ( myEntityType != type ) { + myEntityType = type; + + myListBox->clear(); + myIds.Clear(); + + emit ListContensChanged(); + + updateButtons(); + + if ( type ) + myFilterType = SMESHGUI_VolumeFilter; + else + myFilterType = SMESHGUI_FaceFilter; + setSelectionMode(); + + if ( myActor ) + mySelection->AddIObject( myActor->getIO(), true ); + } +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::entityType +// Purpose : +//======================================================================= + +int SMESHGUI_MultiEditDlg::entityType() +{ + return myEntityType; +} + /* Class : SMESHGUI_ChangeOrientationDlg Description : Modification of orientation of faces @@ -878,7 +951,7 @@ bool SMESHGUI_MultiEditDlg::onApply() SMESHGUI_ChangeOrientationDlg::SMESHGUI_ChangeOrientationDlg( QWidget* theParent, SALOME_Selection* theSelection, const char* theName ) -: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_UnknownFilter, theName ) +: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_FaceFilter, true, theName ) { setCaption( tr( "CAPTION" ) ); } @@ -901,7 +974,7 @@ bool SMESHGUI_ChangeOrientationDlg::process( SMESH::SMESH_MeshEditor_ptr theEdit SMESHGUI_UnionOfTrianglesDlg::SMESHGUI_UnionOfTrianglesDlg( QWidget* theParent, SALOME_Selection* theSelection, const char* theName ) -: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_TriaFilter, theName ) +: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_TriaFilter, false, theName ) { setCaption( tr( "CAPTION" ) ); } @@ -924,7 +997,7 @@ bool SMESHGUI_UnionOfTrianglesDlg::process( SMESH::SMESH_MeshEditor_ptr theEdito SMESHGUI_CuttingOfQuadsDlg::SMESHGUI_CuttingOfQuadsDlg( QWidget* theParent, SALOME_Selection* theSelection, const char* theName ) -: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_QuadFilter, theName ) +: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_QuadFilter, false, theName ) { setCaption( tr( "CAPTION" ) ); diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h index a35f51758..0ec412661 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h @@ -46,6 +46,7 @@ class QPushButton; class SALOME_Selection; class SMESH_Actor; class SALOME_Actor; +class QButtonGroup; /* Class : SMESHGUI_MultiEditDlg @@ -61,6 +62,7 @@ public: SMESHGUI_MultiEditDlg( QWidget*, SALOME_Selection*, const int, + const bool = false, const char* = 0 ); virtual ~SMESHGUI_MultiEditDlg(); @@ -87,6 +89,7 @@ protected slots: void onGroupChk(); virtual void onToAllChk(); void onFilterAccepted(); + void on3d2dChanged(int); protected: @@ -94,13 +97,14 @@ protected: void enterEvent ( QEvent * ) ; void hideEvent ( QHideEvent * ); /* ESC key */ QFrame* createButtonFrame( QWidget* ); - QFrame* createMainFrame ( QWidget* ); + QFrame* createMainFrame ( QWidget*, const bool ); bool isValid( const bool ) const; SMESH::long_array_var getIds(); void updateButtons(); void setSelectionMode(); virtual bool isIdValid( const int theID ) const; virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ) = 0; + int entityType(); protected: @@ -120,6 +124,7 @@ protected: QPushButton* mySortBtn; QCheckBox* myToAllChk; + QButtonGroup* myEntityTypeGrp; QCheckBox* mySubmeshChk; QPushButton* mySubmeshBtn; @@ -135,6 +140,7 @@ protected: Handle(SMESH_TypeFilter) mySubmeshFilter; Handle(SMESH_TypeFilter) myGroupFilter; bool myBusy; + int myEntityType; }; /* diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po index ddfd0b3e2..a58c6a758 100644 --- a/src/SMESHGUI/SMESH_msg_en.po +++ b/src/SMESHGUI/SMESH_msg_en.po @@ -991,6 +991,9 @@ msgstr "Skew" msgid "SMESHGUI_FilterTable::AREA" msgstr "Area" +msgid "SMESHGUI_FilterTable::BAD_ORIENTED_VOLUME" +msgstr "Bad oriented volume" + msgid "SMESHGUI_FilterTable::LESS_THAN" msgstr "Less than" -- 2.30.2 From efdf984e40ba00513859a612721ebe25e711b851 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 26 Jan 2005 06:49:06 +0000 Subject: [PATCH 09/16] Improve checking of validity of mesh elements connectivity --- src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index fe5100d4f..1433e3208 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -309,21 +309,35 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() break; } vector 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); + if(anIsNodeNum) { + for(int i = 0; i < aNbNodes; i++){ + aNodeIds[i] = aNodeInfo->GetElemNum(aCellInfo->GetConn(iElem,i)-1); + } + }else{ + for(int i = 0; i < aNbNodes; i++){ + aNodeIds[i] = aCellInfo->GetConn(iElem,i); + } } - }else{ +#else for(int i = 0; i < aNbNodes; i++){ aNodeIds[i] = aCellInfo->GetConn(iElem,i); } - } -#else - for(int i = 0; i < aNbNodes; i++){ - aNodeIds[i] = aCellInfo->GetConn(iElem,i); - } #endif + anIsValidConnect = true; + }catch(const std::exception& exc){ + //INFOS("Follow exception was cought:\n\t"< Date: Wed, 26 Jan 2005 08:32:21 +0000 Subject: [PATCH 10/16] PAL7358. Add VertexParameters() and EdgeParameters() --- src/SMESH/SMESH_Block.cxx | 56 ++++++++++++++++++++++++++++++++++++++- src/SMESH/SMESH_Block.hxx | 9 ++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/SMESH/SMESH_Block.cxx b/src/SMESH/SMESH_Block.cxx index 016805fd3..4c55ca8e4 100644 --- a/src/SMESH/SMESH_Block.cxx +++ b/src/SMESH/SMESH_Block.cxx @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -381,9 +384,24 @@ bool SMESH_Block::ComputeParameters(const gp_Pnt& thePoint, gp_XYZ& theParams, const int theShapeID) { + if ( VertexParameters( theShapeID, theParams )) + return true; + + if ( IsEdgeID( theShapeID )) { + TEdge& e = myEdge[ theShapeID - ID_Ex00 ]; + GeomAdaptor_Curve curve( e.myC3d ); + double f = Min( e.myFirst, e.myLast ), l = Max( e.myFirst, e.myLast ); + Extrema_ExtPC anExtPC( thePoint, curve, f, l ); + int i, nb = anExtPC.IsDone() ? anExtPC.NbExt() : 0; + for ( i = 1; i <= nb; i++ ) { + if ( anExtPC.IsMin( i )) + return EdgeParameters( theShapeID, anExtPC.Point( i ).Parameter(), theParams ); + } + return false; + } + // MESSAGE( endl<<"SMESH_Block::ComputeParameters( " // < vertexVec; + GetEdgeVertexIDs( theEdgeID, vertexVec ); + VertexParameters( vertexVec[0], theParams ); + TEdge& e = myEdge[ theEdgeID - ID_Ex00 ]; + double param = ( theU - e.myFirst ) / ( e.myLast - e.myFirst ); + theParams.SetCoord( e.myCoordInd, param ); + return true; + } + return false; +} + //======================================================================= //function : GetStateNumber //purpose : diff --git a/src/SMESH/SMESH_Block.hxx b/src/SMESH/SMESH_Block.hxx index 7ab38891a..7258fdeff 100644 --- a/src/SMESH/SMESH_Block.hxx +++ b/src/SMESH/SMESH_Block.hxx @@ -122,7 +122,14 @@ class SMESH_Block: public math_FunctionSetWithDerivatives bool ComputeParameters (const gp_Pnt& thePoint, gp_XYZ& theParams, const int theShapeID = ID_Shell); - // compute point parameters in the block + // compute point parameters in the block. + // Note: for edges, it is better to use EdgeParameters() + + bool VertexParameters(const int theVertexID, gp_XYZ& theParams); + // return parameters of a vertex given by TShapeID + + bool EdgeParameters(const int theEdgeID, const double theU, gp_XYZ& theParams); + // return parameters of a point given by theU on edge static void GetFaceEdgesIDs (const int faceID, vector< int >& edgeVec ); // return edges IDs of a face in the order u0, u1, 0v, 1v -- 2.30.2 From 31e0d2b9b7d4a418c7df17875648031b382c5a5e Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 26 Jan 2005 08:35:00 +0000 Subject: [PATCH 11/16] remove not used fields --- src/SMESH/SMESH_Mesh.hxx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index a28a67ea5..31bd28ee2 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -215,19 +215,17 @@ private: // private: - int _id; // id given by creator (unique within the creator instance) - int _studyId; - int _idDoc; // id given by SMESHDS_Document - int _groupId; // id generator for group objects - bool _isShapeToMesh; // set to true when a shape is given (only once) - list _subShapeHypothesisList; - list _subMeshesUsingHypothesisList; - SMESHDS_Document * _myDocument; - SMESHDS_Mesh * _myMeshDS; - //TopTools_IndexedMapOfShape _subShapes; USE the same map of _myMeshDS + int _id; // id given by creator (unique within the creator instance) + int _studyId; + int _idDoc; // id given by SMESHDS_Document + int _groupId; // id generator for group objects + bool _isShapeToMesh;// set to true when a shape is given (only once) + list _subMeshesUsingHypothesisList; + SMESHDS_Document * _myDocument; + SMESHDS_Mesh * _myMeshDS; map _mapSubMesh; map _mapGroup; - SMESH_Gen *_gen; + SMESH_Gen * _gen; TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors; -- 2.30.2 From 6d13ce68630daaa8550bdb324a5da08529a82450 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 26 Jan 2005 08:42:27 +0000 Subject: [PATCH 12/16] PAL7403. In ShapeToMesh(), remove shape referring data if the main shape becomes NULL --- src/SMESH/SMESH_Mesh.cxx | 43 ++++++++++++++++++++++++++++-------- src/SMESHDS/SMESHDS_Mesh.cxx | 34 ++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index ef500ac8e..eb0f0392d 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -33,6 +33,7 @@ #include "SMESH_Group.hxx" #include "SMESHDS_Group.hxx" #include "SMESHDS_Script.hxx" +#include "SMESHDS_GroupOnGeom.hxx" #include "SMDS_MeshVolume.hxx" #include "utilities.h" @@ -110,15 +111,39 @@ SMESH_Mesh::~SMESH_Mesh() */ //============================================================================= -void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape){ +void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) +{ if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh"); - if (_isShapeToMesh) - throw - SALOME_Exception(LOCALIZED - ("a shape to mesh as already been defined")); + + if ( !_myMeshDS->ShapeToMesh().IsNull() && aShape.IsNull() ) + { + // removal of a shape to mesh, delete objects referring to sub-shapes: + // - sub-meshes + map ::iterator i_sm = _mapSubMesh.begin(); + for ( ; i_sm != _mapSubMesh.end(); ++i_sm ) + delete i_sm->second; + _mapSubMesh.clear(); + // - groups on geometry + map ::iterator i_gr = _mapGroup.begin(); + while ( i_gr != _mapGroup.end() ) { + if ( dynamic_cast( i_gr->second->GetGroupDS() )) { + _myMeshDS->RemoveGroup( i_gr->second->GetGroupDS() ); + delete i_gr->second; + _mapGroup.erase( i_gr++ ); + } + else + i_gr++; + } + _mapAncestors.Clear(); + _mapPropagationChains.Clear(); + } + else + { + if (_isShapeToMesh) + throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined")); + } _isShapeToMesh = true; _myMeshDS->ShapeToMesh(aShape); - // NRI : 24/02/03 //EAP: 1/9/04 TopExp::MapShapes(aShape, _subShapes); USE the same map of _myMeshDS } @@ -132,7 +157,7 @@ int SMESH_Mesh::UNVToMesh(const char* theFileName) { if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "< #include #include @@ -55,8 +56,37 @@ SMESHDS_Mesh::SMESHDS_Mesh(int MeshID):myMeshID(MeshID) //======================================================================= void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S) { - myShape = S; - TopExp::MapShapes(myShape, myIndexToShape); + if ( !myShape.IsNull() && S.IsNull() ) + { + // removal of a shape to mesh, delete ... + // - hypotheses + myShapeToHypothesis.clear(); + // - shape indices in SMDS_Position of nodes + map::iterator i_sub = myShapeIndexToSubMesh.begin(); + for ( ; i_sub != myShapeIndexToSubMesh.end(); i_sub++ ) { + if ( !i_sub->second->IsComplexSubmesh() ) { + SMDS_NodeIteratorPtr nIt = i_sub->second->GetNodes(); + while ( nIt->more() ) + nIt->next()->GetPosition()->SetShapeId( 0 ); + } + } + // - sub-meshes + myIndexToShape.Clear(); + myShapeIndexToSubMesh.clear(); + // - groups on geometry + set::iterator gr = myGroups.begin(); + while ( gr != myGroups.end() ) { + if ( dynamic_cast( *gr )) + myGroups.erase( gr++ ); + else + gr++; + } + } + else { + myShape = S; + if ( !S.IsNull() ) + TopExp::MapShapes(myShape, myIndexToShape); + } } //======================================================================= -- 2.30.2 From 542321374cd456002427be9d180929752703c161 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 26 Jan 2005 08:55:19 +0000 Subject: [PATCH 13/16] PAL7403. In Save(), remove shape referring data if a referred shape was deleted --- src/SMESH_I/SMESH_Gen_i.cxx | 342 +++++++++++++++++++++--------------- 1 file changed, 196 insertions(+), 146 deletions(-) diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 5d1d45ed6..bf046ac9b 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -975,13 +975,15 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // write reference on a shape if exists SALOMEDS::SObject_var myRef; + bool shapeRefFound = false; bool found = gotBranch->FindSubObject( GetRefOnShapeTag(), myRef ); if ( found ) { SALOMEDS::SObject_var myShape; bool ok = myRef->ReferencedObject( myShape ); if ( ok ) { + shapeRefFound = (! CORBA::is_nil( myShape->GetObject() )); string myRefOnObject = myShape->GetID(); - if ( myRefOnObject.length() > 0 ) { + if ( shapeRefFound && myRefOnObject.length() > 0 ) { aSize[ 0 ] = myRefOnObject.length() + 1; aDataset = new HDFdataset( "Ref on shape", aTopGroup, HDF_STRING, aSize, 1 ); aDataset->CreateOnDisk(); @@ -990,11 +992,19 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, } } } + // maybe a shape was deleted in the study + if ( !shapeRefFound && !mySMESHDSMesh->ShapeToMesh().IsNull() ) { + TopoDS_Shape nullShape; + myLocMesh.ShapeToMesh( nullShape ); // remove shape referring data + } // write applied hypotheses if exist SALOMEDS::SObject_var myHypBranch; found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch ); - if ( found ) { + if ( found && !shapeRefFound ) { // remove applied hyps + myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch ); + } + if ( found && shapeRefFound ) { aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup ); aGroup->CreateOnDisk(); @@ -1033,7 +1043,10 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // write applied algorithms if exist SALOMEDS::SObject_var myAlgoBranch; found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(), myAlgoBranch ); - if ( found ) { + if ( found && !shapeRefFound ) { // remove applied hyps + myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch ); + } + if ( found && shapeRefFound ) { aGroup = new HDFgroup( "Applied Algorithms", aTopGroup ); aGroup->CreateOnDisk(); @@ -1070,9 +1083,48 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, } // --> submesh objects sub-branches + for ( int i = GetSubMeshOnVertexTag(); i <= GetSubMeshOnCompoundTag(); i++ ) { SALOMEDS::SObject_var mySubmeshBranch; found = gotBranch->FindSubObject( i, mySubmeshBranch ); + + if ( found ) // check if there is shape reference in submeshes + { + bool hasShapeRef = false; + SALOMEDS::ChildIterator_var itSM = + myCurrentStudy->NewChildIterator( mySubmeshBranch ); + for ( ; itSM->More(); itSM->Next() ) { + SALOMEDS::SObject_var mySubRef, myShape, mySObject = itSM->Value(); + if ( mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef )) + mySubRef->ReferencedObject( myShape ); + if ( !CORBA::is_nil( myShape ) && !CORBA::is_nil( myShape->GetObject() )) + hasShapeRef = true; + else + { // remove one submesh + if ( shapeRefFound ) + { // unassign hypothesis + SMESH::SMESH_subMesh_var mySubMesh = + SMESH::SMESH_subMesh::_narrow( SObjectToObject( mySObject )); + if ( !mySubMesh->_is_nil() ) { + int shapeID = mySubMesh->GetId(); + TopoDS_Shape S = mySMESHDSMesh->IndexToShape( shapeID ); + const list& hypList = + mySMESHDSMesh->GetHypothesis( S ); + list::const_iterator hyp = hypList.begin(); + while ( hyp != hypList.end() ) { + int hypID = (*hyp++)->GetID(); // goto next here because + myLocMesh.RemoveHypothesis( S, hypID ); // hypList changes here + } + } + } + myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( mySObject ); + } + } // loop on submeshes of a type + if ( !shapeRefFound || !hasShapeRef ) { // remove the whole submeshes branch + myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( mySubmeshBranch ); + found = false; + } + } // end check if there is shape reference in submeshes if ( found ) { char name_meshgroup[ 30 ]; if ( i == GetSubMeshOnVertexTag() ) @@ -1099,7 +1151,8 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, for ( ; itSM->More(); itSM->Next() ) { SALOMEDS::SObject_var mySObject = itSM->Value(); CORBA::Object_var anSubObject = SObjectToObject( mySObject ); - if ( !CORBA::is_nil( anSubObject ) ) { + if ( !CORBA::is_nil( anSubObject )) + { SMESH::SMESH_subMesh_var mySubMesh = SMESH::SMESH_subMesh::_narrow( anSubObject ) ; int subid = myStudyContext->findId( string( GetORB()->object_to_string( anSubObject ) ) ); @@ -1109,31 +1162,18 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, aSubGroup = new HDFgroup( submeshGrpName, aGroup ); aSubGroup->CreateOnDisk(); -// // Put submesh data to MED convertor -// if ( myImpl->_mapSubMesh.find( mySubMesh->GetId() ) != myImpl->_mapSubMesh.end() ) { -// if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen_i::Save(): saving submesh with ID = " -// << mySubMesh->GetId() << " to MED file" ); -// ::SMESH_subMesh* aLocalSubmesh = myImpl->_mapSubMesh[mySubMesh->GetId()]; -// myWriter.AddSubMesh( aLocalSubmesh->GetSubMeshDS(), subid ); -// } - - // write reference on a shape if exists - SALOMEDS::SObject_var mySubRef; - found = mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ); - if ( found ) { - SALOMEDS::SObject_var myShape; - bool ok = mySubRef->ReferencedObject( myShape ); - if ( ok ) { - string myRefOnObject = myShape->GetID(); - if ( myRefOnObject.length() > 0 ) { - aSize[ 0 ] = myRefOnObject.length() + 1; - aDataset = new HDFdataset( "Ref on shape", aSubGroup, HDF_STRING, aSize, 1 ); - aDataset->CreateOnDisk(); - aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) ); - aDataset->CloseOnDisk(); - } - } - } + // write reference on a shape, already checked if it exists + SALOMEDS::SObject_var mySubRef, myShape; + if ( mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef )) + mySubRef->ReferencedObject( myShape ); + string myRefOnObject = myShape->GetID(); + if ( myRefOnObject.length() > 0 ) { + aSize[ 0 ] = myRefOnObject.length() + 1; + aDataset = new HDFdataset( "Ref on shape", aSubGroup, HDF_STRING, aSize, 1 ); + aDataset->CreateOnDisk(); + aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) ); + aDataset->CloseOnDisk(); + } // write applied hypotheses if exist SALOMEDS::SObject_var mySubHypBranch; @@ -1257,6 +1297,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // Store the group contents into MED file if ( myLocMesh.GetGroup( myGroupImpl->GetLocalID() ) ) { + if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen_i::Save(): saving group with StoreName = " << grpName << " to MED file" ); SMESHDS_GroupBase* aGrpBaseDS = @@ -1274,7 +1315,8 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, if ( aGeomGrp ) { SALOMEDS::SObject_var mySubRef, myShape; if (mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ) && - mySubRef->ReferencedObject( myShape )) + mySubRef->ReferencedObject( myShape ) && + !CORBA::is_nil( myShape->GetObject() )) { string myRefOnObject = myShape->GetID(); if ( myRefOnObject.length() > 0 ) { @@ -1287,13 +1329,18 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, aDataset->CloseOnDisk(); } } + else // shape ref is invalid: + { + // save a group on geometry as ordinary group + myWriter.AddGroup( aGeomGrp ); + } } } } } aGroup->CloseOnDisk(); } - } + } // loop on groups if ( strcmp( strHasData.c_str(), "1" ) == 0 ) { @@ -1303,135 +1350,138 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // Store node positions on sub-shapes (SMDS_Position): - aGroup = new HDFgroup( "Node Positions", aTopGroup ); - aGroup->CreateOnDisk(); - - // in aGroup, create 5 datasets to contain: - // "Nodes on Edges" - ID of node on edge - // "Edge positions" - U parameter on node on edge - // "Nodes on Faces" - ID of node on face - // "Face U positions" - U parameter of node on face - // "Face V positions" - V parameter of node on face - - // Find out nb of nodes on edges and faces - // Collect corresponing sub-meshes - int nbEdgeNodes = 0, nbFaceNodes = 0; - list aEdgeSM, aFaceSM; - // loop on SMESHDS_SubMesh'es - const map& aSubMeshes = mySMESHDSMesh->SubMeshes(); - map::const_iterator itSubM ( aSubMeshes.begin() ); - for ( ; itSubM != aSubMeshes.end() ; itSubM++ ) - { - SMESHDS_SubMesh* aSubMesh = (*itSubM).second; - if ( aSubMesh->IsComplexSubmesh() ) - continue; // submesh containing other submeshs - int nbNodes = aSubMesh->NbNodes(); - if ( nbNodes == 0 ) continue; - - int aShapeID = (*itSubM).first; - int aShapeType = mySMESHDSMesh->IndexToShape( aShapeID ).ShapeType(); - // write only SMDS_FacePosition and SMDS_EdgePosition - switch ( aShapeType ) { - case TopAbs_FACE: - nbFaceNodes += nbNodes; - aFaceSM.push_back( aSubMesh ); - break; - case TopAbs_EDGE: - nbEdgeNodes += nbNodes; - aEdgeSM.push_back( aSubMesh ); - break; - default: - continue; - } - } - // Treat positions on edges or faces - for ( int onFace = 0; onFace < 2; onFace++ ) + if ( !mySMESHDSMesh->SubMeshes().empty() ) { - // Create arrays to store in datasets - int iNode = 0, nbNodes = ( onFace ? nbFaceNodes : nbEdgeNodes ); - if (!nbNodes) continue; - int* aNodeIDs = new int [ nbNodes ]; - double* aUPos = new double [ nbNodes ]; - double* aVPos = ( onFace ? new double[ nbNodes ] : 0 ); - - // Fill arrays - // loop on sub-meshes - list * pListSM = ( onFace ? &aFaceSM : &aEdgeSM ); - list::iterator itSM = pListSM->begin(); - for ( ; itSM != pListSM->end(); itSM++ ) + aGroup = new HDFgroup( "Node Positions", aTopGroup ); + aGroup->CreateOnDisk(); + + // in aGroup, create 5 datasets to contain: + // "Nodes on Edges" - ID of node on edge + // "Edge positions" - U parameter on node on edge + // "Nodes on Faces" - ID of node on face + // "Face U positions" - U parameter of node on face + // "Face V positions" - V parameter of node on face + + // Find out nb of nodes on edges and faces + // Collect corresponing sub-meshes + int nbEdgeNodes = 0, nbFaceNodes = 0; + list aEdgeSM, aFaceSM; + // loop on SMESHDS_SubMesh'es + const map& aSubMeshes = mySMESHDSMesh->SubMeshes(); + map::const_iterator itSubM ( aSubMeshes.begin() ); + for ( ; itSubM != aSubMeshes.end() ; itSubM++ ) { - SMESHDS_SubMesh* aSubMesh = (*itSM); + SMESHDS_SubMesh* aSubMesh = (*itSubM).second; if ( aSubMesh->IsComplexSubmesh() ) continue; // submesh containing other submeshs - - SMDS_NodeIteratorPtr itNode = aSubMesh->GetNodes(); - // loop on nodes in aSubMesh - while ( itNode->more() ) + int nbNodes = aSubMesh->NbNodes(); + if ( nbNodes == 0 ) continue; + + int aShapeID = (*itSubM).first; + int aShapeType = mySMESHDSMesh->IndexToShape( aShapeID ).ShapeType(); + // write only SMDS_FacePosition and SMDS_EdgePosition + switch ( aShapeType ) { + case TopAbs_FACE: + nbFaceNodes += nbNodes; + aFaceSM.push_back( aSubMesh ); + break; + case TopAbs_EDGE: + nbEdgeNodes += nbNodes; + aEdgeSM.push_back( aSubMesh ); + break; + default: + continue; + } + } + // Treat positions on edges or faces + for ( int onFace = 0; onFace < 2; onFace++ ) + { + // Create arrays to store in datasets + int iNode = 0, nbNodes = ( onFace ? nbFaceNodes : nbEdgeNodes ); + if (!nbNodes) continue; + int* aNodeIDs = new int [ nbNodes ]; + double* aUPos = new double [ nbNodes ]; + double* aVPos = ( onFace ? new double[ nbNodes ] : 0 ); + + // Fill arrays + // loop on sub-meshes + list * pListSM = ( onFace ? &aFaceSM : &aEdgeSM ); + list::iterator itSM = pListSM->begin(); + for ( ; itSM != pListSM->end(); itSM++ ) { - //node ID - const SMDS_MeshNode* node = itNode->next(); - aNodeIDs [ iNode ] = node->GetID(); - - // Position - const SMDS_PositionPtr pos = node->GetPosition(); - if ( onFace ) { // on FACE - const SMDS_FacePosition* fPos = - dynamic_cast( pos.get() ); - if ( fPos ) { - aUPos[ iNode ] = fPos->GetUParameter(); - aVPos[ iNode ] = fPos->GetVParameter(); - iNode++; + SMESHDS_SubMesh* aSubMesh = (*itSM); + if ( aSubMesh->IsComplexSubmesh() ) + continue; // submesh containing other submeshs + + SMDS_NodeIteratorPtr itNode = aSubMesh->GetNodes(); + // loop on nodes in aSubMesh + while ( itNode->more() ) + { + //node ID + const SMDS_MeshNode* node = itNode->next(); + aNodeIDs [ iNode ] = node->GetID(); + + // Position + const SMDS_PositionPtr pos = node->GetPosition(); + if ( onFace ) { // on FACE + const SMDS_FacePosition* fPos = + dynamic_cast( pos.get() ); + if ( fPos ) { + aUPos[ iNode ] = fPos->GetUParameter(); + aVPos[ iNode ] = fPos->GetVParameter(); + iNode++; + } + else + nbNodes--; } - else - nbNodes--; - } - else { // on EDGE - const SMDS_EdgePosition* ePos = - dynamic_cast( pos.get() ); - if ( ePos ) { - aUPos[ iNode ] = ePos->GetUParameter(); - iNode++; + else { // on EDGE + const SMDS_EdgePosition* ePos = + dynamic_cast( pos.get() ); + if ( ePos ) { + aUPos[ iNode ] = ePos->GetUParameter(); + iNode++; + } + else + nbNodes--; } - else - nbNodes--; - } - } // loop on nodes in aSubMesh - } // loop on sub-meshes + } // loop on nodes in aSubMesh + } // loop on sub-meshes - // Write datasets - if ( nbNodes ) - { - aSize[ 0 ] = nbNodes; - // IDS - string aDSName( onFace ? "Nodes on Faces" : "Nodes on Edges"); - aDataset = new HDFdataset( (char*)aDSName.c_str(), aGroup, HDF_INT32, aSize, 1 ); - aDataset->CreateOnDisk(); - aDataset->WriteOnDisk( aNodeIDs ); - aDataset->CloseOnDisk(); - - // U Positions - aDSName = ( onFace ? "Face U positions" : "Edge positions"); - aDataset = new HDFdataset( (char*)aDSName.c_str(), aGroup, HDF_FLOAT64, aSize, 1); - aDataset->CreateOnDisk(); - aDataset->WriteOnDisk( aUPos ); - aDataset->CloseOnDisk(); - // V Positions - if ( onFace ) { - aDataset = new HDFdataset( "Face V positions", aGroup, HDF_FLOAT64, aSize, 1); + // Write datasets + if ( nbNodes ) + { + aSize[ 0 ] = nbNodes; + // IDS + string aDSName( onFace ? "Nodes on Faces" : "Nodes on Edges"); + aDataset = new HDFdataset( (char*)aDSName.c_str(), aGroup, HDF_INT32, aSize, 1 ); + aDataset->CreateOnDisk(); + aDataset->WriteOnDisk( aNodeIDs ); + aDataset->CloseOnDisk(); + + // U Positions + aDSName = ( onFace ? "Face U positions" : "Edge positions"); + aDataset = new HDFdataset( (char*)aDSName.c_str(), aGroup, HDF_FLOAT64, aSize, 1); aDataset->CreateOnDisk(); - aDataset->WriteOnDisk( aVPos ); + aDataset->WriteOnDisk( aUPos ); aDataset->CloseOnDisk(); + // V Positions + if ( onFace ) { + aDataset = new HDFdataset( "Face V positions", aGroup, HDF_FLOAT64, aSize, 1); + aDataset->CreateOnDisk(); + aDataset->WriteOnDisk( aVPos ); + aDataset->CloseOnDisk(); + } } - } - delete [] aNodeIDs; - delete [] aUPos; - if ( aVPos ) delete [] aVPos; + delete [] aNodeIDs; + delete [] aUPos; + if ( aVPos ) delete [] aVPos; - } // treat positions on edges or faces + } // treat positions on edges or faces - // close "Node Positions" group - aGroup->CloseOnDisk(); + // close "Node Positions" group + aGroup->CloseOnDisk(); + } // if ( there are submeshes in SMESHDS_Mesh ) } // if ( hasData ) // close mesh HDF group -- 2.30.2 From 72598d17882a440afe96df9731407ce1bf241c70 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 26 Jan 2005 09:01:26 +0000 Subject: [PATCH 14/16] Prevent exception at shape selection if no mesh was pre-selected --- src/SMESHGUI/SMESHGUI_GroupDlg.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index aa3a15cbd..a83f360b5 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -797,7 +797,11 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() SALOMEDS::SObject_var aGroupMainShapeSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(aGroupMainShape) ); // The mesh SObject SALOMEDS::SObject_var aMeshSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myMesh) ); - + if ( aMeshSO->_is_nil() ) { + myGeomGroup = GEOM::GEOM_Object::_nil(); + busy = false; + return; + } SALOMEDS::SObject_var anObj, aRef; bool isRefOrSubShape = false; if ( aMeshSO->FindSubObject( 1, anObj ) && anObj->ReferencedObject( aRef )) { -- 2.30.2 From 71bc953009d275a48e997446bda1d14c6b570c16 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 26 Jan 2005 09:07:48 +0000 Subject: [PATCH 15/16] In Split(), fix removal from a set being iterated, leading to exception at study restoration if there are intersecting groups --- src/DriverMED/DriverMED_Family.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/DriverMED/DriverMED_Family.cxx b/src/DriverMED/DriverMED_Family.cxx index 34ff2c20b..d9ff5b249 100644 --- a/src/DriverMED/DriverMED_Family.cxx +++ b/src/DriverMED/DriverMED_Family.cxx @@ -350,14 +350,16 @@ void DriverMED_Family::Split (DriverMED_FamilyPtr by, { // Elements set::iterator anIter = by->myElements.begin(); - for (; anIter != by->myElements.end(); anIter++) + while ( anIter != by->myElements.end()) { if (myElements.find(*anIter) != myElements.end()) { common->myElements.insert(*anIter); myElements.erase(*anIter); - by->myElements.erase(*anIter); + by->myElements.erase(anIter++); } + else + anIter++; } if (!common->IsEmpty()) -- 2.30.2 From 07b6737459f0b1fd686320cd11ab537c4d7468d9 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 26 Jan 2005 15:17:35 +0000 Subject: [PATCH 16/16] Changes according MEDWrapper API modifications --- src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index 74490377a..edd5418c4 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -384,7 +384,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() SMDS_MED_ENTITY = eARETE; #endif SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); - TInt aNbConnectivity = MED::GetNbConnectivities(eSEG2); + TInt aNbConnectivity = MED::GetNbNodes(eSEG2); MED::TIntVector anElemNums(aNbElems); MED::TIntVector aFamilyNums(aNbElems); MED::TIntVector aConnectivity(aNbElems*aNbConnectivity); @@ -424,7 +424,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() #ifdef _ELEMENTS_BY_DIM_ SMDS_MED_ENTITY = eFACE; #endif - TInt aNbTriaConn = MED::GetNbConnectivities(eTRIA3); + TInt aNbTriaConn = MED::GetNbNodes(eTRIA3); MED::TIntVector anTriaElemNums; anTriaElemNums.reserve(aNbElems); MED::TIntVector aTriaFamilyNums; @@ -432,7 +432,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector aTriaConn; aTriaConn.reserve(aNbElems*aNbTriaConn); - TInt aNbQuadConn = MED::GetNbConnectivities(eQUAD4); + TInt aNbQuadConn = MED::GetNbNodes(eQUAD4); MED::TIntVector aQuadElemNums; aQuadElemNums.reserve(aNbElems); MED::TIntVector aQuadFamilyNums; @@ -531,7 +531,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() #ifdef _ELEMENTS_BY_DIM_ SMDS_MED_ENTITY = eMAILLE; #endif - TInt aNbTetraConn = MED::GetNbConnectivities(eTETRA4); + TInt aNbTetraConn = MED::GetNbNodes(eTETRA4); MED::TIntVector anTetraElemNums; anTetraElemNums.reserve(aNbElems); MED::TIntVector aTetraFamilyNums; @@ -539,7 +539,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector aTetraConn; aTetraConn.reserve(aNbElems*aNbTetraConn); - TInt aNbPyraConn = MED::GetNbConnectivities(ePYRA5); + TInt aNbPyraConn = MED::GetNbNodes(ePYRA5); MED::TIntVector anPyraElemNums; anPyraElemNums.reserve(aNbElems); MED::TIntVector aPyraFamilyNums; @@ -547,7 +547,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector aPyraConn; aPyraConn.reserve(aNbElems*aNbPyraConn); - TInt aNbPentaConn = MED::GetNbConnectivities(ePENTA6); + TInt aNbPentaConn = MED::GetNbNodes(ePENTA6); MED::TIntVector anPentaElemNums; anPentaElemNums.reserve(aNbElems); MED::TIntVector aPentaFamilyNums; @@ -555,7 +555,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() MED::TIntVector aPentaConn; aPentaConn.reserve(aNbElems*aNbPentaConn); - TInt aNbHexaConn = MED::GetNbConnectivities(eHEXA8); + TInt aNbHexaConn = MED::GetNbNodes(eHEXA8); MED::TIntVector aHexaElemNums; aHexaElemNums.reserve(aNbElems); MED::TIntVector aHexaFamilyNums; -- 2.30.2