Version: 9.16.0
SMDS_ElementFactory.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
6// This library is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 2.1 of the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22// File : SMDS_ElementFactory.hxx
23// Module : SMESH
24//
25#ifndef _SMDS_ElementFactory_HeaderFile
26#define _SMDS_ElementFactory_HeaderFile
27
28#include "SMDS_MeshCell.hxx"
29#include "SMDS_Position.hxx"
30
31#include <Utils_SALOME_Exception.hxx>
32
33#include <boost/container/flat_set.hpp>
34#include <boost/dynamic_bitset.hpp>
35#include <boost/make_shared.hpp>
36#include <boost/ptr_container/ptr_vector.hpp>
37#include <boost/shared_ptr.hpp>
38
39#include <set>
40
41#include <vtkType.h>
42
43#include <smIdType.hxx>
44
46class SMDS_Mesh;
47class SMDS_MeshCell;
48class SMDS_MeshNode;
49
51 bool operator () (const SMDS_ElementChunk* c1, const SMDS_ElementChunk* c2) const;
52};
53typedef boost::ptr_vector<SMDS_ElementChunk> TChunkVector;
54typedef std::set<SMDS_ElementChunk*,_ChunkCompare> TChunkPtrSet;
55
56//------------------------------------------------------------------------------------
65{
66protected:
67 bool myIsNodal; // what to allocate: nodes or cells
69 TChunkVector myChunks; // array of chunks of elements
70 TChunkPtrSet myChunksWithUnused; // sorted chunks having unused elements
71 std::vector< vtkIdType > myVtkIDs; // myVtkIDs[ smdsID-1 ] == vtkID
72 std::vector< smIdType > mySmdsIDs; // mySmdsIDs[ vtkID ] == smdsID - 1
73 smIdType myNbUsedElements; // counter of elements
74
75 friend class SMDS_ElementChunk;
76
77public:
78
79 SMDS_ElementFactory( SMDS_Mesh* mesh, const bool isNodal=false );
80 virtual ~SMDS_ElementFactory();
81
83 smIdType GetFreeID();
84
86 smIdType GetMaxID();
87
89 smIdType GetMinID();
90
92 SMDS_MeshElement* NewElement( const smIdType id );
93
95 SMDS_MeshCell* NewCell( const smIdType id ) { return static_cast<SMDS_MeshCell*>( NewElement( id )); }
96
98 const SMDS_MeshElement* FindElement( const smIdType id ) const;
99
101 smIdType NbUsedElements() const { return myNbUsedElements; }
102
104 // nbElemsToReturn is used to optimize by stopping the iteration as soon as
105 // all elements satisfying filtering condition encountered.
106 template< class ElemIterator >
107 boost::shared_ptr< ElemIterator > GetIterator( SMDS_MeshElement::Filter* filter,
108 size_t nbElemsToReturn = -1 );
109
111 // nbElemsToReturn is used to optimize by stopping the iteration as soon as
112 // all elements assigned to the shape encountered.
113 // sm1stElem is used to quickly find the first chunk holding elements of the shape;
114 // it must have smallest ID between elements on the shape
115 template< class ElemIterator >
116 boost::shared_ptr< ElemIterator > GetShapeIterator( int shapeID,
117 size_t nbElemsToReturn,
118 const SMDS_MeshElement* sm1stElem );
120 void SetAllNotMarked();
121
123 void Free( const SMDS_MeshElement* );
124
126 smIdType FromVtkToSmds( vtkIdType vtkID );
127
129 virtual void Clear();
130
132 // Minimize allocated memory
133 virtual void Compact(std::vector<smIdType>& idCellsOldToNew);
134
136 virtual bool CompactChangePointers();
137
139 static int ChunkSize();
140};
141
142//------------------------------------------------------------------------------------
147{
148 std::vector<char> myShapeDim; // dimension of shapes
149
150public:
151
154
156 SMDS_MeshNode* NewNode( smIdType id ) { return (SMDS_MeshNode*) NewElement(id); }
157
159 const SMDS_MeshNode* FindNode( smIdType id ) { return (const SMDS_MeshNode*) FindElement(id); }
160
162 void SetNbShapes( size_t nbShapes );
163
165 int GetShapeDim( int shapeID ) const;
166
168 void SetShapeDim( int shapeID, int dim );
169
171 virtual void Clear();
172
174 // Minimize allocated memory
175 virtual void Compact(std::vector<smIdType>& idNodesOldToNew);
176
178 virtual bool CompactChangePointers();
179};
180
181//------------------------------------------------------------------------------------
185template< typename ATTR>
186struct _Range
187{
188 typedef ATTR attr_t;
189
190 attr_t myValue; // common attribute value
191 int my1st; // index in the chunk of the 1st element
192 _Range( int i0 = 0, attr_t v = 0 ): myValue( v ), my1st( i0 ) {}
193
194 bool operator < (const _Range& other) const { return my1st < other.my1st; }
195};
196
197typedef std::vector< std::pair< int, int > > TIndexRanges;
198
199//------------------------------------------------------------------------------------
203template< class RANGE >
205{
206 typedef typename RANGE::attr_t attr_t;
208 typedef typename set_t::const_iterator set_iterator;
209
211
212 _RangeSet() { mySet.insert( RANGE( 0, 0 )); }
213
217 size_t Size() const { return mySet.size(); }
218
222 int& First( set_iterator rangePtr ) { return const_cast< int& >( rangePtr->my1st ); }
223
227 size_t Size( set_iterator rangePtr ) const
228 {
229 int next1st =
230 ( rangePtr + 1 == mySet.end() ) ? SMDS_ElementFactory::ChunkSize() : ( rangePtr + 1 )->my1st;
231 return next1st - rangePtr->my1st;
232 }
233
237 bool GetIndices( const attr_t theValue, TIndexRanges & theIndices,
238 const attr_t* /*theMinValue*/ = 0, const attr_t* /*theMaxValue*/ = 0) const
239 {
240 bool isFound = false;
241
242 // if ( sizeof( attr_t ) == sizeof( int ) && theMinValue )
243 // if ( theValue < *theMinValue || theValue > *theMaxValue )
244 // return isFound;
245
246 for ( set_iterator it = mySet.begin(); it < mySet.end(); ++it )
247 {
248 if ( it->myValue == theValue )
249 {
250 theIndices.push_back( std::make_pair( it->my1st, it->my1st + Size( it )));
251 isFound = true;
252 ++it; // the next range value differs from theValue
253 }
254 }
255 return isFound;
256 }
257
263 attr_t GetValue( int theIndex ) const
264 {
265 set_iterator r = mySet.upper_bound( theIndex ) - 1;
266 return r->myValue;
267 }
268
275 attr_t SetValue( int theIndex, attr_t theValue )
276 {
277 set_iterator rNext = mySet.end(); // case of adding elements
278 set_iterator r = rNext - 1;
279 if ( r->my1st > theIndex )
280 {
281 rNext = mySet.upper_bound( theIndex );
282 r = rNext - 1;
283 }
284 int rSize = Size( r ); // range size
285 attr_t rValue = r->myValue;
286 if ( rValue == theValue )
287 return rValue; // it happens while compacting
288
289 if ( r->my1st == theIndex ) // theIndex is the first in the range
290 {
291 bool joinPrev = // can join theIndex to the previous range
292 ( r->my1st > 0 && ( r-1 )->myValue == theValue );
293
294 if ( rSize == 1 )
295 {
296 bool joinNext = // can join to the next range
297 ( rNext != mySet.end() && rNext->myValue == theValue );
298
299 if ( joinPrev )
300 {
301 if ( joinNext ) // && joinPrev
302 {
303 mySet.erase( r, r + 2 );
304 }
305 else // joinPrev && !joinNext
306 {
307 mySet.erase( r );
308 }
309 }
310 else
311 {
312 if ( joinNext ) // && !joinPrev
313 {
314 r = mySet.erase( r ); // then r points to the next range
315 First( r )--;
316 }
317 else // !joinPrev && !joinNext
318 {
319 const_cast< attr_t & >( r->myValue ) = theValue;
320 }
321 }
322 }
323 else // if rSize > 1
324 {
325 if ( joinPrev )
326 {
327 First( r )++;
328 }
329 else
330 {
331 r = mySet.insert( r, RANGE( theIndex + 1, rValue )) - 1;
332 const_cast< attr_t & >( r->myValue ) = theValue;
333 }
334 }
335 }
336 else if ( r->my1st + rSize - 1 == theIndex ) // theIndex is last in the range
337 {
338 if ( rNext != mySet.end() && rNext->myValue == theValue ) // join to the next
339 {
340 First( rNext )--;
341 }
342 else
343 {
344 mySet.insert( r, RANGE( theIndex, theValue ));
345 }
346 }
347 else // theIndex in the middle of the range
348 {
349 r = mySet.insert( r, RANGE( theIndex, theValue ));
350 r = mySet.insert( r, RANGE( theIndex + 1, rValue ));
351 }
352 return rValue;
353 }
354}; // struct _RangeSet
355
356
357typedef _Range< int > _ShapeIDRange; // sub-mesh ID range
358typedef _Range< bool > _UsedRange; // range of used elements
359
362typedef boost::dynamic_bitset<> TBitSet;
363//typedef float TParam;
364typedef double TParam;
365//typedef std::unordered_set<int> TSubIDSet;
366
367//------------------------------------------------------------------------------------
374{
375 SMDS_ElementFactory* myFactory; // holder of this chunk
376 SMDS_MeshElement* myElements; // array of elements
377 smIdType my1stID; // ID of myElements[0]
378 TBitSet myMarkedSet; // mark some elements
379 TUsedRangeSet myUsedRanges; // ranges of used/unused elements
380 TSubIDRangeSet mySubIDRanges; // ranges of elements on the same sub-shape
381 //TSubIDSet* mySubIDSet; // set of sub-shape IDs
382 // int myMinSubID; // min sub-shape ID
383 // int myMaxSubID; // max sub-shape ID
384 std::vector<TParam> myPositions; // UV parameters on shape: 2*param_t per an element
385
386public:
387
388 SMDS_ElementChunk( SMDS_ElementFactory* factory = 0, smIdType id0 = 0 );
390
392 SMDS_MeshElement* Element(int index) { return & myElements[index]; }
393
395 const SMDS_MeshElement* Element(int index) const { return & myElements[index]; }
396
398 smIdType GetUnusedID() const;
399
401 void UseElement( const int index );
402
404 void Free( const SMDS_MeshElement* e );
405
407 static bool IsUsed( const _UsedRange& r ) { return r.myValue; }
408
410 int Index( const SMDS_MeshElement* e ) const { return (int)( e - myElements ); }
411
413 smIdType Get1stID() const { return my1stID; }
414
416 TParam* GetPositionPtr( const SMDS_MeshElement* node, bool allocate=false );
417
419 const TUsedRangeSet& GetUsedRanges() const { return myUsedRanges; }
420 const TUsedRangeSet& GetUsedRangesMinMax( bool& min, bool& max ) const
421 { min = false; max = true; return myUsedRanges; }
422
424 const TSubIDRangeSet& GetSubIDRangesMinMax( int& /*min*/, int& /*max*/ ) const
425 { /*min = myMinSubID; max = myMaxSubID;*/ return mySubIDRanges; }
426
428 void Compact();
429
431 void Dump() const; // debug
432
433
434 // Methods called by SMDS_MeshElement
435
436 smIdType GetID( const SMDS_MeshElement* e ) const;
437
438 vtkIdType GetVtkID( const SMDS_MeshElement* e ) const;
439 void SetVTKID( const SMDS_MeshElement* e, const vtkIdType id );
440
441 int GetShapeID( const SMDS_MeshElement* e ) const;
442 void SetShapeID( const SMDS_MeshElement* e, int shapeID ) const;
443
444 bool IsMarked ( const SMDS_MeshElement* e ) const;
445 void SetIsMarked( const SMDS_MeshElement* e, bool is );
446 void SetAllNotMarked();
447
449 void SetPosition( const SMDS_MeshNode* n, const SMDS_PositionPtr& pos, int shapeID );
450
452};
453
454//------------------------------------------------------------------------------------
458template< class ELEM_ITERATOR, class RANGE_SET >
460{
461 typedef typename ELEM_ITERATOR::value_type element_type;
463 typedef typename RANGE_SET::attr_t attr_type;
464 typedef const RANGE_SET& (SMDS_ElementChunk::*get_rangeset_fun)(attr_type&, attr_type&) const;
465
478
479 _ChunkIterator( const TChunkVector & theChunks,
480 get_rangeset_fun theGetRangeSetFun,
481 attr_type theAttrValue,
482 SMDS_MeshElement::Filter* theFilter,
483 size_t theNbElemsToReturn = -1,
484 int theChunkIndex = 0):
485 myElement( 0 ),
486 myRangeIndex( 0 ),
487 myChunks( theChunks ),
488 myChunkIndex( theChunkIndex-1 ),
489 myGetRangeSetFun( theGetRangeSetFun ),
490 myValue( theAttrValue ),
491 myFilter( theFilter ),
492 myNbElemsToReturn( theNbElemsToReturn ),
493 myNbReturned( 0 )
494 {
495 next();
496 }
498 {
499 delete myFilter;
500 }
501
502 virtual bool more()
503 {
504 return myElement;
505 }
506
508 {
510 myNbReturned += bool( result );
511
512 myElement = 0;
514 while ( ! nextInRange() )
515 {
516 if ( ++myRangeIndex >= (int)myRanges.size() )
517 {
518 myRanges.clear();
519 myRangeIndex = 0;
520 while ( ++myChunkIndex < (int)myChunks.size() &&
521 !getRangeSet().GetIndices( myValue, myRanges, &myMinValue, &myMaxValue ))
522 ;
523 if ( myChunkIndex >= (int)myChunks.size() )
524 break;
525 }
526 }
527 return result;
528 }
529
531 {
532 if ( myRangeIndex < (int)myRanges.size() )
533 {
534 std::pair< int, int > & range = myRanges[ myRangeIndex ];
535 while ( range.first < range.second && !myElement )
536 {
537 myElement = myChunks[ myChunkIndex ].Element( range.first++ );
538 if ( !(*myFilter)( myElement ))
539 myElement = 0;
540 }
541 }
542 return myElement;
543 }
544
545 const RANGE_SET& getRangeSet()
546 {
548 }
549}; // struct _ChunkIterator
550
551
552template< class ElemIterator >
553boost::shared_ptr< ElemIterator >
555 size_t nbElemsToReturn )
556{
558 return boost::make_shared< TChuckIterator >( myChunks,
560 /*isUsed=*/true,
561 filter,
562 nbElemsToReturn );
563}
564
565template< class ElemIterator >
566boost::shared_ptr< ElemIterator >
568 size_t nbElemsToReturn,
569 const SMDS_MeshElement* sm1stElem )
570{
571 smIdType iChunk = sm1stElem ? (( sm1stElem->GetID() - 1 ) / ChunkSize()) : 0;
573 return boost::make_shared< TChuckIterator >( myChunks,
575 /*shapeID=*/shapeID,
577 nbElemsToReturn,
578 iChunk );
579}
580
581#endif
std::set< SMDS_ElementChunk *, _ChunkCompare > TChunkPtrSet
Definition: SMDS_ElementFactory.hxx:54
boost::dynamic_bitset TBitSet
Definition: SMDS_ElementFactory.hxx:362
_RangeSet< _UsedRange > TUsedRangeSet
Definition: SMDS_ElementFactory.hxx:361
std::vector< std::pair< int, int > > TIndexRanges
Definition: SMDS_ElementFactory.hxx:197
double TParam
Definition: SMDS_ElementFactory.hxx:364
_RangeSet< _ShapeIDRange > TSubIDRangeSet
Definition: SMDS_ElementFactory.hxx:360
_Range< int > _ShapeIDRange
Definition: SMDS_ElementFactory.hxx:357
_Range< bool > _UsedRange
Definition: SMDS_ElementFactory.hxx:358
boost::ptr_vector< SMDS_ElementChunk > TChunkVector
Definition: SMDS_ElementFactory.hxx:53
Allocate SMDS_MeshElement's (SMDS_MeshCell's or SMDS_MeshNode's ) and bind some attributes to element...
Definition: SMDS_ElementFactory.hxx:374
TUsedRangeSet myUsedRanges
Definition: SMDS_ElementFactory.hxx:379
const SMDS_MeshElement * Element(int index) const
Return an element by an index [0,ChunkSize()].
Definition: SMDS_ElementFactory.hxx:395
std::vector< TParam > myPositions
Definition: SMDS_ElementFactory.hxx:384
const TUsedRangeSet & GetUsedRangesMinMax(bool &min, bool &max) const
Definition: SMDS_ElementFactory.hxx:420
void Dump() const
Print some data.
Definition: SMDS_ElementFactory.cxx:883
SMDS_MeshElement * Element(int index)
Return an element by an index [0,ChunkSize()].
Definition: SMDS_ElementFactory.hxx:392
SMDS_PositionPtr GetPosition(const SMDS_MeshNode *n) const
Return SMDS_Position of a node on a shape.
Definition: SMDS_ElementFactory.cxx:765
smIdType GetID(const SMDS_MeshElement *e) const
Return an SMDS ID of an element.
Definition: SMDS_ElementFactory.cxx:617
smIdType GetUnusedID() const
Return ID of the first non-used element.
Definition: SMDS_ElementFactory.cxx:579
SMDS_MeshElement * myElements
Definition: SMDS_ElementFactory.hxx:376
TBitSet myMarkedSet
Definition: SMDS_ElementFactory.hxx:378
bool IsMarked(const SMDS_MeshElement *e) const
Set isMarked flag of an element.
Definition: SMDS_ElementFactory.cxx:730
TParam * GetPositionPtr(const SMDS_MeshElement *node, bool allocate=false)
Return pointer to on-shape-parameters of a node.
Definition: SMDS_ElementFactory.cxx:830
const TSubIDRangeSet & GetSubIDRangesMinMax(int &, int &) const
Return ranges of elements assigned to sub-shapes and min/max of sub-shape IDs.
Definition: SMDS_ElementFactory.hxx:424
SMDS_Mesh * GetMesh()
Definition: SMDS_ElementFactory.hxx:451
int Index(const SMDS_MeshElement *e) const
Return index of an element in the chunk.
Definition: SMDS_ElementFactory.hxx:410
SMDS_ElementFactory * myFactory
Definition: SMDS_ElementFactory.hxx:375
void SetShapeID(const SMDS_MeshElement *e, int shapeID) const
Set ID of a shape an element is assigned to.
Definition: SMDS_ElementFactory.cxx:689
int GetShapeID(const SMDS_MeshElement *e) const
Return ID of a shape an element is assigned to.
Definition: SMDS_ElementFactory.cxx:678
void SetIsMarked(const SMDS_MeshElement *e, bool is)
Return isMarked flag of an element.
Definition: SMDS_ElementFactory.cxx:741
void UseElement(const int index)
Mark an element as used.
Definition: SMDS_ElementFactory.cxx:566
smIdType my1stID
Definition: SMDS_ElementFactory.hxx:377
void Compact()
Minimize allocated memory.
Definition: SMDS_ElementFactory.cxx:845
void SetVTKID(const SMDS_MeshElement *e, const vtkIdType id)
Set a Vtk ID of an element.
Definition: SMDS_ElementFactory.cxx:628
void SetPosition(const SMDS_MeshNode *n, const SMDS_PositionPtr &pos, int shapeID)
Set SMDS_Position of a node on a shape.
Definition: SMDS_ElementFactory.cxx:794
const TUsedRangeSet & GetUsedRanges() const
Return ranges of used/non-used elements.
Definition: SMDS_ElementFactory.hxx:419
static bool IsUsed(const _UsedRange &r)
Check if a given range holds used or non-used elements.
Definition: SMDS_ElementFactory.hxx:407
SMDS_ElementChunk(SMDS_ElementFactory *factory=0, smIdType id0=0)
SMDS_ElementChunk constructor.
Definition: SMDS_ElementFactory.cxx:528
smIdType Get1stID() const
Return ID of the 1st element in the chunk.
Definition: SMDS_ElementFactory.hxx:413
void SetAllNotMarked()
Clear marked flag of all elements.
Definition: SMDS_ElementFactory.cxx:754
TSubIDRangeSet mySubIDRanges
Definition: SMDS_ElementFactory.hxx:380
vtkIdType GetVtkID(const SMDS_MeshElement *e) const
Return a Vtk ID of an element.
Definition: SMDS_ElementFactory.cxx:666
~SMDS_ElementChunk()
SMDS_ElementChunk destructor.
Definition: SMDS_ElementFactory.cxx:554
void Free(const SMDS_MeshElement *e)
Mark an element as non-used.
Definition: SMDS_ElementFactory.cxx:595
Allocate SMDS_MeshElement's (SMDS_MeshCell's or SMDS_MeshNode's ) and bind some attributes to element...
Definition: SMDS_ElementFactory.hxx:65
smIdType myNbUsedElements
Definition: SMDS_ElementFactory.hxx:73
std::vector< smIdType > mySmdsIDs
Definition: SMDS_ElementFactory.hxx:72
smIdType FromVtkToSmds(vtkIdType vtkID)
Return an SMDS ID by a Vtk one.
Definition: SMDS_ElementFactory.cxx:226
smIdType NbUsedElements() const
Return a number of used elements.
Definition: SMDS_ElementFactory.hxx:101
TChunkVector myChunks
Definition: SMDS_ElementFactory.hxx:69
void SetAllNotMarked()
Clear marked flag of all elements.
Definition: SMDS_ElementFactory.cxx:239
smIdType GetMaxID()
Return maximal ID of an used element.
Definition: SMDS_ElementFactory.cxx:129
SMDS_Mesh * myMesh
Definition: SMDS_ElementFactory.hxx:68
SMDS_MeshElement * NewElement(const smIdType id)
Return an element by ID. NULL if the element with the given ID is already used.
Definition: SMDS_ElementFactory.cxx:172
virtual ~SMDS_ElementFactory()
Destructor.
Definition: SMDS_ElementFactory.cxx:86
const SMDS_MeshElement * FindElement(const smIdType id) const
Return an used element by ID. NULL if the element with the given ID is not yet used.
Definition: SMDS_ElementFactory.cxx:203
void Free(const SMDS_MeshElement *)
Mark the element as non-used.
Definition: SMDS_ElementFactory.cxx:252
std::vector< vtkIdType > myVtkIDs
Definition: SMDS_ElementFactory.hxx:71
SMDS_ElementFactory(SMDS_Mesh *mesh, const bool isNodal=false)
Create a factory of cells or nodes in a given mesh.
Definition: SMDS_ElementFactory.cxx:75
virtual void Clear()
De-allocate all elements.
Definition: SMDS_ElementFactory.cxx:279
TChunkPtrSet myChunksWithUnused
Definition: SMDS_ElementFactory.hxx:70
virtual bool CompactChangePointers()
Return true if Compact() will change IDs of elements.
Definition: SMDS_ElementFactory.cxx:355
boost::shared_ptr< ElemIterator > GetIterator(SMDS_MeshElement::Filter *filter, size_t nbElemsToReturn=-1)
Return an iterator on all element filtered using a given filter.
Definition: SMDS_ElementFactory.hxx:554
smIdType GetMinID()
Return minimal ID of an used element.
Definition: SMDS_ElementFactory.cxx:150
virtual void Compact(std::vector< smIdType > &idCellsOldToNew)
Remove unused elements located not at the end of the last chunk.
Definition: SMDS_ElementFactory.cxx:296
smIdType GetFreeID()
Return minimal ID of a non-used element.
Definition: SMDS_ElementFactory.cxx:111
boost::shared_ptr< ElemIterator > GetShapeIterator(int shapeID, size_t nbElemsToReturn, const SMDS_MeshElement *sm1stElem)
Return an iterator on all element assigned to a given shape.
Definition: SMDS_ElementFactory.hxx:567
static int ChunkSize()
Return a number of elements in a chunk.
Definition: SMDS_ElementFactory.cxx:99
bool myIsNodal
Definition: SMDS_ElementFactory.hxx:67
SMDS_MeshCell * NewCell(const smIdType id)
Return a SMDS_MeshCell by ID. NULL if the cell with the given ID is already used.
Definition: SMDS_ElementFactory.hxx:95
Base class for all cells.
Definition: SMDS_MeshCell.hxx:32
Base class for elements.
Definition: SMDS_MeshElement.hxx:56
virtual smIdType GetID() const
Return ID of an element.
Definition: SMDS_MeshElement.cxx:108
Definition: SMDS_MeshNode.hxx:36
Definition: SMDS_Mesh.hxx:53
Allocate SMDS_MeshNode's.
Definition: SMDS_ElementFactory.hxx:147
void SetNbShapes(size_t nbShapes)
Set a total number of sub-shapes in the main shape.
Definition: SMDS_ElementFactory.cxx:490
virtual void Compact(std::vector< smIdType > &idNodesOldToNew)
Remove unused nodes located not at the end of the last chunk.
Definition: SMDS_ElementFactory.cxx:391
virtual void Clear()
De-allocate all nodes.
Definition: SMDS_ElementFactory.cxx:479
int GetShapeDim(int shapeID) const
Return a dimension of a shape.
Definition: SMDS_ElementFactory.cxx:502
SMDS_MeshNode * NewNode(smIdType id)
Return a SMDS_MeshNode by ID. NULL if the node with the given ID is already used.
Definition: SMDS_ElementFactory.hxx:156
virtual bool CompactChangePointers()
Return true if Compact() will change IDs of node.
Definition: SMDS_ElementFactory.cxx:467
void SetShapeDim(int shapeID, int dim)
Set a dimension of a shape.
Definition: SMDS_ElementFactory.cxx:513
~SMDS_NodeFactory()
Destructor.
Definition: SMDS_ElementFactory.cxx:378
std::vector< char > myShapeDim
Definition: SMDS_ElementFactory.hxx:148
const SMDS_MeshNode * FindNode(smIdType id)
Return an used node by ID. NULL if the node with the given ID is not yet used.
Definition: SMDS_ElementFactory.hxx:159
SMDS_NodeFactory(SMDS_Mesh *mesh)
Create a factory of nodes in a given mesh.
Definition: SMDS_ElementFactory.cxx:367
Replace "typedef SMDS_Position* SMDS_PositionPtr" by a smart pointer allowing implicit casting to der...
Definition: SMDS_Position.hxx:58
Filters of elements, to be used with SMDS_SetIterator.
Definition: SMDS_MeshElement.hxx:155
Definition: SMDS_MeshElement.hxx:160
Definition: SMDS_ElementFactory.hxx:50
bool operator()(const SMDS_ElementChunk *c1, const SMDS_ElementChunk *c2) const
Compare SMDS_ElementChunk's.
Definition: SMDS_ElementFactory.cxx:910
Iterator on elements in chunks.
Definition: SMDS_ElementFactory.hxx:460
bool nextInRange()
Definition: SMDS_ElementFactory.hxx:530
const RANGE_SET &(SMDS_ElementChunk::* get_rangeset_fun)(attr_type &, attr_type &) const
Definition: SMDS_ElementFactory.hxx:464
int myRangeIndex
Definition: SMDS_ElementFactory.hxx:468
SMDS_MeshElement::Filter * filter_ptr
Definition: SMDS_ElementFactory.hxx:462
attr_type myValue
Definition: SMDS_ElementFactory.hxx:472
virtual bool more()
Definition: SMDS_ElementFactory.hxx:502
const SMDS_MeshElement * myElement
Definition: SMDS_ElementFactory.hxx:466
get_rangeset_fun myGetRangeSetFun
Definition: SMDS_ElementFactory.hxx:471
size_t myNbElemsToReturn
Definition: SMDS_ElementFactory.hxx:476
attr_type myMinValue
Definition: SMDS_ElementFactory.hxx:473
RANGE_SET::attr_t attr_type
Definition: SMDS_ElementFactory.hxx:463
int myChunkIndex
Definition: SMDS_ElementFactory.hxx:470
attr_type myMaxValue
Definition: SMDS_ElementFactory.hxx:474
size_t myNbReturned
Definition: SMDS_ElementFactory.hxx:477
virtual element_type next()
Definition: SMDS_ElementFactory.hxx:507
_ChunkIterator(const TChunkVector &theChunks, get_rangeset_fun theGetRangeSetFun, attr_type theAttrValue, SMDS_MeshElement::Filter *theFilter, size_t theNbElemsToReturn=-1, int theChunkIndex=0)
Definition: SMDS_ElementFactory.hxx:479
ELEM_ITERATOR::value_type element_type
Definition: SMDS_ElementFactory.hxx:461
const TChunkVector & myChunks
Definition: SMDS_ElementFactory.hxx:469
~_ChunkIterator()
Definition: SMDS_ElementFactory.hxx:497
const RANGE_SET & getRangeSet()
Definition: SMDS_ElementFactory.hxx:545
TIndexRanges myRanges
Definition: SMDS_ElementFactory.hxx:467
filter_ptr myFilter
Definition: SMDS_ElementFactory.hxx:475
Sorted set of ranges.
Definition: SMDS_ElementFactory.hxx:205
set_t mySet
Definition: SMDS_ElementFactory.hxx:210
bool GetIndices(const attr_t theValue, TIndexRanges &theIndices, const attr_t *=0, const attr_t *=0) const
Return ranges of indices (from,to) of elements having a given value.
Definition: SMDS_ElementFactory.hxx:237
size_t Size(set_iterator rangePtr) const
Return a number of elements in a range pointed by an iterator.
Definition: SMDS_ElementFactory.hxx:227
size_t Size() const
Return a number of ranges.
Definition: SMDS_ElementFactory.hxx:217
_RangeSet()
Definition: SMDS_ElementFactory.hxx:212
set_t::const_iterator set_iterator
Definition: SMDS_ElementFactory.hxx:208
boost::container::flat_set< RANGE > set_t
Definition: SMDS_ElementFactory.hxx:207
RANGE::attr_t attr_t
Definition: SMDS_ElementFactory.hxx:206
int & First(set_iterator rangePtr)
Return a mutable _Range::my1st of a range pointed by an iterator.
Definition: SMDS_ElementFactory.hxx:222
attr_t GetValue(int theIndex) const
Return value of an element attribute.
Definition: SMDS_ElementFactory.hxx:263
attr_t SetValue(int theIndex, attr_t theValue)
Change value of an element attribute.
Definition: SMDS_ElementFactory.hxx:275
Range of elements in a chunk having the same attribute value.
Definition: SMDS_ElementFactory.hxx:187
_Range(int i0=0, attr_t v=0)
Definition: SMDS_ElementFactory.hxx:192
ATTR attr_t
Definition: SMDS_ElementFactory.hxx:188
int my1st
Definition: SMDS_ElementFactory.hxx:191
bool operator<(const _Range &other) const
Definition: SMDS_ElementFactory.hxx:194
attr_t myValue
Definition: SMDS_ElementFactory.hxx:190