X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_ElementFactory.hxx;h=5fb6b3b4a1c05c353e0d9842c882657339d6e712;hb=46c12766bce7d48c0c9ecc772b47ba12a18afb6b;hp=b25b635c8af09718731fc1d08cfece7a4f9d1c2c;hpb=4c16067d4281f56bd07d3f92fb63fff9c0c1d169;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_ElementFactory.hxx b/src/SMDS/SMDS_ElementFactory.hxx index b25b635c8..5fb6b3b4a 100644 --- a/src/SMDS/SMDS_ElementFactory.hxx +++ b/src/SMDS/SMDS_ElementFactory.hxx @@ -108,8 +108,12 @@ public: //! Return an iterator on all element assigned to a given shape. // nbElemsToReturn is used to optimize by stopping the iteration as soon as // all elements assigned to the shape encountered. + // sm1stElem is used to quickly find the first chunk holding elements of the shape; + // it must have smallest ID between elements on the shape template< class ElemIterator > - boost::shared_ptr< ElemIterator > GetShapeIterator( int shapeID, size_t nbElemsToReturn ); + boost::shared_ptr< ElemIterator > GetShapeIterator( int shapeID, + size_t nbElemsToReturn, + const SMDS_MeshElement* sm1stElem ); //! Mark the element as non-used void Free( const SMDS_MeshElement* ); @@ -231,9 +235,9 @@ struct _RangeSet { bool isFound = false; - if ( sizeof( attr_t ) == sizeof( int ) && theMinValue ) - if ( theValue < *theMinValue || theValue > *theMaxValue ) - return isFound; + // if ( sizeof( attr_t ) == sizeof( int ) && theMinValue ) + // if ( theValue < *theMinValue || theValue > *theMaxValue ) + // return isFound; for ( set_iterator it = mySet.begin(); it < mySet.end(); ++it ) { @@ -266,8 +270,13 @@ struct _RangeSet */ attr_t SetValue( int theIndex, attr_t theValue ) { - set_iterator rNext = mySet.upper_bound( theIndex ); + set_iterator rNext = mySet.end(); // case of adding elements set_iterator r = rNext - 1; + if ( r->my1st > theIndex ) + { + rNext = mySet.upper_bound( theIndex ); + r = rNext - 1; + } int rSize = Size( r ); // range size attr_t rValue = r->myValue; if ( rValue == theValue ) @@ -347,7 +356,9 @@ typedef _Range< bool > _UsedRange; // range of used elements typedef _RangeSet< _ShapeIDRange > TSubIDRangeSet; typedef _RangeSet< _UsedRange > TUsedRangeSet; typedef boost::dynamic_bitset<> TBitSet; -typedef float TParam; +//typedef float TParam; +typedef double TParam; +//typedef std::unordered_set TSubIDSet; //------------------------------------------------------------------------------------ /*! @@ -363,8 +374,9 @@ class SMDS_ElementChunk TBitSet myMarkedSet; // mark some elements TUsedRangeSet myUsedRanges; // ranges of used/unused elements TSubIDRangeSet mySubIDRanges; // ranges of elements on the same sub-shape - int myMinSubID; // min sub-shape ID - int myMaxSubID; // max sub-shape ID + //TSubIDSet* mySubIDSet; // set of sub-shape IDs + // int myMinSubID; // min sub-shape ID + // int myMaxSubID; // max sub-shape ID std::vector myPositions; // UV parameters on shape: 2*param_t per an element public: @@ -406,7 +418,7 @@ public: //! Return ranges of elements assigned to sub-shapes and min/max of sub-shape IDs const TSubIDRangeSet& GetSubIDRangesMinMax( int& min, int& max ) const - { min = myMinSubID; max = myMaxSubID; return mySubIDRanges; } + { /*min = myMinSubID; max = myMaxSubID;*/ return mySubIDRanges; } //! Minimize allocated memory void Compact(); @@ -463,11 +475,12 @@ struct _ChunkIterator : public ELEM_ITERATOR get_rangeset_fun theGetRangeSetFun, attr_type theAttrValue, SMDS_MeshElement::Filter* theFilter, - size_t theNbElemsToReturn = -1): + size_t theNbElemsToReturn = -1, + int theChunkIndex = 0): myElement( 0 ), myRangeIndex( 0 ), myChunks( theChunks ), - myChunkIndex( -1 ), + myChunkIndex( theChunkIndex-1 ), myGetRangeSetFun( theGetRangeSetFun ), myValue( theAttrValue ), myFilter( theFilter ), @@ -546,14 +559,18 @@ SMDS_ElementFactory::GetIterator( SMDS_MeshElement::Filter* filter, template< class ElemIterator > boost::shared_ptr< ElemIterator > -SMDS_ElementFactory::GetShapeIterator( int shapeID, size_t nbElemsToReturn ) +SMDS_ElementFactory::GetShapeIterator( int shapeID, + size_t nbElemsToReturn, + const SMDS_MeshElement* sm1stElem ) { + int iChunk = sm1stElem ? (( sm1stElem->GetID() - 1 ) / ChunkSize()) : 0; typedef _ChunkIterator< ElemIterator, TSubIDRangeSet > TChuckIterator; return boost::make_shared< TChuckIterator >( myChunks, & SMDS_ElementChunk::GetSubIDRangesMinMax, /*shapeID=*/shapeID, new SMDS_MeshElement::NonNullFilter(), - nbElemsToReturn ); + nbElemsToReturn, + iChunk ); } #endif