rename 2d tool classes to be consistent with 3d classes

This commit is contained in:
wmayer
2016-11-21 14:29:51 +01:00
parent 9fe280ed63
commit 2d8e70085e
42 changed files with 950 additions and 951 deletions

View File

@@ -39,8 +39,8 @@
using namespace MeshCore;
using Base::BoundBox3f;
using Base::BoundBox2D;
using Base::Polygon2D;
using Base::BoundBox2d;
using Base::Polygon2d;
bool MeshAlgorithm::IsVertexVisible (const Base::Vector3f &rcVertex, const Base::Vector3f &rcView, const MeshFacetGrid &rclGrid) const
@@ -1075,7 +1075,7 @@ int MeshAlgorithm::Surround(const Base::BoundBox3f& rBox, const Base::Vector3f&
return -1;
}
void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly,
void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
bool bInner, std::vector<unsigned long> &raulFacets) const
{
std::vector<unsigned long>::iterator it;
@@ -1088,7 +1088,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
if (bInner)
{
BoundBox3f clBBox3d;
BoundBox2D clViewBBox, clPolyBBox;
BoundBox2d clViewBBox, clPolyBBox;
std::vector<unsigned long> aulAllElements;
//B-Box des Polygons
@@ -1121,7 +1121,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
{
clPt2d = pclProj->operator()(rclFacet._aclPoints[j]);
clGravityOfFacet += clPt2d;
if (rclPoly.Contains(Base::Vector2D(clPt2d.x, clPt2d.y)) == bInner)
if (rclPoly.Contains(Base::Vector2d(clPt2d.x, clPt2d.y)) == bInner)
{
raulFacets.push_back(*it);
bNoPointInside = false;
@@ -1134,7 +1134,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
{
clGravityOfFacet *= 1.0f/3.0f;
if (rclPoly.Contains(Base::Vector2D(clGravityOfFacet.x, clGravityOfFacet.y)) == bInner)
if (rclPoly.Contains(Base::Vector2d(clGravityOfFacet.x, clGravityOfFacet.y)) == bInner)
raulFacets.push_back(*it);
}
@@ -1150,7 +1150,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
for (int j=0; j<3; j++)
{
clPt2d = pclProj->operator()(clIter->_aclPoints[j]);
if (rclPoly.Contains(Base::Vector2D(clPt2d.x, clPt2d.y)) == bInner)
if (rclPoly.Contains(Base::Vector2d(clPt2d.x, clPt2d.y)) == bInner)
{
raulFacets.push_back(clIter.Position());
break;
@@ -1161,7 +1161,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
}
}
void MeshAlgorithm::CheckFacets(const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly,
void MeshAlgorithm::CheckFacets(const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
bool bInner, std::vector<unsigned long> &raulFacets) const
{
const MeshPointArray& p = _rclMesh.GetPoints();
@@ -1171,7 +1171,7 @@ void MeshAlgorithm::CheckFacets(const Base::ViewProjMethod* pclProj, const Base:
for (MeshFacetArray::_TConstIterator it = f.begin(); it != f.end(); ++it,++index) {
for (int i = 0; i < 3; i++) {
pt2d = (*pclProj)(p[it->_aulPoints[i]]);
if (rclPoly.Contains(Base::Vector2D(pt2d.x, pt2d.y)) == bInner) {
if (rclPoly.Contains(Base::Vector2d(pt2d.x, pt2d.y)) == bInner) {
raulFacets.push_back(index);
break;
}

View File

@@ -36,7 +36,7 @@
namespace Base{
class ViewProjMethod;
class Polygon2D;
class Polygon2d;
}
namespace MeshCore {
@@ -225,12 +225,12 @@ public:
* bInner is \a false then all facets with at least one corner outside the polygon get deleted.
* This algorithm is optimized by using a grid.
*/
void CheckFacets (const MeshFacetGrid &rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly,
void CheckFacets (const MeshFacetGrid &rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
bool bInner, std::vector<unsigned long> &rclRes) const;
/**
* Does the same as the above method unless that it doesn't use a grid.
*/
void CheckFacets (const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly,
void CheckFacets (const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
bool bInner, std::vector<unsigned long> &rclRes) const;
/**
* Determines all facets of the given array \a raclFacetIndices that lie at the edge or that

View File

@@ -698,7 +698,7 @@ void MeshKernel::RemoveInvalids ()
}
void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj,
const Base::Polygon2D& rclPoly, bool bCutInner, std::vector<MeshGeomFacet> &raclFacets)
const Base::Polygon2d& rclPoly, bool bCutInner, std::vector<MeshGeomFacet> &raclFacets)
{
std::vector<unsigned long> aulFacets;
@@ -711,7 +711,7 @@ void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMet
}
void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj,
const Base::Polygon2D& rclPoly, bool bInner, std::vector<unsigned long> &raclCutted)
const Base::Polygon2d& rclPoly, bool bInner, std::vector<unsigned long> &raclCutted)
{
MeshAlgorithm(*this).CheckFacets(rclGrid, pclProj, rclPoly, bInner, raclCutted);
DeleteFacets(raclCutted);

View File

@@ -35,7 +35,7 @@
#include <Base/Matrix.h>
namespace Base{
class Polygon2D;
class Polygon2d;
class ViewProjMethod;
}
@@ -408,13 +408,13 @@ public:
* The facets to be deleted are returned with their geometric reprsentation.
* @see CheckFacets().
*/
void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod *pclP, const Base::Polygon2D& rclPoly,
void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod *pclP, const Base::Polygon2d& rclPoly,
bool bCutInner, std::vector<MeshGeomFacet> &raclFacets);
/**
* Does basically the same as method above unless that the facets to be deleted are returned with their
* index number in the facet array of the mesh structure.
*/
void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclP, const Base::Polygon2D& rclPoly,
void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclP, const Base::Polygon2d& rclPoly,
bool bCutInner, std::vector<unsigned long> &raclCutted);
//@}

View File

@@ -31,7 +31,7 @@
using namespace MeshCore;
MeshTrimming::MeshTrimming(MeshKernel &rclM, const Base::ViewProjMethod* pclProj,
const Base::Polygon2D& rclPoly)
const Base::Polygon2d& rclPoly)
: myMesh(rclM), myInner(true), myProj(pclProj), myPoly(rclPoly)
{
}
@@ -61,7 +61,7 @@ void MeshTrimming::CheckFacets(const MeshFacetGrid& rclGrid, std::vector<unsigne
// cut inner: use grid to accelerate search
if (myInner) {
Base::BoundBox3f clBBox3d;
Base::BoundBox2D clViewBBox, clPolyBBox;
Base::BoundBox2d clViewBBox, clPolyBBox;
std::vector<unsigned long> aulAllElements;
// BBox of polygon
@@ -105,16 +105,16 @@ bool MeshTrimming::HasIntersection(const MeshGeomFacet& rclFacet) const
{
int i;
unsigned long j;
Base::Polygon2D clPoly;
Base::Line2D clFacLine, clPolyLine;
Base::Vector2D S;
Base::Polygon2d clPoly;
Base::Line2d clFacLine, clPolyLine;
Base::Vector2d S;
// is corner of facet inside the polygon
for (i=0; i<3; i++) {
Base::Vector3f clPt2d = myProj->operator ()(rclFacet._aclPoints[i]);
if (myPoly.Contains(Base::Vector2D(clPt2d.x, clPt2d.y)) == myInner)
if (myPoly.Contains(Base::Vector2d(clPt2d.x, clPt2d.y)) == myInner)
return true;
else
clPoly.Add(Base::Vector2D(clPt2d.x, clPt2d.y));
clPoly.Add(Base::Vector2d(clPt2d.x, clPt2d.y));
}
// is corner of polygon inside the facet
@@ -147,7 +147,7 @@ bool MeshTrimming::PolygonContainsCompleteFacet(bool bInner, unsigned long ulInd
for (int i=0; i<3; i++) {
const MeshPoint &rclFacPt = myMesh._aclPointArray[rclFacet._aulPoints[i]];
Base::Vector3f clPt = (*myProj)(rclFacPt);
if (myPoly.Contains(Base::Vector2D(clPt.x, clPt.y)) != bInner)
if (myPoly.Contains(Base::Vector2d(clPt.x, clPt.y)) != bInner)
return false;
}
@@ -156,28 +156,28 @@ bool MeshTrimming::PolygonContainsCompleteFacet(bool bInner, unsigned long ulInd
bool MeshTrimming::IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f& clPoint)
{
Base::Vector2D A, B, C, P;
Base::Vector2d A, B, C, P;
float u,v,w, fDetPAC, fDetPBC, fDetPAB, fDetABC;
Base::Polygon2D clFacPoly;
Base::Polygon2d clFacPoly;
const MeshGeomFacet &rclFacet = myMesh.GetFacet(ulIndex);
for (int i=0; i<3; i++) {
Base::Vector3f clPt = (*myProj)(rclFacet._aclPoints[i]);
clFacPoly.Add(Base::Vector2D(clPt.x, clPt.y));
clFacPoly.Add(Base::Vector2d(clPt.x, clPt.y));
}
A = clFacPoly[0];
B = clFacPoly[1];
C = clFacPoly[2];
fDetABC = (float)(A.fX*B.fY+A.fY*C.fX+B.fX*C.fY-(B.fY*C.fX+A.fY*B.fX+A.fX*C.fY));
fDetABC = (float)(A.x*B.y+A.y*C.x+B.x*C.y-(B.y*C.x+A.y*B.x+A.x*C.y));
for (unsigned long j=0; j<myPoly.GetCtVectors(); j++) {
// facet contains a polygon point -> calculate the corresponding 3d-point
if (clFacPoly.Contains(myPoly[j])) {
P = myPoly[j];
fDetPAC = (float)(A.fX*P.fY+A.fY*C.fX+P.fX*C.fY-(P.fY*C.fX+A.fY*P.fX+A.fX*C.fY));
fDetPBC = (float)(P.fX*B.fY+P.fY*C.fX+B.fX*C.fY-(B.fY*C.fX+P.fY*B.fX+P.fX*C.fY));
fDetPAB = (float)(A.fX*B.fY+A.fY*P.fX+B.fX*P.fY-(B.fY*P.fX+A.fY*B.fX+A.fX*P.fY));
fDetPAC = (float)(A.x*P.y+A.y*C.x+P.x*C.y-(P.y*C.x+A.y*P.x+A.x*C.y));
fDetPBC = (float)(P.x*B.y+P.y*C.x+B.x*C.y-(B.y*C.x+P.y*B.x+P.x*C.y));
fDetPAB = (float)(A.x*B.y+A.y*P.x+B.x*P.y-(B.y*P.x+A.y*B.x+A.x*P.y));
u = fDetPBC / fDetABC;
v = fDetPAC / fDetABC;
w = fDetPAB / fDetABC;
@@ -198,8 +198,8 @@ bool MeshTrimming::IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f&
bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex, int& iSide, std::vector<Base::Vector3f>& raclPoints) const
{
MeshGeomFacet clFac(myMesh.GetFacet(ulIndex));
Base::Vector2D S;
Base::Line2D clFacLine, clPolyLine;
Base::Vector2d S;
Base::Line2d clFacLine, clPolyLine;
int iIntersections=0;
int iIntsctWithEdge0=0, iIntsctWithEdge1=0, iIntsctWithEdge2=0;
@@ -211,15 +211,15 @@ bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex,
if (iIntersections == 4)
break;
Base::Vector2D P3(myPoly[i]), P4(myPoly[(i+1)%myPoly.GetCtVectors()]);
Base::Vector2d P3(myPoly[i]), P4(myPoly[(i+1)%myPoly.GetCtVectors()]);
clPolyLine.clV1 = P3;
clPolyLine.clV2 = P4;
for (int j=0; j<3; j++) {
Base::Vector3f clP1((*myProj)(clFac._aclPoints[j]));
Base::Vector3f clP2((*myProj)(clFac._aclPoints[(j+1)%3]));
Base::Vector2D P1(clP1.x, clP1.y);
Base::Vector2D P2(clP2.x, clP2.y);
Base::Vector2d P1(clP1.x, clP1.y);
Base::Vector2d P2(clP2.x, clP2.y);
clFacLine.clV1 = P1;
clFacLine.clV2 = P2;
@@ -349,10 +349,10 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
int iCtPtsIn=0;
int iCtPtsOn=0;
Base::Vector3f clFacPnt;
Base::Vector2D clProjPnt;
Base::Vector2d clProjPnt;
for (int i=0; i<3; i++) {
clFacPnt = (*myProj)(myMesh._aclPointArray[facet._aulPoints[i]]);
clProjPnt = Base::Vector2D(clFacPnt.x, clFacPnt.y);
clProjPnt = Base::Vector2d(clFacPnt.x, clFacPnt.y);
if (myPoly.Intersect(clProjPnt, MESH_MIN_PT_DIST))
++iCtPtsOn;
else if (myPoly.Contains(clProjPnt) == myInner)
@@ -367,16 +367,16 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
else if (raclPoints.size() == 1) {
Base::Vector3f clP(raclPoints[0]);
clP = ((*myProj)(clP));
Base::Vector2D P(clP.x, clP.y);
Base::Vector2d P(clP.x, clP.y);
MeshGeomFacet clFac(myMesh.GetFacet(ulFacetPos));
// determine the edge containing the intersection point
Base::Line2D clFacLine;
Base::Line2d clFacLine;
for (int j=0; j<3; j++) {
Base::Vector3f clP1((*myProj)(clFac._aclPoints[j]));
Base::Vector3f clP2((*myProj)(clFac._aclPoints[(j+1)%3]));
Base::Vector2D P1(clP1.x, clP1.y);
Base::Vector2D P2(clP2.x, clP2.y);
Base::Vector2d P1(clP1.x, clP1.y);
Base::Vector2d P2(clP2.x, clP2.y);
clFacLine.clV1 = P1;
clFacLine.clV2 = P2;
@@ -415,10 +415,10 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
// check which facets can be inserted
int iCtPts=0;
Base::Vector3f clFacPnt;
Base::Vector2D clProjPnt;
Base::Vector2d clProjPnt;
for (int i=0; i<3; i++) {
clFacPnt = (*myProj)(myMesh._aclPointArray[facet._aulPoints[i]]);
clProjPnt = Base::Vector2D(clFacPnt.x, clFacPnt.y);
clProjPnt = Base::Vector2d(clFacPnt.x, clFacPnt.y);
if (myPoly.Contains(clProjPnt) == myInner)
++iCtPts;
}
@@ -458,10 +458,10 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
// check which facets can be inserted
int iCtPts=0;
Base::Vector3f clFacPnt;
Base::Vector2D clProjPnt;
Base::Vector2d clProjPnt;
for (int i=0; i<3; i++) {
clFacPnt = (*myProj)(myMesh._aclPointArray[facet._aulPoints[i]]);
clProjPnt = Base::Vector2D(clFacPnt.x, clFacPnt.y);
clProjPnt = Base::Vector2d(clFacPnt.x, clFacPnt.y);
if (myPoly.Contains(clProjPnt) == myInner)
++iCtPts;
}
@@ -635,10 +635,10 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
// check which facets should be inserted
int iCtPts=0;
Base::Vector3f clFacPnt;
Base::Vector2D clProjPnt;
Base::Vector2d clProjPnt;
for (int i=0; i<3; i++) {
clFacPnt = (*myProj)(myMesh._aclPointArray[facet._aulPoints[i]]);
clProjPnt = Base::Vector2D(clFacPnt.x, clFacPnt.y);
clProjPnt = Base::Vector2d(clFacPnt.x, clFacPnt.y);
if (myPoly.Contains(clProjPnt) == myInner)
++iCtPts;
}

View File

@@ -39,7 +39,7 @@ public:
enum TMode {INNER, OUTER};
public:
MeshTrimming(MeshKernel& mesh, const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly);
MeshTrimming(MeshKernel& mesh, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly);
~MeshTrimming();
public:
@@ -100,7 +100,7 @@ private:
bool myInner;
std::vector<MeshGeomFacet> myTriangles;
const Base::ViewProjMethod* myProj;
const Base::Polygon2D& myPoly;
const Base::Polygon2d& myPoly;
};
} //namespace MeshCore

View File

@@ -979,7 +979,7 @@ void MeshObject::crossSections(const std::vector<MeshObject::TPlane>& planes, st
}
}
void MeshObject::cut(const Base::Polygon2D& polygon2d,
void MeshObject::cut(const Base::Polygon2d& polygon2d,
const Base::ViewProjMethod& proj, MeshObject::CutType type)
{
MeshCore::MeshAlgorithm meshAlg(this->_kernel);
@@ -1004,7 +1004,7 @@ void MeshObject::cut(const Base::Polygon2D& polygon2d,
this->deleteFacets(check);
}
void MeshObject::trim(const Base::Polygon2D& polygon2d,
void MeshObject::trim(const Base::Polygon2d& polygon2d,
const Base::ViewProjMethod& proj, MeshObject::CutType type)
{
MeshCore::MeshTrimming trim(this->_kernel, &proj, polygon2d);

View File

@@ -50,7 +50,7 @@ class List;
}
namespace Base {
class Polygon2D;
class Polygon2d;
class ViewProjMethod;
}
@@ -217,8 +217,8 @@ public:
std::vector<Base::Vector3d> getPointNormals() const;
void crossSections(const std::vector<TPlane>&, std::vector<TPolylines> &sections,
float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const;
void cut(const Base::Polygon2D& polygon, const Base::ViewProjMethod& proj, CutType);
void trim(const Base::Polygon2D& polygon, const Base::ViewProjMethod& proj, CutType);
void cut(const Base::Polygon2d& polygon, const Base::ViewProjMethod& proj, CutType);
void trim(const Base::Polygon2d& polygon, const Base::ViewProjMethod& proj, CutType);
//@}
/** @name Selection */

View File

@@ -1524,9 +1524,9 @@ PyObject* MeshPy::cut(PyObject *args)
polygon = tria.ProjectToFitPlane();
Base::ViewProjMatrix proj(mat);
Base::Polygon2D polygon2d;
Base::Polygon2d polygon2d;
for (std::vector<Base::Vector3f>::const_iterator it = polygon.begin(); it != polygon.end(); ++it)
polygon2d.Add(Base::Vector2D(it->x, it->y));
polygon2d.Add(Base::Vector2d(it->x, it->y));
getMeshObjectPtr()->cut(polygon2d, proj, MeshObject::CutType(mode));
Py_Return;
@@ -1558,9 +1558,9 @@ PyObject* MeshPy::trim(PyObject *args)
polygon = tria.ProjectToFitPlane();
Base::ViewProjMatrix proj(mat);
Base::Polygon2D polygon2d;
Base::Polygon2d polygon2d;
for (std::vector<Base::Vector3f>::const_iterator it = polygon.begin(); it != polygon.end(); ++it)
polygon2d.Add(Base::Vector2D(it->x, it->y));
polygon2d.Add(Base::Vector2d(it->x, it->y));
getMeshObjectPtr()->trim(polygon2d, proj, MeshObject::CutType(mode));
Py_Return;

View File

@@ -986,11 +986,11 @@ void CmdMeshTrimByPlane::activated(int)
p3 = mat * p3;
p4 = mat * p4;
Base::Polygon2D polygon2d;
polygon2d.Add(Base::Vector2D(p1.x, p1.y));
polygon2d.Add(Base::Vector2D(p2.x, p2.y));
polygon2d.Add(Base::Vector2D(p3.x, p3.y));
polygon2d.Add(Base::Vector2D(p4.x, p4.y));
Base::Polygon2d polygon2d;
polygon2d.Add(Base::Vector2d(p1.x, p1.y));
polygon2d.Add(Base::Vector2d(p2.x, p2.y));
polygon2d.Add(Base::Vector2d(p3.x, p3.y));
polygon2d.Add(Base::Vector2d(p4.x, p4.y));
Mesh::MeshObject::CutType type = Mesh::MeshObject::INNER;
mesh->trim(polygon2d, proj, type);

View File

@@ -1059,9 +1059,9 @@ void ViewProviderMesh::getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
{
#if 1
const bool ok = true;
Base::Polygon2D polygon;
Base::Polygon2d polygon;
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it)
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
polygon.Add(Base::Vector2d((*it)[0],(*it)[1]));
// Get the attached mesh property
Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
@@ -1289,9 +1289,9 @@ void ViewProviderMesh::trimMesh(const std::vector<SbVec2f>& polygon,
{
Mesh::MeshObject* mesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.startEditing();
Base::Polygon2D polygon2d;
Base::Polygon2d polygon2d;
for (std::vector<SbVec2f>::const_iterator it = polygon.begin(); it != polygon.end(); ++it)
polygon2d.Add(Base::Vector2D((*it)[0],(*it)[1]));
polygon2d.Add(Base::Vector2d((*it)[0],(*it)[1]));
Mesh::MeshObject::CutType type = inner ?
Mesh::MeshObject::INNER :