-// File: DBRep_3.cxx
-// Created: Thu Jul 22 16:38:58 1993
-// Author: Remi LEQUETTE
-// <rle@nonox>
+// Created on: 1993-07-22
+// Created by: Remi LEQUETTE
+// Copyright (c) 1993-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>
if (n < 4) return 1;
if (n >= 5) {
DBRep::Set(a[1],
- BRepBuilderAPI_MakeVertex(gp_Pnt(atof(a[2]),atof(a[3]),atof(a[4]))));
+ BRepBuilderAPI_MakeVertex(gp_Pnt(Draw::Atof(a[2]),Draw::Atof(a[3]),Draw::Atof(a[4]))));
}
else {
TopoDS_Shape S = DBRep::Get(a[3]);
if (S.ShapeType() != TopAbs_EDGE) return 0;
BRepAdaptor_Curve C(TopoDS::Edge(S));
gp_Pnt P;
- C.D0(atof(a[2]),P);
+ C.D0(Draw::Atof(a[2]),P);
DBRep::Set(a[1], BRepBuilderAPI_MakeVertex(P));
}
return 0;
TopoDS_Edge E = TopoDS::Edge(aLocalShape);
// TopoDS_Edge E = TopoDS::Edge(DBRep::Get(a[1],TopAbs_EDGE));
if (E.IsNull()) return 1;
- Standard_Real f = atof(a[n-2]);
- Standard_Real l = atof(a[n-1]);
+ Standard_Real f = Draw::Atof(a[n-2]);
+ Standard_Real l = Draw::Atof(a[n-1]);
BRep_Builder B;
if (n == 4)
B.Range(E,f,l);
BRepBuilderAPI_MakePolygon W;
j = 2;
for (i = 1; i <= np; i ++) {
- W.Add(gp_Pnt(atof(a[j]),atof(a[j+1]),atof(a[j+2])));
+ W.Add(gp_Pnt(Draw::Atof(a[j]),Draw::Atof(a[j+1]),Draw::Atof(a[j+2])));
j += 3;
}
DBRep::Set(a[1],W.Wire());
if (n == 5+i) {
if (V1.IsNull()) {
if (!C.IsNull())
- edge = BRepBuilderAPI_MakeEdge(C,atof(a[3]),atof(a[4]));
+ edge = BRepBuilderAPI_MakeEdge(C,Draw::Atof(a[3]),Draw::Atof(a[4]));
else if (S.IsNull())
- edge = BRepBuilderAPI_MakeEdge2d(C2d,atof(a[3]),atof(a[4]));
+ edge = BRepBuilderAPI_MakeEdge2d(C2d,Draw::Atof(a[3]),Draw::Atof(a[4]));
else
- edge = BRepBuilderAPI_MakeEdge(C2d,S,atof(a[4]),atof(a[5]));
+ edge = BRepBuilderAPI_MakeEdge(C2d,S,Draw::Atof(a[4]),Draw::Atof(a[5]));
}
else {
aLocalShape = DBRep::Get(a[4+i],TopAbs_VERTEX);
TopoDS_Vertex V2 = TopoDS::Vertex(aLocalShape);
// TopoDS_Vertex V2 = TopoDS::Vertex(DBRep::Get(a[5+i],TopAbs_VERTEX));
if (!C.IsNull())
- edge = BRepBuilderAPI_MakeEdge(C,V1,V2,atof(a[4]),atof(a[6]));
+ edge = BRepBuilderAPI_MakeEdge(C,V1,V2,Draw::Atof(a[4]),Draw::Atof(a[6]));
else if (S.IsNull())
- edge = BRepBuilderAPI_MakeEdge2d(C2d,V1,V2,atof(a[4]),atof(a[6]));
+ edge = BRepBuilderAPI_MakeEdge2d(C2d,V1,V2,Draw::Atof(a[4]),Draw::Atof(a[6]));
else
- edge = BRepBuilderAPI_MakeEdge(C2d,S,V1,V2,atof(a[5]),atof(a[7]));
+ edge = BRepBuilderAPI_MakeEdge(C2d,S,V1,V2,Draw::Atof(a[5]),Draw::Atof(a[7]));
}
else
return 1;
if (n < 6) return 1;
Standard_Boolean uiso = *a[0] == 'u';
- Standard_Real p = atof(a[3]);
- Standard_Real p1 = atof(a[4]);
- Standard_Real p2 = atof(a[5]);
+ Standard_Real p = Draw::Atof(a[3]);
+ Standard_Real p1 = Draw::Atof(a[4]);
+ Standard_Real p2 = Draw::Atof(a[5]);
TopoDS_Shape Sh = DBRep::Get(a[2],TopAbs_FACE);
if (Sh.IsNull()) return 1;
TopLoc_Location Loc;
di << "profile: The F instruction must precede all moves";
return 1;
}
- x0 = x = atof(a[i-1]);
- y0 = y = atof(a[i]);
+ x0 = x = Draw::Atof(a[i-1]);
+ y0 = y = Draw::Atof(a[i]);
stayfirst = Standard_True;
break;
case 'o':
i += 3;
if (i >= n) goto badargs;
- P.SetLocation(gp_Pnt(atof(a[i-2]),atof(a[i-1]),atof(a[i])));
+ P.SetLocation(gp_Pnt(Draw::Atof(a[i-2]),Draw::Atof(a[i-1]),Draw::Atof(a[i])));
stayfirst = Standard_True;
break;
i += 6;
if (i >= n) goto badargs;
{
- gp_Vec vn(atof(a[i-5]),atof(a[i-4]),atof(a[i-3]));
- gp_Vec vx(atof(a[i-2]),atof(a[i-1]),atof(a[i]));
+ gp_Vec vn(Draw::Atof(a[i-5]),Draw::Atof(a[i-4]),Draw::Atof(a[i-3]));
+ gp_Vec vx(Draw::Atof(a[i-2]),Draw::Atof(a[i-1]),Draw::Atof(a[i]));
if (vn.Magnitude() <= Precision::Confusion()) {
di << "profile : null direction";
return 1;
case 'x':
i++;
if (i >= n) goto badargs;
- length = atof(a[i]);
+ length = Draw::Atof(a[i]);
if ((a[i-1][1] == 'X') || (a[i-1][1] == 'x')) {
length -= x;
}
case 'y':
i++;
if (i >= n) goto badargs;
- length = atof(a[i]);
+ length = Draw::Atof(a[i]);
if ((a[i-1][1] == 'Y') || (a[i-1][1] == 'y')) {
length -= y;
}
case 'l':
i++;
if (i >= n) goto badargs;
- length = atof(a[i]);
+ length = Draw::Atof(a[i]);
move = line;
break;
i += 2;
if (i >= n) goto badargs;
{
- Standard_Real vx = atof(a[i-1]);
- Standard_Real vy = atof(a[i]);
+ Standard_Real vx = Draw::Atof(a[i-1]);
+ Standard_Real vy = Draw::Atof(a[i]);
if ((a[i-2][1] == 'T') || (a[i-2][1] == 't')) {
vx -= x;
vy -= y;
case 'r':
i++;
if (i >= n) goto badargs;
- angle = atof(a[i]) * (M_PI / 180.0);
+ angle = Draw::Atof(a[i]) * (M_PI / 180.0);
if ((a[i-1][1] == 'R') || (a[i-1][1] == 'r')) {
dx = Cos(angle);
dy = Sin(angle);
i += 2;
if (i >= n) goto badargs;
{
- Standard_Real vx = atof(a[i-1]);
- Standard_Real vy = atof(a[i]);
+ Standard_Real vx = Draw::Atof(a[i-1]);
+ Standard_Real vy = Draw::Atof(a[i]);
length = Sqrt(vx*vx+vy*vy);
if (length > Precision::Confusion()) {
// move = line; DUB
case 'c':
i += 2;
if (i >= n) goto badargs;
- radius = atof(a[i-1]);
+ radius = Draw::Atof(a[i-1]);
if (Abs(radius) > Precision::Confusion()) {
- angle = atof(a[i]) * (M_PI / 180.0);
+ angle = Draw::Atof(a[i]) * (M_PI / 180.0);
move = circle;
}
break;
case 'i':
i++;
if (i >= n) goto badargs;
- length = atof(a[i]);
+ length = Draw::Atof(a[i]);
if ((a[i-1][1] == 'X') || (a[i-1][1] == 'x')) {
if (Abs(dx) < Precision::Confusion()) {
di << "Profile : cannot intersect, arg " << i-1;
return 0;
#ifdef DEB
- badargs:
di << "profile : bad number of arguments";
return 1;
#endif
di << "profile: The F instruction must precede all moves";
return 1;
}
- x0 = x = atof(a[i-1]);
- y0 = y = atof(a[i]);
+ x0 = x = Draw::Atof(a[i-1]);
+ y0 = y = Draw::Atof(a[i]);
stayfirst = Standard_True;
break;
case 'x':
i++;
if (i >= n) goto badargs;
- length = atof(a[i]);
+ length = Draw::Atof(a[i]);
if ((a[i-1][1] == 'X') || (a[i-1][1] == 'x')) {
length -= x;
}
case 'y':
i++;
if (i >= n) goto badargs;
- length = atof(a[i]);
+ length = Draw::Atof(a[i]);
if ((a[i-1][1] == 'Y') || (a[i-1][1] == 'y')) {
length -= y;
}
case 'l':
i++;
if (i >= n) goto badargs;
- length = atof(a[i]);
+ length = Draw::Atof(a[i]);
move = line;
break;
i += 2;
if (i >= n) goto badargs;
{
- Standard_Real vx = atof(a[i-1]);
- Standard_Real vy = atof(a[i]);
+ Standard_Real vx = Draw::Atof(a[i-1]);
+ Standard_Real vy = Draw::Atof(a[i]);
if ((a[i-2][1] == 'T') || (a[i-2][1] == 't')) {
vx -= x;
vy -= y;
case 'r':
i++;
if (i >= n) goto badargs;
- angle = atof(a[i]) * (M_PI / 180.0);
+ angle = Draw::Atof(a[i]) * (M_PI / 180.0);
if ((a[i-1][1] == 'R') || (a[i-1][1] == 'r')) {
dx = Cos(angle);
dy = Sin(angle);
i += 2;
if (i >= n) goto badargs;
{
- Standard_Real vx = atof(a[i-1]);
- Standard_Real vy = atof(a[i]);
+ Standard_Real vx = Draw::Atof(a[i-1]);
+ Standard_Real vy = Draw::Atof(a[i]);
length = Sqrt(vx*vx+vy*vy);
if (length > Precision::Confusion()) {
// move = line; DUB
case 'c':
i += 2;
if (i >= n) goto badargs;
- radius = atof(a[i-1]);
+ radius = Draw::Atof(a[i-1]);
if (Abs(radius) > Precision::Confusion()) {
- angle = atof(a[i]) * (M_PI / 180.0);
+ angle = Draw::Atof(a[i]) * (M_PI / 180.0);
move = circle;
}
break;
case 'i':
i++;
if (i >= n) goto badargs;
- length = atof(a[i]);
+ length = Draw::Atof(a[i]);
if ((a[i-1][1] == 'X') || (a[i-1][1] == 'x')) {
if (Abs(dx) < Precision::Confusion()) {
di << "Profile : cannot intersect, arg " << i-1;
Handle(Geom2d_TrimmedCurve) ct =
new Geom2d_TrimmedCurve(l,0,length);
NbCurves++;
- sprintf(name,"%s_%d",a[1],NbCurves);
+ Sprintf(name,"%s_%d",a[1],NbCurves);
DrawTrSurf::Set(name,ct);
di.AppendElement(name);
x += length*dx;
Handle(Geom2d_TrimmedCurve) ct =
new Geom2d_TrimmedCurve(c,0,angle);
NbCurves++;
- sprintf(name,"%s_%d",a[1],NbCurves);
+ Sprintf(name,"%s_%d",a[1],NbCurves);
DrawTrSurf::Set(name,ct);
di.AppendElement(name);
gp_Pnt2d p;
BRepOffsetAPI_MakeOffset Paral;
TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_FACE);
- if ( Base.IsNull()) {
+ if ( Base.IsNull())
+ {
Base = DBRep::Get(a[2]);
if (Base.IsNull()) return 1;
Paral.Init(GeomAbs_Arc);
TopExp_Explorer exp;
- for (exp.Init(Base,TopAbs_WIRE); exp.More(); exp.Next()) {
+ for (exp.Init(Base,TopAbs_WIRE); exp.More(); exp.Next())
+ {
TopoDS_Wire aLocalShape = TopoDS::Wire(exp.Current());
Paral.AddWire(aLocalShape);
-// Paral.AddWire(TopoDS::Wire(exp.Current()));
+ }
}
- }
- else {
+ else
+ {
Base.Orientation(TopAbs_FORWARD);
-// Base = TopoDS::Face(Base.Oriented(TopAbs_FORWARD));
Paral.Init(TopoDS::Face(Base));
- }
+ }
Standard_Real U, dU;
Standard_Integer Nb;
- dU = atof(a[4]);
- Nb = atoi(a[3]);
+ dU = Draw::Atof(a[4]);
+ Nb = Draw::Atoi(a[3]);
Standard_Real Alt = 0.;
- if ( n == 6) Alt = atof(a[5]);
+ if ( n == 6)
+ Alt = Draw::Atof(a[5]);
+
Standard_Integer Compt = 1;
- for ( Standard_Integer i = 1; i <= Nb; i++) {
+ for ( Standard_Integer i = 1; i <= Nb; i++)
+ {
U = i * dU;
Paral.Perform(U,Alt);
- if ( !Paral.IsDone()) {
- //cout << " Parali aux fraises" << endl;
- di << " Parali aux fraises" << "\n";
- }
- else {
- sprintf(name,"%s_%d", a[1], Compt++);
+
+ if ( !Paral.IsDone())
+ {
+ di << " Error: Offset is not done." << "\n";
+ return 1;
+ }
+ else
+ {
+ Sprintf(name,"%s_%d", a[1], Compt++);
char* temp = name; // portage WNT
DBRep::Set(temp,Paral.Shape());
+ }
}
- }
+
return 0;
-}
+ }
//=======================================================================
//function : pickface
if (S.IsNull()) return 1;
char* name = new char[100];
- sprintf(name,"PickedFace %s",pick_name);
+ Sprintf(name,"PickedFace %s",pick_name);
DBRep::Set(name,S);
di.AppendElement(name);
return 0;
//-----------------------------------------------------
EInter.SetFaces(F,F);
Standard_Real TolInter = 1.e-7;
- if (n == 6) TolInter = atof(a[5]);
+ if (n == 6) TolInter = Draw::Atof(a[5]);
EInter.ForceTolerances(TolInter,TolInter);
Standard_Boolean reducesegments = Standard_True;
EInter.Perform (E[0],E[1],reducesegments);
gp_Pnt P = P2D.Value();
TopoDS_Vertex V = BRepLib_MakeVertex(P);
NbV ++;
- sprintf(name,"%s_%d",a[1],NbV);
+ Sprintf(name,"%s_%d",a[1],NbV);
DBRep::Set(name,V);
for (Standard_Integer i = 1; i <= 2; i++) {
//---------------------------------------------------------------
return 0;
}
+
+//=======================================================================
+//function : concatC0wire
+//purpose :
+//=======================================================================
+
+Standard_Integer concatC0wire(Draw_Interpretor&, Standard_Integer n, const char** c)
+{
+ if ( n < 3 ) return 1;
+
+ TopoDS_Shape S = DBRep::Get(c[2],TopAbs_WIRE) ;
+
+ if (S.IsNull())
+ return 1; //test if the shape is empty
+
+ TopoDS_Wire W = TopoDS::Wire(S) ;
+ TopoDS_Shape res;
+
+
+ res = BRepAlgo::ConcatenateWireC0(W); //treatment
+ DBRep::Set(c[1], res);
+ return 0;
+}
+
//=======================================================================
//function : concatwire
//purpose : reduce the multiply degree of the knots to the minimum without
if (S.IsNull()) return 1;
if (n==2) { Ok = BRepLib::BuildCurves3d(S); }
- else { Ok = BRepLib::BuildCurves3d(S,atof(a[2])); }
+ else { Ok = BRepLib::BuildCurves3d(S,Draw::Atof(a[2])); }
//if (!Ok) {cout << " one of the computation failed" << endl;}
if (!Ok) {di << " one of the computation failed" << "\n";}
"reducepcurves shape1 shape2 ...",
reducepcurves, g);
+ theCommands.Add("concatC0wire",
+ "concatC0wire result wire",
+ __FILE__,
+ concatC0wire,
+ g);
+
theCommands.Add("concatwire",
"concatwire result wire [option](G1/C1)",
__FILE__,