// Created on: 1995-04-13
// Created by: Jean Yves LEBEY
// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
#include <BRepTest.hxx>
+#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <DBRep.hxx>
-#include <BRep_Builder.hxx>
+#include <DrawTrSurf.hxx>
+
+#include <string.h>
+#include <stdio.h>
+
+#include <Standard_ErrorHandler.hxx>
+#include <Precision.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Ax1.hxx>
+
+#include <ElCLib.hxx>
+
+#include <TColgp_SequenceOfPnt.hxx>
+
+#include <GeomAbs_JoinType.hxx>
+#include <Geom_Line.hxx>
+
+#include <IntCurvesFace_Intersector.hxx>
+
+#include <TopAbs.hxx>
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_CompSolid.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <BRepIntCurveSurface_Inter.hxx>
-#include <Geom_Line.hxx>
-#include <DrawTrSurf.hxx>
+#include <TopoDS_Iterator.hxx>
-#include <string.h>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
-#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
-#include <Standard_ErrorHandler.hxx>
+#include <LocOpe_CSIntersector.hxx>
+#include <LocOpe_SequenceOfLin.hxx>
+#include <LocOpe_PntFace.hxx>
+#include <BRepFeat_MakeDPrism.hxx>
-//#ifdef WNT
-#include <stdio.h>
-//#endif
+#include <BRepTools.hxx>
+#include <BRepIntCurveSurface_Inter.hxx>
+#include <BRepOffset_MakeOffset.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
+#include <GeomAdaptor_Curve.hxx>
+
+static
+ void SampleEdges (const TopoDS_Shape& theShape,
+ TColgp_SequenceOfPnt& theSeq);
+static
+ TopoDS_Face NextFaceForPrism (const TopoDS_Shape& shape,
+ const TopoDS_Shape& basis,
+ const gp_Ax1& ax1);
+static
+ void PrintState (Draw_Interpretor& aDI,
+ const TopAbs_State& aState);
+//
+static Standard_Integer emptyshape(Draw_Interpretor&, Standard_Integer, const char** );
+static Standard_Integer subshape (Draw_Interpretor&, Standard_Integer, const char** );
+static Standard_Integer brepintcs (Draw_Interpretor&, Standard_Integer, const char** );
+static Standard_Integer MakeBoss (Draw_Interpretor&, Standard_Integer, const char** );
+static Standard_Integer MakeShell (Draw_Interpretor&, Standard_Integer, const char** );
+static Standard_Integer xbounds (Draw_Interpretor&, Standard_Integer, const char** );
+static Standard_Integer xclassify (Draw_Interpretor&, Standard_Integer, const char** );
//=======================================================================
-// shape : shape name V/E/W/F/SH/SO/CS/C
+//function : OtherCommands
+//purpose :
//=======================================================================
+void BRepTest::OtherCommands(Draw_Interpretor& theCommands)
+{
+ static Standard_Boolean done = Standard_False;
+ if (done) return;
+ done = Standard_True;
+
+ const char* g = "TOPOLOGY other commands";
+
+ theCommands.Add("shape",
+ "shape name V/E/W/F/Sh/So/CS/C; make a empty shape",__FILE__,emptyshape,g);
+
+ theCommands.Add("subshape",
+ "subshape name V/E/W/F/Sh/So/CS/C index; get subsshape <index> of given type"
+ ,__FILE__,subshape,g);
+
+ theCommands.Add("BRepIntCS",
+ "Calcul d'intersection entre face et curve : BRepIntCS curve1 [curve2 ...] shape [res] [tol]"
+ ,__FILE__,brepintcs,g);
+
+ theCommands.Add("makeboss", "create a boss on the shape myS", __FILE__, MakeBoss, g);
+ theCommands.Add("mksh", "create a shell on Shape", __FILE__, MakeShell, g);
+ theCommands.Add("xbounds", "xbounds face", __FILE__, xbounds, g);
+ theCommands.Add("xclassify", "use xclassify Solid [Tolerance=1.e-7]", __FILE__, xclassify, g);
+
-static Standard_Integer emptyshape(Draw_Interpretor& , Standard_Integer n, const char** a)
+}
+//=======================================================================
+//function : emptyshape
+//purpose : shape : shape name V/E/W/F/SH/SO/CS/C
+//=======================================================================
+Standard_Integer emptyshape(Draw_Interpretor& , Standard_Integer n, const char** a)
{
if (n <= 1) return 1;
}
//=======================================================================
-// subshape
+//function : subshape
+//purpose :
//=======================================================================
-
-static Standard_Integer subshape(Draw_Interpretor& di, Standard_Integer n, const char** a)
+Standard_Integer subshape(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n <= 2) return 1;
p++;
Standard_Integer i = 0;
if (n == 3) {
- Standard_Integer isub = atoi(a[2]);
+ Standard_Integer isub = Draw::Atoi(a[2]);
TopoDS_Iterator itr(S);
while (itr.More()) {
i++;
if ( i == isub ) {
- sprintf(p,"%d",i);
+ Sprintf(p,"%d",i);
DBRep::Set(newname,itr.Value());
di.AppendElement(newname);
break;
return 1;
}
- Standard_Integer isub = atoi(a[3]);
+ Standard_Integer isub = Draw::Atoi(a[3]);
TopTools_MapOfShape M;
M.Add(S);
TopExp_Explorer ex(S,typ);
if (M.Add(ex.Current())) {
i++;
if ( i == isub ) {
- sprintf(p,"%d",i);
+ Sprintf(p,"%d",i);
DBRep::Set(newname,ex.Current());
di.AppendElement(newname);
break;
}
return 0;
}
-
//=======================================================================
-// subshape
+//function : brepintcs
+//purpose :
//=======================================================================
-
-static Standard_Integer brepintcs(Draw_Interpretor& , Standard_Integer n, const char** a)
+Standard_Integer brepintcs(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
- if (n <= 2) return 1;
- TopoDS_Shape S = DBRep::Get(a[n-1]);
- if (S.IsNull()) return 3;
-
- static BRepIntCurveSurface_Inter theAlg;
- static double tol=1e-6;
- static int nbpi=0;
- static gp_Pnt curp;
+ if (n <= 2)
+ {
+ cout<<"Invalid input arguments. Should be: curve1 [curve2 ...] shape [result] [tol]"<<endl;
+ return 1;
+ }
+ Standard_Integer indshape = 2;
+ TopoDS_Shape S;
+ for( ; indshape <= n-1 ; indshape++)
+ {
+ S = DBRep::Get(a[indshape]);
+ if(!S.IsNull())
+ break;
+ }
+ if (S.IsNull())
+ {
+ cout<<"Invalid input shape"<<endl;
+ return 1;
+ }
- if (n==3) {
+ BRepIntCurveSurface_Inter theAlg;
+ double tol=1e-6;
+ if( indshape < n-1)
+ {
+ Standard_Real preci = atof(a[n-1]);
+ if(preci >= Precision::Confusion())
+ tol = preci;
+ }
+ int nbpi=0;
+ gp_Pnt curp;
+ TopoDS_Compound aComp;
+ BRep_Builder aB;
+ aB.MakeCompound(aComp);
+ if (indshape == 2) {
Handle(Geom_Curve) C= DrawTrSurf::GetCurve(a[1]);
if (C.IsNull()) return 2;
GeomAdaptor_Curve acur(C);
theAlg.Init(S, acur, tol);
+
for (; theAlg.More(); theAlg.Next()) {
curp=theAlg.Pnt();
+ TopoDS_Vertex aV;
+
+ aB.MakeVertex(aV, curp, 0);
+ aB.Add(aComp, aV);
nbpi++;
+ di<<"Point "<<nbpi<<" : "<<curp.X()<<" "<<curp.Y()<<" "<<curp.Z()<<"\n";
char name[64];
char* temp = name; // pour portage WNT
- sprintf(temp, "%s_%d", "brics", nbpi);
+ Sprintf(temp, "%s_%d", "brics", nbpi);
DrawTrSurf::Set(temp, curp);
}
}
else {
- Handle(Geom_Line) hl;
- gp_Lin thel;
- for (Standard_Integer il = 1; il<n ; il++) {
- hl= Handle(Geom_Line)::DownCast(DrawTrSurf::GetCurve(a[il]));
+ theAlg.Load(S,tol );
+ for (Standard_Integer il = 1; il<indshape ; il++)
+ {
+ Handle(Geom_Curve) hl= DrawTrSurf::GetCurve(a[il]);
if (!hl.IsNull()) {
- thel=hl->Lin();
- theAlg.Init(S, thel, tol);
- for (; theAlg.More(); theAlg.Next()) {
- curp=theAlg.Pnt();
- nbpi++;
- char name[64];
- char* temp = name; // pour portage WNT
- sprintf(temp, "%s_%d", "brics", nbpi);
- DrawTrSurf::Set(temp, curp);
- }
+ theAlg.Init(hl);
+ for (; theAlg.More(); theAlg.Next()) {
+ curp=theAlg.Pnt();
+ nbpi++;
+ TopoDS_Vertex aV;
+ aB.MakeVertex(aV, curp, 0);
+ aB.Add(aComp, aV);
+ di<<"Point "<<nbpi<<" : "<<curp.X()<<" "<<curp.Y()<<" "<<curp.Z()<<"\n";
+ char name[64];
+ char* temp = name; // pour portage WNT
+ Sprintf(temp, "%s_%d", "brics", nbpi);
+ DrawTrSurf::Set(temp, curp);
+ }
}
}
}
+ if(!nbpi)
+ di<<"Points of intersections are not found\n";
+ if(indshape < n-1)
+ DBRep::Set(a[n-1], aComp);
//POP pour NT
return 0;
}
-
-
-
-#include <TopoDS.hxx>
-#include <TopAbs.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Dir.hxx>
-#include <Precision.hxx>
-#include <IntCurvesFace_Intersector.hxx>
-#include <ElCLib.hxx>
-#include <BRepFeat_MakeDPrism.hxx>
-#include <BRepTools.hxx>
-#include <TopoDS.hxx>
-//#include <SaveShape.hxx>
-#include <gp_Ax1.hxx>
-#include <TColgp_SequenceOfPnt.hxx>
-#include <LocOpe_CSIntersector.hxx>
-#include <LocOpe_SequenceOfLin.hxx>
-#include <TopAbs_Orientation.hxx>
-#include <LocOpe_PntFace.hxx>
-
-static void SampleEdges (const TopoDS_Shape& theShape, TColgp_SequenceOfPnt& theSeq);
-static TopoDS_Face NextFaceForPrism (const TopoDS_Shape& shape,
- const TopoDS_Shape& basis,
- const gp_Ax1& ax1);
-
//=======================================================================
-// intgo
+//function : MakeBoss
+//purpose :
//=======================================================================
-static Standard_Integer MakeBoss(Draw_Interpretor& , Standard_Integer , const char** a)
+Standard_Integer MakeBoss(Draw_Interpretor& , Standard_Integer , const char** a)
{
-
-
TopoDS_Shape myS = DBRep::Get( a[2] );
TopoDS_Shape myBasis = DBRep::Get( a[3] ) ;
return 0;
}
-
-#include <BRepOffset_MakeOffset.hxx>
-#include <BRepOffset.hxx>
-//#include <SaveShape.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <GeomAbs_JoinType.hxx>
-
//=======================================================================
-// Create a shell
+//function : MakeShell
+//purpose :
//=======================================================================
-static Standard_Integer MakeShell(Draw_Interpretor& , Standard_Integer , const char** a)
+Standard_Integer MakeShell(Draw_Interpretor& , Standard_Integer , const char** a)
{
TopoDS_Shape aShape = DBRep::Get( a[1] );
TopoDS_Face F = TopoDS::Face(InputShape);
// TopoDS_Face F = TopoDS::Face(DBRep::Get( a[2] ));
- Standard_Real Off = -atof( a[3] );
+ Standard_Real Off = -Draw::Atof( a[3] );
BRepOffset_MakeOffset Offset;
}
return 0;
}
-
//=======================================================================
//function : xbounds
//purpose :
Standard_Integer xbounds(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n<2) {
- di << "Usage : " << a[0] << " face" << "\n";
+ di << "Usage : " << a[0] << " face\n";
return 0;
}
//
//
return 0;
}
-
//=======================================================================
-//function : OtherCommands
+//function : xclassify
//purpose :
//=======================================================================
-
-void BRepTest::OtherCommands(Draw_Interpretor& theCommands)
+Standard_Integer xclassify (Draw_Interpretor& aDI, Standard_Integer n, const char** a)
{
- static Standard_Boolean done = Standard_False;
- if (done) return;
- done = Standard_True;
-
- const char* g = "TOPOLOGY other commands";
-
- theCommands.Add("shape",
- "shape name V/E/W/F/Sh/So/CS/C; make a empty shape",__FILE__,emptyshape,g);
-
- theCommands.Add("subshape",
- "subshape name V/E/W/F/Sh/So/CS/C index; get subsshape <index> of given type"
- ,__FILE__,subshape,g);
-
- theCommands.Add("BRepIntCS",
- "Calcul d'intersection entre face et curve : BRepIntCS curve shape"
- ,__FILE__,brepintcs,g);
-
- theCommands.Add("makeboss",
- "create a boss on the shape myS", __FILE__, MakeBoss, g);
-
- theCommands.Add("mksh",
- "create a shell on Shape", __FILE__, MakeShell, g);
-
-
- theCommands.Add("xbounds",
- "xbounds face", __FILE__, xbounds, g);
-
+ if (n < 2) {
+ aDI<<" use xclassify Solid [Tolerance=1.e-7]\n";
+ return 1;
+ }
+
+ TopoDS_Shape aS = DBRep::Get(a[1]);
+ if (aS.IsNull()) {
+ aDI<<" Null Shape is not allowed here\n";
+ return 0;
+ }
+
+ if (aS.ShapeType()!=TopAbs_SOLID) {
+ aDI<< " Shape type must be SOLID\n";
+ return 0;
+ }
+ //
+ Standard_Real aTol=1.e-7;
+ TopAbs_State aState = TopAbs_UNKNOWN;
+ //
+ aTol=1.e-7;
+ if (n==3) {
+ aTol=Draw::Atof(a[2]);
+ }
+ //
+ BRepClass3d_SolidClassifier aSC(aS);
+ aSC.PerformInfinitePoint(aTol);
+
+ aState = aSC.State();
+ PrintState(aDI, aState);
+ //
+ return 0;
+}
+//=======================================================================
+//function : PrintState
+//purpose :
+//=======================================================================
+void PrintState (Draw_Interpretor& aDI,
+ const TopAbs_State& aState)
+{
+ aDI<<"state is: ";
+ switch (aState) {
+ case TopAbs_IN:
+ aDI<<"IN\n";
+ break;
+ case TopAbs_OUT:
+ aDI<<"OUT\n";
+ break;
+ case TopAbs_ON:
+ aDI<<"ON\n";
+ break;
+ case TopAbs_UNKNOWN:
+ default:
+ aDI<<"UNKNOWN\n";
+ break;
+ }
}
-
-
-
//=======================================================================
//function : NextFaceForPrism
//purpose : Search a face from <shape> which intersects with a line of
// direction <ax1> and location a point of <basis>.
//=======================================================================
-static TopoDS_Face NextFaceForPrism (const TopoDS_Shape& shape,
- const TopoDS_Shape& basis,
- const gp_Ax1& ax1)
+TopoDS_Face NextFaceForPrism (const TopoDS_Shape& shape,
+ const TopoDS_Shape& basis,
+ const gp_Ax1& ax1)
{
TopoDS_Face nextFace;
return nextFace;
}
-#include <BRep_Tool.hxx>
//=======================================================================
//function : SampleEdges
//purpose : Sampling of <theShape>.
//design : Collect the vertices and points on the edges
//=======================================================================
-static void SampleEdges (const TopoDS_Shape& theShape, TColgp_SequenceOfPnt& theSeq)
+void SampleEdges (const TopoDS_Shape& theShape, TColgp_SequenceOfPnt& theSeq)
{
theSeq.Clear();