-// File: SWDRAW_ShapeFix.cxx
-// Created: Tue Mar 9 15:49:13 1999
-// Author: data exchange team
-// <det@kinox.nnov.matra-dtv.fr>
-
+// Created on: 1999-03-09
+// Created by: data exchange team
+// Copyright (c) 1999-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 <SWDRAW_ShapeFix.ixx>
+
+#include <Draw.hxx>
#include <DBRep.hxx>
#include <SWDRAW.hxx>
#include <gp_XYZ.hxx>
#include <TopAbs_State.hxx>
#include <Draw_ProgressIndicator.hxx>
+#include <ShapeAnalysis_FreeBounds.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+#include <BRep_Builder.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
#ifdef AIX
#include <strings.h>
Standard_Real tmin,tmax;
mod2 = argv[premarg][0];
- if (mod2 == '=') tmin = tmax = atof (argv[argc-1]);
- else if (mod2 == '<') { tmin = 0; tmax = atof (argv[argc-1]); }
- else if (mod2 == '>') { tmin = atof (argv[argc-1]); tmax = 0; }
- else { tmin = atof (argv[premarg]); tmax = atof (argv[argc-1]); }
+ if (mod2 == '=') tmin = tmax = Draw::Atof (argv[argc-1]);
+ else if (mod2 == '<') { tmin = 0; tmax = Draw::Atof (argv[argc-1]); }
+ else if (mod2 == '>') { tmin = Draw::Atof (argv[argc-1]); tmax = 0; }
+ else { tmin = Draw::Atof (argv[premarg]); tmax = Draw::Atof (argv[argc-1]); }
if (argc == premarg + 1 || tmin == tmax) di<<"Setting Tolerance to "<<tmin<<"\n";
else if (tmax < tmin) di<<"Minimum Tolerance to "<<tmin<<"\n";
if(initShape.IsNull()) continue;
sfs->Init ( initShape );
} break;
- case 2: sfs->SetPrecision (atof(argv[i])); break;
- case 3: sfs->SetMaxTolerance(atof(argv[i])); break;
+ case 2: sfs->SetPrecision (Draw::Atof(argv[i])); break;
+ case 3: sfs->SetMaxTolerance(Draw::Atof(argv[i])); break;
}
}
par++;
if ( mess < 0 )
{
char buff[256];
- sprintf ( buff, "%s_%s", res, "m" );
+ Sprintf ( buff, "%s_%s", res, "m" );
di << " Modified shapes saved in compound: " << buff;
DBRep::Set (buff, aCompound);
}
}
Handle(ShapeFix_Wireframe) SFWF = new ShapeFix_Wireframe(S);
- Standard_Real prec = ( n >3 ? atof(a[3]) : 0. );
+ Standard_Real prec = ( n >3 ? Draw::Atof(a[3]) : 0. );
SFWF->SetPrecision(prec);
if ( SFWF->FixWireGaps() ) {
DBRep::Set(a[1],SFWF->Shape());
return 1;
}
- Standard_Real prec = (n == 4)? atof(a[3]) : 1.;
+ Standard_Real prec = (n == 4)? Draw::Atof(a[3]) : 1.;
ShapeFix_Wireframe SFWF(S);
SFWF.SetPrecision(prec);
Standard_Integer mode = 2;
Standard_Real tolang = M_PI/2;
if(n > k)
- tol = atof(a[k++]);
+ tol = Draw::Atof(a[k++]);
if(n > k)
- mode= atoi(a[k++]);
+ mode= Draw::Atoi(a[k++]);
if(n > k)
- tolang = atof(a[k++]);
+ tolang = Draw::Atof(a[k++]);
Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe();
Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape;
Standard_Real aDistDomain = 0.0;
Standard_Integer k = 3;
if(k < n)
- aTol = atof(a[k++]);
+ aTol = Draw::Atof(a[k++]);
if(k < n)
- aDistDomain = atof(a[k++]);
+ aDistDomain = Draw::Atof(a[k++]);
ShapeAnalysis_Edge sae;
if(sae.CheckOverlapping(e1,e2,aTol,aDistDomain)) {
return 1;
}
TopoDS_Shape Sh1 = DBRep::Get(a[1]);
- Standard_Real ucoord = atof(a[2]);
- Standard_Real vcoord = atof(a[3]);
+ Standard_Real ucoord = Draw::Atof(a[2]);
+ Standard_Real vcoord = Draw::Atof(a[3]);
if(Sh1.IsNull() || Sh1.ShapeType()!= TopAbs_FACE) {
di<<"Invalid arguments"<<"\n";
return 1;
return 0;
}
+static Standard_Integer connectedges(Draw_Interpretor& di, Standard_Integer n, const char** a)
+{
+ if( n < 3) {
+ di<<"Invalid number of arguments. Should be : result shape [toler shared]"<<"\n";
+ return 1;
+ }
+ TopoDS_Shape aSh1 = DBRep::Get(a[2]);
+ if(aSh1.IsNull()) {
+ di<<"Shape is null"<<"\n";
+ return 1;
+ }
+ Standard_Real aTol = Precision::Confusion();
+ if( n > 3)
+ aTol = Draw::Atof(a[3]);
+
+ Standard_Boolean shared = Standard_True;
+ if( n > 4)
+ shared = (Draw::Atoi(a[4]) == 1);
+ TopExp_Explorer aExpE(aSh1,TopAbs_EDGE);
+ Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
+ Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
+ TopTools_IndexedMapOfShape aMapEdges;
+ for( ; aExpE.More(); aExpE.Next())
+ {
+ aSeqEdges->Append(aExpE.Current());
+ aMapEdges.Add(aExpE.Current());
+ }
+
+ ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges,aTol,shared,aSeqWires );
+ TopoDS_Compound aComp;
+ BRep_Builder aB;
+ aB.MakeCompound(aComp);
+ Standard_Integer i = 1;
+ for( ; i <= aSeqWires->Length() ; i++)
+ {
+ TopoDS_Shape aW = aSeqWires->Value(i);
+ di<<"Wire - "<<i<<" : "<<"\n";
+
+ TopExp_Explorer aExp1(aW, TopAbs_EDGE);
+ for( ; aExp1.More(); aExp1.Next())
+ {
+ if(shared)
+ {
+ Standard_Integer ind = aMapEdges.FindIndex(aExp1.Current());
+ di<<ind<<" ";
+ }
+ else
+ {
+ TopoDS_Vertex aV1, aV2;
+ TopExp::Vertices(TopoDS::Edge(aExp1.Current()), aV1,aV2);
+ gp_Pnt aP = BRep_Tool::Pnt(aV1);
+ di<<aP.X()<<" "<<aP.Y()<<" "<<aP.Z()<<"\n";
+ }
+ }
+
+ di<<"\n";
+ aB.Add( aComp,aSeqWires->Value(i));
+ }
+ DBRep::Set(a[1],aComp);
+ return 0;
+
+}
+
//=======================================================================
//function : InitCommands
//purpose :
__FILE__,checkoverlapedges,g);
theCommands.Add ("checkfclass2d","face ucoord vcoord",
__FILE__,checkfclass2d,g);
+ theCommands.Add ("connectedges","res shape [toler shared]",
+ __FILE__,connectedges,g);
+
}