}
// Face tolerance
- Standard_Real squareTolerance = BRep_Tool::Tolerance(F);
- squareTolerance = squareTolerance * squareTolerance;
+ Standard_Real aTol = BRep_Tool::Tolerance(F);
+ Standard_Real squareTolerance = aTol * aTol;
// Compute parameters
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
gp_Pnt aP (theXYZlist->Value(iCLower + iP * 3),
theXYZlist->Value(iCLower + iP * 3 + 1),
theXYZlist->Value(iCLower + iP * 3 + 2));
- Standard_Real U, V;
- gp_Pnt aPonF = GEOMUtils::ProjectPointOnFace(aP, F, U, V);
- if (aP.SquareDistance(aPonF) < squareTolerance) {
- if (isNormalized) {
- // Normalize parameters to be in [0, 1]
- U = (U - U1) / dU;
- V = (V - V1) / dV;
+ try { // as GEOMUtils::ProjectPointOnFace can throw exceptions
+ Standard_Real U, V;
+ gp_Pnt aPonF = GEOMUtils::ProjectPointOnFace(aP, F, U, V, aTol);
+ if (aP.SquareDistance(aPonF) < squareTolerance) {
+ if (isNormalized) {
+ // Normalize parameters to be in [0, 1]
+ U = (U - U1) / dU;
+ V = (V - V1) / dV;
+ }
+ aRet->SetValue(iP * 2 , U);
+ aRet->SetValue(iP * 2 + 1, V);
+ }
+ else {
+ SetErrorCode("Point too far from face");
+ return aRet;
}
- aRet->SetValue(iP * 2 , U);
- aRet->SetValue(iP * 2 + 1, V);
}
- else {
- SetErrorCode("Point too far from face");
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return aRet;
}
}
//=======================================================================
gp_Pnt GEOMUtils::ProjectPointOnFace(const gp_Pnt& thePoint,
const TopoDS_Shape& theFace,
- double& theU, double& theV)
+ double& theU, double& theV,
+ const double theTol)
{
if (theFace.IsNull() || theFace.ShapeType() != TopAbs_FACE)
Standard_TypeMismatch::Raise
BRepTools::UVBounds(aFace, U1, U2, V1, V2);
// projector
- Standard_Real tol = 1.e-4;
+ Standard_Real tol = Max(theTol, 1.e-4);
GeomAPI_ProjectPointOnSurf proj;
proj.Init(surface, U1, U2, V1, V2, tol);
proj.Perform(thePoint);
* \brief Compute numerical functor for the shape.
*
* Resulting value can be used to sort out shapes according to some parameter.
- *
+ *
* Returns a pair of two values (dist, functor) where
* - \a dist is a some value that is computed according to the center of mass of given shape;
* - \a functor is a numerical functor value
*
* The numerical functor is computed according to the shape's topological properties as follows:
- * - orientation for vertices
+ * - orientation for vertices
* - length for edges and wires
* - area for faces and shells
* - volume for solids, compounds, compsolids
* \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
*/
Standard_EXPORT bool CheckTriangulation (const TopoDS_Shape& theShape);
-
+
/*!
* \brief Return type of shape for explode. In case of compound it will be a type of its first sub shape.
* \param theShape The shape to get type of.
Standard_EXPORT Standard_Real GetMinDistanceSingular(const TopoDS_Shape& aSh1,
const TopoDS_Shape& aSh2,
gp_Pnt& Ptmp1, gp_Pnt& Ptmp2);
-
+
/*!
* \brief Computes minumal distance between two shapes.
*
Standard_EXPORT Standard_Real GetMinDistance(const TopoDS_Shape& theShape1,
const TopoDS_Shape& theShape2,
gp_Pnt& thePnt1, gp_Pnt& thePnt2);
-
+
/*!
* \brief Computes normal projection of \a thePoint to \a theFace.
*
* \param theFace the face shape
* \param theU the output U parameter of the point on the face
* \param theV the output V parameter of the point on the face
+ * \param theTol the tolerance value. Maximum of theTol and 1e-04 will be used for calculation.
* \retval the projection (3d point) if found, throws an exception otherwise
*/
Standard_EXPORT gp_Pnt ProjectPointOnFace(const gp_Pnt& thePoint,
const TopoDS_Shape& theFace,
- double& theU, double& theV);
-
+ double& theU, double& theV,
+ const double theTol = 1e-04);
+
/*!
* \brief Returns the point clicked in 3D view.
*
* operation or \c false otherwise
*/
Standard_EXPORT bool CheckBOPArguments(const TopoDS_Shape &theShape);
-
+
/*!
* \brief Limit shape tolerance to the given value
*
/*!
* \brief Fix curves of the given shape
- *
+ *
* The function checks each curve of the input shape in the following way:
* - compute deviation of the curve from the underlying surface in a set of points
* computed with the certain discretization step value
* - find maximum tolerance between computed deviation values
* - limit tolerance of the curve with the computed maximum value
- *
+ *
* \param shape shape being fixed
* \return \c true if resulting shape is valid
*/
*/
Standard_EXPORT bool Write( const TopoDS_Shape& shape,
const char* fileName );
-
+
/*!
* \brief Extract single SOLID from COMPSOLID or COMPOUND.
*