gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
partitionVertex.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef PARTITION_VERTEX_H
7 #define PARTITION_VERTEX_H
8 
9 #include "GModel.h"
10 #include "discreteVertex.h"
11 
13 private:
14  std::vector<int> _partitions;
16 
17 public:
18  partitionVertex(GModel *model, int num, const std::vector<int> &partitions)
19  : discreteVertex(model, num), _partitions(partitions),
20  _parentEntity(nullptr)
21  {
22  }
24  : discreteVertex(model, num), _partitions(), _parentEntity(nullptr)
25  {
26  }
27  partitionVertex(GModel *model, const std::vector<int> &partitions)
28  : discreteVertex(model), _partitions(partitions), _parentEntity(nullptr)
29  {
30  }
31  virtual ~partitionVertex() {}
32  virtual GeomType geomType() const { return PartitionPoint; }
33  virtual void setParentEntity(GEntity *v) { _parentEntity = v; }
34  virtual GEntity *getParentEntity() { return _parentEntity; }
35  virtual void setPartitions(std::vector<int> &partitions)
36  {
37  _partitions = partitions;
38  }
39  virtual const std::vector<int> &getPartitions() const { return _partitions; }
40  virtual int getPartition(std::size_t index) const
41  {
42  return _partitions[index];
43  }
44  virtual std::size_t numPartitions() const { return _partitions.size(); }
45 };
46 
48  : public std::binary_function<partitionVertex *, partitionVertex *, bool> {
49  bool operator()(const partitionVertex *e1, const partitionVertex *e2) const
50  {
51  if(e1->numPartitions() < e2->numPartitions()) return true;
52  if(e1->numPartitions() > e2->numPartitions()) return false;
53  for(std::size_t i = 0; i < e1->numPartitions(); i++) {
54  if(e1->getPartition(i) < e2->getPartition(i)) return true;
55  if(e1->getPartition(i) > e2->getPartition(i)) return false;
56  }
57  return false;
58  }
59 };
60 
61 #endif
partitionVertex::_partitions
std::vector< int > _partitions
Definition: partitionVertex.h:14
partitionVertex::partitionVertex
partitionVertex(GModel *model, int num)
Definition: partitionVertex.h:23
GEntity::model
GModel * model() const
Definition: GEntity.h:277
partitionVertex::~partitionVertex
virtual ~partitionVertex()
Definition: partitionVertex.h:31
partitionVertex::partitionVertex
partitionVertex(GModel *model, const std::vector< int > &partitions)
Definition: partitionVertex.h:27
partitionVertex::setPartitions
virtual void setPartitions(std::vector< int > &partitions)
Definition: partitionVertex.h:35
GEntity
Definition: GEntity.h:31
partitionVertex::getPartitions
virtual const std::vector< int > & getPartitions() const
Definition: partitionVertex.h:39
partitionVertex::geomType
virtual GeomType geomType() const
Definition: partitionVertex.h:32
discreteVertex.h
discreteVertex
Definition: discreteVertex.h:15
partitionVertex::partitionVertex
partitionVertex(GModel *model, int num, const std::vector< int > &partitions)
Definition: partitionVertex.h:18
GModel
Definition: GModel.h:44
partitionVertex::_parentEntity
GEntity * _parentEntity
Definition: partitionVertex.h:15
partitionVertexPtrLessThan::operator()
bool operator()(const partitionVertex *e1, const partitionVertex *e2) const
Definition: partitionVertex.h:49
GEntity::GeomType
GeomType
Definition: GEntity.h:88
partitionVertex::getParentEntity
virtual GEntity * getParentEntity()
Definition: partitionVertex.h:34
partitionVertexPtrLessThan
Definition: partitionVertex.h:48
partitionVertex
Definition: partitionVertex.h:12
GEntity::PartitionPoint
@ PartitionPoint
Definition: GEntity.h:121
GModel.h
partitionVertex::getPartition
virtual int getPartition(std::size_t index) const
Definition: partitionVertex.h:40
partitionVertex::numPartitions
virtual std::size_t numPartitions() const
Definition: partitionVertex.h:44
partitionVertex::setParentEntity
virtual void setParentEntity(GEntity *v)
Definition: partitionVertex.h:33