All: Reformat according to new standard

This commit is contained in:
pre-commit-ci[bot]
2025-11-11 13:49:01 +01:00
committed by Kacper Donat
parent ef997f2259
commit 9fe130cd73
2390 changed files with 154630 additions and 115818 deletions

View File

@@ -27,7 +27,7 @@
#include <FCConfig.h>
#ifdef FC_OS_LINUX
#include <unistd.h>
# include <unistd.h>
#endif
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
@@ -111,8 +111,7 @@ void CurveProjectorShape::Do()
}
void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
std::vector<FaceSplitEdge>& vSplitEdges)
void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge, std::vector<FaceSplitEdge>& vSplitEdges)
{
Standard_Real fFirst, fLast;
Handle(Geom_Curve) hCurve = BRep_Tool::Curve(aEdge, fFirst, fLast);
@@ -124,8 +123,8 @@ void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
Base::Vector3f cStartPoint = Base::Vector3f((float)gpPt.X(), (float)gpPt.Y(), (float)gpPt.Z());
Base::Vector3f cResultPoint, cSplitPoint, cPlanePnt, cPlaneNormal;
MeshCore::FacetIndex uStartFacetIdx, uCurFacetIdx;
MeshCore::FacetIndex uLastFacetIdx =
MeshCore::FACET_INDEX_MAX - 1; // use another value as FACET_INDEX_MAX
MeshCore::FacetIndex uLastFacetIdx = MeshCore::FACET_INDEX_MAX
- 1; // use another value as FACET_INDEX_MAX
MeshCore::FacetIndex auNeighboursIdx[3];
bool GoOn;
@@ -136,10 +135,12 @@ void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
uCurFacetIdx = uStartFacetIdx;
do {
MeshGeomFacet cCurFacet = _Mesh.GetFacet(uCurFacetIdx);
_Mesh.GetFacetNeighbours(uCurFacetIdx,
auNeighboursIdx[0],
auNeighboursIdx[1],
auNeighboursIdx[2]);
_Mesh.GetFacetNeighbours(
uCurFacetIdx,
auNeighboursIdx[0],
auNeighboursIdx[1],
auNeighboursIdx[2]
);
Base::Vector3f PointOnEdge[3];
GoOn = false;
@@ -168,9 +169,10 @@ void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
cPlanePnt = cP0;
}
Handle(Geom_Plane) hPlane =
new Geom_Plane(gp_Pln(gp_Pnt(cPlanePnt.x, cPlanePnt.y, cPlanePnt.z),
gp_Dir(cPlaneNormal.x, cPlaneNormal.y, cPlaneNormal.z)));
Handle(Geom_Plane) hPlane = new Geom_Plane(gp_Pln(
gp_Pnt(cPlanePnt.x, cPlanePnt.y, cPlanePnt.z),
gp_Dir(cPlaneNormal.x, cPlaneNormal.y, cPlaneNormal.z)
));
GeomAPI_IntCS Alg(hCurve, hPlane);
@@ -199,10 +201,12 @@ void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
}
else if (Alg.NbPoints() > 1) {
PointOnEdge[i] = Base::Vector3f(std::numeric_limits<float>::max(), 0, 0);
Base::Console().log("MeshAlgos::projectCurve(): More then one intersection in "
"Facet %lu, Edge %d\n",
uCurFacetIdx,
i);
Base::Console().log(
"MeshAlgos::projectCurve(): More then one intersection in "
"Facet %lu, Edge %d\n",
uCurFacetIdx,
i
);
}
}
}
@@ -220,8 +224,10 @@ void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
GoOn = true;
}
else {
Base::Console().log("MeshAlgos::projectCurve(): Possible reentry in Facet %lu\n",
uCurFacetIdx);
Base::Console().log(
"MeshAlgos::projectCurve(): Possible reentry in Facet %lu\n",
uCurFacetIdx
);
}
if (uCurFacetIdx == uStartFacetIdx) {
@@ -231,10 +237,12 @@ void CurveProjectorShape::projectCurve(const TopoDS_Edge& aEdge,
} while (GoOn);
}
bool CurveProjectorShape::findStartPoint(const MeshKernel& MeshK,
const Base::Vector3f& Pnt,
Base::Vector3f& Rslt,
MeshCore::FacetIndex& FaceIndex)
bool CurveProjectorShape::findStartPoint(
const MeshKernel& MeshK,
const Base::Vector3f& Pnt,
Base::Vector3f& Rslt,
MeshCore::FacetIndex& FaceIndex
)
{
Base::Vector3f TempResultPoint;
float MinLength = std::numeric_limits<float>::max();
@@ -285,9 +293,11 @@ void CurveProjectorSimple::Do()
}
}
void CurveProjectorSimple::GetSampledCurves(const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& rclPoints,
unsigned long ulNbOfPoints)
void CurveProjectorSimple::GetSampledCurves(
const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& rclPoints,
unsigned long ulNbOfPoints
)
{
rclPoints.clear();
@@ -305,9 +315,11 @@ void CurveProjectorSimple::GetSampledCurves(const TopoDS_Edge& aEdge,
// projectToNeighbours(Handle(Geom_Curve) hCurve,float pos
void CurveProjectorSimple::projectCurve(const TopoDS_Edge& aEdge,
const std::vector<Base::Vector3f>&,
std::vector<FaceSplitEdge>&)
void CurveProjectorSimple::projectCurve(
const TopoDS_Edge& aEdge,
const std::vector<Base::Vector3f>&,
std::vector<FaceSplitEdge>&
)
{
Base::Vector3f TempResultPoint;
bool bFirst = true;
@@ -338,7 +350,8 @@ void CurveProjectorSimple::projectCurve(const TopoDS_Edge& aEdge,
if (It->IntersectWithLine(
Base::Vector3f((float)gpPt.X(), (float)gpPt.Y(), (float)gpPt.Z()),
It->GetNormal(),
TempResultPoint)) {
TempResultPoint
)) {
FaceProjctMap[It.Position()].push_back(TempResultPoint);
str << TempResultPoint.x << " " << TempResultPoint.y << " " << TempResultPoint.z
<< std::endl;
@@ -354,16 +367,16 @@ void CurveProjectorSimple::projectCurve(const TopoDS_Edge& aEdge,
}
str.close();
Base::Console().log("Projection map [%d facets with %d points]\n",
FaceProjctMap.size(),
PointCount);
Base::Console().log("Projection map [%d facets with %d points]\n", FaceProjctMap.size(), PointCount);
}
bool CurveProjectorSimple::findStartPoint(const MeshKernel& MeshK,
const Base::Vector3f& Pnt,
Base::Vector3f& Rslt,
MeshCore::FacetIndex& FaceIndex)
bool CurveProjectorSimple::findStartPoint(
const MeshKernel& MeshK,
const Base::Vector3f& Pnt,
Base::Vector3f& Rslt,
MeshCore::FacetIndex& FaceIndex
)
{
Base::Vector3f TempResultPoint;
float MinLength = std::numeric_limits<float>::max();
@@ -394,9 +407,11 @@ bool CurveProjectorSimple::findStartPoint(const MeshKernel& MeshK,
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CurveProjectorWithToolMesh::CurveProjectorWithToolMesh(const TopoDS_Shape& aShape,
const MeshKernel& pMesh,
MeshKernel& rToolMesh)
CurveProjectorWithToolMesh::CurveProjectorWithToolMesh(
const TopoDS_Shape& aShape,
const MeshKernel& pMesh,
MeshKernel& rToolMesh
)
: CurveProjector(aShape, pMesh)
, ToolMesh(rToolMesh)
{
@@ -419,8 +434,7 @@ void CurveProjectorWithToolMesh::Do()
// projectToNeighbours(Handle(Geom_Curve) hCurve,float pos
void CurveProjectorWithToolMesh::makeToolMesh(const TopoDS_Edge& aEdge,
std::vector<MeshGeomFacet>& cVAry)
void CurveProjectorWithToolMesh::makeToolMesh(const TopoDS_Edge& aEdge, std::vector<MeshGeomFacet>& cVAry)
{
Standard_Real fBegin, fEnd;
Handle(Geom_Curve) hCurve = BRep_Tool::Curve(aEdge, fBegin, fEnd);
@@ -450,7 +464,8 @@ void CurveProjectorWithToolMesh::makeToolMesh(const TopoDS_Edge& aEdge,
if (It->IntersectWithLine(
Base::Vector3f((float)gpPt.X(), (float)gpPt.Y(), (float)gpPt.Z()),
It->GetNormal(),
cResultPoint)) {
cResultPoint
)) {
if (Base::Distance(LinePoint, cResultPoint) < 0.5) {
ResultNormal += It->GetNormal();
}
@@ -462,9 +477,7 @@ void CurveProjectorWithToolMesh::makeToolMesh(const TopoDS_Edge& aEdge,
LineSegs.push_back(s);
}
Base::Console().log("Projection map [%d facets with %d points]\n",
FaceProjctMap.size(),
PointCount);
Base::Console().log("Projection map [%d facets with %d points]\n", FaceProjctMap.size(), PointCount);
// build up the new mesh
@@ -497,9 +510,11 @@ MeshProjection::MeshProjection(const MeshKernel& rMesh)
: _rcMesh(rMesh)
{}
void MeshProjection::discretize(const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& polyline,
std::size_t minPoints) const
void MeshProjection::discretize(
const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& polyline,
std::size_t minPoints
) const
{
BRepAdaptor_Curve clCurve(aEdge);
@@ -516,10 +531,7 @@ void MeshProjection::discretize(const TopoDS_Edge& aEdge,
}
if (polyline.size() < minPoints) {
GCPnts_UniformAbscissa clAbsc(clCurve,
static_cast<Standard_Integer>(minPoints),
fFirst,
fLast);
GCPnts_UniformAbscissa clAbsc(clCurve, static_cast<Standard_Integer>(minPoints), fFirst, fLast);
if (clAbsc.IsDone() == Standard_True) {
polyline.clear();
Standard_Integer nNbPoints = clAbsc.NbPoints();
@@ -548,10 +560,12 @@ void MeshProjection::splitMeshByShape(const TopoDS_Shape& aShape, float fMaxDist
str.close();
}
bool MeshProjection::findIntersection(const Edge& edgeSegm,
const Edge& meshEdge,
const Base::Vector3f& dir,
Base::Vector3f& res) const
bool MeshProjection::findIntersection(
const Edge& edgeSegm,
const Edge& meshEdge,
const Base::Vector3f& dir,
Base::Vector3f& res
) const
{
Base::Vector3f planeNormal;
planeNormal = dir.Cross(edgeSegm.cPt2 - edgeSegm.cPt1);
@@ -572,9 +586,11 @@ bool MeshProjection::findIntersection(const Edge& edgeSegm,
return false;
}
void MeshProjection::findSectionParameters(const TopoDS_Edge& edge,
const Base::Vector3f& dir,
std::set<double>& parameters) const
void MeshProjection::findSectionParameters(
const TopoDS_Edge& edge,
const Base::Vector3f& dir,
std::set<double>& parameters
) const
{
MeshAlgorithm clAlg(_rcMesh);
float fAvgLen = clAlg.GetAverageEdgeLength();
@@ -630,9 +646,11 @@ void MeshProjection::findSectionParameters(const TopoDS_Edge& edge,
}
}
void MeshProjection::projectToMesh(const TopoDS_Shape& aShape,
float fMaxDist,
std::vector<PolyLine>& rPolyLines) const
void MeshProjection::projectToMesh(
const TopoDS_Shape& aShape,
float fMaxDist,
std::vector<PolyLine>& rPolyLines
) const
{
// calculate the average edge length and create a grid
MeshAlgorithm clAlg(_rcMesh);
@@ -662,10 +680,12 @@ void MeshProjection::projectToMesh(const TopoDS_Shape& aShape,
}
}
void MeshProjection::projectOnMesh(const std::vector<Base::Vector3f>& pointsIn,
const Base::Vector3f& dir,
float tolerance,
std::vector<Base::Vector3f>& pointsOut) const
void MeshProjection::projectOnMesh(
const std::vector<Base::Vector3f>& pointsIn,
const Base::Vector3f& dir,
float tolerance,
std::vector<Base::Vector3f>& pointsOut
) const
{
// calculate the average edge length and create a grid
MeshAlgorithm clAlg(_rcMesh);
@@ -711,13 +731,15 @@ void MeshProjection::projectOnMesh(const std::vector<Base::Vector3f>& pointsIn,
else {
// go through the boundary points and check if the point can be directly projected
// onto one of them
auto boundaryPnt = std::find_if(boundaryPoints.begin(),
boundaryPoints.end(),
[&it, &dir](const Base::Vector3f& pnt) -> bool {
Base::Vector3f vec = pnt - it;
float angle = vec.GetAngle(dir);
return angle < 1e-6f;
});
auto boundaryPnt = std::find_if(
boundaryPoints.begin(),
boundaryPoints.end(),
[&it, &dir](const Base::Vector3f& pnt) -> bool {
Base::Vector3f vec = pnt - it;
float angle = vec.GetAngle(dir);
return angle < 1e-6f;
}
);
if (boundaryPnt != boundaryPoints.end()) {
pointsOut.push_back(*boundaryPnt);
@@ -743,9 +765,11 @@ void MeshProjection::projectOnMesh(const std::vector<Base::Vector3f>& pointsIn,
}
}
void MeshProjection::projectParallelToMesh(const TopoDS_Shape& aShape,
const Base::Vector3f& dir,
std::vector<PolyLine>& rPolyLines) const
void MeshProjection::projectParallelToMesh(
const TopoDS_Shape& aShape,
const Base::Vector3f& dir,
std::vector<PolyLine>& rPolyLines
) const
{
// calculate the average edge length and create a grid
MeshAlgorithm clAlg(_rcMesh);
@@ -787,13 +811,15 @@ void MeshProjection::projectParallelToMesh(const TopoDS_Shape& aShape,
PolyLine polyline;
for (auto it : hitPointPairs) {
points.clear();
if (meshProjection.projectLineOnMesh(cGrid,
it.first.first,
it.first.second,
it.second.first,
it.second.second,
dir,
points)) {
if (meshProjection.projectLineOnMesh(
cGrid,
it.first.first,
it.first.second,
it.second.first,
it.second.second,
dir,
points
)) {
polyline.points.insert(polyline.points.end(), points.begin(), points.end());
}
}
@@ -803,9 +829,11 @@ void MeshProjection::projectParallelToMesh(const TopoDS_Shape& aShape,
}
}
void MeshProjection::projectParallelToMesh(const std::vector<PolyLine>& aEdges,
const Base::Vector3f& dir,
std::vector<PolyLine>& rPolyLines) const
void MeshProjection::projectParallelToMesh(
const std::vector<PolyLine>& aEdges,
const Base::Vector3f& dir,
std::vector<PolyLine>& rPolyLines
) const
{
// calculate the average edge length and create a grid
MeshAlgorithm clAlg(_rcMesh);
@@ -839,13 +867,15 @@ void MeshProjection::projectParallelToMesh(const std::vector<PolyLine>& aEdges,
PolyLine polyline;
for (auto it : hitPointPairs) {
points.clear();
if (meshProjection.projectLineOnMesh(cGrid,
it.first.first,
it.first.second,
it.second.first,
it.second.second,
dir,
points)) {
if (meshProjection.projectLineOnMesh(
cGrid,
it.first.first,
it.first.second,
it.second.first,
it.second.second,
dir,
points
)) {
polyline.points.insert(polyline.points.end(), points.begin(), points.end());
}
}
@@ -855,10 +885,12 @@ void MeshProjection::projectParallelToMesh(const std::vector<PolyLine>& aEdges,
}
}
void MeshProjection::projectEdgeToEdge(const TopoDS_Edge& aEdge,
float fMaxDist,
const MeshFacetGrid& rGrid,
std::vector<SplitEdge>& rSplitEdges) const
void MeshProjection::projectEdgeToEdge(
const TopoDS_Edge& aEdge,
float fMaxDist,
const MeshFacetGrid& rGrid,
std::vector<SplitEdge>& rSplitEdges
) const
{
std::vector<MeshCore::FacetIndex> auFInds;
std::map<std::pair<MeshCore::PointIndex, MeshCore::PointIndex>, std::list<MeshCore::FacetIndex>>
@@ -878,12 +910,13 @@ void MeshProjection::projectEdgeToEdge(const TopoDS_Edge& aEdge,
for (MeshCore::FacetIndex index : auFInds) {
const MeshFacet& rF = rclFAry[index];
for (int i = 0; i < 3; i++) {
MeshCore::PointIndex ulPt0 =
std::min<MeshCore::PointIndex>(rF._aulPoints[i], rF._aulPoints[(i + 1) % 3]);
MeshCore::PointIndex ulPt1 =
std::max<MeshCore::PointIndex>(rF._aulPoints[i], rF._aulPoints[(i + 1) % 3]);
pEdgeToFace[std::pair<MeshCore::PointIndex, MeshCore::PointIndex>(ulPt0, ulPt1)]
.push_front(index);
MeshCore::PointIndex ulPt0
= std::min<MeshCore::PointIndex>(rF._aulPoints[i], rF._aulPoints[(i + 1) % 3]);
MeshCore::PointIndex ulPt1
= std::max<MeshCore::PointIndex>(rF._aulPoints[i], rF._aulPoints[(i + 1) % 3]);
pEdgeToFace[std::pair<MeshCore::PointIndex, MeshCore::PointIndex>(ulPt0, ulPt1)].push_front(
index
);
}
}
@@ -899,8 +932,8 @@ void MeshProjection::projectEdgeToEdge(const TopoDS_Edge& aEdge,
MeshFacetIterator cFI(_rcMesh);
Base::SequencerLauncher seq("Project curve on mesh", pEdgeToFace.size());
std::map<std::pair<MeshCore::PointIndex, MeshCore::PointIndex>,
std::list<MeshCore::FacetIndex>>::iterator it;
std::map<std::pair<MeshCore::PointIndex, MeshCore::PointIndex>, std::list<MeshCore::FacetIndex>>::iterator
it;
for (it = pEdgeToFace.begin(); it != pEdgeToFace.end(); ++it) {
seq.next();
@@ -925,9 +958,9 @@ void MeshProjection::projectEdgeToEdge(const TopoDS_Edge& aEdge,
// create a plane from the edge normal and point
Base::Vector3f cPlaneNormal = cEdgeNormal % (cE1 - cE0);
Handle(Geom_Plane) hPlane =
new Geom_Plane(gp_Pln(gp_Pnt(cE0.x, cE0.y, cE0.z),
gp_Dir(cPlaneNormal.x, cPlaneNormal.y, cPlaneNormal.z)));
Handle(Geom_Plane) hPlane = new Geom_Plane(
gp_Pln(gp_Pnt(cE0.x, cE0.y, cE0.z), gp_Dir(cPlaneNormal.x, cPlaneNormal.y, cPlaneNormal.z))
);
// get intersection of curve and plane
GeomAPI_IntCS Alg(hCurve, hPlane);

View File

@@ -104,10 +104,12 @@ public:
void projectCurve(const TopoDS_Edge& aEdge, std::vector<FaceSplitEdge>& vSplitEdges);
bool findStartPoint(const MeshKernel& MeshK,
const Base::Vector3f& Pnt,
Base::Vector3f& Rslt,
MeshCore::FacetIndex& FaceIndex);
bool findStartPoint(
const MeshKernel& MeshK,
const Base::Vector3f& Pnt,
Base::Vector3f& Rslt,
MeshCore::FacetIndex& FaceIndex
);
protected:
@@ -124,19 +126,25 @@ public:
~CurveProjectorSimple() override = default;
/// helper to discredicice a Edge...
void GetSampledCurves(const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& rclPoints,
unsigned long ulNbOfPoints = 30);
void GetSampledCurves(
const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& rclPoints,
unsigned long ulNbOfPoints = 30
);
void projectCurve(const TopoDS_Edge& aEdge,
const std::vector<Base::Vector3f>& rclPoints,
std::vector<FaceSplitEdge>& vSplitEdges);
void projectCurve(
const TopoDS_Edge& aEdge,
const std::vector<Base::Vector3f>& rclPoints,
std::vector<FaceSplitEdge>& vSplitEdges
);
bool findStartPoint(const MeshKernel& MeshK,
const Base::Vector3f& Pnt,
Base::Vector3f& Rslt,
MeshCore::FacetIndex& FaceIndex);
bool findStartPoint(
const MeshKernel& MeshK,
const Base::Vector3f& Pnt,
Base::Vector3f& Rslt,
MeshCore::FacetIndex& FaceIndex
);
protected:
@@ -154,9 +162,7 @@ public:
Base::Vector3f n;
};
CurveProjectorWithToolMesh(const TopoDS_Shape& aShape,
const MeshKernel& pMesh,
MeshKernel& rToolMesh);
CurveProjectorWithToolMesh(const TopoDS_Shape& aShape, const MeshKernel& pMesh, MeshKernel& rToolMesh);
~CurveProjectorWithToolMesh() override = default;
@@ -202,20 +208,22 @@ public:
* @param dir
* @param parameters
*/
void findSectionParameters(const TopoDS_Edge& edge,
const Base::Vector3f& dir,
std::set<double>& parameters) const;
void discretize(const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& polyline,
std::size_t minPoints = 2) const;
void findSectionParameters(
const TopoDS_Edge& edge,
const Base::Vector3f& dir,
std::set<double>& parameters
) const;
void discretize(
const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& polyline,
std::size_t minPoints = 2
) const;
/**
* Searches all edges that intersect with the projected curve \a aShape. Therefore \a aShape
* must contain shapes of type TopoDS_Edge, other shape types are ignored. A possible solution
* is taken if the distance between the curve point and the projected point is <= \a fMaxDist.
*/
void projectToMesh(const TopoDS_Shape& aShape,
float fMaxDist,
std::vector<PolyLine>& rPolyLines) const;
void projectToMesh(const TopoDS_Shape& aShape, float fMaxDist, std::vector<PolyLine>& rPolyLines) const;
/**
* @brief projectOnMesh
* Projects the given points onto the mesh along a given direction. The points can can be
@@ -226,22 +234,28 @@ public:
* @param tolerance
* @param pointsOut
*/
void projectOnMesh(const std::vector<Base::Vector3f>& pointsIn,
const Base::Vector3f& dir,
float tolerance,
std::vector<Base::Vector3f>& pointsOut) const;
void projectOnMesh(
const std::vector<Base::Vector3f>& pointsIn,
const Base::Vector3f& dir,
float tolerance,
std::vector<Base::Vector3f>& pointsOut
) const;
/**
* Project all edges of the shape onto the mesh using parallel projection.
*/
void projectParallelToMesh(const TopoDS_Shape& aShape,
const Base::Vector3f& dir,
std::vector<PolyLine>& rPolyLines) const;
void projectParallelToMesh(
const TopoDS_Shape& aShape,
const Base::Vector3f& dir,
std::vector<PolyLine>& rPolyLines
) const;
/**
* Project all polylines onto the mesh using parallel projection.
*/
void projectParallelToMesh(const std::vector<PolyLine>& aEdges,
const Base::Vector3f& dir,
std::vector<PolyLine>& rPolyLines) const;
void projectParallelToMesh(
const std::vector<PolyLine>& aEdges,
const Base::Vector3f& dir,
std::vector<PolyLine>& rPolyLines
) const;
/**
* Cuts the mesh at the curve defined by \a aShape. This method call @ref projectToMesh() to get
* the split the facet at the found points. @see projectToMesh() for more details.
@@ -249,14 +263,13 @@ public:
void splitMeshByShape(const TopoDS_Shape& aShape, float fMaxDist) const;
protected:
void projectEdgeToEdge(const TopoDS_Edge& aCurve,
float fMaxDist,
const MeshCore::MeshFacetGrid& rGrid,
std::vector<SplitEdge>& rSplitEdges) const;
bool findIntersection(const Edge&,
const Edge&,
const Base::Vector3f& dir,
Base::Vector3f& res) const;
void projectEdgeToEdge(
const TopoDS_Edge& aCurve,
float fMaxDist,
const MeshCore::MeshFacetGrid& rGrid,
std::vector<SplitEdge>& rSplitEdges
) const;
bool findIntersection(const Edge&, const Edge&, const Base::Vector3f& dir, Base::Vector3f& res) const;
private:
const MeshKernel& _rcMesh;

View File

@@ -25,7 +25,7 @@
#include <FCConfig.h>
#ifdef FC_OS_LINUX
#include <unistd.h>
# include <unistd.h>
#endif
#include <Base/Builder3D.h>
@@ -48,8 +48,7 @@ void MeshAlgos::offset(MeshCore::MeshKernel* Mesh, float fSize)
unsigned int i = 0;
// go through all the Vertex normals
for (std::vector<Base::Vector3f>::iterator It = normals.begin(); It != normals.end();
++It, i++) {
for (std::vector<Base::Vector3f>::iterator It = normals.begin(); It != normals.end(); ++It, i++) {
// and move each mesh point in the normal direction
Mesh->MovePoint(i, It->Normalize() * fSize);
}
@@ -90,14 +89,18 @@ void MeshAlgos::offsetSpecial2(MeshCore::MeshKernel* Mesh, float fSize)
continue;
}
// calculate the angle between them
float angle = acos((FaceNormals[i] * it->GetNormal())
/ (it->GetNormal().Length() * FaceNormals[i].Length()));
float angle = acos(
(FaceNormals[i] * it->GetNormal())
/ (it->GetNormal().Length() * FaceNormals[i].Length())
);
if (angle > 1.6) {
Base::DrawStyle drawStyle;
drawStyle.pointSize = 4.0F;
Base::PointItem item {it->GetGravityPoint(),
drawStyle,
Base::ColorRGB {1.0F, 0.0F, 0.0F}};
Base::PointItem item {
it->GetGravityPoint(),
drawStyle,
Base::ColorRGB {1.0F, 0.0F, 0.0F}
};
builder.addNode(item);
flipped.insert(it.Position());
}
@@ -130,8 +133,7 @@ void MeshAlgos::offsetSpecial(MeshCore::MeshKernel* Mesh, float fSize, float zma
unsigned int i = 0;
// go through all the Vertex normals
for (std::vector<Base::Vector3f>::iterator It = normals.begin(); It != normals.end();
++It, i++) {
for (std::vector<Base::Vector3f>::iterator It = normals.begin(); It != normals.end(); ++It, i++) {
Base::Vector3f Pnt = Mesh->GetPoint(i);
if (Pnt.z < zmax && Pnt.z > zmin) {
@@ -157,16 +159,20 @@ void MeshAlgos::offsetSpecial(MeshCore::MeshKernel* Mesh, float fSize, float zma
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
void MeshAlgos::cutByShape(const TopoDS_Shape& aShape,
const MeshCore::MeshKernel* pMesh,
MeshCore::MeshKernel* pToolMesh)
void MeshAlgos::cutByShape(
const TopoDS_Shape& aShape,
const MeshCore::MeshKernel* pMesh,
MeshCore::MeshKernel* pToolMesh
)
{
CurveProjectorWithToolMesh Project(aShape, *pMesh, *pToolMesh);
}
void MeshAlgos::cutByCurve(MeshCore::MeshKernel* pMesh,
const std::vector<CurveProjector::FaceSplitEdge>& vSplitEdges)
void MeshAlgos::cutByCurve(
MeshCore::MeshKernel* pMesh,
const std::vector<CurveProjector::FaceSplitEdge>& vSplitEdges
)
{
MeshTopoAlgorithm cTopAlg(*pMesh);
@@ -204,11 +210,13 @@ public:
};
void MeshAlgos::LoftOnCurve(MeshCore::MeshKernel& ResultMesh,
const TopoDS_Shape& Shape,
const std::vector<Base::Vector3f>& poly,
const Base::Vector3f& up,
float MaxSize)
void MeshAlgos::LoftOnCurve(
MeshCore::MeshKernel& ResultMesh,
const TopoDS_Shape& Shape,
const std::vector<Base::Vector3f>& poly,
const Base::Vector3f& up,
float MaxSize
)
{
TopExp_Explorer Ex;
Standard_Real fBegin, fEnd;
@@ -249,9 +257,11 @@ void MeshAlgos::LoftOnCurve(MeshCore::MeshKernel& ResultMesh,
prop.SetParameter(fBegin + ((fEnd - fBegin) * float(i)) / float(res - 1));
prop.Tangent(Tangent);
Base::Vector3f Tng((float)Tangent.X(), (float)Tangent.Y(), (float)Tangent.Z());
Base::Vector3f Ptn((float)prop.Value().X(),
(float)prop.Value().Y(),
(float)prop.Value().Z());
Base::Vector3f Ptn(
(float)prop.Value().X(),
(float)prop.Value().Y(),
(float)prop.Value().Z()
);
Base::Vector3f Up(up);
// normalize and calc the third vector of the plane coordinatesystem
Tng.Normalize();

View File

@@ -57,30 +57,40 @@ public:
/** makes a boolean add
* The int Type stears the boolean oberation: 0=add;1=intersection;2=diff
*/
static MeshCore::MeshKernel* boolean(MeshCore::MeshKernel* Mesh1,
MeshCore::MeshKernel* Mesh2,
MeshCore::MeshKernel* pResult,
int Type = 0);
static MeshCore::MeshKernel* boolean(
MeshCore::MeshKernel* Mesh1,
MeshCore::MeshKernel* Mesh2,
MeshCore::MeshKernel* pResult,
int Type = 0
);
static void cutByShape(const TopoDS_Shape& aShape,
const MeshCore::MeshKernel* pMesh,
MeshCore::MeshKernel* pToolMesh);
static void cutByShape(
const TopoDS_Shape& aShape,
const MeshCore::MeshKernel* pMesh,
MeshCore::MeshKernel* pToolMesh
);
/// helper to discredicice a Edge...
static void GetSampledCurves(const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& rclPoints,
unsigned long ulNbOfPoints = 30);
static void GetSampledCurves(
const TopoDS_Edge& aEdge,
std::vector<Base::Vector3f>& rclPoints,
unsigned long ulNbOfPoints = 30
);
/// creates a mesh loft on base of a curve and an up vector
static void LoftOnCurve(MeshCore::MeshKernel& ResultMesh,
const TopoDS_Shape& Shape,
const std::vector<Base::Vector3f>& poly,
const Base::Vector3f& up = Base::Vector3f(0, 0, 1),
float MaxSize = 0.1);
static void LoftOnCurve(
MeshCore::MeshKernel& ResultMesh,
const TopoDS_Shape& Shape,
const std::vector<Base::Vector3f>& poly,
const Base::Vector3f& up = Base::Vector3f(0, 0, 1),
float MaxSize = 0.1
);
static void cutByCurve(MeshCore::MeshKernel* pMesh,
const std::vector<CurveProjector::FaceSplitEdge>& vSplitEdges);
static void cutByCurve(
MeshCore::MeshKernel* pMesh,
const std::vector<CurveProjector::FaceSplitEdge>& vSplitEdges
);
};
} // namespace MeshPart

View File

@@ -170,9 +170,7 @@ FaceUnwrapper::FaceUnwrapper(const TopoDS_Face& face)
void FaceUnwrapper::findFlatNodes(int steps, double val)
{
std::vector<long> fixed_pins; // TODO: INPUT
lscmrelax::LscmRelax mesh_flattener(this->xyz_nodes.transpose(),
this->tris.transpose(),
fixed_pins);
lscmrelax::LscmRelax mesh_flattener(this->xyz_nodes.transpose(), this->tris.transpose(), fixed_pins);
mesh_flattener.lscm();
for (int j = 0; j < steps; j++) {
mesh_flattener.relax(val);
@@ -183,8 +181,10 @@ void FaceUnwrapper::findFlatNodes(int steps, double val)
ColMat<double, 3> FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face)
{
if (this->uv_nodes.size() == 0) {
throw(std::runtime_error("no uv-coordinates found, interpolating with nurbs is only "
"possible if the flattener was constructed with a nurbs."));
throw(std::runtime_error(
"no uv-coordinates found, interpolating with nurbs is only "
"possible if the flattener was constructed with a nurbs."
));
}
// extract xyz poles, knots, weights, degree
@@ -195,8 +195,10 @@ ColMat<double, 3> FaceUnwrapper::interpolateFlatFace(const TopoDS_Face& face)
const TColStd_Array1OfReal& _vknots = _bspline->VKnotSequence();
Eigen::VectorXd weights;
weights.resize(static_cast<Eigen::Index>(_bspline->NbUPoles())
* static_cast<Eigen::Index>(_bspline->NbVPoles()));
weights.resize(
static_cast<Eigen::Index>(_bspline->NbUPoles())
* static_cast<Eigen::Index>(_bspline->NbVPoles())
);
long i = 0;
for (long u = 1; u <= _bspline->NbUPoles(); u++) {
for (long v = 1; v <= _bspline->NbVPoles(); v++) {

View File

@@ -38,45 +38,45 @@
#include "Mesher.h"
#ifdef HAVE_SMESH
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
#pragma clang diagnostic ignored "-Wextra-semi"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
# if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Woverloaded-virtual"
# pragma clang diagnostic ignored "-Wextra-semi"
# elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# endif
#include <SMESHDS_Mesh.hxx>
#include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx>
#include <StdMeshers_MaxLength.hxx>
# include <SMESHDS_Mesh.hxx>
# include <SMESH_Gen.hxx>
# include <SMESH_Mesh.hxx>
# include <StdMeshers_MaxLength.hxx>
#include <StdMeshers_Arithmetic1D.hxx>
#include <StdMeshers_AutomaticLength.hxx>
#include <StdMeshers_Deflection1D.hxx>
#include <StdMeshers_LocalLength.hxx>
#if SMESH_VERSION_MAJOR <= 9 && SMESH_VERSION_MINOR < 10
#include <StdMeshers_MEFISTO_2D.hxx>
#endif
#include <StdMeshers_MaxElementArea.hxx>
#include <StdMeshers_NumberOfSegments.hxx>
#include <StdMeshers_QuadranglePreference.hxx>
#include <StdMeshers_Quadrangle_2D.hxx>
#include <StdMeshers_Regular_1D.hxx>
# include <StdMeshers_Arithmetic1D.hxx>
# include <StdMeshers_AutomaticLength.hxx>
# include <StdMeshers_Deflection1D.hxx>
# include <StdMeshers_LocalLength.hxx>
# if SMESH_VERSION_MAJOR <= 9 && SMESH_VERSION_MINOR < 10
# include <StdMeshers_MEFISTO_2D.hxx>
# endif
# include <StdMeshers_MaxElementArea.hxx>
# include <StdMeshers_NumberOfSegments.hxx>
# include <StdMeshers_QuadranglePreference.hxx>
# include <StdMeshers_Quadrangle_2D.hxx>
# include <StdMeshers_Regular_1D.hxx>
#include <StdMeshers_LengthFromEdges.hxx>
#include <StdMeshers_NotConformAllowed.hxx>
#if defined(HAVE_NETGEN)
#include <NETGENPlugin_Hypothesis_2D.hxx>
#include <NETGENPlugin_NETGEN_2D.hxx>
#include <NETGENPlugin_SimpleHypothesis_2D.hxx>
#endif // HAVE_NETGEN
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
# include <StdMeshers_LengthFromEdges.hxx>
# include <StdMeshers_NotConformAllowed.hxx>
# if defined(HAVE_NETGEN)
# include <NETGENPlugin_Hypothesis_2D.hxx>
# include <NETGENPlugin_NETGEN_2D.hxx>
# include <NETGENPlugin_SimpleHypothesis_2D.hxx>
# endif // HAVE_NETGEN
# if defined(__clang__)
# pragma clang diagnostic pop
# elif defined(__GNUC__)
# pragma GCC diagnostic pop
# endif
#endif // HAVE_SMESH
using namespace MeshPart;
@@ -143,12 +143,14 @@ public:
MeshCore::MeshFacetArray faces;
faces.reserve(facets.size());
std::transform(facets.cbegin(),
facets.cend(),
std::back_inserter(faces),
[](const Part::TopoShape::Facet& face) {
return MeshCore::MeshFacet(face.I1, face.I2, face.I3);
});
std::transform(
facets.cbegin(),
facets.cend(),
std::back_inserter(faces),
[](const Part::TopoShape::Facet& face) {
return MeshCore::MeshFacet(face.I1, face.I2, face.I3);
}
);
MeshCore::MeshPointArray verts;
verts.reserve(points.size());
@@ -173,14 +175,16 @@ public:
if (createSegm || this->segments) {
auto segments = mesh.createSegments();
meshSegments.reserve(segments.size());
std::transform(segments.cbegin(),
segments.cend(),
std::back_inserter(meshSegments),
[](const Part::BRepMesh::Segment& segm) {
std::vector<MeshCore::FacetIndex> faces;
faces.insert(faces.end(), segm.cbegin(), segm.cend());
return faces;
});
std::transform(
segments.cbegin(),
segments.cend(),
std::back_inserter(meshSegments),
[](const Part::BRepMesh::Segment& segm) {
std::vector<MeshCore::FacetIndex> faces;
faces.insert(faces.end(), segm.cbegin(), segm.cend());
return faces;
}
);
}
Mesh::MeshObject* meshdata = new Mesh::MeshObject();
@@ -251,22 +255,22 @@ Mesh::MeshObject* Mesher::createMesh() const
}
SMESH_Gen* meshgen = Mesher::_mesh_gen;
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
SMESH_Mesh* mesh = meshgen->CreateMesh(true);
#else
# else
SMESH_Mesh* mesh = meshgen->CreateMesh(0, true);
#endif
# endif
int hyp = 0;
switch (method) {
#if defined(HAVE_NETGEN)
# if defined(HAVE_NETGEN)
case Netgen: {
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
NETGENPlugin_Hypothesis_2D* hyp2d = new NETGENPlugin_Hypothesis_2D(hyp++, meshgen);
#else
# else
NETGENPlugin_Hypothesis_2D* hyp2d = new NETGENPlugin_Hypothesis_2D(hyp++, 0, meshgen);
#endif
# endif
if (fineness >= 0 && fineness < 5) {
hyp2d->SetFineness(NETGENPlugin_Hypothesis_2D::Fineness(fineness));
@@ -293,107 +297,103 @@ Mesh::MeshObject* Mesher::createMesh() const
hyp2d->SetQuadAllowed(allowquad);
hyp2d->SetOptimize(optimize);
hyp2d->SetSecondOrder(
secondOrder); // apply bisecting to create four triangles out of one
hyp2d->SetSecondOrder(secondOrder); // apply bisecting to create four triangles out of one
hypoth.push_back(hyp2d);
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
NETGENPlugin_NETGEN_2D* alg2d = new NETGENPlugin_NETGEN_2D(hyp++, meshgen);
#else
# else
NETGENPlugin_NETGEN_2D* alg2d = new NETGENPlugin_NETGEN_2D(hyp++, 0, meshgen);
#endif
# endif
hypoth.push_back(alg2d);
} break;
#endif
#if SMESH_VERSION_MAJOR <= 9 && SMESH_VERSION_MINOR < 10
#if defined(HAVE_MEFISTO)
# endif
# if SMESH_VERSION_MAJOR <= 9 && SMESH_VERSION_MINOR < 10
# if defined(HAVE_MEFISTO)
case Mefisto: {
if (maxLength > 0) {
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
StdMeshers_MaxLength* hyp1d = new StdMeshers_MaxLength(hyp++, meshgen);
#else
# else
StdMeshers_MaxLength* hyp1d = new StdMeshers_MaxLength(hyp++, 0, meshgen);
#endif
# endif
hyp1d->SetLength(maxLength);
hypoth.push_back(hyp1d);
}
else if (localLength > 0) {
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(hyp++, meshgen);
#else
# else
StdMeshers_LocalLength* hyp1d = new StdMeshers_LocalLength(hyp++, 0, meshgen);
#endif
# endif
hyp1d->SetLength(localLength);
hypoth.push_back(hyp1d);
}
else if (maxArea > 0) {
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
StdMeshers_MaxElementArea* hyp2d = new StdMeshers_MaxElementArea(hyp++, meshgen);
#else
# else
StdMeshers_MaxElementArea* hyp2d = new StdMeshers_MaxElementArea(hyp++, 0, meshgen);
#endif
# endif
hyp2d->SetMaxArea(maxArea);
hypoth.push_back(hyp2d);
}
else if (deflection > 0) {
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
StdMeshers_Deflection1D* hyp1d = new StdMeshers_Deflection1D(hyp++, meshgen);
#else
# else
StdMeshers_Deflection1D* hyp1d = new StdMeshers_Deflection1D(hyp++, 0, meshgen);
#endif
# endif
hyp1d->SetDeflection(deflection);
hypoth.push_back(hyp1d);
}
else if (minLen > 0 && maxLen > 0) {
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
StdMeshers_Arithmetic1D* hyp1d = new StdMeshers_Arithmetic1D(hyp++, meshgen);
#else
# else
StdMeshers_Arithmetic1D* hyp1d = new StdMeshers_Arithmetic1D(hyp++, 0, meshgen);
#endif
# endif
hyp1d->SetLength(minLen, false);
hyp1d->SetLength(maxLen, true);
hypoth.push_back(hyp1d);
}
else {
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
StdMeshers_AutomaticLength* hyp1d = new StdMeshers_AutomaticLength(hyp++, meshgen);
#else
StdMeshers_AutomaticLength* hyp1d =
new StdMeshers_AutomaticLength(hyp++, 0, meshgen);
#endif
# else
StdMeshers_AutomaticLength* hyp1d = new StdMeshers_AutomaticLength(hyp++, 0, meshgen);
# endif
hypoth.push_back(hyp1d);
}
{
#if SMESH_VERSION_MAJOR >= 9
StdMeshers_NumberOfSegments* hyp1d =
new StdMeshers_NumberOfSegments(hyp++, meshgen);
#else
StdMeshers_NumberOfSegments* hyp1d =
new StdMeshers_NumberOfSegments(hyp++, 0, meshgen);
#endif
# if SMESH_VERSION_MAJOR >= 9
StdMeshers_NumberOfSegments* hyp1d = new StdMeshers_NumberOfSegments(hyp++, meshgen);
# else
StdMeshers_NumberOfSegments* hyp1d = new StdMeshers_NumberOfSegments(hyp++, 0, meshgen);
# endif
hyp1d->SetNumberOfSegments(1);
hypoth.push_back(hyp1d);
}
if (regular) {
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
StdMeshers_Regular_1D* hyp1d = new StdMeshers_Regular_1D(hyp++, meshgen);
#else
# else
StdMeshers_Regular_1D* hyp1d = new StdMeshers_Regular_1D(hyp++, 0, meshgen);
#endif
# endif
hypoth.push_back(hyp1d);
}
#if SMESH_VERSION_MAJOR >= 9
# if SMESH_VERSION_MAJOR >= 9
StdMeshers_MEFISTO_2D* alg2d = new StdMeshers_MEFISTO_2D(hyp++, meshgen);
#else
# else
StdMeshers_MEFISTO_2D* alg2d = new StdMeshers_MEFISTO_2D(hyp++, 0, meshgen);
#endif
# endif
hypoth.push_back(alg2d);
} break;
#endif
#endif
# endif
# endif
default:
break;
}

View File

@@ -30,7 +30,7 @@
#include <Base/Stream.h>
#ifdef HAVE_SMESH
#include <SMESH_Version.h>
# include <SMESH_Version.h>
#endif
class TopoDS_Shape;

View File

@@ -95,7 +95,8 @@ void CmdMeshPartTrimByPlane::activated(int)
QMessageBox::warning(
Gui::getMainWindow(),
qApp->translate("MeshPart_TrimByPlane", "Select plane"),
qApp->translate("MeshPart_TrimByPlane", "Select a plane to trim the mesh with."));
qApp->translate("MeshPart_TrimByPlane", "Select a plane to trim the mesh with.")
);
return;
}
@@ -103,12 +104,12 @@ void CmdMeshPartTrimByPlane::activated(int)
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(qApp->translate("MeshPart_TrimByPlane", "Trim With Plane"));
msgBox.setText(qApp->translate("MeshPart_TrimByPlane", "Select the side to keep"));
QPushButton* inner =
msgBox.addButton(qApp->translate("MeshPart_TrimByPlane", "Below"), QMessageBox::ActionRole);
QPushButton* outer =
msgBox.addButton(qApp->translate("MeshPart_TrimByPlane", "Above"), QMessageBox::ActionRole);
QPushButton* split =
msgBox.addButton(qApp->translate("MeshPart_TrimByPlane", "Split"), QMessageBox::ActionRole);
QPushButton* inner
= msgBox.addButton(qApp->translate("MeshPart_TrimByPlane", "Below"), QMessageBox::ActionRole);
QPushButton* outer
= msgBox.addButton(qApp->translate("MeshPart_TrimByPlane", "Above"), QMessageBox::ActionRole);
QPushButton* split
= msgBox.addButton(qApp->translate("MeshPart_TrimByPlane", "Split"), QMessageBox::ActionRole);
msgBox.addButton(QMessageBox::Cancel);
msgBox.setDefaultButton(inner);
msgBox.exec();
@@ -129,12 +130,12 @@ void CmdMeshPartTrimByPlane::activated(int)
return;
}
Base::Placement plnPlacement =
static_cast<App::GeoFeature*>(plane.front())->Placement.getValue();
Base::Placement plnPlacement = static_cast<App::GeoFeature*>(plane.front())->Placement.getValue();
openCommand(QT_TRANSLATE_NOOP("Command", "Trim with plane"));
std::vector<App::DocumentObject*> docObj =
Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(
Mesh::Feature::getClassTypeId()
);
for (auto it : docObj) {
Base::Vector3d normal(0, 0, 1);
plnPlacement.getRotation().multVec(normal, normal);
@@ -201,7 +202,8 @@ void CmdMeshPartSection::activated(int)
QMessageBox::warning(
Gui::getMainWindow(),
qApp->translate("MeshPart_Section", "Select plane"),
qApp->translate("MeshPart_Section", "Select a plane to section the mesh with."));
qApp->translate("MeshPart_Section", "Select a plane to section the mesh with.")
);
return;
}
@@ -211,8 +213,9 @@ void CmdMeshPartSection::activated(int)
Base::Vector3d base = plm.getPosition();
openCommand(QT_TRANSLATE_NOOP("Command", "Section with plane"));
std::vector<App::DocumentObject*> docObj =
Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(
Mesh::Feature::getClassTypeId()
);
Mesh::MeshObject::TPlane tplane;
tplane.first = Base::convertTo<Base::Vector3f>(base);
tplane.second = Base::convertTo<Base::Vector3f>(normal);
@@ -283,8 +286,9 @@ void CmdMeshPartCrossSections::activated(int iMsg)
Q_UNUSED(iMsg);
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
if (!dlg) {
std::vector<App::DocumentObject*> obj =
Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(
Mesh::Feature::getClassTypeId()
);
Base::BoundBox3d bbox;
for (auto it : obj) {
bbox.Add(static_cast<Mesh::Feature*>(it)->Mesh.getBoundingBox());
@@ -296,8 +300,7 @@ void CmdMeshPartCrossSections::activated(int iMsg)
bool CmdMeshPartCrossSections::isActive()
{
return (Gui::Selection().countObjectsOfType<Mesh::Feature>() > 0
&& !Gui::Control().activeDialog());
return (Gui::Selection().countObjectsOfType<Mesh::Feature>() > 0 && !Gui::Control().activeDialog());
}
DEF_STD_CMD_A(CmdMeshPartCurveOnMesh)
@@ -323,7 +326,8 @@ void CmdMeshPartCurveOnMesh::activated(int)
}
Gui::Control().showDialog(
new MeshPartGui::TaskCurveOnMesh(static_cast<Gui::View3DInventor*>(mdis.front())));
new MeshPartGui::TaskCurveOnMesh(static_cast<Gui::View3DInventor*>(mdis.front()))
);
}
bool CmdMeshPartCurveOnMesh::isActive()

View File

@@ -123,13 +123,15 @@ private:
class MeshCrossSection
{
public:
MeshCrossSection(const MeshCore::MeshKernel& mesh,
const MeshCore::MeshFacetGrid& grid,
double x,
double y,
double z,
bool connectEdges,
double eps)
MeshCrossSection(
const MeshCore::MeshKernel& mesh,
const MeshCore::MeshFacetGrid& grid,
double x,
double y,
double z,
bool connectEdges,
double eps
)
: mesh(mesh)
, grid(grid)
, x(x)
@@ -270,8 +272,9 @@ void CrossSections::accept()
void CrossSections::apply()
{
std::vector<App::DocumentObject*> obj =
Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType(
Mesh::Feature::getClassTypeId()
);
std::vector<double> d;
if (ui->sectionsBox->isChecked()) {
@@ -307,8 +310,8 @@ void CrossSections::apply()
// NOLINTBEGIN
MeshCrossSection cs(kernel, grid, a, b, c, connectEdges, eps);
QFuture<std::list<TopoDS_Wire>> future =
QtConcurrent::mapped(d, std::bind(&MeshCrossSection::section, &cs, sp::_1));
QFuture<std::list<TopoDS_Wire>> future
= QtConcurrent::mapped(d, std::bind(&MeshCrossSection::section, &cs, sp::_1));
future.waitForFinished();
// NOLINTEND
@@ -358,13 +361,15 @@ void CrossSections::apply()
"points=FreeCAD.getDocument(\"%1\").%2.Mesh.crossSections(%3, %4, %5)\n"
"wires=[]\n"
"for i in points:\n"
" wires.extend([Part.makePolygon(j) for j in i])\n")
" wires.extend([Part.makePolygon(j) for j in i])\n"
)
.arg(QLatin1String(doc->getName()))
.arg(QLatin1String((*it)->getNameInDocument()))
.arg(planes)
.arg(eps)
.arg(connectEdges ? QLatin1String("True") : QLatin1String("False"))
.toLatin1());
.toLatin1()
);
Gui::Command::runCommand(
Gui::Command::App,
@@ -373,10 +378,12 @@ void CrossSections::apply()
"slice=FreeCAD.getDocument(\"%1\").addObject(\"Part::Feature\",\"%2\")\n"
"slice.Shape=comp\n"
"slice.purgeTouched()\n"
"del slice,comp,wires,points")
"del slice,comp,wires,points"
)
.arg(QLatin1String(doc->getName()))
.arg(QLatin1String(s.c_str()))
.toLatin1());
.toLatin1()
);
}
}
catch (const Base::Exception& e) {

View File

@@ -55,9 +55,11 @@ class CrossSections: public QDialog
};
public:
explicit CrossSections(const Base::BoundBox3d& bb,
QWidget* parent = nullptr,
Qt::WindowFlags fl = Qt::WindowFlags());
explicit CrossSections(
const Base::BoundBox3d& bb,
QWidget* parent = nullptr,
Qt::WindowFlags fl = Qt::WindowFlags()
);
~CrossSections() override;
void accept() override;
void apply();

View File

@@ -69,13 +69,13 @@
#ifndef HAVE_ACOSH
#define HAVE_ACOSH
# define HAVE_ACOSH
#endif
#ifndef HAVE_ASINH
#define HAVE_ASINH
# define HAVE_ASINH
#endif
#ifndef HAVE_ATANH
#define HAVE_ATANH
# define HAVE_ATANH
#endif
@@ -279,8 +279,7 @@ public:
MeshCore::MeshProjection meshProjection(kernel);
Base::Vector3f v1 = Base::convertTo<Base::Vector3f>(last.point);
Base::Vector3f v2 = Base::convertTo<Base::Vector3f>(pick.point);
Base::Vector3f vd =
Base::convertTo<Base::Vector3f>(viewer->getViewer()->getViewDirection());
Base::Vector3f vd = Base::convertTo<Base::Vector3f>(viewer->getViewer()->getViewDirection());
if (meshProjection.projectLineOnMesh(*grid, v1, last.facet, v2, pick.facet, vd, polyline)) {
if (polyline.size() > 1) {
if (cutLines.empty()) {
@@ -344,10 +343,7 @@ void CurveOnMeshHandler::enableApproximation(bool on)
d_ptr->approximate = on;
}
void CurveOnMeshHandler::setParameters(int maxDegree,
GeomAbs_Shape cont,
double tol3d,
double angle)
void CurveOnMeshHandler::setParameters(int maxDegree, GeomAbs_Shape cont, double tol3d, double angle)
{
d_ptr->par.maxDegree = maxDegree;
d_ptr->par.cont = cont;
@@ -487,11 +483,7 @@ Handle(Geom_BSplineCurve) CurveOnMeshHandler::approximateSpline(const std::vecto
// GeomAPI_PointsToBSpline fit(pnts, d_ptr->par.weight1, d_ptr->par.weight2,
// d_ptr->par.weight3,
// d_ptr->par.maxDegree, d_ptr->par.cont, d_ptr->par.tol3d);
GeomAPI_PointsToBSpline fit(pnts,
1,
d_ptr->par.maxDegree,
d_ptr->par.cont,
d_ptr->par.tol3d);
GeomAPI_PointsToBSpline fit(pnts, 1, d_ptr->par.maxDegree, d_ptr->par.cont, d_ptr->par.tol3d);
Handle(Geom_BSplineCurve) spline = fit.Curve();
return spline;
}
@@ -512,9 +504,11 @@ void CurveOnMeshHandler::approximateEdge(const TopoDS_Edge& edge, double toleran
pts.reserve(numNodes);
for (int i = aNodes.Lower(); i <= aNodes.Upper(); i++) {
const gp_Pnt& p = aNodes.Value(i);
pts.emplace_back(static_cast<float>(p.X()),
static_cast<float>(p.Y()),
static_cast<float>(p.Z()));
pts.emplace_back(
static_cast<float>(p.X()),
static_cast<float>(p.Y()),
static_cast<float>(p.Z())
);
}
d_ptr->curve->setPoints(pts);
@@ -608,8 +602,7 @@ void CurveOnMeshHandler::Private::vertexCallback(void* ud, SoEventCallback* cb)
if (!self->d_ptr->wireClosed) {
Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(pp->getPath());
if (vp && vp->isDerivedFrom<MeshGui::ViewProviderMesh>()) {
MeshGui::ViewProviderMesh* mesh =
static_cast<MeshGui::ViewProviderMesh*>(vp);
MeshGui::ViewProviderMesh* mesh = static_cast<MeshGui::ViewProviderMesh*>(vp);
const SoDetail* detail = pp->getDetail();
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
// get the mesh and build a grid
@@ -619,7 +612,8 @@ void CurveOnMeshHandler::Private::vertexCallback(void* ud, SoEventCallback* cb)
}
else if (self->d_ptr->mesh != mesh) {
Gui::getMainWindow()->statusBar()->showMessage(
tr("Wrong mesh selected"));
tr("Wrong mesh selected")
);
return;
}

View File

@@ -81,10 +81,12 @@ void CurveOnMeshWidget::onStartButtonClicked()
{
int cont = ui->continuity->itemData(ui->continuity->currentIndex()).toInt();
myCurveHandler->enableApproximation(ui->groupBox_2->isChecked());
myCurveHandler->setParameters(ui->maxDegree->currentIndex() + 1,
static_cast<GeomAbs_Shape>(cont),
ui->meshTolerance->value(),
ui->splitAngle->value().getValue());
myCurveHandler->setParameters(
ui->maxDegree->currentIndex() + 1,
static_cast<GeomAbs_Shape>(cont),
ui->meshTolerance->value(),
ui->splitAngle->value().getValue()
);
myCurveHandler->enableCallback(myView);
}

View File

@@ -62,7 +62,8 @@ Tessellation::Tessellation(QWidget* parent)
ui->stackedWidget->addTab(gmsh, tr("Gmsh"));
ParameterGrp::handle handle = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Mesh/Meshing/Standard");
"User parameter:BaseApp/Preferences/Mod/Mesh/Meshing/Standard"
);
double value = ui->spinSurfaceDeviation->value().getValue();
value = handle->GetFloat("LinearDeflection", value);
double angle = ui->spinAngularDeviation->value().getValue();
@@ -102,22 +103,20 @@ Tessellation::~Tessellation() = default;
void Tessellation::setupConnections()
{
connect(gmsh, &Mesh2ShapeGmsh::processed, this, &Tessellation::gmshProcessed);
connect(ui->estimateMaximumEdgeLength,
&QPushButton::clicked,
this,
&Tessellation::onEstimateMaximumEdgeLengthClicked);
connect(ui->comboFineness,
qOverload<int>(&QComboBox::currentIndexChanged),
this,
&Tessellation::onComboFinenessCurrentIndexChanged);
connect(ui->checkSecondOrder,
&QCheckBox::toggled,
this,
&Tessellation::onCheckSecondOrderToggled);
connect(ui->checkQuadDominated,
&QCheckBox::toggled,
this,
&Tessellation::onCheckQuadDominatedToggled);
connect(
ui->estimateMaximumEdgeLength,
&QPushButton::clicked,
this,
&Tessellation::onEstimateMaximumEdgeLengthClicked
);
connect(
ui->comboFineness,
qOverload<int>(&QComboBox::currentIndexChanged),
this,
&Tessellation::onComboFinenessCurrentIndexChanged
);
connect(ui->checkSecondOrder, &QCheckBox::toggled, this, &Tessellation::onCheckSecondOrderToggled);
connect(ui->checkQuadDominated, &QCheckBox::toggled, this, &Tessellation::onCheckQuadDominatedToggled);
}
void Tessellation::meshingMethod(int id)
@@ -217,10 +216,11 @@ void Tessellation::onEstimateMaximumEdgeLengthClicked()
double edgeLen = 0;
for (auto& sel : Gui::Selection().getSelection("*", Gui::ResolveMode::NoResolve)) {
auto shape = Part::Feature::getTopoShape(sel.pObject,
Part::ShapeOption::ResolveLink
| Part::ShapeOption::Transform,
sel.SubName);
auto shape = Part::Feature::getTopoShape(
sel.pObject,
Part::ShapeOption::ResolveLink | Part::ShapeOption::Transform,
sel.SubName
);
if (shape.hasSubShape(TopAbs_FACE)) {
Base::BoundBox3d bbox = shape.getBoundBox();
edgeLen = std::max<double>(edgeLen, bbox.LengthX());
@@ -252,10 +252,11 @@ bool Tessellation::accept()
bool bodyWithNoTip = false;
bool partWithNoFace = false;
for (auto& sel : Gui::Selection().getSelection("*", Gui::ResolveMode::NoResolve)) {
auto shape = Part::Feature::getTopoShape(sel.pObject,
Part::ShapeOption::ResolveLink
| Part::ShapeOption::Transform,
sel.SubName);
auto shape = Part::Feature::getTopoShape(
sel.pObject,
Part::ShapeOption::ResolveLink | Part::ShapeOption::Transform,
sel.SubName
);
if (shape.hasSubShape(TopAbs_FACE)) {
shapeObjects.emplace_back(sel.pObject, sel.SubName);
}
@@ -277,13 +278,16 @@ bool Tessellation::accept()
this,
windowTitle(),
tr("Error: body without a tip selected.\n"
"Either set the tip of the body or select a different shape."));
"Either set the tip of the body or select a different shape.")
);
}
else if (partWithNoFace) {
QMessageBox::critical(this,
windowTitle(),
tr("Error: shape without faces selected.\n"
"Select a different shape."));
QMessageBox::critical(
this,
windowTitle(),
tr("Error: shape without faces selected.\n"
"Select a different shape.")
);
}
else {
QMessageBox::critical(this, windowTitle(), tr("Select a shape for meshing, first."));
@@ -305,9 +309,7 @@ bool Tessellation::accept()
return doClose;
}
void Tessellation::process(int method,
App::Document* doc,
const std::list<App::SubObjectT>& shapeObjects)
void Tessellation::process(int method, App::Document* doc, const std::list<App::SubObjectT>& shapeObjects)
{
try {
Gui::WaitCursor wc;
@@ -336,13 +338,15 @@ void Tessellation::process(int method,
QString param = getMeshingParameters(method, sobj);
QString cmd = QStringLiteral("__doc__=FreeCAD.getDocument(\"%1\")\n"
"__mesh__=__doc__.addObject(\"Mesh::Feature\",\"Mesh\")\n"
"__part__=__doc__.getObject(\"%2\")\n"
"__shape__=Part.getShape(__part__,\"%3\")\n"
"__mesh__.Mesh=MeshPart.meshFromShape(%4)\n"
"__mesh__.Label=\"%5 (Meshed)\"\n"
"del __doc__, __mesh__, __part__, __shape__\n")
QString cmd = QStringLiteral(
"__doc__=FreeCAD.getDocument(\"%1\")\n"
"__mesh__=__doc__.addObject(\"Mesh::Feature\",\"Mesh\")\n"
"__part__=__doc__.getObject(\"%2\")\n"
"__shape__=Part.getShape(__part__,\"%3\")\n"
"__mesh__.Mesh=MeshPart.meshFromShape(%4)\n"
"__mesh__.Label=\"%5 (Meshed)\"\n"
"del __doc__, __mesh__, __part__, __shape__\n"
)
.arg(this->document, objname, subname, param, label);
Gui::Command::runCommand(Gui::Command::Doc, cmd.toUtf8());
@@ -361,7 +365,8 @@ void Tessellation::saveParameters(int method)
{
if (method == Standard) {
ParameterGrp::handle handle = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Mesh/Meshing/Standard");
"User parameter:BaseApp/Preferences/Mod/Mesh/Meshing/Standard"
);
double value = ui->spinSurfaceDeviation->value().getValue();
handle->SetFloat("LinearDeflection", value);
double angle = ui->spinAngularDeviation->value().getValue();
@@ -376,12 +381,14 @@ void Tessellation::setFaceColors(int method, App::Document* doc, App::DocumentOb
// if Standard mesher is used and face colors should be applied
if (method == Standard) {
if (ui->meshShapeColors->isChecked()) {
Gui::ViewProvider* vpm =
Gui::Application::Instance->getViewProvider(doc->getActiveObject());
Gui::ViewProvider* vpm = Gui::Application::Instance->getViewProvider(
doc->getActiveObject()
);
auto vpmesh = dynamic_cast<MeshGui::ViewProviderMesh*>(vpm);
auto svp = freecad_cast<PartGui::ViewProviderPartExt*>(
Gui::Application::Instance->getViewProvider(obj));
Gui::Application::Instance->getViewProvider(obj)
);
if (vpmesh && svp) {
std::vector<Base::Color> diff_col = svp->ShapeAppearance.getDiffuseColors();
if (ui->groupsFaceColors->isChecked()) {
@@ -412,7 +419,8 @@ void Tessellation::addFaceColors(Mesh::Feature* mesh, const std::vector<Base::Co
auto typeId = App::PropertyColorList::getClassTypeId();
if (auto prop = dynamic_cast<App::PropertyColorList*>(
mesh->addDynamicProperty(typeId.getName(), "FaceColors"))) {
mesh->addDynamicProperty(typeId.getName(), "FaceColors")
)) {
prop->setValues(colorPerFace);
}
}
@@ -458,10 +466,12 @@ QString Tessellation::getStandardParameters(App::DocumentObject* obj) const
bool relative = ui->relativeDeviation->isChecked();
QString param;
param = QStringLiteral("Shape=__shape__, "
"LinearDeflection=%1, "
"AngularDeflection=%2, "
"Relative=%3")
param = QStringLiteral(
"Shape=__shape__, "
"LinearDeflection=%1, "
"AngularDeflection=%2, "
"Relative=%3"
)
.arg(devFace)
.arg(devAngle)
.arg(relative ? QStringLiteral("True") : QStringLiteral("False"));
@@ -470,7 +480,8 @@ QString Tessellation::getStandardParameters(App::DocumentObject* obj) const
}
auto svp = freecad_cast<PartGui::ViewProviderPartExt*>(
Gui::Application::Instance->getViewProvider(obj));
Gui::Application::Instance->getViewProvider(obj)
);
if (ui->groupsFaceColors->isChecked() && svp) {
// TODO: currently, we can only retrieve part feature
// color. The problem is that if the feature is linked,
@@ -484,8 +495,10 @@ QString Tessellation::getStandardParameters(App::DocumentObject* obj) const
// PartGui::ViewProviderPartExt::getShapeColors().
//
param += QStringLiteral(",GroupColors=Gui.getDocument('%1').getObject('%2').DiffuseColor")
.arg(QString::fromLatin1(obj->getDocument()->getName()),
QString::fromLatin1(obj->getNameInDocument()));
.arg(
QString::fromLatin1(obj->getDocument()->getName()),
QString::fromLatin1(obj->getNameInDocument())
);
}
return param;
@@ -511,17 +524,21 @@ QString Tessellation::getNetgenParameters() const
bool optimize = ui->checkOptimizeSurface->isChecked();
bool allowquad = ui->checkQuadDominated->isChecked();
if (fineness <= int(VeryFine)) {
param = QStringLiteral("Shape=__shape__,"
"Fineness=%1,SecondOrder=%2,Optimize=%3,AllowQuad=%4")
param = QStringLiteral(
"Shape=__shape__,"
"Fineness=%1,SecondOrder=%2,Optimize=%3,AllowQuad=%4"
)
.arg(fineness)
.arg(secondOrder ? 1 : 0)
.arg(optimize ? 1 : 0)
.arg(allowquad ? 1 : 0);
}
else {
param = QStringLiteral("Shape=__shape__,"
"GrowthRate=%1,SegPerEdge=%2,SegPerRadius=%3,SecondOrder=%4,"
"Optimize=%5,AllowQuad=%6")
param = QStringLiteral(
"Shape=__shape__,"
"GrowthRate=%1,SegPerEdge=%2,SegPerRadius=%3,SecondOrder=%4,"
"Optimize=%5,AllowQuad=%6"
)
.arg(growthRate)
.arg(nbSegPerEdge)
.arg(nbSegPerRadius)
@@ -574,10 +591,11 @@ bool Mesh2ShapeGmsh::writeProject(QString& inpFile, QString& outFile)
App::DocumentObject* part = sub.getObject();
if (part) {
Part::TopoShape shape = Part::Feature::getTopoShape(part,
Part::ShapeOption::ResolveLink
| Part::ShapeOption::Transform,
sub.getSubName().c_str());
Part::TopoShape shape = Part::Feature::getTopoShape(
part,
Part::ShapeOption::ResolveLink | Part::ShapeOption::Transform,
sub.getSubName().c_str()
);
shape.exportBrep(d->cadFile.c_str());
d->label = part->Label.getStrValue() + " (Meshed)";

View File

@@ -25,25 +25,25 @@
#include <FCGlobal.h>
#ifndef MESHPART_GLOBAL_H
#define MESHPART_GLOBAL_H
# define MESHPART_GLOBAL_H
// MeshPart
#ifndef MeshPartExport
#ifdef MeshPart_EXPORTS
#define MeshPartExport FREECAD_DECL_EXPORT
#else
#define MeshPartExport FREECAD_DECL_IMPORT
#endif
#endif
# ifndef MeshPartExport
# ifdef MeshPart_EXPORTS
# define MeshPartExport FREECAD_DECL_EXPORT
# else
# define MeshPartExport FREECAD_DECL_IMPORT
# endif
# endif
// MeshPartGui
#ifndef MeshPartGuiExport
#ifdef MeshPartGui_EXPORTS
#define MeshPartGuiExport FREECAD_DECL_EXPORT
#else
#define MeshPartGuiExport FREECAD_DECL_IMPORT
#endif
#endif
# ifndef MeshPartGuiExport
# ifdef MeshPartGui_EXPORTS
# define MeshPartGuiExport FREECAD_DECL_EXPORT
# else
# define MeshPartGuiExport FREECAD_DECL_IMPORT
# endif
# endif
#endif // MESHPART_GLOBAL_H