VPTissue Reference Manual
|
An editable mesh with actions to alter the construction of the mesh. More...
#include <EditableMesh.h>
Public Member Functions | |
EditableMesh (const boost::property_tree::ptree &pt) | |
Constructor. More... | |
~EditableMesh () | |
Destructor. | |
bool | CanSplitCell (Node *node1, Node *node2, Cell *cell=nullptr) const |
Checks whether the two given nodes can split a (given) cell (excluding the boundary polygon). More... | |
Cell * | CreateCell (Node *node1, Node *node2, const QPointF &newPoint) |
Creates a new cell with the two given nodes and a third new point. More... | |
void | DeleteCells (const std::list< Cell * > &cells) |
Deletes the given cell from the mesh. More... | |
bool | DeleteTwoDegreeNode (Node *node) |
Deletes the given node from the mesh (which should stay consistent). More... | |
bool | DisplaceNode (Node *node, double x, double y) |
Place a node at the given coordinates. More... | |
std::shared_ptr< SimPT_Sim::Mesh > & | GetMesh () |
Get the mesh. | |
bool | IsDeletableCell (Cell *cell) const |
Checks whether the given cell is deletable (the mesh should stay consistent). More... | |
bool | IsDeletableNode (Node *node) const |
Checks whether the given node is deletable. More... | |
void | ReplaceCell (Cell *cell, std::list< QPolygonF > newCells) |
Replace a given cell with a set of new cells. More... | |
std::vector< Cell * > | SplitCell (Node *node1, Node *node2) |
Does the same as SplitCell, but finds the correct cell that should be split. More... | |
std::vector< Cell * > | SplitCell (Cell *cell, Node *node1, Node *node2) |
Splits a cell in two by the line made by the two given nodes. More... | |
Node * | SplitEdge (const Edge &edge) |
Split a given edge at the center. More... | |
An editable mesh with actions to alter the construction of the mesh.
Definition at line 35 of file EditableMesh.h.
SimPT_Editor::EditableMesh::EditableMesh | ( | const boost::property_tree::ptree & | pt | ) |
Constructor.
Initialize the EditableMesh with a given ptree.
pt | The given ptree. |
Definition at line 46 of file EditableMesh.cpp.
bool SimPT_Editor::EditableMesh::CanSplitCell | ( | Node * | node1, |
Node * | node2, | ||
Cell * | cell = nullptr |
||
) | const |
Checks whether the two given nodes can split a (given) cell (excluding the boundary polygon).
The nodes shouldn't be adjacent to each other, but should be part of the same cell.
node1 | The first node. |
node2 | The second node. |
cell | The cell that should be tested. (If this isn't given, it will resolved to the correct cell if possible.) |
Definition at line 52 of file EditableMesh.cpp.
References SimPT_Editor::PolygonUtils::SlicePolygon().
Referenced by SplitCell().
Cell * SimPT_Editor::EditableMesh::CreateCell | ( | Node * | node1, |
Node * | node2, | ||
const QPointF & | newPoint | ||
) |
Creates a new cell with the two given nodes and a third new point.
Both given nodes should be located at the boundary of the mesh.
If the cell can't be created because of inconsistency in the mesh, it won't create a new cell. This inconsistency implies that the third point should be located outside the boundary polygon and that the new edges may not intersect with the old ones.
node1 | The first endpoint. |
node2 | The second endpoint. |
newPoint | The third endpoint (a new node will be created). |
Definition at line 122 of file EditableMesh.cpp.
References SimPT_Sim::MeshCheck::CheckAll(), SimPT_Editor::PolygonUtils::IsClockwise(), SimPT_Sim::Container::make_const_circular(), SimPT_Sim::Container::next(), and SimPT_Sim::Container::prev().
Referenced by SimPT_Editor::EditControlLogic::CreateCell().
void SimPT_Editor::EditableMesh::DeleteCells | ( | const std::list< Cell * > & | cells | ) |
Deletes the given cell from the mesh.
The deletion of all those cells should keep the mesh consistent.
cells | The cells that will be deleted. |
Definition at line 335 of file EditableMesh.cpp.
References SimPT_Sim::MeshCheck::CheckAll(), SimPT_Sim::Cell::GetIndex(), SimPT_Sim::Container::make_const_circular(), SimPT_Sim::Container::next(), and SimPT_Sim::Container::prev().
Referenced by SimPT_Editor::EditControlLogic::DeleteCells().
bool SimPT_Editor::EditableMesh::DeleteTwoDegreeNode | ( | Node * | node | ) |
Deletes the given node from the mesh (which should stay consistent).
See the documentation of IsDeletableNode(Node*) for the conditions for a node to be deletable. After this node has been deleted, there will be an edge between the neighbors of this node.
node | The node that will be deleted. |
Definition at line 565 of file EditableMesh.cpp.
References SimPT_Sim::MeshCheck::CheckAll(), and IsDeletableNode().
Referenced by SimPT_Editor::EditControlLogic::DeleteNode().
bool SimPT_Editor::EditableMesh::DisplaceNode | ( | Node * | node, |
double | x, | ||
double | y | ||
) |
Place a node at the given coordinates.
node | The node which should be moved. |
x | The x-coordinate. |
y | The y-coordinate. |
Definition at line 678 of file EditableMesh.cpp.
Referenced by SimPT_Editor::EditControlLogic::MoveNode().
bool SimPT_Editor::EditableMesh::IsDeletableCell | ( | Cell * | cell | ) | const |
Checks whether the given cell is deletable (the mesh should stay consistent).
The cell should be at the boundary, can't be the only cell in the mesh and should be present in the mesh.
Definition at line 834 of file EditableMesh.cpp.
References SimPT_Sim::Cell::GetNodes(), SimPT_Sim::Cell::GetWalls(), and SimPT_Sim::Container::next().
bool SimPT_Editor::EditableMesh::IsDeletableNode | ( | Node * | node | ) | const |
Checks whether the given node is deletable.
A node is deletable if it has a degree of two and is only part of cells with more than three nodes.
node | The given node. |
Definition at line 865 of file EditableMesh.cpp.
References SimPT_Sim::NeighborNodes::GetCell(), SimPT_Sim::NeighborNodes::GetNb1(), SimPT_Sim::NeighborNodes::GetNb2(), and SimPT_Sim::Cell::GetNodes().
Referenced by DeleteTwoDegreeNode().
void SimPT_Editor::EditableMesh::ReplaceCell | ( | Cell * | cell, |
std::list< QPolygonF > | newCells | ||
) |
Replace a given cell with a set of new cells.
cell | The old cell that should be replaced. |
newCells | The endpoints of the new cells. |
Every endpoint of the new cells should already be present in the mesh. Every endpoint in the old cell be an endpoint of at least one of the new cells. The endpoints of the new cells should be in order of connection. The sum of the areas of the new cells should be equal to the area of the old cell.
Definition at line 887 of file EditableMesh.cpp.
References SimPT_Sim::MeshCheck::CheckAll(), SimPT_Sim::NeighborNodes::GetCell(), SimPT_Sim::Edge::GetFirst(), SimPT_Sim::Cell::GetIndex(), SimPT_Sim::Cell::GetNodes(), SimPT_Sim::Edge::GetSecond(), SimPT_Sim::Cell::GetWalls(), SimPT_Editor::PolygonUtils::IsClockwise(), SimPT_Sim::Container::make_circular(), SimPT_Sim::Container::make_const_circular(), and SimPT_Sim::Container::next().
Referenced by SimPT_Editor::EditControlLogic::ReplaceCell().
Does the same as SplitCell, but finds the correct cell that should be split.
If this cell can't be found, an empty vector will be returned.
Definition at line 1231 of file EditableMesh.cpp.
References SimPT_Editor::PolygonUtils::SlicePolygon().
Referenced by SimPT_Editor::EditControlLogic::SplitCell().
Splits a cell in two by the line made by the two given nodes.
If the cell can't be split, an empty vector will be returned.
cell | The cell that should get splitted. |
node1 | The first node of the cut. |
node2 | The second node of the cut. |
Definition at line 1283 of file EditableMesh.cpp.
References CanSplitCell(), SimPT_Sim::MeshCheck::CheckAll(), SimPT_Sim::Cell::GetNodes(), SimPT_Sim::Container::make_const_circular(), and SimPT_Sim::Container::next().
Split a given edge at the center.
edge | The given edge. |
Definition at line 1211 of file EditableMesh.cpp.
References SimPT_Sim::MeshCheck::CheckAll(), SimPT_Sim::Edge::GetFirst(), and SimPT_Sim::Edge::GetSecond().
Referenced by SimPT_Editor::EditControlLogic::SplitEdge().