VPTissue Reference Manual
SimPT_Editor::EditableMesh Class Reference

An editable mesh with actions to alter the construction of the mesh. More...

#include <EditableMesh.h>

Collaboration diagram for SimPT_Editor::EditableMesh:
Collaboration graph

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...
 
CellCreateCell (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...
 
NodeSplitEdge (const Edge &edge)
 Split a given edge at the center. More...
 

Detailed Description

An editable mesh with actions to alter the construction of the mesh.

Definition at line 35 of file EditableMesh.h.

Constructor & Destructor Documentation

SimPT_Editor::EditableMesh::EditableMesh ( const boost::property_tree::ptree &  pt)

Constructor.

Initialize the EditableMesh with a given ptree.

Parameters
ptThe given ptree.

Definition at line 46 of file EditableMesh.cpp.

Member Function Documentation

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.

Parameters
node1The first node.
node2The second node.
cellThe cell that should be tested. (If this isn't given, it will resolved to the correct cell if possible.)
Returns
True if the given cell or the resolved cell can be split.

Definition at line 52 of file EditableMesh.cpp.

References SimPT_Editor::PolygonUtils::SlicePolygon().

Referenced by SplitCell().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
node1The first endpoint.
node2The second endpoint.
newPointThe third endpoint (a new node will be created).
Returns
The new cell if it can be created, otherwise a nullptr.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
cellsThe 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
nodeThe node that will be deleted.
Returns
True if the node can be deleted.

Definition at line 565 of file EditableMesh.cpp.

References SimPT_Sim::MeshCheck::CheckAll(), and IsDeletableNode().

Referenced by SimPT_Editor::EditControlLogic::DeleteNode().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SimPT_Editor::EditableMesh::DisplaceNode ( Node node,
double  x,
double  y 
)

Place a node at the given coordinates.

Parameters
nodeThe node which should be moved.
xThe x-coordinate.
yThe y-coordinate.
Returns
True if the node can be moved (without violation the mesh consistency).

Definition at line 678 of file EditableMesh.cpp.

Referenced by SimPT_Editor::EditControlLogic::MoveNode().

Here is the caller graph for this function:

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.

Returns
True if the cell is deletable.

Definition at line 834 of file EditableMesh.cpp.

References SimPT_Sim::Cell::GetNodes(), SimPT_Sim::Cell::GetWalls(), and SimPT_Sim::Container::next().

Here is the call graph for this function:

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.

Parameters
nodeThe given node.
Returns
True if the node is deletable.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void SimPT_Editor::EditableMesh::ReplaceCell ( Cell cell,
std::list< QPolygonF >  newCells 
)

Replace a given cell with a set of new cells.

Parameters
cellThe old cell that should be replaced.
newCellsThe 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().

Here is the call graph for this function:

Here is the caller graph for this function:

vector< Cell * > SimPT_Editor::EditableMesh::SplitCell ( Node node1,
Node node2 
)

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().

Here is the call graph for this function:

Here is the caller graph for this function:

vector< Cell * > SimPT_Editor::EditableMesh::SplitCell ( Cell cell,
Node node1,
Node node2 
)

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.

Parameters
cellThe cell that should get splitted.
node1The first node of the cut.
node2The second node of the cut.
Returns
The two new cells if the splitting succeeded, otherwise the old cell will be returned.

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().

Here is the call graph for this function:

Node * SimPT_Editor::EditableMesh::SplitEdge ( const Edge edge)

Split a given edge at the center.

Parameters
edgeThe given edge.
Returns
The new made node at the split.

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().

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: