1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

85
src/Contap/Contap.cdl Executable file
View File

@@ -0,0 +1,85 @@
-- File: Contap.cdl
-- Created: Fri Feb 5 11:50:39 1993
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1993
package Contap
---Purpose:
uses Standard,StdFail,MMgt, GeomAbs, TopAbs, TCollection, gp, TColgp,
math, IntSurf, IntStart, IntWalk,
Geom2d, TColStd, Geom, Adaptor3d, Adaptor2d
is
deferred generic class ArcTool; -- template class
deferred generic class SurfaceTool; -- template class
deferred generic class TopolTool; -- template class
generic class Point;
generic class Line;
generic class SurfFunction;
generic class ArcFunction;
generic class SurfProps;
generic class ContourGen, ThePoint,TheSequenceOfPoint,TheHSequenceOfPoint,
TheLine, TheSequenceOfLine,
TheSurfProps, TheSurfFunction, TheArcFunction,
TheSearch, TheIWalking, TheSearchInside;
---TheLineConstructor;
class ContAna;
enumeration TFunction is
ContourStd,
ContourPrs,
DraftStd,
DraftPrs
end TFunction;
enumeration IType is -- a replacer dans IntSurf et fusionner avec IntPatch
-- type of the line of contour
Lin, -- pour conflit avec deferred class Line
Circle,
Walking,
Restriction
end IType;
generic class HContToolGen;
generic class HCurve2dToolGen;
class HCurve2dTool instantiates
HCurve2dToolGen from Contap (
HCurve2d from Adaptor2d);
class HContTool instantiates
HContToolGen from Contap (
HVertex from Adaptor3d,
HCurve2d from Adaptor2d,
HSurface from Adaptor3d,
HCurve2dTool from Contap,
HSurfaceTool from Adaptor3d);
class Contour instantiates ContourGen from Contap
(HVertex from Adaptor3d,
HCurve2d from Adaptor2d,
HSurface from Adaptor3d,
HCurve2dTool from Contap,
HSurfaceTool from Adaptor3d,
HContTool from Contap,
TopolTool from Adaptor3d);
end Contap;

129
src/Contap/Contap_ArcFunction.cdl Executable file
View File

@@ -0,0 +1,129 @@
-- File: Contap_ArcFunction.cdl
-- Created: Thu Jun 3 12:32:05 1993
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1993
generic class ArcFunction from Contap
(TheArc as any;
TheSurface as any;
TheArcTool as any; -- as ArcTool from Contap()
TheSurfaceTool as any; -- as SurfaceTool from Contap()
TheSurfProps as any; -- as SurfProps from Contap(TheSurface,
-- TheSurfaceTool)
TheContTool as any) -- as ContTool from Contap()
inherits FunctionWithDerivative from math
uses Pnt from gp,
Dir from gp,
SequenceOfPnt from TColgp,
TFunction from Contap,
--modified by NIZNHY-PKV Thu Mar 29 16:52:28 2001 f
Quadric from IntSurf
--modified by NIZNHY-PKV Thu Mar 29 16:52:31 2001 t
is
Create
returns ArcFunction from Contap;
Set(me: in out; S: TheSurface)
is static;
Set(me: in out; Direction: Dir from gp)
---C++: inline
is static;
Set(me: in out; Direction: Dir from gp; Angle: Real from Standard)
---C++: inline
is static;
Set(me: in out; Eye: Pnt from gp)
---C++: inline
is static;
Set(me: in out; Eye: Pnt from gp; Angle: Real from Standard)
---C++: inline
is static;
Set(me: in out; A: TheArc)
---C++: inline
is static;
Value(me: in out; X: Real from Standard; F: out Real from Standard)
returns Boolean from Standard;
Derivative(me: in out; X: Real from Standard; D: out Real from Standard)
returns Boolean from Standard;
Values(me: in out; X: Real from Standard; F,D: out Real from Standard)
returns Boolean from Standard;
NbSamples(me)
returns Integer from Standard
is static;
GetStateNumber(me: in out)
returns Integer from Standard
is redefined;
Valpoint(me; Index: Integer from Standard)
returns Pnt from gp
---C++: return const&
---C++: inline
is static;
--modified by NIZNHY-PKV Thu Mar 29 16:51:24 2001 f
Quadric(me)
returns Quadric from IntSurf
---C++: return const&
is static;
--modified by NIZNHY-PKV Thu Mar 29 16:51:31 2001 t
fields
myArc : TheArc;
mySurf : TheSurface;
myMean : Real from Standard;
myType : TFunction from Contap;
myDir : Dir from gp;
myCosAng : Real from Standard;
myEye : Pnt from gp;
solpt : Pnt from gp;
seqpt : SequenceOfPnt from TColgp;
--modified by NIZNHY-PKV Thu Mar 29 16:51:41 2001f
myQuad : Quadric from IntSurf;
--modified by NIZNHY-PKV Thu Mar 29 16:51:47 2001t
end ArcFunction;

211
src/Contap/Contap_ArcFunction.gxx Executable file
View File

@@ -0,0 +1,211 @@
#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;
#ifndef DEB
Standard_Real dfu =0.,dfv =0.;
#else
Standard_Real dfu,dfv;
#endif
// 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;
#ifndef DEB
Standard_Real dfu =0.,dfv =0.;
#else
Standard_Real dfu,dfv;
#endif
// 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

View File

@@ -0,0 +1,40 @@
inline void Contap_ArcFunction::Set(const gp_Dir& Direction,
const Standard_Real Angle)
{
myType = Contap_DraftStd;
myDir = Direction;
myCosAng = Cos(PI/2.+Angle);
}
inline void Contap_ArcFunction::Set(const gp_Pnt& Eye,
const Standard_Real Angle)
{
myType = Contap_DraftPrs;
myEye = Eye;
myCosAng = Cos(PI/2.+Angle);
}
inline void Contap_ArcFunction::Set(const gp_Dir& Direction)
{
myType = Contap_ContourStd;
myDir = Direction;
}
inline void Contap_ArcFunction::Set(const gp_Pnt& Eye)
{
myType = Contap_ContourPrs;
myEye = Eye;
}
inline void Contap_ArcFunction::Set(const TheArc& A)
{
myArc = A;
seqpt.Clear();
}
inline const gp_Pnt& Contap_ArcFunction::Valpoint
(const Standard_Integer Index) const
{
return seqpt(Index);
}

52
src/Contap/Contap_ArcTool.cdl Executable file
View File

@@ -0,0 +1,52 @@
-- File: Contap_ArcTool.cdl
-- Created: Wed May 12 09:09:34 1993
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1993
deferred generic class ArcTool from Contap
(TheArc as any )
---Purpose: Template class for a tool on the restriction of
-- a surface.
-- It is possible to implement this class with an instantiation
-- of the class CurveTool from Adaptor3d.
uses Pnt2d from gp,
Vec2d from gp
is
Value(myclass; A: TheArc; X: Real from Standard)
---Purpose: Returns the value in the parametric space
-- of the surface S, of the point of parameter X
-- on the arc A.
returns Pnt2d from gp;
D1(myclass; A: TheArc; X: Real from Standard;
P : out Pnt2d from gp;
D2D : out Vec2d from gp);
---Purpose: Returns the value and the first derivatives in
-- the parametric space of the surface S of the point
-- at parameter X on the arc A.
Resolution(myclass; A: TheArc; Tol3d: Real from Standard)
---Purpose : Returns the parametric resolution corresponding
-- to the space resolution Tol3d.
returns Real from Standard;
end ArcTool;

0
src/Contap/Contap_ArcTool.gxx Executable file
View File

159
src/Contap/Contap_ContAna.cdl Executable file
View File

@@ -0,0 +1,159 @@
-- File: Contap_ContAna.cdl
-- Created: Thu Mar 4 10:51:23 1993
-- Author: Jacques GOUSSARD
-- <jag@form4>
---Copyright: Matra Datavision 1993
class ContAna from Contap
---Purpose: This class provides the computation of the contours
-- for quadric surfaces.
uses Sphere from gp,
Cylinder from gp,
Cone from gp,
Lin from gp,
Circ from gp,
Pnt from gp,
Dir from gp,
CurveType from GeomAbs
raises NotDone from StdFail,
DomainError from Standard,
OutOfRange from Standard
is
Create
returns ContAna from Contap;
Perform(me: in out; S: Sphere from gp; D: Dir from gp)
is static;
Perform(me: in out; S: Sphere from gp; D : Dir from gp;
Ang: Real from Standard)
is static;
Perform(me: in out; S: Sphere from gp; Eye: Pnt from gp)
is static;
Perform(me: in out; C: Cylinder from gp; D: Dir from gp)
is static;
Perform(me: in out; C: Cylinder from gp; D : Dir from gp;
Ang: Real from Standard)
is static;
Perform(me: in out; C: Cylinder from gp; Eye: Pnt from gp)
---Purpose:
is static;
Perform(me: in out; C: Cone from gp; D: Dir from gp)
is static;
Perform(me: in out; C: Cone from gp; D : Dir from gp;
Ang: Real from Standard)
is static;
Perform(me: in out; C: Cone from gp; Eye: Pnt from gp)
---Purpose:
is static;
IsDone(me)
returns Boolean from Standard
---C++: inline
is static;
NbContours(me)
returns Integer from Standard
---C++: inline
raises NotDone from StdFail
is static;
TypeContour(me)
---Purpose: Returns GeomAbs_Line or GeomAbs_Circle, when
-- IsDone() returns True.
returns CurveType from GeomAbs
---C++: inline
raises NotDone from StdFail,
DomainError from Standard
is static;
Circle(me)
returns Circ from gp
---C++: inline
raises NotDone from StdFail,
DomainError from Standard
is static;
Line(me; Index: Integer from Standard)
returns Lin from gp
raises NotDone from StdFail,
DomainError from Standard,
OutOfRange from Standard
is static;
fields
done : Boolean from Standard;
nbSol : Integer from Standard;
typL : CurveType from GeomAbs;
pt1 : Pnt from gp;
pt2 : Pnt from gp;
pt3 : Pnt from gp;
pt4 : Pnt from gp;
dir1 : Dir from gp;
dir2 : Dir from gp;
dir3 : Dir from gp;
dir4 : Dir from gp;
prm : Real from Standard;
end ContAna;

449
src/Contap/Contap_ContAna.cxx Executable file
View File

@@ -0,0 +1,449 @@
#include <Contap_ContAna.ixx>
#include <gp_XYZ.hxx>
#include <gp.hxx>
#define Tolpetit 1.e-8
Contap_ContAna::Contap_ContAna (): done(Standard_False) {}
void Contap_ContAna::Perform (const gp_Sphere& S,
const gp_Dir& D)
{
done = Standard_False;
typL = GeomAbs_Circle;
pt1 = S.Location();
dir1 = D;
if (Abs(D.Dot(S.XAxis().Direction())) < 0.9999999999999) {
dir2 = D.Crossed(S.XAxis().Direction());
}
else {
dir2 = D.Crossed(S.YAxis().Direction());
}
prm = S.Radius();
nbSol = 1;
done = Standard_True;
}
void Contap_ContAna::Perform (const gp_Sphere& S,
const gp_Dir& D,
const Standard_Real Angle)
{
done = Standard_False;
typL = GeomAbs_Circle;
dir1 = D;
if (Abs(D.Dot(S.XAxis().Direction())) < 0.9999999999999) {
dir2 = D.Crossed(S.XAxis().Direction());
}
else {
dir2 = D.Crossed(S.YAxis().Direction());
}
Standard_Real alpha = (S.Direct() ? Angle : -Angle);
pt1.SetXYZ(S.Location().XYZ() - S.Radius()*sin(alpha)*D.XYZ()) ;
prm = S.Radius()*cos(alpha);
nbSol = 1;
done = Standard_True;
}
void Contap_ContAna::Perform (const gp_Sphere& S,
const gp_Pnt& Eye)
{
done = Standard_False;
Standard_Real radius = S.Radius();
Standard_Real dist = Eye.Distance(S.Location());
if (dist <= radius) {
nbSol = 0;
}
else {
prm = radius*sqrt(1.-radius*radius/(dist*dist));
if (prm < Tolpetit) {
nbSol = 0;
}
else {
gp_XYZ locxyz(S.Location().XYZ());
dir1.SetXYZ(Eye.XYZ()-locxyz);
pt1.SetXYZ(locxyz + (radius*radius/dist)*dir1.XYZ());
if (Abs(dir1.Dot(S.XAxis().Direction())) < 0.9999999999999) {
dir2 = dir1.Crossed(S.XAxis().Direction());
}
else {
dir2 = dir1.Crossed(S.YAxis().Direction());
}
nbSol = 1;
typL = GeomAbs_Circle;
}
}
done = Standard_True;
}
void Contap_ContAna::Perform (const gp_Cylinder& C,
const gp_Dir& D)
{
done = Standard_False;
gp_XYZ normale(C.Position().Direction().XYZ());
normale.Cross(D.XYZ());
if (normale.Modulus() <= 1e-15) {
nbSol = 0;
}
else {
normale.Normalize();
typL = GeomAbs_Line;
dir1 = C.Position().Direction();
dir2 = dir1;
pt1.SetXYZ(C.Location().XYZ() + C.Radius()*normale);
pt2.SetXYZ(C.Location().XYZ() - C.Radius()*normale);
nbSol = 2;
}
done = Standard_True;
}
void Contap_ContAna::Perform (const gp_Cylinder& C,
const gp_Dir& D,
const Standard_Real Angle)
{
done = Standard_False;
Standard_Real Coefcos = D.Dot(C.Position().XDirection());
Standard_Real Coefsin = D.Dot(C.Position().YDirection());
Standard_Real Coefcst = cos(PI*0.5 + Angle);
Standard_Real norm1 = Coefcos*Coefcos + Coefsin*Coefsin;
Standard_Real norm2 = sqrt(norm1);
if (Abs(Coefcst) < norm2) {
typL = GeomAbs_Line;
nbSol = 2;
dir1 = dir2 = C.Position().Direction();
if (!C.Direct()) { // la normale est inversee.
Coefcos = -Coefcos;
Coefsin = -Coefsin;
}
// On doit resoudre Coefcos*cos(t) + Coefsin*sin(t) = Coefcst
// et les origines des droites solution sont dans le repere du
// cylindre en (R*cost0, R*sint0,0) et (R*cost1,R*sint1,0)
// En posant cos(phi) = Coefcos/Sqrt(Coefcos**2 + Coefsin**2) et
// sin(phi) = Coefsin/Sqrt(Coefcos**2 + Coefsin**2)
// et en utilisant les relations trigonometriques, on a sans resolution
// les valeurs des cosinus et sinus aux solutions.
prm = Sqrt(norm1 - Coefcst*Coefcst);
Standard_Real cost0,sint0,cost1,sint1;
cost0 = (Coefcos*Coefcst - Coefsin*prm)/norm1;
cost1 = (Coefcos*Coefcst + Coefsin*prm)/norm1;
sint0 = ( Coefcos*prm + Coefsin*Coefcst)/norm1;
sint1 = (-Coefcos*prm + Coefsin*Coefcst)/norm1;
gp_XYZ Xdir(C.Position().XDirection().XYZ());
gp_XYZ Ydir(C.Position().YDirection().XYZ());
gp_XYZ dirxyz;
dirxyz.SetLinearForm(cost0,Xdir,sint0,Ydir);
dirxyz.Multiply(C.Radius());
pt1.SetXYZ(C.Location().XYZ().Added(dirxyz));
dirxyz.SetLinearForm(cost1,Xdir,sint1,Ydir);
dirxyz.Multiply(C.Radius());
pt2.SetXYZ(C.Location().XYZ().Added(dirxyz));
}
else {
nbSol = 0;
}
done = Standard_True;
}
void Contap_ContAna::Perform (const gp_Cylinder& C,
const gp_Pnt& Eye)
{
done = Standard_False;
Standard_Real radius = C.Radius();
gp_Lin theaxis(C.Axis());
Standard_Real dist = theaxis.Distance(Eye);
if (dist <= radius) {
nbSol = 0;
}
else {
typL = GeomAbs_Line;
prm = radius*sqrt(1.-radius*radius/(dist*dist));
dir1 = C.Axis().Direction();
dir2 = dir1;
gp_XYZ axeye(theaxis.Normal(Eye).Direction().XYZ()); // oriente de l axe
// vers l exterieur
gp_XYZ normale((theaxis.Direction().Crossed(axeye)).XYZ());
// normale.Normalize();
pt1.SetXYZ(C.Location().XYZ() + (radius*radius/dist)*axeye);
pt2.SetXYZ(pt1.XYZ() - prm*normale);
pt1.SetXYZ(pt1.XYZ() + prm*normale);
nbSol = 2;
}
done = Standard_True;
}
void Contap_ContAna::Perform (const gp_Cone& C,
const gp_Dir& D)
{
done = Standard_False;
Standard_Real Tgtalpha = Tan(C.SemiAngle());
Standard_Real Coefcos = D.Dot(C.Position().XDirection());
Standard_Real Coefsin = D.Dot(C.Position().YDirection());
Standard_Real Coefcst = D.Dot(C.Axis().Direction())*Tgtalpha;
Standard_Real norm1 = Coefcos*Coefcos + Coefsin*Coefsin;
Standard_Real norm2 = Sqrt(norm1);
// if (Abs(Abs(Coefcst)-norm2) <= Tolpetit) { // tol angulaire 1.e-8
// typL = GeomAbs_Line;
// nbSol = 1;
// pt1 = C.Apex();
// dir1 = D;
// }
// else if (Abs(Coefcst) < norm2) {
if (Abs(Coefcst) < norm2) {
typL = GeomAbs_Line;
nbSol = 2;
pt1 = C.Apex();
pt2 = pt1;
// On doit resoudre Coefcos*cos(t) + Coefsin*sin(t) = Coefcst
// et les vecteurs directeurs des solutions sont
// cos(t0) * XDirection + sin(t0) * YDirection + ZDirection/Tgtalpha
// En posant cos(phi) = Coefcos/Sqrt(Coefcos**2 + Coefsin**2) et
// sin(phi) = Coefsin/Sqrt(Coefcos**2 + Coefsin**2)
// et en utilisant les relations trigonometriques, on a sans resolution
// les valeurs des cosinus et sinus aux solutions.
prm = Sqrt(norm1 - Coefcst*Coefcst);
Standard_Real cost0,sint0,cost1,sint1;
cost0 = (Coefcos*Coefcst - Coefsin*prm)/norm1;
cost1 = (Coefcos*Coefcst + Coefsin*prm)/norm1;
sint0 = ( Coefcos*prm + Coefsin*Coefcst)/norm1;
sint1 = (-Coefcos*prm + Coefsin*Coefcst)/norm1;
gp_XYZ Xdir(C.Position().XDirection().XYZ());
gp_XYZ Ydir(C.Position().YDirection().XYZ());
gp_XYZ Zdir(C.Axis().Direction().XYZ());
gp_XYZ dirxyz;
dirxyz.SetLinearForm(cost0,Xdir,sint0,Ydir,1./Tgtalpha,Zdir);
dir1.SetXYZ(dirxyz);
pt1.SetXYZ(pt1.XYZ()+dirxyz);
dirxyz.SetLinearForm(cost1,Xdir,sint1,Ydir,1./Tgtalpha,Zdir);
dir2.SetXYZ(dirxyz);
pt2.SetXYZ(pt2.XYZ()+dirxyz);
}
else {
nbSol = 0;
}
done = Standard_True;
}
void Contap_ContAna::Perform (const gp_Cone& C,
const gp_Dir& D,
const Standard_Real Angle)
{
done = Standard_False;
nbSol = 0;
Standard_Real Ang = C.SemiAngle();
Standard_Real Cosa = cos(Ang);
Standard_Real Sina = sin(Ang);
Standard_Real Coefcos = D.Dot(C.Position().XDirection());
Standard_Real Coefsin = D.Dot(C.Position().YDirection());
Standard_Real Coefcst1 = cos(PI*0.5 + Angle);
Standard_Real norm1 = Coefcos*Coefcos + Coefsin*Coefsin;
Standard_Real norm2 = Sqrt(norm1);
Standard_Real Coefnz = D.Dot(C.Axis().Direction())*Sina;
Standard_Real Coefcst = (Coefcst1 + Coefnz)/Cosa;
if (Abs(Coefcst) < norm2) {
typL = GeomAbs_Line;
nbSol+= 2;
pt1 = C.Apex();
pt2 = pt1;
// On doit resoudre Coefcos*cos(t) + Coefsin*sin(t) = Coefcst
// et les vecteurs directeurs des solutions sont
// cos(t0) * XDirection + sin(t0) * YDirection + ZDirection/Tgtalpha
// En posant cos(phi) = Coefcos/Sqrt(Coefcos**2 + Coefsin**2) et
// sin(phi) = Coefsin/Sqrt(Coefcos**2 + Coefsin**2)
// et en utilisant les relations trigonometriques, on a sans resolution
// les valeurs des cosinus et sinus aux solutions.
prm = Sqrt(norm1 - Coefcst*Coefcst);
Standard_Real cost0,sint0,cost1,sint1;
cost0 = (Coefcos*Coefcst - Coefsin*prm)/norm1;
cost1 = (Coefcos*Coefcst + Coefsin*prm)/norm1;
sint0 = ( Coefcos*prm + Coefsin*Coefcst)/norm1;
sint1 = (-Coefcos*prm + Coefsin*Coefcst)/norm1;
gp_XYZ Xdir(C.Position().XDirection().XYZ());
gp_XYZ Ydir(C.Position().YDirection().XYZ());
gp_XYZ Zdir(C.Axis().Direction().XYZ());
if (!C.Direct()) {
Zdir.Reverse();
}
gp_XYZ dirxyz;
dirxyz.SetLinearForm(cost0,Xdir,sint0,Ydir,Cosa/Sina,Zdir);
dir1.SetXYZ(dirxyz);
pt1.SetXYZ(pt1.XYZ()+dirxyz);
dirxyz.SetLinearForm(cost1,Xdir,sint1,Ydir,Cosa/Sina,Zdir);
dir2.SetXYZ(dirxyz);
pt2.SetXYZ(pt2.XYZ()+dirxyz);
}
Coefcst = (Coefcst1 - Coefnz)/Cosa;
if (Abs(Coefcst) < norm2) {
typL = GeomAbs_Line;
nbSol+= 2;
pt3 = C.Apex();
pt4 = pt3;
prm = Sqrt(norm1 - Coefcst*Coefcst);
Standard_Real cost0,sint0,cost1,sint1;
cost0 = (Coefcos*Coefcst - Coefsin*prm)/norm1;
cost1 = (Coefcos*Coefcst + Coefsin*prm)/norm1;
sint0 = ( Coefcos*prm + Coefsin*Coefcst)/norm1;
sint1 = (-Coefcos*prm + Coefsin*Coefcst)/norm1;
gp_XYZ Xdir(C.Position().XDirection().XYZ());
gp_XYZ Ydir(C.Position().YDirection().XYZ());
gp_XYZ Zdir(C.Axis().Direction().XYZ());
if (!C.Direct()) {
Zdir.Reverse();
}
gp_XYZ dirxyz;
dirxyz.SetLinearForm(cost0,Xdir,sint0,Ydir,-Cosa/Sina,Zdir);
dir3.SetXYZ(dirxyz);
pt3.SetXYZ(pt3.XYZ()+dirxyz);
dirxyz.SetLinearForm(cost1,Xdir,sint1,Ydir,-Cosa/Sina,Zdir);
dir4.SetXYZ(dirxyz);
pt4.SetXYZ(pt4.XYZ()+dirxyz);
if (nbSol == 2) {
pt1 = pt3;
pt2 = pt4;
dir1 = dir3;
dir2 = dir4;
}
}
done = Standard_True;
}
void Contap_ContAna::Perform (const gp_Cone& C,
const gp_Pnt& Eye)
{
done = Standard_False;
Standard_Real Tgtalpha = Tan(C.SemiAngle());
gp_XYZ apexeye(Eye.XYZ());
apexeye.Subtract(C.Apex().XYZ());
Standard_Real Coefcos = apexeye.Dot(C.Position().XDirection().XYZ());
Standard_Real Coefsin = apexeye.Dot(C.Position().YDirection().XYZ());
Standard_Real Coefcst = apexeye.Dot(C.Axis().Direction().XYZ())*Tgtalpha;
Standard_Real norm1 = Coefcos*Coefcos + Coefsin*Coefsin;
Standard_Real norm2 = Sqrt(Coefcos*Coefcos + Coefsin*Coefsin);
// if (Abs(Abs(Coefcst)-norm2) <= Tolpetit) { // tol angulaire 1.e-8
// typL = GeomAbs_Line;
// nbSol = 1;
// pt1 = C.Apex();
// dir1.SetXYZ(apexeye);
// }
// else if (Abs(Coefcst) < norm2) {
if (Abs(Coefcst) < norm2) {
typL = GeomAbs_Line;
nbSol = 2;
pt1 = C.Apex();
pt2 = pt1;
// On doit resoudre Coefcos*cos(t) + Coefsin*sin(t) = Coefcst
// et les vecteurs directeurs des solutions sont
// cos(t0) * XDirection + sin(t0) * YDirection + ZDirection/Tgtalpha
// En posant cos(phi) = Coefcos/Sqrt(Coefcos**2 + Coefsin**2) et
// sin(phi) = Coefsin/Sqrt(Coefcos**2 + Coefsin**2)
// et en utilisant les relations trigonometriques, on a sans resolution
// les valeurs des cosinus et sinus aux solutions.
prm = Sqrt(norm1 - Coefcst*Coefcst);
Standard_Real cost0,sint0,cost1,sint1;
cost0 = (Coefcos*Coefcst - Coefsin*prm)/norm1;
cost1 = (Coefcos*Coefcst + Coefsin*prm)/norm1;
sint0 = ( Coefcos*prm + Coefsin*Coefcst)/norm1;
sint1 = (-Coefcos*prm + Coefsin*Coefcst)/norm1;
gp_XYZ Xdir(C.Position().XDirection().XYZ());
gp_XYZ Ydir(C.Position().YDirection().XYZ());
gp_XYZ Zdir(C.Axis().Direction().XYZ());
gp_XYZ dirxyz;
dirxyz.SetLinearForm(cost0,Xdir,sint0,Ydir,1./Tgtalpha,Zdir);
dir1.SetXYZ(dirxyz);
pt1.SetXYZ(pt1.XYZ()+dirxyz);
dirxyz.SetLinearForm(cost1,Xdir,sint1,Ydir,1./Tgtalpha,Zdir);
dir2.SetXYZ(dirxyz);
pt2.SetXYZ(pt2.XYZ()+dirxyz);
}
else {
nbSol = 0;
}
done = Standard_True;
}
gp_Lin Contap_ContAna::Line (const Standard_Integer Index) const
{
if (!done) {StdFail_NotDone::Raise();}
if (typL != GeomAbs_Line || nbSol == 0) {Standard_DomainError::Raise();}
if (Index <=0 || Index > nbSol) {Standard_OutOfRange::Raise();}
switch (Index) {
case 1:
return gp_Lin(pt1,dir1);
case 2:
return gp_Lin(pt2,dir2);
case 3:
return gp_Lin(pt3,dir3);
case 4:
return gp_Lin(pt4,dir4);
}
Standard_OutOfRange::Raise("Erreur de programmation dans Contap_ContAna");
return gp_Lin();
}

32
src/Contap/Contap_ContAna.lxx Executable file
View File

@@ -0,0 +1,32 @@
#include <StdFail_NotDone.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_OutOfRange.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
inline Standard_Boolean Contap_ContAna::IsDone () const
{
return done;
}
inline Standard_Integer Contap_ContAna::NbContours () const
{
if (!done) {StdFail_NotDone::Raise();}
return nbSol;
}
inline GeomAbs_CurveType Contap_ContAna::TypeContour () const
{
if (!done) {StdFail_NotDone::Raise();}
if (nbSol == 0) {Standard_DomainError::Raise();}
return typL;
}
inline gp_Circ Contap_ContAna::Circle () const
{
if (!done) {StdFail_NotDone::Raise();}
if (typL != GeomAbs_Circle || nbSol == 0) {Standard_DomainError::Raise();}
return gp_Circ(gp_Ax2(pt1,dir1,dir2),prm);
}

271
src/Contap/Contap_ContourGen.cdl Executable file
View File

@@ -0,0 +1,271 @@
-- File: Contap_ContourGen.cdl
-- Created: Fri Feb 5 09:39:18 1993
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1993
generic class ContourGen from Contap
(TheVertex as any;
TheArc as any;
TheSurface as any;
TheArcTool as any; -- as ArcTool from Contap(TheArc)
TheSurfaceTool as any; -- as SurfaceTool from Contap(TheSurface)
TheContTool as any; -- as ContTool from Contap(TheVertex,TheArc,
-- TheSurface)
TheTopolTool as Transient)-- as TopolTool from IntStart(TheVertex,
-- TheArc)
---Purpose:
uses PathPoint from IntSurf,
PathPointTool from IntSurf,
SequenceOfPathPoint from IntSurf,
InteriorPoint from IntSurf,
InteriorPointTool from IntSurf,
SequenceOfInteriorPoint from IntSurf,
Pnt from gp,
Vec from gp
raises NotDone from StdFail,
OutOfRange from Standard,
ConstructionError from Standard
class ThePoint instantiates Point from Contap
(TheVertex,
TheArc);
class TheSequenceOfPoint instantiates Sequence from TCollection
(ThePoint);
class TheHSequenceOfPoint instantiates HSequence from TCollection
(ThePoint,TheSequenceOfPoint);
class TheLine instantiates Line from Contap
(TheVertex,
TheArc,
ThePoint,
TheHSequenceOfPoint);
class TheSequenceOfLine instantiates Sequence from TCollection
(TheLine);
class TheSurfProps instantiates SurfProps from Contap
(TheSurface,
TheSurfaceTool);
class TheSurfFunction instantiates SurfFunction from Contap
(TheSurface,
TheSurfaceTool,
TheSurfProps from Contap,
TheContTool);
class TheArcFunction instantiates ArcFunction from Contap
(TheArc,
TheSurface,
TheArcTool,
TheSurfaceTool,
TheSurfProps from Contap,
TheContTool);
class TheSearch instantiates SearchOnBoundaries from IntStart
(TheVertex,
TheArc,
TheArcTool,
TheContTool,
TheTopolTool,
TheArcFunction from Contap);
class TheIWalking instantiates IWalking from IntWalk
(PathPoint from IntSurf,
PathPointTool from IntSurf,
SequenceOfPathPoint from IntSurf,
InteriorPoint from IntSurf,
InteriorPointTool from IntSurf,
SequenceOfInteriorPoint from IntSurf,
TheSurface,
TheSurfaceTool,
TheSurfFunction from Contap);
class TheSearchInside instantiates SearchInside from IntStart
(TheSurface,
TheSurfaceTool,
TheTopolTool,
TheContTool,
TheSurfFunction from Contap);
is
Create
returns ContourGen from Contap;
Create(Direction: Vec from gp)
returns ContourGen from Contap;
Create(Direction: Vec from gp; Angle: Real from Standard)
returns ContourGen from Contap;
Create(Eye: Pnt from gp)
returns ContourGen from Contap;
Create(Surf: TheSurface; Domain: TheTopolTool;
Direction: Vec from gp)
---Purpose: Creates the contour in a given direction.
returns ContourGen from Contap;
Create(Surf: TheSurface; Domain: TheTopolTool;
Direction: Vec from gp; Angle: Real from Standard)
---Purpose: Creates the contour in a given direction.
returns ContourGen from Contap;
Create(Surf: TheSurface; Domain: TheTopolTool;
Eye: Pnt from gp)
---Purpose: Creates the contour for a perspective view.
returns ContourGen from Contap;
Perform(me: in out; Surf: TheSurface; Domain: TheTopolTool)
---Purpose: Creates the contour in a given direction.
raises ConstructionError from Standard
is static;
Perform(me: in out; Surf: TheSurface; Domain: TheTopolTool;
Direction: Vec from gp)
---Purpose: Creates the contour in a given direction.
is static;
Perform(me: in out; Surf: TheSurface; Domain: TheTopolTool;
Direction: Vec from gp; Angle: Real from Standard)
---Purpose: Creates the contour in a given direction.
is static;
Perform(me: in out; Surf: TheSurface; Domain: TheTopolTool;
Eye: Pnt from gp)
---Purpose: Creates the contour for a perspective view.
is static;
Init(me: in out; Direction: Vec from gp)
is static;
Init(me: in out; Direction: Vec from gp; Angle: Real from Standard)
is static;
Init(me: in out; Eye: Pnt from gp)
is static;
IsDone(me)
returns Boolean from Standard
---C++: inline
is static;
IsEmpty(me)
---Purpose: Returns true if the is no line.
returns Boolean from Standard
---C++: inline
raises NotDone from StdFail
is static;
NbLines(me)
returns Integer from Standard
---C++: inline
raises NotDone from StdFail
is static;
Line(me; Index: Integer from Standard)
returns TheLine from Contap
---C++: return const&
---C++: inline
raises NotDone from StdFail,
OutOfRange from Standard
is static;
SurfaceFunction(me : in out)
returns TheSurfFunction
---Purpose: Returns a reference on the internal
-- SurfaceFunction. This is used to compute tangents
-- on the lines.
---C++: return &
---C++: inline
is static;
Perform(me: in out; Domain: TheTopolTool)
is static private;
PerformAna(me: in out; Domain: TheTopolTool)
is static private;
fields
done : Boolean from Standard;
slin : TheSequenceOfLine from Contap;
solrst : TheSearch from Contap;
solins : TheSearchInside from Contap;
mySFunc : TheSurfFunction from Contap;
myAFunc : TheArcFunction from Contap;
modeset : Boolean from Standard;
end ContourGen;

View File

@@ -0,0 +1,15 @@
#include <ElCLib.hxx>
#include <gp_Pln.hxx>
#include <gp_Sphere.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Cone.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <Contap_ContAna.hxx>
#include <math_FunctionSetRoot.hxx>
#include <IntSurf.hxx>
#include <Contap_ContourGen_1.gxx>
#include <Contap_ContourGen_2.gxx>
#include <Contap_ContourGen_3.gxx>

View File

@@ -0,0 +1,32 @@
#include <StdFail_NotDone.hxx>
inline Standard_Boolean Contap_ContourGen::IsDone () const
{
return done;
}
inline Standard_Boolean Contap_ContourGen::IsEmpty () const
{
return NbLines()==0;
}
inline Standard_Integer Contap_ContourGen::NbLines () const
{
if (!done) {StdFail_NotDone::Raise();}
return slin.Length();
}
inline const Contap_TheLine &
Contap_ContourGen::Line (const Standard_Integer Index) const
{
if (!done) {StdFail_NotDone::Raise();}
return slin(Index);
}
inline Contap_TheSurfFunction &
Contap_ContourGen::SurfaceFunction ()
{
if (!done) {StdFail_NotDone::Raise();}
return mySFunc;
}

View File

@@ -0,0 +1,151 @@
#include <Standard_ConstructionError.hxx>
Contap_ContourGen::Contap_ContourGen () :
done(Standard_False),modeset(Standard_False)
{}
Contap_ContourGen::Contap_ContourGen (const gp_Vec& Direction) :
done(Standard_False),modeset(Standard_True)
{
mySFunc.Set(Direction);
myAFunc.Set(Direction);
}
Contap_ContourGen::Contap_ContourGen (const gp_Vec& Direction,
const Standard_Real Angle) :
done(Standard_False),modeset(Standard_True)
{
mySFunc.Set(Direction,Angle);
myAFunc.Set(Direction,Angle);
}
Contap_ContourGen::Contap_ContourGen (const gp_Pnt& Eye) :
done(Standard_False),modeset(Standard_True)
{
mySFunc.Set(Eye);
myAFunc.Set(Eye);
}
Contap_ContourGen::Contap_ContourGen (const TheSurface& Surf,
const Handle(TheTopolTool)& Domain,
const gp_Vec& Direction) :
done(Standard_False),modeset(Standard_True)
{
Perform(Surf,Domain,Direction);
}
Contap_ContourGen::Contap_ContourGen (const TheSurface& Surf,
const Handle(TheTopolTool)& Domain,
const gp_Vec& Direction,
const Standard_Real Angle) :
done(Standard_False),modeset(Standard_True)
{
Perform(Surf,Domain,Direction,Angle);
}
Contap_ContourGen::Contap_ContourGen (const TheSurface& Surf,
const Handle(TheTopolTool)& Domain,
const gp_Pnt& Eye) :
done(Standard_False),modeset(Standard_True)
{
Perform(Surf,Domain,Eye);
}
void Contap_ContourGen::Init (const gp_Vec& Direction)
{
done = Standard_False;
modeset = Standard_True;
mySFunc.Set(Direction);
myAFunc.Set(Direction);
}
void Contap_ContourGen::Init(const gp_Vec& Direction,
const Standard_Real Angle)
{
done = Standard_False;
modeset = Standard_True;
mySFunc.Set(Direction,Angle);
myAFunc.Set(Direction,Angle);
}
void Contap_ContourGen::Init (const gp_Pnt& Eye)
{
done = Standard_False;
modeset = Standard_True;
mySFunc.Set(Eye);
myAFunc.Set(Eye);
}
void Contap_ContourGen::Perform (const TheSurface& Surf,
const Handle(TheTopolTool)& Domain)
{
if (!modeset) {Standard_ConstructionError::Raise();}
mySFunc.Set(Surf);
myAFunc.Set(Surf);
GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(Surf);
switch (typS) {
case GeomAbs_Plane:
case GeomAbs_Sphere:
case GeomAbs_Cylinder:
case GeomAbs_Cone:
{
PerformAna(Domain); //Surf,Domain,Direction,0.,gp_Pnt(0.,0.,0.),1);
}
break;
default:
{
Perform(Domain); //Surf,Domain,Direction,0.,gp_Pnt(0.,0.,0.),1);
}
break;
}
}
void Contap_ContourGen::Perform (const TheSurface& Surf,
const Handle(TheTopolTool)& Domain,
const gp_Vec& Direction)
{
Init(Direction);
Perform(Surf,Domain);
}
void Contap_ContourGen::Perform (const TheSurface& Surf,
const Handle(TheTopolTool)& Domain,
const gp_Vec& Direction,
const Standard_Real Angle)
{
Init(Direction,Angle);
Perform(Surf,Domain);
}
void Contap_ContourGen::Perform (const TheSurface& Surf,
const Handle(TheTopolTool)& Domain,
const gp_Pnt& Eye)
{
Init(Eye);
Perform(Surf,Domain);
}

1587
src/Contap/Contap_ContourGen_2.gxx Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,435 @@
//-- Contap_ContourGen_3.gxx
#define Tolpetit 1.e-10 // pour dist au carre
#include <ElSLib.hxx>
#include <TColStd_SequenceOfInteger.hxx>
static Standard_Boolean FindLine(Contap_TheLine& Line,
const TheSurface& Surf,
const gp_Pnt2d& Pt2d,
gp_Pnt& Ptref,
Standard_Real& Paramin,
gp_Vec& Tgmin,
gp_Vec& Norm)
{
// Standard_Integer i;
gp_Pnt pt,ptmin;
gp_Vec tg;
Standard_Real para,dist;
Standard_Real dismin = RealLast();
Contap_TheSurfProps::Normale(Surf,Pt2d.X(),Pt2d.Y(),Ptref,Norm);
if (Line.TypeContour() == Contap_Lin) {
gp_Lin lin(Line.Line());
para = ElCLib::Parameter(lin,Ptref);
ElCLib::D1(para,lin,pt,tg);
dist = pt.Distance(Ptref) + Abs(Norm.Dot(lin.Direction()));
}
else { // Contap__Circle
gp_Circ cir(Line.Circle());
para = ElCLib::Parameter(cir,Ptref);
ElCLib::D1(para,cir,pt,tg);
dist = pt.Distance(Ptref)+Abs(Norm.Dot(tg/cir.Radius()));
}
if (dist < dismin) {
dismin = dist;
Paramin = para;
ptmin = pt;
Tgmin = tg;
}
if (ptmin.SquareDistance(Ptref) <= Tolpetit) {
return Standard_True;
}
else {
return Standard_False;
}
}
static void PutPointsOnLine (const Contap_TheSearch& solrst,
const TheSurface& Surf,
Contap_TheSequenceOfLine& slin)
{
Standard_Integer i,l;//,index;
Standard_Integer NbPoints = solrst.NbPoints();
Standard_Real theparam;
IntSurf_Transition TLine,TArc;
Standard_Boolean goon;
gp_Pnt2d pt2d;
gp_Vec2d d2d;
gp_Pnt ptonsurf;
gp_Vec vectg,normale,tgtrst;
Standard_Real paramlin;
Standard_Integer nbLin = slin.Length();
for(l=1;l<=nbLin;l++) {
Contap_TheLine& Line=slin.ChangeValue(l);
for (i=1; i<= NbPoints; i++) {
const Contap_ThePathPointOfTheSearch& PStart = solrst.Point(i);
const TheArc& thearc = PStart.Arc();
theparam = PStart.Parameter();
TheArcTool::D1(thearc,theparam,pt2d,d2d);
goon = FindLine(Line,Surf,pt2d,ptonsurf,paramlin,vectg,normale);
Contap_ThePoint PPoint;
if (goon) {
gp_Vec d1u,d1v;
gp_Pnt bidpt;
TheSurfaceTool::D1(Surf,pt2d.X(),pt2d.Y(),bidpt,d1u,d1v);
PPoint.SetValue(ptonsurf,pt2d.X(),pt2d.Y());
if (normale.Magnitude() < RealEpsilon()) {
TLine.SetValue();
TArc.SetValue();
}
else {
// Petit test qui devrait permettre de bien traiter les pointes
// des cones, et les sommets d`une sphere. Il faudrait peut-etre
// rajouter une methode dans SurfProps
if (Abs(d2d.Y()) <= Precision::Confusion()) {
tgtrst = d1v.Crossed(normale);
if(d2d.X() < 0.0)
tgtrst.Reverse();
}
else {
tgtrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
}
IntSurf::MakeTransition(vectg,tgtrst,normale,TLine,TArc);
}
PPoint.SetArc(thearc,theparam, TLine, TArc);
PPoint.SetParameter(paramlin);
if (!PStart.IsNew()) {
PPoint.SetVertex(PStart.Vertex());
}
Line.Add(PPoint);
}
}
}
}
//----------------------------------------------------------------------------------
//-- Orientation des contours Apparents quand ceux-ci sont des lignes ou des cercles
//-- On prend un point de la ligne ou du cercle ---> P
//-- On projete ce point sur la surface P ---> u,v
//-- et on evalue la transition au point u,v
//----------------------------------------------------------------------------------
IntSurf_TypeTrans ComputeTransitionOngpLine
(Contap_TheSurfFunction& SFunc,
const gp_Lin& L)
{
const TheSurface& Surf=SFunc.Surface();
GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(Surf);
gp_Pnt P;
gp_Vec T;
ElCLib::D1(0.0,L,P,T);
Standard_Real u,v;
switch (typS) {
case GeomAbs_Cylinder: {
ElSLib::Parameters(TheSurfaceTool::Cylinder(Surf),P,u,v);
break;
}
case GeomAbs_Cone: {
ElSLib::Parameters(TheSurfaceTool::Cone(Surf),P,u,v);
break;
}
case GeomAbs_Sphere: {
ElSLib::Parameters(TheSurfaceTool::Sphere(Surf),P,u,v);
break;
}
#ifndef DEB
default:
break;
#endif
}
return(ComputeTransitionOnLine(SFunc,u,v,T));
}
IntSurf_TypeTrans ComputeTransitionOngpCircle
(Contap_TheSurfFunction& SFunc,
const gp_Circ& C)
{
const TheSurface& Surf=SFunc.Surface();
GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(Surf);
gp_Pnt P;
gp_Vec T;
ElCLib::D1(0.0,C,P,T);
Standard_Real u,v;
switch (typS) {
case GeomAbs_Cylinder: {
ElSLib::Parameters(TheSurfaceTool::Cylinder(Surf),P,u,v);
break;
}
case GeomAbs_Cone: {
ElSLib::Parameters(TheSurfaceTool::Cone(Surf),P,u,v);
break;
}
case GeomAbs_Sphere: {
ElSLib::Parameters(TheSurfaceTool::Sphere(Surf),P,u,v);
break;
}
#ifndef DEB
default:
break;
#endif
}
return(ComputeTransitionOnLine(SFunc,u,v,T));
}
void Contap_ContourGen::PerformAna(const Handle(TheTopolTool)& Domain)
{
done = Standard_False;
slin.Clear();
Standard_Real TolArc = 1.e-5;
Standard_Integer nbCont, nbPointRst, i;
//gp_Circ cirsol;
//gp_Lin linsol;
Contap_ContAna contana;
Contap_TheLine theline;
const TheSurface& Surf = mySFunc.Surface();
Contap_TFunction TypeFunc(mySFunc.FunctionType());
Standard_Boolean PerformSolRst = Standard_True;
GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(Surf);
switch (typS) {
case GeomAbs_Plane:
{
gp_Pln pl(TheSurfaceTool::Plane(Surf));
switch (TypeFunc) {
case Contap_ContourStd:
{
gp_Dir Dirpln(pl.Axis().Direction());
if (Abs(mySFunc.Direction().Dot(Dirpln)) > Precision::Angular()) {
// Aucun point du plan n`est solution, en particulier aucun point
// sur restriction.
PerformSolRst = Standard_False;
}
}
break;
case Contap_ContourPrs:
{
gp_Pnt Eye(mySFunc.Eye());
if (pl.Distance(Eye) > Precision::Confusion()) {
// Aucun point du plan n`est solution, en particulier aucun point
// sur restriction.
PerformSolRst = Standard_False;
}
}
break;
case Contap_DraftStd:
{
gp_Dir Dirpln(pl.Axis().Direction());
Standard_Real Sina = Sin(mySFunc.Angle());
if (Abs(mySFunc.Direction().Dot(Dirpln)+ Sina) > //voir SurfFunction
Precision::Angular()) {
PerformSolRst = Standard_False;
}
}
break;
case Contap_DraftPrs:
default:
{
}
}
}
break;
case GeomAbs_Sphere:
{
switch (TypeFunc) {
case Contap_ContourStd:
{
contana.Perform(TheSurfaceTool::Sphere(Surf),mySFunc.Direction());
}
break;
case Contap_ContourPrs:
{
contana.Perform(TheSurfaceTool::Sphere(Surf),mySFunc.Eye());
}
break;
case Contap_DraftStd:
{
contana.Perform(TheSurfaceTool::Sphere(Surf),
mySFunc.Direction(),mySFunc.Angle());
}
break;
case Contap_DraftPrs:
default:
{
}
}
}
break;
case GeomAbs_Cylinder:
{
switch (TypeFunc) {
case Contap_ContourStd:
{
contana.Perform(TheSurfaceTool::Cylinder(Surf),mySFunc.Direction());
}
break;
case Contap_ContourPrs:
{
contana.Perform(TheSurfaceTool::Cylinder(Surf),mySFunc.Eye());
}
break;
case Contap_DraftStd:
{
contana.Perform(TheSurfaceTool::Cylinder(Surf),
mySFunc.Direction(),mySFunc.Angle());
}
break;
case Contap_DraftPrs:
default:
{
}
}
}
break;
case GeomAbs_Cone:
{
switch (TypeFunc) {
case Contap_ContourStd:
{
contana.Perform(TheSurfaceTool::Cone(Surf),mySFunc.Direction());
}
break;
case Contap_ContourPrs:
{
contana.Perform(TheSurfaceTool::Cone(Surf),mySFunc.Eye());
}
break;
case Contap_DraftStd:
{
contana.Perform(TheSurfaceTool::Cone(Surf),
mySFunc.Direction(),mySFunc.Angle());
}
break;
case Contap_DraftPrs:
default:
{
}
}
#ifndef DEB
default:
break;
#endif
}
break;
}
if (typS != GeomAbs_Plane) {
if (!contana.IsDone()) {
return;
}
nbCont = contana.NbContours();
if (contana.NbContours() == 0) {
done = Standard_True;
return;
}
GeomAbs_CurveType typL = contana.TypeContour();
if (typL == GeomAbs_Circle) {
theline.SetValue(contana.Circle());
IntSurf_TypeTrans TransCircle;
TransCircle = ComputeTransitionOngpCircle(mySFunc,contana.Circle());
theline.SetTransitionOnS(TransCircle);
slin.Append(theline);
}
else if (typL == GeomAbs_Line) {
for (i=1; i<=nbCont; i++) {
theline.SetValue(contana.Line(i));
IntSurf_TypeTrans TransLine;
TransLine = ComputeTransitionOngpLine(mySFunc,contana.Line(i));
theline.SetTransitionOnS(TransLine);
slin.Append(theline);
theline.Clear();
}
/*
if (typS == GeomAbs_Cone) {
Standard_Real u,v;
gp_Cone thecone(TheSurfaceTool::Cone(Surf));
ElSLib::Parameters(thecone,thecone.Apex(),u,v);
Contap_ThePoint vtxapex(thecone.Apex(),u,v);
vtxapex.SetInternal();
vtxapex.SetMultiple();
for (i=1; i<=nbCont i++) {
slin.ChangeValue(i).Add(vtxapex);
}
}
*/
}
}
if(PerformSolRst) {
solrst.Perform(myAFunc,Domain,TolArc,TolArc);
if (!solrst.IsDone()) {
return;
}
nbPointRst = solrst.NbPoints();
if (nbPointRst != 0) {
PutPointsOnLine(solrst,Surf,slin);
}
if (solrst.NbSegments() !=0) {
ProcessSegments(solrst,slin,TolArc,mySFunc,Domain);
}
//-- lbr
//Standard_Boolean oneremov;
Standard_Integer nblinto = slin.Length();
TColStd_SequenceOfInteger SeqToDestroy;
//-- cout<<" Construct Contour_3 nblin = "<<nblinto<<endl;
for(i=1; i<= nblinto ; i++) {
//-- cout<<" nbvtx : "<<slin.Value(i).NbVertex()<<endl;
//--if(slin.Value(i).NbVertex() > 1) {
if(slin.Value(i).TypeContour() != Contap_Restriction) {
LineConstructor(slin,Domain,slin.ChangeValue(i),Surf);
SeqToDestroy.Append(i);
}
//-- }
}
for(i=SeqToDestroy.Length(); i>=1; i--) {
slin.Remove(SeqToDestroy.Value(i));
}
}
done = Standard_True;
}

View File

@@ -0,0 +1,188 @@
-- File: Contap_HContToolGen.cdl
-- Created: Fri Jul 2 13:19:22 1995
-- Author: Laurent BUCHARD
---Copyright: Matra Datavision 1995
generic class HContToolGen from Contap (
TheHVertex as any;
TheHCurve2d as any;
TheHSurface as any;
TheHCurve2dTool as any;
TheHSurfaceTool as any)
---Purpose: Tool for the intersection between 2 surfaces.
-- Regroupe pour l instant les methodes hors Adaptor3d...
uses
Pnt2d from gp,
Pnt from gp
is
NbSamplesU(myclass; S: TheHSurface; u1,u2: Real from Standard)
returns Integer from Standard;
NbSamplesV(myclass; S: TheHSurface; v1,v2: Real from Standard)
returns Integer from Standard;
-- Methodes pour recherche des points interieurs
NbSamplePoints(myclass; S: TheHSurface)
returns Integer from Standard;
SamplePoint(myclass; S : TheHSurface;
Index: Integer from Standard;
U,V: out Real from Standard);
-- Methodes sur un arc de restriction
HasBeenSeen(myclass; C: TheHCurve2d)
---Purpose: Returns True if all the intersection point and edges
-- are known on the Arc.
-- The intersection point are given as vertices.
-- The intersection edges are given as intervals between
-- two vertices.
returns Boolean from Standard;
NbSamplesOnArc(myclass; A: TheHCurve2d)
---Purpose: returns the number of points which is used to make
-- a sample on the arc. this number is a function of
-- the Surface and the CurveOnSurface complexity.
returns Integer from Standard;
Bounds(myclass; C: TheHCurve2d;
Ufirst,Ulast: out Real from Standard);
---Purpose: Returns the parametric limits on the arc C.
-- These limits must be finite : they are either
-- the real limits of the arc, for a finite arc,
-- or a bounding box for an infinite arc.
Project(myclass; C: TheHCurve2d;
P: Pnt2d from gp;
Paramproj: out Real from Standard;
Ptproj : out Pnt2d from gp)
---Purpose: Projects the point P on the arc C.
-- If the methods returns Standard_True, the projection is
-- successful, and Paramproj is the parameter on the arc
-- of the projected point, Ptproj is the projected Point.
-- If the method returns Standard_False, Param proj and Ptproj
-- are not significant.
--
returns Boolean from Standard;
-- Methods on a vertex
Tolerance(myclass; V: TheHVertex; C: TheHCurve2d)
---Purpose: Returns the parametric tolerance used to consider
-- that the vertex and another point meet, i-e
-- if Abs(parameter(Vertex) - parameter(OtherPnt))<=
-- Tolerance, the points are "merged".
returns Real from Standard;
Parameter(myclass; V: TheHVertex; C: TheHCurve2d)
---Purpose: Returns the parameter of the vertex V on the arc A.
returns Real from Standard;
-- The following methods are used when HasBeenSeen returns Standard_True
NbPoints(myclass; C: TheHCurve2d)
---Purpose: Returns the number of intersection points on the arc A.
returns Integer from Standard;
Value(myclass; C: TheHCurve2d; Index: Integer from Standard;
Pt: out Pnt from gp; Tol: out Real from Standard;
U: out Real from Standard);
---Purpose: Returns the value (Pt), the tolerance (Tol), and
-- the parameter (U) on the arc A , of the intersection
-- point of range Index.
IsVertex(myclass; C: TheHCurve2d;
Index: Integer from Standard)
---Purpose: Returns True if the intersection point of range Index
-- corresponds with a vertex on the arc A.
returns Boolean from Standard;
Vertex(myclass; C: TheHCurve2d; Index: Integer from Standard;
V: out TheHVertex);
---Purpose: When IsVertex returns True, this method returns the
-- vertex on the arc A.
NbSegments(myclass; C: TheHCurve2d)
---Purpose: returns the number of part of A solution of the
-- of intersection problem.
returns Integer from Standard;
HasFirstPoint(myclass; C: TheHCurve2d;
Index: Integer from Standard;
IndFirst: out Integer from Standard)
---Purpose: Returns True when the segment of range Index is not
-- open at the left side. In that case, IndFirst is the
-- range in the list intersection points (see NbPoints)
-- of the one which defines the left bound of the segment.
-- Otherwise, the method has to return False, and IndFirst
-- has no meaning.
returns Boolean from Standard;
HasLastPoint(myclass; C: TheHCurve2d;
Index: Integer from Standard;
IndLast: out Integer from Standard)
---Purpose: Returns True when the segment of range Index is not
-- open at the right side. In that case, IndLast is the
-- range in the list intersection points (see NbPoints)
-- of the one which defines the right bound of the segment.
-- Otherwise, the method has to return False, and IndLast
-- has no meaning.
returns Boolean from Standard;
IsAllSolution(myclass; C: TheHCurve2d)
---Purpose: Returns True when the whole restriction is solution
-- of the intersection problem.
returns Boolean from Standard;
end HContToolGen;

View File

@@ -0,0 +1,380 @@
//-- File: Contap_HContToolGen.cdl
//-- Created: Fri Jul 2 13:19:22 1995
//-- Author: Laurent BUCHARD
//-- <lbr@mastox>
//---Copyright: Matra Datavision 1995
#include <Extrema_EPCOfExtPC2d.hxx>
#include <Extrema_POnCurv2d.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <Standard_OutOfRange.hxx>
#include <Handle_Geom_BezierSurface.hxx>
#include <Handle_Geom_BSplineSurface.hxx>
#include <Handle_Geom2d_BezierCurve.hxx>
#include <Handle_Geom2d_BSplineCurve.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
static Standard_Real uinf,vinf,usup,vsup;
#include TheHSurface_hxx
#include TheHCurve2d_hxx
#include TheHVertex_hxx
Standard_Integer Contap_HContToolGen::NbSamplesV
(const TheHSurface& S,
const Standard_Real ,
const Standard_Real )
{
Standard_Integer nbs;
GeomAbs_SurfaceType typS = S->GetType();
switch(typS) {
case GeomAbs_Plane:
{
nbs = 2;
}
break;
case GeomAbs_BezierSurface:
{
nbs = 3 + S->NbVPoles();
}
break;
case GeomAbs_BSplineSurface:
{
//-- Handle_Geom_BSplineSurface& HBS=S->BSpline();
nbs = S->NbVKnots();
nbs*= S->VDegree();
if(nbs < 2) nbs=2;
}
break;
case GeomAbs_Cylinder:
case GeomAbs_Cone:
case GeomAbs_Sphere:
case GeomAbs_Torus:
case GeomAbs_SurfaceOfRevolution:
case GeomAbs_SurfaceOfExtrusion:
{
nbs = 15;
}
break;
default:
{
nbs = 10;
}
break;
}
return(nbs);
}
Standard_Integer Contap_HContToolGen::NbSamplesU
(const TheHSurface& S,
const Standard_Real ,
const Standard_Real )
{
Standard_Integer nbs;
GeomAbs_SurfaceType typS = S->GetType();
switch(typS) {
case GeomAbs_Plane:
{
nbs = 2;
}
break;
case GeomAbs_BezierSurface:
{
nbs = 3 + S->NbUPoles();
}
break;
case GeomAbs_BSplineSurface:
{
//-- Handle_Geom_BSplineSurface& HBS=S->BSpline();
nbs = S->NbUKnots();
nbs*= S->UDegree();
if(nbs < 2) nbs=2;
}
break;
case GeomAbs_Torus:
{
nbs = 20;
}
break;
case GeomAbs_Cylinder:
case GeomAbs_Cone:
case GeomAbs_Sphere:
case GeomAbs_SurfaceOfRevolution:
case GeomAbs_SurfaceOfExtrusion:
{
nbs = 10;
}
break;
default:
{
nbs = 10;
}
break;
}
return(nbs);
}
Standard_Integer Contap_HContToolGen::NbSamplePoints
(const TheHSurface& S)
{
uinf = S->FirstUParameter();
usup = S->LastUParameter();
vinf = S->FirstVParameter();
vsup = S->LastVParameter();
if (usup < uinf) {
Standard_Real temp = uinf;
uinf = usup;
usup = temp;
}
if (vsup < vinf) {
Standard_Real temp = vinf;
vinf = vsup;
vsup = temp;
}
if (uinf == RealFirst() && usup == RealLast()) {
uinf = -1.e5;
usup = 1.e5;
}
else if (uinf == RealFirst()) {
uinf = usup - 2.e5;
}
else if (usup == RealLast()) {
usup = uinf + 2.e5;
}
if (vinf == RealFirst() && vsup == RealLast()) {
vinf = -1.e5;
vsup = 1.e5;
}
else if (vinf == RealFirst()) {
vinf = vsup - 2.e5;
}
else if (vsup == RealLast()) {
vsup = vinf + 2.e5;
}
if(S->GetType() == GeomAbs_BSplineSurface) {
Standard_Integer m = (NbSamplesU(S,uinf,usup)/3) * (NbSamplesV(S,vinf,vsup)/3);
if(m>5) return(m);
else return(5);
}
else
return 5;
}
void Contap_HContToolGen::SamplePoint (const TheHSurface& S,
const Standard_Integer Index,
Standard_Real& U,
Standard_Real& V )
{
if(S->GetType() == GeomAbs_BSplineSurface) {
Standard_Integer nbIntU = NbSamplesU(S,uinf,usup)/3;
Standard_Integer nbIntV = NbSamplesV(S,vinf,vsup)/3;
if(nbIntU * nbIntV >5) {
Standard_Integer indU = (Index-1)/nbIntU; //---- 0 --> nbIntV
Standard_Integer indV = (Index-1) - indU*nbIntU; //---- 0 --> nbIntU
U = uinf + ((usup-uinf)/((Standard_Real)(nbIntU+1)))*(Standard_Real)(indU+1);
V = vinf + ((vsup-vinf)/((Standard_Real)(nbIntV+2)))*(Standard_Real)(indV+1);
//-- cout<<"Index :"<<Index<<" uinf:"<<uinf<<" usup:"<<usup<<" vinf:"<<vinf<<" vsup:"<<vsup<<" ";
//-- cout<<" ("<<indU<<"/"<<nbIntU<<" ->U:"<<U<<" ";
//-- cout<<" ("<<indV<<"/"<<nbIntV<<" ->V:"<<V<<endl;
return;
}
}
switch (Index) {
case 1:
U = 0.75*uinf + 0.25*usup; //0.25;
V = 0.75*vinf + 0.25*vsup; //0.25;
break;
case 2:
U = 0.75*uinf + 0.25*usup; //0.25;
V = 0.25*vinf + 0.75*vsup; //0.75;
break;
case 3:
U = 0.25*uinf + 0.75*usup; //0.75;
V = 0.75*vinf + 0.25*vsup; //0.25;
break;
case 4:
U = 0.25*uinf + 0.75*usup; //0.75;
V = 0.25*vinf + 0.75*vsup; //0.75;
break;
default:
U = 0.5*(uinf+usup); //0.5;
V = 0.5*(vinf+vsup); //0.5;
}
}
Standard_Integer Contap_HContToolGen::NbSamplesOnArc
(const TheHCurve2d& A) {
GeomAbs_CurveType CurveType = A->GetType();
Standard_Real nbsOnC = 5;
switch(CurveType) {
case GeomAbs_Line:
nbsOnC = 2;
break;
case GeomAbs_Circle:
case GeomAbs_Ellipse:
case GeomAbs_Hyperbola:
case GeomAbs_Parabola:
nbsOnC = 10;
break;
case GeomAbs_BezierCurve:
nbsOnC = A->NbPoles();
break;
case GeomAbs_BSplineCurve: {
//-- Handle_Geom2d_BSplineCurve& BSC=A->BSpline();
nbsOnC = 2 + A->NbKnots() * A->Degree();
break;
}
default:
nbsOnC = 10;
}
//#ifndef DEB
return (Standard_Integer)(nbsOnC);
//#else
// return(nbsOnC);
//#endif
}
void Contap_HContToolGen::Bounds(const TheHCurve2d& A,
Standard_Real& Ufirst,
Standard_Real& Ulast)
{
Ufirst = A->FirstParameter();
Ulast = A->LastParameter();
}
Standard_Boolean Contap_HContToolGen::Project (const TheHCurve2d& C,
const gp_Pnt2d& P,
Standard_Real& Paramproj,
gp_Pnt2d& Ptproj)
{
Standard_Real epsX = 1.e-8;
Standard_Integer Nbu = 20;
Standard_Real Tol = 1.e-5;
Standard_Real Dist2;
Extrema_EPCOfExtPC2d extrema(P,C->Curve2d(),Nbu,epsX,Tol);
if (!extrema.IsDone()) {
return Standard_False;
}
Standard_Integer Nbext = extrema.NbExt();
if (Nbext == 0) {
return Standard_False;
}
Standard_Integer indexmin = 1;
Dist2 = extrema.SquareDistance(1);
for (Standard_Integer i=2; i<=Nbext; i++) {
if (extrema.SquareDistance(i) < Dist2) {
indexmin = i;
Dist2 = extrema.SquareDistance(i);
}
}
Paramproj = extrema.Point(indexmin).Parameter();
Ptproj = extrema.Point(indexmin).Value();
return Standard_True;
}
Standard_Real Contap_HContToolGen::Tolerance (const TheHVertex& V,
const TheHCurve2d& C)
{
// return BRepAdaptor2d_Curve2dTool::Resolution(C,BRep_Tool::Tolerance(V));
return V->Resolution(C);
}
Standard_Real Contap_HContToolGen::Parameter (const TheHVertex& V,
const TheHCurve2d& C)
{
// return BRep_Tool::Parameter(V,C.Edge());
return V->Parameter(C);
}
Standard_Boolean Contap_HContToolGen::HasBeenSeen
(const TheHCurve2d&)
{
return Standard_False;
}
Standard_Integer Contap_HContToolGen::NbPoints(const TheHCurve2d&)
{
return 0;
}
void Contap_HContToolGen::Value(const TheHCurve2d&,
const Standard_Integer,
gp_Pnt&,
Standard_Real&,
Standard_Real&)
{
Standard_OutOfRange::Raise();
}
Standard_Boolean Contap_HContToolGen::IsVertex(const TheHCurve2d&,
const Standard_Integer)
{
return Standard_False;
}
void Contap_HContToolGen::Vertex(const TheHCurve2d&,
const Standard_Integer,
TheHVertex&)
{
Standard_OutOfRange::Raise();
}
Standard_Integer Contap_HContToolGen::NbSegments(const TheHCurve2d&)
{
return 0;
}
Standard_Boolean Contap_HContToolGen::HasFirstPoint
(const TheHCurve2d&,
const Standard_Integer,
Standard_Integer&)
{
Standard_OutOfRange::Raise();
return Standard_False;
}
Standard_Boolean Contap_HContToolGen::HasLastPoint
(const TheHCurve2d&,
const Standard_Integer,
Standard_Integer&)
{
Standard_OutOfRange::Raise();
return Standard_False;
}
Standard_Boolean Contap_HContToolGen::IsAllSolution
(const TheHCurve2d&)
{
return Standard_False;
}

View File

@@ -0,0 +1,227 @@
-- File: Contap_HCurve2dToolGen.cdl
-- Created: Mon Jul 17 16:25:23 1995
-- Author: Laurent BUCHARD
-- <lbr@mastox>
---Copyright: Matra Datavision 1995
generic class HCurve2dToolGen from Contap (
CurveGen as any)
uses
Array1OfReal from TColStd,
Shape from GeomAbs,
CurveType from GeomAbs,
Vec2d from gp,
Pnt2d from gp,
Circ2d from gp,
Elips2d from gp,
Hypr2d from gp,
Parab2d from gp,
Lin2d from gp,
BezierCurve from Geom2d,
BSplineCurve from Geom2d
raises
OutOfRange from Standard,
NoSuchObject from Standard,
DomainError from Standard
is
--
-- Global methods - Apply to the whole curve.
--
FirstParameter(myclass; C: CurveGen) returns Real
---C++: inline
;
LastParameter(myclass; C: CurveGen) returns Real
---C++: inline
;
--
-- Services to break the curves to the expected continuity
--
-- If for example you need the curve to be C2 and the method
-- Continuity returns you something lower than C2 (say C1 for
-- example).
--
-- First compute the number of intervals with the requested
-- continuity with the method NbIntervals(). Note that if the
-- continuity is higher than the one you need NbIntervals will
-- return 1.
--
-- Then you get the parameters bounding the intervals with the
-- method Intervals, using an array of length at least
-- NbIntervals()+1.
--
-- If you need to create a curve with a restricted span you can
-- use the method Trim().
Continuity(myclass; C: CurveGen) returns Shape from GeomAbs
---Purpose:
---C++: inline
;
NbIntervals(myclass; C: CurveGen; S : Shape from GeomAbs) returns Integer
---Purpose: Returns the number of intervals for continuity
-- <S>. May be one if Continuity(myclass) >= <S>
---C++: inline
;
Intervals(myclass; C: CurveGen; T : in out Array1OfReal from TColStd;
S : Shape from GeomAbs)
---Purpose: Stores in <T> the parameters bounding the intervals
-- of continuity <S>.
--
-- The array must provide enough room to accomodate
-- for the parameters. i.e. T.Length() > NbIntervals()
raises
OutOfRange from Standard
---C++: inline
;
IsClosed(myclass; C: CurveGen) returns Boolean
---C++: inline
;
IsPeriodic(myclass; C: CurveGen) returns Boolean
---C++: inline
;
Period(myclass; C: CurveGen) returns Real
raises
DomainError from Standard -- if the curve is not periodic
---C++: inline
;
Value(myclass; C: CurveGen; U : Real) returns Pnt2d from gp
--- Purpose : Computes the point of parameter U on the curve.
---C++: inline
;
D0 (myclass; C: CurveGen; U : Real; P : out Pnt2d from gp)
--- Purpose : Computes the point of parameter U on the curve.
---C++: inline
;
D1 (myclass; C: CurveGen; U : Real; P : out Pnt2d from gp ; V : out Vec2d from gp)
--- Purpose : Computes the point of parameter U on the curve with its
-- first derivative.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C1.
---C++: inline
;
D2 (myclass; C: CurveGen; U : Real; P : out Pnt2d from gp; V1, V2 : out Vec2d from gp)
--- Purpose :
-- Returns the point P of parameter U, the first and second
-- derivatives V1 and V2.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C2.
---C++: inline
;
D3 (myclass; C: CurveGen; U : Real; P : out Pnt2d from gp; V1, V2, V3 : out Vec2d from gp)
--- Purpose :
-- Returns the point P of parameter U, the first, the second
-- and the third derivative.
raises
DomainError from Standard
--- Purpose : Raised if the continuity of the current interval
-- is not C3.
---C++: inline
;
DN (myclass; C: CurveGen; U : Real; N : Integer) returns Vec2d from gp
--- Purpose :
-- The returned vector gives the value of the derivative for the
-- order of derivation N.
raises
DomainError from Standard,
--- Purpose : Raised if the continuity of the current interval
-- is not CN.
OutOfRange from Standard
--- Purpose : Raised if N < 1.
---C++: inline
;
Resolution(myclass; C: CurveGen; R3d : Real) returns Real
---Purpose : Returns the parametric resolution corresponding
-- to the real space resolution <R3d>.
---C++: inline
;
GetType(myclass; C: CurveGen) returns CurveType from GeomAbs
---Purpose: Returns the type of the curve in the current
-- interval : Line, Circle, Ellipse, Hyperbola,
-- Parabola, BezierCurve, BSplineCurve, OtherCurve.
---C++: inline
;
--
-- The following methods must be called when GetType returned
-- the corresponding type.
--
Line(myclass; C: CurveGen) returns Lin2d from gp
raises
NoSuchObject from Standard
---C++: inline
;
Circle(myclass; C: CurveGen) returns Circ2d from gp
raises
NoSuchObject from Standard
---C++: inline
;
Ellipse(myclass; C: CurveGen) returns Elips2d from gp
raises
NoSuchObject from Standard
---C++: inline
;
Hyperbola(myclass; C: CurveGen) returns Hypr2d from gp
raises
NoSuchObject from Standard
---C++: inline
;
Parabola(myclass; C: CurveGen) returns Parab2d from gp
raises
NoSuchObject from Standard
---C++: inline
;
Bezier(myclass; C: CurveGen) returns BezierCurve from Geom2d
raises
NoSuchObject from Standard
---C++: inline
;
BSpline(myclass; C: CurveGen) returns BSplineCurve from Geom2d
raises
NoSuchObject from Standard
---C++: inline
;
NbSamples(myclass; C: CurveGen; U0,U1: Real from Standard)
returns Integer from Standard;
end HCurve2dToolGen;

View File

@@ -0,0 +1,37 @@
// File: Contap_HCurve2dToolGen.gxx
// Created: Mon Jul 17 17:39:39 1995
// Author: Modelistation
// <model@mastox>
#include CurveGen_hxx
#include <GeomAbs_CurveType.hxx>
#include <GeomAbs_Shape.hxx>
#include <Handle_Geom2d_BezierCurve.hxx>
#include <Handle_Geom2d_BSplineCurve.hxx>
#include <TColStd_Array1OfReal.hxx>
//============================================================
Standard_Integer Contap_HCurve2dToolGen::NbSamples (const CurveGen& C,
const Standard_Real U0,
const Standard_Real U1) {
GeomAbs_CurveType typC = C->GetType();
static Standard_Real nbsOther = 10.0;
Standard_Real nbs = nbsOther;
if(typC == GeomAbs_Line)
nbs = 2;
else if(typC == GeomAbs_BezierCurve)
nbs = 3 + C->NbPoles();
else if(typC == GeomAbs_BSplineCurve) {
nbs = C->NbKnots();
nbs*= C->Degree();
nbs*= C->LastParameter()- C->FirstParameter();
nbs/= U1-U0;
if(nbs < 2.0) nbs=2;
}
if(nbs>50)
nbs = 50;
return((Standard_Integer)nbs);
}

View File

@@ -0,0 +1,154 @@
// File: Contap_HCurve2dToolGen.lxx
// Created: Thu Oct 22 12:14:59 1992
// Author: Laurent BUCHARD
// <lbr@sdsun2>
#include CurveGen_hxx
#include <GeomAbs_CurveType.hxx>
#include <GeomAbs_Shape.hxx>
#include <gp_Vec2d.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Parab2d.hxx>
#include <gp_Hypr2d.hxx>
#include <Handle_Geom2d_BezierCurve.hxx>
#include <Handle_Geom2d_BSplineCurve.hxx>
#include <TColStd_Array1OfReal.hxx>
//============================================================
inline Standard_Real Contap_HCurve2dToolGen::FirstParameter (const CurveGen& C) {
return(C->FirstParameter());
}
//============================================================
inline Standard_Real Contap_HCurve2dToolGen::LastParameter (const CurveGen& C) {
return(C->LastParameter());
}
//============================================================
inline GeomAbs_Shape Contap_HCurve2dToolGen::Continuity (const CurveGen& C) {
return(C->Continuity());
}
//============================================================
inline Standard_Integer Contap_HCurve2dToolGen::NbIntervals(const CurveGen& C,const GeomAbs_Shape Sh) {
return(C->NbIntervals(Sh));
}
//============================================================
inline void Contap_HCurve2dToolGen::Intervals(const CurveGen& C,
TColStd_Array1OfReal& Tab,
const GeomAbs_Shape Sh) {
C->Intervals(Tab,Sh);
}
//============================================================
inline Standard_Boolean Contap_HCurve2dToolGen::IsClosed(const CurveGen& C) {
return(C->IsClosed());
}
//============================================================
inline Standard_Boolean Contap_HCurve2dToolGen::IsPeriodic(const CurveGen& C) {
return(C->IsPeriodic());
}
//============================================================
inline Standard_Real Contap_HCurve2dToolGen::Period(const CurveGen& C) {
return(C->Period());
}
//============================================================
inline gp_Pnt2d Contap_HCurve2dToolGen::Value (const CurveGen& C,
const Standard_Real U) {
return(C->Value(U));
}
//============================================================
inline void Contap_HCurve2dToolGen::D0(const CurveGen& C,
const Standard_Real U,
gp_Pnt2d& P) {
C->D0(U,P);
}
//============================================================
inline void Contap_HCurve2dToolGen::D1 (const CurveGen& C,
const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& T) {
C->D1(U,P,T);
}
//============================================================
inline void Contap_HCurve2dToolGen::D2 (const CurveGen& C,
const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& T,
gp_Vec2d& N) {
C->D2(U,P,T,N);
}
//============================================================
inline void Contap_HCurve2dToolGen::D3 (const CurveGen& C,
const Standard_Real U,
gp_Pnt2d& P,
gp_Vec2d& V1,
gp_Vec2d& V2,
gp_Vec2d& V3) {
C->D3(U,P,V1,V2,V3);
}
//============================================================
inline gp_Vec2d Contap_HCurve2dToolGen::DN (const CurveGen& C,
const Standard_Real U,
const Standard_Integer N) {
return(C->DN(U,N));
}
//============================================================
inline Standard_Real Contap_HCurve2dToolGen::Resolution(const CurveGen& C,
const Standard_Real R3d) {
return(C->Resolution(R3d));
}
//============================================================
inline GeomAbs_CurveType Contap_HCurve2dToolGen::GetType(const CurveGen& C) {
return(C->GetType());
}
//============================================================
inline gp_Lin2d Contap_HCurve2dToolGen::Line (const CurveGen& C) {
return(C->Line());
}
//============================================================
inline gp_Circ2d Contap_HCurve2dToolGen::Circle (const CurveGen& C) {
return(C->Circle());
}
//============================================================
inline gp_Elips2d Contap_HCurve2dToolGen::Ellipse (const CurveGen& C) {
return(C->Ellipse());
}
//============================================================
inline gp_Parab2d Contap_HCurve2dToolGen::Parabola (const CurveGen& C) {
return(C->Parabola());
}
//============================================================
inline gp_Hypr2d Contap_HCurve2dToolGen::Hyperbola (const CurveGen& C) {
return(C->Hyperbola());
}
//============================================================
inline Handle(Geom2d_BezierCurve) Contap_HCurve2dToolGen::Bezier (const CurveGen& C) {
return(C->Bezier());
}
//============================================================
inline Handle(Geom2d_BSplineCurve) Contap_HCurve2dToolGen::BSpline (const CurveGen& C) {
return(C->BSpline());
}
//============================================================

205
src/Contap/Contap_Line.cdl Executable file
View File

@@ -0,0 +1,205 @@
-- File: Contap_Line.cdl
-- Created: Fri Feb 5 12:13:00 1993
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1993
generic class Line from Contap
(TheVertex as any;
TheArc as any;
ThePoint as any; --as Point from Contap(TheVertex,TheArc)
TheHSequenceOfPoint as Transient) --as HSequence from TCollection
-- (ThePoint)
---Purpose:
uses Pnt from gp,
LineOn2S from IntSurf,
PntOn2S from IntSurf,
TypeTrans from IntSurf,
Lin from gp,
Circ from gp,
Dir from gp,
IType from Contap -- duplique IntPatch_IType. Mettre ds IntSurf
raises DomainError from Standard,
OutOfRange from Standard
is
Create
returns Line from Contap;
SetLineOn2S(me: in out; L: LineOn2S from IntSurf)
is static;
Clear(me: in out)
is static;
LineOn2S(me)
returns LineOn2S from IntSurf
---C++: inline
---C++: return const&
is static;
ResetSeqOfVertex(me: in out)
is static;
Add(me: in out; P: PntOn2S from IntSurf)
---C++: inline
is static;
SetValue(me: in out; L: Lin from gp)
is static;
SetValue(me: in out; C: Circ from gp)
is static;
SetValue(me: in out; A: TheArc)
is static;
Add(me: in out; P: ThePoint)
is static;
NbVertex(me)
returns Integer from Standard
---C++: inline
is static;
Vertex(me; Index: Integer from Standard)
returns ThePoint
---C++: return &
---C++: inline
raises OutOfRange from Standard
is static;
TypeContour(me)
---Purpose: Returns Contap_Lin for a line, Contap_Circle for
-- a circle, and Contap_Walking for a Walking line,
-- Contap_Restriction for a part of boundarie.
returns IType from Contap
---C++: inline
is static;
NbPnts(me)
returns Integer from Standard
---C++: inline
raises DomainError from Standard
-- The exception DomainError is raised if TypeContour does not return
-- Contap_Walking.
is static;
Point(me; Index: Integer from Standard)
returns PntOn2S from IntSurf
---C++: return const&
---C++: inline
raises DomainError from Standard,
OutOfRange from Standard
-- The exception DomainError is raised if TypeContour does not return
-- Contap_Walking.
-- The exception OutOfRange is raised if Index<=0 or Index>NbPoints.
is static;
Line(me)
returns Lin from gp
---C++: inline
raises DomainError from Standard
-- The exception DomainError is raised if TypeContour does not return
-- Contap_Lin.
is static;
Circle(me)
returns Circ from gp
---C++: inline
raises DomainError from Standard
-- The exception DomainError is raised if TypeContour does not return
-- Contap_Circle.
is static;
Arc(me)
returns any TheArc
---C++: return const&
raises DomainError from Standard
-- The exception DomainError is raised if TypeContour does not return
-- Contap_Restriction.
is static;
SetTransitionOnS(me: in out; T: TypeTrans from IntSurf)
---Purpose: Set The Tansition of the line.
--
is static;
TransitionOnS(me)
---Purpose: returns IN if at the "left" of the line, the normale of the
-- surface is oriented to the observator.
returns TypeTrans from IntSurf
is static;
fields
Trans : TypeTrans from IntSurf;
curv : LineOn2S from IntSurf;
svtx : TheHSequenceOfPoint;
thearc : TheArc;
typL : IType from Contap;
pt : Pnt from gp;
dir1 : Dir from gp;
dir2 : Dir from gp;
rad : Real from Standard;
end Line;

89
src/Contap/Contap_Line.gxx Executable file
View File

@@ -0,0 +1,89 @@
//--------------------------------------------------
//-- C o n t a p _ L i n e . g x x --
//--------------------------------------------------
Contap_Line::Contap_Line () {
svtx = new TheHSequenceOfPoint ();
Trans = IntSurf_Undecided;
}
void Contap_Line::ResetSeqOfVertex() {
svtx = new TheHSequenceOfPoint ();
}
void Contap_Line::Add(const ThePoint& P) {
Standard_Integer n = svtx->Length();
if(n==0) {
svtx->Append(P);
}
else {
Standard_Real prm = P.ParameterOnLine();
if(prm > svtx->Value(n).ParameterOnLine()) {
svtx->Append(P);
}
else {
for(Standard_Integer i=n-1;i>0;i--) {
if(prm> svtx->Value(i).ParameterOnLine()) {
svtx->InsertBefore(i+1,P);
return;
}
}
svtx->Prepend(P);
}
}
}
void Contap_Line::Clear () {
if(!curv.IsNull())
curv->Clear();
svtx = new TheHSequenceOfPoint ();
typL = Contap_Walking;
}
void Contap_Line::SetValue(const gp_Lin& L)
{
pt = L.Location();
dir1 = L.Direction();
typL = Contap_Lin;
}
void Contap_Line::SetValue(const gp_Circ& C)
{
pt = C.Location();
dir1 = C.Position().Direction();
dir2 = C.Position().XDirection();
rad = C.Radius();
typL = Contap_Circle;
}
void Contap_Line::SetValue(const TheArc& A)
{
thearc = A;
typL = Contap_Restriction;
}
void Contap_Line::SetLineOn2S(const Handle(IntSurf_LineOn2S)& L) {
curv = L;
typL = Contap_Walking;
}
void Contap_Line::SetTransitionOnS(const IntSurf_TypeTrans T) {
Trans = T;
}
IntSurf_TypeTrans Contap_Line::TransitionOnS() const {
return(Trans);
}
const TheArc& Contap_Line::Arc () const
{
if (typL != Contap_Restriction) {Standard_DomainError::Raise();}
return thearc;
}

57
src/Contap/Contap_Line.lxx Executable file
View File

@@ -0,0 +1,57 @@
#include <Standard_DomainError.hxx>
#include <TColgp_HSequenceOfPnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <IntSurf_PntOn2S.hxx>
#include <IntSurf_LineOn2S.hxx>
#include TheHSequenceOfPoint_hxx
inline const Handle(IntSurf_LineOn2S)& Contap_Line::LineOn2S () const
{
return curv;
}
inline void Contap_Line::Add(const IntSurf_PntOn2S& POn2S)
{
curv->Add(POn2S);
}
inline Standard_Integer Contap_Line::NbVertex () const
{
return svtx->Length();
}
inline ThePoint& Contap_Line::Vertex (const Standard_Integer Index) const
{
return svtx->ChangeSequence()(Index);
}
inline Contap_IType Contap_Line::TypeContour () const
{
return typL;
}
inline Standard_Integer Contap_Line::NbPnts () const {
if (typL != Contap_Walking) {Standard_DomainError::Raise();}
return(curv->NbPoints());
}
inline const IntSurf_PntOn2S& Contap_Line::Point (const Standard_Integer Index) const {
if (typL != Contap_Walking) {Standard_DomainError::Raise();}
return(curv->Value(Index));
}
inline gp_Lin Contap_Line::Line () const
{
if (typL != Contap_Lin) {Standard_DomainError::Raise();}
return gp_Lin(pt,dir1);
}
inline gp_Circ Contap_Line::Circle () const
{
if (typL != Contap_Circle) {Standard_DomainError::Raise();}
return gp_Circ(gp_Ax2(pt,dir1,dir2),rad);
}

262
src/Contap/Contap_Point.cdl Executable file
View File

@@ -0,0 +1,262 @@
-- File: Contap_Point.cdl
-- Created: Thu Mar 4 17:22:45 1993
-- Author: Jacques GOUSSARD
-- <jag@form4>
---Copyright: Matra Datavision 1993
generic class Point from Contap
(TheVertex as any;
TheArc as any)
---Purpose: Definition of a vertex on the contour line.
-- Most of the time, such a point is an intersection
-- between the contour and a restriction of the surface.
-- When it is not tyhe method IsOnArc return False.
-- Such a point is contains geometrical informations (see
-- the Value method) and logical informations.
uses Pnt from gp,
Transition from IntSurf
raises DomainError from Standard
is
Create
---Purpose: Empty constructor.
returns Point from Contap;
Create(Pt: Pnt from gp; U,V: Real from Standard)
---Purpose: Creates a point.
returns Point from Contap;
SetValue(me: in out; Pt: Pnt from gp; U,V: Real from Standard)
---Purpose: Sets the values for a point.
---C++: inline
is static;
SetParameter(me: in out; Para: Real from Standard)
---Purpose: Set the value of the parameter on the intersection line.
---C++: inline
is static;
SetVertex(me: in out; V: TheVertex)
---Purpose: Sets the values of a point which is a vertex on
-- the initial facet of restriction of one
-- of the surface.
---C++: inline
is static;
SetArc(me: in out; A: TheArc; Param: Real from Standard;
TLine,TArc: Transition from IntSurf)
---Purpose: Sets the value of the arc and of the parameter on
-- this arc of the point.
---C++: inline
is static;
SetMultiple(me: in out)
---C++: inline
is static;
SetInternal(me : in out)
---C++: inline
is static;
Value(me)
---Purpose: Returns the intersection point (geometric information).
returns Pnt from gp
---C++: return const&
---C++: inline
is static;
ParameterOnLine(me)
---Purpose: This method returns the parameter of the point
-- on the intersection line.
-- If the points does not belong to an intersection line,
-- the value returned does not have any sens.
returns Real from Standard
---C++: inline
is static;
Parameters(me; U1,V1: out Real from Standard)
---Purpose: Returns the parameters on the surface of the point.
---C++: inline
is static;
IsOnArc(me)
---Purpose: Returns True when the point is an intersection between
-- the contour and a restriction.
returns Boolean from Standard
---C++: inline
is static;
Arc(me)
---Purpose: Returns the arc of restriction containing the
-- vertex.
returns any TheArc
---C++: return const&
---C++: inline
raises DomainError from Standard
--- The exception DomianError is raised when IsOnArc
-- returns Standard_False.
is static;
ParameterOnArc(me)
---Purpose: Returns the parameter of the point on the
-- arc returned by the method Arc().
returns Real from Standard
---C++: inline
raises DomainError from Standard
--- The exception DomianError is raised when IsOnArc
-- returns Standard_False.
is static;
TransitionOnLine(me)
---Purpose: Returns the transition of the point on the contour.
returns Transition from IntSurf
---C++: inline
---C++: return const&
raises DomainError from Standard
--- The exception DomianError is raised when IsOnArc
-- returns Standard_False.
is static;
TransitionOnArc(me)
---Purpose: Returns the transition of the point on the arc.
returns Transition from IntSurf
---C++: inline
---C++: return const&
raises DomainError from Standard
--- The exception DomianError is raised when IsOnArc
-- returns Standard_False.
is static;
IsVertex(me)
---Purpose: Returns TRUE if the point is a vertex on the initial
-- restriction facet of the surface.
returns Boolean from Standard
---C++: inline
is static;
Vertex(me)
---Purpose: Returns the information about the point when it is
-- on the domain of the patch, i-e when the function
-- IsVertex returns True.
-- Otherwise, an exception is raised.
returns any TheVertex
---C++: return const&
---C++: inline
raises DomainError from Standard
is static;
IsMultiple(me)
---Purpose: Returns True if the point belongs to several
-- lines.
returns Boolean from Standard
---C++: inline
is static;
IsInternal(me)
---Purpose: Returns True if the point is an internal one, i.e
-- if the tangent to the line on the point and the
-- eye direction are parallel.
returns Boolean from Standard
---C++: inline
is static;
fields
pt : Pnt from gp;
uparam : Real from Standard;
vparam : Real from Standard;
paraline : Real from Standard;
onarc : Boolean from Standard;
arc : TheArc;
traline : Transition from IntSurf;
traarc : Transition from IntSurf;
prmarc : Real from Standard;
isvtx : Boolean from Standard;
vtx : TheVertex;
ismult : Boolean from Standard;
myInternal : Boolean from Standard;
end Point;

12
src/Contap/Contap_Point.gxx Executable file
View File

@@ -0,0 +1,12 @@
Contap_Point::Contap_Point ():
onarc(Standard_False),isvtx(Standard_False),ismult(Standard_False),
myInternal(Standard_False)
{}
Contap_Point::Contap_Point (const gp_Pnt& Pt,
const Standard_Real U,
const Standard_Real V):
pt(Pt),uparam(U),vparam(V),onarc(Standard_False),isvtx(Standard_False),
ismult(Standard_False),myInternal(Standard_False)
{}

115
src/Contap/Contap_Point.lxx Executable file
View File

@@ -0,0 +1,115 @@
#include <Standard_DomainError.hxx>
inline void Contap_Point::SetValue (const gp_Pnt& Pt,
const Standard_Real U,
const Standard_Real V)
{
pt = Pt;
uparam = U;
vparam = V;
onarc = Standard_False;
isvtx = Standard_False;
ismult= Standard_False;
myInternal = Standard_False;
}
inline void Contap_Point::SetParameter (const Standard_Real Para) {
paraline = Para;
}
inline void Contap_Point::SetVertex(const TheVertex& V) {
isvtx = Standard_True;
vtx = V;
}
inline void Contap_Point::SetArc (const TheArc& A,
const Standard_Real Param,
const IntSurf_Transition& TLine,
const IntSurf_Transition& TArc) {
onarc = Standard_True;
arc = A;
prmarc = Param;
traline = TLine;
traarc = TArc;
}
inline void Contap_Point::SetMultiple ()
{
ismult = Standard_True;
}
inline void Contap_Point::SetInternal ()
{
myInternal = Standard_True;
}
inline Standard_Boolean Contap_Point::IsMultiple () const
{
return ismult;
}
inline Standard_Boolean Contap_Point::IsInternal () const
{
return myInternal;
}
inline const gp_Pnt& Contap_Point::Value () const {
return pt;
}
inline Standard_Real Contap_Point::ParameterOnLine () const {
return paraline;
}
inline void Contap_Point::Parameters (Standard_Real& U1,
Standard_Real& V1) const {
U1 = uparam;
V1 = vparam;
}
inline Standard_Boolean Contap_Point::IsOnArc () const{
return onarc;
}
inline const TheArc& Contap_Point::Arc () const {
if (!onarc) {Standard_DomainError::Raise();}
return arc;
}
inline const IntSurf_Transition& Contap_Point::TransitionOnLine () const {
if (!onarc) {Standard_DomainError::Raise();}
return traline;
}
inline const IntSurf_Transition& Contap_Point::TransitionOnArc () const {
if (!onarc) {Standard_DomainError::Raise();}
return traarc;
}
inline Standard_Real Contap_Point::ParameterOnArc () const {
if (!onarc) {Standard_DomainError::Raise();}
return prmarc;
}
inline Standard_Boolean Contap_Point::IsVertex () const {
return isvtx;
}
inline const TheVertex& Contap_Point::Vertex () const {
if (!isvtx) {Standard_DomainError::Raise();}
return vtx;
}

View File

@@ -0,0 +1,228 @@
-- File: Contap_SurfFunction.cdl
-- Created: Thu Jun 3 15:23:20 1993
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1993
generic class SurfFunction from Contap
(TheSurface as any;
TheSurfaceTool as any;
TheSurfProps as any; -- as SurfProps from Contap(TheSurface,
-- TheSurfaceTool)
TheContTool as any)
inherits FunctionSetWithDerivatives from math
---Purpose: This class describes the function on a parametric surface.
-- the form of the function is F(u,v) = 0 where u and v are
-- the parameteric coordinates of a point on the surface,
-- to compute the contours of the surface.
uses Vector from math,
Matrix from math,
Pnt from gp,
Vec from gp,
Dir from gp,
Dir2d from gp,
TFunction from Contap
raises UndefinedDerivative from StdFail
is
Create
returns SurfFunction from Contap;
Set(me: in out; S: TheSurface)
is static;
Set(me: in out; Eye: Pnt from gp)
---C++: inline
is static;
Set(me: in out; Dir: Dir from gp)
---C++: inline
is static;
Set(me: in out; Dir: Dir from gp; Angle: Real from Standard)
---C++: inline
is static;
Set(me: in out; Eye: Pnt from gp; Angle: Real from Standard)
---C++: inline
is static;
Set(me: in out; Tolerance: Real from Standard)
---C++: inline
is static;
NbVariables(me)
---Purpose: This method has to return 2.
returns Integer from Standard;
NbEquations(me)
---Purpose: This method has to return 1.
returns Integer from Standard;
Value(me : in out; X : Vector from math;
F : out Vector from math)
---Purpose: The dimension of F is 1.
returns Boolean from Standard;
Derivatives(me : in out; X : Vector from math;
D : out Matrix from math)
---Purpose: The dimension of D is (1,2).
returns Boolean from Standard;
Values(me : in out; X : Vector from math;
F : out Vector from math;
D : out Matrix from math)
returns Boolean from Standard;
Root(me)
---Purpose: Root is the value of the function at the solution.
-- It is a vector of dimension 1, i-e a real.
returns Real from Standard
---C++: inline
is static;
Tolerance(me)
---Purpose: Returns the value Tol so that if Abs(Func.Root())<Tol
-- the function is considered null.
--
---C++: inline
returns Real from Standard
is static;
Point(me)
---Purpose: Returns the value of the solution point on the surface.
returns Pnt from gp
---C++: return const&
---C++: inline
is static;
IsTangent(me : in out)
returns Boolean from Standard
is static;
Direction3d(me: in out)
returns Vec from gp
---C++: return const&
---C++: inline
raises UndefinedDerivative from StdFail
is static;
Direction2d(me: in out)
returns Dir2d from gp
---C++: return const&
---C++: inline
raises UndefinedDerivative from StdFail
is static;
FunctionType(me)
returns TFunction from Contap
---C++: inline
is static;
Eye(me)
returns Pnt from gp
---C++: return const&
---C++: inline
is static;
Direction(me)
returns Dir from gp
---C++: return const&
---C++: inline
is static;
Angle(me)
returns Real from Standard
---C++: inline
is static;
Surface(me)
returns any TheSurface
---C++: return const&
---C++: inline
is static;
fields
mySurf : TheSurface;
myMean : Real from Standard;
myType : TFunction from Contap;
myDir : Dir from gp;
myEye : Pnt from gp;
myAng : Real from Standard;
myCosAng : Real from Standard;
tol : Real from Standard;
solpt : Pnt from gp;
valf : Real from Standard;
Usol : Real from Standard;
Vsol : Real from Standard;
Fpu : Real from Standard;
Fpv : Real from Standard;
d2d : Dir2d from gp;
d3d : Vec from gp;
tangent : Boolean from Standard;
computed : Boolean from Standard;
derived : Boolean from Standard;
end SurfFunction;

View File

@@ -0,0 +1,266 @@
// jag 940616 #define Tolpetit 1.e-16
#include <gp.hxx>
Contap_SurfFunction::Contap_SurfFunction ():
myMean(1.),
myType(Contap_ContourStd),
myDir(0.,0.,1.),
myCosAng(0.), // PI/2 - Angle de depouille
tol(1.e-6),
computed(Standard_False),
derived(Standard_False)
{}
void Contap_SurfFunction::Set(const TheSurface& S)
{
mySurf = S;
Standard_Integer i;
Standard_Integer nbs = TheContTool::NbSamplePoints(S);
Standard_Real U,V;
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);
}
computed = Standard_False;
derived = Standard_False;
}
Standard_Integer Contap_SurfFunction::NbVariables () const
{
return 2;
}
Standard_Integer Contap_SurfFunction::NbEquations () const
{
return 1;
}
Standard_Boolean Contap_SurfFunction::Value(const math_Vector& X,
math_Vector& F)
{
Usol = X(1); Vsol = X(2);
// TheSurfaceTool::D1(mySurf,Usol,Vsol,solpt,d1u,d1v);
// gp_Vec norm(d1u.Crossed(d1v));
gp_Vec norm;
TheSurfProps::Normale(mySurf,Usol,Vsol,solpt,norm);
switch (myType) {
case Contap_ContourStd:
{
F(1) = valf = (norm.Dot(myDir))/myMean;
}
break;
case Contap_ContourPrs:
{
F(1) = valf = (norm.Dot(gp_Vec(myEye,solpt)))/myMean;
}
break;
case Contap_DraftStd:
{
F(1) = valf = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
}
break;
default:
{
}
}
computed = Standard_False;
derived = Standard_False;
return Standard_True;
}
Standard_Boolean Contap_SurfFunction::Derivatives(const math_Vector& X,
math_Matrix& Grad)
{
// gp_Vec d2u,d2v,d2uv;
Usol = X(1); Vsol = X(2);
// TheSurfaceTool::D2(mySurf,Usol,Vsol,solpt,d1u,d1v,d2u,d2v,d2uv);
gp_Vec norm,dnu,dnv;
TheSurfProps::NormAndDn(mySurf,Usol,Vsol,solpt,norm,dnu,dnv);
switch (myType) {
case Contap_ContourStd:
{
// Grad(1,1) = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
// Grad(1,2) = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
Grad(1,1) = (dnu.Dot(myDir))/myMean;
Grad(1,2) = (dnv.Dot(myDir))/myMean;
}
break;
case Contap_ContourPrs:
{
gp_Vec Ep(myEye,solpt);
Grad(1,1) = (dnu.Dot(Ep))/myMean;
Grad(1,2) = (dnv.Dot(Ep))/myMean;
}
break;
case Contap_DraftStd:
{
// gp_Vec norm(d1u.Crossed(d1v).Normalized());
// gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
// Grad(1,1) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
// dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
// Grad(1,2) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
norm.Normalize();
Grad(1,1) = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
Grad(1,2) = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
}
break;
case Contap_DraftPrs:
default:
{
}
}
Fpu = Grad(1,1); Fpv = Grad(1,2);
computed = Standard_False;
derived = Standard_True;
return Standard_True;
}
Standard_Boolean Contap_SurfFunction::Values (const math_Vector& X,
math_Vector& F,
math_Matrix& Grad)
{
// gp_Vec d2u,d2v,d2uv;
Usol = X(1); Vsol = X(2);
// TheSurfaceTool::D2(mySurf,Usol,Vsol,solpt,d1u,d1v,d2u,d2v,d2uv);
// gp_Vec norm(d1u.Crossed(d1v));
gp_Vec norm,dnu,dnv;
TheSurfProps::NormAndDn(mySurf,Usol,Vsol,solpt,norm,dnu,dnv);
switch (myType) {
case Contap_ContourStd:
{
F(1) = (norm.Dot(myDir))/myMean;
// Grad(1,1) = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
// Grad(1,2) = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
Grad(1,1) = (dnu.Dot(myDir))/myMean;
Grad(1,2) = (dnv.Dot(myDir))/myMean;
}
break;
case Contap_ContourPrs:
{
gp_Vec Ep(myEye,solpt);
F(1) = (norm.Dot(Ep))/myMean;
// Grad(1,1) = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
// Grad(1,2) = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
Grad(1,1) = (dnu.Dot(Ep))/myMean;
Grad(1,2) = (dnv.Dot(Ep))/myMean;
}
break;
case Contap_DraftStd:
{
F(1) = (norm.Dot(myDir)-myCosAng*norm.Magnitude())/myMean;
norm.Normalize();
/*
gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
Grad(1,1) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
Grad(1,2) = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
*/
Grad(1,1) = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
Grad(1,2) = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
}
break;
case Contap_DraftPrs:
default:
{
}
}
valf = F(1);
Fpu = Grad(1,1); Fpv = Grad(1,2);
computed = Standard_False;
derived = Standard_True;
return Standard_True;
}
Standard_Boolean Contap_SurfFunction::IsTangent ()
{
if (!computed) {
computed = Standard_True;
if(!derived) {
// gp_Vec d2u,d2v,d2uv;
// TheSurfaceTool::D2(mySurf, Usol, Vsol, solpt, d1u, d1v, d2u, d2v, d2uv);
gp_Vec norm,dnu,dnv;
TheSurfProps::NormAndDn(mySurf,Usol,Vsol,solpt,norm,dnu,dnv);
switch (myType) {
case Contap_ContourStd:
{
// Fpu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(myDir))/myMean;
// Fpv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(myDir))/myMean;
Fpu = (dnu.Dot(myDir))/myMean;
Fpv = (dnv.Dot(myDir))/myMean;
}
break;
case Contap_ContourPrs:
{
gp_Vec Ep(myEye,solpt);
// Fpu = ((d2u.Crossed(d1v) + d1u.Crossed(d2uv)).Dot(Ep))/myMean;
// Fpv = ((d2uv.Crossed(d1v) + d1u.Crossed(d2v)).Dot(Ep))/myMean;
Fpu = (dnu.Dot(Ep))/myMean;
Fpv = (dnv.Dot(Ep))/myMean;
}
break;
case Contap_DraftStd:
{
/*
gp_Vec norm(d1u.Crossed(d1v).Normalized());
gp_Vec dnorm(d2u.Crossed(d1v) + d1u.Crossed(d2uv));
Fpu = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
dnorm = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
Fpv = (dnorm.Dot(myDir)-myCosAng*dnorm.Dot(norm))/myMean;
*/
norm.Normalize();
Fpu = (dnu.Dot(myDir)-myCosAng*dnu.Dot(norm))/myMean;
Fpv = (dnv.Dot(myDir)-myCosAng*dnv.Dot(norm))/myMean;
}
break;
case Contap_DraftPrs:
default:
{
}
}
derived = Standard_True;
}
tangent = Standard_False;
Standard_Real D = Sqrt (Fpu * Fpu + Fpv * Fpv);
if (D <= gp::Resolution()) {
tangent = Standard_True;
}
else {
d2d = gp_Dir2d(-Fpv,Fpu);
gp_Vec d1u,d1v;
TheSurfaceTool::D1(mySurf, Usol, Vsol, solpt, d1u, d1v); // ajout jag 02.95
gp_XYZ d3dxyz(-Fpv*d1u.XYZ());
d3dxyz.Add(Fpu*d1v.XYZ());
d3d.SetXYZ(d3dxyz);
//jag 940616 if (d3d.Magnitude() <= Tolpetit) {
if (d3d.Magnitude() <= tol) {
tangent = Standard_True;
}
}
}
return tangent;
}

View File

@@ -0,0 +1,90 @@
#include <StdFail_UndefinedDerivative.hxx>
inline void Contap_SurfFunction::Set(const gp_Pnt& Eye)
{
myType = Contap_ContourPrs; // pers
myEye = Eye;
myAng = 0.;
}
inline void Contap_SurfFunction::Set(const gp_Dir& Direction)
{
myType = Contap_ContourStd; // Contour app
myDir = Direction;
myAng = 0.;
}
inline void Contap_SurfFunction::Set(const gp_Dir& Direction,
const Standard_Real Angle)
{
myType = Contap_DraftStd; // Contour vu
myDir = Direction;
myAng = Angle;
myCosAng = Cos(PI/2.+Angle);
}
inline void Contap_SurfFunction::Set(const gp_Pnt& Eye,
const Standard_Real Angle)
{
myType = Contap_DraftPrs; // Contour vu "conique"...
myEye = Eye;
myAng = Angle;
myCosAng = Cos(PI/2.+Angle);
}
inline void Contap_SurfFunction::Set(const Standard_Real Tolerance)
{
tol = Max(Tolerance, 1.e-12);
}
inline const gp_Pnt& Contap_SurfFunction::Point () const
{
return solpt;
}
inline Standard_Real Contap_SurfFunction::Root () const
{
return valf;
}
inline Standard_Real Contap_SurfFunction::Tolerance () const
{
return tol;
}
inline const gp_Vec& Contap_SurfFunction::Direction3d()
{
if (IsTangent()) StdFail_UndefinedDerivative::Raise();
return d3d;
}
inline const gp_Dir2d& Contap_SurfFunction::Direction2d()
{
if (IsTangent()) StdFail_UndefinedDerivative::Raise();
return d2d;
}
inline const TheSurface& Contap_SurfFunction::Surface() const
{
return mySurf;
}
inline const gp_Pnt& Contap_SurfFunction::Eye() const
{
return myEye;
}
inline const gp_Dir& Contap_SurfFunction::Direction() const
{
return myDir;
}
inline Standard_Real Contap_SurfFunction::Angle () const
{
return myAng;
}
inline Contap_TFunction Contap_SurfFunction::FunctionType () const
{
return myType;
}

47
src/Contap/Contap_SurfProps.cdl Executable file
View File

@@ -0,0 +1,47 @@
-- File: Contap_SurfProps.cdl
-- Created: Fri Feb 24 15:30:15 1995
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1995
generic class SurfProps from Contap
(TheSurface as any;
TheSurfaceTool as any) -- as SurfaceTool from Contap
---Purpose: Internal tool used to compute the normal and its
-- derivatives.
uses Pnt from gp,
Vec from gp
is
Normale(myclass; S: TheSurface; U,V: Real from Standard;
P: out Pnt from gp;
N: out Vec from gp);
---Purpose: Computes the point <P>, and normal vector <N> on
-- <S> at parameters U,V.
DerivAndNorm(myclass; S: TheSurface; U,V: Real from Standard;
P : out Pnt from gp;
d1u,d1v: out Vec from gp;
N : out Vec from gp);
---Purpose: Computes the point <P>, and normal vector <N> on
-- <S> at parameters U,V.
NormAndDn(myclass; S: TheSurface; U,V: Real from Standard;
P : out Pnt from gp;
N,Dnu,Dnv: out Vec from gp);
---Purpose: Computes the point <P>, normal vector <N>, and its
-- derivatives <Dnu> and <Dnv> on <S> at parameters U,V.
end SurfProps;

324
src/Contap/Contap_SurfProps.gxx Executable file
View File

@@ -0,0 +1,324 @@
// File: Contap_SurfProps.gxx
// Created: Fri Feb 24 15:37:28 1995
// Author: Jacques GOUSSARD
// <jag@topsn2>
#include <ElSLib.hxx>
//=======================================================================
//function : Normale
//purpose :
//=======================================================================
void Contap_SurfProps::Normale(const TheSurface& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& Norm)
{
GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(S);
switch (typS) {
case GeomAbs_Plane:
{
gp_Pln pl(TheSurfaceTool::Plane(S));
Norm = pl.Axis().Direction();
P = ElSLib::Value(U,V,pl);
if (!pl.Direct()) {
Norm.Reverse();
}
}
break;
case GeomAbs_Sphere:
{
gp_Sphere sp(TheSurfaceTool::Sphere(S));
P = ElSLib::Value(U,V,sp);
Norm = gp_Vec(sp.Location(),P);
if (sp.Direct()) {
Norm.Divide(sp.Radius());
}
else {
Norm.Divide(-sp.Radius());
}
}
break;
case GeomAbs_Cylinder:
{
gp_Cylinder cy(TheSurfaceTool::Cylinder(S));
P = ElSLib::Value(U,V,cy);
Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
Sin(U),cy.YAxis().Direction());
if (!cy.Direct()) {
Norm.Reverse();
}
}
break;
case GeomAbs_Cone:
{
gp_Cone co(TheSurfaceTool::Cone(S));
P = ElSLib::Value(U,V,co);
Standard_Real Angle = co.SemiAngle();
Standard_Real Sina = sin(Angle);
Standard_Real Cosa = cos(Angle);
Standard_Real Rad = co.RefRadius();
Standard_Real Vcalc = V;
if (Abs(V*Sina + Rad) <= 1e-12) { // on est a l`apex
/*
Standard_Real Vfi = TheSurfaceTool::FirstVParameter(S);
if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
Vcalc = V - 1;
}
else {
Vcalc = V + 1.;
}
*/
Norm.SetCoord(0,0,0);
return;
}
if (Rad + Vcalc*Sina < 0.) {
Norm.SetLinearForm(Sina, co.Axis().Direction(),
Cosa*cos(U),co.XAxis().Direction(),
Cosa*sin(U),co.YAxis().Direction());
}
else {
Norm.SetLinearForm(-Sina, co.Axis().Direction(),
Cosa*cos(U),co.XAxis().Direction(),
Cosa*sin(U),co.YAxis().Direction());
}
if (!co.Direct()) {
Norm.Reverse();
}
}
break;
default:
{
gp_Vec d1u,d1v;
TheSurfaceTool::D1(S,U,V,P,d1u,d1v);
Norm = d1u.Crossed(d1v);
}
break;
}
}
//=======================================================================
//function : DerivAndNorm
//purpose :
//=======================================================================
void Contap_SurfProps::DerivAndNorm(const TheSurface& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& d1u,
gp_Vec& d1v,
gp_Vec& Norm)
{
GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(S);
switch (typS) {
case GeomAbs_Plane:
{
gp_Pln pl(TheSurfaceTool::Plane(S));
Norm = pl.Axis().Direction();
ElSLib::D1(U,V,pl,P,d1u,d1v);
if (!pl.Direct()) {
Norm.Reverse();
}
}
break;
case GeomAbs_Sphere:
{
gp_Sphere sp(TheSurfaceTool::Sphere(S));
ElSLib::D1(U,V,sp,P,d1u,d1v);
Norm = gp_Vec(sp.Location(),P);
if (sp.Direct()) {
Norm.Divide(sp.Radius());
}
else {
Norm.Divide(-sp.Radius());
}
}
break;
case GeomAbs_Cylinder:
{
gp_Cylinder cy(TheSurfaceTool::Cylinder(S));
ElSLib::D1(U,V,cy,P,d1u,d1v);
Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
Sin(U),cy.YAxis().Direction());
if (!cy.Direct()) {
Norm.Reverse();
}
}
break;
case GeomAbs_Cone:
{
gp_Cone co(TheSurfaceTool::Cone(S));
ElSLib::D1(U,V,co,P,d1u,d1v);
Standard_Real Angle = co.SemiAngle();
Standard_Real Sina = Sin(Angle);
Standard_Real Cosa = Cos(Angle);
Standard_Real Rad = co.RefRadius();
Standard_Real Vcalc = V;
if (Abs(V*Sina + Rad) <= RealEpsilon()) { // on est a l`apex
Standard_Real Vfi = TheSurfaceTool::FirstVParameter(S);
if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
Vcalc = V - 1;
}
else {
Vcalc = V + 1.;
}
}
if (Rad + Vcalc*Sina < 0.) {
Norm.SetLinearForm(Sina, co.Axis().Direction(),
Cosa*Cos(U),co.XAxis().Direction(),
Cosa*Sin(U),co.YAxis().Direction());
}
else {
Norm.SetLinearForm(-Sina, co.Axis().Direction(),
Cosa*Cos(U),co.XAxis().Direction(),
Cosa*Sin(U),co.YAxis().Direction());
}
if (!co.Direct()) {
Norm.Reverse();
}
}
break;
default:
{
TheSurfaceTool::D1(S,U,V,P,d1u,d1v);
Norm = d1u.Crossed(d1v);
}
break;
}
}
//=======================================================================
//function : NormAndDn
//purpose :
//=======================================================================
void Contap_SurfProps::NormAndDn(const TheSurface& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Vec& Norm,
gp_Vec& Dnu,
gp_Vec& Dnv)
{
GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(S);
switch (typS) {
case GeomAbs_Plane:
{
gp_Pln pl(TheSurfaceTool::Plane(S));
P = ElSLib::Value(U,V,pl);
Norm = pl.Axis().Direction();
if (!pl.Direct()) {
Norm.Reverse();
}
Dnu = Dnv = gp_Vec(0.,0.,0.);
}
break;
case GeomAbs_Sphere:
{
gp_Sphere sp(TheSurfaceTool::Sphere(S));
ElSLib::D1(U,V,sp,P,Dnu,Dnv);
Norm = gp_Vec(sp.Location(),P);
Standard_Real Rad = sp.Radius();
if (!sp.Direct()) {
Rad = -Rad;
}
Norm.Divide(Rad);
Dnu.Divide(Rad);
Dnv.Divide(Rad);
}
break;
case GeomAbs_Cylinder:
{
gp_Cylinder cy(TheSurfaceTool::Cylinder(S));
P = ElSLib::Value(U,V,cy);
Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
Sin(U),cy.YAxis().Direction());
Dnu.SetLinearForm(-Sin(U),cy.XAxis().Direction(),
Cos(U),cy.YAxis().Direction());
if (!cy.Direct()) {
Norm.Reverse();
Dnu.Reverse();
}
Dnv = gp_Vec(0.,0.,0.);
}
break;
case GeomAbs_Cone:
{
gp_Cone co(TheSurfaceTool::Cone(S));
P = ElSLib::Value(U,V,co);
Standard_Real Angle = co.SemiAngle();
Standard_Real Sina = Sin(Angle);
Standard_Real Cosa = Cos(Angle);
Standard_Real Rad = co.RefRadius();
Standard_Real Vcalc = V;
if (Abs(V*Sina + Rad) <= RealEpsilon()) { // on est a l`apex
Standard_Real Vfi = TheSurfaceTool::FirstVParameter(S);
if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
Vcalc = V - 1;
}
else {
Vcalc = V + 1.;
}
}
if (Rad + Vcalc*Sina < 0.) {
Norm.SetLinearForm(Sina, co.Axis().Direction(),
Cosa*Cos(U),co.XAxis().Direction(),
Cosa*Sin(U),co.YAxis().Direction());
}
else {
Norm.SetLinearForm(-Sina, co.Axis().Direction(),
Cosa*Cos(U),co.XAxis().Direction(),
Cosa*Sin(U),co.YAxis().Direction());
}
Dnu.SetLinearForm(-Cosa*Sin(U),co.XAxis().Direction(),
Cosa*Cos(U),co.YAxis().Direction());
if (!co.Direct()) {
Norm.Reverse();
Dnu.Reverse();
}
Dnv = gp_Vec(0.,0.,0.);
}
break;
default:
{
gp_Vec d1u,d1v,d2u,d2v,d2uv;
TheSurfaceTool::D2(S,U,V,P,d1u,d1v,d2u,d2v,d2uv);
Norm = d1u.Crossed(d1v);
Dnu = d2u.Crossed(d1v) + d1u.Crossed(d2uv);
Dnv = d2uv.Crossed(d1v) + d1u.Crossed(d2v);
}
break;
}
}

134
src/Contap/Contap_SurfaceTool.cdl Executable file
View File

@@ -0,0 +1,134 @@
-- File: Contap_SurfaceTool.cdl
-- Created: Wed May 12 09:11:00 1993
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1993
deferred generic class SurfaceTool from Contap
(TheSurface as any)
---Purpose: Template class for a tool on a surface.
-- It is possible to implement this class with an
-- instantiation of the Surface2Tool from Adaptor3d.
uses SurfaceType from GeomAbs,
Pln from gp,
Sphere from gp,
Cylinder from gp,
Cone from gp,
Pnt from gp,
Vec from gp
is
GetType(myclass; S: TheSurface)
returns SurfaceType from GeomAbs;
Plane(myclass; S: TheSurface)
---Purpose: Returns the plane from gp when GetType returns
-- GeomAbs_Plane.
returns Pln from gp;
Cylinder(myclass; S: TheSurface)
---Purpose: Returns the cylinder from gp when GetType returns
-- GeomAbs_Cylinder.
returns Cylinder from gp;
Sphere(myclass; S: TheSurface)
---Purpose: Returns the sphere from gp when GetType returns
-- GeomAbs_Sphere.
returns Sphere from gp;
Cone(myclass; S: TheSurface)
---Purpose: Returns the cone from gp when GetType returns
-- GeomAbs_Cone.
returns Cone from gp;
UIntervalFirst(myclass ; S: TheSurface)
---Purpose: Returns the first U parameter of the surface.
returns Real from Standard;
VIntervalFirst(myclass ; S: TheSurface)
---Purpose: Returns the first V parameter of the surface.
returns Real from Standard;
UIntervalLast(myclass ; S: TheSurface)
---Purpose: Returns the last U parameter of the surface.
returns Real from Standard;
VIntervalLast(myclass ; S: TheSurface)
---Purpose: Returns the last V parameter of the surface.
returns Real from Standard;
Value (myclass ; S: TheSurface;
U,V : Real from Standard)
---Purpose: Returns the point of parameter (U,V) on the surface.
returns Pnt from gp;
D1(myclass; S: TheSurface; U,V: Real from Standard;
P: out Pnt from gp; D1U,D1V: out Vec from gp);
---Purpose: Returns the point of parameter (U,V) on the surface,
-- and the first derivatives in the directions u and v.
D2(myclass; S: TheSurface; U,V: Real from Standard; P: out Pnt from gp;
D1U,D1V,D2U,D2V,D2UV: out Vec from gp);
---Purpose: Returns the point of parameter (U,V) on the surface,
-- and the first and the second derivatives in the
-- directions u and v.
UResolution(myclass; S : TheSurface; Tol3d: Real from Standard)
---Purpose: Returns the numerical resolution in the U direction,
-- for a given resolution in 3d space.
returns Real from Standard;
VResolution(myclass; S : TheSurface; Tol3d: Real from Standard)
---Purpose: Returns the numerical resolution in the V direction,
-- for a given resolution in 3d space.
returns Real from Standard;
end SurfaceTool;

View File

103
src/Contap/Contap_TopolTool.cdl Executable file
View File

@@ -0,0 +1,103 @@
-- File: Contap_TopolTool.cdl
-- Created: Wed May 12 09:16:05 1993
-- Author: Jacques GOUSSARD
-- <jag@topsn2>
---Copyright: Matra Datavision 1993
deferred generic class TopolTool from Contap
( TheVertex as any;
TheArc as any
)
inherits TShared from MMgt
---Purpose: Template class for an iterator the restriction of
-- a surface.
uses Orientation from TopAbs,
State from TopAbs,
Pnt2d from gp
is
-- Arc iterator
Init(me: mutable)
;
More(me: mutable)
returns Boolean from Standard
;
Value(me: mutable)
returns any TheArc
;
Next(me: mutable)
;
-- Iterator on the vertex of an arc of restriction
Initialize(me: mutable; A:TheArc);
InitVertexIterator(me: mutable)
;
MoreVertex(me: mutable)
returns Boolean from Standard
;
Vertex(me: mutable)
returns any TheVertex
;
NextVertex(me: mutable)
;
Orientation(me: mutable; A: TheArc)
returns Orientation from TopAbs;
Orientation(me: mutable; V: TheVertex)
returns Orientation from TopAbs;
Identical(me: mutable; V1,V2: TheVertex)
---Purpose: Returns True if the vertices V1 and V2 are identical.
-- This method does not take the orientation of the
-- vertices in account.
returns Boolean from Standard;
Classify(me: mutable; P: Pnt2d from gp; Tol: Real from Standard)
returns State from TopAbs;
end TopolTool;

View File

3
src/Contap/FILES Executable file
View File

@@ -0,0 +1,3 @@
Contap_ContourGen_1.gxx
Contap_ContourGen_2.gxx
Contap_ContourGen_3.gxx