mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0024172: Compiler warnings 'unreacheable code' and 'unreferenced local function' in OCAF
Files _Sample.cxx containing unused sample code are removed from several OCAF packages. Cycles for() with body always ending with 'break' are replaced by equivalent if() statements.
This commit is contained in:
parent
eb4320f2d9
commit
b2197f9397
@ -1,433 +0,0 @@
|
|||||||
// Created on: 1999-12-28
|
|
||||||
// Created by: Sergey RUIN
|
|
||||||
// Copyright (c) 1999-1999 Matra Datavision
|
|
||||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
|
||||||
//
|
|
||||||
// The content of this file is subject to the Open CASCADE Technology Public
|
|
||||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
|
||||||
// except in compliance with the License. Please obtain a copy of the License
|
|
||||||
// at http://www.opencascade.org and read it completely before using this file.
|
|
||||||
//
|
|
||||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
|
||||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
|
||||||
//
|
|
||||||
// The Original Code and all software distributed under the License is
|
|
||||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
|
||||||
// Initial Developer hereby disclaims all such warranties, including without
|
|
||||||
// limitation, any warranties of merchantability, fitness for a particular
|
|
||||||
// purpose or non-infringement. Please see the License for the specific terms
|
|
||||||
// and conditions governing the rights and limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <TDF_Data.hxx>
|
|
||||||
#include <TDF_Label.hxx>
|
|
||||||
#include <TDataXtd_Axis.hxx>
|
|
||||||
#include <TDataStd_Current.hxx>
|
|
||||||
#include <TDataStd_Comment.hxx>
|
|
||||||
#include <TDataStd_Integer.hxx>
|
|
||||||
#include <TDataStd_IntegerArray.hxx>
|
|
||||||
#include <TDataStd_Real.hxx>
|
|
||||||
#include <TDataStd_RealArray.hxx>
|
|
||||||
#include <TDF_Reference.hxx>
|
|
||||||
#include <TDataStd_UAttribute.hxx>
|
|
||||||
#include <TDataStd_TreeNode.hxx>
|
|
||||||
#include <TDataXtd_Constraint.hxx>
|
|
||||||
#include <TDataXtd_Shape.hxx>
|
|
||||||
#include <TDataStd_Name.hxx>
|
|
||||||
#include <TDataStd_Directory.hxx>
|
|
||||||
#include <TDataXtd_Point.hxx>
|
|
||||||
#include <TDataXtd_Plane.hxx>
|
|
||||||
#include <TDataXtd_Geometry.hxx>
|
|
||||||
#include <TDataXtd_GeometryEnum.hxx>
|
|
||||||
#include <TDataXtd_ConstraintEnum.hxx>
|
|
||||||
#include <TNaming_NamedShape.hxx>
|
|
||||||
#include <gp_Pnt.hxx>
|
|
||||||
#include <gp_Pln.hxx>
|
|
||||||
#include <gp_Lin.hxx>
|
|
||||||
#include <gp_Ax1.hxx>
|
|
||||||
#include <gp_Cylinder.hxx>
|
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
#include <TopLoc_Location.hxx>
|
|
||||||
#include <TDF_AttributeList.hxx>
|
|
||||||
#include <TColStd_HArray1OfReal.hxx>
|
|
||||||
#include <TCollection_ExtendedString.hxx>
|
|
||||||
#include <TDataStd_ListOfExtendedString.hxx>
|
|
||||||
#include <TDocStd_Document.hxx>
|
|
||||||
#include <TDataStd_TreeNode.hxx>
|
|
||||||
|
|
||||||
#ifdef DEB
|
|
||||||
|
|
||||||
static void Sample()
|
|
||||||
{
|
|
||||||
// Starting with data framework
|
|
||||||
Handle(TDF_Data) DF = new TDF_Data();
|
|
||||||
TDF_Label aLabel = DF->Root();
|
|
||||||
|
|
||||||
//------------------------- TDataStd_Integer (Real) ---------------------------------
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Setting TDataStd_Integer attribute to a label (work with TDataStd_Real is the same)
|
|
||||||
|
|
||||||
Standard_Integer i = 10;
|
|
||||||
|
|
||||||
Handle(TDataStd_Integer) I = TDataStd_Integer::Set(aLabel, i);
|
|
||||||
|
|
||||||
// Getting the value stored in TDataStd_Integer attribute
|
|
||||||
|
|
||||||
Standard_Integer aValue;
|
|
||||||
|
|
||||||
aValue = I->Get();
|
|
||||||
|
|
||||||
// Setting the new value in the attribute
|
|
||||||
|
|
||||||
I->Set( 25 );
|
|
||||||
|
|
||||||
//------------------------- TDataStd_RealArray (IntegerArray is analogical) --------------
|
|
||||||
//-----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Setting TDataStd_RealArray attribute to a label
|
|
||||||
|
|
||||||
Standard_Integer lower = 1, upper = 20;
|
|
||||||
|
|
||||||
Handle(TDataStd_RealArray) realarray = TDataStd_RealArray::Set(aLabel, lower, upper);
|
|
||||||
|
|
||||||
// Filling array
|
|
||||||
|
|
||||||
for(Standard_Integer j = realarray->Lower(); j<= realarray->Upper(); j++) {
|
|
||||||
realarray->SetValue(j, M_PI * j);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieving value by index
|
|
||||||
|
|
||||||
Standard_Real value = realarray->Value(3);
|
|
||||||
|
|
||||||
// Getting handle to an underlying array TColStd_HArray1OfReal
|
|
||||||
|
|
||||||
Handle(TColStd_HArray1OfReal) array = realarray->Array();
|
|
||||||
|
|
||||||
//------------------------- TDataStd_Comment --------------
|
|
||||||
//---------------------------------------------------------
|
|
||||||
|
|
||||||
// Setting TDataStd_Comment attribute to a label
|
|
||||||
|
|
||||||
Handle(TDataStd_Comment) comment = TDataStd_Comment::Set(aLabel);
|
|
||||||
|
|
||||||
// Setting comment string in to the attribute
|
|
||||||
|
|
||||||
TCollection_ExtendedString message = "This is a remark";
|
|
||||||
|
|
||||||
comment->Set(message);
|
|
||||||
|
|
||||||
// Getting comment string stored in the attribute
|
|
||||||
|
|
||||||
TCollection_ExtendedString string = comment->Get();
|
|
||||||
|
|
||||||
//------------------------- TDataStd_Name -----------------
|
|
||||||
//---------------------------------------------------------
|
|
||||||
|
|
||||||
// Setting TDataStd_Name attribute to a label
|
|
||||||
|
|
||||||
// Handle(TDataStd_Name) name = TDataStd_Name::Set(aLabel);
|
|
||||||
|
|
||||||
|
|
||||||
// Checking if the label has a name (TDataStd_Name attribute with not empty name field)
|
|
||||||
|
|
||||||
// Standard_Boolean isempty = name->IsEmpty();
|
|
||||||
|
|
||||||
// Getting the name of the label
|
|
||||||
|
|
||||||
//if( !isempty ) TCollection_ExtendedString thename = name->Get();
|
|
||||||
|
|
||||||
// Erasing the name of the label in TDataStd_Name attribute
|
|
||||||
|
|
||||||
// name->SetEmpty();
|
|
||||||
|
|
||||||
// Setting a new name string in the attribute
|
|
||||||
|
|
||||||
TCollection_ExtendedString aname = "Name of the label";
|
|
||||||
Handle(TDataStd_Name) name = TDataStd_Name::Set(aLabel,aname);
|
|
||||||
|
|
||||||
name->Set(aname);
|
|
||||||
|
|
||||||
// Getting comment string stored in the attribute
|
|
||||||
|
|
||||||
TCollection_ExtendedString namestring = name->Get();
|
|
||||||
|
|
||||||
// Getting the first father label which has TDataStd_Name attribute
|
|
||||||
|
|
||||||
//Handle(TDataStd_Name) father;
|
|
||||||
|
|
||||||
//Standard_Boolean hasfather = name->Father(father);
|
|
||||||
|
|
||||||
// Find if there exists label with full path "Assembly1:Part3:Prism7"
|
|
||||||
|
|
||||||
// Converting string to list of names
|
|
||||||
|
|
||||||
//TCollection_ExtendedString fullpath = "Assembly_1:Part_3:Prism_7";
|
|
||||||
//TDataStd_ListOfExtendedString listofstring;
|
|
||||||
|
|
||||||
//TDataStd_Name::MakePath(fullpath, listofstring);
|
|
||||||
|
|
||||||
//Handle(TDataStd_Name) nameattribute;
|
|
||||||
|
|
||||||
//Standard_Boolean found = TDataStd_Name::Find(DF, listofstring, nameattribute);
|
|
||||||
|
|
||||||
//if( found ) {
|
|
||||||
// Getting the fullpath of the nameattribute (fullpath consists of list of TDataStd_Name attributes situated on
|
|
||||||
// father labels from label where nameattribute is situated to root label
|
|
||||||
//TDF_AttributeList list;
|
|
||||||
|
|
||||||
//nameattribute->FullPath(list);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//TDF_Label currentLabel;
|
|
||||||
|
|
||||||
// ... Finding currentLabel...
|
|
||||||
|
|
||||||
// Search under <currentLabel> a label which fits with the given name
|
|
||||||
|
|
||||||
//Handle(TDataStd_Name) givenname;
|
|
||||||
|
|
||||||
//found = TDataStd_Name::Find(currentLabel, "Sketch_11", givenname);
|
|
||||||
|
|
||||||
//if( found ) {
|
|
||||||
|
|
||||||
// Getting all named child labels of the label where givenname attribute situated
|
|
||||||
//TDF_AttributeList listOfChildren;name to the
|
|
||||||
//Standard_Boolean isAtLeastOneFound = givenname->ChildNames(listOfChildren);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------- TDataStd_UAttribute -----------
|
|
||||||
//---------------------------------------------------------
|
|
||||||
|
|
||||||
// Setting TDataStd_UAttribute to a label
|
|
||||||
|
|
||||||
Standard_GUID guid("01010101-0101-0101-1010-010101010101");
|
|
||||||
|
|
||||||
Handle(TDataStd_UAttribute) uattribute = TDataStd_UAttribute::Set(aLabel, guid);
|
|
||||||
|
|
||||||
// Finding a TDataStd_UAttribute on the label using standard mechanism
|
|
||||||
|
|
||||||
Handle(TDataStd_UAttribute) theUA;
|
|
||||||
if (aLabel.FindAttribute(guid,theUA)) {
|
|
||||||
// do something
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking that a TDataStd_UAttribute exist on a given label using standard mechanism
|
|
||||||
|
|
||||||
if (aLabel.IsAttribute(guid)) {
|
|
||||||
// do something
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------- TDF_Reference -----------
|
|
||||||
//---------------------------------------------------------
|
|
||||||
|
|
||||||
TDF_Label referencedlabel;
|
|
||||||
|
|
||||||
// ... Finding referencedlabel ...
|
|
||||||
|
|
||||||
|
|
||||||
// Setting TDF_Reference attribute to a label
|
|
||||||
|
|
||||||
Handle(TDF_Reference) reference = TDF_Reference::Set(aLabel, referencedlabel);
|
|
||||||
|
|
||||||
// Getting a label to TDF_Reference attribute refers to
|
|
||||||
|
|
||||||
TDF_Label refLabel = reference->Get();
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------- TDataXtd_Point ----------------
|
|
||||||
//---------------------------------------------------------
|
|
||||||
gp_Pnt Pnt;
|
|
||||||
|
|
||||||
// ... Defining point <Pnt> ...
|
|
||||||
|
|
||||||
// Setting TDataXtd_Point attribute to a label
|
|
||||||
|
|
||||||
Handle(TDataXtd_Point) P = TDataXtd_Point::Set(aLabel, Pnt);
|
|
||||||
|
|
||||||
//Retrieve gp_Pnt associated with attribute
|
|
||||||
|
|
||||||
gp_Pnt aPnt;
|
|
||||||
TDataXtd_Geometry::Point(aLabel, aPnt);
|
|
||||||
|
|
||||||
//------------------------- TDataXtd_Plane ----------------
|
|
||||||
//---------------------------------------------------------
|
|
||||||
gp_Pln Plane;
|
|
||||||
|
|
||||||
// ... Defining plane <Plane> ...
|
|
||||||
|
|
||||||
// Setting TDataXtd_Plane attribute to a label
|
|
||||||
|
|
||||||
Handle(TDataXtd_Plane) Pl = TDataXtd_Plane::Set(aLabel, Plane);
|
|
||||||
|
|
||||||
//Retrieve gp_Plane associated with attribute
|
|
||||||
|
|
||||||
gp_Pln aPlane;
|
|
||||||
TDataXtd_Geometry::Plane(aLabel, aPlane);
|
|
||||||
|
|
||||||
//------------------------- TDataXtd_Axis ----------------
|
|
||||||
//---------------------------------------------------------
|
|
||||||
|
|
||||||
gp_Lin Axis;
|
|
||||||
|
|
||||||
// ... Defining axis <Axis> ...
|
|
||||||
|
|
||||||
// Setting TDataXtd_Axis attribute to a label
|
|
||||||
|
|
||||||
Handle(TDataXtd_Axis) axis = TDataXtd_Axis::Set(aLabel, Axis);
|
|
||||||
|
|
||||||
//Retrieve gp_Ax1 associated with attribute
|
|
||||||
|
|
||||||
gp_Ax1 anAxis;
|
|
||||||
TDataXtd_Geometry::Axis(aLabel, anAxis);
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------- TDataXtd_Geometry ----------------
|
|
||||||
//---------------------------------------------------------
|
|
||||||
|
|
||||||
Handle(TNaming_NamedShape) NS;
|
|
||||||
|
|
||||||
// ... Constructing NS which contains cylinder...
|
|
||||||
|
|
||||||
// Setting TDataXtd_Geometry attribute to the label where <NS> is situated
|
|
||||||
|
|
||||||
TDF_Label NSLabel = NS->Label();
|
|
||||||
|
|
||||||
Handle(TDataXtd_Geometry) geom = TDataXtd_Geometry::Set(NSLabel);
|
|
||||||
|
|
||||||
// Setting a type of geometry
|
|
||||||
|
|
||||||
geom->SetType(TDataXtd_CYLINDER);
|
|
||||||
|
|
||||||
// Retrieving gp_Cylinder stored in associated NamedShape
|
|
||||||
|
|
||||||
// Checking the type of geometry
|
|
||||||
|
|
||||||
if( geom->GetType() == TDataXtd_CYLINDER ) {
|
|
||||||
|
|
||||||
gp_Cylinder Cylinder;
|
|
||||||
|
|
||||||
TDataXtd_Geometry::Cylinder(geom->Label(), Cylinder);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------- TDataXtd_Constraint -------------
|
|
||||||
//-----------------------------------------------------------
|
|
||||||
|
|
||||||
// Setting TDataXtd_Constraint to a label
|
|
||||||
|
|
||||||
Handle(TDataXtd_Constraint) constraint = TDataXtd_Constraint::Set(aLabel);
|
|
||||||
|
|
||||||
Handle(TNaming_NamedShape) NS1, NS2;
|
|
||||||
Handle(TDataStd_Real) aDistance;
|
|
||||||
|
|
||||||
// ... Constructing NS1 and NS2 which contain lines and calculating the distance between them ...
|
|
||||||
|
|
||||||
// Setting DISTANCE Dimension between NS1 and NS2
|
|
||||||
|
|
||||||
constraint->Set(TDataXtd_DISTANCE, NS1, NS2);
|
|
||||||
|
|
||||||
constraint->SetValue(aDistance); // <aDistance> should contain the calucalated distance
|
|
||||||
|
|
||||||
// Checking if <constraint> is a Dimension rather than a Constraint
|
|
||||||
|
|
||||||
Standard_Boolean isdimension = constraint->IsDimension();
|
|
||||||
|
|
||||||
if(isdimension) {
|
|
||||||
|
|
||||||
// Getting the distance between NS1 and NS2
|
|
||||||
|
|
||||||
Handle(TDataStd_Real) valOfdistance = constraint->GetValue();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setting PARALLEL constraint between NS1 and NS2
|
|
||||||
|
|
||||||
constraint->Set(TDataXtd_PARALLEL, NS1, NS2);
|
|
||||||
|
|
||||||
// Getting number of geometries which define a constarint
|
|
||||||
|
|
||||||
Standard_Integer number = constraint->NbGeometries();
|
|
||||||
|
|
||||||
// Checking if a constraint is verified
|
|
||||||
|
|
||||||
Standard_Boolean isverified = constraint->Verified();
|
|
||||||
if( !isverified ) {
|
|
||||||
cout << "Constraint is not valid" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------- TDataStd_Directory --------------
|
|
||||||
//-----------------------------------------------------------
|
|
||||||
|
|
||||||
// Setting TDataStd_Directory to a label
|
|
||||||
|
|
||||||
Handle(TDataStd_Directory) directory = TDataStd_Directory::New(aLabel);
|
|
||||||
|
|
||||||
// Creating a new sub directory of the given directory
|
|
||||||
|
|
||||||
Handle(TDataStd_Directory) newdirectory = TDataStd_Directory::AddDirectory(directory);
|
|
||||||
|
|
||||||
// Creating a new label in directory
|
|
||||||
|
|
||||||
TDF_Label newlabel = TDataStd_Directory::MakeObjectLabel(newdirectory);
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------- TDataStd_TreeNode ---------------
|
|
||||||
//-----------------------------------------------------------
|
|
||||||
|
|
||||||
// Let's create a tree:
|
|
||||||
|
|
||||||
// Root
|
|
||||||
// |
|
|
||||||
// --- FirstChild
|
|
||||||
// |
|
|
||||||
// --- SecondChild
|
|
||||||
// |
|
|
||||||
// --- FirstChildOfSecondChild
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Setting a TDataStd_TreeNode attribute to a label.
|
|
||||||
// It becomes a root because it hasn't a father:
|
|
||||||
|
|
||||||
Handle(TDataStd_TreeNode) Root = TDataStd_TreeNode::Set(aLabel);
|
|
||||||
|
|
||||||
// Create a child TreeNode:
|
|
||||||
|
|
||||||
Handle(TDataStd_TreeNode) FirstChild = TDataStd_TreeNode::Set(aLabel.FindChild(1));
|
|
||||||
Root->Append(FirstChild);
|
|
||||||
|
|
||||||
// Let's add a second child node to the Root:
|
|
||||||
|
|
||||||
Handle(TDataStd_TreeNode) SecondChild = TDataStd_TreeNode::Set(aLabel.FindChild(2));
|
|
||||||
Root->Append(SecondChild);
|
|
||||||
|
|
||||||
// Now, it's time to create the a child for the SecondChild node - FirstChildOfSecondChild:
|
|
||||||
|
|
||||||
Handle(TDataStd_TreeNode) FirstChildOfSecondChild = TDataStd_TreeNode::Set(aLabel.FindChild(3));
|
|
||||||
SecondChild->Append(FirstChildOfSecondChild);
|
|
||||||
|
|
||||||
// Let's redesign the tree:
|
|
||||||
|
|
||||||
// Root
|
|
||||||
// |
|
|
||||||
// --- SecondChild
|
|
||||||
// |
|
|
||||||
// --- FirstChild
|
|
||||||
// |
|
|
||||||
// --- FirstChildOfSecondChild
|
|
||||||
|
|
||||||
// Removing of the FirstChild from our tree:
|
|
||||||
|
|
||||||
FirstChild->Remove();
|
|
||||||
|
|
||||||
// Setting the FirstChild node as a first child of the SecondChild node:
|
|
||||||
|
|
||||||
SecondChild->Prepend(FirstChild);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -8,4 +8,4 @@ DDataStd_ConstraintCommands.cxx
|
|||||||
DDataStd_DrawDisplayCommands.cxx
|
DDataStd_DrawDisplayCommands.cxx
|
||||||
DDataStd_ObjectCommands.cxx
|
DDataStd_ObjectCommands.cxx
|
||||||
DDataStd_NameCommands.cxx
|
DDataStd_NameCommands.cxx
|
||||||
DDataStd_Sample.cxx
|
|
||||||
|
@ -1,127 +0,0 @@
|
|||||||
// Created on: 1999-12-28
|
|
||||||
// Created by: Sergey RUIN
|
|
||||||
// Copyright (c) 1999-1999 Matra Datavision
|
|
||||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
|
||||||
//
|
|
||||||
// The content of this file is subject to the Open CASCADE Technology Public
|
|
||||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
|
||||||
// except in compliance with the License. Please obtain a copy of the License
|
|
||||||
// at http://www.opencascade.org and read it completely before using this file.
|
|
||||||
//
|
|
||||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
|
||||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
|
||||||
//
|
|
||||||
// The Original Code and all software distributed under the License is
|
|
||||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
|
||||||
// Initial Developer hereby disclaims all such warranties, including without
|
|
||||||
// limitation, any warranties of merchantability, fitness for a particular
|
|
||||||
// purpose or non-infringement. Please see the License for the specific terms
|
|
||||||
// and conditions governing the rights and limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <TDF_Data.hxx>
|
|
||||||
#include <TDF_Label.hxx>
|
|
||||||
#include <TDocStd_Application.hxx>
|
|
||||||
#include <TDocStd_Document.hxx>
|
|
||||||
#include <TDocStd_XLinkTool.hxx>
|
|
||||||
#include <CDF_Session.hxx>
|
|
||||||
//#include <AppSketch_Application.hxx>
|
|
||||||
|
|
||||||
|
|
||||||
// Unused :
|
|
||||||
#ifdef DEB
|
|
||||||
static void Sample()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
//...Creating application (example of sketch)
|
|
||||||
|
|
||||||
Handle(TDocStd_Application) app; // = new AppSketch_Application ();
|
|
||||||
|
|
||||||
// the application is now handled by the CDF_Session variable
|
|
||||||
|
|
||||||
|
|
||||||
//...Retrieving the application
|
|
||||||
|
|
||||||
|
|
||||||
if (!CDF_Session::Exists()) {
|
|
||||||
Handle(CDF_Session) S = CDF_Session::CurrentSession();
|
|
||||||
if (!S->HasCurrentApplication())
|
|
||||||
Standard_DomainError::Raise("DDocStd::Find no applicative session");
|
|
||||||
app = Handle(TDocStd_Application)::DownCast(S->CurrentApplication());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// none active application
|
|
||||||
}
|
|
||||||
|
|
||||||
//...Creating the new document (document conatins a framework)
|
|
||||||
|
|
||||||
Handle(TDocStd_Document) doc;
|
|
||||||
app->NewDocument("NewDocumentFormat", doc);
|
|
||||||
|
|
||||||
//...Getting application to which the document belongs
|
|
||||||
|
|
||||||
app = Handle(TDocStd_Application)::DownCast(doc->Application());
|
|
||||||
|
|
||||||
|
|
||||||
//...Getting application to which the document belongs
|
|
||||||
|
|
||||||
app = Handle(TDocStd_Application)::DownCast(doc->Application());
|
|
||||||
|
|
||||||
|
|
||||||
//...Getting data framework from document
|
|
||||||
|
|
||||||
Handle(TDF_Data) framework = doc->GetData();
|
|
||||||
|
|
||||||
//...Retrieving the document from a label of its framework
|
|
||||||
|
|
||||||
TDF_Label label;
|
|
||||||
doc = TDocStd_Document::Get(label);
|
|
||||||
|
|
||||||
//... Filling document with data
|
|
||||||
|
|
||||||
//Saving document in the file "/tmp/example.caf" give the full path
|
|
||||||
|
|
||||||
app->SaveAs(doc, "/tmp/example.caf");
|
|
||||||
|
|
||||||
//Closing document
|
|
||||||
|
|
||||||
app->Close(doc);
|
|
||||||
|
|
||||||
//Opening document stored in file
|
|
||||||
|
|
||||||
app->Open("/tmp/example.caf", doc);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Coping content of a document to another document with possibility update copy in future
|
|
||||||
|
|
||||||
Handle(TDocStd_Document) doc1;
|
|
||||||
Handle(TDocStd_Document) doc2;
|
|
||||||
|
|
||||||
|
|
||||||
TDF_Label source = doc1->GetData()->Root();
|
|
||||||
TDF_Label target = doc2->GetData()->Root();
|
|
||||||
TDocStd_XLinkTool XLinkTool;
|
|
||||||
|
|
||||||
//Coping content of a document to another document with possibility update copy in future
|
|
||||||
|
|
||||||
XLinkTool.CopyWithLink(target,source); //Now target document has a copy of source document , the copy also has
|
|
||||||
//a link to have possibility update content of the copy if orginal changed
|
|
||||||
|
|
||||||
//...Something is chaneged in source document
|
|
||||||
|
|
||||||
//Updating copy in target document
|
|
||||||
|
|
||||||
XLinkTool.UpdateLink(target);
|
|
||||||
|
|
||||||
//Cping content of a document to another document
|
|
||||||
|
|
||||||
XLinkTool.Copy(target, source); //Now target document has a copy of source document, there is no link between
|
|
||||||
//the copy and original
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -2,5 +2,4 @@ IDNames.tcl
|
|||||||
DDocStd_ApplicationCommands.cxx
|
DDocStd_ApplicationCommands.cxx
|
||||||
DDocStd_DocumentCommands.cxx
|
DDocStd_DocumentCommands.cxx
|
||||||
DDocStd_ToolsCommands.cxx
|
DDocStd_ToolsCommands.cxx
|
||||||
DDocStd_Sample.cxx
|
|
||||||
DDocStd_MTMCommands.cxx
|
DDocStd_MTMCommands.cxx
|
||||||
|
@ -1,220 +0,0 @@
|
|||||||
// Created on: 1999-12-27
|
|
||||||
// Created by: Sergey RUIN
|
|
||||||
// Copyright (c) 1999-1999 Matra Datavision
|
|
||||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
|
||||||
//
|
|
||||||
// The content of this file is subject to the Open CASCADE Technology Public
|
|
||||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
|
||||||
// except in compliance with the License. Please obtain a copy of the License
|
|
||||||
// at http://www.opencascade.org and read it completely before using this file.
|
|
||||||
//
|
|
||||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
|
||||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
|
||||||
//
|
|
||||||
// The Original Code and all software distributed under the License is
|
|
||||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
|
||||||
// Initial Developer hereby disclaims all such warranties, including without
|
|
||||||
// limitation, any warranties of merchantability, fitness for a particular
|
|
||||||
// purpose or non-infringement. Please see the License for the specific terms
|
|
||||||
// and conditions governing the rights and limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <TDF_Data.hxx>
|
|
||||||
#include <TDF_Label.hxx>
|
|
||||||
#include <TNaming_NamedShape.hxx>
|
|
||||||
#include <TPrsStd_AISPresentation.hxx>
|
|
||||||
#include <TPrsStd_AISViewer.hxx>
|
|
||||||
#include <AIS_InteractiveContext.hxx>
|
|
||||||
#include <AIS_InteractiveObject.hxx>
|
|
||||||
#include <V3d_Viewer.hxx>
|
|
||||||
#include <Quantity_NameOfColor.hxx>
|
|
||||||
#include <TPrsStd_DriverTable.hxx>
|
|
||||||
#include <TPrsStd_NamedShapeDriver.hxx>
|
|
||||||
#include <TPrsStd_PlaneDriver.hxx>
|
|
||||||
#include <TDataXtd_Plane.hxx>
|
|
||||||
|
|
||||||
#ifdef DEB
|
|
||||||
static void Sample()
|
|
||||||
{
|
|
||||||
// Starting with data framework
|
|
||||||
Handle(TDF_Data) DF = new TDF_Data();
|
|
||||||
TDF_Label aLabel = DF->Root();
|
|
||||||
|
|
||||||
//----------------------------------- TPrsStd_AISViewer ----------------------------------------
|
|
||||||
//==============================================================================================
|
|
||||||
|
|
||||||
// Setting the TPrsStd_AISViewer in the framework
|
|
||||||
|
|
||||||
Handle(V3d_Viewer) aViewer;
|
|
||||||
|
|
||||||
//... Initialization of aViewer
|
|
||||||
|
|
||||||
//Creating the new AIS_InteractiveContext
|
|
||||||
Handle(AIS_InteractiveContext) ctx = new AIS_InteractiveContext(aViewer);
|
|
||||||
|
|
||||||
//Creating the new TPrsStd_AISViewer attribute initialized with AIS_InteractiveContext
|
|
||||||
Handle(TPrsStd_AISViewer) aisviewer;
|
|
||||||
|
|
||||||
if( !TPrsStd_AISViewer::Has(aLabel) ) { //Check if there has already been set TPrsStd_AISViewer in the framework
|
|
||||||
aisviewer = TPrsStd_AISViewer::New(aLabel, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Finding TPrsStd_AISViewer attribute in the DataFramework
|
|
||||||
if( TPrsStd_AISViewer::Find(aLabel, aisviewer) ) {
|
|
||||||
aisviewer->Update(); //Update the viewer associated with this attribute
|
|
||||||
}
|
|
||||||
|
|
||||||
//Getting AIS_InteractiveContext from TPrsStd_AISViewer may be done in two ways:
|
|
||||||
|
|
||||||
//1. If we have already gotten TPrsStd_AISViewer attribute (strored in a variable <aisviewer>)
|
|
||||||
Handle(AIS_InteractiveContext) context1 = aisviewer->GetInteractiveContext();
|
|
||||||
|
|
||||||
//2. Getting AIS_InteractiveContext directly
|
|
||||||
Handle(AIS_InteractiveContext) context2;
|
|
||||||
if( TPrsStd_AISViewer::Find(aLabel, context2) ) {
|
|
||||||
//do something...
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------- TPrsStd_Driver and TPrsStd_DriverTable -------------------
|
|
||||||
//==============================================================================================
|
|
||||||
|
|
||||||
// All work for building AIS_InteractiveObject to be presented by TPrsStd_AISPresentation is done
|
|
||||||
// by drivers which are descendants of deferred class TPrsStd_Driver
|
|
||||||
|
|
||||||
// There is a map of drivers with Standard_GUID as a key.
|
|
||||||
|
|
||||||
// Adding driver to the map of drivers
|
|
||||||
|
|
||||||
Handle(TPrsStd_NamedShapeDriver) NSDriver = new TPrsStd_NamedShapeDriver();
|
|
||||||
|
|
||||||
Handle(TPrsStd_DriverTable) table = TPrsStd_DriverTable::Get();
|
|
||||||
|
|
||||||
Standard_GUID guid = TNaming_NamedShape::GetID();
|
|
||||||
|
|
||||||
table->AddDriver(guid, NSDriver);
|
|
||||||
|
|
||||||
// When the first time called TPrsStd_DriverTable loads standard drivers defined in TPrsStd package
|
|
||||||
|
|
||||||
// Getting driver from the map of drivers
|
|
||||||
|
|
||||||
Standard_GUID driverguid = TNaming_NamedShape::GetID();
|
|
||||||
|
|
||||||
Handle(TPrsStd_NamedShapeDriver) driver;
|
|
||||||
|
|
||||||
if( table->FindDriver(driverguid, driver) )
|
|
||||||
cout << "Driver was found " << endl;
|
|
||||||
else
|
|
||||||
cout << "Driver wasn't found" << endl;
|
|
||||||
|
|
||||||
// Driver can be used to build AIS_InteractiveObject for presenting the given label
|
|
||||||
|
|
||||||
Handle(TPrsStd_PlaneDriver) planedriver;
|
|
||||||
|
|
||||||
if( table->FindDriver(TDataXtd_Plane::GetID(), planedriver) ) {
|
|
||||||
|
|
||||||
TDF_Label planelabel;
|
|
||||||
|
|
||||||
// Finding planelabel ...
|
|
||||||
|
|
||||||
Handle(AIS_InteractiveObject) aisobject;
|
|
||||||
|
|
||||||
planedriver->Update(planelabel, aisobject);
|
|
||||||
|
|
||||||
if( !aisobject.IsNull() ) {
|
|
||||||
|
|
||||||
// Do something with aisobject ...
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------- TPrsStd_AISPresentation ----------------------------------
|
|
||||||
//==============================================================================================
|
|
||||||
|
|
||||||
|
|
||||||
TDF_Label ShapeLabel;
|
|
||||||
|
|
||||||
// ... Setting TNaming_NamedShape to <ShapeLabel>
|
|
||||||
|
|
||||||
// Setting the new TPrsStd_AISPresentation to <ShapeLabel>
|
|
||||||
// It can be done in two different ways:
|
|
||||||
|
|
||||||
Handle(TPrsStd_AISPresentation) Presenation;
|
|
||||||
// 1. By giving to TPrsStd_AISPresentation attribute Standard_GUID of an attribute to be displayed:
|
|
||||||
// This GUID will be used to find driver for building AIS_InteractiveObject in the map of drivers
|
|
||||||
|
|
||||||
Presenation = TPrsStd_AISPresentation::Set( ShapeLabel, TNaming_NamedShape::GetID() );
|
|
||||||
|
|
||||||
// 2. Or by giving the attribute itself to TPrsStd_AISPresentation attribute:
|
|
||||||
// An ID of attribute will be used to find driver for building AIS_InteractiveObject in the map of drivers
|
|
||||||
|
|
||||||
Handle(TNaming_NamedShape) NS;
|
|
||||||
if( ShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), NS) ) {
|
|
||||||
Presenation = TPrsStd_AISPresentation::Set( NS );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Displaying (recomputation of presentation of attribute is done only if presentation is null)
|
|
||||||
|
|
||||||
Handle(TPrsStd_AISPresentation) PRS;
|
|
||||||
|
|
||||||
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), PRS) ) PRS->Display();
|
|
||||||
//After call of the method PRS->Display() the presentation of the attribute is marked as displayed in
|
|
||||||
//AIS_InteractiveContext but not in viewer, in order to draw the object in viewer last has to be updated
|
|
||||||
|
|
||||||
TPrsStd_AISViewer::Update(ShapeLabel); //Update presentation of the attribute in a viewer's window
|
|
||||||
|
|
||||||
// Erasing
|
|
||||||
|
|
||||||
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), PRS) ) PRS->Erase();
|
|
||||||
// The method Erase() marks presentation of attribute as erased in AIS_InteractiveContext;
|
|
||||||
// in order to make changes visible in a viewer's window viewer has to be updated
|
|
||||||
TPrsStd_AISViewer::Update(ShapeLabel); //Update viewer to erase presenation of the attribute in a viewer's window
|
|
||||||
//Presentation of the attribute is erased from viewer but
|
|
||||||
// stays in AIS_InteractiveContext
|
|
||||||
|
|
||||||
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), PRS) ) PRS->Erase(Standard_True);
|
|
||||||
TPrsStd_AISViewer::Update(ShapeLabel);
|
|
||||||
//Presentation of the attribute is erased
|
|
||||||
//from viewer and removed from AIS_InteractiveContext
|
|
||||||
|
|
||||||
Handle(TPrsStd_AISPresentation) P;
|
|
||||||
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), P) ) {
|
|
||||||
|
|
||||||
// Updating and displaying presentation of the attribute to be displayed
|
|
||||||
|
|
||||||
P->Display(Standard_True);
|
|
||||||
TPrsStd_AISViewer::Update(ShapeLabel); //Update presenation of the attribute in a viewer's window
|
|
||||||
|
|
||||||
//Getting Standard_GUID of attribute with which TPrsStd_AISPresentation attribute is associeted
|
|
||||||
|
|
||||||
Standard_GUID guid = P->GetDriverGUID();
|
|
||||||
|
|
||||||
//Setting a color to the displayd attribute
|
|
||||||
|
|
||||||
P->SetColor(Quantity_NOC_RED);
|
|
||||||
TPrsStd_AISViewer::Update(ShapeLabel); //Update viewer to make changes visible to user
|
|
||||||
|
|
||||||
//Getting transparency the displayd attribute
|
|
||||||
|
|
||||||
Standard_Real transparency = P->Transparency();
|
|
||||||
|
|
||||||
//Getting AIS_InteractiveObject built and stored in the AIS_Presentation attribute
|
|
||||||
|
|
||||||
Handle(AIS_InteractiveObject) AISObject = P->GetAIS();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ... Attribute is modified
|
|
||||||
|
|
||||||
|
|
||||||
//Updating presentation of the attribute in viewer
|
|
||||||
|
|
||||||
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), PRS) )
|
|
||||||
PRS->Update(); //Updates presentation of attribute in AIS_InteractiveContext
|
|
||||||
TPrsStd_AISViewer::Update(ShapeLabel); //Updates presentation in viewer
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,3 +1,2 @@
|
|||||||
DPrsStd_AISPresentationCommands.cxx
|
DPrsStd_AISPresentationCommands.cxx
|
||||||
DPrsStd_AISViewerCommands.cxx
|
DPrsStd_AISViewerCommands.cxx
|
||||||
DPrsStd_Sample.cxx
|
|
||||||
|
@ -3,5 +3,4 @@ QADNaming_BuilderCommands.cxx
|
|||||||
QADNaming_IteratorsCommands.cxx
|
QADNaming_IteratorsCommands.cxx
|
||||||
QADNaming_ToolsCommands.cxx
|
QADNaming_ToolsCommands.cxx
|
||||||
QADNaming_SelectionCommands.cxx
|
QADNaming_SelectionCommands.cxx
|
||||||
QADNaming_Sample.cxx
|
|
||||||
QADNaming_Selection.tcl
|
QADNaming_Selection.tcl
|
||||||
|
@ -1,415 +0,0 @@
|
|||||||
// Created on: 1999-12-29
|
|
||||||
// Created by: Sergey RUIN
|
|
||||||
// Copyright (c) 1999-1999 Matra Datavision
|
|
||||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
|
||||||
//
|
|
||||||
// The content of this file is subject to the Open CASCADE Technology Public
|
|
||||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
|
||||||
// except in compliance with the License. Please obtain a copy of the License
|
|
||||||
// at http://www.opencascade.org and read it completely before using this file.
|
|
||||||
//
|
|
||||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
|
||||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
|
||||||
//
|
|
||||||
// The Original Code and all software distributed under the License is
|
|
||||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
|
||||||
// Initial Developer hereby disclaims all such warranties, including without
|
|
||||||
// limitation, any warranties of merchantability, fitness for a particular
|
|
||||||
// purpose or non-infringement. Please see the License for the specific terms
|
|
||||||
// and conditions governing the rights and limitations under the License.
|
|
||||||
|
|
||||||
|
|
||||||
#include <gp_Vec.hxx>
|
|
||||||
#include <gp_Trsf.hxx>
|
|
||||||
#include <gp_Pnt.hxx>
|
|
||||||
|
|
||||||
#include <TopoDS.hxx>
|
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
#include <TopoDS_Face.hxx>
|
|
||||||
#include <TopTools_ListOfShape.hxx>
|
|
||||||
#include <TopTools_MapOfShape.hxx>
|
|
||||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
|
||||||
#include <TopExp_Explorer.hxx>
|
|
||||||
|
|
||||||
#include <TopOpeBRepBuild_HBuilder.hxx>
|
|
||||||
|
|
||||||
#include <BRepPrimAPI_MakeBox.hxx>
|
|
||||||
#include <BRepFilletAPI_MakeFillet.hxx>
|
|
||||||
|
|
||||||
#include <BRepAlgo_Cut.hxx>
|
|
||||||
#include <BRepAlgo.hxx>
|
|
||||||
|
|
||||||
#include <TDF_Data.hxx>
|
|
||||||
#include <TDF_Label.hxx>
|
|
||||||
#include <TDF_LabelMap.hxx>
|
|
||||||
#include <TDF_ChildIterator.hxx>
|
|
||||||
#include <TDF_MapIteratorOfLabelMap.hxx>
|
|
||||||
|
|
||||||
#include <TNaming_NamedShape.hxx>
|
|
||||||
#include <TNaming_Selector.hxx>
|
|
||||||
#include <TNaming_Tool.hxx>
|
|
||||||
#include <TNaming_Builder.hxx>
|
|
||||||
#include <TNaming.hxx>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEB
|
|
||||||
|
|
||||||
#define Box1POS 1
|
|
||||||
#define Box2POS 2
|
|
||||||
#define SelectedEdgesPOS 3
|
|
||||||
#define FilletPOS 4
|
|
||||||
#define CutPOS 5
|
|
||||||
|
|
||||||
void Sample()
|
|
||||||
{
|
|
||||||
// Starting with data framework
|
|
||||||
Handle(TDF_Data) DF = new TDF_Data();
|
|
||||||
TDF_Label aLabel = DF->Root();
|
|
||||||
|
|
||||||
TopoDS_Shape Shape, Context;
|
|
||||||
|
|
||||||
// ======================================================
|
|
||||||
// Creating NamedShapes with different type of Evolution
|
|
||||||
// Scenario:
|
|
||||||
// 1.Create Box1 and push it as PRIMITIVE in DF
|
|
||||||
// 2.Create Box2 and push it as PRIMITIVE in DF
|
|
||||||
// 3.Move Box2 (applying a transformation)
|
|
||||||
// 4.Push a selected edges of top face of Box1 in DF,
|
|
||||||
// create Fillet (using selected edges) and push result as modification of Box1
|
|
||||||
// 5.Create a Cut (Box1, Box2) as modification of Box1 and push it in DF
|
|
||||||
// 6.Recover result from DF
|
|
||||||
// ======================================================
|
|
||||||
|
|
||||||
// =====================================
|
|
||||||
// 1.Box1, TNaming_Evolution == PRIMITIVE
|
|
||||||
// =====================================
|
|
||||||
BRepPrimAPI_MakeBox MKBOX1( 100, 100, 100); // creating Box1
|
|
||||||
|
|
||||||
//Load the faces of the box in DF
|
|
||||||
TDF_Label Box1Label = aLabel.FindChild(Box1POS);
|
|
||||||
TDF_Label Top1 = Box1Label.FindChild(1);
|
|
||||||
TDF_Label Bottom1 = Box1Label.FindChild(2);
|
|
||||||
TDF_Label Right1 = Box1Label.FindChild(3);
|
|
||||||
TDF_Label Left1 = Box1Label.FindChild(4);
|
|
||||||
TDF_Label Front1 = Box1Label.FindChild(5);
|
|
||||||
TDF_Label Back1 = Box1Label.FindChild(6);
|
|
||||||
|
|
||||||
TNaming_Builder Box1Ins (Box1Label);
|
|
||||||
Box1Ins.Generated (MKBOX1.Shape());
|
|
||||||
|
|
||||||
TNaming_Builder Top1FaceIns (Top1);
|
|
||||||
TopoDS_Face Top1Face = MKBOX1.TopFace ();
|
|
||||||
Top1FaceIns.Generated (Top1Face);
|
|
||||||
|
|
||||||
TopoDS_Face Bottom1Face = MKBOX1.BottomFace ();
|
|
||||||
TNaming_Builder Bottom1FaceIns (Bottom1);
|
|
||||||
Bottom1FaceIns.Generated (Bottom1Face);
|
|
||||||
|
|
||||||
TopoDS_Face Right1Face = MKBOX1.RightFace ();
|
|
||||||
TNaming_Builder Right1FaceIns (Right1);
|
|
||||||
Right1FaceIns.Generated (Right1Face);
|
|
||||||
|
|
||||||
TopoDS_Face Left1Face = MKBOX1.LeftFace ();
|
|
||||||
TNaming_Builder Left1FaceIns (Left1);
|
|
||||||
Left1FaceIns.Generated (Left1Face);
|
|
||||||
|
|
||||||
TopoDS_Face Front1Face = MKBOX1.FrontFace ();
|
|
||||||
TNaming_Builder Front1FaceIns (Front1);
|
|
||||||
Front1FaceIns.Generated (Front1Face);
|
|
||||||
|
|
||||||
TopoDS_Face Back1Face = MKBOX1.BackFace ();
|
|
||||||
TNaming_Builder Back1FaceIns (Back1);
|
|
||||||
Back1FaceIns.Generated (Back1Face);
|
|
||||||
|
|
||||||
// =====================================
|
|
||||||
// 2.Box2, TNaming_Evolution == PRIMITIVE
|
|
||||||
// =====================================
|
|
||||||
BRepPrimAPI_MakeBox MKBOX2( 150, 150, 150); // creating Box2
|
|
||||||
|
|
||||||
//Load the faces of the box2 in DF
|
|
||||||
TDF_Label Box2Label = aLabel.FindChild(Box2POS);
|
|
||||||
TDF_Label Top2 = Box2Label.FindChild(1);
|
|
||||||
TDF_Label Bottom2 = Box2Label.FindChild(2);
|
|
||||||
TDF_Label Right2 = Box2Label.FindChild(3);
|
|
||||||
TDF_Label Left2 = Box2Label.FindChild(4);
|
|
||||||
TDF_Label Front2 = Box2Label.FindChild(5);
|
|
||||||
TDF_Label Back2 = Box2Label.FindChild(6);
|
|
||||||
|
|
||||||
TNaming_Builder Box2Ins (Box2Label);
|
|
||||||
Box2Ins.Generated (MKBOX2.Shape());
|
|
||||||
|
|
||||||
TNaming_Builder Top2FaceIns (Top2);
|
|
||||||
TopoDS_Face Top2Face = MKBOX2.TopFace ();
|
|
||||||
Top2FaceIns.Generated (Top2Face);
|
|
||||||
|
|
||||||
TopoDS_Face Bottom2Face = MKBOX2.BottomFace ();
|
|
||||||
TNaming_Builder Bottom2FaceIns (Bottom2);
|
|
||||||
Bottom2FaceIns.Generated (Bottom2Face);
|
|
||||||
|
|
||||||
TopoDS_Face Right2Face = MKBOX2.RightFace ();
|
|
||||||
TNaming_Builder Right2FaceIns (Right2);
|
|
||||||
Right2FaceIns.Generated (Right2Face);
|
|
||||||
|
|
||||||
TopoDS_Face Left2Face = MKBOX2.LeftFace ();
|
|
||||||
TNaming_Builder Left2FaceIns (Left2);
|
|
||||||
Left2FaceIns.Generated (Left2Face);
|
|
||||||
|
|
||||||
TopoDS_Face Front2Face = MKBOX2.FrontFace ();
|
|
||||||
TNaming_Builder Front2FaceIns (Front2);
|
|
||||||
Front2FaceIns.Generated (Front2Face);
|
|
||||||
|
|
||||||
TopoDS_Face Back2Face = MKBOX2.BackFace ();
|
|
||||||
TNaming_Builder Back2FaceIns (Back2);
|
|
||||||
Back2FaceIns.Generated (Back2Face);
|
|
||||||
|
|
||||||
// ====================================
|
|
||||||
// 3.Applying a transformation to Box2
|
|
||||||
// ====================================
|
|
||||||
gp_Vec vec1(gp_Pnt(0.,0.,0.),gp_Pnt(50.,50.,20.));
|
|
||||||
gp_Trsf TRSF;
|
|
||||||
TRSF.SetTranslation(vec1);
|
|
||||||
TopLoc_Location loc(TRSF);
|
|
||||||
TDF_LabelMap scope;
|
|
||||||
TDF_ChildIterator itchild;
|
|
||||||
for (itchild.Initialize(Box2Label,Standard_True); itchild.More();itchild.Next()) {
|
|
||||||
if (itchild.Value().IsAttribute(TNaming_NamedShape::GetID())) scope.Add(itchild.Value());
|
|
||||||
}
|
|
||||||
if (Box2Label.IsAttribute(TNaming_NamedShape::GetID())) scope.Add(Box2Label);
|
|
||||||
TDF_MapIteratorOfLabelMap it(scope);
|
|
||||||
for (;it.More();it.Next())
|
|
||||||
TNaming::Displace(it.Key(), loc, Standard_True);//with oldshapes
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
// 4.Push a selected edges of top face of Box1 in DF,
|
|
||||||
// create Fillet (using selected edges) and push result as modification of Box1
|
|
||||||
//=============================================================================
|
|
||||||
Handle(TNaming_NamedShape) B1NS;
|
|
||||||
Box1Label.FindAttribute(TNaming_NamedShape::GetID(), B1NS);
|
|
||||||
const TopoDS_Shape& box1 = TNaming_Tool::GetShape(B1NS);
|
|
||||||
Handle(TNaming_NamedShape) Top1NS;
|
|
||||||
Top1.FindAttribute(TNaming_NamedShape::GetID(), Top1NS);
|
|
||||||
const TopoDS_Shape& top1face = TNaming_Tool::GetShape(Top1NS);
|
|
||||||
|
|
||||||
BRepFilletAPI_MakeFillet MKFILLET(box1);// fillet's algo
|
|
||||||
TDF_Label SelectedEdgesLabel = aLabel.FindChild(SelectedEdgesPOS); //Label for selected edges
|
|
||||||
TopExp_Explorer exp(top1face, TopAbs_EDGE);
|
|
||||||
Standard_Integer i=1;
|
|
||||||
for(;exp.More();exp.Next(),i++) {
|
|
||||||
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
|
|
||||||
const TDF_Label& SelEdge = SelectedEdgesLabel.FindChild(i);
|
|
||||||
// Creating TNaming_Selector on label
|
|
||||||
TNaming_Selector Selector(SelEdge);
|
|
||||||
|
|
||||||
// Inserting shape into data framework, we need the context to find neighbourhood of shape
|
|
||||||
// For example the context for a lateral face of cone is cone itself
|
|
||||||
// If a shape is standalone the context will be the shape itself
|
|
||||||
|
|
||||||
// Selector.Select(Shape, Context);
|
|
||||||
// TNaming_Evolution == SELECTED
|
|
||||||
Selector.Select(E, box1);
|
|
||||||
// Recover selected edge from DF, only for example
|
|
||||||
const TopoDS_Edge& FE = TopoDS::Edge(Selector.NamedShape()->Get());
|
|
||||||
MKFILLET.Add(5., FE);
|
|
||||||
}
|
|
||||||
|
|
||||||
MKFILLET.Build();
|
|
||||||
if(!MKFILLET.IsDone()) return; //Algorithm failed
|
|
||||||
|
|
||||||
// ...put fillet in the DataFramework as modification of Box1
|
|
||||||
TDF_Label FilletLabel = aLabel.FindChild(FilletPOS);
|
|
||||||
TDF_Label DeletedFaces = FilletLabel.FindChild(i++);
|
|
||||||
TDF_Label ModifiedFaces = FilletLabel.FindChild(i++);
|
|
||||||
TDF_Label FacesFromEdges = FilletLabel.FindChild(i++);
|
|
||||||
TDF_Label FacesFromVertices = FilletLabel.FindChild(i);
|
|
||||||
|
|
||||||
// TNaming_Evolution == MODIFY
|
|
||||||
TNaming_Builder bFillet(FilletLabel);
|
|
||||||
bFillet.Modify(box1, MKFILLET.Shape());
|
|
||||||
|
|
||||||
//New faces generated from edges
|
|
||||||
TopTools_MapOfShape View;
|
|
||||||
TNaming_Builder FaceFromEdgeBuilder(FacesFromEdges);
|
|
||||||
TopExp_Explorer ShapeExplorer (box1, TopAbs_EDGE);
|
|
||||||
for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
|
|
||||||
const TopoDS_Shape& Root = ShapeExplorer.Current ();
|
|
||||||
if (!View.Add(Root)) continue;
|
|
||||||
const TopTools_ListOfShape& Shapes = MKFILLET.Generated (Root);
|
|
||||||
TopTools_ListIteratorOfListOfShape ShapesIterator (Shapes);
|
|
||||||
for (;ShapesIterator.More (); ShapesIterator.Next ()) {
|
|
||||||
const TopoDS_Shape& newShape = ShapesIterator.Value ();
|
|
||||||
// TNaming_Evolution == GENERATED
|
|
||||||
if (!Root.IsSame (newShape)) FaceFromEdgeBuilder.Generated (Root,newShape );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Faces of the initial shape modified by MKFILLET
|
|
||||||
View.Clear();
|
|
||||||
TNaming_Builder ModFacesBuilder(ModifiedFaces);
|
|
||||||
ShapeExplorer.Init(box1,TopAbs_FACE);
|
|
||||||
for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
|
|
||||||
const TopoDS_Shape& Root = ShapeExplorer.Current ();
|
|
||||||
if (!View.Add(Root)) continue;
|
|
||||||
const TopTools_ListOfShape& Shapes = MKFILLET.Modified (Root);
|
|
||||||
TopTools_ListIteratorOfListOfShape ShapesIterator (Shapes);
|
|
||||||
for (;ShapesIterator.More (); ShapesIterator.Next ()) {
|
|
||||||
const TopoDS_Shape& newShape = ShapesIterator.Value ();
|
|
||||||
// TNaming_Evolution == MODIFY
|
|
||||||
if (!Root.IsSame (newShape)) ModFacesBuilder.Modify (Root,newShape );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Deleted faces of the initial shape
|
|
||||||
View.Clear();
|
|
||||||
TNaming_Builder DelFacesBuilder(DeletedFaces);
|
|
||||||
ShapeExplorer.Init(box1, TopAbs_FACE);
|
|
||||||
for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
|
|
||||||
const TopoDS_Shape& Root = ShapeExplorer.Current ();
|
|
||||||
if (!View.Add(Root)) continue;
|
|
||||||
// TNaming_Evolution == DELETE
|
|
||||||
if (MKFILLET.IsDeleted (Root)) DelFacesBuilder.Delete (Root);
|
|
||||||
}
|
|
||||||
|
|
||||||
//New faces generated from vertices
|
|
||||||
View.Clear();
|
|
||||||
TNaming_Builder FaceFromVertexBuilder(FacesFromVertices);
|
|
||||||
ShapeExplorer.Init(box1, TopAbs_VERTEX);
|
|
||||||
for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
|
|
||||||
const TopoDS_Shape& Root = ShapeExplorer.Current ();
|
|
||||||
if (!View.Add(Root)) continue;
|
|
||||||
const TopTools_ListOfShape& Shapes = MKFILLET.Generated (Root);
|
|
||||||
TopTools_ListIteratorOfListOfShape ShapesIterator (Shapes);
|
|
||||||
for (;ShapesIterator.More (); ShapesIterator.Next ()) {
|
|
||||||
const TopoDS_Shape& newShape = ShapesIterator.Value ();
|
|
||||||
// TNaming_Evolution == GENERATED
|
|
||||||
if (!Root.IsSame (newShape)) FaceFromVertexBuilder.Generated (Root,newShape );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// =====================================================================
|
|
||||||
// 5.Create a Cut (Box1, Box2) as modification of Box1 and push it in DF
|
|
||||||
// Boolean operation - CUT Object=Box1, Tool=Box2
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
TDF_Label CutLabel = aLabel.FindChild(CutPOS);
|
|
||||||
|
|
||||||
// recover Object
|
|
||||||
Handle(TNaming_NamedShape) ObjectNS;
|
|
||||||
FilletLabel.FindAttribute(TNaming_NamedShape::GetID(), ObjectNS);
|
|
||||||
TopoDS_Shape OBJECT = ObjectNS->Get();
|
|
||||||
|
|
||||||
// Select Tool
|
|
||||||
TDF_Label ToolLabel = CutLabel.FindChild(1);
|
|
||||||
TNaming_Selector ToolSelector(ToolLabel);
|
|
||||||
Handle(TNaming_NamedShape) ToolNS;
|
|
||||||
Box2Label.FindAttribute(TNaming_NamedShape::GetID(), ToolNS);
|
|
||||||
const TopoDS_Shape& Tool = ToolNS->Get();
|
|
||||||
//TNaming_Evolution == SELECTED
|
|
||||||
ToolSelector.Select(Tool, Tool);
|
|
||||||
const TopoDS_Shape& TOOL = ToolSelector.NamedShape()->Get();
|
|
||||||
|
|
||||||
BRepAlgo_Cut mkCUT (OBJECT, TOOL);
|
|
||||||
|
|
||||||
if (!mkCUT.IsDone()) {
|
|
||||||
cout << "CUT: Algorithm failed" << endl;
|
|
||||||
return;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
TopTools_ListOfShape Larg;
|
|
||||||
Larg.Append(OBJECT);
|
|
||||||
Larg.Append(TOOL);
|
|
||||||
|
|
||||||
if (!BRepAlgo::IsValid(Larg, mkCUT.Shape(), Standard_True, Standard_False)) {
|
|
||||||
|
|
||||||
cout << "CUT: Result is not valid" << endl;
|
|
||||||
return;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
// push CUT results in DF as modification of Box1
|
|
||||||
TDF_Label Modified = CutLabel.FindChild(2);
|
|
||||||
TDF_Label Deleted = CutLabel.FindChild(3);
|
|
||||||
TDF_Label Intersections = CutLabel.FindChild(4);
|
|
||||||
TDF_Label NewFaces = CutLabel.FindChild(5);
|
|
||||||
|
|
||||||
TopoDS_Shape newS1 = mkCUT.Shape();
|
|
||||||
const TopoDS_Shape& ObjSh = mkCUT.Shape1();
|
|
||||||
|
|
||||||
//push in the DF result of CUT
|
|
||||||
TNaming_Builder CutBuilder (CutLabel);
|
|
||||||
// TNaming_Evolution == MODIFY
|
|
||||||
CutBuilder.Modify (ObjSh, newS1);
|
|
||||||
|
|
||||||
//push in the DF modified faces
|
|
||||||
View.Clear();
|
|
||||||
TNaming_Builder ModBuilder(Modified);
|
|
||||||
ShapeExplorer.Init(ObjSh, TopAbs_FACE);
|
|
||||||
for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
|
|
||||||
const TopoDS_Shape& Root = ShapeExplorer.Current ();
|
|
||||||
if (!View.Add(Root)) continue;
|
|
||||||
const TopTools_ListOfShape& Shapes = mkCUT.Modified (Root);
|
|
||||||
TopTools_ListIteratorOfListOfShape ShapesIterator (Shapes);
|
|
||||||
for (;ShapesIterator.More (); ShapesIterator.Next ()) {
|
|
||||||
const TopoDS_Shape& newShape = ShapesIterator.Value ();
|
|
||||||
// TNaming_Evolution == MODIFY
|
|
||||||
if (!Root.IsSame (newShape)) ModBuilder.Modify (Root,newShape );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//push in the DF deleted faces
|
|
||||||
View.Clear();
|
|
||||||
TNaming_Builder DelBuilder(Deleted);
|
|
||||||
ShapeExplorer.Init (ObjSh,TopAbs_FACE);
|
|
||||||
for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
|
|
||||||
const TopoDS_Shape& Root = ShapeExplorer.Current ();
|
|
||||||
if (!View.Add(Root)) continue;
|
|
||||||
// TNaming_Evolution == DELETE
|
|
||||||
if (mkCUT.IsDeleted (Root)) DelBuilder.Delete (Root);
|
|
||||||
}
|
|
||||||
|
|
||||||
// push in the DF section edges
|
|
||||||
TNaming_Builder IntersBuilder(Intersections);
|
|
||||||
Handle(TopOpeBRepBuild_HBuilder) build = mkCUT.Builder();
|
|
||||||
TopTools_ListIteratorOfListOfShape its = build->Section();
|
|
||||||
for (; its.More(); its.Next()) {
|
|
||||||
// TNaming_Evolution == SELECTED
|
|
||||||
IntersBuilder.Select(its.Value(),its.Value());
|
|
||||||
}
|
|
||||||
|
|
||||||
// push in the DF new faces added to the object:
|
|
||||||
const TopoDS_Shape& ToolSh = mkCUT.Shape2();
|
|
||||||
TNaming_Builder newBuilder (NewFaces);
|
|
||||||
ShapeExplorer.Init(ToolSh, TopAbs_FACE);
|
|
||||||
for (; ShapeExplorer.More(); ShapeExplorer.Next()) {
|
|
||||||
const TopoDS_Shape& F = ShapeExplorer.Current();
|
|
||||||
const TopTools_ListOfShape& modified = mkCUT.Modified(F);
|
|
||||||
if (!modified.IsEmpty()) {
|
|
||||||
TopTools_ListIteratorOfListOfShape itr(modified);
|
|
||||||
for (; itr.More (); itr.Next ()) {
|
|
||||||
const TopoDS_Shape& newShape = itr.Value();
|
|
||||||
Handle(TNaming_NamedShape) NS = TNaming_Tool::NamedShape(newShape, NewFaces);
|
|
||||||
if (NS.IsNull() || NS->Evolution() != TNaming_MODIFY) {
|
|
||||||
// TNaming_Evolution == GENERATED
|
|
||||||
newBuilder.Generated(F, newShape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// end of CUT
|
|
||||||
|
|
||||||
// =================================================
|
|
||||||
// 6.Recover result from DF
|
|
||||||
// get final result - Box1 shape after CUT operation
|
|
||||||
// =================================================
|
|
||||||
Handle(TNaming_NamedShape) ResultNS;
|
|
||||||
CutLabel.FindAttribute(TNaming_NamedShape::GetID(), ResultNS);
|
|
||||||
const TopoDS_Shape& Result_1 = ResultNS->Get(); // here is result of cut operation
|
|
||||||
ResultNS.Nullify();
|
|
||||||
Box1Label.FindAttribute(TNaming_NamedShape::GetID(), ResultNS);
|
|
||||||
const TopoDS_Shape& Result_2 = TNaming_Tool::CurrentShape(ResultNS);//here is also result of cut operation
|
|
||||||
|
|
||||||
//
|
|
||||||
//Result_1 and Result_2 are the same shapes
|
|
||||||
//=========================================
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -985,17 +985,13 @@ Standard_Boolean TNaming::OuterWire(const TopoDS_Face& theFace, TopoDS_Wire& the
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
static Standard_Boolean IsInternal(const TopoDS_Shape& aSx)
|
static Standard_Boolean IsInternal(const TopoDS_Shape& aSx)
|
||||||
{
|
{
|
||||||
Standard_Boolean bInternal;
|
|
||||||
TopAbs_Orientation aOr;
|
TopAbs_Orientation aOr;
|
||||||
TopoDS_Iterator aIt;
|
Standard_Boolean bInternal(Standard_False);
|
||||||
bInternal = Standard_False;
|
TopoDS_Iterator aIt(aSx);
|
||||||
aIt.Initialize(aSx);
|
if(aIt.More()) {
|
||||||
for (; aIt.More(); aIt.Next())
|
const TopoDS_Shape& aSy = aIt.Value();
|
||||||
{
|
aOr = aSy.Orientation();
|
||||||
const TopoDS_Shape& aSy=aIt.Value();
|
|
||||||
aOr=aSy.Orientation();
|
|
||||||
bInternal = (aOr == TopAbs_INTERNAL || aOr == TopAbs_EXTERNAL);
|
bInternal = (aOr == TopAbs_INTERNAL || aOr == TopAbs_EXTERNAL);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return bInternal;
|
return bInternal;
|
||||||
}
|
}
|
||||||
|
@ -314,12 +314,10 @@ void TNaming_Localizer::GoBack (const TopoDS_Shape& S,
|
|||||||
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
||||||
// Pas d'ascendants => Recherche et exploration du contenant
|
// Pas d'ascendants => Recherche et exploration du contenant
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
TDF_Label Father = Lab.Father();
|
const TDF_Label& Father = Lab.Father();
|
||||||
TNaming_Iterator itLab(Father);
|
TNaming_Iterator itLab(Father);
|
||||||
for (; itLab.More(); itLab.Next()) {
|
if(itLab.More())
|
||||||
Sol = itLab.OldShape();
|
Sol = itLab.OldShape();
|
||||||
break;
|
|
||||||
}
|
|
||||||
//-------------------------------------------
|
//-------------------------------------------
|
||||||
// Recherche des ancetres dans des features.
|
// Recherche des ancetres dans des features.
|
||||||
//-------------------------------------------
|
//-------------------------------------------
|
||||||
|
@ -1086,7 +1086,7 @@ static TopoDS_Shape FindShape(const TNaming_DataMapOfShapeMapOfShape& DM)
|
|||||||
if(aNum < 1) return aResult;
|
if(aNum < 1) return aResult;
|
||||||
TopTools_ListOfShape List;
|
TopTools_ListOfShape List;
|
||||||
TNaming_DataMapIteratorOfDataMapOfShapeMapOfShape it(DM);
|
TNaming_DataMapIteratorOfDataMapOfShapeMapOfShape it(DM);
|
||||||
for (;it.More();it.Next()) {
|
if(it.More()) {
|
||||||
const TopoDS_Shape& aKey1 = it.Key();
|
const TopoDS_Shape& aKey1 = it.Key();
|
||||||
const TNaming_MapOfShape& aMap = it.Value();
|
const TNaming_MapOfShape& aMap = it.Value();
|
||||||
|
|
||||||
@ -1104,7 +1104,6 @@ static TopoDS_Shape FindShape(const TNaming_DataMapOfShapeMapOfShape& DM)
|
|||||||
if(isCand)
|
if(isCand)
|
||||||
List.Append(aS);
|
List.Append(aS);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if(List.IsEmpty()) return aResult;
|
if(List.IsEmpty()) return aResult;
|
||||||
if(List.Extent() == 1) return List.First();
|
if(List.Extent() == 1) return List.First();
|
||||||
|
@ -553,12 +553,10 @@ static Standard_Boolean TestSolution(const TNaming_Scope& MDF,
|
|||||||
static void FindNewShapeInFather (const Handle(TNaming_NamedShape)& NS,
|
static void FindNewShapeInFather (const Handle(TNaming_NamedShape)& NS,
|
||||||
TopoDS_Shape& SC)
|
TopoDS_Shape& SC)
|
||||||
{
|
{
|
||||||
TDF_Label Father = NS->Label().Father();
|
const TDF_Label& Father = NS->Label().Father();
|
||||||
TNaming_Iterator itLab(Father);
|
TNaming_Iterator itLab(Father);
|
||||||
for (; itLab.More(); itLab.Next()) {
|
if(itLab.More())
|
||||||
SC= itLab.NewShape();
|
SC = itLab.NewShape();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user