diff --git a/src/DDataStd/DDataStd_Sample.cxx b/src/DDataStd/DDataStd_Sample.cxx deleted file mode 100755 index 26fac1329c..0000000000 --- a/src/DDataStd/DDataStd_Sample.cxx +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 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 ... - - // 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 ... - - // 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 ... - - // 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 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); // should contain the calucalated distance - - // Checking if 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 diff --git a/src/DDataStd/FILES b/src/DDataStd/FILES index d3a09e4a13..45433a407a 100755 --- a/src/DDataStd/FILES +++ b/src/DDataStd/FILES @@ -8,4 +8,4 @@ DDataStd_ConstraintCommands.cxx DDataStd_DrawDisplayCommands.cxx DDataStd_ObjectCommands.cxx DDataStd_NameCommands.cxx -DDataStd_Sample.cxx + diff --git a/src/DDocStd/DDocStd_Sample.cxx b/src/DDocStd/DDocStd_Sample.cxx deleted file mode 100755 index 9ad7925594..0000000000 --- a/src/DDocStd/DDocStd_Sample.cxx +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -//#include - - -// 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 diff --git a/src/DDocStd/FILES b/src/DDocStd/FILES index 92b14ad55e..ce8fa3313b 100755 --- a/src/DDocStd/FILES +++ b/src/DDocStd/FILES @@ -2,5 +2,4 @@ IDNames.tcl DDocStd_ApplicationCommands.cxx DDocStd_DocumentCommands.cxx DDocStd_ToolsCommands.cxx -DDocStd_Sample.cxx DDocStd_MTMCommands.cxx diff --git a/src/DPrsStd/DPrsStd_Sample.cxx b/src/DPrsStd/DPrsStd_Sample.cxx deleted file mode 100755 index 28ab62447b..0000000000 --- a/src/DPrsStd/DPrsStd_Sample.cxx +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 ) - 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 - - // Setting the new TPrsStd_AISPresentation to - // 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 diff --git a/src/DPrsStd/FILES b/src/DPrsStd/FILES index e25a3ec9ff..32b65dd782 100755 --- a/src/DPrsStd/FILES +++ b/src/DPrsStd/FILES @@ -1,3 +1,2 @@ DPrsStd_AISPresentationCommands.cxx DPrsStd_AISViewerCommands.cxx -DPrsStd_Sample.cxx diff --git a/src/QADNaming/FILES b/src/QADNaming/FILES index c19f89648e..58287328ef 100755 --- a/src/QADNaming/FILES +++ b/src/QADNaming/FILES @@ -3,5 +3,4 @@ QADNaming_BuilderCommands.cxx QADNaming_IteratorsCommands.cxx QADNaming_ToolsCommands.cxx QADNaming_SelectionCommands.cxx -QADNaming_Sample.cxx QADNaming_Selection.tcl diff --git a/src/QADNaming/QADNaming_Sample.cxx b/src/QADNaming/QADNaming_Sample.cxx deleted file mode 100755 index 6ac80853c1..0000000000 --- a/src/QADNaming/QADNaming_Sample.cxx +++ /dev/null @@ -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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -#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 diff --git a/src/TNaming/TNaming.cxx b/src/TNaming/TNaming.cxx index 42b3ec05b6..c00acfdcbd 100755 --- a/src/TNaming/TNaming.cxx +++ b/src/TNaming/TNaming.cxx @@ -984,18 +984,14 @@ Standard_Boolean TNaming::OuterWire(const TopoDS_Face& theFace, TopoDS_Wire& the //purpose : //======================================================================= static Standard_Boolean IsInternal(const TopoDS_Shape& aSx) -{ - Standard_Boolean bInternal; - TopAbs_Orientation aOr; - TopoDS_Iterator aIt; - bInternal = Standard_False; - aIt.Initialize(aSx); - for (; aIt.More(); aIt.Next()) - { - const TopoDS_Shape& aSy=aIt.Value(); - aOr=aSy.Orientation(); - bInternal = (aOr == TopAbs_INTERNAL || aOr == TopAbs_EXTERNAL); - break; +{ + TopAbs_Orientation aOr; + Standard_Boolean bInternal(Standard_False); + TopoDS_Iterator aIt(aSx); + if(aIt.More()) { + const TopoDS_Shape& aSy = aIt.Value(); + aOr = aSy.Orientation(); + bInternal = (aOr == TopAbs_INTERNAL || aOr == TopAbs_EXTERNAL); } return bInternal; } diff --git a/src/TNaming/TNaming_Localizer.cxx b/src/TNaming/TNaming_Localizer.cxx index 8060becdfa..9970338265 100755 --- a/src/TNaming/TNaming_Localizer.cxx +++ b/src/TNaming/TNaming_Localizer.cxx @@ -314,12 +314,10 @@ void TNaming_Localizer::GoBack (const TopoDS_Shape& S, //----------------------------------------------------------- // Pas d'ascendants => Recherche et exploration du contenant //---------------------------------------------------------- - TDF_Label Father = Lab.Father(); + const TDF_Label& Father = Lab.Father(); TNaming_Iterator itLab(Father); - for (; itLab.More(); itLab.Next()) { - Sol = itLab.OldShape(); - break; - } + if(itLab.More()) + Sol = itLab.OldShape(); //------------------------------------------- // Recherche des ancetres dans des features. //------------------------------------------- diff --git a/src/TNaming/TNaming_Name.cxx b/src/TNaming/TNaming_Name.cxx index 5a76e601cf..fe738e096b 100755 --- a/src/TNaming/TNaming_Name.cxx +++ b/src/TNaming/TNaming_Name.cxx @@ -1086,7 +1086,7 @@ static TopoDS_Shape FindShape(const TNaming_DataMapOfShapeMapOfShape& DM) if(aNum < 1) return aResult; TopTools_ListOfShape List; TNaming_DataMapIteratorOfDataMapOfShapeMapOfShape it(DM); - for (;it.More();it.Next()) { + if(it.More()) { const TopoDS_Shape& aKey1 = it.Key(); const TNaming_MapOfShape& aMap = it.Value(); @@ -1104,7 +1104,6 @@ static TopoDS_Shape FindShape(const TNaming_DataMapOfShapeMapOfShape& DM) if(isCand) List.Append(aS); } - break; } if(List.IsEmpty()) return aResult; if(List.Extent() == 1) return List.First(); diff --git a/src/TNaming/TNaming_Naming.cxx b/src/TNaming/TNaming_Naming.cxx index 191dbcaf71..356c6e6cd5 100755 --- a/src/TNaming/TNaming_Naming.cxx +++ b/src/TNaming/TNaming_Naming.cxx @@ -553,12 +553,10 @@ static Standard_Boolean TestSolution(const TNaming_Scope& MDF, static void FindNewShapeInFather (const Handle(TNaming_NamedShape)& NS, TopoDS_Shape& SC) { - TDF_Label Father = NS->Label().Father(); + const TDF_Label& Father = NS->Label().Father(); TNaming_Iterator itLab(Father); - for (; itLab.More(); itLab.Next()) { - SC= itLab.NewShape(); - break; - } + if(itLab.More()) + SC = itLab.NewShape(); } //=======================================================================