Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mesh: extend API to access edges of a facet via Python
- Loading branch information
Showing
14 changed files
with
558 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> * | ||
* * | ||
* This file is part of the FreeCAD CAx development system. * | ||
* * | ||
* This library is free software; you can redistribute it and/or * | ||
* modify it under the terms of the GNU Library General Public * | ||
* License as published by the Free Software Foundation; either * | ||
* version 2 of the License, or (at your option) any later version. * | ||
* * | ||
* This library is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU Library General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU Library General Public * | ||
* License along with this library; see the file COPYING.LIB. If not, * | ||
* write to the Free Software Foundation, Inc., 51 Franklin Street, * | ||
* Fifth Floor, Boston, MA 02110-1301, USA * | ||
* * | ||
***************************************************************************/ | ||
|
||
|
||
#include "PreCompiled.h" | ||
#ifndef _PreComp_ | ||
# include <sstream> | ||
#endif | ||
|
||
#include "Edge.h" | ||
#include "Mesh.h" | ||
|
||
using namespace Mesh; | ||
|
||
Edge::Edge() | ||
: Index(-1) | ||
, Mesh(nullptr) | ||
{ | ||
for (int i=0; i<2; i++) { | ||
PIndex[i] = MeshCore::POINT_INDEX_MAX; | ||
NIndex[i] = MeshCore::FACET_INDEX_MAX; | ||
} | ||
} | ||
|
||
Edge::Edge(const Edge& e) | ||
: MeshCore::MeshGeomEdge(e) | ||
, Index(e.Index) | ||
, Mesh(e.Mesh) | ||
{ | ||
for (int i=0; i<2; i++) { | ||
PIndex[i] = e.PIndex[i]; | ||
NIndex[i] = e.NIndex[i]; | ||
} | ||
} | ||
|
||
Edge::~Edge() | ||
{ | ||
} | ||
|
||
void Edge::operator = (const Edge& e) | ||
{ | ||
MeshCore::MeshGeomEdge::operator = (e); | ||
Mesh = e.Mesh; | ||
Index = e.Index; | ||
for (int i=0; i<2; i++) { | ||
PIndex[i] = e.PIndex[i]; | ||
NIndex[i] = e.NIndex[i]; | ||
} | ||
} | ||
|
||
void Edge::unbound() | ||
{ | ||
Index = -1; | ||
Mesh = nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> * | ||
* * | ||
* This file is part of the FreeCAD CAx development system. * | ||
* * | ||
* This library is free software; you can redistribute it and/or * | ||
* modify it under the terms of the GNU Library General Public * | ||
* License as published by the Free Software Foundation; either * | ||
* version 2 of the License, or (at your option) any later version. * | ||
* * | ||
* This library is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU Library General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU Library General Public * | ||
* License along with this library; see the file COPYING.LIB. If not, * | ||
* write to the Free Software Foundation, Inc., 51 Franklin Street, * | ||
* Fifth Floor, Boston, MA 02110-1301, USA * | ||
* * | ||
***************************************************************************/ | ||
|
||
|
||
#ifndef MESH_EDGE_H | ||
#define MESH_EDGE_H | ||
|
||
#include <Base/Matrix.h> | ||
#include <Base/Vector3D.h> | ||
#include <Base/Handle.h> | ||
|
||
#include <Mod/Mesh/App/Core/Elements.h> | ||
|
||
namespace Mesh | ||
{ | ||
// forward declaration | ||
class MeshObject; | ||
|
||
/** The Edge helper class | ||
* The Edge class provides an interface for the EdgePy class for | ||
* convenient access to the Mesh data structure. This class should not be used | ||
* for programming algorithms in C++. Use Mesh Core classes instead! | ||
*/ | ||
class MeshExport Edge : public MeshCore::MeshGeomEdge | ||
{ | ||
public: | ||
Edge(); | ||
Edge(const Edge& f); | ||
~Edge(); | ||
|
||
bool isBound() const {return Index != -1;} | ||
void unbound(); | ||
void operator = (const Edge& f); | ||
|
||
int Index; | ||
MeshCore::PointIndex PIndex[2]; | ||
MeshCore::FacetIndex NIndex[2]; | ||
Base::Reference<MeshObject> Mesh; | ||
}; | ||
|
||
} // namespace Mesh | ||
|
||
|
||
#endif // MESH_EDGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd"> | ||
<PythonExport | ||
Father="PyObjectBase" | ||
Name="EdgePy" | ||
Twin="Edge" | ||
TwinPointer="Edge" | ||
Include="Mod/Mesh/App/Edge.h" | ||
FatherInclude="Base/PyObjectBase.h" | ||
Namespace="Mesh" | ||
Constructor="true" | ||
Delete="true" | ||
FatherNamespace="Base"> | ||
<Documentation> | ||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer[at]users.sourceforge.net" /> | ||
<DeveloperDocu>Edge in a Mesh</DeveloperDocu> | ||
<UserDocu>Edge in mesh | ||
This is an edge of a facet in a MeshObject. You can get it by e.g. iterating over the facets of a | ||
mesh and calling getEdge(index). | ||
</UserDocu> | ||
</Documentation> | ||
<Methode Name="intersectWithEdge"> | ||
<Documentation> | ||
<UserDocu>intersectWithEdge(Edge) -> list | ||
Get a list of intersection points with another edge. | ||
</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="isParallel"> | ||
<Documentation> | ||
<UserDocu>isParallel(Edge) -> bool | ||
Checks if the two edges are parallel. | ||
</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="isCollinear"> | ||
<Documentation> | ||
<UserDocu>isCollinear(Edge) -> bool | ||
Checks if the two edges are collinear. | ||
</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="unbound"> | ||
<Documentation> | ||
<UserDocu>method unbound() | ||
Cut the connection to a MeshObject. The edge becomes | ||
free and is more or less a simple edge. | ||
After calling unbound() no topological operation will | ||
work! | ||
</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Attribute Name="Index" ReadOnly="true"> | ||
<Documentation> | ||
<UserDocu>The index of this edge of the facet</UserDocu> | ||
</Documentation> | ||
<Parameter Name="Index" Type="Long"/> | ||
</Attribute> | ||
<Attribute Name="Points" ReadOnly="true"> | ||
<Documentation> | ||
<UserDocu>A list of points of the edge</UserDocu> | ||
</Documentation> | ||
<Parameter Name="Points" Type="List"/> | ||
</Attribute> | ||
<Attribute Name="PointIndices" ReadOnly="true"> | ||
<Documentation> | ||
<UserDocu>The index tuple of point vertices of the mesh this edge is built of</UserDocu> | ||
</Documentation> | ||
<Parameter Name="PointIndices" Type="Tuple"/> | ||
</Attribute> | ||
<Attribute Name="NeighbourIndices" ReadOnly="true"> | ||
<Documentation> | ||
<UserDocu>The index tuple of neighbour facets of the mesh this edge is adjacent with</UserDocu> | ||
</Documentation> | ||
<Parameter Name="NeighbourIndices" Type="Tuple"/> | ||
</Attribute> | ||
<Attribute Name="Length" ReadOnly="true"> | ||
<Documentation> | ||
<UserDocu>The length of the edge</UserDocu> | ||
</Documentation> | ||
<Parameter Name="Length" Type="Float"/> | ||
</Attribute> | ||
<Attribute Name="Bound" ReadOnly="true"> | ||
<Documentation> | ||
<UserDocu>Bound state of the edge</UserDocu> | ||
</Documentation> | ||
<Parameter Name="Bound" Type="Boolean"/> | ||
</Attribute> | ||
</PythonExport> | ||
</GenerateModel> |
Oops, something went wrong.