MeshCore::MeshGeomFacet Class Reference

The MeshGeomFacet class is geometric counterpart to MeshFacet that holds the geometric data points of a triangle. More...

#include <Elements.h>

Inheritance diagram for MeshCore::MeshGeomFacet:
Mesh::Facet

List of all members.

Public Member Functions

void AdjustCirculationDirection (void)
 Adjusts the facet's orientation to its normal.
float Area () const
 Calculates the area of a facet.
void ArrangeNormal (const Base::Vector3f &rclN)
 Arrange the facet normal so the both vectors have the same orientation.
void CalcNormal (void)
 Calculates the facet normal for storing internally.
float CenterOfCircumCircle (Base::Vector3f &rclCenter) const
 Calculates the center and radius of the circum circle of the facet.
float CenterOfInscribedCircle (Base::Vector3f &rclCenter) const
 Calculates the center and radius of the inscribed circle of the facet.
bool ContainedByOrIntersectBoundingBox (const Base::BoundBox3f &rcBB) const
 Checks if the facet is inside the bounding box or intersects with it.
float DistancePlaneToPoint (const Base::Vector3f &rclPoint) const
 Calculates the distance of a point to the plane defined by the triangle.
float DistanceToLineSegment (const Base::Vector3f &rcP1, const Base::Vector3f &rcP2) const
 Calculates the shortest distance from the line segment defined by rcP1 and rcP2 to this facet.
float DistanceToPoint (const Base::Vector3f &rclPt, Base::Vector3f &rclNt) const
 Calculates the shortest distance from the point rcPt to the facet.
float DistanceToPoint (const Base::Vector3f &rcPt) const
 Calculates the shortest distance from the point rcPt to the facet.
void Enlarge (float fDist)
 Enlarges the triangle.
bool Foraminate (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, Base::Vector3f &rclRes, float fMaxAngle=F_PI) const
 Calculates the intersection point of the line defined by the base rclPt and the direction rclDir with the facet.
Base::BoundBox3f GetBoundBox (void) const
 Returns the wrapping bounding box.
Base::Vector3f GetGravityPoint (void) const
 Calculates the facet's gravity point.
Base::Vector3f GetNormal (void) const
 Returns the normal of the facet.
bool IntersectBoundingBox (const Base::BoundBox3f &rclBB) const
 Checks if the facet intersects with the given bounding box.
bool IntersectPlaneWithLine (const Base::Vector3f &rclBase, const Base::Vector3f &rclNormal, Base::Vector3f &rclRes) const
 Checks if the plane defined by the facet rclFacet intersects with the line defined by the base rclBase and the direction rclNormal and returns the intersection point rclRes if possible.
int IntersectWithFacet (const MeshGeomFacet &facet, Base::Vector3f &rclPt0, Base::Vector3f &rclPt1) const
 Intersect the facet with the other facet The result is line given by two points (if intersected).
bool IntersectWithFacet (const MeshGeomFacet &rclFacet) const
 This method checks if both facets intersect.
bool IntersectWithLine (const Base::Vector3f &rclPt, const Base::Vector3f &rclDir, Base::Vector3f &rclRes) const
 Calculates the intersection point of the line defined by the base rclPt and the direction rclDir with the facet.
bool IntersectWithPlane (const Base::Vector3f &rclBase, const Base::Vector3f &rclNormal) const
 Checks if the facet intersects with the plane defined by the base rclBase and the normal rclNormal.
bool IntersectWithPlane (const Base::Vector3f &rclBase, const Base::Vector3f &rclNormal, Base::Vector3f &rclP1, Base::Vector3f &rclP2) const
 Checks if the facet intersects with the plane defined by the base rclBase and the normal rclNormal and returns true if two points are found, false otherwise.
bool IsDeformed () const
 Checks whether the triangle is deformed.
bool IsDegenerated () const
 Checks whether the triangle is degenerated.
bool IsFlag (MeshFacet::TFlagType tF) const
 Query the flag state of the facet.
bool IsPointOf (const Base::Vector3f &rclPoint) const
 Checks if the point is inside or at the border of the facet.
bool IsPointOf (const Base::Vector3f &rclPoint, float fDistance) const
 Checks if the point is part of the facet.
bool IsPointOfFace (const Base::Vector3f &rclP, float fDistance) const
 Checks whether the given point is inside the facet with tolerance fDistance.
bool IsPointOfSphere (const MeshGeomFacet &rFacet) const
 This is an overloaded member function, provided for convenience.
bool IsPointOfSphere (const Base::Vector3f &rP) const
 The center and radius of the circum circle define a sphere in 3D.
float MaximumAngle () const
 Calculates the maximum angle of a facet.
void NearestEdgeToPoint (const Base::Vector3f &rclPt, float &fDistance, unsigned short &side) const
 Returns the edge number side of the facet and the distance to the edge that is nearest to the point rclPt.
unsigned short NearestEdgeToPoint (const Base::Vector3f &rclPt) const
 Returns the edge number of the facet that is nearest to the point rclPt.
void NormalInvalid (void)
 Checks if the normal is not yet calculated.
float Perimeter () const
 Calculates the perimeter of the facet.
void ProjectFacetToPlane (MeshGeomFacet &rclFacet) const
 Calculates the projection of a facet onto the plane defined by the triangle.
void ProjectPointToPlane (Base::Vector3f &rclPoint) const
 Calculates the projection of a point onto the plane defined by the triangle.
void ResetFlag (MeshFacet::TFlagType tF)
 Reset flag state.
void SetFlag (MeshFacet::TFlagType tF)
 Set flag state.
void SetNormal (const Base::Vector3f &rclNormal)
 Sets the facet's normal.
void SubSample (float fStep, std::vector< Base::Vector3f > &rclPoints) const
 Subsamples the facet into points with resolution fStep.
float VolumeOfPrism (const MeshGeomFacet &rclF) const
 Calculates the volume of the prism defined by two facets.
bool Weights (const Base::Vector3f &rclP, float &w0, float &w1, float &w2) const
 Calculates the weights w1, .
Construction



 MeshGeomFacet (const Base::Vector3f &v1, const Base::Vector3f &v2, const Base::Vector3f &v3)
 Constructor with the corner points.
 MeshGeomFacet (void)
 default constructor
 ~MeshGeomFacet (void)
 Destruction.

Public Attributes

Base::Vector3f _aclPoints [3]
 Geometric corner points.
unsigned char _ucFlag
 Flag property.
unsigned long _ulProp
 Free usable property.

Protected Attributes

bool _bNormalCalculated
 True if the normal is already calculated.
Base::Vector3f _clNormal
 Normal of the facet.

Detailed Description

The MeshGeomFacet class is geometric counterpart to MeshFacet that holds the geometric data points of a triangle.

Definition at line 292 of file Elements.h.


Constructor & Destructor Documentation

MeshGeomFacet::MeshGeomFacet ( void   ) 

default constructor

Definition at line 224 of file Elements.cpp.

Referenced by Weights().

MeshGeomFacet::MeshGeomFacet ( const Base::Vector3f v1,
const Base::Vector3f v2,
const Base::Vector3f v3 
)

Constructor with the corner points.

Definition at line 232 of file Elements.cpp.

References _aclPoints.

MeshCore::MeshGeomFacet::~MeshGeomFacet ( void   )  [inline]

Destruction.

Definition at line 302 of file Elements.h.


Member Function Documentation

void MeshCore::MeshGeomFacet::AdjustCirculationDirection ( void   )  [inline]

Adjusts the facet's orientation to its normal.

Definition at line 679 of file Elements.h.

References _aclPoints, _clNormal, and boost::numeric::bindings::atlas::swap().

float MeshCore::MeshGeomFacet::Area (  )  const [inline]
void MeshCore::MeshGeomFacet::ArrangeNormal ( const Base::Vector3f rclN  )  [inline]

Arrange the facet normal so the both vectors have the same orientation.

Definition at line 667 of file Elements.h.

References _clNormal, SketcherExample::f, and GetNormal().

void MeshCore::MeshGeomFacet::CalcNormal ( void   )  [inline]
float MeshGeomFacet::CenterOfCircumCircle ( Base::Vector3f rclCenter  )  const

Calculates the center and radius of the circum circle of the facet.

Definition at line 883 of file Elements.cpp.

References _aclPoints, Area(), KDL::sqrt(), RobotExample::w, Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.

Referenced by MeshCore::MeshTopoAlgorithm::DelaunayFlip(), and IsPointOfSphere().

float MeshGeomFacet::CenterOfInscribedCircle ( Base::Vector3f rclCenter  )  const

Calculates the center and radius of the inscribed circle of the facet.

Definition at line 860 of file Elements.cpp.

References _aclPoints, Area(), FemExample::b, Sketcher::Distance, RobotExample::w, Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.

bool MeshCore::MeshGeomFacet::ContainedByOrIntersectBoundingBox ( const Base::BoundBox3f rcBB  )  const [inline]

Checks if the facet is inside the bounding box or intersects with it.

Definition at line 706 of file Elements.h.

References _aclPoints, GetBoundBox(), IntersectBoundingBox(), and Base::BoundBox3< _Precision >::IsInBox().

float MeshCore::MeshGeomFacet::DistancePlaneToPoint ( const Base::Vector3f rclPoint  )  const [inline]

Calculates the distance of a point to the plane defined by the triangle.

Definition at line 638 of file Elements.h.

References _aclPoints, Base::Vector3< _Precision >::DistanceToPlane(), and GetNormal().

Referenced by IsPointOf().

float MeshGeomFacet::DistanceToLineSegment ( const Base::Vector3f rcP1,
const Base::Vector3f rcP2 
) const
float MeshGeomFacet::DistanceToPoint ( const Base::Vector3f rclPt,
Base::Vector3f rclNt 
) const
float MeshCore::MeshGeomFacet::DistanceToPoint ( const Base::Vector3f rcPt  )  const [inline]

Calculates the shortest distance from the point rcPt to the facet.

Definition at line 416 of file Elements.h.

References DistanceToPoint().

Referenced by MeshCore::MeshAlgorithm::Distance(), DistanceToPoint(), MeshCore::MeshAlgorithm::NearestPointFromPoint(), and MeshCore::MeshFacetGrid::SearchNearestFacetInGrid().

void MeshGeomFacet::Enlarge ( float  fDist  ) 
bool MeshGeomFacet::Foraminate ( const Base::Vector3f rclPt,
const Base::Vector3f rclDir,
Base::Vector3f rclRes,
float  fMaxAngle = F_PI 
) const

Calculates the intersection point of the line defined by the base rclPt and the direction rclDir with the facet.

The intersection must be inside the facet. If there is no intersection false is returned. This does actually the same as IntersectWithLine() with one additionally constraint that the angle between the direction of the line and the normal of the plane must not exceed fMaxAngle.

Definition at line 575 of file Elements.cpp.

References _aclPoints, eps, SketcherExample::f, Base::Vector3< _Precision >::GetAngle(), GetNormal(), RobotExample::t, and RobotExample::w.

Referenced by MeshCore::MeshAlgorithm::NearestFacetOnRay(), and MeshCore::MeshAlgorithm::RayNearestField().

Base::BoundBox3f MeshCore::MeshGeomFacet::GetBoundBox ( void   )  const [inline]

Returns the wrapping bounding box.

Definition at line 686 of file Elements.h.

References _aclPoints.

Referenced by ContainedByOrIntersectBoundingBox().

Base::Vector3f MeshCore::MeshGeomFacet::GetGravityPoint ( void   )  const [inline]
Base::Vector3f MeshCore::MeshGeomFacet::GetNormal ( void   )  const [inline]
bool MeshGeomFacet::IntersectBoundingBox ( const Base::BoundBox3f rclBB  )  const
bool MeshGeomFacet::IntersectPlaneWithLine ( const Base::Vector3f rclBase,
const Base::Vector3f rclNormal,
Base::Vector3f rclRes 
) const

Checks if the plane defined by the facet rclFacet intersects with the line defined by the base rclBase and the direction rclNormal and returns the intersection point rclRes if possible.

Definition at line 619 of file Elements.cpp.

References SketcherExample::f, GetGravityPoint(), and GetNormal().

Referenced by IntersectWithLine(), and ProjectFacetToPlane().

int MeshGeomFacet::IntersectWithFacet ( const MeshGeomFacet facet,
Base::Vector3f rclPt0,
Base::Vector3f rclPt1 
) const

Intersect the facet with the other facet The result is line given by two points (if intersected).

Fast Triangle-Triangle Intersection Test by Tomas Möller http://www.acm.org/jgt/papers/Moller97/tritri.html http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/.

Return is the number of intersections points: 0: no intersection, 1: one intersection point (rclPt0), 2: two intersections points (rclPt0, rclPt1)

Definition at line 778 of file Elements.cpp.

References _aclPoints, GetNormal(), IsPointOf(), tri_tri_intersect_with_isectline(), Base::Vector3< _Precision >::x, Base::Vector3< _Precision >::y, and Base::Vector3< _Precision >::z.

bool MeshGeomFacet::IntersectWithFacet ( const MeshGeomFacet rclFacet  )  const
bool MeshGeomFacet::IntersectWithLine ( const Base::Vector3f rclPt,
const Base::Vector3f rclDir,
Base::Vector3f rclRes 
) const

Calculates the intersection point of the line defined by the base rclPt and the direction rclDir with the facet.

The intersection must be inside the facet. If there is no intersection false is returned.

Definition at line 632 of file Elements.cpp.

References SketcherExample::f, IntersectPlaneWithLine(), and IsPointOfFace().

Referenced by MeshCore::MeshEvalFoldsOnSurface::Evaluate().

bool MeshCore::MeshGeomFacet::IntersectWithPlane ( const Base::Vector3f rclBase,
const Base::Vector3f rclNormal 
) const [inline]

Checks if the facet intersects with the plane defined by the base rclBase and the normal rclNormal.

Definition at line 729 of file Elements.h.

References _aclPoints, and Base::Vector3< _Precision >::DistanceToPlane().

bool MeshGeomFacet::IntersectWithPlane ( const Base::Vector3f rclBase,
const Base::Vector3f rclNormal,
Base::Vector3f rclP1,
Base::Vector3f rclP2 
) const
bool MeshGeomFacet::IsDeformed (  )  const

Checks whether the triangle is deformed.

The definition of a deformed triangles is not as strong as the definition of a degenerated triangle. A triangle is deformed if the maximum angle exceeds 120° or the minimum angle falls below 30°. A degenerated triangle is also a deformed triangle.

Definition at line 421 of file Elements.cpp.

References _aclPoints, SketcherExample::f, Wm4::Vector3< Real >::Normalize(), and Base::Vector3< _Precision >::Normalize().

bool MeshGeomFacet::IsDegenerated (  )  const

Checks whether the triangle is degenerated.

A triangle is degenerated if its area is less than an epsilon.

Definition at line 391 of file Elements.cpp.

References _aclPoints, MeshCore::MeshDefinitions::_fMinPointDistanceP2, and eps.

Referenced by MeshCore::MeshTopoAlgorithm::IsSwapEdgeLegal().

bool MeshCore::MeshGeomFacet::IsFlag ( MeshFacet::TFlagType  tF  )  const [inline]

Query the flag state of the facet.

Definition at line 376 of file Elements.h.

bool MeshGeomFacet::IsPointOf ( const Base::Vector3f rclPoint  )  const

Checks if the point is inside or at the border of the facet.

The point must already exactly lie on the plane defined by the facet, which is not checked. This method is very efficient.

Definition at line 825 of file Elements.cpp.

References _aclPoints, eps, RobotExample::t, RobotExample::w, Base::Vector3< _Precision >::x, MovieTool::x, Base::Vector3< _Precision >::y, MovieTool::y, and Base::Vector3< _Precision >::z.

bool MeshGeomFacet::IsPointOf ( const Base::Vector3f rclPoint,
float  fDistance 
) const

Checks if the point is part of the facet.

A point is regarded as part of a facet if the distance is lower fDistance and the projected point in the facet normal direction is inside the triangle.

Definition at line 244 of file Elements.cpp.

References _aclPoints, DistancePlaneToPoint(), Base::Vector3< _Precision >::DistanceToLine(), SketcherExample::f, and GetNormal().

Referenced by IntersectWithFacet().

bool MeshGeomFacet::IsPointOfFace ( const Base::Vector3f rclP,
float  fDistance 
) const

Checks whether the given point is inside the facet with tolerance fDistance.

This method does actually the same as IsPointOf() but this implementation is done more effective through comparison of normals.

Definition at line 306 of file Elements.cpp.

References _aclPoints, FemExample::b, SketcherExample::f, Base::Vector3< _Precision >::Length(), draftTools::p, MovieTool::x, and MovieTool::y.

Referenced by MeshCore::MeshAlgorithm::FirstFacetToVertex(), and IntersectWithLine().

bool MeshGeomFacet::IsPointOfSphere ( const MeshGeomFacet rFacet  )  const

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function. If one of the facet's points is inside the sphere true is returned, otherwise false.

Definition at line 1126 of file Elements.cpp.

References _aclPoints, CenterOfCircumCircle(), draftlibs::fcvec::dist(), and Base::DistanceP2().

bool MeshGeomFacet::IsPointOfSphere ( const Base::Vector3f rP  )  const

The center and radius of the circum circle define a sphere in 3D.

If the point rP is part of this sphere true is returned, otherwise false.

Definition at line 1115 of file Elements.cpp.

References CenterOfCircumCircle(), draftlibs::fcvec::dist(), and Base::DistanceP2().

float MeshGeomFacet::MaximumAngle (  )  const

Calculates the maximum angle of a facet.

Definition at line 1100 of file Elements.cpp.

References _aclPoints, and Base::Vector3< _Precision >::GetAngle().

Referenced by MeshCore::MeshTopoAlgorithm::ShouldSwapEdge(), and MeshCore::QuasiDelaunayTriangulator::Triangulate().

void MeshGeomFacet::NearestEdgeToPoint ( const Base::Vector3f rclPt,
float &  fDistance,
unsigned short &  side 
) const

Returns the edge number side of the facet and the distance to the edge that is nearest to the point rclPt.

Definition at line 987 of file Elements.cpp.

References _aclPoints, Sketcher::Distance, SketcherExample::f, FLOAT_MAX, and RobotExample::t.

unsigned short MeshGeomFacet::NearestEdgeToPoint ( const Base::Vector3f rclPt  )  const

Returns the edge number of the facet that is nearest to the point rclPt.

Definition at line 916 of file Elements.cpp.

References _aclPoints, Sketcher::Distance, SketcherExample::f, FLOAT_MAX, and RobotExample::t.

Referenced by MeshCore::MeshAlgorithm::FirstFacetToVertex().

void MeshCore::MeshGeomFacet::NormalInvalid ( void   )  [inline]

Checks if the normal is not yet calculated.

Definition at line 374 of file Elements.h.

Referenced by MeshCore::MeshFacetIterator::Dereference().

float MeshCore::MeshGeomFacet::Perimeter (  )  const [inline]

Calculates the perimeter of the facet.

Definition at line 691 of file Elements.h.

References _aclPoints, and Sketcher::Distance.

void MeshGeomFacet::ProjectFacetToPlane ( MeshGeomFacet rclFacet  )  const

Calculates the projection of a facet onto the plane defined by the triangle.

Definition at line 357 of file Elements.cpp.

References _aclPoints, GetNormal(), and IntersectPlaneWithLine().

void MeshGeomFacet::ProjectPointToPlane ( Base::Vector3f rclPoint  )  const

Calculates the projection of a point onto the plane defined by the triangle.

Definition at line 352 of file Elements.cpp.

References _aclPoints, GetNormal(), and Base::Vector3< _Precision >::ProjToPlane().

Referenced by MeshCore::MeshAlgorithm::FirstFacetToVertex().

void MeshCore::MeshGeomFacet::ResetFlag ( MeshFacet::TFlagType  tF  )  [inline]

Reset flag state.

Definition at line 382 of file Elements.h.

void MeshCore::MeshGeomFacet::SetFlag ( MeshFacet::TFlagType  tF  )  [inline]

Set flag state.

Definition at line 379 of file Elements.h.

void MeshCore::MeshGeomFacet::SetNormal ( const Base::Vector3f rclNormal  )  [inline]
void MeshGeomFacet::SubSample ( float  fStep,
std::vector< Base::Vector3f > &  rclPoints 
) const
float MeshGeomFacet::VolumeOfPrism ( const MeshGeomFacet rclF  )  const

Calculates the volume of the prism defined by two facets.

Note:
The two facets must not intersect.

Definition at line 1058 of file Elements.cpp.

References _aclPoints, and Base::Length.

bool MeshGeomFacet::Weights ( const Base::Vector3f rclP,
float &  w0,
float &  w1,
float &  w2 
) const

Calculates the weights w1, .

.., w3 of the corners to get the point rclP, i.e. rclP = w0*v0 + w1*v1 + w2*v2 (v0-v2 are the corners corners). If w0+w1+w2==1.0 then the point rclP lies on the plane that is spanned by the facet, otherwise the point doesn't lie on the plane. If the sum of wi is 1 and if each wi is between [0,1] than the point lies inside the facet or on the border, respectively.

If the point doesn't lie on the plane false is returned, true otherwise.

Definition at line 338 of file Elements.cpp.

References _aclPoints, Area(), SketcherExample::f, and MeshGeomFacet().


Member Data Documentation

Geometric corner points.

Definition at line 473 of file Elements.h.

Referenced by MeshCore::MeshKernel::AddFacet(), Inspection::MeshInspectGrid::AddFacet(), MeshCore::MeshFacetGrid::AddFacet(), MeshCore::MeshBuilder::AddFacet(), Mesh::MeshPy::addFacets(), AdjustCirculationDirection(), MeshCore::MeshTopoAlgorithm::AdjustEdgesToCurvatureDirection(), MeshCore::MeshPlaneVisitor::AllowVisit(), Area(), CalcNormal(), CenterOfCircumCircle(), CenterOfInscribedCircle(), MeshCore::MeshAlgorithm::CheckFacets(), ContainedByOrIntersectBoundingBox(), Mesh::MeshObject::createMeshFromList(), MeshGui::ViewProviderMesh::createToolMesh(), MeshCore::MeshTopoAlgorithm::DelaunayFlip(), MeshCore::MeshFacetIterator::Dereference(), DistancePlaneToPoint(), DistanceToLineSegment(), DistanceToPoint(), Enlarge(), MeshGui::ViewProviderMesh::faceInfo(), Mesh::Facet::Facet(), MeshCore::MeshAlgorithm::FillupHole(), Foraminate(), GetBoundBox(), MeshCore::MeshKernel::GetFacet(), MeshCore::MeshAlgorithm::GetFacetsFromPlane(), GetGravityPoint(), Mesh::FacetPy::getPoints(), MeshCore::MeshKernel::GetVolume(), IntersectBoundingBox(), IntersectWithFacet(), IntersectWithPlane(), IsDeformed(), IsDegenerated(), IsPointOf(), IsPointOfFace(), IsPointOfSphere(), MeshCore::MeshInput::LoadAsciiSTL(), MeshCore::MeshInput::LoadInventor(), MaximumAngle(), MeshGeomFacet(), MeshCore::MeshPlaneVisitor::MeshPlaneVisitor(), NearestEdgeToPoint(), Perimeter(), MeshPart::CurveProjectorShape::projectCurve(), ProjectFacetToPlane(), ProjectPointToPlane(), MeshCore::MeshFixDegeneratedFacets::RemoveEdgeTooSmall(), Mesh::FacetPy::representation(), MeshCore::MeshOutput::SaveAsciiSTL(), MeshCore::MeshOutput::SaveBinarySTL(), MeshCore::MeshOutput::SavePython(), SpringbackCorrection::SmoothMesh(), SubSample(), MeshCore::DelaunayTriangulator::Triangulate(), MeshCore::EarClippingTriangulator::Triangulate(), VolumeOfPrism(), and Weights().

True if the normal is already calculated.

Definition at line 470 of file Elements.h.

Referenced by CalcNormal(), GetNormal(), and SetNormal().

Normal of the facet.

Definition at line 469 of file Elements.h.

Referenced by AdjustCirculationDirection(), ArrangeNormal(), CalcNormal(), GetNormal(), and SetNormal().


The documentation for this class was generated from the following files:

Generated on Wed Nov 23 19:02:24 2011 for FreeCAD by  doxygen 1.6.1