// Created on: 1999-12-08 // Created by: Vladislav ROMASHKO // Copyright (c) 1999-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #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 //////#include static Standard_Integer QANewDBRepNaming_CheckNaming(Draw_Interpretor&,Standard_Integer,const char ** a); //static Standard_Integer QANewDBRepNaming_myCheckNaming(Draw_Interpretor&,Standard_Integer,const char ** a); static Standard_Integer QANewDBRepNaming_CheckSelectShape(Draw_Interpretor&,Standard_Integer,const char ** a); static Standard_Integer QANewDBRepNaming_CheckSolve(Draw_Interpretor&,Standard_Integer,const char ** a); #include //======================================================================= //function : AllCommands //purpose : //======================================================================= void QANewDBRepNaming::AllCommands(Draw_Interpretor& theCommands) { static Standard_Boolean done = Standard_False; if (done) return; done = Standard_True; QANewDBRepNaming::PrimitiveCommands (theCommands); QANewDBRepNaming::FeatureCommands (theCommands); const char* g = "Check Naming command" ; theCommands.Add ("CheckNaming", "CheckNaming Doc TestLabel Full(1/0) (Label/Viewer) [Label] [DX[DY[DZ]]]", __FILE__, QANewDBRepNaming_CheckNaming, g); theCommands.Add ("CheckSelectShape", "CheckSelectShape Doc Label SubShapeType", __FILE__, QANewDBRepNaming_CheckSelectShape, g); theCommands.Add ("CheckSolve", "CheckSolve Doc Label", __FILE__, QANewDBRepNaming_CheckSolve, g); const char* com = "set Draw_NamingData 1"; theCommands.Eval(com); } //======================================================================= //function : CheckNaming //purpose : "CheckNaming Doc TestLabel Full(1/0) ShapeFrom(Viewer/Label) [ShapeLabel]" //======================================================================= static Standard_Integer QANewDBRepNaming_CheckNaming(Draw_Interpretor& di,Standard_Integer nb, const char ** a) { Handle(TDF_Data) DF; if(!DDF::GetDF(a[1], DF)) return 1; TDF_Label L; DDF::AddLabel(DF, a[2], L); // cout<<"SELECT A SHAPE ..."<Get()) == Standard_False) di << "Selection error!!!\n"; return 1; } Handle(TNaming_NamedShape) aNS; if (!aSubLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { di<<"Selection didn't produced a Named Shape ...\n"; return 1; } const TopoDS_Shape& aResultOfSelection = TNaming_Tool::GetShape(aNS); if (!aSubShape.IsSame(aResultOfSelection)) { di<<"Failure of selection\n"; return 1; } } catch (Standard_Failure) { di<<"!!! Solving Failed !!!\n"; continue; } } // *** if (!Draw::Atoi(a[3])) return 0; Standard_Real aDX = 100.0; Standard_Real aDY = 100.0; Standard_Real aDZ = 100.0; if(nb > 6) { aDX = Draw::Atof(a[6]); if(nb > 7) aDY = Draw::Atof(a[7]); if(nb > 8) aDZ = Draw::Atof(a[8]); } // cout<Get()); TNaming_Selector SLSolving(itr.Value()); if (!SLSolving.Solve(scope)) { isFailured = Standard_True; aNotSolved += " "; aNotSolved += i; continue; } const Handle(TNaming_NamedShape)& aResultOfSolving = SLSolving.NamedShape(); if (aResultOfSolving.IsNull()) { // cout<<"Failure of Solving: it didn't produced a shape!"<Get()); TopoDS_Shape aSubShape; if (itr.More()) aSubShape = itr.Value(); TDF_LabelMap one,two; TNaming_Tool::FindShape(one, two, aResultOfSolving, aRes); if (aRes.IsNull()) { // cout<<"Failure of TNaming_Tool::FindShape()!"<Get(); if (!aRes.IsSame(allTranslatedSubShapes(i))) { // cout<<"Failure of solving of "<Get(); TopExp_Explorer expl(aContext, (TopAbs_ShapeEnum)Draw::Atoi(a[3])); for (; expl.More(); expl.Next()) { if (expl.Current().IsSame(aSelectedShape)) { di<<"QANewDBRepNaming_CheckSelectShape(): The context is found at "; //NS->Label().EntryDump(cout); Standard_SStream aSStream; NS->Label().EntryDump(aSStream); di << aSStream; di<<"\n"; contextFound = Standard_True; break; } } if (contextFound) break; } aContext = TopoDS_Shape(); } // Selection: TNaming_Selector aSelector(L); if (aContext.IsNull()) { aSelector.Select(aSelectedShape); } else { aSelector.Select(aSelectedShape, aContext); } return 0; } //======================================================================= //function : CheckSelectShape //purpose : "CheckSelectShape Doc Label SubShapeType" //======================================================================= static Standard_Integer QANewDBRepNaming_CheckSolve(Draw_Interpretor&,Standard_Integer /*nb*/, const char ** a) { Handle(TDF_Data) DF; if(!DDF::GetDF(a[1], DF)) return 1; TDF_Label L; DDF::AddLabel(DF, a[2], L); Handle(TNaming_NamedShape) aNS; L.FindAttribute(TNaming_NamedShape::GetID(), aNS); return 0; }