mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
10
src/GeometryTest/FILES
Executable file
10
src/GeometryTest/FILES
Executable file
@@ -0,0 +1,10 @@
|
||||
GeometryTest_ConstraintCommands.cxx
|
||||
GeometryTest_CurveCommands.cxx
|
||||
GeometryTest_FairCurveCommands.cxx
|
||||
GeometryTest_SurfaceCommands.cxx
|
||||
GeometryTest_API2dCommands.cxx
|
||||
GeometryTest_APICommands.cxx
|
||||
GeometryTest_ContinuityCommands.cxx
|
||||
GeometryTest_PolyCommands.cxx
|
||||
|
||||
|
58
src/GeometryTest/GeometryTest.cdl
Executable file
58
src/GeometryTest/GeometryTest.cdl
Executable file
@@ -0,0 +1,58 @@
|
||||
-- File: GeometryTest.cdl
|
||||
-- Created: Mon Jun 24 11:23:25 1991
|
||||
-- Author: Christophe MARION
|
||||
-- <cma@phobox>
|
||||
-- modified by mps (dec 96) add of ContinuityCommands
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
|
||||
package GeometryTest
|
||||
|
||||
---Purpose: this package provides commands for curves and
|
||||
-- surface.
|
||||
uses
|
||||
Draw,
|
||||
Standard,
|
||||
GeomliteTest
|
||||
|
||||
is
|
||||
|
||||
AllCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: defines all geometric commands.
|
||||
|
||||
CurveCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: defines curve commands.
|
||||
|
||||
FairCurveCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: defines fair curve commands.
|
||||
|
||||
SurfaceCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: defines surface commands.
|
||||
|
||||
ConstraintCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: defines cosntrained curves commands.
|
||||
|
||||
API2dCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: defines commands to test the Geom2dAPI
|
||||
-- - Intersection
|
||||
-- - Extrema
|
||||
-- - Projection
|
||||
-- - Approximation, interpolation
|
||||
|
||||
APICommands(I : in out Interpretor from Draw);
|
||||
---Purpose: defines commands to test the Geom2dAPI
|
||||
-- - Intersection
|
||||
-- - Extrema
|
||||
-- - Projection
|
||||
-- - Approximation, interpolation
|
||||
|
||||
ContinuityCommands(I : in out Interpretor from Draw);
|
||||
--- Purpose: defines commands to check local
|
||||
-- continuity between curves or surfaces
|
||||
|
||||
PolyCommands(I : in out Interpretor from Draw);
|
||||
---Purpose: defines command to test the polyhedral
|
||||
-- triangulations and the polygons from the Poly package.
|
||||
|
||||
end GeometryTest;
|
34
src/GeometryTest/GeometryTest.cxx
Executable file
34
src/GeometryTest/GeometryTest.cxx
Executable file
@@ -0,0 +1,34 @@
|
||||
// File: GeometryTest.cxx
|
||||
// Created: Mon Jul 25 19:06:50 1994
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
// modified by mps (dec 96) ajout de ContinuityCommands
|
||||
// jpi 09/06/97 utilisation des commandes de GeomliteTest
|
||||
|
||||
#include <GeometryTest.hxx>
|
||||
#include <GeomliteTest.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
|
||||
void GeometryTest::AllCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
GeomliteTest::AllCommands(theCommands);
|
||||
GeometryTest::CurveCommands(theCommands);
|
||||
GeometryTest::FairCurveCommands(theCommands);
|
||||
GeometryTest::SurfaceCommands(theCommands);
|
||||
GeometryTest::ConstraintCommands(theCommands);
|
||||
// GeometryTest::API2dCommands(theCommands);
|
||||
GeometryTest::APICommands(theCommands);
|
||||
GeometryTest::ContinuityCommands(theCommands);
|
||||
// define the TCL variable Draw_GEOMETRY
|
||||
//char* com = "set Draw_GEOMETRY 1";
|
||||
//theCommands.Eval(com);
|
||||
//char* com2 = "source $env(CASROOT)/src/DrawResources/CURVES.tcl";
|
||||
//theCommands.Eval(com2);
|
||||
//char* com3 = "source $env(CASROOT)/src/DrawResources/SURFACES.tcl";
|
||||
//theCommands.Eval(com3);
|
||||
}
|
324
src/GeometryTest/GeometryTest_API2dCommands.cxx
Executable file
324
src/GeometryTest/GeometryTest_API2dCommands.cxx
Executable file
@@ -0,0 +1,324 @@
|
||||
// File: GeometryTest_API2dCommands.cxx
|
||||
// Created: Wed Jan 11 10:33:13 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
|
||||
#include <GeometryTest.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 <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 (Standard_Integer 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);
|
||||
for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++) {
|
||||
gp_Pnt2d P1,P2;
|
||||
Ex.Points(i,P1,P2);
|
||||
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 << " ";
|
||||
}
|
||||
|
||||
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 GeometryTest::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);
|
||||
}
|
495
src/GeometryTest/GeometryTest_APICommands.cxx
Executable file
495
src/GeometryTest/GeometryTest_APICommands.cxx
Executable file
@@ -0,0 +1,495 @@
|
||||
// File: GeometryTest_APICommands.cxx
|
||||
// Created: Tue Jan 17 18:06:26 1995
|
||||
// Author: Remi LEQUETTE
|
||||
// <rle@bravox>
|
||||
|
||||
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <GeometryTest.hxx>
|
||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||
#include <GeomAPI_ExtremaCurveCurve.hxx>
|
||||
#include <GeomAPI_ExtremaCurveSurface.hxx>
|
||||
#include <GeomAPI_ExtremaSurfaceSurface.hxx>
|
||||
#include <GeomAPI_PointsToBSpline.hxx>
|
||||
#include <GeomAPI_PointsToBSplineSurface.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Draw_Segment3D.hxx>
|
||||
#include <Draw_Marker3D.hxx>
|
||||
#include <Draw_Color.hxx>
|
||||
#include <Draw_MarkerShape.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TColStd_Array2OfReal.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 < 5) return 1;
|
||||
|
||||
gp_Pnt P(atof(a[2]),atof(a[3]),atof(a[4]));
|
||||
|
||||
char name[100];
|
||||
|
||||
Handle(Geom_Curve) GC = DrawTrSurf::GetCurve(a[1]);
|
||||
Handle(Geom_Surface) GS;
|
||||
|
||||
if (GC.IsNull()) {
|
||||
GS = DrawTrSurf::GetSurface(a[1]);
|
||||
if (GS.IsNull())
|
||||
return 1;
|
||||
Standard_Real U1, U2, V1, V2;
|
||||
GS->Bounds(U1,U2,V1,V2);
|
||||
|
||||
GeomAPI_ProjectPointOnSurf proj(P,GS,U1,U2,V1,V2);
|
||||
Standard_Real UU,VV;
|
||||
for ( Standard_Integer i = 1; i <= proj.NbPoints(); i++) {
|
||||
gp_Pnt P1 = proj.Point(i);
|
||||
if ( P.Distance(P1) > Precision::Confusion()) {
|
||||
Handle(Geom_Line) L = new Geom_Line(P,gp_Vec(P,P1));
|
||||
Handle(Geom_TrimmedCurve) CT =
|
||||
new Geom_TrimmedCurve(L, 0., P.Distance(P1));
|
||||
sprintf(name,"%s%d","ext_",i);
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp, CT);
|
||||
di << name << " ";
|
||||
}
|
||||
else {
|
||||
sprintf(name,"%s%d","ext_",i);
|
||||
di << name << " ";
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp, P1);
|
||||
proj.Parameters(i,UU,VV);
|
||||
di << " Le point est sur la surface." << "\n";
|
||||
di << " Ses parametres sont: UU = " << UU << "\n";
|
||||
di << " VV = " << VV << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
GeomAPI_ProjectPointOnCurve proj(P,GC,GC->FirstParameter(),
|
||||
GC->LastParameter());
|
||||
// Standard_Real UU;
|
||||
for ( Standard_Integer i = 1; i <= proj.NbPoints(); i++) {
|
||||
gp_Pnt P1 = proj.Point(i);
|
||||
Standard_Real UU = proj.Parameter(i);
|
||||
di << " parameter " << i << " = " << UU << "\n";
|
||||
if ( P.Distance(P1) > Precision::Confusion()) {
|
||||
Handle(Geom_Line) L = new Geom_Line(P,gp_Vec(P,P1));
|
||||
Handle(Geom_TrimmedCurve) CT =
|
||||
new Geom_TrimmedCurve(L, 0., P.Distance(P1));
|
||||
sprintf(name,"%s%d","ext_",i);
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp, CT);
|
||||
di << name << " ";
|
||||
}
|
||||
else {
|
||||
sprintf(name,"%s%d","ext_",i);
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp, P1);
|
||||
di << name << " ";
|
||||
UU = proj.Parameter(i);
|
||||
di << " Le point est sur la courbe." << "\n";
|
||||
di << " Son parametre est U = " << UU << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : appro
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if ( n<3) return 1;
|
||||
|
||||
Handle(Geom_Curve) GC;
|
||||
Standard_Integer Nb = atoi(a[2]);
|
||||
|
||||
TColgp_Array1OfPnt Points(1, Nb);
|
||||
|
||||
Handle(Draw_Marker3D) mark;
|
||||
|
||||
if ( n == 4) {
|
||||
GC = DrawTrSurf::GetCurve(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 ( Standard_Integer i = 1 ; i <= Nb; i++) {
|
||||
U = U1 + (i-1) * Delta;
|
||||
Points(i) = GC->Value(U);
|
||||
mark = new Draw_Marker3D( Points(i), Draw_X, Draw_vert);
|
||||
dout << mark;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Standard_Integer id,XX,YY,b;
|
||||
dout.Select(id,XX,YY,b);
|
||||
Standard_Real zoom = dout.Zoom(id);
|
||||
|
||||
Points(1) = gp_Pnt( ((Standard_Real)XX)/zoom,
|
||||
((Standard_Real)YY)/zoom,
|
||||
0.);
|
||||
|
||||
mark = new Draw_Marker3D( Points(1), Draw_X, Draw_vert);
|
||||
|
||||
dout << mark;
|
||||
|
||||
for (Standard_Integer i = 2; i<=Nb; i++) {
|
||||
dout.Select(id,XX,YY,b);
|
||||
Points(i) = gp_Pnt( ((Standard_Real)XX)/zoom,
|
||||
((Standard_Real)YY)/zoom,
|
||||
0.);
|
||||
mark = new Draw_Marker3D( Points(i), Draw_X, Draw_vert);
|
||||
dout << mark;
|
||||
}
|
||||
}
|
||||
dout.Flush();
|
||||
Standard_Integer Dmin = 3;
|
||||
Standard_Integer Dmax = 8;
|
||||
Standard_Real Tol3d = 1.e-3;
|
||||
|
||||
Handle(Geom_BSplineCurve) TheCurve;
|
||||
GeomAPI_PointsToBSpline aPointToBSpline(Points,Dmin,Dmax,GeomAbs_C2,Tol3d);
|
||||
TheCurve = aPointToBSpline.Curve();
|
||||
|
||||
|
||||
DrawTrSurf::Set(a[1], TheCurve);
|
||||
di << a[1];
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : grilapp
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer grilapp(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if ( n < 12) return 1;
|
||||
|
||||
Standard_Integer i,j;
|
||||
Standard_Integer Nu = atoi(a[2]);
|
||||
Standard_Integer Nv = atoi(a[3]);
|
||||
TColStd_Array2OfReal ZPoints (1, Nu, 1, Nv);
|
||||
|
||||
Standard_Real X0 = atof(a[4]);
|
||||
Standard_Real dX = atof(a[5]);
|
||||
Standard_Real Y0 = atof(a[6]);
|
||||
Standard_Real dY = atof(a[7]);
|
||||
|
||||
Standard_Integer Count = 8;
|
||||
for ( j = 1; j <= Nv; j++) {
|
||||
for ( i = 1; i <= Nu; i++) {
|
||||
if ( Count > n) return 1;
|
||||
ZPoints(i,j) = atof(a[Count]);
|
||||
Count++;
|
||||
}
|
||||
}
|
||||
|
||||
Handle(Geom_BSplineSurface) S
|
||||
= GeomAPI_PointsToBSplineSurface(ZPoints,X0,dX,Y0,dY);
|
||||
DrawTrSurf::Set(a[1],S);
|
||||
|
||||
di << a[1];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : surfapp
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer surfapp(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if ( n < 5 ) return 1;
|
||||
|
||||
Standard_Integer i,j;
|
||||
Standard_Integer Nu = atoi(a[2]);
|
||||
Standard_Integer Nv = atoi(a[3]);
|
||||
TColgp_Array2OfPnt Points (1, Nu, 1, Nv);
|
||||
|
||||
if ( n == 5) {
|
||||
Handle(Geom_Surface) Surf = DrawTrSurf::GetSurface(a[4]);
|
||||
if ( Surf.IsNull()) return 1;
|
||||
|
||||
Standard_Real U, V, U1, V1, U2, V2;
|
||||
Surf->Bounds( U1, U2, V1, V2);
|
||||
for ( j = 1; j <= Nv; j++) {
|
||||
V = V1 + (j-1) * (V2-V1) / (Nv-1);
|
||||
for ( i = 1; i <= Nu; i++) {
|
||||
U = U1 + (i-1) * (U2-U1) / (Nu-1);
|
||||
Points(i,j) = Surf->Value(U,V);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( n >= 16) {
|
||||
Standard_Integer Count = 4;
|
||||
for ( j = 1; j <= Nv; j++) {
|
||||
for ( i = 1; i <= Nu; i++) {
|
||||
if ( Count > n) return 1;
|
||||
Points(i,j) = gp_Pnt(atof(a[Count]),atof(a[Count+1]),atof(a[Count+2]));
|
||||
Count += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
char name[100];
|
||||
Standard_Integer Count = 1;
|
||||
for ( j = 1; j <= Nv; j++) {
|
||||
for ( i = 1; i <= Nu; i++) {
|
||||
sprintf(name,"point_%d",Count++);
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp,Points(i,j));
|
||||
}
|
||||
}
|
||||
|
||||
Handle(Geom_BSplineSurface) S = GeomAPI_PointsToBSplineSurface(Points);
|
||||
DrawTrSurf::Set(a[1],S);
|
||||
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(Geom_Curve) GC1, GC2;
|
||||
Handle(Geom_Surface) GS1, GS2;
|
||||
|
||||
Standard_Boolean C1 = Standard_False;
|
||||
Standard_Boolean C2 = Standard_False;
|
||||
Standard_Boolean S1 = Standard_False;
|
||||
Standard_Boolean S2 = Standard_False;
|
||||
|
||||
Standard_Real U1f,U1l,U2f,U2l,V1f,V1l,V2f,V2l;
|
||||
|
||||
GC1 = DrawTrSurf::GetCurve(a[1]);
|
||||
if ( GC1.IsNull()) {
|
||||
GS1 = DrawTrSurf::GetSurface(a[1]);
|
||||
if ( GS1.IsNull())
|
||||
return 1;
|
||||
S1 = Standard_True;
|
||||
GS1->Bounds(U1f,U1l,V1f,V1l);
|
||||
}
|
||||
else {
|
||||
C1 = Standard_True;
|
||||
U1f = GC1->FirstParameter();
|
||||
U1l = GC1->LastParameter();
|
||||
}
|
||||
|
||||
GC2 = DrawTrSurf::GetCurve(a[2]);
|
||||
if ( GC2.IsNull()) {
|
||||
GS2 = DrawTrSurf::GetSurface(a[2]);
|
||||
if ( GS2.IsNull())
|
||||
return 1;
|
||||
S2 = Standard_True;
|
||||
GS2->Bounds(U2f,U2l,V2f,V2l);
|
||||
}
|
||||
else {
|
||||
C2 = Standard_True;
|
||||
U2f = GC2->FirstParameter();
|
||||
U2l = GC2->LastParameter();
|
||||
}
|
||||
|
||||
char name[100];
|
||||
if ( C1 && C2) {
|
||||
GeomAPI_ExtremaCurveCurve Ex(GC1,GC2,U1f,U1l,U2f,U2l);
|
||||
if(!Ex.Extrema().IsParallel()) {
|
||||
for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++) {
|
||||
gp_Pnt P1,P2;
|
||||
Ex.Points(i,P1,P2);
|
||||
if (P1.Distance(P2) < 1.e-16) {
|
||||
di << "Extrema " << i << " is point : " << P1.X() << " " << P1.Y() << " " << P1.Z() << "\n";
|
||||
continue;
|
||||
}
|
||||
Handle(Geom_Line) L = new Geom_Line(P1,gp_Vec(P1,P2));
|
||||
Handle(Geom_TrimmedCurve) CT =
|
||||
new Geom_TrimmedCurve(L, 0., P1.Distance(P2));
|
||||
sprintf(name,"%s%d","ext_",i);
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp, CT);
|
||||
di << name << " ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
di << "Infinite number of extremas, distance = " << Ex.LowerDistance() << "\n";
|
||||
}
|
||||
}
|
||||
else if ( C1 & S2) {
|
||||
GeomAPI_ExtremaCurveSurface Ex(GC1,GS2,U1f,U1l,U2f,U2l,V2f,V2l);
|
||||
for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++) {
|
||||
gp_Pnt P1,P2;
|
||||
Ex.Points(i,P1,P2);
|
||||
if (P1.Distance(P2) < 1.e-16) continue;
|
||||
Handle(Geom_Line) L = new Geom_Line(P1,gp_Vec(P1,P2));
|
||||
Handle(Geom_TrimmedCurve) CT =
|
||||
new Geom_TrimmedCurve(L, 0., P1.Distance(P2));
|
||||
sprintf(name,"%s%d","ext_",i);
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp, CT);
|
||||
di << name << " ";
|
||||
}
|
||||
}
|
||||
else if ( S1 & C2) {
|
||||
GeomAPI_ExtremaCurveSurface Ex(GC2,GS1,U2f,U2l,U1f,U1l,V1f,V1l);
|
||||
for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++) {
|
||||
gp_Pnt P1,P2;
|
||||
Ex.Points(i,P1,P2);
|
||||
if (P1.Distance(P2) < 1.e-16) continue;
|
||||
Handle(Geom_Line) L = new Geom_Line(P1,gp_Vec(P1,P2));
|
||||
Handle(Geom_TrimmedCurve) CT =
|
||||
new Geom_TrimmedCurve(L, 0., P1.Distance(P2));
|
||||
sprintf(name,"%s%d","ext_",i);
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp, CT);
|
||||
di << name << " ";
|
||||
}
|
||||
}
|
||||
else if ( S1 & S2) {
|
||||
GeomAPI_ExtremaSurfaceSurface Ex(GS1,GS2,U1f,U1l,V1f,V1l,U2f,U2l,V2f,V2l);
|
||||
for ( Standard_Integer i = 1; i <= Ex.NbExtrema(); i++) {
|
||||
gp_Pnt P1,P2;
|
||||
Ex.Points(i,P1,P2);
|
||||
if (P1.Distance(P2) < 1.e-16) continue;
|
||||
Handle(Geom_Line) L = new Geom_Line(P1,gp_Vec(P1,P2));
|
||||
Handle(Geom_TrimmedCurve) CT =
|
||||
new Geom_TrimmedCurve(L, 0., P1.Distance(P2));
|
||||
sprintf(name,"%s%d","ext_",i);
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp, CT);
|
||||
di << name << " ";
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : totalextcc
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer totalextcc(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if ( n<3) return 1;
|
||||
|
||||
Handle(Geom_Curve) GC1, GC2;
|
||||
|
||||
|
||||
Standard_Real U1f,U1l,U2f,U2l;
|
||||
|
||||
GC1 = DrawTrSurf::GetCurve(a[1]);
|
||||
if ( GC1.IsNull()) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
U1f = GC1->FirstParameter();
|
||||
U1l = GC1->LastParameter();
|
||||
}
|
||||
|
||||
GC2 = DrawTrSurf::GetCurve(a[2]);
|
||||
if ( GC2.IsNull()) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
U2f = GC2->FirstParameter();
|
||||
U2l = GC2->LastParameter();
|
||||
}
|
||||
|
||||
char name[100];
|
||||
GeomAPI_ExtremaCurveCurve Ex(GC1,GC2,U1f,U1l,U2f,U2l);
|
||||
gp_Pnt P1,P2;
|
||||
if(Ex.TotalNearestPoints(P1,P2)) {
|
||||
if (P1.Distance(P2) < 1.e-16) {
|
||||
di << "Extrema is point : " << P1.X() << " " << P1.Y() << " " << P1.Z() << "\n";
|
||||
}
|
||||
else {
|
||||
di << "Extrema is segment of line" << "\n";
|
||||
Handle(Geom_Line) L = new Geom_Line(P1,gp_Vec(P1,P2));
|
||||
Handle(Geom_TrimmedCurve) CT =
|
||||
new Geom_TrimmedCurve(L, 0., P1.Distance(P2));
|
||||
sprintf(name,"%s%d","ext_",1);
|
||||
char* temp = name; // portage WNT
|
||||
DrawTrSurf::Set(temp, CT);
|
||||
di << name << " ";
|
||||
}
|
||||
|
||||
Standard_Real u1, u2;
|
||||
Ex.TotalLowerDistanceParameters(u1, u2);
|
||||
|
||||
di << "Parameters on curves : " << u1 << " " << u2 << "\n";
|
||||
|
||||
}
|
||||
else {
|
||||
di << "Curves are infinite and parallel" << "\n";
|
||||
}
|
||||
|
||||
di << "Minimal distance : " << Ex.TotalLowerDistance() << "\n";
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GeometryTest::APICommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
|
||||
done = Standard_True;
|
||||
const char* g;
|
||||
|
||||
g = "GEOMETRY curves and surfaces analysis";
|
||||
|
||||
theCommands.Add("proj", "proj curve/surf x y z",__FILE__, proj);
|
||||
|
||||
g = "GEOMETRY approximations";
|
||||
|
||||
theCommands.Add("appro", "appro result nbpoint [curve]",__FILE__, appro);
|
||||
theCommands.Add("surfapp","surfapp result nbupoint nbvpoint x y z ....",
|
||||
__FILE__,
|
||||
surfapp);
|
||||
theCommands.Add("grilapp",
|
||||
"grilapp result nbupoint nbvpoint X0 dX Y0 dY z11 z12 .. z1nu .... ",
|
||||
__FILE__,grilapp);
|
||||
|
||||
g = "GEOMETRY curves and surfaces analysis";
|
||||
|
||||
theCommands.Add("extrema", "extrema curve/surface curve/surface",__FILE__,extrema);
|
||||
theCommands.Add("totalextcc", "totalextcc curve curve",__FILE__,totalextcc);
|
||||
}
|
827
src/GeometryTest/GeometryTest_ConstraintCommands.cxx
Executable file
827
src/GeometryTest/GeometryTest_ConstraintCommands.cxx
Executable file
@@ -0,0 +1,827 @@
|
||||
// File: DrawTrSurf_3.cxx
|
||||
// Created: Thu Aug 12 19:33:52 1993
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@topsn3>
|
||||
// JPI : Commande smooth transferee dans GeomliteTest
|
||||
// PMN : Ajout de la commande smooth
|
||||
// JCT : Correction d'un trap dans la commande gcarc
|
||||
|
||||
#include <Standard_Stream.hxx>
|
||||
|
||||
#include <GeometryTest.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Geom2dGcc_Circ2d2TanRad.hxx>
|
||||
#include <Geom2dGcc_Circ2d3Tan.hxx>
|
||||
#include <Geom2dGcc_Circ2d2TanOn.hxx>
|
||||
#include <Geom2dGcc_Circ2dTanOnRad.hxx>
|
||||
#include <Geom2dGcc_Circ2dTanCen.hxx>
|
||||
#include <Geom2dGcc_Lin2d2Tan.hxx>
|
||||
#include <Geom2dGcc_Lin2dTanObl.hxx>
|
||||
#include <Geom2dGcc.hxx>
|
||||
#include <Geom2dGcc_QualifiedCurve.hxx>
|
||||
#include <Geom2d_CartesianPoint.hxx>
|
||||
#include <Geom2d_Circle.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <GeomAPI_Interpolate.hxx>
|
||||
#include <Draw_Marker3D.hxx>
|
||||
#include <Geom2dAPI_Interpolate.hxx>
|
||||
#include <Draw_Marker2D.hxx>
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <TColgp_HArray1OfPnt2d.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <DrawTrSurf_BSplineCurve.hxx>
|
||||
#include <DrawTrSurf_BSplineCurve2d.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 <AppDef_MultiLine.hxx>
|
||||
#include <AppDef_TheVariational.hxx>
|
||||
#include <AppParCurves_HArray1OfConstraintCouple.hxx>
|
||||
#include <AppParCurves_ConstraintCouple.hxx>
|
||||
#include <GC_MakeSegment.hxx>
|
||||
#include <GC_MakeArcOfCircle.hxx>
|
||||
|
||||
//#ifdef WNT
|
||||
#include <stdio.h>
|
||||
#ifdef WNT
|
||||
Standard_IMPORT Draw_Viewer dout;
|
||||
#endif
|
||||
Standard_IMPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color);
|
||||
|
||||
|
||||
static Standard_Integer solutions(Draw_Interpretor& di,
|
||||
Geom2dGcc_Circ2d2TanRad& ct3, const char* name)
|
||||
{
|
||||
char solname[200];
|
||||
|
||||
Draw_Color col = DrawTrSurf_CurveColor(Draw_Color(Draw_vert));
|
||||
DrawTrSurf_CurveColor(col);
|
||||
|
||||
if (ct3.IsDone()) {
|
||||
for (Standard_Integer i = 1 ; i <= ct3.NbSolutions() ; i++) {
|
||||
Handle(Geom2d_Circle) C = new Geom2d_Circle(ct3.ThisSolution(i));
|
||||
sprintf(solname,"%s_%d",name,i);
|
||||
char* temp = solname; // pour portage WNT
|
||||
DrawTrSurf::Set(temp,C);
|
||||
di << solname << " ";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
di << "Circ2d2TanRad Not done";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static Standard_Integer solutions(Draw_Interpretor& di,
|
||||
Geom2dGcc_Circ2d3Tan& ct3, const char* name)
|
||||
{
|
||||
char solname[200];
|
||||
|
||||
Draw_Color col = DrawTrSurf_CurveColor(Draw_Color(Draw_vert));
|
||||
DrawTrSurf_CurveColor(col);
|
||||
|
||||
if (ct3.IsDone()) {
|
||||
for (Standard_Integer i = 1 ; i <= ct3.NbSolutions() ; i++) {
|
||||
Handle(Geom2d_Circle) C = new Geom2d_Circle(ct3.ThisSolution(i));
|
||||
sprintf(solname,"%s_%d",name,i);
|
||||
char* temp = solname; // pour portage WNT
|
||||
DrawTrSurf::Set(temp,C);
|
||||
di << solname << " ";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
di << "Circ2d3Tan Not done";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : cirtang
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer cirtang (Draw_Interpretor& di,Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 5) return 1;
|
||||
|
||||
Handle(Geom2d_Curve) C1 = DrawTrSurf::GetCurve2d(a[2]);
|
||||
Handle(Geom2d_Curve) C2 = DrawTrSurf::GetCurve2d(a[3]);
|
||||
Handle(Geom2d_Curve) C3 = DrawTrSurf::GetCurve2d(a[4]);
|
||||
gp_Pnt2d P1,P2,P3;
|
||||
Standard_Boolean ip1 = DrawTrSurf::GetPoint2d(a[2],P1);
|
||||
Standard_Boolean ip2 = DrawTrSurf::GetPoint2d(a[3],P2);
|
||||
Standard_Boolean ip3 = DrawTrSurf::GetPoint2d(a[4],P3);
|
||||
|
||||
Standard_Real tol = Precision::Confusion();
|
||||
if (n > 5) tol = atof(a[5]);
|
||||
|
||||
|
||||
if (!C1.IsNull()) {
|
||||
// C-...
|
||||
if (!C2.IsNull()) {
|
||||
// C-C-...
|
||||
if (!C3.IsNull()) {
|
||||
// C-C-C
|
||||
Geom2dGcc_Circ2d3Tan ct3(Geom2dGcc::Unqualified(C1),
|
||||
Geom2dGcc::Unqualified(C2),
|
||||
Geom2dGcc::Unqualified(C3),
|
||||
tol,0,0,0);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else if (ip3) {
|
||||
// C-C-P
|
||||
Geom2dGcc_Circ2d3Tan ct3(Geom2dGcc::Unqualified(C1),
|
||||
Geom2dGcc::Unqualified(C2),
|
||||
new Geom2d_CartesianPoint(P3),
|
||||
tol,0,0);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else {
|
||||
// C-C-R
|
||||
Geom2dGcc_Circ2d2TanRad ct3(Geom2dGcc::Unqualified(C1),
|
||||
Geom2dGcc::Unqualified(C2),
|
||||
atof(a[4]),tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
}
|
||||
else if (ip2) {
|
||||
// C-P-..
|
||||
if (!C3.IsNull()) {
|
||||
// C-P-C
|
||||
Geom2dGcc_Circ2d3Tan ct3(Geom2dGcc::Unqualified(C1),
|
||||
Geom2dGcc::Unqualified(C3),
|
||||
new Geom2d_CartesianPoint(P2),
|
||||
tol,0,0);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else if (ip3) {
|
||||
// C-P-P
|
||||
Geom2dGcc_Circ2d3Tan ct3(Geom2dGcc::Unqualified(C1),
|
||||
new Geom2d_CartesianPoint(P2),
|
||||
new Geom2d_CartesianPoint(P3),
|
||||
tol,0);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else {
|
||||
// C-P-R
|
||||
Geom2dGcc_Circ2d2TanRad ct3(Geom2dGcc::Unqualified(C1),
|
||||
new Geom2d_CartesianPoint(P2),
|
||||
atof(a[4]),tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
// C-R-..
|
||||
if (!C3.IsNull()) {
|
||||
// C-R-C
|
||||
Geom2dGcc_Circ2d2TanRad ct3(Geom2dGcc::Unqualified(C1),
|
||||
Geom2dGcc::Unqualified(C3),
|
||||
atof(a[3]),
|
||||
tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else if (ip3) {
|
||||
// C-R-P
|
||||
Geom2dGcc_Circ2d2TanRad ct3(Geom2dGcc::Unqualified(C1),
|
||||
new Geom2d_CartesianPoint(P3),
|
||||
atof(a[3]),
|
||||
tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else {
|
||||
// C-R-R
|
||||
di << "Curve, radius, radius ???"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (ip1) {
|
||||
// P-...
|
||||
if (!C2.IsNull()) {
|
||||
// P-C-...
|
||||
if (!C3.IsNull()) {
|
||||
// P-C-C
|
||||
Geom2dGcc_Circ2d3Tan ct3(Geom2dGcc::Unqualified(C2),
|
||||
Geom2dGcc::Unqualified(C3),
|
||||
new Geom2d_CartesianPoint(P1),
|
||||
tol,0,0);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else if (ip3) {
|
||||
// P-C-P
|
||||
Geom2dGcc_Circ2d3Tan ct3(Geom2dGcc::Unqualified(C2),
|
||||
new Geom2d_CartesianPoint(P1),
|
||||
new Geom2d_CartesianPoint(P3),
|
||||
tol,0);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else {
|
||||
// P-C-R
|
||||
Geom2dGcc_Circ2d2TanRad ct3(Geom2dGcc::Unqualified(C2),
|
||||
new Geom2d_CartesianPoint(P1),
|
||||
atof(a[4]),tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
}
|
||||
else if (ip2) {
|
||||
// P-P-..
|
||||
if (!C3.IsNull()) {
|
||||
// P-P-C
|
||||
Geom2dGcc_Circ2d3Tan ct3(Geom2dGcc::Unqualified(C3),
|
||||
new Geom2d_CartesianPoint(P1),
|
||||
new Geom2d_CartesianPoint(P2),
|
||||
tol,0);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else if (ip3) {
|
||||
// P-P-P
|
||||
Geom2dGcc_Circ2d3Tan ct3(new Geom2d_CartesianPoint(P1),
|
||||
new Geom2d_CartesianPoint(P2),
|
||||
new Geom2d_CartesianPoint(P3),
|
||||
tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else {
|
||||
// P-P-R
|
||||
Geom2dGcc_Circ2d2TanRad ct3(new Geom2d_CartesianPoint(P1),
|
||||
new Geom2d_CartesianPoint(P2),
|
||||
atof(a[4]),tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
// P-R-..
|
||||
if (!C3.IsNull()) {
|
||||
// P-R-C
|
||||
Geom2dGcc_Circ2d2TanRad ct3(Geom2dGcc::Unqualified(C3),
|
||||
new Geom2d_CartesianPoint(P1),
|
||||
atof(a[3]),
|
||||
tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else if (ip3) {
|
||||
// P-R-P
|
||||
Geom2dGcc_Circ2d2TanRad ct3(new Geom2d_CartesianPoint(P1),
|
||||
new Geom2d_CartesianPoint(P3),
|
||||
atof(a[3]),
|
||||
tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else {
|
||||
// P-R-R
|
||||
di << "Point, radius, radius ???"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
// R-...
|
||||
if (!C2.IsNull()) {
|
||||
// R-C-...
|
||||
if (!C3.IsNull()) {
|
||||
// R-C-C
|
||||
Geom2dGcc_Circ2d2TanRad ct3(Geom2dGcc::Unqualified(C2),
|
||||
Geom2dGcc::Unqualified(C3),
|
||||
atof(a[2]),
|
||||
tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else if (ip3) {
|
||||
// R-C-P
|
||||
Geom2dGcc_Circ2d2TanRad ct3(Geom2dGcc::Unqualified(C2),
|
||||
new Geom2d_CartesianPoint(P3),
|
||||
atof(a[2]),
|
||||
tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else {
|
||||
// R-C-R
|
||||
di << "Radius - Curve - Radius ??"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (ip2) {
|
||||
// R-P-..
|
||||
if (!C3.IsNull()) {
|
||||
// R-P-C
|
||||
Geom2dGcc_Circ2d2TanRad ct3(Geom2dGcc::Unqualified(C3),
|
||||
new Geom2d_CartesianPoint(P2),
|
||||
atof(a[2]),
|
||||
tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else if (ip3) {
|
||||
// R-P-P
|
||||
Geom2dGcc_Circ2d2TanRad ct3(new Geom2d_CartesianPoint(P2),
|
||||
new Geom2d_CartesianPoint(P3),
|
||||
atof(a[2]),
|
||||
tol);
|
||||
return solutions(di,ct3,a[1]);
|
||||
}
|
||||
|
||||
else {
|
||||
// R-P-R
|
||||
di << "Radius - Point - Radius ??"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
// R-R-..
|
||||
di << "radius, radius ???"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : lintang
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer lintang (Draw_Interpretor& di,Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 4) return 1;
|
||||
|
||||
Handle(Geom2d_Curve) C1 = DrawTrSurf::GetCurve2d(a[2]);
|
||||
Handle(Geom2d_Curve) C2 = DrawTrSurf::GetCurve2d(a[3]);
|
||||
|
||||
char solname[200];
|
||||
|
||||
if (C1.IsNull() || C2.IsNull())
|
||||
return 1;
|
||||
|
||||
Draw_Color col = DrawTrSurf_CurveColor(Draw_Color(Draw_vert));
|
||||
|
||||
if (n >= 5) {
|
||||
Handle(Geom2d_Line) L = Handle(Geom2d_Line)::DownCast(C2);
|
||||
if (L.IsNull()) {
|
||||
di << "Second argument must be a line";
|
||||
return 1;
|
||||
}
|
||||
Standard_Real ang = atof(a[4]) * PI180;
|
||||
Geom2dGcc_Lin2dTanObl ct3(Geom2dGcc::Unqualified(C1),
|
||||
L->Lin2d(),
|
||||
Precision::Angular(),
|
||||
(C1->FirstParameter()+C1->LastParameter())/2.,
|
||||
ang);
|
||||
if (ct3.IsDone()) {
|
||||
for (Standard_Integer i = 1 ; i <= ct3.NbSolutions() ; i++) {
|
||||
Handle(Geom2d_Line) LS = new Geom2d_Line(ct3.ThisSolution(i));
|
||||
sprintf(solname,"%s_%d",a[1],i);
|
||||
char* temp = solname; // pour portage WNT
|
||||
DrawTrSurf::Set(temp,LS);
|
||||
di << solname << " ";
|
||||
}
|
||||
}
|
||||
else
|
||||
di << "Lin2dTanObl Not done" << "\n";
|
||||
}
|
||||
else {
|
||||
Geom2dGcc_Lin2d2Tan ct3(Geom2dGcc::Unqualified(C1),
|
||||
Geom2dGcc::Unqualified(C2),
|
||||
Precision::Angular(),
|
||||
(C1->FirstParameter()+C1->LastParameter())/2.,
|
||||
(C2->FirstParameter()+C2->LastParameter())/2.);
|
||||
if (ct3.IsDone()) {
|
||||
for (Standard_Integer i = 1 ; i <= ct3.NbSolutions() ; i++) {
|
||||
Handle(Geom2d_Line) LS = new Geom2d_Line(ct3.ThisSolution(i));
|
||||
sprintf(solname,"%s_%d",a[1],i);
|
||||
char* temp = solname; // pour portage WNT
|
||||
DrawTrSurf::Set(temp,LS);
|
||||
di << solname << " ";
|
||||
}
|
||||
}
|
||||
else
|
||||
di << "Lin2d2Tan Not done" << "\n";
|
||||
}
|
||||
|
||||
DrawTrSurf_CurveColor(col);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==================================================================================
|
||||
static Standard_Integer interpol (Draw_Interpretor& di,Standard_Integer n, const char** a)
|
||||
//==================================================================================
|
||||
{
|
||||
if (n == 1) {
|
||||
di <<"give a name to your curve !" << "\n";
|
||||
return 0;
|
||||
}
|
||||
if (n == 2) {
|
||||
Standard_Integer id,XX,YY,b, i, j;
|
||||
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)) {
|
||||
Handle(Draw_Marker3D) mark;
|
||||
Handle(TColgp_HArray1OfPnt) Points = new TColgp_HArray1OfPnt(1, 1);
|
||||
P.SetCoord((Standard_Real)XX/zoom,(Standard_Real)YY/zoom, 0.0);
|
||||
Points->SetValue(1 , P);
|
||||
Handle(TColgp_HArray1OfPnt) ThePoints = new TColgp_HArray1OfPnt(1, 2);
|
||||
ThePoints->SetValue(1 , P);
|
||||
mark = new Draw_Marker3D(Points->Value(1), Draw_X, Draw_vert);
|
||||
dout << mark;
|
||||
dout.Flush();
|
||||
Handle(Geom_BSplineCurve) C;
|
||||
i = 1;
|
||||
|
||||
while (b != 3) {
|
||||
dout.Select(id,XX,YY,b, Standard_False);
|
||||
P.SetCoord((Standard_Real)XX/zoom,(Standard_Real)YY/zoom, 0.0);
|
||||
ThePoints->SetValue(i+1, P);
|
||||
newcurve = Standard_False;
|
||||
if (!(ThePoints->Value(i)).IsEqual(ThePoints->Value(i+1), 1.e-06)) {
|
||||
if (b == 1) {
|
||||
i++;
|
||||
mark = new Draw_Marker3D(ThePoints->Value(i), Draw_X, Draw_vert);
|
||||
dout << mark;
|
||||
dout.Flush();
|
||||
Points =
|
||||
new TColgp_HArray1OfPnt(ThePoints->Lower(),ThePoints->Upper());
|
||||
Points->ChangeArray1() = ThePoints->Array1();
|
||||
newcurve = Standard_True;
|
||||
}
|
||||
GeomAPI_Interpolate anInterpolator(ThePoints,
|
||||
Standard_False,
|
||||
1.0e-5);
|
||||
anInterpolator.Perform() ;
|
||||
if (anInterpolator.IsDone()) {
|
||||
C = anInterpolator.Curve() ;
|
||||
Handle(DrawTrSurf_BSplineCurve)
|
||||
DC = new DrawTrSurf_BSplineCurve(C);
|
||||
DC->ClearPoles();
|
||||
DC->ClearKnots();
|
||||
Draw::Set(a[1], DC);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
if (newcurve) {
|
||||
ThePoints = new TColgp_HArray1OfPnt(1, i+1);
|
||||
for (j = 1; j <= i; j++) ThePoints->SetValue(j, Points->Value(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
GeomAPI_Interpolate anInterpolator(ThePoints,
|
||||
Standard_False,
|
||||
1.0e-5);
|
||||
anInterpolator.Perform() ;
|
||||
if (anInterpolator.IsDone()) {
|
||||
C = anInterpolator.Curve() ;
|
||||
DrawTrSurf::Set(a[1], C);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Handle(Draw_Marker2D) mark;
|
||||
Handle(TColgp_HArray1OfPnt2d) Points = new TColgp_HArray1OfPnt2d(1, 1);
|
||||
P2d.SetCoord((Standard_Real)XX/zoom,(Standard_Real)YY/zoom);
|
||||
Points->SetValue(1 , P2d);
|
||||
Handle(TColgp_HArray1OfPnt2d) ThePoints = new TColgp_HArray1OfPnt2d(1, 2);
|
||||
ThePoints->SetValue(1, P2d);
|
||||
mark = new Draw_Marker2D(P2d, Draw_X, Draw_vert);
|
||||
dout << mark;
|
||||
dout.Flush();
|
||||
Handle(Geom2d_BSplineCurve) C;
|
||||
i = 1;
|
||||
|
||||
while (b != 3) {
|
||||
dout.Select(id,XX,YY,b, Standard_False);
|
||||
P2d.SetCoord((Standard_Real)XX/zoom,(Standard_Real)YY/zoom);
|
||||
ThePoints->SetValue(i+1, P2d);
|
||||
newcurve = Standard_False;
|
||||
if (!(ThePoints->Value(i)).IsEqual(ThePoints->Value(i+1), 1.e-06)) {
|
||||
if (b == 1) {
|
||||
i++;
|
||||
mark = new Draw_Marker2D(P2d, Draw_X, Draw_vert);
|
||||
dout << mark;
|
||||
dout.Flush();
|
||||
Points =
|
||||
new TColgp_HArray1OfPnt2d(ThePoints->Lower(),ThePoints->Upper());
|
||||
Points->ChangeArray1() = ThePoints->Array1();
|
||||
newcurve = Standard_True;
|
||||
}
|
||||
Geom2dAPI_Interpolate a2dInterpolator(ThePoints,
|
||||
Standard_False,
|
||||
1.0e-5) ;
|
||||
a2dInterpolator.Perform() ;
|
||||
if (a2dInterpolator.IsDone()) {
|
||||
C = a2dInterpolator.Curve() ;
|
||||
|
||||
Handle(DrawTrSurf_BSplineCurve2d)
|
||||
DC = new DrawTrSurf_BSplineCurve2d(C);
|
||||
DC->ClearPoles();
|
||||
DC->ClearKnots();
|
||||
Draw::Set(a[1], DC);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
|
||||
if (newcurve) {
|
||||
ThePoints = new TColgp_HArray1OfPnt2d(1, i+1);
|
||||
for (j = 1; j <= i; j++) ThePoints->SetValue(j, Points->Value(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
Geom2dAPI_Interpolate a2dInterpolator(Points,
|
||||
Standard_False,
|
||||
1.0e-5) ;
|
||||
a2dInterpolator.Perform() ;
|
||||
if (a2dInterpolator.IsDone()) {
|
||||
C = a2dInterpolator.Curve() ;
|
||||
|
||||
DrawTrSurf::Set(a[1], C);
|
||||
dout.RepaintView(id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (n == 3) {
|
||||
// lecture du fichier.
|
||||
// nbpoints, 2d ou 3d, puis valeurs.
|
||||
const char* nomfic = a[2];
|
||||
ifstream iFile(nomfic, ios::in);
|
||||
if (!iFile) return 1;
|
||||
Standard_Integer nbp, i;
|
||||
Standard_Real x, y, z;
|
||||
iFile >> nbp;
|
||||
char dimen[3];
|
||||
iFile >> dimen;
|
||||
if (!strcmp(dimen,"3d")) {
|
||||
Handle_TColgp_HArray1OfPnt Point =
|
||||
new TColgp_HArray1OfPnt(1, nbp);
|
||||
for (i = 1; i <= nbp; i++) {
|
||||
iFile >> x >> y >> z;
|
||||
Point->SetValue(i, gp_Pnt(x, y, z));
|
||||
}
|
||||
GeomAPI_Interpolate anInterpolator(Point,
|
||||
Standard_False,
|
||||
1.0e-5) ;
|
||||
anInterpolator.Perform() ;
|
||||
if (anInterpolator.IsDone()) {
|
||||
Handle(Geom_BSplineCurve) C =
|
||||
anInterpolator.Curve();
|
||||
DrawTrSurf::Set(a[1], C);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(dimen,"2d")) {
|
||||
Handle(TColgp_HArray1OfPnt2d) PointPtr =
|
||||
new TColgp_HArray1OfPnt2d(1, nbp);
|
||||
for (i = 1; i <= nbp; i++) {
|
||||
iFile >> x >> y;
|
||||
PointPtr->SetValue(i, gp_Pnt2d(x, y));
|
||||
}
|
||||
Geom2dAPI_Interpolate a2dInterpolator(PointPtr,
|
||||
Standard_False,
|
||||
1.0e-5);
|
||||
a2dInterpolator.Perform() ;
|
||||
if (a2dInterpolator.IsDone()) {
|
||||
Handle(Geom2d_BSplineCurve) C = a2dInterpolator.Curve() ;
|
||||
DrawTrSurf::Set(a[1], C);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer tanginterpol (Draw_Interpretor& di,
|
||||
Standard_Integer n,
|
||||
const char** a)
|
||||
{
|
||||
|
||||
|
||||
if (n < 4)
|
||||
return 1;
|
||||
|
||||
Standard_Integer
|
||||
ii,
|
||||
jj,
|
||||
// num_knots,
|
||||
// degree,
|
||||
num_tangents,
|
||||
num_read,
|
||||
num_start,
|
||||
num_parameters ;
|
||||
|
||||
|
||||
Standard_Real
|
||||
// delta,
|
||||
tolerance;
|
||||
// parameter ;
|
||||
|
||||
Standard_Boolean periodic_flag = Standard_False ;
|
||||
gp_Pnt a_point ;
|
||||
gp_Vec a_vector ;
|
||||
tolerance = 1.0e-5 ;
|
||||
|
||||
|
||||
|
||||
|
||||
Handle(Geom_BSplineCurve) NewCurvePtr ;
|
||||
|
||||
|
||||
|
||||
|
||||
num_read = 2 ;
|
||||
if (strcmp(a[num_read],"p") == 0) {
|
||||
periodic_flag = Standard_True ;
|
||||
num_read += 1 ;
|
||||
}
|
||||
num_parameters = atoi(a[num_read]) ;
|
||||
|
||||
if (num_parameters < 2) {
|
||||
num_parameters = 2 ;
|
||||
}
|
||||
if ( n < num_parameters * 3 + num_read) {
|
||||
return 1 ;
|
||||
}
|
||||
Handle_TColgp_HArray1OfPnt PointsArrayPtr=
|
||||
new TColgp_HArray1OfPnt(1,num_parameters) ;
|
||||
|
||||
num_tangents = ((n - num_read) / 3) - num_parameters ;
|
||||
num_tangents = Max (0,num_tangents) ;
|
||||
num_tangents = Min (num_parameters, num_tangents) ;
|
||||
ii = 1 ;
|
||||
num_start = num_read ;
|
||||
num_read += 1 ;
|
||||
while (num_read <= num_parameters * 3 + num_start ) {
|
||||
for (jj = 1 ; jj <= 3 ; jj++) {
|
||||
a_point.SetCoord(jj,atof(a[num_read])) ;
|
||||
num_read += 1 ;
|
||||
}
|
||||
PointsArrayPtr->SetValue(ii,a_point) ;
|
||||
ii += 1 ;
|
||||
}
|
||||
GeomAPI_Interpolate anInterpolator(PointsArrayPtr,
|
||||
periodic_flag,
|
||||
tolerance) ;
|
||||
|
||||
if (num_tangents > 0) {
|
||||
TColgp_Array1OfVec TangentsArray(1,num_parameters) ;
|
||||
Handle_TColStd_HArray1OfBoolean
|
||||
TangentFlagsPtr =
|
||||
new TColStd_HArray1OfBoolean(1,num_parameters) ;
|
||||
|
||||
for (ii = 1 ; ii <= num_tangents ; ii++) {
|
||||
TangentFlagsPtr->SetValue(ii,Standard_True) ;
|
||||
}
|
||||
for (ii = num_tangents + 1 ; ii <= num_parameters ; ii++) {
|
||||
TangentFlagsPtr->SetValue(ii,Standard_False) ;
|
||||
}
|
||||
ii = 1 ;
|
||||
while (ii <= num_tangents) {
|
||||
for (jj = 1 ; jj <= 3 ; jj++) {
|
||||
a_vector.SetCoord(jj,atof(a[num_read])) ;
|
||||
num_read += 1 ;
|
||||
}
|
||||
TangentsArray.SetValue(ii,a_vector) ;
|
||||
ii += 1 ;
|
||||
}
|
||||
|
||||
|
||||
anInterpolator.Load(TangentsArray,
|
||||
TangentFlagsPtr) ;
|
||||
}
|
||||
anInterpolator.Perform() ;
|
||||
if (anInterpolator.IsDone()) {
|
||||
NewCurvePtr =
|
||||
anInterpolator.Curve() ;
|
||||
|
||||
DrawTrSurf::Set(a[1],
|
||||
NewCurvePtr) ;
|
||||
di << a[2] << " " ;
|
||||
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//==================================================================================
|
||||
static Standard_Integer gcarc (Draw_Interpretor& di,Standard_Integer n, const char** a)
|
||||
//==================================================================================
|
||||
{
|
||||
if (n >= 5) {
|
||||
gp_Pnt P1,P2,P3,P4;
|
||||
if (!strcmp(a[2], "seg")) {
|
||||
if (DrawTrSurf::GetPoint(a[3], P1)) {
|
||||
if (DrawTrSurf::GetPoint(a[4], P2)) {
|
||||
Handle(Geom_Curve) theline = GC_MakeSegment(P1,P2).Value();
|
||||
DrawTrSurf::Set(a[1], theline);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcmp(a[2], "cir")) {
|
||||
if (DrawTrSurf::GetPoint(a[3], P1)) {
|
||||
if (DrawTrSurf::GetPoint(a[4], P2)) {
|
||||
if (DrawTrSurf::GetPoint(a[5], P3)) {
|
||||
// if (DrawTrSurf::GetPoint(a[6], P4)) {
|
||||
if (n>6) {
|
||||
#ifdef DEB
|
||||
Standard_Boolean ip4 =
|
||||
#endif
|
||||
DrawTrSurf::GetPoint(a[6], P4);
|
||||
gp_Vec V1 = gp_Vec(P2,P3);
|
||||
Handle(Geom_Curve)thearc = GC_MakeArcOfCircle(P1,V1,P4).Value();
|
||||
DrawTrSurf::Set(a[1], thearc);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
Handle(Geom_Curve)thearc = GC_MakeArcOfCircle(P1,P2,P3).Value();
|
||||
DrawTrSurf::Set(a[1], thearc);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
di <<"give a name for arc and the type seg or cir then" << "\n";
|
||||
di <<"give passing points p1 p2 for seg p1 p2 p3 or p1 p2 p3 p4 for cir (p2 p3 is a tgtvec)!" << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConstraintCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
||||
void GeometryTest::ConstraintCommands(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("cirtang",
|
||||
"cirtang cname curve/point/radius curve/point/radius curve/point/radius",
|
||||
__FILE__,
|
||||
cirtang,g);
|
||||
|
||||
theCommands.Add("lintan",
|
||||
"lintan lname curve1 curve2 [angle]",
|
||||
__FILE__,
|
||||
lintang,g);
|
||||
|
||||
|
||||
theCommands.Add("interpol",
|
||||
"interpol cname [fic]",
|
||||
__FILE__,
|
||||
interpol, g);
|
||||
theCommands.Add("tanginterpol",
|
||||
"tanginterpol curve [p] num_points points [tangents] modifier p = periodic",
|
||||
__FILE__,
|
||||
tanginterpol,g);
|
||||
|
||||
theCommands.Add("gcarc",
|
||||
"gcarc name seg/cir p1 p2 p3 p4",
|
||||
__FILE__,
|
||||
gcarc,g);
|
||||
}
|
428
src/GeometryTest/GeometryTest_ContinuityCommands.cxx
Executable file
428
src/GeometryTest/GeometryTest_ContinuityCommands.cxx
Executable file
@@ -0,0 +1,428 @@
|
||||
// File: Test.cxx
|
||||
// Created: Wed Jul 31 10:35:38 1996
|
||||
// Author: Herve LOUESSARD
|
||||
// <hl1@sgi29>
|
||||
|
||||
|
||||
|
||||
#include <LocalAnalysis.hxx>
|
||||
#include <LocalAnalysis_SurfaceContinuity.hxx>
|
||||
#include <LocalAnalysis_CurveContinuity.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <GeometryTest.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
|
||||
/*********************************************************************************/
|
||||
void InitEpsSurf(Standard_Real& epsnl,Standard_Real& epsdis, Standard_Real& epsangk1,
|
||||
Standard_Real& epsangk2, Standard_Real& epsangn1,
|
||||
Standard_Real& perce,Standard_Real& maxlen )
|
||||
{
|
||||
epsnl = 0.001;
|
||||
epsdis = 0.001;
|
||||
epsangk1 = 0.001 ;
|
||||
epsangk2 = 0.001;
|
||||
epsangn1 = 0.001 ;
|
||||
perce = 0.01;
|
||||
maxlen = 10000 ;
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void InitEpsCurv(Standard_Real& epsnl ,Standard_Real& epsdis, Standard_Real& epsangk1,
|
||||
Standard_Real& epsangk2, Standard_Real& epsangg1,
|
||||
Standard_Real& epsangg2,Standard_Real& percent,
|
||||
Standard_Real& maxlen)
|
||||
{
|
||||
epsnl = 0.001 ;
|
||||
epsdis = 0.001 ;
|
||||
epsangk1= 0.001 ;
|
||||
epsangk2= 0.001;
|
||||
epsangg1= 0.001 ;
|
||||
epsangg2= 0.001 ;
|
||||
percent= 0.01;
|
||||
maxlen= 10000;
|
||||
}
|
||||
/*********************************************************************************/
|
||||
|
||||
static Standard_Integer surfaceCcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{ Standard_Real U1, U2, V1, V2, u1, u2, v1, v2;
|
||||
GeomAbs_Shape TypeCont;
|
||||
Standard_Integer ord;
|
||||
Standard_Boolean b1, b2, b3, b4;
|
||||
Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
|
||||
if (n<8) return 1;
|
||||
|
||||
InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
|
||||
|
||||
Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
|
||||
if (surf1.IsNull()) return 1 ;
|
||||
|
||||
Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
|
||||
if (surf2.IsNull()) return 1;
|
||||
|
||||
U1 = atof(a[3]);
|
||||
U2 = atof(a[6]);
|
||||
V1 = atof(a[4]);
|
||||
V2 = atof(a[7]);
|
||||
|
||||
ord = atoi(a[1]);
|
||||
|
||||
surf1->Bounds(u1, u2, v1, v2);
|
||||
b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
|
||||
b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
|
||||
|
||||
surf2->Bounds(u1, u2, v1, v2);
|
||||
b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
|
||||
b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
|
||||
|
||||
if (!((b1 && b2)&&(b3 && b4))) return 1;
|
||||
|
||||
|
||||
switch ( ord )
|
||||
{ case 0 : { TypeCont=GeomAbs_C0;
|
||||
switch(n)
|
||||
{ case 10 : epsC0= atof(a[9]);
|
||||
case 9 : epsnl = atof(a[8]);
|
||||
case 8 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
|
||||
TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
}
|
||||
break;
|
||||
case 1 : { TypeCont=GeomAbs_C1;
|
||||
switch(n)
|
||||
{ case 11 : epsC1=atof(a[10]);
|
||||
case 10 : epsC0= atof(a[9]);
|
||||
case 9 : epsnl = atof(a[8]);
|
||||
case 8 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
|
||||
TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
|
||||
}
|
||||
break;
|
||||
case 2 : { TypeCont=GeomAbs_C2;
|
||||
switch(n)
|
||||
{
|
||||
case 12 : epsC2= atof(a[11]);
|
||||
case 11 : epsC1=atof(a[10]);
|
||||
case 10 : epsC0= atof(a[9]);
|
||||
case 9 : epsnl = atof(a[8]);
|
||||
case 8 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
|
||||
TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default : {}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
|
||||
static Standard_Integer surfaceGcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{ Standard_Real U1, U2, V1, V2,u1, u2, v1, v2;
|
||||
GeomAbs_Shape TypeCont;
|
||||
Standard_Integer ord;
|
||||
Standard_Boolean b1, b2, b3, b4;
|
||||
Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
|
||||
|
||||
if (n<8) return 1;
|
||||
InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
|
||||
|
||||
Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
|
||||
if (surf1.IsNull()) return 1 ;
|
||||
|
||||
Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
|
||||
if (surf2.IsNull()) return 1;
|
||||
|
||||
U1 = atof(a[3]);
|
||||
U2 = atof(a[6]);
|
||||
V1 = atof(a[4]);
|
||||
V2 = atof(a[7]);
|
||||
|
||||
ord = atoi(a[1]);
|
||||
|
||||
surf1->Bounds(u1, u2, v1, v2);
|
||||
b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
|
||||
b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
|
||||
|
||||
surf2->Bounds(u1, u2, v1, v2);
|
||||
b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
|
||||
b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
|
||||
|
||||
if (!((b1 && b2)&&(b3 && b4))) return 1;
|
||||
|
||||
|
||||
switch ( ord )
|
||||
{
|
||||
case 1 : { TypeCont=GeomAbs_G1;
|
||||
switch(n)
|
||||
{ case 11 : epsG1=atof(a[10]);
|
||||
case 10 : epsC0= atof(a[9]);
|
||||
case 9 : epsnl = atof(a[8]);
|
||||
case 8 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
|
||||
TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
|
||||
}
|
||||
break;
|
||||
case 2 : { TypeCont=GeomAbs_G2;
|
||||
switch(n)
|
||||
{ case 13 : maxlen =atof (a[12]);
|
||||
case 12 : perce=atof(a[11]);
|
||||
case 11 : epsG1=atof(a[10]);
|
||||
case 10 : epsC0= atof(a[9]);
|
||||
case 9 : epsnl = atof(a[8]);
|
||||
case 8 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
|
||||
TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default : {}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
|
||||
static Standard_Integer curveGcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{ Standard_Real U1, U2, u1, u2;
|
||||
GeomAbs_Shape TypeCont;
|
||||
Standard_Integer ord;
|
||||
Standard_Boolean b1, b2;
|
||||
Standard_Real epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
|
||||
if (n<6) return 1;
|
||||
|
||||
Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
|
||||
if (curv1.IsNull()) return 1;
|
||||
Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
|
||||
if (curv2.IsNull()) return 1;
|
||||
|
||||
U1 = atof(a[3]);
|
||||
U2 = atof(a[5]);
|
||||
|
||||
ord = atoi(a[1]);
|
||||
|
||||
u1=curv1->FirstParameter();
|
||||
u2=curv1->LastParameter();
|
||||
b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
|
||||
|
||||
u1=curv2->FirstParameter();
|
||||
u2=curv2->LastParameter();
|
||||
b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
|
||||
|
||||
if (!(b1 && b2)) return 1;
|
||||
|
||||
InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
|
||||
switch ( ord )
|
||||
{
|
||||
case 1 : {
|
||||
switch(n)
|
||||
{ case 9 : epsG1=atof(a[8]);
|
||||
case 8 : epsC0= atof(a[7]);
|
||||
case 7 : epsnl = atof(a[6]);
|
||||
case 6 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
TypeCont=GeomAbs_G1;
|
||||
LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
|
||||
epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen );
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
}
|
||||
break;
|
||||
case 2 : {
|
||||
TypeCont=GeomAbs_G2;
|
||||
switch(n)
|
||||
{case 12 :maxlen =atof(a[11]);
|
||||
case 11 :percent=atof(a[10]);
|
||||
case 10 : epsG2= atof(a[9]);
|
||||
case 9 : epsG1=atof(a[8]);
|
||||
case 8 : epsC0= atof(a[7]);
|
||||
case 7 : epsnl = atof(a[6]);
|
||||
case 6 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
|
||||
epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen );
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
}
|
||||
break;
|
||||
default : {}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
|
||||
static Standard_Integer curveCcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{ Standard_Real U1, U2, u1, u2;
|
||||
GeomAbs_Shape TypeCont;
|
||||
Standard_Integer ord;
|
||||
Standard_Boolean b1, b2;
|
||||
Standard_Real epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
|
||||
if (n<6) return 1;
|
||||
|
||||
Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
|
||||
if (curv1.IsNull()) return 1;
|
||||
Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
|
||||
if (curv2.IsNull()) return 1;
|
||||
|
||||
U1 = atof(a[3]);
|
||||
U2 = atof(a[5]);
|
||||
|
||||
ord = atoi(a[1]);
|
||||
|
||||
u1=curv1->FirstParameter();
|
||||
u2=curv1->LastParameter();
|
||||
b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
|
||||
|
||||
u1=curv2->FirstParameter();
|
||||
u2=curv2->LastParameter();
|
||||
b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
|
||||
|
||||
if (!(b1 && b2)) return 1;
|
||||
|
||||
|
||||
InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
|
||||
switch ( ord )
|
||||
{ case 0 : { switch(n)
|
||||
{ case 8 : epsC0= atof(a[7]);
|
||||
case 7 : epsnl = atof(a[6]);
|
||||
case 6 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
TypeCont=GeomAbs_C0;
|
||||
LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
|
||||
epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen );
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
|
||||
} break;
|
||||
case 1 : { switch(n)
|
||||
{ case 9 : epsC1 =atof(a[8]);
|
||||
case 8 : epsC0= atof(a[7]);
|
||||
case 7 : epsnl = atof(a[6]);
|
||||
case 6 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
TypeCont=GeomAbs_C1;
|
||||
LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
|
||||
epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen );
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
|
||||
} break;
|
||||
case 2 : { TypeCont=GeomAbs_C2;
|
||||
switch(n)
|
||||
{
|
||||
case 10 : epsC2= atof(a[9]);
|
||||
case 9 : epsC1=atof(a[8]);
|
||||
case 8 : epsC0= atof(a[7]);
|
||||
case 7 : epsnl = atof(a[6]);
|
||||
case 6 : {} break;
|
||||
default : return 1;
|
||||
}
|
||||
LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
|
||||
epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen );
|
||||
//LocalAnalysis::Dump(RES,cout);
|
||||
Standard_SStream aSStream;
|
||||
LocalAnalysis::Dump(RES,aSStream);
|
||||
di << aSStream;
|
||||
}
|
||||
break;
|
||||
default : {}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/***************************************************************************/
|
||||
void GeometryTest::ContinuityCommands( 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 continuity analysis ";
|
||||
|
||||
|
||||
|
||||
theCommands.Add("surfaceCcontinuity",
|
||||
" surfaceCcontinuity order surf1 parU1 parV1 surf2 parU2 parV2 [eps_nul[ epsC0 [epsC1 [epsC2]]]]",
|
||||
__FILE__,
|
||||
surfaceCcontinuity ,g);
|
||||
|
||||
theCommands.Add("surfaceGcontinuity",
|
||||
" surfaceGcontinuity order surf1 parU1 parV1 surf2 parU2 parV2 [eps_nul[ epsG0 [epsG1[percent [maxlen]]]]",
|
||||
__FILE__,
|
||||
surfaceGcontinuity ,g);
|
||||
|
||||
theCommands.Add("curveCcontinuity",
|
||||
"curveCcontinuity order curv1 u1 curv2 u2 [epsnul [epsC0 [epsC1 [epsC2 ]]]] ",
|
||||
__FILE__,
|
||||
curveCcontinuity,g);
|
||||
|
||||
|
||||
theCommands.Add("curveGcontinuity",
|
||||
"curveGcontinuity order curv1 u1 curv2 u2 [epsnul [epsG0 [epsG1 [epsG2 [percent [maxlen ]]]]]] ",
|
||||
__FILE__,
|
||||
curveGcontinuity,g);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1523
src/GeometryTest/GeometryTest_CurveCommands.cxx
Executable file
1523
src/GeometryTest/GeometryTest_CurveCommands.cxx
Executable file
File diff suppressed because it is too large
Load Diff
366
src/GeometryTest/GeometryTest_FairCurveCommands.cxx
Executable file
366
src/GeometryTest/GeometryTest_FairCurveCommands.cxx
Executable file
@@ -0,0 +1,366 @@
|
||||
// File: GeometryTest_FairCurveCommands.cxx
|
||||
// Created: Wed Oct 9 11:09:12 1996
|
||||
// Author: Philippe MANGIN
|
||||
// <pmn@sgi29>
|
||||
|
||||
|
||||
#include <GeometryTest.ixx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <DrawTrSurf_Point.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <FairCurve_AnalysisCode.hxx>
|
||||
#include <FairCurve_Batten.hxx>
|
||||
#include <FairCurve_MinimalVariation.hxx>
|
||||
#include <DrawFairCurve_Batten.hxx>
|
||||
#include <DrawFairCurve_MinimalVariation.hxx>
|
||||
#include <string.h>
|
||||
|
||||
//=======================================================================
|
||||
Standard_Boolean IsGoodNumber(Standard_Integer argc, Standard_Integer waiting, Draw_Interpretor& di)
|
||||
//=======================================================================
|
||||
{
|
||||
// argc vaut 1 de plus, puisque argv[0] contient le nom de la commande
|
||||
if (argc != (waiting+1))
|
||||
{
|
||||
di << "Waiting "<< waiting << " arguments" << "\n";
|
||||
return Standard_False;
|
||||
}
|
||||
else
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
BattenCurve(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,6,di)) return 1;
|
||||
|
||||
const char *cp1 = argv[1];
|
||||
const char *cp2 = argv[2];
|
||||
const char *cangle1 = argv[3];
|
||||
const char *cangle2 = argv[4];
|
||||
const char *cheigth = argv[5];
|
||||
const char *BattenName = argv[6];
|
||||
|
||||
Standard_Boolean Ok;
|
||||
FairCurve_AnalysisCode Iana;
|
||||
Standard_Real a1 = atof(cangle1),
|
||||
a2 = atof(cangle2),
|
||||
h = atof(cheigth);
|
||||
gp_Pnt2d P1, P2;
|
||||
|
||||
|
||||
if (! DrawTrSurf::GetPoint2d(cp1, P1) ) return 1;
|
||||
if (! DrawTrSurf::GetPoint2d(cp2, P2) ) return 1;
|
||||
|
||||
FairCurve_Batten* Bat = new FairCurve_Batten (P1, P2, h);
|
||||
Bat->SetAngle1(a1*PI/180);
|
||||
Bat->SetAngle2(a2*PI/180);
|
||||
|
||||
Ok = Bat->Compute(Iana);
|
||||
|
||||
Handle(DrawFairCurve_Batten) aBatten = new DrawFairCurve_Batten(Bat);
|
||||
|
||||
if (aBatten.IsNull()) {
|
||||
di << " Batten null "<< "\n";
|
||||
return 1;
|
||||
}
|
||||
Draw::Set(BattenName,aBatten);
|
||||
|
||||
return 0;
|
||||
// !!! Delete of Bat have to be make in DrawFairCurve_Batten destructor !!!!!
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
MVCurve(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,6,di)) return 1;
|
||||
|
||||
const char *cp1 = argv[1];
|
||||
const char *cp2 = argv[2];
|
||||
const char *cangle1 = argv[3];
|
||||
const char *cangle2 = argv[4];
|
||||
const char *cheigth = argv[5];
|
||||
const char *MVCName = argv[6];
|
||||
|
||||
Standard_Boolean Ok;
|
||||
FairCurve_AnalysisCode Iana;
|
||||
Standard_Real a1 = atof(cangle1),
|
||||
a2 = atof(cangle2),
|
||||
h = atof(cheigth);
|
||||
gp_Pnt2d P1, P2;
|
||||
|
||||
|
||||
if (! DrawTrSurf::GetPoint2d(cp1, P1) ) return 1;
|
||||
if (! DrawTrSurf::GetPoint2d(cp2, P2) ) return 1;
|
||||
|
||||
FairCurve_MinimalVariation* MVC = new FairCurve_MinimalVariation (P1, P2, h);
|
||||
MVC->SetAngle1(a1*PI/180);
|
||||
MVC->SetAngle2(a2*PI/180);
|
||||
|
||||
Ok = MVC->Compute(Iana);
|
||||
|
||||
Handle(DrawFairCurve_MinimalVariation) aMVC = new DrawFairCurve_MinimalVariation(MVC);
|
||||
|
||||
if (aMVC.IsNull()) {
|
||||
di << " MVC null "<< "\n";
|
||||
return 1;
|
||||
}
|
||||
Draw::Set(MVCName, aMVC);
|
||||
|
||||
return 0;
|
||||
// !!! Delete of Bat have to be make in DrawFairCurve_MinimalVariation destructor !!!!!
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
SetPoint(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,3,di)) return 1;
|
||||
|
||||
const char *side = argv[1];
|
||||
const char *PointName = argv[2];
|
||||
const char *BattenName = argv[3];
|
||||
|
||||
Standard_Integer cote = atoi(side);
|
||||
|
||||
Handle(DrawTrSurf_Point)
|
||||
Pnt = Handle(DrawTrSurf_Point)::DownCast(Draw::Get(PointName));
|
||||
if (Pnt.IsNull()) return 1;
|
||||
|
||||
|
||||
Handle(DrawFairCurve_Batten)
|
||||
Bat = Handle(DrawFairCurve_Batten)::DownCast(Draw::Get(BattenName));
|
||||
if (Bat.IsNull()) return 1;
|
||||
|
||||
Bat->SetPoint(cote, Pnt->Point2d());
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
SetAngle(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,3,di)) return 1;
|
||||
|
||||
const char *side = argv[1];
|
||||
const char *val = argv[2];
|
||||
const char *BattenName = argv[3];
|
||||
|
||||
Standard_Real angle = atof(val);
|
||||
Standard_Integer cote = atoi(side);
|
||||
|
||||
Handle(DrawFairCurve_Batten)
|
||||
Bat = Handle(DrawFairCurve_Batten)::DownCast(Draw::Get(BattenName));
|
||||
if (Bat.IsNull()) return 1;
|
||||
|
||||
Bat->SetAngle(cote, angle);
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
SetCurvature(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,3,di)) return 1;
|
||||
|
||||
const char *side = argv[1];
|
||||
const char *val = argv[2];
|
||||
const char *MVCName = argv[3];
|
||||
|
||||
Standard_Real rho = atof(val);
|
||||
Standard_Integer cote = atoi(side);
|
||||
|
||||
Handle(DrawFairCurve_MinimalVariation)
|
||||
MVC = Handle(DrawFairCurve_MinimalVariation)::DownCast(Draw::Get(MVCName));
|
||||
if (MVC.IsNull()) return 1;
|
||||
|
||||
MVC->SetCurvature(cote, rho);
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
SetSlide(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,2,di)) return 1;
|
||||
|
||||
const char *val = argv[1];
|
||||
const char *BattenName = argv[2];
|
||||
|
||||
Standard_Real slide = atof(val);
|
||||
|
||||
Handle(DrawFairCurve_Batten)
|
||||
Bat = Handle(DrawFairCurve_Batten)::DownCast(Draw::Get(BattenName));
|
||||
if (Bat.IsNull()) return 1;
|
||||
|
||||
Bat->SetSliding(slide);
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
FreeAngle(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,2,di)) return 1;
|
||||
|
||||
const char *side = argv[1];
|
||||
const char *BattenName = argv[2];
|
||||
|
||||
Standard_Integer cote = atoi(side);
|
||||
|
||||
Handle(DrawFairCurve_Batten)
|
||||
Bat = Handle(DrawFairCurve_Batten)::DownCast(Draw::Get(BattenName));
|
||||
if (Bat.IsNull()) return 1;
|
||||
|
||||
Bat->FreeAngle(cote);
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
FreeCurvature(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,2,di)) return 1;
|
||||
|
||||
const char *side = argv[1];
|
||||
const char *MVCName = argv[2];
|
||||
|
||||
Standard_Integer cote = atoi(side);
|
||||
|
||||
Handle(DrawFairCurve_MinimalVariation)
|
||||
MVC = Handle(DrawFairCurve_MinimalVariation)::DownCast(Draw::Get(MVCName));
|
||||
if (MVC.IsNull()) return 1;
|
||||
|
||||
MVC->FreeCurvature(cote);
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
FreeSlide(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,1,di)) return 1;
|
||||
|
||||
const char *BattenName = argv[1];
|
||||
|
||||
Handle(DrawFairCurve_Batten)
|
||||
Bat = Handle(DrawFairCurve_Batten)::DownCast(Draw::Get(BattenName));
|
||||
if (Bat.IsNull()) return 1;
|
||||
|
||||
Bat->FreeSliding();
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
SetHeight(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,2,di)) return 1;
|
||||
|
||||
const char *val = argv[1];
|
||||
const char *BattenName = argv[2];
|
||||
|
||||
Standard_Real Height = atof(val);
|
||||
|
||||
Handle(DrawFairCurve_Batten)
|
||||
Bat = Handle(DrawFairCurve_Batten)::DownCast(Draw::Get(BattenName));
|
||||
if (Bat.IsNull()) return 1;
|
||||
|
||||
Bat->SetHeight(Height);
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
SetSlope(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,2,di)) return 1;
|
||||
|
||||
const char *val = argv[1];
|
||||
const char *BattenName = argv[2];
|
||||
|
||||
Standard_Real Slope = atof(val);
|
||||
|
||||
Handle(DrawFairCurve_Batten)
|
||||
Bat = Handle(DrawFairCurve_Batten)::DownCast(Draw::Get(BattenName));
|
||||
if (Bat.IsNull()) return 1;
|
||||
|
||||
Bat->SetSlope(Slope);
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
//=======================================================================
|
||||
static Standard_Integer
|
||||
SetPhysicalRatio(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
{
|
||||
if (!IsGoodNumber(argc,2,di)) return 1;
|
||||
|
||||
const char *val = argv[1];
|
||||
const char *MVCName = argv[2];
|
||||
|
||||
Standard_Real ratio = atof(val);
|
||||
|
||||
Handle(DrawFairCurve_MinimalVariation)
|
||||
MVC = Handle(DrawFairCurve_MinimalVariation)::DownCast(Draw::Get(MVCName));
|
||||
if (MVC.IsNull()) return 1;
|
||||
|
||||
MVC->SetPhysicalRatio(ratio);
|
||||
Draw::Repaint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
void GeometryTest::FairCurveCommands(Draw_Interpretor& TheCommande)
|
||||
//=======================================================================
|
||||
|
||||
{
|
||||
const char* g;
|
||||
|
||||
g = "FairCurve command";
|
||||
|
||||
TheCommande.Add("battencurve","battencurve P1 P2 Angle1 Angle2 Heigth BattenName",
|
||||
__FILE__,BattenCurve, g);
|
||||
TheCommande.Add("minvarcurve","MVCurve P1 P2 Angle1 Angle2 Heigth MVCName",
|
||||
__FILE__,MVCurve, g);
|
||||
TheCommande.Add("setpoint","setpoint side point BattenName ",__FILE__, SetPoint, g);
|
||||
TheCommande.Add("setangle","setangle side angle BattenName ",__FILE__, SetAngle, g);
|
||||
TheCommande.Add("setslide","setangle slidingfactor BattenName ",__FILE__, SetSlide, g);
|
||||
TheCommande.Add("freeangle","freeangle side BattenName",__FILE__, FreeAngle, g);
|
||||
TheCommande.Add("freeslide","freeslide BattenName",__FILE__, FreeSlide, g);
|
||||
TheCommande.Add("setheight","setheight height BattenName ",__FILE__, SetHeight, g);
|
||||
TheCommande.Add("setslope","setslope slope BattenName ",__FILE__, SetSlope, g);
|
||||
TheCommande.Add("setcurvature","setcurvature side rho MVCName ",__FILE__, SetCurvature, g);
|
||||
TheCommande.Add("freecurvature","freecurvature side MVCName ",__FILE__, FreeCurvature, g);
|
||||
TheCommande.Add("setphysicalratio","physicalratio ratio MVCName ",__FILE__, SetPhysicalRatio, g);
|
||||
}
|
191
src/GeometryTest/GeometryTest_PolyCommands.cxx
Executable file
191
src/GeometryTest/GeometryTest_PolyCommands.cxx
Executable file
@@ -0,0 +1,191 @@
|
||||
// File: GeometryTest_PolyCommands.cxx
|
||||
// Created: Mon Mar 6 19:16:20 1995
|
||||
// Author: Laurent PAINNOT
|
||||
// <lpa@metrox>
|
||||
|
||||
|
||||
#include <GeometryTest.ixx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
#include <Poly_Triangle.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <DrawTrSurf_Triangulation.hxx>
|
||||
#include <DrawTrSurf_Polygon3D.hxx>
|
||||
#include <DrawTrSurf_Polygon2D.hxx>
|
||||
|
||||
#include <Poly_Polygon3D.hxx>
|
||||
#include <Poly_Polygon2D.hxx>
|
||||
|
||||
#ifdef WNT
|
||||
Standard_IMPORT Draw_Viewer dout;
|
||||
#endif
|
||||
//=======================================================================
|
||||
//function : polytr
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer polytr(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 4)
|
||||
return 1;
|
||||
|
||||
Standard_Integer nbNodes = atoi(a[2]);
|
||||
Standard_Integer nbTri = atoi(a[3]);
|
||||
|
||||
// read the nodes
|
||||
Standard_Integer i, j = 4;
|
||||
TColgp_Array1OfPnt Nodes(1, nbNodes);
|
||||
|
||||
for (i = 1; i <= nbNodes; i++) {
|
||||
if (j + 2 >= n) {
|
||||
di << "Not enough nodes";
|
||||
return 1;
|
||||
}
|
||||
Nodes(i).SetCoord(atof(a[j]),atof(a[j+1]),atof(a[j+2]));
|
||||
j += 3;
|
||||
}
|
||||
|
||||
// read the triangles
|
||||
|
||||
Poly_Array1OfTriangle Triangles(1, nbTri);
|
||||
for (i = 1; i <= nbTri; i++) {
|
||||
if (j + 2 >= n) {
|
||||
di << "Not enough triangles";
|
||||
return 1;
|
||||
}
|
||||
Triangles(i).Set(atoi(a[j]),atoi(a[j+1]),atoi(a[j+2]));
|
||||
j += 3;
|
||||
}
|
||||
|
||||
Handle(Poly_Triangulation) T = new Poly_Triangulation(Nodes,Triangles);
|
||||
|
||||
DrawTrSurf::Set(a[1],T);
|
||||
|
||||
return 0;//wnt
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : polygon3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer polygon3d(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 4)
|
||||
return 1;
|
||||
|
||||
Standard_Integer nbNodes = atoi(a[2]);
|
||||
|
||||
// read the nodes
|
||||
Standard_Integer i, j = 3;
|
||||
TColgp_Array1OfPnt Nodes(1, nbNodes);
|
||||
|
||||
for (i = 1; i <= nbNodes; i++) {
|
||||
if (j + 2 >= n) {
|
||||
di << "Not enough nodes";
|
||||
return 1;
|
||||
}
|
||||
Nodes(i).SetCoord(atof(a[j]),atof(a[j+1]),atof(a[j+2]));
|
||||
j += 3;
|
||||
}
|
||||
|
||||
Handle(Poly_Polygon3D) P3d = new Poly_Polygon3D(Nodes);
|
||||
|
||||
DrawTrSurf::Set(a[1], P3d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : polygon2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer polygon2d(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 4)
|
||||
return 1;
|
||||
|
||||
Standard_Integer nbNodes = atoi(a[2]);
|
||||
|
||||
// read the nodes
|
||||
Standard_Integer i, j = 3;
|
||||
TColgp_Array1OfPnt2d Nodes(1, nbNodes);
|
||||
|
||||
for (i = 1; i <= nbNodes; i++) {
|
||||
if (j + 1 >= n) {
|
||||
di << "Not enough nodes";
|
||||
return 1;
|
||||
}
|
||||
Nodes(i).SetCoord(atof(a[j]),atof(a[j+1]));
|
||||
j += 2;
|
||||
}
|
||||
|
||||
Handle(Poly_Polygon2D) P2d = new Poly_Polygon2D(Nodes);
|
||||
|
||||
DrawTrSurf::Set(a[1], P2d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : shnodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer shnodes(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n != 2) return 1;
|
||||
Handle(DrawTrSurf_Triangulation) T
|
||||
= Handle(DrawTrSurf_Triangulation)::DownCast(Draw::Get(a[1]));
|
||||
|
||||
if (!T.IsNull()) {
|
||||
Standard_Boolean SHOWNODES = T->ShowNodes();
|
||||
T->ShowNodes(!SHOWNODES);
|
||||
}
|
||||
|
||||
|
||||
|
||||
dout.RepaintAll();
|
||||
|
||||
return 0;//wnt
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : shtriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer shtriangles(Draw_Interpretor& , Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n != 2) return 1;
|
||||
|
||||
Handle(DrawTrSurf_Triangulation) T
|
||||
= Handle(DrawTrSurf_Triangulation)::DownCast(Draw::Get(a[1]));
|
||||
Standard_Boolean SHOWTRIANGLES = T->ShowTriangles();
|
||||
T->ShowTriangles(!SHOWTRIANGLES);
|
||||
dout.RepaintAll();
|
||||
return 0;//wnt
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PolyCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void GeometryTest::PolyCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
|
||||
const char* g = "Poly Commands";
|
||||
|
||||
theCommands.Add("polytr","polytr name nbnodes nbtri x1 y1 z1 ... n1 n2 n3 ...",__FILE__,polytr,g);
|
||||
theCommands.Add("polygon3d","polygon3d name nbnodes x1 y1 z1 ...",__FILE__,polygon3d,g);
|
||||
theCommands.Add("polygon2d","polygon2d name nbnodes x1 y1 ...",__FILE__,polygon2d,g);
|
||||
theCommands.Add("shnodes","shnodes name", __FILE__,shnodes, g);
|
||||
theCommands.Add("shtriangles","shtriangles name", __FILE__,shtriangles, g);
|
||||
}
|
375
src/GeometryTest/GeometryTest_SurfaceCommands.cxx
Executable file
375
src/GeometryTest/GeometryTest_SurfaceCommands.cxx
Executable file
@@ -0,0 +1,375 @@
|
||||
// File: DrawTrSurf_2.cxx
|
||||
// Created: Thu Aug 12 19:33:52 1993
|
||||
// Author: Bruno DUMORTIER
|
||||
// <dub@topsn3>
|
||||
// 09/06/97 : JPI : suppression des commandes redondantes suite a la creation de GeomliteTest
|
||||
// Modified: Mon Jan 18 11:06:46 1999
|
||||
// Author: Joelle CHAUVET
|
||||
// <jct@sgi64>
|
||||
// option -NS dans la commande tuyau pour distinguer les tuyaux
|
||||
// a section evolutive des tuyaux a N sections avec N = 2
|
||||
|
||||
#include <GeometryTest.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Display.hxx>
|
||||
|
||||
#include <GeomAbs_SurfaceType.hxx>
|
||||
#include <GeomAbs_IsoType.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <GeomConvert.hxx>
|
||||
|
||||
|
||||
#include <GeomAdaptor_Surface.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
#include <TColGeom_SequenceOfCurve.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <GeomFill.hxx>
|
||||
#include <GeomFill_BSplineCurves.hxx>
|
||||
#include <GeomFill_Pipe.hxx>
|
||||
#include <GeomFill_SectionGenerator.hxx>
|
||||
#include <GeomFill_Line.hxx>
|
||||
#include <GeomFill_AppSurf.hxx>
|
||||
|
||||
|
||||
#include <DrawTrSurf_BezierSurface.hxx>
|
||||
#include <DrawTrSurf_BSplineSurface.hxx>
|
||||
|
||||
#ifdef WNT
|
||||
#include <stdio.h>
|
||||
//#define strcasecmp strcmp Already defined
|
||||
Standard_IMPORT Draw_Viewer dout;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : sweep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer sweep (Draw_Interpretor&,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet;
|
||||
Standard_Integer ipath =2, isection =4 , NbSeg=30, MaxDegree = 10;
|
||||
Standard_Real Tol = 1.e-4;
|
||||
#if DEB
|
||||
static Standard_Boolean AdvApprox_Debug = 1;
|
||||
#endif
|
||||
|
||||
if (n < 4 ) return 1;
|
||||
|
||||
if (! strcmp(a[2],"-FX")) {
|
||||
ipath = 3;
|
||||
Option = GeomFill_IsFixed;
|
||||
}
|
||||
if (! strcmp(a[2],"-FR")) {
|
||||
ipath = 3;
|
||||
Option = GeomFill_IsFrenet;
|
||||
}
|
||||
if (! strcmp(a[2],"-CF")) {
|
||||
ipath = 3;
|
||||
Option = GeomFill_IsCorrectedFrenet;
|
||||
}
|
||||
if (! strcmp(a[2],"-CN")) {
|
||||
ipath = 3;
|
||||
isection = 7;
|
||||
Option = GeomFill_IsConstantNormal;
|
||||
}
|
||||
if (! strcmp(a[2],"-DX")) {
|
||||
ipath = 3;
|
||||
isection = 5;
|
||||
Option = GeomFill_IsDarboux;
|
||||
}
|
||||
|
||||
GeomFill_Pipe Pipe;
|
||||
Pipe.GenerateParticularCase(Standard_True);
|
||||
|
||||
if (Option == GeomFill_IsDarboux) {
|
||||
Handle(Geom2d_Curve) path = DrawTrSurf::GetCurve2d(a[ipath]);
|
||||
if ( path.IsNull()) return 1;
|
||||
|
||||
Handle(Geom_Surface) Support = DrawTrSurf::GetSurface(a[ipath+1]);
|
||||
if ( Support.IsNull()) return 1;
|
||||
|
||||
Handle(Geom_Curve) firstS = DrawTrSurf::GetCurve(a[ipath+2]);
|
||||
if ( firstS.IsNull()) return 1;
|
||||
|
||||
Pipe.Init(path, Support, firstS);
|
||||
}
|
||||
else if (Option == GeomFill_IsConstantNormal) {
|
||||
gp_Dir D ( atof(a[3]), atof(a[4]), atof(a[5]) );
|
||||
Handle(Geom_Curve) path = DrawTrSurf::GetCurve(a[6]);
|
||||
Handle(Geom_Curve) firstS = DrawTrSurf::GetCurve(a[7]);
|
||||
Pipe.Init(path, firstS, D);
|
||||
}
|
||||
else {
|
||||
Handle(Geom_Curve) path = DrawTrSurf::GetCurve(a[ipath]);
|
||||
if ( path.IsNull()) return 1;
|
||||
|
||||
Handle(Geom_Curve) firstS = DrawTrSurf::GetCurve(a[ipath+1]);
|
||||
if ( firstS.IsNull()) return 1;
|
||||
|
||||
Pipe.Init(path, firstS, Option);
|
||||
}
|
||||
|
||||
if (n >=isection+2) {
|
||||
MaxDegree = atoi(a[isection+1]);
|
||||
if (n >isection+2) NbSeg = atoi(a[isection+2]);
|
||||
}
|
||||
|
||||
Pipe.Perform(Tol, Standard_False, GeomAbs_C2, MaxDegree, NbSeg);
|
||||
|
||||
DrawTrSurf::Set(a[1], Pipe.Surface());
|
||||
return 0;
|
||||
|
||||
}
|
||||
//=======================================================================
|
||||
//function : tuyau
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer tuyau (Draw_Interpretor&,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
if ( n < 4) return 1;
|
||||
#if DEB
|
||||
static Standard_Boolean AdvApprox_Debug = 1;
|
||||
#endif
|
||||
|
||||
GeomAbs_Shape Cont = GeomAbs_C2;
|
||||
GeomFill_Pipe Pipe;
|
||||
Pipe.GenerateParticularCase(Standard_True);
|
||||
|
||||
Standard_Boolean Option_NS = Standard_False;
|
||||
Standard_Integer indice_path = 2, narg = n;
|
||||
if (! strcmp(a[1],"-NS")) {
|
||||
Option_NS = Standard_True;
|
||||
indice_path++;
|
||||
narg--;
|
||||
}
|
||||
Handle(Geom_Curve) path = DrawTrSurf::GetCurve(a[indice_path]);
|
||||
if ( path.IsNull()) return 1;
|
||||
|
||||
Standard_Integer isect = indice_path+1;
|
||||
Handle(Geom_Curve) firstS = DrawTrSurf::GetCurve(a[isect]);
|
||||
if ( firstS.IsNull()) {
|
||||
if ( narg == 4) {
|
||||
// tuyau a rayon constant.
|
||||
Pipe.Init(path, atof(a[isect]));
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
if ( narg == 4) {
|
||||
// tuyau a section constante.
|
||||
Pipe.Init(path,firstS, GeomFill_IsCorrectedFrenet);
|
||||
}
|
||||
else {
|
||||
if ( narg == 5 && !Option_NS) {
|
||||
// tuyau a section evolutive
|
||||
Handle(Geom_Curve) lastS = DrawTrSurf::GetCurve(a[isect+1]);
|
||||
Cont = GeomAbs_C2;
|
||||
Pipe.Init(path, firstS, lastS);
|
||||
}
|
||||
else {
|
||||
// tuyau a N sections, N>=2
|
||||
TColGeom_SequenceOfCurve Seq;
|
||||
Seq.Clear();
|
||||
Seq.Append(firstS);
|
||||
for (Standard_Integer i=isect+1;i<n;i++) {
|
||||
Handle(Geom_Curve) nextS = DrawTrSurf::GetCurve(a[i]);
|
||||
Seq.Append(nextS);
|
||||
}
|
||||
Cont = GeomAbs_C2;
|
||||
Pipe.Init(path, Seq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pipe.Perform(1.e-4, Standard_False, Cont);
|
||||
DrawTrSurf::Set(a[indice_path-1], Pipe.Surface());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ruled
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer ruled(Draw_Interpretor& di,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
if ( n < 4) return 1;
|
||||
|
||||
Handle(Geom_Curve) C1 = DrawTrSurf::GetCurve(a[2]);
|
||||
if ( C1.IsNull()) {
|
||||
di << " C1 is not a Curve ==> Command failed" << "\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(Geom_Curve) C2 = DrawTrSurf::GetCurve(a[3]);
|
||||
if ( C2.IsNull()) {
|
||||
di << " C2 is not a Curve ==> Command failed" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) S = GeomFill::Surface(C1,C2);
|
||||
if ( S.IsNull()) return 1;
|
||||
|
||||
DrawTrSurf::Set(a[1],S);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : appsurf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer appsurf(Draw_Interpretor& di,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
if ( n < 4) return 1;
|
||||
|
||||
GeomFill_SectionGenerator Section;
|
||||
Standard_Integer i;
|
||||
Handle(Geom_Curve) C;
|
||||
for ( i = 2; i < n; i++) {
|
||||
C = DrawTrSurf::GetCurve(a[i]);
|
||||
if (C.IsNull())
|
||||
return 1;
|
||||
Section.AddCurve(C);
|
||||
}
|
||||
|
||||
Section.Perform(Precision::PConfusion());
|
||||
|
||||
Handle(GeomFill_Line) Line = new GeomFill_Line(n-2);
|
||||
Standard_Integer NbIt = 0;
|
||||
GeomFill_AppSurf App( 3, 8, Precision::Confusion(), Precision::PConfusion(),
|
||||
NbIt);
|
||||
|
||||
App.Perform( Line, Section);
|
||||
|
||||
if ( !App.IsDone()) {
|
||||
di << " Approximation aux fraises " << "\n";
|
||||
}
|
||||
|
||||
Standard_Integer UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, NbVKnots;
|
||||
App.SurfShape(UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, NbVKnots);
|
||||
|
||||
Handle(Geom_BSplineSurface) GBS = new
|
||||
Geom_BSplineSurface(App.SurfPoles(),
|
||||
App.SurfWeights(),
|
||||
App.SurfUKnots(),
|
||||
App.SurfVKnots(),
|
||||
App.SurfUMults(),
|
||||
App.SurfVMults(),
|
||||
App.UDegree(),
|
||||
App.VDegree());
|
||||
|
||||
DrawTrSurf::Set(a[1],GBS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer fillcurves(Draw_Interpretor& di,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
if ( n < 6) return 1;
|
||||
|
||||
Standard_Integer i;
|
||||
Handle(Geom_Curve) aC;
|
||||
Handle(Geom_BSplineCurve) C[4];
|
||||
for ( i = 2; i < 6; i++) {
|
||||
aC = DrawTrSurf::GetCurve(a[i]);
|
||||
if (aC.IsNull())
|
||||
return 1;
|
||||
C[i-2] = GeomConvert::CurveToBSplineCurve(aC, Convert_RationalC1);
|
||||
}
|
||||
|
||||
Standard_Integer ist = 2;
|
||||
GeomFill_FillingStyle Style = GeomFill_CoonsStyle;
|
||||
if(n > 6) ist = atoi(a[6]);
|
||||
|
||||
if(ist == 1) Style = GeomFill_StretchStyle;
|
||||
if(ist == 2) Style = GeomFill_CoonsStyle;
|
||||
if(ist == 3) Style = GeomFill_CurvedStyle;
|
||||
|
||||
GeomFill_BSplineCurves aFilling(C[0], C[1], C[2], C[3], Style);
|
||||
|
||||
const Handle(Geom_BSplineSurface)& GBS = aFilling.Surface();
|
||||
DrawTrSurf::Set(a[1],GBS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SurfaceCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
||||
void GeometryTest::SurfaceCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean loaded = Standard_False;
|
||||
if (loaded) return;
|
||||
loaded = Standard_True;
|
||||
|
||||
DrawTrSurf::BasicCommands(theCommands);
|
||||
|
||||
const char* g;
|
||||
|
||||
g = "GEOMETRY surfaces creation";
|
||||
|
||||
|
||||
theCommands.Add("tuyau",
|
||||
"tuyau [-NS] result Path Curve/Radius [Curve2] [Curve3] ... \n the option -NS is used only with 2 sections.\n With it, <result> is going from the first section to the last section \n Without, <result> is a pipe by evolutive section ",
|
||||
__FILE__,
|
||||
tuyau,g);
|
||||
|
||||
theCommands.Add("partuyau",
|
||||
"tuyau result Path Curve/Radius [Curve2]\n the parametrization of the surface in the V direction will be as the Path",
|
||||
__FILE__,
|
||||
tuyau,g);
|
||||
|
||||
theCommands.Add("sweep", "sweep result [options] path [Surf] curve [Tol [nbsegment]]\n sweep the the curve along the path, options are \n -FX : Tangent and Normal are fixed\n -FR : Tangent and Normal are given by Frenet trihedron \n -CF : Tangente is given by Frenet, \n the Normal is computed to minimize the torsion \n -DX : Tangent and Normal are given by Darboux trihedron \n <path> have to be a 2d curve,\n <Surf> have to be defined\n -CN dx dy dz : Normal is given by dx dy dz" ,
|
||||
__FILE__,
|
||||
sweep, g);
|
||||
|
||||
theCommands.Add("ruled",
|
||||
"ruled result C1 C2",
|
||||
__FILE__,
|
||||
ruled,g);
|
||||
|
||||
theCommands.Add("appsurf",
|
||||
"appsurf result C1 C2 C3 .....: \n\tCreate a surface passing through the curves",
|
||||
__FILE__,
|
||||
appsurf,g);
|
||||
|
||||
theCommands.Add("fillcurves",
|
||||
"fillcurves result C1 C2 C3 C4 [style 1/2/3]: \n\tCreate a surface filling frame of 4 curves",
|
||||
__FILE__,
|
||||
fillcurves,g);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user