Skip to content

Instantly share code, notes, and snippets.

Created July 17, 2013 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1a54610a912c49e0d251 to your computer and use it in GitHub Desktop.
Save anonymous/1a54610a912c49e0d251 to your computer and use it in GitHub Desktop.
mitk::Point3D p;
mitk::Mesh::Pointer mesh1 = mitk::Mesh::New();
{ mitk::FillVector3D(p, 0, 0, 0); mitk::PointOperation addPoint(mitk::OpINSERT, p, 0); mesh1->ExecuteOperation(&addPoint); }
{ mitk::FillVector3D(p, 3, 0, 0); mitk::PointOperation addPoint(mitk::OpINSERT, p, 1); mesh1->ExecuteOperation(&addPoint); }
{ mitk::FillVector3D(p, 1.5, 2.5, 0); mitk::PointOperation addPoint(mitk::OpINSERT, p, 2); mesh1->ExecuteOperation(&addPoint); }
{ mitk::FillVector3D(p, 1.5, 1.5, 1.5); mitk::PointOperation addPoint(mitk::OpINSERT, p, 3); mesh1->ExecuteOperation(&addPoint); }
{
const unsigned int cellId = mesh1->GetNewCellId(); mitk::LineOperation newCell(mitk::OpNEWCELL, cellId); mesh1->ExecuteOperation(&newCell);
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 0); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 1); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 2); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation closeCell(mitk::OpCLOSECELL, cellId); mesh1->ExecuteOperation(&closeCell); }
}
{
const unsigned int cellId = mesh1->GetNewCellId(); mitk::LineOperation newCell(mitk::OpNEWCELL, cellId); mesh1->ExecuteOperation(&newCell);
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 0); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 1); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 3); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation closeCell(mitk::OpCLOSECELL, cellId); mesh1->ExecuteOperation(&closeCell); }
}
{
const unsigned int cellId = mesh1->GetNewCellId(); mitk::LineOperation newCell(mitk::OpNEWCELL, cellId); mesh1->ExecuteOperation(&newCell);
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 0); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 2); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 3); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation closeCell(mitk::OpCLOSECELL, cellId); mesh1->ExecuteOperation(&closeCell); }
}
{
const unsigned int cellId = mesh1->GetNewCellId(); mitk::LineOperation newCell(mitk::OpNEWCELL, cellId); mesh1->ExecuteOperation(&newCell);
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 1); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 2); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 3); mesh1->ExecuteOperation(&addLine); }
{ mitk::LineOperation closeCell(mitk::OpCLOSECELL, cellId); mesh1->ExecuteOperation(&closeCell); }
}
// Same mesh but translated by (1, 0, 1)
mitk::Mesh::Pointer mesh2 = mitk::Mesh::New();
{ mitk::FillVector3D(p, 1, 0, 1); mitk::PointOperation addPoint(mitk::OpINSERT, p, 0); mesh2->ExecuteOperation(&addPoint); }
{ mitk::FillVector3D(p, 4, 0, 1); mitk::PointOperation addPoint(mitk::OpINSERT, p, 1); mesh2->ExecuteOperation(&addPoint); }
{ mitk::FillVector3D(p, 2.5, 3.5, 1); mitk::PointOperation addPoint(mitk::OpINSERT, p, 2); mesh2->ExecuteOperation(&addPoint); }
{ mitk::FillVector3D(p, 2.5, 2.5, 2.5); mitk::PointOperation addPoint(mitk::OpINSERT, p, 3); mesh2->ExecuteOperation(&addPoint); }
{
const unsigned int cellId = mesh2->GetNewCellId(); mitk::LineOperation newCell(mitk::OpNEWCELL, cellId); mesh2->ExecuteOperation(&newCell);
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 0); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 1); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 2); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation closeCell(mitk::OpCLOSECELL, cellId); mesh2->ExecuteOperation(&closeCell); }
}
{
const unsigned int cellId = mesh2->GetNewCellId(); mitk::LineOperation newCell(mitk::OpNEWCELL, cellId); mesh2->ExecuteOperation(&newCell);
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 0); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 1); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 3); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation closeCell(mitk::OpCLOSECELL, cellId); mesh2->ExecuteOperation(&closeCell); }
}
{
const unsigned int cellId = mesh2->GetNewCellId(); mitk::LineOperation newCell(mitk::OpNEWCELL, cellId); mesh2->ExecuteOperation(&newCell);
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 0); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 2); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 3); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation closeCell(mitk::OpCLOSECELL, cellId); mesh2->ExecuteOperation(&closeCell); }
}
{
const unsigned int cellId = mesh2->GetNewCellId(); mitk::LineOperation newCell(mitk::OpNEWCELL, cellId); mesh2->ExecuteOperation(&newCell);
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 1); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 2); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation addLine(mitk::OpADDLINE, cellId, 3); mesh2->ExecuteOperation(&addLine); }
{ mitk::LineOperation closeCell(mitk::OpCLOSECELL, cellId); mesh2->ExecuteOperation(&closeCell); }
}
mitk::Mesh::Pointer mesh = mitk::Mesh::New();
mesh->SetMesh(mesh1->GetMesh(0), 0);
mesh->SetMesh(mesh2->GetMesh(0), 1);
mitk::DataNode::Pointer meshNode = mitk::DataNode::New();
meshNode->SetData(mesh);
meshNode->SetStringProperty("name", "My mesh!");
meshNode->SetBoolProperty("show points", false);
meshNode->SetBoolProperty("show contour", true);
GetDataStorage()->Add(meshNode, m_CurrentImageNode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment