Script to create Menger sponge

This commit is contained in:
wmayer
2012-03-03 02:37:03 +01:00
parent 1e5d8eeeab
commit d6ea5f782f
5 changed files with 213 additions and 0 deletions

View File

@@ -380,6 +380,30 @@ bool MeshFixDuplicateFacets::Fixup()
// ----------------------------------------------------------------------
bool MeshEvalInternalFacets::Evaluate()
{
_indices.clear();
unsigned long uIndex=0;
const MeshFacetArray& rFaces = _rclMesh.GetFacets();
// get all facets
std::set<FaceIterator, MeshFacet_Less > aFaceSet;
MeshFacetArray::_TConstIterator first = rFaces.begin();
for (MeshFacetArray::_TConstIterator it = rFaces.begin(); it != rFaces.end(); ++it, uIndex++) {
std::pair<std::set<FaceIterator, MeshFacet_Less>::iterator, bool>
pI = aFaceSet.insert(it);
if (!pI.second) {
// collect both elements
_indices.push_back(*pI.first - first);
_indices.push_back(uIndex);
}
}
return _indices.empty();
}
// ----------------------------------------------------------------------
bool MeshEvalDegeneratedFacets::Evaluate()
{
MeshFacetIterator it(_rclMesh);

View File

@@ -188,6 +188,35 @@ public:
bool Fixup ();
};
/**
* The MeshEvalInternalFacets class identifies internal facets of a volume mesh.
* @author Werner Mayer
*/
class MeshExport MeshEvalInternalFacets : public MeshEvaluation
{
public:
/**
* Construction.
*/
MeshEvalInternalFacets (const MeshKernel &rclM) : MeshEvaluation( rclM ) { }
/**
* Destruction.
*/
~MeshEvalInternalFacets () { }
/**
* Identifiy internal facets.
*/
bool Evaluate ();
/**
* Return the indices.
*/
const std::vector<unsigned long>& GetIndices() const
{ return _indices; }
private:
std::vector<unsigned long> _indices;
};
/**
* The MeshEvalDegeneratedFacets class searches for degenerated facets. A facet is degenerated either if its points
* are collinear, i.e. they lie on a line or two points are coincident. In the latter case these points are duplicated.

View File

@@ -127,6 +127,16 @@ Example:
<UserDocu>Remove a list of facet indices from the mesh</UserDocu>
</Documentation>
</Methode>
<Methode Name="getInternalFacets" Const="true">
<Documentation>
<UserDocu>Builds a list of facet indices with triangles that are inside a volume mesh</UserDocu>
</Documentation>
</Methode>
<Methode Name="rebuildNeighbourHood">
<Documentation>
<UserDocu>Repairs the neighbourhood which might be broken</UserDocu>
</Documentation>
</Methode>
<Methode Name="addMesh">
<Documentation>
<UserDocu>Combine this mesh with another mesh.</UserDocu>

View File

@@ -36,6 +36,7 @@
#include "MeshProperties.h"
#include "Core/Algorithm.h"
#include "Core/Iterator.h"
#include "Core/Degeneration.h"
#include "Core/Elements.h"
#include "Core/Grid.h"
#include "Core/MeshKernel.h"
@@ -581,6 +582,35 @@ PyObject* MeshPy::removeFacets(PyObject *args)
Py_Return;
}
PyObject* MeshPy::getInternalFacets(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
MeshCore::MeshEvalInternalFacets eval(kernel);
eval.Evaluate();
const std::vector<unsigned long>& indices = eval.GetIndices();
Py::List ary(indices.size());
Py::List::size_type pos=0;
for (std::vector<unsigned long>::const_iterator it = indices.begin(); it != indices.end(); ++it) {
ary[pos++] = Py::Long(*it);
}
return Py::new_reference_to(ary);
}
PyObject* MeshPy::rebuildNeighbourHood(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
kernel.RebuildNeighbours();
Py_Return;
}
PyObject* MeshPy::addMesh(PyObject *args)
{
PyObject* mesh;