Improve NNC memory use

This commit is contained in:
Gaute Lindkvist
2020-05-15 12:55:25 +02:00
committed by Magne Sjaastad
parent 97dd891d38
commit ab0b05b31c
18 changed files with 178 additions and 162 deletions
@@ -33,38 +33,54 @@ public:
RigConnection();
RigConnection( unsigned c1GlobIdx,
unsigned c2GlobIdx,
cvf::StructGridInterface::FaceType c1Face,
const std::vector<cvf::Vec3f>& polygon );
cvf::StructGridInterface::FaceType c1Face = cvf::StructGridInterface::NO_FACE,
const std::vector<cvf::Vec3f>& polygon = {} );
RigConnection( size_t c1GlobIdx,
size_t c2GlobIdx,
cvf::StructGridInterface::FaceType c1Face = cvf::StructGridInterface::NO_FACE,
const std::vector<cvf::Vec3f>& polygon = {} );
RigConnection( const RigConnection& rhs );
RigConnection& operator=( RigConnection& rhs );
RigConnection& operator=( const RigConnection& rhs );
bool operator==( const RigConnection& rhs );
bool operator<( const RigConnection& other ) const;
bool hasCommonArea() const;
unsigned m_c1GlobIdx;
unsigned m_c2GlobIdx;
cvf::StructGridInterface::FaceType m_c1Face;
std::vector<cvf::Vec3f> m_polygon;
inline size_t c1GlobIdx() const { return m_c1GlobIdx; }
inline size_t c2GlobIdx() const { return m_c2GlobIdx; }
inline cvf::StructGridInterface::FaceType face() const
{
return static_cast<cvf::StructGridInterface::FaceType>( m_c1Face );
}
inline void setFace( cvf::StructGridInterface::FaceType face ) { m_c1Face = static_cast<unsigned char>( face ); }
inline const std::vector<cvf::Vec3f>& polygon() const { return m_polygon; }
inline void setPolygon( const std::vector<cvf::Vec3f>& polygon ) { m_polygon = polygon; }
private:
unsigned m_c1GlobIdx;
unsigned m_c2GlobIdx;
unsigned char m_c1Face;
std::vector<cvf::Vec3f> m_polygon;
};
class RigConnectionContainer
{
public:
RigConnection operator[]( size_t i ) const;
RigConnectionContainer() = default;
std::pair<unsigned, unsigned>& indexPair( size_t i );
unsigned char& face( size_t i );
std::vector<cvf::Vec3f>& polygon( size_t i );
const RigConnection& operator[]( size_t i ) const;
RigConnection& operator[]( size_t i );
void push_back( const RigConnection& connection );
void insert( const RigConnectionContainer& other );
void push_back( const RigConnectionContainer& connection );
size_t size() const;
void clear();
bool empty() const;
void remove_duplicates();
void reserve( size_t requiredSize );
private:
std::vector<std::pair<unsigned, unsigned>> m_globalIndices;
std::vector<unsigned char> m_faces;
std::vector<std::vector<cvf::Vec3f>> m_polygons;
std::vector<RigConnection> m_connections;
};