1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

1
src/SWDRAW/FILES Executable file
View File

@@ -0,0 +1 @@
cpulimit.pc

64
src/SWDRAW/SWDRAW.cdl Executable file
View File

@@ -0,0 +1,64 @@
-- File: SWDRAW.cdl
-- Created: Wed May 6 13:34:18 1998
-- Author: Christian CAILLET
-- <cky@paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
package SWDRAW
---Purpose: Provides DRAW interface to the functionalities of Shape Healing
-- toolkit (SHAPEWORKS Delivery Unit).
--
-- Classes prefixed with Shape* corresponds to the packages of
-- Shape Healing.
uses TCollection, TColStd, TopoDS, TopTools, Draw, ShapeProcessAPI
is
class ShapeTool;
---Purpose: Contains commands to activate Topology/Geometry not
-- Shape Healing
class ShapeAnalysis;
---Purpose: Contains commands to activate package ShapeAnalysis
class ShapeBuild;
---Purpose: Contains commands to activate package ShapeBuild
class ShapeConstruct;
---Purpose: Contains commands to activate package ShapeConstruct
class ShapeCustom;
---Purpose: Contains commands to activate package ShapeCustom
class ShapeExtend;
---Purpose: Contains commands to activate package ShapeExtend
class ShapeFix;
---Purpose: Contains commands to activate package ShapeFix
class ShapeUpgrade;
---Purpose: Contains commands to activate package ShapeUpgrade
class ShapeProcess;
---Purpose: Contains commands to activate package ShapeProcess
class ShapeProcessAPI;
---Purpose: Contains commands to activate package ShapeProcessAPI
class ToVRML;
---Purpose: A utility which writes a Shape to VRML format
---Remark : It can be placed elsewhere, while it depends on
-- only BRepMesh i.e. TOPOLOGY
Init (theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in SWDRAW
GroupName returns CString is private;
---Purpose: Returns the name of the DRAW group accumulating the
-- commands from the classes prefixed with Shape*.
-- Returns "Shape Healing".
end SWDRAW;

237
src/SWDRAW/SWDRAW.cxx Executable file
View File

@@ -0,0 +1,237 @@
#include <SWDRAW.ixx>
#include <DBRep.hxx>
// CKY 4-AOUT-1998 : pb avec GeomFill
//#include <GeometryTest.hxx>
//#include <BRepTest.hxx>
//#include <MeshTest.hxx>
#include <SWDRAW_ShapeTool.hxx>
#include <SWDRAW_ShapeAnalysis.hxx>
#include <SWDRAW_ShapeBuild.hxx>
#include <SWDRAW_ShapeConstruct.hxx>
#include <SWDRAW_ShapeCustom.hxx>
#include <SWDRAW_ShapeExtend.hxx>
#include <SWDRAW_ShapeFix.hxx>
#include <SWDRAW_ShapeUpgrade.hxx>
#include <SWDRAW_ShapeProcess.hxx>
#include <SWDRAW_ShapeProcessAPI.hxx>
// tovrml
#include <TopoDS_Shape.hxx>
#include <SWDRAW_ToVRML.hxx>
//#72 rln 09.03.99 Packaging of SWDRAW
#include <ShapeProcess_OperLibrary.hxx>
#include <BRepTools.hxx>
#include <Draw_Window.hxx>
#include <BRep_Builder.hxx>
#include <gp_Trsf.hxx>
// for NSPApply -- CKY 12 JUL 2001
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
static int dejadraw = 0;
//=======================================================================
//function : cpulimit (WNT)
//purpose :
//=======================================================================
#ifdef WNT
#include "cpulimit.pc"
static Standard_Integer cpulimit_draw(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n < 2) { di<<"Give a value"<<"\n"; return 1; }
int nn = atoi(a[1]);
di<<"LIMIT ELASPED TIME = "<<nn<<" seconds"<<"\n";
limitelapsed(nn);
return 0;
}
#endif
//#72 rln 09.03.99 Packaging of SWDRAW
//=======================================================================
//function : tovrml
//purpose :
//=======================================================================
static Standard_Integer tovrml(Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
{
if (n < 3) return 1;
SWDRAW_ToVRML avrml;
TopoDS_Shape sh = DBRep::Get (a[1]);
const char* filename = a[2];
if (!avrml.Write (sh,filename)) return 1;
return 0;
}
//=======================================================================
//function : LocSet
//purpose :
//=======================================================================
static Standard_Integer LocSet (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 2) {
di << argv[0] << "LocSet a [b [c]]: set location for shape \"a\":" << "\n";
di << "- to Null if one argument is given" << "\n";
di << "- to location of shape b if two arguments are given" << "\n";
di << "- to difference of locations of shapes b and c if three arguments are given" << "\n";
return 1;
}
TopoDS_Shape a = DBRep::Get ( argv[1] );
if ( a.IsNull() ) {
di << "No shape named \"" << argv[1] << "\" found" << "\n";
return 1;
}
TopLoc_Location L;
if ( argc >2 ) {
TopoDS_Shape b = DBRep::Get ( argv[2] );
if ( b.IsNull() ) {
di << "No shape named \"" << argv[2] << "\" found" << "\n";
return 1;
}
if ( argc >3 ) {
TopoDS_Shape c = DBRep::Get ( argv[3] );
if ( c.IsNull() ) {
di << "No shape named \"" << argv[3] << "\" found" << "\n";
return 1;
}
L = b.Location().Multiplied ( c.Location().Inverted() );
}
else L = b.Location();
}
a.Location ( L );
DBRep::Set ( argv[1], a );
return 0;
}
//=======================================================================
//function : LocDump
//purpose :
//=======================================================================
static Standard_Integer LocDump (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 2) {
di << argv[0] << "LocDump a: dump location of shape \"a\"" << "\n";
return 1;
}
TopoDS_Shape a = DBRep::Get ( argv[1] );
if ( a.IsNull() ) {
di << "No shape named \"" << argv[1] << "\" found" << "\n";
return 1;
}
TopLoc_Location L = a.Location();
di << "Location of shape " << argv[1] << ":" << "\n";
// L.ShallowDump ( di );
di << "Results in:" << "\n";
gp_Trsf T = L.Transformation();
TopLoc_Location l ( T );
//l.ShallowDump ( di );
Standard_SStream aSStream;
l.ShallowDump ( aSStream );
di << aSStream;
return 0;
}
//=======================================================================
//function : NSPApply
//purpose : CKY , 12 JUL 2001
//=======================================================================
static Standard_Integer NSPApply (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if ( argc < 6) {
di<<"NSPApply result(new shape) shape(initial shape) rscfile sequence tol [maxtol, default=1]"<<"\n";
return 1;
}
TopoDS_Shape shape = DBRep::Get ( argv[2] );
if (shape.IsNull()) {
di << "No shape named \"" << argv[1] << "\" found" << "\n";
return 1;
}
TopoDS_Shape newshape;
Standard_Real tol = atof(argv[5]);
Standard_Real maxtol = 1.;
if (argc > 6) maxtol = atof(argv[6]);
XSAlgo::AlgoContainer()->PrepareForTransfer();
Handle(Standard_Transient) info; // reserved for special uses
newshape = XSAlgo::AlgoContainer()->ProcessShape
( shape, tol, maxtol, argv[3] , argv[4] , info);
// WHAT IS MISSING HERE IS MERGING with starting transfer map
if (newshape.IsNull()) {
di<<"No result produced"<<"\n";
}
else
DBRep::Set ( argv[1], newshape );
return 0;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void SWDRAW::Init (Draw_Interpretor& theCommands)
{
if (!dejadraw) {
dejadraw = 1;
// DBRep::BasicCommands(theCommands);
// CKY 4-AOUT-1998 : pb avec GeomFill
// GeometryTest::AllCommands(theCommands);
// BRepTest::AllCommands(theCommands);
// MeshTest::Commands(theCommands);
}
SWDRAW_ShapeTool::InitCommands (theCommands);
SWDRAW_ShapeAnalysis::InitCommands (theCommands);
SWDRAW_ShapeBuild::InitCommands (theCommands);
SWDRAW_ShapeConstruct::InitCommands (theCommands);
SWDRAW_ShapeCustom::InitCommands (theCommands);
SWDRAW_ShapeExtend::InitCommands (theCommands);
SWDRAW_ShapeFix::InitCommands (theCommands);
SWDRAW_ShapeUpgrade::InitCommands (theCommands);
SWDRAW_ShapeProcess::InitCommands (theCommands);
SWDRAW_ShapeProcessAPI::InitCommands (theCommands);
#ifdef WNT
theCommands.Add("limitelapsed", "nn seconds",__FILE__, cpulimit_draw, "essai");
#endif
// locations
theCommands.Add("LocSet", "a [b [c]]: set loc b->a; use no args to get help",__FILE__,LocSet,"essai");
theCommands.Add("LocDump", "a: dump location of a",__FILE__,LocDump,"essai");
//tovrml
theCommands.Add("tovrml", "shape filename",__FILE__, tovrml, "essai");
// register operators for ShapeProcessing
ShapeProcess_OperLibrary::Init();
// new shape processing
theCommands.Add ("NSPApply","NSPApply result shape rscfilename sequence tol [maxtol, default=1]",
__FILE__,NSPApply,"essai");
}
//=======================================================================
//function : GroupName
//purpose :
//=======================================================================
Standard_CString SWDRAW::GroupName()
{
return "Shape Healing";
}

View File

@@ -0,0 +1,24 @@
-- File: SWDRAW_ShapeAnalysis.cdl
-- Created: Tue Mar 9 15:26:10 1999
-- Author: data exchange team
-- <det@nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ShapeAnalysis from SWDRAW
---Purpose: Contains commands to activate package ShapeAnalysis
-- List of DRAW commands and corresponding functionalities:
-- tolerance - ShapeAnalysis_ShapeTolerance
-- projcurve - ShapeAnalysis_Curve
-- projface - ShapeAnalysis_Surface
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in ShapeAnalysis
end ShapeAnalysis;

View File

@@ -0,0 +1,869 @@
// File: SWDRAW_ShapeAnalysis.cxx
// Created: Tue Mar 9 15:48:00 1999
// Author: data exchange team
// <det@kinox.nnov.matra-dtv.fr>
// sln 19.11.2001. Bug 2: Correction of output of 'statshape' draw function.
#include <SWDRAW_ShapeAnalysis.ixx>
#include <stdio.h>
#include <DBRep.hxx>
#include <DrawTrSurf.hxx>
#include <SWDRAW.hxx>
#include <Precision.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI.hxx>
#include <ShapeAnalysis.hxx>
#include <ShapeAnalysis_ShapeTolerance.hxx>
#include <ShapeAnalysis_Curve.hxx>
#include <ShapeAnalysis_Surface.hxx>
#include <ShapeAnalysis_Edge.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Wire.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Edge.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <GProp_GProps.hxx>
#include <BRepGProp.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <ShapeAnalysis_ShapeContents.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TCollection_AsciiString.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <ShapeAnalysis_FreeBoundsProperties.hxx>
#include <ShapeAnalysis_FreeBoundData.hxx>
#include <ShapeFix_FreeBounds.hxx>
#include <ShapeExtend_WireData.hxx>
static Standard_Integer tolerance
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 2) { di<<"myshape : analyses a shape\n"
<< "myshape [mode] valmin : sub-shapes over valmin\n"
<<"myshape [mode] valmin valmax : between valmin and valmax\n"
<<"myshape [mode] 0 valmax : below valmax\n"
<<" more : all shapes(D) v vertices e edges f faces c combined(faces)"<<"\n";
return (argc < 2 ? 0 : 1 /* Error */); }
Standard_CString arg1 = argv[1];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
ShapeAnalysis_ShapeTolerance sat;
if (argc == 2) {
sat.InitTolerance();
sat.AddTolerance (Shape);
di<<"Tolerance MAX="<<sat.GlobalTolerance(1)<<" AVG="<<sat.GlobalTolerance(0)<<" MIN="<<sat.GlobalTolerance(-1)<<"\n";
sat.InitTolerance();
sat.AddTolerance (Shape,TopAbs_FACE);
di<<"FACE : MAX="<<sat.GlobalTolerance(1)<<" AVG="<<sat.GlobalTolerance(0)<<" MIN="<<sat.GlobalTolerance(-1)<<"\n";
sat.InitTolerance();
sat.AddTolerance (Shape,TopAbs_EDGE);
di<<"EDGE : MAX="<<sat.GlobalTolerance(1)<<" AVG="<<sat.GlobalTolerance(0)<<" MIN="<<sat.GlobalTolerance(-1)<<"\n";
sat.InitTolerance();
sat.AddTolerance (Shape,TopAbs_VERTEX);
di<<"VERTEX : MAX="<<sat.GlobalTolerance(1)<<" AVG="<<sat.GlobalTolerance(0)<<" MIN="<<sat.GlobalTolerance(-1)<<"\n";
} else {
// Analyse plus fouillee
Standard_Integer nextarg = 2;
char opt = argv[2][0];
TopAbs_ShapeEnum type = TopAbs_SHAPE;
if (opt == 'a') nextarg = 3;
else if (opt == 'c') { nextarg = 3; type = TopAbs_SHELL; }
else if (opt == 'e') { nextarg = 3; type = TopAbs_EDGE; }
else if (opt == 'f') { nextarg = 3; type = TopAbs_FACE; }
else if (opt == 'v') { nextarg = 3; type = TopAbs_VERTEX; }
if (nextarg < 3) opt = 'a';
Standard_Real tol1= 0., tol2= 0.;
if (nextarg < argc) tol1 = atof (argv[nextarg]);
if (nextarg < argc-1) tol2 = atof (argv[nextarg+1]);
// Standard_Real tol = atof (argv[2]);
Handle(TopTools_HSequenceOfShape) list = sat.InTolerance (Shape,tol1,tol2,type);
Standard_Integer i, nb = list->Length();
switch (type) {
case TopAbs_VERTEX : di<<"Analysing Vertices gives "; break;
case TopAbs_EDGE : di<<"Analysing Edges gives "; break;
case TopAbs_FACE : di<<"Analysing Faces gives "; break;
case TopAbs_SHELL : di<<"Analysing Shells,Faces+content gives "; break;
default : di<<"Analysing all sub-shapes gives ";
}
if (tol1 == 0) di<<nb<<" Shapes below tol="<<tol2;
else if (tol2 == 0) di<<nb<<" Shapes over tol="<<tol1;
else di<<nb<<" Shapes between tol1="<<tol1<<" and tol2="<<tol2;
if (nb == 1) di<<" , named tol_1";
if (nb > 1) di<<" , named tol_1 to tol_"<<nb;
di<<"\n";
char nomsh[30];
for (i = 1; i <= nb; i ++) {
sprintf (nomsh,"tol_%d",i);
DBRep::Set (nomsh,list->Value(i));
}
}
return 0;
}
static Standard_Integer projface
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 4) { di<<"Give FACE name and X Y [Z]"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
if (Shape.ShapeType() != TopAbs_FACE) { di<<"Not a face"<<"\n"; return 1 /* Error */; }
TopoDS_Face F = TopoDS::Face (Shape);
Handle(Geom_Surface) thesurf = BRep_Tool::Surface (F); // pas locface
// On y va
Standard_Real X,Y,Z,U,V;
X = U = atof (argv[2]);
Y = V = atof (argv[3]);
if (argc > 4) {
Z = atof (argv[4]);
gp_Pnt P3D (X,Y,Z);
di<<" Point 3D X = "<<X<<" Y = "<<Y<<" Z = "<<Z<<"\n";
Standard_Real uf, ul, vf, vl;
thesurf->Bounds(uf, ul, vf, vl);
if (Precision::IsInfinite(uf)) uf = -1000;
if (Precision::IsInfinite(ul)) ul = 1000;
if (Precision::IsInfinite(vf)) vf = -1000;
if (Precision::IsInfinite(vl)) vl = 1000;
Standard_Real du = Abs(ul-uf)/10; Standard_Real dv = Abs(vl-vf)/10;
GeomAPI_ProjectPointOnSurf proj(P3D, thesurf, uf-du, ul+du, vf-dv, vl+dv);
Standard_Integer sol, nPSurf = proj.NbPoints();
di<<" Found "<<nPSurf<<" Points"<<"\n";
for (sol = 1; sol <= nPSurf; sol ++) {
di<<"n0 "<<sol<<" Distance "<<proj.Distance(sol);
proj.Parameters(sol, U,V);
di<<" U = "<<U<<" V = "<<V<<"\n";
// reprojection
P3D = thesurf->Value (U,V);
di<<" => reproj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
}
// Que donne ShapeTool ?
P3D.SetCoord (X,Y,Z);
Handle(ShapeAnalysis_Surface) su = new ShapeAnalysis_Surface(thesurf);
gp_Pnt2d suval = su->ValueOfUV (P3D,BRep_Tool::Tolerance(F));
suval.Coord(U,V);
di<<"** ShapeAnalysis_Surface gives U = "<<U<<" V = "<<V<<"\n";
P3D = thesurf->Value(U,V);
di<<" => reproj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
} else {
di<<" Point UV U = "<<U<<" V = "<<V<<"\n";
gp_Pnt P3D = thesurf->Value(U,V);
di<<" => proj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
}
return 0;
}
static Standard_Integer projcurve
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// admet une EDGE ou une CURVE
if (argc < 5) { di<<"Give : EDGE X Y Z or CURVE3D X Y Z or CURVE3D first last X Y Z"<<"\n"; return 1 /* Error */; }
const char * arg1 = argv[1];
Standard_Integer i0 = 0;
TopoDS_Shape Shape = DBRep::Get(arg1);
Handle(Geom_Curve) C; Standard_Real cf,cl;
if (!Shape.IsNull()) {
if (Shape.ShapeType() == TopAbs_EDGE) {
TopoDS_Edge E = TopoDS::Edge(Shape);
C = BRep_Tool::Curve (E,cf,cl);
di<<"Edge "<<arg1<<" Params from "<<cf<<" to "<<cl<<"\n";
} else {
di<<"SHAPE "<<arg1<<" Not an EDGE"<<"\n"; return 1 /* Error */;
}
} else {
const char* a1 = arg1;
C = DrawTrSurf::GetCurve (a1);
if (C.IsNull())
{ di<<arg1<<" neither EDGE nor CURVE 3D"<<"\n"; return 1 /* Error */; }
cf = C->FirstParameter(); cl = C->LastParameter();
if (argc >= 7) { cf = atof (argv[2]); cl = atof (argv[3]); i0 = 2; }
di<<"Curve 3D "<<arg1<<" Params from "<<cf<<" to "<<cl<<"\n";
}
Standard_Real X,Y,Z;
X = atof (argv[2+i0]);
Y = atof (argv[3+i0]);
Z = atof (argv[4+i0]);
di<<"Precision (BRepBuilderAPI) : "<<BRepBuilderAPI::Precision()
<<" Projection : "<<X<<" "<<Y<<" "<<Z<<"\n";
gp_Pnt P3D (X,Y,Z);
gp_Pnt res; Standard_Real param,dist;
dist = ShapeAnalysis_Curve().Project (C,P3D,BRepBuilderAPI::Precision(),res,param, cf,cl);
res.Coord(X,Y,Z);
di<<"Result : "<<X<<" "<<Y<<" "<<Z<<"\n"<<"Param = "<<param<<" Gap = "<<dist<<"\n";
return 0;
}
static Standard_Integer anaface
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 2) { di<<"donner un nom de face"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<arg1<<" inconnu"<<"\n"; return 1 /* Error */; }
// if (Shape.ShapeType() != TopAbs_FACE) { di<<"Pas une FACE"<<"\n"; return 1 /* Error */; }
// On regarde les wires, sont-ils bien fermes
Standard_Integer nbw = 0, nbe = 0;
Handle(Geom_Surface) surface;
TopoDS_Face Face;
if (Shape.ShapeType() == TopAbs_FACE) {
Face = TopoDS::Face(Shape);
surface = BRep_Tool::Surface (Face); // pas locface
// TopLoc_Location locface;
di<<"Face, surface type = "<<surface->DynamicType()->Name()<<" Tol="<<BRep_Tool::Tolerance(Face);
if (Face.Orientation() == TopAbs_REVERSED) {
di<<" (REV)";
// Face.Orientation(TopAbs_FORWARD);
}
di<<"\n";
}
else { di<<"Analyse Wires, Ignore Faces"<<"\n"; }
Standard_Boolean iasurf = !surface.IsNull();
//:sw if (!Face.IsNull()) STW.SetFace (Face);
//:sw else STW.SetPrecision (BRepBuilderAPI::Precision());
for (TopExp_Explorer exp(Shape,TopAbs_WIRE); exp.More(); exp.Next()) {
TopoDS_Wire Wire = TopoDS::Wire (exp.Current()); nbw ++; nbe = 0;
di<<"WIRE "<<nbw;
if (Wire.Orientation() == TopAbs_FORWARD) di<<" (FWD)"<<"\n";
else di<<" (REV)"<<"\n";
gp_Pnt fin,debut;
gp_Pnt2d finuv,debuv; gp_XY baseuv;
TopoDS_Vertex fv,lv;
Standard_Real maxp3d = 0., maxuv = 0., maxvtx = 0.;
Standard_Real df3d= 0.,dl3d= 0.,dvtx= 0.,duv= 0.;
Standard_Boolean iaw2d = iasurf;
Standard_Real u1= 0.,u2= 0.,v1= 0.,v2= 0.,umin= 0.,umax= 0.,vmin= 0.,vmax= 0., totcross= 0.;
//:sw STW.ClearWire(); STW.Load (Wire);
// if (STW.Reorder()) di<<"Wire reordered to explore"<<"\n";
// for (TopExp_Explorer exe(Wire.Oriented(TopAbs_FORWARD),TopAbs_EDGE); exe.More(); exe.Next()) {
// TopoDS_Edge Edge = TopoDS::Edge (exe.Current()); nbe ++;
//:sw for (nbe = 1; nbe <= STW.NbEdges(); nbe ++) {
//:sw TopoDS_Edge Edge = STW.Edge(nbe);
TopoDS_Iterator it (Wire); //:sw: ShapeTool_Wire -> TopoDS_Iterator (it is the same)
for (; it.More(); it.Next()) {
TopoDS_Edge Edge = TopoDS::Edge (it.Value());
di<<"Wire "<<nbw<<", Edge "<<nbe;
if (Edge.Orientation() == TopAbs_FORWARD) di<<" (FWD";
else di<<" (REV";
di<<" , Tol= "<<BRep_Tool::Tolerance (Edge)<<" )"<<"\n";
Standard_Real f3d,l3d,f2d,l2d;
Handle(Geom_Curve) curve3d = BRep_Tool::Curve (Edge,f3d,l3d);
Handle(Geom2d_Curve) curve2d;
if (iasurf) curve2d = BRep_Tool::CurveOnSurface(Edge,Face,f2d,l2d);
Standard_Boolean ia2d = !curve2d.IsNull(); iaw2d |= ia2d;
if (!ia2d) di<<"-- No PCurve"<<"\n";
if (curve3d.IsNull()) di<<"-- no Curve 3d"<<"\n";
// On va tacher de calculer les positions et les comparer
gp_Pnt2d fuv,luv;
if (Edge.Orientation() == TopAbs_FORWARD)
{ TopExp::Vertices (Edge,fv,lv);
if (ia2d) BRep_Tool::UVPoints (Edge,Face,fuv,luv); }
else
{ TopExp::Vertices (Edge,lv,fv);
if (ia2d) BRep_Tool::UVPoints (Edge,Face,luv,fuv); }
gp_Pnt fp = BRep_Tool::Pnt (fv);
gp_Pnt lp = BRep_Tool::Pnt (lv);
gp_Pnt fxyz, lxyz;
if (ia2d) {
surface->D0 (fuv.X(),fuv.Y(),fxyz);
surface->D0 (luv.X(),luv.Y(),lxyz);
df3d = fp.Distance (fxyz); maxp3d = Max (maxp3d,df3d);
dl3d = lp.Distance (lxyz); maxp3d = Max (maxp3d,dl3d);
if (nbe > 1) duv = finuv.Distance (fuv); maxuv = Max (maxuv, duv);
// et les min-max
u1 = Min (fuv.X(),luv.X()); u2 = Max (fuv.X(),luv.X());
v1 = Min (fuv.Y(),luv.Y()); v2 = Max (fuv.Y(),luv.Y());
if (nbe == 1) { umin = u1; umax = u2; vmin = v1; vmax = v2; }
else { umin = Min(umin,u1); umax = Max(umax,u2); vmin = Min(vmin,v1); vmax = Max(vmax,v2); }
// et la classification directe
if (nbe == 1) { baseuv = fuv.XY(); totcross = 0; }
else {
gp_XY buv1 = fuv.XY() - baseuv;
gp_XY buv2 = luv.XY() - baseuv;
totcross += buv2.Crossed(buv1);
}
}
// Resultats ...
if (nbe == 1) { debut = fxyz; debuv = fuv; }
else {
duv = finuv.Distance (fuv); maxuv = Max (maxuv, duv);
dvtx = fin.Distance (fxyz); maxvtx = Max (maxvtx,dvtx);
di<<" Fin("<<nbe-1<<")-Debut("<<nbe<<"): DISTANCE="<<dvtx;
if (ia2d) di<<" DeltaUV="<<duv;
di<<" Tol(Fin)="<<BRep_Tool::Tolerance(lv)<<"\n";
}
fin = lxyz; finuv = luv;
di<<"-- Deb : VTX="<<fp.X()<<" , "<<fp.Y()<<" , "<<fp.Z()
<<"\n XYZ="<<fxyz.X()<<" , "<<fxyz.Y()<<" , "<<fxyz.Z()
<<"\n UV="<<fuv.X()<<" , "<<fuv.Y()<<" -- D.UV/3D="<<df3d<<"\n";
di<<"-- Fin : VTX="<<lp.X()<<" , "<<lp.Y()<<" , "<<lp.Z()
<<"\n XYZ="<<lxyz.X()<<" , "<<lxyz.Y()<<" , "<<lxyz.Z()
<<"\n UV="<<luv.X()<<" , "<<luv.Y()<<" -- D.UV/3D="<<dl3d<<"\n";
}
dvtx = fin.Distance (debut); maxvtx = Max (maxvtx,dvtx);
if (iaw2d) { duv = finuv.Distance (debuv); maxuv = Max (maxuv, duv); }
di<<" Fin("<<nbe<<")-Debut(1): DISTANCE="<<dvtx;
if (iaw2d) di <<" DeltaUV="<<duv;
di<<" Tol(Fin)="<<BRep_Tool::Tolerance(lv)<<"\n";
di<<" Wire "<<nbw<<" Max : Dist.Vertex="<<maxvtx;
if (iaw2d) di<<" Ecart UV/3D="<<maxp3d<<" DeltaUV="<<maxuv;
di<<"\n";
// Min Max
if (iaw2d) {
di<<"TotCross="<<totcross;
di<<" UMin-Max:"<<umin<<" , "<<umax<<" VMin-Max:"<<vmin<<" , "<<vmax<<"\n";
Standard_Real difu = umax - umin, difv = vmax - vmin;
GProp_GProps G;
BRepGProp::SurfaceProperties(Face,G);
if (G.Mass() > 0) di<<"GProps:Mass Out"<<"\n";
else di<<"GProps:Mass In"<<"\n";
/// return (G.Mass() > 0);
BRepTopAdaptor_FClass2d fcl (Face,BRep_Tool::Tolerance(Face));
if (fcl.PerformInfinitePoint () == TopAbs_OUT) di<<"Classifier Infinite : Out"<<"\n";
else di<<"Classifier Infinite : In"<<"\n";
gp_Pnt2d pcl;
pcl.SetCoord(umin-difu,vmin-difv);
if (fcl.Perform (pcl) == TopAbs_OUT) di<<"Classifier UMin-VMin : Out"<<"\n";
pcl.SetCoord(umin-difu,vmax+difv);
if (fcl.Perform (pcl) == TopAbs_OUT) di<<"Classifier UMin-VMax : Out"<<"\n";
pcl.SetCoord(umax+difu,vmin-difv);
if (fcl.Perform (pcl) == TopAbs_OUT) di<<"Classifier UMax-VMin : Out"<<"\n";
pcl.SetCoord(umax+difu,vmax+difv);
if (fcl.Perform (pcl) == TopAbs_OUT) di<<"Classifier UMax-VMax : Out"<<"\n";
}
}
if (ShapeAnalysis::IsOuterBound (Face)) di<<"ShapeAnalysis: Outer Bound"<<"\n";
else di<<"ShapeAnalysis: Not Outer Bound"<<"\n";
di<<" Total "<<nbw<<" Wire(s)"<<"\n";
return 0;
}
static Standard_Integer XSHAPE_statshape(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 2) { di<<"ShapeName; + options : prefix for particular cases : what to get"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
Standard_CString arg2 = NULL;
Standard_CString arg3 = NULL;
if (argc > 2) arg2 = argv[2];
if (argc > 3) arg3 = argv[3];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
char nompart[100];
Standard_Integer nb;
ShapeAnalysis_ShapeContents analyzer;
if(argc > 3) {
analyzer.ModifyBigSplineMode()=(strstr("bigspl",arg3)!=NULL);
analyzer.ModifyIndirectMode()=(strstr("indsur",arg3)!=NULL);
analyzer.ModifyOffestSurfaceMode()=(strstr("ofsur",arg3)!=NULL);
analyzer.ModifyTrimmed3dMode()=(strstr("trc3d",arg3)!=NULL);
analyzer.ModifyOffsetCurveMode()=(strstr("ofcur",arg3)!=NULL);
analyzer.ModifyTrimmed2dMode()=(strstr("trc2d",arg3)!=NULL);
}
analyzer.Perform(Shape);
di<<"Count Item\n----- ----"<<"\n";
nb = analyzer.NbEdges();
if(nb>0) di<<nb<<" "<<" EDGE (Oriented)"<<"\n";
nb = analyzer.NbSharedEdges();
if(nb>0) di<<nb<<" "<<" EDGE (Shared)"<<"\n";
nb = analyzer.NbFreeEdges();
if(nb>0) di<<nb<<" "<<" EDGE (Free)"<<"\n";
nb = analyzer.NbFaces();
if(nb>0) di<<nb<<" "<<" FACE"<<"\n";
nb = analyzer.NbFreeFaces();
if(nb>0) di<<nb<<" "<<" FACE (Free)"<<"\n";
nb = analyzer.NbFreeWires();
if(nb>0) di<<nb<<" "<<" WIRE (Free)"<<"\n";
nb = analyzer.NbShells();
if(nb>0) di<<nb<<" "<<" SHELL"<<"\n";
nb = analyzer.NbSolids();
if(nb>0) di<<nb<<" "<<" SOLID"<<"\n";
nb = analyzer.NbVertices();
if(nb>0) di<<nb<<" "<<" VERTEX (Oriented)"<<"\n";
nb = analyzer.NbSharedVertices();
if(nb>0) di<<nb<<" "<<" VERTEX (Shared)"<<"\n";
nb = analyzer.NbWires();
if(nb>0) di<<nb<<" "<<" WIRE"<<"\n";
nb = analyzer.NbFaceWithSevWires();
if(nb>0) di<<nb<<" "<<"Face with more than one wire"<<"\n";
nb = analyzer.NbNoPCurve();
if(nb>0) di<<nb<<" "<<"No pcurve"<<"\n";
nb = analyzer.NbSolidsWithVoids();
if(nb>0) di<<nb<<" "<<"SOLID with voids"<<"\n";
nb = analyzer.NbWireWitnSeam();
if(nb>0) di<<nb<<" "<<"Wire(s) with one seam edge"<<"\n";
nb = analyzer.NbWireWithSevSeams();
if(nb>0) di<<nb<<" "<<"Wire(s) with several seam edges"<<"\n";
nb = analyzer.NbBigSplines();
if(nb>0) di<<nb<<" "<<"bigspl : BSpline > 8192 poles"<<"\n";
nb = analyzer.NbBezierSurf();
if(nb>0) di<<nb<<" "<<"bezsur : BezierSurface"<<"\n";
nb = analyzer.NbBSplibeSurf();
if(nb>0) di<<nb<<" "<<"bspsur : BSplineSurface"<<"\n";
nb = analyzer.NbC0Curves();
if(nb>0) di<<nb<<" "<<"c0curv : Curve Only C0"<<"\n";
nb = analyzer.NbC0Surfaces();
if(nb>0) di<<nb<<" "<<"c0surf : Surface Only C0"<<"\n";
nb = analyzer.NbIndirectSurf();
if(nb>0) di<<nb<<" "<<"indsur : Indirect Surface"<<"\n";
nb = analyzer.NbOffsetCurves();
if(nb>0) di<<nb<<" "<<"ofcur : Offset Curve(s)"<<"\n";
nb = analyzer.NbOffsetSurf();
if(nb>0) di<<nb<<" "<<"ofsur : Offset Surface"<<"\n";
nb = analyzer.NbTrimmedCurve2d();
if(nb>0) di<<nb<<" "<<"trc2d : Trimmed Curve2d"<<"\n";
nb = analyzer.NbTrimmedCurve3d();
if(nb>0) di<<nb<<" "<<"trc3d : Trimmed Curve3d"<<"\n";
nb = analyzer.NbTrimSurf();
if(nb>0) di<<nb<<" "<<"trimsu : RectangularTrimmedSurface"<<"\n";
if(arg3 ==NULL) return 0;
Handle(TopTools_HSequenceOfShape) sec;
if(analyzer.ModifyBigSplineMode()) {
sec = analyzer.BigSplineSec();
for(Standard_Integer i = 1; i <= sec->Length(); i++) {
sprintf(nompart,"%s_bigspl_%d",arg2,i);
DBRep::Set (nompart,sec->Value(i));
}
}
if(analyzer.ModifyIndirectMode()) {
sec = analyzer.IndirectSec();
for(Standard_Integer i = 1; i <= sec->Length(); i++) {
sprintf(nompart,"%s_indsur_%d",arg2,i);
DBRep::Set (nompart,sec->Value(i));
}
}
if(analyzer.ModifyOffestSurfaceMode()) {
sec = analyzer.OffsetSurfaceSec();
for(Standard_Integer i = 1; i <= sec->Length(); i++) {
sprintf(nompart,"%s_ofsur_%d",arg2,i);
DBRep::Set (nompart,sec->Value(i));
}
}
if(analyzer.ModifyTrimmed3dMode()) {
sec = analyzer.Trimmed3dSec();
for(Standard_Integer i = 1; i <= sec->Length(); i++) {
sprintf(nompart,"%s_trc3d_%d",arg2,i);
DBRep::Set (nompart,sec->Value(i));
}
}
if(analyzer.ModifyOffsetCurveMode()) {
sec = analyzer.OffsetCurveSec();
for(Standard_Integer i = 1; i <= sec->Length(); i++) {
sprintf(nompart,"%s_ofcur_%d",arg2,i);
DBRep::Set (nompart,sec->Value(i));
}
}
if(analyzer.ModifyTrimmed2dMode()) {
sec = analyzer.Trimmed2dSec();
for(Standard_Integer i = 1; i <= sec->Length(); i++) {
sprintf(nompart,"%s_trc2d_%d",arg2,i);
DBRep::Set (nompart,sec->Value(i));
}
}
return 0;
}
static Standard_Integer XSHAPE_comptoledge
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if ( argc <2 ) {
di << "Use:\n"
"> comptol shape [nbpoints=371] [prefix]\n\n"
"Computes real tolerance of edges in the shape \n"
"as maximal deviation of 3d curve and pcurves.\n"
"Deviation is computed by nbpoints sample points (default is 371).\n"
"Gives the max, min and average value on all edges in the shape\n"
"If prefix is defined, edges with maximal real tolerance and\n"
"relation (and corresponding faces) will be saved with such names\n" << "\n";
return 0;
}
TopoDS_Shape shape = DBRep::Get(argv[1]);
if (shape.IsNull()) { di << "Shape name \"" << argv[1] << "\" is invalid" << "\n"; return 1; }
Standard_Integer nbpnts = 371;
Standard_CString prefix = 0;
if ( argc >2 ) {
if ( IsDigit(argv[2][0]) ) {
nbpnts = atoi(argv[2]);
if ( nbpnts <2 ) nbpnts = 2;
if ( argc >3 ) prefix = argv[3];
}
else prefix = argv[2];
}
Standard_Integer num = 0;
Standard_Real max=0, min=0, ave=0.;
Standard_Real relmax=0, relmin=0, relave=0.;
ShapeAnalysis_Edge sae;
TopoDS_Edge edmax, edmaxrel;
for ( TopExp_Explorer exp(shape,TopAbs_EDGE); exp.More(); exp.Next() ) {
Standard_Real tol;
TopoDS_Edge edge = TopoDS::Edge(exp.Current());
sae.CheckSameParameter ( edge, tol, nbpnts );
Standard_Real t = BRep_Tool::Tolerance(edge);
Standard_Real rel = tol / ( t > Precision::Confusion() ? t : Precision::Confusion() );
ave += tol;
relave += rel;
if ( ! num ) { max = min = tol; relmax = relmin = rel; edmax = edmaxrel = edge; }
else {
if ( max < tol ) { max = tol; edmax = edge; }
if ( min > tol ) min = tol;
if ( relmax < rel ) { relmax = rel; edmaxrel = edge; }
if ( relmin > rel ) relmin = rel;
}
num++;
}
if ( ! num ) { di << "No edges found in the shape" << "\n"; return 1; }
di << "Edges tolerance computed by " << nbpnts << " points: \n"
"MAX=" << max << " AVG=" << ave/num << " MIN=" << min << "\n";
di << "Relation real tolerance / tolerance set in edge\n"
"MAX=" << relmax << " AVG=" << relave/num << " MIN=" << relmin << "\n";
if ( prefix && prefix[0] ) {
char name[21];
sprintf ( name, "%.10s_edge_tol", prefix );
DBRep::Set (name,edmax);
di << "Edge with max tolerance saved to " << name;
if ( edmax.IsSame ( edmaxrel ) ) di << "\n";
else {
sprintf ( name, "%.10s_edge_rel", prefix );
DBRep::Set (name,edmaxrel);
di << "; edge with max relation saved to " << name << "\n";
}
Standard_Integer num1=0;
for ( TopExp_Explorer fac(shape,TopAbs_FACE); fac.More(); fac.Next() ) {
TopoDS_Face face = TopoDS::Face ( fac.Current() );
for ( TopExp_Explorer ed(face,TopAbs_EDGE); ed.More(); ed.Next() ) {
TopoDS_Edge edge = TopoDS::Edge ( ed.Current() );
if ( edge.IsSame ( edmax ) || edge.IsSame ( edmaxrel ) ) {
if ( ! num1 ) di << "Concerned faces saved to shapes ";
sprintf ( name, "%.10s_%d", prefix, num1+1 );
DBRep::Set (name,face);
//cout << ( num1 ? ", " : "" ) << name;
if (num1 == 0) {
di << "" << name;
} else {
di << ", " << name;
}
num1++;
break;
}
}
}
if ( num1 >0 ) di << "\n";
}
return 0;
}
//=======================================================================
//function : freebounds
//purpose :
//=======================================================================
static Standard_Integer freebounds (Draw_Interpretor& di,
Standard_Integer n, const char** a)
{
if ((n < 3) || (n > 5)) return 1;
TopoDS_Shape shape = DBRep::Get(a[1]);
if (shape.IsNull()) return 1;
Standard_Real toler = atof (a[2]);
Standard_Boolean splitclosed = Standard_False, splitopen = Standard_False;
if ( n > 3) splitclosed = atoi (a[3]);
if ( n > 4) splitopen = atoi (a[4]);
ShapeAnalysis_FreeBounds F;
if (toler <= 0)
F = ShapeAnalysis_FreeBounds (shape, splitclosed, splitopen);
else
F = ShapeAnalysis_FreeBounds (shape, toler, splitclosed, splitopen);
char name[100];
TopoDS_Shape wires = F.GetClosedWires();
sprintf (name, "%s_c", a[1]);
DBRep::Set (name, wires);
di << name << " - closed wires" << "\n";
wires = F.GetOpenWires();
sprintf (name, "%s_o", a[1]);
DBRep::Set (name, wires);
di << name << " - open wires" << "\n";
return 0;
}
//=======================================================================
//function : PrintProps
//purpose : auxilary for FreeBoundsProps
//=======================================================================
static void PrintProps(Standard_Integer i,
const Handle(ShapeAnalysis_FreeBoundData)& fbd,
Draw_Interpretor& di)
{
char str[100];
Standard_Real area = fbd->Area();
Standard_Real perimeter = fbd->Perimeter();
Standard_Real ratio = fbd->Ratio();
Standard_Real width = fbd->Width();
Standard_Integer notch = fbd->NbNotches();
sprintf(str," %d\t%12.5f\t%12.5f\t%12.5f\t%12.5f\t%d", i, area, perimeter, ratio, width, notch);
di<<str<<"\n";
}
//=======================================================================
//function : FreeBoundsProps
//purpose :
//=======================================================================
static Standard_Integer FreeBoundsProps(Draw_Interpretor& di,
Standard_Integer n, const char** a)
{
if ( (n < 2)||(n > 5) ) {
di<<"Usage : freeprops shapename [tolerance [splitclosed [splitopen]]]"<<"\n";
return 1;
}
TopoDS_Shape source = DBRep::Get(a[1]);
if (source.IsNull()) {
di<<"Error : unknown shape "<<a[1]<<"\n";
return 1;
}
Standard_Real toler = 0.;
Standard_Boolean splitclosed = Standard_False, splitopen = Standard_False;
if (n > 2) toler = atof(a[2]);
if (n > 3) splitclosed = atoi(a[3]);
if (n > 4) splitopen = atoi(a[4]);
ShapeAnalysis_FreeBoundsProperties analyzer;
if (toler > 0)
analyzer.Init(source, toler, splitclosed, splitopen);
else
analyzer.Init(source, splitclosed, splitopen);
analyzer.Perform();
TopoDS_Compound closed, open;
BRep_Builder B;
Standard_Integer nb = analyzer.NbClosedFreeBounds();
di<<"\n";
di<<" \t"<<"Area mm2"<<"\t"<<"Length mm"<<"\t"<<"Ratio L/W"<<"\t"<<"Width mm"<<"\t"<<"Nb noth"<<"\n";
B.MakeCompound(closed);
if (nb) {
di<<"Closed bounds properties"<<"\n";
for (Standard_Integer i=1; i <= nb; i++) {
Handle(ShapeAnalysis_FreeBoundData) fbd = analyzer.ClosedFreeBound(i);
PrintProps(i, fbd, di);
B.Add(closed,fbd->FreeBound());
}
}
nb = analyzer.NbOpenFreeBounds();
B.MakeCompound(open);
if (nb) {
di<<"Open bounds properties"<<"\n";
for (Standard_Integer i=1; i <= nb; i++) {
Handle(ShapeAnalysis_FreeBoundData) fbd = analyzer.OpenFreeBound(i);
PrintProps(i, fbd, di);
B.Add(open,fbd->FreeBound());
}
}
char name[100];
sprintf (name, "%s_c",a[1]);
di << name << " - closed wires, ";
DBRep::Set(name, closed);
sprintf (name, "%s_o",a[1]);
di << name << " - closed wires " << "\n";
DBRep::Set(name, open);
return 0;
}
//=======================================================================
//function : closefreebounds
//purpose :
//=======================================================================
static Standard_Integer closefreebounds (Draw_Interpretor& di,
Standard_Integer n, const char** a)
{
if ((n < 4) || (n > 6)) return 1;
TopoDS_Shape shape = DBRep::Get(a[1]);
if (shape.IsNull()) return 1;
Standard_Real sewtoler = atof (a[2]), closetoler = atof (a[3]);
Standard_Boolean splitclosed = Standard_False, splitopen = Standard_False;
if ( n > 4) splitclosed = atoi (a[3]);
if ( n > 5) splitopen = atoi (a[4]);
ShapeFix_FreeBounds F;
if (sewtoler <= 0)
F = ShapeFix_FreeBounds (shape, closetoler, splitclosed, splitopen);
else
F = ShapeFix_FreeBounds (shape, sewtoler, closetoler, splitclosed, splitopen);
char name[100];
TopoDS_Shape wires = F.GetClosedWires();
sprintf (name, "%s_c", a[1]);
DBRep::Set (name, wires);
di << name << " - closed wires" << "\n";
wires = F.GetOpenWires();
sprintf (name, "%s_o", a[1]);
DBRep::Set (name, wires);
di << name << " - open wires" << "\n";
return 0;
}
//=======================================================================
//function : MyVISEDG
//purpose :
//=======================================================================
static Standard_Integer MyVISEDG (Draw_Interpretor& /*di*/,
Standard_Integer n, const char** a)
{
if (n >4) return 1;
TopoDS_Shape MaListe = DBRep::Get(a[1]);
if (MaListe.IsNull()) return 1;
TopoDS_Compound TheList = TopoDS::Compound(MaListe);
if (TheList.IsNull()) return 1;
Standard_Real toler = 0.001;
int create = 0;
if ( n >= 3) toler = atof(a[2]);
if (n == 4 && !strcmp(a[3],"C")) create = 1;
ShapeAnalysis_FreeBounds F(TheList,toler);
//
//
//
char name[100];
char num[5];
if (!create)
{
TopoDS_Compound Wires = F.GetClosedWires();
TopoDS_Iterator S(Wires);
Standard_Integer iwire = 0;
while (S.More())
{
sprintf (num,"%d",iwire);
name[0] = 'w';
name[1] = '\0';
strncat(name,num,strlen(num));
name[strlen(name)] = '\0';
DBRep::Set(name,S.Value());
S.Next();
iwire++;
}
iwire = 0;
TopoDS_Compound Edges = F.GetOpenWires();
S.Initialize(Edges);
iwire = 0;
while (S.More())
{
sprintf (num,"%d",iwire);
name[0] = 'E';
name[1] = '\0';
strncat(name,num,strlen(num));
name[strlen(name)] = '\0';
DBRep::Set(name,S.Value());
S.Next();
iwire++;
}
}
else
{
}
return 0;
}
static Standard_Integer getareacontour (Draw_Interpretor& di,
Standard_Integer n, const char** a)
{
if (n < 2) return 1;
TopoDS_Shape shape = DBRep::Get(a[1]);
if (shape.IsNull()) {
di<<"Shape is not defined"<<"\n";
return 1;
}
if(shape.ShapeType() != TopAbs_WIRE) {
di<<"invalid type of argument"<<"\n";
return 1;
}
//Handle(ShapeExtend_WireData) asewd = new ShapeExtend_WireData(TopoDS::Wire(shape));
Standard_Real anArea = ShapeAnalysis::ContourArea(TopoDS::Wire(shape));
di<<"Area = "<<anArea<<"\n";
return 0;
}
//=======================================================================
//function : InitCommands
//purpose :
//=======================================================================
void SWDRAW_ShapeAnalysis::InitCommands(Draw_Interpretor& theCommands)
{
static Standard_Integer initactor = 0;
if (initactor) return; initactor = 1;
Standard_CString g = SWDRAW::GroupName();
theCommands.Add ("tolerance","shape [tolmin tolmax:real]", __FILE__,tolerance,g);
theCommands.Add ("projface","nom_face X Y [Z]", __FILE__,projface,g);
theCommands.Add ("projcurve","nom_edge | curve3d | curve3d first last + X Y Z",
__FILE__,projcurve,g);
theCommands.Add ("anaface","nomface",__FILE__,anaface,g);
theCommands.Add ("statshape","shape [particul] : stats/particularites",
__FILE__,XSHAPE_statshape,g);
theCommands.Add ("comptol","shape [nbpoints]",__FILE__,XSHAPE_comptoledge,g);
theCommands.Add("freebounds",
"shp toler [splitclosed [splitopen]] - free bounds; toler <= 0 for shells (no sewing call)",
__FILE__, freebounds, g);
const char* groupold="DE: old";
theCommands.Add("fbprops",
"shp [toler [splitclosed [splitopen]]] - free bounds properties; toler <= 0 or not specified - for shells (no sewing call)",
__FILE__, FreeBoundsProps, groupold);
theCommands.Add("fbclose",
"shp sewtoler closetoler [splitclosed [splitopen]] - closes free bounds; use sewtoler <= 0 for shells (no sewing call)",
__FILE__, closefreebounds, groupold);
theCommands.Add("K_VISEDG",
"K_VISEDG Visu of free edge of a compound of faces.",
__FILE__, MyVISEDG, groupold);
theCommands.Add("getareacontour","wire ",__FILE__, getareacontour, groupold);
}

View File

@@ -0,0 +1,21 @@
-- File: SWDRAW_ShapeBuild.cdl
-- Created: Tue Mar 9 15:19:30 1999
-- Author: data exchange team
-- <det@kinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ShapeBuild from SWDRAW
---Purpose: Contains commands to activate package ShapeBuild
-- List of DRAW commands and corresponding functionalities:
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in ShapeBuild
end ShapeBuild;

View File

@@ -0,0 +1,16 @@
// File: SWDRAW_ShapeBuild.cxx
// Created: Tue Mar 9 15:48:26 1999
// Author: data exchange team
// <det@kinox.nnov.matra-dtv.fr>
#include <SWDRAW_ShapeBuild.ixx>
//=======================================================================
//function : InitCommands
//purpose :
//=======================================================================
void SWDRAW_ShapeBuild::InitCommands(Draw_Interpretor& )
{
}

View File

@@ -0,0 +1,22 @@
-- File: SWDRAW_ShapeConstruct.cdl
-- Created: Tue Mar 9 15:19:44 1999
-- Author: data exchange team
-- <det@nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ShapeConstruct from SWDRAW
---Purpose: Contains commands to activate package ShapeConstruct
-- List of DRAW commands and corresponding functionalities:
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in ShapeConstruct
end ShapeConstruct;

View File

@@ -0,0 +1,11 @@
// File: SWDRAW_ShapeConstruct.cxx
// Created: Tue Mar 9 15:48:45 1999
// Author: data exchange team
// <det@nnov.matra-dtv.fr>
#include <SWDRAW_ShapeConstruct.ixx>
void SWDRAW_ShapeConstruct::InitCommands(Draw_Interpretor& /*theCommands*/)
{
}

View File

@@ -0,0 +1,23 @@
-- File: SWDRAW_ShapeCustom.cdl
-- Created: Tue Mar 9 14:56:15 1999
-- Author: Roman LYGIN
-- <rln@kinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ShapeCustom from SWDRAW
---Purpose: Contains commands to activate package ShapeCustom
-- List of DRAW commands and corresponding functionalities:
-- directfaces - ShapeCustom::DirectFaces
-- scaleshape - ShapeCustom::ScaleShape
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in ShapeCustom
end ShapeCustom;

477
src/SWDRAW/SWDRAW_ShapeCustom.cxx Executable file
View File

@@ -0,0 +1,477 @@
// File: SWDRAW_ShapeCustom.cxx
// Created: Tue Mar 9 14:56:39 1999
// Author: Roman LYGIN
// <rln@kinox.nnov.matra-dtv.fr>
// abv 08.05.99: new command convtorevol
#include <SWDRAW_ShapeCustom.ixx>
#include <DBRep.hxx>
#include <SWDRAW.hxx>
#include <TopoDS_Shape.hxx>
#include <ShapeCustom.hxx>
#include <ShapeCustom_BSplineRestriction.hxx>
#include <ShapeCustom_RestrictionParameters.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Edge.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <TopAbs.hxx>
#include <DrawTrSurf.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <Geom_SweptSurface.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_SweptSurface.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_OffsetSurface.hxx>
#include <ShapeFix.hxx>
#include <GeomAbs_Shape.hxx>
#include <TColStd_Array2OfInteger.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_OffsetCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_OffsetCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom_Plane.hxx>
#include <TColStd_Array1OfReal.hxx>
static Standard_Integer ContToInteger( const GeomAbs_Shape Cont)
{
Standard_Integer result =0;
switch(Cont) {
case GeomAbs_C0:
case GeomAbs_G1: result = 0; break;
case GeomAbs_C1:
case GeomAbs_G2: result = 1; break;
case GeomAbs_C2: result = 2; break;
case GeomAbs_C3: result = 3; break;
default : result = 4; break;
}
return result;
}
static Standard_Integer directfaces(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) { di<<"Donner un nom de SHAPE + un nom de RESULTAT"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
Standard_CString arg2 = argv[2];
TopoDS_Shape Shape = DBRep::Get(arg2);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg2<<"\n"; return 1 /* Error */; }
TopoDS_Shape result = ShapeCustom::DirectFaces (Shape);
if (result.IsNull()) { di<<"NO RESULT"<<"\n"; return 1; }
else if (result == Shape) { di<<"No modif"<<"\n"; return 0; }
di<<"DirectFaces -> Result : "<<arg1<<"\n";
DBRep::Set (arg1,result);
return 0; // Done
}
static Standard_Integer ckeckKnots(const TColStd_Array1OfReal& theKnots,
Standard_Real theFirst,
Standard_Real theLast)
{
Standard_Integer i =1, nb = theKnots.Length();
Standard_Integer aNum =0;
for( ; i< nb; i++)
{
if(!aNum)
{
Standard_Real aDF = theKnots(i) - theFirst;
if(fabs(aDF) <= Precision::PConfusion() ||
aDF > Precision::PConfusion())
{
aNum++;
continue;
}
}
else
{
Standard_Real aDL = theKnots(i) - theLast;
if(fabs(aDL) <= Precision::PConfusion() ||
aDL > Precision::PConfusion())
break;
aNum++;
}
}
return aNum;
}
static void expcurv2d(const Handle(Geom2d_Curve)& aCurve, TColStd_Array2OfInteger& Nb, const Standard_Integer Degree,
const Standard_Integer MaxSeg,
const Standard_Integer theCont,
Standard_Real theFirst,
Standard_Real theLast)
{
if(aCurve.IsNull()) return;
if (aCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) {
Handle(Geom2d_TrimmedCurve) tmp = Handle(Geom2d_TrimmedCurve)::DownCast (aCurve);
Handle(Geom2d_Curve) BasCurve = tmp->BasisCurve();
expcurv2d(BasCurve,Nb,Degree,MaxSeg,theCont,theFirst,theLast);
return;
}
if (aCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) {
Handle(Geom2d_OffsetCurve) tmp = Handle(Geom2d_OffsetCurve)::DownCast (aCurve);
Handle(Geom2d_Curve) BasCurve = tmp->BasisCurve();
expcurv2d(BasCurve,Nb,Degree,MaxSeg,theCont,theFirst,theLast);
return;
}
Standard_Integer aCont = ContToInteger(aCurve->Continuity());
if(aCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) {
Handle(Geom2d_BSplineCurve) Bs = Handle(Geom2d_BSplineCurve)::DownCast(aCurve);
if(Bs->Degree() > Degree) Nb.ChangeValue(1,1)++;
if(Bs->NbKnots() -1 > MaxSeg) Nb.ChangeValue(1,2)++;
if(Bs->IsRational()) Nb.ChangeValue(1,3)++;
if(aCont < theCont && Bs->NbKnots() > 2)
{
TColStd_Array1OfReal aKnots(1,Bs->NbKnots());
Bs->Knots(aKnots);
Standard_Integer nbInt = ckeckKnots(aKnots,theFirst,theLast);
if(nbInt >1)
Nb.ChangeValue(1,4)++;
}
return;
}
if (aCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) {
Handle(Geom2d_BezierCurve) Bs = Handle(Geom2d_BezierCurve)::DownCast(aCurve);
if(Bs->Degree() > Degree) Nb.ChangeValue(2,1)++;
if(Bs->IsRational() > ((unsigned int)MaxSeg) ) Nb.ChangeValue(2,3)++;
if(aCont < theCont)
{
Nb.ChangeValue(2,4)++;
}
return;
}
else
Nb.ChangeValue(1,5)++;
return;
}
static void expcurv(const Handle(Geom_Curve)& aCurve, TColStd_Array2OfInteger& Nb, const Standard_Integer Degree,
const Standard_Integer MaxSeg,
const Standard_Integer theCont,
Standard_Real theFirst,
Standard_Real theLast)
{
if(aCurve.IsNull()) return;
if (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) tmp = Handle(Geom_TrimmedCurve)::DownCast (aCurve);
Handle(Geom_Curve) BasCurve = tmp->BasisCurve();
expcurv(BasCurve,Nb,Degree,MaxSeg,theCont,theFirst,theLast);
return;
}
if (aCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) {
Handle(Geom_OffsetCurve) tmp = Handle(Geom_OffsetCurve)::DownCast (aCurve);
Handle(Geom_Curve) BasCurve = tmp->BasisCurve();
expcurv(BasCurve,Nb,Degree,MaxSeg,theCont,theFirst,theLast);
return;
}
Standard_Integer aCont = ContToInteger(aCurve->Continuity());
if(aCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
Handle(Geom_BSplineCurve) Bs = Handle(Geom_BSplineCurve)::DownCast(aCurve);
if(Bs->Degree() > Degree) Nb.ChangeValue(1,1)++;
if(Bs->NbKnots() -1 > MaxSeg) Nb.ChangeValue(1,2)++;
if(Bs->IsRational()) Nb.ChangeValue(1,3)++;
if(aCont < theCont && Bs->NbKnots() > 2)
{
TColStd_Array1OfReal aKnots(1,Bs->NbKnots());
Bs->Knots(aKnots);
Standard_Integer nbInt = ckeckKnots(aKnots,theFirst,theLast);
if(nbInt >1)
Nb.ChangeValue(1,4)++;
}
return;
}
if (aCurve->IsKind(STANDARD_TYPE(Geom_BezierCurve))) {
Handle(Geom_BezierCurve) Bs = Handle(Geom_BezierCurve)::DownCast(aCurve);
if(Bs->Degree() > Degree) Nb.ChangeValue(2,1)++;
if(Bs->IsRational() > ((unsigned int)MaxSeg) ) Nb.ChangeValue(2,3)++;
if(aCont < theCont)
Nb.ChangeValue(2,4)++;
return;
}
else
Nb.ChangeValue(1,5)++;
return;
}
static void expsurf(const Handle(Geom_Surface)& aSurface, TColStd_Array2OfInteger& NbSurf, const Standard_Integer Degree,
const Standard_Integer MaxSeg,
const Standard_Integer theCont)
{
if (aSurface.IsNull()) return;
if (aSurface->IsKind(STANDARD_TYPE(Geom_SweptSurface))) {
Handle(Geom_SweptSurface) aSurf = Handle(Geom_SweptSurface)::DownCast(aSurface);
Handle(Geom_Curve) BasCurve = aSurf->BasisCurve();
expcurv(BasCurve,NbSurf,Degree,MaxSeg,theCont,BasCurve->FirstParameter(),
BasCurve->LastParameter());
return;
}
if (aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
Handle(Geom_RectangularTrimmedSurface) aSurf = Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
Handle(Geom_Surface) theSurf = aSurf->BasisSurface();
expsurf(theSurf,NbSurf,Degree,MaxSeg,theCont);
return;
}
if(aSurface->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
Handle(Geom_OffsetSurface) aSurf = Handle(Geom_OffsetSurface)::DownCast(aSurface);
Handle(Geom_Surface) theSurf = aSurf->BasisSurface();
expsurf(theSurf,NbSurf,Degree,MaxSeg,theCont);
return;
}
Standard_Integer aCont = ContToInteger(aSurface->Continuity());
if (aSurface->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) {
Handle(Geom_BSplineSurface) BS = Handle(Geom_BSplineSurface)::DownCast(aSurface);
if(BS->UDegree() > Degree || BS->VDegree() > Degree) NbSurf.ChangeValue(1,1)++;
if(((BS->NbUKnots()-1) * (BS->NbVKnots()-1)) >MaxSeg) NbSurf.ChangeValue(1,2)++;
if(BS->IsURational() || BS->IsVRational()) NbSurf.ChangeValue(1,3)++;
if(aCont < theCont)
NbSurf.ChangeValue(1,4)++;
return;
}
if (aSurface->IsKind(STANDARD_TYPE(Geom_BezierSurface))) {
Handle(Geom_BezierSurface) BS = Handle(Geom_BezierSurface)::DownCast(aSurface);
if(BS->UDegree() > Degree || BS->VDegree() > Degree) NbSurf.ChangeValue(2,1)++;
if(BS->IsURational() || BS->IsVRational()) NbSurf.ChangeValue(2,3)++;
if(aCont < theCont)
NbSurf.ChangeValue(2,4)++;
return;
}
if(aSurface->IsKind(STANDARD_TYPE(Geom_Plane)))
{
NbSurf.ChangeValue(1,5)++;
}
else
NbSurf.ChangeValue(2,5)++;
}
static Standard_Integer expshape(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc <4) {
di << "Incorrect number of arguments. Must be 3" << "\n";
return 1 /* Error */;
}
Standard_CString arg2 = argv[1];
TopoDS_Shape Shape = DBRep::Get(arg2);
Standard_Integer Degree = atoi(argv[2]);
Standard_Integer MaxSeg = atoi(argv[3]);
GeomAbs_Shape aCont3 = GeomAbs_C0;
Standard_Integer k = 4;
if( argc > k)
{
if(strcmp(argv[k],"C0") == 0) aCont3 = GeomAbs_C0;
else if (strcmp(argv[k],"C1") == 0) aCont3 = GeomAbs_C1;
else if (strcmp(argv[k],"C2") == 0) aCont3 = GeomAbs_C2;
else if (strcmp(argv[k],"C3") == 0) aCont3 = GeomAbs_C3;
else if (strcmp(argv[k],"CN") == 0) aCont3 = GeomAbs_CN;
else if (strcmp(argv[k],"G1") == 0) aCont3 = GeomAbs_C0;
else if (strcmp(argv[k],"G2") == 0) aCont3 = GeomAbs_C1;
else {
di<< "Invalid argument Cont3e" << "\n"; return 1; }
}
Standard_Integer aCont = ContToInteger(aCont3);
TColStd_Array2OfInteger NbSurf(1,2,1,5);
TColStd_Array2OfInteger NbCurv(1,2,1,5);
TColStd_Array2OfInteger NbCurv2d(1,2,1,5);
Standard_Integer nbSeam =0;
NbSurf.Init(0);
NbCurv.Init(0);
NbCurv2d.Init(0);
if (Shape.IsNull()) { di << "Shape unknown: " << arg2 << "\n"; return 1 /* Error */; }
TopExp_Explorer Ex;
Standard_Integer nbF =1;
for (Ex.Init(Shape,TopAbs_FACE); Ex.More(); Ex.Next(),nbF++) {
TopoDS_Face F = TopoDS::Face(Ex.Current());
TopLoc_Location L;
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(F,L);
expsurf(aSurface,NbSurf,Degree,MaxSeg,aCont);
TopExp_Explorer exp;
Standard_Integer nbE = 1;
for(exp.Init(F,TopAbs_EDGE); exp.More(); exp.Next(),nbE++) {
TopoDS_Edge E = TopoDS::Edge(exp.Current());
if(BRep_Tool::IsClosed(E,F))
nbSeam++;
Standard_Real First,Last;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(E,L,First, Last);
expcurv(aCurve,NbCurv,Degree,MaxSeg,aCont,First, Last);
Standard_Real First2d,Last2d;
Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(E,F,First2d,Last2d);
expcurv2d(aCurve2d,NbCurv2d,Degree,MaxSeg,aCont,First2d,Last2d);
}
}
di<<"Number of seam edges - "<<nbSeam<<"\n";
//if(NbSurf.Value(1,1) !=0)
di<< "Number of BSpline surfaces with degree more then "<< Degree << " - " <<NbSurf.Value(1,1)<<"\n";
//if(NbSurf.Value(1,2) !=0)
di<< "Number of BSpline surfaces with number of spans more then "<< MaxSeg << " - " <<NbSurf.Value(1,2)<<"\n";
//if(NbSurf.Value(1,3) !=0)
di<< "Number of Rational BSpline surfaces " << NbSurf.Value(1,3)<<"\n";
//if(NbSurf.Value(1,4) !=0)
di<< "Number of BSpline surfaces with continuity less than specified - " << NbSurf.Value(1,4)<<"\n";
//if(NbSurf.Value(2,1) !=0)
di<< "Number of Bezier surfaces with degree more then "<< Degree << " - " <<NbSurf.Value(2,1)<<"\n";
//if(NbSurf.Value(2,3) !=0)
di<< "Number of Rational Bezier surfaces " << " - " <<NbSurf.Value(2,3)<<"\n";
//if(NbSurf.Value(2,4) !=0)
di<< "Number of Bezier surfaces with continuity less than specified - " << NbSurf.Value(2,4)<<"\n";
//if(NbSurf.Value(1,5) !=0)
di<< "Number of Planes - " << NbSurf.Value(1,5)<<"\n";
//if(NbSurf.Value(2,5) !=0)
di<< "Number of other surfaces - " << NbSurf.Value(2,5)<<"\n";
//if(NbCurv.Value(1,1) !=0)
di<< "Number of BSpline curves with degree more then "<< Degree << " - " <<NbCurv.Value(1,1)<<"\n";
//if(NbCurv.Value(1,2) !=0)
di<< "Number of BSpline curves with number of spans more then - "<< MaxSeg << " - " <<NbCurv.Value(1,2)<<"\n";
//if(NbCurv.Value(1,3) !=0)
di<< "Number of Rational BSpline curves " << NbCurv.Value(1,3)<<"\n";
//if(NbCurv.Value(1,4) !=0)
di<< "Number of BSpline curves with less continuity - " << NbCurv.Value(1,4)<<"\n";
//if(NbCurv.Value(2,1) !=0)
di<< "Number of Bezier curves with degree more then - "<< Degree << " - " <<NbCurv.Value(2,1)<<"\n";
//if(NbCurv.Value(2,3) !=0)
di<< "Number of Rational Bezier curves " << " - " <<NbCurv.Value(2,3)<<"\n";
//if(NbCurv.Value(2,4) !=0)
di<< "Number of Bezier curves with less continuity - " << NbCurv.Value(2,4)<<"\n";
//if(NbCurv.Value(1,5) !=0)
di<< "Number of other curves - " << NbCurv.Value(1,5)<<"\n";
//if(NbCurv2d.Value(1,1) !=0)
di<< "Number of BSpline pcurves with degree more then - "<< Degree << " - " <<NbCurv2d.Value(1,1)<<"\n";
//if(NbCurv2d.Value(1,2) !=0)
di<< "Number of BSpline pcurves with number of spans more then "<< MaxSeg << " - " <<NbCurv2d.Value(1,2)<<"\n";
//if(NbCurv2d.Value(1,3) !=0)
di<< "Number of Rational BSpline pcurves - " << NbCurv2d.Value(1,3)<<"\n";
// if(NbCurv2d.Value(1,4) !=0)
di<< "Number of BSpline pcurves with less continuity - " << NbCurv2d.Value(1,4)<<"\n";
//if(NbCurv2d.Value(2,1) !=0)
di<< "Number of Bezier pcurves with degree more then "<< Degree <<" - " <<" - " <<NbCurv2d.Value(2,1)<<"\n";
//if(NbCurv2d.Value(2,3) !=0)
di<< "Number of Rational Bezier pcurves " << " - " <<NbCurv2d.Value(2,3)<<"\n";
//if(NbCurv2d.Value(2,4) !=0)
di<< "Number of Bezier pcurves with less continuity - " << NbCurv2d.Value(2,4)<<"\n";
//if(NbCurv2d.Value(1,5) !=0)
di<< "Number of other pcurves - " << NbCurv2d.Value(1,5)<<"\n";
return 0;
}
static Standard_Integer scaleshape(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc !=4) {
di << "Incorrect number of arguments. Must be 4" << "\n";
return 1 /* Error */;
}
Standard_CString arg2 = argv[2];
TopoDS_Shape Shape = DBRep::Get(arg2);
if (Shape.IsNull()) { di << "Shape unknown: " << arg2 << "\n"; return 1 /* Error */; }
TopoDS_Shape result = ShapeCustom::ScaleShape (Shape, atof(argv[3]));
if (result.IsNull()) { di << "NO RESULT" << "\n"; return 1; }
else if (result == Shape) { di << "NO MODIFICATIONS" << "\n"; return 0; }
DBRep::Set (argv[1],result);
return 0;
}
static Standard_Integer BSplRes(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 11) {
di << "Incorrect number of arguments. Must be 10" << "\n";
return 1 /* Error */;
}
Standard_CString arg2 = argv[2];
TopoDS_Shape Shape = DBRep::Get(arg2);
if (Shape.IsNull()) { di << "Shape unknown: " << arg2 << "\n"; return 1 /* Error */; }
GeomAbs_Shape aCont3;
if(strcmp(argv[7],"C0") == 0) aCont3 = GeomAbs_C0;
else if (strcmp(argv[7],"C1") == 0) aCont3 = GeomAbs_C1;
else if (strcmp(argv[7],"C2") == 0) aCont3 = GeomAbs_C2;
else if (strcmp(argv[7],"C3") == 0) aCont3 = GeomAbs_C3;
else if (strcmp(argv[7],"CN") == 0) aCont3 = GeomAbs_CN;
else if (strcmp(argv[7],"G1") == 0) aCont3 = GeomAbs_C0;
else if (strcmp(argv[7],"G2") == 0) aCont3 = GeomAbs_C1;
else {
di<< "Invalid argument Cont3e" << "\n"; return 1; }
GeomAbs_Shape aCont2;
if(strcmp(argv[8],"C0") == 0) aCont2 = GeomAbs_C0;
else if (strcmp(argv[8],"C1") == 0) aCont2 = GeomAbs_C1;
else if (strcmp(argv[8],"C2") == 0) aCont2 = GeomAbs_C2;
else if (strcmp(argv[8],"C3") == 0) aCont2 = GeomAbs_C3;
else if (strcmp(argv[8],"CN") == 0) aCont2 = GeomAbs_CN;
else if (strcmp(argv[8],"G1") == 0) aCont2 = GeomAbs_C0;
else if (strcmp(argv[8],"G2") == 0) aCont2 = GeomAbs_C1;
else {
di<< "Invalid argument Cont3e" << "\n"; return 1; }
Handle(ShapeCustom_RestrictionParameters) aParameters = new ShapeCustom_RestrictionParameters;
TopoDS_Shape result = ShapeCustom::BSplineRestriction (Shape, atof(argv[3]), atof(argv[4]), atoi(argv[5]),atoi(argv[6]),aCont3,aCont2,(Standard_Boolean) atoi(argv[9]),(Standard_Boolean) atoi(argv[10]),aParameters);
if (result.IsNull()) { di << "NO RESULT" << "\n"; return 1; }
else if (result == Shape) {
di << "NO MODIFICATIONS" << "\n";
DBRep::Set (argv[1],result); return 0;
}
ShapeFix::SameParameter(result,Standard_False);
DBRep::Set (argv[1],result);
return 0;
}
static Standard_Integer convtorevol(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) { di<<"Convert surfaces to revolution: convtorevol result shape"<<"\n"; return 1; }
Standard_CString arg1 = argv[1];
Standard_CString arg2 = argv[2];
TopoDS_Shape Shape = DBRep::Get(arg2);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg2<<"\n"; return 1; }
TopoDS_Shape result = ShapeCustom::ConvertToRevolution (Shape);
if (result.IsNull()) { di<<"NO RESULT"<<"\n"; return 1; }
else if (result == Shape) { di<<"No modif"<<"\n"; return 0; }
di<<"ConvertToRevolution -> Result : "<<arg1<<"\n";
DBRep::Set (arg1,result);
return 0; // Done
}
//======================================================================
//function : InitCommands
//purpose :
//=======================================================================
void SWDRAW_ShapeCustom::InitCommands(Draw_Interpretor& theCommands)
{
static Standard_Integer initactor = 0;
if (initactor) return; initactor = 1;
Standard_CString g = SWDRAW::GroupName();
theCommands.Add ("directfaces", "directfaces result shape", __FILE__, directfaces, g);
theCommands.Add ("expshape", "expshape shape maxdegree maxseg [min_continuity]", __FILE__, expshape, g);
theCommands.Add ("scaleshape", "scaleshape result shape scale", __FILE__, scaleshape, g);
theCommands.Add ("bsplres", "BSplineRestriction result shape tol3d tol2d reqdegree reqnbsegments continuity3d continuity2d PriorDeg RationalConvert", __FILE__,BSplRes, g);
theCommands.Add ("convtorevol", "convtorevol result shape", __FILE__, convtorevol, g);
}

View File

@@ -0,0 +1,22 @@
-- File: SWDRAW_ShapeExtend.cdl
-- Created: Tue Mar 9 18:22:41 1999
-- Author: data exchange team
-- <det@kinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ShapeExtend from SWDRAW
---Purpose: Contains commands to activate package ShapeExtend
-- List of DRAW commands and corresponding functionalities:
-- sortcompound - ShapeExtend_Explorer::SortedCompound
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in ShapeExtend
end ShapeExtend;

View File

@@ -0,0 +1,95 @@
// File: SWDRAW_ShapeExtend.cxx
// Created: Tue Mar 9 18:23:40 1999
// Author: data exchange team
// <det@kinox.nnov.matra-dtv.fr>
#include <SWDRAW_ShapeExtend.ixx>
#include <DBRep.hxx>
#include <SWDRAW.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <ShapeExtend_Explorer.hxx>
#include <TopoDS_Shape.hxx>
static Standard_Integer sortcompound (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
Standard_CString arg1 = argv[1];
if (argc < 2) {
di<<"Give shape name. As is, just displays shape type"<<"\n";
di<<" or add result_name type [mode]"<<"\n";
di<<" Type : v (vertex) e (edge) w (wire) f (face) s (shell) so (solid)"<<"\n";
di<<" Mode : n (normal, by default) e (explore) c (compound) x (explore+comp)"<<"\n";
return 0;
}
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
if (argc < 4) {
ShapeExtend_Explorer sbx;
for (int i = 0; i < 2; i ++) {
TopAbs_ShapeEnum ts = sbx.ShapeType(Shape,i);
//cout<<" Type "<<(i ? " (via Compound) : " : "(True) : ");
if (i == 0) {
di<<" Type "<<"(True) : ";
} else {
di<<" Type "<<" (via Compound) : ";
}
switch (ts) {
case TopAbs_SHAPE : di<<"SHAPE (empty)"; break;
case TopAbs_VERTEX : di<<"VERTEX"; break;
case TopAbs_EDGE : di<<"EDGE"; break;
case TopAbs_WIRE : di<<"WIRE"; break;
case TopAbs_FACE : di<<"FACE"; break;
case TopAbs_SHELL : di<<"SHELL"; break;
case TopAbs_SOLID : di<<"SOLID"; break;
case TopAbs_COMPSOLID : di<<"COMPSOLID"; break;
case TopAbs_COMPOUND : di<<"COMPOUND"; if (i>0) di<<" (heterogeneous)"; break;
}
}
di<<"\n";
return 0;
}
TopAbs_ShapeEnum tse = TopAbs_COMPOUND;
char tsc = argv[3][0];
switch (tsc) {
case 'v' : tse = TopAbs_VERTEX; break;
case 'e' : tse = TopAbs_EDGE; break;
case 'w' : tse = TopAbs_WIRE; break;
case 'f' : tse = TopAbs_FACE; break;
case 's' : tse = TopAbs_SHELL;
if (argv[3][1] == 'o') tse = TopAbs_SOLID; break;
default : break;
}
Standard_Boolean modexp = Standard_False;
Standard_Boolean modcom = Standard_False;
if (argc > 4) {
switch (argv[4][0]) {
case 'e' : modexp = Standard_True; break;
case 'c' : modcom = Standard_True; break;
case 'x' : modexp = modcom = Standard_True; break;
default : break;
}
ShapeExtend_Explorer sbx;
Shape = sbx.SortedCompound (Shape,tse,modexp,modcom);
if ( Shape.IsNull()) { di<<"Empty result"<<"\n"; return 0; }
DBRep::Set(argv[2],Shape);
}
return 0; // Done
}
//=======================================================================
//function : InitCommands
//purpose :
//=======================================================================
void SWDRAW_ShapeExtend::InitCommands(Draw_Interpretor& theCommands)
{
static Standard_Integer initactor = 0;
if (initactor) return; initactor = 1;
Standard_CString g = SWDRAW::GroupName();
theCommands.Add ("sortcompound","shape_entree shape_result type=v-e-w-f-s-so [mode=n-e-c-x]",
__FILE__,sortcompound,g);
}

26
src/SWDRAW/SWDRAW_ShapeFix.cdl Executable file
View File

@@ -0,0 +1,26 @@
-- File: SWDRAW_ShapeFix.cdl
-- Created: Tue Mar 9 15:26:21 1999
-- Author: data exchange team
-- <det@kinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ShapeFix from SWDRAW
---Purpose: Contains commands to activate package ShapeFix
-- List of DRAW commands and corresponding functionalities:
-- edgesameparam - ShapeFix::SameParameter
-- settolerance - ShapeFix_ShapeTolerance
-- stwire - ShapeFix_Wire
-- reface - ShapeFix_Face
-- repcurve - ShapeFix_PCurves
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in ShapeFix
end ShapeFix;

679
src/SWDRAW/SWDRAW_ShapeFix.cxx Executable file
View File

@@ -0,0 +1,679 @@
// File: SWDRAW_ShapeFix.cxx
// Created: Tue Mar 9 15:49:13 1999
// Author: data exchange team
// <det@kinox.nnov.matra-dtv.fr>
#include <SWDRAW_ShapeFix.ixx>
#include <DBRep.hxx>
#include <SWDRAW.hxx>
#include <gp_XYZ.hxx>
#include <gp_Pnt2d.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <ShapeBuild_ReShape.hxx>
#include <ShapeAnalysis_Edge.hxx>
#include <ShapeAnalysis_WireOrder.hxx>
#include <ShapeAnalysis_WireVertex.hxx>
#include <ShapeAnalysis_Wire.hxx>
#include <ShapeExtend_WireData.hxx>
#include <ShapeFix.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <ShapeFix_Wire.hxx>
#include <ShapeFix_WireVertex.hxx>
#include <ShapeFix_Wireframe.hxx>
#include <ShapeFix_Face.hxx>
#include <ShapeFix_Shape.hxx>
#include <Precision.hxx>
#include <ShapeExtend_DataMapOfShapeListOfMsg.hxx>
#include <ShapeExtend_MsgRegistrator.hxx>
#include <ShapeExtend_DataMapIteratorOfDataMapOfShapeListOfMsg.hxx>
#include <Message_ListIteratorOfListOfMsg.hxx>
#include <Message_Msg.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopAbs_State.hxx>
#ifdef AIX
#include <strings.h>
#endif
#include <stdio.h>
#include <ShapeExtend_WireData.hxx>
//=======================================================================
//function : edgesameparam
//purpose :
//=======================================================================
static Standard_Integer edgesameparam (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// const Standard_CString arg1 = argv[1];
const Standard_CString arg2 (argc > 2 ? argv[2] : NULL);
// **** Edge:SameParameter ****
if (argc < 2) { di<<"shapename , option f to force, else only Edges not-SameParameter are computed"<<"\n"; return 1 /* Error */; }
TopoDS_Shape Shape = DBRep::Get(argv[1]);
if (!ShapeFix::SameParameter(Shape, (argc > 2 && arg2[0] == 'f') , BRepBuilderAPI::Precision()) )
di<<"Some edges were not processed"<<"\n";
di<<"\n";
return 0; // Done
}
//=======================================================================
//function : settolerance
//purpose :
//=======================================================================
static Standard_Integer settolerance (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) {
di<< "myshape val : forces tolerances at <val>"<<"\n"
<< "myshape < max : sets maximum tolerance to <max>"<<"\n"
<< "myshape > min : sets minimum tolerance to <min>"<<"\n"
<< "myshape min max : bounds tolerances between <min> and <max>"<<"\n"
<<"myshape mode=v-e-f other args : idem but only on vertex-edge-face"<<"\n";
return (argc < 2 ? 0 : 1 /* Error */);
}
Standard_CString arg1 = argv[1];
Standard_CString arg2 = argv[2];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
char mod2 = arg2[0];
Standard_Integer premarg = 2;
TopAbs_ShapeEnum styp = TopAbs_SHAPE;
if (mod2 == 'v') { styp = TopAbs_VERTEX; premarg = 3; }
if (mod2 == 'e') { styp = TopAbs_EDGE; premarg = 3; }
if (mod2 == 'w') { styp = TopAbs_WIRE; premarg = 3; }
if (mod2 == 'f') { styp = TopAbs_FACE; premarg = 3; }
if (mod2 == 'a') { styp = TopAbs_SHAPE; premarg = 3; }
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 (argc == premarg + 1 || tmin == tmax) di<<"Setting Tolerance to "<<tmin<<"\n";
else if (tmax < tmin) di<<"Minimum Tolerance to "<<tmin<<"\n";
else if (tmin <= 0) di<<"Maximum Tolerance to "<<tmax<<"\n";
else di<<"Tolerance Limited between "<<tmin<<" and "<<tmax<<"\n";
ShapeFix_ShapeTolerance sat;
sat.LimitTolerance (Shape,tmin,tmax,styp);
return 0; // Done
}
//=======================================================================
//function : stwire
//purpose :
//=======================================================================
static Standard_Integer stwire (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 2) { // help
di<<"Donner nom shape depart + nom shape resultat + option"<<"\n";
di<<"Options de chargement : x add connected (sinon add simple)\n"
<< "Options de traitement : l fix little/BRepBuilderAPI\n"
<<"Options de sortie : aucune make simple\n"
<<" m MakeAPI r avec reorder v vertex\n"
<<"Autres (se cumulent) : q quid(stats)"<<"\n";
return 0;
}
if (argc < 4) { di<<"stwire tout court pour help"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
Standard_CString arg2 = argv[2];
// Options
Standard_Integer i; int ox,ol,om,orint,oq,ov; ox=ol=om=orint=oq=ov=0;
for (i = 3; i < argc; i ++) {
int valopt = 1;
char opt = argv[i][0];
if (opt == '+') opt = argv[i][1];
if (opt == '-') { opt = argv[i][1]; valopt = 0; }
switch (opt) {
case 'l' : ol = valopt; break;
case 'm' : om = valopt; break;
case 'q' : oq = valopt; break;
case 'r' : orint = valopt; break;
case 'v' : ov = valopt; break;
case 'x' : ox = valopt; break;
default : break;
}
}
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<arg1<<" inconnu"<<"\n"; return 1 /* Error */; }
// On y va
Handle(ShapeExtend_WireData) sbwd = new ShapeExtend_WireData;
Handle(ShapeAnalysis_Wire) saw = new ShapeAnalysis_Wire;
saw->Load ( sbwd );
TopoDS_Shape awire; // en principe un Wire
if (Shape.ShapeType() == TopAbs_WIRE) {
awire = Shape;
} else if (Shape.ShapeType() == TopAbs_FACE) {
saw->SetFace (TopoDS::Face(Shape));
TopExp_Explorer expw(Shape,TopAbs_WIRE);
if (expw.More()) awire = expw.Current();
saw->SetPrecision (BRepBuilderAPI::Precision());
}
if (awire.IsNull()) {
di<<"Neither FACE nor WIRE : "<<arg1<<"\n";
di<<"Considering as list of edges ..."<<"\n";
awire = Shape;
// return 1 /* Error */;
}
// Chargement : normal ou par connected(oriented)
// if (ox) {
for (TopExp_Explorer exp(Shape,TopAbs_EDGE); exp.More(); exp.Next()) {
TopoDS_Edge E = TopoDS::Edge (exp.Current());
Standard_Integer orient = saw->CheckShapeConnect (E);
di<<"Orientation : "<<orient<<" LowerDist : "<< saw->MinDistance3d() << "\n";
if (ox) sbwd->AddOriented (E,orient);
else sbwd->Add (E);
}
// }
// else sbwd->Init (awire);
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
sfw->Init ( saw );
// Traitement en cours
if (ol) {
Standard_Integer nb = sfw->NbEdges();
for (i = 1; i <= nb; i ++) {
Standard_Boolean stat = sfw->FixSmall (i, Standard_True, 0.0);
//cout<<"FixSmall for"<<i<<(stat ? " done" : " not done"); //:sw <<" StatusFix="<<STW.StatusFix()<<"\n";
di<<"FixSmall for"<<i;
if (!stat) {
di<<" not done";
} else {
di<<" done";
}
if ( sfw->LastFixStatus ( ShapeExtend_FAIL ) ) di << " (failed)";
di << "\n";
}
}
// Traitement
if (orint) { // reorder ?
ShapeAnalysis_WireOrder WO ( (Shape.ShapeType() != TopAbs_FACE), BRepBuilderAPI::Precision());
Standard_Integer stwo = saw->CheckOrder (WO);
Standard_Integer nb = WO.NbEdges();
di<<"Reorder status : "<<stwo<<" NbEdges="<<nb<<"\n";
for (i = 1; i <= nb; i ++) {
Standard_Integer iord = WO.Ordered(i);
di<<"Edge n0 "<<i;
if ( sbwd->Edge(iord).Orientation() == TopAbs_REVERSED) di<<" REV";
else di<<" FWD";
di<<" ordered to "<<iord<<" Gap="<<WO.Gap(i)<<"\n";
}
di<<"Reorder not yet done"<<"\n";
sfw->FixReorder (WO);
// Mais on n execute pas
}
// Statistiques
if (oq) {
ShapeAnalysis_Edge sae;
Standard_Integer nb = sbwd->NbEdges();
di<<"NbEdges : "<<nb<<"\n";
for (i = 1; i <= nb; i ++) {
TopoDS_Edge E = sbwd->Edge(i);
di<<"Edge "<<i;
if (E.Orientation() == TopAbs_REVERSED) di<<" REV";
else di<<" FWD";
if (BRep_Tool::Degenerated(E)) di<<" DGNR";
if (sbwd->IsSeam(i)) di<<" SEAM_WIRE";
if (Shape.ShapeType() == TopAbs_FACE &&
sae.IsSeam(E,TopoDS::Face(Shape))) di<<" SEAM_FACE";
if (Shape.ShapeType() == TopAbs_FACE )
if (sae.HasPCurve(E,TopoDS::Face(Shape))) di<<" PCU";
else di<<" NO_PCU";
if (sae.HasCurve3d(E)) di<<" C3D";
else di<<" NO_C3D";
if (sae.IsClosed3d(E)) di<<" CLOSED";
di<<"\n";
}
}
// Resultat
TopoDS_Wire result;
if (ov) {
ShapeAnalysis_WireVertex sawv;
sawv.Init ( sbwd, saw->Precision() );
sawv.Analyze();
Standard_Integer nb = sbwd->NbEdges();
di<<"Nb(End)Vertex : "<<nb<<"\n";
for (i = 1; i <= nb; i ++) {
gp_XYZ pos; Standard_Real upre,ufol;
Standard_Integer stat = sawv.Data (i,pos,upre,ufol);
di<<i<<" : ";
switch (stat) {
case 0 : di<<"Same Vertex"<<"\n"; break;
case 1 : di<<"Same Coords with recorded precisions (but not Same Vertex)"<<"\n"; break;
case 2 : di<<"Close (with preci="<< saw->Precision()<<")"<<"\n"; break;
case 3 : di<<"End of "<<i<<" OK, Start of "<<(i == nb ? 1 : i+1)<<" at U="<<ufol; break;
case 4 : di<<"End of "<<i<<" at U="<<upre<<", Start of "<<(i == nb ? 1 : i+1)<<" OK"; break;
case 5 : di<<"Intersection, End of "<<i<<" at U="<<upre<<", Start of "<<(i == nb ? 1 : i+1)<<" at U="<<ufol; break;
default : di<<"Disjoined"<<"\n";
}
if (stat >= 3 && stat <= 5) di<<"\n - Position : "<<pos.X()<<" "<<pos.Y()<<" "<<pos.Z()<<"\n";
}
ShapeFix_WireVertex sfwv;
sfwv.Init ( sawv );
di<<"Nb Fixed Vertex : "<< sfwv.Fix() <<"\n";
}
/*
if (oc) {
if ( Shape.ShapeType() == TopAbs_FACE ) {
Correct_Wire CW ( TopoDS::Face(Shape) );
Standard_Integer i, nb = sbwd->NbEdges();
Standard_Integer num = 1;
for (i = 1; i <= nb; i ++) CW.Add (sbwd->Edge(i));
CW.Perform ( saw->Precision() );
nb = CW.NbWires();
if (nb != 1) {
// On prend celui qui a le plus d edges
Standard_Integer nbe, maxe = 0;
for (i = 1; i <= nb; i ++) {
TopoDS_Wire wir = CW.Wire(i);
nbe = 0;
for (TopoDS_Iterator ite(wir); ite.More(); ite.Next()) nbe ++;
if (nbe > maxe) { num = i; maxe = nbe; }
}
di<<"Correct_Wire produced "<<nb<<" Wires, taken n0 "<<num<<"\n";
}
result = CW.Wire (num);
}
else di << "Cannot apply Correct_Wire: face not defined" << "\n";
}
*/
else if (om) result = sbwd->WireAPIMake();
else result = sbwd->Wire();
if (result.IsNull()) {
di<<"Pas de resultat, desole"<<"\n";
return 1; // Fail
}
DBRep::Set (arg2,result);
return 0; // Done
}
//=======================================================================
//function : reface
//purpose :
//=======================================================================
static Standard_Integer reface (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) { di<<"Donner un nom de SHAPE (SHELL ou FACE) + un nom de RESULTAT"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
Standard_CString arg2 = argv[2];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
Standard_Boolean rebuild = Standard_False;
Handle(ShapeFix_Face) STF = new ShapeFix_Face;
// Options ?
Standard_Integer i; // svv Jan11 2000 : porting on DEC
for (i = 3; i < argc; i ++) {
Standard_Boolean valopt = Standard_True;
char opt = argv[i][0];
if (opt == '+') opt = argv[i][1];
if (opt == '-') { opt = argv[i][1]; valopt = Standard_False; }
//cout<<(valopt ? ".." : ".. NO");
if (!valopt) {
di<<".. NO";
} else {
di<<"..";
}
if (opt == 'R') { di<<" REBUILD-ANYWAY .."; rebuild = valopt; }
if (opt == 'd') { di<<" fix-dgnr .."; STF->FixWireTool()->FixDegeneratedMode() = valopt; }
if (opt == 'r') { di<<" fix-reorder-wire .."; STF->FixWireTool()->FixReorderMode() = valopt; }
if (opt == 'k') {
}
}
TopoDS_Face face;
ShapeBuild_ReShape resh;
Standard_Integer nbf = 0, nbfc = 0;
for (TopExp_Explorer EF (Shape,TopAbs_FACE); EF.More(); EF.Next()) {
TopoDS_Face F = TopoDS::Face (EF.Current()); face = F;
nbf ++;
Standard_Boolean newface = Standard_False;
// on va voir si ShapeTool_Face trouve qqchose a redire
//:sw ShapeTool_Wire STW;
//:sw STW.SetFace (F);
STF->Init (F); // qui fait tout
STF->Perform();
face = STF->Face();
newface = STF->Status(ShapeExtend_DONE) || rebuild;
if (newface) { nbfc ++; resh.Replace (F,face); }
}
if (nbfc > 0) {
di<<"Faces reprises par ShapeFix_Face : "<<nbfc<<"\n";
DBRep::Set (arg2,resh.Apply (Shape,TopAbs_FACE,2));
return 0; // Done
}
else di<<"ShapeFix_Face n a rien trouve a redire"<<"\n";
return 0;
}
//=======================================================================
//function : fixshape
//purpose :
//=======================================================================
static Standard_Integer fixshape (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
Handle(ShapeExtend_MsgRegistrator) msg = new ShapeExtend_MsgRegistrator;
Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
sfs->SetMsgRegistrator ( msg );
Standard_CString res = 0;
Standard_Integer par = 0, mess=0;
for ( Standard_Integer i=1; i < argc; i++ ) {
if ( argv[i][0] == '-' || argv[i][0] == '+' || argv[i][0] == '*' ) {
Standard_Integer val = ( argv[i][0] == '-' ? 0 : argv[i][0] == '+' ? 1 : -1 );
switch ( argv[i][1] ) {
case 'l': sfs->FixWireTool()->FixLackingMode() = val;
case 'o': sfs->FixFaceTool()->FixOrientationMode() = val;
case 'h': sfs->FixWireTool()->FixShiftedMode() = val;
case 'm': sfs->FixFaceTool()->FixMissingSeamMode() = val;
case 'd': sfs->FixWireTool()->FixDegeneratedMode() = val;
case 's': sfs->FixWireTool()->FixSmallMode() = val;
case 'i': sfs->FixWireTool()->FixSelfIntersectionMode() = val;
case 'n': sfs->FixWireTool()->FixNotchedEdgesMode() = val;
case '?': mess = val;
}
continue;
}
else {
switch ( par ) {
case 0: res = argv[i]; break;
case 1: {
TopoDS_Shape initShape = DBRep::Get(argv[i]);
if(initShape.IsNull()) continue;
sfs->Init ( initShape );
} break;
case 2: sfs->SetPrecision (atof(argv[i])); break;
case 3: sfs->SetMaxTolerance(atof(argv[i])); break;
}
}
par++;
}
if ( par <2 ) {
di << "Use: " << argv[0] << " result shape [tolerance [max_tolerance]] [switches]" << "\n";
di << "Switches allow to tune parameters of ShapeFix" << "\n";
di << "The following syntax is used: <symbol><parameter>" << "\n";
di << "- symbol may be - to set parameter off, + to set on or * to set default" << "\n";
di << "- parameters are identified by letters:" << "\n";
di << " l - FixLackingMode" << "\n";
di << " o - FixOrientationMode" << "\n";
di << " h - FixShiftedMode" << "\n";
di << " m - FixMissingSeamMode" << "\n";
di << " d - FixDegeneratedMode" << "\n";
di << " s - FixSmallMode" << "\n";
di << " i - FixSelfIntersectionMode" << "\n";
di << " n - FixNotchedEdgesMode" << "\n";
di << "For enhanced message output, use switch '+?'" << "\n";
return 1;
}
sfs->Perform();
DBRep::Set (res,sfs->Shape());
if ( mess ) {
Standard_Integer num = 0;
const ShapeExtend_DataMapOfShapeListOfMsg &map = msg->MapShape();
for ( ShapeExtend_DataMapIteratorOfDataMapOfShapeListOfMsg it(map); it.More(); it.Next() ) {
//cout << it.Key().TShape()->DynamicType()->Name() << " " << *(void**)&it.Key().TShape();
Standard_SStream aSStream;
aSStream << it.Key().TShape()->DynamicType()->Name() << " " << *(void**)&it.Key().TShape();
di << aSStream;
if ( mess <0 ) {
char buff[256];
sprintf ( buff, "%s_%d", res, ++num );
di << " (saved in DRAW shape " << buff << ")";
DBRep::Set (buff,it.Key());
}
di << ":" << "\n";
for (Message_ListIteratorOfListOfMsg iter (it.Value()); iter.More(); iter.Next())
di << " " << TCollection_AsciiString(iter.Value().Value()).ToCString() << "\n";
}
}
return 0; // Done
}
//=======================================================================
//function : fixgaps
//purpose :
//=======================================================================
Standard_Integer fixgaps(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n < 3) return 1;
TopoDS_Shape S = DBRep::Get(a[2]);
if (S.IsNull()) {
di << " Shape is null" << "\n";
return 1;
}
Handle(ShapeFix_Wireframe) SFWF = new ShapeFix_Wireframe(S);
Standard_Real prec = ( n >3 ? atof(a[3]) : 0. );
SFWF->SetPrecision(prec);
if ( SFWF->FixWireGaps() ) {
DBRep::Set(a[1],SFWF->Shape());
di<<" Wireframe gaps fixed on shape"<<"\n";
}
return 0;
}
//=======================================================================
//function : fixsmall
//purpose :
//=======================================================================
Standard_Integer fixsmall(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n < 3) return 1;
TopoDS_Shape S = DBRep::Get(a[2]);
if (S.IsNull()) {
di << " Shape is null" << "\n";
return 1;
}
Standard_Real prec = (n == 4)? atof(a[3]) : 1.;
ShapeFix_Wireframe SFWF(S);
SFWF.SetPrecision(prec);
if (SFWF.FixSmallEdges()) {
DBRep::Set(a[1],SFWF.Shape());
di<<" Small edges fixed on shape"<<"\n";
}
return 0;
}
//=======================================================================
//function : fixsmalledges
//purpose :
//=======================================================================
static Standard_Integer fixsmalledges(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if( n < 3) {
di<<"Invalid number of arguments"<<"\n";
return 1;
}
TopoDS_Shape Sh = DBRep::Get(a[2]);
Standard_Integer k = 3;
Standard_Real tol = 100000;
Standard_Integer mode = 2;
Standard_Real tolang = PI/2;
if(n > k)
tol = atof(a[k++]);
if(n > k)
mode= atoi(a[k++]);
if(n > k)
tolang = atof(a[k++]);
Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe();
Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape;
aSfwr->SetContext(aReShape);
aSfwr->Load(Sh);
aSfwr->SetPrecision(tol);
Standard_Boolean aModeDrop = Standard_True;
if(mode == 2)
aModeDrop = Standard_False;
TopTools_MapOfShape theSmallEdges, theMultyEdges;
TopTools_DataMapOfShapeListOfShape theEdgeToFaces,theFaceWithSmall;
aSfwr->CheckSmallEdges(theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges);
aSfwr->MergeSmallEdges (theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges, aModeDrop,tolang);
//aSfwr->FixSmallEdges();
TopoDS_Shape resShape = aSfwr->Shape();;
DBRep::Set ( a[1], resShape );
return 0;
}
//=======================================================================
//function : checkoverlapedges
//purpose :
//=======================================================================
static Standard_Integer checkoverlapedges(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if( n < 3) {
di<<"Invalid number of arguments"<<"\n";
return 1;
}
TopoDS_Shape Sh1 = DBRep::Get(a[1]);
TopoDS_Shape Sh2 = DBRep::Get(a[2]);
if(Sh1.IsNull() || Sh2.IsNull()) {
di<<"Invalid arguments"<<"\n";
return 1;
}
TopoDS_Edge e1 = TopoDS::Edge(Sh1);
TopoDS_Edge e2 = TopoDS::Edge(Sh2);
if(e1.IsNull() || e2.IsNull()) {
di<<"Invalid type of arguments"<<"\n";
return 1;
}
Standard_Real aTol = Precision::Confusion();
Standard_Real aDistDomain = 0.0;
Standard_Integer k = 3;
if(k < n)
aTol = atof(a[k++]);
if(k < n)
aDistDomain = atof(a[k++]);
ShapeAnalysis_Edge sae;
if(sae.CheckOverlapping(e1,e2,aTol,aDistDomain)) {
if(aDistDomain ==0.0)
di<<"Edges is overlaping comletly"<<"\n";
else {
di<<"Edges is overlaped"<<"\n";
di<<"with tolerance = "<<aTol<<"\n";
di<<"on segment length = "<<aDistDomain<<"\n";
}
}
else di<<"Edges is not overlaped"<<"\n";
return 0;
}
//=======================================================================
//function : checkfclass2d
//purpose :
//=======================================================================
static Standard_Integer checkfclass2d(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if( n < 4) {
di<<"Invalid number of arguments"<<"\n";
return 1;
}
TopoDS_Shape Sh1 = DBRep::Get(a[1]);
Standard_Real ucoord = atof(a[2]);
Standard_Real vcoord = atof(a[3]);
if(Sh1.IsNull() || Sh1.ShapeType()!= TopAbs_FACE) {
di<<"Invalid arguments"<<"\n";
return 1;
}
TopoDS_Face aFace = TopoDS::Face(Sh1);
gp_Pnt2d p2d(ucoord,vcoord);
BRepTopAdaptor_FClass2d f2d(aFace,Precision::Confusion());
TopAbs_State stat = f2d.Perform(p2d);
if(stat == TopAbs_OUT)
di<<"Point is OUT"<<"\n";
else if(stat == TopAbs_IN)
di<<"Point is IN"<<"\n";
else if(stat == TopAbs_ON)
di<<"Point is ON"<<"\n";
else
di<<"Point is UNKNOWN"<<"\n";
return 0;
}
//=======================================================================
//function : InitCommands
//purpose :
//=======================================================================
void SWDRAW_ShapeFix::InitCommands(Draw_Interpretor& theCommands)
{
static Standard_Integer initactor = 0;
if (initactor) return; initactor = 1;
Standard_CString g = SWDRAW::GroupName();
theCommands.Add ("edgesameparam","nom shape draw ou * [+ option force]",
__FILE__,edgesameparam,g);
theCommands.Add ("settolerance","shape [mode=v-e-f-a] val(fix value) or tolmin tolmax",
__FILE__,settolerance,g);
theCommands.Add ("stwire","stwire tout court pour help complet",
__FILE__,stwire,g);
theCommands.Add ("reface","shape result : controle sens wire",
__FILE__,reface,g);
theCommands.Add ("fixshape","res shape [preci [maxpreci]] [{switches}]",
__FILE__,fixshape,g);
// theCommands.Add ("testfill","result edge1 edge2",
// __FILE__,XSHAPE_testfill,g);
theCommands.Add ("fixwgaps","result shape [toler=0]",
__FILE__,fixgaps,g);
theCommands.Add ("fixsmall","result shape [toler=1.]",
__FILE__,fixsmall,g);
theCommands.Add ("fixsmalledges","result shape [toler mode amxangle]",
__FILE__,fixsmalledges,g);
theCommands.Add ("checkoverlapedges","edge1 edge2 [toler domaindist]",
__FILE__,checkoverlapedges,g);
theCommands.Add ("checkfclass2d","face ucoord vcoord",
__FILE__,checkfclass2d,g);
}

View File

@@ -0,0 +1,20 @@
-- File: SWDRAW_ShapeProcess.cdl
-- Created: Sat Jun 19 15:26:38 1999
-- Author: data exchange team
-- <det@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ShapeProcess from SWDRAW
---Purpose: Contains commands to activate package ShapeProcess
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in ShapeProc
end ShapeProcess;

View File

@@ -0,0 +1,66 @@
// File: SWDRAW_ShapeProcess.cxx
// Created: Sat Jun 19 15:49:27 1999
// Author: Andrey BETENEV
// <abv@nnov.matra-dtv.fr>
#include <SWDRAW_ShapeProcess.ixx>
#include <SWDRAW.hxx>
#include <DBRep.hxx>
#include <Draw_Interpretor.hxx>
#include <TopoDS_Shape.hxx>
#include <ShapeProcess.hxx>
#include <ShapeProcess_ShapeContext.hxx>
#include <ShapeProcess_OperLibrary.hxx>
//=======================================================================
//function : ApplySequence
//purpose :
//=======================================================================
static Standard_Integer ApplySequence(Draw_Interpretor& di,
Standard_Integer argc, const char** argv)
{
if (argc < 4) { di<<"Specify result, shape, resource name and prefix (optional)"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
Standard_CString arg2 = argv[2];
Standard_CString arg3 = argv[3];
Standard_CString arg4 = "";
if (argc > 4) arg4 = argv[4];
TopoDS_Shape Shape = DBRep::Get(arg2);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg2<<"\n"; return 1 /* Error */; }
Handle(ShapeProcess_ShapeContext) context = new ShapeProcess_ShapeContext (Shape, arg3);
ShapeProcess::Perform ( context, arg4 );
context->PrintStatistics();
TopoDS_Shape result = context->Result();
// seq.PrintPreparationResult ();
if ( result.IsNull() ) {
di << "No result" << "\n";
}
else if ( result == Shape ) {
di << "Shape not modified" << "\n";
}
DBRep::Set (arg1,result);
return 0;
}
//=======================================================================
//function : InitCommands
//purpose :
//=======================================================================
void SWDRAW_ShapeProcess::InitCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean initactor = 0;
if (initactor) return; initactor = 1;
ShapeProcess_OperLibrary::Init();
Standard_CString g = SWDRAW::GroupName(); // "Tests of DivideTool";
theCommands.Add ("SPApply","SPApply result shape rscfilename [sequence]",
__FILE__,ApplySequence,g);
}

View File

@@ -0,0 +1,20 @@
-- File: SWDRAW_ShapeProcessAPI.cdl
-- Created: Sat Jun 19 15:26:38 1999
-- Author: data exchange team
-- <det@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ShapeProcessAPI from SWDRAW
---Purpose: Contains commands to activate package ShapeProcessAPI
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in ShapeProcessAPI
end ShapeProcessAPI;

View File

@@ -0,0 +1,55 @@
// File: SWDRAW_ShapeProcessAPI.cxx
// Created: Sat Jun 19 15:49:27 1999
// Author: data exchange team
// <det@doomox.nnov.matra-dtv.fr>
#include <SWDRAW_ShapeProcessAPI.ixx>
#include <SWDRAW.hxx>
#include <DBRep.hxx>
#include <TopoDS_Shape.hxx>
#include <ShapeProcessAPI_ApplySequence.hxx>
#include <ShapeProcess_ShapeContext.hxx>
#include <stdio.h>
//=======================================================================
//function : ApplySequence
//purpose :
//=======================================================================
static Standard_Integer ApplySequence(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 4) { di<<"Specify result, shape, resource name and prefix (optional)"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
Standard_CString arg2 = argv[2];
Standard_CString arg3 = argv[3];
Standard_CString arg4 = "";
if (argc > 4) arg4 = argv[4];
TopoDS_Shape Shape = DBRep::Get(arg2);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg2<<"\n"; return 1 /* Error */; }
ShapeProcessAPI_ApplySequence seq (arg3, arg4);
TopoDS_Shape result = seq.PrepareShape(Shape, Standard_True, TopAbs_FACE);//fill history map for faces and above
seq.PrintPreparationResult();
DBRep::Set (arg1,result);
return 0;
}
//=======================================================================
//function : InitCommands
//purpose :
//=======================================================================
void SWDRAW_ShapeProcessAPI::InitCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean initactor = Standard_False;
if (!initactor) {
initactor = Standard_True;
Standard_CString g = SWDRAW::GroupName(); // "Tests of DivideTool";
theCommands.Add ("DT_ApplySeq","DT_ApplySeq result shape rscfilename [prefix]",
__FILE__,ApplySequence,g);
}
}

25
src/SWDRAW/SWDRAW_ShapeTool.cdl Executable file
View File

@@ -0,0 +1,25 @@
-- File: SWDRAW_ShapeTool.cdl
-- Created: Tue Apr 22 18:34:27 1997
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class ShapeTool from SWDRAW
---Purpose : Defines functions to control shapes (in way useful for XSTEP),
-- additional features which should be basic, or call tools which
-- are bound with transfer needs.
-- But these functions work on shapes, geometry, nothing else
-- (no file, no model, no entity)
uses CString, Interpretor from Draw
is
InitCommands (myclass; theCommands : in out Interpretor from Draw);
---Purpose : Defines and loads all basic functions for SWDRAW on Shapes
end ShapeTool;

266
src/SWDRAW/SWDRAW_ShapeTool.cxx Executable file
View File

@@ -0,0 +1,266 @@
// 25.12.98 pdn renaming
// 02.02.99 cky/rln PRO17746: transmitting 'sketch' command to XSDRAWEUC
// 23.02.99 abv: method ShapeFix::FillFace() removed
// 02.03.99 cky/rln: command edgeregul only accepts tolerance
// 15.06.99 abv/pdn: command comptol added (from S4030)
#include <SWDRAW_ShapeTool.ixx>
#include <DBRep.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRepBuilderAPI.hxx>
// + edge, face
#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>
// + edgeregul/updtol
#include <BRepLib.hxx>
// + fillface
#include <Geom_TrimmedCurve.hxx>
#include <stdio.h>
#include <Precision.hxx>
#include <DrawTrSurf.hxx>
#include <GeomLib.hxx>
static Standard_Integer XSHAPE_edge
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 2) { di<<"donner un nom de shape"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<arg1<<" inconnu"<<"\n"; return 1 /* Error */; }
Standard_Integer nbe = 0, nbf = 0; Standard_Real f3d,l3d;
for (TopExp_Explorer exp(Shape,TopAbs_EDGE); exp.More(); exp.Next()) {
TopoDS_Edge Edge = TopoDS::Edge (exp.Current()); nbe ++;
if (BRep_Tool::Degenerated(Edge)) continue;
Handle(Geom_Curve) curve3d = BRep_Tool::Curve (Edge,f3d,l3d);
if (curve3d.IsNull()) {
char nomsh[30];
nbf ++;
sprintf (nomsh,"faultedge_%d",nbf);
di<<"Edge sans Curve3d, n0 "<<nbe<<"\n";
DBRep::Set (nomsh,Edge);
}
}
return 0;
}
static Standard_Integer XSHAPE_explorewire
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
char nomsh[30];
if (argc < 2) { di<<"donner un nom de wire"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<arg1<<" inconnu"<<"\n"; return 1 /* Error */; }
if (Shape.ShapeType() != TopAbs_WIRE) { di<<"Pas un WIRE"<<"\n"; return 1 /* Error */; }
TopoDS_Wire W = TopoDS::Wire (Shape);
TopoDS_Face F;
if (argc > 2) {
Standard_CString arg2 = argv[2];
TopoDS_Shape aLocalShape = DBRep::Get(arg2);
F = TopoDS::Face ( aLocalShape );
}
Standard_Integer i,num = 0, nbw, nbe = 0;
TopTools_IndexedMapOfShape map;
for (TopoDS_Iterator ext(W); ext.More(); ext.Next()) {
if (ext.Value().ShapeType() != TopAbs_EDGE) continue;
TopoDS_Edge E = TopoDS::Edge (ext.Value());
nbe ++; num = map.Add(E);
}
int* nbs = new int[nbe+1]; for (i = 0; i <= nbe; i ++) nbs[i] = 0;
di<<"TopoDS_Iterator(EDGE) donne "<<nbe<<" Edges dont "<<num<<" distinctes"<<"\n";
nbe = num;
nbw = 0;
for (TopExp_Explorer exe(W.Oriented(TopAbs_FORWARD),TopAbs_EDGE); exe.More(); exe.Next()) nbw ++;
di<<"TopExp_Explorer(EDGE) donne "<<nbw<<" Edges"<<"\n";
nbw = 0;
BRepTools_WireExplorer bwe;
if (F.IsNull()) bwe.Init(W);
else bwe.Init (W,F);
for (; bwe.More(); bwe.Next()) {
TopoDS_Edge E = TopoDS::Edge (bwe.Current());
nbw ++;
num = map.FindIndex(E);
nbs[num] ++;
}
di<<"BRepTools_WireExplorer donne "<<nbw<<" Edges"<<"\n";
di<<"Par rapport a la map, edges sautees par WE en NOWE_num, passees > 1 fois en MULTWE_num"<<"\n";
if (nbs[0] > 0) di<<"NB : Edge n0 0 comptee "<<nbs[0]<<" fois"<<"\n";
for (i = 1; i <= nbe; i ++) {
if (nbs[i] < 1) {
di<<"Edge n0 "<<i<<" pas vue par WE"<<"\n";
sprintf (nomsh,"NOWE_%d",i);
DBRep::Set (nomsh,map.FindKey(i));
} else if (nbs[i] > 1) {
di<<"Edge n0 "<<i<<" vue par WE : "<<nbs[i]<<" fois"<<"\n";
sprintf (nomsh,"MULT_%d",i);
DBRep::Set (nomsh,map.FindKey(i));
}
}
delete [] nbs;
return 0;
}
static Standard_Integer XSHAPE_ssolid
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) { di<<"Give new solid name + shell name"<<"\n"; return 1 /* Error */; }
Standard_CString arg1 = argv[1];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
TopAbs_ShapeEnum shen = Shape.ShapeType();
if (shen == TopAbs_SOLID) {
di<<" Already a Solide ! nothing done"<<"\n";
return 0;
}
if (shen != TopAbs_SHELL) {
di<<" Not a Shell"<<"\n"; return 1 /* Error */;
}
if (!Shape.Free ()) {
di<<"Shape non Free -> Freeing"<<"\n";
Shape.Free(Standard_True);
}
TopoDS_Shell sh = TopoDS::Shell (Shape);
TopoDS_Solid solid;
BRep_Builder B;
B.MakeSolid (solid);
B.Add (solid,sh);
// Pas encore fini : il faut une bonne orientation
BRepClass3d_SolidClassifier bsc3d (solid);
bsc3d.PerformInfinitePoint(BRepBuilderAPI::Precision());
if (bsc3d.State() == TopAbs_IN) {
// Ensuite, inverser C-A-D REPRENDRE LES SHELLS
// (l inversion du solide n est pas bien prise en compte)
di<<"NB : Shell to be reversed"<<"\n";
TopoDS_Solid soli2;
B.MakeSolid (soli2); // on recommence
sh.Reverse();
B.Add (soli2,sh);
solid = soli2;
}
DBRep::Set(argv[2],solid);
return 0; // Done
}
static Standard_Integer XSHAPE_edgeregul
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
//cky/rln 03.02.99 To eliminate dependence of SWDRAW on TKXSBase (to use only ShapeHealing)
Standard_Real tolang; // = Interface_Static::RVal("XSTEP.encoderegularity.angle");
// if (argc < 3) di<<"Current value for regularity angle : "<<tolang<<"\n";
if (argc < 3) {
di<<"Donner nom de shape.\n + option : angle en radian, sinon la valeur courante est prise"<<"\n";
return 0;
}
Standard_CString arg1 = argv[1];
Standard_CString arg2 = argv[2];
if (argc > 2) tolang = atof (arg2);
if (tolang <= 0) {
di<<"Not a suitable value : "<<tolang<<"\n";
return 1 /* Error */;
}
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
BRepLib::EncodeRegularity (Shape,tolang);
return 0; // Done
}
static Standard_Integer samerange (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if ( argc ==2 ) {
TopoDS_Shape Shape = DBRep::Get(argv[1]);
if (Shape.IsNull()) { di<<"Shape unknown: "<<argv[2]<<"\n"; return 1; }
for ( TopExp_Explorer exp(Shape,TopAbs_EDGE); exp.More(); exp.Next() ) {
TopoDS_Edge edge = TopoDS::Edge ( exp.Current() );
BRepLib::SameRange ( edge, Precision::PConfusion() );
}
}
else if ( argc == 7 ) {
Handle(Geom2d_Curve) C = DrawTrSurf::GetCurve2d(argv[2]);
if (C.IsNull()) { di<<"Curve unknown: "<<argv[2]<<"\n"; return 1; }
Standard_Real oldFirst = atof(argv[3]);
Standard_Real oldLast = atof(argv[4]);
Standard_Real current_first = atof(argv[5]);
Standard_Real current_last = atof(argv[6]);
Standard_Real Tol = Precision::PConfusion();
Handle(Geom2d_Curve) NewC2d;
GeomLib::SameRange(Tol, C, oldFirst,oldLast,
current_first, current_last, NewC2d);
DrawTrSurf::Set(argv[1],NewC2d);
}
else {
di << "Apply BRepLib::SameRange() to shape or GeomLib::SameRange() to pcurve:" << "\n";
di << "> samerange shape" << "\n";
di << "or" << "\n";
di << "> samerange newcurve curve2d first last newfirst newlast" << "\n";
}
return 0;
}
// ########################################
// ## DECLARATIONS ##
// ########################################
static int initactor = 0;
void SWDRAW_ShapeTool::InitCommands (Draw_Interpretor& theCommands)
{
if (initactor) return; initactor = 1;
const char* g;
g = "DE: old";
theCommands.Add ("anaedges","nom shape",
__FILE__,XSHAPE_edge,g);
theCommands.Add ("expwire","nom wire [nom face]",
__FILE__,XSHAPE_explorewire,g);
theCommands.Add ("ssolid","nom shell + nouveau nom solid",
__FILE__,XSHAPE_ssolid,g);
theCommands.Add ("edgeregul","shape val",
__FILE__,XSHAPE_edgeregul,g);
theCommands.Add ("samerange","{ shape | result curve2d first last newfirst newlast }",
__FILE__,samerange,g);
}

View File

@@ -0,0 +1,31 @@
-- File: SWDRAW_ShapeUpgrade.cdl
-- Created: Tue Mar 9 15:26:38 1999
-- Author: data exchange team
-- <det@kinox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class ShapeUpgrade from SWDRAW
---Purpose: Contains commands to activate package ShapeUpgrade
-- List of DRAW commands and corresponding functionalities:
-- DT_ShapeDivide - ShapeUpgrade_ShapeDivide
-- DT_PlaneDividedFace - ShapeUpgrade_PlaneDividedFace
-- DT_PlaneGridShell - ShapeUpgrade_PlaneGridShell
-- DT_PlaneFaceCommon - ShapeUpgrade_PlaneFaceCommon
-- DT_Split2dCurve - ShapeUpgrade_Split2dCurve
-- DT_SplitCurve - ShapeUpgrade_SplitCurve
-- DT_SplitSurface - ShapeUpgrade_SplitSurface
-- DT_SupportModification - ShapeUpgrade_DataMapOfShapeSurface
-- DT_Debug - ShapeUpgrade::SetDebug
-- shellsolid - ShapeAnalysis_Shell/ShapeUpgrade_ShellSewing
uses
Interpretor from Draw
is
InitCommands (myclass; theCommands: in out Interpretor from Draw);
---Purpose: Loads commands defined in ShapeUpgrade
end ShapeUpgrade;

1500
src/SWDRAW/SWDRAW_ShapeUpgrade.cxx Executable file

File diff suppressed because it is too large Load Diff

71
src/SWDRAW/SWDRAW_ToVRML.cdl Executable file
View File

@@ -0,0 +1,71 @@
-- File: SWDRAW_ToVRML.cdl
-- Created: Mon Aug 3 18:40:15 1998
-- Author: Christian CAILLET
-- <cky@heliox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class ToVRML from SWDRAW
---Purpose : Writes a Shape to a File in VRML Format
uses CString, OStream, AsciiString from TCollection, Shape from TopoDS
is
Create returns ToVRML;
EmissiveColorRed (me : in out) returns Real;
---C++ : return &
EmissiveColorGreen (me : in out) returns Real;
---C++ : return &
EmissiveColorBlue (me : in out) returns Real;
---C++ : return &
DiffuseColorRed (me : in out) returns Real;
---C++ : return &
DiffuseColorGreen (me : in out) returns Real;
---C++ : return &
DiffuseColorBlue (me : in out) returns Real;
---C++ : return &
Transparency (me : in out) returns Real;
---C++ : return &
AmbientIntensity (me : in out) returns Real;
---C++ : return &
SpecularColorRed (me : in out) returns Real;
---C++ : return &
SpecularColorGreen (me : in out) returns Real;
---C++ : return &
SpecularColorBlue (me : in out) returns Real;
---C++ : return &
Shininess (me : in out) returns Real;
---C++ : return &
Texture (me : in out) returns AsciiString;
---C++ : return &
CreaseAngle (me : in out) returns Real;
---C++ : return &
Deflection (me : in out) returns Real;
---C++ : return &
Write (me; shape : Shape from TopoDS; filename : CString) returns Boolean;
---Purpose : conversion of a Shape into VRML format for 3d visualisation
fields
myEmissiveColorRed : Real; -- def 0.3
myEmissiveColorGreen : Real; -- def 0.3
myEmissiveColorBlue : Real; -- def 0.3
myDiffuseColorRed : Real; -- def 0.3
myDiffuseColorGreen : Real; -- def 0.3
myDiffuseColorBlue : Real; -- def 0.5
myTransparency : Real; -- def 0.0
myAmbientIntensity : Real; -- def 0.3
mySpecularColorRed : Real; -- def 0.7
mySpecularColorGreen : Real; -- def 0.7
mySpecularColorBlue : Real; -- def 0.8
myShininess : Real; -- def 0.1
myTexture : AsciiString; -- def " [] "
myCreaseAngle : Real; -- def 1.57
myDeflection : Real; -- def 0.005
end ToVRML;

175
src/SWDRAW/SWDRAW_ToVRML.cxx Executable file
View File

@@ -0,0 +1,175 @@
#include <SWDRAW_ToVRML.ixx>
#include <Standard_Stream.hxx>
#include <BRepMesh_FastDiscret.hxx>
#include <BRepMesh_Triangle.hxx>
#include <BRepMesh_Edge.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <gp_Pnt.hxx> //ied_modif_for_compil_Nov-20-1998
SWDRAW_ToVRML::SWDRAW_ToVRML ()
{
myEmissiveColorRed = 0.3;
myEmissiveColorGreen = 0.3;
myEmissiveColorBlue = 0.3;
myDiffuseColorRed = 0.3;
myDiffuseColorGreen = 0.3;
myDiffuseColorBlue = 0.5;
myTransparency = 0.0;
myAmbientIntensity = 0.3;
mySpecularColorRed = 0.7;
mySpecularColorGreen = 0.7;
mySpecularColorBlue = 0.8;
myShininess = 0.1;
myTexture = " [] " ;
myCreaseAngle = 1.57;
myDeflection = 0.005;
}
Standard_Real& SWDRAW_ToVRML::EmissiveColorRed () { return myEmissiveColorRed ; }
Standard_Real& SWDRAW_ToVRML::EmissiveColorGreen() { return myEmissiveColorGreen; }
Standard_Real& SWDRAW_ToVRML::EmissiveColorBlue () { return myEmissiveColorBlue ; }
Standard_Real& SWDRAW_ToVRML::DiffuseColorRed () { return myDiffuseColorRed ; }
Standard_Real& SWDRAW_ToVRML::DiffuseColorGreen () { return myDiffuseColorGreen ; }
Standard_Real& SWDRAW_ToVRML::DiffuseColorBlue () { return myDiffuseColorBlue ; }
Standard_Real& SWDRAW_ToVRML::Transparency () { return myTransparency ; }
Standard_Real& SWDRAW_ToVRML::AmbientIntensity () { return myAmbientIntensity ; }
Standard_Real& SWDRAW_ToVRML::SpecularColorRed () { return mySpecularColorRed ; }
Standard_Real& SWDRAW_ToVRML::SpecularColorGreen() { return mySpecularColorGreen; }
Standard_Real& SWDRAW_ToVRML::SpecularColorBlue () { return mySpecularColorBlue ; }
Standard_Real& SWDRAW_ToVRML::Shininess () { return myShininess ; }
TCollection_AsciiString& SWDRAW_ToVRML::Texture () { return myTexture ; }
Standard_Real& SWDRAW_ToVRML::CreaseAngle() { return myCreaseAngle; }
Standard_Real& SWDRAW_ToVRML::Deflection () { return myDeflection ; }
//=======================================================================
// function : ToVRML::Write
// purpose : conversion of a Shape into VRML format for 3d visualisation
//=======================================================================
Standard_Boolean SWDRAW_ToVRML::Write
(const TopoDS_Shape& aShape, const Standard_CString filename) const
{
filebuf thefile;
ostream TheFileOut(&thefile);
if (thefile.open(filename,ios::out))
{
// Creates facets from the shape
// Create (defle : Real from Standard;
// shape : Shape from TopoDS;
// angl : Real from Standard= 0.17;
// withShare : Boolean from Standard=Standard_True;
// inshape : Boolean from Standard=Standard_False;
// relative : Boolean from Standard=Standard_False;
// shapetrigu: Boolean from Standard=Standard_False)
// returns mutable Discret from BRepMesh;
Bnd_Box B;
BRepBndLib::Add(aShape, B);
Handle(BRepMesh_FastDiscret) TheDiscret =
new BRepMesh_FastDiscret(myDeflection,
aShape,
B,
0.17,
Standard_True,
Standard_False,
Standard_True,
Standard_True);
Standard_Integer i,j;
// header of the VRML file
TheFileOut << "#VRML V2.0 utf8" << endl;
TheFileOut << "Group {" << endl;
TheFileOut << " children [ " << endl;
TheFileOut << " NavigationInfo {" << endl;
TheFileOut << " type \"EXAMINE\" " << endl;
TheFileOut << " }," << endl;
TheFileOut << "Shape {" << endl;
TheFileOut << " appearance Appearance {" << endl;
TheFileOut << " texture ImageTexture {" << endl;
TheFileOut << " url " << myTexture.ToCString() << endl;
TheFileOut << " }" << endl;
TheFileOut << " material Material { " << endl;
TheFileOut << " diffuseColor " << myDiffuseColorRed << " " << myDiffuseColorGreen << " " << myDiffuseColorBlue << " " << endl;
TheFileOut << " emissiveColor " << myEmissiveColorRed << " "
<< myEmissiveColorGreen << " " << myEmissiveColorBlue << " " << endl;
TheFileOut << " transparency " << myTransparency << endl;
TheFileOut << " ambientIntensity " << myAmbientIntensity << " " << endl;
TheFileOut << " specularColor " << mySpecularColorRed << " " << mySpecularColorGreen << " " << mySpecularColorBlue << " " << endl;
TheFileOut << " shininess " <<myShininess << " " << endl;
TheFileOut << " }" << endl;
TheFileOut << " }" << endl;
TheFileOut << " geometry IndexedFaceSet {" << endl;
TheFileOut << " coord Coordinate {" << endl;
TheFileOut << " point [" << endl;
// puts the coordinates of all the vertices using the order
// given during the discretisation
for (i=1;i<=TheDiscret->NbVertices();i++)
{
gp_Pnt TheVertex=TheDiscret->Pnt(i);
TheFileOut << " "
<< TheVertex.Coord().X() << " "
<< TheVertex.Coord().Y() << " "
<< TheVertex.Coord().Z() << "," << endl;
}
TheFileOut << " ]" << endl;
TheFileOut << " }" << endl;
TheFileOut << " coordIndex [" << endl;
// retrieves all the triangles in order to draw the facets
for (j=1; j <= TheDiscret->NbTriangles(); j++)
{
BRepMesh_Triangle TheTri=TheDiscret->Triangle(j);
Standard_Integer e1,e2,e3,i1,i2,i3;
Standard_Boolean b1,b2,b3;
TheTri.Edges(e1,e2,e3,b1,b2,b3);
if (b1)
{
i1 = TheDiscret->Edge(e1).FirstNode()-1;
i2 = TheDiscret->Edge(e1).LastNode()-1;
}
else
{
i2 = TheDiscret->Edge(e1).FirstNode()-1;
i1 = TheDiscret->Edge(e1).LastNode()-1;
}
if (b2)
{
i3 = TheDiscret->Edge(e2).LastNode()-1;
}
else
{
i3 = TheDiscret->Edge(e2).FirstNode()-1;
}
TheFileOut << " " << i1 << ", " << i2 << ", " << i3 << ", -1, " << endl;
}
TheFileOut << " ]" << endl;
TheFileOut << " solid FALSE" << endl; // it is not a closed solid
TheFileOut << " creaseAngle " << myCreaseAngle << " " << endl; // for smooth shading
TheFileOut << " }" << endl;
TheFileOut << " }" << endl;
TheFileOut << " ]" << endl;
TheFileOut << "} " << endl;
}
else return Standard_False; // failure when opening file
thefile.close();
return Standard_True;
}

59
src/SWDRAW/cpulimit.pc Executable file
View File

@@ -0,0 +1,59 @@
#ifdef WNT
#include <windows.h>
#include <winbase.h>
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
static clock_t MDTV_CPU_LIMIT; // Cpu_limit in Sec.
static clock_t MDTV_CPU_CURRENT; // cpu time already used at last
// cpulimit call. (sec.)
static unsigned int __stdcall CpuFunc(void * param) {
clock_t current;
while ( 1 ) {
Sleep(5);
current = clock()/1000;
if ((current-MDTV_CPU_CURRENT) >= MDTV_CPU_LIMIT ){
printf("CpuFunc : Fin sur Cpu Limit \n");
ExitProcess(2);
return(0);
}
}
return(0);
}
//static Standard_Integer cpulimit(Draw_Interpretor& DI, Standard_Integer n, char** a)
void limitelapsed(int n ) {
static int first=1;
unsigned int __stdcall CpuFunc(void * );
unsigned ThreadID;
MDTV_CPU_LIMIT = n;
MDTV_CPU_CURRENT = clock()/1000;
if (first) { // Lancer le thread au 1er appel seulement.
first=0;
_beginthreadex(
NULL, // no security attributes
0, // use default stack size
CpuFunc, // thread function
NULL, // argument to thread function
0, // use default creation flags
&ThreadID); // returns the thread identifier
}
}
#endif