#include "HYDRO_trace.hxx"
#include <BRepTools.hxx>
-//! The type is intended to traverse the container
-//! either from the begin to the end or vice versa.
+/*! The type is intended to traverse the container
+ * either from the begin to the end or vice versa.
+ */
template<typename ContainerType, typename IteratorType>
class Iterator
{
IteratorType& operator *() {return myIterator;}
};
-// Inserts the value after the position.
+/*! Inserts the value after the position.
+ *
+ */
template<typename ItemType> static void InsertAfter(
const typename std::list<ItemType>::iterator& thePosition,
const ItemType& theValue,
}
}
-// Converts the curve to a smooth cubic B-spline using the deflection.
+/*! Converts the curve to a smooth cubic B-spline using the deflection.
+ *
+ */
static Handle(Geom_BSplineCurve) BSpline(
const BRepAdaptor_Curve& theCurve, const double theDeflection)
{
return aConverter.HasResult() ? aConverter.Curve() : aBSpline;
}
-// Replaces the vertex of the edge considering the edge orientation.
+/*! Replaces the vertex of the edge considering the edge orientation.
+ *
+ */
static TopoDS_Edge ReplaceVertex(
const TopoDS_Edge& theEdge, const bool theIsEndVertex)
{
return aNewEdge;
}
-// Projects the point to the curve.
+/*! Projects the point to the curve.
+ *
+ */
double ProjectPointToCurve(
const gp_XYZ& thePoint,
const Adaptor3d_Curve& theCurve,
return ProjectPointToCurve(thePoint, BRepAdaptor_Curve(theEdge), theParameter);
}
-// Adds the parameter to the curve parameter list.
+/*! Adds the parameter to the curve parameter list.
+ *
+ */
static int AddParameter(
const Adaptor3d_Curve& theCurve,
const double theParameter,
return 1;
}
-// Intersects the first curve by the second one and
-// adds the intersection parameters to the ordered list.
-static int IntersectCurve(
- const Adaptor3d_Curve& theCurve1,
- const Adaptor3d_Curve& theCurve2,
- std::list<double>& theParameters)
-{
- // Process the ends.
- int aIntCount = 0;
- const gp_XYZ aEndPs[] = {
- theCurve2.Value(theCurve2.FirstParameter()).XYZ(),
- theCurve2.Value(theCurve2.LastParameter()).XYZ()};
- for (int aPI = 0; aPI < 2; ++aPI)
- {
- double aParameter;
- if (ProjectPointToCurve(aEndPs[aPI], theCurve1, aParameter) <=
- Precision::SquareConfusion())
- {
- DEBTRACE("aParameter " << aParameter);
- aIntCount += AddParameter(theCurve1, aParameter, theParameters);
- }
- }
-
- // Process the internal extremums.
- Extrema_ExtCC aAlgo(theCurve1, theCurve2); //, 1.e-6, 1.e-6);
- if (aAlgo.IsDone())
- {
- const int aECount = aAlgo.NbExt();
- for (int aEN = 1; aEN <= aECount; ++aEN)
- {
- Extrema_POnCurv aP1, aP2;
- aAlgo.Points(aEN, aP1, aP2);
- DEBTRACE("SquareDistance " << aP1.Value().SquareDistance(aP2.Value()));
- if (aP1.Value().SquareDistance(aP2.Value()) <=
- Precision::SquareConfusion())
- {
- DEBTRACE("aP1.Parameter() " << aP1.Parameter());
- aIntCount += AddParameter(theCurve1, aP1.Parameter(), theParameters);
- }
- }
- }
- return aIntCount;
-}
-
+/*! Intersects the first curve by the second one and
+ * adds the intersection parameters to the ordered list.
+ */
static int IntersectShape(
const TopoDS_Edge& theEdge1,
const TopoDS_Edge& theEdge2,
if (theEdge1.IsSame(theEdge2))
Standard_ConstructionError::Raise("The lines to make intersection must be different");
-// std::ostringstream oshp1, oshp2;
-// BRepTools::Write(theEdge1, oshp1);
-// BRepTools::Write(theEdge2, oshp2);
-// BRep_Builder aBuilder;
-// std::istringstream ishp1(oshp1.str());
-// std::istringstream ishp2(oshp2.str());
-// TopoDS_Shape aShape1, aShape2;
-// DEBTRACE("oshp1.str() " << oshp1.str());
-// DEBTRACE("oshp2.str() " << oshp2.str());
-// try
-// {
-// BRepTools::Read(aShape1, ishp1, aBuilder);
-// } catch (Standard_Failure)
-// {
-// DEBTRACE("Error Brep conversion");
-// return 0;
-// }
-// try
-// {
-// BRepTools::Read(aShape2, ishp2, aBuilder);
-// } catch (Standard_Failure)
-// {
-// DEBTRACE("Error Brep conversion");
-// return 0;
-// }
-
int nbSols = 0;
BRepAdaptor_Curve aCurve1 = BRepAdaptor_Curve(theEdge1);
- //BRepAdaptor_Curve aCurve2 = BRepAdaptor_Curve(theEdge2);
// --- Calculate Lines Intersections Points: two times, changing the order (sometimes intersections not detected)
- BRepExtrema_DistShapeShape dst(theEdge1, theEdge2); // first
+ BRepExtrema_DistShapeShape dst(theEdge1, theEdge2); // first order
if (dst.IsDone())
{
DEBTRACE("nb solutions found: " << dst.NbSolution());
}
}
- BRepExtrema_DistShapeShape dst2(theEdge2, theEdge1); // second
+ BRepExtrema_DistShapeShape dst2(theEdge2, theEdge1); // second order
if (dst2.IsDone())
{
DEBTRACE("nb solutions found: " << dst.NbSolution());
return nbSols;
}
-// Intersects the first edge by the second one and
-// adds the intersection parameters to the ordered list.
+/*! Intersects the first edge by the second one and
+ * adds the intersection parameters to the ordered list.
+ */
static int IntersectEdge(
const TopoDS_Edge& theEdge1,
const TopoDS_Edge& theEdge2,
std::list<double>& theParameters)
{
return IntersectShape(theEdge1, theEdge2, theParameters);
-// BRepAdaptor_Curve aCurve1 = BRepAdaptor_Curve(theEdge1);
-// BRepAdaptor_Curve aCurve2 = BRepAdaptor_Curve(theEdge2);
-// return IntersectCurve(aCurve1, aCurve2, theParameters);
}
-// Returns the curve tangent in the position: 0 - start, 1 - end.
+/*! Returns the curve tangent in the position: 0 - start, 1 - end.
+ *
+ */
static gp_XYZ Tangent(const Adaptor3d_Curve& theCurve, const int thePosition)
{
const Standard_Real aParam = (thePosition == 0) ?
return ((1 / aNorm) * aV).XYZ();
}
-// Returns the edge tangent in the position: 0 - start, 1 - end.
+/*! Returns the edge tangent in the position: 0 - start, 1 - end.
+ *
+ */
static gp_XYZ Tangent(const TopoDS_Edge& theEdge, const int thePosition)
{
BRepAdaptor_Curve aCurve(theEdge);