+ fix mesh trimming
This commit is contained in:
parent
7120279ec0
commit
b316991220
|
@ -431,3 +431,19 @@ void Polygon2D::Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rc
|
|||
rclResultPolygonList.push_back(clResultPolygon);
|
||||
}
|
||||
|
||||
bool Polygon2D::Intersect (const Vector2D &rclV, double eps) const
|
||||
{
|
||||
if (_aclVct.size() < 2)
|
||||
return false;
|
||||
|
||||
size_t numPts = GetCtVectors();
|
||||
for (size_t i = 0; i < numPts; i++) {
|
||||
Vector2D clPt0 = (*this)[i];
|
||||
Vector2D clPt1 = (*this)[(i+1)%numPts];
|
||||
Line2D clLine(clPt0, clPt1);
|
||||
if (clLine.Intersect(rclV, eps))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -154,7 +154,8 @@ public:
|
|||
// misc
|
||||
BoundBox2D CalcBoundBox (void) const;
|
||||
bool Contains (const Vector2D &rclV) const;
|
||||
void Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rclResultPolygonList) const;
|
||||
void Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rclResultPolygonList) const;
|
||||
bool Intersect (const Vector2D &rclV, double eps) const;
|
||||
|
||||
private:
|
||||
std::vector<Vector2D> _aclVct;
|
||||
|
|
|
@ -346,18 +346,21 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
|
|||
// no intersection point found => triangle is only touched at a corner point
|
||||
if (raclPoints.size() == 0) {
|
||||
MeshFacet& facet = myMesh._aclFacetArray[ulFacetPos];
|
||||
int iCtPts=0;
|
||||
int iCtPtsIn=0;
|
||||
int iCtPtsOn=0;
|
||||
Base::Vector3f clFacPnt;
|
||||
Base::Vector2D clProjPnt;
|
||||
for (int i=0; i<3; i++) {
|
||||
clFacPnt = (*myProj)(myMesh._aclPointArray[facet._aulPoints[i]]);
|
||||
clProjPnt = Base::Vector2D(clFacPnt.x, clFacPnt.y);
|
||||
if (myPoly.Contains(clProjPnt) == myInner)
|
||||
++iCtPts;
|
||||
if (myPoly.Intersect(clProjPnt, MESH_MIN_PT_DIST))
|
||||
++iCtPtsOn;
|
||||
else if (myPoly.Contains(clProjPnt) == myInner)
|
||||
++iCtPtsIn;
|
||||
}
|
||||
|
||||
// in this case we can use the original triangle
|
||||
if (iCtPts < 3)
|
||||
if (iCtPtsIn != (3 - iCtPtsOn))
|
||||
aclNewFacets.push_back(myMesh.GetFacet(ulFacetPos));
|
||||
}
|
||||
// one intersection point found => triangle is also touched at a corner point
|
||||
|
|
Loading…
Reference in New Issue
Block a user