expose mesh analyzing functions to Python
This commit is contained in:
@@ -39,7 +39,14 @@ Get a list of intersection points with another triangle.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Index" ReadOnly="true">
|
||||
<Methode Name="isDegenerated">
|
||||
<Documentation>
|
||||
<UserDocu>isDegenerated([float]) -> boolean
|
||||
Returns true if the facet is degenerated, otherwise false.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Index" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The index of this facet in the MeshObject</UserDocu>
|
||||
</Documentation>
|
||||
|
||||
@@ -128,6 +128,22 @@ PyObject* FacetPy::intersect(PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* FacetPy::isDegenerated(PyObject *args)
|
||||
{
|
||||
float fEpsilon = MeshCore::MeshDefinitions::_fMinPointDistanceP2;
|
||||
if (!PyArg_ParseTuple(args, "|f", &fEpsilon))
|
||||
return NULL;
|
||||
|
||||
FacetPy::PointerType face = this->getFacetPtr();
|
||||
if (!face->isBound()) {
|
||||
throw Py::RuntimeError("Unbound facet");
|
||||
}
|
||||
|
||||
const MeshCore::MeshKernel& kernel = face->Mesh->getKernel();
|
||||
MeshCore::MeshGeomFacet tria = kernel.GetFacet(face->Index);
|
||||
return Py::new_reference_to(Py::Boolean(tria.IsDegenerated(fEpsilon)));
|
||||
}
|
||||
|
||||
Py::List FacetPy::getPoints(void) const
|
||||
{
|
||||
FacetPy::PointerType face = this->getFacetPtr();
|
||||
@@ -160,8 +176,9 @@ Py::Tuple FacetPy::getPointIndices(void) const
|
||||
Py::Tuple FacetPy::getNeighbourIndices(void) const
|
||||
{
|
||||
FacetPy::PointerType face = this->getFacetPtr();
|
||||
if (!face->isBound())
|
||||
{ return Py::Tuple(); }
|
||||
if (!face->isBound()) {
|
||||
return Py::Tuple();
|
||||
}
|
||||
|
||||
Py::Tuple idxTuple(3);
|
||||
for (int i=0; i<3; i++) {
|
||||
@@ -173,8 +190,9 @@ Py::Tuple FacetPy::getNeighbourIndices(void) const
|
||||
Py::Float FacetPy::getArea(void) const
|
||||
{
|
||||
FacetPy::PointerType face = this->getFacetPtr();
|
||||
if (!face->isBound())
|
||||
{ return Py::Float(0.0); }
|
||||
if (!face->isBound()) {
|
||||
return Py::Float(0.0);
|
||||
}
|
||||
|
||||
const MeshCore::MeshKernel& kernel = face->Mesh->getKernel();
|
||||
MeshCore::MeshGeomFacet tria = kernel.GetFacet(face->Index);
|
||||
|
||||
@@ -250,7 +250,12 @@ for c in mesh.getSeparatecomponents():
|
||||
<UserDocu>Get the number of wrong oriented facets</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="hasInvalidPoints" Const="true">
|
||||
<Methode Name="getNonUniformOrientedFacets" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Get a tuple of wrong oriented facets</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="hasInvalidPoints" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Check if the mesh has points with invalid coordinates (NaN)</UserDocu>
|
||||
</Documentation>
|
||||
|
||||
@@ -1000,6 +1000,22 @@ PyObject* MeshPy::countNonUniformOrientedFacets(PyObject *args)
|
||||
return Py_BuildValue("k", count);
|
||||
}
|
||||
|
||||
PyObject* MeshPy::getNonUniformOrientedFacets(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
|
||||
const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
|
||||
MeshCore::MeshEvalOrientation cMeshEval(kernel);
|
||||
std::vector<unsigned long> inds = cMeshEval.GetIndices();
|
||||
Py::Tuple tuple(inds.size());
|
||||
for (std::size_t i=0; i<inds.size(); i++) {
|
||||
tuple.setItem(i, Py::Long(inds[i]));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(tuple);
|
||||
}
|
||||
|
||||
PyObject* MeshPy::harmonizeNormals(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkDegenrated">
|
||||
<property name="text">
|
||||
<string>Consider a face only degenerated if it has no area</string>
|
||||
<string>Only consider zero area faces as degenerated</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
|
||||
Reference in New Issue
Block a user