1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00
Files
occt/src/Contap/Contap_ArcFunction.gxx
bugmaster b311480ed5 0023024: Update headers of OCCT files
Added appropriate copyright and license information in source files
2012-03-21 19:43:04 +04:00

223 lines
6.4 KiB
Plaintext
Executable File

// Created on: 1993-06-03
// Created by: Jacques GOUSSARD
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
Contap_ArcFunction::Contap_ArcFunction ():
myMean(1.),
myType(Contap_ContourStd),
myDir(0.,0.,1.)
{}
void Contap_ArcFunction::Set(const TheSurface& S)
{
mySurf = S;
Standard_Integer i;
Standard_Integer nbs = TheContTool::NbSamplePoints(S);
Standard_Real U,V;
// gp_Vec d1u,d1v;
gp_Vec norm;
if (nbs > 0) {
myMean = 0.;
for (i = 1; i <= nbs; i++) {
TheContTool::SamplePoint(S,i,U,V);
// TheSurfaceTool::D1(S,U,V,solpt,d1u,d1v);
// myMean = myMean + d1u.Crossed(d1v).Magnitude();
TheSurfProps::Normale(S,U,V,solpt,norm);
myMean = myMean + norm.Magnitude();
}
myMean = myMean / ((Standard_Real)nbs);
}
}
Standard_Boolean Contap_ArcFunction::Value (const Standard_Real U,
Standard_Real& F)
{
//gp_Vec d1u,d1v;
gp_Pnt2d pt2d(TheArcTool::Value(myArc,U));
// TheSurfaceTool::D1(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v);
// gp_Vec norm(d1u.Crossed(d1v));
gp_Vec norm;
TheSurfProps::Normale(mySurf,pt2d.X(),pt2d.Y(),solpt,norm);
switch (myType) {
case Contap_ContourStd:
{
F = (norm.Dot(myDir))/myMean;
}
break;
case Contap_ContourPrs:
{
F = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
}
break;
case Contap_DraftStd:
{
F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
}
break;
case Contap_DraftPrs:
default:
{
}
}
return Standard_True;
}
Standard_Boolean Contap_ArcFunction::Derivative (const Standard_Real U,
Standard_Real& D)
{
gp_Pnt2d pt2d;
gp_Vec2d d2d;
Standard_Real dfu =0.,dfv =0.;
// gp_Vec d1u,d1v,d2u,d2v,d2uv;
TheArcTool::D1(myArc,U,pt2d,d2d);
// TheSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
gp_Vec norm,dnu,dnv;
TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
switch (myType) {
case Contap_ContourStd:
{
// dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
// dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
dfu = (dnu.Dot(myDir))/myMean;
dfv = (dnv.Dot(myDir))/myMean;
}
break;
case Contap_ContourPrs:
{
gp_Vec Ep(myEye,solpt);
// dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
// dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
dfu = (dnu.Dot(Ep))/myMean;
dfv = (dnv.Dot(Ep))/myMean;
}
break;
case Contap_DraftStd:
{
/*
gp_Vec norm(d1u.Crossed(d1v).Normalized());
gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
*/
norm.Normalized();
dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
}
break;
case Contap_DraftPrs:
default:
{
}
}
D = d2d.X()*dfu + d2d.Y()*dfv;
return Standard_True;
}
Standard_Boolean Contap_ArcFunction::Values (const Standard_Real U,
Standard_Real& F,
Standard_Real& D)
{
gp_Pnt2d pt2d;
gp_Vec2d d2d;
Standard_Real dfu =0.,dfv =0.;
// gp_Vec d1u,d1v,d2u,d2v,d2uv;
TheArcTool::D1(myArc,U,pt2d,d2d);
// TheSurfaceTool::D2(mySurf,pt2d.X(),pt2d.Y(),solpt,d1u,d1v,d2u,d2v,d2uv);
// gp_Vec norm(d1u.Crossed(d1v));
gp_Vec norm,dnu,dnv;
TheSurfProps::NormAndDn(mySurf,pt2d.X(),pt2d.Y(),solpt,norm,dnu,dnv);
switch (myType) {
case Contap_ContourStd:
{
F = (norm.Dot(myDir))/myMean;
// dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
// dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
dfu = (dnu.Dot(myDir))/myMean;
dfv = (dnv.Dot(myDir))/myMean;
}
break;
case Contap_ContourPrs:
{
gp_Vec Ep(myEye,solpt);
F = (norm.Dot(Ep))/myMean;
// dfu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
// dfv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
dfu = (dnu.Dot(Ep))/myMean;
dfv = (dnv.Dot(Ep))/myMean;
}
break;
case Contap_DraftStd:
{
F = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
norm.Normalize();
/*
gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
dfu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
dfv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
*/
dfu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
dfv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
}
break;
case Contap_DraftPrs:
default:
{
}
}
D = d2d.X()*dfu + d2d.Y()*dfv;
return Standard_True;
}
Standard_Integer Contap_ArcFunction::GetStateNumber ()
{
seqpt.Append(solpt);
return seqpt.Length();
}
Standard_Integer Contap_ArcFunction::NbSamples () const
{
return Max(Max(TheContTool::NbSamplesU(mySurf,0.,0.),
TheContTool::NbSamplesV(mySurf,0.,0.)),
TheContTool::NbSamplesOnArc(myArc));
}
//modified by NIZNHY-PKV Thu Mar 29 16:53:07 2001f
//=======================================================================
//function : Quadric
//purpose : returns empty Quadric
//=======================================================================
const IntSurf_Quadric& Contap_ArcFunction::Quadric() const
{
return(myQuad);
}
//modified by NIZNHY-PKV Thu Mar 29 16:53:09 2001t