mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-10 08:08:36 +08:00
Added DRAW command dlocale to set and query current locale of the C subsystem Equivalents of C functions working with conversions of strings to/from reals added in Standard_CString, providing locale-independent behavior (using always "C" locale) In DRAW packages, calls to atof() and atoi() are replaced by direct calls to Draw::Atof() and Draw::Atoi(), respectively, instead of substituting by #define Use of atof(), strtod(), and *scanf() involving floating point conversions in OCCT code replaced by locale-independent Atof() and Strtod() Calls to sprintf() involving floating point in OCCT code are replaced by call to locale-independent Sprintf(), except a few places where converted strings are used immediately for display in the 3d viewer Changes of global locale are eliminated throughout OCCT code Proposed correction for GNU libC where v*printf_l functions are absent Added test case (bugs xde bug22898) for data exchange operations with non-standard locale Use xlocale on Mac OS X and within glibc Corrected strtod_l wrapper Generate error rather than warning Introduce Standard_CLocaleSentry replacement for removed OSD_Localizer Standard_CLocaleSentry - copy locale string Standard_CLocaleSentry - use _configthreadlocale on Windows Standard_CLocaleSentry::GetCLocale() - return locale_t rather than void* Corrected misprint in ~Standard_CLocaleSentry() Use French locale in bug22898 test case Mark test case as skipped if locale is unavailable on tested system. Use fr_FR locale for tests on Mac OS X
383 lines
12 KiB
C++
Executable File
383 lines
12 KiB
C++
Executable File
// Created on: 1996-10-09
|
|
// Created by: Philippe MANGIN
|
|
// Copyright (c) 1996-1999 Matra Datavision
|
|
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
|
//
|
|
// The content of this file is subject to the Open CASCADE Technology Public
|
|
// License Version 6.5 (the "License"). You may not use the content of this file
|
|
// except in compliance with the License. Please obtain a copy of the License
|
|
// at http://www.opencascade.org and read it completely before using this file.
|
|
//
|
|
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
|
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
|
//
|
|
// The Original Code and all software distributed under the License is
|
|
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
|
// Initial Developer hereby disclaims all such warranties, including without
|
|
// limitation, any warranties of merchantability, fitness for a particular
|
|
// purpose or non-infringement. Please see the License for the specific terms
|
|
// and conditions governing the rights and limitations under the License.
|
|
|
|
|
|
|
|
#include <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 = Draw::Atof(cangle1),
|
|
a2 = Draw::Atof(cangle2),
|
|
h = Draw::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*M_PI/180);
|
|
Bat->SetAngle2(a2*M_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 = Draw::Atof(cangle1),
|
|
a2 = Draw::Atof(cangle2),
|
|
h = Draw::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*M_PI/180);
|
|
MVC->SetAngle2(a2*M_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 = Draw::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 = Draw::Atof(val);
|
|
Standard_Integer cote = Draw::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 = Draw::Atof(val);
|
|
Standard_Integer cote = Draw::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 = Draw::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 = Draw::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 = Draw::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 = Draw::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 = Draw::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 = Draw::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);
|
|
}
|