VPTissue Reference Manual
EditableMesh.h
Go to the documentation of this file.
1 #ifndef SIMPT_EDITOR_EDITABLE_MESH_H_INCLUDED
2 #define SIMPT_EDITOR_EDITABLE_MESH_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "bio/Mesh.h"
23 
24 #include <boost/property_tree/ptree.hpp>
25 #include <QLineF>
26 #include <QPolygonF>
27 
28 namespace SimPT_Editor {
29 
30 using namespace SimPT_Sim;
31 
36 {
37 public:
44  EditableMesh(const boost::property_tree::ptree& pt);
45 
49  ~EditableMesh();
50 
61  bool CanSplitCell(Node* node1, Node* node2, Cell* cell = nullptr) const;
62 
76  Cell* CreateCell(Node* node1, Node* node2, const QPointF& newPoint);
77 
83  void DeleteCells(const std::list<Cell*>& cells);
84 
94  bool DeleteTwoDegreeNode(Node* node);
95 
104  bool DisplaceNode(Node* node, double x, double y);
105 
109  std::shared_ptr<SimPT_Sim::Mesh>& GetMesh();
110 
118  bool IsDeletableCell(Cell* cell) const;
119 
127  bool IsDeletableNode(Node* node) const;
128 
140  void ReplaceCell(Cell* cell, std::list<QPolygonF> newCells);
141 
148  Node* SplitEdge(const Edge& edge);
149 
154  std::vector<Cell*> SplitCell(Node* node1, Node* node2);
155 
165  std::vector<Cell*> SplitCell(Cell* cell, Node* node1, Node* node2);
166 
167 private:
179  bool DeleteTwoDegreeNodeInconsistent(Node* node);
180 
185  void FixCellIDs();
186 
191  void FixNodeIDs();
192 
197  void FixWallIDs();
198 
207  bool IsConsistent(const std::list<QLineF>& excluded, const std::list<QLineF>& included) const;
208 
216  bool IsConsistent(Node* node) const;
217 
224  void SetAtBoundary(Node* node);
225 
226 private:
227  std::shared_ptr<SimPT_Sim::Mesh> m_mesh;
228  std::vector<Cell*>& m_cells;
229  std::vector<Node*>& m_nodes;
230  std::vector<Wall*>& m_walls;
231 
232  static constexpr double g_accuracy = 1.0e-12; // Needed for floating-point errors in Qt intersections.
233 };
234 
235 } // namespace
236 
237 #endif // end_of_include_guard
A cell contains walls and nodes.
Definition: Cell.h:48
Namespace for SimPT tissue editor package.
Definition: Cell.h:32
Node in cell wall.
Definition: Node.h:39
Namespace for the core simulator.
An Edge connects two nodes and is ambidextrous.
Definition: Edge.h:31
An editable mesh with actions to alter the construction of the mesh.
Definition: EditableMesh.h:35
Interface for Mesh.