mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-05-11 01:58:22 +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
278 lines
7.9 KiB
C++
Executable File
278 lines
7.9 KiB
C++
Executable File
// Created on: 1995-02-22
|
|
// Created by: Jacques GOUSSARD
|
|
// Copyright (c) 1995-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 <BRepTest.hxx>
|
|
#include <DBRep.hxx>
|
|
#include <DrawTrSurf.hxx>
|
|
#include <Draw_Appli.hxx>
|
|
#include <Draw_Interpretor.hxx>
|
|
|
|
#include <BRepOffsetAPI_DraftAngle.hxx>
|
|
#include <BRepOffsetAPI_MakeDraft.hxx>
|
|
#include <TopoDS.hxx>
|
|
#include <TopoDS_Face.hxx>
|
|
#include <gp_Pln.hxx>
|
|
#include <gp_Dir.hxx>
|
|
|
|
static void Print(Draw_Interpretor& di,
|
|
const Draft_ErrorStatus St)
|
|
{
|
|
di << " Error Status : ";
|
|
switch (St) {
|
|
case Draft_NoError:
|
|
di << "No error";
|
|
break;
|
|
|
|
case Draft_FaceRecomputation:
|
|
di << "Impossible face recomputation";
|
|
break;
|
|
|
|
case Draft_EdgeRecomputation:
|
|
di << "Impossible edge recomputation";
|
|
break;
|
|
|
|
case Draft_VertexRecomputation:
|
|
di << "Impossible vertex recomputation";
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
static Standard_Integer DEP(Draw_Interpretor& theCommands,
|
|
Standard_Integer narg, const char** a)
|
|
{
|
|
if ((narg<14)||(narg%8 != 6)) return 1;
|
|
TopoDS_Shape V = DBRep::Get(a[2]);
|
|
BRepOffsetAPI_DraftAngle drft(V);
|
|
|
|
gp_Dir Dirextract(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
|
|
|
|
TopoDS_Face F;
|
|
Standard_Real Angle;
|
|
gp_Pnt Pax;
|
|
gp_Dir Dax;
|
|
for (Standard_Integer ii = 0; ii < (narg-6)/8; ii++){
|
|
TopoDS_Shape aLocalShape(DBRep::Get(a[8*ii+6],TopAbs_FACE));
|
|
F = TopoDS::Face(aLocalShape);
|
|
// F = TopoDS::Face(DBRep::Get(a[8*ii+6],TopAbs_FACE));
|
|
Angle = Draw::Atof(a[8*ii+7])*M_PI/180.;
|
|
Pax.SetCoord(Draw::Atof(a[8*ii+8]),Draw::Atof(a[8*ii+9]),Draw::Atof(a[8*ii+10]));
|
|
Dax.SetCoord(Draw::Atof(a[8*ii+11]),Draw::Atof(a[8*ii+12]),Draw::Atof(a[8*ii+13]));
|
|
drft.Add(F,Dirextract,Angle,gp_Pln(Pax,Dax));
|
|
if (!drft.AddDone()) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!drft.AddDone()) {
|
|
DBRep::Set("bugdep",drft.ProblematicShape());
|
|
theCommands << "Bad shape in variable bugdep ";
|
|
Print(theCommands,drft.Status());
|
|
return 1;
|
|
}
|
|
drft.Build();
|
|
if (drft.IsDone()) {
|
|
DBRep::Set(a[1],drft);
|
|
return 0;
|
|
}
|
|
DBRep::Set("bugdep",drft.ProblematicShape());
|
|
theCommands << "Problem encountered during the reconstruction : ";
|
|
theCommands << "bad shape in variable bugdep; ";
|
|
Print(theCommands,drft.Status());
|
|
return 1;
|
|
}
|
|
|
|
|
|
static Standard_Integer NDEP(Draw_Interpretor& theCommands,
|
|
Standard_Integer narg, const char** a)
|
|
{
|
|
if ((narg<15)||((narg)%9 != 6)) return 1;
|
|
TopoDS_Shape V = DBRep::Get(a[2]);
|
|
if ( V.IsNull()) {
|
|
//cout << a[2] << " is not a Shape" << endl;
|
|
theCommands << a[2] << " is not a Shape" << "\n";
|
|
return 1;
|
|
}
|
|
|
|
BRepOffsetAPI_DraftAngle drft(V);
|
|
|
|
gp_Dir Dirextract(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
|
|
|
|
TopoDS_Face F;
|
|
Standard_Real Angle;
|
|
gp_Pnt Pax;
|
|
gp_Dir Dax;
|
|
Standard_Boolean Flag;
|
|
for (Standard_Integer ii = 0; ii < (narg-6)/9; ii++){
|
|
TopoDS_Shape aLocalFace(DBRep::Get(a[9*ii+6],TopAbs_FACE));
|
|
F = TopoDS::Face(aLocalFace);
|
|
// F = TopoDS::Face(DBRep::Get(a[9*ii+6],TopAbs_FACE));
|
|
|
|
if ( F.IsNull()) {
|
|
//cout << a[9*ii+6] << " is not a face" << endl;
|
|
theCommands << a[9*ii+6] << " is not a face" << "\n";
|
|
return 1;
|
|
}
|
|
|
|
//#ifdef DEB
|
|
// Flag = Draw::Atof(a[9*ii+7]); // BUG?? Real -> Boolean ???
|
|
//#else
|
|
Flag = (Standard_Boolean ) Draw::Atof(a[9*ii+7]);
|
|
//#endif
|
|
Angle = Draw::Atof(a[9*ii+8])*M_PI/180.;
|
|
Pax.SetCoord(Draw::Atof(a[9*ii+9]),Draw::Atof(a[9*ii+10]),Draw::Atof(a[9*ii+11]));
|
|
Dax.SetCoord(Draw::Atof(a[9*ii+12]),Draw::Atof(a[9*ii+13]),Draw::Atof(a[9*ii+14]));
|
|
drft.Add(F,Dirextract,Angle,gp_Pln(Pax,Dax), Flag);
|
|
if (!drft.AddDone()) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!drft.AddDone()) {
|
|
DBRep::Set("bugdep",drft.ProblematicShape());
|
|
theCommands << "Bad shape in variable bugdep ";
|
|
Print(theCommands,drft.Status());
|
|
return 1;
|
|
}
|
|
drft.Build();
|
|
if (drft.IsDone()) {
|
|
DBRep::Set(a[1],drft);
|
|
return 0;
|
|
}
|
|
DBRep::Set("bugdep",drft.ProblematicShape());
|
|
theCommands << "Problem encountered during the reconstruction : ";
|
|
theCommands << "bad shape in variable bugdep; ";
|
|
Print(theCommands,drft.Status());
|
|
return 1;
|
|
}
|
|
|
|
static Standard_Integer draft (Draw_Interpretor& di,
|
|
Standard_Integer n, const char** a)
|
|
{
|
|
Standard_Integer Inside = -1;
|
|
Standard_Boolean Internal = Standard_False;
|
|
if (n < 8) return 1;
|
|
|
|
Standard_Real x, y ,z, teta;
|
|
TopoDS_Shape SInit = DBRep::Get(a[2]);//shape d'arret
|
|
|
|
x = Draw::Atof(a[3]);
|
|
y = Draw::Atof(a[4]); // direction de depouille
|
|
z = Draw::Atof(a[5]);
|
|
teta = Draw::Atof(a[6]); //angle de depouille (teta)
|
|
|
|
gp_Dir D(x,y,z);
|
|
|
|
|
|
|
|
BRepOffsetAPI_MakeDraft MkDraft(SInit, D, teta);
|
|
|
|
if (n>8) {
|
|
Standard_Integer cur = 8;
|
|
if (!strcmp(a[cur],"-IN")) {
|
|
Inside = 1;
|
|
cur++;
|
|
}
|
|
else if (!strcmp(a[cur],"-OUT")) {
|
|
Inside = 0;
|
|
cur++;
|
|
}
|
|
|
|
if (cur<n) {
|
|
if (!strcmp(a[cur],"-Ri")) {
|
|
MkDraft.SetOptions(BRepBuilderAPI_RightCorner);
|
|
cur++;
|
|
}
|
|
else if (!strcmp(a[cur],"-Ro")) {
|
|
MkDraft.SetOptions(BRepBuilderAPI_RoundCorner);
|
|
cur++;
|
|
}
|
|
}
|
|
if (cur<n) {
|
|
if (!strcmp(a[cur],"-Internal")) {
|
|
Internal = Standard_True;
|
|
cur++;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (Internal) {
|
|
MkDraft.SetDraft(Internal);
|
|
di << "Internal Draft : " << "\n";
|
|
//cout << "Internal Draft : " << endl;
|
|
}
|
|
else
|
|
di << "External Draft : " << "\n";
|
|
//cout << "External Draft : " << endl;
|
|
|
|
TopoDS_Shape Stop = DBRep::Get(a[7]);//shape d'arret
|
|
if (!Stop.IsNull()) {
|
|
Standard_Boolean KeepOutside = Standard_True;
|
|
if (Inside==0) KeepOutside = Standard_False;
|
|
MkDraft.Perform(Stop, KeepOutside);
|
|
}
|
|
else {
|
|
Handle(Geom_Surface) Surf = DrawTrSurf::GetSurface(a[7]);
|
|
if (! Surf.IsNull()) { // surface d'arret
|
|
Standard_Boolean KeepInside = Standard_True;
|
|
if (Inside==1) KeepInside = Standard_False;
|
|
MkDraft.Perform(Surf, KeepInside);
|
|
}
|
|
else { // by Lenght
|
|
Standard_Real L = Draw::Atof(a[7]);
|
|
if (L > 1.e-7) {
|
|
MkDraft.Perform(L);
|
|
}
|
|
else return 1;
|
|
}
|
|
}
|
|
|
|
DBRep::Set(a[1], MkDraft.Shape());
|
|
DBRep::Set("DraftShell", MkDraft.Shell());
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : DraftAngleCommands
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
void BRepTest::DraftAngleCommands(Draw_Interpretor& theCommands)
|
|
{
|
|
static Standard_Boolean done = Standard_False;
|
|
if (done) return;
|
|
done = Standard_True;
|
|
|
|
DBRep::BasicCommands(theCommands);
|
|
|
|
const char* g = "Draft angle modification commands";
|
|
|
|
theCommands.Add("depouille", " Inclines faces of a shape, dep result shape dirx diry dirz face angle x y x dx dy dz [face angle...]",__FILE__,DEP,g);
|
|
|
|
theCommands.Add("ndepouille", " Inclines faces of a shape, dep result shape dirx diry dirz face 0/1 angle x y x dx dy dz [face 0/1 angle...]",__FILE__,NDEP,g);
|
|
|
|
theCommands.Add("draft"," Compute a draft surface along a shape, \n draft result shape dirx diry dirz angle shape/surf/length [-IN/-OUT] [Ri/Ro] [-Internal]",
|
|
__FILE__,draft,g);
|
|
}
|