X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FDriverMED%2FDriverMED_Family.cxx;h=25646c67c45a768ae471f0ae52ead8a38a70ef78;hp=0da2c4cffa942131a326e1a762c981e705cd08ed;hb=64c772da5a9dd285f16f1f7efa07bb4c7fbdd4c3;hpb=4ff5bd61540272713e48de1eee75625028c32155 diff --git a/src/DriverMED/DriverMED_Family.cxx b/src/DriverMED/DriverMED_Family.cxx index 0da2c4cff..25646c67c 100644 --- a/src/DriverMED/DriverMED_Family.cxx +++ b/src/DriverMED/DriverMED_Family.cxx @@ -16,7 +16,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -129,6 +129,16 @@ DriverMED_Family return myElements.empty(); } +bool CompareColors( const SALOMEDS::Color& theColor, const SALOMEDS::Color& theRefColor ) +{ + if( fabs( theColor.R - theRefColor.R ) < 0.01 && + fabs( theColor.G - theRefColor.G ) < 0.01 && + fabs( theColor.B - theRefColor.B ) < 0.01 ) + return true; + + return false; +} + //============================================================================= /*! * Split each group from list on some parts (families) @@ -201,11 +211,37 @@ DriverMED_Family } // Process groups - SMESHDS_GroupBasePtrList::const_iterator aGroupsIter = theGroups.begin(); - for (; aGroupsIter != theGroups.end(); aGroupsIter++) + SMESHDS_GroupBasePtrList::const_iterator aGroupsIter; + + int id = 0; + ColorMap aColorMap; + for (aGroupsIter = theGroups.begin(); aGroupsIter != theGroups.end(); aGroupsIter++) + { + Quantity_Color aQColor = (*aGroupsIter)->GetColor(); + SALOMEDS::Color aColor; + aColor.R = aQColor.Red(); + aColor.G = aQColor.Green(); + aColor.B = aQColor.Blue(); + + bool isFound = false; + for (ColorMap::iterator aColorIter = aColorMap.begin(); aColorIter != aColorMap.end(); aColorIter++) + { + SALOMEDS::Color aRefColor = aColorIter->second; + if( CompareColors( aColor, aRefColor ) ) + { + isFound = true; + break; + } + } + + if( !isFound ) + aColorMap[ id++ ] = aColor; + } + + for (aGroupsIter = theGroups.begin(); aGroupsIter != theGroups.end(); aGroupsIter++) { DriverMED_FamilyPtr aFam2 (new DriverMED_Family); - aFam2->Init(*aGroupsIter); + aFam2->Init(*aGroupsIter, aColorMap); DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin(); while (aFamsIter != aFamilies.end()) @@ -321,7 +357,7 @@ DriverMED_Family::GetFamilyInfo(const MED::PWrapper& theWrapper, MED::PFamilyInfo anInfo; string aValue = aStr.str(); - if(myId == 0){ + if(myId == 0 || myGroupAttributVal == 0){ anInfo = theWrapper->CrFamilyInfo(theMeshInfo, aValue, myId, @@ -329,8 +365,7 @@ DriverMED_Family::GetFamilyInfo(const MED::PWrapper& theWrapper, }else{ MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description, MED::TIntVector anAttrIds (1, myId); // Id=0, - MED::TIntVector anAttrVals (1); - anAttrVals[0] = myGroupAttributVal != 0? myGroupAttributVal: myId; + MED::TIntVector anAttrVals (1, myGroupAttributVal); anInfo = theWrapper->CrFamilyInfo(theMeshInfo, aValue, myId, @@ -365,7 +400,7 @@ DriverMED_Family::GetFamilyInfo(const MED::PWrapper& theWrapper, * Initialize the tool by SMESHDS_GroupBase */ //============================================================================= -void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup) +void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup, const ColorMap& theColorMap) { // Elements myElements.clear(); @@ -384,11 +419,22 @@ void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup) myGroupAttributVal = 0; - if (theGroup->GetColorGroup()!=0) + ColorMap::const_iterator aColorIter = theColorMap.begin(); + for (; aColorIter != theColorMap.end(); aColorIter++) + { + Quantity_Color aGroupQColor = theGroup->GetColor(); + SALOMEDS::Color aGroupColor; + aGroupColor.R = aGroupQColor.Red(); + aGroupColor.G = aGroupQColor.Green(); + aGroupColor.B = aGroupQColor.Blue(); + + SALOMEDS::Color aColor = aColorIter->second; + if( CompareColors( aGroupColor, aColor ) ) { - myGroupAttributVal = theGroup->GetColorGroup(); + myGroupAttributVal = aColorIter->first; + break; } - + } } //=============================================================================