Example #1
0
/*! \brief Returns the oriented normal of a triangle
 *
 *  \warning The returned vector is not normalized
 *
 *  \param nodes  Vertices of the triangulation that \p triangle belongs to
 *  \param triangle  Triangle whose normal has to be computed
 *  \param ori  Orientation of the triangle (generally inherited from the
 *              triangulated face)
 */
gp_Vec MathUtils::triangleNormal(
        const TColgp_Array1OfPnt &nodes,
        const Poly_Triangle &triangle,
        TopAbs_Orientation ori)
{
    Standard_Integer n1, n2, n3;
    if (ori == TopAbs_REVERSED)
        triangle.Get(n1, n3, n2);
    else
        triangle.Get(n1, n2, n3);
    assert(nodes.Lower() <= n1 && n1 <= nodes.Upper());
    assert(nodes.Lower() <= n2 && n2 <= nodes.Upper());
    assert(nodes.Lower() <= n3 && n3 <= nodes.Upper());
    const gp_Vec v1(nodes(n1), nodes(n2)); // V1=(P1,P2)
    const gp_Vec v2(nodes(n2), nodes(n3)); // V2=(P2,P3)
    const gp_Vec v3(nodes(n3), nodes(n1)); // V3=(P3,P1)

    if ((v1.SquareMagnitude() > 1.e-10)
            && (v2.SquareMagnitude() > 1.e-10)
            && (v3.SquareMagnitude() > 1.e-10))
    {
        return v1.Crossed(v2);
    }
    return v1;
}
Example #2
0
Handle(Geom_BSplineSurface) ParameterCorrection::CreateSurface(const TColgp_Array1OfPnt& points, 
                                                                unsigned short usIter,
                                                                bool  bParaCor,
                                                                float fSizeFactor)
{
  if (_pvcPoints != NULL)
  {
    delete _pvcPoints;
    _pvcPoints = NULL;
    delete _pvcUVParam;
    _pvcUVParam = NULL;
  }
  _pvcPoints = new TColgp_Array1OfPnt(points.Lower(), points.Upper());
  *_pvcPoints = points;
  _pvcUVParam = new TColgp_Array1OfPnt2d(points.Lower(), points.Upper());

  if (_usUCtrlpoints*_usVCtrlpoints > _pvcPoints->Length())
    return NULL; //LGS unterbestimmt
  if(!DoInitialParameterCorrection(fSizeFactor))
    return NULL;

  if (bParaCor)
    DoParameterCorrection(usIter);

  return new Geom_BSplineSurface
                      (_vCtrlPntsOfSurf,
                       _vUKnots, 
                       _vVKnots,
                       _vUMults,
                       _vVMults,
                       _usUOrder-1,
                       _usVOrder-1);
}