mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
2
src/QANewDBRepNaming/FILES
Executable file
2
src/QANewDBRepNaming/FILES
Executable file
@@ -0,0 +1,2 @@
|
||||
QANewDBRepNaming_PrimitiveCommands.cxx
|
||||
QANewDBRepNaming_FeatureCommands.cxx
|
29
src/QANewDBRepNaming/QANewDBRepNaming.cdl
Executable file
29
src/QANewDBRepNaming/QANewDBRepNaming.cdl
Executable file
@@ -0,0 +1,29 @@
|
||||
-- File: QADBRepNaming.cdl
|
||||
-- Created: Thu Dec 8 10:20:34 1999
|
||||
-- Author: Vladislav ROMASHKO
|
||||
-- <vro@flox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
package QANewDBRepNaming
|
||||
|
||||
---Purpose: To test topological naming
|
||||
|
||||
uses
|
||||
|
||||
Draw,
|
||||
TCollection,
|
||||
TDF,
|
||||
TNaming,
|
||||
TopoDS,
|
||||
gp
|
||||
|
||||
is
|
||||
|
||||
AllCommands (Di : in out Interpretor from Draw);
|
||||
|
||||
PrimitiveCommands (DI : in out Interpretor from Draw);
|
||||
-- OffsetCommands (DI : in out Interpretor from Draw);
|
||||
-- FilletCommands (DI : in out Interpretor from Draw);
|
||||
FeatureCommands (DI : in out Interpretor from Draw);
|
||||
|
||||
end QADBRepNaming;
|
382
src/QANewDBRepNaming/QANewDBRepNaming.cxx
Executable file
382
src/QANewDBRepNaming/QANewDBRepNaming.cxx
Executable file
@@ -0,0 +1,382 @@
|
||||
// File: QANewDBRepNaming.cxx
|
||||
// Created: Wed Dec 8 15:28:05 1999
|
||||
// Author: Vladislav ROMASHKO
|
||||
// <vro@flox.nnov.matra-dtv.fr>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <QANewDBRepNaming.ixx>
|
||||
|
||||
#include <DDF.hxx>
|
||||
|
||||
#include <TDF_Data.hxx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TNaming_Selector.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <ViewerTest.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TNaming_Tool.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <TDF_LabelMap.hxx>
|
||||
#include <TNaming.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <TNaming_NamingTool.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <TNaming_Naming.hxx>
|
||||
#include <TNaming_Name.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <ViewerTest.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
|
||||
#include <TNaming_Builder.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
|
||||
//////#include <Draw_PluginMacro.hxx>
|
||||
//////#include <DBrowser.hxx>
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_CheckNaming(Draw_Interpretor&,Standard_Integer,const char ** a);
|
||||
|
||||
//static Standard_Integer QANewDBRepNaming_myCheckNaming(Draw_Interpretor&,Standard_Integer,const char ** a);
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_CheckSelectShape(Draw_Interpretor&,Standard_Integer,const char ** a);
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_CheckSolve(Draw_Interpretor&,Standard_Integer,const char ** a);
|
||||
|
||||
#include <QADNaming.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : AllCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void QANewDBRepNaming::AllCommands(Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
|
||||
QANewDBRepNaming::PrimitiveCommands (theCommands);
|
||||
QANewDBRepNaming::FeatureCommands (theCommands);
|
||||
|
||||
const char* g = "Check Naming command" ;
|
||||
|
||||
theCommands.Add ("CheckNaming",
|
||||
"CheckNaming Doc TestLabel Full(1/0) (Label/Viewer) [Label] [DX[DY[DZ]]]",
|
||||
__FILE__, QANewDBRepNaming_CheckNaming, g);
|
||||
|
||||
theCommands.Add ("CheckSelectShape",
|
||||
"CheckSelectShape Doc Label SubShapeType",
|
||||
__FILE__, QANewDBRepNaming_CheckSelectShape, g);
|
||||
|
||||
theCommands.Add ("CheckSolve",
|
||||
"CheckSolve Doc Label",
|
||||
__FILE__, QANewDBRepNaming_CheckSolve, g);
|
||||
|
||||
const char* com = "set Draw_NamingData 1";
|
||||
theCommands.Eval(com);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckNaming
|
||||
//purpose : "CheckNaming Doc TestLabel Full(1/0) ShapeFrom(Viewer/Label) [ShapeLabel]"
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_CheckNaming(Draw_Interpretor& di,Standard_Integer nb, const char ** a)
|
||||
{
|
||||
Handle(TDF_Data) DF;
|
||||
if(!DDF::GetDF(a[1], DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, a[2], L);
|
||||
|
||||
// cout<<"SELECT A SHAPE ..."<<endl;
|
||||
Handle(TNaming_NamedShape) amyNS;
|
||||
TopoDS_Shape aSelectedShape;
|
||||
if (!strcmp(a[4],"Label")){
|
||||
Handle(TNaming_NamedShape) atiNS=new TNaming_NamedShape;
|
||||
TDF_Label L2;
|
||||
DDF::AddLabel(DF, a[5], L2);
|
||||
if (!L2.FindAttribute(TNaming_NamedShape::GetID(), atiNS)) {
|
||||
di<<"Error: Cannot find shape on label."<<"\n";
|
||||
return 1;
|
||||
}
|
||||
amyNS = atiNS;
|
||||
aSelectedShape=TNaming_Tool::GetShape(atiNS);
|
||||
}
|
||||
else
|
||||
if (!strcmp(a[4],"Viewer"))
|
||||
aSelectedShape = ViewerTest::PickShape(TopAbs_SHAPE);
|
||||
else{
|
||||
di<<"Error: Incorrect argument #4"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aSelectedShape.IsNull()) {
|
||||
di<<"Nothing has been selected ... try again"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape allSubShapes;
|
||||
TopExp::MapShapes(aSelectedShape, allSubShapes);
|
||||
// cout<<"SELECTION ..."<<endl;
|
||||
// cout << "i = " << allSubShapes.Extent() << endl;
|
||||
Standard_Integer count = 0, j, i;
|
||||
char aDrawName[80] = "Select";
|
||||
char aDrawNumber[10];
|
||||
|
||||
for (i = 1; i <= allSubShapes.Extent(); i++) {
|
||||
const TDF_Label& aSubLabel = L.FindChild(i);
|
||||
const TopoDS_Shape& aSubShape = allSubShapes(i);
|
||||
// cout<<i<<" ";TopAbs::Print(aSubShape.ShapeType(), cout); cout<<" ";
|
||||
|
||||
// DBRep::Set("Selected", aSubShape);
|
||||
|
||||
TNaming_Selector SL (aSubLabel);
|
||||
|
||||
// cout << i << " ";TopAbs::Print(aSelectedShape.ShapeType(), cout); cout<<" ";
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
if(SL.Select(aSubShape, aSelectedShape) == Standard_False) {
|
||||
// if(SL.Select(aSubShape, amyNS->Get()) == Standard_False)
|
||||
di << "Selection error!!!" << "\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(TNaming_NamedShape) aNS;
|
||||
if (!aSubLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
|
||||
di<<"Selection didn't produced a Named Shape ..."<<"\n";
|
||||
return 1;
|
||||
}
|
||||
const TopoDS_Shape& aResultOfSelection = TNaming_Tool::GetShape(aNS);
|
||||
if (!aSubShape.IsSame(aResultOfSelection)) {
|
||||
di<<"Failure of selection"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
} catch (Standard_Failure) {
|
||||
di<<"!!! Solving Failed !!!" << "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ***
|
||||
|
||||
if (!atoi(a[3])) return 0;
|
||||
Standard_Real aDX = 100.0;
|
||||
Standard_Real aDY = 100.0;
|
||||
Standard_Real aDZ = 100.0;
|
||||
if(nb > 6) {
|
||||
aDX = atof(a[6]);
|
||||
if(nb > 7) aDY = atof(a[7]);
|
||||
if(nb > 8) aDZ = atof(a[8]);
|
||||
}
|
||||
// cout<<endl;
|
||||
// cout<<"TRANSLATION ... DX = "<<aDX <<" DY = "<< aDY <<" DZ = " << aDZ <<endl;
|
||||
gp_Vec aTranslation(aDX, aDY, aDZ);
|
||||
gp_Trsf aTrsf;
|
||||
aTrsf.SetTranslation(aTranslation);
|
||||
TopLoc_Location aLoc(aTrsf);
|
||||
const TDF_Label& anOriginLabel = TNaming_Tool::NamedShape(aSelectedShape, L)->Label();
|
||||
if (anOriginLabel.IsNull()) di<<"Origin is null"<<"\n";
|
||||
// TNaming::Displace(anOriginLabel, aLoc);
|
||||
// cout<<"Translate label ";anOriginLabel.EntryDump(cout);cout<<endl;
|
||||
TDF_ChildIterator Labelitr(L.Root(), Standard_False);
|
||||
for (; Labelitr.More(); Labelitr.Next()) {
|
||||
// if (Labelitr.Value() == anOriginLabel) break;
|
||||
// cout<<"Translate label ";Labelitr.Value().EntryDump(cout);cout<<endl;
|
||||
TNaming::Displace(Labelitr.Value(), aLoc);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
Handle(TNaming_NamedShape) aNS;
|
||||
if (!anOriginLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return 1;
|
||||
aSelectedShape = TNaming_Tool::GetShape(aNS);
|
||||
}
|
||||
TopTools_IndexedMapOfShape allTranslatedSubShapes;
|
||||
TopExp::MapShapes(aSelectedShape, allTranslatedSubShapes);
|
||||
|
||||
Standard_Boolean isFailured = Standard_False;
|
||||
|
||||
// cout<<"SOLVING ..."<<endl;
|
||||
TDF_LabelMap scope;
|
||||
TDF_ChildIterator itr(L.Root(), Standard_True);
|
||||
i = 1;
|
||||
char aNotSolved[1000];
|
||||
aNotSolved[0]=0;
|
||||
for (itr.Initialize(L, Standard_False); itr.More(); itr.Next(), i++) {
|
||||
Handle(TNaming_NamedShape) aNS;
|
||||
if (!itr.Value().FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
|
||||
// cout<<"Wrong selection ..."<<endl;
|
||||
return 1;
|
||||
}
|
||||
const TopAbs_ShapeEnum TypeOfNaming = aNS->Get().ShapeType();
|
||||
// cout<<i<<" ";TopAbs::Print(TypeOfNaming, cout); cout<<" ";
|
||||
// DBRep::Set("Solved", aNS->Get());
|
||||
TNaming_Selector SLSolving(itr.Value());
|
||||
if (!SLSolving.Solve(scope)) {
|
||||
isFailured = Standard_True;
|
||||
sprintf(aNotSolved,"%s %d",aNotSolved,i);
|
||||
continue;
|
||||
}
|
||||
const Handle(TNaming_NamedShape)& aResultOfSolving = SLSolving.NamedShape();
|
||||
if (aResultOfSolving.IsNull()) {
|
||||
// cout<<"Failure of Solving: it didn't produced a shape!"<<endl;
|
||||
// return 1;
|
||||
isFailured = Standard_True;
|
||||
sprintf(aNotSolved,"%s %d",aNotSolved,i);
|
||||
// break;
|
||||
continue;
|
||||
}
|
||||
TopoDS_Shape aRes;
|
||||
/* if (TypeOfNaming == TopAbs_WIRE || TypeOfNaming == TopAbs_SHELL) {
|
||||
TopoDS_Iterator itr(aResultOfSolving->Get());
|
||||
TopoDS_Shape aSubShape;
|
||||
if (itr.More()) aSubShape = itr.Value();
|
||||
TDF_LabelMap one,two;
|
||||
TNaming_Tool::FindShape(one, two, aResultOfSolving, aRes);
|
||||
if (aRes.IsNull()) {
|
||||
// cout<<"Failure of TNaming_Tool::FindShape()!"<<endl;
|
||||
// return 1;
|
||||
sprintf(aNotSolved,"%s %d",aNotSolved,i);
|
||||
isFailured = Standard_True;
|
||||
// break;
|
||||
continue;
|
||||
}
|
||||
} else */
|
||||
aRes = aResultOfSolving->Get();
|
||||
if (!aRes.IsSame(allTranslatedSubShapes(i))) {
|
||||
// cout<<"Failure of solving of "<<i<<"-th sub label"<<endl;
|
||||
// TNaming::DumpShape(aRes);
|
||||
// TNaming::DumpShape(allTranslatedSubShapes(i));
|
||||
// return 1;
|
||||
gp_XYZ aCoord1(0,0,0),aCoord2(0,0,0);
|
||||
TopTools_MapOfShape aVertices;
|
||||
if (aRes.ShapeType()==TopAbs_VERTEX) aCoord1=BRep_Tool::Pnt(TopoDS::Vertex(aRes)).Coord(); else {
|
||||
TopExp_Explorer anExp(aRes,TopAbs_VERTEX);
|
||||
for(;anExp.More();anExp.Next()) {
|
||||
// mpv: that's only stub for the seam edges bug
|
||||
if (aVertices.Contains(anExp.Current())) continue;
|
||||
aVertices.Add(anExp.Current());
|
||||
|
||||
aCoord1.Add(BRep_Tool::Pnt(TopoDS::Vertex(anExp.Current())).Coord());
|
||||
// gp_XYZ a = BRep_Tool::Pnt(TopoDS::Vertex(anExp.Current())).Coord();
|
||||
// cout<<"a1 ("<<a.X()<<" "<<a.Y()<<" "<<a.Z()<<")"<<endl;
|
||||
}
|
||||
}
|
||||
if (allTranslatedSubShapes(i).ShapeType()==TopAbs_VERTEX)
|
||||
aCoord2=BRep_Tool::Pnt(TopoDS::Vertex(allTranslatedSubShapes(i))).Coord();
|
||||
else {
|
||||
aVertices.Clear();
|
||||
TopExp_Explorer anExp(allTranslatedSubShapes(i),TopAbs_VERTEX);
|
||||
for(;anExp.More();anExp.Next()) {
|
||||
// mpv: that's only stub for the seam edges bug
|
||||
if (aVertices.Contains(anExp.Current())) continue;
|
||||
aVertices.Add(anExp.Current());
|
||||
|
||||
aCoord2.Add(BRep_Tool::Pnt(TopoDS::Vertex(anExp.Current())).Coord());
|
||||
// gp_XYZ a = BRep_Tool::Pnt(TopoDS::Vertex(anExp.Current())).Coord();
|
||||
// cout<<"a1 ("<<a.X()<<" "<<a.Y()<<" "<<a.Z()<<")"<<endl;
|
||||
}
|
||||
}
|
||||
if (!aCoord1.IsEqual(aCoord2,Precision::Confusion()) || aRes.ShapeType() != allTranslatedSubShapes(i).ShapeType()) {
|
||||
sprintf(aNotSolved,"%s %d",aNotSolved,i);
|
||||
isFailured = Standard_True;
|
||||
// break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// cout<<endl;
|
||||
}
|
||||
|
||||
if (isFailured) {
|
||||
di<<aNotSolved;
|
||||
//mpv: let's no catch returns 1 in tclsh return 1;
|
||||
}
|
||||
// cout<<"Good!"<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckSelectShape
|
||||
//purpose : "CheckSelectShape Doc Label SubShapeType"
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_CheckSelectShape(Draw_Interpretor& di, Standard_Integer nb, const char ** a)
|
||||
{
|
||||
Handle(TDF_Data) DF;
|
||||
if(!DDF::GetDF(a[1], DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, a[2], L);
|
||||
|
||||
di<<"SELECT A SUB-SHAPE ..."<<"\n";
|
||||
TopoDS_Shape aSelectedShape = ViewerTest::PickShape((TopAbs_ShapeEnum)atoi(a[3]));
|
||||
if (aSelectedShape.IsNull()) {
|
||||
di<<"QANewDBRepNaming_CheckSelectShape(): Nothing is selected ..."<<"\n";
|
||||
return 1;
|
||||
}
|
||||
// Find the context:
|
||||
TopoDS_Shape aContext;
|
||||
TDF_ChildIterator itr(L.Root());
|
||||
Standard_Boolean contextFound = Standard_False;
|
||||
for (; itr.More(); itr.Next()) {
|
||||
Handle(TNaming_NamedShape) NS;
|
||||
if (itr.Value().FindAttribute(TNaming_NamedShape::GetID(), NS)) {
|
||||
aContext = NS->Get();
|
||||
TopExp_Explorer expl(aContext, (TopAbs_ShapeEnum)atoi(a[3]));
|
||||
for (; expl.More(); expl.Next()) {
|
||||
if (expl.Current().IsSame(aSelectedShape)) {
|
||||
di<<"QANewDBRepNaming_CheckSelectShape(): The context is found at ";
|
||||
|
||||
//NS->Label().EntryDump(cout);
|
||||
Standard_SStream aSStream;
|
||||
NS->Label().EntryDump(aSStream);
|
||||
di << aSStream;
|
||||
di<<"\n";
|
||||
contextFound = Standard_True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (contextFound) break;
|
||||
}
|
||||
aContext = TopoDS_Shape();
|
||||
}
|
||||
// Selection:
|
||||
TNaming_Selector aSelector(L);
|
||||
if (aContext.IsNull()) {
|
||||
aSelector.Select(aSelectedShape);
|
||||
} else {
|
||||
aSelector.Select(aSelectedShape, aContext);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckSelectShape
|
||||
//purpose : "CheckSelectShape Doc Label SubShapeType"
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_CheckSolve(Draw_Interpretor&,Standard_Integer nb, const char ** a)
|
||||
{
|
||||
Handle(TDF_Data) DF;
|
||||
if(!DDF::GetDF(a[1], DF)) return 1;
|
||||
TDF_Label L;
|
||||
DDF::AddLabel(DF, a[2], L);
|
||||
Handle(TNaming_NamedShape) aNS;
|
||||
L.FindAttribute(TNaming_NamedShape::GetID(), aNS);
|
||||
|
||||
return 0;
|
||||
}
|
404
src/QANewDBRepNaming/QANewDBRepNaming_FeatureCommands.cxx
Executable file
404
src/QANewDBRepNaming/QANewDBRepNaming_FeatureCommands.cxx
Executable file
@@ -0,0 +1,404 @@
|
||||
// File: QANewDBRepNaming_FeatureCommands.cxx
|
||||
// Created: Thu Dec 23 11:53:39 1999
|
||||
// Author: Vladislav ROMASHKO
|
||||
// <vro@flox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <QANewDBRepNaming.ixx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <QANewDBRepNaming.hxx>
|
||||
#include <DBRep.hxx>
|
||||
|
||||
#include <DDocStd.hxx>
|
||||
|
||||
#include <DDF.hxx>
|
||||
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TDataXtd_Geometry.hxx>
|
||||
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <TNaming_Tool.hxx>
|
||||
#include <TNaming_Builder.hxx>
|
||||
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <BRepAlgoAPI_Fuse.hxx>
|
||||
#include <BRepAlgoAPI_Common.hxx>
|
||||
#include <BRepAlgoAPI_Cut.hxx>
|
||||
#include <BRepAlgoAPI_Section.hxx>
|
||||
|
||||
#include <QANewModTopOpe_Limitation.hxx>
|
||||
#include <QANewModTopOpe_Intersection.hxx>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
|
||||
#include <BRepLib.hxx>
|
||||
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
|
||||
#include <GCE2d_MakeLine.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
|
||||
#include <QANewBRepNaming_Fuse.hxx>
|
||||
#include <QANewBRepNaming_Cut.hxx>
|
||||
#include <QANewBRepNaming_Common.hxx>
|
||||
#include <QANewBRepNaming_Intersection.hxx>
|
||||
#include <QANewBRepNaming_Limitation.hxx>
|
||||
|
||||
#include <BRepTools.hxx>
|
||||
#include <TDF_LabelMap.hxx>
|
||||
#include <QANewModTopOpe_Glue.hxx>
|
||||
#include <QANewBRepNaming_Gluing.hxx>
|
||||
|
||||
//==============================================================
|
||||
//function : QANewDBRepNaming_NameBooleanOperationFeat
|
||||
//purpose : NameBooleanOperationFeat Doc Label Op = 1(Fuse), 2(Cut), 3(Common), 4(Inserction) 5(Limitation) DrawShape1 DrawShape2 [Forward = 0 || Reversed = 1 || BothSides = 2]
|
||||
//==============================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameBooleanOperationFeat (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb != 6 || nb != 7) {
|
||||
di << "QANewDBRepNaming_NameBooleanOperationFeat : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) D;
|
||||
if (!DDocStd::GetDocument(arg[1],D)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[2], L)) return 1;
|
||||
|
||||
const Standard_Integer Op = (Standard_Integer)atoi(arg[3]);
|
||||
const TopoDS_Shape& S1 = DBRep::Get(arg[4]);
|
||||
const TopoDS_Shape& S2 = DBRep::Get(arg[5]);
|
||||
|
||||
Standard_Integer Orientation = 0;
|
||||
if (nb == 7) Orientation = atoi(arg[6]);
|
||||
|
||||
switch (Op) {
|
||||
case 1: {
|
||||
di << "BRepAlgoAPI_Fuse" << "\n";
|
||||
BRepAlgoAPI_Fuse mkFuse(S1, S2);
|
||||
|
||||
assert(mkFuse.IsDone());
|
||||
QANewBRepNaming_Fuse nameBool(L);
|
||||
nameBool.Load(mkFuse);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
di << "BRepAlgoAPI_Cut" << "\n";
|
||||
BRepAlgoAPI_Cut mkCut(S1, S2);
|
||||
|
||||
assert(mkCut.IsDone());
|
||||
QANewBRepNaming_Cut nameBool(L);
|
||||
nameBool.Load(mkCut);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
di << "BRepAlgoAPI_Common" << "\n";
|
||||
BRepAlgoAPI_Common mkCommon(S1, S2);
|
||||
|
||||
assert(mkCommon.IsDone());
|
||||
QANewBRepNaming_Common nameBool(L);
|
||||
nameBool.Load(mkCommon);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
QANewModTopOpe_Intersection mkSection(S1, S2);
|
||||
assert(mkSection.IsDone());
|
||||
QANewBRepNaming_Intersection nameBool(L);
|
||||
nameBool.Load(mkSection);
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
QANewModTopOpe_Limitation mkLimit(S1, S2);
|
||||
const QANewModTopOpe_ModeOfLimitation aMode = (QANewModTopOpe_ModeOfLimitation) Orientation;
|
||||
mkLimit.SetMode(aMode);
|
||||
mkLimit.Cut();
|
||||
// if (Orientation = 0) mkLimit.CutForward();
|
||||
// else if (Orientation = 1) mkLimit.CutReversed();
|
||||
// else if (Orientation = 2) mkLimit.CutBothSides();
|
||||
assert(mkLimit.IsDone());
|
||||
QANewBRepNaming_Limitation nameBool(L);
|
||||
nameBool.Load(mkLimit);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
di<<"QANewDBRepNaming_NameBooleanOperation The type of operation must be 1 - fuse, 2 - cut or 3 - common"<<"\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
//function : QANewDBRepNaming_NameFuse
|
||||
//purpose : NameFuse Doc Label DrawShape1 DrawShape2
|
||||
//==============================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameFuse (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb != 5) {
|
||||
di << "QANewDBRepNaming_NameFuse : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) D;
|
||||
if (!DDocStd::GetDocument(arg[1],D)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[2], L)) return 1;
|
||||
const TopoDS_Shape& S1 = DBRep::Get(arg[3]);
|
||||
const TopoDS_Shape& S2 = DBRep::Get(arg[4]);
|
||||
QANewBRepNaming_Fuse nameBool(L);
|
||||
|
||||
di << "BRepAlgoAPI_Fuse" << "\n";
|
||||
BRepAlgoAPI_Fuse mkFuse(S1, S2);
|
||||
|
||||
assert(mkFuse.IsDone());
|
||||
nameBool.Load(mkFuse);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
//function : QANewDBRepNaming_NameCut
|
||||
//purpose : NameCut Doc Label DrawShape1 DrawShape2
|
||||
//==============================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameCut (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb != 5) {
|
||||
di << "QANewDBRepNaming_NameCut : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) D;
|
||||
if (!DDocStd::GetDocument(arg[1],D)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[2], L)) return 1;
|
||||
const TopoDS_Shape& S1 = DBRep::Get(arg[3]);
|
||||
const TopoDS_Shape& S2 = DBRep::Get(arg[4]);
|
||||
// DBRep::Set("aShape", S1);
|
||||
QANewBRepNaming_Cut nameBool(L);
|
||||
// DBRep::Set("S1", S1);
|
||||
// DBRep::Set("S2", S2);
|
||||
|
||||
di << "BRepAlgoAPI_Cut" << "\n";
|
||||
BRepAlgoAPI_Cut mkCut(S1, S2);
|
||||
|
||||
// DBRep::Set("CutRes", mkCut.Shape());
|
||||
// DBRep::Set("Shape1", mkCut.Shape1());
|
||||
// DBRep::Set("Shape2", mkCut.Shape2());
|
||||
// BRepTools::Write(mkCut.Shape1(), "/dn04/OS/SAMTECH/env/S1.brep");
|
||||
assert(mkCut.IsDone());
|
||||
nameBool.Load(mkCut);
|
||||
// BRepTools::Write(mkCut.Shape1(), "/dn04/OS/SAMTECH/env/S2.brep");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
//function : QANewDBRepNaming_NameCommon
|
||||
//purpose : NameCommon Doc Label DrawShape1 DrawShape2
|
||||
//==============================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameCommon (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb != 5) {
|
||||
di << "QANewDBRepNaming_NameCommon : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) D;
|
||||
if (!DDocStd::GetDocument(arg[1],D)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[2], L)) return 1;
|
||||
const TopoDS_Shape& S1 = DBRep::Get(arg[3]);
|
||||
const TopoDS_Shape& S2 = DBRep::Get(arg[4]);
|
||||
QANewBRepNaming_Common nameBool(L);
|
||||
|
||||
di << "BRepAlgoAPI_Common" << "\n";
|
||||
BRepAlgoAPI_Common mkCommon(S1, S2);
|
||||
|
||||
assert(mkCommon.IsDone());
|
||||
nameBool.Load(mkCommon);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
//function : QANewDBRepNaming_NameIntersection
|
||||
//purpose : NameIntersection Doc Label DrawShape1 DrawShape2
|
||||
//==============================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameIntersection (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb != 5) {
|
||||
di << "QANewDBRepNaming_NameIntersection : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) D;
|
||||
if (!DDocStd::GetDocument(arg[1],D)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[2], L)) return 1;
|
||||
const TopoDS_Shape& S1 = DBRep::Get(arg[3]);
|
||||
const TopoDS_Shape& S2 = DBRep::Get(arg[4]);
|
||||
QANewBRepNaming_Intersection nameBool(L);
|
||||
QANewModTopOpe_Intersection mkIntersection(S1, S2);
|
||||
assert(mkIntersection.IsDone());
|
||||
nameBool.Load(mkIntersection);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
//function : QANewDBRepNaming_NameLimit
|
||||
//purpose : NameLimit Doc Label DrawShape1 DrawShape2 [Orientation (Forward - 0, Reversed - 1 or BothSise - 2)]
|
||||
//==============================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameLimit (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb != 5 && nb != 6) {
|
||||
di << "QANewDBRepNaming_NameLimit : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) D;
|
||||
if (!DDocStd::GetDocument(arg[1],D)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[2], L)) return 1;
|
||||
const TopoDS_Shape& S1 = DBRep::Get(arg[3]);
|
||||
const TopoDS_Shape& S2 = DBRep::Get(arg[4]);
|
||||
Standard_Integer Orientation = 0;
|
||||
if (nb == 6) {
|
||||
Orientation = atoi(arg[5]);
|
||||
}
|
||||
QANewBRepNaming_Limitation nameBool(L);
|
||||
const QANewModTopOpe_ModeOfLimitation aMode = (QANewModTopOpe_ModeOfLimitation) Orientation;
|
||||
QANewModTopOpe_Limitation mkLimit(S1, S2, aMode);
|
||||
mkLimit.Cut();
|
||||
// if (Orientation == 0) mkLimit.CutForward();
|
||||
// else if (Orientation == 1) mkLimit.CutReversed();
|
||||
// else if (Orientation == 2) mkLimit.CutBothSides();
|
||||
assert(mkLimit.IsDone());
|
||||
nameBool.Load(mkLimit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
//function : QANewDBRepNaming_NameGlue
|
||||
//purpose : NameGlue Doc Label ObjectLabel ToolLabel [auxiliary valid labels]
|
||||
//==============================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameGlue (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb < 5) {
|
||||
di << "QANewDBRepNaming_NameGlue : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) D;
|
||||
if (!DDocStd::GetDocument(arg[1],D)) return 1;
|
||||
TDF_Label L,OL,TL;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[2], L)) return 1;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[3], OL)) return 1;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[4], TL)) return 1;
|
||||
TDF_LabelMap aLog;
|
||||
for(Standard_Integer i=5;i<nb;i++) {
|
||||
TDF_Label aLabel;
|
||||
if (!DDF::AddLabel(D->GetData(), arg[i], aLabel)) return 1;
|
||||
aLog.Add(aLabel);
|
||||
}
|
||||
Handle(TNaming_NamedShape) anObjectNS,aToolNS;
|
||||
if (!OL.FindAttribute(TNaming_NamedShape::GetID(),anObjectNS)) return 1;
|
||||
if (!TL.FindAttribute(TNaming_NamedShape::GetID(),aToolNS)) return 1;
|
||||
|
||||
QANewModTopOpe_Glue aMKGlue(TNaming_Tool::CurrentShape(anObjectNS),TNaming_Tool::CurrentShape(aToolNS));
|
||||
if (!aMKGlue.IsDone()) return 1;
|
||||
aMKGlue.Build();
|
||||
if (!aMKGlue.IsDone()) return 1;
|
||||
|
||||
QANewBRepNaming_Gluing aGlue(L);
|
||||
aGlue.SetContext(TNaming_Tool::CurrentShape(anObjectNS),TNaming_Tool::CurrentShape(aToolNS));
|
||||
aGlue.SetLog(aLog);
|
||||
aGlue.Load(aMKGlue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FeatureCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void QANewDBRepNaming::FeatureCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
const char* g = "Naming algorithm commands for features" ;
|
||||
|
||||
|
||||
theCommands.Add ("NameBooleanOperationFeat",
|
||||
"NameBooleanOperationFeat Doc Label Operation(1, 2, 3, 4 or 5) DrawShape1 DrawShape2 [Forward = 0 || Reversed = 1 || BothSides = 2] ",
|
||||
__FILE__, QANewDBRepNaming_NameBooleanOperationFeat, g);
|
||||
|
||||
theCommands.Add ("NameFuse",
|
||||
"NameFuse Doc Label DrawShape1 DrawShape2",
|
||||
__FILE__, QANewDBRepNaming_NameFuse, g);
|
||||
|
||||
theCommands.Add ("NameCut",
|
||||
"NameCut Doc Label DrawShape1 DrawShape2",
|
||||
__FILE__, QANewDBRepNaming_NameCut, g);
|
||||
|
||||
theCommands.Add ("NameCommon",
|
||||
"NameCommon Doc Label DrawShape1 DrawShape2",
|
||||
__FILE__, QANewDBRepNaming_NameCommon, g);
|
||||
|
||||
theCommands.Add ("NameIntersection",
|
||||
"NameIntersection Doc Label DrawShape1 DrawShape2",
|
||||
__FILE__, QANewDBRepNaming_NameIntersection, g);
|
||||
|
||||
theCommands.Add ("NameLimit",
|
||||
"NameLimit Doc Label DrawShape1 DrawShape2 [Orientation (Forward - 0, Reversed - 1 or BothSise - 2)]",
|
||||
__FILE__, QANewDBRepNaming_NameLimit, g);
|
||||
|
||||
theCommands.Add ("NameGlue",
|
||||
"NameGlue Doc Label ObjectLabel ToolLabel [auxiliary valid labels]",
|
||||
__FILE__, QANewDBRepNaming_NameGlue, g);
|
||||
|
||||
}
|
460
src/QANewDBRepNaming/QANewDBRepNaming_PrimitiveCommands.cxx
Executable file
460
src/QANewDBRepNaming/QANewDBRepNaming_PrimitiveCommands.cxx
Executable file
@@ -0,0 +1,460 @@
|
||||
// File: QANewDBRepNaming_PrimitiveCommands.cxx
|
||||
// Created: Thu Dec 23 11:25:57 1999
|
||||
// Author: Vladislav ROMASHKO
|
||||
// <vro@flox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <QANewDBRepNaming.ixx>
|
||||
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
|
||||
#include <DBRep.hxx>
|
||||
|
||||
#include <DDF.hxx>
|
||||
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <TNaming_Tool.hxx>
|
||||
#include <TNaming_Builder.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
|
||||
#include <QANewBRepNaming_Box.hxx>
|
||||
#include <QANewBRepNaming_Cylinder.hxx>
|
||||
#include <QANewBRepNaming_Sphere.hxx>
|
||||
#include <QANewBRepNaming_Prism.hxx>
|
||||
#include <QANewBRepNaming_Revol.hxx>
|
||||
#include <QANewBRepNaming_ImportShape.hxx>
|
||||
|
||||
#include <BRepPrimAPI_MakeCylinder.hxx>
|
||||
#include <BRepPrimAPI_MakeSphere.hxx>
|
||||
|
||||
#include <BRepPrimAPI_MakePrism.hxx>
|
||||
#include <BRepPrimAPI_MakeRevol.hxx>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
|
||||
#include <TDataXtd_Geometry.hxx>
|
||||
|
||||
#include <TopExp.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <assert.h>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
#include <QADNaming.hxx>
|
||||
#include <BRepFilletAPI_MakeFillet.hxx>
|
||||
#include <QANewBRepNaming_Fillet.hxx>
|
||||
#include <BRepFilletAPI_MakeChamfer.hxx>
|
||||
#include <QANewBRepNaming_Chamfer.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : QANewDBRepNaming_NameBox
|
||||
//purpose : NameCylinder Doc Label dx dy dz
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameBox (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if(nb == 6) {
|
||||
TDF_Label L;
|
||||
if (!QADNaming::Entry(arg, L)) return 1;
|
||||
|
||||
BRepPrimAPI_MakeBox mkBox(atof(arg[3]), atof(arg[4]), atof(arg[5]));
|
||||
mkBox.Build();
|
||||
|
||||
if(!mkBox.IsDone()) {
|
||||
di << "The box hasn't been built" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QANewBRepNaming_Box nameBox(L);
|
||||
nameBox.Load(mkBox,QANewBRepNaming_SOLID);
|
||||
return 0;
|
||||
}
|
||||
di << "QANewDBRepNaming_NameBox : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : QANewDBRepNaming_NameCylinder
|
||||
//purpose : NameCylinder Doc Label R H Angle [ShapeType(Shell/Solid)]
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameCylinder (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if(nb == 6 || nb == 7) {
|
||||
TDF_Label L;
|
||||
if (!QADNaming::Entry(arg, L)) return 1;
|
||||
|
||||
BRepPrimAPI_MakeCylinder mkCylinder(atof(arg[3]), atof(arg[4]));
|
||||
if (atof(arg[5]) != 0.) {
|
||||
// for Mandrake-10 - mkv,02.06.06 - mkCylinder = BRepPrimAPI_MakeCylinder(atof(arg[3]), atof(arg[4]), atof(arg[5]));
|
||||
BRepPrimAPI_MakeCylinder MakeCylinder(atof(arg[3]), atof(arg[4]), atof(arg[5]));
|
||||
mkCylinder = MakeCylinder;
|
||||
}
|
||||
mkCylinder.Build();
|
||||
|
||||
if(!mkCylinder.IsDone()) {
|
||||
di << "The cylinder hasn't been built" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QANewBRepNaming_Cylinder nameCylinder(L);
|
||||
if (nb == 6) nameCylinder.Load(mkCylinder, QANewBRepNaming_SHELL);
|
||||
else if (atoi(arg[6]) == 0) nameCylinder.Load(mkCylinder, QANewBRepNaming_SHELL);
|
||||
else nameCylinder.Load(mkCylinder, QANewBRepNaming_SOLID);
|
||||
|
||||
return 0;
|
||||
}
|
||||
di << "QANewDBRepNaming_NameCylinder : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : QANewDBRepNaming_NameSphere
|
||||
//purpose : NameSphere Doc Label R X Y Z Angle1 Angle2 Angle3 [ShapeType(Shell/Solid)]
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameSphere (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
TDF_Label L;
|
||||
if (!QADNaming::Entry(arg, L)) return 1;
|
||||
Standard_Real R = atof(arg[3]);
|
||||
Standard_Real X = atof(arg[4]);
|
||||
Standard_Real Y = atof(arg[5]);
|
||||
Standard_Real Z = atof(arg[6]);
|
||||
Standard_Real DX = atof(arg[7]);
|
||||
Standard_Real DY = atof(arg[8]);
|
||||
Standard_Real DZ = atof(arg[9]);
|
||||
QANewBRepNaming_TypeOfPrimitive3D type = QANewBRepNaming_SHELL;
|
||||
if (nb == 11) type = (QANewBRepNaming_TypeOfPrimitive3D) atoi(arg[10]);
|
||||
|
||||
QANewBRepNaming_Sphere nameSphere(L);
|
||||
BRepPrimAPI_MakeSphere mkSphere(R);
|
||||
if (DX == 0 && DY == 0 && DZ == 0) {
|
||||
// for Mandrake-10 - mkv,02.06.06 - mkSphere = BRepPrimAPI_MakeSphere(gp_Pnt(X, Y, Z), R);
|
||||
BRepPrimAPI_MakeSphere MakeSphere1(gp_Pnt(X, Y, Z), R);
|
||||
mkSphere = MakeSphere1;
|
||||
} else {
|
||||
// for Mandrake-10 - mkv,02.06.06 - mkSphere = BRepPrimAPI_MakeSphere(gp_Pnt(X, Y, Z), R, DX, DY, DZ);
|
||||
BRepPrimAPI_MakeSphere MakeSphere2(gp_Pnt(X, Y, Z), R, DX, DY, DZ);
|
||||
mkSphere = MakeSphere2;
|
||||
}
|
||||
mkSphere.Build();
|
||||
if(!mkSphere.IsDone()) {
|
||||
di << "The sphere hasn't been built" << "\n";
|
||||
return 1;
|
||||
}
|
||||
nameSphere.Load(mkSphere, type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//function : QANewDBRepNaming_NamePrism
|
||||
//purpose : NamePrism Doc Label BasisLabel H Direction(X Y Z) [Inf/Semi-Inf]
|
||||
//===========================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NamePrism (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb < 5 || nb > 9 || nb == 6 || nb == 7) {
|
||||
di << "QANewDBRepNaming_NamePrism : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TDF_Label L,BL;
|
||||
if (!QADNaming::Entry(arg, L)) return 1;
|
||||
if (!DDF::AddLabel(L.Data(), arg[3], BL)) return 1;
|
||||
|
||||
Standard_Real H = atof(arg[4]);
|
||||
|
||||
Handle(TNaming_NamedShape) BasisNS;
|
||||
if (!BL.FindAttribute(TNaming_NamedShape::GetID(), BasisNS)) return 1;
|
||||
const TopoDS_Shape& Basis = TNaming_Tool::CurrentShape(BasisNS);
|
||||
|
||||
QANewBRepNaming_Prism namePrism(L);
|
||||
|
||||
if (nb >= 8) {
|
||||
gp_Dir Direction(atof(arg[5]), atof(arg[6]), atof(arg[7]));
|
||||
gp_Vec Vector(Direction);
|
||||
Vector.Normalize();
|
||||
Vector *= H;
|
||||
|
||||
if (nb == 8) {
|
||||
BRepPrimAPI_MakePrism mkPrism(Basis, Vector);
|
||||
mkPrism.Build();
|
||||
|
||||
if(!mkPrism.IsDone()) {
|
||||
di << "The prism hasn't been built" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
namePrism.Load(mkPrism, Basis);
|
||||
}
|
||||
else if (nb == 9) {
|
||||
BRepPrimAPI_MakePrism mkPrism(Basis, Direction, (Standard_Boolean)atoi(arg[8]));
|
||||
mkPrism.Build();
|
||||
|
||||
if(!mkPrism.IsDone()) {
|
||||
di << "The prism hasn't been built" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
namePrism.Load(mkPrism, Basis);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//function : QANewDBRepNaming_NameRevol
|
||||
//purpose : NameRevol Doc Label BasisLabel AxisLabel Angle
|
||||
//===========================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameRevol (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb < 5 || nb > 6) {
|
||||
di << "QANewDBRepNaming_NameRevol : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TDF_Label L, BL, AL;
|
||||
if (!QADNaming::Entry(arg, L)) return 1;
|
||||
|
||||
if (!DDF::AddLabel(L.Data(), arg[3], BL)) return 1;
|
||||
if (!DDF::AddLabel(L.Data(), arg[4], AL)) return 1;
|
||||
|
||||
Handle(TNaming_NamedShape) BasisNS, AxisNS;
|
||||
if (!BL.FindAttribute(TNaming_NamedShape::GetID(), BasisNS)) return 1;
|
||||
if (!AL.FindAttribute(TNaming_NamedShape::GetID(), AxisNS)) return 1;
|
||||
const TopoDS_Shape& Basis = TNaming_Tool::CurrentShape(BasisNS);
|
||||
const TopoDS_Shape& Axis = TNaming_Tool::CurrentShape(AxisNS);
|
||||
|
||||
if (Axis.ShapeType() != TopAbs_EDGE) return 1;
|
||||
|
||||
gp_Ax1 axis;
|
||||
TopoDS_Vertex fV = TopExp::FirstVertex(TopoDS::Edge(Axis), Standard_True);
|
||||
TopoDS_Vertex lV = TopExp::LastVertex(TopoDS::Edge(Axis), Standard_True);
|
||||
if (!fV.IsNull() || !lV.IsNull()) {
|
||||
gp_Vec alocalV(BRep_Tool::Pnt(fV),BRep_Tool::Pnt(lV));
|
||||
gp_Dir Direction(alocalV);
|
||||
// gp_Dir Direction(gp_Vec(BRep_Tool::Pnt(fV), BRep_Tool::Pnt(lV)));
|
||||
axis.SetLocation(BRep_Tool::Pnt(fV));
|
||||
axis.SetDirection(Direction);
|
||||
}
|
||||
else {
|
||||
TDataXtd_Geometry::Axis(AL, axis);
|
||||
}
|
||||
|
||||
QANewBRepNaming_Revol nameRevol(L);
|
||||
|
||||
if(nb == 5) {
|
||||
|
||||
BRepPrimAPI_MakeRevol mkRevol(Basis, axis);
|
||||
mkRevol.Build();
|
||||
|
||||
if(!mkRevol.IsDone()) {
|
||||
di << "The revol hasn't been built" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
nameRevol.Load(mkRevol, Basis);
|
||||
}
|
||||
else if (nb == 6) {
|
||||
|
||||
Standard_Real Angle = atof(arg[5]);
|
||||
|
||||
BRepPrimAPI_MakeRevol mkRevol(Basis, axis, Angle);
|
||||
mkRevol.Build();
|
||||
|
||||
if(!mkRevol.IsDone()) {
|
||||
di << "The revol hasn't been built" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
nameRevol.Load(mkRevol, Basis);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//function : QANewDBRepNaming_NameFillet
|
||||
//purpose : NameFillet Doc Label SourceShapeLabel PathLabel Radius
|
||||
//===========================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameFillet (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb != 6) {
|
||||
di << "QANewDBRepNaming_NameFillet : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TDF_Label L, BL, PL;
|
||||
if (!QADNaming::Entry(arg, L)) return 1;
|
||||
|
||||
if (!DDF::AddLabel(L.Data(), arg[3], BL)) return 1;
|
||||
if (!DDF::AddLabel(L.Data(), arg[4], PL)) return 1;
|
||||
Standard_Real aRadius = atoi(arg[5]);
|
||||
Handle(TNaming_NamedShape) BasisNS, PathNS;
|
||||
if (!BL.FindAttribute(TNaming_NamedShape::GetID(), BasisNS)) return 1;
|
||||
if (!PL.FindAttribute(TNaming_NamedShape::GetID(), PathNS)) return 1;
|
||||
const TopoDS_Shape& Basis = TNaming_Tool::CurrentShape(BasisNS);
|
||||
const TopoDS_Shape& Path = TNaming_Tool::CurrentShape(PathNS);
|
||||
|
||||
BRepFilletAPI_MakeFillet aFillet(Basis);
|
||||
TopExp_Explorer anExp(Path,TopAbs_EDGE);
|
||||
if (anExp.More()) {
|
||||
for(;anExp.More();anExp.Next()) {
|
||||
aFillet.Add(aRadius,TopoDS::Edge(anExp.Current()));
|
||||
}
|
||||
} else aFillet.Add(aRadius,TopoDS::Edge(Path));
|
||||
aFillet.Build();
|
||||
if (!aFillet.IsDone()) return 1;
|
||||
QANewBRepNaming_Fillet aNaming(L);
|
||||
aNaming.Load(Basis, aFillet);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//function : QANewDBRepNaming_NameChamfer
|
||||
//purpose : NameChamfer Doc Label SourceShapeLabel EdgeLabel FaceLabel Distance1 Distance2
|
||||
//===========================================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameChamfer (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb != 8) {
|
||||
di << "QANewDBRepNaming_NameChamfer : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TDF_Label L, BL, EL, FL;
|
||||
Standard_Real aDist1, aDist2;
|
||||
|
||||
if (!QADNaming::Entry(arg, L)) return 1;
|
||||
|
||||
if (!DDF::AddLabel(L.Data(), arg[3], BL)) return 1;
|
||||
if (!DDF::AddLabel(L.Data(), arg[4], EL)) return 1;
|
||||
if (!DDF::AddLabel(L.Data(), arg[5], FL)) return 1;
|
||||
aDist1 = atoi(arg[6]);
|
||||
aDist2 = atoi(arg[7]);
|
||||
|
||||
Handle(TNaming_NamedShape) BasisNS, EdgeNS, FaceNS;
|
||||
if (!BL.FindAttribute(TNaming_NamedShape::GetID(), BasisNS)) return 1;
|
||||
if (!EL.FindAttribute(TNaming_NamedShape::GetID(), EdgeNS)) return 1;
|
||||
if (!FL.FindAttribute(TNaming_NamedShape::GetID(), FaceNS)) return 1;
|
||||
const TopoDS_Shape& Basis = TNaming_Tool::CurrentShape(BasisNS);
|
||||
const TopoDS_Shape& Edge = TNaming_Tool::CurrentShape(EdgeNS);
|
||||
const TopoDS_Shape& Face = TNaming_Tool::CurrentShape(FaceNS);
|
||||
|
||||
BRepFilletAPI_MakeChamfer aChamfer(Basis);
|
||||
TopExp_Explorer anExp(Edge,TopAbs_EDGE);
|
||||
if (anExp.More()) {
|
||||
for(;anExp.More();anExp.Next()) {
|
||||
aChamfer.Add(aDist1,aDist2,TopoDS::Edge(anExp.Current()),TopoDS::Face(Face));
|
||||
}
|
||||
} else {aChamfer.Add(aDist1,aDist2,TopoDS::Edge(Edge),TopoDS::Face(Face));}
|
||||
aChamfer.Build();
|
||||
if (!aChamfer.IsDone()) return 1;
|
||||
QANewBRepNaming_Chamfer aNaming(L);
|
||||
aNaming.Load(Basis, aChamfer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
//function : QANewDBRepNaming_NameImportShape
|
||||
//purpose : NameImportShape Doc Label DrawShape
|
||||
//==============================================================
|
||||
|
||||
static Standard_Integer QANewDBRepNaming_NameImportShape (Draw_Interpretor& di,
|
||||
Standard_Integer nb,
|
||||
const char ** arg)
|
||||
{
|
||||
if (nb != 4) {
|
||||
di << "QANewDBRepNaming_NameImportShape : Error" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDF_Data) D;
|
||||
if (!DDF::GetDF(arg[1],D)) return 1;
|
||||
TDF_Label L;
|
||||
if (!DDF::AddLabel(D, arg[2], L)) return 1;
|
||||
|
||||
const TopoDS_Shape& S = DBRep::Get(arg[3]);
|
||||
|
||||
QANewBRepNaming_ImportShape nameIS(L);
|
||||
nameIS.Load(S);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : PrimitiveCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void QANewDBRepNaming::PrimitiveCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
static Standard_Boolean done = Standard_False;
|
||||
if (done) return;
|
||||
done = Standard_True;
|
||||
const char* g = "Naming algorithm commands for primitives" ;
|
||||
|
||||
|
||||
theCommands.Add ("NameBox",
|
||||
"NameBox Doc Label dx dy dz",
|
||||
__FILE__, QANewDBRepNaming_NameBox, g);
|
||||
|
||||
theCommands.Add ("NameCylinder",
|
||||
"NameCylinder Doc Label R H Angle [ShapeType(Shell/Solid)]",
|
||||
__FILE__, QANewDBRepNaming_NameCylinder, g);
|
||||
|
||||
theCommands.Add ("NameSphere",
|
||||
"NameSphere Doc Label R X Y Z Angle1 Angle2 Angle3 [ShapeType(Shell/Solid)]",
|
||||
__FILE__, QANewDBRepNaming_NameSphere, g);
|
||||
|
||||
theCommands.Add ("NamePrism",
|
||||
"NamePrism Doc Label BasisLabel H Direction(X Y Z) Inf(1/0, by feafault = 0)",
|
||||
__FILE__, QANewDBRepNaming_NamePrism, g);
|
||||
|
||||
theCommands.Add ("NameRevol",
|
||||
"NameRevol Doc Label BasisLabel AxisLabel Angle",
|
||||
__FILE__, QANewDBRepNaming_NameRevol, g);
|
||||
|
||||
theCommands.Add ("NameFillet",
|
||||
"NameFillet Doc Label SourceShapeLabel PathLabel Radius",
|
||||
__FILE__, QANewDBRepNaming_NameFillet, g);
|
||||
|
||||
theCommands.Add ("NameChamfer",
|
||||
"NameChamfer Doc Label SourceShapeLabel EdgeLabel FaceLabel Distance1 Distance2",
|
||||
__FILE__, QANewDBRepNaming_NameChamfer, g);
|
||||
|
||||
theCommands.Add ("NameImportShape",
|
||||
"NameImportShape Doc Label DrawShape",
|
||||
__FILE__, QANewDBRepNaming_NameImportShape, g);
|
||||
|
||||
}
|
Reference in New Issue
Block a user