+ implement method getPointNormals
This commit is contained in:
parent
9846e52ed9
commit
3a4e93bb3d
|
@ -834,6 +834,26 @@ Base::Vector3d MeshObject::getPointNormal(unsigned long index) const
|
|||
return normal;
|
||||
}
|
||||
|
||||
std::vector<Base::Vector3d> MeshObject::getPointNormals() const
|
||||
{
|
||||
std::vector<Base::Vector3f> temp = _kernel.CalcVertexNormals();
|
||||
|
||||
std::vector<Base::Vector3d> normals;
|
||||
normals.reserve(temp.size());
|
||||
for (std::vector<Base::Vector3f>::iterator it = temp.begin(); it != temp.end(); ++it) {
|
||||
Base::Vector3d normal = transformToOutside(*it);
|
||||
// the normal is a vector, hence we must not apply the translation part
|
||||
// of the transformation to the vector
|
||||
normal.x -= _Mtrx[0][3];
|
||||
normal.y -= _Mtrx[1][3];
|
||||
normal.z -= _Mtrx[2][3];
|
||||
normal.Normalize();
|
||||
normals.push_back(normal);
|
||||
}
|
||||
|
||||
return normals;
|
||||
}
|
||||
|
||||
void MeshObject::crossSections(const std::vector<MeshObject::TPlane>& planes, std::vector<MeshObject::TPolylines> §ions,
|
||||
float fMinEps, bool bConnectPolygons) const
|
||||
{
|
||||
|
|
|
@ -205,6 +205,7 @@ public:
|
|||
void setPoint(unsigned long, const Base::Vector3d& v);
|
||||
void smooth(int iterations, float d_max);
|
||||
Base::Vector3d getPointNormal(unsigned long) const;
|
||||
std::vector<Base::Vector3d> getPointNormals() const;
|
||||
void crossSections(const std::vector<TPlane>&, std::vector<TPolylines> §ions,
|
||||
float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const;
|
||||
void cut(const Base::Polygon2D& polygon, const Base::ViewProjMethod& proj, CutType);
|
||||
|
|
|
@ -155,6 +155,14 @@ Example:
|
|||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getPointNormals" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
getPointNormals()
|
||||
Get the normals of the points.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="countSegments" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Get the number of segments which may also be 0</UserDocu>
|
||||
|
|
|
@ -685,6 +685,22 @@ PyObject* MeshPy::setPoint(PyObject *args)
|
|||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* MeshPy::getPointNormals(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
|
||||
PY_TRY {
|
||||
std::vector<Base::Vector3d> normals = getMeshObjectPtr()->getPointNormals();
|
||||
Py::Tuple ary(normals.size());
|
||||
std::size_t numNormals = normals.size();
|
||||
for (std::size_t i=0; i<numNormals; i++) {
|
||||
ary.setItem(i, Py::Vector(normals[i]));
|
||||
}
|
||||
return Py::new_reference_to(ary);
|
||||
} PY_CATCH;
|
||||
}
|
||||
|
||||
PyObject* MeshPy::countSegments(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
|
|
Loading…
Reference in New Issue
Block a user