From 409c15e89f56f7d521fbe0eb881f572c63478620 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 17 Sep 2018 22:16:50 +0300 Subject: [PATCH] 23586: [EDF] HYDRO: Copy mesh to new geometry --- idl/BLSURFPlugin_Algorithm.idl | 24 -- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 64 +++- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 25 +- .../BLSURFPlugin_Hypothesis_i.cxx | 311 +++++++++++++----- .../BLSURFPlugin_Hypothesis_i.hxx | 30 +- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 9 +- 6 files changed, 312 insertions(+), 151 deletions(-) diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index e02d105..59f8dfc 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -674,32 +674,8 @@ module BLSURFPlugin /*! * Sets the file for export resulting mesh in GMF format */ -// void SetGMFFile(in string theFileName, in boolean isBinary); void SetGMFFile(in string theFileName); string GetGMFFile(); -// boolean GetGMFFileMode(); - - // - // Obsolete methods - To be removed in V7 - // - void SetPhyMin(in double theMinSize); - double GetPhyMin(); - void SetPhyMax(in double theMaxSize); - double GetPhyMax(); - void SetGeoMin(in double theMinSize); - double GetGeoMin(); - void SetGeoMax(in double theMaxSize); - double GetGeoMax(); - void SetAngleMeshS(in double angle); - double GetAngleMeshS(); - void SetAngleMeshC(in double angle); - double GetAngleMeshC(); - void SetDecimesh(in boolean toIgnoreEdges); - boolean GetDecimesh(); - void SetPreCADRemoveNanoEdges(in boolean toRemoveNanoEdges); - boolean GetPreCADRemoveNanoEdges(); - void SetPreCADEpsNano(in double epsNano); - double GetPreCADEpsNano(); }; }; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 5472398..b17921d 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -1444,16 +1444,10 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, // //////// CREATE //////////// if (toCreate) { toNotify = true; - _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex); - _enfVertexList.insert(newEnfVertex); - if (theVertexEntry == "") { - _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords); - _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex; - } - else { - _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry); - _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex; - } + AddEnforcedVertex( theFaceEntry, newEnfVertex ); + } + else { + delete newEnfVertex; } if (toNotify) @@ -1462,6 +1456,27 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, return toNotify; } +//======================================================================= +//function : AddEnforcedVertex +//======================================================================= + +void BLSURFPlugin_Hypothesis::AddEnforcedVertex( const TEntry& faceEntry, + TEnfVertex * newEnfVertex ) +{ + if ( newEnfVertex ) + { + _faceEntryEnfVertexListMap[faceEntry].insert(newEnfVertex); + _enfVertexList.insert(newEnfVertex); + if ( newEnfVertex->geomEntry.empty() ) { + _faceEntryCoordsListMap[faceEntry].insert(newEnfVertex->coords); + _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex; + } + else { + _faceEntryEnfVertexEntryListMap[faceEntry].insert(newEnfVertex->geomEntry); + _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex; + } + } +} //======================================================================= //function : GetEnforcedVertices @@ -1706,18 +1721,25 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) //======================================================================= //function : ClearAllEnforcedVertices //======================================================================= -void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() { +void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() +{ _faceEntryEnfVertexListMap.clear(); - _enfVertexList.clear(); _faceEntryCoordsListMap.clear(); _coordsEnfVertexMap.clear(); _faceEntryEnfVertexEntryListMap.clear(); _enfVertexEntryEnfVertexMap.clear(); + + TEnfVertexList::iterator it_enfVertex = _enfVertexList.begin(); + for ( ; it_enfVertex != _enfVertexList.end(); ++it_enfVertex ) + delete *it_enfVertex; + _enfVertexList.clear(); + // Enable internal enforced vertices on specific face if requested by user // _faceEntryInternalVerticesList.clear(); NotifySubMeshesHypothesisModification(); } + //================================================================================ /*! * \brief Return the enforced vertices @@ -2821,7 +2843,7 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) break; isOK = static_cast(load >> newAtShapeEntry); if (!isOK) - break; + break; isOK = static_cast(load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step); } if (isOK) { @@ -2981,6 +3003,22 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) } } + if ( hasEnforcedVertex ) { + isOK = static_cast(load >> option_or_sm); + if (isOK) { + if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__") + hasPreCADFacesPeriodicity = true; + else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__") + hasPreCADEdgesPeriodicity = true; + else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__") + hasFacesPeriodicity = true; + else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__") + hasEdgesPeriodicity = true; + else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__") + hasVerticesPeriodicity = true; + } + } + // PERIODICITY if (hasPreCADFacesPeriodicity) diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 390b2f0..b485629 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -373,15 +373,16 @@ public: bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument); void ClearAllEnforcedVertices(); + void AddEnforcedVertex( const TEntry& theFaceEntry, TEnfVertex * theEnfVertex ); - const TFaceEntryEnfVertexListMap _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; } - const TEnfVertexList _GetAllEnforcedVertices() const { return _enfVertexList; } + const TFaceEntryEnfVertexListMap& _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; } + const TEnfVertexList& _GetAllEnforcedVertices() const { return _enfVertexList; } - const TFaceEntryCoordsListMap _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; } - const TCoordsEnfVertexMap _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; } + const TFaceEntryCoordsListMap& _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; } + const TCoordsEnfVertexMap& _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; } - const TFaceEntryEnfVertexEntryListMap _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; } - const TEnfVertexEntryEnfVertexMap _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; } + const TFaceEntryEnfVertexEntryListMap& _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; } + const TEnfVertexEntryEnfVertexMap& _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; } // TODO GROUPS // const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; } @@ -480,23 +481,23 @@ public: // const TPreCadPeriodicityEntriesVector _GetPreCadFacesPeriodicityEntries() const { return _preCadFacesPeriodicityEntriesVector; } static TPreCadPeriodicityVector GetDefaultPreCadFacesPeriodicityVector() { return TPreCadPeriodicityVector(); } - const TPreCadPeriodicityVector _GetPreCadFacesPeriodicityVector() const { return _preCadFacesPeriodicityVector; } + const TPreCadPeriodicityVector& _GetPreCadFacesPeriodicityVector() const { return _preCadFacesPeriodicityVector; } static TPreCadPeriodicityVector GetPreCadFacesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp); static TPreCadPeriodicityVector GetDefaultPreCadEdgesPeriodicityVector() { return TPreCadPeriodicityVector(); } - const TPreCadPeriodicityVector _GetPreCadEdgesPeriodicityVector() const { return _preCadEdgesPeriodicityVector; } + const TPreCadPeriodicityVector& _GetPreCadEdgesPeriodicityVector() const { return _preCadEdgesPeriodicityVector; } static TPreCadPeriodicityVector GetPreCadEdgesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp); static TFacesPeriodicityVector GetDefaultFacesPeriodicityVector() { return TFacesPeriodicityVector(); } - const TFacesPeriodicityVector _GetFacesPeriodicityVector() const { return _facesPeriodicityVector; } + const TFacesPeriodicityVector& _GetFacesPeriodicityVector() const { return _facesPeriodicityVector; } static TFacesPeriodicityVector GetFacesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp); static TEdgesPeriodicityVector GetDefaultEdgesPeriodicityVector() { return TEdgesPeriodicityVector(); } - const TEdgesPeriodicityVector _GetEdgesPeriodicityVector() const { return _edgesPeriodicityVector; } + const TEdgesPeriodicityVector& _GetEdgesPeriodicityVector() const { return _edgesPeriodicityVector; } static TEdgesPeriodicityVector GetEdgesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp); static TVerticesPeriodicityVector GetDefaultVerticesPeriodicityVector() { return TVerticesPeriodicityVector(); } - const TVerticesPeriodicityVector _GetVerticesPeriodicityVector() const { return _verticesPeriodicityVector; } + const TVerticesPeriodicityVector& _GetVerticesPeriodicityVector() const { return _verticesPeriodicityVector; } static TVerticesPeriodicityVector GetVerticesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp); void ClearPreCadPeriodicityVectors(); @@ -605,8 +606,6 @@ private: TSizeMap _sizeMap; TSizeMap _attractors; TAttractorMap _classAttractors; - TSizeMap _attEntry; - TParamsMap _attParams; TFaceEntryEnfVertexListMap _faceEntryEnfVertexListMap; TEnfVertexList _enfVertexList; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index eacff52..cb34600 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -1742,7 +1742,7 @@ void BLSURFPlugin_Hypothesis_i::SetConstantSizeMapEntry(const char* entry, GEOM: THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } if (valueChanged) - SMESH::TPythonDump() << _this() << ".SetConstantSizeMap(" << entry << ", '" << sizeMap << "' )"; + SMESH::TPythonDump() << _this() << ".SetConstantSizeMap(" << entry << ", " << sizeMap << " )"; } //============================================================================= @@ -2943,7 +2943,6 @@ bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexGeom(GEOM::GEOM_Object_ptr theV string theVertexEntry = theVertex->GetStudyEntry(); GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); string aName; if (theVertexEntry.empty()) { @@ -3011,7 +3010,6 @@ bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexGeomWithGroup(GEOM::GEOM_Object string theVertexEntry = theVertex->GetStudyEntry(); GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); string aName; if (theVertexEntry.empty()) { @@ -3053,7 +3051,6 @@ bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr t std::string theVertexEntry = theVertex->GetStudyEntry(); GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); string aName; if (theVertexEntry.empty()) { @@ -3845,85 +3842,249 @@ char* BLSURFPlugin_Hypothesis_i::GetGMFFile() { //================================================================================ /*! - * \brief Verify whether hypothesis supports given entity type + * \brief Verify whether hypothesis supports given entity type * \param type - dimension (see SMESH::Dimension enumeration) * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise - * + * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ -//================================================================================ +//================================================================================ CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported(SMESH::Dimension type) { return type == SMESH::DIM_2D; } -// -// Obsolete methods - To be removed in V7 -// -void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize) { - this->SetMinSize(theMinSize); -} -CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin() { - return this->GetMinSize(); -} -void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize) { - this->SetMaxSize(theMaxSize); -} -CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax() { - return this->GetMaxSize(); -} -void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize) { - this->SetMinSize(theMinSize); -} -CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin() { - return this->GetMinSize(); -} -void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize) { - this->SetMaxSize(theMaxSize); -} -CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax() { - return this->GetMaxSize(); -} -void BLSURFPlugin_Hypothesis_i::SetAngleMeshS(CORBA::Double theValue) { - this->SetAngleMesh(theValue); -} -CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS() { - return this->GetAngleMesh(); -} -void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double theValue) { - this->SetAngleMesh(theValue); -} -CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC() { - return this->GetAngleMesh(); -} -void BLSURFPlugin_Hypothesis_i::SetDecimesh(CORBA::Boolean theValue) { - std::string theValueStr = theValue ? "1" : "0"; - this->SetOptionValue("respect_geometry",theValueStr.c_str()); -} -CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh() { - std::string theValueStr = this->GetOptionValue("respect_geometry"); - if (theValueStr.empty() || theValueStr == "respect") - return true; - return false; -} -void BLSURFPlugin_Hypothesis_i::SetPreCADRemoveNanoEdges(CORBA::Boolean theValue) { - std::string theValueStr = theValue ? "1" : "0"; - this->AddPreCADOption("remove_tiny_edges",theValueStr.c_str()); -} -CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADRemoveNanoEdges() { - std::string theValueStr = this->GetPreCADOption("remove_tiny_edges"); - if (theValueStr == "1") - return true; - return false; -} -void BLSURFPlugin_Hypothesis_i::SetPreCADEpsNano(CORBA::Double theValue) { - std::ostringstream theValueStr; - theValueStr << theValue; - this->AddPreCADOption("tiny_edge_length",theValueStr.str().c_str()); +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +BLSURFPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + typedef ::BLSURFPlugin_Hypothesis BH; + const BH* impl = static_cast( myBaseImpl ); + + { + const BH::TSizeMap& sizeMap = impl->_GetSizeMapEntries(); + BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin(); + for ( ; entry2size != sizeMap.cend(); ++entry2size ) + entryArray.push_back( entry2size->first ); + } + { + const BH::TSizeMap& sizeMap = impl->_GetAttractorEntries(); + BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin(); + for ( ; entry2size != sizeMap.cend(); ++entry2size ) + entryArray.push_back( entry2size->first ); + } + { + const BH::TAttractorMap& classAttractors = impl-> _GetClassAttractorEntries(); + BH::TAttractorMap::const_iterator entry2size = classAttractors.cbegin(); + for ( ; entry2size != classAttractors.cend(); ++entry2size ) + entryArray.push_back( entry2size->first ); + } + { + const BH::TFaceEntryEnfVertexListMap& faceEntryEnfVertexListMap = impl->_GetAllEnforcedVerticesByFace(); + BH::TFaceEntryEnfVertexListMap::const_iterator entry2evList = faceEntryEnfVertexListMap.cbegin(); + for ( ; entry2evList != faceEntryEnfVertexListMap.cend(); ++entry2evList ) + { + entryArray.push_back( entry2evList->first ); + + const BH::TEnfVertexList& evList = entry2evList->second; + BH::TEnfVertexList::const_iterator evIt = evList.cbegin(); + for ( ; evIt != evList.cend(); ++evIt ) + { + const BH::TEnfVertex* ev = *evIt; + entryArray.push_back( ev->geomEntry ); + entryArray.insert( entryArray.end(), ev->faceEntries.cbegin(), ev->faceEntries.cend() ); + } + } + } + // { // duplicated data of faceEntryEnfVertexListMap + // const BH::TEnfVertexList& enfVertexList = impl->_GetAllEnforcedVertices(); + // const BH::TFaceEntryCoordsListMap& faceEntryCoordsListMap = impl->_GetAllCoordsByFace(); + // const BH::TFaceEntryEnfVertexEntryListMap& faceEntryEnfVertexEntryListMap = impl->_GetAllEnfV // const BH::TEnfVertexEntryEnfVertexMap& enfVertexEntryEnfVertexMap = impl->_GetAllEnforcedVert // } + { + const BH::TPreCadPeriodicityVector& preCadFacesPeriodicityVector = impl->_GetPreCadFacesPeriodicityVector(); + BH::TPreCadPeriodicityVector::const_iterator pcp = preCadFacesPeriodicityVector.cbegin(); + for ( ; pcp != preCadFacesPeriodicityVector.cend(); ++pcp ) + { + entryArray.push_back( pcp->shape1Entry ); + entryArray.push_back( pcp->shape2Entry ); + entryArray.insert( entryArray.end(), + pcp->theSourceVerticesEntries.cbegin(), + pcp->theSourceVerticesEntries.cend() ); + entryArray.insert( entryArray.end(), + pcp->theTargetVerticesEntries.cbegin(), + pcp->theTargetVerticesEntries.cend() ); + } + } + { + const BH::TPreCadPeriodicityVector& preCadEdgesPeriodicityVector = impl->_GetPreCadEdgesPeriodicityVector(); + BH::TPreCadPeriodicityVector::const_iterator pcp = preCadEdgesPeriodicityVector.cbegin(); + for ( ; pcp != preCadEdgesPeriodicityVector.cend(); ++pcp ) + { + entryArray.push_back( pcp->shape1Entry ); + entryArray.push_back( pcp->shape2Entry ); + entryArray.insert( entryArray.end(), + pcp->theSourceVerticesEntries.cbegin(), + pcp->theSourceVerticesEntries.cend() ); + entryArray.insert( entryArray.end(), + pcp->theTargetVerticesEntries.cbegin(), + pcp->theTargetVerticesEntries.cend() ); + } + } + { + const BH::THyperPatchList& hyperPatchList = impl->GetHyperPatches(); + BH::THyperPatchList::const_iterator idSet = hyperPatchList.cbegin(); + for ( ; idSet != hyperPatchList.cend(); ++idSet ) + { + subIDArray.insert( subIDArray.end(), idSet->cbegin(), idSet->cend() ); + } + } + return true; } -CORBA::Double BLSURFPlugin_Hypothesis_i::GetPreCADEpsNano() { - std::istringstream theValueStr(this->GetPreCADOption("tiny_edge_length")); - double result; - theValueStr >> result; - return result; + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +BLSURFPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + typedef ::BLSURFPlugin_Hypothesis BH; + BH* impl = static_cast( myBaseImpl ); + + size_t iEnt = 0; + { + BH::TSizeMap& sizeMapNew = const_cast< BH::TSizeMap& >( impl->_GetSizeMapEntries() ); + BH::TSizeMap sizeMap; + sizeMap.swap( sizeMapNew ); + BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin(); + for ( ; entry2size != sizeMap.cend(); ++entry2size, ++iEnt ) + if ( entryArray[ iEnt ].empty() == entry2size->first.empty() ) + sizeMapNew[ entryArray[ iEnt ]] = entry2size->second; + } + { + BH::TSizeMap& sizeMapNew = const_cast< BH::TSizeMap& >( impl->_GetAttractorEntries() ); + BH::TSizeMap sizeMap; + sizeMap.swap( sizeMapNew ); + BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin(); + for ( ; entry2size != sizeMap.cend(); ++entry2size, ++iEnt ) + if ( entryArray[ iEnt ].empty() == entry2size->first.empty() ) + sizeMapNew[ entryArray[ iEnt ]] = entry2size->second; + } + { + BH::TAttractorMap& attrMapNew = + const_cast< BH::TAttractorMap& > ( impl->_GetClassAttractorEntries() ); + BH::TAttractorMap attrMap; + attrMap.swap( attrMapNew ); + BH::TAttractorMap::const_iterator entry2size = attrMap.cbegin(); + for ( ; entry2size != attrMap.cend(); ++entry2size, ++iEnt ) + if ( entryArray[ iEnt ].empty() == entry2size->first.empty() ) + attrMapNew.insert( std::make_pair( entryArray[ iEnt ], entry2size->second )); + else + delete entry2size->second; + } + { + BH::TFaceEntryEnfVertexListMap& faceEntryEnfVertexListMapNew = + const_cast< BH::TFaceEntryEnfVertexListMap& >( impl->_GetAllEnforcedVerticesByFace() ); + BH::TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap; + faceEntryEnfVertexListMap.swap( faceEntryEnfVertexListMapNew ); + + BH::TEnfVertexList& enfVertexList = + const_cast< BH::TEnfVertexList& > ( impl->_GetAllEnforcedVertices() ); + enfVertexList.clear(); // avoid removal + + impl->ClearAllEnforcedVertices(); + + BH::TFaceEntryEnfVertexListMap::iterator entry2evList = faceEntryEnfVertexListMap.begin(); + for ( ; entry2evList != faceEntryEnfVertexListMap.end(); ++entry2evList ) + { + const BH::TEntry& entry = entryArray[ iEnt++ ]; + bool faceOk = ( entry.empty() == entry2evList->first.empty() ); + + BH::TEnfVertexList& evList = entry2evList->second; + BH::TEnfVertexList::iterator evIt = evList.begin(); + for ( ; evIt != evList.end(); ++evIt ) + { + BH::TEnfVertex* ev = *evIt; + bool ok = faceOk && ( ev->geomEntry.empty() != entryArray[ iEnt ].empty() ); + ev->geomEntry = entryArray[ iEnt++ ]; + BH::TEntryList faceEntriesNew; + BH::TEntryList::iterator fEnt = ev->faceEntries.begin(); + for ( ; fEnt != ev->faceEntries.end(); ++fEnt, ++iEnt ) + { + if ( !entryArray[ iEnt ].empty() ) + faceEntriesNew.insert( entryArray[ iEnt ]); + } + if ( ok ) + { + ev->faceEntries.swap( faceEntriesNew ); + impl->AddEnforcedVertex( entry, ev ); + } + else + { + delete ev; + } + } + } + } + { + BH::TPreCadPeriodicityVector& preCadPeriodicityVector = + const_cast< BH::TPreCadPeriodicityVector&> ( impl->_GetPreCadFacesPeriodicityVector() ); + BH::TPreCadPeriodicityVector::iterator pcp = preCadPeriodicityVector.begin(); + for ( ; pcp != preCadPeriodicityVector.end(); ++pcp ) + { + pcp->shape1Entry = entryArray[ iEnt++ ]; + pcp->shape2Entry = entryArray[ iEnt++ ]; + for ( size_t i = 0; i < pcp->theSourceVerticesEntries.size(); ++i, iEnt++ ) + pcp->theSourceVerticesEntries[i] = entryArray[ iEnt ]; + + for ( size_t i = 0; i < pcp->theTargetVerticesEntries.size(); ++i, iEnt++ ) + pcp->theTargetVerticesEntries[i] = entryArray[ iEnt ]; + } + } + { + BH::TPreCadPeriodicityVector& preCadPeriodicityVector = + const_cast< BH::TPreCadPeriodicityVector&> ( impl->_GetPreCadEdgesPeriodicityVector() ); + BH::TPreCadPeriodicityVector::iterator pcp = preCadPeriodicityVector.begin(); + for ( ; pcp != preCadPeriodicityVector.end(); ++pcp ) + { + pcp->shape1Entry = entryArray[ iEnt++ ]; + pcp->shape2Entry = entryArray[ iEnt++ ]; + for ( size_t i = 0; i < pcp->theSourceVerticesEntries.size(); ++i, iEnt++ ) + pcp->theSourceVerticesEntries[i] = entryArray[ iEnt ]; + + for ( size_t i = 0; i < pcp->theTargetVerticesEntries.size(); ++i, iEnt++ ) + pcp->theTargetVerticesEntries[i] = entryArray[ iEnt ]; + } + } + + size_t iID = 0; + { + BH::THyperPatchList& hyperPatchListNew = + const_cast< BH::THyperPatchList& >( impl->GetHyperPatches() ); + BH::THyperPatchList hyperPatchList; + hyperPatchList.swap( hyperPatchListNew ); + BH::THyperPatchList::iterator idSet = hyperPatchList.begin(); + for ( ; idSet != hyperPatchList.end(); ++idSet ) + { + BH::THyperPatchTags& ids = *idSet; + BH::THyperPatchTags idsNew; + BH::THyperPatchTags::iterator i = ids.begin(); + for ( ; i != ids.end(); ++i, ++iID ) + if ( subIDArray[ iID ] > 0 ) + idsNew.insert( subIDArray[ iID ]); + if ( !idsNew.empty() ) + hyperPatchListNew.push_back( idsNew ); + } + } + + return ( iEnt == entryArray.size() && iID == subIDArray.size() ); } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index 7024bbf..2851a88 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -408,28 +408,16 @@ public: CORBA::Boolean IsDimSupported(SMESH::Dimension type); - // - // Obsolete methods - To be removed in V7 - // - void SetPhyMin(CORBA::Double theMinSize); - CORBA::Double GetPhyMin(); - void SetPhyMax(CORBA::Double theMaxSize); - CORBA::Double GetPhyMax(); - void SetGeoMin(CORBA::Double theMinSize); - CORBA::Double GetGeoMin(); - void SetGeoMax(CORBA::Double theMaxSize); - CORBA::Double GetGeoMax(); - void SetAngleMeshS(CORBA::Double angle); - CORBA::Double GetAngleMeshS(); - void SetAngleMeshC(CORBA::Double angle); - CORBA::Double GetAngleMeshC(); - void SetDecimesh(CORBA::Boolean toIgnoreEdges); - CORBA::Boolean GetDecimesh(); - void SetPreCADRemoveNanoEdges(CORBA::Boolean toRemoveNanoEdges); - CORBA::Boolean GetPreCADRemoveNanoEdges(); - void SetPreCADEpsNano(CORBA::Double epsNano); - CORBA::Double GetPreCADEpsNano(); + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); private: /////////////////////// // PERIODICITY // diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index ecd3942..1e1f463 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -1298,7 +1298,6 @@ void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() { myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1); if (myEnfVertex->GetShapeType() == GEOM::VERTEX) { - BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations(); if (CORBA::is_nil(measureOp)) return; @@ -1449,8 +1448,6 @@ This method is called when a item is added into the enforced vertices tree widge */ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() { - BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - getGeomSelectionTool()->selectionMgr()->clearFilters(); myEnfVertexWdg->deactivateSelection(); @@ -2194,14 +2191,16 @@ void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothes { periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in(); periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in(); - periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in(); + if ( onFace ) + periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in(); } if (targetVertices.length()!=0) { periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in(); periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in(); - periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in(); + if ( onFace ) + periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in(); } if (onFace) -- 2.39.2