//
// This file is part of Open CASCADE Technology software library.
//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
#include <Draw_Appli.hxx>
#include <DrawTrSurf.hxx>
#include <DrawTrSurf_BSplineCurve2d.hxx>
+#include <DrawTrSurf_Point.hxx>
#include <gp.hxx>
#include <Precision.hxx>
#include <TopOpeBRepDS_Transition.hxx>
#include <stdio.h>
-#ifdef WNT
+#ifdef _WIN32
Standard_IMPORT Draw_Viewer dout;
#endif
static Standard_Integer vertex(Draw_Interpretor& , Standard_Integer n, const char** a)
{
- if (n < 4) return 1;
+ if (n < 3) return 1;
if (n >= 5) {
DBRep::Set(a[1],
BRepBuilderAPI_MakeVertex(gp_Pnt(Draw::Atof(a[2]),Draw::Atof(a[3]),Draw::Atof(a[4]))));
}
- else {
+ else if (n == 4)
+ {
TopoDS_Shape S = DBRep::Get(a[3]);
if (S.IsNull()) return 0;
if (S.ShapeType() != TopAbs_EDGE) return 0;
C.D0(Draw::Atof(a[2]),P);
DBRep::Set(a[1], BRepBuilderAPI_MakeVertex(P));
}
+ else
+ {
+ Handle(DrawTrSurf_Point) aP =
+ Handle(DrawTrSurf_Point)::DownCast(Draw::Get(a[2]));
+ DBRep::Set(a[1], BRepBuilderAPI_MakeVertex(aP->Point()));
+ }
return 0;
}
}
else {
//cout <<"Error creating edge"<<endl;
- di <<"Error creating edge"<<"\n";
+ di <<"Error creating edge\n";
}
return 0;
}
if (n < 3) return 1;
Standard_Integer i;
BRepBuilderAPI_MakeWire MW;
- for (i = 2; i < n; i ++) {
- TopoDS_Shape S = DBRep::Get(a[i]);
- if (S.IsNull()) continue;
- if (S.ShapeType() == TopAbs_EDGE)
- MW.Add(TopoDS::Edge(S));
- else if (S.ShapeType() == TopAbs_WIRE)
- MW.Add(TopoDS::Wire(S));
- else
- continue;
+ Standard_Boolean IsUnsorted = !strcmp(a[2], "-unsorted");
+
+ if (!IsUnsorted)
+ for (i = 2; i < n; i ++) {
+ TopoDS_Shape S = DBRep::Get(a[i]);
+ if (S.IsNull()) continue;
+ if (S.ShapeType() == TopAbs_EDGE)
+ MW.Add(TopoDS::Edge(S));
+ else if (S.ShapeType() == TopAbs_WIRE)
+ MW.Add(TopoDS::Wire(S));
+ else
+ continue;
+ }
+ else
+ {
+ TopTools_ListOfShape aLE;
+ for (i = 3; i < n; i ++)
+ {
+ TopoDS_Shape S = DBRep::Get(a[i]);
+ TopExp_Explorer Exp(S, TopAbs_EDGE);
+ for (;Exp.More();Exp.Next())
+ {
+ const TopoDS_Edge& anE = TopoDS::Edge(Exp.Current());
+ if (!anE.IsNull())
+ aLE.Append(anE);
+ }
+ }
+ MW.Add(aLE);
}
+
if (!MW.IsDone()) {
//cout << "Wire not done" << endl;
- di << "Wire not done" << "\n";
- return 0;
+ di << "Wire not done with an error:\n";
+ switch (MW.Error())
+ {
+ case BRepBuilderAPI_EmptyWire:
+ di << "BRepBuilderAPI_EmptyWire\n";
+ break;
+ case BRepBuilderAPI_DisconnectedWire:
+ di << "BRepBuilderAPI_DisconnectedWire\n";
+ break;
+ case BRepBuilderAPI_NonManifoldWire:
+ di << "BRepBuilderAPI_NonManifoldWire\n";
+ break;
+ default:
+ break;
+ }
}
- DBRep::Set(a[1],MW);
+ else
+ DBRep::Set(a[1],MW);
return 0;
}
Handle(Geom2d_Curve) C2d = DrawTrSurf::GetCurve2d(a[2]);
if (C.IsNull() && C2d.IsNull()) {
//cout << a[2] << " is not a curve" << endl;
- di << a[2] << " is not a curve" << "\n";
+ di << a[2] << " is not a curve\n";
return 1;
}
Handle(Geom_Curve) C = BRep_Tool::Curve(TopoDS::Edge(S),L,f,l);
if (C.IsNull()) {
//cout << a[2] << " has no 3d curve" << endl;
- di << a[2] << " has no 3d curve" << "\n";
+ di << a[2] << " has no 3d curve\n";
return 1;
}
C = new Geom_TrimmedCurve(C,f,l);
if (na < 3) return 1;
TopoDS_Shape S;
- S = DBRep::Get(a[2],TopAbs_EDGE); if (S.IsNull()) return 1;
+ S = DBRep::Get(a[2],TopAbs_EDGE);
+ if (S.IsNull())
+ return 1;
+
TopoDS_Edge E = TopoDS::Edge(S);
TopLoc_Location L;
Handle(Geom2d_Curve) C;
Handle(Geom_Surface) Surf;
+ Standard_Boolean hasFace = Standard_False;
+
if ( na == 3 ) {
// get the first PCurve connected to edge E
BRep_Tool::CurveOnSurface(E,C,Surf,L,f,l);
}
- else if ( na == 4 ) {
- S = DBRep::Get(a[3],TopAbs_FACE); if (S.IsNull()) return 1;
- TopoDS_Face F = TopoDS::Face(S);
- C = BRep_Tool::CurveOnSurface(E,F,f,l);
+ else if ( na == 4 )
+ {
+ S = DBRep::Get(a[3],TopAbs_FACE);
+ if (S.IsNull())
+ {
+ Standard_Integer ind = Draw::Atoi(a[3]);
+ BRep_Tool::CurveOnSurface(E,C,Surf,L,f,l,ind);
+ }
+ else
+ {
+ hasFace = Standard_True;
+ TopoDS_Face F = TopoDS::Face(S);
+ C = BRep_Tool::CurveOnSurface(E,F,f,l);
+ }
}
if (C.IsNull()) {
//cout << a[2] << " has no 2d curve"; if (na == 4) cout << " on " << a[3];
//cout << endl;
- di << a[2] << " has no 2d curve"; if (na == 4) di << " on " << a[3];
+ di << a[2] << " has no 2d curve";
+
+ if (hasFace)
+ {
+ di << " on " << a[3];
+ }
+
di << "\n";
return 1;
}
0.0e0) ;
gp_Pnt2d first_point(0.0e0,
0.0e0) ;
- Standard_Integer i = 2,
- wait = 1 ;
+ Standard_Integer i = 2;
+ Standard_Boolean wait = Standard_True;
// Standard_Real x0 = 0, y0 = 0, x = 0, y = 0, dx = 1, dy = 0;
Standard_Real x = 0, y = 0, dx = 1, dy = 0;
BRepBuilderAPI_MakeWire MW;
if (n < 5) return 1;
char name[100];
- BRepOffsetAPI_MakeOffset Paral;
+ BRepOffsetAPI_MakeOffset Paral;
+ GeomAbs_JoinType theJoinType = GeomAbs_Arc;
+ if (n >= 6 && strcmp(a[5], "i") == 0)
+ theJoinType = GeomAbs_Intersection;
+ Paral.Init(theJoinType);
TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_FACE);
if ( Base.IsNull())
{
Base = DBRep::Get(a[2]);
if (Base.IsNull()) return 1;
- Paral.Init(GeomAbs_Arc);
+ Paral.Init(theJoinType);
TopExp_Explorer exp;
for (exp.Init(Base,TopAbs_WIRE); exp.More(); exp.Next())
{
else
{
Base.Orientation(TopAbs_FORWARD);
- Paral.Init(TopoDS::Face(Base));
+ Paral.Init(TopoDS::Face(Base), theJoinType);
+ }
+
+ Standard_Real U, dU;
+ Standard_Integer Nb;
+ dU = Draw::Atof(a[4]);
+ Nb = Draw::Atoi(a[3]);
+
+ Standard_Real Alt = 0.;
+ if ( n == 7)
+ Alt = Draw::Atof(a[6]);
+
+ Standard_Integer Compt = 1;
+
+ for ( Standard_Integer i = 1; i <= Nb; i++)
+ {
+ U = i * dU;
+ Paral.Perform(U,Alt);
+
+ 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 : openoffset
+//purpose :
+//=======================================================================
+
+Standard_Integer openoffset(Draw_Interpretor& di,
+ Standard_Integer n, const char** a)
+{
+ if (n < 5) return 1;
+ char name[100];
+
+ BRepOffsetAPI_MakeOffset Paral;
+ GeomAbs_JoinType theJoinType = GeomAbs_Arc;
+ if (n == 6 && strcmp(a[5], "i") == 0)
+ theJoinType = GeomAbs_Intersection;
+ Paral.Init(theJoinType, Standard_True);
+ TopoDS_Shape Base = DBRep::Get(a[2] ,TopAbs_FACE);
+
+ if ( Base.IsNull())
+ {
+ Base = DBRep::Get(a[2], TopAbs_WIRE);
+ if (Base.IsNull()) return 1;
+ Paral.AddWire(TopoDS::Wire(Base));
+ }
+ else
+ {
+ Base.Orientation(TopAbs_FORWARD);
+ Paral.Init(TopoDS::Face(Base), theJoinType, Standard_True);
}
Standard_Real U, dU;
Nb = Draw::Atoi(a[3]);
Standard_Real Alt = 0.;
- if ( n == 6)
- Alt = Draw::Atof(a[5]);
Standard_Integer Compt = 1;
if ( !Paral.IsDone())
{
- di << " Error: Offset is not done." << "\n";
+ di << " Error: Offset is not done.\n";
return 1;
}
else
if (EInter.IsEmpty()) {
//cout << " No intersection found" << endl;
- di << " No intersection found" << "\n";
+ di << " No intersection found\n";
return 0;
}
di << " Orientation of vertex " << NbV << " on " << a[i+1] << ": ";
if (OO == TopAbs_FORWARD) {
//cout << "FORWARD" << endl;
- di << "FORWARD" << "\n";
+ di << "FORWARD\n";
} else {
//cout << "REVERSED" << endl;
- di << "REVERSED" << "\n";
+ di << "REVERSED\n";
}
}
}
if ( (n <2) || (n>3) ) {
//cout << " 1 or 2 arguments expected" << endl;
- di << " 1 or 2 arguments expected" << "\n";
+ di << " 1 or 2 arguments expected\n";
return 1;
}
Standard_Boolean Ok;
- TopoDS_Shape S = DBRep::Get(a[1],TopAbs_FACE);
+ TopoDS_Shape S = DBRep::Get(a[1]);
if (S.IsNull()) return 1;
if (n==2) { Ok = BRepLib::BuildCurves3d(S); }
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";}
+ if (!Ok) {di << " one of the computation failed\n";}
return 0;
}
TopoDS_Shape aShape = DBRep::Get(a[i]);
if (aShape.IsNull())
//cout << a[i] << " is not a valid shape" << endl;
- di << a[i] << " is not a valid shape" << "\n";
+ di << a[i] << " is not a valid shape\n";
else
BRepTools::RemoveUnusedPCurves(aShape);
}
const char* g = "TOPOLOGY Curve topology commands";
theCommands.Add("vertex",
- "vertex name [x y z / p edge]",__FILE__,
+ "vertex name [x y z | p edge | poin]",__FILE__,
vertex,g);
theCommands.Add("etrim",
polyvertex,g);
theCommands.Add("wire",
- "wire wirename e1/w1 [e2/w2 ...]",__FILE__,
+ "wire wirename [-unsorted] e1/w1 [e2/w2 ...]",__FILE__,
wire,g);
theCommands.Add("profile",
profile2d,g);
theCommands.Add("mkoffset",
- "mkoffset result face/compound of wires nboffset stepoffset [alt]",__FILE__,
+ "mkoffset result face/compound of wires nboffset stepoffset [jointype(a/i) [alt]]",__FILE__,
mkoffset);
+ theCommands.Add("openoffset",
+ "openoffset result face/wire nboffset stepoffset [jointype(a/i)]",__FILE__,
+ openoffset);
theCommands.Add("mkedge",
"mkedge edge curve [surface] [pfirst plast] [vfirst [pfirst] vlast [plast]] ",__FILE__,
mkcurve,g);
theCommands.Add("mk2dcurve",
- "mk2dcurve curve edge [face]",__FILE__,
+ "mk2dcurve curve edge [face OR index]",__FILE__,
mk2dcurve,g);
theCommands.Add("mkpoint",