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

7
src/GeomliteTest/FILES Executable file
View File

@@ -0,0 +1,7 @@
GeomliteTest_API2dCommands.cxx
GeomliteTest_ApproxCommands.cxx
GeomliteTest_CurveCommands.cxx
GeomliteTest_SurfaceCommands.cxx
GeomliteTest_ModificationCommands.cxx

View File

@@ -0,0 +1,45 @@
-- File: GeometryTest.cdl
-- Created: Mon Jun 24 11:23:25 1991
-- Author: Christophe MARION
-- <cma@phobox>
-- modified by jct (15/04/97) add of ModificationCommands
---Copyright: Matra Datavision 1991
package GeomliteTest
---Purpose: this package provides elementary commands for curves and
-- surface.
uses
Draw,
Standard
is
AllCommands(I : in out Interpretor from Draw);
---Purpose: defines all geometric commands.
CurveCommands(I : in out Interpretor from Draw);
---Purpose: defines curve commands.
SurfaceCommands(I : in out Interpretor from Draw);
---Purpose: defines surface commands.
API2dCommands(I : in out Interpretor from Draw);
---Purpose: defines commands to test the Geom2dAPI
-- - Intersection
-- - Extrema
-- - Projection
-- - Approximation, interpolation
ApproxCommands(I : in out Interpretor from Draw);
---Purpose: defines constrained curves commands.
ModificationCommands(I : in out Interpretor from Draw);
---Purpose: defines curves and surfaces modification commands.
-- - Curve extension to point
-- - Surface extension by length
end GeomliteTest;

View File

@@ -0,0 +1,28 @@
// File: GeometryTest.cxx
// Created: Mon Jul 25 19:06:50 1994
// Author: Remi LEQUETTE
// <rle@bravox>
// modified by jct (15.04.97) ajout de ModificationCommands
#include <GeomliteTest.hxx>
#include <Standard_Boolean.hxx>
#include <Draw_Interpretor.hxx>
void GeomliteTest::AllCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
GeomliteTest::CurveCommands(theCommands);
GeomliteTest::SurfaceCommands(theCommands);
GeomliteTest::ApproxCommands(theCommands);
GeomliteTest::API2dCommands(theCommands);
GeomliteTest::ModificationCommands(theCommands);
// define the TCL variable Draw_GEOMETRY
//char* com = "set Draw_GEOMETRY 1";
//theCommands.Eval(com);
}

View File

@@ -0,0 +1,342 @@
// File: GeometryTest_API2dCommands.cxx
// Created: Wed Jan 11 10:33:13 1995
// Author: Remi LEQUETTE
// <rle@bravox>
// modified : pmn 11/04/97 : mis dans GeomliteTest
#include <GeomliteTest.hxx>
#include <Geom2d_Curve.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <DrawTrSurf.hxx>
#include <Draw_Appli.hxx>
#include <DrawTrSurf_Curve2d.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <Geom2dAPI_ExtremaCurveCurve.hxx>
#include <Geom2dAPI_PointsToBSpline.hxx>
#include <Geom2dAPI_InterCurveCurve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <gp_Pnt.hxx>
#include <Draw_Marker2D.hxx>
#include <Draw_Color.hxx>
#include <Draw_MarkerShape.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <GeomAbs_Shape.hxx>
#include <Precision.hxx>
#include <stdio.h>
#ifdef WNT
Standard_IMPORT Draw_Viewer dout;
#endif
//=======================================================================
//function : proj
//purpose :
//=======================================================================
static Standard_Integer proj (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if ( n < 4) return 1;
gp_Pnt2d P(atof(a[2]),atof(a[3]));
char name[100];
Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(a[1]);
if (GC.IsNull())
return 1;
Geom2dAPI_ProjectPointOnCurve proj(P,GC,GC->FirstParameter(),
GC->LastParameter());
for ( Standard_Integer i = 1; i <= proj.NbPoints(); i++) {
gp_Pnt2d P1 = proj.Point(i);
Handle(Geom2d_Line) L = new Geom2d_Line(P,gp_Vec2d(P,P1));
Handle(Geom2d_TrimmedCurve) CT =
new Geom2d_TrimmedCurve(L, 0., P.Distance(P1));
sprintf(name,"%s%d","ext_",i);
char* temp = name; // portage WNT
DrawTrSurf::Set(temp, CT);
di << name << " ";
}
return 0;
}
//=======================================================================
//function : appro
//purpose :
//=======================================================================
static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
// Approximation et interpolation 2d
// 2dappro
// - affiche la tolerance
// 2dappro tol
// - change la tolerance
// 2dappro result nbpoint
// - saisie interactive
// 2dappro result nbpoint curve
// - calcule des points sur la courbe
// 2dappro result nbpoint x1 y1 x2 y2 ..
// - tableau de points
// 2dappro result nbpoint x1 dx y1 y2 ..
// - tableau de points (x1,y1) (x1+dx,y2) ... avec x = t
static Standard_Real Tol2d = 1.e-6;
if (n < 3) {
if (n == 2)
Tol2d = atof(a[1]);
di << "Tolerance for 2d approx : "<< Tol2d << "\n";
return 0;
}
Standard_Integer i, Nb = atoi(a[2]);
Standard_Boolean hasPoints = Standard_True;
TColgp_Array1OfPnt2d Points(1, Nb);
TColStd_Array1OfReal YValues(1,Nb);
Standard_Real X0=0,DX=0;
Handle(Draw_Marker2D) mark;
if (n == 3) {
// saisie interactive
Standard_Integer id,XX,YY,b;
dout.Select(id,XX,YY,b);
Standard_Real zoom = dout.Zoom(id);
Points(1) = gp_Pnt2d( ((Standard_Real)XX)/zoom,
((Standard_Real)YY)/zoom );
mark = new Draw_Marker2D( Points(1), Draw_X, Draw_vert);
dout << mark;
for (i = 2; i<=Nb; i++) {
dout.Select(id,XX,YY,b);
Points(i) = gp_Pnt2d( ((Standard_Real)XX)/zoom,
((Standard_Real)YY)/zoom );
mark = new Draw_Marker2D( Points(i), Draw_X, Draw_vert);
dout << mark;
}
}
else {
if ( n == 4) {
// points sur courbe
Handle(Geom2d_Curve) GC = DrawTrSurf::GetCurve2d(a[3]);
if ( GC.IsNull())
return 1;
Standard_Real U, U1, U2;
U1 = GC->FirstParameter();
U2 = GC->LastParameter();
Standard_Real Delta = ( U2 - U1) / (Nb-1);
for ( i = 1 ; i <= Nb; i++) {
U = U1 + (i-1) * Delta;
Points(i) = GC->Value(U);
}
}
else {
// test points ou ordonnees
hasPoints = Standard_False;
Standard_Integer nc = n - 3;
if (nc == 2 * Nb) {
// points
nc = 3;
for (i = 1; i <= Nb; i++) {
Points(i).SetCoord(atof(a[nc]),atof(a[nc+1]));
nc += 2;
}
}
else if (nc - 2 == Nb) {
// YValues
nc = 5;
X0 = atof(a[3]);
DX = atof(a[4]);
for (i = 1; i <= Nb; i++) {
YValues(i) = atof(a[nc]);
Points(i).SetCoord(X0+(i-1)*DX,YValues(i));
nc++;
}
}
else
return 1;
}
// display the points
for ( i = 1 ; i <= Nb; i++) {
mark = new Draw_Marker2D( Points(i), Draw_X, Draw_vert);
dout << mark;
}
}
dout.Flush();
Standard_Integer Dmin = 3;
Standard_Integer Dmax = 8;
Handle(Geom2d_BSplineCurve) TheCurve;
if (hasPoints)
TheCurve = Geom2dAPI_PointsToBSpline(Points,Dmin,Dmax,GeomAbs_C2,Tol2d);
else
TheCurve = Geom2dAPI_PointsToBSpline(YValues,X0,DX,Dmin,Dmax,GeomAbs_C2,Tol2d);
DrawTrSurf::Set(a[1], TheCurve);
di << a[1];
return 0;
}
//=======================================================================
//function : extrema
//purpose :
//=======================================================================
static Standard_Integer extrema(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if ( n<3) return 1;
Handle(Geom2d_Curve) GC1, GC2;
Standard_Real U1f,U1l,U2f,U2l;
GC1 = DrawTrSurf::GetCurve2d(a[1]);
if ( GC1.IsNull())
return 1;
U1f = GC1->FirstParameter();
U1l = GC1->LastParameter();
GC2 = DrawTrSurf::GetCurve2d(a[2]);
if ( GC2.IsNull())
return 1;
U2f = GC2->FirstParameter();
U2l = GC2->LastParameter();
char name[100];
Geom2dAPI_ExtremaCurveCurve Ex(GC1,GC2,U1f,U1l,U2f,U2l);
// modified by APV (compilation error - LINUX)
// for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++) {
Standard_Integer i;
for ( i = 1; i <= Ex.NbExtrema(); i++) {
// modified by APV (compilation error - LINUX)
gp_Pnt2d P1,P2;
Ex.Points(i,P1,P2);
di << "dist " << i << ": " << Ex.Distance(i) << " \n";
if (Ex.Distance(i) <= Precision::PConfusion()) {
Handle(Draw_Marker2D) mark = new Draw_Marker2D( P1, Draw_X, Draw_vert);
dout << mark;
dout.Flush();
}
else {
Handle(Geom2d_Line) L = new Geom2d_Line(P1,gp_Vec2d(P1,P2));
Handle(Geom2d_TrimmedCurve) CT =
new Geom2d_TrimmedCurve(L, 0., P1.Distance(P2));
sprintf(name,"%s%d","ext_",i);
char* temp = name; // portage WNT
DrawTrSurf::Set(temp, CT);
di << name << " ";
}
}
if (i==1)
di << "No decisions ";
return 0;
}
//=======================================================================
//function : intersect
//purpose :
//=======================================================================
static Standard_Integer intersect(Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
{
if( n < 2)
return 1;
Handle(Geom2d_Curve) C1 = DrawTrSurf::GetCurve2d(a[1]);
if ( C1.IsNull())
return 1;
Standard_Real Tol = 0.001;
Geom2dAPI_InterCurveCurve Intersector;
Handle(Geom2d_Curve) C2;
if ( n == 3) {
C2 = DrawTrSurf::GetCurve2d(a[2]);
if ( C2.IsNull())
return 1;
Intersector.Init(C1,C2,Tol);
}
else {
Intersector.Init(C1, Tol);
}
Standard_Integer i;
for ( i = 1; i <= Intersector.NbPoints(); i++) {
gp_Pnt2d P = Intersector.Point(i);
Handle(Draw_Marker2D) mark = new Draw_Marker2D( P, Draw_X, Draw_vert);
dout << mark;
}
dout.Flush();
Handle(Geom2d_Curve) S1,S2;
Handle(DrawTrSurf_Curve2d) CD;
if ( n == 3) {
for ( i = 1; i <= Intersector.NbSegments(); i++) {
Intersector.Segment(i,S1,S2);
CD = new DrawTrSurf_Curve2d(S1, Draw_bleu, 30);
dout << CD;
CD = new DrawTrSurf_Curve2d(S2, Draw_violet, 30);
dout << CD;
}
}
dout.Flush();
return 0;
}
void GeomliteTest::API2dCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
const char *g;
done = Standard_True;
g = "GEOMETRY curves and surfaces analysis";
theCommands.Add("2dproj", "proj curve x y",__FILE__, proj,g);
g = "GEOMETRY approximations";
theCommands.Add("2dapprox", "2dapprox result nbpoint [curve] [[x] y [x] y...]",__FILE__,
appro,g);
theCommands.Add("2dinterpole", "2dinterpole result nbpoint [curve] [[x] y [x] y ...]",__FILE__,
appro,g);
g = "GEOMETRY curves and surfaces analysis";
theCommands.Add("2dextrema", "extrema curve curve",__FILE__,
extrema,g);
g = "GEOMETRY intersections";
theCommands.Add("2dintersect", "intersect curve curve",__FILE__,
intersect,g);
}

View File

@@ -0,0 +1,752 @@
// File: GeomliteTest_ApproxCommands
// Created: Thu Aug 12 19:33:52 1993
// Author: Bruno DUMORTIER
// <dub@topsn3>
// PMN : Ajout de la commande smooth
// PMN : 11/07/97 Passage a GeomliteTest de bsmooth.
#include <Standard_Stream.hxx>
#include <GeomliteTest.hxx>
#include <DrawTrSurf.hxx>
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <Draw_Interpretor.hxx>
#include <Precision.hxx>
#include <Draw_Marker3D.hxx>
#include <Draw_Marker2D.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_BezierCurve.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <TColgp_SequenceOfPnt2d.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <DrawTrSurf_BSplineCurve.hxx>
#include <DrawTrSurf_BezierCurve.hxx>
#include <DrawTrSurf_BSplineCurve2d.hxx>
#include <DrawTrSurf_BezierCurve2d.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_HArray1OfVec.hxx>
#include <TColgp_Array1OfVec.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfBoolean.hxx>
#include <Handle_TColStd_HArray1OfReal.hxx>
#include <Handle_TColStd_HArray1OfBoolean.hxx>
#include <AppParCurves_MultiBSpCurve.hxx>
#include <AppParCurves_MultiCurve.hxx>
#include <AppDef_MultiLine.hxx>
#include <AppDef_TheVariational.hxx>
#include <AppDef_Compute.hxx>
#include <AppParCurves_HArray1OfConstraintCouple.hxx>
#include <AppParCurves_ConstraintCouple.hxx>
#include <AppDef_HArray1OfMultiPointConstraint.hxx>
#include <AppDef_Array1OfMultiPointConstraint.hxx>
#include <math_Vector.hxx>
#ifdef WNT
#include <stdio.h>
Standard_IMPORT Draw_Viewer dout;
#endif
//Draw_Color DrawTrSurf_CurveColor(const Draw_Color);
//=======================================================================
//function : NbConstraint
//=======================================================================
static Standard_Integer NbConstraint(const AppParCurves_Constraint C1,
const AppParCurves_Constraint C2)
{
Standard_Integer N =0;
switch (C1) {
case AppParCurves_PassPoint :
{
N = 1;
break;
}
case AppParCurves_TangencyPoint :
{
N =2;
break;
}
case AppParCurves_CurvaturePoint :
{
N = 3;
break;
}
#ifndef DEB
default:
break;
#endif
}
switch (C2) {
case AppParCurves_PassPoint :
{
N++;
break;
}
case AppParCurves_TangencyPoint :
{
N += 2;
break;
}
case AppParCurves_CurvaturePoint :
{
N += 3;
break;
}
#ifndef DEB
default:
break;
#endif
}
return N;
}
//=======================================================================
//function : PointsByPick
//=======================================================================
static Standard_Integer PointsByPick
(Handle(AppDef_HArray1OfMultiPointConstraint)& MPC, Draw_Interpretor& di)
{
Standard_Integer id,XX,YY,b, i;
di << "Pick points "<< "\n";
dout.Select(id, XX, YY, b);
Standard_Real zoom = dout.Zoom(id);
if (b != 1) return 0;
if (id < 0) return 0;
gp_Pnt P;
gp_Pnt2d P2d;
//Standard_Boolean newcurve;
if (dout.Is3D(id)) {
// Cas du 3D -------
Handle(Draw_Marker3D) mark;
TColgp_SequenceOfPnt ThePoints;
P.SetCoord((Standard_Real)XX/zoom,(Standard_Real)YY/zoom, 0.0);
ThePoints.Append (P);
mark = new Draw_Marker3D(P, Draw_X, Draw_orange);
dout << mark;
dout.Flush();
i = 1;
while (b != 3) {
dout.Select(id,XX,YY,b, Standard_False);
if (b == 1) {
i++;
P.SetCoord( (Standard_Real)XX/zoom,
(Standard_Real)YY/zoom, 0.0);
ThePoints.Append(P);
mark = new Draw_Marker3D(P, Draw_X, Draw_orange);
dout << mark;
dout.Flush();
}
}
MPC = new (AppDef_HArray1OfMultiPointConstraint)(1, ThePoints.Length());
AppDef_MultiPointConstraint mpc(1,0);
MPC->ChangeArray1().Init(mpc);
for (i=1; i<=ThePoints.Length(); i++) {
AppDef_MultiPointConstraint mpc(1,0);
mpc.SetPoint(1, ThePoints.Value(i));
MPC->SetValue(i, mpc);
}
}
else {
// Cas du 2D -------
Handle(Draw_Marker2D) mark;
TColgp_SequenceOfPnt2d ThePoints;
P2d.SetCoord((Standard_Real)XX/zoom,(Standard_Real)YY/zoom);
ThePoints.Append(P2d);
mark = new Draw_Marker2D(P2d, Draw_X, Draw_orange);
dout << mark;
dout.Flush();
i = 1;
while (b != 3) {
dout.Select(id,XX,YY,b, Standard_False);
if (b == 1) {
i++;
P2d.SetCoord( (Standard_Real)XX/zoom, (Standard_Real)YY/zoom );
ThePoints.Append (P2d);
mark = new Draw_Marker2D(P2d, Draw_X, Draw_orange);
dout << mark;
dout.Flush();
}
}
MPC = new (AppDef_HArray1OfMultiPointConstraint)(1, ThePoints.Length());
for (i=1; i<=ThePoints.Length(); i++) {
AppDef_MultiPointConstraint mpc(0,1);
mpc.SetPoint2d(1, ThePoints.Value(i));
MPC->SetValue(i, mpc);
}
}
return id;
}
//=======================================================================
//function : PointsByFile
//=======================================================================
static void PointsByFile(Handle(AppDef_HArray1OfMultiPointConstraint)& MPC,
Handle(AppParCurves_HArray1OfConstraintCouple)& TABofCC,
ifstream& iFile,
Draw_Interpretor& di)
{
Standard_Integer nbp, i, nbc;
char c;
Standard_Real x, y, z;
iFile >> nbp;
char dimen[3];
iFile >> dimen;
if (!strcmp(dimen,"3d")) {
Handle(Draw_Marker3D) mark;
MPC = new (AppDef_HArray1OfMultiPointConstraint)(1, nbp);
for (i = 1; i <= nbp; i++) {
iFile >> x >> y >> z;
AppDef_MultiPointConstraint mpc(1,0);
mpc.SetPoint(1, gp_Pnt(x, y, z));
MPC->SetValue(i,mpc);
mark = new Draw_Marker3D(gp_Pnt(x, y, z), Draw_X, Draw_orange);
dout << mark;
}
Standard_Boolean HasConstrainte = Standard_False;
if (iFile.get(c)) {
if ( IsControl( (Standard_Character)c) ) {
if (iFile.get(c)) HasConstrainte = Standard_True;
}
else HasConstrainte = Standard_True;
}
if (HasConstrainte) {
Standard_Integer num, ordre;
iFile >> nbc;
if ((nbc < 1) || (nbc>nbp)) return; // Y a comme un probleme
AppParCurves_Constraint Constraint = AppParCurves_NoConstraint;
TABofCC = new AppParCurves_HArray1OfConstraintCouple(1, nbp);
for(i=1; i<=nbp; i++){
AppParCurves_ConstraintCouple ACC(i,Constraint);
TABofCC->SetValue(i,ACC);
}
for(i=1; i<=nbc; i++) {
iFile >> num >> ordre;
if ((num<1)||(num>nbp)) {
di << "Error on point Index in constrainte" << "\n";
return;
}
Constraint = (AppParCurves_Constraint) (ordre+1);
TABofCC->ChangeValue(num).SetConstraint(Constraint);
if (Constraint >= AppParCurves_TangencyPoint) {
iFile >> x >> y >> z;
MPC->ChangeValue(num).SetTang(1, gp_Vec(x,y,z));
}
if (Constraint >= AppParCurves_CurvaturePoint) {
iFile >> x >> y >> z;
MPC->ChangeValue(num).SetCurv(1, gp_Vec(x,y,z));
}
}
}
}
else if (!strcmp(dimen,"2d")) {
Handle(Draw_Marker2D) mark;
MPC = new (AppDef_HArray1OfMultiPointConstraint)(1, nbp);
for (i = 1; i <= nbp; i++) {
iFile >> x >> y;
AppDef_MultiPointConstraint mpc(0,1);
mpc.SetPoint2d(1, gp_Pnt2d(x, y));
MPC->SetValue(i, mpc);
mark = new Draw_Marker2D(gp_Pnt2d(x, y), Draw_X, Draw_orange);
dout << mark;
}
Standard_Boolean HasConstrainte = Standard_False;
if (iFile.get(c)) {
if ( IsControl( (Standard_Character)c) ) {
if (iFile.get(c)) HasConstrainte = Standard_True;
}
else HasConstrainte = Standard_True;
}
if (HasConstrainte) {
Standard_Integer num, ordre;
iFile >> nbc;
if ((nbc < 1) || (nbc>nbp)) return; // Y a comme un probleme
AppParCurves_Constraint Constraint = AppParCurves_NoConstraint;
TABofCC = new AppParCurves_HArray1OfConstraintCouple(1, nbp);
for(i=1; i<=nbp; i++){
AppParCurves_ConstraintCouple ACC(i,Constraint);
TABofCC->SetValue(i,ACC);
}
for(i=1; i<=nbc; i++) {
iFile >> num >> ordre;
if ((num<1)||(num>nbp)) {
di << "Error on point Index in constrainte" << "\n";
return;
}
Constraint = (AppParCurves_Constraint) (ordre+1);
TABofCC->ChangeValue(num).SetConstraint(Constraint);
if (Constraint >= AppParCurves_TangencyPoint) {
iFile >> x >> y;
MPC->ChangeValue(num).SetTang2d(1, gp_Vec2d(x,y));
}
if (Constraint >= AppParCurves_CurvaturePoint) {
iFile >> x >> y;
MPC->ChangeValue(num).SetCurv2d(1, gp_Vec2d(x,y));
}
}
}
}
}
//==================================================================================
static Standard_Integer smoothing (Draw_Interpretor& di,Standard_Integer n, const char** a)
//==================================================================================
// Tolerance < 0 lissage "filtre"
// Tolerance > 0 lissage avec respect de l'erreur max
// Tolerance = 0 interpolation.
//
{
Standard_Real Tolerance=0;
#ifdef DEB
AppParCurves_Constraint Constraint;
#else
AppParCurves_Constraint Constraint=AppParCurves_NoConstraint;
#endif
Handle(AppParCurves_HArray1OfConstraintCouple)TABofCC;
TABofCC.Nullify();
Handle(AppDef_HArray1OfMultiPointConstraint) Points;
Standard_Integer id = 0, DegMax = -1;
if (n == 1) {
di <<"give a name to your curve !" << "\n";
return 0;
}
if (n == 2) {
di <<"give a tolerance to your curve !" << "\n";
return 0;
}
if (n == 3) {
Tolerance = atof(a[2]);
if (Abs(Tolerance) < Precision::Confusion()*1.e-7) {
Constraint = AppParCurves_PassPoint;
}
else {
Constraint = AppParCurves_NoConstraint;
}
// Designation Graphique ------------------------
id = PointsByPick(Points, di);
}
else if (n >= 4) {
Standard_Integer ific = 3;
Tolerance = atof(a[2]);
if (Abs(Tolerance) < Precision::Confusion()*1.e-7) {
Constraint = AppParCurves_PassPoint;
}
else {
Constraint = AppParCurves_NoConstraint;
}
if (! strcmp(a[3],"-D")) {
DegMax = atoi(a[4]);
ific = 5;
}
if (n > ific) {
// lecture du fichier.
// nbpoints, 2d ou 3d, puis valeurs.
const char* nomfic = a[ific];
ifstream iFile(nomfic, ios::in);
if (!iFile) {
di << a[ific] <<"do not exist !" << "\n";
return 1;
}
PointsByFile(Points, TABofCC, iFile, di);
}
else {
// Designation Graphique
id = PointsByPick(Points, di);
}
}
AppDef_MultiLine AML(Points->Array1());
// Compute --------------
Standard_Integer i;
if (Points->Value(1).NbPoints()==0){
// Cas 2d
Handle(TColgp_HArray1OfPnt2d) ThePoints;
// Calcul du lissage
Standard_Integer NbPoints = Points->Length();
if (TABofCC.IsNull()) {
TABofCC = new AppParCurves_HArray1OfConstraintCouple(1, NbPoints);
for(i=1; i<=NbPoints; i++){
AppParCurves_ConstraintCouple ACC(i,Constraint);
TABofCC->SetValue(i,ACC);
}
}
AppDef_TheVariational Variation(AML,
1, NbPoints,
TABofCC);
if (DegMax > 0) {
if (DegMax < 3) Variation.SetContinuity(GeomAbs_C0);
else if (DegMax <5) Variation.SetContinuity(GeomAbs_C1);
Variation.SetMaxDegree(DegMax);
}
Variation.SetTolerance( Abs(Tolerance));
if (Tolerance>0) { Variation.SetWithMinMax(Standard_True);}
Variation.Approximate();
# ifdef DEB
//Variation.Dump(cout);
Standard_SStream aSStream;
Variation.Dump(aSStream);
di << aSStream;
# endif
AppParCurves_MultiBSpCurve AnMuC = Variation.Value();
TColgp_Array1OfPnt2d ThePoles (1, AnMuC.NbPoles() );
AnMuC.Curve(1, ThePoles);
Handle(Geom2d_BSplineCurve) Cvliss = new (Geom2d_BSplineCurve)
(ThePoles,
AnMuC.Knots(),
AnMuC. Multiplicities(),
AnMuC.Degree() );
Handle(DrawTrSurf_BSplineCurve2d)
DC = new DrawTrSurf_BSplineCurve2d(Cvliss);
DC->ClearPoles();
Draw::Set(a[1], DC);
if (id!=0) dout.RepaintView(id);
}
else {
Standard_Integer NbPoints = Points->Length();
if (TABofCC.IsNull()) {
TABofCC = new AppParCurves_HArray1OfConstraintCouple(1, NbPoints);
for(i=1; i<=NbPoints; i++){
AppParCurves_ConstraintCouple ACC(i,Constraint);
TABofCC->SetValue(i,ACC);
}
}
AppDef_TheVariational Variation(AML,
1, NbPoints,
TABofCC);
if (DegMax > 0) {
if (DegMax < 3) Variation.SetContinuity(GeomAbs_C0);
else if (DegMax <5) Variation.SetContinuity(GeomAbs_C1);
Variation.SetMaxDegree(DegMax);
}
Variation.SetTolerance( Abs(Tolerance));
if (Tolerance>0) { Variation.SetWithMinMax(Standard_True);}
Variation.Approximate();
# ifdef DEB
//Variation.Dump(cout);
Standard_SStream aSStream;
Variation.Dump(aSStream);
di << aSStream;
# endif
AppParCurves_MultiBSpCurve AnMuC = Variation.Value();
TColgp_Array1OfPnt ThePoles (1, AnMuC.NbPoles() );
AnMuC.Curve(1, ThePoles);
Handle(Geom_BSplineCurve) Cvliss = new (Geom_BSplineCurve)
(ThePoles,
AnMuC.Knots(),
AnMuC. Multiplicities(),
AnMuC.Degree() );
Handle(DrawTrSurf_BSplineCurve)
DC = new DrawTrSurf_BSplineCurve(Cvliss);
DC->ClearPoles();
Draw::Set(a[1], DC);
if (id!=0) dout.RepaintView(id);
}
return 0;
}
//=============================================================================
static Standard_Integer smoothingbybezier (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
//============================================================================
{
Standard_Real Tolerance=0;
#ifdef DEB
AppParCurves_Constraint Constraint;
#else
AppParCurves_Constraint Constraint=AppParCurves_NoConstraint;
#endif
Handle(AppParCurves_HArray1OfConstraintCouple)TABofCC;
Handle(AppDef_HArray1OfMultiPointConstraint) Points;
Standard_Integer id = 0;
Standard_Integer methode=0;
Standard_Integer Degree = 8;
if (n == 1) {
di <<"give a name to your curve !" << "\n";
return 0;
}
if (n == 2) {
di <<"give a tolerance to your curve !" << "\n";
return 0;
}
if (n == 3) {
di <<"give a max degree!" << "\n";
return 0;
}
if (n == 4) {
di <<"give an option!" << "\n";
return 0;
}
if (n >= 5) {
Tolerance = atof(a[2]);
Degree = atoi(a[3]);
if (! strcmp(a[4],"-GR")) {
methode = 1;
}
else if (! strcmp(a[4],"-PR")) {
methode = 2;
}
else { methode = 3;}
if (Abs(Tolerance) < Precision::Confusion()*1.e-7) {
Constraint = AppParCurves_PassPoint;
}
else {
Constraint = AppParCurves_NoConstraint;
}
if (n==5)
// Designation Graphique ------------------------
id = PointsByPick(Points, di);
else {
// lecture du fichier.
// nbpoints, 2d ou 3d, puis valeurs.
const char* nomfic = a[5];
ifstream iFile(nomfic, ios::in);
if (!iFile) {
di << a[6] <<"do not exist !" << "\n";
return 1;
}
PointsByFile(Points, TABofCC, iFile, di);
}
}
AppDef_MultiLine AML(Points->Array1());
// Compute --------------
Standard_Integer i;
if (Points->Value(1).NbPoints()==0){
// Cas 2d
Handle(TColgp_HArray1OfPnt2d) ThePoints;
// Calcul du lissage
Standard_Integer NbPoints = Points->Length();
if (TABofCC.IsNull()) {
TABofCC = new AppParCurves_HArray1OfConstraintCouple(1, NbPoints);
for(i=1; i<=NbPoints; i++){
AppParCurves_ConstraintCouple ACC(i,Constraint);
TABofCC->SetValue(i,ACC);
}
AppParCurves_ConstraintCouple AC1(1, AppParCurves_PassPoint);
if (TABofCC->Value(1).Constraint()<AppParCurves_PassPoint)
TABofCC->SetValue(1, AC1);
AppParCurves_ConstraintCouple AC2(NbPoints, AppParCurves_PassPoint);
if (TABofCC->Value(NbPoints).Constraint()<AppParCurves_PassPoint)
TABofCC->SetValue(NbPoints, AC2);
}
if (methode < 3) {
Standard_Boolean mySquare = (methode == 2);
Standard_Integer degmin = 4;
Standard_Integer NbIteration = 5;
#ifdef DEB
Standard_Integer NbConst =
#endif
NbConstraint(TABofCC->Value(1).Constraint(),
TABofCC->Value(NbPoints).Constraint());
if (Degree < 4) degmin = Max(1, Degree -1);
degmin = Max(degmin, NbConstraint(TABofCC->Value(1).Constraint(),
TABofCC->Value(NbPoints).Constraint()) );
AppDef_Compute Appr(degmin, Degree,
Abs(Tolerance), Abs(Tolerance),
NbIteration, Standard_False,
Approx_ChordLength, mySquare);
Appr.SetConstraints(TABofCC->Value(1).Constraint(),
TABofCC->Value(NbPoints).Constraint());
Appr.Perform (AML);
if (! Appr.IsAllApproximated()) {
di << " No result" << "\n";
}
AppParCurves_MultiCurve AnMuC = Appr.Value();
ThePoints = new (TColgp_HArray1OfPnt2d) (1, AnMuC.NbPoles() );
AnMuC.Curve(1, ThePoints->ChangeArray1());
Standard_Real err, err2d;
Appr.Error(1, err, err2d);
di <<" Error2D is : " << err2d << "\n";
}
else {
AppDef_TheVariational Varia(AML,
1, NbPoints,
TABofCC,
Degree, 1);
Varia.SetTolerance(Abs(Tolerance));
Varia.Approximate();
if (! Varia.IsDone()) {
di << " No result" << "\n";
}
AppParCurves_MultiBSpCurve AnMuC = Varia.Value();
di <<" Error2D is : " << Varia.MaxError() << "\n";
ThePoints = new (TColgp_HArray1OfPnt2d) (1, AnMuC.NbPoles() );
AnMuC.Curve(1, ThePoints->ChangeArray1());
}
Handle(Geom2d_BezierCurve) Cvliss =
new (Geom2d_BezierCurve)(ThePoints->Array1());
Handle(DrawTrSurf_BezierCurve2d) DC =
new (DrawTrSurf_BezierCurve2d) (Cvliss);
Draw::Set(a[1], DC);
if (id!=0) dout.RepaintView(id);
}
else {
// Cas 3d
Handle(TColgp_HArray1OfPnt) ThePoints;
Standard_Integer NbPoints = Points->Length();
if (TABofCC.IsNull()) {
TABofCC = new AppParCurves_HArray1OfConstraintCouple(1, NbPoints);
for(i=1; i<=NbPoints; i++){
AppParCurves_ConstraintCouple ACC(i,Constraint);
TABofCC->SetValue(i,ACC);
}
AppParCurves_ConstraintCouple AC1(1, AppParCurves_PassPoint);
if (TABofCC->Value(1).Constraint()<AppParCurves_PassPoint)
TABofCC->SetValue(1, AC1);
AppParCurves_ConstraintCouple AC2(NbPoints, AppParCurves_PassPoint);
if (TABofCC->Value(NbPoints).Constraint()<AppParCurves_PassPoint)
TABofCC->SetValue(NbPoints, AC2);
}
if (methode < 3) {
Standard_Boolean mySquare = (methode == 2);
Standard_Integer degmin = 4;
Standard_Integer NbIteration = 5;
if (Degree < 4) degmin = Max(1, Degree - 1);
degmin = Max(degmin, NbConstraint(TABofCC->Value(1).Constraint(),
TABofCC->Value(NbPoints).Constraint()) );
AppDef_Compute Appr(degmin, Degree,
Abs(Tolerance), Abs(Tolerance),
NbIteration, Standard_False,
Approx_ChordLength, mySquare);
Appr.SetConstraints(TABofCC->Value(1).Constraint(),
TABofCC->Value(NbPoints).Constraint());
Appr.Perform (AML);
if (! Appr.IsAllApproximated()) {
di << " No result" << "\n";
}
AppParCurves_MultiCurve AnMuC = Appr.Value();
ThePoints = new (TColgp_HArray1OfPnt) (1, AnMuC.NbPoles() );
AnMuC.Curve(1, ThePoints->ChangeArray1());
Standard_Real err, err2d;
Appr.Error(1, err, err2d);
di <<" Error3D is : " << err << "\n";
}
else {
AppDef_TheVariational Varia(AML,
1, NbPoints,
TABofCC,
Degree, 1);
Varia.SetTolerance(Abs(Tolerance));
Varia.Approximate();
if (! Varia.IsDone()) {
di << " No result" << "\n";
}
AppParCurves_MultiBSpCurve AnMuC = Varia.Value();
di <<" Error3D is : " << Varia.MaxError() << "\n";
ThePoints = new (TColgp_HArray1OfPnt) (1, AnMuC.NbPoles() );
AnMuC.Curve(1, ThePoints->ChangeArray1());
}
Handle(Geom_BezierCurve) Cvliss =
new (Geom_BezierCurve)(ThePoints->Array1());
Handle(DrawTrSurf_BezierCurve)
DC = new DrawTrSurf_BezierCurve(Cvliss);
Draw::Set(a[1], DC);
if (id!=0) dout.RepaintView(id);
}
return 0;
}
//=======================================================================
//function : ConstraintCommands
//purpose :
//=======================================================================
void GeomliteTest::ApproxCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean loaded = Standard_False;
if (loaded) return;
loaded = Standard_True;
DrawTrSurf::BasicCommands(theCommands);
const char* g;
// constrained constructs
g = "GEOMETRY Constraints";
theCommands.Add("bsmooth",
"bsmooth cname tol [-D degree] [fic]",
__FILE__,
smoothing, g);
theCommands.Add("bzsmooth",
"bzsmooth cname tol degree option [fic]",
__FILE__,
smoothingbybezier, g);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,157 @@
// File: GeomliteTest_ModificationCommands.cxx
// Created: Thu Apr 15 12:00 1997
// Author: Joelle CHAUVET
// <jct@sgi38>
#include <GeomliteTest.hxx>
#include <DrawTrSurf.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_Appli.hxx>
#include <Draw_Display.hxx>
#include <Precision.hxx>
#include <GeomLib.hxx>
#ifdef WNT
#include <stdio.h>
//#define strcasecmp strcmp Already defined
#endif
//=======================================================================
//function : extendcurve
//purpose :
//=======================================================================
static Standard_Integer extendcurve (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n < 4) return 1;
Handle(Geom_BoundedCurve) GB =
Handle(Geom_BoundedCurve)::DownCast(DrawTrSurf::GetCurve(a[1]));
if (GB.IsNull()) {
di << "extendcurve needs a Bounded curve";
return 1;
}
gp_Pnt P;
if ( !DrawTrSurf::GetPoint(a[2],P)) return 1;
Standard_Boolean apres = Standard_True;
if (n == 5) {
if (strcmp(a[4], "B") == 0) {
apres = Standard_False ;
}
}
Standard_Integer cont=atoi(a[3]);
GeomLib::ExtendCurveToPoint(GB,P,cont,apres);
DrawTrSurf::Set(a[1],GB);
return 0;
}
//=======================================================================
//function : extendsurf
//purpose :
//=======================================================================
static Standard_Integer extendsurf (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n < 4) return 1;
Handle(Geom_BoundedSurface) GB =
Handle(Geom_BoundedSurface)::DownCast(DrawTrSurf::GetSurface(a[1]));
if (GB.IsNull()) {
di << "extendsurf needs a Bounded surface";
return 1;
}
Standard_Real chord=atof(a[2]);
Standard_Integer cont=atoi(a[3]);
Standard_Boolean enU = Standard_True, apres = Standard_True;
if (n >= 5) {
if (strcmp(a[4], "V") == 0) {
enU = Standard_False ;
}
if (strcmp(a[4], "B") == 0) {
apres = Standard_False ;
}
}
if (n == 6) {
if (strcmp(a[5], "B") == 0) {
apres = Standard_False ;
}
}
GeomLib::ExtendSurfByLength(GB,chord,cont,enU,apres);
DrawTrSurf::Set(a[1],GB);
return 0;
}
//=======================================================================
//function : samerange
//purpose :
//=======================================================================
static Standard_Integer samerange (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n < 6) return 1;
Handle(Geom2d_Curve) C = DrawTrSurf::GetCurve2d(a[2]);
Handle(Geom2d_Curve) Res;
Standard_Real f, l, rf, rl;
f = atof(a[3]);
l = atof(a[4]);
rf = atof(a[5]);
rl = atof(a[6]);
GeomLib::SameRange(Precision::PConfusion(), C,
f, l, rf, rl, Res);
DrawTrSurf::Set(a[1],Res);
return 0;
}
//=======================================================================
//function : ModificationCommands
//purpose :
//=======================================================================
void GeomliteTest::ModificationCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean loaded = Standard_False;
if (loaded) return;
loaded = Standard_True;
DrawTrSurf::BasicCommands(theCommands);
const char* g;
g = "GEOMETRY Curves and Surfaces modification";
theCommands.Add("extendcurve",
"extendcurve name point cont [A(fter)/B(efore)]",
__FILE__,
extendcurve , g);
theCommands.Add("extendsurf",
"extendsurf name length cont [U/V] [A(fter)/B(efore)]",
__FILE__,
extendsurf, g);
theCommands.Add("chgrange",
"chgrange newname curve2d first last RequestedFirst RequestedLast ]",
__FILE__,
samerange, g);
}

File diff suppressed because it is too large Load Diff